Pass in WETH address into Forwarder constructor

This commit is contained in:
Amir Bandeali 2019-11-29 15:59:18 -08:00
parent 6beedba957
commit 84b660d2ef
2 changed files with 5 additions and 35 deletions

View File

@ -17,41 +17,12 @@ import { ExchangeContract } from '@0x/contracts-exchange';
import { ForwarderContract } from '@0x/contracts-exchange-forwarder';
import { StakingProxyContract, TestStakingContract, ZrxVaultContract } from '@0x/contracts-staking';
import { Web3ProviderEngine } from '@0x/subproviders';
import { AbiEncoder, BigNumber, providerUtils } from '@0x/utils';
import { MethodAbi, SupportedProvider, TxData } from 'ethereum-types';
import { BigNumber, providerUtils } from '@0x/utils';
import { SupportedProvider, TxData } from 'ethereum-types';
import { constants } from './utils/constants';
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
* version of the 0x protocol.
@ -272,7 +243,7 @@ export async function runMigrationsAsync(
txDefaults,
artifacts,
exchange.address,
encodeERC20AssetData(etherToken.address),
etherToken.address,
);
const contractAddresses = {

View File

@ -221,7 +221,7 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
]);
await submitAndExecuteTransactionAsync(governor, governor.address, batchTransactionData);
const devUtils = await DevUtilsContract.deployFrom0xArtifactAsync(
await DevUtilsContract.deployFrom0xArtifactAsync(
devUtilsArtifacts.DevUtils,
provider,
txDefaults,
@ -238,14 +238,13 @@ export async function runMigrationsAsync(supportedProvider: SupportedProvider, t
chainId,
);
const wethAssetData = await devUtils.encodeERC20AssetData(deployedAddresses.etherToken).callAsync();
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
forwarderArtifacts.Forwarder,
provider,
txDefaults,
forwarderArtifacts,
exchange.address,
wethAssetData,
deployedAddresses.etherToken,
);
await forwarder.approveMakerAssetProxy(deployedAddresses.etherToken).awaitTransactionSuccessAsync();
}