aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts11
-rw-r--r--packages/contracts/test/ether_token.ts53
-rw-r--r--packages/contracts/test/exchange/core.ts63
-rw-r--r--packages/contracts/test/exchange/dispatcher.ts29
-rw-r--r--packages/contracts/test/exchange/libs.ts2
-rw-r--r--packages/contracts/test/exchange/match_orders.ts163
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts2
-rw-r--r--packages/contracts/test/exchange/transactions.ts12
-rw-r--r--packages/contracts/test/exchange/wrapper.ts37
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts2
-rw-r--r--packages/contracts/test/multi_sig_with_time_lock.ts29
-rw-r--r--packages/contracts/test/token_registry.ts3
-rw-r--r--packages/contracts/test/tutorials/arbitrage.ts4
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts50
-rw-r--r--packages/contracts/test/utils/match_order_tester.ts2
-rw-r--r--packages/contracts/test/zrx_token.ts56
16 files changed, 251 insertions, 267 deletions
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index 0f3080c99..4ee38db80 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -1,4 +1,3 @@
-import { ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -37,8 +36,6 @@ describe('Asset Transfer Proxies', () => {
let erc721Wrapper: ERC721Wrapper;
let erc721MakerTokenId: BigNumber;
- let zeroEx: ZeroEx;
-
before(async () => {
await blockchainLifecycle.startAsync();
});
@@ -73,10 +70,6 @@ describe('Asset Transfer Proxies', () => {
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
-
- zeroEx = new ZeroEx(provider, {
- networkId: constants.TESTRPC_NETWORK_ID,
- });
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -200,7 +193,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: exchangeAddress },
);
- const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const newBalances = await erc20Wrapper.getBalancesAsync();
expect(res.logs.length).to.equal(numTransfers);
@@ -383,7 +376,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: exchangeAddress },
);
- const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(res.logs.length).to.equal(numTransfers);
const newOwnerMakerAssetA = await erc721Token.ownerOf.callAsync(makerTokenIdA);
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts
index 4c647bbc7..9b04dd187 100644
--- a/packages/contracts/test/ether_token.ts
+++ b/packages/contracts/test/ether_token.ts
@@ -1,4 +1,4 @@
-import { ContractWrappersError, ZeroEx } from '0x.js';
+import { ContractWrappers, ContractWrappersError } from '@0xproject/contract-wrappers';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -17,8 +17,8 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('EtherToken', () => {
let account: string;
- const gasPrice = ZeroEx.toBaseUnitAmount(new BigNumber(20), 9);
- let zeroEx: ZeroEx;
+ const gasPrice = Web3Wrapper.toBaseUnitAmount(new BigNumber(20), 9);
+ let contractWrappers: ContractWrappers;
let etherTokenAddress: string;
before(async () => {
@@ -33,7 +33,7 @@ describe('EtherToken', () => {
const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, txDefaults);
etherTokenAddress = etherToken.address;
- zeroEx = new ZeroEx(provider, {
+ contractWrappers = new ContractWrappers(provider, {
gasPrice,
networkId: constants.TESTRPC_NETWORK_ID,
});
@@ -49,23 +49,23 @@ describe('EtherToken', () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
const ethToDeposit = initEthBalance.plus(1);
- return expect(zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account)).to.be.rejectedWith(
- ContractWrappersError.InsufficientEthBalanceForDeposit,
- );
+ return expect(
+ contractWrappers.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account),
+ ).to.be.rejectedWith(ContractWrappersError.InsufficientEthBalanceForDeposit);
});
it('should convert deposited Ether to wrapped Ether tokens', async () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
+ const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
- const txHash = await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const txHash = await contractWrappers.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
+ const receipt = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
+ const finalEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas)));
expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit));
@@ -74,29 +74,34 @@ describe('EtherToken', () => {
describe('withdraw', () => {
it('should throw if caller attempts to withdraw greater than caller balance', async () => {
- const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
+ const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
const ethTokensToWithdraw = initEthTokenBalance.plus(1);
return expect(
- zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account),
+ contractWrappers.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account),
).to.be.rejectedWith(ContractWrappersError.InsufficientWEthBalanceForWithdrawal);
});
it('should convert ether tokens to ether with sufficient balance', async () => {
const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
- await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
- const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
+ await contractWrappers.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
+ const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
const ethTokensToWithdraw = initEthTokenBalance;
expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0);
- const txHash = await zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account, {
- gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS,
- });
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const txHash = await contractWrappers.etherToken.withdrawAsync(
+ etherTokenAddress,
+ ethTokensToWithdraw,
+ account,
+ {
+ gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS,
+ },
+ );
+ const receipt = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
+ const finalEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
expect(finalEthBalance).to.be.bignumber.equal(
initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)),
@@ -108,9 +113,9 @@ describe('EtherToken', () => {
describe('fallback', () => {
it('should convert sent ether to ether tokens', async () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
+ const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
- const ethToDeposit = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
+ const ethToDeposit = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18);
const txHash = await web3Wrapper.sendTransactionAsync({
from: account,
@@ -119,11 +124,11 @@ describe('EtherToken', () => {
gasPrice,
});
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const receipt = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
+ const finalEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas)));
expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit));
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 1edd44aff..f1d9a4156 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -1,6 +1,7 @@
-import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { LogWithDecodedArgs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import 'make-promises-safe';
@@ -59,8 +60,6 @@ describe('Exchange core', () => {
let defaultMakerAssetAddress: string;
let defaultTakerAssetAddress: string;
- let zeroEx: ZeroEx;
-
before(async () => {
await blockchainLifecycle.startAsync();
});
@@ -91,11 +90,7 @@ describe('Exchange core', () => {
txDefaults,
assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
);
- zeroEx = new ZeroEx(provider, {
- exchangeContractAddress: exchange.address,
- networkId: constants.TESTRPC_NETWORK_ID,
- });
- exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
+ exchangeWrapper = new ExchangeWrapper(exchange, provider);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
@@ -178,8 +173,8 @@ describe('Exchange core', () => {
it('should transfer the correct amounts when makerAssetAmount === takerAssetAmount', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
});
const takerAssetFilledAmountBefore = await exchangeWrapper.getTakerAssetFilledAmountAsync(
@@ -231,8 +226,8 @@ describe('Exchange core', () => {
it('should transfer the correct amounts when makerAssetAmount > takerAssetAmount', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
});
const takerAssetFilledAmountBefore = await exchangeWrapper.getTakerAssetFilledAmountAsync(
@@ -284,8 +279,8 @@ describe('Exchange core', () => {
it('should transfer the correct amounts when makerAssetAmount < takerAssetAmount', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
});
const takerAssetFilledAmountBefore = await exchangeWrapper.getTakerAssetFilledAmountAsync(
@@ -338,8 +333,8 @@ describe('Exchange core', () => {
it('should transfer the correct amounts when taker is specified and order is claimed by taker', async () => {
signedOrder = orderFactory.newSignedOrder({
takerAddress,
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
});
const takerAssetFilledAmountBefore = await exchangeWrapper.getTakerAssetFilledAmountAsync(
@@ -457,8 +452,8 @@ describe('Exchange core', () => {
it('should throw when taker is specified and order is claimed by other', async () => {
signedOrder = orderFactory.newSignedOrder({
takerAddress: feeRecipientAddress,
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
});
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
constants.REVERT,
@@ -467,7 +462,7 @@ describe('Exchange core', () => {
it('should throw if signature is invalid', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
});
const invalidR = ethUtil.sha3('invalidR');
@@ -513,7 +508,7 @@ describe('Exchange core', () => {
it('should throw if maker erc20Balances are too low to fill order', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
@@ -523,7 +518,7 @@ describe('Exchange core', () => {
it('should throw if taker erc20Balances are too low to fill order', async () => {
signedOrder = orderFactory.newSignedOrder({
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
@@ -538,6 +533,9 @@ describe('Exchange core', () => {
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
+ // HACK: `rejectWith` returns a "promise-like" type, but not an actual "Promise", so TSLint
+ // complains, even though we do need to `await` it. So we disable the TSLint error below.
+ // tslint:disable-next-line:await-promise
await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
constants.REVERT,
);
@@ -556,6 +554,9 @@ describe('Exchange core', () => {
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
+ // HACK: `rejectWith` returns a "promise-like" type, but not an actual "Promise", so TSLint
+ // complains, even though we do need to `await` it. So we disable the TSLint error below.
+ // tslint:disable-next-line:await-promise
await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
constants.REVERT,
);
@@ -709,23 +710,23 @@ describe('Exchange core', () => {
erc20Balances = await erc20Wrapper.getBalancesAsync();
const signedOrders = await Promise.all([
orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(9), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(9), 18),
salt: new BigNumber(0),
}),
orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(79), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(79), 18),
salt: new BigNumber(1),
}),
orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(979), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(979), 18),
salt: new BigNumber(2),
}),
orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(7979), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(7979), 18),
salt: new BigNumber(3),
}),
]);
@@ -901,7 +902,7 @@ describe('Exchange core', () => {
const makerAssetId = erc721MakerAssetIds[0];
signedOrder = orderFactory.newSignedOrder({
makerAssetAmount: new BigNumber(1),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
makerAssetData: assetProxyUtils.encodeERC721ProxyData(erc721Token.address, makerAssetId),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultTakerAssetAddress),
});
@@ -941,7 +942,7 @@ describe('Exchange core', () => {
const takerAssetId = erc721TakerAssetIds[0];
signedOrder = orderFactory.newSignedOrder({
takerAssetAmount: new BigNumber(1),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
takerAssetData: assetProxyUtils.encodeERC721ProxyData(erc721Token.address, takerAssetId),
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultMakerAssetAddress),
});
diff --git a/packages/contracts/test/exchange/dispatcher.ts b/packages/contracts/test/exchange/dispatcher.ts
index a1c37d8c8..a2238bd10 100644
--- a/packages/contracts/test/exchange/dispatcher.ts
+++ b/packages/contracts/test/exchange/dispatcher.ts
@@ -1,4 +1,3 @@
-import { ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -83,7 +82,7 @@ describe('AssetProxyDispatcher', () => {
});
describe('registerAssetProxy', () => {
it('should record proxy upon registration', async () => {
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -99,7 +98,7 @@ describe('AssetProxyDispatcher', () => {
it('should be able to record multiple proxies', async () => {
// Record first proxy
- const prevERC20ProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevERC20ProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -112,7 +111,7 @@ describe('AssetProxyDispatcher', () => {
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Record another proxy
- const prevERC721ProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevERC721ProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC721,
@@ -128,7 +127,7 @@ describe('AssetProxyDispatcher', () => {
it('should replace proxy address upon re-registration', async () => {
// Initial registration
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -165,7 +164,7 @@ describe('AssetProxyDispatcher', () => {
it('should throw if registering with incorrect "currentAssetProxyAddress" field', async () => {
// Initial registration
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -177,12 +176,12 @@ describe('AssetProxyDispatcher', () => {
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
- // The following transaction will throw because the currentAddress is no longer ZeroEx.NULL_ADDRESS
+ // The following transaction will throw because the currentAddress is no longer constants.NULL_ADDRESS
return expect(
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
erc20Proxy.address,
- ZeroEx.NULL_ADDRESS,
+ constants.NULL_ADDRESS,
{ from: owner },
),
).to.be.rejectedWith(constants.REVERT);
@@ -190,7 +189,7 @@ describe('AssetProxyDispatcher', () => {
it('should be able to reset proxy address to NULL', async () => {
// Initial registration
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -203,7 +202,7 @@ describe('AssetProxyDispatcher', () => {
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// The following transaction will reset the proxy address
- const newProxyAddress = ZeroEx.NULL_ADDRESS;
+ const newProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -218,7 +217,7 @@ describe('AssetProxyDispatcher', () => {
});
it('should throw if requesting address is not owner', async () => {
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
return expect(
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -230,7 +229,7 @@ describe('AssetProxyDispatcher', () => {
});
it('should throw if attempting to register a proxy to the incorrect id', async () => {
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
return expect(
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC721,
@@ -244,7 +243,7 @@ describe('AssetProxyDispatcher', () => {
describe('getAssetProxy', () => {
it('should return correct address of registered proxy', async () => {
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
@@ -260,14 +259,14 @@ describe('AssetProxyDispatcher', () => {
it('should return NULL address if requesting non-existent proxy', async () => {
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(ZeroEx.NULL_ADDRESS);
+ expect(proxyAddress).to.be.equal(constants.NULL_ADDRESS);
});
});
describe('dispatchTransferFrom', () => {
it('should dispatch transfer to registered proxy', async () => {
// Register ERC20 proxy
- const prevProxyAddress = ZeroEx.NULL_ADDRESS;
+ const prevProxyAddress = constants.NULL_ADDRESS;
await web3Wrapper.awaitTransactionMinedAsync(
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts
index 883de7a12..5c530a9b1 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -1,4 +1,3 @@
-import { ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -35,7 +34,6 @@ describe('Exchange libs', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults);
- const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
const defaultOrderParams = {
...constants.STATIC_ORDER_PARAMS,
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts
index b08b9e763..e732c90db 100644
--- a/packages/contracts/test/exchange/match_orders.ts
+++ b/packages/contracts/test/exchange/match_orders.ts
@@ -1,6 +1,7 @@
-import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { LogWithDecodedArgs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
@@ -76,8 +77,6 @@ describe('matchOrders', () => {
let matchOrderTester: MatchOrderTester;
- let zeroEx: ZeroEx;
-
before(async () => {
await blockchainLifecycle.startAsync();
});
@@ -117,11 +116,7 @@ describe('matchOrders', () => {
txDefaults,
assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
);
- zeroEx = new ZeroEx(provider, {
- exchangeContractAddress: exchange.address,
- networkId: constants.TESTRPC_NETWORK_ID,
- });
- exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
+ exchangeWrapper = new ExchangeWrapper(exchange, provider);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
// Authorize ERC20 and ERC721 trades by exchange
@@ -173,16 +168,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match signedOrderLeft with signedOrderRight
@@ -207,16 +202,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Store original taker balance
@@ -252,16 +247,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(20), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(4), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(20), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(4), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -286,16 +281,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(50), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -320,16 +315,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(50), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -359,8 +354,8 @@ describe('matchOrders', () => {
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(50), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match signedOrderLeft with signedOrderRight2
@@ -389,8 +384,8 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
@@ -398,8 +393,8 @@ describe('matchOrders', () => {
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(50), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -429,8 +424,8 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(50), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
// Match signedOrderLeft2 with signedOrderRight
@@ -462,16 +457,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress,
});
// Match orders
@@ -490,16 +485,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -519,16 +514,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -548,16 +543,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -577,16 +572,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -606,16 +601,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: makerAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: makerAddressRight,
});
// Match orders
@@ -634,16 +629,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Cancel left order
@@ -660,16 +655,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Cancel right order
@@ -686,16 +681,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -716,16 +711,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -746,16 +741,16 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(2), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
@@ -778,14 +773,14 @@ describe('matchOrders', () => {
makerAssetData: assetProxyUtils.encodeERC721ProxyData(defaultERC721AssetAddress, erc721TokenToTransfer),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
makerAssetAmount: new BigNumber(1),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressLeft,
});
const signedOrderRight = orderFactoryRight.newSignedOrder({
makerAddress: makerAddressRight,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20TakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC721ProxyData(defaultERC721AssetAddress, erc721TokenToTransfer),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
takerAssetAmount: new BigNumber(1),
feeRecipientAddress: feeRecipientAddressRight,
});
@@ -812,7 +807,7 @@ describe('matchOrders', () => {
makerAddress: makerAddressLeft,
makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
takerAssetData: assetProxyUtils.encodeERC721ProxyData(defaultERC721AssetAddress, erc721TokenToTransfer),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
takerAssetAmount: new BigNumber(1),
feeRecipientAddress: feeRecipientAddressLeft,
});
@@ -821,7 +816,7 @@ describe('matchOrders', () => {
makerAssetData: assetProxyUtils.encodeERC721ProxyData(defaultERC721AssetAddress, erc721TokenToTransfer),
takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultERC20MakerAssetAddress),
makerAssetAmount: new BigNumber(1),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
feeRecipientAddress: feeRecipientAddressRight,
});
// Match orders
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index d96b9e3fb..91614c666 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -1,4 +1,3 @@
-import { ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -39,7 +38,6 @@ describe('MixinSignatureValidator', () => {
provider,
txDefaults,
);
- const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
const defaultOrderParams = {
...constants.STATIC_ORDER_PARAMS,
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 798c8283b..203c05e53 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -1,5 +1,3 @@
-import { ZeroEx } from '0x.js';
-
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -59,8 +57,6 @@ describe('Exchange transactions', () => {
let defaultMakerTokenAddress: string;
let defaultTakerTokenAddress: string;
- let zeroEx: ZeroEx;
-
before(async () => {
await blockchainLifecycle.startAsync();
});
@@ -83,11 +79,7 @@ describe('Exchange transactions', () => {
txDefaults,
assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
);
- zeroEx = new ZeroEx(provider, {
- exchangeContractAddress: exchange.address,
- networkId: constants.TESTRPC_NETWORK_ID,
- });
- exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
+ exchangeWrapper = new ExchangeWrapper(exchange, provider);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await web3Wrapper.awaitTransactionMinedAsync(
@@ -188,7 +180,7 @@ describe('Exchange transactions', () => {
it('should reset the currentContextAddress', async () => {
await exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
const currentContextAddress = await exchange.currentContextAddress.callAsync();
- expect(currentContextAddress).to.equal(ZeroEx.NULL_ADDRESS);
+ expect(currentContextAddress).to.equal(constants.NULL_ADDRESS);
});
});
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index caaceb460..39f861968 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -1,4 +1,3 @@
-import { ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -54,8 +53,6 @@ describe('Exchange wrappers', () => {
let defaultMakerAssetAddress: string;
let defaultTakerAssetAddress: string;
- let zeroEx: ZeroEx;
-
before(async () => {
await blockchainLifecycle.startAsync();
});
@@ -86,11 +83,7 @@ describe('Exchange wrappers', () => {
txDefaults,
assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
);
- zeroEx = new ZeroEx(provider, {
- exchangeContractAddress: exchange.address,
- networkId: constants.TESTRPC_NETWORK_ID,
- });
- exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
+ exchangeWrapper = new ExchangeWrapper(exchange, provider);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
@@ -131,8 +124,8 @@ describe('Exchange wrappers', () => {
describe('fillOrKillOrder', () => {
it('should transfer the correct amounts', async () => {
const signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
});
const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2);
await exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress, {
@@ -199,8 +192,8 @@ describe('Exchange wrappers', () => {
describe('fillOrderNoThrow', () => {
it('should transfer the correct amounts', async () => {
const signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
});
const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2);
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress, {
@@ -243,7 +236,7 @@ describe('Exchange wrappers', () => {
it('should not change erc20Balances if maker erc20Balances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
});
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -253,7 +246,7 @@ describe('Exchange wrappers', () => {
it('should not change erc20Balances if taker erc20Balances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder({
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
});
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -644,7 +637,7 @@ describe('Exchange wrappers', () => {
});
it('should fill all signedOrders if cannot fill entire takerAssetFillAmount', async () => {
- const takerAssetFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ const takerAssetFillAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
erc20Balances[makerAddress][defaultMakerAssetAddress] = erc20Balances[makerAddress][
defaultMakerAssetAddress
@@ -687,7 +680,7 @@ describe('Exchange wrappers', () => {
return expect(
exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
- takerAssetFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -733,7 +726,7 @@ describe('Exchange wrappers', () => {
});
it('should fill all signedOrders if cannot fill entire takerAssetFillAmount', async () => {
- const takerAssetFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ const takerAssetFillAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
erc20Balances[makerAddress][defaultMakerAssetAddress] = erc20Balances[makerAddress][
defaultMakerAssetAddress
@@ -776,7 +769,7 @@ describe('Exchange wrappers', () => {
return expect(
exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerAssetFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -822,7 +815,7 @@ describe('Exchange wrappers', () => {
});
it('should fill all signedOrders if cannot fill entire makerAssetFillAmount', async () => {
- const makerAssetFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ const makerAssetFillAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
erc20Balances[makerAddress][defaultMakerAssetAddress] = erc20Balances[makerAddress][
defaultMakerAssetAddress
@@ -865,7 +858,7 @@ describe('Exchange wrappers', () => {
return expect(
exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
- makerAssetFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -911,7 +904,7 @@ describe('Exchange wrappers', () => {
});
it('should fill all signedOrders if cannot fill entire takerAssetFillAmount', async () => {
- const takerAssetFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ const takerAssetFillAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
erc20Balances[makerAddress][defaultMakerAssetAddress] = erc20Balances[makerAddress][
defaultMakerAssetAddress
@@ -954,7 +947,7 @@ describe('Exchange wrappers', () => {
return expect(
exchangeWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, {
- makerAssetFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index a468255e9..ce3adbdae 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -1,5 +1,5 @@
-import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import BN = require('bn.js');
diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts
index 3f61005e7..6f18de3e7 100644
--- a/packages/contracts/test/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/multi_sig_with_time_lock.ts
@@ -1,5 +1,5 @@
-import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, web3Factory } from '@0xproject/dev-utils';
+import { LogWithDecodedArgs } from '@0xproject/types';
import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
@@ -20,7 +20,6 @@ const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLock.compilerOutput.abi;
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]);
describe('MultiSigWalletWithTimeLock', () => {
@@ -80,7 +79,10 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [SECONDS_TIME_LOCKED.toNumber()],
};
const txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- const txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
@@ -100,14 +102,17 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [SECONDS_TIME_LOCKED.toNumber()],
};
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- const txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
txId = log.args.transactionId;
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, { from: owners[1] });
- const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(res.logs).to.have.length(2);
const blockNum = await web3Wrapper.getBlockNumberAsync();
@@ -127,7 +132,10 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [SECONDS_TIME_LOCKED.toNumber()],
};
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- const txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
@@ -139,7 +147,7 @@ describe('MultiSigWalletWithTimeLock', () => {
expect(initialSecondsTimeLocked).to.be.equal(0);
txHash = await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] });
- const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(res.logs).to.have.length(2);
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());
@@ -174,7 +182,10 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [newSecondsTimeLocked],
};
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- let txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ let txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
@@ -182,7 +193,7 @@ describe('MultiSigWalletWithTimeLock', () => {
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, {
from: owners[1],
});
- txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ txReceipt = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(txReceipt.logs).to.have.length(2);
});
const newSecondsTimeLocked = 0;
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts
index 308dee8e6..49d4f3901 100644
--- a/packages/contracts/test/token_registry.ts
+++ b/packages/contracts/test/token_registry.ts
@@ -1,4 +1,3 @@
-import { ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber, NULL_BYTES } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -66,7 +65,7 @@ describe('TokenRegistry', () => {
};
const nullToken = {
- address: ZeroEx.NULL_ADDRESS,
+ address: constants.NULL_ADDRESS,
name: '',
symbol: '',
decimals: 0,
diff --git a/packages/contracts/test/tutorials/arbitrage.ts b/packages/contracts/test/tutorials/arbitrage.ts
index 723ddb066..e5787d5b8 100644
--- a/packages/contracts/test/tutorials/arbitrage.ts
+++ b/packages/contracts/test/tutorials/arbitrage.ts
@@ -38,7 +38,7 @@
// let amountGive: BigNumber;
// let makerTokenAmount: BigNumber;
// let takerTokenAmount: BigNumber;
-// const feeRecipient = ZeroEx.NULL_ADDRESS;
+// const feeRecipient = constants.NULL_ADDRESS;
// const INITIAL_BALANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
// const INITIAL_ALLOWANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
@@ -115,7 +115,7 @@
// exchangeContractAddress: exchange.address,
// networkId: constants.TESTRPC_NETWORK_ID,
// });
-// exWrapper = new ExchangeWrapper(exchange, zeroEx);
+// exWrapper = new ExchangeWrapper(exchange, provider);
// makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
// takerTokenAmount = makerTokenAmount;
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index 27b94ead6..e831301e1 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -1,4 +1,4 @@
-import { ZeroEx } from '0x.js';
+import { ContractWrappers } from '@0xproject/contract-wrappers';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -19,7 +19,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('UnlimitedAllowanceToken', () => {
let owner: string;
let spender: string;
- const zeroEx = new ZeroEx(provider, {
+ const contractWrappers = new ContractWrappers(provider, {
networkId: constants.TESTRPC_NETWORK_ID,
});
@@ -60,7 +60,7 @@ describe('UnlimitedAllowanceToken', () => {
});
describe('transfer', () => {
it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const ownerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
return expect(token.transfer.callAsync(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
constants.REVERT,
@@ -69,11 +69,11 @@ describe('UnlimitedAllowanceToken', () => {
it('should transfer balance from sender to receiver', async () => {
const receiver = spender;
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = new BigNumber(1);
- await zeroEx.token.transferAsync(tokenAddress, owner, receiver, amountToTransfer);
- const finalOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const finalReceiverBalance = await zeroEx.token.getBalanceAsync(tokenAddress, receiver);
+ await contractWrappers.token.transferAsync(tokenAddress, owner, receiver, amountToTransfer);
+ const finalOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const finalReceiverBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, receiver);
const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
const expectedFinalReceiverBalance = amountToTransfer;
@@ -91,9 +91,9 @@ describe('UnlimitedAllowanceToken', () => {
describe('transferFrom', () => {
it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const ownerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
+ await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
return expect(
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender,
@@ -102,10 +102,10 @@ describe('UnlimitedAllowanceToken', () => {
});
it('should throw if spender has insufficient allowance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const ownerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance;
- const spenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const spenderAllowance = await contractWrappers.token.getAllowanceAsync(tokenAddress, owner, spender);
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(isSpenderAllowanceInsufficient).to.be.true();
@@ -125,44 +125,44 @@ describe('UnlimitedAllowanceToken', () => {
});
it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ const initSpenderAllowance = contractWrappers.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
+ await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await contractWrappers.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(tokenAddress, owner, spender);
expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
});
it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await contractWrappers.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender);
+ const newOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const newSpenderBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, spender);
expect(newOwnerBalance).to.be.bignumber.equal(0);
expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance);
});
it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await contractWrappers.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(tokenAddress, owner, spender);
expect(newSpenderAllowance).to.be.bignumber.equal(0);
});
});
diff --git a/packages/contracts/test/utils/match_order_tester.ts b/packages/contracts/test/utils/match_order_tester.ts
index ae874e502..43196728c 100644
--- a/packages/contracts/test/utils/match_order_tester.ts
+++ b/packages/contracts/test/utils/match_order_tester.ts
@@ -1,5 +1,5 @@
-import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { LogWithDecodedArgs } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts
index d7658f788..e632364ef 100644
--- a/packages/contracts/test/zrx_token.ts
+++ b/packages/contracts/test/zrx_token.ts
@@ -1,4 +1,4 @@
-import { ZeroEx } from '0x.js';
+import { ContractWrappers } from '@0xproject/contract-wrappers';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -19,7 +19,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('ZRXToken', () => {
let owner: string;
let spender: string;
- let zeroEx: ZeroEx;
+ let contractWrappers: ContractWrappers;
let MAX_UINT: BigNumber;
@@ -36,12 +36,12 @@ describe('ZRXToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];
- zeroEx = new ZeroEx(provider, {
+ contractWrappers = new ContractWrappers(provider, {
networkId: constants.TESTRPC_NETWORK_ID,
});
zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, txDefaults);
zrxAddress = zrxToken.address;
- MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
+ MAX_UINT = contractWrappers.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -59,7 +59,7 @@ describe('ZRXToken', () => {
it('should have a total supply of 1 billion tokens', async () => {
const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync());
const expectedTotalSupply = 1000000000;
- expect(ZeroEx.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply);
+ expect(Web3Wrapper.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply);
});
it('should be named 0x Protocol Token', async () => {
@@ -77,7 +77,7 @@ describe('ZRXToken', () => {
describe('constructor', () => {
it('should initialize owner balance to totalSupply', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
+ const ownerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync());
expect(totalSupply).to.be.bignumber.equal(ownerBalance);
});
@@ -86,11 +86,11 @@ describe('ZRXToken', () => {
describe('transfer', () => {
it('should transfer balance from sender to receiver', async () => {
const receiver = spender;
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = new BigNumber(1);
- await zeroEx.token.transferAsync(zrxAddress, owner, receiver, amountToTransfer);
- const finalOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
- const finalReceiverBalance = await zeroEx.token.getBalanceAsync(zrxAddress, receiver);
+ await contractWrappers.token.transferAsync(zrxAddress, owner, receiver, amountToTransfer);
+ const finalOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const finalReceiverBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, receiver);
const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
const expectedFinalReceiverBalance = amountToTransfer;
@@ -108,9 +108,9 @@ describe('ZRXToken', () => {
describe('transferFrom', () => {
it('should return false if owner has insufficient balance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
+ const ownerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
- await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer, {
+ await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
});
const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, {
@@ -120,10 +120,10 @@ describe('ZRXToken', () => {
});
it('should return false if spender has insufficient allowance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
+ const ownerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = ownerBalance;
- const spenderAllowance = await zeroEx.token.getAllowanceAsync(zrxAddress, owner, spender);
+ const spenderAllowance = await contractWrappers.token.getAllowanceAsync(zrxAddress, owner, spender);
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(isSpenderAllowanceInsufficient).to.be.true();
@@ -142,46 +142,46 @@ describe('ZRXToken', () => {
});
it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = MAX_UINT;
- await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance, {
+ await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance, {
gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
});
- await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
+ await contractWrappers.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(zrxAddress, owner, spender);
+ const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(zrxAddress, owner, spender);
expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
});
it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
- const initSpenderBalance = await zeroEx.token.getBalanceAsync(zrxAddress, spender);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const initSpenderBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, spender);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
+ await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance);
+ await contractWrappers.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
- const newSpenderBalance = await zeroEx.token.getBalanceAsync(zrxAddress, spender);
+ const newOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const newSpenderBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, spender);
expect(newOwnerBalance).to.be.bignumber.equal(0);
expect(newSpenderBalance).to.be.bignumber.equal(initSpenderBalance.plus(initOwnerBalance));
});
it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
+ const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer);
- await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
+ await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer);
+ await contractWrappers.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(zrxAddress, owner, spender);
+ const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(zrxAddress, owner, spender);
expect(newSpenderAllowance).to.be.bignumber.equal(0);
});
});