From ebbb4df227d5e290b4bd392322405440dded6e4c Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 21 Jan 2019 15:16:16 +1100 Subject: [PATCH 1/4] Remove owner from migrations --- packages/migrations/src/migration.ts | 50 ++++++++++------------------ 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index e0f2450173..f33d6337aa 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -18,8 +18,9 @@ import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info'; */ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial): Promise { const web3Wrapper = new Web3Wrapper(provider); - const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); - const owner = accounts[0]; + if (_.isUndefined(txDefaults.from)) { + throw new Error('from address must be specified'); + } // Proxies const erc20Proxy = await wrappers.ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -84,48 +85,38 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { - from: owner, - }), + await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { - from: owner, - }), + await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { - from: owner, - }), + await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, txDefaults), ); // MultiAssetProxy await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, { - from: owner, - }), + await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, { - from: owner, - }), + await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc20Proxy.address), + await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc721Proxy.address), + await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc721Proxy.address, txDefaults), ); // Register the Asset Proxies to the Exchange await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(erc20Proxy.address), + await exchange.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(erc721Proxy.address), + await exchange.registerAssetProxy.sendTransactionAsync(erc721Proxy.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await exchange.registerAssetProxy.sendTransactionAsync(multiAssetProxy.address), + await exchange.registerAssetProxy.sendTransactionAsync(multiAssetProxy.address, txDefaults), ); // Forwarder @@ -156,7 +147,8 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial ); // Multisigs - const owners = [accounts[0], accounts[1]]; + const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); + const owners = _.uniq([accounts[0], accounts[1], txDefaults.from]); const confirmationsRequired = new BigNumber(2); const secondsRequired = new BigNumber(0); @@ -173,19 +165,13 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial // Transfer Ownership to the Asset Proxy Owner await web3Wrapper.awaitTransactionSuccessAsync( - await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { - from: owner, - }), + await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { - from: owner, - }), + await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), ); await web3Wrapper.awaitTransactionSuccessAsync( - await multiAssetProxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, { - from: owner, - }), + await multiAssetProxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, txDefaults), ); // Fund the Forwarder with ZRX From bee48d1d4304738afd67c829490f2b90b6ce8677 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 21 Jan 2019 15:52:39 +1100 Subject: [PATCH 2/4] Remove partial type for TxData txDefaults --- packages/migrations/CHANGELOG.json | 4 ++++ packages/migrations/src/migration.ts | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 64ae94b14c..7938f137f8 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -5,6 +5,10 @@ { "note": "Upgrade the bignumber.js to v8.0.2", "pr": 1517 + }, + { + "note": "Removed `owner` in Migrations. `txDefaults` is now a non-Partial type", + "pr": 1533 } ] }, diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index f33d6337aa..7668ec9238 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -16,11 +16,8 @@ import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info'; * @param txDefaults Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter). * @returns The addresses of the contracts that were deployed. */ -export async function runMigrationsAsync(provider: Provider, txDefaults: Partial): Promise { +export async function runMigrationsAsync(provider: Provider, txDefaults: TxData): Promise { const web3Wrapper = new Web3Wrapper(provider); - if (_.isUndefined(txDefaults.from)) { - throw new Error('from address must be specified'); - } // Proxies const erc20Proxy = await wrappers.ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -206,10 +203,7 @@ let _cachedContractAddresses: ContractAddresses; * @param txDefaults Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter). * @returns The addresses of the contracts that were deployed. */ -export async function runMigrationsOnceAsync( - provider: Provider, - txDefaults: Partial, -): Promise { +export async function runMigrationsOnceAsync(provider: Provider, txDefaults: TxData): Promise { if (!_.isUndefined(_cachedContractAddresses)) { return _cachedContractAddresses; } From 98203bcc8ccc771e925d041f58025c37f1da1305 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 21 Jan 2019 16:02:20 +1100 Subject: [PATCH 3/4] Convert from to lower case. fixes #1490 --- packages/migrations/CHANGELOG.json | 4 ++++ packages/migrations/src/cli.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 7938f137f8..6637746dea 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -9,6 +9,10 @@ { "note": "Removed `owner` in Migrations. `txDefaults` is now a non-Partial type", "pr": 1533 + }, + { + "note": "Convert `from` to lower case", + "pr": 1533 } ] }, diff --git a/packages/migrations/src/cli.ts b/packages/migrations/src/cli.ts index 2404e79217..4e8ce982fa 100644 --- a/packages/migrations/src/cli.ts +++ b/packages/migrations/src/cli.ts @@ -27,8 +27,9 @@ const args = yargs const provider = new Web3ProviderEngine(); provider.addProvider(rpcSubprovider); provider.start(); + const normalizedFromAddress = (args.from as string).toLowerCase(); const txDefaults = { - from: args.from, + from: normalizedFromAddress, }; await runMigrationsAsync(provider, txDefaults); process.exit(0); From 6f090a2fdada03eab95ca7cc800c4ca6d851e6ee Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Wed, 23 Jan 2019 11:11:32 +1100 Subject: [PATCH 4/4] Improve CHANGELOG --- packages/migrations/CHANGELOG.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 6637746dea..ffda41e103 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -7,11 +7,15 @@ "pr": 1517 }, { - "note": "Removed `owner` in Migrations. `txDefaults` is now a non-Partial type", + "note": "Removed `owner` in Migrations", "pr": 1533 }, { - "note": "Convert `from` to lower case", + "note": "`txDefaults` parameter now requires the `from` field", + "pr": 1533 + }, + { + "note": "Convert `from` to lower case when passed in via cli", "pr": 1533 } ]