From 92b0efff5abaac8bea468a1b3f897d004ec9c542 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 10:56:31 -0700 Subject: Migrate migrations to v2 --- .gitignore | 3 +- packages/0x.js/package.json | 2 +- packages/0x.js/test/global_hooks.ts | 4 +- packages/connect/package.json | 2 +- packages/contract-wrappers/package.json | 2 +- packages/contract-wrappers/test/global_hooks.ts | 4 +- packages/contracts/src/utils/exchange_wrapper.ts | 4 +- packages/contracts/src/utils/formatters.ts | 3 +- packages/contracts/src/utils/match_order_tester.ts | 3 +- packages/contracts/src/utils/order_factory.ts | 3 +- packages/contracts/src/utils/order_utils.ts | 5 +- packages/contracts/src/utils/types.ts | 39 ++---- packages/contracts/test/exchange/core.ts | 4 +- packages/contracts/test/exchange/libs.ts | 2 +- packages/contracts/test/exchange/match_orders.ts | 3 +- .../contracts/test/exchange/signature_validator.ts | 2 +- packages/contracts/test/exchange/transactions.ts | 5 +- packages/contracts/test/exchange/wrapper.ts | 3 +- packages/fill-scenarios/package.json | 2 +- packages/migrations/package.json | 24 +++- packages/migrations/src/artifacts.ts | 21 ---- packages/migrations/src/index.ts | 3 +- packages/migrations/src/migrate.ts | 19 ++- packages/migrations/src/migration.ts | 132 -------------------- packages/migrations/src/types.ts | 18 +-- packages/migrations/src/utils/token_info.ts | 11 +- packages/migrations/src/v1/artifacts.ts | 21 ++++ packages/migrations/src/v1/migration.ts | 133 +++++++++++++++++++++ packages/migrations/src/v2/artifacts.ts | 21 ++++ packages/migrations/src/v2/migration.ts | 118 ++++++++++++++++++ packages/order-utils/package.json | 2 +- packages/order-watcher/package.json | 2 +- packages/order-watcher/test/global_hooks.ts | 4 +- packages/types/src/index.ts | 30 ++--- yarn.lock | 7 ++ 35 files changed, 405 insertions(+), 256 deletions(-) delete mode 100644 packages/migrations/src/artifacts.ts delete mode 100644 packages/migrations/src/migration.ts create mode 100644 packages/migrations/src/v1/artifacts.ts create mode 100644 packages/migrations/src/v1/migration.ts create mode 100644 packages/migrations/src/v2/artifacts.ts create mode 100644 packages/migrations/src/v2/migration.ts diff --git a/.gitignore b/.gitignore index 5d0b845ce..96f562b1e 100644 --- a/.gitignore +++ b/.gitignore @@ -86,7 +86,8 @@ packages/contract-wrappers/src/contract_wrappers/generated/ packages/metacoin/src/contract_wrappers packages/fill-scenarios/src/generated_contract_wrappers/ packages/order-watcher/src/generated_contract_wrappers/ -packages/migrations/src/contract_wrappers +packages/migrations/src/v1/contract_wrappers +packages/migrations/src/v2/contract_wrappers # solc-bin in sol-compiler packages/sol-compiler/solc_bin/ diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index a498124b6..e4f7a1d03 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -104,7 +104,7 @@ "@0xproject/order-utils": "^0.0.5", "@0xproject/order-watcher": "^0.0.2", "@0xproject/sol-compiler": "^0.5.0", - "@0xproject/types": "^0.7.0", + "@0xproject/types": "0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", diff --git a/packages/0x.js/test/global_hooks.ts b/packages/0x.js/test/global_hooks.ts index fa1dfae38..d9768e61c 100644 --- a/packages/0x.js/test/global_hooks.ts +++ b/packages/0x.js/test/global_hooks.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0xproject/dev-utils'; -import { runMigrationsAsync } from '@0xproject/migrations'; +import { runV1MigrationsAsync } from '@0xproject/migrations'; import * as path from 'path'; import { constants } from './utils/constants'; @@ -15,5 +15,5 @@ before('migrate contracts', async function(): Promise { from: devConstants.TESTRPC_FIRST_ADDRESS, }; const artifactsDir = `../migrations/artifacts/1.0.0`; - await runMigrationsAsync(provider, artifactsDir, txDefaults); + await runV1MigrationsAsync(provider, artifactsDir, txDefaults); }); diff --git a/packages/connect/package.json b/packages/connect/package.json index d1e392606..a959a9948 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -52,7 +52,7 @@ "dependencies": { "@0xproject/assert": "^0.2.10", "@0xproject/json-schemas": "0.7.22", - "@0xproject/types": "^0.7.0", + "@0xproject/types": "0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "isomorphic-fetch": "^2.2.1", diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 6183bb701..9185ab46f 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -81,7 +81,7 @@ "@0xproject/fill-scenarios": "^0.0.2", "@0xproject/json-schemas": "0.7.22", "@0xproject/order-utils": "^0.0.5", - "@0xproject/types": "^0.7.0", + "@0xproject/types": "0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", diff --git a/packages/contract-wrappers/test/global_hooks.ts b/packages/contract-wrappers/test/global_hooks.ts index fa1dfae38..d9768e61c 100644 --- a/packages/contract-wrappers/test/global_hooks.ts +++ b/packages/contract-wrappers/test/global_hooks.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0xproject/dev-utils'; -import { runMigrationsAsync } from '@0xproject/migrations'; +import { runV1MigrationsAsync } from '@0xproject/migrations'; import * as path from 'path'; import { constants } from './utils/constants'; @@ -15,5 +15,5 @@ before('migrate contracts', async function(): Promise { from: devConstants.TESTRPC_FIRST_ADDRESS, }; const artifactsDir = `../migrations/artifacts/1.0.0`; - await runMigrationsAsync(provider, artifactsDir, txDefaults); + await runV1MigrationsAsync(provider, artifactsDir, txDefaults); }); diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts index c353442f3..f2533a598 100644 --- a/packages/contracts/src/utils/exchange_wrapper.ts +++ b/packages/contracts/src/utils/exchange_wrapper.ts @@ -1,4 +1,4 @@ -import { Provider, TransactionReceiptWithDecodedLogs } from '@0xproject/types'; +import { Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; @@ -10,7 +10,7 @@ import { constants } from './constants'; import { formatters } from './formatters'; import { LogDecoder } from './log_decoder'; import { orderUtils } from './order_utils'; -import { AssetProxyId, OrderInfo, SignedOrder, SignedTransaction } from './types'; +import { AssetProxyId, OrderInfo, SignedTransaction } from './types'; export class ExchangeWrapper { private _exchange: ExchangeContract; diff --git a/packages/contracts/src/utils/formatters.ts b/packages/contracts/src/utils/formatters.ts index bfa48d6f1..d84a16469 100644 --- a/packages/contracts/src/utils/formatters.ts +++ b/packages/contracts/src/utils/formatters.ts @@ -1,8 +1,9 @@ import { BigNumber } from '@0xproject/utils'; +import { SignedOrder } from '@0xproject/types'; import * as _ from 'lodash'; import { orderUtils } from './order_utils'; -import { BatchCancelOrders, BatchFillOrders, MarketBuyOrders, MarketSellOrders, SignedOrder } from './types'; +import { BatchCancelOrders, BatchFillOrders, MarketBuyOrders, MarketSellOrders } from './types'; export const formatters = { createBatchFill(signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[] = []): BatchFillOrders { diff --git a/packages/contracts/src/utils/match_order_tester.ts b/packages/contracts/src/utils/match_order_tester.ts index 30039937f..87399b9f6 100644 --- a/packages/contracts/src/utils/match_order_tester.ts +++ b/packages/contracts/src/utils/match_order_tester.ts @@ -1,5 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; -import { LogWithDecodedArgs } from '@0xproject/types'; +import { LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); @@ -29,7 +29,6 @@ import { ERC20BalancesByOwner, ERC721TokenIdsByOwner, ExchangeStatus, - SignedOrder, TransferAmountsByMatchOrders as TransferAmounts, } from '../utils/types'; import { provider, web3Wrapper } from '../utils/web3_wrapper'; diff --git a/packages/contracts/src/utils/order_factory.ts b/packages/contracts/src/utils/order_factory.ts index 86b3d5ac7..f704c26ec 100644 --- a/packages/contracts/src/utils/order_factory.ts +++ b/packages/contracts/src/utils/order_factory.ts @@ -1,11 +1,12 @@ import { generatePseudoRandomSalt } from '@0xproject/order-utils'; +import { SignedOrder, UnsignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { constants } from './constants'; import { orderUtils } from './order_utils'; import { signingUtils } from './signing_utils'; -import { SignatureType, SignedOrder, UnsignedOrder } from './types'; +import { SignatureType } from './types'; export class OrderFactory { private _defaultOrderParams: Partial; diff --git a/packages/contracts/src/utils/order_utils.ts b/packages/contracts/src/utils/order_utils.ts index 8adc6b735..9542a3858 100644 --- a/packages/contracts/src/utils/order_utils.ts +++ b/packages/contracts/src/utils/order_utils.ts @@ -1,10 +1,11 @@ +import { Order, SignedOrder, UnsignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; import { crypto } from './crypto'; -import { CancelOrder, MatchOrder, OrderStruct, SignatureType, SignedOrder, UnsignedOrder } from './types'; +import { CancelOrder, MatchOrder, SignatureType } from './types'; export const orderUtils = { createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => { @@ -22,7 +23,7 @@ export const orderUtils = { }; return cancel; }, - getOrderStruct(signedOrder: SignedOrder): OrderStruct { + getOrderStruct(signedOrder: SignedOrder): Order { const orderStruct = { senderAddress: signedOrder.senderAddress, makerAddress: signedOrder.makerAddress, diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts index ef86b4f38..8c53b966f 100644 --- a/packages/contracts/src/utils/types.ts +++ b/packages/contracts/src/utils/types.ts @@ -1,4 +1,4 @@ -import { AbiDefinition, ContractAbi } from '@0xproject/types'; +import { AbiDefinition, ContractAbi, Order } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; export interface ERC20BalancesByOwner { @@ -18,25 +18,25 @@ export interface SubmissionContractEventArgs { } export interface BatchFillOrders { - orders: OrderStruct[]; + orders: Order[]; signatures: string[]; takerAssetFillAmounts: BigNumber[]; } export interface MarketSellOrders { - orders: OrderStruct[]; + orders: Order[]; signatures: string[]; takerAssetFillAmount: BigNumber; } export interface MarketBuyOrders { - orders: OrderStruct[]; + orders: Order[]; signatures: string[]; makerAssetFillAmount: BigNumber; } export interface BatchCancelOrders { - orders: OrderStruct[]; + orders: Order[]; } export interface CancelOrdersBefore { @@ -113,29 +113,6 @@ export enum ContractName { Authorizable = 'Authorizable', } -export interface SignedOrder extends UnsignedOrder { - signature: string; -} - -export interface OrderStruct { - senderAddress: string; - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; -} - -export interface UnsignedOrder extends OrderStruct { - exchangeAddress: string; -} - export enum SignatureType { Illegal, Invalid, @@ -199,13 +176,13 @@ export interface ProxyData { } export interface CancelOrder { - order: OrderStruct; + order: Order; takerAssetCancelAmount: BigNumber; } export interface MatchOrder { - left: OrderStruct; - right: OrderStruct; + left: Order; + right: Order; leftSignature: string; rightSignature: string; } diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 4776216ca..f5cae7c7c 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -1,5 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; -import { LogWithDecodedArgs } from '@0xproject/types'; +import { LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; @@ -26,7 +26,7 @@ import { ERC721Wrapper } from '../../src/utils/erc721_wrapper'; import { ExchangeWrapper } from '../../src/utils/exchange_wrapper'; import { OrderFactory } from '../../src/utils/order_factory'; import { orderUtils } from '../../src/utils/order_utils'; -import { AssetProxyId, ContractName, ERC20BalancesByOwner, ExchangeStatus, SignedOrder } from '../../src/utils/types'; +import { AssetProxyId, ContractName, ERC20BalancesByOwner, ExchangeStatus } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; chaiSetup.configure(); diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts index 5c530a9b1..768909d48 100644 --- a/packages/contracts/test/exchange/libs.ts +++ b/packages/contracts/test/exchange/libs.ts @@ -1,5 +1,6 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { BigNumber } from '@0xproject/utils'; +import { SignedOrder } from '@0xproject/types'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); @@ -11,7 +12,6 @@ import { chaiSetup } from '../../src/utils/chai_setup'; import { constants } from '../../src/utils/constants'; import { OrderFactory } from '../../src/utils/order_factory'; import { orderUtils } from '../../src/utils/order_utils'; -import { SignedOrder } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; chaiSetup.configure(); diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts index 1834e929c..0da0287bc 100644 --- a/packages/contracts/test/exchange/match_orders.ts +++ b/packages/contracts/test/exchange/match_orders.ts @@ -1,5 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; -import { LogWithDecodedArgs } from '@0xproject/types'; +import { LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; @@ -33,7 +33,6 @@ import { ERC721TokenIdsByOwner, ExchangeStatus, OrderInfo, - SignedOrder, } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts index 91614c666..376fff438 100644 --- a/packages/contracts/test/exchange/signature_validator.ts +++ b/packages/contracts/test/exchange/signature_validator.ts @@ -1,4 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; +import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); @@ -11,7 +12,6 @@ import { chaiSetup } from '../../src/utils/chai_setup'; import { constants } from '../../src/utils/constants'; import { OrderFactory } from '../../src/utils/order_factory'; import { orderUtils } from '../../src/utils/order_utils'; -import { SignedOrder } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; chaiSetup.configure(); diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts index 24f7230fa..da628f30b 100644 --- a/packages/contracts/test/exchange/transactions.ts +++ b/packages/contracts/test/exchange/transactions.ts @@ -1,4 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; +import { SignedOrder, Order } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import * as ethUtil from 'ethereumjs-util'; @@ -20,9 +21,7 @@ import { AssetProxyId, ERC20BalancesByOwner, ExchangeStatus, - OrderStruct, SignatureType, - SignedOrder, SignedTransaction, } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; @@ -47,7 +46,7 @@ describe('Exchange transactions', () => { let erc20Balances: ERC20BalancesByOwner; let signedOrder: SignedOrder; let signedTx: SignedTransaction; - let order: OrderStruct; + let order: Order; let orderFactory: OrderFactory; let makerTransactionFactory: TransactionFactory; let takerTransactionFactory: TransactionFactory; diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index e7217c2a7..7e1818f4a 100644 --- a/packages/contracts/test/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -1,4 +1,5 @@ import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; +import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; @@ -20,7 +21,7 @@ import { ERC20Wrapper } from '../../src/utils/erc20_wrapper'; import { ERC721Wrapper } from '../../src/utils/erc721_wrapper'; import { ExchangeWrapper } from '../../src/utils/exchange_wrapper'; import { OrderFactory } from '../../src/utils/order_factory'; -import { AssetProxyId, ERC20BalancesByOwner, SignedOrder } from '../../src/utils/types'; +import { AssetProxyId, ERC20BalancesByOwner } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; chaiSetup.configure(); diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index 0d8ea6d13..f74c2672d 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -38,7 +38,7 @@ "dependencies": { "@0xproject/base-contract": "^0.3.2", "@0xproject/order-utils": "^0.0.5", - "@0xproject/types": "^0.7.0", + "@0xproject/types": "0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", diff --git a/packages/migrations/package.json b/packages/migrations/package.json index 08f7aa6b2..54866110e 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -10,18 +10,28 @@ "scripts": { "watch": "tsc -w", "prebuild": "run-s clean copy_artifacts generate_contract_wrappers", - "copy_artifacts": "copyfiles 'artifacts/1.0.0/**/*' ./lib", + "copy_artifacts": "copyfiles 'artifacts/**/*' ./lib", "build": "tsc", "clean": "shx rm -rf lib src/contract_wrappers", "lint": "tslint --project .", - "migrate": "run-s build compile script:migrate", - "script:migrate": "node ./lib/migrate.js", - "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers --backend ethers && prettier --write 'src/contract_wrappers/**.ts'", + "migrate:v1": "run-s build compile script:migrate:v1", + "migrate:v2": "run-s build compile script:migrate:v2", + "script:migrate:v1": "node ./lib/migrate.js --contracts-version 1.0.0", + "script:migrate:v2": "node ./lib/migrate.js --contracts-version 2.0.0", + "generate_contract_wrappers": "run-p generate_contract_wrappers:*", + "generate_contract_wrappers:v1": + "abi-gen --abis ${npm_package_config_abis_v1} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/v1/contract_wrappers --backend ethers && prettier --write 'src/v1/contract_wrappers/**.ts'", + "generate_contract_wrappers:v2": + "abi-gen --abis ${npm_package_config_abis_v2} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/v2/contract_wrappers --backend ethers && prettier --write 'src/v2/contract_wrappers/**.ts'", "compile": "sol-compiler" }, "config": { - "abis": - "artifacts/1.0.0/@(DummyERC20Token|TokenTransferProxy_v1|Exchange_v1|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|WETH9).json" + "abis": { + "v1": + "artifacts/1.0.0/@(DummyERC20Token|TokenTransferProxy_v1|Exchange_v1|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|WETH9).json", + "v2": + "artifacts/2.0.0/@(DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|ZRXToken|WETH9).json" + } }, "license": "Apache-2.0", "devDependencies": { @@ -29,6 +39,8 @@ "@0xproject/dev-utils": "^0.4.2", "@0xproject/tslint-config": "^0.4.18", "@0xproject/types": "^0.7.0", + "@types/yargs": "^10.0.0", + "yargs": "^10.0.3", "make-promises-safe": "^1.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", diff --git a/packages/migrations/src/artifacts.ts b/packages/migrations/src/artifacts.ts deleted file mode 100644 index acc267256..000000000 --- a/packages/migrations/src/artifacts.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ContractArtifact } from '@0xproject/sol-compiler'; - -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/index.ts b/packages/migrations/src/index.ts index c342247a3..5bf2f847d 100644 --- a/packages/migrations/src/index.ts +++ b/packages/migrations/src/index.ts @@ -1 +1,2 @@ -export { runMigrationsAsync } from './migration'; +export { runV1MigrationsAsync } from './v1/migration'; +export { runV2MigrationsAsync } from './v2/migration'; diff --git a/packages/migrations/src/migrate.ts b/packages/migrations/src/migrate.ts index 1230f376e..49b4e897c 100644 --- a/packages/migrations/src/migrate.ts +++ b/packages/migrations/src/migrate.ts @@ -3,8 +3,16 @@ import { devConstants, web3Factory } from '@0xproject/dev-utils'; import { Provider } from '@0xproject/types'; import { logUtils } from '@0xproject/utils'; import * as path from 'path'; +import * as yargs from 'yargs'; -import { runMigrationsAsync } from './migration'; +import { runV1MigrationsAsync } from './v1/migration'; +import { runV2MigrationsAsync } from './v2/migration'; + +enum ContractVersions { + V1 = '1.0.0', + V2 = '2.0.0', +} +const args = yargs.argv; (async () => { const txDefaults = { @@ -12,8 +20,13 @@ import { runMigrationsAsync } from './migration'; }; const providerConfigs = { shouldUseInProcessGanache: false }; const provider: Provider = web3Factory.getRpcProvider(providerConfigs); - const artifactsDir = 'artifacts/1.0.0'; - await runMigrationsAsync(provider, artifactsDir, txDefaults); + const contractsVersion = args.contractsVersion; + const artifactsDir = `artifacts/${contractsVersion}`; + if (contractsVersion === ContractVersions.V1) { + await runV1MigrationsAsync(provider, artifactsDir, txDefaults); + } else { + await runV2MigrationsAsync(provider, artifactsDir, txDefaults); + } process.exit(0); })().catch(err => { logUtils.log(err); diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts deleted file mode 100644 index e29414a57..000000000 --- a/packages/migrations/src/migration.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { Provider, TxData } from '@0xproject/types'; -import { BigNumber, NULL_BYTES } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import * as _ from 'lodash'; - -import { ArtifactWriter } from './artifact_writer'; -import { artifacts } from './artifacts'; -import { DummyERC20TokenContract } from './contract_wrappers/dummy_e_r_c20_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'; -import { ContractName } from './types'; -import { tokenInfo } from './utils/token_info'; - -/** - * Custom migrations should be defined in this function. This will be called with the CLI 'migrate' 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 runMigrationsAsync = async (provider: Provider, artifactsDir: string, txDefaults: Partial) => { - 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 tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }); - await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: owner }); - const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync( - zrxToken.address, - tokenInfo[0].name, - tokenInfo[0].symbol, - tokenInfo[0].decimals, - tokenInfo[0].ipfsHash, - tokenInfo[0].swarmHash, - { from: owner }, - ); - const decimals = 18; - await tokenReg.addToken.sendTransactionAsync( - zrxToken.address, - '0x Protocol Token', - 'ZRX', - decimals, - NULL_BYTES, - NULL_BYTES, - { - from: owner, - gas: addTokenGasEstimate, - }, - ); - await tokenReg.addToken.sendTransactionAsync( - etherToken.address, - 'Ether Token', - 'WETH', - decimals, - NULL_BYTES, - NULL_BYTES, - { - from: owner, - gas: addTokenGasEstimate, - }, - ); - for (const token of tokenInfo) { - const totalSupply = new BigNumber(100000000000000000000); - const dummyToken = await DummyERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC20Token, - provider, - txDefaults, - token.name, - token.symbol, - token.decimals, - totalSupply, - ); - 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/types.ts b/packages/migrations/src/types.ts index 5ece26c5d..65f685797 100644 --- a/packages/migrations/src/types.ts +++ b/packages/migrations/src/types.ts @@ -1,16 +1,6 @@ import { BigNumber } from '@0xproject/utils'; -export interface MultiSigConfig { - owners: string[]; - confirmationsRequired: number; - secondsRequired: number; -} - -export interface MultiSigConfigByNetwork { - [networkName: string]: MultiSigConfig; -} - -export interface Token { +export interface ERC20Token { address?: string; name: string; symbol: string; @@ -19,9 +9,9 @@ export interface Token { swarmHash: string; } -export interface TokenInfoByNetwork { - development: Token[]; - live: Token[]; +export interface ERC721Token { + name: string; + symbol: string; } export enum ContractName { diff --git a/packages/migrations/src/utils/token_info.ts b/packages/migrations/src/utils/token_info.ts index e72a80220..7975c2174 100644 --- a/packages/migrations/src/utils/token_info.ts +++ b/packages/migrations/src/utils/token_info.ts @@ -1,8 +1,8 @@ import { BigNumber, NULL_BYTES } from '@0xproject/utils'; -import { Token } from '../types'; +import { ERC20Token, ERC721Token } from '../types'; -export const tokenInfo: Token[] = [ +export const erc20TokenInfo: ERC20Token[] = [ { name: 'Augur Reputation Token', symbol: 'REP', @@ -39,3 +39,10 @@ export const tokenInfo: Token[] = [ swarmHash: NULL_BYTES, }, ]; + +export const erc721TokenInfo: ERC721Token[] = [ + { + name: 'CryptoKitties', + symbol: 'CK', + }, +]; diff --git a/packages/migrations/src/v1/artifacts.ts b/packages/migrations/src/v1/artifacts.ts new file mode 100644 index 000000000..d0a9f735a --- /dev/null +++ b/packages/migrations/src/v1/artifacts.ts @@ -0,0 +1,21 @@ +import { ContractArtifact } from '@0xproject/sol-compiler'; + +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/v1/migration.ts b/packages/migrations/src/v1/migration.ts new file mode 100644 index 000000000..233339244 --- /dev/null +++ b/packages/migrations/src/v1/migration.ts @@ -0,0 +1,133 @@ +import { Provider, TxData } from '@0xproject/types'; +import { BigNumber, NULL_BYTES } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; + +import { ArtifactWriter } from '../artifact_writer'; +import { ContractName } from '../types'; +import { erc20TokenInfo } from '../utils/token_info'; + +import { artifacts } from './artifacts'; +import { DummyERC20TokenContract } from './contract_wrappers/dummy_e_r_c20_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) => { + 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 tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }); + 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 tokenReg.addToken.sendTransactionAsync( + zrxToken.address, + '0x Protocol Token', + 'ZRX', + decimals, + NULL_BYTES, + NULL_BYTES, + { + from: owner, + gas: addTokenGasEstimate, + }, + ); + 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 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/v2/artifacts.ts b/packages/migrations/src/v2/artifacts.ts new file mode 100644 index 000000000..3079e4d89 --- /dev/null +++ b/packages/migrations/src/v2/artifacts.ts @@ -0,0 +1,21 @@ +import { ContractArtifact } from '@0xproject/sol-compiler'; + +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 MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress from '../../artifacts/2.0.0/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.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, + MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress: (MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress 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, +}; diff --git a/packages/migrations/src/v2/migration.ts b/packages/migrations/src/v2/migration.ts new file mode 100644 index 000000000..daad1ec00 --- /dev/null +++ b/packages/migrations/src/v2/migration.ts @@ -0,0 +1,118 @@ +import { Provider, TxData } from '@0xproject/types'; +import { BigNumber, NULL_BYTES } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; + +import { ArtifactWriter } from '../artifact_writer'; +import { ContractName } from '../types'; +import { erc20TokenInfo, erc721TokenInfo } from '../utils/token_info'; + +import { artifacts } from './artifacts'; +import { DummyERC20TokenContract } from './contract_wrappers/dummy_e_r_c20_token'; +import { DummyERC721TokenContract } from './contract_wrappers/dummy_e_r_c721_token'; +import { ERC20ProxyContract } from './contract_wrappers/e_r_c20_proxy'; +import { ERC721ProxyContract } from './contract_wrappers/e_r_c721_proxy'; +import { ExchangeContract } from './contract_wrappers/exchange'; +import { MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract } from './contract_wrappers/multi_sig_wallet_with_time_lock_except_remove_authorized_address'; +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) => { + 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 exchange = await ExchangeContract.deployFrom0xArtifactAsync( + artifacts.Exchange, + provider, + txDefaults, + zrxToken.address, + ); + 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]; + + // TODO(leonid) use `AssetProxyOwner` after https://github.com/0xProject/0x-monorepo/pull/571 is merged + // ERC20 Multisig + const multiSigERC20 = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract.deployFrom0xArtifactAsync( + artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress, + provider, + txDefaults, + owners, + confirmationsRequired, + secondsRequired, + erc20proxy.address, + ); + artifactsWriter.saveArtifact(multiSigERC20); + await erc20proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }); + await erc20proxy.transferOwnership.sendTransactionAsync(multiSigERC20.address, { from: owner }); + + // ERC721 Multisig + const multiSigERC721 = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract.deployFrom0xArtifactAsync( + artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress, + provider, + txDefaults, + owners, + confirmationsRequired, + secondsRequired, + erc721proxy.address, + ); + artifactsWriter.saveArtifact(multiSigERC721); + await erc721proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }); + await erc721proxy.transferOwnership.sendTransactionAsync(multiSigERC20.address, { from: owner }); + + // Dummy ERC20 tokens + for (const token of erc20TokenInfo) { + const totalSupply = new BigNumber(100000000000000000000); + const dummyErc20Token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( + artifacts.DummyERC20Token, + provider, + txDefaults, + token.name, + token.symbol, + token.decimals, + totalSupply, + ); + } + + // CK -> Token registry + const cryptoKittieToken = await DummyERC721TokenContract.deployFrom0xArtifactAsync( + artifacts.DummyERC721Token, + provider, + txDefaults, + erc721TokenInfo[0].name, + erc721TokenInfo[0].symbol, + ); +}; diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 19e3d5668..3586c4523 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -64,7 +64,7 @@ "dependencies": { "@0xproject/assert": "^0.2.10", "@0xproject/json-schemas": "0.7.22", - "@0xproject/types": "^0.7.0", + "@0xproject/types": "0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index ee9d66cd3..a1aed439b 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -82,7 +82,7 @@ "@0xproject/fill-scenarios": "^0.0.2", "@0xproject/json-schemas": "0.7.22", "@0xproject/order-utils": "^0.0.5", - "@0xproject/types": "^0.7.0", + "@0xproject/types": "0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", diff --git a/packages/order-watcher/test/global_hooks.ts b/packages/order-watcher/test/global_hooks.ts index d4d033dd4..1df80533c 100644 --- a/packages/order-watcher/test/global_hooks.ts +++ b/packages/order-watcher/test/global_hooks.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0xproject/dev-utils'; -import { runMigrationsAsync } from '@0xproject/migrations'; +import { runV1MigrationsAsync } from '@0xproject/migrations'; import 'make-promises-safe'; import * as path from 'path'; @@ -16,5 +16,5 @@ before('migrate contracts', async function(): Promise { from: devConstants.TESTRPC_FIRST_ADDRESS, }; const artifactsDir = `../migrations/artifacts/1.0.0`; - await runMigrationsAsync(provider, artifactsDir, txDefaults); + await runV1MigrationsAsync(provider, artifactsDir, txDefaults); }); diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 055c47e0a..7831f580e 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -282,22 +282,26 @@ export interface RawLogEntry { } export interface Order { - maker: string; - taker: string; + senderAddress: string; + makerAddress: string; + takerAddress: string; makerFee: BigNumber; takerFee: BigNumber; - makerTokenAmount: BigNumber; - takerTokenAmount: BigNumber; - makerTokenAddress: string; - takerTokenAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerAssetData: string; + takerAssetData: string; salt: BigNumber; - exchangeContractAddress: string; - feeRecipient: string; - expirationUnixTimestampSec: BigNumber; + feeRecipientAddress: string; + expirationTimeSeconds: BigNumber; } -export interface SignedOrder extends Order { - ecSignature: ECSignature; +export interface SignedOrder extends UnsignedOrder { + signature: string; +} + +export interface UnsignedOrder extends Order { + exchangeAddress: string; } /** @@ -349,10 +353,6 @@ export interface Artifact { }; } -export type OrderAddresses = [string, string, string, string, string]; - -export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]; - export type DoneCallback = (err?: Error) => void; export interface OrderRelevantState { diff --git a/yarn.lock b/yarn.lock index 93bfc206f..58758bf09 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,6 +15,13 @@ jsonschema "^1.2.0" lodash.values "^4.3.0" +"@0xproject/types@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.6.3.tgz#0bc066967aad4151011b6e478bb707b1afb8504b" + dependencies: + "@types/node" "^8.0.53" + bignumber.js "~4.1.0" + "@0xproject/types@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.5.0.tgz#ba3cfbc11a8c6344b57c9680aa7df2ea84b9bf05" -- cgit v1.2.3 From 45c4de16d2c4a7c413dc878f442d31ae46085a68 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 14:33:48 -0700 Subject: Do a fake version bump on types so that yarn doesn't try to install updated version for not yet migrated packages --- packages/types/CHANGELOG.json | 9 +++++++++ packages/types/package.json | 2 +- yarn.lock | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 8abc5bd99..6acfbb98a 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "0.8.0", + "changes": [ + { + "note": "Change the order type to v2 format", + "pr": 618 + } + ] + }, { "version": "0.7.0", "changes": [ diff --git a/packages/types/package.json b/packages/types/package.json index 0968c6b7a..d9afe5afc 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/types", - "version": "0.7.0", + "version": "0.7.1", "engines": { "node": ">=6.12" }, diff --git a/yarn.lock b/yarn.lock index 58758bf09..3de08250a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,9 +15,9 @@ jsonschema "^1.2.0" lodash.values "^4.3.0" -"@0xproject/types@0.6.3": - version "0.6.3" - resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.6.3.tgz#0bc066967aad4151011b6e478bb707b1afb8504b" +"@0xproject/types@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.7.0.tgz#fad13925ee92ad4ee1980668a5cb2bed4dcaab8f" dependencies: "@types/node" "^8.0.53" bignumber.js "~4.1.0" -- cgit v1.2.3 From 6d3fbbe25612eb74548a66153b4a45e182af50a8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 14:40:32 -0700 Subject: Pin types version in website --- packages/website/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/website/package.json b/packages/website/package.json index a91437646..f4a9231c2 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -23,6 +23,7 @@ "@0xproject/subproviders": "^0.10.2", "@0xproject/contract-wrappers": "^0.0.2", "@0xproject/typescript-typings": "^0.3.2", + "@0xproject/types": "0.7.0", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", "accounting": "^0.4.1", -- cgit v1.2.3 From fd6ce470e7a0391a26e43381f360803e3472683f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 14:40:53 -0700 Subject: Unpin types version in @0xproject/connect --- packages/connect/package.json | 2 +- packages/connect/src/index.ts | 2 +- packages/connect/src/types.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/connect/package.json b/packages/connect/package.json index a959a9948..d1e392606 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -52,7 +52,7 @@ "dependencies": { "@0xproject/assert": "^0.2.10", "@0xproject/json-schemas": "0.7.22", - "@0xproject/types": "0.7.0", + "@0xproject/types": "^0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "isomorphic-fetch": "^2.2.1", diff --git a/packages/connect/src/index.ts b/packages/connect/src/index.ts index 135b5b5f6..ef5d8683e 100644 --- a/packages/connect/src/index.ts +++ b/packages/connect/src/index.ts @@ -17,4 +17,4 @@ export { WebSocketOrderbookChannelConfig, } from './types'; -export { ECSignature, Order, SignedOrder } from '@0xproject/types'; +export { Order, SignedOrder } from '@0xproject/types'; diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts index b0467f22a..074ab950f 100644 --- a/packages/connect/src/types.ts +++ b/packages/connect/src/types.ts @@ -1,4 +1,4 @@ -import { ECSignature, Order, SignedOrder } from '@0xproject/types'; +import { Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; export interface Client { -- cgit v1.2.3 From ea3f82ccc25ad411d32d4dd8c2dbcbc95847dc0b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 14:56:20 -0700 Subject: Fix linter issues --- packages/contracts/src/utils/formatters.ts | 2 +- packages/contracts/test/exchange/libs.ts | 2 +- packages/contracts/test/exchange/transactions.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contracts/src/utils/formatters.ts b/packages/contracts/src/utils/formatters.ts index d84a16469..c46d668bc 100644 --- a/packages/contracts/src/utils/formatters.ts +++ b/packages/contracts/src/utils/formatters.ts @@ -1,5 +1,5 @@ -import { BigNumber } from '@0xproject/utils'; import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { orderUtils } from './order_utils'; diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts index 768909d48..b704d5914 100644 --- a/packages/contracts/test/exchange/libs.ts +++ b/packages/contracts/test/exchange/libs.ts @@ -1,6 +1,6 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; -import { BigNumber } from '@0xproject/utils'; import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts index da628f30b..33fe11bfa 100644 --- a/packages/contracts/test/exchange/transactions.ts +++ b/packages/contracts/test/exchange/transactions.ts @@ -1,5 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; -import { SignedOrder, Order } from '@0xproject/types'; +import { Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import * as ethUtil from 'ethereumjs-util'; -- cgit v1.2.3 From 1717c5c00d99fd74ef12ab4aa4655412974121c2 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 15:28:37 -0700 Subject: Pin types in sra-report --- packages/sra-report/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 7e58a80a2..2ed176f66 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -32,7 +32,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md", "dependencies": { "@0xproject/assert": "^0.2.10", - "@0xproject/types": "^0.7.0", + "@0xproject/types": "0.7.0", "@0xproject/order-utils": "^0.0.5", "@0xproject/connect": "^0.6.13", "@0xproject/json-schemas": "0.7.22", -- cgit v1.2.3 From 9fa567aa783fe7ab67f131d05db85513fa6d9fc4 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 15:42:29 -0700 Subject: Fix a typo --- packages/migrations/src/v2/migration.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/migrations/src/v2/migration.ts b/packages/migrations/src/v2/migration.ts index daad1ec00..fd7223252 100644 --- a/packages/migrations/src/v2/migration.ts +++ b/packages/migrations/src/v2/migration.ts @@ -91,7 +91,7 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str ); artifactsWriter.saveArtifact(multiSigERC721); await erc721proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }); - await erc721proxy.transferOwnership.sendTransactionAsync(multiSigERC20.address, { from: owner }); + await erc721proxy.transferOwnership.sendTransactionAsync(multiSigERC721.address, { from: owner }); // Dummy ERC20 tokens for (const token of erc20TokenInfo) { @@ -107,7 +107,7 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str ); } - // CK -> Token registry + // ERC721 const cryptoKittieToken = await DummyERC721TokenContract.deployFrom0xArtifactAsync( artifacts.DummyERC721Token, provider, -- cgit v1.2.3 From 3e907d7f4fddcb9ae5438b5676bf9ecd99007909 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 15:45:11 -0700 Subject: Pin connect in sra-report --- packages/sra-report/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 2ed176f66..cc34b5ced 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -34,7 +34,7 @@ "@0xproject/assert": "^0.2.10", "@0xproject/types": "0.7.0", "@0xproject/order-utils": "^0.0.5", - "@0xproject/connect": "^0.6.13", + "@0xproject/connect": "0.6.12", "@0xproject/json-schemas": "0.7.22", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", -- cgit v1.2.3 From 4ee636ecca20d2744a7d133194aa950f3f6fb833 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 24 May 2018 16:07:11 -0700 Subject: Temporarily disable installation tests --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3cdb906e3..ab42ade09 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -183,9 +183,9 @@ workflows: main: jobs: - build - - test-installation: - requires: - - build + # - test-installation: + # requires: + # - build - test-0xjs: requires: - build -- cgit v1.2.3