From 6943bbcacbd9a1df0cdddb2696a768aec4b3d2c4 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Feb 2019 10:12:49 +0100 Subject: Temp --- .github/autolabeler.yml | 1 + contracts/asset-proxy/compiler.json | 24 +-- contracts/asset-proxy/package.json | 5 +- contracts/asset-proxy/src/artifacts.ts | 29 ++++ contracts/asset-proxy/src/artifacts/index.ts | 19 --- contracts/asset-proxy/src/wrappers.ts | 13 ++ contracts/asset-proxy/src/wrappers/index.ts | 7 - contracts/asset-proxy/test/proxies.ts | 28 ++-- contracts/asset-proxy/test/utils/erc20_wrapper.ts | 6 +- contracts/asset-proxy/test/utils/erc721_wrapper.ts | 6 +- contracts/asset-proxy/tsconfig.json | 25 +-- contracts/erc20/compiler.json | 27 ++-- contracts/erc20/package.json | 5 +- contracts/erc20/src/artifacts.ts | 27 ++++ contracts/erc20/src/artifacts/index.ts | 30 ---- contracts/erc20/src/wrappers.ts | 12 ++ contracts/erc20/src/wrappers/index.ts | 11 -- contracts/erc20/tsconfig.json | 28 ++-- contracts/erc721/compiler.json | 19 +-- contracts/erc721/package.json | 5 +- contracts/erc721/src/artifacts.ts | 19 +++ contracts/erc721/src/artifacts/index.ts | 20 --- contracts/erc721/src/wrappers.ts | 8 + contracts/erc721/src/wrappers/index.ts | 7 - contracts/erc721/tsconfig.json | 20 +-- contracts/exchange-forwarder/compiler.json | 13 +- contracts/exchange-forwarder/package.json | 5 +- contracts/exchange-forwarder/src/artifacts.ts | 15 ++ .../exchange-forwarder/src/artifacts/index.ts | 7 - contracts/exchange-forwarder/src/wrappers.ts | 6 + contracts/exchange-forwarder/src/wrappers/index.ts | 1 - contracts/exchange-forwarder/test/forwarder.ts | 20 ++- .../test/utils/forwarder_wrapper.ts | 10 +- contracts/exchange-forwarder/tsconfig.json | 14 +- contracts/exchange-libs/compiler.json | 21 ++- contracts/exchange-libs/package.json | 5 +- contracts/exchange-libs/src/artifacts.ts | 21 +++ contracts/exchange-libs/src/artifacts/index.ts | 17 -- contracts/exchange-libs/src/wrappers.ts | 9 ++ contracts/exchange-libs/src/wrappers/index.ts | 6 - contracts/exchange-libs/tsconfig.json | 20 ++- contracts/exchange/compiler.json | 49 +++--- contracts/exchange/package.json | 5 +- contracts/exchange/src/artifacts.ts | 57 +++++++ contracts/exchange/src/artifacts/index.ts | 41 ----- contracts/exchange/src/wrappers.ts | 27 ++++ contracts/exchange/src/wrappers/index.ts | 18 --- contracts/exchange/test/core.ts | 31 ++-- contracts/exchange/test/dispatcher.ts | 14 +- contracts/exchange/test/match_orders.ts | 19 ++- contracts/exchange/test/signature_validator.ts | 3 +- contracts/exchange/test/utils/exchange_wrapper.ts | 4 +- .../test/utils/fill_order_combinatorial_utils.ts | 9 +- contracts/exchange/test/wrapper.ts | 17 +- contracts/exchange/tsconfig.json | 50 +++--- contracts/extensions/compiler.json | 19 ++- contracts/extensions/package.json | 5 +- contracts/extensions/src/artifacts.ts | 27 ++++ contracts/extensions/src/artifacts/index.ts | 13 -- contracts/extensions/src/wrappers.ts | 12 ++ contracts/extensions/src/wrappers/index.ts | 4 - .../extensions/test/balance_threshold_filter.ts | 6 +- contracts/extensions/test/dutch_auction.ts | 18 ++- contracts/extensions/test/order_matcher.ts | 47 +++--- contracts/extensions/test/order_validator.ts | 18 ++- .../test/utils/balance_threshold_wrapper.ts | 15 +- .../test/utils/dutch_auction_test_wrapper.ts | 10 +- contracts/extensions/tsconfig.json | 21 +-- contracts/multisig/compiler.json | 16 +- contracts/multisig/package.json | 5 +- contracts/multisig/src/artifacts.ts | 17 ++ contracts/multisig/src/artifacts/index.ts | 15 -- contracts/multisig/src/wrappers.ts | 7 + contracts/multisig/src/wrappers/index.ts | 5 - contracts/multisig/test/asset_proxy_owner.ts | 6 +- .../test/utils/asset_proxy_owner_wrapper.ts | 4 +- contracts/multisig/tsconfig.json | 17 +- contracts/utils/compiler.json | 15 +- contracts/utils/package.json | 5 +- contracts/utils/src/artifacts.ts | 19 +++ contracts/utils/src/artifacts/index.ts | 19 --- contracts/utils/src/wrappers.ts | 8 + contracts/utils/src/wrappers/index.ts | 2 - contracts/utils/tsconfig.json | 20 +-- package.json | 1 + packages/contracts-gen/.npmignore | 6 + packages/contracts-gen/CHANGELOG.json | 1 + packages/contracts-gen/README.md | 76 +++++++++ packages/contracts-gen/bin/contracts-gen.js | 2 + packages/contracts-gen/package.json | 49 ++++++ packages/contracts-gen/src/contracts-gen.ts | 171 +++++++++++++++++++++ packages/contracts-gen/src/index.ts | 6 + packages/contracts-gen/tsconfig.json | 8 + packages/contracts-gen/tslint.json | 3 + packages/monorepo-scripts/package.json | 8 + packages/monorepo-scripts/src/deps_versions.ts | 9 +- packages/monorepo-scripts/src/publish.ts | 6 +- packages/monorepo-scripts/src/test_installation.ts | 4 +- packages/monorepo-scripts/src/types.ts | 17 +- .../src/utils/doc_generate_and_upload_utils.ts | 3 +- packages/monorepo-scripts/src/utils/utils.ts | 14 +- packages/sol-compiler/src/compiler.ts | 11 +- packages/sol-compiler/src/utils/compiler.ts | 5 +- packages/types/src/index.ts | 20 +++ tsconfig.json | 1 + yarn.lock | 44 ++---- 106 files changed, 1110 insertions(+), 685 deletions(-) create mode 100644 contracts/asset-proxy/src/artifacts.ts delete mode 100644 contracts/asset-proxy/src/artifacts/index.ts create mode 100644 contracts/asset-proxy/src/wrappers.ts delete mode 100644 contracts/asset-proxy/src/wrappers/index.ts create mode 100644 contracts/erc20/src/artifacts.ts delete mode 100644 contracts/erc20/src/artifacts/index.ts create mode 100644 contracts/erc20/src/wrappers.ts delete mode 100644 contracts/erc20/src/wrappers/index.ts create mode 100644 contracts/erc721/src/artifacts.ts delete mode 100644 contracts/erc721/src/artifacts/index.ts create mode 100644 contracts/erc721/src/wrappers.ts delete mode 100644 contracts/erc721/src/wrappers/index.ts create mode 100644 contracts/exchange-forwarder/src/artifacts.ts delete mode 100644 contracts/exchange-forwarder/src/artifacts/index.ts create mode 100644 contracts/exchange-forwarder/src/wrappers.ts delete mode 100644 contracts/exchange-forwarder/src/wrappers/index.ts create mode 100644 contracts/exchange-libs/src/artifacts.ts delete mode 100644 contracts/exchange-libs/src/artifacts/index.ts create mode 100644 contracts/exchange-libs/src/wrappers.ts delete mode 100644 contracts/exchange-libs/src/wrappers/index.ts create mode 100644 contracts/exchange/src/artifacts.ts delete mode 100644 contracts/exchange/src/artifacts/index.ts create mode 100644 contracts/exchange/src/wrappers.ts delete mode 100644 contracts/exchange/src/wrappers/index.ts create mode 100644 contracts/extensions/src/artifacts.ts delete mode 100644 contracts/extensions/src/artifacts/index.ts create mode 100644 contracts/extensions/src/wrappers.ts delete mode 100644 contracts/extensions/src/wrappers/index.ts create mode 100644 contracts/multisig/src/artifacts.ts delete mode 100644 contracts/multisig/src/artifacts/index.ts create mode 100644 contracts/multisig/src/wrappers.ts delete mode 100644 contracts/multisig/src/wrappers/index.ts create mode 100644 contracts/utils/src/artifacts.ts delete mode 100644 contracts/utils/src/artifacts/index.ts create mode 100644 contracts/utils/src/wrappers.ts delete mode 100644 contracts/utils/src/wrappers/index.ts create mode 100644 packages/contracts-gen/.npmignore create mode 100644 packages/contracts-gen/CHANGELOG.json create mode 100644 packages/contracts-gen/README.md create mode 100755 packages/contracts-gen/bin/contracts-gen.js create mode 100644 packages/contracts-gen/package.json create mode 100644 packages/contracts-gen/src/contracts-gen.ts create mode 100644 packages/contracts-gen/src/index.ts create mode 100644 packages/contracts-gen/tsconfig.json create mode 100644 packages/contracts-gen/tslint.json diff --git a/.github/autolabeler.yml b/.github/autolabeler.yml index 321ec18a4..fb5b00aa4 100644 --- a/.github/autolabeler.yml +++ b/.github/autolabeler.yml @@ -2,6 +2,7 @@ python: ['python-packages'] contracts: ['contracts'] sol-doc: ['packages/sol-doc'] sol-resolver: ['packages/sol-resolver'] +contracts-gen: ['packages/contracts-gen'] sra-spec: ['packages/sra-spec'] subproviders: ['packages/subproviders'] contract-addresses: ['packages/contract-addresses'] diff --git a/contracts/asset-proxy/compiler.json b/contracts/asset-proxy/compiler.json index 70d4c6b20..aab143bad 100644 --- a/contracts/asset-proxy/compiler.json +++ b/contracts/asset-proxy/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -20,12 +17,17 @@ } }, "contracts": [ - "IAssetData", - "IAssetProxy", - "IAuthorizable", - "ERC20Proxy", - "ERC721Proxy", - "MixinAuthorizable", - "MultiAssetProxy" + "@0x/contracts-erc20/contracts/test/DummyERC20Token.sol", + "@0x/contracts-erc20/contracts/test/DummyMultipleReturnERC20Token.sol", + "@0x/contracts-erc20/contracts/test/DummyNoReturnERC20Token.sol", + "@0x/contracts-erc721/contracts/test/DummyERC721Receiver.sol", + "@0x/contracts-erc721/contracts/test/DummyERC721Token.sol", + "src/ERC20Proxy.sol", + "src/ERC721Proxy.sol", + "src/MixinAuthorizable.sol", + "src/MultiAssetProxy.sol", + "src/interfaces/IAssetData.sol", + "src/interfaces/IAssetProxy.sol", + "src/interfaces/IAuthorizable.sol" ] } diff --git a/contracts/asset-proxy/package.json b/contracts/asset-proxy/package.json index 360fdab75..ce686b7ef 100644 --- a/contracts/asset-proxy/package.json +++ b/contracts/asset-proxy/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(ERC20Proxy|ERC721Proxy|IAssetData|IAssetProxy|IAuthorizable|MixinAuthorizable|MultiAssetProxy).json" + "abis": "./generated-artifacts/@(DummyERC20Token|DummyERC721Receiver|DummyERC721Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Proxy|ERC721Proxy|IAssetData|IAssetProxy|IAuthorizable|MixinAuthorizable|MultiAssetProxy).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -48,6 +50,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/asset-proxy/src/artifacts.ts b/contracts/asset-proxy/src/artifacts.ts new file mode 100644 index 000000000..87b80d075 --- /dev/null +++ b/contracts/asset-proxy/src/artifacts.ts @@ -0,0 +1,29 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; +import * as DummyERC721Receiver from '../generated-artifacts/DummyERC721Receiver.json'; +import * as DummyERC721Token from '../generated-artifacts/DummyERC721Token.json'; +import * as DummyMultipleReturnERC20Token from '../generated-artifacts/DummyMultipleReturnERC20Token.json'; +import * as DummyNoReturnERC20Token from '../generated-artifacts/DummyNoReturnERC20Token.json'; +import * as ERC20Proxy from '../generated-artifacts/ERC20Proxy.json'; +import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json'; +import * as IAssetData from '../generated-artifacts/IAssetData.json'; +import * as IAssetProxy from '../generated-artifacts/IAssetProxy.json'; +import * as IAuthorizable from '../generated-artifacts/IAuthorizable.json'; +import * as MixinAuthorizable from '../generated-artifacts/MixinAuthorizable.json'; +import * as MultiAssetProxy from '../generated-artifacts/MultiAssetProxy.json'; +export const artifacts = { + DummyERC20Token: DummyERC20Token as ContractArtifact, + DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, + DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, + DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, + DummyERC721Token: DummyERC721Token as ContractArtifact, + ERC20Proxy: ERC20Proxy as ContractArtifact, + ERC721Proxy: ERC721Proxy as ContractArtifact, + MixinAuthorizable: MixinAuthorizable as ContractArtifact, + MultiAssetProxy: MultiAssetProxy as ContractArtifact, + IAssetData: IAssetData as ContractArtifact, + IAssetProxy: IAssetProxy as ContractArtifact, + IAuthorizable: IAuthorizable as ContractArtifact, +}; diff --git a/contracts/asset-proxy/src/artifacts/index.ts b/contracts/asset-proxy/src/artifacts/index.ts deleted file mode 100644 index 7f3060815..000000000 --- a/contracts/asset-proxy/src/artifacts/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as ERC20Proxy from '../../generated-artifacts/ERC20Proxy.json'; -import * as ERC721Proxy from '../../generated-artifacts/ERC721Proxy.json'; -import * as IAssetData from '../../generated-artifacts/IAssetData.json'; -import * as IAssetProxy from '../../generated-artifacts/IAssetProxy.json'; -import * as IAuthorizable from '../../generated-artifacts/IAuthorizable.json'; -import * as MixinAuthorizable from '../../generated-artifacts/MixinAuthorizable.json'; -import * as MultiAssetProxy from '../../generated-artifacts/MultiAssetProxy.json'; - -export const artifacts = { - IAuthorizable: IAuthorizable as ContractArtifact, - IAssetData: IAssetData as ContractArtifact, - IAssetProxy: IAssetProxy as ContractArtifact, - ERC20Proxy: ERC20Proxy as ContractArtifact, - ERC721Proxy: ERC721Proxy as ContractArtifact, - MixinAuthorizable: MixinAuthorizable as ContractArtifact, - MultiAssetProxy: MultiAssetProxy as ContractArtifact, -}; diff --git a/contracts/asset-proxy/src/wrappers.ts b/contracts/asset-proxy/src/wrappers.ts new file mode 100644 index 000000000..4bff2f423 --- /dev/null +++ b/contracts/asset-proxy/src/wrappers.ts @@ -0,0 +1,13 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +export * from '../generated-wrappers/dummy_erc20_token'; +export * from '../generated-wrappers/dummy_erc721_receiver'; +export * from '../generated-wrappers/dummy_erc721_token'; +export * from '../generated-wrappers/dummy_multiple_return_erc20_token'; +export * from '../generated-wrappers/dummy_no_return_erc20_token'; +export * from '../generated-wrappers/erc20_proxy'; +export * from '../generated-wrappers/erc721_proxy'; +export * from '../generated-wrappers/i_asset_data'; +export * from '../generated-wrappers/i_asset_proxy'; +export * from '../generated-wrappers/i_authorizable'; +export * from '../generated-wrappers/mixin_authorizable'; +export * from '../generated-wrappers/multi_asset_proxy'; diff --git a/contracts/asset-proxy/src/wrappers/index.ts b/contracts/asset-proxy/src/wrappers/index.ts deleted file mode 100644 index 6aecbc086..000000000 --- a/contracts/asset-proxy/src/wrappers/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from '../../generated-wrappers/i_asset_data'; -export * from '../../generated-wrappers/i_asset_proxy'; -export * from '../../generated-wrappers/erc20_proxy'; -export * from '../../generated-wrappers/erc721_proxy'; -export * from '../../generated-wrappers/mixin_authorizable'; -export * from '../../generated-wrappers/multi_asset_proxy'; -export * from '../../generated-wrappers/i_authorizable'; diff --git a/contracts/asset-proxy/test/proxies.ts b/contracts/asset-proxy/test/proxies.ts index 797787135..c2f9653aa 100644 --- a/contracts/asset-proxy/test/proxies.ts +++ b/contracts/asset-proxy/test/proxies.ts @@ -1,15 +1,3 @@ -import { - artifacts as erc20Artifacts, - DummyERC20TokenContract, - DummyERC20TokenTransferEventArgs, - DummyMultipleReturnERC20TokenContract, - DummyNoReturnERC20TokenContract, -} from '@0x/contracts-erc20'; -import { - artifacts as erc721Artifacts, - DummyERC721ReceiverContract, - DummyERC721TokenContract, -} from '@0x/contracts-erc721'; import { chaiSetup, constants, @@ -30,6 +18,12 @@ import * as _ from 'lodash'; import { artifacts, + DummyERC20TokenContract, + DummyERC20TokenTransferEventArgs, + DummyERC721ReceiverContract, + DummyERC721TokenContract, + DummyMultipleReturnERC20TokenContract, + DummyNoReturnERC20TokenContract, ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, @@ -154,7 +148,7 @@ describe('Asset Transfer Proxies', () => { constants.DUMMY_TOKEN_DECIMALS, ); noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync( - erc20Artifacts.DummyNoReturnERC20Token, + artifacts.DummyNoReturnERC20Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, @@ -163,7 +157,7 @@ describe('Asset Transfer Proxies', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ); multipleReturnErc20Token = await DummyMultipleReturnERC20TokenContract.deployFrom0xArtifactAsync( - erc20Artifacts.DummyMultipleReturnERC20Token, + artifacts.DummyMultipleReturnERC20Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, @@ -204,7 +198,7 @@ describe('Asset Transfer Proxies', () => { // Deploy and configure ERC721 tokens and receiver [erc721TokenA, erc721TokenB] = await erc721Wrapper.deployDummyTokensAsync(); erc721Receiver = await DummyERC721ReceiverContract.deployFrom0xArtifactAsync( - erc721Artifacts.DummyERC721Receiver, + artifacts.DummyERC721Receiver, provider, txDefaults, ); @@ -568,7 +562,7 @@ describe('Asset Transfer Proxies', () => { erc721Receiver.address, amount, ); - const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc721Artifacts }); + const logDecoder = new LogDecoder(web3Wrapper, artifacts); const tx = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ to: erc721Proxy.address, @@ -760,7 +754,7 @@ describe('Asset Transfer Proxies', () => { inputAmount, ); const erc20Balances = await erc20Wrapper.getBalancesAsync(); - const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts }); + const logDecoder = new LogDecoder(web3Wrapper, artifacts); const tx = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ to: multiAssetProxy.address, diff --git a/contracts/asset-proxy/test/utils/erc20_wrapper.ts b/contracts/asset-proxy/test/utils/erc20_wrapper.ts index 12cd06ece..09607e776 100644 --- a/contracts/asset-proxy/test/utils/erc20_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc20_wrapper.ts @@ -1,4 +1,3 @@ -import { artifacts as tokensArtifacts, DummyERC20TokenContract } from '@0x/contracts-erc20'; import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils'; import { assetDataUtils } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; @@ -6,8 +5,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; -import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy'; -import { artifacts } from '../../src/artifacts'; +import { artifacts, DummyERC20TokenContract, ERC20ProxyContract } from '../../src'; export class ERC20Wrapper { private readonly _tokenOwnerAddresses: string[]; @@ -38,7 +36,7 @@ export class ERC20Wrapper { for (let i = 0; i < numberToDeploy; i++) { this._dummyTokenContracts.push( await DummyERC20TokenContract.deployFrom0xArtifactAsync( - tokensArtifacts.DummyERC20Token, + artifacts.DummyERC20Token, this._provider, txDefaults, constants.DUMMY_TOKEN_NAME, diff --git a/contracts/asset-proxy/test/utils/erc721_wrapper.ts b/contracts/asset-proxy/test/utils/erc721_wrapper.ts index fc43d8c52..92d1398a7 100644 --- a/contracts/asset-proxy/test/utils/erc721_wrapper.ts +++ b/contracts/asset-proxy/test/utils/erc721_wrapper.ts @@ -1,4 +1,3 @@ -import { artifacts as tokensArtifacts, DummyERC721TokenContract } from '@0x/contracts-erc721'; import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils'; import { generatePseudoRandomSalt } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; @@ -6,8 +5,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; -import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy'; -import { artifacts } from '../../src/artifacts'; +import { artifacts, DummyERC721TokenContract, ERC721ProxyContract } from '../../src'; export class ERC721Wrapper { private readonly _tokenOwnerAddresses: string[]; @@ -30,7 +28,7 @@ export class ERC721Wrapper { for (const i of _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY)) { this._dummyTokenContracts.push( await DummyERC721TokenContract.deployFrom0xArtifactAsync( - tokensArtifacts.DummyERC721Token, + artifacts.DummyERC721Token, this._provider, txDefaults, constants.DUMMY_TOKEN_NAME, diff --git a/contracts/asset-proxy/tsconfig.json b/contracts/asset-proxy/tsconfig.json index 7baa48cbe..526be2c64 100644 --- a/contracts/asset-proxy/tsconfig.json +++ b/contracts/asset-proxy/tsconfig.json @@ -1,19 +1,20 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/IAssetData.json", - "./generated-artifacts/IAssetProxy.json", - "./generated-artifacts/IAuthorizable.json", - "./generated-artifacts/ERC20Proxy.json", - "./generated-artifacts/ERC721Proxy.json", - "./generated-artifacts/MixinAuthorizable.json", - "./generated-artifacts/MultiAssetProxy.json" + "generated-artifacts/DummyERC20Token.json", + "generated-artifacts/DummyERC721Receiver.json", + "generated-artifacts/DummyERC721Token.json", + "generated-artifacts/DummyMultipleReturnERC20Token.json", + "generated-artifacts/DummyNoReturnERC20Token.json", + "generated-artifacts/ERC20Proxy.json", + "generated-artifacts/ERC721Proxy.json", + "generated-artifacts/IAssetData.json", + "generated-artifacts/IAssetProxy.json", + "generated-artifacts/IAuthorizable.json", + "generated-artifacts/MixinAuthorizable.json", + "generated-artifacts/MultiAssetProxy.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/erc20/compiler.json b/contracts/erc20/compiler.json index 264f6231a..033917d22 100644 --- a/contracts/erc20/compiler.json +++ b/contracts/erc20/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -20,16 +17,16 @@ } }, "contracts": [ - "DummyERC20Token", - "DummyMultipleReturnERC20Token", - "DummyNoReturnERC20Token", - "ReentrantERC20Token", - "ERC20Token", - "IERC20Token", - "MintableERC20Token", - "UnlimitedAllowanceERC20Token", - "IEtherToken", - "WETH9", - "ZRXToken" + "src/ERC20Token.sol", + "src/MintableERC20Token.sol", + "src/UnlimitedAllowanceERC20Token.sol", + "src/WETH9.sol", + "src/ZRXToken.sol", + "src/interfaces/IERC20Token.sol", + "src/interfaces/IEtherToken.sol", + "test/DummyERC20Token.sol", + "test/DummyMultipleReturnERC20Token.sol", + "test/DummyNoReturnERC20Token.sol", + "test/ReentrantERC20Token.sol" ] } diff --git a/contracts/erc20/package.json b/contracts/erc20/package.json index 778b9257d..801f2a034 100644 --- a/contracts/erc20/package.json +++ b/contracts/erc20/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ReentrantERC20Token|ERC20Token|IERC20Token|MintableERC20Token|UnlimitedAllowanceERC20Token|IEtherToken|WETH9|ZRXToken).json" + "abis": "./generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|MintableERC20Token|ReentrantERC20Token|UnlimitedAllowanceERC20Token|WETH9|ZRXToken).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -49,6 +51,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/erc20/src/artifacts.ts b/contracts/erc20/src/artifacts.ts new file mode 100644 index 000000000..0627b98cf --- /dev/null +++ b/contracts/erc20/src/artifacts.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +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 MintableERC20Token from '../generated-artifacts/MintableERC20Token.json'; +import * as ReentrantERC20Token from '../generated-artifacts/ReentrantERC20Token.json'; +import * as UnlimitedAllowanceERC20Token from '../generated-artifacts/UnlimitedAllowanceERC20Token.json'; +import * as WETH9 from '../generated-artifacts/WETH9.json'; +import * as ZRXToken from '../generated-artifacts/ZRXToken.json'; +export const artifacts = { + ERC20Token: ERC20Token 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, + ReentrantERC20Token: ReentrantERC20Token as ContractArtifact, +}; diff --git a/contracts/erc20/src/artifacts/index.ts b/contracts/erc20/src/artifacts/index.ts deleted file mode 100644 index ce1ae06ac..000000000 --- a/contracts/erc20/src/artifacts/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -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 MintableERC20Token from '../../generated-artifacts/MintableERC20Token.json'; -import * as ReentrantERC20Token from '../../generated-artifacts/ReentrantERC20Token.json'; -import * as UnlimitedAllowanceERC20Token from '../../generated-artifacts/UnlimitedAllowanceERC20Token.json'; -import * as WETH9 from '../../generated-artifacts/WETH9.json'; -import * as ZRXToken from '../../generated-artifacts/ZRXToken.json'; - -// tslint:disable:no-unnecessary-type-assertion -export const artifacts = { - DummyERC20Token: DummyERC20Token as ContractArtifact, - DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, - DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, - ReentrantERC20Token: ReentrantERC20Token as ContractArtifact, - ERC20Token: ERC20Token as ContractArtifact, - IERC20Token: IERC20Token as ContractArtifact, - MintableERC20Token: MintableERC20Token as ContractArtifact, - UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, - IEtherToken: IEtherToken as ContractArtifact, - WETH9: WETH9 as ContractArtifact, - // Note(albrow): "as any" hack still required here because ZRXToken does not - // conform to the v2 artifact type. - ZRXToken: (ZRXToken as any) as ContractArtifact, -}; diff --git a/contracts/erc20/src/wrappers.ts b/contracts/erc20/src/wrappers.ts new file mode 100644 index 000000000..b66c3b1ca --- /dev/null +++ b/contracts/erc20/src/wrappers.ts @@ -0,0 +1,12 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +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/mintable_erc20_token'; +export * from '../generated-wrappers/reentrant_erc20_token'; +export * from '../generated-wrappers/unlimited_allowance_erc20_token'; +export * from '../generated-wrappers/weth9'; +export * from '../generated-wrappers/zrx_token'; diff --git a/contracts/erc20/src/wrappers/index.ts b/contracts/erc20/src/wrappers/index.ts deleted file mode 100644 index b4e4ef969..000000000 --- a/contracts/erc20/src/wrappers/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export * from '../../generated-wrappers/zrx_token'; -export * from '../../generated-wrappers/weth9'; -export * from '../../generated-wrappers/unlimited_allowance_erc20_token'; -export * from '../../generated-wrappers/reentrant_erc20_token'; -export * from '../../generated-wrappers/mintable_erc20_token'; -export * from '../../generated-wrappers/i_ether_token'; -export * from '../../generated-wrappers/i_erc20_token'; -export * from '../../generated-wrappers/erc20_token'; -export * from '../../generated-wrappers/dummy_no_return_erc20_token'; -export * from '../../generated-wrappers/dummy_multiple_return_erc20_token'; -export * from '../../generated-wrappers/dummy_erc20_token'; diff --git a/contracts/erc20/tsconfig.json b/contracts/erc20/tsconfig.json index 4df7424be..74419260a 100644 --- a/contracts/erc20/tsconfig.json +++ b/contracts/erc20/tsconfig.json @@ -1,23 +1,19 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/DummyERC20Token.json", - "./generated-artifacts/DummyMultipleReturnERC20Token.json", - "./generated-artifacts/DummyNoReturnERC20Token.json", - "./generated-artifacts/ReentrantERC20Token.json", - "./generated-artifacts/ERC20Token.json", - "./generated-artifacts/IERC20Token.json", - "./generated-artifacts/MintableERC20Token.json", - "./generated-artifacts/UnlimitedAllowanceERC20Token.json", - "./generated-artifacts/IEtherToken.json", - "./generated-artifacts/WETH9.json", - "./generated-artifacts/ZRXToken.json" + "generated-artifacts/DummyERC20Token.json", + "generated-artifacts/DummyMultipleReturnERC20Token.json", + "generated-artifacts/DummyNoReturnERC20Token.json", + "generated-artifacts/ERC20Token.json", + "generated-artifacts/IERC20Token.json", + "generated-artifacts/IEtherToken.json", + "generated-artifacts/MintableERC20Token.json", + "generated-artifacts/ReentrantERC20Token.json", + "generated-artifacts/UnlimitedAllowanceERC20Token.json", + "generated-artifacts/WETH9.json", + "generated-artifacts/ZRXToken.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/erc721/compiler.json b/contracts/erc721/compiler.json index db8589016..09d79ba28 100644 --- a/contracts/erc721/compiler.json +++ b/contracts/erc721/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -20,12 +17,12 @@ } }, "contracts": [ - "DummyERC721Receiver", - "InvalidERC721Receiver", - "DummyERC721Token", - "ERC721Token", - "IERC721Receiver", - "IERC721Token", - "MintableERC721Token" + "src/ERC721Token.sol", + "src/MintableERC721Token.sol", + "src/interfaces/IERC721Receiver.sol", + "src/interfaces/IERC721Token.sol", + "test/DummyERC721Receiver.sol", + "test/DummyERC721Token.sol", + "test/InvalidERC721Receiver.sol" ] } diff --git a/contracts/erc721/package.json b/contracts/erc721/package.json index 096e1025e..54f261a80 100644 --- a/contracts/erc721/package.json +++ b/contracts/erc721/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(DummyERC721Receiver|InvalidERC721Receiver|DummyERC721Token|ERC721Token|IERC721Receiver|IERC721Token|MintableERC721Token).json" + "abis": "./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": { "type": "git", @@ -49,6 +51,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/erc721/src/artifacts.ts b/contracts/erc721/src/artifacts.ts new file mode 100644 index 000000000..daa29a83c --- /dev/null +++ b/contracts/erc721/src/artifacts.ts @@ -0,0 +1,19 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC721Receiver from '../generated-artifacts/DummyERC721Receiver.json'; +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 = { + 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/artifacts/index.ts b/contracts/erc721/src/artifacts/index.ts deleted file mode 100644 index 8d5ec8a46..000000000 --- a/contracts/erc721/src/artifacts/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as DummyERC721Receiver from '../../generated-artifacts/DummyERC721Receiver.json'; -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'; - -// tslint:disable:no-unnecessary-type-assertion -export const artifacts = { - DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, - InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact, - DummyERC721Token: DummyERC721Token as ContractArtifact, - ERC721Token: ERC721Token as ContractArtifact, - IERC721Receiver: IERC721Receiver as ContractArtifact, - IERC721Token: IERC721Token as ContractArtifact, - MintableERC721Token: MintableERC721Token as ContractArtifact, -}; diff --git a/contracts/erc721/src/wrappers.ts b/contracts/erc721/src/wrappers.ts new file mode 100644 index 000000000..909e05868 --- /dev/null +++ b/contracts/erc721/src/wrappers.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +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/src/wrappers/index.ts b/contracts/erc721/src/wrappers/index.ts deleted file mode 100644 index ba6c51885..000000000 --- a/contracts/erc721/src/wrappers/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from '../../generated-wrappers/mintable_erc721_token'; -export * from '../../generated-wrappers/invalid_erc721_receiver'; -export * from '../../generated-wrappers/i_erc721_token'; -export * from '../../generated-wrappers/i_erc721_receiver'; -export * from '../../generated-wrappers/erc721_token'; -export * from '../../generated-wrappers/dummy_erc721_token'; -export * from '../../generated-wrappers/dummy_erc721_receiver'; diff --git a/contracts/erc721/tsconfig.json b/contracts/erc721/tsconfig.json index 098c3a7f3..3b218affe 100644 --- a/contracts/erc721/tsconfig.json +++ b/contracts/erc721/tsconfig.json @@ -1,19 +1,15 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/DummyERC721Receiver.json", - "./generated-artifacts/InvalidERC721Receiver.json", - "./generated-artifacts/DummyERC721Token.json", - "./generated-artifacts/ERC721Token.json", - "./generated-artifacts/IERC721Receiver.json", - "./generated-artifacts/IERC721Token.json", - "./generated-artifacts/MintableERC721Token.json" + "generated-artifacts/DummyERC721Receiver.json", + "generated-artifacts/DummyERC721Token.json", + "generated-artifacts/ERC721Token.json", + "generated-artifacts/IERC721Receiver.json", + "generated-artifacts/IERC721Token.json", + "generated-artifacts/InvalidERC721Receiver.json", + "generated-artifacts/MintableERC721Token.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange-forwarder/compiler.json b/contracts/exchange-forwarder/compiler.json index e93eb4bdd..051e81de5 100644 --- a/contracts/exchange-forwarder/compiler.json +++ b/contracts/exchange-forwarder/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -19,5 +16,11 @@ } } }, - "contracts": ["Forwarder"] + "contracts": [ + "@0x/contracts-erc20/contracts/src/WETH9.sol", + "@0x/contracts-erc20/contracts/test/DummyERC20Token.sol", + "@0x/contracts-erc721/contracts/test/DummyERC721Token.sol", + "@0x/contracts-exchange/contracts/src/Exchange.sol", + "src/Forwarder.sol" + ] } diff --git a/contracts/exchange-forwarder/package.json b/contracts/exchange-forwarder/package.json index 73a30e851..388980177 100644 --- a/contracts/exchange-forwarder/package.json +++ b/contracts/exchange-forwarder/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(Forwarder).json" + "abis": "./generated-artifacts/@(DummyERC20Token|DummyERC721Token|Exchange|Forwarder|WETH9).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -50,6 +52,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/exchange-forwarder/src/artifacts.ts b/contracts/exchange-forwarder/src/artifacts.ts new file mode 100644 index 000000000..39295b797 --- /dev/null +++ b/contracts/exchange-forwarder/src/artifacts.ts @@ -0,0 +1,15 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; +import * as DummyERC721Token from '../generated-artifacts/DummyERC721Token.json'; +import * as Exchange from '../generated-artifacts/Exchange.json'; +import * as Forwarder from '../generated-artifacts/Forwarder.json'; +import * as WETH9 from '../generated-artifacts/WETH9.json'; +export const artifacts = { + WETH9: WETH9 as ContractArtifact, + DummyERC20Token: DummyERC20Token as ContractArtifact, + DummyERC721Token: DummyERC721Token as ContractArtifact, + Exchange: Exchange as ContractArtifact, + Forwarder: Forwarder as ContractArtifact, +}; diff --git a/contracts/exchange-forwarder/src/artifacts/index.ts b/contracts/exchange-forwarder/src/artifacts/index.ts deleted file mode 100644 index f15dac49a..000000000 --- a/contracts/exchange-forwarder/src/artifacts/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as Forwarder from '../../generated-artifacts/Forwarder.json'; - -export const artifacts = { - Forwarder: Forwarder as ContractArtifact, -}; diff --git a/contracts/exchange-forwarder/src/wrappers.ts b/contracts/exchange-forwarder/src/wrappers.ts new file mode 100644 index 000000000..a023f878c --- /dev/null +++ b/contracts/exchange-forwarder/src/wrappers.ts @@ -0,0 +1,6 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +export * from '../generated-wrappers/dummy_erc20_token'; +export * from '../generated-wrappers/dummy_erc721_token'; +export * from '../generated-wrappers/exchange'; +export * from '../generated-wrappers/forwarder'; +export * from '../generated-wrappers/weth9'; diff --git a/contracts/exchange-forwarder/src/wrappers/index.ts b/contracts/exchange-forwarder/src/wrappers/index.ts deleted file mode 100644 index 89dff9e74..000000000 --- a/contracts/exchange-forwarder/src/wrappers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../../generated-wrappers/forwarder'; diff --git a/contracts/exchange-forwarder/test/forwarder.ts b/contracts/exchange-forwarder/test/forwarder.ts index 24c219563..5acf113dd 100644 --- a/contracts/exchange-forwarder/test/forwarder.ts +++ b/contracts/exchange-forwarder/test/forwarder.ts @@ -1,7 +1,5 @@ import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; -import { artifacts as erc20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20'; -import { DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeWrapper } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -23,7 +21,15 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import { artifacts, ForwarderContract, ForwarderWrapper } from '../src'; +import { + artifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + ExchangeContract, + ForwarderContract, + ForwarderWrapper, + WETH9Contract, +} from '../src'; chaiSetup.configure(); const expect = chai.expect; @@ -88,14 +94,14 @@ describe(ContractName.Forwarder, () => { const erc721Balances = await erc721Wrapper.getBalancesAsync(); erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address]; - wethContract = await WETH9Contract.deployFrom0xArtifactAsync(erc20Artifacts.WETH9, provider, txDefaults); + wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults); weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider); erc20Wrapper.addDummyTokenContract(weth); wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address); zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - exchangeArtifacts.Exchange, + artifacts.Exchange, provider, txDefaults, zrxAssetData, @@ -166,7 +172,7 @@ describe(ContractName.Forwarder, () => { describe('constructor', () => { it('should revert if assetProxy is unregistered', async () => { const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - exchangeArtifacts.Exchange, + artifacts.Exchange, provider, txDefaults, zrxAssetData, diff --git a/contracts/exchange-forwarder/test/utils/forwarder_wrapper.ts b/contracts/exchange-forwarder/test/utils/forwarder_wrapper.ts index 207106852..4f9f6110a 100644 --- a/contracts/exchange-forwarder/test/utils/forwarder_wrapper.ts +++ b/contracts/exchange-forwarder/test/utils/forwarder_wrapper.ts @@ -1,6 +1,3 @@ -import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; -import { artifacts as erc721Artifacts } from '@0x/contracts-erc721'; -import { artifacts as exchangeArtifacts } from '@0x/contracts-exchange'; import { constants, formatters, LogDecoder, MarketSellOrders } from '@0x/contracts-test-utils'; import { SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; @@ -61,12 +58,7 @@ export class ForwarderWrapper { constructor(contractInstance: ForwarderContract, provider: Provider) { this._forwarderContract = contractInstance; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, { - ...artifacts, - ...erc20Artifacts, - ...erc721Artifacts, - ...exchangeArtifacts, - }); + this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); } public async marketSellOrdersWithEthAsync( orders: SignedOrder[], diff --git a/contracts/exchange-forwarder/tsconfig.json b/contracts/exchange-forwarder/tsconfig.json index cd80b5a5f..92c3a0475 100644 --- a/contracts/exchange-forwarder/tsconfig.json +++ b/contracts/exchange-forwarder/tsconfig.json @@ -1,11 +1,13 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], - "files": ["./generated-artifacts/Forwarder.json"], + "files": [ + "generated-artifacts/DummyERC20Token.json", + "generated-artifacts/DummyERC721Token.json", + "generated-artifacts/Exchange.json", + "generated-artifacts/Forwarder.json", + "generated-artifacts/WETH9.json" + ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange-libs/compiler.json b/contracts/exchange-libs/compiler.json index c4f0c6bd9..2a69896e6 100644 --- a/contracts/exchange-libs/compiler.json +++ b/contracts/exchange-libs/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -20,13 +17,13 @@ } }, "contracts": [ - "TestLibs", - "LibOrder", - "LibMath", - "LibFillResults", - "LibAbiEncoder", - "LibEIP712", - "LibAssetProxyErrors", - "LibConstants" + "src/LibAbiEncoder.sol", + "src/LibAssetProxyErrors.sol", + "src/LibConstants.sol", + "src/LibEIP712.sol", + "src/LibFillResults.sol", + "src/LibMath.sol", + "src/LibOrder.sol", + "test/TestLibs.sol" ] } diff --git a/contracts/exchange-libs/package.json b/contracts/exchange-libs/package.json index f3efdd00e..a2279af91 100644 --- a/contracts/exchange-libs/package.json +++ b/contracts/exchange-libs/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(LibMath|LibOrder|LibFillResults|LibAbiEncoder|TestLibs|LibEIP712).json" + "abis": "./generated-artifacts/@(LibAbiEncoder|LibAssetProxyErrors|LibConstants|LibEIP712|LibFillResults|LibMath|LibOrder|TestLibs).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -49,6 +51,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/exchange-libs/src/artifacts.ts b/contracts/exchange-libs/src/artifacts.ts new file mode 100644 index 000000000..5e660e1a8 --- /dev/null +++ b/contracts/exchange-libs/src/artifacts.ts @@ -0,0 +1,21 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as LibAbiEncoder from '../generated-artifacts/LibAbiEncoder.json'; +import * as LibAssetProxyErrors from '../generated-artifacts/LibAssetProxyErrors.json'; +import * as LibConstants from '../generated-artifacts/LibConstants.json'; +import * as LibEIP712 from '../generated-artifacts/LibEIP712.json'; +import * as LibFillResults from '../generated-artifacts/LibFillResults.json'; +import * as LibMath from '../generated-artifacts/LibMath.json'; +import * as LibOrder from '../generated-artifacts/LibOrder.json'; +import * as TestLibs from '../generated-artifacts/TestLibs.json'; +export const artifacts = { + LibAbiEncoder: LibAbiEncoder as ContractArtifact, + LibAssetProxyErrors: LibAssetProxyErrors as ContractArtifact, + LibConstants: LibConstants as ContractArtifact, + LibEIP712: LibEIP712 as ContractArtifact, + LibFillResults: LibFillResults as ContractArtifact, + LibMath: LibMath as ContractArtifact, + LibOrder: LibOrder as ContractArtifact, + TestLibs: TestLibs as ContractArtifact, +}; diff --git a/contracts/exchange-libs/src/artifacts/index.ts b/contracts/exchange-libs/src/artifacts/index.ts deleted file mode 100644 index 3955bbe2b..000000000 --- a/contracts/exchange-libs/src/artifacts/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as LibAbiEncoder from '../../generated-artifacts/LibAbiEncoder.json'; -import * as LibEIP721 from '../../generated-artifacts/LibEIP712.json'; -import * as LibFillResults from '../../generated-artifacts/LibFillResults.json'; -import * as LibMath from '../../generated-artifacts/LibMath.json'; -import * as LibOrder from '../../generated-artifacts/LibOrder.json'; -import * as TestLibs from '../../generated-artifacts/TestLibs.json'; - -export const artifacts = { - TestLibs: TestLibs as ContractArtifact, - LibAbiEncoder: LibAbiEncoder as ContractArtifact, - LibFillResults: LibFillResults as ContractArtifact, - LibMath: LibMath as ContractArtifact, - LibOrder: LibOrder as ContractArtifact, - LibEIP721: LibEIP721 as ContractArtifact, -}; diff --git a/contracts/exchange-libs/src/wrappers.ts b/contracts/exchange-libs/src/wrappers.ts new file mode 100644 index 000000000..840886181 --- /dev/null +++ b/contracts/exchange-libs/src/wrappers.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +export * from '../generated-wrappers/lib_abi_encoder'; +export * from '../generated-wrappers/lib_asset_proxy_errors'; +export * from '../generated-wrappers/lib_constants'; +export * from '../generated-wrappers/lib_e_i_p712'; +export * from '../generated-wrappers/lib_fill_results'; +export * from '../generated-wrappers/lib_math'; +export * from '../generated-wrappers/lib_order'; +export * from '../generated-wrappers/test_libs'; diff --git a/contracts/exchange-libs/src/wrappers/index.ts b/contracts/exchange-libs/src/wrappers/index.ts deleted file mode 100644 index baaae6e34..000000000 --- a/contracts/exchange-libs/src/wrappers/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from '../../generated-wrappers/test_libs'; -export * from '../../generated-wrappers/lib_abi_encoder'; -export * from '../../generated-wrappers/lib_fill_results'; -export * from '../../generated-wrappers/lib_math'; -export * from '../../generated-wrappers/lib_order'; -export * from '../../generated-wrappers/lib_e_i_p712'; diff --git a/contracts/exchange-libs/tsconfig.json b/contracts/exchange-libs/tsconfig.json index 27ca35085..1b5d54175 100644 --- a/contracts/exchange-libs/tsconfig.json +++ b/contracts/exchange-libs/tsconfig.json @@ -1,18 +1,16 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/TestLibs.json", - "./generated-artifacts/LibOrder.json", - "./generated-artifacts/LibFillResults.json", - "./generated-artifacts/LibAbiEncoder.json", - "./generated-artifacts/LibEIP712.json", - "./generated-artifacts/LibMath.json" + "generated-artifacts/LibAbiEncoder.json", + "generated-artifacts/LibAssetProxyErrors.json", + "generated-artifacts/LibConstants.json", + "generated-artifacts/LibEIP712.json", + "generated-artifacts/LibFillResults.json", + "generated-artifacts/LibMath.json", + "generated-artifacts/LibOrder.json", + "generated-artifacts/TestLibs.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange/compiler.json b/contracts/exchange/compiler.json index 6a5f666d1..b7a94cd13 100644 --- a/contracts/exchange/compiler.json +++ b/contracts/exchange/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -20,23 +17,31 @@ } }, "contracts": [ - "Exchange", - "IAssetProxyDispatcher", - "IExchange", - "IExchangeCore", - "IMatchOrders", - "ISignatureValidator", - "ITransactions", - "IValidator", - "IWallet", - "IWrapperFunctions", - "TestAssetProxyDispatcher", - "TestExchangeInternals", - "TestSignatureValidator", - "TestStaticCallReceiver", - "ExchangeWrapper", - "Validator", - "Wallet", - "Whitelist" + "@0x/contracts-asset-proxy/contracts/src/ERC20Proxy.sol", + "@0x/contracts-asset-proxy/contracts/src/ERC721Proxy.sol", + "@0x/contracts-asset-proxy/contracts/src/MultiAssetProxy.sol", + "@0x/contracts-erc20/contracts/test/DummyERC20Token.sol", + "@0x/contracts-erc20/contracts/test/DummyNoReturnERC20Token.sol", + "@0x/contracts-erc20/contracts/test/ReentrantERC20Token.sol", + "@0x/contracts-erc721/contracts/test/DummyERC721Token.sol", + "@0x/contracts-exchange-libs/contracts/test/TestLibs.sol", + "examples/ExchangeWrapper.sol", + "examples/Validator.sol", + "examples/Wallet.sol", + "examples/Whitelist.sol", + "src/Exchange.sol", + "src/interfaces/IAssetProxyDispatcher.sol", + "src/interfaces/IExchange.sol", + "src/interfaces/IExchangeCore.sol", + "src/interfaces/IMatchOrders.sol", + "src/interfaces/ISignatureValidator.sol", + "src/interfaces/ITransactions.sol", + "src/interfaces/IValidator.sol", + "src/interfaces/IWallet.sol", + "src/interfaces/IWrapperFunctions.sol", + "test/TestAssetProxyDispatcher.sol", + "test/TestExchangeInternals.sol", + "test/TestSignatureValidator.sol", + "test/TestStaticCallReceiver.sol" ] } diff --git a/contracts/exchange/package.json b/contracts/exchange/package.json index a11767626..51a6cdf26 100644 --- a/contracts/exchange/package.json +++ b/contracts/exchange/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(ERC20Proxy|ERC721Proxy|Exchange|IAssetProxyDispatcher|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|IWrapperFunctions|IValidator|IWallet|MixinAuthorizable|MultiAssetProxy|TestSignatureValidator|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver|ExchangeWrapper|Validator|Wallet|Whitelist).json" + "abis": "./generated-artifacts/@(DummyERC20Token|DummyERC721Token|DummyNoReturnERC20Token|ERC20Proxy|ERC721Proxy|Exchange|ExchangeWrapper|IAssetProxyDispatcher|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|IValidator|IWallet|IWrapperFunctions|MultiAssetProxy|ReentrantERC20Token|TestAssetProxyDispatcher|TestExchangeInternals|TestLibs|TestSignatureValidator|TestStaticCallReceiver|Validator|Wallet|Whitelist).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -48,6 +50,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/exchange/src/artifacts.ts b/contracts/exchange/src/artifacts.ts new file mode 100644 index 000000000..e49aea10b --- /dev/null +++ b/contracts/exchange/src/artifacts.ts @@ -0,0 +1,57 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; +import * as DummyERC721Token from '../generated-artifacts/DummyERC721Token.json'; +import * as DummyNoReturnERC20Token from '../generated-artifacts/DummyNoReturnERC20Token.json'; +import * as ERC20Proxy from '../generated-artifacts/ERC20Proxy.json'; +import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json'; +import * as Exchange from '../generated-artifacts/Exchange.json'; +import * as ExchangeWrapper from '../generated-artifacts/ExchangeWrapper.json'; +import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispatcher.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 ISignatureValidator from '../generated-artifacts/ISignatureValidator.json'; +import * as ITransactions from '../generated-artifacts/ITransactions.json'; +import * as IValidator from '../generated-artifacts/IValidator.json'; +import * as IWallet from '../generated-artifacts/IWallet.json'; +import * as IWrapperFunctions from '../generated-artifacts/IWrapperFunctions.json'; +import * as MultiAssetProxy from '../generated-artifacts/MultiAssetProxy.json'; +import * as ReentrantERC20Token from '../generated-artifacts/ReentrantERC20Token.json'; +import * as TestAssetProxyDispatcher from '../generated-artifacts/TestAssetProxyDispatcher.json'; +import * as TestExchangeInternals from '../generated-artifacts/TestExchangeInternals.json'; +import * as TestLibs from '../generated-artifacts/TestLibs.json'; +import * as TestSignatureValidator from '../generated-artifacts/TestSignatureValidator.json'; +import * as TestStaticCallReceiver from '../generated-artifacts/TestStaticCallReceiver.json'; +import * as Validator from '../generated-artifacts/Validator.json'; +import * as Wallet from '../generated-artifacts/Wallet.json'; +import * as Whitelist from '../generated-artifacts/Whitelist.json'; +export const artifacts = { + ERC20Proxy: ERC20Proxy as ContractArtifact, + ERC721Proxy: ERC721Proxy as ContractArtifact, + MultiAssetProxy: MultiAssetProxy as ContractArtifact, + DummyERC20Token: DummyERC20Token as ContractArtifact, + DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, + ReentrantERC20Token: ReentrantERC20Token as ContractArtifact, + DummyERC721Token: DummyERC721Token as ContractArtifact, + TestLibs: TestLibs as ContractArtifact, + ExchangeWrapper: ExchangeWrapper as ContractArtifact, + Validator: Validator as ContractArtifact, + Wallet: Wallet as ContractArtifact, + Whitelist: Whitelist as ContractArtifact, + Exchange: Exchange as ContractArtifact, + IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, + IExchange: IExchange as ContractArtifact, + IExchangeCore: IExchangeCore as ContractArtifact, + IMatchOrders: IMatchOrders as ContractArtifact, + ISignatureValidator: ISignatureValidator as ContractArtifact, + ITransactions: ITransactions as ContractArtifact, + IValidator: IValidator as ContractArtifact, + IWallet: IWallet as ContractArtifact, + IWrapperFunctions: IWrapperFunctions as ContractArtifact, + TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact, + TestExchangeInternals: TestExchangeInternals as ContractArtifact, + TestSignatureValidator: TestSignatureValidator as ContractArtifact, + TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact, +}; diff --git a/contracts/exchange/src/artifacts/index.ts b/contracts/exchange/src/artifacts/index.ts deleted file mode 100644 index 798ff17ab..000000000 --- a/contracts/exchange/src/artifacts/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as Exchange from '../../generated-artifacts/Exchange.json'; -import * as ExchangeWrapper from '../../generated-artifacts/ExchangeWrapper.json'; -import * as IAssetProxyDispatcher from '../../generated-artifacts/IAssetProxyDispatcher.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 ISignatureValidator from '../../generated-artifacts/ISignatureValidator.json'; -import * as ITransactions from '../../generated-artifacts/ITransactions.json'; -import * as IValidator from '../../generated-artifacts/IValidator.json'; -import * as IWallet from '../../generated-artifacts/IWallet.json'; -import * as IWrapperFunctions from '../../generated-artifacts/IWrapperFunctions.json'; -import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json'; -import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json'; -import * as TestSignatureValidator from '../../generated-artifacts/TestSignatureValidator.json'; -import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCallReceiver.json'; -import * as Validator from '../../generated-artifacts/Validator.json'; -import * as Wallet from '../../generated-artifacts/Wallet.json'; -import * as Whitelist from '../../generated-artifacts/Whitelist.json'; - -export const artifacts = { - Exchange: Exchange as ContractArtifact, - TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact, - TestExchangeInternals: TestExchangeInternals as ContractArtifact, - TestSignatureValidator: TestSignatureValidator as ContractArtifact, - TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact, - IExchange: IExchange as ContractArtifact, - IExchangeCore: IExchangeCore as ContractArtifact, - IMatchOrders: IMatchOrders as ContractArtifact, - ISignatureValidator: ISignatureValidator as ContractArtifact, - ITransactions: ITransactions as ContractArtifact, - IWrapperFunctions: IWrapperFunctions as ContractArtifact, - IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, - IValidator: IValidator as ContractArtifact, - IWallet: IWallet as ContractArtifact, - ExchangeWrapper: ExchangeWrapper as ContractArtifact, - Validator: Validator as ContractArtifact, - Wallet: Wallet as ContractArtifact, - Whitelist: Whitelist as ContractArtifact, -}; diff --git a/contracts/exchange/src/wrappers.ts b/contracts/exchange/src/wrappers.ts new file mode 100644 index 000000000..eca3c1c89 --- /dev/null +++ b/contracts/exchange/src/wrappers.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +export * from '../generated-wrappers/dummy_erc20_token'; +export * from '../generated-wrappers/dummy_erc721_token'; +export * from '../generated-wrappers/dummy_no_return_erc20_token'; +export * from '../generated-wrappers/erc20_proxy'; +export * from '../generated-wrappers/erc721_proxy'; +export * from '../generated-wrappers/exchange'; +export * from '../generated-wrappers/exchange_wrapper'; +export * from '../generated-wrappers/i_asset_proxy_dispatcher'; +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_signature_validator'; +export * from '../generated-wrappers/i_transactions'; +export * from '../generated-wrappers/i_validator'; +export * from '../generated-wrappers/i_wallet'; +export * from '../generated-wrappers/i_wrapper_functions'; +export * from '../generated-wrappers/multi_asset_proxy'; +export * from '../generated-wrappers/reentrant_erc20_token'; +export * from '../generated-wrappers/test_asset_proxy_dispatcher'; +export * from '../generated-wrappers/test_exchange_internals'; +export * from '../generated-wrappers/test_libs'; +export * from '../generated-wrappers/test_signature_validator'; +export * from '../generated-wrappers/test_static_call_receiver'; +export * from '../generated-wrappers/validator'; +export * from '../generated-wrappers/wallet'; +export * from '../generated-wrappers/whitelist'; diff --git a/contracts/exchange/src/wrappers/index.ts b/contracts/exchange/src/wrappers/index.ts deleted file mode 100644 index 86e939b56..000000000 --- a/contracts/exchange/src/wrappers/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -export * from '../../generated-wrappers/exchange'; -export * from '../../generated-wrappers/test_asset_proxy_dispatcher'; -export * from '../../generated-wrappers/test_exchange_internals'; -export * from '../../generated-wrappers/test_signature_validator'; -export * from '../../generated-wrappers/test_static_call_receiver'; -export * from '../../generated-wrappers/i_asset_proxy_dispatcher'; -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_signature_validator'; -export * from '../../generated-wrappers/i_transactions'; -export * from '../../generated-wrappers/i_wrapper_functions'; -export * from '../../generated-wrappers/i_validator'; -export * from '../../generated-wrappers/i_wallet'; -export * from '../../generated-wrappers/exchange_wrapper'; -export * from '../../generated-wrappers/validator'; -export * from '../../generated-wrappers/wallet'; -export * from '../../generated-wrappers/whitelist'; diff --git a/contracts/exchange/test/core.ts b/contracts/exchange/test/core.ts index 74161cc73..7e61ef7ac 100644 --- a/contracts/exchange/test/core.ts +++ b/contracts/exchange/test/core.ts @@ -1,19 +1,4 @@ -import { - artifacts as proxyArtifacts, - ERC20ProxyContract, - ERC20Wrapper, - ERC721ProxyContract, - ERC721Wrapper, - MultiAssetProxyContract, -} from '@0x/contracts-asset-proxy'; -import { - artifacts as erc20Artifacts, - DummyERC20TokenContract, - DummyERC20TokenTransferEventArgs, - DummyNoReturnERC20TokenContract, - ReentrantERC20TokenContract, -} from '@0x/contracts-erc20'; -import { DummyERC721TokenContract } from '@0x/contracts-erc721'; +import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; import { chaiSetup, constants, @@ -39,9 +24,17 @@ import * as _ from 'lodash'; import { artifacts, + DummyERC20TokenContract, + DummyERC20TokenTransferEventArgs, + DummyERC721TokenContract, + DummyNoReturnERC20TokenContract, + ERC20ProxyContract, + ERC721ProxyContract, ExchangeCancelEventArgs, ExchangeContract, ExchangeWrapper, + MultiAssetProxyContract, + ReentrantERC20TokenContract, TestStaticCallReceiverContract, } from '../src'; @@ -98,7 +91,7 @@ describe('Exchange core', () => { erc20Proxy = await erc20Wrapper.deployProxyAsync(); erc721Proxy = await erc721Wrapper.deployProxyAsync(); multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync( - proxyArtifacts.MultiAssetProxy, + artifacts.MultiAssetProxy, provider, txDefaults, ); @@ -120,7 +113,7 @@ describe('Exchange core', () => { txDefaults, ); reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync( - erc20Artifacts.ReentrantERC20Token, + artifacts.ReentrantERC20Token, provider, txDefaults, exchange.address, @@ -345,7 +338,7 @@ describe('Exchange core', () => { describe('Testing exchange of ERC20 tokens with no return values', () => { before(async () => { noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync( - erc20Artifacts.DummyNoReturnERC20Token, + artifacts.DummyNoReturnERC20Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, diff --git a/contracts/exchange/test/dispatcher.ts b/contracts/exchange/test/dispatcher.ts index a25755936..8263b0402 100644 --- a/contracts/exchange/test/dispatcher.ts +++ b/contracts/exchange/test/dispatcher.ts @@ -1,11 +1,4 @@ -import { - artifacts as proxyArtifacts, - ERC20ProxyContract, - ERC20Wrapper, - ERC721ProxyContract, - ERC721Wrapper, -} from '@0x/contracts-asset-proxy'; -import { DummyERC20TokenContract } from '@0x/contracts-erc20'; +import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; import { chaiSetup, constants, @@ -25,6 +18,9 @@ import * as _ from 'lodash'; import { artifacts, + DummyERC20TokenContract, + ERC20ProxyContract, + ERC721ProxyContract, TestAssetProxyDispatcherAssetProxyRegisteredEventArgs, TestAssetProxyDispatcherContract, } from '../src'; @@ -131,7 +127,7 @@ describe('AssetProxyDispatcher', () => { expect(proxyAddress).to.be.equal(erc20Proxy.address); // Deploy a new version of the ERC20 Transfer Proxy contract const newErc20TransferProxy = await ERC20ProxyContract.deployFrom0xArtifactAsync( - proxyArtifacts.ERC20Proxy, + artifacts.ERC20Proxy, provider, txDefaults, ); diff --git a/contracts/exchange/test/match_orders.ts b/contracts/exchange/test/match_orders.ts index d17025ddd..98fea67ea 100644 --- a/contracts/exchange/test/match_orders.ts +++ b/contracts/exchange/test/match_orders.ts @@ -1,6 +1,4 @@ -import { ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, ERC721Wrapper } from '@0x/contracts-asset-proxy'; -import { artifacts as erc20Artifacts, DummyERC20TokenContract, ReentrantERC20TokenContract } from '@0x/contracts-erc20'; -import { DummyERC721TokenContract } from '@0x/contracts-erc721'; +import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; import { chaiSetup, constants, @@ -20,7 +18,18 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, ExchangeContract, ExchangeWrapper, MatchOrderTester, TestExchangeInternalsContract } from '../src'; +import { + artifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + ERC20ProxyContract, + ERC721ProxyContract, + ExchangeContract, + ExchangeWrapper, + MatchOrderTester, + ReentrantERC20TokenContract, + TestExchangeInternalsContract, +} from '../src'; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); chaiSetup.configure(); @@ -131,7 +140,7 @@ describe('matchOrders', () => { ); reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync( - erc20Artifacts.ReentrantERC20Token, + artifacts.ReentrantERC20Token, provider, txDefaults, exchange.address, diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts index 89eac4ddb..33510e50c 100644 --- a/contracts/exchange/test/signature_validator.ts +++ b/contracts/exchange/test/signature_validator.ts @@ -1,4 +1,3 @@ -import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; import { addressUtils, chaiSetup, @@ -78,7 +77,7 @@ describe('MixinSignatureValidator', () => { provider, txDefaults, ); - signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts }); + signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, artifacts); await web3Wrapper.awaitTransactionSuccessAsync( await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(testValidator.address, true, { from: signerAddress, diff --git a/contracts/exchange/test/utils/exchange_wrapper.ts b/contracts/exchange/test/utils/exchange_wrapper.ts index eca535c65..61176751f 100644 --- a/contracts/exchange/test/utils/exchange_wrapper.ts +++ b/contracts/exchange/test/utils/exchange_wrapper.ts @@ -1,5 +1,3 @@ -import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; -import { artifacts as erc721Artifacts } from '@0x/contracts-erc721'; import { FillResults, formatters, @@ -25,7 +23,7 @@ export class ExchangeWrapper { constructor(exchangeContract: ExchangeContract, provider: Provider) { this._exchange = exchangeContract; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...erc20Artifacts, ...erc721Artifacts }); + this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); } public async fillOrderAsync( signedOrder: SignedOrder, diff --git a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts index 26b168909..00ca8a9fc 100644 --- a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts @@ -1,5 +1,4 @@ import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; -import { artifacts as libsArtifacts, TestLibsContract } from '@0x/contracts-exchange-libs'; import { AllowanceAmountScenario, AssetDataScenario, @@ -33,7 +32,7 @@ import { LogWithDecodedArgs, Provider, TxData } from 'ethereum-types'; import * as _ from 'lodash'; import 'make-promises-safe'; -import { artifacts, ExchangeContract, ExchangeFillEventArgs } from '../../src'; +import { artifacts, ExchangeContract, ExchangeFillEventArgs, TestLibsContract } from '../../src'; import { AssetWrapper } from './asset_wrapper'; import { ExchangeWrapper } from './exchange_wrapper'; @@ -129,11 +128,7 @@ export async function fillOrderCombinatorialUtilsFactoryAsync( exchangeContract.address, ); - const testLibsContract = await TestLibsContract.deployFrom0xArtifactAsync( - libsArtifacts.TestLibs, - provider, - txDefaults, - ); + const testLibsContract = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults); const fillOrderCombinatorialUtils = new FillOrderCombinatorialUtils( orderFactory, diff --git a/contracts/exchange/test/wrapper.ts b/contracts/exchange/test/wrapper.ts index 62a0d426f..5476ac99d 100644 --- a/contracts/exchange/test/wrapper.ts +++ b/contracts/exchange/test/wrapper.ts @@ -1,6 +1,4 @@ -import { ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, ERC721Wrapper } from '@0x/contracts-asset-proxy'; -import { artifacts as erc20Artifacts, DummyERC20TokenContract, ReentrantERC20TokenContract } from '@0x/contracts-erc20'; -import { DummyERC721TokenContract } from '@0x/contracts-erc721'; +import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; import { chaiSetup, constants, @@ -22,7 +20,16 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, ExchangeContract, ExchangeWrapper } from '../src'; +import { + artifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + ERC20ProxyContract, + ERC721ProxyContract, + ExchangeContract, + ExchangeWrapper, + ReentrantERC20TokenContract, +} from '../src'; chaiSetup.configure(); const expect = chai.expect; @@ -107,7 +114,7 @@ describe('Exchange wrappers', () => { ); reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync( - erc20Artifacts.ReentrantERC20Token, + artifacts.ReentrantERC20Token, provider, txDefaults, exchange.address, diff --git a/contracts/exchange/tsconfig.json b/contracts/exchange/tsconfig.json index b0fcd1771..35ca3d933 100644 --- a/contracts/exchange/tsconfig.json +++ b/contracts/exchange/tsconfig.json @@ -1,30 +1,34 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/IAssetProxyDispatcher.json", - "./generated-artifacts/IExchange.json", - "./generated-artifacts/IExchangeCore.json", - "./generated-artifacts/IMatchOrders.json", - "./generated-artifacts/ISignatureValidator.json", - "./generated-artifacts/ITransactions.json", - "./generated-artifacts/IValidator.json", - "./generated-artifacts/IWallet.json", - "./generated-artifacts/IWrapperFunctions.json", - "./generated-artifacts/Exchange.json", - "./generated-artifacts/TestAssetProxyDispatcher.json", - "./generated-artifacts/TestExchangeInternals.json", - "./generated-artifacts/TestSignatureValidator.json", - "./generated-artifacts/TestStaticCallReceiver.json", - "./generated-artifacts/ExchangeWrapper.json", - "./generated-artifacts/Validator.json", - "./generated-artifacts/Wallet.json", - "./generated-artifacts/Whitelist.json" + "generated-artifacts/DummyERC20Token.json", + "generated-artifacts/DummyERC721Token.json", + "generated-artifacts/DummyNoReturnERC20Token.json", + "generated-artifacts/ERC20Proxy.json", + "generated-artifacts/ERC721Proxy.json", + "generated-artifacts/Exchange.json", + "generated-artifacts/ExchangeWrapper.json", + "generated-artifacts/IAssetProxyDispatcher.json", + "generated-artifacts/IExchange.json", + "generated-artifacts/IExchangeCore.json", + "generated-artifacts/IMatchOrders.json", + "generated-artifacts/ISignatureValidator.json", + "generated-artifacts/ITransactions.json", + "generated-artifacts/IValidator.json", + "generated-artifacts/IWallet.json", + "generated-artifacts/IWrapperFunctions.json", + "generated-artifacts/MultiAssetProxy.json", + "generated-artifacts/ReentrantERC20Token.json", + "generated-artifacts/TestAssetProxyDispatcher.json", + "generated-artifacts/TestExchangeInternals.json", + "generated-artifacts/TestLibs.json", + "generated-artifacts/TestSignatureValidator.json", + "generated-artifacts/TestStaticCallReceiver.json", + "generated-artifacts/Validator.json", + "generated-artifacts/Wallet.json", + "generated-artifacts/Whitelist.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/extensions/compiler.json b/contracts/extensions/compiler.json index 91e0bd429..41fd582ad 100644 --- a/contracts/extensions/compiler.json +++ b/contracts/extensions/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -19,5 +16,17 @@ } } }, - "contracts": ["BalanceThresholdFilter", "DutchAuction", "OrderMatcher", "OrderValidator"] + "contracts": [ + "@0x/contracts-asset-proxy/contracts/src/ERC20Proxy.sol", + "@0x/contracts-asset-proxy/contracts/src/ERC721Proxy.sol", + "@0x/contracts-erc20/contracts/src/WETH9.sol", + "@0x/contracts-erc20/contracts/test/DummyERC20Token.sol", + "@0x/contracts-erc721/contracts/test/DummyERC721Token.sol", + "@0x/contracts-exchange/contracts/examples/ExchangeWrapper.sol", + "@0x/contracts-exchange/contracts/src/Exchange.sol", + "src/BalanceThresholdFilter/BalanceThresholdFilter.sol", + "src/DutchAuction/DutchAuction.sol", + "src/OrderMatcher/OrderMatcher.sol", + "src/OrderValidator/OrderValidator.sol" + ] } diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json index ad829033f..698c42ccf 100644 --- a/contracts/extensions/package.json +++ b/contracts/extensions/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(BalanceThresholdFilter|DutchAuction|OrderMatcher|OrderValidator).json" + "abis": "./generated-artifacts/@(BalanceThresholdFilter|DummyERC20Token|DummyERC721Token|DutchAuction|ERC20Proxy|ERC721Proxy|Exchange|ExchangeWrapper|OrderMatcher|OrderValidator|WETH9).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -50,6 +52,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/extensions/src/artifacts.ts b/contracts/extensions/src/artifacts.ts new file mode 100644 index 000000000..6db3daecc --- /dev/null +++ b/contracts/extensions/src/artifacts.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as BalanceThresholdFilter from '../generated-artifacts/BalanceThresholdFilter.json'; +import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; +import * as DummyERC721Token from '../generated-artifacts/DummyERC721Token.json'; +import * as DutchAuction from '../generated-artifacts/DutchAuction.json'; +import * as ERC20Proxy from '../generated-artifacts/ERC20Proxy.json'; +import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json'; +import * as Exchange from '../generated-artifacts/Exchange.json'; +import * as ExchangeWrapper from '../generated-artifacts/ExchangeWrapper.json'; +import * as OrderMatcher from '../generated-artifacts/OrderMatcher.json'; +import * as OrderValidator from '../generated-artifacts/OrderValidator.json'; +import * as WETH9 from '../generated-artifacts/WETH9.json'; +export const artifacts = { + ERC20Proxy: ERC20Proxy as ContractArtifact, + ERC721Proxy: ERC721Proxy as ContractArtifact, + WETH9: WETH9 as ContractArtifact, + DummyERC20Token: DummyERC20Token as ContractArtifact, + DummyERC721Token: DummyERC721Token as ContractArtifact, + ExchangeWrapper: ExchangeWrapper as ContractArtifact, + Exchange: Exchange as ContractArtifact, + BalanceThresholdFilter: BalanceThresholdFilter as ContractArtifact, + DutchAuction: DutchAuction as ContractArtifact, + OrderMatcher: OrderMatcher as ContractArtifact, + OrderValidator: OrderValidator as ContractArtifact, +}; diff --git a/contracts/extensions/src/artifacts/index.ts b/contracts/extensions/src/artifacts/index.ts deleted file mode 100644 index f2aee4908..000000000 --- a/contracts/extensions/src/artifacts/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as BalanceThresholdFilter from '../../generated-artifacts/BalanceThresholdFilter.json'; -import * as DutchAuction from '../../generated-artifacts/DutchAuction.json'; -import * as OrderMatcher from '../../generated-artifacts/OrderMatcher.json'; -import * as OrderValidator from '../../generated-artifacts/OrderValidator.json'; - -export const artifacts = { - BalanceThresholdFilter: BalanceThresholdFilter as ContractArtifact, - DutchAuction: DutchAuction as ContractArtifact, - OrderMatcher: OrderMatcher as ContractArtifact, - OrderValidator: OrderValidator as ContractArtifact, -}; diff --git a/contracts/extensions/src/wrappers.ts b/contracts/extensions/src/wrappers.ts new file mode 100644 index 000000000..d34cca292 --- /dev/null +++ b/contracts/extensions/src/wrappers.ts @@ -0,0 +1,12 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +export * from '../generated-wrappers/balance_threshold_filter'; +export * from '../generated-wrappers/dummy_erc20_token'; +export * from '../generated-wrappers/dummy_erc721_token'; +export * from '../generated-wrappers/dutch_auction'; +export * from '../generated-wrappers/erc20_proxy'; +export * from '../generated-wrappers/erc721_proxy'; +export * from '../generated-wrappers/exchange'; +export * from '../generated-wrappers/exchange_wrapper'; +export * from '../generated-wrappers/order_matcher'; +export * from '../generated-wrappers/order_validator'; +export * from '../generated-wrappers/weth9'; diff --git a/contracts/extensions/src/wrappers/index.ts b/contracts/extensions/src/wrappers/index.ts deleted file mode 100644 index eed198524..000000000 --- a/contracts/extensions/src/wrappers/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from '../../generated-wrappers/balance_threshold_filter'; -export * from '../../generated-wrappers/dutch_auction'; -export * from '../../generated-wrappers/order_matcher'; -export * from '../../generated-wrappers/order_validator'; diff --git a/contracts/extensions/test/balance_threshold_filter.ts b/contracts/extensions/test/balance_threshold_filter.ts index c79a72f5a..34eb319de 100644 --- a/contracts/extensions/test/balance_threshold_filter.ts +++ b/contracts/extensions/test/balance_threshold_filter.ts @@ -1,3 +1,4 @@ +import { ExchangeWrapper } from '@0x/contracts-exchange'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { assetDataUtils } from '@0x/order-utils'; import { Order, RevertReason, SignedOrder } from '@0x/types'; @@ -9,7 +10,6 @@ import * as _ from 'lodash'; import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; import { DummyERC20TokenContract } from '@0x/contracts-erc20'; -import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -24,7 +24,7 @@ import { web3Wrapper, } from '@0x/contracts-test-utils'; -import { artifacts, BalanceThresholdFilterContract, BalanceThresholdWrapper } from '../src'; +import { artifacts, BalanceThresholdFilterContract, BalanceThresholdWrapper, ExchangeContract } from '../src'; chaiSetup.configure(); const expect = chai.expect; @@ -127,7 +127,7 @@ describe(ContractName.BalanceThresholdFilter, () => { await erc20Wrapper.setBalancesAndAllowancesAsync(); // Deploy Exchange contract exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - exchangeArtifacts.Exchange, + artifacts.Exchange, provider, txDefaults, zrxAssetData, diff --git a/contracts/extensions/test/dutch_auction.ts b/contracts/extensions/test/dutch_auction.ts index 34ff25c3d..efe813ffc 100644 --- a/contracts/extensions/test/dutch_auction.ts +++ b/contracts/extensions/test/dutch_auction.ts @@ -1,8 +1,6 @@ import { DutchAuctionWrapper } from '@0x/contract-wrappers'; import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; -import { artifacts as erc20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20'; -import { DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeWrapper } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -23,7 +21,15 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, DutchAuctionContract, DutchAuctionTestWrapper } from '../src'; +import { + artifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + DutchAuctionContract, + DutchAuctionTestWrapper, + ExchangeContract, + WETH9Contract, +} from '../src'; chaiSetup.configure(); const expect = chai.expect; @@ -82,12 +88,12 @@ describe(ContractName.DutchAuction, () => { const erc721Balances = await erc721Wrapper.getBalancesAsync(); erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address]; - wethContract = await WETH9Contract.deployFrom0xArtifactAsync(erc20Artifacts.WETH9, provider, txDefaults); + wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults); erc20Wrapper.addDummyTokenContract(wethContract as any); const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - exchangeArtifacts.Exchange, + artifacts.Exchange, provider, txDefaults, zrxAssetData, diff --git a/contracts/extensions/test/order_matcher.ts b/contracts/extensions/test/order_matcher.ts index 0b2f9ddbb..d726de8e0 100644 --- a/contracts/extensions/test/order_matcher.ts +++ b/contracts/extensions/test/order_matcher.ts @@ -1,17 +1,5 @@ -import { - artifacts as proxyArtifacts, - ERC20ProxyContract, - ERC20Wrapper, - ERC721ProxyContract, -} from '@0x/contracts-asset-proxy'; -import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20'; -import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { - artifacts as exchangeArtifacts, - ExchangeContract, - ExchangeFillEventArgs, - ExchangeWrapper, -} from '@0x/contracts-exchange'; +import { ERC20Wrapper } from '@0x/contracts-asset-proxy'; +import { ExchangeWrapper } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -34,7 +22,16 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, OrderMatcherContract } from '../src'; +import { + artifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + ERC20ProxyContract, + ERC721ProxyContract, + ExchangeContract, + ExchangeFillEventArgs, + OrderMatcherContract, +} from '../src'; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); chaiSetup.configure(); @@ -104,14 +101,10 @@ describe('OrderMatcher', () => { erc20Proxy = await erc20Wrapper.deployProxyAsync(); await erc20Wrapper.setBalancesAndAllowancesAsync(); // Deploy ERC721 proxy - erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync( - proxyArtifacts.ERC721Proxy, - provider, - txDefaults, - ); + erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync(artifacts.ERC721Proxy, provider, txDefaults); // Depoy exchange exchange = await ExchangeContract.deployFrom0xArtifactAsync( - exchangeArtifacts.Exchange, + artifacts.Exchange, provider, txDefaults, assetDataUtils.encodeERC20AssetData(zrxToken.address), @@ -200,7 +193,7 @@ describe('OrderMatcher', () => { describe('constructor', () => { it('should revert if assetProxy is unregistered', async () => { const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( - exchangeArtifacts.Exchange, + artifacts.Exchange, provider, txDefaults, constants.NULL_BYTES, @@ -454,7 +447,7 @@ describe('OrderMatcher', () => { signedOrderLeft.signature, signedOrderRight.signature, ); - const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts, ...exchangeArtifacts }); + const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -492,7 +485,7 @@ describe('OrderMatcher', () => { signedOrderLeft.signature, signedOrderRight.signature, ); - const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts, ...exchangeArtifacts }); + const logDecoder = new LogDecoder(web3Wrapper, artifacts); const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( await web3Wrapper.sendTransactionAsync({ data, @@ -729,7 +722,7 @@ describe('OrderMatcher', () => { }); it('should allow owner to withdraw ERC721 tokens', async () => { const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync( - erc721Artifacts.DummyERC721Token, + artifacts.DummyERC721Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, @@ -774,7 +767,7 @@ describe('OrderMatcher', () => { }); it('should be able to approve an ERC721 token by passing in allowance = 1', async () => { const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync( - erc721Artifacts.DummyERC721Token, + artifacts.DummyERC721Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, @@ -791,7 +784,7 @@ describe('OrderMatcher', () => { }); it('should be able to approve an ERC721 token by passing in allowance > 1', async () => { const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync( - erc721Artifacts.DummyERC721Token, + artifacts.DummyERC721Token, provider, txDefaults, constants.DUMMY_TOKEN_NAME, diff --git a/contracts/extensions/test/order_validator.ts b/contracts/extensions/test/order_validator.ts index 88dae14fb..ec31cafbc 100644 --- a/contracts/extensions/test/order_validator.ts +++ b/contracts/extensions/test/order_validator.ts @@ -1,7 +1,5 @@ -import { ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, ERC721Wrapper } 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 { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; +import { ExchangeWrapper } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -18,7 +16,15 @@ import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, OrderValidatorContract } from '../src'; +import { + artifacts, + DummyERC20TokenContract, + DummyERC721TokenContract, + ERC20ProxyContract, + ERC721ProxyContract, + ExchangeContract, + OrderValidatorContract, +} from '../src'; chaiSetup.configure(); const expect = chai.expect; @@ -74,7 +80,7 @@ describe('OrderValidator', () => { const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); exchange = await ExchangeContract.deployFrom0xArtifactAsync( - exchangeArtifacts.Exchange, + artifacts.Exchange, provider, txDefaults, zrxAssetData, diff --git a/contracts/extensions/test/utils/balance_threshold_wrapper.ts b/contracts/extensions/test/utils/balance_threshold_wrapper.ts index 3178d992e..ab59c5688 100644 --- a/contracts/extensions/test/utils/balance_threshold_wrapper.ts +++ b/contracts/extensions/test/utils/balance_threshold_wrapper.ts @@ -1,6 +1,3 @@ -import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; -import { artifacts as erc721Artifacts } from '@0x/contracts-erc721'; -import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange'; import { FillResults, formatters, @@ -15,8 +12,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { BalanceThresholdFilterContract } from '../../generated-wrappers/balance_threshold_filter'; -import { artifacts } from '../../src/artifacts'; +import { artifacts, BalanceThresholdFilterContract, ExchangeContract } from '../../src'; export class BalanceThresholdWrapper { private readonly _balanceThresholdFilter: BalanceThresholdFilterContract; @@ -34,12 +30,7 @@ export class BalanceThresholdWrapper { this._exchange = exchangeContract; this._signerTransactionFactory = signerTransactionFactory; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, { - ...artifacts, - ...erc20Artifacts, - ...erc721Artifacts, - ...exchangeArtifacts, - }); + this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); } public async fillOrderAsync( signedOrder: SignedOrder, @@ -227,7 +218,7 @@ export class BalanceThresholdWrapper { from: string, ): Promise { const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight); - const data = await this._exchange.matchOrders.getABIEncodedTransactionData( + const data = this._exchange.matchOrders.getABIEncodedTransactionData( params.left, params.right, params.leftSignature, diff --git a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts index 5899ffcac..06cdc21d5 100644 --- a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts +++ b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts @@ -1,6 +1,3 @@ -import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; -import { artifacts as erc721Artifacts } from '@0x/contracts-erc721'; -import { artifacts as exchangeArtifacts } from '@0x/contracts-exchange'; import { LogDecoder } from '@0x/contracts-test-utils'; import { DutchAuctionDetails, SignedOrder } from '@0x/types'; import { Web3Wrapper } from '@0x/web3-wrapper'; @@ -18,12 +15,7 @@ export class DutchAuctionTestWrapper { constructor(contractInstance: DutchAuctionContract, provider: Provider) { this._dutchAuctionContract = contractInstance; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, { - ...artifacts, - ...erc20Artifacts, - ...erc721Artifacts, - ...exchangeArtifacts, - }); + this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); } /** * Matches the buy and sell orders at an amount given the following: the current block time, the auction diff --git a/contracts/extensions/tsconfig.json b/contracts/extensions/tsconfig.json index 0c06c6902..b424bfa04 100644 --- a/contracts/extensions/tsconfig.json +++ b/contracts/extensions/tsconfig.json @@ -1,16 +1,19 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/BalanceThresholdFilter.json", - "./generated-artifacts/DutchAuction.json", - "./generated-artifacts/OrderMatcher.json", - "./generated-artifacts/OrderValidator.json" + "generated-artifacts/BalanceThresholdFilter.json", + "generated-artifacts/DummyERC20Token.json", + "generated-artifacts/DummyERC721Token.json", + "generated-artifacts/DutchAuction.json", + "generated-artifacts/ERC20Proxy.json", + "generated-artifacts/ERC721Proxy.json", + "generated-artifacts/Exchange.json", + "generated-artifacts/ExchangeWrapper.json", + "generated-artifacts/OrderMatcher.json", + "generated-artifacts/OrderValidator.json", + "generated-artifacts/WETH9.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/multisig/compiler.json b/contracts/multisig/compiler.json index ae3905238..336a9ed7b 100644 --- a/contracts/multisig/compiler.json +++ b/contracts/multisig/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -20,10 +17,11 @@ } }, "contracts": [ - "AssetProxyOwner", - "MultiSigWallet", - "MultiSigWalletWithTimeLock", - "TestAssetProxyOwner", - "TestRejectEther" + "@0x/contracts-asset-proxy/contracts/src/MixinAuthorizable.sol", + "src/AssetProxyOwner.sol", + "src/MultiSigWallet.sol", + "src/MultiSigWalletWithTimeLock.sol", + "test/TestAssetProxyOwner.sol", + "test/TestRejectEther.sol" ] } diff --git a/contracts/multisig/package.json b/contracts/multisig/package.json index cbdd96fd8..c5cc8ef25 100644 --- a/contracts/multisig/package.json +++ b/contracts/multisig/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(AssetProxyOwner|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestRejectEther).json" + "abis": "./generated-artifacts/@(AssetProxyOwner|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestRejectEther).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -49,6 +51,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "chai": "^4.0.1", diff --git a/contracts/multisig/src/artifacts.ts b/contracts/multisig/src/artifacts.ts new file mode 100644 index 000000000..37aa9d4ef --- /dev/null +++ b/contracts/multisig/src/artifacts.ts @@ -0,0 +1,17 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as AssetProxyOwner from '../generated-artifacts/AssetProxyOwner.json'; +import * as MixinAuthorizable from '../generated-artifacts/MixinAuthorizable.json'; +import * as MultiSigWallet from '../generated-artifacts/MultiSigWallet.json'; +import * as MultiSigWalletWithTimeLock from '../generated-artifacts/MultiSigWalletWithTimeLock.json'; +import * as TestAssetProxyOwner from '../generated-artifacts/TestAssetProxyOwner.json'; +import * as TestRejectEther from '../generated-artifacts/TestRejectEther.json'; +export const artifacts = { + MixinAuthorizable: MixinAuthorizable as ContractArtifact, + AssetProxyOwner: AssetProxyOwner as ContractArtifact, + MultiSigWallet: MultiSigWallet as ContractArtifact, + MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact, + TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact, + TestRejectEther: TestRejectEther as ContractArtifact, +}; diff --git a/contracts/multisig/src/artifacts/index.ts b/contracts/multisig/src/artifacts/index.ts deleted file mode 100644 index 326d79000..000000000 --- a/contracts/multisig/src/artifacts/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as AssetProxyOwner from '../../generated-artifacts/AssetProxyOwner.json'; -import * as MultiSigWallet from '../../generated-artifacts/MultiSigWallet.json'; -import * as MultiSigWalletWithTimeLock from '../../generated-artifacts/MultiSigWalletWithTimeLock.json'; -import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json'; -import * as TestRejectEther from '../../generated-artifacts/TestRejectEther.json'; - -export const artifacts = { - AssetProxyOwner: AssetProxyOwner as ContractArtifact, - MultiSigWallet: MultiSigWallet as ContractArtifact, - MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact, - TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact, - TestRejectEther: TestRejectEther as ContractArtifact, -}; diff --git a/contracts/multisig/src/wrappers.ts b/contracts/multisig/src/wrappers.ts new file mode 100644 index 000000000..fc46799d0 --- /dev/null +++ b/contracts/multisig/src/wrappers.ts @@ -0,0 +1,7 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +export * from '../generated-wrappers/asset_proxy_owner'; +export * from '../generated-wrappers/mixin_authorizable'; +export * from '../generated-wrappers/multi_sig_wallet'; +export * from '../generated-wrappers/multi_sig_wallet_with_time_lock'; +export * from '../generated-wrappers/test_asset_proxy_owner'; +export * from '../generated-wrappers/test_reject_ether'; diff --git a/contracts/multisig/src/wrappers/index.ts b/contracts/multisig/src/wrappers/index.ts deleted file mode 100644 index 43ab25704..000000000 --- a/contracts/multisig/src/wrappers/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from '../../generated-wrappers/asset_proxy_owner'; -export * from '../../generated-wrappers/multi_sig_wallet'; -export * from '../../generated-wrappers/multi_sig_wallet_with_time_lock'; -export * from '../../generated-wrappers/test_asset_proxy_owner'; -export * from '../../generated-wrappers/test_reject_ether'; diff --git a/contracts/multisig/test/asset_proxy_owner.ts b/contracts/multisig/test/asset_proxy_owner.ts index 62081554b..7bf4069cb 100644 --- a/contracts/multisig/test/asset_proxy_owner.ts +++ b/contracts/multisig/test/asset_proxy_owner.ts @@ -1,4 +1,3 @@ -import { artifacts as proxyArtifacts, MixinAuthorizableContract } from '@0x/contracts-asset-proxy'; import { chaiSetup, constants, @@ -26,6 +25,7 @@ import { AssetProxyOwnerExecutionFailureEventArgs, AssetProxyOwnerSubmissionEventArgs, AssetProxyOwnerWrapper, + MixinAuthorizableContract, TestAssetProxyOwnerContract, } from '../src'; @@ -58,12 +58,12 @@ describe('AssetProxyOwner', () => { notOwner = accounts[3]; const initialOwner = accounts[0]; erc20Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync( - proxyArtifacts.MixinAuthorizable, + artifacts.MixinAuthorizable, provider, txDefaults, ); erc721Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync( - proxyArtifacts.MixinAuthorizable, + artifacts.MixinAuthorizable, provider, txDefaults, ); diff --git a/contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts b/contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts index b6040d8e3..d5aaaf519 100644 --- a/contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts +++ b/contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts @@ -1,5 +1,3 @@ -import { artifacts as proxyArtifacts } from '@0x/contracts-asset-proxy'; -import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; import { LogDecoder } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; @@ -16,7 +14,7 @@ export class AssetProxyOwnerWrapper { constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) { this._assetProxyOwner = assetproxyOwnerContract; this._web3Wrapper = new Web3Wrapper(provider); - this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...erc20Artifacts, ...proxyArtifacts }); + this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts); } public async submitTransactionAsync( destination: string, diff --git a/contracts/multisig/tsconfig.json b/contracts/multisig/tsconfig.json index ad1707e43..094f89413 100644 --- a/contracts/multisig/tsconfig.json +++ b/contracts/multisig/tsconfig.json @@ -1,17 +1,14 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/AssetProxyOwner.json", - "./generated-artifacts/MultiSigWallet.json", - "./generated-artifacts/MultiSigWalletWithTimeLock.json", - "./generated-artifacts/TestAssetProxyOwner.json", - "./generated-artifacts/TestRejectEther.json" + "generated-artifacts/AssetProxyOwner.json", + "generated-artifacts/MixinAuthorizable.json", + "generated-artifacts/MultiSigWallet.json", + "generated-artifacts/MultiSigWalletWithTimeLock.json", + "generated-artifacts/TestAssetProxyOwner.json", + "generated-artifacts/TestRejectEther.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/utils/compiler.json b/contracts/utils/compiler.json index 7473ea6d1..a54f547df 100644 --- a/contracts/utils/compiler.json +++ b/contracts/utils/compiler.json @@ -3,10 +3,7 @@ "contractsDir": "./contracts", "useDockerisedSolc": true, "compilerSettings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, + "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ @@ -19,5 +16,13 @@ } } }, - "contracts": ["TestConstants", "TestLibBytes", "LibBytes", "Ownable", "IOwnable", "ReentrancyGuard", "SafeMath"] + "contracts": [ + "src/LibBytes.sol", + "src/Ownable.sol", + "src/ReentrancyGuard.sol", + "src/SafeMath.sol", + "src/interfaces/IOwnable.sol", + "test/TestConstants.sol", + "test/TestLibBytes.sol" + ] } diff --git a/contracts/utils/package.json b/contracts/utils/package.json index 33d94cc33..afa4a7011 100644 --- a/contracts/utils/package.json +++ b/contracts/utils/package.json @@ -29,10 +29,12 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test", + "contracts:gen": "contracts-gen", "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(IOwnable|Ownable|LibBytes|ReentrancyGuard|SafeMath|TestConstants|TestLibBytes).json" + "abis": "./generated-artifacts/@(IOwnable|LibBytes|Ownable|ReentrancyGuard|SafeMath|TestConstants|TestLibBytes).json", + "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { "type": "git", @@ -49,6 +51,7 @@ "@0x/dev-utils": "^1.0.24", "@0x/sol-compiler": "^2.0.2", "@0x/tslint-config": "^2.0.2", + "@0x/contracts-gen": "^1.0.0", "@types/lodash": "4.14.104", "@types/node": "*", "@types/bn.js": "^4.11.0", diff --git a/contracts/utils/src/artifacts.ts b/contracts/utils/src/artifacts.ts new file mode 100644 index 000000000..26f665eec --- /dev/null +++ b/contracts/utils/src/artifacts.ts @@ -0,0 +1,19 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +import { ContractArtifact } from 'ethereum-types'; + +import * as IOwnable from '../generated-artifacts/IOwnable.json'; +import * as LibBytes from '../generated-artifacts/LibBytes.json'; +import * as Ownable from '../generated-artifacts/Ownable.json'; +import * as ReentrancyGuard from '../generated-artifacts/ReentrancyGuard.json'; +import * as SafeMath from '../generated-artifacts/SafeMath.json'; +import * as TestConstants from '../generated-artifacts/TestConstants.json'; +import * as TestLibBytes from '../generated-artifacts/TestLibBytes.json'; +export const artifacts = { + LibBytes: LibBytes as ContractArtifact, + Ownable: Ownable as ContractArtifact, + ReentrancyGuard: ReentrancyGuard as ContractArtifact, + SafeMath: SafeMath as ContractArtifact, + IOwnable: IOwnable as ContractArtifact, + TestConstants: TestConstants as ContractArtifact, + TestLibBytes: TestLibBytes as ContractArtifact, +}; diff --git a/contracts/utils/src/artifacts/index.ts b/contracts/utils/src/artifacts/index.ts deleted file mode 100644 index a5c2b215c..000000000 --- a/contracts/utils/src/artifacts/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as IOwnable from '../../generated-artifacts/IOwnable.json'; -import * as LibBytes from '../../generated-artifacts/LibBytes.json'; -import * as Ownable from '../../generated-artifacts/Ownable.json'; -import * as ReentrancyGuard from '../../generated-artifacts/ReentrancyGuard.json'; -import * as SafeMath from '../../generated-artifacts/SafeMath.json'; -import * as TestConstants from '../../generated-artifacts/TestConstants.json'; -import * as TestLibBytes from '../../generated-artifacts/TestLibBytes.json'; - -export const artifacts = { - TestConstants: TestConstants as ContractArtifact, - TestLibBytes: TestLibBytes as ContractArtifact, - IOwnable: IOwnable as ContractArtifact, - LibBytes: LibBytes as ContractArtifact, - Ownable: Ownable as ContractArtifact, - SafeMath: SafeMath as ContractArtifact, - ReentrancyGuard: ReentrancyGuard as ContractArtifact, -}; diff --git a/contracts/utils/src/wrappers.ts b/contracts/utils/src/wrappers.ts new file mode 100644 index 000000000..fc8e4584a --- /dev/null +++ b/contracts/utils/src/wrappers.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by contracts-gen. Don't edit manually. +export * from '../generated-wrappers/i_ownable'; +export * from '../generated-wrappers/lib_bytes'; +export * from '../generated-wrappers/ownable'; +export * from '../generated-wrappers/reentrancy_guard'; +export * from '../generated-wrappers/safe_math'; +export * from '../generated-wrappers/test_constants'; +export * from '../generated-wrappers/test_lib_bytes'; diff --git a/contracts/utils/src/wrappers/index.ts b/contracts/utils/src/wrappers/index.ts deleted file mode 100644 index 823b7fa4b..000000000 --- a/contracts/utils/src/wrappers/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from '../../generated-wrappers/test_constants'; -export * from '../../generated-wrappers/test_lib_bytes'; diff --git a/contracts/utils/tsconfig.json b/contracts/utils/tsconfig.json index 68251e6b0..efd71ff93 100644 --- a/contracts/utils/tsconfig.json +++ b/contracts/utils/tsconfig.json @@ -1,19 +1,15 @@ { "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, + "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "./generated-artifacts/TestConstants.json", - "./generated-artifacts/TestLibBytes.json", - "./generated-artifacts/IOwnable.json", - "./generated-artifacts/Ownable.json", - "./generated-artifacts/LibBytes.json", - "./generated-artifacts/SafeMath.json", - "./generated-artifacts/ReentrancyGuard.json" + "generated-artifacts/IOwnable.json", + "generated-artifacts/LibBytes.json", + "generated-artifacts/Ownable.json", + "generated-artifacts/ReentrancyGuard.json", + "generated-artifacts/SafeMath.json", + "generated-artifacts/TestConstants.json", + "generated-artifacts/TestLibBytes.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/package.json b/package.json index 62b4c1c36..c52057e4f 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "build:ts": "tsc -b", "watch:ts": "tsc -b -w", "clean": "wsrun clean $PKG --fast-exit -r --parallel --exclude-missing", + "contracts:gen": "wsrun contracts:gen $PKG --fast-exit -r --parallel --exclude-missing", "remove_node_modules": "lerna clean --yes; rm -rf node_modules", "rebuild": "run-s clean build", "rebuild:no_website": "run-s clean build:no_website", diff --git a/packages/contracts-gen/.npmignore b/packages/contracts-gen/.npmignore new file mode 100644 index 000000000..d645458f6 --- /dev/null +++ b/packages/contracts-gen/.npmignore @@ -0,0 +1,6 @@ +.* +yarn-error.log +/src/ +/scripts/ +tsconfig.json +/lib/monorepo_scripts/ diff --git a/packages/contracts-gen/CHANGELOG.json b/packages/contracts-gen/CHANGELOG.json new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/packages/contracts-gen/CHANGELOG.json @@ -0,0 +1 @@ +[] diff --git a/packages/contracts-gen/README.md b/packages/contracts-gen/README.md new file mode 100644 index 000000000..b32fa53cc --- /dev/null +++ b/packages/contracts-gen/README.md @@ -0,0 +1,76 @@ +# Contracts Gen + +This package allows you to generate boilerplate TypeScript code and configs for smart contracts packages. + +## Installation + +`yarn add -g @0x/contracts-gen` + +## Usage + +Run it from within your smart contracts packages. + +```bash +contracts-gen +``` + +You should run this tool after each time you move your contracts around to regenerate boilerplate code and configs. + +## What can it generate + +This tool does the following: + +- Reads your `compiler.json`. Specifically list of smart contracts. +- Creates `wrapper.ts` file which exports all contract wrappers. +- Creates `artifacts.ts` file which exports all contract artifacts. +- Generates list of JSON artifact files in `tsconfig.json` +- Generates a glob for abi-gen in `package.json` + +On top of that - if your `compiler.json` has contracts referenced just by name - it will resolve the name to relative path and put it there. +It also sorts all the lists in it's output leading to smaller and cleaner diffs. + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/contracts-gen yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/contracts-gen yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` diff --git a/packages/contracts-gen/bin/contracts-gen.js b/packages/contracts-gen/bin/contracts-gen.js new file mode 100755 index 000000000..ec6ab4db6 --- /dev/null +++ b/packages/contracts-gen/bin/contracts-gen.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('../lib/src/contracts-gen.js'); diff --git a/packages/contracts-gen/package.json b/packages/contracts-gen/package.json new file mode 100644 index 000000000..8526feabc --- /dev/null +++ b/packages/contracts-gen/package.json @@ -0,0 +1,49 @@ +{ + "name": "@0x/contracts-gen", + "version": "1.0.0", + "engines": { + "node": ">=6.12" + }, + "description": "Generates boilerplate code for smart contracts packages", + "main": "lib/src/index.js", + "types": "lib/src/index.d.ts", + "scripts": { + "lint": "tslint --format stylish --project .", + "clean": "shx rm -rf lib", + "build": "tsc -b", + "build:ci": "yarn build" + }, + "bin": { + "contracts-gen": "bin/contracts-gen.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts-gen/README.md", + "dependencies": { + "@0x/types": "^1.5.2", + "@0x/utils": "^3.0.1", + "@0x/typescript-typings": "^3.0.8", + "ethereum-types": "^1.1.6", + "@0x/sol-resolver": "^1.2.3", + "lodash": "^4.17.5", + "prettier": "^1.16.3", + "to-snake-case": "^1.0.0" + }, + "devDependencies": { + "@0x/tslint-config": "^2.0.2", + "@types/node": "*", + "@types/prettier": "^1.15.2", + "shx": "^0.2.2", + "tslint": "5.11.0", + "typescript": "3.0.1" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/contracts-gen/src/contracts-gen.ts b/packages/contracts-gen/src/contracts-gen.ts new file mode 100644 index 000000000..0695d9c98 --- /dev/null +++ b/packages/contracts-gen/src/contracts-gen.ts @@ -0,0 +1,171 @@ +#!/usr/bin/env node + +import { NameResolver } from '@0x/sol-resolver'; +import { PackageJSON } from '@0x/types'; +import { logUtils } from '@0x/utils'; +import { CompilerOptions } from 'ethereum-types'; +import * as fs from 'fs'; +import * as _ from 'lodash'; +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_CONTRACTS_DIR = 'contracts'; +const DEFAULT_WRAPPERS_DIR = 'generated-wrappers'; +const AUTO_GENERATED_BANNER = `This file is auto-generated by contracts-gen. Don't edit manually.`; +const AUTO_GENERATED_BANNER_FOR_LISTS = `This list is auto-generated by contracts-gen. Don't edit manually.`; + +(async () => { + const packageDir = process.cwd(); + const compilerJSON = readJSONFile('compiler.json'); + const contracts = compilerJSON.contracts; + const contractsDir = compilerJSON.contractsDir || DEFAULT_CONTRACTS_DIR; + const artifactsDir = compilerJSON.artifactsDir || DEFAULT_ARTIFACTS_DIR; + const wrappersDir = DEFAULT_WRAPPERS_DIR; + if (!_.isArray(contracts)) { + 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); + process.exit(0); +})().catch(err => { + logUtils.log(err); + process.exit(1); +}); + +function generateCompilerJSONContractsList( + contracts: string[], + contractsDir: string, + prettierConfig: prettier.Options | null, +): void { + const COMPILER_JSON_FILE_PATH = 'compiler.json'; + const compilerJSON = readJSONFile(COMPILER_JSON_FILE_PATH); + compilerJSON.contracts = _.map(contracts, contract => { + if (contract.endsWith(SOLIDITY_EXTENSION)) { + // If it's already a relative path - NO-OP. + return contract; + } else { + // If it's just a contract name - resolve it and rewrite. + return new NameResolver(contractsDir).resolve(contract).path; + } + }); + compilerJSON.contracts = _.sortBy(compilerJSON.contracts); + const compilerJSONString = JSON.stringify(compilerJSON); + const formattedCompilerJSON = prettier.format(compilerJSONString, { + ...prettierConfig, + filepath: COMPILER_JSON_FILE_PATH, + }); + fs.writeFileSync(COMPILER_JSON_FILE_PATH, formattedCompilerJSON); +} + +function generateArtifactsTs(contracts: string[], artifactsDir: 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`); + return `import * as ${contractName} from '${importPath}';`; + }); + const sortedImports = _.sortBy(imports); + const artifacts = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + if (contractName === 'ZRXToken') { + // HACK(albrow): "as any" hack still required here because ZRXToken does not + // conform to the v2 artifact type. + return `${contractName}: (${contractName} as any) as ContractArtifact,`; + } else { + return `${contractName}: ${contractName} as ContractArtifact,`; + } + }); + const artifactsTs = ` + // ${AUTO_GENERATED_BANNER} + import { ContractArtifact } from 'ethereum-types'; + + ${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); +} + +function generateWrappersTs(contracts: string[], wrappersDir: string, prettierConfig: prettier.Options | null): void { + const imports = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + const outputFileName = makeOutputFileName(contractName); + const exportPath = path.join('..', wrappersDir, outputFileName); + return `export * from '${exportPath}';`; + }); + const sortedImports = _.sortBy(imports); + const wrappersTs = ` + // ${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); +} + +function generateTsConfigJSONFilesList( + contracts: string[], + artifactsDir: 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 contractName = path.basename(contract, SOLIDITY_EXTENSION); + const artifactPath = path.join(artifactsDir, `${contractName}.json`); + return artifactPath; + }); + tsConfig.files = _.sortBy(tsConfig.files); + const tsConfigString = JSON.stringify(tsConfig); + const formattedTsConfig = prettier.format(tsConfigString, { ...prettierConfig, filepath: TS_CONFIG_FILE_PATH }); + fs.writeFileSync(TS_CONFIG_FILE_PATH, formattedTsConfig); +} + +function generatePackageJSONABIConfig( + contracts: string[], + artifactsDir: string, + prettierConfig: prettier.Options | null, +): void { + let packageJSON = readJSONFile('package.json'); + const contractNames = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + return contractName; + }); + const sortedContractNames = _.sortBy(contractNames); + packageJSON = { + ...packageJSON, + config: { + ...packageJSON.config, + 'abis:comment': AUTO_GENERATED_BANNER_FOR_LISTS, + abis: `${artifactsDir}/@(${sortedContractNames.join('|')}).json`, + }, + }; + const PACKAGE_JSON_FILE_PATH = 'package.json'; + const packageJSONString = JSON.stringify(packageJSON); + const formattedPackageJSON = prettier.format(packageJSONString, { + ...prettierConfig, + filepath: PACKAGE_JSON_FILE_PATH, + }); + fs.writeFileSync(PACKAGE_JSON_FILE_PATH, formattedPackageJSON); +} + +function makeOutputFileName(name: string): string { + let fileName = toSnakeCase(name); + // HACK: Snake case doesn't make a lot of sense for abbreviated names but we can't reliably detect abbreviations + // so we special-case the abbreviations we use. + fileName = fileName.replace('z_r_x', 'zrx').replace('e_r_c', 'erc'); + return fileName; +} + +function readJSONFile(filePath: string): T { + const JSONString = fs.readFileSync(filePath, 'utf8'); + const parsed: T = JSON.parse(JSONString); + return parsed; +} diff --git a/packages/contracts-gen/src/index.ts b/packages/contracts-gen/src/index.ts new file mode 100644 index 000000000..4863ab794 --- /dev/null +++ b/packages/contracts-gen/src/index.ts @@ -0,0 +1,6 @@ +/** + * This module is a CLI tool. As soon as you run it - it starts doing stuff. + * At the same time - our installation tests assume that you can import package without causing side effects. + * That's why our main entry point it empty. No side effects. But out secondary entry poing - contracts-gen.ts is a CLI tool and starts running as soon as you import/run it. + */ +export {}; diff --git a/packages/contracts-gen/tsconfig.json b/packages/contracts-gen/tsconfig.json new file mode 100644 index 000000000..233008d61 --- /dev/null +++ b/packages/contracts-gen/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*"] +} diff --git a/packages/contracts-gen/tslint.json b/packages/contracts-gen/tslint.json new file mode 100644 index 000000000..dd9053357 --- /dev/null +++ b/packages/contracts-gen/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0x/tslint-config"] +} diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 187a80c93..e6273fd60 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -8,6 +8,9 @@ "description": "Helper scripts for the monorepo", "main": "lib/index.js", "types": "lib/index.d.ts", + "bin": { + "contracts-gen": "bin/contracts-gen.js" + }, "scripts": { "build": "tsc -b", "build:ci": "yarn build", @@ -36,6 +39,7 @@ "@types/mkdirp": "^0.5.2", "@types/node": "*", "@types/opn": "^5.1.0", + "@types/prettier": "^1.15.2", "@types/rimraf": "^2.0.2", "@types/semver": "5.5.0", "@types/yargs": "^10.0.0", @@ -48,17 +52,20 @@ }, "dependencies": { "@0x/utils": "^3.0.1", + "@0x/types": "^1.5.2", "@lerna/batch-packages": "^3.0.0-beta.18", "@types/depcheck": "^0.6.0", "async-child-process": "^1.1.1", "chalk": "^2.3.0", "es6-promisify": "^5.0.0", + "ethereum-types": "^1.1.6", "glob": "^7.1.2", "isomorphic-fetch": "2.2.1", "lodash": "^4.17.5", "mkdirp": "^0.5.1", "moment": "2.21.0", "opn": "^5.3.0", + "prettier": "^1.16.3", "promisify-child-process": "^1.0.5", "prompt": "^1.0.0", "publish-release": "0xproject/publish-release", @@ -66,6 +73,7 @@ "semver": "5.5.0", "semver-diff": "^2.1.0", "semver-sort": "0.0.4", + "snake-case": "^2.1.0", "typedoc": "0.13.0", "yargs": "^10.0.3" }, diff --git a/packages/monorepo-scripts/src/deps_versions.ts b/packages/monorepo-scripts/src/deps_versions.ts index 1053906b7..d15bb6b4d 100644 --- a/packages/monorepo-scripts/src/deps_versions.ts +++ b/packages/monorepo-scripts/src/deps_versions.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node +import { PackageJSON } from '@0x/types'; import chalk from 'chalk'; -import * as fs from 'fs'; import { sync as globSync } from 'glob'; import * as _ from 'lodash'; @@ -21,11 +21,10 @@ const PACKAGE_JSON_GLOB = '../*/package.json'; // tslint:disable:no-unused-variable function getDependencies(path: string): Dependencies { - const file = fs.readFileSync(path).toString(); - const parsed = JSON.parse(file); + const packageJSON = utils.readJSONFile(path); const dependencies = { - ...parsed.dependencies, - ...parsed.devDependencies, + ...packageJSON.dependencies, + ...packageJSON.devDependencies, }; return dependencies; } diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 105d87dcd..ddb2811f2 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node +import { PackageJSON } from '@0x/types'; import { logUtils } from '@0x/utils'; import * as promisify from 'es6-promisify'; -import * as fs from 'fs'; import * as _ from 'lodash'; import * as moment from 'moment'; import opn = require('opn'); @@ -141,8 +141,8 @@ async function publishImagesToDockerHubAsync(allUpdatedPackages: Package[]): Pro function getPackagesWithDocs(allUpdatedPackages: Package[]): Package[] { const rootPackageJsonPath = `${constants.monorepoRootPath}/package.json`; - const rootPackageJson = JSON.parse(fs.readFileSync(rootPackageJsonPath).toString()); - const packagesWithDocPagesStringIfExist = _.get(rootPackageJson, 'config.packagesWithDocPages', undefined); + const rootPackageJSON = utils.readJSONFile(rootPackageJsonPath); + const packagesWithDocPagesStringIfExist = _.get(rootPackageJSON, 'config.packagesWithDocPages', undefined); if (_.isUndefined(packagesWithDocPagesStringIfExist)) { return []; // None to generate & publish } diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 822f48967..ec145cd32 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -8,7 +8,7 @@ import { exec as execAsync } from 'promisify-child-process'; import * as rimraf from 'rimraf'; import { promisify } from 'util'; -import { Package } from './types'; +import { Changelog, Package } from './types'; import { utils } from './utils/utils'; // Packages might not be runnable if they are command-line tools or only run in browsers. @@ -100,7 +100,7 @@ async function testInstallPackageAsync( installablePackage: Package, ): Promise { const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); - const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version; + const lastChangelogVersion = utils.readJSONFile(changelogPath)[0].version; const packageName = installablePackage.packageJson.name; utils.log(`Testing ${packageName}@${lastChangelogVersion}`); const packageDirName = path.join(...`${packageName}-test`.split('/')); diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts index 4af4fd257..e285d9082 100644 --- a/packages/monorepo-scripts/src/types.ts +++ b/packages/monorepo-scripts/src/types.ts @@ -1,3 +1,5 @@ +import { PackageJSON } from '@0x/types'; + export interface UpdatedPackage { name: string; version: string; @@ -34,21 +36,6 @@ export interface GitTagsByPackageName { [packageName: string]: string[]; } -export interface PackageJSON { - private?: boolean; - version: string; - name: string; - main?: string; - scripts?: { [command: string]: string }; - config?: { - postpublish?: { - assets?: string[]; - docOmitExports?: string[]; - dockerHubRepo?: string; - }; - }; -} - export interface Package { location: string; packageJson: PackageJSON; diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts index 1a4294e9c..c0e86ad44 100644 --- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts +++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts @@ -1,3 +1,4 @@ +import { PackageJSON } from '@0x/types'; import { existsSync, readFileSync, writeFileSync } from 'fs'; import * as _ from 'lodash'; import * as path from 'path'; @@ -6,7 +7,7 @@ import * as ts from 'typescript'; import { constants } from '../constants'; import { docGenConfigs } from '../doc_gen_configs'; -import { ExportInfo, ExportNameToTypedocNames, ExportPathToExportedItems, PackageJSON } from '../types'; +import { ExportInfo, ExportNameToTypedocNames, ExportPathToExportedItems } from '../types'; import { utils } from './utils'; diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts index 28c5658f3..20a6932c3 100644 --- a/packages/monorepo-scripts/src/utils/utils.ts +++ b/packages/monorepo-scripts/src/utils/utils.ts @@ -1,3 +1,4 @@ +import { PackageJSON } from '@0x/types'; import batchPackages = require('@lerna/batch-packages'); import * as fs from 'fs'; import * as _ from 'lodash'; @@ -5,7 +6,7 @@ import { exec as execAsync } from 'promisify-child-process'; import semver = require('semver'); import { constants } from '../constants'; -import { GitTagsByPackageName, Package, PackageJSON, UpdatedPackage } from '../types'; +import { GitTagsByPackageName, Package, UpdatedPackage } from '../types'; import { changelogUtils } from './changelog_utils'; @@ -13,6 +14,11 @@ export const utils = { log(...args: any[]): void { console.log(...args); // tslint:disable-line:no-console }, + readJSONFile(path: string): T { + const JSONString = fs.readFileSync(path, 'utf8'); + const parsed: T = JSON.parse(JSONString); + return parsed; + }, getTopologicallySortedPackages(rootDir: string): Package[] { const packages = utils.getPackages(rootDir); const batchedPackages: PackageJSON[] = _.flatten(batchPackages(_.map(packages, pkg => pkg.packageJson), false)); @@ -23,8 +29,7 @@ export const utils = { return topsortedPackages; }, getPackages(rootDir: string): Package[] { - const rootPackageJsonString = fs.readFileSync(`${rootDir}/package.json`, 'utf8'); - const rootPackageJson = JSON.parse(rootPackageJsonString); + const rootPackageJson = utils.readJSONFile(`${rootDir}/package.json`); if (_.isUndefined(rootPackageJson.workspaces)) { throw new Error(`Did not find 'workspaces' key in root package.json`); } @@ -40,8 +45,7 @@ export const utils = { } const pathToPackageJson = `${rootDir}/${workspacePath}${subpackageName}`; try { - const packageJsonString = fs.readFileSync(`${pathToPackageJson}/package.json`, 'utf8'); - const packageJson = JSON.parse(packageJsonString); + const packageJson = utils.readJSONFile(`${pathToPackageJson}/package.json`); const pkg = { location: pathToPackageJson, packageJson, diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index efee3eb8a..743acacaa 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -195,9 +195,7 @@ export class Compiler { path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION), ); } else { - contractNamesToCompile = this._specifiedContracts.map(specifiedContract => - path.basename(specifiedContract, constants.SOLIDITY_FILE_EXTENSION), - ); + return this._specifiedContracts; } return contractNamesToCompile; } @@ -217,12 +215,9 @@ export class Compiler { for (const contractName of contractNames) { const spyResolver = new SpyResolver(this._resolver); const contractSource = spyResolver.resolve(contractName); - const sourceTreeHashHex = getSourceTreeHash( - spyResolver, - path.join(this._contractsDir, contractSource.path), - ).toString('hex'); + const sourceTreeHashHex = getSourceTreeHash(spyResolver, contractSource.path).toString('hex'); const contractData = { - contractName, + contractName: path.basename(contractName, constants.SOLIDITY_FILE_EXTENSION), currentArtifactIfExists: await getContractArtifactIfExistsAsync(this._artifactsDir, contractName), sourceTreeHashHex: `0x${sourceTreeHashHex}`, }; diff --git a/packages/sol-compiler/src/utils/compiler.ts b/packages/sol-compiler/src/utils/compiler.ts index c75f76dac..dffd07b1d 100644 --- a/packages/sol-compiler/src/utils/compiler.ts +++ b/packages/sol-compiler/src/utils/compiler.ts @@ -26,7 +26,10 @@ export async function getContractArtifactIfExistsAsync( contractName: string, ): Promise { let contractArtifact; - const currentArtifactPath = `${artifactsDir}/${contractName}.json`; + const currentArtifactPath = `${artifactsDir}/${path.basename( + contractName, + constants.SOLIDITY_FILE_EXTENSION, + )}.json`; try { const opts = { encoding: 'utf8', diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 49f788fb0..dec386ccf 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -685,3 +685,23 @@ export interface DutchAuctionDetails { currentAmount: BigNumber; currentTimeSeconds: BigNumber; } + +export interface PackageJSON { + private?: boolean; + version: string; + name: string; + main?: string; + scripts?: { [command: string]: string }; + config?: { + postpublish?: { + assets?: string[]; + docOmitExports?: string[]; + dockerHubRepo?: string; + }; + 'abis:comment'?: string; + abis?: string; + }; + dependencies?: { [dependencyName: string]: string }; + devDependencies?: { [dependencyName: string]: string }; + workspaces?: string[]; +} diff --git a/tsconfig.json b/tsconfig.json index 0a063c85b..bfa83503e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -40,6 +40,7 @@ { "path": "./packages/contract-addresses" }, { "path": "./packages/contract-artifacts" }, { "path": "./packages/contract-wrappers" }, + { "path": "./packages/contracts-gen" }, { "path": "./packages/dev-utils" }, { "path": "./packages/ethereum-types" }, { "path": "./packages/fill-scenarios" }, diff --git a/yarn.lock b/yarn.lock index 3bc39a830..477e020c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1591,6 +1591,11 @@ version "0.0.29" resolved "https://registry.yarnpkg.com/@types/pluralize/-/pluralize-0.0.29.tgz#6ffa33ed1fc8813c469b859681d09707eb40d03c" +"@types/prettier@^1.15.2": + version "1.15.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.15.2.tgz#91594ea7cb6f3b1f7ea69f32621246654c7cc231" + integrity sha512-XIB0ZCaFZmWUHAa9dBqP5UKXXHwuukmVlP+XcyU94dui2k+l2lG+CHAbt2ffenHPUqoIs5Beh8Pdf2YEq/CZ7A== + "@types/prop-types@*": version "15.5.5" resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.5.5.tgz#17038dd322c2325f5da650a94d5f9974943625e3" @@ -7920,7 +7925,8 @@ got@^6.7.1: graceful-fs@4.1.15, graceful-fs@^3.0.0, graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@~1.2.0: version "4.1.15" - resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" + integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== "graceful-readlink@>= 1.0.0": version "1.0.1" @@ -12950,6 +12956,11 @@ prettier@^1.14.3, prettier@^1.15.3: version "1.15.3" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.3.tgz#1feaac5bdd181237b54dbe65d874e02a1472786a" +prettier@^1.16.3: + version "1.16.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.3.tgz#8c62168453badef702f34b45b6ee899574a6a65d" + integrity sha512-kn/GU6SMRYPxUakNXhpP0EedT/KmaPzr0H5lIsDogrykbaxOpOfAFfk5XA7DZrJyMAv1wlMV3CPcZruGXVVUZw== + pretty-bytes@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" @@ -13495,15 +13506,6 @@ react-dom@^16.3.2: object-assign "^4.1.1" prop-types "^15.6.0" -react-dom@^16.4.2: - version "16.7.0" - resolved "https://registry.npmjs.org/react-dom/-/react-dom-16.7.0.tgz#a17b2a7ca89ee7390bc1ed5eb81783c7461748b8" - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" - scheduler "^0.12.0" - react-dom@^16.5.2: version "16.5.2" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7" @@ -13561,8 +13563,8 @@ react-highlight@0xproject/react-highlight#fix/react-version: dependencies: highlight.js "^9.11.0" highlightjs-solidity "^1.0.5" - react "^16.4.2" - react-dom "^16.4.2" + react "^16.5.2" + react-dom "^16.5.2" react-hot-loader@^4.3.3: version "4.3.4" @@ -13830,15 +13832,6 @@ react@^16.3.2: object-assign "^4.1.1" prop-types "^15.6.0" -react@^16.4.2: - version "16.7.0" - resolved "https://registry.npmjs.org/react/-/react-16.7.0.tgz#b674ec396b0a5715873b350446f7ea0802ab6381" - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" - scheduler "^0.12.0" - react@^16.5.2: version "16.5.2" resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42" @@ -14727,13 +14720,6 @@ schedule@^0.5.0: dependencies: object-assign "^4.1.1" -scheduler@^0.12.0: - version "0.12.0" - resolved "https://registry.npmjs.org/scheduler/-/scheduler-0.12.0.tgz#8ab17699939c0aedc5a196a657743c496538647b" - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - schema-utils@^0.4.4: version "0.4.7" resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187" @@ -15134,6 +15120,7 @@ smart-buffer@^4.0.1: snake-case@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-2.1.0.tgz#41bdb1b73f30ec66a04d4e2cad1b76387d4d6d9f" + integrity sha1-Qb2xtz8w7GagTU4srRt2OH1NbZ8= dependencies: no-case "^2.2.0" @@ -16300,6 +16287,7 @@ to-regex@^3.0.1, to-regex@^3.0.2: to-snake-case@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/to-snake-case/-/to-snake-case-1.0.0.tgz#ce746913897946019a87e62edfaeaea4c608ab8c" + integrity sha1-znRpE4l5RgGah+Yu366upMYIq4w= dependencies: to-space-case "^1.0.0" -- cgit v1.2.3 From 31d1390039aec962153e33884a7c0585561bd946 Mon Sep 17 00:00:00 2001 From: Fabio B Date: Mon, 4 Feb 2019 12:52:36 +0100 Subject: Update packages/contracts-gen/README.md Co-Authored-By: LogvinovLeon --- packages/contracts-gen/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contracts-gen/README.md b/packages/contracts-gen/README.md index b32fa53cc..feaf9e65f 100644 --- a/packages/contracts-gen/README.md +++ b/packages/contracts-gen/README.md @@ -20,7 +20,7 @@ You should run this tool after each time you move your contracts around to regen This tool does the following: -- Reads your `compiler.json`. Specifically list of smart contracts. +- Reads your `compiler.json`. Specifically the list of smart contracts. - Creates `wrapper.ts` file which exports all contract wrappers. - Creates `artifacts.ts` file which exports all contract artifacts. - Generates list of JSON artifact files in `tsconfig.json` -- cgit v1.2.3 From 129ae3a737e0ab32be8e25dc2504bcf31a564cef Mon Sep 17 00:00:00 2001 From: Fabio B Date: Mon, 4 Feb 2019 12:56:18 +0100 Subject: Update packages/contracts-gen/src/index.ts Co-Authored-By: LogvinovLeon --- packages/contracts-gen/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contracts-gen/src/index.ts b/packages/contracts-gen/src/index.ts index 4863ab794..c5f4b01f1 100644 --- a/packages/contracts-gen/src/index.ts +++ b/packages/contracts-gen/src/index.ts @@ -1,6 +1,6 @@ /** * This module is a CLI tool. As soon as you run it - it starts doing stuff. * At the same time - our installation tests assume that you can import package without causing side effects. - * That's why our main entry point it empty. No side effects. But out secondary entry poing - contracts-gen.ts is a CLI tool and starts running as soon as you import/run it. + * That's why our main entry point it empty. No side effects. But our secondary entry point - contracts-gen.ts is a CLI tool and starts running as soon as you import/run it. */ export {}; -- cgit v1.2.3 From 47357ddec84fedb9e449edf6a75d3c7ab295aa6b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Feb 2019 12:58:19 +0100 Subject: Remove redundant dependencies --- packages/monorepo-scripts/package.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index e6273fd60..187a80c93 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -8,9 +8,6 @@ "description": "Helper scripts for the monorepo", "main": "lib/index.js", "types": "lib/index.d.ts", - "bin": { - "contracts-gen": "bin/contracts-gen.js" - }, "scripts": { "build": "tsc -b", "build:ci": "yarn build", @@ -39,7 +36,6 @@ "@types/mkdirp": "^0.5.2", "@types/node": "*", "@types/opn": "^5.1.0", - "@types/prettier": "^1.15.2", "@types/rimraf": "^2.0.2", "@types/semver": "5.5.0", "@types/yargs": "^10.0.0", @@ -52,20 +48,17 @@ }, "dependencies": { "@0x/utils": "^3.0.1", - "@0x/types": "^1.5.2", "@lerna/batch-packages": "^3.0.0-beta.18", "@types/depcheck": "^0.6.0", "async-child-process": "^1.1.1", "chalk": "^2.3.0", "es6-promisify": "^5.0.0", - "ethereum-types": "^1.1.6", "glob": "^7.1.2", "isomorphic-fetch": "2.2.1", "lodash": "^4.17.5", "mkdirp": "^0.5.1", "moment": "2.21.0", "opn": "^5.3.0", - "prettier": "^1.16.3", "promisify-child-process": "^1.0.5", "prompt": "^1.0.0", "publish-release": "0xproject/publish-release", @@ -73,7 +66,6 @@ "semver": "5.5.0", "semver-diff": "^2.1.0", "semver-sort": "0.0.4", - "snake-case": "^2.1.0", "typedoc": "0.13.0", "yargs": "^10.0.3" }, -- cgit v1.2.3 From 1a88eac9c7e8f30f5d1f57132a48e59abd912d41 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Feb 2019 13:00:15 +0100 Subject: Make the banner more visible --- contracts/asset-proxy/src/artifacts.ts | 6 +++++- contracts/asset-proxy/src/wrappers.ts | 6 +++++- contracts/erc20/src/artifacts.ts | 6 +++++- contracts/erc20/src/wrappers.ts | 6 +++++- contracts/erc721/src/artifacts.ts | 6 +++++- contracts/erc721/src/wrappers.ts | 6 +++++- contracts/exchange-forwarder/src/artifacts.ts | 6 +++++- contracts/exchange-forwarder/src/wrappers.ts | 6 +++++- contracts/exchange-libs/src/artifacts.ts | 6 +++++- contracts/exchange-libs/src/wrappers.ts | 6 +++++- contracts/exchange/src/artifacts.ts | 6 +++++- contracts/exchange/src/wrappers.ts | 6 +++++- contracts/extensions/src/artifacts.ts | 6 +++++- contracts/extensions/src/wrappers.ts | 6 +++++- contracts/multisig/src/artifacts.ts | 6 +++++- contracts/multisig/src/wrappers.ts | 6 +++++- contracts/utils/src/artifacts.ts | 6 +++++- contracts/utils/src/wrappers.ts | 6 +++++- packages/contracts-gen/src/contracts-gen.ts | 10 +++++++--- 19 files changed, 97 insertions(+), 21 deletions(-) diff --git a/contracts/asset-proxy/src/artifacts.ts b/contracts/asset-proxy/src/artifacts.ts index 87b80d075..d82c0537e 100644 --- a/contracts/asset-proxy/src/artifacts.ts +++ b/contracts/asset-proxy/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; diff --git a/contracts/asset-proxy/src/wrappers.ts b/contracts/asset-proxy/src/wrappers.ts index 4bff2f423..f8cd342c0 100644 --- a/contracts/asset-proxy/src/wrappers.ts +++ b/contracts/asset-proxy/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/dummy_erc20_token'; export * from '../generated-wrappers/dummy_erc721_receiver'; export * from '../generated-wrappers/dummy_erc721_token'; diff --git a/contracts/erc20/src/artifacts.ts b/contracts/erc20/src/artifacts.ts index 0627b98cf..c97a73195 100644 --- a/contracts/erc20/src/artifacts.ts +++ b/contracts/erc20/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; diff --git a/contracts/erc20/src/wrappers.ts b/contracts/erc20/src/wrappers.ts index b66c3b1ca..40193e7d8 100644 --- a/contracts/erc20/src/wrappers.ts +++ b/contracts/erc20/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ 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'; diff --git a/contracts/erc721/src/artifacts.ts b/contracts/erc721/src/artifacts.ts index daa29a83c..79a76e21b 100644 --- a/contracts/erc721/src/artifacts.ts +++ b/contracts/erc721/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as DummyERC721Receiver from '../generated-artifacts/DummyERC721Receiver.json'; diff --git a/contracts/erc721/src/wrappers.ts b/contracts/erc721/src/wrappers.ts index 909e05868..716f6cca4 100644 --- a/contracts/erc721/src/wrappers.ts +++ b/contracts/erc721/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/dummy_erc721_receiver'; export * from '../generated-wrappers/dummy_erc721_token'; export * from '../generated-wrappers/erc721_token'; diff --git a/contracts/exchange-forwarder/src/artifacts.ts b/contracts/exchange-forwarder/src/artifacts.ts index 39295b797..94bcdf84a 100644 --- a/contracts/exchange-forwarder/src/artifacts.ts +++ b/contracts/exchange-forwarder/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; diff --git a/contracts/exchange-forwarder/src/wrappers.ts b/contracts/exchange-forwarder/src/wrappers.ts index a023f878c..cbe72c5cf 100644 --- a/contracts/exchange-forwarder/src/wrappers.ts +++ b/contracts/exchange-forwarder/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/dummy_erc20_token'; export * from '../generated-wrappers/dummy_erc721_token'; export * from '../generated-wrappers/exchange'; diff --git a/contracts/exchange-libs/src/artifacts.ts b/contracts/exchange-libs/src/artifacts.ts index 5e660e1a8..861d6f3d2 100644 --- a/contracts/exchange-libs/src/artifacts.ts +++ b/contracts/exchange-libs/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as LibAbiEncoder from '../generated-artifacts/LibAbiEncoder.json'; diff --git a/contracts/exchange-libs/src/wrappers.ts b/contracts/exchange-libs/src/wrappers.ts index 840886181..05244d87b 100644 --- a/contracts/exchange-libs/src/wrappers.ts +++ b/contracts/exchange-libs/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/lib_abi_encoder'; export * from '../generated-wrappers/lib_asset_proxy_errors'; export * from '../generated-wrappers/lib_constants'; diff --git a/contracts/exchange/src/artifacts.ts b/contracts/exchange/src/artifacts.ts index e49aea10b..efdacd376 100644 --- a/contracts/exchange/src/artifacts.ts +++ b/contracts/exchange/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; diff --git a/contracts/exchange/src/wrappers.ts b/contracts/exchange/src/wrappers.ts index eca3c1c89..1c1d7fdb4 100644 --- a/contracts/exchange/src/wrappers.ts +++ b/contracts/exchange/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/dummy_erc20_token'; export * from '../generated-wrappers/dummy_erc721_token'; export * from '../generated-wrappers/dummy_no_return_erc20_token'; diff --git a/contracts/extensions/src/artifacts.ts b/contracts/extensions/src/artifacts.ts index 6db3daecc..efa5c859c 100644 --- a/contracts/extensions/src/artifacts.ts +++ b/contracts/extensions/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as BalanceThresholdFilter from '../generated-artifacts/BalanceThresholdFilter.json'; diff --git a/contracts/extensions/src/wrappers.ts b/contracts/extensions/src/wrappers.ts index d34cca292..1a67d2ee3 100644 --- a/contracts/extensions/src/wrappers.ts +++ b/contracts/extensions/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/balance_threshold_filter'; export * from '../generated-wrappers/dummy_erc20_token'; export * from '../generated-wrappers/dummy_erc721_token'; diff --git a/contracts/multisig/src/artifacts.ts b/contracts/multisig/src/artifacts.ts index 37aa9d4ef..7d8a85884 100644 --- a/contracts/multisig/src/artifacts.ts +++ b/contracts/multisig/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as AssetProxyOwner from '../generated-artifacts/AssetProxyOwner.json'; diff --git a/contracts/multisig/src/wrappers.ts b/contracts/multisig/src/wrappers.ts index fc46799d0..81aab39da 100644 --- a/contracts/multisig/src/wrappers.ts +++ b/contracts/multisig/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/asset_proxy_owner'; export * from '../generated-wrappers/mixin_authorizable'; export * from '../generated-wrappers/multi_sig_wallet'; diff --git a/contracts/utils/src/artifacts.ts b/contracts/utils/src/artifacts.ts index 26f665eec..15a1abedf 100644 --- a/contracts/utils/src/artifacts.ts +++ b/contracts/utils/src/artifacts.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ import { ContractArtifact } from 'ethereum-types'; import * as IOwnable from '../generated-artifacts/IOwnable.json'; diff --git a/contracts/utils/src/wrappers.ts b/contracts/utils/src/wrappers.ts index fc8e4584a..8748cb074 100644 --- a/contracts/utils/src/wrappers.ts +++ b/contracts/utils/src/wrappers.ts @@ -1,4 +1,8 @@ -// This file is auto-generated by contracts-gen. Don't edit manually. +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ export * from '../generated-wrappers/i_ownable'; export * from '../generated-wrappers/lib_bytes'; export * from '../generated-wrappers/ownable'; diff --git a/packages/contracts-gen/src/contracts-gen.ts b/packages/contracts-gen/src/contracts-gen.ts index 0695d9c98..0160a8204 100644 --- a/packages/contracts-gen/src/contracts-gen.ts +++ b/packages/contracts-gen/src/contracts-gen.ts @@ -14,7 +14,11 @@ const SOLIDITY_EXTENSION = '.sol'; const DEFAULT_ARTIFACTS_DIR = 'artifacts'; const DEFAULT_CONTRACTS_DIR = 'contracts'; const DEFAULT_WRAPPERS_DIR = 'generated-wrappers'; -const AUTO_GENERATED_BANNER = `This file is auto-generated by contracts-gen. Don't edit manually.`; +const AUTO_GENERATED_BANNER = `/* +* ----------------------------------------------------------------------------- +* Warning: This file is auto-generated by contracts-gen. Don't edit manually. +* ----------------------------------------------------------------------------- +*/`; const AUTO_GENERATED_BANNER_FOR_LISTS = `This list is auto-generated by contracts-gen. Don't edit manually.`; (async () => { @@ -82,7 +86,7 @@ function generateArtifactsTs(contracts: string[], artifactsDir: string, prettier } }); const artifactsTs = ` - // ${AUTO_GENERATED_BANNER} + ${AUTO_GENERATED_BANNER} import { ContractArtifact } from 'ethereum-types'; ${sortedImports.join('\n')} @@ -102,7 +106,7 @@ function generateWrappersTs(contracts: string[], wrappersDir: string, prettierCo }); const sortedImports = _.sortBy(imports); const wrappersTs = ` - // ${AUTO_GENERATED_BANNER} + ${AUTO_GENERATED_BANNER} ${sortedImports.join('\n')} `; const WRAPPERS_TS_FILE_PATH = 'src/wrappers.ts'; -- cgit v1.2.3 From 4d75681357b04ae77637ee62645b662796a3b15b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Feb 2019 13:11:20 +0100 Subject: Add @0x/types dependency --- packages/monorepo-scripts/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 187a80c93..6904a793b 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -48,6 +48,7 @@ }, "dependencies": { "@0x/utils": "^3.0.1", + "@0x/types": "^1.5.2", "@lerna/batch-packages": "^3.0.0-beta.18", "@types/depcheck": "^0.6.0", "async-child-process": "^1.1.1", -- cgit v1.2.3 From 7519d60fb7c298148fbbc9aefa981eda3ac9637b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 7 Feb 2019 11:29:04 +0100 Subject: Fix linter issues --- packages/monorepo-scripts/src/deps_versions.ts | 2 +- packages/monorepo-scripts/src/publish.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/monorepo-scripts/src/deps_versions.ts b/packages/monorepo-scripts/src/deps_versions.ts index fb57a26ef..bb7e50f51 100644 --- a/packages/monorepo-scripts/src/deps_versions.ts +++ b/packages/monorepo-scripts/src/deps_versions.ts @@ -25,7 +25,7 @@ interface ParsedDependencies { const PACKAGE_JSON_GLOB = '../../*/package.json'; const config = utils.readJSONFile(path.join(__dirname, '../../../package.json')) - .config as PackageJSONConfig; + .config as PackageJSONConfig; // tslint:disable-line no-unnecessary-type-assertion const dependenciesWithIgnoredVersions: string[] = (config.ignoreDependencyVersions as string).split(' '); const packagesWithIgnoredVersions: string[] = (config.ignoreDependencyVersionsForPackage as string).split(' '); diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index b9179678e..ddb2811f2 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -47,7 +47,7 @@ async function confirmAsync(message: string): Promise { await confirmAsync( 'THIS IS NOT A TEST PUBLISH! You are about to publish one or more packages to npm. Are you sure you want to continue? (y/n)', ); - // await confirmDocPagesRenderAsync(packagesWithDocs); + await confirmDocPagesRenderAsync(packagesWithDocs); } // Update CHANGELOGs -- cgit v1.2.3 From 88432a5e673e0b98aa45145394e6b6fe1bedf20d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 7 Feb 2019 11:49:59 +0100 Subject: Fix deps versions --- contracts/asset-proxy/package.json | 2 +- contracts/erc20/package.json | 2 +- contracts/erc721/package.json | 2 +- contracts/exchange-forwarder/package.json | 2 +- contracts/exchange-libs/package.json | 2 +- contracts/exchange/package.json | 2 +- contracts/extensions/package.json | 2 +- contracts/multisig/package.json | 2 +- contracts/test-utils/package.json | 2 +- contracts/utils/package.json | 2 +- package.json | 2 +- packages/contracts-gen/package.json | 12 ++++++------ packages/pipeline/package.json | 2 +- packages/website/package.json | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/contracts/asset-proxy/package.json b/contracts/asset-proxy/package.json index 88ae7e3a5..51d26b0ac 100644 --- a/contracts/asset-proxy/package.json +++ b/contracts/asset-proxy/package.json @@ -77,7 +77,7 @@ "@0x/utils": "^4.0.2", "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/erc20/package.json b/contracts/erc20/package.json index 082395376..b3517a8c0 100644 --- a/contracts/erc20/package.json +++ b/contracts/erc20/package.json @@ -75,7 +75,7 @@ "@0x/utils": "^4.0.2", "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/erc721/package.json b/contracts/erc721/package.json index 3989830a9..a8cf7016f 100644 --- a/contracts/erc721/package.json +++ b/contracts/erc721/package.json @@ -74,7 +74,7 @@ "@0x/utils": "^4.0.2", "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/exchange-forwarder/package.json b/contracts/exchange-forwarder/package.json index 511d749f7..1ed3bee3a 100644 --- a/contracts/exchange-forwarder/package.json +++ b/contracts/exchange-forwarder/package.json @@ -81,7 +81,7 @@ "@0x/utils": "^4.0.2", "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/exchange-libs/package.json b/contracts/exchange-libs/package.json index 8b50ca3f6..2b7a1c404 100644 --- a/contracts/exchange-libs/package.json +++ b/contracts/exchange-libs/package.json @@ -75,7 +75,7 @@ "@0x/utils": "^4.0.2", "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/exchange/package.json b/contracts/exchange/package.json index 021ae219a..6c3781b54 100644 --- a/contracts/exchange/package.json +++ b/contracts/exchange/package.json @@ -80,7 +80,7 @@ "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", "ethereumjs-util": "^5.1.1", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json index 34b994f02..118926eb5 100644 --- a/contracts/extensions/package.json +++ b/contracts/extensions/package.json @@ -81,7 +81,7 @@ "@0x/utils": "^4.0.2", "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/multisig/package.json b/contracts/multisig/package.json index d6e5989cd..ce29122c4 100644 --- a/contracts/multisig/package.json +++ b/contracts/multisig/package.json @@ -75,7 +75,7 @@ "@0x/utils": "^4.0.2", "@0x/web3-wrapper": "^4.0.1", "ethereum-types": "^2.0.0", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json index 0b8478e05..f73e1f456 100644 --- a/contracts/test-utils/package.json +++ b/contracts/test-utils/package.json @@ -66,7 +66,7 @@ "ethereumjs-util": "^5.1.1", "ethers": "~4.0.4", "js-combinatorics": "^0.5.3", - "lodash": "^4.17.5", + "lodash": "^4.17.11", "make-promises-safe": "^1.1.0" }, "publishConfig": { diff --git a/contracts/utils/package.json b/contracts/utils/package.json index 9b66f532e..3b0e5a527 100644 --- a/contracts/utils/package.json +++ b/contracts/utils/package.json @@ -77,7 +77,7 @@ "bn.js": "^4.11.8", "ethereum-types": "^2.0.0", "ethereumjs-util": "^5.1.1", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/package.json b/package.json index be6d01c87..1c7ff93ed 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "lcov-result-merger": "^3.0.0", "lerna": "^3.0.0-beta.25", "npm-run-all": "^4.1.2", - "prettier": "^1.15.3", + "prettier": "^1.16.3", "source-map-support": "^0.5.6", "typescript": "3.0.1", "wsrun": "^2.2.0" diff --git a/packages/contracts-gen/package.json b/packages/contracts-gen/package.json index 9f9f14c4a..1265cac69 100644 --- a/packages/contracts-gen/package.json +++ b/packages/contracts-gen/package.json @@ -27,16 +27,16 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts-gen/README.md", "dependencies": { "@0x/types": "^2.0.1", - "@0x/utils": "^3.0.1", - "@0x/typescript-typings": "^3.0.8", - "ethereum-types": "^1.1.6", - "@0x/sol-resolver": "^1.2.3", - "lodash": "^4.17.5", + "@0x/utils": "^4.0.2", + "@0x/typescript-typings": "^4.0.0", + "ethereum-types": "^2.0.0", + "@0x/sol-resolver": "^2.0.1", + "lodash": "^4.17.11", "prettier": "^1.16.3", "to-snake-case": "^1.0.0" }, "devDependencies": { - "@0x/tslint-config": "^2.0.2", + "@0x/tslint-config": "^3.0.0", "@types/node": "*", "@types/prettier": "^1.15.2", "shx": "^0.2.2", diff --git a/packages/pipeline/package.json b/packages/pipeline/package.json index a1500cc74..3e45aa992 100644 --- a/packages/pipeline/package.json +++ b/packages/pipeline/package.json @@ -57,7 +57,7 @@ "dockerode": "^2.5.7", "ethereum-types": "^2.0.0", "pg": "^7.5.0", - "prettier": "^1.15.3", + "prettier": "^1.16.3", "ramda": "^0.25.0", "reflect-metadata": "^0.1.12", "sqlite3": "^4.0.2", diff --git a/packages/website/package.json b/packages/website/package.json index 77295d4de..62b83b3ec 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -47,7 +47,7 @@ "find-versions": "^2.0.0", "jsonschema": "^1.2.0", "less": "^2.7.2", - "lodash": "^4.17.5", + "lodash": "^4.17.11", "material-ui": "^0.20.0", "moment": "2.21.0", "numeral": "^2.0.6", -- cgit v1.2.3 From fd4d3cff880e9131d55a4e534c17289db5f72b6b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 7 Feb 2019 12:13:24 +0100 Subject: Fix sol-compiler bug with remappings causing smart recompilation to now work --- package.json | 2 ++ packages/metacoin/package.json | 3 ++- packages/sol-compiler/CHANGELOG.json | 9 +++++++++ packages/sol-compiler/src/compiler.ts | 5 ++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1c7ff93ed..af32a3c8f 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,8 @@ "watch:ts": "tsc -b -w", "clean": "wsrun clean $PKG --fast-exit -r --parallel --exclude-missing", "contracts:gen": "wsrun contracts:gen $PKG --fast-exit -r --parallel --exclude-missing", + "contracts:compile": "wsrun compile $PKG --fast-exit -r --stages --exclude-missing", + "contracts:watch": "wsrun watch $PKG --parallel --exclude-missing", "remove_node_modules": "lerna clean --yes; rm -rf node_modules", "rebuild": "run-s clean build", "rebuild:no_website": "run-s clean build:no_website", diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 24b387355..fbff1c62a 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -24,7 +24,8 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test:coverage", - "compile": "sol-compiler compile" + "compile": "sol-compiler", + "watch": "sol-compiler -w" }, "author": "", "license": "Apache-2.0", diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index 5f103342e..dd65f3aed 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.0.2", + "changes": [ + { + "note": "Fix a bug when smart recompilation wasn't working because of remappings", + "pr": 1575 + } + ] + }, { "timestamp": 1549452781, "version": "3.0.1", diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index 743acacaa..c5dea1155 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -324,7 +324,10 @@ export class Compiler { } else { const currentArtifact = contractData.currentArtifactIfExists as ContractArtifact; const isUserOnLatestVersion = currentArtifact.schemaVersion === constants.LATEST_ARTIFACT_VERSION; - const didCompilerSettingsChange = !_.isEqual(currentArtifact.compiler.settings, this._compilerSettings); + const didCompilerSettingsChange = !_.isEqual( + _.omit(currentArtifact.compiler.settings, 'remappings'), + this._compilerSettings, + ); const didSourceChange = currentArtifact.sourceTreeHashHex !== contractData.sourceTreeHashHex; return !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange; } -- cgit v1.2.3 From 2ef3af000378f66daa0212daaf23c807d018711e Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 7 Feb 2019 13:20:03 +0100 Subject: Omit remapping in compiler settings equality checks --- packages/sol-compiler/src/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index c5dea1155..67021d445 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -326,7 +326,7 @@ export class Compiler { const isUserOnLatestVersion = currentArtifact.schemaVersion === constants.LATEST_ARTIFACT_VERSION; const didCompilerSettingsChange = !_.isEqual( _.omit(currentArtifact.compiler.settings, 'remappings'), - this._compilerSettings, + _.omit(this._compilerSettings, 'remappings'), ); const didSourceChange = currentArtifact.sourceTreeHashHex !== contractData.sourceTreeHashHex; return !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange; -- cgit v1.2.3