From 2c73bbd689e40eb97fb3ff8e40b7904c39f4ab30 Mon Sep 17 00:00:00 2001 From: Michael Zhu Date: Tue, 4 Aug 2020 11:30:43 -0700 Subject: [PATCH] appease CI --- .../test/swap_quote_consumer_utils_test.ts | 1 + packages/migrations/src/migration.ts | 93 ++++++++++++++----- 2 files changed, 72 insertions(+), 22 deletions(-) diff --git a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts index 3fe2fe4919..a4022a5407 100644 --- a/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts +++ b/packages/asset-swapper/test/swap_quote_consumer_utils_test.ts @@ -121,6 +121,7 @@ describe('swapQuoteConsumerUtils', () => { swapQuoteConsumer = new SwapQuoteConsumer(provider, { chainId, + contractAddresses, }); }); after(async () => { diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index 7f8f972e88..67af1f6f78 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -15,9 +15,9 @@ import { } from '@0x/contracts-coordinator'; import { artifacts as devUtilsArtifacts, DevUtilsContract } from '@0x/contracts-dev-utils'; import { artifacts as erc1155Artifacts } from '@0x/contracts-erc1155'; -import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; +import { artifacts as erc20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20'; import { artifacts as erc20BridgeSamplerArtifacts } from '@0x/contracts-erc20-bridge-sampler'; -import { artifacts as erc721Artifacts } from '@0x/contracts-erc721'; +import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721'; import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange'; import { artifacts as forwarderArtifacts, ForwarderContract } from '@0x/contracts-exchange-forwarder'; import { @@ -42,6 +42,7 @@ import { BigNumber, providerUtils } from '@0x/utils'; import { SupportedProvider, TxData } from 'ethereum-types'; import { constants } from './utils/constants'; +import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info'; const allArtifacts = { ...assetProxyArtifacts, @@ -119,7 +120,28 @@ export async function runMigrationsAsync( ): Promise { const provider = providerUtils.standardizeOrThrow(supportedProvider); const chainId = new BigNumber(await providerUtils.getChainIdAsync(provider)); - const { exchangeV2, etherToken, zrxToken } = getContractAddressesForChainOrThrow(chainId.toNumber()); + const { exchangeV2 } = getContractAddressesForChainOrThrow(chainId.toNumber()); + + const zrxToken = await DummyERC20TokenContract.deployFrom0xArtifactAsync( + erc20Artifacts.DummyERC20Token, + provider, + txDefaults, + allArtifacts, + '0x Protocol Token', + 'ZRX', + new BigNumber(18), + new BigNumber(1000000000000000000000000000), + ); + + // Ether token + const etherToken = await WETH9Contract.deployFrom0xArtifactAsync( + erc20Artifacts.WETH9, + provider, + txDefaults, + allArtifacts, + ); + + await _migrateDummyTokensAsync(provider, txDefaults); // Exchange const exchange = await ExchangeContract.deployFrom0xArtifactAsync( @@ -130,18 +152,6 @@ export async function runMigrationsAsync( chainId, ); - // Dev Utils - const devUtils = await DevUtilsContract.deployWithLibrariesFrom0xArtifactAsync( - devUtilsArtifacts.DevUtils, - devUtilsArtifacts, - provider, - txDefaults, - allArtifacts, - exchange.address, - NULL_ADDRESS, - NULL_ADDRESS, - ); - // CoordinatorRegistry const coordinatorRegistry = await CoordinatorRegistryContract.deployFrom0xArtifactAsync( coordinatorArtifacts.CoordinatorRegistry, @@ -169,11 +179,23 @@ export async function runMigrationsAsync( erc20BridgeProxy, ] = await _migrateAssetProxiesAsync(exchange, provider, txDefaults); + // Dev Utils + const devUtils = await DevUtilsContract.deployWithLibrariesFrom0xArtifactAsync( + devUtilsArtifacts.DevUtils, + devUtilsArtifacts, + provider, + txDefaults, + allArtifacts, + exchange.address, + NULL_ADDRESS, + NULL_ADDRESS, + ); + const [zrxVault, stakingLogic, stakingProxy] = await _migrateStakingAsync( exchange, erc20Proxy, - zrxToken, - etherToken, + zrxToken.address, + etherToken.address, provider, txDefaults, ); @@ -188,7 +210,7 @@ export async function runMigrationsAsync( allArtifacts, exchange.address, exchangeV2, - etherToken, + etherToken.address, ); const [ @@ -199,15 +221,15 @@ export async function runMigrationsAsync( affiliateFeeTransformer, exchangeProxyFlashWalletAddress, exchangeProxyAllowanceTargetAddress, - ] = await _migrateExchangeProxyAsync(exchange, etherToken, provider, txDefaults); + ] = await _migrateExchangeProxyAsync(exchange, etherToken.address, provider, txDefaults); const contractAddresses = { ...NULL_ADDRESSES, erc20Proxy: erc20Proxy.address, erc721Proxy: erc721Proxy.address, erc1155Proxy: erc1155Proxy.address, - zrxToken, - etherToken, + zrxToken: zrxToken.address, + etherToken: etherToken.address, exchange: exchange.address, erc20BridgeProxy: erc20BridgeProxy.address, forwarder: forwarder.address, @@ -216,7 +238,6 @@ export async function runMigrationsAsync( multiAssetProxy: multiAssetProxy.address, staticCallProxy: staticCallProxy.address, devUtils: devUtils.address, - exchangeV2: exchangeV2, zrxVault: zrxVault.address, staking: stakingLogic.address, stakingProxy: stakingProxy.address, @@ -439,6 +460,33 @@ async function _migrateExchangeProxyAsync( ]; } +async function _migrateDummyTokensAsync(provider: ZeroExProvider, txDefaults: TxData): Promise { + // Dummy ERC20 tokens + for (const token of erc20TokenInfo) { + const totalSupply = new BigNumber(1000000000000000000000000000); + await DummyERC20TokenContract.deployFrom0xArtifactAsync( + erc20Artifacts.DummyERC20Token, + provider, + txDefaults, + allArtifacts, + token.name, + token.symbol, + token.decimals, + totalSupply, + ); + } + + // Dummy ERC721 token + await DummyERC721TokenContract.deployFrom0xArtifactAsync( + erc721Artifacts.DummyERC721Token, + provider, + txDefaults, + allArtifacts, + erc721TokenInfo[0].name, + erc721TokenInfo[0].symbol, + ); +} + let _cachedContractAddresses: ContractAddresses; /** @@ -459,3 +507,4 @@ export async function runMigrationsOnceAsync( _cachedContractAddresses = await runMigrationsAsync(provider, txDefaults); return _cachedContractAddresses; } +// tslint:disable-next-line: max-file-line-count