aboutsummaryrefslogtreecommitdiffstats
path: root/packages/migrations
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2019-01-10 20:12:45 +0800
committerJacob Evans <jacob@dekz.net>2019-01-12 15:49:16 +0800
commite3b3f82c8c48219de70c7bb3f8a0816c98f41ed0 (patch)
tree409c5e7c293dd5bc4e0235d96a24af2b39789a39 /packages/migrations
parent797d7c7878e33ce012259a6a5db5335e9dc838ba (diff)
downloaddexon-sol-tools-e3b3f82c8c48219de70c7bb3f8a0816c98f41ed0.tar
dexon-sol-tools-e3b3f82c8c48219de70c7bb3f8a0816c98f41ed0.tar.gz
dexon-sol-tools-e3b3f82c8c48219de70c7bb3f8a0816c98f41ed0.tar.bz2
dexon-sol-tools-e3b3f82c8c48219de70c7bb3f8a0816c98f41ed0.tar.lz
dexon-sol-tools-e3b3f82c8c48219de70c7bb3f8a0816c98f41ed0.tar.xz
dexon-sol-tools-e3b3f82c8c48219de70c7bb3f8a0816c98f41ed0.tar.zst
dexon-sol-tools-e3b3f82c8c48219de70c7bb3f8a0816c98f41ed0.zip
feature(migrations): Add MultiAssetProxy Migration
Diffstat (limited to 'packages/migrations')
-rw-r--r--packages/migrations/CHANGELOG.json15
-rw-r--r--packages/migrations/src/migration.ts84
2 files changed, 70 insertions, 29 deletions
diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json
index 13aca373b..13a99bb05 100644
--- a/packages/migrations/CHANGELOG.json
+++ b/packages/migrations/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.4.0",
+ "changes": [
+ {
+ "note": "Added migrations for `MultiAssetProxy` contract",
+ "pr": 1503
+ }
+ ]
+ },
+ {
"timestamp": 1547225310,
"version": "2.3.1",
"changes": [
@@ -58,7 +67,8 @@
"version": "2.1.0",
"changes": [
{
- "note": "Export all type declarations used by the public interface, as well as the `ContractAddresses` mapping",
+ "note":
+ "Export all type declarations used by the public interface, as well as the `ContractAddresses` mapping",
"pr": 1301
}
],
@@ -104,7 +114,8 @@
"version": "2.0.0",
"changes": [
{
- "note": "Contract artifacts have been moved to the new @0xproject/contract-artifacts package. v1 migrations have been removed. `runMigrationsAsync` returns the addresses of the contracts that were deployed.",
+ "note":
+ "Contract artifacts have been moved to the new @0xproject/contract-artifacts package. v1 migrations have been removed. `runMigrationsAsync` returns the addresses of the contracts that were deployed.",
"pr": 1105
}
],
diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts
index 99d1719f1..3d97409e6 100644
--- a/packages/migrations/src/migration.ts
+++ b/packages/migrations/src/migration.ts
@@ -68,13 +68,46 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
secondsRequired,
);
+ // Dummy ERC20 tokens
+ for (const token of erc20TokenInfo) {
+ const totalSupply = new BigNumber(1000000000000000000000000000);
+ // tslint:disable-next-line:no-unused-variable
+ const dummyErc20Token = await wrappers.DummyERC20TokenContract.deployFrom0xArtifactAsync(
+ artifacts.DummyERC20Token,
+ provider,
+ txDefaults,
+ token.name,
+ token.symbol,
+ token.decimals,
+ totalSupply,
+ );
+ }
+
+ // ERC721
+ // tslint:disable-next-line:no-unused-variable
+ const cryptoKittieToken = await wrappers.DummyERC721TokenContract.deployFrom0xArtifactAsync(
+ artifacts.DummyERC721Token,
+ provider,
+ txDefaults,
+ erc721TokenInfo[0].name,
+ erc721TokenInfo[0].symbol,
+ );
+
+ const multiAssetProxy = await wrappers.MultiAssetProxyContract.deployFrom0xArtifactAsync(
+ artifacts.MultiAssetProxy,
+ provider,
+ txDefaults,
+ );
+
+ // Note: Perform all setup after contract deployments to have consistent addresses
+ // available in the snapshots
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
from: owner,
}),
);
await web3Wrapper.awaitTransactionSuccessAsync(
- await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, {
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, {
from: owner,
}),
);
@@ -84,7 +117,7 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
}),
);
await web3Wrapper.awaitTransactionSuccessAsync(
- await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, {
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, {
from: owner,
}),
);
@@ -96,30 +129,8 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
await web3Wrapper.awaitTransactionSuccessAsync(
await exchange.registerAssetProxy.sendTransactionAsync(erc721Proxy.address),
);
-
- // Dummy ERC20 tokens
- for (const token of erc20TokenInfo) {
- const totalSupply = new BigNumber(1000000000000000000000000000);
- // tslint:disable-next-line:no-unused-variable
- const dummyErc20Token = await wrappers.DummyERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC20Token,
- provider,
- txDefaults,
- token.name,
- token.symbol,
- token.decimals,
- totalSupply,
- );
- }
-
- // ERC721
- // tslint:disable-next-line:no-unused-variable
- const cryptoKittieToken = await wrappers.DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
- provider,
- txDefaults,
- erc721TokenInfo[0].name,
- erc721TokenInfo[0].symbol,
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await exchange.registerAssetProxy.sendTransactionAsync(multiAssetProxy.address),
);
// Forwarder
@@ -149,6 +160,23 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
exchange.address,
);
+ // Transfer Ownership to the Asset Proxy Owner
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, {
+ from: owner,
+ }),
+ );
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, {
+ from: owner,
+ }),
+ );
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await multiAssetProxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, {
+ from: owner,
+ }),
+ );
+
// Fund the Forwarder with ZRX
const zrxDecimals = await zrxToken.decimals.callAsync();
const zrxForwarderAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5000), zrxDecimals);
@@ -156,7 +184,7 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
await zrxToken.transfer.sendTransactionAsync(forwarder.address, zrxForwarderAmount, txDefaults),
);
- return {
+ const contractAddresses = {
erc20Proxy: erc20Proxy.address,
erc721Proxy: erc721Proxy.address,
zrxToken: zrxToken.address,
@@ -167,6 +195,8 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
orderValidator: orderValidator.address,
dutchAuction: dutchAuction.address,
};
+
+ return contractAddresses;
}
let _cachedContractAddresses: ContractAddresses;