diff --git a/.gitignore b/.gitignore index a2c59d30b4..efa2b704d0 100644 --- a/.gitignore +++ b/.gitignore @@ -80,19 +80,33 @@ TODO.md # generated contract artifacts/ contracts/integrations/generated-artifacts/ +contracts/integrations/test/generated-artifacts/ contracts/staking/generated-artifacts/ +contracts/staking/test/generated-artifacts/ contracts/coordinator/generated-artifacts/ +contracts/coordinator/test/generated-artifacts/ contracts/exchange/generated-artifacts/ +contracts/exchange/test/generated-artifacts/ contracts/asset-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-libs/test/generated-artifacts/ contracts/erc20/generated-artifacts/ +contracts/erc20/test/generated-artifacts/ contracts/erc721/generated-artifacts/ +contracts/erc721/test/generated-artifacts/ contracts/erc1155/generated-artifacts/ +contracts/erc1155/test/generated-artifacts/ contracts/extensions/generated-artifacts/ +contracts/extensions/test/generated-artifacts/ contracts/exchange-forwarder/generated-artifacts/ +contracts/exchange-forwarder/test/generated-artifacts/ contracts/dev-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/ @@ -114,19 +128,33 @@ contracts/dev-utils/build/ # generated contract wrappers packages/python-contract-wrappers/generated/ contracts/integrations/generated-wrappers/ +contracts/integrations/test/generated-wrappers/ contracts/staking/generated-wrappers/ +contracts/staking/test/generated-wrappers/ contracts/coordinator/generated-wrappers/ +contracts/coordinator/test/generated-wrappers/ contracts/exchange/generated-wrappers/ +contracts/exchange/test/generated-wrappers/ contracts/asset-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-libs/test/generated-wrappers/ contracts/erc20/generated-wrappers/ +contracts/erc20/test/generated-wrappers/ contracts/erc721/generated-wrappers/ +contracts/erc721/test/generated-wrappers/ contracts/erc1155/generated-wrappers/ +contracts/erc1155/test/generated-wrappers/ contracts/extensions/generated-wrappers/ +contracts/extensions/test/generated-wrappers/ contracts/exchange-forwarder/generated-wrappers/ +contracts/exchange-forwarder/test/generated-wrappers/ contracts/dev-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/.prettierignore b/.prettierignore index ff3bf6e8c7..1435fa7dd3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,33 +1,61 @@ lib .nyc_output /contracts/integrations/generated-wrappers +/contracts/integrations/test/generated-wrappers /contracts/integrations/generated-artifacts +/contracts/integrations/test/generated-artifacts /contracts/staking/generated-wrappers +/contracts/staking/test/generated-wrappers /contracts/staking/generated-artifacts +/contracts/staking/test/generated-artifacts /contracts/coordinator/generated-wrappers +/contracts/coordinator/test/generated-wrappers /contracts/coordinator/generated-artifacts +/contracts/coordinator/test/generated-artifacts /contracts/exchange/generated-wrappers +/contracts/exchange/test/generated-wrappers /contracts/exchange/generated-artifacts +/contracts/exchange/test/generated-artifacts /contracts/asset-proxy/generated-wrappers +/contracts/asset-proxy/test/generated-wrappers /contracts/asset-proxy/generated-artifacts +/contracts/asset-proxy/test/generated-artifacts /contracts/multisig/generated-wrappers +/contracts/multisig/test/generated-wrappers /contracts/multisig/generated-artifacts +/contracts/multisig/test/generated-artifacts /contracts/utils/generated-wrappers +/contracts/utils/test/generated-wrappers /contracts/utils/generated-artifacts +/contracts/utils/test/generated-artifacts /contracts/exchange-libs/generated-wrappers +/contracts/exchange-libs/test/generated-wrappers /contracts/exchange-libs/generated-artifacts +/contracts/exchange-libs/test/generated-artifacts /contracts/erc20/generated-wrappers +/contracts/erc20/test/generated-wrappers /contracts/erc20/generated-artifacts +/contracts/erc20/test/generated-artifacts /contracts/erc721/generated-wrappers +/contracts/erc721/test/generated-wrappers /contracts/erc721/generated-artifacts +/contracts/erc721/test/generated-artifacts /contracts/erc1155/generated-wrappers +/contracts/erc1155/test/generated-wrappers /contracts/erc1155/generated-artifacts +/contracts/erc1155/test/generated-artifacts /contracts/extensions/generated-wrappers +/contracts/extensions/test/generated-wrappers /contracts/extensions/generated-artifacts +/contracts/extensions/test/generated-artifacts /contracts/exchange-forwarder/generated-wrappers +/contracts/exchange-forwarder/test/generated-wrappers /contracts/exchange-forwarder/generated-artifacts +/contracts/exchange-forwarder/test/generated-artifacts /contracts/dev-utils/generated-wrappers +/contracts/dev-utils/test/generated-wrappers /contracts/dev-utils/generated-artifacts +/contracts/dev-utils/test/generated-artifacts /contracts/staking/build/ /contracts/coordinator/build/ /contracts/exchange/build/ diff --git a/.prettierrc b/.prettierrc index 58a17fac22..335d6f4ec4 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { - "tabWidth": 4, "printWidth": 120, - "trailingComma": all, - "singleQuote": true + "tabWidth": 4, + "singleQuote": true, + "trailingComma": "all" } diff --git a/contracts/asset-proxy/.npmignore b/contracts/asset-proxy/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/asset-proxy/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/asset-proxy/CHANGELOG.json b/contracts/asset-proxy/CHANGELOG.json index 7a4dc7481a..83585535c9 100644 --- a/contracts/asset-proxy/CHANGELOG.json +++ b/contracts/asset-proxy/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.3.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "2.3.0-beta.1", "changes": [ 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..ecea28dd80 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,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": "./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", + "publicInterfaceContracts": "ERC1155Proxy,ERC20Proxy,ERC721Proxy,MultiAssetProxy,StaticCallProxy,ERC20BridgeProxy,Eth2DaiBridge,IAssetData,IAssetProxy,UniswapBridge,TestStaticCallTarget", + "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": { @@ -51,9 +53,11 @@ "@0x/abi-gen": "^4.4.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/types": "^2.5.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -61,6 +65,7 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "ethereumjs-util": "^5.1.1", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -76,14 +81,11 @@ "@0x/contracts-erc1155": "^1.2.0-beta.1", "@0x/contracts-erc20": "^2.3.0-beta.1", "@0x/contracts-erc721": "^2.2.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", "@0x/order-utils": "^8.5.0-beta.1", - "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", "@0x/web3-wrapper": "^6.1.0-beta.1", "ethereum-types": "^2.2.0-beta.1", - "ethereumjs-util": "^5.1.1", "lodash": "^4.17.11" }, "publishConfig": { diff --git a/contracts/asset-proxy/src/artifacts.ts b/contracts/asset-proxy/src/artifacts.ts index ebe46f9d40..1dd886dedf 100644 --- a/contracts/asset-proxy/src/artifacts.ts +++ b/contracts/asset-proxy/src/artifacts.ts @@ -12,44 +12,20 @@ import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json'; import * as Eth2DaiBridge from '../generated-artifacts/Eth2DaiBridge.json'; import * as IAssetData from '../generated-artifacts/IAssetData.json'; import * as IAssetProxy from '../generated-artifacts/IAssetProxy.json'; -import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispatcher.json'; -import * as IAuthorizable from '../generated-artifacts/IAuthorizable.json'; -import * as IERC20Bridge from '../generated-artifacts/IERC20Bridge.json'; -import * as IEth2Dai from '../generated-artifacts/IEth2Dai.json'; -import * as IUniswapExchange from '../generated-artifacts/IUniswapExchange.json'; -import * as IUniswapExchangeFactory from '../generated-artifacts/IUniswapExchangeFactory.json'; -import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json'; -import * as MixinAuthorizable from '../generated-artifacts/MixinAuthorizable.json'; import * as MultiAssetProxy from '../generated-artifacts/MultiAssetProxy.json'; -import * as Ownable from '../generated-artifacts/Ownable.json'; import * as StaticCallProxy from '../generated-artifacts/StaticCallProxy.json'; -import * as TestERC20Bridge from '../generated-artifacts/TestERC20Bridge.json'; -import * as TestEth2DaiBridge from '../generated-artifacts/TestEth2DaiBridge.json'; import * as TestStaticCallTarget from '../generated-artifacts/TestStaticCallTarget.json'; -import * as TestUniswapBridge from '../generated-artifacts/TestUniswapBridge.json'; import * as UniswapBridge from '../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, + ERC20BridgeProxy: ERC20BridgeProxy 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, + UniswapBridge: UniswapBridge as ContractArtifact, TestStaticCallTarget: TestStaticCallTarget as ContractArtifact, - TestUniswapBridge: TestUniswapBridge as ContractArtifact, }; diff --git a/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts b/contracts/asset-proxy/src/erc1155_proxy_wrapper.ts similarity index 99% rename from contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts rename to contracts/asset-proxy/src/erc1155_proxy_wrapper.ts index 5bc707af41..fe68af2cfb 100644 --- a/contracts/asset-proxy/test/utils/erc1155_proxy_wrapper.ts +++ b/contracts/asset-proxy/src/erc1155_proxy_wrapper.ts @@ -13,7 +13,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ERC1155ProxyContract, IAssetProxyContract } from '../../src'; +import { artifacts } from './artifacts'; + +import { ERC1155ProxyContract, IAssetProxyContract } from './wrappers'; export class ERC1155ProxyWrapper { private readonly _tokenOwnerAddresses: string[]; diff --git a/contracts/asset-proxy/test/utils/erc20_wrapper.ts b/contracts/asset-proxy/src/erc20_wrapper.ts similarity index 98% rename from contracts/asset-proxy/test/utils/erc20_wrapper.ts rename to contracts/asset-proxy/src/erc20_wrapper.ts index 52e8d43142..c928375a92 100644 --- a/contracts/asset-proxy/test/utils/erc20_wrapper.ts +++ b/contracts/asset-proxy/src/erc20_wrapper.ts @@ -5,7 +5,9 @@ import { BigNumber } from '@0x/utils'; import { ZeroExProvider } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ERC20ProxyContract } from '../../src'; +import { artifacts } from './artifacts'; + +import { ERC20ProxyContract } from './wrappers'; export class ERC20Wrapper { private readonly _tokenOwnerAddresses: string[]; diff --git a/contracts/asset-proxy/test/utils/erc721_wrapper.ts b/contracts/asset-proxy/src/erc721_wrapper.ts similarity index 99% rename from contracts/asset-proxy/test/utils/erc721_wrapper.ts rename to contracts/asset-proxy/src/erc721_wrapper.ts index e2ae988930..cbee407178 100644 --- a/contracts/asset-proxy/test/utils/erc721_wrapper.ts +++ b/contracts/asset-proxy/src/erc721_wrapper.ts @@ -5,7 +5,9 @@ import { BigNumber } from '@0x/utils'; import { ZeroExProvider } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ERC721ProxyContract } from '../../src'; +import { artifacts } from './artifacts'; + +import { ERC721ProxyContract } from './wrappers'; export class ERC721Wrapper { private readonly _tokenOwnerAddresses: string[]; diff --git a/contracts/asset-proxy/src/index.ts b/contracts/asset-proxy/src/index.ts index ba813e7caf..c09b5adde2 100644 --- a/contracts/asset-proxy/src/index.ts +++ b/contracts/asset-proxy/src/index.ts @@ -1,3 +1,6 @@ export * from './artifacts'; export * from './wrappers'; -export * from '../test/utils'; + +export { ERC20Wrapper } from './erc20_wrapper'; +export { ERC721Wrapper } from './erc721_wrapper'; +export { ERC1155ProxyWrapper } from './erc1155_proxy_wrapper'; diff --git a/contracts/asset-proxy/src/wrappers.ts b/contracts/asset-proxy/src/wrappers.ts index a39cbd282b..0fa37a911c 100644 --- a/contracts/asset-proxy/src/wrappers.ts +++ b/contracts/asset-proxy/src/wrappers.ts @@ -10,19 +10,7 @@ export * from '../generated-wrappers/erc721_proxy'; export * from '../generated-wrappers/eth2_dai_bridge'; export * from '../generated-wrappers/i_asset_data'; export * from '../generated-wrappers/i_asset_proxy'; -export * from '../generated-wrappers/i_asset_proxy_dispatcher'; -export * from '../generated-wrappers/i_authorizable'; -export * from '../generated-wrappers/i_erc20_bridge'; -export * from '../generated-wrappers/i_eth2_dai'; -export * from '../generated-wrappers/i_uniswap_exchange'; -export * from '../generated-wrappers/i_uniswap_exchange_factory'; -export * from '../generated-wrappers/mixin_asset_proxy_dispatcher'; -export * from '../generated-wrappers/mixin_authorizable'; export * from '../generated-wrappers/multi_asset_proxy'; -export * from '../generated-wrappers/ownable'; export * from '../generated-wrappers/static_call_proxy'; -export * from '../generated-wrappers/test_erc20_bridge'; -export * from '../generated-wrappers/test_eth2_dai_bridge'; export * from '../generated-wrappers/test_static_call_target'; -export * from '../generated-wrappers/test_uniswap_bridge'; export * from '../generated-wrappers/uniswap_bridge'; 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/authorizable.ts b/contracts/asset-proxy/test/authorizable.ts index 4a7794734c..1685c609f9 100644 --- a/contracts/asset-proxy/test/authorizable.ts +++ b/contracts/asset-proxy/test/authorizable.ts @@ -5,7 +5,9 @@ import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, MixinAuthorizableContract } from '../src'; +import { artifacts } from './artifacts'; + +import { MixinAuthorizableContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/asset-proxy/test/erc1155_proxy.ts b/contracts/asset-proxy/test/erc1155_proxy.ts index 82c410a184..4f26770972 100644 --- a/contracts/asset-proxy/test/erc1155_proxy.ts +++ b/contracts/asset-proxy/test/erc1155_proxy.ts @@ -23,7 +23,10 @@ import { LogWithDecodedArgs } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; -import { artifacts, ERC1155ProxyContract, ERC1155ProxyWrapper, IAssetDataContract } from '../src'; +import { ERC1155ProxyWrapper } from '../src/erc1155_proxy_wrapper'; +import { ERC1155ProxyContract, IAssetDataContract } from '../src/wrappers'; + +import { artifacts } from './artifacts'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/asset-proxy/test/erc20bridge_proxy.ts b/contracts/asset-proxy/test/erc20bridge_proxy.ts index 28d0cc8684..b10b74cb4f 100644 --- a/contracts/asset-proxy/test/erc20bridge_proxy.ts +++ b/contracts/asset-proxy/test/erc20bridge_proxy.ts @@ -14,7 +14,9 @@ import { AbiEncoder, AuthorizableRevertErrors, BigNumber, StringRevertError } fr import { DecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ERC20BridgeProxyContract, TestERC20BridgeContract } from '../src'; +import { artifacts } from './artifacts'; + +import { ERC20BridgeProxyContract, TestERC20BridgeContract } from './wrappers'; blockchainTests.resets('ERC20BridgeProxy unit tests', env => { const PROXY_ID = AssetProxyId.ERC20Bridge; diff --git a/contracts/asset-proxy/test/eth2dai_bridge.ts b/contracts/asset-proxy/test/eth2dai_bridge.ts index 2cf0173239..b368c8d4ad 100644 --- a/contracts/asset-proxy/test/eth2dai_bridge.ts +++ b/contracts/asset-proxy/test/eth2dai_bridge.ts @@ -15,14 +15,15 @@ import { BigNumber, RawRevertError } from '@0x/utils'; import { DecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; + import { - artifacts, TestEth2DaiBridgeContract, TestEth2DaiBridgeEvents, TestEth2DaiBridgeSellAllAmountEventArgs, TestEth2DaiBridgeTokenApproveEventArgs, TestEth2DaiBridgeTokenTransferEventArgs, -} from '../src'; +} from './wrappers'; blockchainTests.resets('Eth2DaiBridge unit tests', env => { const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); diff --git a/contracts/asset-proxy/test/proxies.ts b/contracts/asset-proxy/test/proxies.ts index 232b085086..5f48bda4dd 100644 --- a/contracts/asset-proxy/test/proxies.ts +++ b/contracts/asset-proxy/test/proxies.ts @@ -29,18 +29,13 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { - artifacts, - ERC1155ProxyContract, - ERC1155ProxyWrapper, - ERC20ProxyContract, - ERC20Wrapper, - ERC721ProxyContract, - ERC721Wrapper, - IAssetDataContract, - IAssetProxyContract, - MultiAssetProxyContract, -} from '../src'; +import { ERC1155ProxyWrapper } from '../src/erc1155_proxy_wrapper'; +import { ERC20Wrapper } from '../src/erc20_wrapper'; +import { ERC721Wrapper } from '../src/erc721_wrapper'; +import { ERC1155ProxyContract, ERC20ProxyContract, ERC721ProxyContract } from '../src/wrappers'; + +import { artifacts } from './artifacts'; +import { IAssetDataContract, IAssetProxyContract, MultiAssetProxyContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/asset-proxy/test/static_call_proxy.ts b/contracts/asset-proxy/test/static_call_proxy.ts index 743cc476a3..8fcbc57e25 100644 --- a/contracts/asset-proxy/test/static_call_proxy.ts +++ b/contracts/asset-proxy/test/static_call_proxy.ts @@ -14,7 +14,9 @@ import { AbiEncoder, BigNumber } from '@0x/utils'; import * as chai from 'chai'; import * as ethUtil from 'ethereumjs-util'; -import { artifacts, IAssetProxyContract, StaticCallProxyContract, TestStaticCallTargetContract } from '../src'; +import { artifacts } from './artifacts'; + +import { IAssetProxyContract, StaticCallProxyContract, TestStaticCallTargetContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/asset-proxy/test/uniswap_bridge.ts b/contracts/asset-proxy/test/uniswap_bridge.ts index 2f7f6a0290..66815b421e 100644 --- a/contracts/asset-proxy/test/uniswap_bridge.ts +++ b/contracts/asset-proxy/test/uniswap_bridge.ts @@ -16,8 +16,9 @@ import { BigNumber } from '@0x/utils'; import { DecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; + import { - artifacts, TestUniswapBridgeContract, TestUniswapBridgeEthToTokenTransferInputEventArgs as EthToTokenTransferInputArgs, TestUniswapBridgeEvents as ContractEvents, @@ -27,7 +28,7 @@ import { TestUniswapBridgeTokenTransferEventArgs as TokenTransferArgs, TestUniswapBridgeWethDepositEventArgs as WethDepositArgs, TestUniswapBridgeWethWithdrawEventArgs as WethWithdrawArgs, -} from '../src'; +} from './wrappers'; blockchainTests.resets('UniswapBridge unit tests', env => { const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); diff --git a/contracts/asset-proxy/test/utils/index.ts b/contracts/asset-proxy/test/utils/index.ts deleted file mode 100644 index 897806e703..0000000000 --- a/contracts/asset-proxy/test/utils/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './erc20_wrapper'; -export * from './erc721_wrapper'; -export * from './erc1155_proxy_wrapper'; 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..f96ede121d 100644 --- a/contracts/asset-proxy/tsconfig.json +++ b/contracts/asset-proxy/tsconfig.json @@ -10,22 +10,33 @@ "generated-artifacts/Eth2DaiBridge.json", "generated-artifacts/IAssetData.json", "generated-artifacts/IAssetProxy.json", - "generated-artifacts/IAssetProxyDispatcher.json", - "generated-artifacts/IAuthorizable.json", - "generated-artifacts/IERC20Bridge.json", - "generated-artifacts/IEth2Dai.json", - "generated-artifacts/IUniswapExchange.json", - "generated-artifacts/IUniswapExchangeFactory.json", - "generated-artifacts/MixinAssetProxyDispatcher.json", - "generated-artifacts/MixinAuthorizable.json", "generated-artifacts/MultiAssetProxy.json", - "generated-artifacts/Ownable.json", "generated-artifacts/StaticCallProxy.json", - "generated-artifacts/TestERC20Bridge.json", - "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/.npmignore b/contracts/coordinator/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/coordinator/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/coordinator/CHANGELOG.json b/contracts/coordinator/CHANGELOG.json index d498f1d6ba..af648d5ff6 100644 --- a/contracts/coordinator/CHANGELOG.json +++ b/contracts/coordinator/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.1.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "2.1.0-beta.1", "changes": [ 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..16436de2d5 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,21 +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": "./generated-artifacts/@(Coordinator|CoordinatorRegistry|ICoordinatorApprovalVerifier|ICoordinatorCore|ICoordinatorRegistryCore|ICoordinatorSignatureValidator|LibConstants|LibCoordinatorApproval|LibCoordinatorRichErrors|LibEIP712CoordinatorDomain|MixinCoordinatorApprovalVerifier|MixinCoordinatorCore|MixinCoordinatorRegistryCore|MixinSignatureValidator).json", + "publicInterfaceContracts": "Coordinator,CoordinatorRegistry,LibCoordinatorApproval,LibCoordinatorRichErrors,LibEIP712CoordinatorDomain,LibConstants", + "abis": "./test/generated-artifacts/@(Coordinator|CoordinatorRegistry|ICoordinatorApprovalVerifier|ICoordinatorCore|ICoordinatorRegistryCore|ICoordinatorSignatureValidator|LibConstants|LibCoordinatorApproval|LibCoordinatorRichErrors|LibEIP712CoordinatorDomain|MixinCoordinatorApprovalVerifier|MixinCoordinatorCore|MixinCoordinatorRegistryCore|MixinSignatureValidator).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { @@ -59,6 +61,7 @@ "@0x/order-utils": "^8.5.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -81,9 +84,7 @@ "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "ethereumjs-util": "^5.1.1" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/coordinator/test/utils/approval_factory.ts b/contracts/coordinator/src/approval_factory.ts similarity index 91% rename from contracts/coordinator/test/utils/approval_factory.ts rename to contracts/coordinator/src/approval_factory.ts index 2ee069de03..97c2ae999a 100644 --- a/contracts/coordinator/test/utils/approval_factory.ts +++ b/contracts/coordinator/src/approval_factory.ts @@ -1,7 +1,8 @@ import { hexConcat, signingUtils } from '@0x/contracts-test-utils'; import { SignatureType, SignedZeroExTransaction } from '@0x/types'; -import { hashUtils, SignedCoordinatorApproval } from './index'; +import { hashUtils } from './hash_utils'; +import { SignedCoordinatorApproval } from './types'; export class ApprovalFactory { private readonly _privateKey: Buffer; diff --git a/contracts/coordinator/src/artifacts.ts b/contracts/coordinator/src/artifacts.ts index 9722198ad8..61e478dc39 100644 --- a/contracts/coordinator/src/artifacts.ts +++ b/contracts/coordinator/src/artifacts.ts @@ -7,31 +7,15 @@ import { ContractArtifact } from 'ethereum-types'; import * as Coordinator from '../generated-artifacts/Coordinator.json'; import * as CoordinatorRegistry from '../generated-artifacts/CoordinatorRegistry.json'; -import * as ICoordinatorApprovalVerifier from '../generated-artifacts/ICoordinatorApprovalVerifier.json'; -import * as ICoordinatorCore from '../generated-artifacts/ICoordinatorCore.json'; -import * as ICoordinatorRegistryCore from '../generated-artifacts/ICoordinatorRegistryCore.json'; -import * as ICoordinatorSignatureValidator from '../generated-artifacts/ICoordinatorSignatureValidator.json'; import * as LibConstants from '../generated-artifacts/LibConstants.json'; import * as LibCoordinatorApproval from '../generated-artifacts/LibCoordinatorApproval.json'; import * as LibCoordinatorRichErrors from '../generated-artifacts/LibCoordinatorRichErrors.json'; import * as LibEIP712CoordinatorDomain from '../generated-artifacts/LibEIP712CoordinatorDomain.json'; -import * as MixinCoordinatorApprovalVerifier from '../generated-artifacts/MixinCoordinatorApprovalVerifier.json'; -import * as MixinCoordinatorCore from '../generated-artifacts/MixinCoordinatorCore.json'; -import * as MixinCoordinatorRegistryCore from '../generated-artifacts/MixinCoordinatorRegistryCore.json'; -import * as MixinSignatureValidator from '../generated-artifacts/MixinSignatureValidator.json'; export const artifacts = { Coordinator: Coordinator as ContractArtifact, - MixinCoordinatorApprovalVerifier: MixinCoordinatorApprovalVerifier as ContractArtifact, - MixinCoordinatorCore: MixinCoordinatorCore as ContractArtifact, - MixinSignatureValidator: MixinSignatureValidator as ContractArtifact, - ICoordinatorApprovalVerifier: ICoordinatorApprovalVerifier as ContractArtifact, - ICoordinatorCore: ICoordinatorCore as ContractArtifact, - ICoordinatorSignatureValidator: ICoordinatorSignatureValidator as ContractArtifact, - LibConstants: LibConstants as ContractArtifact, + CoordinatorRegistry: CoordinatorRegistry as ContractArtifact, LibCoordinatorApproval: LibCoordinatorApproval as ContractArtifact, LibCoordinatorRichErrors: LibCoordinatorRichErrors as ContractArtifact, LibEIP712CoordinatorDomain: LibEIP712CoordinatorDomain as ContractArtifact, - CoordinatorRegistry: CoordinatorRegistry as ContractArtifact, - MixinCoordinatorRegistryCore: MixinCoordinatorRegistryCore as ContractArtifact, - ICoordinatorRegistryCore: ICoordinatorRegistryCore as ContractArtifact, + LibConstants: LibConstants as ContractArtifact, }; diff --git a/contracts/coordinator/test/utils/hash_utils.ts b/contracts/coordinator/src/hash_utils.ts similarity index 100% rename from contracts/coordinator/test/utils/hash_utils.ts rename to contracts/coordinator/src/hash_utils.ts diff --git a/contracts/coordinator/src/index.ts b/contracts/coordinator/src/index.ts index ba813e7caf..fc96ee9ddc 100644 --- a/contracts/coordinator/src/index.ts +++ b/contracts/coordinator/src/index.ts @@ -1,3 +1,4 @@ export * from './artifacts'; export * from './wrappers'; -export * from '../test/utils'; +export { ApprovalFactory } from './approval_factory'; +export { SignedCoordinatorApproval } from './types'; diff --git a/contracts/coordinator/test/utils/types.ts b/contracts/coordinator/src/types.ts similarity index 100% rename from contracts/coordinator/test/utils/types.ts rename to contracts/coordinator/src/types.ts diff --git a/contracts/coordinator/src/wrappers.ts b/contracts/coordinator/src/wrappers.ts index 1307b59821..53905d57a5 100644 --- a/contracts/coordinator/src/wrappers.ts +++ b/contracts/coordinator/src/wrappers.ts @@ -5,15 +5,7 @@ */ export * from '../generated-wrappers/coordinator'; export * from '../generated-wrappers/coordinator_registry'; -export * from '../generated-wrappers/i_coordinator_approval_verifier'; -export * from '../generated-wrappers/i_coordinator_core'; -export * from '../generated-wrappers/i_coordinator_registry_core'; -export * from '../generated-wrappers/i_coordinator_signature_validator'; export * from '../generated-wrappers/lib_constants'; export * from '../generated-wrappers/lib_coordinator_approval'; export * from '../generated-wrappers/lib_coordinator_rich_errors'; export * from '../generated-wrappers/lib_e_i_p712_coordinator_domain'; -export * from '../generated-wrappers/mixin_coordinator_approval_verifier'; -export * from '../generated-wrappers/mixin_coordinator_core'; -export * from '../generated-wrappers/mixin_coordinator_registry_core'; -export * from '../generated-wrappers/mixin_signature_validator'; diff --git a/contracts/coordinator/test/artifacts.ts b/contracts/coordinator/test/artifacts.ts new file mode 100644 index 0000000000..d432f86b29 --- /dev/null +++ b/contracts/coordinator/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 Coordinator from '../test/generated-artifacts/Coordinator.json'; +import * as CoordinatorRegistry from '../test/generated-artifacts/CoordinatorRegistry.json'; +import * as ICoordinatorApprovalVerifier from '../test/generated-artifacts/ICoordinatorApprovalVerifier.json'; +import * as ICoordinatorCore from '../test/generated-artifacts/ICoordinatorCore.json'; +import * as ICoordinatorRegistryCore from '../test/generated-artifacts/ICoordinatorRegistryCore.json'; +import * as ICoordinatorSignatureValidator from '../test/generated-artifacts/ICoordinatorSignatureValidator.json'; +import * as LibConstants from '../test/generated-artifacts/LibConstants.json'; +import * as LibCoordinatorApproval from '../test/generated-artifacts/LibCoordinatorApproval.json'; +import * as LibCoordinatorRichErrors from '../test/generated-artifacts/LibCoordinatorRichErrors.json'; +import * as LibEIP712CoordinatorDomain from '../test/generated-artifacts/LibEIP712CoordinatorDomain.json'; +import * as MixinCoordinatorApprovalVerifier from '../test/generated-artifacts/MixinCoordinatorApprovalVerifier.json'; +import * as MixinCoordinatorCore from '../test/generated-artifacts/MixinCoordinatorCore.json'; +import * as MixinCoordinatorRegistryCore from '../test/generated-artifacts/MixinCoordinatorRegistryCore.json'; +import * as MixinSignatureValidator from '../test/generated-artifacts/MixinSignatureValidator.json'; +export const artifacts = { + Coordinator: Coordinator as ContractArtifact, + MixinCoordinatorApprovalVerifier: MixinCoordinatorApprovalVerifier as ContractArtifact, + MixinCoordinatorCore: MixinCoordinatorCore as ContractArtifact, + MixinSignatureValidator: MixinSignatureValidator as ContractArtifact, + ICoordinatorApprovalVerifier: ICoordinatorApprovalVerifier as ContractArtifact, + ICoordinatorCore: ICoordinatorCore as ContractArtifact, + ICoordinatorSignatureValidator: ICoordinatorSignatureValidator as ContractArtifact, + LibConstants: LibConstants as ContractArtifact, + LibCoordinatorApproval: LibCoordinatorApproval as ContractArtifact, + LibCoordinatorRichErrors: LibCoordinatorRichErrors as ContractArtifact, + LibEIP712CoordinatorDomain: LibEIP712CoordinatorDomain as ContractArtifact, + CoordinatorRegistry: CoordinatorRegistry as ContractArtifact, + MixinCoordinatorRegistryCore: MixinCoordinatorRegistryCore as ContractArtifact, + ICoordinatorRegistryCore: ICoordinatorRegistryCore as ContractArtifact, +}; diff --git a/contracts/coordinator/test/coordinator_registry.ts b/contracts/coordinator/test/coordinator_registry.ts index 743132fa7e..4d732c2af5 100644 --- a/contracts/coordinator/test/coordinator_registry.ts +++ b/contracts/coordinator/test/coordinator_registry.ts @@ -1,6 +1,8 @@ import { blockchainTests, expect, verifyEvents } from '@0x/contracts-test-utils'; -import { artifacts, CoordinatorRegistryContract, CoordinatorRegistryCoordinatorEndpointSetEventArgs } from '../src'; +import { artifacts } from './artifacts'; + +import { CoordinatorRegistryContract, CoordinatorRegistryCoordinatorEndpointSetEventArgs } from './wrappers'; // tslint:disable:no-unnecessary-type-assertion blockchainTests.resets('Coordinator Registry tests', env => { diff --git a/contracts/coordinator/test/libs.ts b/contracts/coordinator/test/libs.ts index ef6eb0b2a7..44ca15253d 100644 --- a/contracts/coordinator/test/libs.ts +++ b/contracts/coordinator/test/libs.ts @@ -2,7 +2,11 @@ import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts import { transactionHashUtils } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; -import { artifacts, CoordinatorContract, hashUtils } from '../src'; +import { hashUtils } from '../src/hash_utils'; + +import { artifacts } from './artifacts'; + +import { CoordinatorContract } from './wrappers'; blockchainTests.resets('Libs tests', env => { let coordinatorContract: CoordinatorContract; diff --git a/contracts/coordinator/test/mixins.ts b/contracts/coordinator/test/mixins.ts index 4ee471b797..2534fa676d 100644 --- a/contracts/coordinator/test/mixins.ts +++ b/contracts/coordinator/test/mixins.ts @@ -1,7 +1,8 @@ -import { constants as exchangeConstants, exchangeDataEncoder, ExchangeFunctionName } from '@0x/contracts-exchange'; +import { exchangeDataEncoder } from '@0x/contracts-exchange'; import { blockchainTests, constants, + ExchangeFunctionName, expect, hexConcat, hexSlice, @@ -12,7 +13,11 @@ import { CoordinatorRevertErrors, transactionHashUtils } from '@0x/order-utils'; import { SignatureType, SignedOrder } from '@0x/types'; import { BigNumber, LibBytesRevertErrors } from '@0x/utils'; -import { ApprovalFactory, artifacts, CoordinatorContract } from '../src'; +import { ApprovalFactory } from '../src/approval_factory'; + +import { artifacts } from './artifacts'; + +import { CoordinatorContract } from './wrappers'; blockchainTests.resets('Mixins tests', env => { let chainId: number; @@ -144,7 +149,7 @@ blockchainTests.resets('Mixins tests', env => { }); describe('decodeOrdersFromFillData', () => { - for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { + for (const fnName of constants.SINGLE_FILL_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -158,7 +163,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.BATCH_FILL_FN_NAMES) { + for (const fnName of constants.BATCH_FILL_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -172,7 +177,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.MARKET_FILL_FN_NAMES) { + for (const fnName of constants.MARKET_FILL_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -186,7 +191,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.MATCH_ORDER_FN_NAMES) { + for (const fnName of constants.MATCH_ORDER_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -200,7 +205,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.CANCEL_ORDER_FN_NAMES) { + for (const fnName of constants.CANCEL_ORDER_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -227,7 +232,7 @@ blockchainTests.resets('Mixins tests', env => { }); describe('Single order approvals', () => { - for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { + for (const fnName of constants.SINGLE_FILL_FN_NAMES) { it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[approver1]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -341,9 +346,9 @@ blockchainTests.resets('Mixins tests', env => { }); describe('Batch order approvals', () => { for (const fnName of [ - ...exchangeConstants.BATCH_FILL_FN_NAMES, - ...exchangeConstants.MARKET_FILL_FN_NAMES, - ...exchangeConstants.MATCH_ORDER_FN_NAMES, + ...constants.BATCH_FILL_FN_NAMES, + ...constants.MARKET_FILL_FN_NAMES, + ...constants.MATCH_ORDER_FN_NAMES, ]) { it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { const orders = [defaultOrder, defaultOrder]; diff --git a/contracts/coordinator/test/utils/index.ts b/contracts/coordinator/test/utils/index.ts deleted file mode 100644 index bd5bd79dae..0000000000 --- a/contracts/coordinator/test/utils/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { hashUtils } from './hash_utils'; -export { ApprovalFactory } from './approval_factory'; -export * from './types'; diff --git a/contracts/coordinator/test/wrappers.ts b/contracts/coordinator/test/wrappers.ts new file mode 100644 index 0000000000..cfc1187fb8 --- /dev/null +++ b/contracts/coordinator/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/coordinator'; +export * from '../test/generated-wrappers/coordinator_registry'; +export * from '../test/generated-wrappers/i_coordinator_approval_verifier'; +export * from '../test/generated-wrappers/i_coordinator_core'; +export * from '../test/generated-wrappers/i_coordinator_registry_core'; +export * from '../test/generated-wrappers/i_coordinator_signature_validator'; +export * from '../test/generated-wrappers/lib_constants'; +export * from '../test/generated-wrappers/lib_coordinator_approval'; +export * from '../test/generated-wrappers/lib_coordinator_rich_errors'; +export * from '../test/generated-wrappers/lib_e_i_p712_coordinator_domain'; +export * from '../test/generated-wrappers/mixin_coordinator_approval_verifier'; +export * from '../test/generated-wrappers/mixin_coordinator_core'; +export * from '../test/generated-wrappers/mixin_coordinator_registry_core'; +export * from '../test/generated-wrappers/mixin_signature_validator'; diff --git a/contracts/coordinator/tsconfig.json b/contracts/coordinator/tsconfig.json index 8db06e4dd6..cd6b5d948f 100644 --- a/contracts/coordinator/tsconfig.json +++ b/contracts/coordinator/tsconfig.json @@ -5,18 +5,24 @@ "files": [ "generated-artifacts/Coordinator.json", "generated-artifacts/CoordinatorRegistry.json", - "generated-artifacts/ICoordinatorApprovalVerifier.json", - "generated-artifacts/ICoordinatorCore.json", - "generated-artifacts/ICoordinatorRegistryCore.json", - "generated-artifacts/ICoordinatorSignatureValidator.json", "generated-artifacts/LibConstants.json", "generated-artifacts/LibCoordinatorApproval.json", "generated-artifacts/LibCoordinatorRichErrors.json", "generated-artifacts/LibEIP712CoordinatorDomain.json", - "generated-artifacts/MixinCoordinatorApprovalVerifier.json", - "generated-artifacts/MixinCoordinatorCore.json", - "generated-artifacts/MixinCoordinatorRegistryCore.json", - "generated-artifacts/MixinSignatureValidator.json" + "test/generated-artifacts/Coordinator.json", + "test/generated-artifacts/CoordinatorRegistry.json", + "test/generated-artifacts/ICoordinatorApprovalVerifier.json", + "test/generated-artifacts/ICoordinatorCore.json", + "test/generated-artifacts/ICoordinatorRegistryCore.json", + "test/generated-artifacts/ICoordinatorSignatureValidator.json", + "test/generated-artifacts/LibConstants.json", + "test/generated-artifacts/LibCoordinatorApproval.json", + "test/generated-artifacts/LibCoordinatorRichErrors.json", + "test/generated-artifacts/LibEIP712CoordinatorDomain.json", + "test/generated-artifacts/MixinCoordinatorApprovalVerifier.json", + "test/generated-artifacts/MixinCoordinatorCore.json", + "test/generated-artifacts/MixinCoordinatorRegistryCore.json", + "test/generated-artifacts/MixinSignatureValidator.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/dev-utils/.npmignore b/contracts/dev-utils/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/dev-utils/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/dev-utils/CHANGELOG.json b/contracts/dev-utils/CHANGELOG.json index aedbc80894..28422f6e3f 100644 --- a/contracts/dev-utils/CHANGELOG.json +++ b/contracts/dev-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "0.1.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "0.1.0-beta.1", "changes": [ 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..da8e082cf3 100644 --- a/contracts/dev-utils/package.json +++ b/contracts/dev-utils/package.json @@ -10,20 +10,22 @@ "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", + "publicInterfaceContracts": "DevUtils,LibAssetData,LibTransactionDecoder", + "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": { @@ -37,6 +39,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/contracts/dev-utils/README.md", "devDependencies": { "@0x/abi-gen": "^4.4.0-beta.1", + "@0x/assert": "^2.2.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", @@ -46,18 +49,12 @@ "solhint": "^1.4.1", "truffle": "^5.0.32", "tslint": "5.11.0", - "typescript": "3.0.1" + "typescript": "3.0.1", + "ethers": "~4.0.4" }, "dependencies": { - "@0x/assert": "^2.2.0-beta.1", "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contract-addresses": "^3.3.0-beta.2", - "@0x/json-schemas": "^4.1.0-beta.1", - "@0x/types": "^2.5.0-beta.1", - "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "ethers": "~4.0.4" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/dev-utils/src/artifacts.ts b/contracts/dev-utils/src/artifacts.ts index 6d4be86321..3c2f022c66 100644 --- a/contracts/dev-utils/src/artifacts.ts +++ b/contracts/dev-utils/src/artifacts.ts @@ -6,16 +6,10 @@ import { ContractArtifact } from 'ethereum-types'; import * as DevUtils from '../generated-artifacts/DevUtils.json'; -import * as EthBalanceChecker from '../generated-artifacts/EthBalanceChecker.json'; import * as LibAssetData from '../generated-artifacts/LibAssetData.json'; import * as LibTransactionDecoder from '../generated-artifacts/LibTransactionDecoder.json'; -import * as OrderTransferSimulationUtils from '../generated-artifacts/OrderTransferSimulationUtils.json'; -import * as OrderValidationUtils from '../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/src/wrappers.ts b/contracts/dev-utils/src/wrappers.ts index 1461c60cd0..e07c65436d 100644 --- a/contracts/dev-utils/src/wrappers.ts +++ b/contracts/dev-utils/src/wrappers.ts @@ -6,5 +6,3 @@ export * from '../generated-wrappers/dev_utils'; export * from '../generated-wrappers/lib_asset_data'; export * from '../generated-wrappers/lib_transaction_decoder'; -export * from '../generated-wrappers/order_transfer_simulation_utils'; -export * from '../generated-wrappers/order_validation_utils'; 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..ec5f1f9157 100644 --- a/contracts/dev-utils/tsconfig.json +++ b/contracts/dev-utils/tsconfig.json @@ -4,11 +4,14 @@ "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ "generated-artifacts/DevUtils.json", - "generated-artifacts/EthBalanceChecker.json", "generated-artifacts/LibAssetData.json", "generated-artifacts/LibTransactionDecoder.json", - "generated-artifacts/OrderTransferSimulationUtils.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/.npmignore b/contracts/erc1155/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/erc1155/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/erc1155/CHANGELOG.json b/contracts/erc1155/CHANGELOG.json index 2f95790bb8..4e372b26b8 100644 --- a/contracts/erc1155/CHANGELOG.json +++ b/contracts/erc1155/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "1.2.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "1.2.0-beta.1", "changes": [ 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..ff4b75b746 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,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": "./generated-artifacts/@(DummyERC1155Receiver|ERC1155|ERC1155Mintable|IERC1155|IERC1155Mintable|IERC1155Receiver|MixinNonFungibleToken).json", + "publicInterfaceContracts": "ERC1155,ERC1155Mintable,IERC1155Receiver,DummyERC1155Receiver", + "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": { @@ -53,6 +55,8 @@ "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/types": "^2.5.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -72,8 +76,6 @@ "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", - "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", "@0x/web3-wrapper": "^6.1.0-beta.1", diff --git a/contracts/erc1155/src/artifacts.ts b/contracts/erc1155/src/artifacts.ts index 196fb37ef5..42606f89ca 100644 --- a/contracts/erc1155/src/artifacts.ts +++ b/contracts/erc1155/src/artifacts.ts @@ -8,16 +8,10 @@ import { ContractArtifact } from 'ethereum-types'; import * as DummyERC1155Receiver from '../generated-artifacts/DummyERC1155Receiver.json'; import * as ERC1155 from '../generated-artifacts/ERC1155.json'; import * as ERC1155Mintable from '../generated-artifacts/ERC1155Mintable.json'; -import * as IERC1155 from '../generated-artifacts/IERC1155.json'; -import * as IERC1155Mintable from '../generated-artifacts/IERC1155Mintable.json'; import * as IERC1155Receiver from '../generated-artifacts/IERC1155Receiver.json'; -import * as MixinNonFungibleToken from '../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/utils/erc1155_wrapper.ts b/contracts/erc1155/src/erc1155_wrapper.ts similarity index 98% rename from contracts/erc1155/test/utils/erc1155_wrapper.ts rename to contracts/erc1155/src/erc1155_wrapper.ts index 984935db17..a0c3b21848 100644 --- a/contracts/erc1155/test/utils/erc1155_wrapper.ts +++ b/contracts/erc1155/src/erc1155_wrapper.ts @@ -5,7 +5,9 @@ import * as chai from 'chai'; import { LogWithDecodedArgs, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ERC1155MintableContract, ERC1155TransferSingleEventArgs } from '../../src'; +import { ERC1155MintableContract, ERC1155TransferSingleEventArgs } from './wrappers'; + +import { artifacts } from './artifacts'; const expect = chai.expect; diff --git a/contracts/erc1155/src/index.ts b/contracts/erc1155/src/index.ts index 334373edbd..9b5503a9b4 100644 --- a/contracts/erc1155/src/index.ts +++ b/contracts/erc1155/src/index.ts @@ -1,3 +1,3 @@ export * from './wrappers'; export * from './artifacts'; -export { Erc1155Wrapper } from '../test/utils/erc1155_wrapper'; +export { Erc1155Wrapper } from './erc1155_wrapper'; diff --git a/contracts/erc1155/src/wrappers.ts b/contracts/erc1155/src/wrappers.ts index b7819dfce1..f48fde01c5 100644 --- a/contracts/erc1155/src/wrappers.ts +++ b/contracts/erc1155/src/wrappers.ts @@ -6,7 +6,4 @@ export * from '../generated-wrappers/dummy_erc1155_receiver'; export * from '../generated-wrappers/erc1155'; export * from '../generated-wrappers/erc1155_mintable'; -export * from '../generated-wrappers/i_erc1155_mintable'; export * from '../generated-wrappers/i_erc1155_receiver'; -export * from '../generated-wrappers/ierc1155'; -export * from '../generated-wrappers/mixin_non_fungible_token'; 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/erc1155_token.ts b/contracts/erc1155/test/erc1155_token.ts index ef3b2def3e..c06ceeb976 100644 --- a/contracts/erc1155/test/erc1155_token.ts +++ b/contracts/erc1155/test/erc1155_token.ts @@ -13,14 +13,11 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { - artifacts, - DummyERC1155ReceiverBatchTokenReceivedEventArgs, - DummyERC1155ReceiverContract, - ERC1155MintableContract, -} from '../src'; +import { Erc1155Wrapper } from '../src/erc1155_wrapper'; +import { ERC1155MintableContract } from '../src/wrappers'; -import { Erc1155Wrapper } from './utils/erc1155_wrapper'; +import { artifacts } from './artifacts'; +import { DummyERC1155ReceiverBatchTokenReceivedEventArgs, DummyERC1155ReceiverContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); 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..751a5cace3 100644 --- a/contracts/erc1155/tsconfig.json +++ b/contracts/erc1155/tsconfig.json @@ -6,10 +6,14 @@ "generated-artifacts/DummyERC1155Receiver.json", "generated-artifacts/ERC1155.json", "generated-artifacts/ERC1155Mintable.json", - "generated-artifacts/IERC1155.json", - "generated-artifacts/IERC1155Mintable.json", "generated-artifacts/IERC1155Receiver.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/.npmignore b/contracts/erc20/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/erc20/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/erc20/CHANGELOG.json b/contracts/erc20/CHANGELOG.json index e0b330d1a2..5db312aba7 100644 --- a/contracts/erc20/CHANGELOG.json +++ b/contracts/erc20/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.3.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "2.3.0-beta.1", "changes": [ 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..ae724e48d2 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,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" }, "config": { - "abis": "./generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|LibERC20Token|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json", + "publicInterfaceContracts": "DummyERC20Token,ERC20Token,WETH9,ZRXToken,DummyNoReturnERC20Token,DummyMultipleReturnERC20Token", + "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": { @@ -50,9 +52,12 @@ "@0x/abi-gen": "^4.4.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/utils": "^4.6.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -60,6 +65,7 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -70,13 +76,9 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", - "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "lodash": "^4.17.11" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/erc20/src/artifacts.ts b/contracts/erc20/src/artifacts.ts index 8d48dc2753..58950e0e05 100644 --- a/contracts/erc20/src/artifacts.ts +++ b/contracts/erc20/src/artifacts.ts @@ -9,29 +9,13 @@ import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; import * as DummyMultipleReturnERC20Token from '../generated-artifacts/DummyMultipleReturnERC20Token.json'; import * as DummyNoReturnERC20Token from '../generated-artifacts/DummyNoReturnERC20Token.json'; import * as ERC20Token from '../generated-artifacts/ERC20Token.json'; -import * as IERC20Token from '../generated-artifacts/IERC20Token.json'; -import * as IEtherToken from '../generated-artifacts/IEtherToken.json'; -import * as LibERC20Token from '../generated-artifacts/LibERC20Token.json'; -import * as MintableERC20Token from '../generated-artifacts/MintableERC20Token.json'; -import * as TestLibERC20Token from '../generated-artifacts/TestLibERC20Token.json'; -import * as TestLibERC20TokenTarget from '../generated-artifacts/TestLibERC20TokenTarget.json'; -import * as UnlimitedAllowanceERC20Token from '../generated-artifacts/UnlimitedAllowanceERC20Token.json'; -import * as UntransferrableDummyERC20Token from '../generated-artifacts/UntransferrableDummyERC20Token.json'; import * as WETH9 from '../generated-artifacts/WETH9.json'; import * as ZRXToken from '../generated-artifacts/ZRXToken.json'; export const artifacts = { + DummyERC20Token: DummyERC20Token as ContractArtifact, 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, + DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, }; diff --git a/contracts/erc20/src/wrappers.ts b/contracts/erc20/src/wrappers.ts index e38e07af17..738809db4a 100644 --- a/contracts/erc20/src/wrappers.ts +++ b/contracts/erc20/src/wrappers.ts @@ -7,13 +7,5 @@ export * from '../generated-wrappers/dummy_erc20_token'; export * from '../generated-wrappers/dummy_multiple_return_erc20_token'; export * from '../generated-wrappers/dummy_no_return_erc20_token'; export * from '../generated-wrappers/erc20_token'; -export * from '../generated-wrappers/i_erc20_token'; -export * from '../generated-wrappers/i_ether_token'; -export * from '../generated-wrappers/lib_erc20_token'; -export * from '../generated-wrappers/mintable_erc20_token'; -export * from '../generated-wrappers/test_lib_erc20_token'; -export * from '../generated-wrappers/test_lib_erc20_token_target'; -export * from '../generated-wrappers/unlimited_allowance_erc20_token'; -export * from '../generated-wrappers/untransferrable_dummy_erc20_token'; export * from '../generated-wrappers/weth9'; export * from '../generated-wrappers/zrx_token'; 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/lib_erc20_token.ts b/contracts/erc20/test/lib_erc20_token.ts index b843867a8c..48c85587ea 100644 --- a/contracts/erc20/test/lib_erc20_token.ts +++ b/contracts/erc20/test/lib_erc20_token.ts @@ -9,7 +9,9 @@ import { } from '@0x/contracts-test-utils'; import { RawRevertError, StringRevertError } from '@0x/utils'; -import { artifacts, TestLibERC20TokenContract, TestLibERC20TokenTargetEvents } from '../src'; +import { TestLibERC20TokenContract, TestLibERC20TokenTargetEvents } from './wrappers'; + +import { artifacts } from './artifacts'; blockchainTests('LibERC20Token', env => { let testContract: TestLibERC20TokenContract; diff --git a/contracts/erc20/test/unlimited_allowance_token.ts b/contracts/erc20/test/unlimited_allowance_token.ts index 9d9de2ab01..34d2e9333f 100644 --- a/contracts/erc20/test/unlimited_allowance_token.ts +++ b/contracts/erc20/test/unlimited_allowance_token.ts @@ -11,7 +11,9 @@ import { RevertReason } from '@0x/types'; import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; -import { artifacts, DummyERC20TokenContract } from '../src'; +import { DummyERC20TokenContract } from './wrappers'; + +import { artifacts } from './artifacts'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/erc20/test/weth9.ts b/contracts/erc20/test/weth9.ts index 602abd29f9..1d766184fe 100644 --- a/contracts/erc20/test/weth9.ts +++ b/contracts/erc20/test/weth9.ts @@ -12,7 +12,9 @@ import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; -import { artifacts, WETH9Contract } from '../src'; +import { WETH9Contract } from './wrappers'; + +import { artifacts } from './artifacts'; chaiSetup.configure(); const expect = chai.expect; 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/test/zrx_token.ts b/contracts/erc20/test/zrx_token.ts index a148fc0d85..068d8c5c56 100644 --- a/contracts/erc20/test/zrx_token.ts +++ b/contracts/erc20/test/zrx_token.ts @@ -4,7 +4,9 @@ import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; -import { artifacts, ZRXTokenContract } from '../src'; +import { ZRXTokenContract } from './wrappers'; + +import { artifacts } from './artifacts'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/erc20/tsconfig.json b/contracts/erc20/tsconfig.json index 5c706d141a..f7dc0989b3 100644 --- a/contracts/erc20/tsconfig.json +++ b/contracts/erc20/tsconfig.json @@ -7,16 +7,22 @@ "generated-artifacts/DummyMultipleReturnERC20Token.json", "generated-artifacts/DummyNoReturnERC20Token.json", "generated-artifacts/ERC20Token.json", - "generated-artifacts/IERC20Token.json", - "generated-artifacts/IEtherToken.json", - "generated-artifacts/LibERC20Token.json", - "generated-artifacts/MintableERC20Token.json", - "generated-artifacts/TestLibERC20Token.json", - "generated-artifacts/TestLibERC20TokenTarget.json", - "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/.npmignore b/contracts/erc721/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/erc721/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/erc721/CHANGELOG.json b/contracts/erc721/CHANGELOG.json index 1afba90b4a..562d6545c7 100644 --- a/contracts/erc721/CHANGELOG.json +++ b/contracts/erc721/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.2.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "2.2.0-beta.1", "changes": [ 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..c7dddce225 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,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": "./generated-artifacts/@(DummyERC721Receiver|DummyERC721Token|ERC721Token|IERC721Receiver|IERC721Token|InvalidERC721Receiver|MintableERC721Token).json", + "publicInterfaceContracts": "DummyERC721Token,ERC721Token,IERC721Receiver,DummyERC721Receiver", + "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": { @@ -54,6 +56,10 @@ "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/types": "^2.5.0-beta.1", + "@0x/utils": "^4.6.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -61,6 +67,7 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -72,13 +79,8 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", - "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", - "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "lodash": "^4.17.11" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/erc721/src/artifacts.ts b/contracts/erc721/src/artifacts.ts index 79a76e21b4..6a7cf0034c 100644 --- a/contracts/erc721/src/artifacts.ts +++ b/contracts/erc721/src/artifacts.ts @@ -9,15 +9,9 @@ import * as DummyERC721Receiver from '../generated-artifacts/DummyERC721Receiver import * as DummyERC721Token from '../generated-artifacts/DummyERC721Token.json'; import * as ERC721Token from '../generated-artifacts/ERC721Token.json'; import * as IERC721Receiver from '../generated-artifacts/IERC721Receiver.json'; -import * as IERC721Token from '../generated-artifacts/IERC721Token.json'; -import * as InvalidERC721Receiver from '../generated-artifacts/InvalidERC721Receiver.json'; -import * as MintableERC721Token from '../generated-artifacts/MintableERC721Token.json'; export const artifacts = { + DummyERC721Token: DummyERC721Token as ContractArtifact, 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/src/wrappers.ts b/contracts/erc721/src/wrappers.ts index 716f6cca4e..0f0bd5c866 100644 --- a/contracts/erc721/src/wrappers.ts +++ b/contracts/erc721/src/wrappers.ts @@ -7,6 +7,3 @@ export * from '../generated-wrappers/dummy_erc721_receiver'; export * from '../generated-wrappers/dummy_erc721_token'; export * from '../generated-wrappers/erc721_token'; export * from '../generated-wrappers/i_erc721_receiver'; -export * from '../generated-wrappers/i_erc721_token'; -export * from '../generated-wrappers/invalid_erc721_receiver'; -export * from '../generated-wrappers/mintable_erc721_token'; 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/erc721_token.ts b/contracts/erc721/test/erc721_token.ts index b3c0ba4141..04cbc1e549 100644 --- a/contracts/erc721/test/erc721_token.ts +++ b/contracts/erc721/test/erc721_token.ts @@ -15,13 +15,14 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import { - artifacts, DummyERC721ReceiverContract, DummyERC721ReceiverTokenReceivedEventArgs, DummyERC721TokenContract, DummyERC721TokenTransferEventArgs, InvalidERC721ReceiverContract, -} from '../src'; +} from './wrappers'; + +import { artifacts } from './artifacts'; chaiSetup.configure(); const expect = chai.expect; 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..279937a8d0 100644 --- a/contracts/erc721/tsconfig.json +++ b/contracts/erc721/tsconfig.json @@ -7,9 +7,13 @@ "generated-artifacts/DummyERC721Token.json", "generated-artifacts/ERC721Token.json", "generated-artifacts/IERC721Receiver.json", - "generated-artifacts/IERC721Token.json", - "generated-artifacts/InvalidERC721Receiver.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/.npmignore b/contracts/exchange-forwarder/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/exchange-forwarder/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/exchange-forwarder/CHANGELOG.json b/contracts/exchange-forwarder/CHANGELOG.json index bef9b2978e..ef22a71bd8 100644 --- a/contracts/exchange-forwarder/CHANGELOG.json +++ b/contracts/exchange-forwarder/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.1.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "3.1.0-beta.1", "changes": [ 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..86a86f4f73 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,20 +21,22 @@ "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" }, "config": { - "abis": "./generated-artifacts/@(Forwarder|IAssets|IForwarder|IForwarderCore|LibConstants|LibForwarderRichErrors|MixinAssets|MixinExchangeWrapper|MixinForwarderCore|MixinWeth).json", + "publicInterfaceContracts": "Forwarder", + "abis": "./test/generated-artifacts/@(Forwarder|IAssets|IForwarder|IForwarderCore|LibConstants|LibForwarderRichErrors|MixinAssets|MixinExchangeWrapper|MixinForwarderCore|MixinWeth).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { @@ -50,9 +52,20 @@ "@0x/abi-gen": "^4.4.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", + "@0x/contracts-asset-proxy": "^2.3.0-beta.1", + "@0x/contracts-dev-utils": "^0.1.0-beta.1", + "@0x/contracts-erc20": "^2.3.0-beta.1", + "@0x/contracts-erc721": "^2.2.0-beta.1", + "@0x/contracts-exchange": "^2.2.0-beta.1", + "@0x/contracts-exchange-libs": "^3.1.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/order-utils": "^8.5.0-beta.1", + "@0x/types": "^2.5.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/utils": "^4.6.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -60,6 +73,7 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -71,20 +85,8 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contracts-asset-proxy": "^2.3.0-beta.1", - "@0x/contracts-dev-utils": "^0.1.0-beta.1", - "@0x/contracts-erc20": "^2.3.0-beta.1", - "@0x/contracts-erc721": "^2.2.0-beta.1", - "@0x/contracts-exchange": "^2.2.0-beta.1", - "@0x/contracts-exchange-libs": "^3.1.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", - "@0x/order-utils": "^8.5.0-beta.1", - "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", - "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "lodash": "^4.17.11" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/exchange-forwarder/src/artifacts.ts b/contracts/exchange-forwarder/src/artifacts.ts index 9643be939a..a316777cb3 100644 --- a/contracts/exchange-forwarder/src/artifacts.ts +++ b/contracts/exchange-forwarder/src/artifacts.ts @@ -6,24 +6,4 @@ import { ContractArtifact } from 'ethereum-types'; import * as Forwarder from '../generated-artifacts/Forwarder.json'; -import * as IAssets from '../generated-artifacts/IAssets.json'; -import * as IForwarder from '../generated-artifacts/IForwarder.json'; -import * as IForwarderCore from '../generated-artifacts/IForwarderCore.json'; -import * as LibConstants from '../generated-artifacts/LibConstants.json'; -import * as LibForwarderRichErrors from '../generated-artifacts/LibForwarderRichErrors.json'; -import * as MixinAssets from '../generated-artifacts/MixinAssets.json'; -import * as MixinExchangeWrapper from '../generated-artifacts/MixinExchangeWrapper.json'; -import * as MixinForwarderCore from '../generated-artifacts/MixinForwarderCore.json'; -import * as MixinWeth from '../generated-artifacts/MixinWeth.json'; -export const artifacts = { - Forwarder: Forwarder as ContractArtifact, - MixinAssets: MixinAssets as ContractArtifact, - MixinExchangeWrapper: MixinExchangeWrapper as ContractArtifact, - MixinForwarderCore: MixinForwarderCore as ContractArtifact, - MixinWeth: MixinWeth as ContractArtifact, - IAssets: IAssets as ContractArtifact, - IForwarder: IForwarder as ContractArtifact, - IForwarderCore: IForwarderCore as ContractArtifact, - LibConstants: LibConstants as ContractArtifact, - LibForwarderRichErrors: LibForwarderRichErrors as ContractArtifact, -}; +export const artifacts = { Forwarder: Forwarder as ContractArtifact }; diff --git a/contracts/exchange-forwarder/src/wrappers.ts b/contracts/exchange-forwarder/src/wrappers.ts index 23213da16e..e77944402a 100644 --- a/contracts/exchange-forwarder/src/wrappers.ts +++ b/contracts/exchange-forwarder/src/wrappers.ts @@ -4,12 +4,3 @@ * ----------------------------------------------------------------------------- */ export * from '../generated-wrappers/forwarder'; -export * from '../generated-wrappers/i_assets'; -export * from '../generated-wrappers/i_forwarder'; -export * from '../generated-wrappers/i_forwarder_core'; -export * from '../generated-wrappers/lib_constants'; -export * from '../generated-wrappers/lib_forwarder_rich_errors'; -export * from '../generated-wrappers/mixin_assets'; -export * from '../generated-wrappers/mixin_exchange_wrapper'; -export * from '../generated-wrappers/mixin_forwarder_core'; -export * from '../generated-wrappers/mixin_weth'; diff --git a/contracts/exchange-forwarder/test/artifacts.ts b/contracts/exchange-forwarder/test/artifacts.ts new file mode 100644 index 0000000000..2e786fdfa4 --- /dev/null +++ b/contracts/exchange-forwarder/test/artifacts.ts @@ -0,0 +1,29 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as Forwarder from '../test/generated-artifacts/Forwarder.json'; +import * as IAssets from '../test/generated-artifacts/IAssets.json'; +import * as IForwarder from '../test/generated-artifacts/IForwarder.json'; +import * as IForwarderCore from '../test/generated-artifacts/IForwarderCore.json'; +import * as LibConstants from '../test/generated-artifacts/LibConstants.json'; +import * as LibForwarderRichErrors from '../test/generated-artifacts/LibForwarderRichErrors.json'; +import * as MixinAssets from '../test/generated-artifacts/MixinAssets.json'; +import * as MixinExchangeWrapper from '../test/generated-artifacts/MixinExchangeWrapper.json'; +import * as MixinForwarderCore from '../test/generated-artifacts/MixinForwarderCore.json'; +import * as MixinWeth from '../test/generated-artifacts/MixinWeth.json'; +export const artifacts = { + Forwarder: Forwarder as ContractArtifact, + MixinAssets: MixinAssets as ContractArtifact, + MixinExchangeWrapper: MixinExchangeWrapper as ContractArtifact, + MixinForwarderCore: MixinForwarderCore as ContractArtifact, + MixinWeth: MixinWeth as ContractArtifact, + IAssets: IAssets as ContractArtifact, + IForwarder: IForwarder as ContractArtifact, + IForwarderCore: IForwarderCore as ContractArtifact, + LibConstants: LibConstants as ContractArtifact, + LibForwarderRichErrors: LibForwarderRichErrors as ContractArtifact, +}; diff --git a/contracts/exchange-forwarder/test/wrappers.ts b/contracts/exchange-forwarder/test/wrappers.ts new file mode 100644 index 0000000000..fd8cbc5af8 --- /dev/null +++ b/contracts/exchange-forwarder/test/wrappers.ts @@ -0,0 +1,15 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/forwarder'; +export * from '../test/generated-wrappers/i_assets'; +export * from '../test/generated-wrappers/i_forwarder'; +export * from '../test/generated-wrappers/i_forwarder_core'; +export * from '../test/generated-wrappers/lib_constants'; +export * from '../test/generated-wrappers/lib_forwarder_rich_errors'; +export * from '../test/generated-wrappers/mixin_assets'; +export * from '../test/generated-wrappers/mixin_exchange_wrapper'; +export * from '../test/generated-wrappers/mixin_forwarder_core'; +export * from '../test/generated-wrappers/mixin_weth'; diff --git a/contracts/exchange-forwarder/tsconfig.json b/contracts/exchange-forwarder/tsconfig.json index e5d468a5ce..8186631147 100644 --- a/contracts/exchange-forwarder/tsconfig.json +++ b/contracts/exchange-forwarder/tsconfig.json @@ -4,15 +4,16 @@ "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ "generated-artifacts/Forwarder.json", - "generated-artifacts/IAssets.json", - "generated-artifacts/IForwarder.json", - "generated-artifacts/IForwarderCore.json", - "generated-artifacts/LibConstants.json", - "generated-artifacts/LibForwarderRichErrors.json", - "generated-artifacts/MixinAssets.json", - "generated-artifacts/MixinExchangeWrapper.json", - "generated-artifacts/MixinForwarderCore.json", - "generated-artifacts/MixinWeth.json" + "test/generated-artifacts/Forwarder.json", + "test/generated-artifacts/IAssets.json", + "test/generated-artifacts/IForwarder.json", + "test/generated-artifacts/IForwarderCore.json", + "test/generated-artifacts/LibConstants.json", + "test/generated-artifacts/LibForwarderRichErrors.json", + "test/generated-artifacts/MixinAssets.json", + "test/generated-artifacts/MixinExchangeWrapper.json", + "test/generated-artifacts/MixinForwarderCore.json", + "test/generated-artifacts/MixinWeth.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange-libs/.npmignore b/contracts/exchange-libs/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/exchange-libs/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/exchange-libs/CHANGELOG.json b/contracts/exchange-libs/CHANGELOG.json index 635478980e..40e35e91f8 100644 --- a/contracts/exchange-libs/CHANGELOG.json +++ b/contracts/exchange-libs/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.1.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "3.1.0-beta.1", "changes": [ 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..546a35baf3 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,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": "./generated-artifacts/@(IWallet|LibEIP712ExchangeDomain|LibExchangeRichErrors|LibFillResults|LibMath|LibMathRichErrors|LibOrder|LibZeroExTransaction|TestLibEIP712ExchangeDomain|TestLibFillResults|TestLibMath|TestLibOrder|TestLibZeroExTransaction).json", + "publicInterfaceContracts": "IWallet,LibEIP712ExchangeDomain,LibExchangeRichErrors,LibMath,LibMathRichErrors,LibOrder,LibZeroExTransaction", + "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": { @@ -55,6 +57,7 @@ "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/subproviders": "^5.1.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -63,6 +66,7 @@ "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", "ethereumjs-util": "^5.1.1", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -79,9 +83,7 @@ "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "lodash": "^4.17.11" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/exchange-libs/src/artifacts.ts b/contracts/exchange-libs/src/artifacts.ts index 1769fc432a..e511f8c4ac 100644 --- a/contracts/exchange-libs/src/artifacts.ts +++ b/contracts/exchange-libs/src/artifacts.ts @@ -8,28 +8,16 @@ import { ContractArtifact } from 'ethereum-types'; import * as IWallet from '../generated-artifacts/IWallet.json'; import * as LibEIP712ExchangeDomain from '../generated-artifacts/LibEIP712ExchangeDomain.json'; import * as LibExchangeRichErrors from '../generated-artifacts/LibExchangeRichErrors.json'; -import * as LibFillResults from '../generated-artifacts/LibFillResults.json'; import * as LibMath from '../generated-artifacts/LibMath.json'; import * as LibMathRichErrors from '../generated-artifacts/LibMathRichErrors.json'; import * as LibOrder from '../generated-artifacts/LibOrder.json'; import * as LibZeroExTransaction from '../generated-artifacts/LibZeroExTransaction.json'; -import * as TestLibEIP712ExchangeDomain from '../generated-artifacts/TestLibEIP712ExchangeDomain.json'; -import * as TestLibFillResults from '../generated-artifacts/TestLibFillResults.json'; -import * as TestLibMath from '../generated-artifacts/TestLibMath.json'; -import * as TestLibOrder from '../generated-artifacts/TestLibOrder.json'; -import * as TestLibZeroExTransaction from '../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/src/wrappers.ts b/contracts/exchange-libs/src/wrappers.ts index 695fe2da79..03a7601de2 100644 --- a/contracts/exchange-libs/src/wrappers.ts +++ b/contracts/exchange-libs/src/wrappers.ts @@ -6,13 +6,7 @@ export * from '../generated-wrappers/i_wallet'; export * from '../generated-wrappers/lib_e_i_p712_exchange_domain'; export * from '../generated-wrappers/lib_exchange_rich_errors'; -export * from '../generated-wrappers/lib_fill_results'; export * from '../generated-wrappers/lib_math'; export * from '../generated-wrappers/lib_math_rich_errors'; export * from '../generated-wrappers/lib_order'; export * from '../generated-wrappers/lib_zero_ex_transaction'; -export * from '../generated-wrappers/test_lib_e_i_p712_exchange_domain'; -export * from '../generated-wrappers/test_lib_fill_results'; -export * from '../generated-wrappers/test_lib_math'; -export * from '../generated-wrappers/test_lib_order'; -export * from '../generated-wrappers/test_lib_zero_ex_transaction'; 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/lib_eip712_exchange_domain.ts b/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts index e608726e47..536aff2f22 100644 --- a/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts +++ b/contracts/exchange-libs/test/lib_eip712_exchange_domain.ts @@ -2,7 +2,9 @@ import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts import { BigNumber, signTypedDataUtils } from '@0x/utils'; import * as ethUtil from 'ethereumjs-util'; -import { artifacts, TestLibEIP712ExchangeDomainContract } from '../src'; +import { TestLibEIP712ExchangeDomainContract } from './wrappers'; + +import { artifacts } from './artifacts'; blockchainTests('LibEIP712ExchangeDomain', env => { describe('constructor', () => { diff --git a/contracts/exchange-libs/test/lib_fill_results.ts b/contracts/exchange-libs/test/lib_fill_results.ts index c62ee15803..8d65b0d0ac 100644 --- a/contracts/exchange-libs/test/lib_fill_results.ts +++ b/contracts/exchange-libs/test/lib_fill_results.ts @@ -13,7 +13,10 @@ import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as _ from 'lodash'; -import { artifacts, ReferenceFunctions, TestLibFillResultsContract } from '../src'; +import { addFillResults, calculateFillResults, getPartialAmountFloor } from '../src/reference_functions'; + +import { artifacts } from './artifacts'; +import { TestLibFillResultsContract } from './wrappers'; blockchainTests('LibFillResults', env => { interface PartialMatchedFillResults { @@ -92,7 +95,7 @@ blockchainTests('LibFillResults', env => { // in any mathematical operation in either the reference TypeScript // implementation or the Solidity implementation of // calculateFillResults. - return ReferenceFunctions.calculateFillResults( + return calculateFillResults( makeOrder(otherAmount, orderTakerAssetAmount, otherAmount, otherAmount), takerAssetFilledAmount, takerAssetFilledAmount, // Using this so that the gas price is distinct from protocolFeeMultiplier @@ -139,7 +142,7 @@ blockchainTests('LibFillResults', env => { takerFee: ONE_ETHER.times(0.0025), }); const takerAssetFilledAmount = ONE_ETHER.dividedToIntegerBy(3); - const expected = ReferenceFunctions.calculateFillResults( + const expected = calculateFillResults( order, takerAssetFilledAmount, DEFAULT_PROTOCOL_FEE_MULTIPLIER, @@ -184,7 +187,7 @@ blockchainTests('LibFillResults', env => { makerFee: MAX_UINT256_ROOT.times(11), }); const takerAssetFilledAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10); - const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor( + const makerAssetFilledAmount = getPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount, @@ -272,7 +275,7 @@ blockchainTests('LibFillResults', env => { makerFee: new BigNumber(100), }); const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3); - const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor( + const makerAssetFilledAmount = getPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount, @@ -299,7 +302,7 @@ blockchainTests('LibFillResults', env => { takerFee: new BigNumber(100), }); const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3); - const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor( + const makerAssetFilledAmount = getPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount, @@ -349,7 +352,7 @@ blockchainTests('LibFillResults', env => { makerFee: new BigNumber(100), }); const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3); - const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor( + const makerAssetFilledAmount = getPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount, @@ -392,7 +395,7 @@ blockchainTests('LibFillResults', env => { it('matches the output of the reference function', async () => { const [a, b] = DEFAULT_FILL_RESULTS; - const expected = ReferenceFunctions.addFillResults(a, b); + const expected = addFillResults(a, b); const actual = await libsContract.addFillResults.callAsync(a, b); expect(actual).to.deep.equal(expected); }); diff --git a/contracts/exchange-libs/test/lib_math.ts b/contracts/exchange-libs/test/lib_math.ts index 5e9b89023e..a5d1c73a19 100644 --- a/contracts/exchange-libs/test/lib_math.ts +++ b/contracts/exchange-libs/test/lib_math.ts @@ -9,7 +9,17 @@ import { import { LibMathRevertErrors } from '@0x/order-utils'; import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; -import { artifacts, ReferenceFunctions, TestLibMathContract } from '../src'; +import { + getPartialAmountCeil, + getPartialAmountFloor, + isRoundingErrorCeil, + isRoundingErrorFloor, + safeGetPartialAmountCeil, + safeGetPartialAmountFloor, +} from '../src/reference_functions'; + +import { artifacts } from './artifacts'; +import { TestLibMathContract } from './wrappers'; blockchainTests('LibMath', env => { const { ONE_ETHER, MAX_UINT256, MAX_UINT256_ROOT, ZERO_AMOUNT } = constants; @@ -42,7 +52,7 @@ blockchainTests('LibMath', env => { describe.optional('combinatorial tests', () => { testCombinatoriallyWithReferenceFunc( 'getPartialAmountFloor', - createAsyncReferenceFunction(ReferenceFunctions.getPartialAmountFloor), + createAsyncReferenceFunction(getPartialAmountFloor), createContractTestFunction('getPartialAmountFloor'), [uint256Values, uint256Values, uint256Values], ); @@ -53,7 +63,7 @@ blockchainTests('LibMath', env => { const numerator = ONE_ETHER; const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); - const expected = ReferenceFunctions.getPartialAmountFloor(numerator, denominator, target); + const expected = getPartialAmountFloor(numerator, denominator, target); const actual = await libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target); expect(actual).to.bignumber.eq(expected); }); @@ -101,7 +111,7 @@ blockchainTests('LibMath', env => { describe.optional('combinatorial tests', () => { testCombinatoriallyWithReferenceFunc( 'getPartialAmountCeil', - createAsyncReferenceFunction(ReferenceFunctions.getPartialAmountCeil), + createAsyncReferenceFunction(getPartialAmountCeil), createContractTestFunction('getPartialAmountCeil'), [uint256Values, uint256Values, uint256Values], ); @@ -112,7 +122,7 @@ blockchainTests('LibMath', env => { const numerator = ONE_ETHER; const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); - const expected = ReferenceFunctions.getPartialAmountCeil(numerator, denominator, target); + const expected = getPartialAmountCeil(numerator, denominator, target); const actual = await libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target); expect(actual).to.bignumber.eq(expected); }); @@ -161,7 +171,7 @@ blockchainTests('LibMath', env => { describe.optional('combinatorial tests', () => { testCombinatoriallyWithReferenceFunc( 'safeGetPartialAmountFloor', - createAsyncReferenceFunction(ReferenceFunctions.safeGetPartialAmountFloor), + createAsyncReferenceFunction(safeGetPartialAmountFloor), createContractTestFunction('safeGetPartialAmountFloor'), [uint256Values, uint256Values, uint256Values], ); @@ -172,7 +182,7 @@ blockchainTests('LibMath', env => { const numerator = ONE_ETHER; const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); - const expected = ReferenceFunctions.safeGetPartialAmountFloor(numerator, denominator, target); + const expected = safeGetPartialAmountFloor(numerator, denominator, target); const actual = await libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target); expect(actual).to.bignumber.eq(expected); }); @@ -226,7 +236,7 @@ blockchainTests('LibMath', env => { describe.optional('combinatorial tests', () => { testCombinatoriallyWithReferenceFunc( 'safeGetPartialAmountCeil', - createAsyncReferenceFunction(ReferenceFunctions.safeGetPartialAmountCeil), + createAsyncReferenceFunction(safeGetPartialAmountCeil), createContractTestFunction('safeGetPartialAmountCeil'), [uint256Values, uint256Values, uint256Values], ); @@ -237,7 +247,7 @@ blockchainTests('LibMath', env => { const numerator = ONE_ETHER; const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); - const expected = ReferenceFunctions.safeGetPartialAmountCeil(numerator, denominator, target); + const expected = safeGetPartialAmountCeil(numerator, denominator, target); const actual = await libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target); expect(actual).to.bignumber.eq(expected); }); @@ -291,7 +301,7 @@ blockchainTests('LibMath', env => { describe.optional('combinatorial tests', () => { testCombinatoriallyWithReferenceFunc( 'isRoundingErrorFloor', - createAsyncReferenceFunction(ReferenceFunctions.isRoundingErrorFloor), + createAsyncReferenceFunction(isRoundingErrorFloor), createContractTestFunction('isRoundingErrorFloor'), [uint256Values, uint256Values, uint256Values], ); @@ -321,7 +331,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); // tslint:disable-next-line: boolean-naming - const expected = ReferenceFunctions.isRoundingErrorFloor(numerator, denominator, target); + const expected = isRoundingErrorFloor(numerator, denominator, target); // tslint:disable-next-line: boolean-naming const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target); expect(actual).to.eq(expected); @@ -357,7 +367,7 @@ blockchainTests('LibMath', env => { describe.optional('combinatorial tests', () => { testCombinatoriallyWithReferenceFunc( 'isRoundingErrorCeil', - createAsyncReferenceFunction(ReferenceFunctions.isRoundingErrorCeil), + createAsyncReferenceFunction(isRoundingErrorCeil), createContractTestFunction('isRoundingErrorCeil'), [uint256Values, uint256Values, uint256Values], ); @@ -387,7 +397,7 @@ blockchainTests('LibMath', env => { const denominator = ONE_ETHER.dividedToIntegerBy(2); const target = ONE_ETHER.times(0.01); // tslint:disable-next-line: boolean-naming - const expected = ReferenceFunctions.isRoundingErrorCeil(numerator, denominator, target); + const expected = isRoundingErrorCeil(numerator, denominator, target); // tslint:disable-next-line: boolean-naming const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target); expect(actual).to.eq(expected); diff --git a/contracts/exchange-libs/test/lib_order.ts b/contracts/exchange-libs/test/lib_order.ts index ec87e6b4cd..dac5b7e1cf 100644 --- a/contracts/exchange-libs/test/lib_order.ts +++ b/contracts/exchange-libs/test/lib_order.ts @@ -5,7 +5,9 @@ import { BigNumber, signTypedDataUtils } from '@0x/utils'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; -import { artifacts, TestLibOrderContract } from '../src'; +import { TestLibOrderContract } from './wrappers'; + +import { artifacts } from './artifacts'; blockchainTests('LibOrder', env => { let libOrderContract: TestLibOrderContract; diff --git a/contracts/exchange-libs/test/lib_zero_ex_transaction.ts b/contracts/exchange-libs/test/lib_zero_ex_transaction.ts index 00d3446606..1c4b9c8d17 100644 --- a/contracts/exchange-libs/test/lib_zero_ex_transaction.ts +++ b/contracts/exchange-libs/test/lib_zero_ex_transaction.ts @@ -5,7 +5,9 @@ import { BigNumber, signTypedDataUtils } from '@0x/utils'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; -import { artifacts, TestLibZeroExTransactionContract } from '../src'; +import { TestLibZeroExTransactionContract } from './wrappers'; + +import { artifacts } from './artifacts'; blockchainTests('LibZeroExTransaction', env => { let libZeroExTransactionContract: TestLibZeroExTransactionContract; 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..26f76e6e57 100644 --- a/contracts/exchange-libs/tsconfig.json +++ b/contracts/exchange-libs/tsconfig.json @@ -6,16 +6,23 @@ "generated-artifacts/IWallet.json", "generated-artifacts/LibEIP712ExchangeDomain.json", "generated-artifacts/LibExchangeRichErrors.json", - "generated-artifacts/LibFillResults.json", "generated-artifacts/LibMath.json", "generated-artifacts/LibMathRichErrors.json", "generated-artifacts/LibOrder.json", "generated-artifacts/LibZeroExTransaction.json", - "generated-artifacts/TestLibEIP712ExchangeDomain.json", - "generated-artifacts/TestLibFillResults.json", - "generated-artifacts/TestLibMath.json", - "generated-artifacts/TestLibOrder.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/.npmignore b/contracts/exchange/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/exchange/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/exchange/CHANGELOG.json b/contracts/exchange/CHANGELOG.json index 3e2d1d80d0..6fa9b1c63a 100644 --- a/contracts/exchange/CHANGELOG.json +++ b/contracts/exchange/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.2.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "2.2.0-beta.1", "changes": [ diff --git a/contracts/exchange/compiler.json b/contracts/exchange/compiler.json index 6b74c612c2..6d739870f0 100644 --- a/contracts/exchange/compiler.json +++ b/contracts/exchange/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "./generated-artifacts", + "artifactsDir": "./test/generated-artifacts", "contractsDir": "./contracts", "useDockerisedSolc": false, "isOfflineMode": false, diff --git a/contracts/exchange/package.json b/contracts/exchange/package.json index 26787aec5e..18aeaac665 100644 --- a/contracts/exchange/package.json +++ b/contracts/exchange/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,24 @@ "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 ./generated-artifacts/**/* --exclude ./test/generated-wrappers/**/* --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/@(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", - "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." + "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", @@ -53,9 +55,13 @@ "@0x/contracts-multisig": "^3.2.0-beta.1", "@0x/contracts-staking": "^1.1.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", + "@0x/contracts-asset-proxy": "^2.3.0-beta.1", + "@0x/contracts-exchange-libs": "^3.1.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -63,6 +69,7 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "ethereumjs-util": "^5.1.1", "js-combinatorics": "^0.5.3", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", @@ -75,20 +82,15 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contracts-asset-proxy": "^2.3.0-beta.1", "@0x/contracts-dev-utils": "^0.1.0-beta.1", "@0x/contracts-erc1155": "^1.2.0-beta.1", "@0x/contracts-erc20": "^2.3.0-beta.1", "@0x/contracts-erc721": "^2.2.0-beta.1", - "@0x/contracts-exchange-libs": "^3.1.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", "@0x/order-utils": "^8.5.0-beta.1", "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", "ethereum-types": "^2.2.0-beta.1", - "ethereumjs-util": "^5.1.1", "lodash": "^4.17.11" }, "publishConfig": { diff --git a/contracts/exchange/src/artifacts.ts b/contracts/exchange/src/artifacts.ts index 34354204c4..37310d8640 100644 --- a/contracts/exchange/src/artifacts.ts +++ b/contracts/exchange/src/artifacts.ts @@ -6,74 +6,5 @@ import { ContractArtifact } from 'ethereum-types'; import * as Exchange from '../generated-artifacts/Exchange.json'; -import * as IAssetProxy from '../generated-artifacts/IAssetProxy.json'; -import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispatcher.json'; -import * as IEIP1271Data from '../generated-artifacts/IEIP1271Data.json'; -import * as IEIP1271Wallet from '../generated-artifacts/IEIP1271Wallet.json'; import * as IExchange from '../generated-artifacts/IExchange.json'; -import * as IExchangeCore from '../generated-artifacts/IExchangeCore.json'; -import * as IMatchOrders from '../generated-artifacts/IMatchOrders.json'; -import * as IProtocolFees from '../generated-artifacts/IProtocolFees.json'; -import * as ISignatureValidator from '../generated-artifacts/ISignatureValidator.json'; -import * as IsolatedExchange from '../generated-artifacts/IsolatedExchange.json'; -import * as ITransactions from '../generated-artifacts/ITransactions.json'; -import * as ITransferSimulator from '../generated-artifacts/ITransferSimulator.json'; -import * as IWallet from '../generated-artifacts/IWallet.json'; -import * as IWrapperFunctions from '../generated-artifacts/IWrapperFunctions.json'; -import * as LibExchangeRichErrorDecoder from '../generated-artifacts/LibExchangeRichErrorDecoder.json'; -import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json'; -import * as MixinExchangeCore from '../generated-artifacts/MixinExchangeCore.json'; -import * as MixinMatchOrders from '../generated-artifacts/MixinMatchOrders.json'; -import * as MixinProtocolFees from '../generated-artifacts/MixinProtocolFees.json'; -import * as MixinSignatureValidator from '../generated-artifacts/MixinSignatureValidator.json'; -import * as MixinTransactions from '../generated-artifacts/MixinTransactions.json'; -import * as MixinTransferSimulator from '../generated-artifacts/MixinTransferSimulator.json'; -import * as MixinWrapperFunctions from '../generated-artifacts/MixinWrapperFunctions.json'; -import * as ReentrancyTester from '../generated-artifacts/ReentrancyTester.json'; -import * as TestAssetProxyDispatcher from '../generated-artifacts/TestAssetProxyDispatcher.json'; -import * as TestExchangeInternals from '../generated-artifacts/TestExchangeInternals.json'; -import * as TestLibExchangeRichErrorDecoder from '../generated-artifacts/TestLibExchangeRichErrorDecoder.json'; -import * as TestProtocolFeeCollector from '../generated-artifacts/TestProtocolFeeCollector.json'; -import * as TestProtocolFees from '../generated-artifacts/TestProtocolFees.json'; -import * as TestProtocolFeesReceiver from '../generated-artifacts/TestProtocolFeesReceiver.json'; -import * as TestSignatureValidator from '../generated-artifacts/TestSignatureValidator.json'; -import * as TestTransactions from '../generated-artifacts/TestTransactions.json'; -import * as TestValidatorWallet from '../generated-artifacts/TestValidatorWallet.json'; -import * as TestWrapperFunctions from '../generated-artifacts/TestWrapperFunctions.json'; -export const artifacts = { - Exchange: Exchange as ContractArtifact, - MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact, - MixinExchangeCore: MixinExchangeCore as ContractArtifact, - MixinMatchOrders: MixinMatchOrders as ContractArtifact, - MixinProtocolFees: MixinProtocolFees as ContractArtifact, - MixinSignatureValidator: MixinSignatureValidator as ContractArtifact, - MixinTransactions: MixinTransactions as ContractArtifact, - MixinTransferSimulator: MixinTransferSimulator as ContractArtifact, - MixinWrapperFunctions: MixinWrapperFunctions as ContractArtifact, - IAssetProxy: IAssetProxy as ContractArtifact, - IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, - IEIP1271Data: IEIP1271Data as ContractArtifact, - IEIP1271Wallet: IEIP1271Wallet as ContractArtifact, - IExchange: IExchange as ContractArtifact, - IExchangeCore: IExchangeCore as ContractArtifact, - IMatchOrders: IMatchOrders as ContractArtifact, - IProtocolFees: IProtocolFees as ContractArtifact, - ISignatureValidator: ISignatureValidator as ContractArtifact, - ITransactions: ITransactions as ContractArtifact, - ITransferSimulator: ITransferSimulator as ContractArtifact, - IWallet: IWallet as ContractArtifact, - IWrapperFunctions: IWrapperFunctions as ContractArtifact, - LibExchangeRichErrorDecoder: LibExchangeRichErrorDecoder as ContractArtifact, - IsolatedExchange: IsolatedExchange as ContractArtifact, - ReentrancyTester: ReentrancyTester as ContractArtifact, - TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact, - TestExchangeInternals: TestExchangeInternals as ContractArtifact, - TestLibExchangeRichErrorDecoder: TestLibExchangeRichErrorDecoder as ContractArtifact, - TestProtocolFeeCollector: TestProtocolFeeCollector as ContractArtifact, - TestProtocolFees: TestProtocolFees as ContractArtifact, - TestProtocolFeesReceiver: TestProtocolFeesReceiver as ContractArtifact, - TestSignatureValidator: TestSignatureValidator as ContractArtifact, - TestTransactions: TestTransactions as ContractArtifact, - TestValidatorWallet: TestValidatorWallet as ContractArtifact, - TestWrapperFunctions: TestWrapperFunctions as ContractArtifact, -}; +export const artifacts = { Exchange: Exchange as ContractArtifact, IExchange: IExchange as ContractArtifact }; diff --git a/contracts/exchange/test/balance_stores/balance_store.ts b/contracts/exchange/src/balance_stores/balance_store.ts similarity index 100% rename from contracts/exchange/test/balance_stores/balance_store.ts rename to contracts/exchange/src/balance_stores/balance_store.ts diff --git a/contracts/exchange/test/balance_stores/blockchain_balance_store.ts b/contracts/exchange/src/balance_stores/blockchain_balance_store.ts similarity index 100% rename from contracts/exchange/test/balance_stores/blockchain_balance_store.ts rename to contracts/exchange/src/balance_stores/blockchain_balance_store.ts diff --git a/contracts/exchange/test/balance_stores/local_balance_store.ts b/contracts/exchange/src/balance_stores/local_balance_store.ts similarity index 100% rename from contracts/exchange/test/balance_stores/local_balance_store.ts rename to contracts/exchange/src/balance_stores/local_balance_store.ts diff --git a/contracts/exchange/test/balance_stores/types.ts b/contracts/exchange/src/balance_stores/types.ts similarity index 100% rename from contracts/exchange/test/balance_stores/types.ts rename to contracts/exchange/src/balance_stores/types.ts diff --git a/contracts/exchange/test/utils/exchange_data_encoder.ts b/contracts/exchange/src/exchange_data_encoder.ts similarity index 83% rename from contracts/exchange/test/utils/exchange_data_encoder.ts rename to contracts/exchange/src/exchange_data_encoder.ts index 5b7e383d08..24022757fb 100644 --- a/contracts/exchange/test/utils/exchange_data_encoder.ts +++ b/contracts/exchange/src/exchange_data_encoder.ts @@ -1,33 +1,33 @@ -import { constants, provider } from '@0x/contracts-test-utils'; +import { constants, ExchangeFunctionName, provider } from '@0x/contracts-test-utils'; import { orderHashUtils } from '@0x/order-utils'; import { SignedOrder } from '@0x/types'; -import { constants as exchangeConstants, ExchangeFunctionName, IExchangeContract } from '../../src'; +import { IExchangeContract } from './wrappers'; export const exchangeDataEncoder = { encodeOrdersToExchangeData(fnName: ExchangeFunctionName, orders: SignedOrder[] = []): string { const exchangeInstance = new IExchangeContract(constants.NULL_ADDRESS, provider); let data; - if (exchangeConstants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) { + if (constants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) { data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( orders[0], orders[0].takerAssetAmount, orders[0].signature, ); - } else if (exchangeConstants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1) { + } else if (constants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1) { data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( orders, orders.map(order => order.takerAssetAmount), orders.map(order => order.signature), ); - } else if (exchangeConstants.MARKET_FILL_FN_NAMES.indexOf(fnName) !== -1) { + } else if (constants.MARKET_FILL_FN_NAMES.indexOf(fnName) !== -1) { const fillAsset = /Buy/.test(fnName) ? 'makerAssetAmount' : 'takerAssetAmount'; data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( orders, orders.map(order => order[fillAsset]).reduce((prev, curr) => prev.plus(curr)), orders.map(order => order.signature), ); - } else if (exchangeConstants.MATCH_ORDER_FN_NAMES.indexOf(fnName) !== -1) { + } else if (constants.MATCH_ORDER_FN_NAMES.indexOf(fnName) !== -1) { data = exchangeInstance.matchOrders.getABIEncodedTransactionData( orders[0], orders[1], diff --git a/contracts/exchange/src/index.ts b/contracts/exchange/src/index.ts index 4b64e3df2b..db2a3f1ec4 100644 --- a/contracts/exchange/src/index.ts +++ b/contracts/exchange/src/index.ts @@ -1,5 +1,5 @@ export * from './artifacts'; export * from './wrappers'; -export * from '../test/balance_stores'; -export * from '../test/utils'; -export * from './wrapper_interfaces'; +export { BlockchainBalanceStore } from './balance_stores/blockchain_balance_store'; +export { LocalBalanceStore } from './balance_stores/local_balance_store'; +export { exchangeDataEncoder } from './exchange_data_encoder'; diff --git a/contracts/exchange/src/wrappers.ts b/contracts/exchange/src/wrappers.ts index 28922d2dfc..acb3e1d6c0 100644 --- a/contracts/exchange/src/wrappers.ts +++ b/contracts/exchange/src/wrappers.ts @@ -4,37 +4,4 @@ * ----------------------------------------------------------------------------- */ export * from '../generated-wrappers/exchange'; -export * from '../generated-wrappers/i_asset_proxy'; -export * from '../generated-wrappers/i_asset_proxy_dispatcher'; -export * from '../generated-wrappers/i_e_i_p1271_data'; -export * from '../generated-wrappers/i_e_i_p1271_wallet'; export * from '../generated-wrappers/i_exchange'; -export * from '../generated-wrappers/i_exchange_core'; -export * from '../generated-wrappers/i_match_orders'; -export * from '../generated-wrappers/i_protocol_fees'; -export * from '../generated-wrappers/i_signature_validator'; -export * from '../generated-wrappers/i_transactions'; -export * from '../generated-wrappers/i_transfer_simulator'; -export * from '../generated-wrappers/i_wallet'; -export * from '../generated-wrappers/i_wrapper_functions'; -export * from '../generated-wrappers/isolated_exchange'; -export * from '../generated-wrappers/lib_exchange_rich_error_decoder'; -export * from '../generated-wrappers/mixin_asset_proxy_dispatcher'; -export * from '../generated-wrappers/mixin_exchange_core'; -export * from '../generated-wrappers/mixin_match_orders'; -export * from '../generated-wrappers/mixin_protocol_fees'; -export * from '../generated-wrappers/mixin_signature_validator'; -export * from '../generated-wrappers/mixin_transactions'; -export * from '../generated-wrappers/mixin_transfer_simulator'; -export * from '../generated-wrappers/mixin_wrapper_functions'; -export * from '../generated-wrappers/reentrancy_tester'; -export * from '../generated-wrappers/test_asset_proxy_dispatcher'; -export * from '../generated-wrappers/test_exchange_internals'; -export * from '../generated-wrappers/test_lib_exchange_rich_error_decoder'; -export * from '../generated-wrappers/test_protocol_fee_collector'; -export * from '../generated-wrappers/test_protocol_fees'; -export * from '../generated-wrappers/test_protocol_fees_receiver'; -export * from '../generated-wrappers/test_signature_validator'; -export * from '../generated-wrappers/test_transactions'; -export * from '../generated-wrappers/test_validator_wallet'; -export * from '../generated-wrappers/test_wrapper_functions'; diff --git a/contracts/exchange/test/artifacts.ts b/contracts/exchange/test/artifacts.ts new file mode 100644 index 0000000000..8eb424b93b --- /dev/null +++ b/contracts/exchange/test/artifacts.ts @@ -0,0 +1,79 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as Exchange from '../test/generated-artifacts/Exchange.json'; +import * as IAssetProxy from '../test/generated-artifacts/IAssetProxy.json'; +import * as IAssetProxyDispatcher from '../test/generated-artifacts/IAssetProxyDispatcher.json'; +import * as IEIP1271Data from '../test/generated-artifacts/IEIP1271Data.json'; +import * as IEIP1271Wallet from '../test/generated-artifacts/IEIP1271Wallet.json'; +import * as IExchange from '../test/generated-artifacts/IExchange.json'; +import * as IExchangeCore from '../test/generated-artifacts/IExchangeCore.json'; +import * as IMatchOrders from '../test/generated-artifacts/IMatchOrders.json'; +import * as IProtocolFees from '../test/generated-artifacts/IProtocolFees.json'; +import * as ISignatureValidator from '../test/generated-artifacts/ISignatureValidator.json'; +import * as IsolatedExchange from '../test/generated-artifacts/IsolatedExchange.json'; +import * as ITransactions from '../test/generated-artifacts/ITransactions.json'; +import * as ITransferSimulator from '../test/generated-artifacts/ITransferSimulator.json'; +import * as IWallet from '../test/generated-artifacts/IWallet.json'; +import * as IWrapperFunctions from '../test/generated-artifacts/IWrapperFunctions.json'; +import * as LibExchangeRichErrorDecoder from '../test/generated-artifacts/LibExchangeRichErrorDecoder.json'; +import * as MixinAssetProxyDispatcher from '../test/generated-artifacts/MixinAssetProxyDispatcher.json'; +import * as MixinExchangeCore from '../test/generated-artifacts/MixinExchangeCore.json'; +import * as MixinMatchOrders from '../test/generated-artifacts/MixinMatchOrders.json'; +import * as MixinProtocolFees from '../test/generated-artifacts/MixinProtocolFees.json'; +import * as MixinSignatureValidator from '../test/generated-artifacts/MixinSignatureValidator.json'; +import * as MixinTransactions from '../test/generated-artifacts/MixinTransactions.json'; +import * as MixinTransferSimulator from '../test/generated-artifacts/MixinTransferSimulator.json'; +import * as MixinWrapperFunctions from '../test/generated-artifacts/MixinWrapperFunctions.json'; +import * as ReentrancyTester from '../test/generated-artifacts/ReentrancyTester.json'; +import * as TestAssetProxyDispatcher from '../test/generated-artifacts/TestAssetProxyDispatcher.json'; +import * as TestExchangeInternals from '../test/generated-artifacts/TestExchangeInternals.json'; +import * as TestLibExchangeRichErrorDecoder from '../test/generated-artifacts/TestLibExchangeRichErrorDecoder.json'; +import * as TestProtocolFeeCollector from '../test/generated-artifacts/TestProtocolFeeCollector.json'; +import * as TestProtocolFees from '../test/generated-artifacts/TestProtocolFees.json'; +import * as TestProtocolFeesReceiver from '../test/generated-artifacts/TestProtocolFeesReceiver.json'; +import * as TestSignatureValidator from '../test/generated-artifacts/TestSignatureValidator.json'; +import * as TestTransactions from '../test/generated-artifacts/TestTransactions.json'; +import * as TestValidatorWallet from '../test/generated-artifacts/TestValidatorWallet.json'; +import * as TestWrapperFunctions from '../test/generated-artifacts/TestWrapperFunctions.json'; +export const artifacts = { + Exchange: Exchange as ContractArtifact, + MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact, + MixinExchangeCore: MixinExchangeCore as ContractArtifact, + MixinMatchOrders: MixinMatchOrders as ContractArtifact, + MixinProtocolFees: MixinProtocolFees as ContractArtifact, + MixinSignatureValidator: MixinSignatureValidator as ContractArtifact, + MixinTransactions: MixinTransactions as ContractArtifact, + MixinTransferSimulator: MixinTransferSimulator as ContractArtifact, + MixinWrapperFunctions: MixinWrapperFunctions as ContractArtifact, + IAssetProxy: IAssetProxy as ContractArtifact, + IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, + IEIP1271Data: IEIP1271Data as ContractArtifact, + IEIP1271Wallet: IEIP1271Wallet as ContractArtifact, + IExchange: IExchange as ContractArtifact, + IExchangeCore: IExchangeCore as ContractArtifact, + IMatchOrders: IMatchOrders as ContractArtifact, + IProtocolFees: IProtocolFees as ContractArtifact, + ISignatureValidator: ISignatureValidator as ContractArtifact, + ITransactions: ITransactions as ContractArtifact, + ITransferSimulator: ITransferSimulator as ContractArtifact, + IWallet: IWallet as ContractArtifact, + IWrapperFunctions: IWrapperFunctions as ContractArtifact, + LibExchangeRichErrorDecoder: LibExchangeRichErrorDecoder as ContractArtifact, + IsolatedExchange: IsolatedExchange as ContractArtifact, + ReentrancyTester: ReentrancyTester as ContractArtifact, + TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact, + TestExchangeInternals: TestExchangeInternals as ContractArtifact, + TestLibExchangeRichErrorDecoder: TestLibExchangeRichErrorDecoder as ContractArtifact, + TestProtocolFeeCollector: TestProtocolFeeCollector as ContractArtifact, + TestProtocolFees: TestProtocolFees as ContractArtifact, + TestProtocolFeesReceiver: TestProtocolFeesReceiver as ContractArtifact, + TestSignatureValidator: TestSignatureValidator as ContractArtifact, + TestTransactions: TestTransactions as ContractArtifact, + TestValidatorWallet: TestValidatorWallet as ContractArtifact, + TestWrapperFunctions: TestWrapperFunctions as ContractArtifact, +}; diff --git a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts index 0c6e552f3b..c6df6a38ca 100644 --- a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts +++ b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts @@ -14,15 +14,12 @@ import { BigNumber } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { - BalanceStore, - BlockchainBalanceStore, - ExchangeContract, - LocalBalanceStore, - TokenContractsByName, - TokenIds, - TokenOwnersByName, -} from '../../src'; +import { ExchangeContract } from '../wrappers'; + +import { BalanceStore } from '../../src/balance_stores/balance_store'; +import { BlockchainBalanceStore } from '../../src/balance_stores/blockchain_balance_store'; +import { LocalBalanceStore } from '../../src/balance_stores/local_balance_store'; +import { TokenContractsByName, TokenIds, TokenOwnersByName } from '../../src/balance_stores/types'; export class FillOrderWrapper { private readonly _blockchainBalanceStore: BlockchainBalanceStore; diff --git a/contracts/exchange/test/balance_stores/index.ts b/contracts/exchange/test/balance_stores/index.ts deleted file mode 100644 index cb0e290bca..0000000000 --- a/contracts/exchange/test/balance_stores/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { BalanceStore } from './balance_store'; -export { LocalBalanceStore } from './local_balance_store'; -export { BlockchainBalanceStore } from './blockchain_balance_store'; -export * from './types'; diff --git a/contracts/exchange/test/codesize.ts b/contracts/exchange/test/codesize.ts index e7b2d7a498..a3091c6e6c 100644 --- a/contracts/exchange/test/codesize.ts +++ b/contracts/exchange/test/codesize.ts @@ -4,7 +4,7 @@ import * as chai from 'chai'; chaiSetup.configure(); const expect = chai.expect; -import { artifacts } from '../src'; +import { artifacts } from './artifacts'; describe('Contract Size Checks', () => { describe('Exchange', () => { diff --git a/contracts/exchange/test/core.ts b/contracts/exchange/test/core.ts index 55da2bd13b..c8059fa765 100644 --- a/contracts/exchange/test/core.ts +++ b/contracts/exchange/test/core.ts @@ -11,7 +11,7 @@ import { TestStaticCallTargetContract, } from '@0x/contracts-asset-proxy'; import { DevUtilsContract } from '@0x/contracts-dev-utils'; -import { ERC1155MintableContract } from '@0x/contracts-erc1155'; +import { ERC1155MintableContract, Erc1155Wrapper } from '@0x/contracts-erc1155'; import { artifacts as erc20Artifacts, DummyERC20TokenContract, @@ -40,17 +40,12 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { Erc1155Wrapper } from '../../erc1155/lib/src'; -import { - artifacts, - ExchangeCancelEventArgs, - ExchangeContract, - ExchangeWrapper, - TestValidatorWalletContract, - ValidatorWalletAction, -} from '../src'; +import { ValidatorWalletAction } from './utils/constants'; +import { ExchangeWrapper } from './utils/exchange_wrapper'; +import { artifacts } from './artifacts'; import { FillOrderWrapper } from './assertion_wrappers/fill_order_wrapper'; +import { ExchangeCancelEventArgs, ExchangeContract, TestValidatorWalletContract } from './wrappers'; // tslint:disable:no-unnecessary-type-assertion blockchainTests.resets('Exchange core', () => { diff --git a/contracts/exchange/test/dispatcher.ts b/contracts/exchange/test/dispatcher.ts index 067f3e2fac..e26a28ae54 100644 --- a/contracts/exchange/test/dispatcher.ts +++ b/contracts/exchange/test/dispatcher.ts @@ -24,11 +24,8 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { - artifacts, - TestAssetProxyDispatcherAssetProxyRegisteredEventArgs, - TestAssetProxyDispatcherContract, -} from '../src'; +import { artifacts } from './artifacts'; +import { TestAssetProxyDispatcherAssetProxyRegisteredEventArgs, TestAssetProxyDispatcherContract } from './wrappers'; import { dependencyArtifacts } from './utils/dependency_artifacts'; diff --git a/contracts/exchange/test/internal.ts b/contracts/exchange/test/internal.ts index 9713714774..897662a2ad 100644 --- a/contracts/exchange/test/internal.ts +++ b/contracts/exchange/test/internal.ts @@ -7,12 +7,12 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; import { - artifacts, TestExchangeInternalsContract, TestExchangeInternalsDispatchTransferFromCalledEventArgs, TestExchangeInternalsFillEventArgs, -} from '../src'; +} from './wrappers'; blockchainTests('Exchange core internal functions', env => { const CHAIN_ID = 1337; diff --git a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts index f0c85b5394..400fb4890b 100644 --- a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts +++ b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts @@ -11,7 +11,8 @@ import { ExchangeRevertErrors, generatePseudoRandomSalt } from '@0x/order-utils' import { BigNumber, RevertError } from '@0x/utils'; import * as _ from 'lodash'; -import { artifacts, TestLibExchangeRichErrorDecoderContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLibExchangeRichErrorDecoderContract } from './wrappers'; blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults }) => { const ASSET_PROXY_ID_LENGTH = 4; diff --git a/contracts/exchange/test/match_orders.ts b/contracts/exchange/test/match_orders.ts index e05aad4316..66714ee59e 100644 --- a/contracts/exchange/test/match_orders.ts +++ b/contracts/exchange/test/match_orders.ts @@ -30,7 +30,10 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, ExchangeContract, ExchangeWrapper } from '../src'; +import { ExchangeWrapper } from './utils/exchange_wrapper'; + +import { artifacts } from './artifacts'; +import { ExchangeContract } from './wrappers'; import { MatchOrderTester, TokenBalances } from './utils/match_order_tester'; diff --git a/contracts/exchange/test/protocol_fees.ts b/contracts/exchange/test/protocol_fees.ts index 5cba8686ff..c01cd6e9b5 100644 --- a/contracts/exchange/test/protocol_fees.ts +++ b/contracts/exchange/test/protocol_fees.ts @@ -1,7 +1,8 @@ import { blockchainTests } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; -import { artifacts, TestProtocolFeesContract, TestProtocolFeesReceiverContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestProtocolFeesContract, TestProtocolFeesReceiverContract } from './wrappers'; // The contents of this test suite does not inform the reader about the assertions made in these // tests. For more information and a more accurate view of the tests, check out diff --git a/contracts/exchange/test/protocol_fees_manager.ts b/contracts/exchange/test/protocol_fees_manager.ts index 010fe122c6..480b1d9de0 100644 --- a/contracts/exchange/test/protocol_fees_manager.ts +++ b/contracts/exchange/test/protocol_fees_manager.ts @@ -2,12 +2,12 @@ import { blockchainTests, constants, expect } from '@0x/contracts-test-utils'; import { BigNumber, OwnableRevertErrors } from '@0x/utils'; import { LogWithDecodedArgs } from 'ethereum-types'; +import { artifacts } from './artifacts'; import { - artifacts, ExchangeContract, ExchangeProtocolFeeCollectorAddressEventArgs, ExchangeProtocolFeeMultiplierEventArgs, -} from '../src'; +} from './wrappers'; blockchainTests.resets('MixinProtocolFees', env => { let accounts: string[]; diff --git a/contracts/exchange/test/reentrancy_tests.ts b/contracts/exchange/test/reentrancy_tests.ts index 593c8285f2..148bfb60c1 100644 --- a/contracts/exchange/test/reentrancy_tests.ts +++ b/contracts/exchange/test/reentrancy_tests.ts @@ -3,7 +3,8 @@ import { BigNumber } from '@0x/utils'; import { DataItem, MethodAbi, TupleDataItem } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ReentrancyTesterContract } from '../src'; +import { artifacts } from './artifacts'; +import { ReentrancyTesterContract } from './wrappers'; import { constants as TestConstants } from './utils/constants'; diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts index 33aec898fb..ef0f2ff195 100644 --- a/contracts/exchange/test/signature_validator.ts +++ b/contracts/exchange/test/signature_validator.ts @@ -17,15 +17,15 @@ import { BigNumber, StringRevertError } from '@0x/utils'; import { LogWithDecodedArgs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); +import { artifacts } from './artifacts'; import { - artifacts, IEIP1271DataContract, TestSignatureValidatorContract, TestSignatureValidatorSignatureValidatorApprovalEventArgs, TestValidatorWalletContract, -} from '../src'; +} from './wrappers'; -import { ValidatorWalletAction } from './utils'; +import { ValidatorWalletAction } from './utils/constants'; // tslint:disable:no-unnecessary-type-assertion blockchainTests.resets('MixinSignatureValidator', env => { diff --git a/contracts/exchange/test/transactions.ts b/contracts/exchange/test/transactions.ts index 00e932dbe6..5ecff45135 100644 --- a/contracts/exchange/test/transactions.ts +++ b/contracts/exchange/test/transactions.ts @@ -6,6 +6,7 @@ import { blockchainTests, constants, describe, + ExchangeFunctionName, expect, getLatestBlockTimestampAsync, OrderFactory, @@ -18,19 +19,18 @@ import { LogWithDecodedArgs, MethodAbi } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; +import { exchangeDataEncoder } from '../src/exchange_data_encoder'; + +import { artifacts as localArtifacts } from './artifacts'; +import { ExchangeWrapper } from './utils/exchange_wrapper'; import { - artifacts as localArtifacts, - constants as exchangeConstants, ExchangeCancelEventArgs, ExchangeCancelUpToEventArgs, ExchangeContract, - exchangeDataEncoder, ExchangeFillEventArgs, - ExchangeFunctionName, ExchangeSignatureValidatorApprovalEventArgs, ExchangeTransactionExecutionEventArgs, - ExchangeWrapper, -} from '../src/'; +} from './wrappers'; const artifacts = { ...erc20Artifacts, ...localArtifacts }; @@ -210,9 +210,9 @@ blockchainTests.resets('Exchange transactions', env => { }); describe('fill methods', () => { for (const fnName of [ - ...exchangeConstants.SINGLE_FILL_FN_NAMES, - ...exchangeConstants.BATCH_FILL_FN_NAMES, - ...exchangeConstants.MARKET_FILL_FN_NAMES, + ...constants.SINGLE_FILL_FN_NAMES, + ...constants.BATCH_FILL_FN_NAMES, + ...constants.MARKET_FILL_FN_NAMES, ]) { it(`${fnName} should revert if signature is invalid and not called by signer`, async () => { const orders = [await orderFactory.newSignedOrderAsync()]; @@ -301,7 +301,7 @@ blockchainTests.resets('Exchange transactions', env => { const decodedReturnData = abiEncoder.decodeReturnValues(returnData); const fillResults = - exchangeConstants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1 + constants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1 ? decodedReturnData.fillResults[0] : decodedReturnData.fillResults; diff --git a/contracts/exchange/test/transactions_unit_tests.ts b/contracts/exchange/test/transactions_unit_tests.ts index 257bbf798d..35e5aec284 100644 --- a/contracts/exchange/test/transactions_unit_tests.ts +++ b/contracts/exchange/test/transactions_unit_tests.ts @@ -5,7 +5,8 @@ import { BigNumber, StringRevertError } from '@0x/utils'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, TestTransactionsContract, TestTransactionsTransactionExecutionEventArgs } from '../src'; +import { artifacts } from './artifacts'; +import { TestTransactionsContract, TestTransactionsTransactionExecutionEventArgs } from './wrappers'; blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDefaults }) => { let transactionsContract: TestTransactionsContract; diff --git a/contracts/exchange/test/utils/constants.ts b/contracts/exchange/test/utils/constants.ts index d34001dc22..cee5450e2a 100644 --- a/contracts/exchange/test/utils/constants.ts +++ b/contracts/exchange/test/utils/constants.ts @@ -1,4 +1,4 @@ -import { ExchangeFunctionName } from './types'; +import { ExchangeFunctionName } from '@0x/contracts-test-utils'; export const constants = { // These are functions not secured by the `nonReentrant`, directly or @@ -13,28 +13,6 @@ export const constants = { ExchangeFunctionName.SetProtocolFeeCollectorAddress, ExchangeFunctionName.DetachProtocolFeeCollector, ], - SINGLE_FILL_FN_NAMES: [ExchangeFunctionName.FillOrder, ExchangeFunctionName.FillOrKillOrder], - BATCH_FILL_FN_NAMES: [ - ExchangeFunctionName.BatchFillOrders, - ExchangeFunctionName.BatchFillOrKillOrders, - ExchangeFunctionName.BatchFillOrdersNoThrow, - ], - MARKET_FILL_FN_NAMES: [ - ExchangeFunctionName.MarketBuyOrdersFillOrKill, - ExchangeFunctionName.MarketSellOrdersFillOrKill, - ExchangeFunctionName.MarketBuyOrdersNoThrow, - ExchangeFunctionName.MarketSellOrdersNoThrow, - ], - MATCH_ORDER_FN_NAMES: [ExchangeFunctionName.MatchOrders, ExchangeFunctionName.MatchOrdersWithMaximalFill], - BATCH_MATCH_ORDER_FN_NAMES: [ - ExchangeFunctionName.BatchMatchOrders, - ExchangeFunctionName.BatchMatchOrdersWithMaximalFill, - ], - CANCEL_ORDER_FN_NAMES: [ - ExchangeFunctionName.CancelOrder, - ExchangeFunctionName.BatchCancelOrders, - ExchangeFunctionName.CancelOrdersUpTo, - ], }; export enum ValidatorWalletAction { diff --git a/contracts/exchange/test/utils/exchange_wrapper.ts b/contracts/exchange/test/utils/exchange_wrapper.ts index dead507440..615467c431 100644 --- a/contracts/exchange/test/utils/exchange_wrapper.ts +++ b/contracts/exchange/test/utils/exchange_wrapper.ts @@ -11,7 +11,7 @@ import { AbiEncoder, BigNumber } from '@0x/utils'; import { MethodAbi, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { ExchangeContract } from '../../src'; +import { ExchangeContract } from '../wrappers'; import { AbiDecodedFillOrderData } from './types'; diff --git a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts index b63580c95b..3fa9f6ccd1 100644 --- a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts @@ -15,7 +15,9 @@ import { LogWithDecodedArgs, TxData } from 'ethereum-types'; import * as _ from 'lodash'; import 'make-promises-safe'; -import { artifacts, ExchangeContract, ExchangeFillEventArgs } from '../../src'; +import { artifacts } from '../artifacts'; + +import { ExchangeContract, ExchangeFillEventArgs } from '../wrappers'; import { AssetWrapper } from './asset_wrapper'; import { ExchangeWrapper } from './exchange_wrapper'; diff --git a/contracts/exchange/test/utils/index.ts b/contracts/exchange/test/utils/index.ts deleted file mode 100644 index 3fe740f591..0000000000 --- a/contracts/exchange/test/utils/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './exchange_wrapper'; -export * from './exchange_data_encoder'; -export * from './types'; -export * from './constants'; diff --git a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts index 0d6f948068..0b94a9af97 100644 --- a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts +++ b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts @@ -12,12 +12,13 @@ import { TxData, Web3Wrapper } from '@0x/web3-wrapper'; import * as crypto from 'crypto'; import { LogEntry } from 'ethereum-types'; +import { artifacts } from '../artifacts'; + import { - artifacts, IsolatedExchangeContract, IsolatedExchangeDispatchTransferFromCalledEventArgs as DispatchTransferFromCallArgs, IsolatedExchangeFillEventArgs as FillEventArgs, -} from '../../src'; +} from '../wrappers'; export interface AssetBalances { [assetData: string]: { [address: string]: BigNumber }; diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index 13ae715025..3d903edca5 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -16,12 +16,12 @@ import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; import * as ethjs from 'ethereumjs-util'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; import { - artifacts, TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, TestWrapperFunctionsContract, TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, -} from '../src'; +} from './wrappers'; blockchainTests('Exchange wrapper functions unit tests.', env => { const CHAIN_ID = 0x74657374; diff --git a/contracts/exchange/test/wrappers.ts b/contracts/exchange/test/wrappers.ts new file mode 100644 index 0000000000..7daa712abe --- /dev/null +++ b/contracts/exchange/test/wrappers.ts @@ -0,0 +1,40 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/exchange'; +export * from '../test/generated-wrappers/i_asset_proxy'; +export * from '../test/generated-wrappers/i_asset_proxy_dispatcher'; +export * from '../test/generated-wrappers/i_e_i_p1271_data'; +export * from '../test/generated-wrappers/i_e_i_p1271_wallet'; +export * from '../test/generated-wrappers/i_exchange'; +export * from '../test/generated-wrappers/i_exchange_core'; +export * from '../test/generated-wrappers/i_match_orders'; +export * from '../test/generated-wrappers/i_protocol_fees'; +export * from '../test/generated-wrappers/i_signature_validator'; +export * from '../test/generated-wrappers/i_transactions'; +export * from '../test/generated-wrappers/i_transfer_simulator'; +export * from '../test/generated-wrappers/i_wallet'; +export * from '../test/generated-wrappers/i_wrapper_functions'; +export * from '../test/generated-wrappers/isolated_exchange'; +export * from '../test/generated-wrappers/lib_exchange_rich_error_decoder'; +export * from '../test/generated-wrappers/mixin_asset_proxy_dispatcher'; +export * from '../test/generated-wrappers/mixin_exchange_core'; +export * from '../test/generated-wrappers/mixin_match_orders'; +export * from '../test/generated-wrappers/mixin_protocol_fees'; +export * from '../test/generated-wrappers/mixin_signature_validator'; +export * from '../test/generated-wrappers/mixin_transactions'; +export * from '../test/generated-wrappers/mixin_transfer_simulator'; +export * from '../test/generated-wrappers/mixin_wrapper_functions'; +export * from '../test/generated-wrappers/reentrancy_tester'; +export * from '../test/generated-wrappers/test_asset_proxy_dispatcher'; +export * from '../test/generated-wrappers/test_exchange_internals'; +export * from '../test/generated-wrappers/test_lib_exchange_rich_error_decoder'; +export * from '../test/generated-wrappers/test_protocol_fee_collector'; +export * from '../test/generated-wrappers/test_protocol_fees'; +export * from '../test/generated-wrappers/test_protocol_fees_receiver'; +export * from '../test/generated-wrappers/test_signature_validator'; +export * from '../test/generated-wrappers/test_transactions'; +export * from '../test/generated-wrappers/test_validator_wallet'; +export * from '../test/generated-wrappers/test_wrapper_functions'; diff --git a/contracts/exchange/tsconfig.json b/contracts/exchange/tsconfig.json index c38484f4d5..06fbc962d6 100644 --- a/contracts/exchange/tsconfig.json +++ b/contracts/exchange/tsconfig.json @@ -4,40 +4,42 @@ "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ "generated-artifacts/Exchange.json", - "generated-artifacts/IAssetProxy.json", - "generated-artifacts/IAssetProxyDispatcher.json", - "generated-artifacts/IEIP1271Data.json", - "generated-artifacts/IEIP1271Wallet.json", "generated-artifacts/IExchange.json", - "generated-artifacts/IExchangeCore.json", - "generated-artifacts/IMatchOrders.json", - "generated-artifacts/IProtocolFees.json", - "generated-artifacts/ISignatureValidator.json", - "generated-artifacts/ITransactions.json", - "generated-artifacts/ITransferSimulator.json", - "generated-artifacts/IWallet.json", - "generated-artifacts/IWrapperFunctions.json", - "generated-artifacts/IsolatedExchange.json", - "generated-artifacts/LibExchangeRichErrorDecoder.json", - "generated-artifacts/MixinAssetProxyDispatcher.json", - "generated-artifacts/MixinExchangeCore.json", - "generated-artifacts/MixinMatchOrders.json", - "generated-artifacts/MixinProtocolFees.json", - "generated-artifacts/MixinSignatureValidator.json", - "generated-artifacts/MixinTransactions.json", - "generated-artifacts/MixinTransferSimulator.json", - "generated-artifacts/MixinWrapperFunctions.json", - "generated-artifacts/ReentrancyTester.json", - "generated-artifacts/TestAssetProxyDispatcher.json", - "generated-artifacts/TestExchangeInternals.json", - "generated-artifacts/TestLibExchangeRichErrorDecoder.json", - "generated-artifacts/TestProtocolFeeCollector.json", - "generated-artifacts/TestProtocolFees.json", - "generated-artifacts/TestProtocolFeesReceiver.json", - "generated-artifacts/TestSignatureValidator.json", - "generated-artifacts/TestTransactions.json", - "generated-artifacts/TestValidatorWallet.json", - "generated-artifacts/TestWrapperFunctions.json" + "test/generated-artifacts/Exchange.json", + "test/generated-artifacts/IAssetProxy.json", + "test/generated-artifacts/IAssetProxyDispatcher.json", + "test/generated-artifacts/IEIP1271Data.json", + "test/generated-artifacts/IEIP1271Wallet.json", + "test/generated-artifacts/IExchange.json", + "test/generated-artifacts/IExchangeCore.json", + "test/generated-artifacts/IMatchOrders.json", + "test/generated-artifacts/IProtocolFees.json", + "test/generated-artifacts/ISignatureValidator.json", + "test/generated-artifacts/ITransactions.json", + "test/generated-artifacts/ITransferSimulator.json", + "test/generated-artifacts/IWallet.json", + "test/generated-artifacts/IWrapperFunctions.json", + "test/generated-artifacts/IsolatedExchange.json", + "test/generated-artifacts/LibExchangeRichErrorDecoder.json", + "test/generated-artifacts/MixinAssetProxyDispatcher.json", + "test/generated-artifacts/MixinExchangeCore.json", + "test/generated-artifacts/MixinMatchOrders.json", + "test/generated-artifacts/MixinProtocolFees.json", + "test/generated-artifacts/MixinSignatureValidator.json", + "test/generated-artifacts/MixinTransactions.json", + "test/generated-artifacts/MixinTransferSimulator.json", + "test/generated-artifacts/MixinWrapperFunctions.json", + "test/generated-artifacts/ReentrancyTester.json", + "test/generated-artifacts/TestAssetProxyDispatcher.json", + "test/generated-artifacts/TestExchangeInternals.json", + "test/generated-artifacts/TestLibExchangeRichErrorDecoder.json", + "test/generated-artifacts/TestProtocolFeeCollector.json", + "test/generated-artifacts/TestProtocolFees.json", + "test/generated-artifacts/TestProtocolFeesReceiver.json", + "test/generated-artifacts/TestSignatureValidator.json", + "test/generated-artifacts/TestTransactions.json", + "test/generated-artifacts/TestValidatorWallet.json", + "test/generated-artifacts/TestWrapperFunctions.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/extensions/.npmignore b/contracts/extensions/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/extensions/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/extensions/CHANGELOG.json b/contracts/extensions/CHANGELOG.json index 5372faa434..367e7892bf 100644 --- a/contracts/extensions/CHANGELOG.json +++ b/contracts/extensions/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "4.1.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "4.1.0-beta.1", "changes": [ 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..b30c5ae98e 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,20 +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": { + "publicInterfaceContracts": "DutchAuction,OrderMatcher,BalanceThresholdFilter", "abis": "./generated-artifacts/@(BalanceThresholdFilter|DutchAuction|Exchange|ExchangeWrapper|OrderMatcher|WETH9).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, @@ -51,6 +53,17 @@ "@0x/abi-gen": "^4.4.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", + "@0x/contracts-asset-proxy": "^2.3.0-beta.1", + "@0x/contracts-dev-utils": "^0.1.0-beta.1", + "@0x/contracts-erc20": "^2.3.0-beta.1", + "@0x/contracts-erc721": "^2.2.0-beta.1", + "@0x/contracts-exchange": "^2.2.0-beta.1", + "@0x/contracts-exchange-libs": "^3.1.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/order-utils": "^8.5.0-beta.1", + "@0x/utils": "^4.6.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", + "@0x/types": "^2.5.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", @@ -61,6 +74,7 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -72,20 +86,8 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contracts-asset-proxy": "^2.3.0-beta.1", - "@0x/contracts-dev-utils": "^0.1.0-beta.1", - "@0x/contracts-erc20": "^2.3.0-beta.1", - "@0x/contracts-erc721": "^2.2.0-beta.1", - "@0x/contracts-exchange": "^2.2.0-beta.1", - "@0x/contracts-exchange-libs": "^3.1.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", - "@0x/order-utils": "^8.5.0-beta.1", - "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", - "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "lodash": "^4.17.11" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/extensions/src/index.ts b/contracts/extensions/src/index.ts index ba813e7caf..d55f08ea2d 100644 --- a/contracts/extensions/src/index.ts +++ b/contracts/extensions/src/index.ts @@ -1,3 +1,2 @@ export * from './artifacts'; export * from './wrappers'; -export * from '../test/utils'; diff --git a/contracts/extensions/test/balance_threshold_filter.ts b/contracts/extensions/test/balance_threshold_filter.ts index 7fe4ee5566..311a746076 100644 --- a/contracts/extensions/test/balance_threshold_filter.ts +++ b/contracts/extensions/test/balance_threshold_filter.ts @@ -1,5 +1,5 @@ import { DevUtilsContract } from '@0x/contracts-dev-utils'; -import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { ExchangeRevertErrors } from '@0x/order-utils'; import { Order, RevertReason, SignedOrder } from '@0x/types'; @@ -24,7 +24,11 @@ import { web3Wrapper, } from '@0x/contracts-test-utils'; -import { artifacts, BalanceThresholdFilterContract, BalanceThresholdWrapper } from '../src'; +import { BalanceThresholdWrapper } from './utils/balance_threshold_wrapper'; + +import { BalanceThresholdFilterContract } from './wrappers'; + +import { artifacts } from './artifacts'; chaiSetup.configure(); const expect = chai.expect; @@ -52,7 +56,6 @@ describe(ContractName.BalanceThresholdFilter, () => { let zrxAssetData: string; let zrxToken: DummyERC20TokenContract; let exchangeInstance: ExchangeContract; - let exchangeWrapper: ExchangeWrapper; let devUtils: DevUtilsContract; let orderFactory: OrderFactory; @@ -139,9 +142,10 @@ describe(ContractName.BalanceThresholdFilter, () => { zrxAssetData, new BigNumber(chainId), ); - exchangeWrapper = new ExchangeWrapper(exchangeInstance); // Register proxies - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); + await exchangeInstance.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + from: owner, + }); await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { from: owner, }); diff --git a/contracts/extensions/test/dutch_auction.ts b/contracts/extensions/test/dutch_auction.ts index c7cfab18ab..ab9598147f 100644 --- a/contracts/extensions/test/dutch_auction.ts +++ b/contracts/extensions/test/dutch_auction.ts @@ -2,7 +2,7 @@ import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { DummyERC20TokenContract } from '@0x/contracts-erc20'; import { DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -22,7 +22,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, DutchAuctionContract, DutchAuctionTestWrapper, WETH9Contract } from '../src'; +import { DutchAuctionContract, DutchAuctionTestWrapper, WETH9Contract } from './wrappers'; + +import { artifacts } from './artifacts'; chaiSetup.configure(); const expect = chai.expect; @@ -98,9 +100,12 @@ describe(ContractName.DutchAuction, () => { zrxAssetData, new BigNumber(chainId), ); - const exchangeWrapper = new ExchangeWrapper(exchangeInstance); - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); + await exchangeInstance.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + from: owner, + }); + await exchangeInstance.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { + from: owner, + }); await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { from: owner, diff --git a/contracts/extensions/test/order_matcher.ts b/contracts/extensions/test/order_matcher.ts index bd85592601..561435373b 100644 --- a/contracts/extensions/test/order_matcher.ts +++ b/contracts/extensions/test/order_matcher.ts @@ -7,7 +7,7 @@ import { import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { DummyERC20TokenContract } from '@0x/contracts-erc20'; import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -15,6 +15,7 @@ import { expectContractCreationFailedAsync, LogDecoder, OrderFactory, + orderUtils, provider, sendTransactionResult, txDefaults, @@ -29,7 +30,9 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ExchangeFillEventArgs, OrderMatcherContract } from '../src'; +import { ExchangeFillEventArgs, OrderMatcherContract } from './wrappers'; + +import { artifacts } from './artifacts'; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); chaiSetup.configure(); @@ -53,7 +56,6 @@ describe('OrderMatcher', () => { let orderMatcher: OrderMatcherContract; let erc20BalancesByOwner: ERC20BalancesByOwner; - let exchangeWrapper: ExchangeWrapper; let erc20Wrapper: ERC20Wrapper; let orderFactoryLeft: OrderFactory; let orderFactoryRight: OrderFactory; @@ -117,10 +119,12 @@ describe('OrderMatcher', () => { await devUtils.encodeERC20AssetData.callAsync(zrxToken.address), new BigNumber(chainId), ); - exchangeWrapper = new ExchangeWrapper(exchange); - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); - // Authorize ERC20 trades by exchange + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + from: owner, + }); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { + from: owner, + }); // Authorize ERC20 trades by exchange await web3Wrapper.awaitTransactionSuccessAsync( await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner, @@ -486,12 +490,20 @@ describe('OrderMatcher', () => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18), }); - await exchangeWrapper.fillOrderAsync(signedOrderLeft, takerAddress, { - takerAssetFillAmount: signedOrderLeft.takerAssetAmount.dividedToIntegerBy(5), - }); - await exchangeWrapper.fillOrderAsync(signedOrderRight, takerAddress, { - takerAssetFillAmount: signedOrderRight.takerAssetAmount.dividedToIntegerBy(5), - }); + let params = orderUtils.createFill(signedOrderLeft, signedOrderLeft.takerAssetAmount.dividedToIntegerBy(5)); + await exchange.fillOrder.awaitTransactionSuccessAsync( + params.order, + params.takerAssetFillAmount, + params.signature, + { from: takerAddress }, + ); + params = orderUtils.createFill(signedOrderRight, signedOrderRight.takerAssetAmount.dividedToIntegerBy(5)); + await exchange.fillOrder.awaitTransactionSuccessAsync( + params.order, + params.takerAssetFillAmount, + params.signature, + { from: takerAddress }, + ); const data = exchange.matchOrders.getABIEncodedTransactionData( signedOrderLeft, signedOrderRight, diff --git a/contracts/extensions/test/utils/balance_threshold_wrapper.ts b/contracts/extensions/test/utils/balance_threshold_wrapper.ts index 30d1798aeb..627e7c1a30 100644 --- a/contracts/extensions/test/utils/balance_threshold_wrapper.ts +++ b/contracts/extensions/test/utils/balance_threshold_wrapper.ts @@ -13,7 +13,9 @@ import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import { artifacts, BalanceThresholdFilterContract } from '../../src'; +import { BalanceThresholdFilterContract } from './wrappers'; + +import { artifacts } from './artifacts'; export class BalanceThresholdWrapper { private readonly _balanceThresholdFilter: BalanceThresholdFilterContract; diff --git a/contracts/integrations/.npmignore b/contracts/integrations/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/integrations/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore 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..9a5d5a3bf7 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,21 +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 --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 --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/@(TestFramework).json", + "publicInterfaceContracts": "TestFramework", + "abis": "./test/generated-artifacts/@(TestFramework).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { @@ -50,9 +52,16 @@ "devDependencies": { "@0x/abi-gen": "^4.4.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", + "@0x/contracts-coordinator": "^2.1.0-beta.1", + "@0x/contracts-dev-utils": "^0.1.0-beta.1", + "@0x/contracts-exchange-forwarder": "^3.1.0-beta.1", + "@0x/contracts-exchange-libs": "^3.1.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/order-utils": "^8.5.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -72,23 +81,16 @@ "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", "@0x/contracts-asset-proxy": "^2.3.0-beta.1", - "@0x/contracts-coordinator": "^2.1.0-beta.1", - "@0x/contracts-dev-utils": "^0.1.0-beta.1", "@0x/contracts-erc1155": "^1.2.0-beta.1", "@0x/contracts-erc20": "^2.3.0-beta.1", "@0x/contracts-erc721": "^2.2.0-beta.1", "@0x/contracts-exchange": "^2.2.0-beta.1", - "@0x/contracts-exchange-forwarder": "^3.1.0-beta.1", - "@0x/contracts-exchange-libs": "^3.1.0-beta.1", "@0x/contracts-multisig": "^3.2.0-beta.1", "@0x/contracts-staking": "^1.1.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", - "@0x/order-utils": "^8.5.0-beta.1", "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", "ethereum-types": "^2.2.0-beta.1", "lodash": "^4.17.11" }, diff --git a/contracts/integrations/test/utils/function_assertions.ts b/contracts/integrations/src/function_assertions.ts similarity index 98% rename from contracts/integrations/test/utils/function_assertions.ts rename to contracts/integrations/src/function_assertions.ts index 37ebceb2cc..e6b3f27e6f 100644 --- a/contracts/integrations/test/utils/function_assertions.ts +++ b/contracts/integrations/src/function_assertions.ts @@ -84,10 +84,12 @@ export class FunctionAssertion implements Assertion { // result and receipt to the after condition. try { callResult.data = await this.wrapperFunction.callAsync(...args); + // tslint:disable:await-promise callResult.receipt = this.wrapperFunction.awaitTransactionSuccessAsync !== undefined ? await this.wrapperFunction.awaitTransactionSuccessAsync(...args) : undefined; + // tslint:enable:await-promise } catch (error) { callResult.data = error; callResult.success = false; diff --git a/contracts/integrations/src/index.ts b/contracts/integrations/src/index.ts index 97179831da..d595a9f090 100644 --- a/contracts/integrations/src/index.ts +++ b/contracts/integrations/src/index.ts @@ -1,4 +1,3 @@ export * from './artifacts'; export * from './wrappers'; -export * from '../test/utils/function_assertions'; -export * from '../test/utils/deployment_manager'; +export * from './function_assertions'; diff --git a/contracts/integrations/test/actors/base.ts b/contracts/integrations/test/actors/base.ts index a763e02f8d..285352aed8 100644 --- a/contracts/integrations/test/actors/base.ts +++ b/contracts/integrations/test/actors/base.ts @@ -5,7 +5,7 @@ import { SignatureType, SignedZeroExTransaction, ZeroExTransaction } from '@0x/t import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; export type Constructor = new (...args: any[]) => T; diff --git a/contracts/integrations/test/actors/taker.ts b/contracts/integrations/test/actors/taker.ts index a63311b139..c591d07888 100644 --- a/contracts/integrations/test/actors/taker.ts +++ b/contracts/integrations/test/actors/taker.ts @@ -2,7 +2,7 @@ import { SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; import { Actor, Constructor } from './base'; diff --git a/contracts/integrations/test/actors/utils.ts b/contracts/integrations/test/actors/utils.ts index 9311e170b6..2164cbeec6 100644 --- a/contracts/integrations/test/actors/utils.ts +++ b/contracts/integrations/test/actors/utils.ts @@ -1,4 +1,4 @@ -import { TokenOwnersByName } from '@0x/contracts-exchange'; +import { ObjectMap } from '@0x/types'; import * as _ from 'lodash'; import { Actor } from './base'; @@ -7,6 +7,6 @@ import { Actor } from './base'; * Utility function to convert Actors into an object mapping readable names to addresses. * Useful for BalanceStore. */ -export function actorAddressesByName(actors: Actor[]): TokenOwnersByName { +export function actorAddressesByName(actors: Actor[]): ObjectMap { return _.zipObject(actors.map(actor => actor.name), actors.map(actor => actor.address)); } diff --git a/contracts/integrations/test/artifacts.ts b/contracts/integrations/test/artifacts.ts new file mode 100644 index 0000000000..8ea0d872cf --- /dev/null +++ b/contracts/integrations/test/artifacts.ts @@ -0,0 +1,9 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as TestFramework from '../test/generated-artifacts/TestFramework.json'; +export const artifacts = { TestFramework: TestFramework as ContractArtifact }; diff --git a/contracts/integrations/test/coordinator/coordinator_test.ts b/contracts/integrations/test/coordinator/coordinator_test.ts index d953739a3f..7178534295 100644 --- a/contracts/integrations/test/coordinator/coordinator_test.ts +++ b/contracts/integrations/test/coordinator/coordinator_test.ts @@ -2,18 +2,17 @@ import { CoordinatorContract, SignedCoordinatorApproval } from '@0x/contracts-co import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { BlockchainBalanceStore, - constants as exchangeConstants, ExchangeCancelEventArgs, ExchangeCancelUpToEventArgs, exchangeDataEncoder, ExchangeEvents, ExchangeFillEventArgs, - ExchangeFunctionName, LocalBalanceStore, } from '@0x/contracts-exchange'; import { blockchainTests, constants, + ExchangeFunctionName, expect, hexConcat, hexSlice, @@ -26,7 +25,7 @@ import { BigNumber } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import { Actor, actorAddressesByName, FeeRecipient, Maker } from '../actors'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; import { deployCoordinatorAsync } from './deploy_coordinator'; @@ -174,7 +173,7 @@ blockchainTests.resets('Coordinator integration tests', env => { let transaction: SignedZeroExTransaction; let approval: SignedCoordinatorApproval; - for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { + for (const fnName of constants.SINGLE_FILL_FN_NAMES) { before(async () => { order = await maker.signOrderAsync(); data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, [order]); @@ -321,7 +320,7 @@ blockchainTests.resets('Coordinator integration tests', env => { let transaction: SignedZeroExTransaction; let approval: SignedCoordinatorApproval; - for (const fnName of [...exchangeConstants.MARKET_FILL_FN_NAMES, ...exchangeConstants.BATCH_FILL_FN_NAMES]) { + for (const fnName of [...constants.MARKET_FILL_FN_NAMES, ...constants.BATCH_FILL_FN_NAMES]) { before(async () => { orders = [await maker.signOrderAsync(), await maker.signOrderAsync()]; data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); diff --git a/contracts/integrations/test/coordinator/deploy_coordinator.ts b/contracts/integrations/test/coordinator/deploy_coordinator.ts index f5b1c93842..90b274da60 100644 --- a/contracts/integrations/test/coordinator/deploy_coordinator.ts +++ b/contracts/integrations/test/coordinator/deploy_coordinator.ts @@ -3,7 +3,7 @@ import { artifacts as exchangeArtifacts } from '@0x/contracts-exchange'; import { BlockchainTestsEnvironment } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; /** * Deploys a Coordinator contract configured to work alongside the provided `deployment`. diff --git a/contracts/integrations/test/utils/deployment_manager.ts b/contracts/integrations/test/deployment_manager.ts similarity index 99% rename from contracts/integrations/test/utils/deployment_manager.ts rename to contracts/integrations/test/deployment_manager.ts index b67008cbf1..7695f0c8af 100644 --- a/contracts/integrations/test/utils/deployment_manager.ts +++ b/contracts/integrations/test/deployment_manager.ts @@ -9,13 +9,7 @@ import { import { artifacts as ERC1155Artifacts, ERC1155MintableContract } from '@0x/contracts-erc1155'; import { artifacts as ERC20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20'; import { artifacts as ERC721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { - artifacts as exchangeArtifacts, - AssetProxyDispatcher, - Authorizable, - ExchangeContract, - Ownable, -} from '@0x/contracts-exchange'; +import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange'; import { artifacts as multisigArtifacts, ZeroExGovernorContract } from '@0x/contracts-multisig'; import { artifacts as stakingArtifacts, @@ -28,6 +22,8 @@ import { BigNumber } from '@0x/utils'; import { TxData } from 'ethereum-types'; import * as _ from 'lodash'; +import { AssetProxyDispatcher, Authorizable, Ownable } from './wrapper_interfaces'; + /** * Adds a batch of authorities to a list of authorizable contracts. * @param owner The owner of the authorizable contracts. diff --git a/contracts/integrations/test/forwarder/deploy_forwarder.ts b/contracts/integrations/test/forwarder/deploy_forwarder.ts index 88056fb423..27630b441c 100644 --- a/contracts/integrations/test/forwarder/deploy_forwarder.ts +++ b/contracts/integrations/test/forwarder/deploy_forwarder.ts @@ -3,7 +3,7 @@ import { artifacts, ForwarderContract } from '@0x/contracts-exchange-forwarder'; import { BlockchainTestsEnvironment } from '@0x/contracts-test-utils'; import { assetDataUtils } from '@0x/order-utils'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; /** * Deploys a Forwarder contract configured to work alongside the provided `deployment`. diff --git a/contracts/integrations/test/forwarder/forwarder_test.ts b/contracts/integrations/test/forwarder/forwarder_test.ts index f521b9e44c..c3f91abef3 100644 --- a/contracts/integrations/test/forwarder/forwarder_test.ts +++ b/contracts/integrations/test/forwarder/forwarder_test.ts @@ -21,7 +21,7 @@ import { ForwarderRevertErrors } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; import { Actor, actorAddressesByName, FeeRecipient, Maker } from '../actors'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; import { deployForwarderAsync } from './deploy_forwarder'; import { ForwarderTestFactory } from './forwarder_test_factory'; diff --git a/contracts/integrations/test/forwarder/forwarder_test_factory.ts b/contracts/integrations/test/forwarder/forwarder_test_factory.ts index fcc0b83199..e8b5ec3074 100644 --- a/contracts/integrations/test/forwarder/forwarder_test_factory.ts +++ b/contracts/integrations/test/forwarder/forwarder_test_factory.ts @@ -7,7 +7,7 @@ import { BigNumber, RevertError } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import { Actor, FeeRecipient, Maker } from '../actors'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; // Necessary bookkeeping to validate Forwarder results interface ForwarderFillState { diff --git a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts index 7cc4a15424..953ddc2606 100644 --- a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts +++ b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts @@ -1,8 +1,8 @@ -import { Authorizable, Ownable } from '@0x/contracts-exchange'; import { constants as stakingConstants } from '@0x/contracts-staking'; import { blockchainTests, expect } from '@0x/contracts-test-utils'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; +import { Authorizable, Ownable } from '../wrapper_interfaces'; blockchainTests('Deployment Manager', env => { let owner: string; diff --git a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts index f10ec1efb7..4d5175e70a 100644 --- a/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts +++ b/contracts/integrations/test/framework-unit-tests/function_assertion_test.ts @@ -2,8 +2,10 @@ import { blockchainTests, constants, expect, filterLogsToArguments, getRandomInt import { BigNumber, StringRevertError } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import { artifacts, TestFrameworkContract, TestFrameworkEventEventArgs, TestFrameworkEvents } from '../../src'; -import { FunctionAssertion, Result } from '../utils/function_assertions'; +import { FunctionAssertion, Result } from '../../src/function_assertions'; + +import { artifacts } from '../artifacts'; +import { TestFrameworkContract, TestFrameworkEventEventArgs, TestFrameworkEvents } from '../wrappers'; const { ZERO_AMOUNT, MAX_UINT256 } = constants; diff --git a/contracts/integrations/test/internal-integration-tests/deployment_test.ts b/contracts/integrations/test/internal-integration-tests/deployment_test.ts index d6e49e0e09..f569dac429 100644 --- a/contracts/integrations/test/internal-integration-tests/deployment_test.ts +++ b/contracts/integrations/test/internal-integration-tests/deployment_test.ts @@ -8,14 +8,11 @@ import { } from '@0x/contracts-asset-proxy'; import { artifacts as exchangeArtifacts, - AssetProxyDispatcher, - Authorizable, ExchangeAssetProxyRegisteredEventArgs, ExchangeContract, ExchangeEvents, ExchangeProtocolFeeCollectorAddressEventArgs, ExchangeProtocolFeeMultiplierEventArgs, - Ownable, } from '@0x/contracts-exchange'; import { artifacts as multisigArtifacts, ZeroExGovernorContract } from '@0x/contracts-multisig'; import { @@ -36,6 +33,8 @@ import { AssetProxyId } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { TxData } from 'ethereum-types'; +import { AssetProxyDispatcher, Authorizable, Ownable } from '../wrapper_interfaces'; + // tslint:disable:no-unnecessary-type-assertion blockchainTests('Deployment and Configuration End to End Tests', env => { // Available Addresses diff --git a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts index 2ba36dcce6..14df0ba1f5 100644 --- a/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts +++ b/contracts/integrations/test/internal-integration-tests/exchange_wrapper_test.ts @@ -1,6 +1,6 @@ import { artifacts as assetProxyArtifacts } from '@0x/contracts-asset-proxy'; import { DevUtilsContract } from '@0x/contracts-dev-utils'; -import { IERC20TokenEvents, IERC20TokenTransferEventArgs } from '@0x/contracts-erc20'; +import { artifacts as erc20Artifacts, ERC20TokenEvents, ERC20TokenTransferEventArgs } from '@0x/contracts-erc20'; import { artifacts as exchangeArtifacts, BlockchainBalanceStore, @@ -30,7 +30,7 @@ import * as _ from 'lodash'; import { Actor } from '../actors/base'; import { Maker } from '../actors/maker'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; const { addFillResults, safeGetPartialAmountFloor } = ReferenceFunctions; @@ -117,6 +117,7 @@ blockchainTests.resets('Exchange wrappers', env => { ...assetProxyArtifacts, ...exchangeArtifacts, ...stakingArtifacts, + ...erc20Artifacts, }); }); @@ -192,7 +193,7 @@ blockchainTests.resets('Exchange wrappers', env => { function verifyFillEvents(receipt: TransactionReceiptWithDecodedLogs, fillTestInfos: FillTestInfo[]): void { const expectedFillEvents: IExchangeFillEventArgs[] = []; - let expectedTransferEvents: IERC20TokenTransferEventArgs[] = []; + let expectedTransferEvents: ERC20TokenTransferEventArgs[] = []; for (const { signedOrder, expectedFillResults, shouldPayWethFees } of fillTestInfos) { const orderHash = orderHashUtils.getOrderHashHex(signedOrder); @@ -248,7 +249,7 @@ blockchainTests.resets('Exchange wrappers', env => { expectedTransferEvents = expectedTransferEvents.concat(transferEvents); } verifyEvents(receipt, expectedFillEvents, IExchangeEvents.Fill); - verifyEvents(receipt, expectedTransferEvents, IERC20TokenEvents.Transfer); + verifyEvents(receipt, expectedTransferEvents, ERC20TokenEvents.Transfer); } function calculateScaledFillResultsWithMaker(signedOrder: SignedOrder, fillAmount: BigNumber): FillResults { diff --git a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts index 16f532f609..ce56b856a3 100644 --- a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts +++ b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts @@ -1,9 +1,9 @@ import { DevUtilsContract } from '@0x/contracts-dev-utils'; -import { IERC20TokenEvents, IERC20TokenTransferEventArgs } from '@0x/contracts-erc20'; +import { ERC20TokenEvents, ERC20TokenTransferEventArgs } from '@0x/contracts-erc20'; import { BlockchainBalanceStore, - IExchangeEvents, - IExchangeFillEventArgs, + ExchangeEvents, + ExchangeFillEventArgs, LocalBalanceStore, } from '@0x/contracts-exchange'; import { @@ -21,7 +21,7 @@ import { BigNumber } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import { actorAddressesByName, FeeRecipient, Maker, OperatorStakerMaker, StakerKeeper, Taker } from '../actors'; -import { DeploymentManager } from '../utils/deployment_manager'; +import { DeploymentManager } from '../deployment_manager'; const devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider); blockchainTests.resets('fillOrder integration tests', env => { @@ -142,7 +142,7 @@ blockchainTests.resets('fillOrder integration tests', env => { function verifyFillEvents(order: SignedOrder, receipt: TransactionReceiptWithDecodedLogs): void { // Ensure that the fill event was correct. - verifyEvents( + verifyEvents( receipt, [ { @@ -162,11 +162,11 @@ blockchainTests.resets('fillOrder integration tests', env => { protocolFeePaid: DeploymentManager.protocolFee, }, ], - IExchangeEvents.Fill, + ExchangeEvents.Fill, ); // Ensure that the transfer events were correctly emitted. - verifyEvents( + verifyEvents( receipt, [ { @@ -180,7 +180,7 @@ blockchainTests.resets('fillOrder integration tests', env => { _value: order.makerAssetAmount, }, ], - IERC20TokenEvents.Transfer, + ERC20TokenEvents.Transfer, ); } diff --git a/contracts/exchange/src/wrapper_interfaces.ts b/contracts/integrations/test/wrapper_interfaces.ts similarity index 100% rename from contracts/exchange/src/wrapper_interfaces.ts rename to contracts/integrations/test/wrapper_interfaces.ts diff --git a/contracts/integrations/test/wrappers.ts b/contracts/integrations/test/wrappers.ts new file mode 100644 index 0000000000..74a642fc95 --- /dev/null +++ b/contracts/integrations/test/wrappers.ts @@ -0,0 +1,6 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/test_framework'; diff --git a/contracts/integrations/tsconfig.json b/contracts/integrations/tsconfig.json index 7f0aa6948a..18b5c60dac 100644 --- a/contracts/integrations/tsconfig.json +++ b/contracts/integrations/tsconfig.json @@ -2,5 +2,5 @@ "extends": "../../tsconfig", "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], - "files": ["generated-artifacts/TestFramework.json"] + "files": ["generated-artifacts/TestFramework.json", "test/generated-artifacts/TestFramework.json"] } diff --git a/contracts/multisig/.npmignore b/contracts/multisig/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/multisig/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/multisig/CHANGELOG.json b/contracts/multisig/CHANGELOG.json index e68d4209d4..43e3f9273a 100644 --- a/contracts/multisig/CHANGELOG.json +++ b/contracts/multisig/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.2.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "3.2.0-beta.1", "changes": [ 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..804cfd6f13 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,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" }, "config": { - "abis": "./generated-artifacts/@(ContractCallReceiver|MultiSigWallet|MultiSigWalletWithTimeLock|TestRejectEther|TestZeroExGovernor|ZeroExGovernor).json", + "publicInterfaceContracts": "MultiSigWalletWithTimeLock,ZeroExGovernor", + "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": { @@ -49,10 +51,16 @@ "devDependencies": { "@0x/abi-gen": "^4.4.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", + "@0x/contracts-asset-proxy": "^2.3.0-beta.1", + "@0x/contracts-erc20": "^2.3.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/types": "^2.5.0-beta.1", "@0x/contracts-test-utils": "^3.2.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/utils": "^4.6.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", "@types/node": "*", @@ -60,6 +68,7 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -70,15 +79,8 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contracts-asset-proxy": "^2.3.0-beta.1", - "@0x/contracts-erc20": "^2.3.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", - "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", - "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", - "ethereum-types": "^2.2.0-beta.1", - "lodash": "^4.17.11" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/multisig/src/artifacts.ts b/contracts/multisig/src/artifacts.ts index 8a0baca5d1..b9f2145823 100644 --- a/contracts/multisig/src/artifacts.ts +++ b/contracts/multisig/src/artifacts.ts @@ -5,17 +5,9 @@ */ import { ContractArtifact } from 'ethereum-types'; -import * as ContractCallReceiver from '../generated-artifacts/ContractCallReceiver.json'; -import * as MultiSigWallet from '../generated-artifacts/MultiSigWallet.json'; import * as MultiSigWalletWithTimeLock from '../generated-artifacts/MultiSigWalletWithTimeLock.json'; -import * as TestRejectEther from '../generated-artifacts/TestRejectEther.json'; -import * as TestZeroExGovernor from '../generated-artifacts/TestZeroExGovernor.json'; import * as ZeroExGovernor from '../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/src/index.ts b/contracts/multisig/src/index.ts index ba813e7caf..d55f08ea2d 100644 --- a/contracts/multisig/src/index.ts +++ b/contracts/multisig/src/index.ts @@ -1,3 +1,2 @@ export * from './artifacts'; export * from './wrappers'; -export * from '../test/utils'; diff --git a/contracts/multisig/src/wrappers.ts b/contracts/multisig/src/wrappers.ts index 2bd971f5d3..e4ae7b41c1 100644 --- a/contracts/multisig/src/wrappers.ts +++ b/contracts/multisig/src/wrappers.ts @@ -3,9 +3,5 @@ * Warning: This file is auto-generated by contracts-gen. Don't edit manually. * ----------------------------------------------------------------------------- */ -export * from '../generated-wrappers/contract_call_receiver'; -export * from '../generated-wrappers/multi_sig_wallet'; export * from '../generated-wrappers/multi_sig_wallet_with_time_lock'; -export * from '../generated-wrappers/test_reject_ether'; -export * from '../generated-wrappers/test_zero_ex_governor'; export * from '../generated-wrappers/zero_ex_governor'; 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/multi_sig_with_time_lock.ts b/contracts/multisig/test/multi_sig_with_time_lock.ts index 6f59a7f60b..b0d0378b0b 100644 --- a/contracts/multisig/test/multi_sig_with_time_lock.ts +++ b/contracts/multisig/test/multi_sig_with_time_lock.ts @@ -15,17 +15,18 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; import { - artifacts, MultiSigWalletWithTimeLockConfirmationEventArgs, MultiSigWalletWithTimeLockConfirmationTimeSetEventArgs, MultiSigWalletWithTimeLockContract, MultiSigWalletWithTimeLockExecutionEventArgs, MultiSigWalletWithTimeLockExecutionFailureEventArgs, MultiSigWalletWithTimeLockSubmissionEventArgs, - MultiSigWrapper, TestRejectEtherContract, -} from '../src'; +} from './wrappers'; + +import { MultiSigWrapper } from './utils/multi_sig_wrapper'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/multisig/test/utils/multi_sig_wrapper.ts b/contracts/multisig/test/utils/multi_sig_wrapper.ts index 11f2ce51eb..bc74782000 100644 --- a/contracts/multisig/test/utils/multi_sig_wrapper.ts +++ b/contracts/multisig/test/utils/multi_sig_wrapper.ts @@ -3,8 +3,8 @@ import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import { MultiSigWalletContract, MultiSigWalletWithTimeLockContract } from '../../src'; -import { artifacts } from '../../src/artifacts'; +import { artifacts } from '../artifacts'; +import { MultiSigWalletContract, MultiSigWalletWithTimeLockContract } from '../wrappers'; export class MultiSigWrapper { private readonly _multiSig: MultiSigWalletContract | MultiSigWalletWithTimeLockContract; diff --git a/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts b/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts index 19a0688fd9..a7c20dd07c 100644 --- a/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts +++ b/contracts/multisig/test/utils/zero_ex_governor_wrapper.ts @@ -3,7 +3,7 @@ import { AbiEncoder, BigNumber } from '@0x/utils'; import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { TestZeroExGovernorContract, ZeroExGovernorContract, ZeroExGovernorSubmissionEventArgs } from '../../src'; +import { TestZeroExGovernorContract, ZeroExGovernorContract, ZeroExGovernorSubmissionEventArgs } from '../wrappers'; // tslint:disable: no-unnecessary-type-assertion export class ZeroExGovernorWrapper { 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/test/zero_ex_governor.ts b/contracts/multisig/test/zero_ex_governor.ts index 9615070613..77b5359031 100644 --- a/contracts/multisig/test/zero_ex_governor.ts +++ b/contracts/multisig/test/zero_ex_governor.ts @@ -4,15 +4,16 @@ import { BigNumber, LibBytesRevertErrors } from '@0x/utils'; import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; +import { ZeroExGovernorWrapper } from './utils/zero_ex_governor_wrapper'; + +import { artifacts } from './artifacts'; import { - artifacts, ContractCallReceiverContract, ContractCallReceiverEventArgs, TestZeroExGovernorContract, ZeroExGovernorExecutionEventArgs, ZeroExGovernorFunctionCallTimeLockRegistrationEventArgs, - ZeroExGovernorWrapper, -} from '../src'; +} from './wrappers'; // tslint:disable: no-unnecessary-type-assertion blockchainTests.resets('ZeroExGovernor', env => { diff --git a/contracts/multisig/tsconfig.json b/contracts/multisig/tsconfig.json index 643ad217e9..033cabd126 100644 --- a/contracts/multisig/tsconfig.json +++ b/contracts/multisig/tsconfig.json @@ -3,12 +3,14 @@ "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "generated-artifacts/ContractCallReceiver.json", - "generated-artifacts/MultiSigWallet.json", "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/.npmignore b/contracts/staking/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/staking/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/staking/CHANGELOG.json b/contracts/staking/CHANGELOG.json index cc59fe576c..1c20be9014 100644 --- a/contracts/staking/CHANGELOG.json +++ b/contracts/staking/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "1.1.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "1.1.0-beta.1", "changes": [ 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..73d0cccd3f 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,24 @@ "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": { + "publicInterfaceContracts": "IStaking,IStakingEvents,IStakingProxy,IZrxVault,LibStakingRichErrors,Staking,StakingProxy,ZrxVault,TestStaking", "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", @@ -53,7 +55,12 @@ "@0x/contracts-dev-utils": "^0.1.0-beta.1", "@0x/contracts-exchange-libs": "^3.1.0-beta.1", "@0x/contracts-gen": "^1.1.0-beta.1", - "@0x/contracts-test-utils": "^3.2.0-beta.1", + "@0x/contracts-asset-proxy": "^2.3.0-beta.1", + "@0x/contracts-erc20": "^2.3.0-beta.1", + "@0x/contracts-utils": "^3.3.0-beta.1", + "@0x/order-utils": "^8.5.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", + "@0x/types": "^2.5.0-beta.1", "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", @@ -67,6 +74,7 @@ "js-combinatorics": "^0.5.3", "make-promises-safe": "^1.1.0", "mocha": "^4.1.0", + "lodash": "^4.17.11", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "solhint": "^1.4.1", @@ -76,17 +84,11 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/contracts-asset-proxy": "^2.3.0-beta.1", - "@0x/contracts-erc20": "^2.3.0-beta.1", - "@0x/contracts-utils": "^3.3.0-beta.1", - "@0x/order-utils": "^8.5.0-beta.1", - "@0x/types": "^2.5.0-beta.1", + "@0x/contracts-test-utils": "^3.2.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", "ethereum-types": "^2.2.0-beta.1", - "ethereumjs-util": "^5.1.1", - "lodash": "^4.17.11" + "ethereumjs-util": "^5.1.1" }, "publishConfig": { "access": "public" diff --git a/contracts/staking/src/artifacts.ts b/contracts/staking/src/artifacts.ts index 2729748a69..857f91a64b 100644 --- a/contracts/staking/src/artifacts.ts +++ b/contracts/staking/src/artifacts.ts @@ -8,110 +8,20 @@ import { ContractArtifact } from 'ethereum-types'; import * as IStaking from '../generated-artifacts/IStaking.json'; import * as IStakingEvents from '../generated-artifacts/IStakingEvents.json'; import * as IStakingProxy from '../generated-artifacts/IStakingProxy.json'; -import * as IStorage from '../generated-artifacts/IStorage.json'; -import * as IStorageInit from '../generated-artifacts/IStorageInit.json'; -import * as IStructs from '../generated-artifacts/IStructs.json'; import * as IZrxVault from '../generated-artifacts/IZrxVault.json'; -import * as LibCobbDouglas from '../generated-artifacts/LibCobbDouglas.json'; -import * as LibFixedMath from '../generated-artifacts/LibFixedMath.json'; -import * as LibFixedMathRichErrors from '../generated-artifacts/LibFixedMathRichErrors.json'; -import * as LibSafeDowncast from '../generated-artifacts/LibSafeDowncast.json'; import * as LibStakingRichErrors from '../generated-artifacts/LibStakingRichErrors.json'; -import * as MixinAbstract from '../generated-artifacts/MixinAbstract.json'; -import * as MixinConstants from '../generated-artifacts/MixinConstants.json'; -import * as MixinCumulativeRewards from '../generated-artifacts/MixinCumulativeRewards.json'; -import * as MixinDeploymentConstants from '../generated-artifacts/MixinDeploymentConstants.json'; -import * as MixinExchangeFees from '../generated-artifacts/MixinExchangeFees.json'; -import * as MixinExchangeManager from '../generated-artifacts/MixinExchangeManager.json'; -import * as MixinFinalizer from '../generated-artifacts/MixinFinalizer.json'; -import * as MixinParams from '../generated-artifacts/MixinParams.json'; -import * as MixinScheduler from '../generated-artifacts/MixinScheduler.json'; -import * as MixinStake from '../generated-artifacts/MixinStake.json'; -import * as MixinStakeBalances from '../generated-artifacts/MixinStakeBalances.json'; -import * as MixinStakeStorage from '../generated-artifacts/MixinStakeStorage.json'; -import * as MixinStakingPool from '../generated-artifacts/MixinStakingPool.json'; -import * as MixinStakingPoolRewards from '../generated-artifacts/MixinStakingPoolRewards.json'; -import * as MixinStorage from '../generated-artifacts/MixinStorage.json'; import * as Staking from '../generated-artifacts/Staking.json'; import * as StakingProxy from '../generated-artifacts/StakingProxy.json'; -import * as TestAssertStorageParams from '../generated-artifacts/TestAssertStorageParams.json'; -import * as TestCobbDouglas from '../generated-artifacts/TestCobbDouglas.json'; -import * as TestCumulativeRewardTracking from '../generated-artifacts/TestCumulativeRewardTracking.json'; -import * as TestDelegatorRewards from '../generated-artifacts/TestDelegatorRewards.json'; -import * as TestExchangeManager from '../generated-artifacts/TestExchangeManager.json'; -import * as TestFinalizer from '../generated-artifacts/TestFinalizer.json'; -import * as TestInitTarget from '../generated-artifacts/TestInitTarget.json'; -import * as TestLibFixedMath from '../generated-artifacts/TestLibFixedMath.json'; -import * as TestLibSafeDowncast from '../generated-artifacts/TestLibSafeDowncast.json'; -import * as TestMixinCumulativeRewards from '../generated-artifacts/TestMixinCumulativeRewards.json'; -import * as TestMixinParams from '../generated-artifacts/TestMixinParams.json'; -import * as TestMixinScheduler from '../generated-artifacts/TestMixinScheduler.json'; -import * as TestMixinStake from '../generated-artifacts/TestMixinStake.json'; -import * as TestMixinStakeBalances from '../generated-artifacts/TestMixinStakeBalances.json'; -import * as TestMixinStakeStorage from '../generated-artifacts/TestMixinStakeStorage.json'; -import * as TestMixinStakingPool from '../generated-artifacts/TestMixinStakingPool.json'; -import * as TestMixinStakingPoolRewards from '../generated-artifacts/TestMixinStakingPoolRewards.json'; -import * as TestProtocolFees from '../generated-artifacts/TestProtocolFees.json'; -import * as TestProxyDestination from '../generated-artifacts/TestProxyDestination.json'; import * as TestStaking from '../generated-artifacts/TestStaking.json'; -import * as TestStakingNoWETH from '../generated-artifacts/TestStakingNoWETH.json'; -import * as TestStakingProxy from '../generated-artifacts/TestStakingProxy.json'; -import * as TestStakingProxyUnit from '../generated-artifacts/TestStakingProxyUnit.json'; -import * as TestStorageLayoutAndConstants from '../generated-artifacts/TestStorageLayoutAndConstants.json'; import * as ZrxVault from '../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, + Staking: Staking as ContractArtifact, + StakingProxy: StakingProxy as ContractArtifact, + ZrxVault: ZrxVault 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/utils/constants.ts b/contracts/staking/src/constants.ts similarity index 100% rename from contracts/staking/test/utils/constants.ts rename to contracts/staking/src/constants.ts diff --git a/contracts/staking/src/index.ts b/contracts/staking/src/index.ts index 2f65d0dcec..4369c93603 100644 --- a/contracts/staking/src/index.ts +++ b/contracts/staking/src/index.ts @@ -1,4 +1,4 @@ export * from './wrappers'; export * from './artifacts'; -export { constants } from '../test/utils/constants'; -export * from '../test/utils/types'; +export { constants } from './constants'; +export { StakeInfo, StakeStatus } from './types'; diff --git a/contracts/staking/test/utils/types.ts b/contracts/staking/src/types.ts similarity index 100% rename from contracts/staking/test/utils/types.ts rename to contracts/staking/src/types.ts diff --git a/contracts/staking/src/wrappers.ts b/contracts/staking/src/wrappers.ts index 04657b7802..f331c5466c 100644 --- a/contracts/staking/src/wrappers.ts +++ b/contracts/staking/src/wrappers.ts @@ -6,54 +6,9 @@ export * from '../generated-wrappers/i_staking'; export * from '../generated-wrappers/i_staking_events'; export * from '../generated-wrappers/i_staking_proxy'; -export * from '../generated-wrappers/i_storage'; -export * from '../generated-wrappers/i_storage_init'; -export * from '../generated-wrappers/i_structs'; export * from '../generated-wrappers/i_zrx_vault'; -export * from '../generated-wrappers/lib_cobb_douglas'; -export * from '../generated-wrappers/lib_fixed_math'; -export * from '../generated-wrappers/lib_fixed_math_rich_errors'; -export * from '../generated-wrappers/lib_safe_downcast'; export * from '../generated-wrappers/lib_staking_rich_errors'; -export * from '../generated-wrappers/mixin_abstract'; -export * from '../generated-wrappers/mixin_constants'; -export * from '../generated-wrappers/mixin_cumulative_rewards'; -export * from '../generated-wrappers/mixin_deployment_constants'; -export * from '../generated-wrappers/mixin_exchange_fees'; -export * from '../generated-wrappers/mixin_exchange_manager'; -export * from '../generated-wrappers/mixin_finalizer'; -export * from '../generated-wrappers/mixin_params'; -export * from '../generated-wrappers/mixin_scheduler'; -export * from '../generated-wrappers/mixin_stake'; -export * from '../generated-wrappers/mixin_stake_balances'; -export * from '../generated-wrappers/mixin_stake_storage'; -export * from '../generated-wrappers/mixin_staking_pool'; -export * from '../generated-wrappers/mixin_staking_pool_rewards'; -export * from '../generated-wrappers/mixin_storage'; export * from '../generated-wrappers/staking'; export * from '../generated-wrappers/staking_proxy'; -export * from '../generated-wrappers/test_assert_storage_params'; -export * from '../generated-wrappers/test_cobb_douglas'; -export * from '../generated-wrappers/test_cumulative_reward_tracking'; -export * from '../generated-wrappers/test_delegator_rewards'; -export * from '../generated-wrappers/test_exchange_manager'; -export * from '../generated-wrappers/test_finalizer'; -export * from '../generated-wrappers/test_init_target'; -export * from '../generated-wrappers/test_lib_fixed_math'; -export * from '../generated-wrappers/test_lib_safe_downcast'; -export * from '../generated-wrappers/test_mixin_cumulative_rewards'; -export * from '../generated-wrappers/test_mixin_params'; -export * from '../generated-wrappers/test_mixin_scheduler'; -export * from '../generated-wrappers/test_mixin_stake'; -export * from '../generated-wrappers/test_mixin_stake_balances'; -export * from '../generated-wrappers/test_mixin_stake_storage'; -export * from '../generated-wrappers/test_mixin_staking_pool'; -export * from '../generated-wrappers/test_mixin_staking_pool_rewards'; -export * from '../generated-wrappers/test_protocol_fees'; -export * from '../generated-wrappers/test_proxy_destination'; export * from '../generated-wrappers/test_staking'; -export * from '../generated-wrappers/test_staking_no_w_e_t_h'; -export * from '../generated-wrappers/test_staking_proxy'; -export * from '../generated-wrappers/test_staking_proxy_unit'; -export * from '../generated-wrappers/test_storage_layout_and_constants'; export * from '../generated-wrappers/zrx_vault'; diff --git a/contracts/staking/test/actors/finalizer_actor.ts b/contracts/staking/test/actors/finalizer_actor.ts index 2d2e099b3c..e5b6c52754 100644 --- a/contracts/staking/test/actors/finalizer_actor.ts +++ b/contracts/staking/test/actors/finalizer_actor.ts @@ -2,7 +2,6 @@ import { constants, expect } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; -import { StakingApiWrapper } from '../utils/api_wrapper'; import { BalanceByOwner, DelegatorBalancesByPoolId, @@ -12,7 +11,8 @@ import { OperatorShareByPoolId, RewardBalanceByPoolId, RewardByPoolId, -} from '../utils/types'; +} from '../../src/types'; +import { StakingApiWrapper } from '../utils/api_wrapper'; import { BaseActor } from './base_actor'; diff --git a/contracts/staking/test/actors/staker_actor.ts b/contracts/staking/test/actors/staker_actor.ts index 469f235730..39a6a2cf90 100644 --- a/contracts/staking/test/actors/staker_actor.ts +++ b/contracts/staking/test/actors/staker_actor.ts @@ -2,8 +2,8 @@ import { expect } from '@0x/contracts-test-utils'; import { BigNumber, RevertError } from '@0x/utils'; import * as _ from 'lodash'; +import { StakeBalances, StakeInfo, StakeStatus, StoredBalance } from '../../src/types'; import { StakingApiWrapper } from '../utils/api_wrapper'; -import { StakeBalances, StakeInfo, StakeStatus, StoredBalance } from '../utils/types'; import { BaseActor } from './base_actor'; 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/codesize_test.ts b/contracts/staking/test/codesize_test.ts index 2fe4af1b13..21557401ea 100644 --- a/contracts/staking/test/codesize_test.ts +++ b/contracts/staking/test/codesize_test.ts @@ -1,6 +1,6 @@ import { constants, expect, getCodesizeFromArtifact } from '@0x/contracts-test-utils'; -import { artifacts } from '../src'; +import { artifacts } from './artifacts'; describe('Contract Size Checks', () => { describe('Staking', () => { diff --git a/contracts/staking/test/epoch_test.ts b/contracts/staking/test/epoch_test.ts index ab5d470f34..352a4c6d6b 100644 --- a/contracts/staking/test/epoch_test.ts +++ b/contracts/staking/test/epoch_test.ts @@ -2,8 +2,9 @@ import { ERC20Wrapper } from '@0x/contracts-asset-proxy'; import { blockchainTests, expect } from '@0x/contracts-test-utils'; import * as _ from 'lodash'; +import { constants as stakingConstants } from '../src/constants'; + import { deployAndConfigureContractsAsync, StakingApiWrapper } from './utils/api_wrapper'; -import { constants as stakingConstants } from './utils/constants'; // tslint:disable:no-unnecessary-type-assertion blockchainTests('Epochs', env => { diff --git a/contracts/staking/test/layout_and_constant_regression_test.ts b/contracts/staking/test/layout_and_constant_regression_test.ts index 968200ab1e..4a74d5eacf 100644 --- a/contracts/staking/test/layout_and_constant_regression_test.ts +++ b/contracts/staking/test/layout_and_constant_regression_test.ts @@ -1,6 +1,7 @@ import { blockchainTests } from '@0x/contracts-test-utils'; -import { artifacts, TestStorageLayoutAndConstantsContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestStorageLayoutAndConstantsContract } from './wrappers'; blockchainTests('Storage Layout and Deployment Constants Regression Tests', env => { it('Should successfully deploy the staking contract after running the layout and regression test', async () => { diff --git a/contracts/staking/test/migration_test.ts b/contracts/staking/test/migration_test.ts index d6f9b50f2a..f1400b6310 100644 --- a/contracts/staking/test/migration_test.ts +++ b/contracts/staking/test/migration_test.ts @@ -2,17 +2,17 @@ import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/c import { StakingRevertErrors } from '@0x/order-utils'; import { AuthorizableRevertErrors, BigNumber, StringRevertError } from '@0x/utils'; +import { constants as stakingConstants } from '../src/constants'; + +import { artifacts } from './artifacts'; import { - artifacts, StakingContract, StakingProxyContract, TestAssertStorageParamsContract, TestInitTargetContract, TestStakingProxyContract, TestStakingProxyStakingContractAttachedToProxyEventArgs, -} from '../src/'; - -import { constants as stakingConstants } from './utils/constants'; +} from './wrappers'; blockchainTests('Migration tests', env => { let authorizedAddress: string; diff --git a/contracts/staking/test/pools_test.ts b/contracts/staking/test/pools_test.ts index 7dc69c08c8..9bde7fbd24 100644 --- a/contracts/staking/test/pools_test.ts +++ b/contracts/staking/test/pools_test.ts @@ -3,10 +3,11 @@ import { blockchainTests, constants, expect } from '@0x/contracts-test-utils'; import { StakingRevertErrors } from '@0x/order-utils'; import * as _ from 'lodash'; +import { constants as stakingConstants } from '../src/constants'; + import { MakerActor } from './actors/maker_actor'; import { PoolOperatorActor } from './actors/pool_operator_actor'; import { deployAndConfigureContractsAsync, StakingApiWrapper } from './utils/api_wrapper'; -import { constants as stakingConstants } from './utils/constants'; // tslint:disable:no-unnecessary-type-assertion // tslint:disable:max-file-line-count diff --git a/contracts/staking/test/rewards_test.ts b/contracts/staking/test/rewards_test.ts index 0f0c4f5172..a9da9181ad 100644 --- a/contracts/staking/test/rewards_test.ts +++ b/contracts/staking/test/rewards_test.ts @@ -4,12 +4,13 @@ import { StakingRevertErrors } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; +import { DelegatorsByPoolId, OperatorByPoolId, StakeInfo, StakeStatus } from '../src/types'; + import { FinalizerActor } from './actors/finalizer_actor'; import { PoolOperatorActor } from './actors/pool_operator_actor'; import { StakerActor } from './actors/staker_actor'; import { deployAndConfigureContractsAsync, StakingApiWrapper } from './utils/api_wrapper'; import { toBaseUnitAmount } from './utils/number_utils'; -import { DelegatorsByPoolId, OperatorByPoolId, StakeInfo, StakeStatus } from './utils/types'; // tslint:disable:no-unnecessary-type-assertion // tslint:disable:max-file-line-count diff --git a/contracts/staking/test/stake_test.ts b/contracts/staking/test/stake_test.ts index 065178d80a..aa5ca3cacb 100644 --- a/contracts/staking/test/stake_test.ts +++ b/contracts/staking/test/stake_test.ts @@ -4,10 +4,11 @@ import { StakingRevertErrors } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; +import { StakeInfo, StakeStatus } from '../src/types'; + import { StakerActor } from './actors/staker_actor'; import { deployAndConfigureContractsAsync, StakingApiWrapper } from './utils/api_wrapper'; import { toBaseUnitAmount } from './utils/number_utils'; -import { StakeInfo, StakeStatus } from './utils/types'; // tslint:disable:no-unnecessary-type-assertion blockchainTests.resets('Stake Statuses', env => { diff --git a/contracts/staking/test/unit_tests/delegator_reward_test.ts b/contracts/staking/test/unit_tests/delegator_reward_test.ts index 58e4855e20..de36003a9a 100644 --- a/contracts/staking/test/unit_tests/delegator_reward_test.ts +++ b/contracts/staking/test/unit_tests/delegator_reward_test.ts @@ -12,19 +12,19 @@ import { import { BigNumber } from '@0x/utils'; import { LogEntry } from 'ethereum-types'; -import { - artifacts, - TestDelegatorRewardsContract, - TestDelegatorRewardsEvents, - TestDelegatorRewardsTransferEventArgs, -} from '../../src'; - +import { artifacts } from '../artifacts'; import { assertIntegerRoughlyEquals as assertRoughlyEquals, getRandomInteger, toBaseUnitAmount, } from '../utils/number_utils'; +import { + TestDelegatorRewardsContract, + TestDelegatorRewardsEvents, + TestDelegatorRewardsTransferEventArgs, +} from '../wrappers'; + blockchainTests.resets('Delegator rewards unit tests', env => { let testContract: TestDelegatorRewardsContract; diff --git a/contracts/staking/test/unit_tests/exchange_test.ts b/contracts/staking/test/unit_tests/exchange_test.ts index 6f21999d87..54a4263e21 100644 --- a/contracts/staking/test/unit_tests/exchange_test.ts +++ b/contracts/staking/test/unit_tests/exchange_test.ts @@ -3,12 +3,12 @@ import { StakingRevertErrors } from '@0x/order-utils'; import { AuthorizableRevertErrors } from '@0x/utils'; import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; +import { artifacts } from '../artifacts'; import { - artifacts, TestExchangeManagerContract, TestExchangeManagerExchangeAddedEventArgs, TestExchangeManagerExchangeRemovedEventArgs, -} from '../../src'; +} from '../wrappers'; blockchainTests.resets('Exchange Unit Tests', env => { // Addresses diff --git a/contracts/staking/test/unit_tests/finalizer_test.ts b/contracts/staking/test/unit_tests/finalizer_test.ts index 8143917b34..04846e498b 100644 --- a/contracts/staking/test/unit_tests/finalizer_test.ts +++ b/contracts/staking/test/unit_tests/finalizer_test.ts @@ -12,8 +12,11 @@ import { BigNumber } from '@0x/utils'; import { LogEntry } from 'ethereum-types'; import * as _ from 'lodash'; +import { constants as stakingConstants } from '../../src/constants'; +import { artifacts } from '../artifacts'; +import { assertIntegerRoughlyEquals, getRandomInteger, toBaseUnitAmount } from '../utils/number_utils'; + import { - artifacts, IStakingEventsEpochEndedEventArgs, IStakingEventsEpochFinalizedEventArgs, IStakingEventsEvents, @@ -21,9 +24,7 @@ import { TestFinalizerContract, TestFinalizerDepositStakingPoolRewardsEventArgs as DepositStakingPoolRewardsEventArgs, TestFinalizerEvents, -} from '../../src'; -import { constants as stakingConstants } from '../utils/constants'; -import { assertIntegerRoughlyEquals, getRandomInteger, toBaseUnitAmount } from '../utils/number_utils'; +} from '../wrappers'; blockchainTests.resets('Finalizer unit tests', env => { const { ZERO_AMOUNT } = constants; diff --git a/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts b/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts index e0080e560e..f37fbc4751 100644 --- a/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts +++ b/contracts/staking/test/unit_tests/lib_cobb_douglas_test.ts @@ -2,10 +2,11 @@ import { blockchainTests, Numberish } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; -import { artifacts, TestCobbDouglasContract } from '../../src/'; - import { assertRoughlyEquals, getRandomInteger, getRandomPortion, toDecimal } from '../utils/number_utils'; +import { artifacts } from '../artifacts'; +import { TestCobbDouglasContract } from '../wrappers'; + // tslint:disable: no-unnecessary-type-assertion blockchainTests('LibCobbDouglas unit tests', env => { const FUZZ_COUNT = 1024; diff --git a/contracts/staking/test/unit_tests/lib_fixed_math_test.ts b/contracts/staking/test/unit_tests/lib_fixed_math_test.ts index 2e98089a67..43aeface8c 100644 --- a/contracts/staking/test/unit_tests/lib_fixed_math_test.ts +++ b/contracts/staking/test/unit_tests/lib_fixed_math_test.ts @@ -3,10 +3,11 @@ import { BigNumber, FixedMathRevertErrors } from '@0x/utils'; import { Decimal } from 'decimal.js'; import * as _ from 'lodash'; -import { artifacts, TestLibFixedMathContract } from '../../src'; - import { assertRoughlyEquals, fromFixed, toDecimal, toFixed } from '../utils/number_utils'; +import { artifacts } from '../artifacts'; +import { TestLibFixedMathContract } from '../wrappers'; + blockchainTests('LibFixedMath unit tests', env => { let testContract: TestLibFixedMathContract; diff --git a/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts b/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts index 9a3ac8931e..4cc19e4d38 100644 --- a/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts +++ b/contracts/staking/test/unit_tests/lib_safe_downcast_test.ts @@ -1,7 +1,8 @@ import { blockchainTests, expect, Numberish } from '@0x/contracts-test-utils'; import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; -import { artifacts, TestLibSafeDowncastContract } from '../../src/'; +import { artifacts } from '../artifacts'; +import { TestLibSafeDowncastContract } from '../wrappers'; blockchainTests('LibSafeDowncast unit tests', env => { let testContract: TestLibSafeDowncastContract; diff --git a/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts b/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts index 97dcb1753c..8b9a4e161e 100644 --- a/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts +++ b/contracts/staking/test/unit_tests/mixin_cumulative_rewards_test.ts @@ -2,11 +2,12 @@ import { blockchainTests, expect } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; -import { artifacts, TestMixinCumulativeRewardsContract } from '../../src'; - -import { constants as stakingConstants } from '../utils/constants'; +import { constants as stakingConstants } from '../../src/constants'; import { toBaseUnitAmount } from '../utils/number_utils'; +import { artifacts } from '../artifacts'; +import { TestMixinCumulativeRewardsContract } from '../wrappers'; + blockchainTests.resets('MixinCumulativeRewards unit tests', env => { const ZERO = new BigNumber(0); const testRewards = [ diff --git a/contracts/staking/test/unit_tests/mixin_scheduler_test.ts b/contracts/staking/test/unit_tests/mixin_scheduler_test.ts index b8e49225b8..d13a8f4d29 100644 --- a/contracts/staking/test/unit_tests/mixin_scheduler_test.ts +++ b/contracts/staking/test/unit_tests/mixin_scheduler_test.ts @@ -3,14 +3,14 @@ import { StakingRevertErrors } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; import { LogWithDecodedArgs } from 'ethereum-types'; +import { constants as stakingConstants } from '../../src/constants'; + +import { artifacts } from '../artifacts'; import { - artifacts, TestMixinSchedulerContract, TestMixinSchedulerEvents, TestMixinSchedulerGoToNextEpochTestInfoEventArgs, -} from '../../src'; - -import { constants as stakingConstants } from '../utils/constants'; +} from '../wrappers'; blockchainTests.resets('MixinScheduler unit tests', env => { let testContract: TestMixinSchedulerContract; diff --git a/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts b/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts index 066e4077a4..c3da4d3487 100644 --- a/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts +++ b/contracts/staking/test/unit_tests/mixin_stake_storage_test.ts @@ -2,10 +2,11 @@ import { blockchainTests, expect, Numberish } from '@0x/contracts-test-utils'; import { StakingRevertErrors } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; -import { StoredBalance } from '../utils/types'; +import { constants } from '../../src/constants'; +import { StoredBalance } from '../../src/types'; -import { artifacts, TestMixinStakeStorageContract } from '../../src'; -import { constants } from '../utils/constants'; +import { artifacts } from '../artifacts'; +import { TestMixinStakeStorageContract } from '../wrappers'; blockchainTests.resets('MixinStakeStorage unit tests', env => { let testContract: TestMixinStakeStorageContract; diff --git a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts index 88e344f3be..a125b9d90b 100644 --- a/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts +++ b/contracts/staking/test/unit_tests/mixin_staking_pool_rewards.ts @@ -14,9 +14,10 @@ import { import { BigNumber } from '@0x/utils'; import { LogEntry, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import { StoredBalance } from '../utils/types'; +import { StoredBalance } from '../../src/types'; -import { artifacts, TestMixinStakingPoolRewardsContract, TestMixinStakingPoolRewardsEvents as Events } from '../../src'; +import { artifacts } from '../artifacts'; +import { TestMixinStakingPoolRewardsContract, TestMixinStakingPoolRewardsEvents as Events } from '../wrappers'; blockchainTests.resets('MixinStakingPoolRewards unit tests', env => { let testContract: TestMixinStakingPoolRewardsContract; diff --git a/contracts/staking/test/unit_tests/params_test.ts b/contracts/staking/test/unit_tests/params_test.ts index e49a46a141..146a267905 100644 --- a/contracts/staking/test/unit_tests/params_test.ts +++ b/contracts/staking/test/unit_tests/params_test.ts @@ -3,10 +3,11 @@ import { AuthorizableRevertErrors, BigNumber } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, IStakingEventsParamsSetEventArgs, TestMixinParamsContract } from '../../src/'; +import { artifacts } from '../artifacts'; +import { IStakingEventsParamsSetEventArgs, TestMixinParamsContract } from '../wrappers'; -import { constants as stakingConstants } from '../utils/constants'; -import { StakingParams } from '../utils/types'; +import { constants as stakingConstants } from '../../src/constants'; +import { StakingParams } from '../../src/types'; blockchainTests('Configurable Parameters unit tests', env => { let testContract: TestMixinParamsContract; diff --git a/contracts/staking/test/unit_tests/protocol_fees_test.ts b/contracts/staking/test/unit_tests/protocol_fees_test.ts index 1c027fad3a..fc082262ba 100644 --- a/contracts/staking/test/unit_tests/protocol_fees_test.ts +++ b/contracts/staking/test/unit_tests/protocol_fees_test.ts @@ -12,14 +12,14 @@ import { BigNumber } from '@0x/utils'; import { LogEntry } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from '../artifacts'; import { - artifacts, IStakingEventsEvents, IStakingEventsStakingPoolEarnedRewardsInEpochEventArgs, TestProtocolFeesContract, TestProtocolFeesERC20ProxyTransferFromEventArgs, TestProtocolFeesEvents, -} from '../../src'; +} from '../wrappers'; import { getRandomInteger } from '../utils/number_utils'; diff --git a/contracts/staking/test/unit_tests/stake_balances_test.ts b/contracts/staking/test/unit_tests/stake_balances_test.ts index 019a4487b1..d4f28914df 100644 --- a/contracts/staking/test/unit_tests/stake_balances_test.ts +++ b/contracts/staking/test/unit_tests/stake_balances_test.ts @@ -8,9 +8,11 @@ import { } from '@0x/contracts-test-utils'; import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; -import { artifacts, TestMixinStakeBalancesContract } from '../../src'; -import { constants as stakingConstants } from '../utils/constants'; -import { StakeStatus, StoredBalance } from '../utils/types'; +import { artifacts } from '../artifacts'; +import { TestMixinStakeBalancesContract } from '../wrappers'; + +import { constants as stakingConstants } from '../../src/constants'; +import { StakeStatus, StoredBalance } from '../../src/types'; blockchainTests.resets('MixinStakeBalances unit tests', env => { let testContract: TestMixinStakeBalancesContract; diff --git a/contracts/staking/test/unit_tests/stake_test.ts b/contracts/staking/test/unit_tests/stake_test.ts index 76e5dd5d47..1c50d162cf 100644 --- a/contracts/staking/test/unit_tests/stake_test.ts +++ b/contracts/staking/test/unit_tests/stake_test.ts @@ -13,10 +13,10 @@ import { StakingRevertErrors } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; -import { StakeStatus } from '../utils/types'; +import { StakeStatus } from '../../src/types'; +import { artifacts } from '../artifacts'; import { - artifacts, TestMixinStakeContract, TestMixinStakeDecreaseCurrentAndNextBalanceEventArgs as DecreaseCurrentAndNextBalanceEventArgs, TestMixinStakeDecreaseNextBalanceEventArgs as DecreaseNextBalanceEventArgs, @@ -30,7 +30,7 @@ import { TestMixinStakeWithdrawAndSyncDelegatorRewardsEventArgs as WithdrawAndSyncDelegatorRewardsEventArgs, TestMixinStakeZrxVaultDepositFromEventArgs as ZrxVaultDepositFromEventArgs, TestMixinStakeZrxVaultWithdrawFromEventArgs as ZrxVaultWithdrawFromEventArgs, -} from '../../src'; +} from '../wrappers'; blockchainTests.resets('MixinStake unit tests', env => { let testContract: TestMixinStakeContract; diff --git a/contracts/staking/test/unit_tests/staking_pool_test.ts b/contracts/staking/test/unit_tests/staking_pool_test.ts index fef82105fb..b39bfa15d2 100644 --- a/contracts/staking/test/unit_tests/staking_pool_test.ts +++ b/contracts/staking/test/unit_tests/staking_pool_test.ts @@ -12,12 +12,12 @@ import { StakingRevertErrors } from '@0x/order-utils'; import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; import * as _ from 'lodash'; +import { artifacts } from '../artifacts'; import { - artifacts, TestMixinStakingPoolContract, TestMixinStakingPoolEvents, TestMixinStakingPoolStakingPoolCreatedEventArgs as StakingPoolCreated, -} from '../../src'; +} from '../wrappers'; blockchainTests.resets('MixinStakingPool unit tests', env => { let testContract: TestMixinStakingPoolContract; diff --git a/contracts/staking/test/unit_tests/staking_proxy_test.ts b/contracts/staking/test/unit_tests/staking_proxy_test.ts index 825ed7f2bb..d89a87a6ab 100644 --- a/contracts/staking/test/unit_tests/staking_proxy_test.ts +++ b/contracts/staking/test/unit_tests/staking_proxy_test.ts @@ -3,15 +3,15 @@ import { StakingRevertErrors } from '@0x/order-utils'; import { AuthorizableRevertErrors, BigNumber } from '@0x/utils'; import * as _ from 'lodash'; +import { artifacts } from '../artifacts'; import { - artifacts, StakingProxyEvents, TestProxyDestinationContract, TestProxyDestinationEvents, TestStakingProxyUnitContract, -} from '../../src'; +} from '../wrappers'; -import { constants as stakingConstants } from '../utils/constants'; +import { constants as stakingConstants } from '../../src/constants'; blockchainTests.resets('StakingProxy unit tests', env => { const testString = 'Hello, World!'; diff --git a/contracts/staking/test/unit_tests/zrx_vault_test.ts b/contracts/staking/test/unit_tests/zrx_vault_test.ts index 6c2209ce44..031a78ef83 100644 --- a/contracts/staking/test/unit_tests/zrx_vault_test.ts +++ b/contracts/staking/test/unit_tests/zrx_vault_test.ts @@ -13,17 +13,17 @@ import { RevertReason } from '@0x/types'; import { AuthorizableRevertErrors, BigNumber, SafeMathRevertErrors } from '@0x/utils'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import { constants as stakingConstants } from '../utils/constants'; +import { constants as stakingConstants } from '../../src/constants'; +import { artifacts } from '../artifacts'; import { - artifacts, ZrxVaultContract, ZrxVaultDepositEventArgs, ZrxVaultInCatastrophicFailureModeEventArgs, ZrxVaultStakingProxySetEventArgs, ZrxVaultWithdrawEventArgs, ZrxVaultZrxProxySetEventArgs, -} from '../../src'; +} from '../wrappers'; blockchainTests.resets('ZrxVault unit tests', env => { let accounts: string[]; diff --git a/contracts/staking/test/utils/api_wrapper.ts b/contracts/staking/test/utils/api_wrapper.ts index 11fba1b467..f67c80bc84 100644 --- a/contracts/staking/test/utils/api_wrapper.ts +++ b/contracts/staking/test/utils/api_wrapper.ts @@ -6,8 +6,8 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { BlockParamLiteral, ContractArtifact, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from '../artifacts'; import { - artifacts, IStakingEventsEpochEndedEventArgs, IStakingEventsStakingPoolEarnedRewardsInEpochEventArgs, StakingProxyContract, @@ -15,10 +15,10 @@ import { TestStakingContract, TestStakingEvents, ZrxVaultContract, -} from '../../src'; +} from '../wrappers'; -import { constants as stakingConstants } from './constants'; -import { DecodedLogs, EndOfEpochInfo, StakingParams } from './types'; +import { constants as stakingConstants } from '../../src/constants'; +import { DecodedLogs, EndOfEpochInfo, StakingParams } from '../../src/types'; export class StakingApiWrapper { // The address of the real Staking.sol contract diff --git a/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts b/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts index e16f12c323..bcab706e61 100644 --- a/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts +++ b/contracts/staking/test/utils/cumulative_reward_tracking_simulation.ts @@ -3,11 +3,12 @@ import { BigNumber } from '@0x/utils'; import { DecodedLogEntry, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, TestCumulativeRewardTrackingContract, TestCumulativeRewardTrackingEvents } from '../../src'; +import { DecodedLogs, StakeInfo, StakeStatus } from '../../src/types'; +import { artifacts } from '../artifacts'; +import { TestCumulativeRewardTrackingContract, TestCumulativeRewardTrackingEvents } from '../wrappers'; import { StakingApiWrapper } from './api_wrapper'; import { toBaseUnitAmount } from './number_utils'; -import { DecodedLogs, StakeInfo, StakeStatus } from './types'; export enum TestAction { Finalize, 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..5f0be618eb 100644 --- a/contracts/staking/tsconfig.json +++ b/contracts/staking/tsconfig.json @@ -6,57 +6,66 @@ "generated-artifacts/IStaking.json", "generated-artifacts/IStakingEvents.json", "generated-artifacts/IStakingProxy.json", - "generated-artifacts/IStorage.json", - "generated-artifacts/IStorageInit.json", - "generated-artifacts/IStructs.json", "generated-artifacts/IZrxVault.json", - "generated-artifacts/LibCobbDouglas.json", - "generated-artifacts/LibFixedMath.json", - "generated-artifacts/LibFixedMathRichErrors.json", - "generated-artifacts/LibSafeDowncast.json", "generated-artifacts/LibStakingRichErrors.json", - "generated-artifacts/MixinAbstract.json", - "generated-artifacts/MixinConstants.json", - "generated-artifacts/MixinCumulativeRewards.json", - "generated-artifacts/MixinDeploymentConstants.json", - "generated-artifacts/MixinExchangeFees.json", - "generated-artifacts/MixinExchangeManager.json", - "generated-artifacts/MixinFinalizer.json", - "generated-artifacts/MixinParams.json", - "generated-artifacts/MixinScheduler.json", - "generated-artifacts/MixinStake.json", - "generated-artifacts/MixinStakeBalances.json", - "generated-artifacts/MixinStakeStorage.json", - "generated-artifacts/MixinStakingPool.json", - "generated-artifacts/MixinStakingPoolRewards.json", - "generated-artifacts/MixinStorage.json", "generated-artifacts/Staking.json", "generated-artifacts/StakingProxy.json", - "generated-artifacts/TestAssertStorageParams.json", - "generated-artifacts/TestCobbDouglas.json", - "generated-artifacts/TestCumulativeRewardTracking.json", - "generated-artifacts/TestDelegatorRewards.json", - "generated-artifacts/TestExchangeManager.json", - "generated-artifacts/TestFinalizer.json", - "generated-artifacts/TestInitTarget.json", - "generated-artifacts/TestLibFixedMath.json", - "generated-artifacts/TestLibSafeDowncast.json", - "generated-artifacts/TestMixinCumulativeRewards.json", - "generated-artifacts/TestMixinParams.json", - "generated-artifacts/TestMixinScheduler.json", - "generated-artifacts/TestMixinStake.json", - "generated-artifacts/TestMixinStakeBalances.json", - "generated-artifacts/TestMixinStakeStorage.json", - "generated-artifacts/TestMixinStakingPool.json", - "generated-artifacts/TestMixinStakingPoolRewards.json", - "generated-artifacts/TestProtocolFees.json", - "generated-artifacts/TestProxyDestination.json", "generated-artifacts/TestStaking.json", - "generated-artifacts/TestStakingNoWETH.json", - "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/test-utils/.npmignore b/contracts/test-utils/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/test-utils/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/test-utils/CHANGELOG.json b/contracts/test-utils/CHANGELOG.json index 4afdf294d2..a3bfaa5882 100644 --- a/contracts/test-utils/CHANGELOG.json +++ b/contracts/test-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.2.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "3.2.0-beta.1", "changes": [ diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json index b11457b816..dc3ecef751 100644 --- a/contracts/test-utils/package.json +++ b/contracts/test-utils/package.json @@ -34,6 +34,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/test-utils/README.md", "devDependencies": { + "@0x/sol-compiler": "^3.2.0-beta.1", + "@0x/tslint-config": "^3.1.0-beta.1", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "tslint": "5.11.0", @@ -42,12 +44,10 @@ "dependencies": { "@0x/dev-utils": "^2.4.0-beta.1", "@0x/order-utils": "^8.5.0-beta.1", - "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/sol-coverage": "^3.1.0-beta.1", "@0x/sol-profiler": "^3.2.0-beta.1", "@0x/sol-trace": "^2.1.0-beta.1", "@0x/subproviders": "^5.1.0-beta.1", - "@0x/tslint-config": "^3.1.0-beta.1", "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", diff --git a/contracts/test-utils/src/constants.ts b/contracts/test-utils/src/constants.ts index eb93afbcf7..b71b8a4ca5 100644 --- a/contracts/test-utils/src/constants.ts +++ b/contracts/test-utils/src/constants.ts @@ -3,6 +3,8 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; +import { ExchangeFunctionName } from './types'; + const TESTRPC_PRIVATE_KEYS_STRINGS = [ '0xf2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d', '0x5d862464fe9303452126c8bc94274b8c5f9874cbd219789b3eb2128075a76f72', @@ -84,4 +86,26 @@ export const constants = { PPM_DENOMINATOR: 1e6, PPM_100_PERCENT: 1e6, MAX_CODE_SIZE: 24576, + SINGLE_FILL_FN_NAMES: [ExchangeFunctionName.FillOrder, ExchangeFunctionName.FillOrKillOrder], + BATCH_FILL_FN_NAMES: [ + ExchangeFunctionName.BatchFillOrders, + ExchangeFunctionName.BatchFillOrKillOrders, + ExchangeFunctionName.BatchFillOrdersNoThrow, + ], + MARKET_FILL_FN_NAMES: [ + ExchangeFunctionName.MarketBuyOrdersFillOrKill, + ExchangeFunctionName.MarketSellOrdersFillOrKill, + ExchangeFunctionName.MarketBuyOrdersNoThrow, + ExchangeFunctionName.MarketSellOrdersNoThrow, + ], + MATCH_ORDER_FN_NAMES: [ExchangeFunctionName.MatchOrders, ExchangeFunctionName.MatchOrdersWithMaximalFill], + BATCH_MATCH_ORDER_FN_NAMES: [ + ExchangeFunctionName.BatchMatchOrders, + ExchangeFunctionName.BatchMatchOrdersWithMaximalFill, + ], + CANCEL_ORDER_FN_NAMES: [ + ExchangeFunctionName.CancelOrder, + ExchangeFunctionName.BatchCancelOrders, + ExchangeFunctionName.CancelOrdersUpTo, + ], }; diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index 063859363d..a2ba137c0a 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -57,6 +57,7 @@ export { Token, TokenBalances, TransactionDataParams, + ExchangeFunctionName, } from './types'; export { blockchainTests, BlockchainTestsEnvironment, describe } from './mocha_blockchain'; export { chaiSetup, expect } from './chai_setup'; diff --git a/contracts/test-utils/src/types.ts b/contracts/test-utils/src/types.ts index 01b445f184..2db80a1437 100644 --- a/contracts/test-utils/src/types.ts +++ b/contracts/test-utils/src/types.ts @@ -171,3 +171,33 @@ export interface FillEventArgs { } export type Numberish = BigNumber | string | number; + +export enum ExchangeFunctionName { + BatchCancelOrders = 'batchCancelOrders', + BatchExecuteTransactions = 'batchExecuteTransactions', + BatchFillOrKillOrders = 'batchFillOrKillOrders', + BatchFillOrders = 'batchFillOrders', + BatchFillOrdersNoThrow = 'batchFillOrdersNoThrow', + BatchMatchOrders = 'batchMatchOrders', + BatchMatchOrdersWithMaximalFill = 'batchMatchOrdersWithMaximalFill', + CancelOrder = 'cancelOrder', + CancelOrdersUpTo = 'cancelOrdersUpTo', + ExecuteTransaction = 'executeTransaction', + FillOrKillOrder = 'fillOrKillOrder', + FillOrder = 'fillOrder', + FillOrderNoThrow = 'fillOrderNoThrow', + MarketBuyOrdersNoThrow = 'marketBuyOrdersNoThrow', + MarketSellOrdersNoThrow = 'marketSellOrdersNoThrow', + MarketBuyOrdersFillOrKill = 'marketBuyOrdersFillOrKill', + MarketSellOrdersFillOrKill = 'marketSellOrdersFillOrKill', + MatchOrders = 'matchOrders', + MatchOrdersWithMaximalFill = 'matchOrdersWithMaximalFill', + PreSign = 'preSign', + RegisterAssetProxy = 'registerAssetProxy', + SetSignatureValidatorApproval = 'setSignatureValidatorApproval', + SimulateDispatchTransferFromCalls = 'simulateDispatchTransferFromCalls', + TransferOwnership = 'transferOwnership', + SetProtocolFeeMultiplier = 'setProtocolFeeMultiplier', + SetProtocolFeeCollectorAddress = 'setProtocolFeeCollectorAddress', + DetachProtocolFeeCollector = 'detachProtocolFeeCollector', +} diff --git a/contracts/test-utils/test/mocha_blockchain.ts b/contracts/test-utils/test/mocha_blockchain.ts index 15c4ea43e5..9e84f28524 100644 --- a/contracts/test-utils/test/mocha_blockchain.ts +++ b/contracts/test-utils/test/mocha_blockchain.ts @@ -1,7 +1,9 @@ import * as _ from 'lodash'; import * as process from 'process'; -import { blockchainTests, constants, describe, expect } from '../src'; +import { expect } from '../src/chai_setup'; +import { constants } from '../src/constants'; +import { blockchainTests, describe } from '../src/mocha_blockchain'; blockchainTests('mocha blockchain extensions', env => { describe('blockchainTests()', () => { diff --git a/contracts/test-utils/test/subtests/mocha_blockchain_1.ts b/contracts/test-utils/test/subtests/mocha_blockchain_1.ts index 8c2fb0aae0..1af57b7380 100644 --- a/contracts/test-utils/test/subtests/mocha_blockchain_1.ts +++ b/contracts/test-utils/test/subtests/mocha_blockchain_1.ts @@ -1,4 +1,5 @@ -import { blockchainTests, BlockchainTestsEnvironment, expect } from '../../src'; +import { expect } from '../../src/chai_setup'; +import { blockchainTests, BlockchainTestsEnvironment } from '../../src/mocha_blockchain'; // tslint:disable: no-default-export completed-docs export function append(env: BlockchainTestsEnvironment): void { diff --git a/contracts/test-utils/test/test_with_reference.ts b/contracts/test-utils/test/test_with_reference.ts index 7407bf0c93..45c577e452 100644 --- a/contracts/test-utils/test/test_with_reference.ts +++ b/contracts/test-utils/test/test_with_reference.ts @@ -1,6 +1,7 @@ import { AnyRevertError, StringRevertError } from '@0x/utils'; -import { expect } from '../src'; +import { expect } from '../src/chai_setup'; + import { testWithReferenceFuncAsync } from '../src/test_with_reference'; async function divAsync(x: number, y: number): Promise { 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..d91335b46b 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", - "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", + "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 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/tests/test/dev-utils/lib_transaction_decoder.ts b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts index 9fe5ee13d6..37ad8fac86 100644 --- a/contracts/tests/test/dev-utils/lib_transaction_decoder.ts +++ b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts @@ -1,4 +1,4 @@ -import { IExchangeContract } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { BigNumber } from '@0x/utils'; @@ -32,7 +32,7 @@ const signature = describe('LibTransactionDecoder', () => { let libTxDecoder: LibTransactionDecoderContract; - const exchangeInterface = new IExchangeContract(constants.NULL_ADDRESS, provider, txDefaults); + const exchangeInterface = new ExchangeContract(constants.NULL_ADDRESS, provider, txDefaults); before(async () => { await blockchainLifecycle.startAsync(); libTxDecoder = await LibTransactionDecoderContract.deployFrom0xArtifactAsync( diff --git a/contracts/tests/test/dev-utils/order_validation_utils.ts b/contracts/tests/test/dev-utils/order_validation_utils.ts index 05f5ea8da5..29a9ea9049 100644 --- a/contracts/tests/test/dev-utils/order_validation_utils.ts +++ b/contracts/tests/test/dev-utils/order_validation_utils.ts @@ -8,7 +8,7 @@ import { } from '@0x/contracts-asset-proxy'; import { DummyERC20TokenContract } from '@0x/contracts-erc20'; import { DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -93,10 +93,15 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { txDefaults, artifacts, ); - const exchangeWrapper = new ExchangeWrapper(exchange); - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, owner); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { + from: owner, + }); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { + from: owner, + }); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync(multiAssetProxy.address, { + from: owner, + }); await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); diff --git a/contracts/utils/.npmignore b/contracts/utils/.npmignore new file mode 100644 index 0000000000..bdf2b8acbe --- /dev/null +++ b/contracts/utils/.npmignore @@ -0,0 +1,10 @@ +# Blacklist all files +.* +* +# Whitelist lib +!lib/**/* +# Whitelist Solidity contracts +!contracts/src/**/* +# Blacklist tests in lib +/lib/test/* +# Package specific ignore diff --git a/contracts/utils/CHANGELOG.json b/contracts/utils/CHANGELOG.json index 4a880e21bd..2310b0900a 100644 --- a/contracts/utils/CHANGELOG.json +++ b/contracts/utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.3.0-beta.2", + "changes": [ + { + "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", + "pr": 2330 + } + ] + }, { "version": "3.3.0-beta.1", "changes": [ 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..2eb36bfbf5 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,24 @@ "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": { + "publicInterfaceContracts": "Authorizable,IAuthorizable,IOwnable,LibAddress,LibAddressArray,LibAddressArrayRichErrors,LibAuthorizableRichErrors,LibBytes,LibBytesRichErrors,LibEIP1271,LibEIP712,LibFractions,LibOwnableRichErrors,LibReentrancyGuardRichErrors,LibRichErrors,LibSafeMath,LibSafeMathRichErrors,Ownable,ReentrancyGuard,Refundable", "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", @@ -54,6 +56,9 @@ "@0x/dev-utils": "^2.4.0-beta.1", "@0x/sol-compiler": "^3.2.0-beta.1", "@0x/tslint-config": "^3.1.0-beta.1", + "@0x/order-utils": "^8.5.0-beta.1", + "@0x/types": "^2.5.0-beta.1", + "@0x/web3-wrapper": "^6.1.0-beta.1", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", "@types/mocha": "^5.2.7", @@ -62,6 +67,8 @@ "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", "dirty-chai": "^2.0.1", + "ethereumjs-util": "^5.1.1", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0", "mocha": "^6.2.0", "npm-run-all": "^4.1.2", @@ -73,15 +80,10 @@ }, "dependencies": { "@0x/base-contract": "^5.5.0-beta.1", - "@0x/order-utils": "^8.5.0-beta.1", - "@0x/types": "^2.5.0-beta.1", "@0x/typescript-typings": "^4.4.0-beta.1", "@0x/utils": "^4.6.0-beta.1", - "@0x/web3-wrapper": "^6.1.0-beta.1", "bn.js": "^4.11.8", - "ethereum-types": "^2.2.0-beta.1", - "ethereumjs-util": "^5.1.1", - "lodash": "^4.17.11" + "ethereum-types": "^2.2.0-beta.1" }, "publishConfig": { "access": "public" diff --git a/contracts/utils/src/artifacts.ts b/contracts/utils/src/artifacts.ts index 983f2951ed..9a894a4f0f 100644 --- a/contracts/utils/src/artifacts.ts +++ b/contracts/utils/src/artifacts.ts @@ -25,20 +25,10 @@ import * as LibSafeMathRichErrors from '../generated-artifacts/LibSafeMathRichEr import * as Ownable from '../generated-artifacts/Ownable.json'; import * as ReentrancyGuard from '../generated-artifacts/ReentrancyGuard.json'; import * as Refundable from '../generated-artifacts/Refundable.json'; -import * as TestLibAddress from '../generated-artifacts/TestLibAddress.json'; -import * as TestLibAddressArray from '../generated-artifacts/TestLibAddressArray.json'; -import * as TestLibBytes from '../generated-artifacts/TestLibBytes.json'; -import * as TestLibEIP712 from '../generated-artifacts/TestLibEIP712.json'; -import * as TestLibRichErrors from '../generated-artifacts/TestLibRichErrors.json'; -import * as TestLibSafeMath from '../generated-artifacts/TestLibSafeMath.json'; -import * as TestLogDecoding from '../generated-artifacts/TestLogDecoding.json'; -import * as TestLogDecodingDownstream from '../generated-artifacts/TestLogDecodingDownstream.json'; -import * as TestOwnable from '../generated-artifacts/TestOwnable.json'; -import * as TestReentrancyGuard from '../generated-artifacts/TestReentrancyGuard.json'; -import * as TestRefundable from '../generated-artifacts/TestRefundable.json'; -import * as TestRefundableReceiver from '../generated-artifacts/TestRefundableReceiver.json'; export const artifacts = { Authorizable: Authorizable as ContractArtifact, + IAuthorizable: IAuthorizable as ContractArtifact, + IOwnable: IOwnable as ContractArtifact, LibAddress: LibAddress as ContractArtifact, LibAddressArray: LibAddressArray as ContractArtifact, LibAddressArrayRichErrors: LibAddressArrayRichErrors as ContractArtifact, @@ -56,18 +46,4 @@ export const artifacts = { 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/src/wrappers.ts b/contracts/utils/src/wrappers.ts index da266a03dd..fe1277f8e8 100644 --- a/contracts/utils/src/wrappers.ts +++ b/contracts/utils/src/wrappers.ts @@ -23,15 +23,3 @@ export * from '../generated-wrappers/lib_safe_math_rich_errors'; export * from '../generated-wrappers/ownable'; export * from '../generated-wrappers/reentrancy_guard'; export * from '../generated-wrappers/refundable'; -export * from '../generated-wrappers/test_lib_address'; -export * from '../generated-wrappers/test_lib_address_array'; -export * from '../generated-wrappers/test_lib_bytes'; -export * from '../generated-wrappers/test_lib_e_i_p712'; -export * from '../generated-wrappers/test_lib_rich_errors'; -export * from '../generated-wrappers/test_lib_safe_math'; -export * from '../generated-wrappers/test_log_decoding'; -export * from '../generated-wrappers/test_log_decoding_downstream'; -export * from '../generated-wrappers/test_ownable'; -export * from '../generated-wrappers/test_reentrancy_guard'; -export * from '../generated-wrappers/test_refundable'; -export * from '../generated-wrappers/test_refundable_receiver'; 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/authorizable.ts b/contracts/utils/test/authorizable.ts index b2a1a46876..5a7df0c885 100644 --- a/contracts/utils/test/authorizable.ts +++ b/contracts/utils/test/authorizable.ts @@ -4,7 +4,8 @@ import { AuthorizableRevertErrors, BigNumber, OwnableRevertErrors } from '@0x/ut import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, AuthorizableContract } from '../src'; +import { artifacts } from './artifacts'; +import { AuthorizableContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/utils/test/lib_address.ts b/contracts/utils/test/lib_address.ts index a538e610c0..32f2742142 100644 --- a/contracts/utils/test/lib_address.ts +++ b/contracts/utils/test/lib_address.ts @@ -2,7 +2,8 @@ import { chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test import { BlockchainLifecycle } from '@0x/dev-utils'; import * as chai from 'chai'; -import { artifacts, TestLibAddressContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLibAddressContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/utils/test/lib_address_array.ts b/contracts/utils/test/lib_address_array.ts index 5f74cc3659..0999ba506a 100644 --- a/contracts/utils/test/lib_address_array.ts +++ b/contracts/utils/test/lib_address_array.ts @@ -4,7 +4,8 @@ import { BigNumber, LibAddressArrayRevertErrors } from '@0x/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, TestLibAddressArrayContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLibAddressArrayContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/utils/test/lib_bytes.ts b/contracts/utils/test/lib_bytes.ts index 541ea43dff..c0498f4430 100644 --- a/contracts/utils/test/lib_bytes.ts +++ b/contracts/utils/test/lib_bytes.ts @@ -4,7 +4,8 @@ import BN = require('bn.js'); import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; -import { artifacts, TestLibBytesContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLibBytesContract } from './wrappers'; // BUG: Ideally we would use fromHex(memory).toString('hex') // https://github.com/Microsoft/TypeScript/issues/23155 diff --git a/contracts/utils/test/lib_eip712.ts b/contracts/utils/test/lib_eip712.ts index 34c46eedbb..75c559091c 100644 --- a/contracts/utils/test/lib_eip712.ts +++ b/contracts/utils/test/lib_eip712.ts @@ -5,7 +5,8 @@ import * as chai from 'chai'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; -import { artifacts, TestLibEIP712Contract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLibEIP712Contract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/utils/test/lib_rich_errors.ts b/contracts/utils/test/lib_rich_errors.ts index 3e796ca119..7d5ed539d7 100644 --- a/contracts/utils/test/lib_rich_errors.ts +++ b/contracts/utils/test/lib_rich_errors.ts @@ -1,7 +1,8 @@ import { blockchainTests, expect, hexRandom } from '@0x/contracts-test-utils'; import { coerceThrownErrorAsRevertError, StringRevertError } from '@0x/utils'; -import { artifacts, TestLibRichErrorsContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLibRichErrorsContract } from './wrappers'; blockchainTests('LibRichErrors', env => { let lib: TestLibRichErrorsContract; diff --git a/contracts/utils/test/lib_safe_math.ts b/contracts/utils/test/lib_safe_math.ts index 39e1ae5d1a..8724479a62 100644 --- a/contracts/utils/test/lib_safe_math.ts +++ b/contracts/utils/test/lib_safe_math.ts @@ -2,9 +2,11 @@ import { blockchainTests, constants, describe, expect } from '@0x/contracts-test import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; import * as _ from 'lodash'; -import { artifacts, TestLibSafeMathContract } from '../src'; import * as ReferenceFunctions from '../src/reference_functions'; +import { artifacts } from './artifacts'; +import { TestLibSafeMathContract } from './wrappers'; + function toBigNumber(a: number | string): BigNumber { return new BigNumber(a); } diff --git a/contracts/utils/test/log_decoding.ts b/contracts/utils/test/log_decoding.ts index 13d9d14971..ebf3e3b533 100644 --- a/contracts/utils/test/log_decoding.ts +++ b/contracts/utils/test/log_decoding.ts @@ -4,7 +4,8 @@ import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import { DecodedLogArgs, LogWithDecodedArgs } from 'ethereum-types'; -import { artifacts, TestLogDecodingContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLogDecodingContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/utils/test/ownable.ts b/contracts/utils/test/ownable.ts index d4859f730f..76bc98f55e 100644 --- a/contracts/utils/test/ownable.ts +++ b/contracts/utils/test/ownable.ts @@ -1,7 +1,8 @@ import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/contracts-test-utils'; import { OwnableRevertErrors } from '@0x/utils'; -import { artifacts, IOwnableEvents, IOwnableOwnershipTransferredEventArgs, TestOwnableContract } from '../src'; +import { artifacts } from './artifacts'; +import { IOwnableEvents, IOwnableOwnershipTransferredEventArgs, TestOwnableContract } from './wrappers'; blockchainTests.resets('Ownable', env => { let ownable: TestOwnableContract; diff --git a/contracts/utils/test/reentrancy_guard.ts b/contracts/utils/test/reentrancy_guard.ts index 9018e6f4c0..6356e27cf0 100644 --- a/contracts/utils/test/reentrancy_guard.ts +++ b/contracts/utils/test/reentrancy_guard.ts @@ -4,7 +4,8 @@ import { ReentrancyGuardRevertErrors } from '@0x/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, TestReentrancyGuardContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestReentrancyGuardContract } from './wrappers'; chaiSetup.configure(); const expect = chai.expect; diff --git a/contracts/utils/test/refundable.ts b/contracts/utils/test/refundable.ts index 8411716231..497a1f0f32 100644 --- a/contracts/utils/test/refundable.ts +++ b/contracts/utils/test/refundable.ts @@ -2,7 +2,8 @@ import { blockchainTests, constants } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; -import { artifacts, TestRefundableContract, TestRefundableReceiverContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestRefundableContract, TestRefundableReceiverContract } from './wrappers'; blockchainTests('Refundable', env => { let refundable: TestRefundableContract; 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..5f15b82479 100644 --- a/contracts/utils/tsconfig.json +++ b/contracts/utils/tsconfig.json @@ -23,18 +23,38 @@ "generated-artifacts/Ownable.json", "generated-artifacts/ReentrancyGuard.json", "generated-artifacts/Refundable.json", - "generated-artifacts/TestLibAddress.json", - "generated-artifacts/TestLibAddressArray.json", - "generated-artifacts/TestLibBytes.json", - "generated-artifacts/TestLibEIP712.json", - "generated-artifacts/TestLibRichErrors.json", - "generated-artifacts/TestLibSafeMath.json", - "generated-artifacts/TestLogDecoding.json", - "generated-artifacts/TestLogDecodingDownstream.json", - "generated-artifacts/TestOwnable.json", - "generated-artifacts/TestReentrancyGuard.json", - "generated-artifacts/TestRefundable.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/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts b/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts deleted file mode 100644 index 4fac46c6b4..0000000000 --- a/packages/abi-gen-wrappers/src/generated-wrappers/eth_balance_checker.ts +++ /dev/null @@ -1,207 +0,0 @@ -// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming -// tslint:disable:whitespace no-unbound-method no-trailing-whitespace -// tslint:disable:no-unused-variable -import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; -import { schemas } from '@0x/json-schemas'; -import { - BlockParam, - BlockParamLiteral, - BlockRange, - CallData, - ContractAbi, - ContractArtifact, - DecodedLogArgs, - MethodAbi, - TransactionReceiptWithDecodedLogs, - TxData, - TxDataPayable, - SupportedProvider, -} from 'ethereum-types'; -import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils'; -import { - AwaitTransactionSuccessOpts, - EventCallback, - IndexedFilterValues, - SendTransactionOpts, - SimpleContractArtifact, -} from '@0x/types'; -import { Web3Wrapper } from '@0x/web3-wrapper'; -import { assert } from '@0x/assert'; -import * as ethers from 'ethers'; -// tslint:enable:no-unused-variable - -/* istanbul ignore next */ -// tslint:disable:no-parameter-reassignment -// tslint:disable-next-line:class-name -export class EthBalanceCheckerContract extends BaseContract { - /** - * @ignore - */ - public static deployedBytecode: string | undefined; - /** - * Batch fetches ETH balances - */ - public getEthBalances = { - /** - * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an - * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas - * since they don't modify state. - * @param addresses Array of addresses. - * @returns Array of ETH balances. - */ - async callAsync( - addresses: string[], - callData: Partial = {}, - defaultBlock?: BlockParam, - ): Promise { - assert.isArray('addresses', addresses); - assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (defaultBlock !== undefined) { - assert.isBlockParam('defaultBlock', defaultBlock); - } - const self = (this as any) as EthBalanceCheckerContract; - const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; - let rawCallResult; - try { - rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - } catch (err) { - BaseContract._throwIfThrownErrorIsRevertError(err); - throw err; - } - BaseContract._throwIfCallResultIsRevertError(rawCallResult); - const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])'); - // tslint:disable boolean-naming - const result = abiEncoder.strictDecodeReturnValue(rawCallResult); - // tslint:enable boolean-naming - return result; - }, - }; - public static async deployFrom0xArtifactAsync( - artifact: ContractArtifact | SimpleContractArtifact, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, - ): Promise { - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - if (artifact.compilerOutput === undefined) { - throw new Error('Compiler output not found in the artifact file'); - } - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const bytecode = artifact.compilerOutput.evm.bytecode.object; - const abi = artifact.compilerOutput.abi; - const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {}; - if (Object.keys(logDecodeDependencies) !== undefined) { - for (const key of Object.keys(logDecodeDependencies)) { - logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi; - } - } - return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly); - } - public static async deployAsync( - bytecode: string, - abi: ContractAbi, - supportedProvider: SupportedProvider, - txDefaults: Partial, - logDecodeDependencies: { [contractName: string]: ContractAbi }, - ): Promise { - assert.isHexString('bytecode', bytecode); - assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ - schemas.addressSchema, - schemas.numberSchema, - schemas.jsNumber, - ]); - const provider = providerUtils.standardizeOrThrow(supportedProvider); - const constructorAbi = BaseContract._lookupConstructorAbi(abi); - [] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); - const iface = new ethers.utils.Interface(abi); - const deployInfo = iface.deployFunction; - const txData = deployInfo.encode(bytecode, []); - const web3Wrapper = new Web3Wrapper(provider); - const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { data: txData }, - txDefaults, - web3Wrapper.estimateGasAsync.bind(web3Wrapper), - ); - const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults); - logUtils.log(`transactionHash: ${txHash}`); - const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); - logUtils.log(`EthBalanceChecker successfully deployed at ${txReceipt.contractAddress}`); - const contractInstance = new EthBalanceCheckerContract( - txReceipt.contractAddress as string, - provider, - txDefaults, - logDecodeDependencies, - ); - contractInstance.constructorArgs = []; - return contractInstance; - } - - /** - * @returns The contract ABI - */ - public static ABI(): ContractAbi { - const abi = [ - { - constant: true, - inputs: [ - { - name: 'addresses', - type: 'address[]', - }, - ], - name: 'getEthBalances', - outputs: [ - { - name: '', - type: 'uint256[]', - }, - ], - payable: false, - stateMutability: 'view', - type: 'function', - }, - ] as ContractAbi; - return abi; - } - constructor( - address: string, - supportedProvider: SupportedProvider, - txDefaults?: Partial, - logDecodeDependencies?: { [contractName: string]: ContractAbi }, - deployedBytecode: string | undefined = EthBalanceCheckerContract.deployedBytecode, - ) { - super( - 'EthBalanceChecker', - EthBalanceCheckerContract.ABI(), - address, - supportedProvider, - txDefaults, - logDecodeDependencies, - deployedBytecode, - ); - classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); - } -} - -// tslint:disable:max-file-line-count -// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align -// tslint:enable:trailing-comma whitespace no-trailing-whitespace diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 01a63721d0..06bdd91c9b 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -42,7 +42,7 @@ "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", - "contracts:gen": "contracts-gen" + "contracts:gen": "contracts-gen generate" }, "config": { "abis": "./test-cli/fixtures/artifacts/@(AbiGenDummy|LibDummy|TestLibDummy).json", 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 c5fb4be505..3b73662dfc 100644 --- a/packages/contracts-gen/src/contracts-gen.ts +++ b/packages/contracts-gen/src/contracts-gen.ts @@ -7,14 +7,19 @@ 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'); const SOLIDITY_EXTENSION = '.sol'; -const DEFAULT_ARTIFACTS_DIR = 'artifacts'; +const DEFAULT_ARTIFACTS_DIR = 'test/artifacts'; const DEFAULT_CONTRACTS_DIR = 'contracts'; -const DEFAULT_WRAPPERS_DIR = 'generated-wrappers'; +const DEFAULT_WRAPPERS_DIR = 'test/generated-wrappers'; +const SRC_ARTIFACTS_TS_FILE_PATH = 'src/artifacts.ts'; +const TEST_ARTIFACTS_TS_FILE_PATH = 'test/artifacts.ts'; +const SRC_WRAPPERS_TS_FILE_PATH = 'src/wrappers.ts'; +const TEST_WRAPPERS_TS_FILE_PATH = 'test/wrappers.ts'; const AUTO_GENERATED_BANNER = `/* * ----------------------------------------------------------------------------- * Warning: This file is auto-generated by contracts-gen. Don't edit manually. @@ -22,30 +27,126 @@ 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 contracts = compiler.getContractNamesToCompile(); - const contractsDir = compilerJSON.contractsDir || DEFAULT_CONTRACTS_DIR; - const artifactsDir = compilerJSON.artifactsDir || DEFAULT_ARTIFACTS_DIR; - const wrappersDir = DEFAULT_WRAPPERS_DIR; - if (!_.isArray(contracts)) { + 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 prettierConfig = await prettier.resolveConfig(packageDir); - generateCompilerJSONContractsList(contracts, contractsDir, prettierConfig); - generateArtifactsTs(contracts, artifactsDir, prettierConfig); - generateWrappersTs(contracts, wrappersDir, prettierConfig); - generateTsConfigJSONFilesList(contracts, artifactsDir, prettierConfig); - generatePackageJSONABIConfig(contracts, artifactsDir, prettierConfig); + let srcContracts = testContracts; + 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 testArtifactsDir = compilerJSON.artifactsDir || DEFAULT_ARTIFACTS_DIR; + const srcArtifactsDir = convertToTopLevelDir('testArtifactsDir', testArtifactsDir); + const testWrappersDir = DEFAULT_WRAPPERS_DIR; + const srcWrappersDir = convertToTopLevelDir('testWrappersDir', testWrappersDir); + + // Make sure all dirs exist, if not, create them + mkdirp.sync(testArtifactsDir); + mkdirp.sync(srcArtifactsDir); + mkdirp.sync(testWrappersDir); + mkdirp.sync(srcWrappersDir); + + 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('./'); + if (hasDotPrefix) { + finalPath = aPath.substr(2); + } + const segments = finalPath.split('/'); + if (segments.length === 0) { + throw new Error(`Cannot have empty path for ${name}`); + } + if (segments.length === 1) { + return aPath; + } + segments.shift(); + return `${hasDotPrefix ? './' : ''}${segments.join('/')}`; +} + function generateCompilerJSONContractsList( contracts: string[], contractsDir: string, @@ -73,7 +174,12 @@ function generateCompilerJSONContractsList( fs.writeFileSync(COMPILER_JSON_FILE_PATH, formattedCompilerJSON); } -function generateArtifactsTs(contracts: string[], artifactsDir: 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`); @@ -97,12 +203,16 @@ function generateArtifactsTs(contracts: string[], artifactsDir: string, prettier ${sortedImports.join('\n')} export const artifacts = {${artifacts.join('\n')}}; `; - const ARTIFACTS_TS_FILE_PATH = 'src/artifacts.ts'; - const formattedArtifactsTs = prettier.format(artifactsTs, { ...prettierConfig, filepath: ARTIFACTS_TS_FILE_PATH }); - fs.writeFileSync(ARTIFACTS_TS_FILE_PATH, formattedArtifactsTs); + const formattedArtifactsTs = prettier.format(artifactsTs, { ...prettierConfig, filepath: artifactsTsFilePath }); + fs.writeFileSync(artifactsTsFilePath, formattedArtifactsTs); } -function generateWrappersTs(contracts: string[], wrappersDir: 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); @@ -114,23 +224,30 @@ function generateWrappersTs(contracts: string[], wrappersDir: string, prettierCo ${AUTO_GENERATED_BANNER} ${sortedImports.join('\n')} `; - const WRAPPERS_TS_FILE_PATH = 'src/wrappers.ts'; - const formattedArtifactsTs = prettier.format(wrappersTs, { ...prettierConfig, filepath: WRAPPERS_TS_FILE_PATH }); - fs.writeFileSync(WRAPPERS_TS_FILE_PATH, formattedArtifactsTs); + const formattedArtifactsTs = prettier.format(wrappersTs, { ...prettierConfig, filepath: wrappersTsFilePath }); + fs.writeFileSync(wrappersTsFilePath, formattedArtifactsTs); } function generateTsConfigJSONFilesList( - contracts: string[], - artifactsDir: string, + testContracts: string[], + testArtifactsDir: string, + srcContracts: string[], + srcArtifactsDir: string, prettierConfig: prettier.Options | null, ): void { const TS_CONFIG_FILE_PATH = 'tsconfig.json'; const tsConfig = readJSONFile(TS_CONFIG_FILE_PATH); - tsConfig.files = _.map(contracts, contract => { + const testFiles = _.map(testContracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + const artifactPath = path.join(testArtifactsDir, `${contractName}.json`); + return artifactPath; + }); + const srcFiles = _.map(srcContracts, contract => { const contractName = path.basename(contract, SOLIDITY_EXTENSION); - const artifactPath = path.join(artifactsDir, `${contractName}.json`); + const artifactPath = path.join(srcArtifactsDir, `${contractName}.json`); return artifactPath; }); + tsConfig.files = [...testFiles, ...srcFiles]; tsConfig.files = _.sortBy(tsConfig.files); const tsConfigString = JSON.stringify(tsConfig); const formattedTsConfig = prettier.format(tsConfigString, { ...prettierConfig, filepath: TS_CONFIG_FILE_PATH }); @@ -139,6 +256,7 @@ function generateTsConfigJSONFilesList( function generatePackageJSONABIConfig( contracts: string[], + configName: string, artifactsDir: string, prettierConfig: prettier.Options | null, ): void { @@ -152,8 +270,8 @@ function generatePackageJSONABIConfig( ...packageJSON, config: { ...packageJSON.config, - 'abis:comment': AUTO_GENERATED_BANNER_FOR_LISTS, - abis: `${artifactsDir}/@(${sortedContractNames.join('|')}).json`, + [`${configName}:comment`]: AUTO_GENERATED_BANNER_FOR_LISTS, + [configName]: `${artifactsDir}/@(${sortedContractNames.join('|')}).json`, }, }; const PACKAGE_JSON_FILE_PATH = 'package.json'; diff --git a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts index 151addd23b..456d93e761 100644 --- a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts +++ b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts @@ -4,6 +4,7 @@ import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; import { GanacheSubprovider, MnemonicWalletSubprovider, Web3ProviderEngine } from '../../src/'; + import { DoneCallback, WalletSubproviderErrors } from '../../src/types'; import { chaiSetup } from '../chai_setup'; import { fixtureData } from '../utils/fixture_data';