-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove openzeppelin and import the few interface files we need. Remove `Ownable` from `Verifier`. * Add standalone deploy script, remove migration script * update yarn.lock * add compile.js script and use it * add `setEnforcer` test * compiler.js: add source to artifact
- Loading branch information
1 parent
cfbd5eb
commit 986fda7
Showing
15 changed files
with
500 additions
and
4,121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pragma solidity ^0.5.0; | ||
|
||
/** | ||
* @title IERC165 | ||
* @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md | ||
*/ | ||
interface IERC165 { | ||
/** | ||
* @notice Query if a contract implements an interface | ||
* @param interfaceId The interface identifier, as specified in ERC-165 | ||
* @dev Interface identification is specified in ERC-165. This function | ||
* uses less than 30,000 gas. | ||
*/ | ||
function supportsInterface(bytes4 interfaceId) external view returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pragma solidity ^0.5.0; | ||
|
||
/** | ||
* @title ERC20 interface | ||
* @dev see https://github.com/ethereum/EIPs/issues/20 | ||
*/ | ||
interface IERC20 { | ||
function transfer(address to, uint256 value) external returns (bool); | ||
|
||
function approve(address spender, uint256 value) external returns (bool); | ||
|
||
function transferFrom(address from, address to, uint256 value) external returns (bool); | ||
|
||
function totalSupply() external view returns (uint256); | ||
|
||
function balanceOf(address who) external view returns (uint256); | ||
|
||
function allowance(address owner, address spender) external view returns (uint256); | ||
|
||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
|
||
event Approval(address indexed owner, address indexed spender, uint256 value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
pragma solidity ^0.5.0; | ||
|
||
import "./IERC165.sol"; | ||
|
||
/** | ||
* @title ERC721 Non-Fungible Token Standard basic interface | ||
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md | ||
*/ | ||
contract IERC721 is IERC165 { | ||
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); | ||
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); | ||
event ApprovalForAll(address indexed owner, address indexed operator, bool approved); | ||
|
||
function balanceOf(address owner) public view returns (uint256 balance); | ||
function ownerOf(uint256 tokenId) public view returns (address owner); | ||
|
||
function approve(address to, uint256 tokenId) public; | ||
function getApproved(uint256 tokenId) public view returns (address operator); | ||
|
||
function setApprovalForAll(address operator, bool _approved) public; | ||
function isApprovedForAll(address owner, address operator) public view returns (bool); | ||
|
||
function transferFrom(address from, address to, uint256 tokenId) public; | ||
function safeTransferFrom(address from, address to, uint256 tokenId) public; | ||
|
||
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const { basename } = require('path'); | ||
const solc = require('solc'); | ||
|
||
const contractsDir = 'contracts'; | ||
const files = fs.readdirSync(contractsDir); | ||
const sources = {}; | ||
let outputDir = ''; | ||
|
||
['build/', 'contracts'].forEach( | ||
function (dir) { | ||
outputDir += dir; | ||
if (!fs.existsSync(outputDir)) { | ||
fs.mkdirSync(outputDir); | ||
} | ||
} | ||
); | ||
|
||
while (files.length) { | ||
const file = files.pop(); | ||
const path = `${contractsDir}/${file}`; | ||
const stat = fs.statSync(path); | ||
|
||
if (stat.isFile() && (file.endsWith('.sol') || file.endsWith('.slb') || file.endsWith('.yul'))) { | ||
const source = fs.readFileSync(path).toString(); | ||
const k = basename(path); | ||
sources[k] = { content: source }; | ||
process.stdout.write(`> Compiling ${path}\n`); | ||
} | ||
|
||
if (stat.isDirectory()) { | ||
fs.readdirSync(path).forEach( | ||
function (p) { | ||
files.push(`${file}/${p}`); | ||
} | ||
); | ||
} | ||
} | ||
|
||
const compilerInput = { | ||
language: 'Solidity', | ||
sources: sources, | ||
settings: { | ||
evmVersion: 'constantinople', | ||
optimizer: { | ||
enabled: true, | ||
runs: 2, | ||
}, | ||
outputSelection: { | ||
'*': { | ||
'': [ | ||
'legacyAST', | ||
'ast', | ||
], | ||
'*': [ | ||
'abi', | ||
'metadata', | ||
'evm.bytecode.object', | ||
'evm.bytecode.sourceMap', | ||
'evm.deployedBytecode.object', | ||
'evm.deployedBytecode.sourceMap', | ||
'userdoc', | ||
'devdoc', | ||
], | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const output = JSON.parse(solc.compile(JSON.stringify(compilerInput))); | ||
|
||
if (output.errors) { | ||
output.errors.forEach((obj) => process.stderr.write(obj.formattedMessage)); | ||
} | ||
|
||
if (!output.contracts) { | ||
process.exit(1); | ||
} | ||
|
||
for (const file in output.contracts) { | ||
const contract = output.contracts[file]; | ||
const sourceObj = output.sources[file]; | ||
const source = sources[file].content; | ||
|
||
for (const contractName in contract) { | ||
const obj = contract[contractName]; | ||
|
||
obj.id = sourceObj.id; | ||
obj.ast = sourceObj.ast; | ||
obj.legacyAST = sourceObj.legacyAST; | ||
obj.source = source; | ||
|
||
const evm = obj.evm; | ||
delete obj.evm; | ||
|
||
obj.contractName = contractName; | ||
obj.bytecode = `0x${evm.bytecode.object}`; | ||
obj.sourceMap = evm.bytecode.sourceMap; | ||
obj.deployedBytecode = `0x${evm.deployedBytecode.object}`; | ||
obj.deployedSourceMap = evm.deployedBytecode.sourceMap; | ||
|
||
const artifactPath = `${outputDir}/${contractName}.json`; | ||
|
||
fs.writeFileSync(artifactPath, JSON.stringify(obj, null, 2)); | ||
process.stdout.write(`> Artifact for ${contractName} written to ${artifactPath}\n`); | ||
} | ||
} | ||
|
||
process.stdout.write(`> Compiled successfully using solc ${solc.version()}\n`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.