Pass in WETH address into Forwarder constructor
This commit is contained in:
parent
6beedba957
commit
84b660d2ef
@ -17,41 +17,12 @@ import { ExchangeContract } from '@0x/contracts-exchange';
|
|||||||
import { ForwarderContract } from '@0x/contracts-exchange-forwarder';
|
import { ForwarderContract } from '@0x/contracts-exchange-forwarder';
|
||||||
import { StakingProxyContract, TestStakingContract, ZrxVaultContract } from '@0x/contracts-staking';
|
import { StakingProxyContract, TestStakingContract, ZrxVaultContract } from '@0x/contracts-staking';
|
||||||
import { Web3ProviderEngine } from '@0x/subproviders';
|
import { Web3ProviderEngine } from '@0x/subproviders';
|
||||||
import { AbiEncoder, BigNumber, providerUtils } from '@0x/utils';
|
import { BigNumber, providerUtils } from '@0x/utils';
|
||||||
import { MethodAbi, SupportedProvider, TxData } from 'ethereum-types';
|
import { SupportedProvider, TxData } from 'ethereum-types';
|
||||||
|
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info';
|
import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info';
|
||||||
|
|
||||||
// HACK (xianny): Copied from @0x/order-utils to get rid of circular dependency
|
|
||||||
/**
|
|
||||||
* Encodes an ERC20 token address into a hex encoded assetData string, usable in the makerAssetData or
|
|
||||||
* takerAssetData fields in a 0x order.
|
|
||||||
* @param tokenAddress The ERC20 token address to encode
|
|
||||||
* @return The hex encoded assetData string
|
|
||||||
*/
|
|
||||||
function encodeERC20AssetData(tokenAddress: string): string {
|
|
||||||
const ERC20_METHOD_ABI: MethodAbi = {
|
|
||||||
constant: false,
|
|
||||||
inputs: [
|
|
||||||
{
|
|
||||||
name: 'tokenContract',
|
|
||||||
type: 'address',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
name: 'ERC20Token',
|
|
||||||
outputs: [],
|
|
||||||
payable: false,
|
|
||||||
stateMutability: 'nonpayable',
|
|
||||||
type: 'function',
|
|
||||||
};
|
|
||||||
const encodingRules: AbiEncoder.EncodingRules = { shouldOptimize: true };
|
|
||||||
const abiEncoder = new AbiEncoder.Method(ERC20_METHOD_ABI);
|
|
||||||
const args = [tokenAddress];
|
|
||||||
const assetData = abiEncoder.encode(args, encodingRules);
|
|
||||||
return assetData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and deploys all the contracts that are required for the latest
|
* Creates and deploys all the contracts that are required for the latest
|
||||||
* version of the 0x protocol.
|
* version of the 0x protocol.
|
||||||
@ -272,7 +243,7 @@ export async function runMigrationsAsync(
|
|||||||
txDefaults,
|
txDefaults,
|
||||||
artifacts,
|
artifacts,
|
||||||
exchange.address,
|
exchange.address,
|
||||||
encodeERC20AssetData(etherToken.address),
|
etherToken.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
const contractAddresses = {
|
const contractAddresses = {
|
||||||
|
@ -221,7 +221,7 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
|
|||||||
]);
|
]);
|
||||||
await submitAndExecuteTransactionAsync(governor, governor.address, batchTransactionData);
|
await submitAndExecuteTransactionAsync(governor, governor.address, batchTransactionData);
|
||||||
|
|
||||||
const devUtils = await DevUtilsContract.deployFrom0xArtifactAsync(
|
await DevUtilsContract.deployFrom0xArtifactAsync(
|
||||||
devUtilsArtifacts.DevUtils,
|
devUtilsArtifacts.DevUtils,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
@ -238,14 +238,13 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
|
|||||||
chainId,
|
chainId,
|
||||||
);
|
);
|
||||||
|
|
||||||
const wethAssetData = await devUtils.encodeERC20AssetData(deployedAddresses.etherToken).callAsync();
|
|
||||||
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
|
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
|
||||||
forwarderArtifacts.Forwarder,
|
forwarderArtifacts.Forwarder,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
forwarderArtifacts,
|
forwarderArtifacts,
|
||||||
exchange.address,
|
exchange.address,
|
||||||
wethAssetData,
|
deployedAddresses.etherToken,
|
||||||
);
|
);
|
||||||
await forwarder.approveMakerAssetProxy(deployedAddresses.etherToken).awaitTransactionSuccessAsync();
|
await forwarder.approveMakerAssetProxy(deployedAddresses.etherToken).awaitTransactionSuccessAsync();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user