diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-04-11 08:53:34 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:17 +0800 |
commit | 78d81f193f3b9358ab86819f83c76b8bcd52a9c9 (patch) | |
tree | 6f3532ebbf6ed2bc3d07747ba442ec77d4d9ebe3 /packages/contracts/test/exchange/helpers.ts | |
parent | b9e0cd4512e6c7cd7584961df6ba106541826836 (diff) | |
download | dexon-sol-tools-78d81f193f3b9358ab86819f83c76b8bcd52a9c9.tar dexon-sol-tools-78d81f193f3b9358ab86819f83c76b8bcd52a9c9.tar.gz dexon-sol-tools-78d81f193f3b9358ab86819f83c76b8bcd52a9c9.tar.bz2 dexon-sol-tools-78d81f193f3b9358ab86819f83c76b8bcd52a9c9.tar.lz dexon-sol-tools-78d81f193f3b9358ab86819f83c76b8bcd52a9c9.tar.xz dexon-sol-tools-78d81f193f3b9358ab86819f83c76b8bcd52a9c9.tar.zst dexon-sol-tools-78d81f193f3b9358ab86819f83c76b8bcd52a9c9.zip |
Asset Proxy Dispatcher
Diffstat (limited to 'packages/contracts/test/exchange/helpers.ts')
-rw-r--r-- | packages/contracts/test/exchange/helpers.ts | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts index 4fa55efa1..37e53630e 100644 --- a/packages/contracts/test/exchange/helpers.ts +++ b/packages/contracts/test/exchange/helpers.ts @@ -6,11 +6,16 @@ import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange'; +import { + encodeERC20ProxyMetadata, + encodeERC20ProxyMetadata_V1, + encodeERC721ProxyMetadata, +} from '../../src/utils/asset_proxy_utils'; import { constants } from '../../src/utils/constants'; import { ExchangeWrapper } from '../../src/utils/exchange_wrapper'; import { OrderFactory } from '../../src/utils/order_factory'; import { orderUtils } from '../../src/utils/order_utils'; -import { ContractName, SignedOrder } from '../../src/utils/types'; +import { AssetProxyId, ContractName, SignedOrder } from '../../src/utils/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; import { provider, web3Wrapper } from '../utils/web3_wrapper'; @@ -23,6 +28,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('Exchange', () => { let makerAddress: string; let feeRecipientAddress: string; + let assetProxyManagerAddress: string; let signedOrder: SignedOrder; let exchangeWrapper: ExchangeWrapper; @@ -30,9 +36,14 @@ describe('Exchange', () => { before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); - [makerAddress, feeRecipientAddress] = accounts; + [makerAddress, feeRecipientAddress, assetProxyManagerAddress] = accounts; const tokenRegistry = await deployer.deployAsync(ContractName.TokenRegistry); const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy); + const assetProxyDispatcher = await deployer.deployAsync(ContractName.AssetProxyDispatcher); + const erc20TransferProxyV1 = await deployer.deployAsync(ContractName.ERC20TransferProxy_V1, [ + tokenTransferProxy.address, + ]); + const erc20TransferProxy = await deployer.deployAsync(ContractName.ERC20TransferProxy); const [rep, dgd, zrx] = await Promise.all([ deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS), deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS), @@ -40,10 +51,36 @@ describe('Exchange', () => { ]); const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [ zrx.address, - tokenTransferProxy.address, + AssetProxyId.ERC20, + assetProxyDispatcher.address, ]); const exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider); - await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] }); + await assetProxyDispatcher.addAuthorizedAddress.sendTransactionAsync(assetProxyManagerAddress, { + from: accounts[0], + }); + await assetProxyDispatcher.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] }); + await erc20TransferProxyV1.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, { + from: accounts[0], + }); + await erc20TransferProxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, { + from: accounts[0], + }); + await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(erc20TransferProxyV1.address, { + from: accounts[0], + }); + const nilAddress = '0x0000000000000000000000000000000000000000'; + await assetProxyDispatcher.setAssetProxy.sendTransactionAsync( + AssetProxyId.ERC20_V1, + erc20TransferProxyV1.address, + nilAddress, + { from: accounts[0] }, + ); + await assetProxyDispatcher.setAssetProxy.sendTransactionAsync( + AssetProxyId.ERC20, + erc20TransferProxy.address, + nilAddress, + { from: accounts[0] }, + ); const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID }); exchangeWrapper = new ExchangeWrapper(exchange, zeroEx); const defaultOrderParams = { @@ -56,6 +93,8 @@ describe('Exchange', () => { takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18), makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), + makerAssetProxyData: encodeERC20ProxyMetadata(rep.address), + takerAssetProxyData: encodeERC20ProxyMetadata(dgd.address), }; const privateKey = constants.TESTRPC_PRIVATE_KEYS[0]; orderFactory = new OrderFactory(privateKey, defaultOrderParams); |