diff options
-rw-r--r-- | packages/migrations/CHANGELOG.json | 12 | ||||
-rw-r--r-- | packages/migrations/src/cli.ts | 3 | ||||
-rw-r--r-- | packages/migrations/src/migration.ts | 54 |
3 files changed, 31 insertions, 38 deletions
diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 64ae94b14..ffda41e10 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -5,6 +5,18 @@ { "note": "Upgrade the bignumber.js to v8.0.2", "pr": 1517 + }, + { + "note": "Removed `owner` in Migrations", + "pr": 1533 + }, + { + "note": "`txDefaults` parameter now requires the `from` field", + "pr": 1533 + }, + { + "note": "Convert `from` to lower case when passed in via cli", + "pr": 1533 } ] }, diff --git a/packages/migrations/src/cli.ts b/packages/migrations/src/cli.ts index 2404e7921..4e8ce982f 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); diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index e0f245017..7668ec923 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -16,10 +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<TxData>): Promise<ContractAddresses> { +export async function runMigrationsAsync(provider: Provider, txDefaults: TxData): Promise<ContractAddresses> { const web3Wrapper = new Web3Wrapper(provider); - const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); - const owner = accounts[0]; // Proxies const erc20Proxy = await wrappers.ERC20ProxyContract.deployFrom0xArtifactAsync( @@ -84,48 +82,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 +144,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 +162,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 @@ -220,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<TxData>, -): Promise<ContractAddresses> { +export async function runMigrationsOnceAsync(provider: Provider, txDefaults: TxData): Promise<ContractAddresses> { if (!_.isUndefined(_cachedContractAddresses)) { return _cachedContractAddresses; } |