diff --git a/.gitignore b/.gitignore index f0d8eccf9f..b43312c5d3 100644 --- a/.gitignore +++ b/.gitignore @@ -91,13 +91,13 @@ contracts/coordinator/test/generated-artifacts/ contracts/exchange/generated-artifacts/ contracts/exchange/test/generated-artifacts/ contracts/asset-proxy/generated-artifacts/ -contracts/asset/test-proxy/generated-artifacts/ +contracts/asset-proxy/test/generated-artifacts/ contracts/multisig/generated-artifacts/ contracts/multisig/test/generated-artifacts/ contracts/utils/generated-artifacts/ contracts/utils/test/generated-artifacts/ contracts/exchange-libs/generated-artifacts/ -contracts/exchange/test-libs/generated-artifacts/ +contracts/exchange-libs/test/generated-artifacts/ contracts/erc20/generated-artifacts/ contracts/erc20/test/generated-artifacts/ contracts/erc721/generated-artifacts/ @@ -107,9 +107,9 @@ contracts/erc1155/test/generated-artifacts/ contracts/extensions/generated-artifacts/ contracts/extensions/test/generated-artifacts/ contracts/exchange-forwarder/generated-artifacts/ -contracts/exchange/test-forwarder/generated-artifacts/ +contracts/exchange-forwarder/test/generated-artifacts/ contracts/dev-utils/generated-artifacts/ -contracts/dev/test-utils/generated-artifacts/ +contracts/dev-utils/test/generated-artifacts/ packages/sol-tracing-utils/test/fixtures/artifacts/ python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts/ @@ -139,13 +139,13 @@ contracts/coordinator/test/generated-wrappers/ contracts/exchange/generated-wrappers/ contracts/exchange/test/generated-wrappers/ contracts/asset-proxy/generated-wrappers/ -contracts/asset/test-proxy/generated-wrappers/ +contracts/asset-proxy/test/generated-wrappers/ contracts/multisig/generated-wrappers/ contracts/multisig/test/generated-wrappers/ contracts/utils/generated-wrappers/ contracts/utils/test/generated-wrappers/ contracts/exchange-libs/generated-wrappers/ -contracts/exchange/test-libs/generated-wrappers/ +contracts/exchange-libs/test/generated-wrappers/ contracts/erc20/generated-wrappers/ contracts/erc20/test/generated-wrappers/ contracts/erc721/generated-wrappers/ @@ -155,9 +155,9 @@ contracts/erc1155/test/generated-wrappers/ contracts/extensions/generated-wrappers/ contracts/extensions/test/generated-wrappers/ contracts/exchange-forwarder/generated-wrappers/ -contracts/exchange/test-forwarder/generated-wrappers/ +contracts/exchange-forwarder/test/generated-wrappers/ contracts/dev-utils/generated-wrappers/ -contracts/dev/test-utils/generated-wrappers/ +contracts/dev-utils/test/generated-wrappers/ python-packages/contract_wrappers/src/zero_ex/contract_wrappers/dev_utils/__init__.py python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc20_token/__init__.py python-packages/contract_wrappers/src/zero_ex/contract_wrappers/exchange/__init__.py diff --git a/contracts/asset-proxy/compiler.json b/contracts/asset-proxy/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/asset-proxy/compiler.json +++ b/contracts/asset-proxy/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/asset-proxy/package.json b/contracts/asset-proxy/package.json index cb7c61daf9..9fc098cd31 100644 --- a/contracts/asset-proxy/package.json +++ b/contracts/asset-proxy/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,21 +21,22 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IERC20Bridge|IEth2Dai|IUniswapExchange|IUniswapExchangeFactory|MixinAssetProxyDispatcher|MixinAuthorizable|MultiAssetProxy|Ownable|StaticCallProxy|TestERC20Bridge|TestEth2DaiBridge|TestStaticCallTarget|TestUniswapBridge|UniswapBridge).json", + "abis": "./test/generated-artifacts/@(ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IERC20Bridge|IEth2Dai|IUniswapExchange|IUniswapExchangeFactory|MixinAssetProxyDispatcher|MixinAuthorizable|MultiAssetProxy|Ownable|StaticCallProxy|TestERC20Bridge|TestEth2DaiBridge|TestStaticCallTarget|TestUniswapBridge|UniswapBridge).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/asset-proxy/test/artifacts.ts b/contracts/asset-proxy/test/artifacts.ts new file mode 100644 index 0000000000..54e7e8757e --- /dev/null +++ b/contracts/asset-proxy/test/artifacts.ts @@ -0,0 +1,55 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as ERC1155Proxy from '../test/generated-artifacts/ERC1155Proxy.json'; +import * as ERC20BridgeProxy from '../test/generated-artifacts/ERC20BridgeProxy.json'; +import * as ERC20Proxy from '../test/generated-artifacts/ERC20Proxy.json'; +import * as ERC721Proxy from '../test/generated-artifacts/ERC721Proxy.json'; +import * as Eth2DaiBridge from '../test/generated-artifacts/Eth2DaiBridge.json'; +import * as IAssetData from '../test/generated-artifacts/IAssetData.json'; +import * as IAssetProxy from '../test/generated-artifacts/IAssetProxy.json'; +import * as IAssetProxyDispatcher from '../test/generated-artifacts/IAssetProxyDispatcher.json'; +import * as IAuthorizable from '../test/generated-artifacts/IAuthorizable.json'; +import * as IERC20Bridge from '../test/generated-artifacts/IERC20Bridge.json'; +import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json'; +import * as IUniswapExchange from '../test/generated-artifacts/IUniswapExchange.json'; +import * as IUniswapExchangeFactory from '../test/generated-artifacts/IUniswapExchangeFactory.json'; +import * as MixinAssetProxyDispatcher from '../test/generated-artifacts/MixinAssetProxyDispatcher.json'; +import * as MixinAuthorizable from '../test/generated-artifacts/MixinAuthorizable.json'; +import * as MultiAssetProxy from '../test/generated-artifacts/MultiAssetProxy.json'; +import * as Ownable from '../test/generated-artifacts/Ownable.json'; +import * as StaticCallProxy from '../test/generated-artifacts/StaticCallProxy.json'; +import * as TestERC20Bridge from '../test/generated-artifacts/TestERC20Bridge.json'; +import * as TestEth2DaiBridge from '../test/generated-artifacts/TestEth2DaiBridge.json'; +import * as TestStaticCallTarget from '../test/generated-artifacts/TestStaticCallTarget.json'; +import * as TestUniswapBridge from '../test/generated-artifacts/TestUniswapBridge.json'; +import * as UniswapBridge from '../test/generated-artifacts/UniswapBridge.json'; +export const artifacts = { + MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact, + MixinAuthorizable: MixinAuthorizable as ContractArtifact, + Ownable: Ownable as ContractArtifact, + ERC1155Proxy: ERC1155Proxy as ContractArtifact, + ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact, + ERC20Proxy: ERC20Proxy as ContractArtifact, + ERC721Proxy: ERC721Proxy as ContractArtifact, + MultiAssetProxy: MultiAssetProxy as ContractArtifact, + StaticCallProxy: StaticCallProxy as ContractArtifact, + Eth2DaiBridge: Eth2DaiBridge as ContractArtifact, + UniswapBridge: UniswapBridge as ContractArtifact, + IAssetData: IAssetData as ContractArtifact, + IAssetProxy: IAssetProxy as ContractArtifact, + IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, + IAuthorizable: IAuthorizable as ContractArtifact, + IERC20Bridge: IERC20Bridge as ContractArtifact, + IEth2Dai: IEth2Dai as ContractArtifact, + IUniswapExchange: IUniswapExchange as ContractArtifact, + IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact, + TestERC20Bridge: TestERC20Bridge as ContractArtifact, + TestEth2DaiBridge: TestEth2DaiBridge as ContractArtifact, + TestStaticCallTarget: TestStaticCallTarget as ContractArtifact, + TestUniswapBridge: TestUniswapBridge as ContractArtifact, +}; diff --git a/contracts/asset-proxy/test/wrappers.ts b/contracts/asset-proxy/test/wrappers.ts new file mode 100644 index 0000000000..af9dcfc25d --- /dev/null +++ b/contracts/asset-proxy/test/wrappers.ts @@ -0,0 +1,28 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/erc1155_proxy'; +export * from '../test/generated-wrappers/erc20_bridge_proxy'; +export * from '../test/generated-wrappers/erc20_proxy'; +export * from '../test/generated-wrappers/erc721_proxy'; +export * from '../test/generated-wrappers/eth2_dai_bridge'; +export * from '../test/generated-wrappers/i_asset_data'; +export * from '../test/generated-wrappers/i_asset_proxy'; +export * from '../test/generated-wrappers/i_asset_proxy_dispatcher'; +export * from '../test/generated-wrappers/i_authorizable'; +export * from '../test/generated-wrappers/i_erc20_bridge'; +export * from '../test/generated-wrappers/i_eth2_dai'; +export * from '../test/generated-wrappers/i_uniswap_exchange'; +export * from '../test/generated-wrappers/i_uniswap_exchange_factory'; +export * from '../test/generated-wrappers/mixin_asset_proxy_dispatcher'; +export * from '../test/generated-wrappers/mixin_authorizable'; +export * from '../test/generated-wrappers/multi_asset_proxy'; +export * from '../test/generated-wrappers/ownable'; +export * from '../test/generated-wrappers/static_call_proxy'; +export * from '../test/generated-wrappers/test_erc20_bridge'; +export * from '../test/generated-wrappers/test_eth2_dai_bridge'; +export * from '../test/generated-wrappers/test_static_call_target'; +export * from '../test/generated-wrappers/test_uniswap_bridge'; +export * from '../test/generated-wrappers/uniswap_bridge'; diff --git a/contracts/asset-proxy/tsconfig.json b/contracts/asset-proxy/tsconfig.json index 8ca5339b81..63f22050f0 100644 --- a/contracts/asset-proxy/tsconfig.json +++ b/contracts/asset-proxy/tsconfig.json @@ -25,7 +25,30 @@ "generated-artifacts/TestEth2DaiBridge.json", "generated-artifacts/TestStaticCallTarget.json", "generated-artifacts/TestUniswapBridge.json", - "generated-artifacts/UniswapBridge.json" + "generated-artifacts/UniswapBridge.json", + "test/generated-artifacts/ERC1155Proxy.json", + "test/generated-artifacts/ERC20BridgeProxy.json", + "test/generated-artifacts/ERC20Proxy.json", + "test/generated-artifacts/ERC721Proxy.json", + "test/generated-artifacts/Eth2DaiBridge.json", + "test/generated-artifacts/IAssetData.json", + "test/generated-artifacts/IAssetProxy.json", + "test/generated-artifacts/IAssetProxyDispatcher.json", + "test/generated-artifacts/IAuthorizable.json", + "test/generated-artifacts/IERC20Bridge.json", + "test/generated-artifacts/IEth2Dai.json", + "test/generated-artifacts/IUniswapExchange.json", + "test/generated-artifacts/IUniswapExchangeFactory.json", + "test/generated-artifacts/MixinAssetProxyDispatcher.json", + "test/generated-artifacts/MixinAuthorizable.json", + "test/generated-artifacts/MultiAssetProxy.json", + "test/generated-artifacts/Ownable.json", + "test/generated-artifacts/StaticCallProxy.json", + "test/generated-artifacts/TestERC20Bridge.json", + "test/generated-artifacts/TestEth2DaiBridge.json", + "test/generated-artifacts/TestStaticCallTarget.json", + "test/generated-artifacts/TestUniswapBridge.json", + "test/generated-artifacts/UniswapBridge.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/coordinator/compiler.json b/contracts/coordinator/compiler.json index 0edd285700..4a8f61a09f 100644 --- a/contracts/coordinator/compiler.json +++ b/contracts/coordinator/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "compilerSettings": { diff --git a/contracts/coordinator/package.json b/contracts/coordinator/package.json index 52f7dd3f6b..d052d9a650 100644 --- a/contracts/coordinator/package.json +++ b/contracts/coordinator/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,16 +21,17 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, diff --git a/contracts/dev-utils/compiler.json b/contracts/dev-utils/compiler.json index 10160aa539..220e81a33a 100644 --- a/contracts/dev-utils/compiler.json +++ b/contracts/dev-utils/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/dev-utils/package.json b/contracts/dev-utils/package.json index 51472eca68..fd19351074 100644 --- a/contracts/dev-utils/package.json +++ b/contracts/dev-utils/package.json @@ -10,20 +10,21 @@ "build": "yarn pre_build && tsc -b", "test": "echo !!! Run tests in @0x/contracts-tests instead !!!", "build:ci": "yarn build", - "pre_build": "run-s compile quantify_bytecode contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile quantify_bytecode contracts:gen generate_contract_wrappers contracts:copy", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "contracts:gen": "contracts-gen", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", - "quantify_bytecode": "echo EVM bytecode object lengths:;for i in ./generated-artifacts/*.json; do node -e \"console.log('$i\t' + (require('$i').compilerOutput.evm.bytecode.object.length - 2) / 2)\"; done", + "quantify_bytecode": "echo EVM bytecode object lengths:;for i in ./test/generated-artifacts/*.json; do node -e \"console.log('$i\t' + (require('$i').compilerOutput.evm.bytecode.object.length - 2) / 2)\"; done", "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(DevUtils|EthBalanceChecker|LibAssetData|LibTransactionDecoder|OrderTransferSimulationUtils|OrderValidationUtils).json", + "abis": "./test/generated-artifacts/@(DevUtils|EthBalanceChecker|LibAssetData|LibTransactionDecoder|OrderTransferSimulationUtils|OrderValidationUtils).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/dev-utils/test/artifacts.ts b/contracts/dev-utils/test/artifacts.ts new file mode 100644 index 0000000000..767d984040 --- /dev/null +++ b/contracts/dev-utils/test/artifacts.ts @@ -0,0 +1,21 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as DevUtils from '../test/generated-artifacts/DevUtils.json'; +import * as EthBalanceChecker from '../test/generated-artifacts/EthBalanceChecker.json'; +import * as LibAssetData from '../test/generated-artifacts/LibAssetData.json'; +import * as LibTransactionDecoder from '../test/generated-artifacts/LibTransactionDecoder.json'; +import * as OrderTransferSimulationUtils from '../test/generated-artifacts/OrderTransferSimulationUtils.json'; +import * as OrderValidationUtils from '../test/generated-artifacts/OrderValidationUtils.json'; +export const artifacts = { + DevUtils: DevUtils as ContractArtifact, + EthBalanceChecker: EthBalanceChecker as ContractArtifact, + LibAssetData: LibAssetData as ContractArtifact, + LibTransactionDecoder: LibTransactionDecoder as ContractArtifact, + OrderTransferSimulationUtils: OrderTransferSimulationUtils as ContractArtifact, + OrderValidationUtils: OrderValidationUtils as ContractArtifact, +}; diff --git a/contracts/dev-utils/test/wrappers.ts b/contracts/dev-utils/test/wrappers.ts new file mode 100644 index 0000000000..cbbea9c7cc --- /dev/null +++ b/contracts/dev-utils/test/wrappers.ts @@ -0,0 +1,11 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/dev_utils'; +export * from '../test/generated-wrappers/eth_balance_checker'; +export * from '../test/generated-wrappers/lib_asset_data'; +export * from '../test/generated-wrappers/lib_transaction_decoder'; +export * from '../test/generated-wrappers/order_transfer_simulation_utils'; +export * from '../test/generated-wrappers/order_validation_utils'; diff --git a/contracts/dev-utils/tsconfig.json b/contracts/dev-utils/tsconfig.json index d160f0c58d..9c73a11607 100644 --- a/contracts/dev-utils/tsconfig.json +++ b/contracts/dev-utils/tsconfig.json @@ -8,7 +8,13 @@ "generated-artifacts/LibAssetData.json", "generated-artifacts/LibTransactionDecoder.json", "generated-artifacts/OrderTransferSimulationUtils.json", - "generated-artifacts/OrderValidationUtils.json" + "generated-artifacts/OrderValidationUtils.json", + "test/generated-artifacts/DevUtils.json", + "test/generated-artifacts/EthBalanceChecker.json", + "test/generated-artifacts/LibAssetData.json", + "test/generated-artifacts/LibTransactionDecoder.json", + "test/generated-artifacts/OrderTransferSimulationUtils.json", + "test/generated-artifacts/OrderValidationUtils.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/erc1155/compiler.json b/contracts/erc1155/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/erc1155/compiler.json +++ b/contracts/erc1155/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/erc1155/package.json b/contracts/erc1155/package.json index 85b1844313..cacb08e9af 100644 --- a/contracts/erc1155/package.json +++ b/contracts/erc1155/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,21 +21,22 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(DummyERC1155Receiver|ERC1155|ERC1155Mintable|IERC1155|IERC1155Mintable|IERC1155Receiver|MixinNonFungibleToken).json", + "abis": "./test/generated-artifacts/@(DummyERC1155Receiver|ERC1155|ERC1155Mintable|IERC1155|IERC1155Mintable|IERC1155Receiver|MixinNonFungibleToken).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/erc1155/test/artifacts.ts b/contracts/erc1155/test/artifacts.ts new file mode 100644 index 0000000000..dd3e54205d --- /dev/null +++ b/contracts/erc1155/test/artifacts.ts @@ -0,0 +1,23 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC1155Receiver from '../test/generated-artifacts/DummyERC1155Receiver.json'; +import * as ERC1155 from '../test/generated-artifacts/ERC1155.json'; +import * as ERC1155Mintable from '../test/generated-artifacts/ERC1155Mintable.json'; +import * as IERC1155 from '../test/generated-artifacts/IERC1155.json'; +import * as IERC1155Mintable from '../test/generated-artifacts/IERC1155Mintable.json'; +import * as IERC1155Receiver from '../test/generated-artifacts/IERC1155Receiver.json'; +import * as MixinNonFungibleToken from '../test/generated-artifacts/MixinNonFungibleToken.json'; +export const artifacts = { + ERC1155: ERC1155 as ContractArtifact, + ERC1155Mintable: ERC1155Mintable as ContractArtifact, + MixinNonFungibleToken: MixinNonFungibleToken as ContractArtifact, + IERC1155: IERC1155 as ContractArtifact, + IERC1155Mintable: IERC1155Mintable as ContractArtifact, + IERC1155Receiver: IERC1155Receiver as ContractArtifact, + DummyERC1155Receiver: DummyERC1155Receiver as ContractArtifact, +}; diff --git a/contracts/erc1155/test/wrappers.ts b/contracts/erc1155/test/wrappers.ts new file mode 100644 index 0000000000..1f7cf349d1 --- /dev/null +++ b/contracts/erc1155/test/wrappers.ts @@ -0,0 +1,12 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/dummy_erc1155_receiver'; +export * from '../test/generated-wrappers/erc1155'; +export * from '../test/generated-wrappers/erc1155_mintable'; +export * from '../test/generated-wrappers/i_erc1155_mintable'; +export * from '../test/generated-wrappers/i_erc1155_receiver'; +export * from '../test/generated-wrappers/ierc1155'; +export * from '../test/generated-wrappers/mixin_non_fungible_token'; diff --git a/contracts/erc1155/tsconfig.json b/contracts/erc1155/tsconfig.json index bfa8deee96..df202ecd79 100644 --- a/contracts/erc1155/tsconfig.json +++ b/contracts/erc1155/tsconfig.json @@ -9,7 +9,14 @@ "generated-artifacts/IERC1155.json", "generated-artifacts/IERC1155Mintable.json", "generated-artifacts/IERC1155Receiver.json", - "generated-artifacts/MixinNonFungibleToken.json" + "generated-artifacts/MixinNonFungibleToken.json", + "test/generated-artifacts/DummyERC1155Receiver.json", + "test/generated-artifacts/ERC1155.json", + "test/generated-artifacts/ERC1155Mintable.json", + "test/generated-artifacts/IERC1155.json", + "test/generated-artifacts/IERC1155Mintable.json", + "test/generated-artifacts/IERC1155Receiver.json", + "test/generated-artifacts/MixinNonFungibleToken.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/erc20/compiler.json b/contracts/erc20/compiler.json index ac8f2ed76d..e65c0e7194 100644 --- a/contracts/erc20/compiler.json +++ b/contracts/erc20/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/erc20/package.json b/contracts/erc20/package.json index b5c1f2e8f2..68e3c21a24 100644 --- a/contracts/erc20/package.json +++ b/contracts/erc20/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,20 +21,21 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "./generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|LibERC20Token|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json", + "abis": "./test/generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|LibERC20Token|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/erc20/test/artifacts.ts b/contracts/erc20/test/artifacts.ts new file mode 100644 index 0000000000..78062e41f1 --- /dev/null +++ b/contracts/erc20/test/artifacts.ts @@ -0,0 +1,37 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC20Token from '../test/generated-artifacts/DummyERC20Token.json'; +import * as DummyMultipleReturnERC20Token from '../test/generated-artifacts/DummyMultipleReturnERC20Token.json'; +import * as DummyNoReturnERC20Token from '../test/generated-artifacts/DummyNoReturnERC20Token.json'; +import * as ERC20Token from '../test/generated-artifacts/ERC20Token.json'; +import * as IERC20Token from '../test/generated-artifacts/IERC20Token.json'; +import * as IEtherToken from '../test/generated-artifacts/IEtherToken.json'; +import * as LibERC20Token from '../test/generated-artifacts/LibERC20Token.json'; +import * as MintableERC20Token from '../test/generated-artifacts/MintableERC20Token.json'; +import * as TestLibERC20Token from '../test/generated-artifacts/TestLibERC20Token.json'; +import * as TestLibERC20TokenTarget from '../test/generated-artifacts/TestLibERC20TokenTarget.json'; +import * as UnlimitedAllowanceERC20Token from '../test/generated-artifacts/UnlimitedAllowanceERC20Token.json'; +import * as UntransferrableDummyERC20Token from '../test/generated-artifacts/UntransferrableDummyERC20Token.json'; +import * as WETH9 from '../test/generated-artifacts/WETH9.json'; +import * as ZRXToken from '../test/generated-artifacts/ZRXToken.json'; +export const artifacts = { + ERC20Token: ERC20Token as ContractArtifact, + LibERC20Token: LibERC20Token as ContractArtifact, + MintableERC20Token: MintableERC20Token as ContractArtifact, + UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, + WETH9: WETH9 as ContractArtifact, + ZRXToken: (ZRXToken as any) as ContractArtifact, + IERC20Token: IERC20Token as ContractArtifact, + IEtherToken: IEtherToken as ContractArtifact, + DummyERC20Token: DummyERC20Token as ContractArtifact, + DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, + DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, + TestLibERC20Token: TestLibERC20Token as ContractArtifact, + TestLibERC20TokenTarget: TestLibERC20TokenTarget as ContractArtifact, + UntransferrableDummyERC20Token: UntransferrableDummyERC20Token as ContractArtifact, +}; diff --git a/contracts/erc20/test/wrappers.ts b/contracts/erc20/test/wrappers.ts new file mode 100644 index 0000000000..f7ebf18b6a --- /dev/null +++ b/contracts/erc20/test/wrappers.ts @@ -0,0 +1,19 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/dummy_erc20_token'; +export * from '../test/generated-wrappers/dummy_multiple_return_erc20_token'; +export * from '../test/generated-wrappers/dummy_no_return_erc20_token'; +export * from '../test/generated-wrappers/erc20_token'; +export * from '../test/generated-wrappers/i_erc20_token'; +export * from '../test/generated-wrappers/i_ether_token'; +export * from '../test/generated-wrappers/lib_erc20_token'; +export * from '../test/generated-wrappers/mintable_erc20_token'; +export * from '../test/generated-wrappers/test_lib_erc20_token'; +export * from '../test/generated-wrappers/test_lib_erc20_token_target'; +export * from '../test/generated-wrappers/unlimited_allowance_erc20_token'; +export * from '../test/generated-wrappers/untransferrable_dummy_erc20_token'; +export * from '../test/generated-wrappers/weth9'; +export * from '../test/generated-wrappers/zrx_token'; diff --git a/contracts/erc20/tsconfig.json b/contracts/erc20/tsconfig.json index 5c706d141a..76d201e0c1 100644 --- a/contracts/erc20/tsconfig.json +++ b/contracts/erc20/tsconfig.json @@ -16,7 +16,21 @@ "generated-artifacts/UnlimitedAllowanceERC20Token.json", "generated-artifacts/UntransferrableDummyERC20Token.json", "generated-artifacts/WETH9.json", - "generated-artifacts/ZRXToken.json" + "generated-artifacts/ZRXToken.json", + "test/generated-artifacts/DummyERC20Token.json", + "test/generated-artifacts/DummyMultipleReturnERC20Token.json", + "test/generated-artifacts/DummyNoReturnERC20Token.json", + "test/generated-artifacts/ERC20Token.json", + "test/generated-artifacts/IERC20Token.json", + "test/generated-artifacts/IEtherToken.json", + "test/generated-artifacts/LibERC20Token.json", + "test/generated-artifacts/MintableERC20Token.json", + "test/generated-artifacts/TestLibERC20Token.json", + "test/generated-artifacts/TestLibERC20TokenTarget.json", + "test/generated-artifacts/UnlimitedAllowanceERC20Token.json", + "test/generated-artifacts/UntransferrableDummyERC20Token.json", + "test/generated-artifacts/WETH9.json", + "test/generated-artifacts/ZRXToken.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/erc721/compiler.json b/contracts/erc721/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/erc721/compiler.json +++ b/contracts/erc721/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/erc721/package.json b/contracts/erc721/package.json index b86b7e8afc..8ecbda03c2 100644 --- a/contracts/erc721/package.json +++ b/contracts/erc721/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,21 +21,22 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(DummyERC721Receiver|DummyERC721Token|ERC721Token|IERC721Receiver|IERC721Token|InvalidERC721Receiver|MintableERC721Token).json", + "abis": "./test/generated-artifacts/@(DummyERC721Receiver|DummyERC721Token|ERC721Token|IERC721Receiver|IERC721Token|InvalidERC721Receiver|MintableERC721Token).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/erc721/test/artifacts.ts b/contracts/erc721/test/artifacts.ts new file mode 100644 index 0000000000..327aa03b77 --- /dev/null +++ b/contracts/erc721/test/artifacts.ts @@ -0,0 +1,23 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC721Receiver from '../test/generated-artifacts/DummyERC721Receiver.json'; +import * as DummyERC721Token from '../test/generated-artifacts/DummyERC721Token.json'; +import * as ERC721Token from '../test/generated-artifacts/ERC721Token.json'; +import * as IERC721Receiver from '../test/generated-artifacts/IERC721Receiver.json'; +import * as IERC721Token from '../test/generated-artifacts/IERC721Token.json'; +import * as InvalidERC721Receiver from '../test/generated-artifacts/InvalidERC721Receiver.json'; +import * as MintableERC721Token from '../test/generated-artifacts/MintableERC721Token.json'; +export const artifacts = { + ERC721Token: ERC721Token as ContractArtifact, + MintableERC721Token: MintableERC721Token as ContractArtifact, + IERC721Receiver: IERC721Receiver as ContractArtifact, + IERC721Token: IERC721Token as ContractArtifact, + DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, + DummyERC721Token: DummyERC721Token as ContractArtifact, + InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact, +}; diff --git a/contracts/erc721/test/wrappers.ts b/contracts/erc721/test/wrappers.ts new file mode 100644 index 0000000000..bcf38a7079 --- /dev/null +++ b/contracts/erc721/test/wrappers.ts @@ -0,0 +1,12 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/dummy_erc721_receiver'; +export * from '../test/generated-wrappers/dummy_erc721_token'; +export * from '../test/generated-wrappers/erc721_token'; +export * from '../test/generated-wrappers/i_erc721_receiver'; +export * from '../test/generated-wrappers/i_erc721_token'; +export * from '../test/generated-wrappers/invalid_erc721_receiver'; +export * from '../test/generated-wrappers/mintable_erc721_token'; diff --git a/contracts/erc721/tsconfig.json b/contracts/erc721/tsconfig.json index 3b218affe6..9df1c3a825 100644 --- a/contracts/erc721/tsconfig.json +++ b/contracts/erc721/tsconfig.json @@ -9,7 +9,14 @@ "generated-artifacts/IERC721Receiver.json", "generated-artifacts/IERC721Token.json", "generated-artifacts/InvalidERC721Receiver.json", - "generated-artifacts/MintableERC721Token.json" + "generated-artifacts/MintableERC721Token.json", + "test/generated-artifacts/DummyERC721Receiver.json", + "test/generated-artifacts/DummyERC721Token.json", + "test/generated-artifacts/ERC721Token.json", + "test/generated-artifacts/IERC721Receiver.json", + "test/generated-artifacts/IERC721Token.json", + "test/generated-artifacts/InvalidERC721Receiver.json", + "test/generated-artifacts/MintableERC721Token.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange-forwarder/compiler.json b/contracts/exchange-forwarder/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/exchange-forwarder/compiler.json +++ b/contracts/exchange-forwarder/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/exchange-forwarder/package.json b/contracts/exchange-forwarder/package.json index 4b3d026b18..6bb6248672 100644 --- a/contracts/exchange-forwarder/package.json +++ b/contracts/exchange-forwarder/package.json @@ -13,7 +13,7 @@ "build": "yarn pre_build && tsc -b", "build:ts": "tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "echo !!! Tests have been relocated to @0x/contracts-integrations !!!", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,15 +21,16 @@ "test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, diff --git a/contracts/exchange-libs/compiler.json b/contracts/exchange-libs/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/exchange-libs/compiler.json +++ b/contracts/exchange-libs/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/exchange-libs/package.json b/contracts/exchange-libs/package.json index d2b2203a1f..a3c961a822 100644 --- a/contracts/exchange-libs/package.json +++ b/contracts/exchange-libs/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,21 +21,22 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(IWallet|LibEIP712ExchangeDomain|LibExchangeRichErrors|LibFillResults|LibMath|LibMathRichErrors|LibOrder|LibZeroExTransaction|TestLibEIP712ExchangeDomain|TestLibFillResults|TestLibMath|TestLibOrder|TestLibZeroExTransaction).json", + "abis": "./test/generated-artifacts/@(IWallet|LibEIP712ExchangeDomain|LibExchangeRichErrors|LibFillResults|LibMath|LibMathRichErrors|LibOrder|LibZeroExTransaction|TestLibEIP712ExchangeDomain|TestLibFillResults|TestLibMath|TestLibOrder|TestLibZeroExTransaction).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/exchange-libs/test/artifacts.ts b/contracts/exchange-libs/test/artifacts.ts new file mode 100644 index 0000000000..01c47756ec --- /dev/null +++ b/contracts/exchange-libs/test/artifacts.ts @@ -0,0 +1,35 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as IWallet from '../test/generated-artifacts/IWallet.json'; +import * as LibEIP712ExchangeDomain from '../test/generated-artifacts/LibEIP712ExchangeDomain.json'; +import * as LibExchangeRichErrors from '../test/generated-artifacts/LibExchangeRichErrors.json'; +import * as LibFillResults from '../test/generated-artifacts/LibFillResults.json'; +import * as LibMath from '../test/generated-artifacts/LibMath.json'; +import * as LibMathRichErrors from '../test/generated-artifacts/LibMathRichErrors.json'; +import * as LibOrder from '../test/generated-artifacts/LibOrder.json'; +import * as LibZeroExTransaction from '../test/generated-artifacts/LibZeroExTransaction.json'; +import * as TestLibEIP712ExchangeDomain from '../test/generated-artifacts/TestLibEIP712ExchangeDomain.json'; +import * as TestLibFillResults from '../test/generated-artifacts/TestLibFillResults.json'; +import * as TestLibMath from '../test/generated-artifacts/TestLibMath.json'; +import * as TestLibOrder from '../test/generated-artifacts/TestLibOrder.json'; +import * as TestLibZeroExTransaction from '../test/generated-artifacts/TestLibZeroExTransaction.json'; +export const artifacts = { + IWallet: IWallet as ContractArtifact, + LibEIP712ExchangeDomain: LibEIP712ExchangeDomain as ContractArtifact, + LibExchangeRichErrors: LibExchangeRichErrors as ContractArtifact, + LibFillResults: LibFillResults as ContractArtifact, + LibMath: LibMath as ContractArtifact, + LibMathRichErrors: LibMathRichErrors as ContractArtifact, + LibOrder: LibOrder as ContractArtifact, + LibZeroExTransaction: LibZeroExTransaction as ContractArtifact, + TestLibEIP712ExchangeDomain: TestLibEIP712ExchangeDomain as ContractArtifact, + TestLibFillResults: TestLibFillResults as ContractArtifact, + TestLibMath: TestLibMath as ContractArtifact, + TestLibOrder: TestLibOrder as ContractArtifact, + TestLibZeroExTransaction: TestLibZeroExTransaction as ContractArtifact, +}; diff --git a/contracts/exchange-libs/test/wrappers.ts b/contracts/exchange-libs/test/wrappers.ts new file mode 100644 index 0000000000..c0205dc234 --- /dev/null +++ b/contracts/exchange-libs/test/wrappers.ts @@ -0,0 +1,18 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/i_wallet'; +export * from '../test/generated-wrappers/lib_e_i_p712_exchange_domain'; +export * from '../test/generated-wrappers/lib_exchange_rich_errors'; +export * from '../test/generated-wrappers/lib_fill_results'; +export * from '../test/generated-wrappers/lib_math'; +export * from '../test/generated-wrappers/lib_math_rich_errors'; +export * from '../test/generated-wrappers/lib_order'; +export * from '../test/generated-wrappers/lib_zero_ex_transaction'; +export * from '../test/generated-wrappers/test_lib_e_i_p712_exchange_domain'; +export * from '../test/generated-wrappers/test_lib_fill_results'; +export * from '../test/generated-wrappers/test_lib_math'; +export * from '../test/generated-wrappers/test_lib_order'; +export * from '../test/generated-wrappers/test_lib_zero_ex_transaction'; diff --git a/contracts/exchange-libs/tsconfig.json b/contracts/exchange-libs/tsconfig.json index b75670d9f7..8babe39b95 100644 --- a/contracts/exchange-libs/tsconfig.json +++ b/contracts/exchange-libs/tsconfig.json @@ -15,7 +15,20 @@ "generated-artifacts/TestLibFillResults.json", "generated-artifacts/TestLibMath.json", "generated-artifacts/TestLibOrder.json", - "generated-artifacts/TestLibZeroExTransaction.json" + "generated-artifacts/TestLibZeroExTransaction.json", + "test/generated-artifacts/IWallet.json", + "test/generated-artifacts/LibEIP712ExchangeDomain.json", + "test/generated-artifacts/LibExchangeRichErrors.json", + "test/generated-artifacts/LibFillResults.json", + "test/generated-artifacts/LibMath.json", + "test/generated-artifacts/LibMathRichErrors.json", + "test/generated-artifacts/LibOrder.json", + "test/generated-artifacts/LibZeroExTransaction.json", + "test/generated-artifacts/TestLibEIP712ExchangeDomain.json", + "test/generated-artifacts/TestLibFillResults.json", + "test/generated-artifacts/TestLibMath.json", + "test/generated-artifacts/TestLibOrder.json", + "test/generated-artifacts/TestLibZeroExTransaction.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange/package.json b/contracts/exchange/package.json index 95a807844c..4236d0c7a5 100644 --- a/contracts/exchange/package.json +++ b/contracts/exchange/package.json @@ -12,21 +12,17 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", "test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html", "test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha", "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", - "compile": "run-s compile:test compile:src", - "compile:test": "sol-compiler", - "compile:src": "sol-compiler --artifacts-dir generated-artifacts --contracts ${npm_package_config_whitelistedContracts}", + "compile": "sol-compiler", "watch": "sol-compiler -w", "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", - "generate_contract_wrappers": "run-s generate_contract_wrappers:test generate_contract_wrappers:src", - "generate_contract_wrappers:test": "abi-gen --debug --abis ${npm_package_config_test_abis} --output test/generated-wrappers --backend ethers", - "generate_contract_wrappers:src": "abi-gen --debug --abis ${npm_package_config_src_abis} --output generated-wrappers --backend ethers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-wrappers/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", @@ -34,16 +30,15 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, "config": { - "whitelistedContracts": "Exchange,IExchange", - "test-abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", - "test-abis": "./test/generated-artifacts/@(Exchange|IAssetProxy|IAssetProxyDispatcher|IEIP1271Data|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|IProtocolFees|ISignatureValidator|ITransactions|ITransferSimulator|IWallet|IWrapperFunctions|IsolatedExchange|LibExchangeRichErrorDecoder|MixinAssetProxyDispatcher|MixinExchangeCore|MixinMatchOrders|MixinProtocolFees|MixinSignatureValidator|MixinTransactions|MixinTransferSimulator|MixinWrapperFunctions|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestProtocolFeeCollector|TestProtocolFees|TestProtocolFeesReceiver|TestSignatureValidator|TestTransactions|TestValidatorWallet|TestWrapperFunctions).json", - "src-abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", - "src-abis": "./generated-artifacts/@(Exchange|IExchange).json" + "publicInterfaceContracts": "Exchange,IExchange", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", + "abis": "./test/generated-artifacts/@(Exchange|IAssetProxy|IAssetProxyDispatcher|IEIP1271Data|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|IProtocolFees|ISignatureValidator|ITransactions|ITransferSimulator|IWallet|IWrapperFunctions|IsolatedExchange|LibExchangeRichErrorDecoder|MixinAssetProxyDispatcher|MixinExchangeCore|MixinMatchOrders|MixinProtocolFees|MixinSignatureValidator|MixinTransactions|MixinTransferSimulator|MixinWrapperFunctions|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestProtocolFeeCollector|TestProtocolFees|TestProtocolFeesReceiver|TestSignatureValidator|TestTransactions|TestValidatorWallet|TestWrapperFunctions).json" }, "repository": { "type": "git", diff --git a/contracts/extensions/compiler.json b/contracts/extensions/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/extensions/compiler.json +++ b/contracts/extensions/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json index 805012ac4f..c76ba61685 100644 --- a/contracts/extensions/package.json +++ b/contracts/extensions/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,16 +21,17 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, diff --git a/contracts/integrations/compiler.json b/contracts/integrations/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/integrations/compiler.json +++ b/contracts/integrations/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/integrations/package.json b/contracts/integrations/package.json index ef6947a761..9aa7f28a1b 100644 --- a/contracts/integrations/package.json +++ b/contracts/integrations/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,16 +21,17 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, diff --git a/contracts/multisig/compiler.json b/contracts/multisig/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/multisig/compiler.json +++ b/contracts/multisig/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/multisig/package.json b/contracts/multisig/package.json index c796579fe9..7c6ad6ba9d 100644 --- a/contracts/multisig/package.json +++ b/contracts/multisig/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,20 +21,21 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "./generated-artifacts/@(ContractCallReceiver|MultiSigWallet|MultiSigWalletWithTimeLock|TestRejectEther|TestZeroExGovernor|ZeroExGovernor).json", + "abis": "./test/generated-artifacts/@(ContractCallReceiver|MultiSigWallet|MultiSigWalletWithTimeLock|TestRejectEther|TestZeroExGovernor|ZeroExGovernor).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/multisig/test/artifacts.ts b/contracts/multisig/test/artifacts.ts new file mode 100644 index 0000000000..35da180f3a --- /dev/null +++ b/contracts/multisig/test/artifacts.ts @@ -0,0 +1,21 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as ContractCallReceiver from '../test/generated-artifacts/ContractCallReceiver.json'; +import * as MultiSigWallet from '../test/generated-artifacts/MultiSigWallet.json'; +import * as MultiSigWalletWithTimeLock from '../test/generated-artifacts/MultiSigWalletWithTimeLock.json'; +import * as TestRejectEther from '../test/generated-artifacts/TestRejectEther.json'; +import * as TestZeroExGovernor from '../test/generated-artifacts/TestZeroExGovernor.json'; +import * as ZeroExGovernor from '../test/generated-artifacts/ZeroExGovernor.json'; +export const artifacts = { + MultiSigWallet: MultiSigWallet as ContractArtifact, + MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact, + ZeroExGovernor: ZeroExGovernor as ContractArtifact, + ContractCallReceiver: ContractCallReceiver as ContractArtifact, + TestRejectEther: TestRejectEther as ContractArtifact, + TestZeroExGovernor: TestZeroExGovernor as ContractArtifact, +}; diff --git a/contracts/multisig/test/wrappers.ts b/contracts/multisig/test/wrappers.ts new file mode 100644 index 0000000000..199d7c282f --- /dev/null +++ b/contracts/multisig/test/wrappers.ts @@ -0,0 +1,11 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/contract_call_receiver'; +export * from '../test/generated-wrappers/multi_sig_wallet'; +export * from '../test/generated-wrappers/multi_sig_wallet_with_time_lock'; +export * from '../test/generated-wrappers/test_reject_ether'; +export * from '../test/generated-wrappers/test_zero_ex_governor'; +export * from '../test/generated-wrappers/zero_ex_governor'; diff --git a/contracts/multisig/tsconfig.json b/contracts/multisig/tsconfig.json index 643ad217e9..f300bb3934 100644 --- a/contracts/multisig/tsconfig.json +++ b/contracts/multisig/tsconfig.json @@ -8,7 +8,13 @@ "generated-artifacts/MultiSigWalletWithTimeLock.json", "generated-artifacts/TestRejectEther.json", "generated-artifacts/TestZeroExGovernor.json", - "generated-artifacts/ZeroExGovernor.json" + "generated-artifacts/ZeroExGovernor.json", + "test/generated-artifacts/ContractCallReceiver.json", + "test/generated-artifacts/MultiSigWallet.json", + "test/generated-artifacts/MultiSigWalletWithTimeLock.json", + "test/generated-artifacts/TestRejectEther.json", + "test/generated-artifacts/TestZeroExGovernor.json", + "test/generated-artifacts/ZeroExGovernor.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/staking/compiler.json b/contracts/staking/compiler.json index b8225dc0c4..4487fe30d1 100644 --- a/contracts/staking/compiler.json +++ b/contracts/staking/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": true, diff --git a/contracts/staking/package.json b/contracts/staking/package.json index 827eb6dc70..c430758c02 100644 --- a/contracts/staking/package.json +++ b/contracts/staking/package.json @@ -13,7 +13,7 @@ "build2": "tsc -b", "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -22,22 +22,23 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, "config": { "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", - "abis": "./generated-artifacts/@(IStaking|IStakingEvents|IStakingProxy|IStorage|IStorageInit|IStructs|IZrxVault|LibCobbDouglas|LibFixedMath|LibFixedMathRichErrors|LibSafeDowncast|LibStakingRichErrors|MixinAbstract|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinFinalizer|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewards|MixinStorage|Staking|StakingProxy|TestAssertStorageParams|TestCobbDouglas|TestCumulativeRewardTracking|TestDelegatorRewards|TestExchangeManager|TestFinalizer|TestInitTarget|TestLibFixedMath|TestLibSafeDowncast|TestMixinCumulativeRewards|TestMixinParams|TestMixinScheduler|TestMixinStake|TestMixinStakeBalances|TestMixinStakeStorage|TestMixinStakingPool|TestMixinStakingPoolRewards|TestProtocolFees|TestProxyDestination|TestStaking|TestStakingNoWETH|TestStakingProxy|TestStakingProxyUnit|TestStorageLayoutAndConstants|ZrxVault).json" + "abis": "./test/generated-artifacts/@(IStaking|IStakingEvents|IStakingProxy|IStorage|IStorageInit|IStructs|IZrxVault|LibCobbDouglas|LibFixedMath|LibFixedMathRichErrors|LibSafeDowncast|LibStakingRichErrors|MixinAbstract|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinFinalizer|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewards|MixinStorage|Staking|StakingProxy|TestAssertStorageParams|TestCobbDouglas|TestCumulativeRewardTracking|TestDelegatorRewards|TestExchangeManager|TestFinalizer|TestInitTarget|TestLibFixedMath|TestLibSafeDowncast|TestMixinCumulativeRewards|TestMixinParams|TestMixinScheduler|TestMixinStake|TestMixinStakeBalances|TestMixinStakeStorage|TestMixinStakingPool|TestMixinStakingPoolRewards|TestProtocolFees|TestProxyDestination|TestStaking|TestStakingNoWETH|TestStakingProxy|TestStakingProxyUnit|TestStorageLayoutAndConstants|ZrxVault).json" }, "repository": { "type": "git", diff --git a/contracts/staking/test/artifacts.ts b/contracts/staking/test/artifacts.ts new file mode 100644 index 0000000000..9064620477 --- /dev/null +++ b/contracts/staking/test/artifacts.ts @@ -0,0 +1,117 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as IStaking from '../test/generated-artifacts/IStaking.json'; +import * as IStakingEvents from '../test/generated-artifacts/IStakingEvents.json'; +import * as IStakingProxy from '../test/generated-artifacts/IStakingProxy.json'; +import * as IStorage from '../test/generated-artifacts/IStorage.json'; +import * as IStorageInit from '../test/generated-artifacts/IStorageInit.json'; +import * as IStructs from '../test/generated-artifacts/IStructs.json'; +import * as IZrxVault from '../test/generated-artifacts/IZrxVault.json'; +import * as LibCobbDouglas from '../test/generated-artifacts/LibCobbDouglas.json'; +import * as LibFixedMath from '../test/generated-artifacts/LibFixedMath.json'; +import * as LibFixedMathRichErrors from '../test/generated-artifacts/LibFixedMathRichErrors.json'; +import * as LibSafeDowncast from '../test/generated-artifacts/LibSafeDowncast.json'; +import * as LibStakingRichErrors from '../test/generated-artifacts/LibStakingRichErrors.json'; +import * as MixinAbstract from '../test/generated-artifacts/MixinAbstract.json'; +import * as MixinConstants from '../test/generated-artifacts/MixinConstants.json'; +import * as MixinCumulativeRewards from '../test/generated-artifacts/MixinCumulativeRewards.json'; +import * as MixinDeploymentConstants from '../test/generated-artifacts/MixinDeploymentConstants.json'; +import * as MixinExchangeFees from '../test/generated-artifacts/MixinExchangeFees.json'; +import * as MixinExchangeManager from '../test/generated-artifacts/MixinExchangeManager.json'; +import * as MixinFinalizer from '../test/generated-artifacts/MixinFinalizer.json'; +import * as MixinParams from '../test/generated-artifacts/MixinParams.json'; +import * as MixinScheduler from '../test/generated-artifacts/MixinScheduler.json'; +import * as MixinStake from '../test/generated-artifacts/MixinStake.json'; +import * as MixinStakeBalances from '../test/generated-artifacts/MixinStakeBalances.json'; +import * as MixinStakeStorage from '../test/generated-artifacts/MixinStakeStorage.json'; +import * as MixinStakingPool from '../test/generated-artifacts/MixinStakingPool.json'; +import * as MixinStakingPoolRewards from '../test/generated-artifacts/MixinStakingPoolRewards.json'; +import * as MixinStorage from '../test/generated-artifacts/MixinStorage.json'; +import * as Staking from '../test/generated-artifacts/Staking.json'; +import * as StakingProxy from '../test/generated-artifacts/StakingProxy.json'; +import * as TestAssertStorageParams from '../test/generated-artifacts/TestAssertStorageParams.json'; +import * as TestCobbDouglas from '../test/generated-artifacts/TestCobbDouglas.json'; +import * as TestCumulativeRewardTracking from '../test/generated-artifacts/TestCumulativeRewardTracking.json'; +import * as TestDelegatorRewards from '../test/generated-artifacts/TestDelegatorRewards.json'; +import * as TestExchangeManager from '../test/generated-artifacts/TestExchangeManager.json'; +import * as TestFinalizer from '../test/generated-artifacts/TestFinalizer.json'; +import * as TestInitTarget from '../test/generated-artifacts/TestInitTarget.json'; +import * as TestLibFixedMath from '../test/generated-artifacts/TestLibFixedMath.json'; +import * as TestLibSafeDowncast from '../test/generated-artifacts/TestLibSafeDowncast.json'; +import * as TestMixinCumulativeRewards from '../test/generated-artifacts/TestMixinCumulativeRewards.json'; +import * as TestMixinParams from '../test/generated-artifacts/TestMixinParams.json'; +import * as TestMixinScheduler from '../test/generated-artifacts/TestMixinScheduler.json'; +import * as TestMixinStake from '../test/generated-artifacts/TestMixinStake.json'; +import * as TestMixinStakeBalances from '../test/generated-artifacts/TestMixinStakeBalances.json'; +import * as TestMixinStakeStorage from '../test/generated-artifacts/TestMixinStakeStorage.json'; +import * as TestMixinStakingPool from '../test/generated-artifacts/TestMixinStakingPool.json'; +import * as TestMixinStakingPoolRewards from '../test/generated-artifacts/TestMixinStakingPoolRewards.json'; +import * as TestProtocolFees from '../test/generated-artifacts/TestProtocolFees.json'; +import * as TestProxyDestination from '../test/generated-artifacts/TestProxyDestination.json'; +import * as TestStaking from '../test/generated-artifacts/TestStaking.json'; +import * as TestStakingNoWETH from '../test/generated-artifacts/TestStakingNoWETH.json'; +import * as TestStakingProxy from '../test/generated-artifacts/TestStakingProxy.json'; +import * as TestStakingProxyUnit from '../test/generated-artifacts/TestStakingProxyUnit.json'; +import * as TestStorageLayoutAndConstants from '../test/generated-artifacts/TestStorageLayoutAndConstants.json'; +import * as ZrxVault from '../test/generated-artifacts/ZrxVault.json'; +export const artifacts = { + Staking: Staking as ContractArtifact, + StakingProxy: StakingProxy as ContractArtifact, + ZrxVault: ZrxVault as ContractArtifact, + MixinExchangeFees: MixinExchangeFees as ContractArtifact, + MixinExchangeManager: MixinExchangeManager as ContractArtifact, + MixinConstants: MixinConstants as ContractArtifact, + MixinDeploymentConstants: MixinDeploymentConstants as ContractArtifact, + MixinStorage: MixinStorage as ContractArtifact, + IStaking: IStaking as ContractArtifact, + IStakingEvents: IStakingEvents as ContractArtifact, + IStakingProxy: IStakingProxy as ContractArtifact, + IStorage: IStorage as ContractArtifact, + IStorageInit: IStorageInit as ContractArtifact, + IStructs: IStructs as ContractArtifact, + IZrxVault: IZrxVault as ContractArtifact, + LibCobbDouglas: LibCobbDouglas as ContractArtifact, + LibFixedMath: LibFixedMath as ContractArtifact, + LibFixedMathRichErrors: LibFixedMathRichErrors as ContractArtifact, + LibSafeDowncast: LibSafeDowncast as ContractArtifact, + LibStakingRichErrors: LibStakingRichErrors as ContractArtifact, + MixinStake: MixinStake as ContractArtifact, + MixinStakeBalances: MixinStakeBalances as ContractArtifact, + MixinStakeStorage: MixinStakeStorage as ContractArtifact, + MixinCumulativeRewards: MixinCumulativeRewards as ContractArtifact, + MixinStakingPool: MixinStakingPool as ContractArtifact, + MixinStakingPoolRewards: MixinStakingPoolRewards as ContractArtifact, + MixinAbstract: MixinAbstract as ContractArtifact, + MixinFinalizer: MixinFinalizer as ContractArtifact, + MixinParams: MixinParams as ContractArtifact, + MixinScheduler: MixinScheduler as ContractArtifact, + TestAssertStorageParams: TestAssertStorageParams as ContractArtifact, + TestCobbDouglas: TestCobbDouglas as ContractArtifact, + TestCumulativeRewardTracking: TestCumulativeRewardTracking as ContractArtifact, + TestDelegatorRewards: TestDelegatorRewards as ContractArtifact, + TestExchangeManager: TestExchangeManager as ContractArtifact, + TestFinalizer: TestFinalizer as ContractArtifact, + TestInitTarget: TestInitTarget as ContractArtifact, + TestLibFixedMath: TestLibFixedMath as ContractArtifact, + TestLibSafeDowncast: TestLibSafeDowncast as ContractArtifact, + TestMixinCumulativeRewards: TestMixinCumulativeRewards as ContractArtifact, + TestMixinParams: TestMixinParams as ContractArtifact, + TestMixinScheduler: TestMixinScheduler as ContractArtifact, + TestMixinStake: TestMixinStake as ContractArtifact, + TestMixinStakeBalances: TestMixinStakeBalances as ContractArtifact, + TestMixinStakeStorage: TestMixinStakeStorage as ContractArtifact, + TestMixinStakingPool: TestMixinStakingPool as ContractArtifact, + TestMixinStakingPoolRewards: TestMixinStakingPoolRewards as ContractArtifact, + TestProtocolFees: TestProtocolFees as ContractArtifact, + TestProxyDestination: TestProxyDestination as ContractArtifact, + TestStaking: TestStaking as ContractArtifact, + TestStakingNoWETH: TestStakingNoWETH as ContractArtifact, + TestStakingProxy: TestStakingProxy as ContractArtifact, + TestStakingProxyUnit: TestStakingProxyUnit as ContractArtifact, + TestStorageLayoutAndConstants: TestStorageLayoutAndConstants as ContractArtifact, +}; diff --git a/contracts/staking/test/wrappers.ts b/contracts/staking/test/wrappers.ts new file mode 100644 index 0000000000..4c8dd0c7b7 --- /dev/null +++ b/contracts/staking/test/wrappers.ts @@ -0,0 +1,59 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/i_staking'; +export * from '../test/generated-wrappers/i_staking_events'; +export * from '../test/generated-wrappers/i_staking_proxy'; +export * from '../test/generated-wrappers/i_storage'; +export * from '../test/generated-wrappers/i_storage_init'; +export * from '../test/generated-wrappers/i_structs'; +export * from '../test/generated-wrappers/i_zrx_vault'; +export * from '../test/generated-wrappers/lib_cobb_douglas'; +export * from '../test/generated-wrappers/lib_fixed_math'; +export * from '../test/generated-wrappers/lib_fixed_math_rich_errors'; +export * from '../test/generated-wrappers/lib_safe_downcast'; +export * from '../test/generated-wrappers/lib_staking_rich_errors'; +export * from '../test/generated-wrappers/mixin_abstract'; +export * from '../test/generated-wrappers/mixin_constants'; +export * from '../test/generated-wrappers/mixin_cumulative_rewards'; +export * from '../test/generated-wrappers/mixin_deployment_constants'; +export * from '../test/generated-wrappers/mixin_exchange_fees'; +export * from '../test/generated-wrappers/mixin_exchange_manager'; +export * from '../test/generated-wrappers/mixin_finalizer'; +export * from '../test/generated-wrappers/mixin_params'; +export * from '../test/generated-wrappers/mixin_scheduler'; +export * from '../test/generated-wrappers/mixin_stake'; +export * from '../test/generated-wrappers/mixin_stake_balances'; +export * from '../test/generated-wrappers/mixin_stake_storage'; +export * from '../test/generated-wrappers/mixin_staking_pool'; +export * from '../test/generated-wrappers/mixin_staking_pool_rewards'; +export * from '../test/generated-wrappers/mixin_storage'; +export * from '../test/generated-wrappers/staking'; +export * from '../test/generated-wrappers/staking_proxy'; +export * from '../test/generated-wrappers/test_assert_storage_params'; +export * from '../test/generated-wrappers/test_cobb_douglas'; +export * from '../test/generated-wrappers/test_cumulative_reward_tracking'; +export * from '../test/generated-wrappers/test_delegator_rewards'; +export * from '../test/generated-wrappers/test_exchange_manager'; +export * from '../test/generated-wrappers/test_finalizer'; +export * from '../test/generated-wrappers/test_init_target'; +export * from '../test/generated-wrappers/test_lib_fixed_math'; +export * from '../test/generated-wrappers/test_lib_safe_downcast'; +export * from '../test/generated-wrappers/test_mixin_cumulative_rewards'; +export * from '../test/generated-wrappers/test_mixin_params'; +export * from '../test/generated-wrappers/test_mixin_scheduler'; +export * from '../test/generated-wrappers/test_mixin_stake'; +export * from '../test/generated-wrappers/test_mixin_stake_balances'; +export * from '../test/generated-wrappers/test_mixin_stake_storage'; +export * from '../test/generated-wrappers/test_mixin_staking_pool'; +export * from '../test/generated-wrappers/test_mixin_staking_pool_rewards'; +export * from '../test/generated-wrappers/test_protocol_fees'; +export * from '../test/generated-wrappers/test_proxy_destination'; +export * from '../test/generated-wrappers/test_staking'; +export * from '../test/generated-wrappers/test_staking_no_w_e_t_h'; +export * from '../test/generated-wrappers/test_staking_proxy'; +export * from '../test/generated-wrappers/test_staking_proxy_unit'; +export * from '../test/generated-wrappers/test_storage_layout_and_constants'; +export * from '../test/generated-wrappers/zrx_vault'; diff --git a/contracts/staking/tsconfig.json b/contracts/staking/tsconfig.json index 9f73beed73..92bb839e10 100644 --- a/contracts/staking/tsconfig.json +++ b/contracts/staking/tsconfig.json @@ -56,7 +56,61 @@ "generated-artifacts/TestStakingProxy.json", "generated-artifacts/TestStakingProxyUnit.json", "generated-artifacts/TestStorageLayoutAndConstants.json", - "generated-artifacts/ZrxVault.json" + "generated-artifacts/ZrxVault.json", + "test/generated-artifacts/IStaking.json", + "test/generated-artifacts/IStakingEvents.json", + "test/generated-artifacts/IStakingProxy.json", + "test/generated-artifacts/IStorage.json", + "test/generated-artifacts/IStorageInit.json", + "test/generated-artifacts/IStructs.json", + "test/generated-artifacts/IZrxVault.json", + "test/generated-artifacts/LibCobbDouglas.json", + "test/generated-artifacts/LibFixedMath.json", + "test/generated-artifacts/LibFixedMathRichErrors.json", + "test/generated-artifacts/LibSafeDowncast.json", + "test/generated-artifacts/LibStakingRichErrors.json", + "test/generated-artifacts/MixinAbstract.json", + "test/generated-artifacts/MixinConstants.json", + "test/generated-artifacts/MixinCumulativeRewards.json", + "test/generated-artifacts/MixinDeploymentConstants.json", + "test/generated-artifacts/MixinExchangeFees.json", + "test/generated-artifacts/MixinExchangeManager.json", + "test/generated-artifacts/MixinFinalizer.json", + "test/generated-artifacts/MixinParams.json", + "test/generated-artifacts/MixinScheduler.json", + "test/generated-artifacts/MixinStake.json", + "test/generated-artifacts/MixinStakeBalances.json", + "test/generated-artifacts/MixinStakeStorage.json", + "test/generated-artifacts/MixinStakingPool.json", + "test/generated-artifacts/MixinStakingPoolRewards.json", + "test/generated-artifacts/MixinStorage.json", + "test/generated-artifacts/Staking.json", + "test/generated-artifacts/StakingProxy.json", + "test/generated-artifacts/TestAssertStorageParams.json", + "test/generated-artifacts/TestCobbDouglas.json", + "test/generated-artifacts/TestCumulativeRewardTracking.json", + "test/generated-artifacts/TestDelegatorRewards.json", + "test/generated-artifacts/TestExchangeManager.json", + "test/generated-artifacts/TestFinalizer.json", + "test/generated-artifacts/TestInitTarget.json", + "test/generated-artifacts/TestLibFixedMath.json", + "test/generated-artifacts/TestLibSafeDowncast.json", + "test/generated-artifacts/TestMixinCumulativeRewards.json", + "test/generated-artifacts/TestMixinParams.json", + "test/generated-artifacts/TestMixinScheduler.json", + "test/generated-artifacts/TestMixinStake.json", + "test/generated-artifacts/TestMixinStakeBalances.json", + "test/generated-artifacts/TestMixinStakeStorage.json", + "test/generated-artifacts/TestMixinStakingPool.json", + "test/generated-artifacts/TestMixinStakingPoolRewards.json", + "test/generated-artifacts/TestProtocolFees.json", + "test/generated-artifacts/TestProxyDestination.json", + "test/generated-artifacts/TestStaking.json", + "test/generated-artifacts/TestStakingNoWETH.json", + "test/generated-artifacts/TestStakingProxy.json", + "test/generated-artifacts/TestStakingProxyUnit.json", + "test/generated-artifacts/TestStorageLayoutAndConstants.json", + "test/generated-artifacts/ZrxVault.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/tests/compiler.json b/contracts/tests/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/tests/compiler.json +++ b/contracts/tests/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/tests/package.json b/contracts/tests/package.json index 1d26ab6616..9ae908f542 100644 --- a/contracts/tests/package.json +++ b/contracts/tests/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -22,16 +22,17 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, diff --git a/contracts/utils/compiler.json b/contracts/utils/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/utils/compiler.json +++ b/contracts/utils/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/utils/package.json b/contracts/utils/package.json index c0939e5f6a..d64c103771 100644 --- a/contracts/utils/package.json +++ b/contracts/utils/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "build:ci": "yarn build", - "pre_build": "run-s compile contracts:gen generate_contract_wrappers", + "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", @@ -21,22 +21,23 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile": "sol-compiler", "watch": "sol-compiler -w", - "clean": "shx rm -rf lib generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", - "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", - "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", + "generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", + "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", + "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", - "contracts:gen": "contracts-gen", + "contracts:gen": "contracts-gen generate", + "contracts:copy": "contracts-gen copy", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", "compile:truffle": "truffle compile" }, "config": { "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", - "abis": "./generated-artifacts/@(Authorizable|IAuthorizable|IOwnable|LibAddress|LibAddressArray|LibAddressArrayRichErrors|LibAuthorizableRichErrors|LibBytes|LibBytesRichErrors|LibEIP1271|LibEIP712|LibFractions|LibOwnableRichErrors|LibReentrancyGuardRichErrors|LibRichErrors|LibSafeMath|LibSafeMathRichErrors|Ownable|ReentrancyGuard|Refundable|TestLibAddress|TestLibAddressArray|TestLibBytes|TestLibEIP712|TestLibRichErrors|TestLibSafeMath|TestLogDecoding|TestLogDecodingDownstream|TestOwnable|TestReentrancyGuard|TestRefundable|TestRefundableReceiver).json" + "abis": "./test/generated-artifacts/@(Authorizable|IAuthorizable|IOwnable|LibAddress|LibAddressArray|LibAddressArrayRichErrors|LibAuthorizableRichErrors|LibBytes|LibBytesRichErrors|LibEIP1271|LibEIP712|LibFractions|LibOwnableRichErrors|LibReentrancyGuardRichErrors|LibRichErrors|LibSafeMath|LibSafeMathRichErrors|Ownable|ReentrancyGuard|Refundable|TestLibAddress|TestLibAddressArray|TestLibBytes|TestLibEIP712|TestLibRichErrors|TestLibSafeMath|TestLogDecoding|TestLogDecodingDownstream|TestOwnable|TestReentrancyGuard|TestRefundable|TestRefundableReceiver).json" }, "repository": { "type": "git", diff --git a/contracts/utils/test/artifacts.ts b/contracts/utils/test/artifacts.ts new file mode 100644 index 0000000000..724fb646f9 --- /dev/null +++ b/contracts/utils/test/artifacts.ts @@ -0,0 +1,73 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as Authorizable from '../test/generated-artifacts/Authorizable.json'; +import * as IAuthorizable from '../test/generated-artifacts/IAuthorizable.json'; +import * as IOwnable from '../test/generated-artifacts/IOwnable.json'; +import * as LibAddress from '../test/generated-artifacts/LibAddress.json'; +import * as LibAddressArray from '../test/generated-artifacts/LibAddressArray.json'; +import * as LibAddressArrayRichErrors from '../test/generated-artifacts/LibAddressArrayRichErrors.json'; +import * as LibAuthorizableRichErrors from '../test/generated-artifacts/LibAuthorizableRichErrors.json'; +import * as LibBytes from '../test/generated-artifacts/LibBytes.json'; +import * as LibBytesRichErrors from '../test/generated-artifacts/LibBytesRichErrors.json'; +import * as LibEIP1271 from '../test/generated-artifacts/LibEIP1271.json'; +import * as LibEIP712 from '../test/generated-artifacts/LibEIP712.json'; +import * as LibFractions from '../test/generated-artifacts/LibFractions.json'; +import * as LibOwnableRichErrors from '../test/generated-artifacts/LibOwnableRichErrors.json'; +import * as LibReentrancyGuardRichErrors from '../test/generated-artifacts/LibReentrancyGuardRichErrors.json'; +import * as LibRichErrors from '../test/generated-artifacts/LibRichErrors.json'; +import * as LibSafeMath from '../test/generated-artifacts/LibSafeMath.json'; +import * as LibSafeMathRichErrors from '../test/generated-artifacts/LibSafeMathRichErrors.json'; +import * as Ownable from '../test/generated-artifacts/Ownable.json'; +import * as ReentrancyGuard from '../test/generated-artifacts/ReentrancyGuard.json'; +import * as Refundable from '../test/generated-artifacts/Refundable.json'; +import * as TestLibAddress from '../test/generated-artifacts/TestLibAddress.json'; +import * as TestLibAddressArray from '../test/generated-artifacts/TestLibAddressArray.json'; +import * as TestLibBytes from '../test/generated-artifacts/TestLibBytes.json'; +import * as TestLibEIP712 from '../test/generated-artifacts/TestLibEIP712.json'; +import * as TestLibRichErrors from '../test/generated-artifacts/TestLibRichErrors.json'; +import * as TestLibSafeMath from '../test/generated-artifacts/TestLibSafeMath.json'; +import * as TestLogDecoding from '../test/generated-artifacts/TestLogDecoding.json'; +import * as TestLogDecodingDownstream from '../test/generated-artifacts/TestLogDecodingDownstream.json'; +import * as TestOwnable from '../test/generated-artifacts/TestOwnable.json'; +import * as TestReentrancyGuard from '../test/generated-artifacts/TestReentrancyGuard.json'; +import * as TestRefundable from '../test/generated-artifacts/TestRefundable.json'; +import * as TestRefundableReceiver from '../test/generated-artifacts/TestRefundableReceiver.json'; +export const artifacts = { + Authorizable: Authorizable as ContractArtifact, + LibAddress: LibAddress as ContractArtifact, + LibAddressArray: LibAddressArray as ContractArtifact, + LibAddressArrayRichErrors: LibAddressArrayRichErrors as ContractArtifact, + LibAuthorizableRichErrors: LibAuthorizableRichErrors as ContractArtifact, + LibBytes: LibBytes as ContractArtifact, + LibBytesRichErrors: LibBytesRichErrors as ContractArtifact, + LibEIP1271: LibEIP1271 as ContractArtifact, + LibEIP712: LibEIP712 as ContractArtifact, + LibFractions: LibFractions as ContractArtifact, + LibOwnableRichErrors: LibOwnableRichErrors as ContractArtifact, + LibReentrancyGuardRichErrors: LibReentrancyGuardRichErrors as ContractArtifact, + LibRichErrors: LibRichErrors as ContractArtifact, + LibSafeMath: LibSafeMath as ContractArtifact, + LibSafeMathRichErrors: LibSafeMathRichErrors as ContractArtifact, + Ownable: Ownable as ContractArtifact, + ReentrancyGuard: ReentrancyGuard as ContractArtifact, + Refundable: Refundable as ContractArtifact, + IAuthorizable: IAuthorizable as ContractArtifact, + IOwnable: IOwnable as ContractArtifact, + TestLibAddress: TestLibAddress as ContractArtifact, + TestLibAddressArray: TestLibAddressArray as ContractArtifact, + TestLibBytes: TestLibBytes as ContractArtifact, + TestLibEIP712: TestLibEIP712 as ContractArtifact, + TestLibRichErrors: TestLibRichErrors as ContractArtifact, + TestLibSafeMath: TestLibSafeMath as ContractArtifact, + TestLogDecoding: TestLogDecoding as ContractArtifact, + TestLogDecodingDownstream: TestLogDecodingDownstream as ContractArtifact, + TestOwnable: TestOwnable as ContractArtifact, + TestReentrancyGuard: TestReentrancyGuard as ContractArtifact, + TestRefundable: TestRefundable as ContractArtifact, + TestRefundableReceiver: TestRefundableReceiver as ContractArtifact, +}; diff --git a/contracts/utils/test/wrappers.ts b/contracts/utils/test/wrappers.ts new file mode 100644 index 0000000000..a0397108f0 --- /dev/null +++ b/contracts/utils/test/wrappers.ts @@ -0,0 +1,37 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/authorizable'; +export * from '../test/generated-wrappers/i_authorizable'; +export * from '../test/generated-wrappers/i_ownable'; +export * from '../test/generated-wrappers/lib_address'; +export * from '../test/generated-wrappers/lib_address_array'; +export * from '../test/generated-wrappers/lib_address_array_rich_errors'; +export * from '../test/generated-wrappers/lib_authorizable_rich_errors'; +export * from '../test/generated-wrappers/lib_bytes'; +export * from '../test/generated-wrappers/lib_bytes_rich_errors'; +export * from '../test/generated-wrappers/lib_e_i_p1271'; +export * from '../test/generated-wrappers/lib_e_i_p712'; +export * from '../test/generated-wrappers/lib_fractions'; +export * from '../test/generated-wrappers/lib_ownable_rich_errors'; +export * from '../test/generated-wrappers/lib_reentrancy_guard_rich_errors'; +export * from '../test/generated-wrappers/lib_rich_errors'; +export * from '../test/generated-wrappers/lib_safe_math'; +export * from '../test/generated-wrappers/lib_safe_math_rich_errors'; +export * from '../test/generated-wrappers/ownable'; +export * from '../test/generated-wrappers/reentrancy_guard'; +export * from '../test/generated-wrappers/refundable'; +export * from '../test/generated-wrappers/test_lib_address'; +export * from '../test/generated-wrappers/test_lib_address_array'; +export * from '../test/generated-wrappers/test_lib_bytes'; +export * from '../test/generated-wrappers/test_lib_e_i_p712'; +export * from '../test/generated-wrappers/test_lib_rich_errors'; +export * from '../test/generated-wrappers/test_lib_safe_math'; +export * from '../test/generated-wrappers/test_log_decoding'; +export * from '../test/generated-wrappers/test_log_decoding_downstream'; +export * from '../test/generated-wrappers/test_ownable'; +export * from '../test/generated-wrappers/test_reentrancy_guard'; +export * from '../test/generated-wrappers/test_refundable'; +export * from '../test/generated-wrappers/test_refundable_receiver'; diff --git a/contracts/utils/tsconfig.json b/contracts/utils/tsconfig.json index 58803aad69..393c332fdf 100644 --- a/contracts/utils/tsconfig.json +++ b/contracts/utils/tsconfig.json @@ -34,7 +34,39 @@ "generated-artifacts/TestOwnable.json", "generated-artifacts/TestReentrancyGuard.json", "generated-artifacts/TestRefundable.json", - "generated-artifacts/TestRefundableReceiver.json" + "generated-artifacts/TestRefundableReceiver.json", + "test/generated-artifacts/Authorizable.json", + "test/generated-artifacts/IAuthorizable.json", + "test/generated-artifacts/IOwnable.json", + "test/generated-artifacts/LibAddress.json", + "test/generated-artifacts/LibAddressArray.json", + "test/generated-artifacts/LibAddressArrayRichErrors.json", + "test/generated-artifacts/LibAuthorizableRichErrors.json", + "test/generated-artifacts/LibBytes.json", + "test/generated-artifacts/LibBytesRichErrors.json", + "test/generated-artifacts/LibEIP1271.json", + "test/generated-artifacts/LibEIP712.json", + "test/generated-artifacts/LibFractions.json", + "test/generated-artifacts/LibOwnableRichErrors.json", + "test/generated-artifacts/LibReentrancyGuardRichErrors.json", + "test/generated-artifacts/LibRichErrors.json", + "test/generated-artifacts/LibSafeMath.json", + "test/generated-artifacts/LibSafeMathRichErrors.json", + "test/generated-artifacts/Ownable.json", + "test/generated-artifacts/ReentrancyGuard.json", + "test/generated-artifacts/Refundable.json", + "test/generated-artifacts/TestLibAddress.json", + "test/generated-artifacts/TestLibAddressArray.json", + "test/generated-artifacts/TestLibBytes.json", + "test/generated-artifacts/TestLibEIP712.json", + "test/generated-artifacts/TestLibRichErrors.json", + "test/generated-artifacts/TestLibSafeMath.json", + "test/generated-artifacts/TestLogDecoding.json", + "test/generated-artifacts/TestLogDecodingDownstream.json", + "test/generated-artifacts/TestOwnable.json", + "test/generated-artifacts/TestReentrancyGuard.json", + "test/generated-artifacts/TestRefundable.json", + "test/generated-artifacts/TestRefundableReceiver.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/packages/contracts-gen/package.json b/packages/contracts-gen/package.json index 08adf4df11..68a5e927fe 100644 --- a/packages/contracts-gen/package.json +++ b/packages/contracts-gen/package.json @@ -35,7 +35,8 @@ "ethereum-types": "^2.2.0-beta.1", "lodash": "^4.17.11", "prettier": "^1.16.3", - "to-snake-case": "^1.0.0" + "to-snake-case": "^1.0.0", + "mkdirp": "^0.5.1" }, "devDependencies": { "@0x/tslint-config": "^3.1.0-beta.1", @@ -43,7 +44,8 @@ "@types/prettier": "^1.15.2", "shx": "^0.2.2", "tslint": "5.11.0", - "typescript": "3.0.1" + "typescript": "3.0.1", + "@types/mkdirp": "^0.5.2" }, "publishConfig": { "access": "public" diff --git a/packages/contracts-gen/src/contracts-gen.ts b/packages/contracts-gen/src/contracts-gen.ts index 7cf87ff428..fc1da302f4 100644 --- a/packages/contracts-gen/src/contracts-gen.ts +++ b/packages/contracts-gen/src/contracts-gen.ts @@ -7,6 +7,7 @@ import { logUtils } from '@0x/utils'; import { CompilerOptions } from 'ethereum-types'; import * as fs from 'fs'; import * as _ from 'lodash'; +import * as mkdirp from 'mkdirp'; import * as path from 'path'; import * as prettier from 'prettier'; import toSnakeCase = require('to-snake-case'); @@ -26,40 +27,102 @@ const AUTO_GENERATED_BANNER = `/* */`; const AUTO_GENERATED_BANNER_FOR_LISTS = `This list is auto-generated by contracts-gen. Don't edit manually.`; const ALL_CONTRACTS_IDENTIFIER = '*'; +const GENERATE = 'generate'; +const COPY = 'copy'; (async () => { - const packageDir = process.cwd(); + const command = process.argv.pop(); + if (command !== GENERATE && command !== COPY) { + throw new Error(`Unknown command found: ${command}`); + } + const compilerJSON = readJSONFile('compiler.json'); const compiler = new Compiler(compilerJSON); const testContracts = compiler.getContractNamesToCompile(); if (!_.isArray(testContracts)) { throw new Error('Unable to run the generator bacause contracts key in compiler.json is not of type array'); } - const packageJSON = readJSONFile('package.json'); let srcContracts = testContracts; - if (packageJSON.config !== undefined && packageJSON.config !== undefined) { - srcContracts = (packageJSON.config as any).whitelistedContracts.split(','); + const packageJSON = readJSONFile('package.json'); + if (packageJSON.config !== undefined && (packageJSON.config as any).publicInterfaceContracts !== undefined) { + srcContracts = (packageJSON.config as any).publicInterfaceContracts.split(','); + } + if (!_.isArray(testContracts)) { + throw new Error('Unable to run the generator bacause contracts key in compiler.json is not of type array'); } - const testContractsDir = compilerJSON.contractsDir || DEFAULT_CONTRACTS_DIR; const testArtifactsDir = compilerJSON.artifactsDir || DEFAULT_ARTIFACTS_DIR; - const testWrappersDir = DEFAULT_WRAPPERS_DIR; - const prettierConfig = await prettier.resolveConfig(packageDir); - generateCompilerJSONContractsList(testContracts, testContractsDir, prettierConfig); - generateArtifactsTs(testContracts, testArtifactsDir, TEST_ARTIFACTS_TS_FILE_PATH, prettierConfig); const srcArtifactsDir = convertToTopLevelDir('testArtifactsDir', testArtifactsDir); - generateArtifactsTs(srcContracts, srcArtifactsDir, SRC_ARTIFACTS_TS_FILE_PATH, prettierConfig); + const testWrappersDir = DEFAULT_WRAPPERS_DIR; const srcWrappersDir = convertToTopLevelDir('testWrappersDir', testWrappersDir); - generateWrappersTs(testContracts, testWrappersDir, TEST_WRAPPERS_TS_FILE_PATH, prettierConfig); - generateWrappersTs(srcContracts, srcWrappersDir, SRC_WRAPPERS_TS_FILE_PATH, prettierConfig); - generateTsConfigJSONFilesList(testContracts, testArtifactsDir, srcContracts, srcArtifactsDir, prettierConfig); - generatePackageJSONABIConfig(testContracts, 'test-abis', testArtifactsDir, prettierConfig); - generatePackageJSONABIConfig(srcContracts, 'src-abis', srcArtifactsDir, prettierConfig); + if (command === GENERATE) { + await regenerateContractPackageAsync( + testContracts, + srcContracts, + testArtifactsDir, + srcArtifactsDir, + testWrappersDir, + srcWrappersDir, + ); + } else if (command === COPY) { + copyOverTestArtifactsAndWrappersToSrc( + srcContracts, + testArtifactsDir, + srcArtifactsDir, + testWrappersDir, + srcWrappersDir, + ); + } process.exit(0); })().catch(err => { logUtils.log(err); process.exit(1); }); +function copyOverTestArtifactsAndWrappersToSrc( + srcContracts: string[], + testArtifactsDir: string, + srcArtifactsDir: string, + testWrappersDir: string, + srcWrappersDir: string, +): void { + // Copy over artifacts + srcContracts.forEach(contract => { + const srcPath = `${srcArtifactsDir}/${contract}.json`; + mkdirp.sync(srcArtifactsDir); + fs.copyFileSync(`${testArtifactsDir}/${contract}.json`, srcPath); + }); + + // Copy over wrappers + srcContracts.forEach(contract => { + const wrapperFileName = makeOutputFileName(contract); + const srcPath = `${srcWrappersDir}/${wrapperFileName}.ts`; + mkdirp.sync(srcWrappersDir); + fs.copyFileSync(`${testWrappersDir}/${wrapperFileName}.ts`, srcPath); + }); +} + +async function regenerateContractPackageAsync( + testContracts: string[], + srcContracts: string[], + testArtifactsDir: string, + srcArtifactsDir: string, + testWrappersDir: string, + srcWrappersDir: string, +): Promise { + const compilerJSON = readJSONFile('compiler.json'); + + const packageDir = process.cwd(); + const testContractsDir = compilerJSON.contractsDir || DEFAULT_CONTRACTS_DIR; + const prettierConfig = await prettier.resolveConfig(packageDir); + generateCompilerJSONContractsList(testContracts, testContractsDir, prettierConfig); + generateArtifactsTs(testContracts, testArtifactsDir, TEST_ARTIFACTS_TS_FILE_PATH, prettierConfig); + generateArtifactsTs(srcContracts, srcArtifactsDir, SRC_ARTIFACTS_TS_FILE_PATH, prettierConfig); + generateWrappersTs(testContracts, testWrappersDir, TEST_WRAPPERS_TS_FILE_PATH, prettierConfig); + generateWrappersTs(srcContracts, srcWrappersDir, SRC_WRAPPERS_TS_FILE_PATH, prettierConfig); + generateTsConfigJSONFilesList(testContracts, testArtifactsDir, srcContracts, srcArtifactsDir, prettierConfig); + generatePackageJSONABIConfig(testContracts, 'abis', testArtifactsDir, prettierConfig); +} + function convertToTopLevelDir(name: string, aPath: string): string { let finalPath = aPath; const hasDotPrefix = aPath.startsWith('./'); @@ -104,7 +167,12 @@ function generateCompilerJSONContractsList( fs.writeFileSync(COMPILER_JSON_FILE_PATH, formattedCompilerJSON); } -function generateArtifactsTs(contracts: string[], artifactsDir: string, artifactsTsFilePath: string, prettierConfig: prettier.Options | null): void { +function generateArtifactsTs( + contracts: string[], + artifactsDir: string, + artifactsTsFilePath: string, + prettierConfig: prettier.Options | null, +): void { const imports = _.map(contracts, contract => { const contractName = path.basename(contract, SOLIDITY_EXTENSION); const importPath = path.join('..', artifactsDir, `${contractName}.json`); @@ -129,10 +197,16 @@ function generateArtifactsTs(contracts: string[], artifactsDir: string, artifact export const artifacts = {${artifacts.join('\n')}}; `; const formattedArtifactsTs = prettier.format(artifactsTs, { ...prettierConfig, filepath: artifactsTsFilePath }); + mkdirp.sync(artifactsTsFilePath); fs.writeFileSync(artifactsTsFilePath, formattedArtifactsTs); } -function generateWrappersTs(contracts: string[], wrappersDir: string, wrappersTsFilePath: string, prettierConfig: prettier.Options | null): void { +function generateWrappersTs( + contracts: string[], + wrappersDir: string, + wrappersTsFilePath: string, + prettierConfig: prettier.Options | null, +): void { const imports = _.map(contracts, contract => { const contractName = path.basename(contract, SOLIDITY_EXTENSION); const outputFileName = makeOutputFileName(contractName); @@ -145,6 +219,7 @@ function generateWrappersTs(contracts: string[], wrappersDir: string, wrappersTs ${sortedImports.join('\n')} `; const formattedArtifactsTs = prettier.format(wrappersTs, { ...prettierConfig, filepath: wrappersTsFilePath }); + mkdirp.sync(wrappersTsFilePath); fs.writeFileSync(wrappersTsFilePath, formattedArtifactsTs); }