diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/contract-wrappers/package.json | 5 | ||||
-rw-r--r-- | packages/contracts/compiler.json | 2 | ||||
-rw-r--r-- | packages/fill-scenarios/package.json | 2 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/AssetProxyOwner.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/AssetProxyOwner.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/DummyERC20Token.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/DummyERC20Token.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/DummyERC721Token.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/DummyERC721Token.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/ERC20Proxy.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/ERC20Proxy.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/ERC20Token.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/ERC20Token.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/ERC721Proxy.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/ERC721Proxy.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/ERC721Token.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/ERC721Token.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/Exchange.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/Exchange.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/Forwarder.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/Forwarder.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/IValidator.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/IValidator.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/IWallet.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/IWallet.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/OrderValidator.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/OrderValidator.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/WETH9.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/WETH9.json) | 0 | ||||
-rw-r--r-- | packages/migrations/artifacts/2.0.0/ZRXToken.json (renamed from packages/migrations/artifacts/2.0.0-mainnet/ZRXToken.json) | 0 | ||||
-rw-r--r-- | packages/migrations/package.json | 11 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-beta-testnet/artifacts.ts | 23 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-mainnet/artifacts.ts | 17 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-mainnet/migration.ts | 122 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-testnet/artifacts.ts | 23 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-testnet/migration.ts (renamed from packages/migrations/src/2.0.0-beta-testnet/migration.ts) | 0 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0/artifacts.ts | 10 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0/constants.ts (renamed from packages/migrations/src/2.0.0-mainnet/constants.ts) | 0 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0/migration.ts | 155 | ||||
-rw-r--r-- | packages/order-utils/package.json | 4 | ||||
-rw-r--r-- | packages/order-watcher/package.json | 2 |
28 files changed, 96 insertions, 280 deletions
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 5d5c8069a..b36ae946f 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -12,7 +12,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", - "pre_build": "run-s update_artifacts_v2_beta update_artifacts_v2 generate_contract_wrappers copy_artifacts", + "pre_build": "run-s update_artifacts generate_contract_wrappers copy_artifacts", "generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy|Forwarder|OrderValidator).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers", "lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*", "test:circleci": "run-s test:coverage", @@ -20,8 +20,7 @@ "rebuild_and_test": "run-s build test", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", - "update_artifacts_v2_beta": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json src/artifacts; done;", - "update_artifacts_v2": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;", + "update_artifacts": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;", "copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts", "clean": "shx rm -rf _bundles lib test_temp test/artifacts src/contract_wrappers/generated src/artifacts generated_docs", "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit", diff --git a/packages/contracts/compiler.json b/packages/contracts/compiler.json index cdf49dcf6..559b7cd1f 100644 --- a/packages/contracts/compiler.json +++ b/packages/contracts/compiler.json @@ -1,5 +1,5 @@ { - "artifactsDir": "../migrations/artifacts/2.0.0", + "artifactsDir": "../migrations/artifacts/development", "contractsDir": "src/", "compilerSettings": { "optimizer": { diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index 60192d03e..ee5ff1806 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "yarn pre_build && tsc -b", "pre_build": "run-s update_artifacts generate_contract_wrappers", - "update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json lib/artifacts; done;", + "update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json lib/artifacts; done;", "generate_contract_wrappers": "abi-gen --abis 'lib/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers", "copy_monorepo_scripts": "copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", "clean": "shx rm -rf lib src/generated_contract_wrappers", diff --git a/packages/migrations/artifacts/2.0.0-mainnet/AssetProxyOwner.json b/packages/migrations/artifacts/2.0.0/AssetProxyOwner.json index 680ed3abd..680ed3abd 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/AssetProxyOwner.json +++ b/packages/migrations/artifacts/2.0.0/AssetProxyOwner.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/DummyERC20Token.json b/packages/migrations/artifacts/2.0.0/DummyERC20Token.json index e0c5eb5dd..e0c5eb5dd 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/DummyERC20Token.json +++ b/packages/migrations/artifacts/2.0.0/DummyERC20Token.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/DummyERC721Token.json b/packages/migrations/artifacts/2.0.0/DummyERC721Token.json index f0363ad81..f0363ad81 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/DummyERC721Token.json +++ b/packages/migrations/artifacts/2.0.0/DummyERC721Token.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/ERC20Proxy.json b/packages/migrations/artifacts/2.0.0/ERC20Proxy.json index 5bd37ef26..5bd37ef26 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/ERC20Proxy.json +++ b/packages/migrations/artifacts/2.0.0/ERC20Proxy.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/ERC20Token.json b/packages/migrations/artifacts/2.0.0/ERC20Token.json index 11ec4b57a..11ec4b57a 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/ERC20Token.json +++ b/packages/migrations/artifacts/2.0.0/ERC20Token.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/ERC721Proxy.json b/packages/migrations/artifacts/2.0.0/ERC721Proxy.json index 2359c0519..2359c0519 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/ERC721Proxy.json +++ b/packages/migrations/artifacts/2.0.0/ERC721Proxy.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/ERC721Token.json b/packages/migrations/artifacts/2.0.0/ERC721Token.json index ceb374730..ceb374730 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/ERC721Token.json +++ b/packages/migrations/artifacts/2.0.0/ERC721Token.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/Exchange.json b/packages/migrations/artifacts/2.0.0/Exchange.json index 631bba974..631bba974 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/Exchange.json +++ b/packages/migrations/artifacts/2.0.0/Exchange.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/Forwarder.json b/packages/migrations/artifacts/2.0.0/Forwarder.json index 3879837e5..3879837e5 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/Forwarder.json +++ b/packages/migrations/artifacts/2.0.0/Forwarder.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/IValidator.json b/packages/migrations/artifacts/2.0.0/IValidator.json index 0ccb7b343..0ccb7b343 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/IValidator.json +++ b/packages/migrations/artifacts/2.0.0/IValidator.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/IWallet.json b/packages/migrations/artifacts/2.0.0/IWallet.json index df892d360..df892d360 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/IWallet.json +++ b/packages/migrations/artifacts/2.0.0/IWallet.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/OrderValidator.json b/packages/migrations/artifacts/2.0.0/OrderValidator.json index c6af06d9c..c6af06d9c 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/OrderValidator.json +++ b/packages/migrations/artifacts/2.0.0/OrderValidator.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/WETH9.json b/packages/migrations/artifacts/2.0.0/WETH9.json index 8cca84e41..8cca84e41 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/WETH9.json +++ b/packages/migrations/artifacts/2.0.0/WETH9.json diff --git a/packages/migrations/artifacts/2.0.0-mainnet/ZRXToken.json b/packages/migrations/artifacts/2.0.0/ZRXToken.json index 76ee77b34..76ee77b34 100644 --- a/packages/migrations/artifacts/2.0.0-mainnet/ZRXToken.json +++ b/packages/migrations/artifacts/2.0.0/ZRXToken.json diff --git a/packages/migrations/package.json b/packages/migrations/package.json index 847a93472..22a71e3bc 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -11,7 +11,7 @@ "build": "yarn pre_build && tsc -b", "pre_build": "run-s compile:v2 copy_artifacts generate_contract_wrappers", "copy_artifacts": "copyfiles 'artifacts/**/*' ./lib", - "clean": "shx rm -rf lib src/1.0.0/contract_wrappers src/2.0.0/contract_wrappers src/2.0.0-beta-testnet/contract_wrappers src/2.0.0-mainnet/contract_wrappers artifacts/2.0.0", + "clean": "shx rm -rf lib src/1.0.0/contract_wrappers src/2.0.0-testnet/contract_wrappers src/2.0.0/contract_wrappers src/development/contract_wrappers artifacts/development", "lint": "tslint --project . --exclude **/src/v2/contract_wrappers/**/* --exclude **/src/v1/contract_wrappers/**/*", "migrate:v1": "run-s build compile:v1 script:migrate:v1", "migrate:v2": "run-s build compile:v2 script:migrate:v2", @@ -27,16 +27,13 @@ "generate_contract_wrappers:v2-beta-testnet": "abi-gen --abis ${npm_package_config_abis_v2BetaTestnet} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/2.0.0-beta-testnet/contract_wrappers --backend ethers", "generate_contract_wrappers:v2-mainnet": "abi-gen --abis ${npm_package_config_abis_v2Mainnet} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/2.0.0-mainnet/contract_wrappers --backend ethers", "compile:v1": "sol-compiler --artifacts-dir artifacts/1.0.0 --contracts Exchange_v1,DummyERC20Token,ZRXToken,WETH9,TokenTransferProxy_v1,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,TokenRegistry", - "compile:v2": "sol-compiler --artifacts-dir artifacts/2.0.0 --contracts AssetProxyOwner,ERC20Token,DummyERC20Token,ERC721Token,DummyERC721Token,ERC20Proxy,ERC721Proxy,Exchange,Forwarder,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,ZRXToken,WETH9,IWallet,IValidator,OrderValidator", - "compile:v2-beta-testnet": "sol-compiler --artifacts-dir artifacts/2.0.0-beta-testnet --contracts AssetProxyOwner,DummyERC20Token,DummyERC721Token,ERC20Proxy,ERC721Proxy,Exchange,Forwarder,IWallet,IValidator,ERC20Token,ERC721Token,OrderValidator,ZRXToken", - "compile:v2-mainnet": "sol-compiler --artifacts-dir artifacts/2.0.0-mainnet --contracts AssetProxyOwner,ERC20Proxy,ERC721Proxy,Exchange,Forwarder,OrderValidator" }, "config": { "abis": { "v1": "artifacts/1.0.0/@(DummyERC20Token|TokenTransferProxy_v1|Exchange_v1|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|WETH9).json", - "v2": "artifacts/2.0.0/@(ERC20Token|DummyERC20Token|ERC721Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|Forwarder|AssetProxyOwner|ZRXToken|WETH9|IWallet|IValidator|OrderValidator).json", - "v2BetaTestnet": "artifacts/2.0.0-beta-testnet/@(DummyERC721Token|DummyERC20Token|ERC20Token|ERC721Token|ERC20Proxy|ERC721Proxy|Exchange|Forwarder|AssetProxyOwner|IWallet|IValidator|OrderValidator|ZRXToken).json", - "v2Mainnet": "artifacts/2.0.0-mainnet/@(AssetProxyOwner|ERC20Proxy|ERC721Proxy|Exchange|Forwarder|OrderValidator).json" + "v2Testnet": "artifacts/2.0.0-testnet/@(DummyERC721Token|DummyERC20Token|ERC20Token|ERC721Token|ERC20Proxy|ERC721Proxy|Exchange|Forwarder|AssetProxyOwner|IWallet|IValidator|OrderValidator|ZRXToken).json", + "v2": "artifacts/2.0.0/@(DummyERC721Token|DummyERC20Token|ERC20Token|ERC721Token|ERC20Proxy|ERC721Proxy|Exchange|Forwarder|AssetProxyOwner|IWallet|IValidator|OrderValidator|ZRXToken).json", + "development": "artifacts/development/@(DummyERC721Token|DummyERC20Token|ERC20Token|ERC721Token|ERC20Proxy|ERC721Proxy|Exchange|Forwarder|AssetProxyOwner|IWallet|IValidator|OrderValidator|ZRXToken).json" } }, "license": "Apache-2.0", diff --git a/packages/migrations/src/2.0.0-beta-testnet/artifacts.ts b/packages/migrations/src/2.0.0-beta-testnet/artifacts.ts deleted file mode 100644 index ba5fa68a4..000000000 --- a/packages/migrations/src/2.0.0-beta-testnet/artifacts.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as AssetProxyOwner from '../../artifacts/2.0.0-beta-testnet/AssetProxyOwner.json'; -import * as DummyERC20Token from '../../artifacts/2.0.0-beta-testnet/DummyERC20Token.json'; -import * as DummyERC721Token from '../../artifacts/2.0.0-beta-testnet/DummyERC721Token.json'; -import * as ERC20Proxy from '../../artifacts/2.0.0-beta-testnet/ERC20Proxy.json'; -import * as ERC721Proxy from '../../artifacts/2.0.0-beta-testnet/ERC721Proxy.json'; -import * as Exchange from '../../artifacts/2.0.0-beta-testnet/Exchange.json'; -import * as Forwarder from '../../artifacts/2.0.0-beta-testnet/Forwarder.json'; -import * as OrderValidator from '../../artifacts/2.0.0-beta-testnet/OrderValidator.json'; -import * as ZRXToken from '../../artifacts/2.0.0-beta-testnet/ZRXToken.json'; - -export const artifacts = { - AssetProxyOwner: (AssetProxyOwner as any) as ContractArtifact, - Exchange: (Exchange as any) as ContractArtifact, - ERC20Proxy: (ERC20Proxy as any) as ContractArtifact, - ERC721Proxy: (ERC721Proxy as any) as ContractArtifact, - DummyERC721Token: (DummyERC721Token as any) as ContractArtifact, - DummyERC20Token: (DummyERC20Token as any) as ContractArtifact, - Forwarder: (Forwarder as any) as ContractArtifact, - OrderValidator: (OrderValidator as any) as ContractArtifact, - ZRX: (ZRXToken as any) as ContractArtifact, -}; diff --git a/packages/migrations/src/2.0.0-mainnet/artifacts.ts b/packages/migrations/src/2.0.0-mainnet/artifacts.ts deleted file mode 100644 index 8091fa9d0..000000000 --- a/packages/migrations/src/2.0.0-mainnet/artifacts.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as AssetProxyOwner from '../../artifacts/2.0.0-mainnet/AssetProxyOwner.json'; -import * as ERC20Proxy from '../../artifacts/2.0.0-mainnet/ERC20Proxy.json'; -import * as ERC721Proxy from '../../artifacts/2.0.0-mainnet/ERC721Proxy.json'; -import * as Exchange from '../../artifacts/2.0.0-mainnet/Exchange.json'; -import * as Forwarder from '../../artifacts/2.0.0-mainnet/Forwarder.json'; -import * as OrderValidator from '../../artifacts/2.0.0-mainnet/OrderValidator.json'; - -export const artifacts = { - AssetProxyOwner: (AssetProxyOwner as any) as ContractArtifact, - ERC20Proxy: (ERC20Proxy as any) as ContractArtifact, - ERC721Proxy: (ERC721Proxy as any) as ContractArtifact, - Exchange: (Exchange as any) as ContractArtifact, - Forwarder: (Forwarder as any) as ContractArtifact, - OrderValidator: (OrderValidator as any) as ContractArtifact, -}; diff --git a/packages/migrations/src/2.0.0-mainnet/migration.ts b/packages/migrations/src/2.0.0-mainnet/migration.ts deleted file mode 100644 index 4100a750c..000000000 --- a/packages/migrations/src/2.0.0-mainnet/migration.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { assetDataUtils } from '@0xproject/order-utils'; -import { logUtils } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { Provider, TxData } from 'ethereum-types'; - -import { ArtifactWriter } from '../utils/artifact_writer'; - -import { artifacts } from './artifacts'; -import { constants } from './constants'; -import { AssetProxyOwnerContract } from './contract_wrappers/asset_proxy_owner'; -import { ERC20ProxyContract } from './contract_wrappers/erc20_proxy'; -import { ERC721ProxyContract } from './contract_wrappers/erc721_proxy'; -import { ExchangeContract } from './contract_wrappers/exchange'; -import { ForwarderContract } from './contract_wrappers/forwarder'; -import { OrderValidatorContract } from './contract_wrappers/order_validator'; - -/** - * Custom migrations should be defined in this function. This will be called with the CLI 'migrate:v2-mainnet' command. - * Migrations could be written to run in parallel, but if you want contract addresses to be created deterministically, - * the migration should be written to run synchronously. - * @param provider Web3 provider instance. - * @param artifactsDir The directory with compiler artifact files. - * @param txDefaults Default transaction values to use when deploying contracts. - */ -export const runV2MainnetMigrationsAsync = async ( - provider: Provider, - artifactsDir: string, - txDefaults: Partial<TxData>, -) => { - const web3Wrapper = new Web3Wrapper(provider); - const networkId = await web3Wrapper.getNetworkIdAsync(); - const artifactsWriter = new ArtifactWriter(artifactsDir, networkId); - - // Deploy AssetProxies - const erc20proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(artifacts.ERC20Proxy, provider, txDefaults); - artifactsWriter.saveArtifact(erc20proxy); - const erc721proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync( - artifacts.ERC721Proxy, - provider, - txDefaults, - ); - artifactsWriter.saveArtifact(erc721proxy); - - // Deploy Exchange - const exchange = await ExchangeContract.deployFrom0xArtifactAsync(artifacts.Exchange, provider, txDefaults); - artifactsWriter.saveArtifact(exchange); - - let txHash; - // Register AssetProxies in Exchange - txHash = await exchange.registerAssetProxy.sendTransactionAsync(erc20proxy.address); - logUtils.log(`transactionHash: ${txHash}`); - logUtils.log('Registering ERC20Proxy'); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); - - txHash = await exchange.registerAssetProxy.sendTransactionAsync(erc721proxy.address); - logUtils.log(`transactionHash: ${txHash}`); - logUtils.log('Registering ERC721Proxy'); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); - - // Deploy AssetProxyOwner - const assetProxies = [erc20proxy.address, erc721proxy.address]; - const assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync( - artifacts.AssetProxyOwner, - provider, - txDefaults, - constants.ASSET_PROXY_OWNER_OWNERS, - assetProxies, - constants.ASSET_PROXY_OWNER_REQUIRED_CONFIRMATIONS, - constants.ASSET_PROXY_OWNER_SECONDS_TIMELOCKED, - ); - artifactsWriter.saveArtifact(assetProxyOwner); - - // Deploy Forwarder - const zrxAssetData = assetDataUtils.encodeERC20AssetData(constants.ZRX_ADDRESS); - const wethAssetData = assetDataUtils.encodeERC20AssetData(constants.WETH_ADDRESS); - const forwarder = await ForwarderContract.deployFrom0xArtifactAsync( - artifacts.Forwarder, - provider, - txDefaults, - exchange.address, - zrxAssetData, - wethAssetData, - ); - artifactsWriter.saveArtifact(forwarder); - - // Deploy OrderValidator - const orderValidator = await OrderValidatorContract.deployFrom0xArtifactAsync( - artifacts.OrderValidator, - provider, - txDefaults, - exchange.address, - zrxAssetData, - ); - artifactsWriter.saveArtifact(orderValidator); - - // Authorize Exchange contracts to call AssetProxies - txHash = await erc20proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address); - logUtils.log(`transactionHash: ${txHash}`); - logUtils.log('Authorizing Exchange on ERC20Proxy'); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); - - txHash = await erc721proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address); - logUtils.log(`transactionHash: ${txHash}`); - logUtils.log('Authorizing Exchange on ERC721Proxy'); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); - - // Transfer ownership of AssetProxies and Exchange to AssetProxyOwner - txHash = await erc20proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address); - logUtils.log(`transactionHash: ${txHash}`); - logUtils.log('Transferring ownership of ERC20Proxy'); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); - - txHash = await erc721proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address); - logUtils.log(`transactionHash: ${txHash}`); - logUtils.log('Transferring ownership of ERC721Proxy'); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); - - txHash = await exchange.transferOwnership.sendTransactionAsync(assetProxyOwner.address); - logUtils.log(`transactionHash: ${txHash}`); - logUtils.log('Transferring ownership of Exchange'); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); -}; diff --git a/packages/migrations/src/2.0.0-testnet/artifacts.ts b/packages/migrations/src/2.0.0-testnet/artifacts.ts new file mode 100644 index 000000000..f1c6ecd88 --- /dev/null +++ b/packages/migrations/src/2.0.0-testnet/artifacts.ts @@ -0,0 +1,23 @@ +import { ContractArtifact } from 'ethereum-types'; + +import * as AssetProxyOwner from '../../artifacts/2.0.0-testnet/AssetProxyOwner.json'; +import * as DummyERC20Token from '../../artifacts/2.0.0-testnet/DummyERC20Token.json'; +import * as DummyERC721Token from '../../artifacts/2.0.0-testnet/DummyERC721Token.json'; +import * as ERC20Proxy from '../../artifacts/2.0.0-testnet/ERC20Proxy.json'; +import * as ERC721Proxy from '../../artifacts/2.0.0-testnet/ERC721Proxy.json'; +import * as Exchange from '../../artifacts/2.0.0-testnet/Exchange.json'; +import * as Forwarder from '../../artifacts/2.0.0-testnet/Forwarder.json'; +import * as OrderValidator from '../../artifacts/2.0.0-testnet/OrderValidator.json'; +import * as ZRXToken from '../../artifacts/2.0.0-testnet/ZRXToken.json'; + +export const artifacts = { + AssetProxyOwner: (AssetProxyOwner as any) as ContractArtifact, + Exchange: (Exchange as any) as ContractArtifact, + ERC20Proxy: (ERC20Proxy as any) as ContractArtifact, + ERC721Proxy: (ERC721Proxy as any) as ContractArtifact, + DummyERC721Token: (DummyERC721Token as any) as ContractArtifact, + DummyERC20Token: (DummyERC20Token as any) as ContractArtifact, + Forwarder: (Forwarder as any) as ContractArtifact, + OrderValidator: (OrderValidator as any) as ContractArtifact, + ZRX: (ZRXToken as any) as ContractArtifact, +}; diff --git a/packages/migrations/src/2.0.0-beta-testnet/migration.ts b/packages/migrations/src/2.0.0-testnet/migration.ts index 62a16ddae..62a16ddae 100644 --- a/packages/migrations/src/2.0.0-beta-testnet/migration.ts +++ b/packages/migrations/src/2.0.0-testnet/migration.ts diff --git a/packages/migrations/src/2.0.0/artifacts.ts b/packages/migrations/src/2.0.0/artifacts.ts index e96c555d6..65736c001 100644 --- a/packages/migrations/src/2.0.0/artifacts.ts +++ b/packages/migrations/src/2.0.0/artifacts.ts @@ -1,25 +1,17 @@ import { ContractArtifact } from 'ethereum-types'; import * as AssetProxyOwner from '../../artifacts/2.0.0/AssetProxyOwner.json'; -import * as DummyERC20Token from '../../artifacts/2.0.0/DummyERC20Token.json'; -import * as DummyERC721Token from '../../artifacts/2.0.0/DummyERC721Token.json'; import * as ERC20Proxy from '../../artifacts/2.0.0/ERC20Proxy.json'; import * as ERC721Proxy from '../../artifacts/2.0.0/ERC721Proxy.json'; import * as Exchange from '../../artifacts/2.0.0/Exchange.json'; import * as Forwarder from '../../artifacts/2.0.0/Forwarder.json'; import * as OrderValidator from '../../artifacts/2.0.0/OrderValidator.json'; -import * as WETH9 from '../../artifacts/2.0.0/WETH9.json'; -import * as ZRX from '../../artifacts/2.0.0/ZRXToken.json'; export const artifacts = { - ZRX: (ZRX as any) as ContractArtifact, - DummyERC20Token: (DummyERC20Token as any) as ContractArtifact, - DummyERC721Token: (DummyERC721Token as any) as ContractArtifact, AssetProxyOwner: (AssetProxyOwner as any) as ContractArtifact, - Exchange: (Exchange as any) as ContractArtifact, - WETH9: (WETH9 as any) as ContractArtifact, ERC20Proxy: (ERC20Proxy as any) as ContractArtifact, ERC721Proxy: (ERC721Proxy as any) as ContractArtifact, + Exchange: (Exchange as any) as ContractArtifact, Forwarder: (Forwarder as any) as ContractArtifact, OrderValidator: (OrderValidator as any) as ContractArtifact, }; diff --git a/packages/migrations/src/2.0.0-mainnet/constants.ts b/packages/migrations/src/2.0.0/constants.ts index 99649f687..99649f687 100644 --- a/packages/migrations/src/2.0.0-mainnet/constants.ts +++ b/packages/migrations/src/2.0.0/constants.ts diff --git a/packages/migrations/src/2.0.0/migration.ts b/packages/migrations/src/2.0.0/migration.ts index e1dcea8b0..4100a750c 100644 --- a/packages/migrations/src/2.0.0/migration.ts +++ b/packages/migrations/src/2.0.0/migration.ts @@ -1,37 +1,37 @@ import { assetDataUtils } from '@0xproject/order-utils'; -import { BigNumber } from '@0xproject/utils'; +import { logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Provider, TxData } from 'ethereum-types'; import { ArtifactWriter } from '../utils/artifact_writer'; -import { erc20TokenInfo, erc721TokenInfo } from '../utils/token_info'; import { artifacts } from './artifacts'; +import { constants } from './constants'; import { AssetProxyOwnerContract } from './contract_wrappers/asset_proxy_owner'; -import { DummyERC20TokenContract } from './contract_wrappers/dummy_erc20_token'; -import { DummyERC721TokenContract } from './contract_wrappers/dummy_erc721_token'; import { ERC20ProxyContract } from './contract_wrappers/erc20_proxy'; import { ERC721ProxyContract } from './contract_wrappers/erc721_proxy'; import { ExchangeContract } from './contract_wrappers/exchange'; import { ForwarderContract } from './contract_wrappers/forwarder'; import { OrderValidatorContract } from './contract_wrappers/order_validator'; -import { WETH9Contract } from './contract_wrappers/weth9'; -import { ZRXTokenContract } from './contract_wrappers/zrx_token'; /** - * Custom migrations should be defined in this function. This will be called with the CLI 'migrate:v2' command. + * Custom migrations should be defined in this function. This will be called with the CLI 'migrate:v2-mainnet' command. * Migrations could be written to run in parallel, but if you want contract addresses to be created deterministically, * the migration should be written to run synchronously. * @param provider Web3 provider instance. * @param artifactsDir The directory with compiler artifact files. * @param txDefaults Default transaction values to use when deploying contracts. */ -export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: string, txDefaults: Partial<TxData>) => { +export const runV2MainnetMigrationsAsync = async ( + provider: Provider, + artifactsDir: string, + txDefaults: Partial<TxData>, +) => { const web3Wrapper = new Web3Wrapper(provider); const networkId = await web3Wrapper.getNetworkIdAsync(); const artifactsWriter = new ArtifactWriter(artifactsDir, networkId); - // Proxies + // Deploy AssetProxies const erc20proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(artifacts.ERC20Proxy, provider, txDefaults); artifactsWriter.saveArtifact(erc20proxy); const erc721proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync( @@ -41,109 +41,49 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str ); artifactsWriter.saveArtifact(erc721proxy); - // ZRX - const zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, txDefaults); - artifactsWriter.saveArtifact(zrxToken); - - // Ether token - const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults); - artifactsWriter.saveArtifact(etherToken); - - // Exchange - const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); - const exchange = await ExchangeContract.deployFrom0xArtifactAsync( - artifacts.Exchange, - provider, - txDefaults, - zrxAssetData, - ); + // Deploy Exchange + const exchange = await ExchangeContract.deployFrom0xArtifactAsync(artifacts.Exchange, provider, txDefaults); artifactsWriter.saveArtifact(exchange); - // Multisigs - const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); - const owners = [accounts[0], accounts[1]]; - const confirmationsRequired = new BigNumber(2); - const secondsRequired = new BigNumber(0); - const owner = accounts[0]; + let txHash; + // Register AssetProxies in Exchange + txHash = await exchange.registerAssetProxy.sendTransactionAsync(erc20proxy.address); + logUtils.log(`transactionHash: ${txHash}`); + logUtils.log('Registering ERC20Proxy'); + await web3Wrapper.awaitTransactionSuccessAsync(txHash); + + txHash = await exchange.registerAssetProxy.sendTransactionAsync(erc721proxy.address); + logUtils.log(`transactionHash: ${txHash}`); + logUtils.log('Registering ERC721Proxy'); + await web3Wrapper.awaitTransactionSuccessAsync(txHash); - // AssetProxyOwner + // Deploy AssetProxyOwner + const assetProxies = [erc20proxy.address, erc721proxy.address]; const assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync( artifacts.AssetProxyOwner, provider, txDefaults, - owners, - [erc20proxy.address, erc721proxy.address], - confirmationsRequired, - secondsRequired, + constants.ASSET_PROXY_OWNER_OWNERS, + assetProxies, + constants.ASSET_PROXY_OWNER_REQUIRED_CONFIRMATIONS, + constants.ASSET_PROXY_OWNER_SECONDS_TIMELOCKED, ); artifactsWriter.saveArtifact(assetProxyOwner); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc20proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { - from: owner, - }), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc20proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { - from: owner, - }), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc721proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { - from: owner, - }), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await erc721proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { - from: owner, - }), - ); - - // Register the Asset Proxies to the Exchange - await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(erc20proxy.address), - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(erc721proxy.address), - ); - - // Dummy ERC20 tokens - for (const token of erc20TokenInfo) { - const totalSupply = new BigNumber(1000000000000000000000000000); - // tslint:disable-next-line:no-unused-variable - const dummyErc20Token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC20Token, - provider, - txDefaults, - token.name, - token.symbol, - token.decimals, - totalSupply, - ); - } - - // ERC721 - // tslint:disable-next-line:no-unused-variable - const cryptoKittieToken = await DummyERC721TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC721Token, - provider, - txDefaults, - erc721TokenInfo[0].name, - erc721TokenInfo[0].symbol, - ); - - // Forwarder + // Deploy Forwarder + const zrxAssetData = assetDataUtils.encodeERC20AssetData(constants.ZRX_ADDRESS); + const wethAssetData = assetDataUtils.encodeERC20AssetData(constants.WETH_ADDRESS); const forwarder = await ForwarderContract.deployFrom0xArtifactAsync( artifacts.Forwarder, provider, txDefaults, exchange.address, - assetDataUtils.encodeERC20AssetData(zrxToken.address), - assetDataUtils.encodeERC20AssetData(etherToken.address), + zrxAssetData, + wethAssetData, ); artifactsWriter.saveArtifact(forwarder); - // OrderValidator + // Deploy OrderValidator const orderValidator = await OrderValidatorContract.deployFrom0xArtifactAsync( artifacts.OrderValidator, provider, @@ -152,4 +92,31 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str zrxAssetData, ); artifactsWriter.saveArtifact(orderValidator); + + // Authorize Exchange contracts to call AssetProxies + txHash = await erc20proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address); + logUtils.log(`transactionHash: ${txHash}`); + logUtils.log('Authorizing Exchange on ERC20Proxy'); + await web3Wrapper.awaitTransactionSuccessAsync(txHash); + + txHash = await erc721proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address); + logUtils.log(`transactionHash: ${txHash}`); + logUtils.log('Authorizing Exchange on ERC721Proxy'); + await web3Wrapper.awaitTransactionSuccessAsync(txHash); + + // Transfer ownership of AssetProxies and Exchange to AssetProxyOwner + txHash = await erc20proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address); + logUtils.log(`transactionHash: ${txHash}`); + logUtils.log('Transferring ownership of ERC20Proxy'); + await web3Wrapper.awaitTransactionSuccessAsync(txHash); + + txHash = await erc721proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address); + logUtils.log(`transactionHash: ${txHash}`); + logUtils.log('Transferring ownership of ERC721Proxy'); + await web3Wrapper.awaitTransactionSuccessAsync(txHash); + + txHash = await exchange.transferOwnership.sendTransactionAsync(assetProxyOwner.address); + logUtils.log(`transactionHash: ${txHash}`); + logUtils.log('Transferring ownership of Exchange'); + await web3Wrapper.awaitTransactionSuccessAsync(txHash); }; diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 7d2caa0e8..368a5edb1 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -9,9 +9,9 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", - "pre_build": "run-s update_artifacts_v2_beta generate_contract_wrappers", + "pre_build": "run-s update_artifacts generate_contract_wrappers", "generate_contract_wrappers": "abi-gen --abis 'lib/src/artifacts/@(Exchange|IWallet|IValidator|DummyERC20Token|ERC20Proxy|ERC20Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers", - "update_artifacts_v2_beta": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json lib/src/artifacts; done;", + "update_artifacts": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json lib/src/artifacts; done;", "test": "yarn run_mocha", "rebuild_and_test": "run-s build test", "test:circleci": "yarn test:coverage", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index 27eeca6fd..95fec2464 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -22,7 +22,7 @@ "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts", - "update_artifacts": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json src/artifacts; done;", + "update_artifacts": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;", "clean": "shx rm -rf _bundles lib test_temp test/artifacts src/generated_contract_wrappers generated_docs", "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES" |