aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-04-24 14:23:01 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-24 14:23:01 +0800
commit27a44f0e77da67dd0b928945135cf28b93cbe87f (patch)
tree58e4c94c12ec718d8638fb1ed8f86a24b787ffbd /packages/contracts
parent32e77753b518e0821d75c404b9dcd16af8f2cd8b (diff)
downloaddexon-sol-tools-27a44f0e77da67dd0b928945135cf28b93cbe87f.tar
dexon-sol-tools-27a44f0e77da67dd0b928945135cf28b93cbe87f.tar.gz
dexon-sol-tools-27a44f0e77da67dd0b928945135cf28b93cbe87f.tar.bz2
dexon-sol-tools-27a44f0e77da67dd0b928945135cf28b93cbe87f.tar.lz
dexon-sol-tools-27a44f0e77da67dd0b928945135cf28b93cbe87f.tar.xz
dexon-sol-tools-27a44f0e77da67dd0b928945135cf28b93cbe87f.tar.zst
dexon-sol-tools-27a44f0e77da67dd0b928945135cf28b93cbe87f.zip
Rename variables, create private validation methods in token wrappers
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/src/utils/erc20_wrapper.ts65
-rw-r--r--packages/contracts/src/utils/erc721_wrapper.ts126
-rw-r--r--packages/contracts/src/utils/types.ts2
-rw-r--r--packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts22
-rw-r--r--packages/contracts/test/asset_proxy_dispatcher/proxies.ts36
-rw-r--r--packages/contracts/test/exchange/core.ts115
-rw-r--r--packages/contracts/test/exchange/wrapper.ts204
-rw-r--r--packages/contracts/test/zrx_token.ts24
8 files changed, 308 insertions, 286 deletions
diff --git a/packages/contracts/src/utils/erc20_wrapper.ts b/packages/contracts/src/utils/erc20_wrapper.ts
index 212a639ff..c2effb617 100644
--- a/packages/contracts/src/utils/erc20_wrapper.ts
+++ b/packages/contracts/src/utils/erc20_wrapper.ts
@@ -14,57 +14,53 @@ export class ERC20Wrapper {
private _contractOwnerAddress: string;
private _deployer: Deployer;
private _provider: Provider;
- private _dummyERC20TokenContracts?: DummyERC20TokenContract[];
- private _erc20ProxyContract?: ERC20ProxyContract;
+ private _dummyTokenContracts?: DummyERC20TokenContract[];
+ private _proxyContract?: ERC20ProxyContract;
constructor(deployer: Deployer, provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._deployer = deployer;
this._provider = provider;
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
}
- public async deployDummyERC20TokensAsync(): Promise<DummyERC20TokenContract[]> {
+ public async deployDummyTokensAsync(): Promise<DummyERC20TokenContract[]> {
const tokenContractInstances = await Promise.all(
- _.map(_.range(constants.NUM_DUMMY_ERC20_TO_DEPLOY), () =>
+ _.times(constants.NUM_DUMMY_ERC20_TO_DEPLOY, () =>
this._deployer.deployAsync(ContractName.DummyERC20Token, constants.DUMMY_ERC20_TOKEN_ARGS),
),
);
- this._dummyERC20TokenContracts = _.map(
+ this._dummyTokenContracts = _.map(
tokenContractInstances,
tokenContractInstance =>
new DummyERC20TokenContract(tokenContractInstance.abi, tokenContractInstance.address, this._provider),
);
- return this._dummyERC20TokenContracts;
+ return this._dummyTokenContracts;
}
- public async deployERC20ProxyAsync(): Promise<ERC20ProxyContract> {
+ public async deployProxyAsync(): Promise<ERC20ProxyContract> {
const proxyContractInstance = await this._deployer.deployAsync(ContractName.ERC20Proxy);
- this._erc20ProxyContract = new ERC20ProxyContract(
+ this._proxyContract = new ERC20ProxyContract(
proxyContractInstance.abi,
proxyContractInstance.address,
this._provider,
);
- return this._erc20ProxyContract;
+ return this._proxyContract;
}
public async setBalancesAndAllowancesAsync() {
- if (_.isUndefined(this._dummyERC20TokenContracts)) {
- throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyERC20TokensAsync"');
- }
- if (_.isUndefined(this._erc20ProxyContract)) {
- throw new Error('ERC20 proxy contract not yet deployed, please call "deployERC20ProxyAsync"');
- }
- const setBalancePromises: any[] = [];
- const setAllowancePromises: any[] = [];
- _.forEach(this._dummyERC20TokenContracts, dummyERC20TokenContract => {
+ this._validateDummyTokenContractsExistOrThrow();
+ this._validateProxyContractExistsOrThrow();
+ const setBalancePromises: Array<Promise<string>> = [];
+ const setAllowancePromises: Array<Promise<string>> = [];
+ _.forEach(this._dummyTokenContracts, dummyTokenContract => {
_.forEach(this._tokenOwnerAddresses, tokenOwnerAddress => {
setBalancePromises.push(
- dummyERC20TokenContract.setBalance.sendTransactionAsync(
+ dummyTokenContract.setBalance.sendTransactionAsync(
tokenOwnerAddress,
constants.INITIAL_ERC20_BALANCE,
{ from: this._contractOwnerAddress },
),
);
setAllowancePromises.push(
- dummyERC20TokenContract.approve.sendTransactionAsync(
- (this._erc20ProxyContract as ERC20ProxyContract).address,
+ dummyTokenContract.approve.sendTransactionAsync(
+ (this._proxyContract as ERC20ProxyContract).address,
constants.INITIAL_ERC20_ALLOWANCE,
{ from: tokenOwnerAddress },
),
@@ -74,18 +70,16 @@ export class ERC20Wrapper {
await Promise.all([...setBalancePromises, ...setAllowancePromises]);
}
public async getBalancesAsync(): Promise<ERC20BalancesByOwner> {
- if (_.isUndefined(this._dummyERC20TokenContracts)) {
- throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
- }
+ this._validateDummyTokenContractsExistOrThrow();
const balancesByOwner: ERC20BalancesByOwner = {};
- const balancePromises: any[] = [];
+ const balancePromises: Array<Promise<BigNumber>> = [];
const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = [];
- _.forEach(this._dummyERC20TokenContracts, dummyERC20TokenContract => {
+ _.forEach(this._dummyTokenContracts, dummyTokenContract => {
_.forEach(this._tokenOwnerAddresses, tokenOwnerAddress => {
- balancePromises.push(dummyERC20TokenContract.balanceOf.callAsync(tokenOwnerAddress));
+ balancePromises.push(dummyTokenContract.balanceOf.callAsync(tokenOwnerAddress));
balanceInfo.push({
tokenOwnerAddress,
- tokenAddress: dummyERC20TokenContract.address,
+ tokenAddress: dummyTokenContract.address,
});
});
});
@@ -105,10 +99,17 @@ export class ERC20Wrapper {
return this._tokenOwnerAddresses;
}
public getTokenAddresses(): string[] {
- const tokenAddresses = _.map(
- this._dummyERC20TokenContracts,
- dummyERC20TokenContract => dummyERC20TokenContract.address,
- );
+ const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
+ private _validateDummyTokenContractsExistOrThrow() {
+ if (_.isUndefined(this._dummyTokenContracts)) {
+ throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
+ }
+ }
+ private _validateProxyContractExistsOrThrow() {
+ if (_.isUndefined(this._proxyContract)) {
+ throw new Error('ERC20 proxy contract not yet deployed, please call "deployProxyAsync"');
+ }
+ }
}
diff --git a/packages/contracts/src/utils/erc721_wrapper.ts b/packages/contracts/src/utils/erc721_wrapper.ts
index 0c62fd5d9..b78b76b51 100644
--- a/packages/contracts/src/utils/erc721_wrapper.ts
+++ b/packages/contracts/src/utils/erc721_wrapper.ts
@@ -8,84 +8,74 @@ import { DummyERC721TokenContract } from '../contract_wrappers/generated/dummy_e
import { ERC721ProxyContract } from '../contract_wrappers/generated/e_r_c721_proxy';
import { constants } from './constants';
-import { ContractName, ERC721BalancesByOwner } from './types';
+import { ContractName, ERC721TokenIdsByOwner } from './types';
export class ERC721Wrapper {
private _tokenOwnerAddresses: string[];
private _contractOwnerAddress: string;
private _deployer: Deployer;
private _provider: Provider;
- private _dummyERC721TokenContracts?: DummyERC721TokenContract[];
- private _erc721ProxyContract?: ERC721ProxyContract;
- private _initialERC721BalancesByOwner: ERC721BalancesByOwner = {};
+ private _dummyTokenContracts?: DummyERC721TokenContract[];
+ private _proxyContract?: ERC721ProxyContract;
+ private _initialTokenIdsByOwner: ERC721TokenIdsByOwner = {};
constructor(deployer: Deployer, provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._deployer = deployer;
this._provider = provider;
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
}
- public async deployDummyERC721TokensAsync(): Promise<DummyERC721TokenContract[]> {
+ public async deployDummyTokensAsync(): Promise<DummyERC721TokenContract[]> {
const tokenContractInstances = await Promise.all(
- _.map(_.range(constants.NUM_DUMMY_ERC721_TO_DEPLOY), () =>
+ _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY, () =>
this._deployer.deployAsync(ContractName.DummyERC721Token, constants.DUMMY_ERC721_TOKEN_ARGS),
),
);
- this._dummyERC721TokenContracts = _.map(
+ this._dummyTokenContracts = _.map(
tokenContractInstances,
tokenContractInstance =>
new DummyERC721TokenContract(tokenContractInstance.abi, tokenContractInstance.address, this._provider),
);
- return this._dummyERC721TokenContracts;
+ return this._dummyTokenContracts;
}
- public async deployERC721ProxyAsync(): Promise<ERC721ProxyContract> {
+ public async deployProxyAsync(): Promise<ERC721ProxyContract> {
const proxyContractInstance = await this._deployer.deployAsync(ContractName.ERC721Proxy);
- this._erc721ProxyContract = new ERC721ProxyContract(
+ this._proxyContract = new ERC721ProxyContract(
proxyContractInstance.abi,
proxyContractInstance.address,
this._provider,
);
- return this._erc721ProxyContract;
+ return this._proxyContract;
}
public async setBalancesAndAllowancesAsync() {
- if (_.isUndefined(this._dummyERC721TokenContracts)) {
- throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyERC721TokensAsync"');
- }
- if (_.isUndefined(this._erc721ProxyContract)) {
- throw new Error('ERC721 proxy contract not yet deployed, please call "deployERC721ProxyAsync"');
- }
- const setBalancePromises: any[] = [];
- const setAllowancePromises: any[] = [];
- this._initialERC721BalancesByOwner = {};
- _.forEach(this._dummyERC721TokenContracts, dummyERC721TokenContract => {
+ this._validateDummyTokenContractsExistOrThrow();
+ this._validateProxyContractExistsOrThrow();
+ const setBalancePromises: Array<Promise<string>> = [];
+ const setAllowancePromises: Array<Promise<string>> = [];
+ this._initialTokenIdsByOwner = {};
+ _.forEach(this._dummyTokenContracts, dummyTokenContract => {
_.forEach(this._tokenOwnerAddresses, tokenOwnerAddress => {
_.forEach(_.range(constants.NUM_ERC721_TOKENS_TO_MINT), () => {
const tokenId = ZeroEx.generatePseudoRandomSalt();
setBalancePromises.push(
- dummyERC721TokenContract.mint.sendTransactionAsync(tokenOwnerAddress, tokenId, {
+ dummyTokenContract.mint.sendTransactionAsync(tokenOwnerAddress, tokenId, {
from: this._contractOwnerAddress,
}),
);
- if (_.isUndefined(this._initialERC721BalancesByOwner[tokenOwnerAddress])) {
- this._initialERC721BalancesByOwner[tokenOwnerAddress] = {
- [dummyERC721TokenContract.address]: [],
+ if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress])) {
+ this._initialTokenIdsByOwner[tokenOwnerAddress] = {
+ [dummyTokenContract.address]: [],
};
}
- if (
- _.isUndefined(
- this._initialERC721BalancesByOwner[tokenOwnerAddress][dummyERC721TokenContract.address],
- )
- ) {
- this._initialERC721BalancesByOwner[tokenOwnerAddress][dummyERC721TokenContract.address] = [];
+ if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address])) {
+ this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] = [];
}
- this._initialERC721BalancesByOwner[tokenOwnerAddress][dummyERC721TokenContract.address].push(
- tokenId,
- );
+ this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId);
});
- const approval = true;
+ const shouldApprove = true;
setAllowancePromises.push(
- dummyERC721TokenContract.setApprovalForAll.sendTransactionAsync(
- (this._erc721ProxyContract as ERC721ProxyContract).address,
- approval,
+ dummyTokenContract.setApprovalForAll.sendTransactionAsync(
+ (this._proxyContract as ERC721ProxyContract).address,
+ shouldApprove,
{ from: tokenOwnerAddress },
),
);
@@ -93,28 +83,22 @@ export class ERC721Wrapper {
});
await Promise.all([...setBalancePromises, ...setAllowancePromises]);
}
- public async getBalancesAsync(): Promise<ERC721BalancesByOwner> {
- if (_.isUndefined(this._dummyERC721TokenContracts)) {
- throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyERC721TokensAsync"');
- }
- if (_.keys(this._initialERC721BalancesByOwner).length === 0) {
- throw new Error(
- 'Dummy ERC721 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
- );
- }
- const balancesByOwner: ERC721BalancesByOwner = {};
- const tokenOwnerPromises: any[] = [];
+ public async getBalancesAsync(): Promise<ERC721TokenIdsByOwner> {
+ this._validateDummyTokenContractsExistOrThrow();
+ this._validateBalancesAndAllowancesSetOrThrow();
+ const tokenIdsByOwner: ERC721TokenIdsByOwner = {};
+ const tokenOwnerPromises: Array<Promise<string>> = [];
const tokenInfo: Array<{ tokenId: BigNumber; tokenAddress: string }> = [];
- _.forEach(this._dummyERC721TokenContracts, dummyERC721TokenContract => {
+ _.forEach(this._dummyTokenContracts, dummyTokenContract => {
_.forEach(this._tokenOwnerAddresses, tokenOwnerAddress => {
- const initialTokenOwnerIds = this._initialERC721BalancesByOwner[tokenOwnerAddress][
- dummyERC721TokenContract.address
+ const initialTokenOwnerIds = this._initialTokenIdsByOwner[tokenOwnerAddress][
+ dummyTokenContract.address
];
_.forEach(initialTokenOwnerIds, tokenId => {
- tokenOwnerPromises.push(dummyERC721TokenContract.ownerOf.callAsync(tokenId));
+ tokenOwnerPromises.push(dummyTokenContract.ownerOf.callAsync(tokenId));
tokenInfo.push({
tokenId,
- tokenAddress: dummyERC721TokenContract.address,
+ tokenAddress: dummyTokenContract.address,
});
});
});
@@ -123,26 +107,40 @@ export class ERC721Wrapper {
_.forEach(tokenOwnerAddresses, (tokenOwnerAddress, ownerIndex) => {
const tokenAddress = tokenInfo[ownerIndex].tokenAddress;
const tokenId = tokenInfo[ownerIndex].tokenId;
- if (_.isUndefined(balancesByOwner[tokenOwnerAddress])) {
- balancesByOwner[tokenOwnerAddress] = {
+ if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress])) {
+ tokenIdsByOwner[tokenOwnerAddress] = {
[tokenAddress]: [],
};
}
- if (_.isUndefined(balancesByOwner[tokenOwnerAddress][tokenAddress])) {
- balancesByOwner[tokenOwnerAddress][tokenAddress] = [];
+ if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress][tokenAddress])) {
+ tokenIdsByOwner[tokenOwnerAddress][tokenAddress] = [];
}
- balancesByOwner[tokenOwnerAddress][tokenAddress].push(tokenId);
+ tokenIdsByOwner[tokenOwnerAddress][tokenAddress].push(tokenId);
});
- return balancesByOwner;
+ return tokenIdsByOwner;
}
public getTokenOwnerAddresses(): string[] {
return this._tokenOwnerAddresses;
}
public getTokenAddresses(): string[] {
- const tokenAddresses = _.map(
- this._dummyERC721TokenContracts,
- dummyERC721TokenContract => dummyERC721TokenContract.address,
- );
+ const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
+ private _validateDummyTokenContractsExistOrThrow() {
+ if (_.isUndefined(this._dummyTokenContracts)) {
+ throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyTokensAsync"');
+ }
+ }
+ private _validateProxyContractExistsOrThrow() {
+ if (_.isUndefined(this._proxyContract)) {
+ throw new Error('ERC721 proxy contract not yet deployed, please call "deployProxyAsync"');
+ }
+ }
+ private _validateBalancesAndAllowancesSetOrThrow() {
+ if (_.keys(this._initialTokenIdsByOwner).length === 0) {
+ throw new Error(
+ 'Dummy ERC721 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
+ );
+ }
+ }
}
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index 629187e95..1e3cd5b9a 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -7,7 +7,7 @@ export interface ERC20BalancesByOwner {
};
}
-export interface ERC721BalancesByOwner {
+export interface ERC721TokenIdsByOwner {
[ownerAddress: string]: {
[tokenAddress: string]: BigNumber[];
};
diff --git a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
index b5630d807..6e0ec3dee 100644
--- a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
+++ b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
@@ -29,7 +29,7 @@ describe('AssetProxyDispatcher', () => {
let makerAddress: string;
let takerAddress: string;
- let zrx: DummyERC20TokenContract;
+ let zrxToken: DummyERC20TokenContract;
let erc20Proxy: ERC20ProxyContract;
let erc721Proxy: ERC721ProxyContract;
let assetProxyDispatcher: AssetProxyDispatcherContract;
@@ -46,11 +46,11 @@ describe('AssetProxyDispatcher', () => {
erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
- [zrx] = await erc20Wrapper.deployDummyERC20TokensAsync();
- erc20Proxy = await erc20Wrapper.deployERC20ProxyAsync();
+ [zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
+ erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
- erc721Proxy = await erc721Wrapper.deployERC721ProxyAsync();
+ erc721Proxy = await erc721Wrapper.deployProxyAsync();
const assetProxyDispatcherInstance = await deployer.deployAsync(ContractName.AssetProxyDispatcher);
assetProxyDispatcher = new AssetProxyDispatcherContract(
@@ -230,7 +230,7 @@ describe('AssetProxyDispatcher', () => {
{ from: owner },
);
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
@@ -243,17 +243,17 @@ describe('AssetProxyDispatcher', () => {
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(amount),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(amount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].add(amount),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].add(amount),
);
});
it('should throw if dispatching to unregistered proxy', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
@@ -278,7 +278,7 @@ describe('AssetProxyDispatcher', () => {
{ from: owner },
);
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
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 830f40e13..14d96f023 100644
--- a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
+++ b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
@@ -29,7 +29,7 @@ describe('Asset Transfer Proxies', () => {
let makerAddress: string;
let takerAddress: string;
- let zrx: DummyERC20TokenContract;
+ let zrxToken: DummyERC20TokenContract;
let erc721Token: DummyERC721TokenContract;
let erc20Proxy: ERC20ProxyContract;
let erc721Proxy: ERC721ProxyContract;
@@ -51,15 +51,15 @@ describe('Asset Transfer Proxies', () => {
erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
- [zrx] = await erc20Wrapper.deployDummyERC20TokensAsync();
- erc20Proxy = await erc20Wrapper.deployERC20ProxyAsync();
+ [zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
+ erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcherAddress, {
from: owner,
});
- [erc721Token] = await erc721Wrapper.deployDummyERC721TokensAsync();
- erc721Proxy = await erc721Wrapper.deployERC721ProxyAsync();
+ [erc721Token] = await erc721Wrapper.deployDummyTokensAsync();
+ erc721Proxy = await erc721Wrapper.deployProxyAsync();
await erc721Wrapper.setBalancesAndAllowancesAsync();
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerTokenId = erc721Balances[makerAddress][erc721Token.address][0];
@@ -76,7 +76,7 @@ describe('Asset Transfer Proxies', () => {
describe('Transfer Proxy - ERC20', () => {
it('should successfully transfer tokens', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
@@ -89,17 +89,17 @@ describe('Asset Transfer Proxies', () => {
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(amount),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(amount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].add(amount),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].add(amount),
);
});
it('should do nothing if transferring 0 amount of a token', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(0);
@@ -112,21 +112,21 @@ describe('Asset Transfer Proxies', () => {
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address],
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address],
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address],
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address],
);
});
it('should throw if allowances are too low', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Create allowance less than transfer amount. Set allowance on proxy.
const allowance = new BigNumber(0);
const transferAmount = new BigNumber(10);
- await zrx.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
+ await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
from: makerAddress,
});
// Perform a transfer; expect this to fail.
@@ -143,7 +143,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if requesting address is not authorized', async () => {
// Construct metadata for ERC20 proxy
- const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrx.address);
+ const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(10);
return expect(
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 9065c5e3f..666486cc3 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -28,7 +28,6 @@ import {
AssetProxyId,
ContractName,
ERC20BalancesByOwner,
- ERC721BalancesByOwner,
ExchangeContractErrs,
SignedOrder,
} from '../../src/utils/types';
@@ -48,7 +47,7 @@ describe('Exchange core', () => {
let erc20TokenA: DummyERC20TokenContract;
let erc20TokenB: DummyERC20TokenContract;
- let zrx: DummyERC20TokenContract;
+ let zrxToken: DummyERC20TokenContract;
let erc721Token: DummyERC721TokenContract;
let exchange: ExchangeContract;
let assetProxyDispatcher: AssetProxyDispatcherContract;
@@ -77,12 +76,12 @@ describe('Exchange core', () => {
erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
- [erc20TokenA, erc20TokenB, zrx] = await erc20Wrapper.deployDummyERC20TokensAsync();
- erc20Proxy = await erc20Wrapper.deployERC20ProxyAsync();
+ [erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
+ erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
- [erc721Token] = await erc721Wrapper.deployDummyERC721TokensAsync();
- erc721Proxy = await erc721Wrapper.deployERC721ProxyAsync();
+ [erc721Token] = await erc721Wrapper.deployDummyTokensAsync();
+ erc721Proxy = await erc721Wrapper.deployProxyAsync();
await erc721Wrapper.setBalancesAndAllowancesAsync();
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
@@ -117,7 +116,7 @@ describe('Exchange core', () => {
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
assetProxyDispatcher.address,
- assetProxyUtils.encodeERC20ProxyData(zrx.address),
+ assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
]);
exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
await assetProxyDispatcher.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
@@ -227,8 +226,8 @@ describe('Exchange core', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFeePaid),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -236,11 +235,11 @@ describe('Exchange core', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFeePaid),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)),
);
});
@@ -280,8 +279,8 @@ describe('Exchange core', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFeePaid),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -289,11 +288,11 @@ describe('Exchange core', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFeePaid),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)),
);
});
@@ -333,8 +332,8 @@ describe('Exchange core', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFeePaid),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -342,11 +341,11 @@ describe('Exchange core', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFeePaid),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)),
);
});
@@ -388,8 +387,8 @@ describe('Exchange core', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFeePaid),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -397,11 +396,11 @@ describe('Exchange core', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFeePaid),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)),
);
});
@@ -424,8 +423,8 @@ describe('Exchange core', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(signedOrder.takerAssetAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(signedOrder.makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(signedOrder.makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(signedOrder.takerAssetAmount),
@@ -433,11 +432,13 @@ describe('Exchange core', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(signedOrder.makerAssetAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(signedOrder.takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(signedOrder.takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(
+ signedOrder.makerFee.add(signedOrder.takerFee),
+ ),
);
});
@@ -768,8 +769,8 @@ describe('Exchange core', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(fillTakerAssetAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(fillTakerAssetAmount),
@@ -777,11 +778,11 @@ describe('Exchange core', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(fillMakerAssetAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)),
);
});
});
@@ -949,14 +950,16 @@ describe('Exchange core', () => {
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(signedOrder.makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(signedOrder.makerFee),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(signedOrder.takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(signedOrder.takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(
+ signedOrder.makerFee.add(signedOrder.takerFee),
+ ),
);
});
@@ -987,14 +990,16 @@ describe('Exchange core', () => {
expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultMakerAssetAddress].minus(signedOrder.makerAssetAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(signedOrder.makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(signedOrder.makerFee),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(signedOrder.takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(signedOrder.takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(
+ signedOrder.makerFee.add(signedOrder.takerFee),
+ ),
);
});
});
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 60f47373e..d2d82f977 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -19,13 +19,7 @@ import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
import { OrderFactory } from '../../src/utils/order_factory';
-import {
- AssetProxyId,
- ContractName,
- ERC20BalancesByOwner,
- ERC721BalancesByOwner,
- SignedOrder,
-} from '../../src/utils/types';
+import { AssetProxyId, ContractName, ERC20BalancesByOwner, SignedOrder } from '../../src/utils/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { provider, web3Wrapper } from '../utils/web3_wrapper';
@@ -42,7 +36,7 @@ describe('Exchange wrappers', () => {
let erc20TokenA: DummyERC20TokenContract;
let erc20TokenB: DummyERC20TokenContract;
- let zrx: DummyERC20TokenContract;
+ let zrxToken: DummyERC20TokenContract;
let erc721Token: DummyERC721TokenContract;
let exchange: ExchangeContract;
let assetProxyDispatcher: AssetProxyDispatcherContract;
@@ -70,12 +64,12 @@ describe('Exchange wrappers', () => {
erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
- [erc20TokenA, erc20TokenB, zrx] = await erc20Wrapper.deployDummyERC20TokensAsync();
- erc20Proxy = await erc20Wrapper.deployERC20ProxyAsync();
+ [erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
+ erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
- [erc721Token] = await erc721Wrapper.deployDummyERC721TokensAsync();
- erc721Proxy = await erc721Wrapper.deployERC721ProxyAsync();
+ [erc721Token] = await erc721Wrapper.deployDummyTokensAsync();
+ erc721Proxy = await erc721Wrapper.deployProxyAsync();
await erc721Wrapper.setBalancesAndAllowancesAsync();
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetId = erc721Balances[makerAddress][erc721Token.address][0];
@@ -110,7 +104,7 @@ describe('Exchange wrappers', () => {
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
assetProxyDispatcher.address,
- assetProxyUtils.encodeERC20ProxyData(zrx.address),
+ assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
]);
exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
await assetProxyDispatcher.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
@@ -169,8 +163,8 @@ describe('Exchange wrappers', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -178,11 +172,11 @@ describe('Exchange wrappers', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)),
);
});
@@ -237,8 +231,8 @@ describe('Exchange wrappers', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -246,11 +240,11 @@ describe('Exchange wrappers', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)),
);
});
@@ -303,11 +297,11 @@ describe('Exchange wrappers', () => {
});
it('should not change erc20Balances if makerAssetAddress is ZRX, makerAssetAmount + makerFee > maker balance', async () => {
- const makerZRXBalance = new BigNumber(erc20Balances[makerAddress][zrx.address]);
+ const makerZRXBalance = new BigNumber(erc20Balances[makerAddress][zrxToken.address]);
const signedOrder = orderFactory.newSignedOrder({
makerAssetAmount: makerZRXBalance,
makerFee: new BigNumber(1),
- makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address),
+ makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
});
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -315,11 +309,11 @@ describe('Exchange wrappers', () => {
});
it('should not change erc20Balances if makerAssetAddress is ZRX, makerAssetAmount + makerFee > maker allowance', async () => {
- const makerZRXAllowance = await zrx.allowance.callAsync(makerAddress, erc20Proxy.address);
+ const makerZRXAllowance = await zrxToken.allowance.callAsync(makerAddress, erc20Proxy.address);
const signedOrder = orderFactory.newSignedOrder({
makerAssetAmount: new BigNumber(makerZRXAllowance),
makerFee: new BigNumber(1),
- makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address),
+ makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
});
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -327,11 +321,11 @@ describe('Exchange wrappers', () => {
});
it('should not change erc20Balances if takerAssetAddress is ZRX, takerAssetAmount + takerFee > taker balance', async () => {
- const takerZRXBalance = new BigNumber(erc20Balances[takerAddress][zrx.address]);
+ const takerZRXBalance = new BigNumber(erc20Balances[takerAddress][zrxToken.address]);
const signedOrder = orderFactory.newSignedOrder({
takerAssetAmount: takerZRXBalance,
takerFee: new BigNumber(1),
- takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address),
+ takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
});
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -339,11 +333,11 @@ describe('Exchange wrappers', () => {
});
it('should not change erc20Balances if takerAssetAddress is ZRX, takerAssetAmount + takerFee > taker allowance', async () => {
- const takerZRXAllowance = await zrx.allowance.callAsync(takerAddress, erc20Proxy.address);
+ const takerZRXAllowance = await zrxToken.allowance.callAsync(takerAddress, erc20Proxy.address);
const signedOrder = orderFactory.newSignedOrder({
takerAssetAmount: new BigNumber(takerZRXAllowance),
takerFee: new BigNumber(1),
- takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address),
+ takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
});
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -409,16 +403,20 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add(
takerAssetFillAmount,
);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(makerFee);
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
+ makerFee,
+ );
erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add(
makerAssetFilledAmount,
);
erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][
takerAssetAddress
].minus(takerAssetFillAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(takerFee);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
+ takerFee,
+ );
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(makerFee.add(takerFee));
});
@@ -454,16 +452,20 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add(
takerAssetFillAmount,
);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(makerFee);
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
+ makerFee,
+ );
erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add(
makerAssetFilledAmount,
);
erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][
takerAssetAddress
].minus(takerAssetFillAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(takerFee);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
+ takerFee,
+ );
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(makerFee.add(takerFee));
});
@@ -515,16 +517,20 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add(
takerAssetFillAmount,
);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(makerFee);
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
+ makerFee,
+ );
erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add(
makerAssetFilledAmount,
);
erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][
takerAssetAddress
].minus(takerAssetFillAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(takerFee);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
+ takerFee,
+ );
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(makerFee.add(takerFee));
});
@@ -566,16 +572,20 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add(
takerAssetFillAmount,
);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(makerFee);
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
+ makerFee,
+ );
erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add(
makerAssetFilledAmount,
);
erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][
takerAssetAddress
].minus(takerAssetFillAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(takerFee);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
+ takerFee,
+ );
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(makerFee.add(takerFee));
});
@@ -611,8 +621,8 @@ describe('Exchange wrappers', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -620,11 +630,11 @@ describe('Exchange wrappers', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)),
);
});
@@ -637,7 +647,7 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][
defaultTakerAssetAddress
].add(signedOrder.takerAssetAmount);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
signedOrder.makerFee,
);
erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][
@@ -646,11 +656,11 @@ describe('Exchange wrappers', () => {
erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][
defaultTakerAssetAddress
].minus(signedOrder.takerAssetAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
signedOrder.takerFee,
);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(signedOrder.makerFee.add(signedOrder.takerFee));
});
await exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
@@ -664,7 +674,9 @@ describe('Exchange wrappers', () => {
it('should throw when an signedOrder does not use the same takerAssetAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({
+ takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
+ }),
orderFactory.newSignedOrder(),
];
@@ -698,8 +710,8 @@ describe('Exchange wrappers', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount),
@@ -707,11 +719,11 @@ describe('Exchange wrappers', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)),
);
});
@@ -724,7 +736,7 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][
defaultTakerAssetAddress
].add(signedOrder.takerAssetAmount);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
signedOrder.makerFee,
);
erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][
@@ -733,11 +745,11 @@ describe('Exchange wrappers', () => {
erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][
defaultTakerAssetAddress
].minus(signedOrder.takerAssetAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
signedOrder.takerFee,
);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(signedOrder.makerFee.add(signedOrder.takerFee));
});
await exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
@@ -751,7 +763,9 @@ describe('Exchange wrappers', () => {
it('should throw when a signedOrder does not use the same takerAssetAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({
+ takerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
+ }),
orderFactory.newSignedOrder(),
];
@@ -785,8 +799,8 @@ describe('Exchange wrappers', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(makerAmountBought),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(makerAmountBought),
@@ -794,11 +808,11 @@ describe('Exchange wrappers', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFillAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)),
);
});
@@ -811,7 +825,7 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][
defaultTakerAssetAddress
].add(signedOrder.takerAssetAmount);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
signedOrder.makerFee,
);
erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][
@@ -820,11 +834,11 @@ describe('Exchange wrappers', () => {
erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][
defaultTakerAssetAddress
].minus(signedOrder.takerAssetAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
signedOrder.takerFee,
);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(signedOrder.makerFee.add(signedOrder.takerFee));
});
await exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
@@ -838,7 +852,9 @@ describe('Exchange wrappers', () => {
it('should throw when an signedOrder does not use the same makerAssetAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({
+ makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
+ }),
orderFactory.newSignedOrder(),
];
@@ -872,8 +888,8 @@ describe('Exchange wrappers', () => {
expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultTakerAssetAddress].add(makerAmountBought),
);
- expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerFee),
);
expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultTakerAssetAddress].minus(makerAmountBought),
@@ -881,11 +897,11 @@ describe('Exchange wrappers', () => {
expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFillAmount),
);
- expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].minus(takerFee),
);
- expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
- erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)),
);
});
@@ -898,7 +914,7 @@ describe('Exchange wrappers', () => {
erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][
defaultTakerAssetAddress
].add(signedOrder.takerAssetAmount);
- erc20Balances[makerAddress][zrx.address] = erc20Balances[makerAddress][zrx.address].minus(
+ erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus(
signedOrder.makerFee,
);
erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][
@@ -907,11 +923,11 @@ describe('Exchange wrappers', () => {
erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][
defaultTakerAssetAddress
].minus(signedOrder.takerAssetAmount);
- erc20Balances[takerAddress][zrx.address] = erc20Balances[takerAddress][zrx.address].minus(
+ erc20Balances[takerAddress][zrxToken.address] = erc20Balances[takerAddress][zrxToken.address].minus(
signedOrder.takerFee,
);
- erc20Balances[feeRecipientAddress][zrx.address] = erc20Balances[feeRecipientAddress][
- zrx.address
+ erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][
+ zrxToken.address
].add(signedOrder.makerFee.add(signedOrder.takerFee));
});
await exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
@@ -925,7 +941,9 @@ describe('Exchange wrappers', () => {
it('should throw when a signedOrder does not use the same makerAssetAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrx.address) }),
+ orderFactory.newSignedOrder({
+ makerAssetData: assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
+ }),
orderFactory.newSignedOrder(),
];
diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts
index 259b4310e..ddb7f0b35 100644
--- a/packages/contracts/test/zrx_token.ts
+++ b/packages/contracts/test/zrx_token.ts
@@ -24,7 +24,7 @@ describe('ZRXToken', () => {
let MAX_UINT: BigNumber;
- let zrx: ZRXTokenContract;
+ let zrxToken: ZRXTokenContract;
let zrxAddress: string;
before(async () => {
@@ -35,8 +35,8 @@ describe('ZRXToken', () => {
networkId: constants.TESTRPC_NETWORK_ID,
});
const zrxInstance = await deployer.deployAsync(ContractName.ZRXToken);
- zrx = new ZRXTokenContract(zrxInstance.abi, zrxInstance.address, provider);
- zrxAddress = zrx.address;
+ zrxToken = new ZRXTokenContract(zrxInstance.abi, zrxInstance.address, provider);
+ zrxAddress = zrxToken.address;
MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
});
beforeEach(async () => {
@@ -47,25 +47,25 @@ describe('ZRXToken', () => {
});
describe('constants', () => {
it('should have 18 decimals', async () => {
- const decimals = new BigNumber(await zrx.decimals.callAsync());
+ const decimals = new BigNumber(await zrxToken.decimals.callAsync());
const expectedDecimals = 18;
expect(decimals).to.be.bignumber.equal(expectedDecimals);
});
it('should have a total supply of 1 billion tokens', async () => {
- const totalSupply = new BigNumber(await zrx.totalSupply.callAsync());
+ const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync());
const expectedTotalSupply = 1000000000;
expect(ZeroEx.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply);
});
it('should be named 0x Protocol Token', async () => {
- const name = await zrx.name.callAsync();
+ const name = await zrxToken.name.callAsync();
const expectedName = '0x Protocol Token';
expect(name).to.be.equal(expectedName);
});
it('should have the symbol ZRX', async () => {
- const symbol = await zrx.symbol.callAsync();
+ const symbol = await zrxToken.symbol.callAsync();
const expectedSymbol = 'ZRX';
expect(symbol).to.be.equal(expectedSymbol);
});
@@ -74,7 +74,7 @@ describe('ZRXToken', () => {
describe('constructor', () => {
it('should initialize owner balance to totalSupply', async () => {
const ownerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
- const totalSupply = new BigNumber(await zrx.totalSupply.callAsync());
+ const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync());
expect(totalSupply).to.be.bignumber.equal(ownerBalance);
});
});
@@ -95,7 +95,7 @@ describe('ZRXToken', () => {
});
it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await zrx.transfer.callAsync(spender, new BigNumber(0), {
+ const didReturnTrue = await zrxToken.transfer.callAsync(spender, new BigNumber(0), {
from: owner,
});
expect(didReturnTrue).to.be.true();
@@ -109,7 +109,7 @@ describe('ZRXToken', () => {
await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer, {
gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
});
- const didReturnTrue = await zrx.transferFrom.callAsync(owner, spender, amountToTransfer, { from: spender });
+ const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
@@ -121,13 +121,13 @@ describe('ZRXToken', () => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- const didReturnTrue = await zrx.transferFrom.callAsync(owner, spender, amountToTransfer, { from: spender });
+ const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
it('should return true on a 0 value transfer', async () => {
const amountToTransfer = new BigNumber(0);
- const didReturnTrue = await zrx.transferFrom.callAsync(owner, spender, amountToTransfer, { from: spender });
+ const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.true();
});