aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-04-22 07:03:58 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-22 08:31:17 +0800
commit1c94ab7cc3819ee991800a3d2439c02e4083a891 (patch)
tree09fc1bfcebb298e6443e1fb4e33e42b6a9b825d5 /packages/contracts
parentaa3be5198093c5514d8ce237272e390f8be65d65 (diff)
downloaddexon-sol-tools-1c94ab7cc3819ee991800a3d2439c02e4083a891.tar
dexon-sol-tools-1c94ab7cc3819ee991800a3d2439c02e4083a891.tar.gz
dexon-sol-tools-1c94ab7cc3819ee991800a3d2439c02e4083a891.tar.bz2
dexon-sol-tools-1c94ab7cc3819ee991800a3d2439c02e4083a891.tar.lz
dexon-sol-tools-1c94ab7cc3819ee991800a3d2439c02e4083a891.tar.xz
dexon-sol-tools-1c94ab7cc3819ee991800a3d2439c02e4083a891.tar.zst
dexon-sol-tools-1c94ab7cc3819ee991800a3d2439c02e4083a891.zip
export proxyUtils instead of individual functions
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/src/utils/asset_proxy_utils.ts66
-rw-r--r--packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts8
-rw-r--r--packages/contracts/test/asset_proxy_dispatcher/proxies.ts20
-rw-r--r--packages/contracts/test/exchange/core.ts40
-rw-r--r--packages/contracts/test/exchange/helpers.ts6
-rw-r--r--packages/contracts/test/exchange/wrapper.ts28
6 files changed, 83 insertions, 85 deletions
diff --git a/packages/contracts/src/utils/asset_proxy_utils.ts b/packages/contracts/src/utils/asset_proxy_utils.ts
index da610cbcc..29e50a860 100644
--- a/packages/contracts/src/utils/asset_proxy_utils.ts
+++ b/packages/contracts/src/utils/asset_proxy_utils.ts
@@ -4,37 +4,35 @@ import ethUtil = require('ethereumjs-util');
import { AssetProxyId } from './types';
-export function encodeAssetProxyId(assetProxyId: AssetProxyId): Buffer {
- return ethUtil.toBuffer(assetProxyId);
-}
-
-export function encodeAddress(address: string): Buffer {
- if (!ethUtil.isValidAddress(address)) {
- throw new Error(`Invalid Address: ${address}`);
- }
- const encodedAddress = ethUtil.toBuffer(address);
- return encodedAddress;
-}
-
-export function encodeUint256(value: BigNumber): Buffer {
- const formattedValue = new BN(value.toString(10));
- const encodedValue = ethUtil.toBuffer(formattedValue);
- return encodedValue;
-}
-
-export function encodeERC20ProxyData(tokenAddress: string): string {
- const encodedAssetProxyId = encodeAssetProxyId(AssetProxyId.ERC20);
- const encodedAddress = encodeAddress(tokenAddress);
- const encodedMetadata = Buffer.concat([encodedAssetProxyId, encodedAddress]);
- const encodedMetadataHex = ethUtil.bufferToHex(encodedMetadata);
- return encodedMetadataHex;
-}
-
-export function encodeERC721ProxyData(tokenAddress: string, tokenId: BigNumber): string {
- const encodedAssetProxyId = encodeAssetProxyId(AssetProxyId.ERC721);
- const encodedAddress = encodeAddress(tokenAddress);
- const encodedTokenId = encodeUint256(tokenId);
- const encodedMetadata = Buffer.concat([encodedAssetProxyId, encodedAddress, encodedTokenId]);
- const encodedMetadataHex = ethUtil.bufferToHex(encodedMetadata);
- return encodedMetadataHex;
-}
+export const proxyUtils = {
+ encodeAssetProxyId(assetProxyId: AssetProxyId): Buffer {
+ return ethUtil.toBuffer(assetProxyId);
+ },
+ encodeAddress(address: string): Buffer {
+ if (!ethUtil.isValidAddress(address)) {
+ throw new Error(`Invalid Address: ${address}`);
+ }
+ const encodedAddress = ethUtil.toBuffer(address);
+ return encodedAddress;
+ },
+ encodeUint256(value: BigNumber): Buffer {
+ const formattedValue = new BN(value.toString(10));
+ const encodedValue = ethUtil.toBuffer(formattedValue);
+ return encodedValue;
+ },
+ encodeERC20ProxyData(tokenAddress: string): string {
+ const encodedAssetProxyId = proxyUtils.encodeAssetProxyId(AssetProxyId.ERC20);
+ const encodedAddress = proxyUtils.encodeAddress(tokenAddress);
+ const encodedMetadata = Buffer.concat([encodedAssetProxyId, encodedAddress]);
+ const encodedMetadataHex = ethUtil.bufferToHex(encodedMetadata);
+ return encodedMetadataHex;
+ },
+ encodeERC721ProxyData(tokenAddress: string, tokenId: BigNumber): string {
+ const encodedAssetProxyId = proxyUtils.encodeAssetProxyId(AssetProxyId.ERC721);
+ const encodedAddress = proxyUtils.encodeAddress(tokenAddress);
+ const encodedTokenId = proxyUtils.encodeUint256(tokenId);
+ const encodedMetadata = Buffer.concat([encodedAssetProxyId, encodedAddress, encodedTokenId]);
+ const encodedMetadataHex = ethUtil.bufferToHex(encodedMetadata);
+ return encodedMetadataHex;
+ },
+};
diff --git a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
index f54ed6442..48312d4ee 100644
--- a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
+++ b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
@@ -10,7 +10,7 @@ import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/
import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token';
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
-import { encodeERC20ProxyData, encodeERC721ProxyData } from '../../src/utils/asset_proxy_utils';
+import { proxyUtils } from '../../src/utils/asset_proxy_utils';
import { Balances } from '../../src/utils/balances';
import { constants } from '../../src/utils/constants';
import { AssetProxyId, ContractName } from '../../src/utils/types';
@@ -242,7 +242,7 @@ describe('AssetProxyDispatcher', () => {
{ from: owner },
);
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = proxyUtils.encodeERC20ProxyData(zrx.address);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(10);
@@ -265,7 +265,7 @@ describe('AssetProxyDispatcher', () => {
it('should throw if dispatching to unregistered proxy', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = proxyUtils.encodeERC20ProxyData(zrx.address);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(10);
@@ -290,7 +290,7 @@ describe('AssetProxyDispatcher', () => {
{ from: owner },
);
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = proxyUtils.encodeERC20ProxyData(zrx.address);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(10);
diff --git a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
index 2a8b6d567..df585a68d 100644
--- a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
+++ b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
@@ -10,7 +10,7 @@ import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/
import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token';
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
-import { encodeERC20ProxyData, encodeERC721ProxyData } from '../../src/utils/asset_proxy_utils';
+import { proxyUtils } from '../../src/utils/asset_proxy_utils';
import { Balances } from '../../src/utils/balances';
import { constants } from '../../src/utils/constants';
import { AssetProxyId, ContractName } from '../../src/utils/types';
@@ -93,7 +93,7 @@ describe('Asset Transfer Proxies', () => {
describe('Transfer Proxy - ERC20', () => {
it('should successfully transfer tokens', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = proxyUtils.encodeERC20ProxyData(zrx.address);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(10);
@@ -116,7 +116,7 @@ describe('Asset Transfer Proxies', () => {
it('should do nothing if transferring 0 amount of a token', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = proxyUtils.encodeERC20ProxyData(zrx.address);
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(0);
@@ -135,7 +135,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if allowances are too low', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = proxyUtils.encodeERC20ProxyData(zrx.address);
// Create allowance less than transfer amount. Set allowance on proxy.
const allowance = new BigNumber(0);
const transferAmount = new BigNumber(10);
@@ -156,7 +156,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if requesting address is not authorized', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = proxyUtils.encodeERC20ProxyData(zrx.address);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(10);
return expect(
@@ -170,7 +170,7 @@ describe('Asset Transfer Proxies', () => {
describe('Transfer Proxy - ERC721', () => {
it('should successfully transfer tokens', async () => {
// Construct metadata for ERC721 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
+ const encodedProxyMetadata = proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Verify pre-condition
const ownerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(ownerMakerToken).to.be.bignumber.equal(makerAddress);
@@ -191,7 +191,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if transferring 0 amount of a token', async () => {
// Construct metadata for ERC721 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
+ const encodedProxyMetadata = proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Verify pre-condition
const ownerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(ownerMakerToken).to.be.bignumber.equal(makerAddress);
@@ -211,7 +211,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if transferring > 1 amount of a token', async () => {
// Construct metadata for ERC721 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
+ const encodedProxyMetadata = proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Verify pre-condition
const ownerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
expect(ownerMakerToken).to.be.bignumber.equal(makerAddress);
@@ -231,7 +231,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if allowances are too low', async () => {
// Construct metadata for ERC721 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
+ const encodedProxyMetadata = proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Remove transfer approval for makerAddress.
await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, {
from: makerAddress,
@@ -247,7 +247,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if requesting address is not authorized', async () => {
// Construct metadata for ERC721 proxy
- const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
+ const encodedProxyMetadata = proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
return expect(
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index baa157dbc..482eb84e9 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -18,7 +18,7 @@ import {
ExchangeErrorContractEventArgs,
FillContractEventArgs,
} from '../../src/contract_wrappers/generated/exchange';
-import { encodeERC20ProxyData, encodeERC721ProxyData } from '../../src/utils/asset_proxy_utils';
+import { proxyUtils } from '../../src/utils/asset_proxy_utils';
import { Balances } from '../../src/utils/balances';
import { constants } from '../../src/utils/constants';
import { crypto } from '../../src/utils/crypto';
@@ -130,7 +130,7 @@ describe('Exchange', () => {
// Deploy and configure Exchange
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
assetProxyDispatcher.address,
- encodeERC20ProxyData(zrx.address),
+ proxyUtils.encodeERC20ProxyData(zrx.address),
]);
exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
await assetProxyDispatcher.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
@@ -151,8 +151,8 @@ describe('Exchange', () => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
- makerAssetData: encodeERC20ProxyData(defaultMakerTokenAddress),
- takerAssetData: encodeERC20ProxyData(defaultTakerTokenAddress),
+ makerAssetData: proxyUtils.encodeERC20ProxyData(defaultMakerTokenAddress),
+ takerAssetData: proxyUtils.encodeERC20ProxyData(defaultTakerTokenAddress),
};
const privateKey = constants.TESTRPC_PRIVATE_KEYS[0];
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
@@ -829,8 +829,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -854,8 +854,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -876,8 +876,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -898,8 +898,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(2),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -920,8 +920,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(500),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -942,8 +942,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(0),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -963,8 +963,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(1),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC20ProxyData(defaultTakerTokenAddress),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC20ProxyData(defaultTakerTokenAddress),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -1001,8 +1001,8 @@ describe('Exchange', () => {
signedOrder = orderFactory.newSignedOrder({
takerTokenAmount: new BigNumber(1),
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
- makerAssetData: encodeERC20ProxyData(defaultMakerTokenAddress),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC20ProxyData(defaultMakerTokenAddress),
});
// Verify pre-conditions
const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts
index e04153695..430305d8d 100644
--- a/packages/contracts/test/exchange/helpers.ts
+++ b/packages/contracts/test/exchange/helpers.ts
@@ -7,7 +7,7 @@ import ethUtil = require('ethereumjs-util');
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
-import { encodeERC20ProxyData } from '../../src/utils/asset_proxy_utils';
+import { proxyUtils } 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';
@@ -58,8 +58,8 @@ describe('Exchange', () => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
- makerAssetData: encodeERC20ProxyData(rep.address),
- takerAssetData: encodeERC20ProxyData(dgd.address),
+ makerAssetData: proxyUtils.encodeERC20ProxyData(rep.address),
+ takerAssetData: proxyUtils.encodeERC20ProxyData(dgd.address),
};
const privateKey = constants.TESTRPC_PRIVATE_KEYS[0];
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 429c141f6..3023596ae 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -13,7 +13,7 @@ import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c2
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
import { TokenRegistryContract } from '../../src/contract_wrappers/generated/token_registry';
-import { encodeERC20ProxyData, encodeERC721ProxyData } from '../../src/utils/asset_proxy_utils';
+import { proxyUtils } from '../../src/utils/asset_proxy_utils';
import { Balances } from '../../src/utils/balances';
import { constants } from '../../src/utils/constants';
import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
@@ -111,7 +111,7 @@ describe('Exchange', () => {
// Deploy and configure Exchange
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
assetProxyDispatcher.address,
- encodeERC20ProxyData(zrx.address),
+ proxyUtils.encodeERC20ProxyData(zrx.address),
]);
exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
await assetProxyDispatcher.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
@@ -129,8 +129,8 @@ describe('Exchange', () => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
- makerAssetData: encodeERC20ProxyData(defaultMakerTokenAddress),
- takerAssetData: encodeERC20ProxyData(defaultTakerTokenAddress),
+ makerAssetData: proxyUtils.encodeERC20ProxyData(defaultMakerTokenAddress),
+ takerAssetData: proxyUtils.encodeERC20ProxyData(defaultTakerTokenAddress),
};
const privateKey = constants.TESTRPC_PRIVATE_KEYS[0];
@@ -332,7 +332,7 @@ describe('Exchange', () => {
const signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: makerZRXBalance,
makerFee: new BigNumber(1),
- makerAssetData: encodeERC20ProxyData(zrx.address),
+ makerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await dmyBalances.getAsync();
@@ -344,7 +344,7 @@ describe('Exchange', () => {
const signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(makerZRXAllowance),
makerFee: new BigNumber(1),
- makerAssetData: encodeERC20ProxyData(zrx.address),
+ makerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await dmyBalances.getAsync();
@@ -356,7 +356,7 @@ describe('Exchange', () => {
const signedOrder = orderFactory.newSignedOrder({
takerTokenAmount: takerZRXBalance,
takerFee: new BigNumber(1),
- takerAssetData: encodeERC20ProxyData(zrx.address),
+ takerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await dmyBalances.getAsync();
@@ -368,7 +368,7 @@ describe('Exchange', () => {
const signedOrder = orderFactory.newSignedOrder({
takerTokenAmount: new BigNumber(takerZRXAllowance),
takerFee: new BigNumber(1),
- takerAssetData: encodeERC20ProxyData(zrx.address),
+ takerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await dmyBalances.getAsync();
@@ -382,8 +382,8 @@ describe('Exchange', () => {
const signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
- makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
+ makerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, makerTokenId),
+ takerAssetData: proxyUtils.encodeERC721ProxyData(erc721Token.address, takerTokenId),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -689,7 +689,7 @@ describe('Exchange', () => {
it('should throw when an signedOrder does not use the same takerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ takerAssetData: encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({ takerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];
@@ -776,7 +776,7 @@ describe('Exchange', () => {
it('should throw when a signedOrder does not use the same takerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ takerAssetData: encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({ takerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];
@@ -863,7 +863,7 @@ describe('Exchange', () => {
it('should throw when an signedOrder does not use the same makerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ makerAssetData: encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({ makerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];
@@ -950,7 +950,7 @@ describe('Exchange', () => {
it('should throw when a signedOrder does not use the same makerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ makerAssetData: encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({ makerAssetData: proxyUtils.encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];