diff options
Diffstat (limited to 'packages/migrations/src')
-rw-r--r-- | packages/migrations/src/1.0.0/artifacts.ts | 2 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-beta-testnet/artifacts.ts | 13 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0-beta-testnet/migration.ts | 104 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0/artifacts.ts | 4 | ||||
-rw-r--r-- | packages/migrations/src/2.0.0/migration.ts | 22 | ||||
-rw-r--r-- | packages/migrations/src/index.ts | 1 | ||||
-rw-r--r-- | packages/migrations/src/migrate.ts | 15 | ||||
-rw-r--r-- | packages/migrations/src/monorepo_scripts/postpublish.ts | 8 | ||||
-rw-r--r-- | packages/migrations/src/utils/artifact_writer.ts | 2 | ||||
-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 |
12 files changed, 50 insertions, 155 deletions
diff --git a/packages/migrations/src/1.0.0/artifacts.ts b/packages/migrations/src/1.0.0/artifacts.ts index d0a9f735a..f5226e174 100644 --- a/packages/migrations/src/1.0.0/artifacts.ts +++ b/packages/migrations/src/1.0.0/artifacts.ts @@ -1,4 +1,4 @@ -import { ContractArtifact } from '@0xproject/sol-compiler'; +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'; 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 c9a341eb3..000000000 --- a/packages/migrations/src/2.0.0-beta-testnet/artifacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ContractArtifact } from '@0xproject/sol-compiler'; - -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'; - -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, -}; 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 19fe5f02c..000000000 --- a/packages/migrations/src/2.0.0-beta-testnet/migration.ts +++ /dev/null @@ -1,104 +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'; - -/** - * 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); - - // 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/artifacts.ts b/packages/migrations/src/2.0.0/artifacts.ts index 8bbd1fcd9..e96c555d6 100644 --- a/packages/migrations/src/2.0.0/artifacts.ts +++ b/packages/migrations/src/2.0.0/artifacts.ts @@ -1,4 +1,4 @@ -import { ContractArtifact } from '@0xproject/sol-compiler'; +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'; @@ -7,6 +7,7 @@ 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'; @@ -20,4 +21,5 @@ export const artifacts = { 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 index f51c236de..1c30fb9ec 100644 --- a/packages/migrations/src/2.0.0/migration.ts +++ b/packages/migrations/src/2.0.0/migration.ts @@ -14,6 +14,7 @@ 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'; @@ -49,12 +50,8 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str artifactsWriter.saveArtifact(etherToken); // Exchange - const exchange = await ExchangeContract.deployFrom0xArtifactAsync( - artifacts.Exchange, - provider, - txDefaults, - assetDataUtils.encodeERC20AssetData(zrxToken.address), - ); + const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); + const exchange = await ExchangeContract.deployFrom0xArtifactAsync(artifacts.Exchange, provider, txDefaults); artifactsWriter.saveArtifact(exchange); // Multisigs @@ -75,6 +72,7 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str secondsRequired, ); artifactsWriter.saveArtifact(assetProxyOwner); + await web3Wrapper.awaitTransactionSuccessAsync( await erc20proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner, @@ -135,10 +133,18 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str provider, txDefaults, exchange.address, - etherToken.address, - zrxToken.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/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/monorepo_scripts/postpublish.ts b/packages/migrations/src/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/migrations/src/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/migrations/src/utils/artifact_writer.ts b/packages/migrations/src/utils/artifact_writer.ts index b7522df05..ea9c7952d 100644 --- a/packages/migrations/src/utils/artifact_writer.ts +++ b/packages/migrations/src/utils/artifact_writer.ts @@ -1,5 +1,5 @@ import { BaseContract } from '@0xproject/base-contract'; -import { ContractArtifact } from '@0xproject/sol-compiler'; +import { ContractArtifact } from 'ethereum-types'; import * as fs from 'fs'; import * as path from 'path'; 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', }, ]; |