feature(migrations): Add MultiAssetProxy Migration
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"version": "2.4.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added migrations for `MultiAssetProxy` contract",
|
||||
"pr": 1503
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1547225310,
|
||||
"version": "2.3.1",
|
||||
@@ -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
|
||||
}
|
||||
],
|
||||
|
||||
@@ -68,35 +68,6 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
|
||||
secondsRequired,
|
||||
);
|
||||
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
|
||||
from: owner,
|
||||
}),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await erc20Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, {
|
||||
from: owner,
|
||||
}),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
|
||||
from: owner,
|
||||
}),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await erc721Proxy.transferOwnership.sendTransactionAsync(assetProxyOwner.address, {
|
||||
from: owner,
|
||||
}),
|
||||
);
|
||||
|
||||
// Register the Asset Proxies to the Exchange
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await exchange.registerAssetProxy.sendTransactionAsync(erc20Proxy.address),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await exchange.registerAssetProxy.sendTransactionAsync(erc721Proxy.address),
|
||||
);
|
||||
|
||||
// Dummy ERC20 tokens
|
||||
for (const token of erc20TokenInfo) {
|
||||
const totalSupply = new BigNumber(1000000000000000000000000000);
|
||||
@@ -122,6 +93,46 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
|
||||
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.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, {
|
||||
from: owner,
|
||||
}),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
|
||||
from: owner,
|
||||
}),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, {
|
||||
from: owner,
|
||||
}),
|
||||
);
|
||||
|
||||
// Register the Asset Proxies to the Exchange
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await exchange.registerAssetProxy.sendTransactionAsync(erc20Proxy.address),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await exchange.registerAssetProxy.sendTransactionAsync(erc721Proxy.address),
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await exchange.registerAssetProxy.sendTransactionAsync(multiAssetProxy.address),
|
||||
);
|
||||
|
||||
// Forwarder
|
||||
const forwarder = await wrappers.ForwarderContract.deployFrom0xArtifactAsync(
|
||||
artifacts.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;
|
||||
|
||||
Reference in New Issue
Block a user