Add Exchange Proxy to Ganache snapshot (#2612)
* `@0x/contracts-zero-ex`: Expose migration tools. * `@0x/contract-addresses`: Update ganache snapshot Exchange Proxy addresses * `@0x/migrations`: Add Exchange Proxy migration
This commit is contained in:
parent
7431651666
commit
a5a68acfec
@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Export migration tools",
|
||||||
|
"pr": 2612
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1592969527,
|
"timestamp": 1592969527,
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
|
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"publicInterfaceContracts": "ZeroEx,FullMigration,InitialMigration,IFlashWallet,IAllowanceTarget,IERC20Transformer,IOwnable,ISimpleFunctionRegistry,ITokenSpender,ITransformERC20,FillQuoteTransformer,PayTakerTransformer,WethTransformer",
|
"publicInterfaceContracts": "ZeroEx,FullMigration,InitialMigration,IFlashWallet,IAllowanceTarget,IERC20Transformer,IOwnable,ISimpleFunctionRegistry,ITokenSpender,ITransformERC20,FillQuoteTransformer,PayTakerTransformer,WethTransformer,Ownable,SimpleFunctionRegistry,TransformERC20,TokenSpender",
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|AllowanceTarget|Bootstrap|FillQuoteTransformer|FixinCommon|FlashWallet|FullMigration|IAllowanceTarget|IBootstrap|IERC20Transformer|IExchange|IFeature|IFlashWallet|IOwnable|ISimpleFunctionRegistry|ITestSimpleFunctionRegistryFeature|ITokenSpender|ITransformERC20|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibMigrate|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibSpenderRichErrors|LibStorage|LibTokenSpenderStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|Ownable|PayTakerTransformer|SimpleFunctionRegistry|TestCallTarget|TestDelegateCaller|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFullMigration|TestInitialMigration|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestTokenSpender|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TokenSpender|TransformERC20|Transformer|TransformerDeployer|WethTransformer|ZeroEx).json"
|
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|AllowanceTarget|Bootstrap|FillQuoteTransformer|FixinCommon|FlashWallet|FullMigration|IAllowanceTarget|IBootstrap|IERC20Transformer|IExchange|IFeature|IFlashWallet|IOwnable|ISimpleFunctionRegistry|ITestSimpleFunctionRegistryFeature|ITokenSpender|ITransformERC20|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibMigrate|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibSpenderRichErrors|LibStorage|LibTokenSpenderStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|Ownable|PayTakerTransformer|SimpleFunctionRegistry|TestCallTarget|TestDelegateCaller|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFullMigration|TestInitialMigration|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestTokenSpender|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TokenSpender|TransformERC20|Transformer|TransformerDeployer|WethTransformer|ZeroEx).json"
|
||||||
},
|
},
|
||||||
@ -58,7 +58,6 @@
|
|||||||
"@0x/dev-utils": "^3.2.2",
|
"@0x/dev-utils": "^3.2.2",
|
||||||
"@0x/order-utils": "^10.3.0",
|
"@0x/order-utils": "^10.3.0",
|
||||||
"@0x/sol-compiler": "^4.1.0",
|
"@0x/sol-compiler": "^4.1.0",
|
||||||
"@0x/subproviders": "^6.1.0",
|
|
||||||
"@0x/ts-doc-gen": "^0.0.22",
|
"@0x/ts-doc-gen": "^0.0.22",
|
||||||
"@0x/tslint-config": "^4.0.0",
|
"@0x/tslint-config": "^4.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
@ -75,6 +74,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^6.2.2",
|
"@0x/base-contract": "^6.2.2",
|
||||||
|
"@0x/subproviders": "^6.1.0",
|
||||||
"@0x/types": "^3.1.3",
|
"@0x/types": "^3.1.3",
|
||||||
"@0x/typescript-typings": "^5.1.0",
|
"@0x/typescript-typings": "^5.1.0",
|
||||||
"@0x/utils": "^5.5.0",
|
"@0x/utils": "^5.5.0",
|
||||||
|
@ -15,7 +15,11 @@ import * as IOwnable from '../generated-artifacts/IOwnable.json';
|
|||||||
import * as ISimpleFunctionRegistry from '../generated-artifacts/ISimpleFunctionRegistry.json';
|
import * as ISimpleFunctionRegistry from '../generated-artifacts/ISimpleFunctionRegistry.json';
|
||||||
import * as ITokenSpender from '../generated-artifacts/ITokenSpender.json';
|
import * as ITokenSpender from '../generated-artifacts/ITokenSpender.json';
|
||||||
import * as ITransformERC20 from '../generated-artifacts/ITransformERC20.json';
|
import * as ITransformERC20 from '../generated-artifacts/ITransformERC20.json';
|
||||||
|
import * as Ownable from '../generated-artifacts/Ownable.json';
|
||||||
import * as PayTakerTransformer from '../generated-artifacts/PayTakerTransformer.json';
|
import * as PayTakerTransformer from '../generated-artifacts/PayTakerTransformer.json';
|
||||||
|
import * as SimpleFunctionRegistry from '../generated-artifacts/SimpleFunctionRegistry.json';
|
||||||
|
import * as TokenSpender from '../generated-artifacts/TokenSpender.json';
|
||||||
|
import * as TransformERC20 from '../generated-artifacts/TransformERC20.json';
|
||||||
import * as WethTransformer from '../generated-artifacts/WethTransformer.json';
|
import * as WethTransformer from '../generated-artifacts/WethTransformer.json';
|
||||||
import * as ZeroEx from '../generated-artifacts/ZeroEx.json';
|
import * as ZeroEx from '../generated-artifacts/ZeroEx.json';
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
@ -32,4 +36,8 @@ export const artifacts = {
|
|||||||
FillQuoteTransformer: FillQuoteTransformer as ContractArtifact,
|
FillQuoteTransformer: FillQuoteTransformer as ContractArtifact,
|
||||||
PayTakerTransformer: PayTakerTransformer as ContractArtifact,
|
PayTakerTransformer: PayTakerTransformer as ContractArtifact,
|
||||||
WethTransformer: WethTransformer as ContractArtifact,
|
WethTransformer: WethTransformer as ContractArtifact,
|
||||||
|
Ownable: Ownable as ContractArtifact,
|
||||||
|
SimpleFunctionRegistry: SimpleFunctionRegistry as ContractArtifact,
|
||||||
|
TransformERC20: TransformERC20 as ContractArtifact,
|
||||||
|
TokenSpender: TokenSpender as ContractArtifact,
|
||||||
};
|
};
|
||||||
|
@ -41,3 +41,6 @@ export {
|
|||||||
TupleDataItem,
|
TupleDataItem,
|
||||||
StateMutability,
|
StateMutability,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
|
|
||||||
|
export * from './nonce_utils';
|
||||||
|
export * from './migration';
|
||||||
|
130
contracts/zero-ex/src/migration.ts
Normal file
130
contracts/zero-ex/src/migration.ts
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
import { BaseContract } from '@0x/base-contract';
|
||||||
|
import { SupportedProvider } from '@0x/subproviders';
|
||||||
|
import { TxData } from 'ethereum-types';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { artifacts } from './artifacts';
|
||||||
|
import {
|
||||||
|
FullMigrationContract,
|
||||||
|
InitialMigrationContract,
|
||||||
|
OwnableContract,
|
||||||
|
SimpleFunctionRegistryContract,
|
||||||
|
TokenSpenderContract,
|
||||||
|
TransformERC20Contract,
|
||||||
|
ZeroExContract,
|
||||||
|
} from './wrappers';
|
||||||
|
|
||||||
|
// tslint:disable: completed-docs
|
||||||
|
|
||||||
|
export interface BootstrapFeatures {
|
||||||
|
registry: SimpleFunctionRegistryContract;
|
||||||
|
ownable: OwnableContract;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deployBootstrapFeaturesAsync(
|
||||||
|
provider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
features: Partial<BootstrapFeatures> = {},
|
||||||
|
): Promise<BootstrapFeatures> {
|
||||||
|
return {
|
||||||
|
registry:
|
||||||
|
features.registry ||
|
||||||
|
(await SimpleFunctionRegistryContract.deployFrom0xArtifactAsync(
|
||||||
|
artifacts.SimpleFunctionRegistry,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
artifacts,
|
||||||
|
)),
|
||||||
|
ownable:
|
||||||
|
features.ownable ||
|
||||||
|
(await OwnableContract.deployFrom0xArtifactAsync(artifacts.Ownable, provider, txDefaults, artifacts)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function initialMigrateAsync(
|
||||||
|
owner: string,
|
||||||
|
provider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
features: Partial<BootstrapFeatures> = {},
|
||||||
|
): Promise<ZeroExContract> {
|
||||||
|
const _features = await deployBootstrapFeaturesAsync(provider, txDefaults, features);
|
||||||
|
const migrator = await InitialMigrationContract.deployFrom0xArtifactAsync(
|
||||||
|
artifacts.InitialMigration,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
artifacts,
|
||||||
|
txDefaults.from as string,
|
||||||
|
);
|
||||||
|
const deployCall = migrator.deploy(owner, toFeatureAdddresses(_features));
|
||||||
|
const zeroEx = new ZeroExContract(await deployCall.callAsync(), provider, {});
|
||||||
|
await deployCall.awaitTransactionSuccessAsync();
|
||||||
|
return zeroEx;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FullFeatures extends BootstrapFeatures {
|
||||||
|
tokenSpender: TokenSpenderContract;
|
||||||
|
transformERC20: TransformERC20Contract;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FullMigrationOpts {
|
||||||
|
transformerDeployer: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deployFullFeaturesAsync(
|
||||||
|
provider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
features: Partial<FullFeatures> = {},
|
||||||
|
): Promise<FullFeatures> {
|
||||||
|
return {
|
||||||
|
...(await deployBootstrapFeaturesAsync(provider, txDefaults)),
|
||||||
|
tokenSpender:
|
||||||
|
features.tokenSpender ||
|
||||||
|
(await TokenSpenderContract.deployFrom0xArtifactAsync(
|
||||||
|
artifacts.TokenSpender,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
artifacts,
|
||||||
|
)),
|
||||||
|
transformERC20:
|
||||||
|
features.transformERC20 ||
|
||||||
|
(await TransformERC20Contract.deployFrom0xArtifactAsync(
|
||||||
|
artifacts.TransformERC20,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
artifacts,
|
||||||
|
)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fullMigrateAsync(
|
||||||
|
owner: string,
|
||||||
|
provider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
features: Partial<FullFeatures> = {},
|
||||||
|
opts: Partial<FullMigrationOpts> = {},
|
||||||
|
): Promise<ZeroExContract> {
|
||||||
|
const _features = await deployFullFeaturesAsync(provider, txDefaults, features);
|
||||||
|
const migrator = await FullMigrationContract.deployFrom0xArtifactAsync(
|
||||||
|
artifacts.FullMigration,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
artifacts,
|
||||||
|
txDefaults.from as string,
|
||||||
|
);
|
||||||
|
const _opts = {
|
||||||
|
transformerDeployer: txDefaults.from as string,
|
||||||
|
...opts,
|
||||||
|
};
|
||||||
|
const deployCall = migrator.deploy(owner, toFeatureAdddresses(_features), _opts);
|
||||||
|
const zeroEx = new ZeroExContract(await deployCall.callAsync(), provider, {});
|
||||||
|
await deployCall.awaitTransactionSuccessAsync();
|
||||||
|
return zeroEx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tslint:disable:space-before-function-parent one-line
|
||||||
|
export function toFeatureAdddresses<T extends BootstrapFeatures | FullFeatures | (BootstrapFeatures & FullFeatures)>(
|
||||||
|
features: T,
|
||||||
|
): { [name in keyof T]: string } {
|
||||||
|
// TS can't figure this out.
|
||||||
|
return _.mapValues(features, (c: BaseContract) => c.address) as any;
|
||||||
|
}
|
@ -13,6 +13,10 @@ export * from '../generated-wrappers/i_simple_function_registry';
|
|||||||
export * from '../generated-wrappers/i_token_spender';
|
export * from '../generated-wrappers/i_token_spender';
|
||||||
export * from '../generated-wrappers/i_transform_erc20';
|
export * from '../generated-wrappers/i_transform_erc20';
|
||||||
export * from '../generated-wrappers/initial_migration';
|
export * from '../generated-wrappers/initial_migration';
|
||||||
|
export * from '../generated-wrappers/ownable';
|
||||||
export * from '../generated-wrappers/pay_taker_transformer';
|
export * from '../generated-wrappers/pay_taker_transformer';
|
||||||
|
export * from '../generated-wrappers/simple_function_registry';
|
||||||
|
export * from '../generated-wrappers/token_spender';
|
||||||
|
export * from '../generated-wrappers/transform_erc20';
|
||||||
export * from '../generated-wrappers/weth_transformer';
|
export * from '../generated-wrappers/weth_transformer';
|
||||||
export * from '../generated-wrappers/zero_ex';
|
export * from '../generated-wrappers/zero_ex';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { blockchainTests, constants, expect, randomAddress, verifyEventsFromLogs } from '@0x/contracts-test-utils';
|
import { blockchainTests, constants, expect, randomAddress, verifyEventsFromLogs } from '@0x/contracts-test-utils';
|
||||||
import { BigNumber, hexUtils, OwnableRevertErrors, ZeroExRevertErrors } from '@0x/utils';
|
import { BigNumber, hexUtils, OwnableRevertErrors, ZeroExRevertErrors } from '@0x/utils';
|
||||||
|
|
||||||
|
import { ZeroExContract } from '../../src/wrappers';
|
||||||
import { artifacts } from '../artifacts';
|
import { artifacts } from '../artifacts';
|
||||||
import { initialMigrateAsync } from '../utils/migration';
|
import { initialMigrateAsync } from '../utils/migration';
|
||||||
import {
|
import {
|
||||||
@ -9,7 +10,6 @@ import {
|
|||||||
ITestSimpleFunctionRegistryFeatureContract,
|
ITestSimpleFunctionRegistryFeatureContract,
|
||||||
TestSimpleFunctionRegistryFeatureImpl1Contract,
|
TestSimpleFunctionRegistryFeatureImpl1Contract,
|
||||||
TestSimpleFunctionRegistryFeatureImpl2Contract,
|
TestSimpleFunctionRegistryFeatureImpl2Contract,
|
||||||
ZeroExContract,
|
|
||||||
} from '../wrappers';
|
} from '../wrappers';
|
||||||
|
|
||||||
blockchainTests.resets('SimpleFunctionRegistry feature', env => {
|
blockchainTests.resets('SimpleFunctionRegistry feature', env => {
|
||||||
|
@ -7,15 +7,11 @@ import {
|
|||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { BigNumber, hexUtils, StringRevertError, ZeroExRevertErrors } from '@0x/utils';
|
import { BigNumber, hexUtils, StringRevertError, ZeroExRevertErrors } from '@0x/utils';
|
||||||
|
|
||||||
|
import { TokenSpenderContract, ZeroExContract } from '../../src/wrappers';
|
||||||
import { artifacts } from '../artifacts';
|
import { artifacts } from '../artifacts';
|
||||||
import { abis } from '../utils/abis';
|
import { abis } from '../utils/abis';
|
||||||
import { fullMigrateAsync } from '../utils/migration';
|
import { fullMigrateAsync } from '../utils/migration';
|
||||||
import {
|
import { TestTokenSpenderERC20TokenContract, TestTokenSpenderERC20TokenEvents } from '../wrappers';
|
||||||
TestTokenSpenderERC20TokenContract,
|
|
||||||
TestTokenSpenderERC20TokenEvents,
|
|
||||||
TokenSpenderContract,
|
|
||||||
ZeroExContract,
|
|
||||||
} from '../wrappers';
|
|
||||||
|
|
||||||
blockchainTests.resets('TokenSpender feature', env => {
|
blockchainTests.resets('TokenSpender feature', env => {
|
||||||
let zeroEx: ZeroExContract;
|
let zeroEx: ZeroExContract;
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
import { ETH_TOKEN_ADDRESS } from '@0x/order-utils';
|
import { ETH_TOKEN_ADDRESS } from '@0x/order-utils';
|
||||||
import { AbiEncoder, hexUtils, OwnableRevertErrors, ZeroExRevertErrors } from '@0x/utils';
|
import { AbiEncoder, hexUtils, OwnableRevertErrors, ZeroExRevertErrors } from '@0x/utils';
|
||||||
|
|
||||||
|
import { TransformERC20Contract, ZeroExContract } from '../../src/wrappers';
|
||||||
import { artifacts } from '../artifacts';
|
import { artifacts } from '../artifacts';
|
||||||
import { abis } from '../utils/abis';
|
import { abis } from '../utils/abis';
|
||||||
import { fullMigrateAsync } from '../utils/migration';
|
import { fullMigrateAsync } from '../utils/migration';
|
||||||
@ -20,9 +21,7 @@ import {
|
|||||||
TestMintableERC20TokenContract,
|
TestMintableERC20TokenContract,
|
||||||
TestMintTokenERC20TransformerContract,
|
TestMintTokenERC20TransformerContract,
|
||||||
TestMintTokenERC20TransformerEvents,
|
TestMintTokenERC20TransformerEvents,
|
||||||
TransformERC20Contract,
|
|
||||||
TransformERC20Events,
|
TransformERC20Events,
|
||||||
ZeroExContract,
|
|
||||||
} from '../wrappers';
|
} from '../wrappers';
|
||||||
|
|
||||||
blockchainTests.resets('TransformERC20 feature', env => {
|
blockchainTests.resets('TransformERC20 feature', env => {
|
||||||
|
@ -1,130 +1,10 @@
|
|||||||
import { BaseContract } from '@0x/base-contract';
|
export {
|
||||||
import { SupportedProvider } from '@0x/subproviders';
|
BootstrapFeatures,
|
||||||
import { TxData } from 'ethereum-types';
|
deployBootstrapFeaturesAsync,
|
||||||
import * as _ from 'lodash';
|
deployFullFeaturesAsync,
|
||||||
|
initialMigrateAsync,
|
||||||
import { artifacts } from '../artifacts';
|
fullMigrateAsync,
|
||||||
import {
|
toFeatureAdddresses,
|
||||||
FullMigrationContract,
|
FullMigrationOpts,
|
||||||
InitialMigrationContract,
|
FullFeatures,
|
||||||
OwnableContract,
|
} from '../../src/migration';
|
||||||
SimpleFunctionRegistryContract,
|
|
||||||
TokenSpenderContract,
|
|
||||||
TransformERC20Contract,
|
|
||||||
ZeroExContract,
|
|
||||||
} from '../wrappers';
|
|
||||||
|
|
||||||
// tslint:disable: completed-docs
|
|
||||||
|
|
||||||
export interface BootstrapFeatures {
|
|
||||||
registry: SimpleFunctionRegistryContract;
|
|
||||||
ownable: OwnableContract;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function deployBootstrapFeaturesAsync(
|
|
||||||
provider: SupportedProvider,
|
|
||||||
txDefaults: Partial<TxData>,
|
|
||||||
features: Partial<BootstrapFeatures> = {},
|
|
||||||
): Promise<BootstrapFeatures> {
|
|
||||||
return {
|
|
||||||
registry:
|
|
||||||
features.registry ||
|
|
||||||
(await SimpleFunctionRegistryContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.SimpleFunctionRegistry,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
)),
|
|
||||||
ownable:
|
|
||||||
features.ownable ||
|
|
||||||
(await OwnableContract.deployFrom0xArtifactAsync(artifacts.Ownable, provider, txDefaults, artifacts)),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function initialMigrateAsync(
|
|
||||||
owner: string,
|
|
||||||
provider: SupportedProvider,
|
|
||||||
txDefaults: Partial<TxData>,
|
|
||||||
features: Partial<BootstrapFeatures> = {},
|
|
||||||
): Promise<ZeroExContract> {
|
|
||||||
const _features = await deployBootstrapFeaturesAsync(provider, txDefaults, features);
|
|
||||||
const migrator = await InitialMigrationContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.InitialMigration,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
txDefaults.from as string,
|
|
||||||
);
|
|
||||||
const deployCall = migrator.deploy(owner, toFeatureAdddresses(_features));
|
|
||||||
const zeroEx = new ZeroExContract(await deployCall.callAsync(), provider, {});
|
|
||||||
await deployCall.awaitTransactionSuccessAsync();
|
|
||||||
return zeroEx;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FullFeatures extends BootstrapFeatures {
|
|
||||||
tokenSpender: TokenSpenderContract;
|
|
||||||
transformERC20: TransformERC20Contract;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FullMigrationOpts {
|
|
||||||
transformerDeployer: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function deployFullFeaturesAsync(
|
|
||||||
provider: SupportedProvider,
|
|
||||||
txDefaults: Partial<TxData>,
|
|
||||||
features: Partial<FullFeatures> = {},
|
|
||||||
): Promise<FullFeatures> {
|
|
||||||
return {
|
|
||||||
...(await deployBootstrapFeaturesAsync(provider, txDefaults)),
|
|
||||||
tokenSpender:
|
|
||||||
features.tokenSpender ||
|
|
||||||
(await TokenSpenderContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.TokenSpender,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
)),
|
|
||||||
transformERC20:
|
|
||||||
features.transformERC20 ||
|
|
||||||
(await TransformERC20Contract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.TransformERC20,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
)),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function fullMigrateAsync(
|
|
||||||
owner: string,
|
|
||||||
provider: SupportedProvider,
|
|
||||||
txDefaults: Partial<TxData>,
|
|
||||||
features: Partial<FullFeatures> = {},
|
|
||||||
opts: Partial<FullMigrationOpts> = {},
|
|
||||||
): Promise<ZeroExContract> {
|
|
||||||
const _features = await deployFullFeaturesAsync(provider, txDefaults, features);
|
|
||||||
const migrator = await FullMigrationContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.FullMigration,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
txDefaults.from as string,
|
|
||||||
);
|
|
||||||
const _opts = {
|
|
||||||
transformerDeployer: txDefaults.from as string,
|
|
||||||
...opts,
|
|
||||||
};
|
|
||||||
const deployCall = migrator.deploy(owner, toFeatureAdddresses(_features), _opts);
|
|
||||||
const zeroEx = new ZeroExContract(await deployCall.callAsync(), provider, {});
|
|
||||||
await deployCall.awaitTransactionSuccessAsync();
|
|
||||||
return zeroEx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tslint:disable:space-before-function-parent one-line
|
|
||||||
export function toFeatureAdddresses<T extends BootstrapFeatures | FullFeatures | (BootstrapFeatures & FullFeatures)>(
|
|
||||||
features: T,
|
|
||||||
): { [name in keyof T]: string } {
|
|
||||||
// TS can't figure this out.
|
|
||||||
return _.mapValues(features, (c: BaseContract) => c.address) as any;
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { blockchainTests, constants, expect, verifyEventsFromLogs } from '@0x/contracts-test-utils';
|
import { blockchainTests, constants, expect, verifyEventsFromLogs } from '@0x/contracts-test-utils';
|
||||||
import { BigNumber, ZeroExRevertErrors } from '@0x/utils';
|
import { BigNumber, ZeroExRevertErrors } from '@0x/utils';
|
||||||
|
|
||||||
|
import { ZeroExContract } from '../src/wrappers';
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
import { artifacts } from './artifacts';
|
||||||
import { initialMigrateAsync } from './utils/migration';
|
import { initialMigrateAsync } from './utils/migration';
|
||||||
import {
|
import {
|
||||||
@ -9,7 +11,6 @@ import {
|
|||||||
ISimpleFunctionRegistryContract,
|
ISimpleFunctionRegistryContract,
|
||||||
TestZeroExFeatureContract,
|
TestZeroExFeatureContract,
|
||||||
TestZeroExFeatureEvents,
|
TestZeroExFeatureEvents,
|
||||||
ZeroExContract,
|
|
||||||
} from './wrappers';
|
} from './wrappers';
|
||||||
|
|
||||||
blockchainTests.resets('ZeroEx contract', env => {
|
blockchainTests.resets('ZeroEx contract', env => {
|
||||||
|
@ -13,7 +13,11 @@
|
|||||||
"generated-artifacts/ITokenSpender.json",
|
"generated-artifacts/ITokenSpender.json",
|
||||||
"generated-artifacts/ITransformERC20.json",
|
"generated-artifacts/ITransformERC20.json",
|
||||||
"generated-artifacts/InitialMigration.json",
|
"generated-artifacts/InitialMigration.json",
|
||||||
|
"generated-artifacts/Ownable.json",
|
||||||
"generated-artifacts/PayTakerTransformer.json",
|
"generated-artifacts/PayTakerTransformer.json",
|
||||||
|
"generated-artifacts/SimpleFunctionRegistry.json",
|
||||||
|
"generated-artifacts/TokenSpender.json",
|
||||||
|
"generated-artifacts/TransformERC20.json",
|
||||||
"generated-artifacts/WethTransformer.json",
|
"generated-artifacts/WethTransformer.json",
|
||||||
"generated-artifacts/ZeroEx.json",
|
"generated-artifacts/ZeroEx.json",
|
||||||
"test/generated-artifacts/AffiliateFeeTransformer.json",
|
"test/generated-artifacts/AffiliateFeeTransformer.json",
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "4.11.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Update ganache snapshot Exchange Proxy addresses",
|
||||||
|
"pr": 2612
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "4.10.0",
|
"version": "4.10.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -209,14 +209,14 @@
|
|||||||
"maximumGasPrice": "0x0000000000000000000000000000000000000000",
|
"maximumGasPrice": "0x0000000000000000000000000000000000000000",
|
||||||
"dexForwarderBridge": "0x0000000000000000000000000000000000000000",
|
"dexForwarderBridge": "0x0000000000000000000000000000000000000000",
|
||||||
"multiBridge": "0x0000000000000000000000000000000000000000",
|
"multiBridge": "0x0000000000000000000000000000000000000000",
|
||||||
"exchangeProxyGovernor": "0x618f9c67ce7bf1a50afa1e7e0238422601b0ff6e",
|
"exchangeProxyGovernor": "0x0000000000000000000000000000000000000000",
|
||||||
"exchangeProxy": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
|
"exchangeProxy": "0x4b8ce0fa221284de4aaa09be3e7bf6193444b786",
|
||||||
"exchangeProxyAllowanceTarget": "0xf740b67da229f2f10bcbd38a7979992fcc71b8eb",
|
"exchangeProxyAllowanceTarget": "0xd6724bf180441a89d08ea3aeded2c995180b9a04",
|
||||||
"exchangeProxyTransformerDeployer": "0x80a36559ab9a497fb658325ed771a584eb0f13da",
|
"exchangeProxyTransformerDeployer": "0x5409ed021d9299bf6814279a6a1411a7e866a631",
|
||||||
"transformers": {
|
"transformers": {
|
||||||
"wethTransformer": "0x7bab5f7299e1ca123bb44eb71e6c89be7e558cc8",
|
"wethTransformer": "0xb125995f5a4766c451cd8c34c4f5cac89b724571",
|
||||||
"payTakerTransformer": "0xe8c07a119452b55eee2f999478aab97f3656d841",
|
"payTakerTransformer": "0x10a736a7b223f1fe1050264249d1abb975741e75",
|
||||||
"fillQuoteTransformer": "0x9b81a08ef144e7aa4925f7fd77da1e1b3990e59a"
|
"fillQuoteTransformer": "0x33def1aa867be09809f3a01ce41d5ec1888846c9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "6.4.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add Exchange Proxy migration.",
|
||||||
|
"pr": 2612
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -83,6 +83,7 @@
|
|||||||
"@0x/contracts-multisig": "^4.1.6",
|
"@0x/contracts-multisig": "^4.1.6",
|
||||||
"@0x/contracts-staking": "^2.0.13",
|
"@0x/contracts-staking": "^2.0.13",
|
||||||
"@0x/contracts-utils": "^4.5.0",
|
"@0x/contracts-utils": "^4.5.0",
|
||||||
|
"@0x/contracts-zero-ex": "^0.1.1",
|
||||||
"@0x/sol-compiler": "^4.1.0",
|
"@0x/sol-compiler": "^4.1.0",
|
||||||
"@0x/subproviders": "^6.1.0",
|
"@0x/subproviders": "^6.1.0",
|
||||||
"@0x/typescript-typings": "^5.1.0",
|
"@0x/typescript-typings": "^5.1.0",
|
||||||
|
@ -29,6 +29,14 @@ import {
|
|||||||
TestStakingContract,
|
TestStakingContract,
|
||||||
ZrxVaultContract,
|
ZrxVaultContract,
|
||||||
} from '@0x/contracts-staking';
|
} from '@0x/contracts-staking';
|
||||||
|
import {
|
||||||
|
artifacts as exchangeProxyArtifacts,
|
||||||
|
FillQuoteTransformerContract,
|
||||||
|
fullMigrateAsync as fullMigrateExchangeProxyAsync,
|
||||||
|
ITokenSpenderContract,
|
||||||
|
PayTakerTransformerContract,
|
||||||
|
WethTransformerContract,
|
||||||
|
} from '@0x/contracts-zero-ex';
|
||||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||||
import { BigNumber, providerUtils } from '@0x/utils';
|
import { BigNumber, providerUtils } from '@0x/utils';
|
||||||
import { SupportedProvider, TxData } from 'ethereum-types';
|
import { SupportedProvider, TxData } from 'ethereum-types';
|
||||||
@ -47,6 +55,7 @@ const allArtifacts = {
|
|||||||
...forwarderArtifacts,
|
...forwarderArtifacts,
|
||||||
...stakingArtifacts,
|
...stakingArtifacts,
|
||||||
...erc20BridgeSamplerArtifacts,
|
...erc20BridgeSamplerArtifacts,
|
||||||
|
...exchangeProxyArtifacts,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { NULL_ADDRESS } = constants;
|
const { NULL_ADDRESS } = constants;
|
||||||
@ -292,6 +301,35 @@ export async function runMigrationsAsync(
|
|||||||
devUtils.address,
|
devUtils.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Exchange Proxy //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const exchangeProxy = await fullMigrateExchangeProxyAsync(txDefaults.from, provider, txDefaults);
|
||||||
|
const allowanceTargetAddress = await new ITokenSpenderContract(exchangeProxy.address, provider, txDefaults)
|
||||||
|
.getAllowanceTarget()
|
||||||
|
.callAsync();
|
||||||
|
|
||||||
|
// Deploy transformers.
|
||||||
|
const fillQuoteTransformer = await FillQuoteTransformerContract.deployFrom0xArtifactAsync(
|
||||||
|
exchangeProxyArtifacts.FillQuoteTransformer,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
allArtifacts,
|
||||||
|
exchange.address,
|
||||||
|
);
|
||||||
|
const payTakerTransformer = await PayTakerTransformerContract.deployFrom0xArtifactAsync(
|
||||||
|
exchangeProxyArtifacts.PayTakerTransformer,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
allArtifacts,
|
||||||
|
);
|
||||||
|
const wethTransformer = await WethTransformerContract.deployFrom0xArtifactAsync(
|
||||||
|
exchangeProxyArtifacts.WethTransformer,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
allArtifacts,
|
||||||
|
etherToken.address,
|
||||||
|
);
|
||||||
|
|
||||||
const contractAddresses = {
|
const contractAddresses = {
|
||||||
erc20Proxy: erc20Proxy.address,
|
erc20Proxy: erc20Proxy.address,
|
||||||
erc721Proxy: erc721Proxy.address,
|
erc721Proxy: erc721Proxy.address,
|
||||||
@ -327,13 +365,13 @@ export async function runMigrationsAsync(
|
|||||||
dexForwarderBridge: NULL_ADDRESS,
|
dexForwarderBridge: NULL_ADDRESS,
|
||||||
multiBridge: NULL_ADDRESS,
|
multiBridge: NULL_ADDRESS,
|
||||||
exchangeProxyGovernor: NULL_ADDRESS,
|
exchangeProxyGovernor: NULL_ADDRESS,
|
||||||
exchangeProxy: NULL_ADDRESS,
|
exchangeProxy: exchangeProxy.address,
|
||||||
exchangeProxyAllowanceTarget: NULL_ADDRESS,
|
exchangeProxyAllowanceTarget: allowanceTargetAddress,
|
||||||
exchangeProxyTransformerDeployer: NULL_ADDRESS,
|
exchangeProxyTransformerDeployer: txDefaults.from,
|
||||||
transformers: {
|
transformers: {
|
||||||
wethTransformer: NULL_ADDRESS,
|
wethTransformer: wethTransformer.address,
|
||||||
payTakerTransformer: NULL_ADDRESS,
|
payTakerTransformer: payTakerTransformer.address,
|
||||||
fillQuoteTransformer: NULL_ADDRESS,
|
fillQuoteTransformer: fillQuoteTransformer.address,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return contractAddresses;
|
return contractAddresses;
|
||||||
|
@ -19,6 +19,6 @@ describe('addresses', () => {
|
|||||||
};
|
};
|
||||||
const migrationAddresses = await runMigrationsAsync(provider, txDefaults);
|
const migrationAddresses = await runMigrationsAsync(provider, txDefaults);
|
||||||
const expectedAddresses = getContractAddressesForChainOrThrow(ChainId.Ganache);
|
const expectedAddresses = getContractAddressesForChainOrThrow(ChainId.Ganache);
|
||||||
expect(migrationAddresses).to.include(expectedAddresses);
|
expect(migrationAddresses).to.deep.eq(expectedAddresses);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user