diff options
Diffstat (limited to 'packages/migrations/src')
-rw-r--r-- | packages/migrations/src/2.0.0-beta-testnet/artifacts.ts | 15 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-beta-testnet/migration.ts | 115 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0/migration.ts | 7 | ||||
-rw-r--r-- | packages/migrations/src/index.ts | 1 | ||||
-rw-r--r-- | packages/migrations/src/migrate.ts | 15 | ||||
-rw-r--r-- | packages/migrations/src/utils/constants.ts | 2 | ||||
-rw-r--r-- | packages/migrations/src/utils/provider_factory.ts | 14 | ||||
-rw-r--r-- | packages/migrations/src/utils/token_info.ts | 18 |
8 files changed, 32 insertions, 155 deletions
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 a9c7235c1..000000000 --- a/packages/migrations/src/2.0.0-beta-testnet/artifacts.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ContractArtifact } from 'ethereum-types'; - -import * as AssetProxyOwner from '../../artifacts/2.0.0-beta-testnet/AssetProxyOwner.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 OrderValidator from '../../artifacts/2.0.0-beta-testnet/OrderValidator.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, - OrderValidator: (OrderValidator as any) as ContractArtifact, -}; diff --git a/packages/migrations/src/2.0.0-beta-testnet/migration.ts b/packages/migrations/src/2.0.0-beta-testnet/migration.ts deleted file mode 100644 index cc9f5a859..000000000 --- a/packages/migrations/src/2.0.0-beta-testnet/migration.ts +++ /dev/null @@ -1,115 +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 { constants } from '../utils/constants'; - -import { artifacts } from './artifacts'; -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 { OrderValidatorContract } from './contract_wrappers/order_validator'; - -/** - * Custom migrations should be defined in this function. This will be called with the CLI 'migrate:v2-beta-testnet' 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 runV2TestnetMigrationsAsync = 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 zrxAddressOnKovan = '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570'; - const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxAddressOnKovan); - const exchange = await ExchangeContract.deployFrom0xArtifactAsync( - artifacts.Exchange, - provider, - txDefaults, - zrxAssetData, - ); - 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 assetProxyOwner = await AssetProxyOwnerContract.deployFrom0xArtifactAsync( - artifacts.AssetProxyOwner, - provider, - txDefaults, - constants.ASSET_PROXY_OWNER_OWNERS, - [erc20proxy.address, erc721proxy.address], - constants.ASSET_PROXY_OWNER_CONFIRMATIONS, - constants.ASSET_PROXY_OWNER_TIMELOCK, - ); - artifactsWriter.saveArtifact(assetProxyOwner); - - // 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/migration.ts b/packages/migrations/src/2.0.0/migration.ts index e1dcea8b0..1c30fb9ec 100644 --- a/packages/migrations/src/2.0.0/migration.ts +++ b/packages/migrations/src/2.0.0/migration.ts @@ -51,12 +51,7 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str // Exchange const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); - const exchange = await ExchangeContract.deployFrom0xArtifactAsync( - artifacts.Exchange, - provider, - txDefaults, - zrxAssetData, - ); + const exchange = await ExchangeContract.deployFrom0xArtifactAsync(artifacts.Exchange, provider, txDefaults); artifactsWriter.saveArtifact(exchange); // Multisigs diff --git a/packages/migrations/src/index.ts b/packages/migrations/src/index.ts index 188f566df..5354b3501 100644 --- a/packages/migrations/src/index.ts +++ b/packages/migrations/src/index.ts @@ -1,3 +1,2 @@ export { runV1MigrationsAsync } from './1.0.0/migration'; export { runV2MigrationsAsync } from './2.0.0/migration'; -export { runV2TestnetMigrationsAsync } from './2.0.0-beta-testnet/migration'; diff --git a/packages/migrations/src/migrate.ts b/packages/migrations/src/migrate.ts index c46d3580a..338832feb 100644 --- a/packages/migrations/src/migrate.ts +++ b/packages/migrations/src/migrate.ts @@ -1,20 +1,15 @@ #!/usr/bin/env node import { devConstants, web3Factory } from '@0xproject/dev-utils'; import { logUtils } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Provider } from 'ethereum-types'; import * as yargs from 'yargs'; import { runV1MigrationsAsync } from './1.0.0/migration'; -import { runV2TestnetMigrationsAsync } from './2.0.0-beta-testnet/migration'; import { runV2MigrationsAsync } from './2.0.0/migration'; -import { providerFactory } from './utils/provider_factory'; - enum ContractVersions { V1 = '1.0.0', V2 = '2.0.0', - V2Testnet = '2.0.0-beta-testnet', } const args = yargs.argv; @@ -41,16 +36,6 @@ const args = yargs.argv; }; await runV2MigrationsAsync(provider, artifactsDir, txDefaults); break; - case ContractVersions.V2Testnet: - provider = await providerFactory.getLedgerProviderAsync(); - const web3Wrapper = new Web3Wrapper(provider); - const accounts = await web3Wrapper.getAvailableAddressesAsync(); - txDefaults = { - from: accounts[0], - gas: devConstants.GAS_LIMIT, - }; - await runV2TestnetMigrationsAsync(provider, artifactsDir, txDefaults); - break; default: throw new Error(`Unsupported contract version: ${contractsVersion}`); } diff --git a/packages/migrations/src/utils/constants.ts b/packages/migrations/src/utils/constants.ts index 4ae2ff833..63898ac02 100644 --- a/packages/migrations/src/utils/constants.ts +++ b/packages/migrations/src/utils/constants.ts @@ -13,4 +13,6 @@ export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', KOVAN_RPC_URL: 'https://kovan.infura.io/', KOVAN_NETWORK_ID: 42, + MAINNET_RPC_URL: 'https://mainnet.infura.io/', + MAINNET_NETWORK_ID: 1, }; diff --git a/packages/migrations/src/utils/provider_factory.ts b/packages/migrations/src/utils/provider_factory.ts index a0d4e436e..e7e00a039 100644 --- a/packages/migrations/src/utils/provider_factory.ts +++ b/packages/migrations/src/utils/provider_factory.ts @@ -12,7 +12,7 @@ async function ledgerEthereumNodeJsClientFactoryAsync(): Promise<LedgerEthereumC return ledgerEthClient; } export const providerFactory = { - async getLedgerProviderAsync(): Promise<Provider> { + async getKovanLedgerProviderAsync(): Promise<Provider> { const provider = new Web3ProviderEngine(); const ledgerWalletConfigs = { networkId: constants.KOVAN_NETWORK_ID, @@ -24,4 +24,16 @@ export const providerFactory = { provider.start(); return provider; }, + async getMainnetLedgerProviderAsync(): Promise<Provider> { + const provider = new Web3ProviderEngine(); + const ledgerWalletConfigs = { + networkId: constants.MAINNET_NETWORK_ID, + ledgerEthereumClientFactoryAsync: ledgerEthereumNodeJsClientFactoryAsync, + }; + const ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs); + provider.addProvider(ledgerSubprovider); + provider.addProvider(new RPCSubprovider(constants.MAINNET_RPC_URL)); + provider.start(); + return provider; + }, }; diff --git a/packages/migrations/src/utils/token_info.ts b/packages/migrations/src/utils/token_info.ts index 7975c2174..200f94896 100644 --- a/packages/migrations/src/utils/token_info.ts +++ b/packages/migrations/src/utils/token_info.ts @@ -2,6 +2,20 @@ import { BigNumber, NULL_BYTES } from '@0xproject/utils'; import { ERC20Token, ERC721Token } from '../types'; +export const etherTokenByNetwork: { [networkId: number]: { address: string } } = { + 3: { + address: '0xc778417e063141139fce010982780140aa0cd5ab', + }, + 4: { + address: '0xc778417e063141139fce010982780140aa0cd5ab', + }, + 42: { + address: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + }, + 50: { + address: '', + }, +}; export const erc20TokenInfo: ERC20Token[] = [ { name: 'Augur Reputation Token', @@ -42,7 +56,7 @@ export const erc20TokenInfo: ERC20Token[] = [ export const erc721TokenInfo: ERC721Token[] = [ { - name: 'CryptoKitties', - symbol: 'CK', + name: '0xen ERC721', + symbol: '0xen', }, ]; |