aboutsummaryrefslogtreecommitdiffstats
path: root/packages/migrations/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/migrations/src')
-rw-r--r--packages/migrations/src/1.0.0/artifacts.ts21
-rw-r--r--packages/migrations/src/1.0.0/migration.ts142
-rw-r--r--packages/migrations/src/2.0.0/artifacts.ts25
-rw-r--r--packages/migrations/src/2.0.0/migration.ts150
-rw-r--r--packages/migrations/src/globals.d.ts6
-rw-r--r--packages/migrations/src/index.ts3
-rw-r--r--packages/migrations/src/migrate.ts43
-rw-r--r--packages/migrations/src/migration.ts175
-rw-r--r--packages/migrations/src/types.ts2
-rw-r--r--packages/migrations/src/utils/artifact_writer.ts26
-rw-r--r--packages/migrations/src/utils/constants.ts2
-rw-r--r--packages/migrations/src/utils/provider_factory.ts2
-rw-r--r--packages/migrations/src/utils/token_info.ts2
13 files changed, 190 insertions, 409 deletions
diff --git a/packages/migrations/src/1.0.0/artifacts.ts b/packages/migrations/src/1.0.0/artifacts.ts
deleted file mode 100644
index f5226e174..000000000
--- a/packages/migrations/src/1.0.0/artifacts.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { ContractArtifact } from 'ethereum-types';
-
-import * as DummyERC20Token from '../../artifacts/1.0.0/DummyERC20Token.json';
-import * as Exchange from '../../artifacts/1.0.0/Exchange_v1.json';
-import * as MultiSigWalletWithTimeLock from '../../artifacts/1.0.0/MultiSigWalletWithTimeLock.json';
-import * as MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress from '../../artifacts/1.0.0/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json';
-import * as TokenRegistry from '../../artifacts/1.0.0/TokenRegistry.json';
-import * as TokenTransferProxy from '../../artifacts/1.0.0/TokenTransferProxy_v1.json';
-import * as EtherToken from '../../artifacts/1.0.0/WETH9.json';
-import * as ZRX from '../../artifacts/1.0.0/ZRXToken.json';
-
-export const artifacts = {
- ZRX: (ZRX as any) as ContractArtifact,
- DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
- Exchange: (Exchange as any) as ContractArtifact,
- EtherToken: (EtherToken as any) as ContractArtifact,
- TokenRegistry: (TokenRegistry as any) as ContractArtifact,
- TokenTransferProxy: (TokenTransferProxy as any) as ContractArtifact,
- MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact,
- MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress: (MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress as any) as ContractArtifact,
-};
diff --git a/packages/migrations/src/1.0.0/migration.ts b/packages/migrations/src/1.0.0/migration.ts
deleted file mode 100644
index 0a3c25ae1..000000000
--- a/packages/migrations/src/1.0.0/migration.ts
+++ /dev/null
@@ -1,142 +0,0 @@
-import { BigNumber, NULL_BYTES } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import { Provider, TxData } from 'ethereum-types';
-
-import { ArtifactWriter } from '../utils/artifact_writer';
-import { erc20TokenInfo } from '../utils/token_info';
-
-import { artifacts } from './artifacts';
-import { DummyERC20TokenContract } from './contract_wrappers/dummy_erc20_token';
-import { Exchange_v1Contract } from './contract_wrappers/exchange_v1';
-import { MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract } from './contract_wrappers/multi_sig_wallet_with_time_lock_except_remove_authorized_address';
-import { TokenRegistryContract } from './contract_wrappers/token_registry';
-import { TokenTransferProxy_v1Contract } from './contract_wrappers/tokentransferproxy_v1';
-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:v1' 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 runV1MigrationsAsync = async (provider: Provider, artifactsDir: string, txDefaults: Partial<TxData>) => {
- const web3Wrapper = new Web3Wrapper(provider);
- const networkId = await web3Wrapper.getNetworkIdAsync();
- const artifactsWriter = new ArtifactWriter(artifactsDir, networkId);
- const tokenTransferProxy = await TokenTransferProxy_v1Contract.deployFrom0xArtifactAsync(
- artifacts.TokenTransferProxy,
- provider,
- txDefaults,
- );
- artifactsWriter.saveArtifact(tokenTransferProxy);
- const zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, txDefaults);
- artifactsWriter.saveArtifact(zrxToken);
-
- const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, txDefaults);
- artifactsWriter.saveArtifact(etherToken);
- const tokenReg = await TokenRegistryContract.deployFrom0xArtifactAsync(
- artifacts.TokenRegistry,
- provider,
- txDefaults,
- );
- artifactsWriter.saveArtifact(tokenReg);
-
- const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync();
- const owners = [accounts[0], accounts[1]];
- const confirmationsRequired = new BigNumber(2);
- const secondsRequired = new BigNumber(0);
- const exchange = await Exchange_v1Contract.deployFrom0xArtifactAsync(
- artifacts.Exchange,
- provider,
- txDefaults,
- zrxToken.address,
- tokenTransferProxy.address,
- );
- artifactsWriter.saveArtifact(exchange);
- const multiSig = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract.deployFrom0xArtifactAsync(
- artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,
- provider,
- txDefaults,
- owners,
- confirmationsRequired,
- secondsRequired,
- tokenTransferProxy.address,
- );
- artifactsWriter.saveArtifact(multiSig);
-
- const owner = accounts[0];
-
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }),
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: owner }),
- );
- const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync(
- zrxToken.address,
- erc20TokenInfo[0].name,
- erc20TokenInfo[0].symbol,
- erc20TokenInfo[0].decimals,
- erc20TokenInfo[0].ipfsHash,
- erc20TokenInfo[0].swarmHash,
- { from: owner },
- );
- const decimals = 18;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenReg.addToken.sendTransactionAsync(
- zrxToken.address,
- '0x Protocol Token',
- 'ZRX',
- decimals,
- NULL_BYTES,
- NULL_BYTES,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- ),
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenReg.addToken.sendTransactionAsync(
- etherToken.address,
- 'Ether Token',
- 'WETH',
- decimals,
- NULL_BYTES,
- NULL_BYTES,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- ),
- );
- for (const token of erc20TokenInfo) {
- const totalSupply = new BigNumber(100000000000000000000);
- const dummyToken = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC20Token,
- provider,
- txDefaults,
- token.name,
- token.symbol,
- token.decimals,
- totalSupply,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenReg.addToken.sendTransactionAsync(
- dummyToken.address,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- ),
- );
- }
-};
diff --git a/packages/migrations/src/2.0.0/artifacts.ts b/packages/migrations/src/2.0.0/artifacts.ts
deleted file mode 100644
index e96c555d6..000000000
--- a/packages/migrations/src/2.0.0/artifacts.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-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,
- Forwarder: (Forwarder as any) as ContractArtifact,
- OrderValidator: (OrderValidator as any) as ContractArtifact,
-};
diff --git a/packages/migrations/src/2.0.0/migration.ts b/packages/migrations/src/2.0.0/migration.ts
deleted file mode 100644
index 1c30fb9ec..000000000
--- a/packages/migrations/src/2.0.0/migration.ts
+++ /dev/null
@@ -1,150 +0,0 @@
-import { assetDataUtils } from '@0xproject/order-utils';
-import { BigNumber } 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 { 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.
- * 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>) => {
- const web3Wrapper = new Web3Wrapper(provider);
- const networkId = await web3Wrapper.getNetworkIdAsync();
- const artifactsWriter = new ArtifactWriter(artifactsDir, networkId);
-
- // Proxies
- const erc20proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(artifacts.ERC20Proxy, provider, txDefaults);
- artifactsWriter.saveArtifact(erc20proxy);
- const erc721proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync(
- artifacts.ERC721Proxy,
- provider,
- txDefaults,
- );
- 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);
- 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];
-
- // AssetProxyOwner
- const assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync(
- artifacts.AssetProxyOwner,
- provider,
- txDefaults,
- owners,
- [erc20proxy.address, erc721proxy.address],
- confirmationsRequired,
- secondsRequired,
- );
- 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
- const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
- artifacts.Forwarder,
- provider,
- txDefaults,
- exchange.address,
- assetDataUtils.encodeERC20AssetData(zrxToken.address),
- assetDataUtils.encodeERC20AssetData(etherToken.address),
- );
- artifactsWriter.saveArtifact(forwarder);
-
- // OrderValidator
- const orderValidator = await OrderValidatorContract.deployFrom0xArtifactAsync(
- artifacts.OrderValidator,
- provider,
- txDefaults,
- exchange.address,
- zrxAssetData,
- );
- artifactsWriter.saveArtifact(orderValidator);
-};
diff --git a/packages/migrations/src/globals.d.ts b/packages/migrations/src/globals.d.ts
deleted file mode 100644
index 94e63a32d..000000000
--- a/packages/migrations/src/globals.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/migrations/src/index.ts b/packages/migrations/src/index.ts
index 5354b3501..8f629a24b 100644
--- a/packages/migrations/src/index.ts
+++ b/packages/migrations/src/index.ts
@@ -1,2 +1 @@
-export { runV1MigrationsAsync } from './1.0.0/migration';
-export { runV2MigrationsAsync } from './2.0.0/migration';
+export { runMigrationsAsync, runMigrationsOnceAsync } from './migration';
diff --git a/packages/migrations/src/migrate.ts b/packages/migrations/src/migrate.ts
index 338832feb..d7a76d2f8 100644
--- a/packages/migrations/src/migrate.ts
+++ b/packages/migrations/src/migrate.ts
@@ -1,44 +1,21 @@
#!/usr/bin/env node
-import { devConstants, web3Factory } from '@0xproject/dev-utils';
-import { logUtils } from '@0xproject/utils';
+import { devConstants, web3Factory } from '@0x/dev-utils';
+import { logUtils } from '@0x/utils';
import { Provider } from 'ethereum-types';
-import * as yargs from 'yargs';
-import { runV1MigrationsAsync } from './1.0.0/migration';
-import { runV2MigrationsAsync } from './2.0.0/migration';
-
-enum ContractVersions {
- V1 = '1.0.0',
- V2 = '2.0.0',
-}
-const args = yargs.argv;
+import { runMigrationsAsync } from './migration';
(async () => {
- const contractsVersion = args.contractsVersion;
- const artifactsDir = `artifacts/${contractsVersion}`;
let providerConfigs;
let provider: Provider;
let txDefaults;
- switch (contractsVersion) {
- case ContractVersions.V1:
- providerConfigs = { shouldUseInProcessGanache: false };
- provider = web3Factory.getRpcProvider(providerConfigs);
- txDefaults = {
- from: devConstants.TESTRPC_FIRST_ADDRESS,
- };
- await runV1MigrationsAsync(provider, artifactsDir, txDefaults);
- break;
- case ContractVersions.V2:
- providerConfigs = { shouldUseInProcessGanache: false };
- provider = web3Factory.getRpcProvider(providerConfigs);
- txDefaults = {
- from: devConstants.TESTRPC_FIRST_ADDRESS,
- };
- await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
- break;
- default:
- throw new Error(`Unsupported contract version: ${contractsVersion}`);
- }
+
+ providerConfigs = { shouldUseInProcessGanache: false };
+ provider = web3Factory.getRpcProvider(providerConfigs);
+ txDefaults = {
+ from: devConstants.TESTRPC_FIRST_ADDRESS,
+ };
+ await runMigrationsAsync(provider, txDefaults);
process.exit(0);
})().catch(err => {
logUtils.log(err);
diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts
new file mode 100644
index 000000000..86c76a54b
--- /dev/null
+++ b/packages/migrations/src/migration.ts
@@ -0,0 +1,175 @@
+import * as wrappers from '@0x/abi-gen-wrappers';
+import { ContractAddresses } from '@0x/contract-addresses';
+import * as artifacts from '@0x/contract-artifacts';
+import { assetDataUtils } from '@0x/order-utils';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
+import { Provider, TxData } from 'ethereum-types';
+import * as _ from 'lodash';
+
+import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info';
+
+/**
+ * Creates and deploys all the contracts that are required for the latest
+ * version of the 0x protocol. Custom migrations can be defined here. This will
+ * be called with the CLI 'migrate:v2' command.
+ * @param provider Web3 provider instance.
+ * @param txDefaults Default transaction values to use when deploying contracts.
+ * @returns The addresses of the contracts that were deployed.
+ */
+export async function runMigrationsAsync(provider: Provider, txDefaults: Partial<TxData>): Promise<ContractAddresses> {
+ const web3Wrapper = new Web3Wrapper(provider);
+
+ // Proxies
+ const erc20Proxy = await wrappers.ERC20ProxyContract.deployFrom0xArtifactAsync(
+ artifacts.ERC20Proxy,
+ provider,
+ txDefaults,
+ );
+ const erc721Proxy = await wrappers.ERC721ProxyContract.deployFrom0xArtifactAsync(
+ artifacts.ERC721Proxy,
+ provider,
+ txDefaults,
+ );
+
+ // ZRX
+ const zrxToken = await wrappers.ZRXTokenContract.deployFrom0xArtifactAsync(
+ artifacts.ZRXToken,
+ provider,
+ txDefaults,
+ );
+
+ // Ether token
+ const etherToken = await wrappers.WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults);
+
+ // Exchange
+ const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
+ const exchange = await wrappers.ExchangeContract.deployFrom0xArtifactAsync(
+ artifacts.Exchange,
+ provider,
+ txDefaults,
+ );
+
+ // 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];
+
+ // AssetProxyOwner
+ const assetProxyOwner = await wrappers.AssetProxyOwnerContract.deployFrom0xArtifactAsync(
+ artifacts.AssetProxyOwner,
+ provider,
+ txDefaults,
+ owners,
+ [erc20Proxy.address, erc721Proxy.address],
+ confirmationsRequired,
+ secondsRequired,
+ );
+
+ 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 wrappers.DummyERC20TokenContract.deployFrom0xArtifactAsync(
+ artifacts.DummyERC20Token,
+ provider,
+ txDefaults,
+ token.name,
+ token.symbol,
+ token.decimals,
+ totalSupply,
+ );
+ }
+
+ // ERC721
+ // tslint:disable-next-line:no-unused-variable
+ const cryptoKittieToken = await wrappers.DummyERC721TokenContract.deployFrom0xArtifactAsync(
+ artifacts.DummyERC721Token,
+ provider,
+ txDefaults,
+ erc721TokenInfo[0].name,
+ erc721TokenInfo[0].symbol,
+ );
+
+ // Forwarder
+ const forwarder = await wrappers.ForwarderContract.deployFrom0xArtifactAsync(
+ artifacts.Forwarder,
+ provider,
+ txDefaults,
+ exchange.address,
+ assetDataUtils.encodeERC20AssetData(zrxToken.address),
+ assetDataUtils.encodeERC20AssetData(etherToken.address),
+ );
+
+ // OrderValidator
+ const orderValidator = await wrappers.OrderValidatorContract.deployFrom0xArtifactAsync(
+ artifacts.OrderValidator,
+ provider,
+ txDefaults,
+ exchange.address,
+ zrxAssetData,
+ );
+
+ return {
+ erc20Proxy: erc20Proxy.address,
+ erc721Proxy: erc721Proxy.address,
+ zrxToken: zrxToken.address,
+ etherToken: etherToken.address,
+ exchange: exchange.address,
+ assetProxyOwner: assetProxyOwner.address,
+ forwarder: forwarder.address,
+ orderValidator: orderValidator.address,
+ };
+}
+
+let _cachedContractAddresses: ContractAddresses;
+
+/**
+ * Exactly like runMigrationsAsync but will only run the migrations the first
+ * time it is called. Any subsequent calls will return the cached contract
+ * addresses.
+ * @param provider Web3 provider instance.
+ * @param txDefaults Default transaction values to use when deploying contracts.
+ * @returns The addresses of the contracts that were deployed.
+ */
+export async function runMigrationsOnceAsync(
+ provider: Provider,
+ txDefaults: Partial<TxData>,
+): Promise<ContractAddresses> {
+ if (!_.isUndefined(_cachedContractAddresses)) {
+ return _cachedContractAddresses;
+ }
+ _cachedContractAddresses = await runMigrationsAsync(provider, txDefaults);
+ return _cachedContractAddresses;
+}
diff --git a/packages/migrations/src/types.ts b/packages/migrations/src/types.ts
index 65f685797..87e66f356 100644
--- a/packages/migrations/src/types.ts
+++ b/packages/migrations/src/types.ts
@@ -1,4 +1,4 @@
-import { BigNumber } from '@0xproject/utils';
+import { BigNumber } from '@0x/utils';
export interface ERC20Token {
address?: string;
diff --git a/packages/migrations/src/utils/artifact_writer.ts b/packages/migrations/src/utils/artifact_writer.ts
deleted file mode 100644
index ea9c7952d..000000000
--- a/packages/migrations/src/utils/artifact_writer.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { BaseContract } from '@0xproject/base-contract';
-import { ContractArtifact } from 'ethereum-types';
-import * as fs from 'fs';
-import * as path from 'path';
-
-export class ArtifactWriter {
- private readonly _artifactsDir: string;
- private readonly _networkId: number;
- constructor(artifactsDir: string, networkId: number) {
- this._artifactsDir = artifactsDir;
- this._networkId = networkId;
- }
- // This updates the artifact file but does not update the `artifacts` module above. It will not
- // contain the saved artifact changes.
- public saveArtifact(contract: BaseContract): void {
- const contractName = contract.contractName;
- const artifactFile = path.join(this._artifactsDir, `${contractName}.json`);
- const artifact: ContractArtifact = JSON.parse(fs.readFileSync(artifactFile).toString());
- artifact.networks[this._networkId] = {
- address: contract.address,
- links: {},
- constructorArgs: JSON.stringify(contract.constructorArgs),
- };
- fs.writeFileSync(artifactFile, JSON.stringify(artifact, null, '\t'));
- }
-}
diff --git a/packages/migrations/src/utils/constants.ts b/packages/migrations/src/utils/constants.ts
index 63898ac02..8b16a0520 100644
--- a/packages/migrations/src/utils/constants.ts
+++ b/packages/migrations/src/utils/constants.ts
@@ -1,4 +1,4 @@
-import { BigNumber } from '@0xproject/utils';
+import { BigNumber } from '@0x/utils';
export const constants = {
ASSET_PROXY_OWNER_OWNERS: [
diff --git a/packages/migrations/src/utils/provider_factory.ts b/packages/migrations/src/utils/provider_factory.ts
index e7e00a039..8017b672a 100644
--- a/packages/migrations/src/utils/provider_factory.ts
+++ b/packages/migrations/src/utils/provider_factory.ts
@@ -1,4 +1,4 @@
-import { LedgerEthereumClient, LedgerSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';
+import { LedgerEthereumClient, LedgerSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import Eth from '@ledgerhq/hw-app-eth';
// tslint:disable:no-implicit-dependencies
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
diff --git a/packages/migrations/src/utils/token_info.ts b/packages/migrations/src/utils/token_info.ts
index 200f94896..6e0411f60 100644
--- a/packages/migrations/src/utils/token_info.ts
+++ b/packages/migrations/src/utils/token_info.ts
@@ -1,4 +1,4 @@
-import { BigNumber, NULL_BYTES } from '@0xproject/utils';
+import { BigNumber, NULL_BYTES } from '@0x/utils';
import { ERC20Token, ERC721Token } from '../types';