aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-12-22 22:05:32 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-01-03 18:37:38 +0800
commite744e4cd989bd3ae1070c59f7baa8097f18b8b06 (patch)
treea7fde03873f3c1b8689d3991edbb362f8022e5f0 /packages/contracts
parent9a96e8c704b6f84e00bbe848159a4819844cf09d (diff)
downloaddexon-0x-contracts-e744e4cd989bd3ae1070c59f7baa8097f18b8b06.tar.gz
dexon-0x-contracts-e744e4cd989bd3ae1070c59f7baa8097f18b8b06.tar.zst
dexon-0x-contracts-e744e4cd989bd3ae1070c59f7baa8097f18b8b06.zip
Apply prettier config
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/deploy/cli.ts40
-rw-r--r--packages/contracts/deploy/migrations/config/token_info.ts4
-rw-r--r--packages/contracts/deploy/migrations/migrate.ts26
-rw-r--r--packages/contracts/deploy/src/commands.ts8
-rw-r--r--packages/contracts/deploy/src/compiler.ts21
-rw-r--r--packages/contracts/deploy/src/deployer.ts25
-rw-r--r--packages/contracts/deploy/src/utils/contract.ts6
-rw-r--r--packages/contracts/deploy/src/utils/encoder.ts2
-rw-r--r--packages/contracts/deploy/src/utils/fs_wrapper.ts2
-rw-r--r--packages/contracts/deploy/src/utils/types.ts2
-rw-r--r--packages/contracts/deploy/test/deploy_test.ts12
-rw-r--r--packages/contracts/deploy/test/fixtures/exchange_bin.ts6
-rw-r--r--packages/contracts/deploy/test/util/constants.ts2
-rw-r--r--packages/contracts/globalsAugment.d.ts4
-rw-r--r--packages/contracts/migrations/1_initial_migration.ts4
-rw-r--r--packages/contracts/migrations/2_deploy_independent_contracts.ts21
-rw-r--r--packages/contracts/migrations/3_register_tokens.ts155
-rw-r--r--packages/contracts/migrations/4_configure_proxy.ts41
-rw-r--r--packages/contracts/migrations/5_transfer_ownership.ts29
-rw-r--r--packages/contracts/migrations/config/multisig_sample.ts2
-rw-r--r--packages/contracts/migrations/config/token_info.ts4
-rw-r--r--packages/contracts/test/ts/ether_token.ts29
-rw-r--r--packages/contracts/test/ts/exchange/core.ts570
-rw-r--r--packages/contracts/test/ts/exchange/helpers.ts24
-rw-r--r--packages/contracts/test/ts/exchange/wrapper.ts251
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock.ts29
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts53
-rw-r--r--packages/contracts/test/ts/token_registry.ts96
-rw-r--r--packages/contracts/test/ts/token_transfer_proxy/auth.ts46
-rw-r--r--packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts52
-rw-r--r--packages/contracts/test/ts/unlimited_allowance_token.ts28
-rw-r--r--packages/contracts/test/ts/unlimited_allowance_token_v2.ts43
-rw-r--r--packages/contracts/test/ts/zrx_token.ts24
-rw-r--r--packages/contracts/util/artifacts.ts3
-rw-r--r--packages/contracts/util/balances.ts6
-rw-r--r--packages/contracts/util/crypto.ts4
-rw-r--r--packages/contracts/util/exchange_wrapper.ts108
-rw-r--r--packages/contracts/util/formatters.ts82
-rw-r--r--packages/contracts/util/multi_sig_wrapper.ts19
-rw-r--r--packages/contracts/util/order.ts12
-rw-r--r--packages/contracts/util/order_factory.ts25
-rw-r--r--packages/contracts/util/token_registry_wrapper.ts4
-rw-r--r--packages/contracts/util/types.ts2
43 files changed, 1083 insertions, 843 deletions
diff --git a/packages/contracts/deploy/cli.ts b/packages/contracts/deploy/cli.ts
index b02849826..c3a03e406 100644
--- a/packages/contracts/deploy/cli.ts
+++ b/packages/contracts/deploy/cli.ts
@@ -1,23 +1,19 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import {BigNumber} from 'bignumber.js';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BigNumber } from 'bignumber.js';
import * as _ from 'lodash';
import * as path from 'path';
import * as Web3 from 'web3';
import * as yargs from 'yargs';
-import {commands} from './src/commands';
-import {
- CliOptions,
- CompilerOptions,
- DeployerOptions,
-} from './src/utils/types';
+import { commands } from './src/commands';
+import { CliOptions, CompilerOptions, DeployerOptions } from './src/utils/types';
const DEFAULT_OPTIMIZER_ENABLED = false;
const DEFAULT_CONTRACTS_DIR = path.resolve('contracts');
const DEFAULT_ARTIFACTS_DIR = `${path.resolve('build')}/artifacts/`;
const DEFAULT_NETWORK_ID = 50;
const DEFAULT_JSONRPC_PORT = 8545;
-const DEFAULT_GAS_PRICE = ((10 ** 9) * 2).toString();
+const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
/**
* Compiles all contracts with options passed in through CLI.
@@ -108,8 +104,7 @@ function deployCommandBuilder(yargsInstance: any) {
description: 'comma separated list of constructor args to deploy contract with',
})
.demandOption(['contract', 'args'])
- .help()
- .argv;
+ .help().argv;
}
(() => {
@@ -149,18 +144,13 @@ function deployCommandBuilder(yargsInstance: any) {
type: 'string',
description: 'account to use for deploying contracts',
})
- .command('compile',
- 'compile contracts',
- identityCommandBuilder,
- onCompileCommand)
- .command('migrate',
- 'compile and deploy contracts using migration scripts',
- identityCommandBuilder,
- onMigrateCommand)
- .command('deploy',
- 'deploy a single contract with provided arguments',
- deployCommandBuilder,
- onDeployCommand)
- .help()
- .argv;
+ .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
+ .command(
+ 'migrate',
+ 'compile and deploy contracts using migration scripts',
+ identityCommandBuilder,
+ onMigrateCommand,
+ )
+ .command('deploy', 'deploy a single contract with provided arguments', deployCommandBuilder, onDeployCommand)
+ .help().argv;
})();
diff --git a/packages/contracts/deploy/migrations/config/token_info.ts b/packages/contracts/deploy/migrations/config/token_info.ts
index f56914ecb..751150c03 100644
--- a/packages/contracts/deploy/migrations/config/token_info.ts
+++ b/packages/contracts/deploy/migrations/config/token_info.ts
@@ -1,5 +1,5 @@
-import {constants} from './../../src/utils/constants';
-import {Token} from './../../src/utils/types';
+import { constants } from './../../src/utils/constants';
+import { Token } from './../../src/utils/types';
export const tokenInfo: Token[] = [
{
diff --git a/packages/contracts/deploy/migrations/migrate.ts b/packages/contracts/deploy/migrations/migrate.ts
index d21d48a82..85f219a81 100644
--- a/packages/contracts/deploy/migrations/migrate.ts
+++ b/packages/contracts/deploy/migrations/migrate.ts
@@ -1,10 +1,10 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import {BigNumber} from 'bignumber.js';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BigNumber } from 'bignumber.js';
import * as _ from 'lodash';
-import {Deployer} from './../src/deployer';
-import {constants} from './../src/utils/constants';
-import {tokenInfo} from './config/token_info';
+import { Deployer } from './../src/deployer';
+import { constants } from './../src/utils/constants';
+import { tokenInfo } from './config/token_info';
export const migrator = {
/**
@@ -29,12 +29,13 @@ export const migrator = {
const multiSigArgs = [owners, confirmationsRequired, secondsRequired, tokenTransferProxy.address];
const exchange = await deployer.deployAndSaveAsync('Exchange', exchangeArgs);
const multiSig = await deployer.deployAndSaveAsync(
- 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', multiSigArgs,
+ 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
+ multiSigArgs,
);
const owner = accounts[0];
- await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {from: owner});
- await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, {from: owner});
+ await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
+ await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: owner });
const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync(
zrxToken.address,
tokenInfo[0].name,
@@ -42,7 +43,7 @@ export const migrator = {
tokenInfo[0].decimals,
tokenInfo[0].ipfsHash,
tokenInfo[0].swarmHash,
- {from: owner},
+ { from: owner },
);
await tokenReg.addToken.sendTransactionAsync(
zrxToken.address,
@@ -70,12 +71,7 @@ export const migrator = {
);
for (const token of tokenInfo) {
const totalSupply = new BigNumber(0);
- const args = [
- token.name,
- token.symbol,
- token.decimals,
- totalSupply,
- ];
+ const args = [token.name, token.symbol, token.decimals, totalSupply];
const dummyToken = await deployer.deployAsync('DummyToken', args);
await tokenReg.addToken.sendTransactionAsync(
dummyToken.address,
diff --git a/packages/contracts/deploy/src/commands.ts b/packages/contracts/deploy/src/commands.ts
index fc421a760..b87b9e632 100644
--- a/packages/contracts/deploy/src/commands.ts
+++ b/packages/contracts/deploy/src/commands.ts
@@ -1,7 +1,7 @@
-import {migrator} from './../migrations/migrate';
-import {Compiler} from './compiler';
-import {Deployer} from './deployer';
-import {CompilerOptions, DeployerOptions} from './utils/types';
+import { migrator } from './../migrations/migrate';
+import { Compiler } from './compiler';
+import { Deployer } from './deployer';
+import { CompilerOptions, DeployerOptions } from './utils/types';
export const commands = {
async compileAsync(opts: CompilerOptions): Promise<void> {
diff --git a/packages/contracts/deploy/src/compiler.ts b/packages/contracts/deploy/src/compiler.ts
index 02b8699b6..8b99371fa 100644
--- a/packages/contracts/deploy/src/compiler.ts
+++ b/packages/contracts/deploy/src/compiler.ts
@@ -4,8 +4,8 @@ import * as path from 'path';
import solc = require('solc');
import * as Web3 from 'web3';
-import {binPaths} from './../solc/bin_paths';
-import {fsWrapper} from './utils/fs_wrapper';
+import { binPaths } from './../solc/bin_paths';
+import { fsWrapper } from './utils/fs_wrapper';
import {
CompilerOptions,
ContractArtifact,
@@ -14,7 +14,7 @@ import {
ContractSources,
ImportContents,
} from './utils/types';
-import {utils} from './utils/utils';
+import { utils } from './utils/utils';
const SOLIDITY_FILE_EXTENSION = '.sol';
@@ -150,9 +150,10 @@ export class Compiler {
currentArtifact = JSON.parse(currentArtifactString);
oldNetworks = currentArtifact.networks;
const oldNetwork: ContractData = oldNetworks[this._networkId];
- shouldCompile = _.isUndefined(oldNetwork) ||
- oldNetwork.keccak256 !== sourceHash ||
- oldNetwork.optimizer_enabled !== this._optimizerEnabled;
+ shouldCompile =
+ _.isUndefined(oldNetwork) ||
+ oldNetwork.keccak256 !== sourceHash ||
+ oldNetwork.optimizer_enabled !== this._optimizerEnabled;
} catch (err) {
shouldCompile = true;
}
@@ -174,9 +175,11 @@ export class Compiler {
const sourcesToCompile = {
sources: input,
};
- const compiled = solcInstance.compile(sourcesToCompile,
- this._optimizerEnabled,
- this._findImportsIfSourcesExist.bind(this));
+ const compiled = solcInstance.compile(
+ sourcesToCompile,
+ this._optimizerEnabled,
+ this._findImportsIfSourcesExist.bind(this),
+ );
if (!_.isUndefined(compiled.errors)) {
_.each(compiled.errors, errMsg => {
diff --git a/packages/contracts/deploy/src/deployer.ts b/packages/contracts/deploy/src/deployer.ts
index ea1de59d3..6f03581e8 100644
--- a/packages/contracts/deploy/src/deployer.ts
+++ b/packages/contracts/deploy/src/deployer.ts
@@ -1,17 +1,13 @@
-import {TxData} from '@0xproject/types';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import { TxData } from '@0xproject/types';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {Contract} from './utils/contract';
-import {encoder} from './utils/encoder';
-import {fsWrapper} from './utils/fs_wrapper';
-import {
- ContractArtifact,
- ContractData,
- DeployerOptions,
-} from './utils/types';
-import {utils} from './utils/utils';
+import { Contract } from './utils/contract';
+import { encoder } from './utils/encoder';
+import { fsWrapper } from './utils/fs_wrapper';
+import { ContractArtifact, ContractData, DeployerOptions } from './utils/types';
+import { utils } from './utils/utils';
// Gas added to gas estimate to make sure there is sufficient gas for deployment.
const EXTRA_GAS = 200000;
@@ -99,8 +95,11 @@ export class Deployer {
* @param contractAddress Contract address to save to artifact.
* @param args Contract constructor arguments that will be encoded and saved to artifact.
*/
- private async _saveContractDataToArtifactAsync(contractName: string,
- contractAddress: string, args: any[]): Promise<void> {
+ private async _saveContractDataToArtifactAsync(
+ contractName: string,
+ contractAddress: string,
+ args: any[],
+ ): Promise<void> {
const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName);
const contractData: ContractData = this._getContractDataFromArtifactIfExists(contractArtifact);
const abi = contractData.abi;
diff --git a/packages/contracts/deploy/src/utils/contract.ts b/packages/contracts/deploy/src/utils/contract.ts
index ffad9ed70..2c8bbb79e 100644
--- a/packages/contracts/deploy/src/utils/contract.ts
+++ b/packages/contracts/deploy/src/utils/contract.ts
@@ -1,9 +1,9 @@
-import {schemas, SchemaValidator} from '@0xproject/json-schemas';
-import {promisify} from '@0xproject/utils';
+import { schemas, SchemaValidator } from '@0xproject/json-schemas';
+import { promisify } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {AbiType} from './types';
+import { AbiType } from './types';
export class Contract implements Web3.ContractInstance {
public address: string;
diff --git a/packages/contracts/deploy/src/utils/encoder.ts b/packages/contracts/deploy/src/utils/encoder.ts
index 0248e9f03..d5f807774 100644
--- a/packages/contracts/deploy/src/utils/encoder.ts
+++ b/packages/contracts/deploy/src/utils/encoder.ts
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
import * as web3Abi from 'web3-eth-abi';
-import {AbiType} from './types';
+import { AbiType } from './types';
export const encoder = {
encodeConstructorArgsFromAbi(args: any[], abi: Web3.ContractAbi): string {
diff --git a/packages/contracts/deploy/src/utils/fs_wrapper.ts b/packages/contracts/deploy/src/utils/fs_wrapper.ts
index 90785d0dd..34c7caa0e 100644
--- a/packages/contracts/deploy/src/utils/fs_wrapper.ts
+++ b/packages/contracts/deploy/src/utils/fs_wrapper.ts
@@ -1,4 +1,4 @@
-import {promisify} from '@0xproject/utils';
+import { promisify } from '@0xproject/utils';
import * as fs from 'fs';
export const fsWrapper = {
diff --git a/packages/contracts/deploy/src/utils/types.ts b/packages/contracts/deploy/src/utils/types.ts
index 6831079e6..e054b9cc2 100644
--- a/packages/contracts/deploy/src/utils/types.ts
+++ b/packages/contracts/deploy/src/utils/types.ts
@@ -1,4 +1,4 @@
-import {TxData} from '@0xproject/types';
+import { TxData } from '@0xproject/types';
import * as Web3 from 'web3';
import * as yargs from 'yargs';
diff --git a/packages/contracts/deploy/test/deploy_test.ts b/packages/contracts/deploy/test/deploy_test.ts
index 263174a94..51dbf0e5b 100644
--- a/packages/contracts/deploy/test/deploy_test.ts
+++ b/packages/contracts/deploy/test/deploy_test.ts
@@ -1,12 +1,12 @@
import * as chai from 'chai';
import 'mocha';
-import {Compiler} from './../src/compiler';
-import {Deployer} from './../src/deployer';
-import {fsWrapper} from './../src/utils/fs_wrapper';
-import {CompilerOptions, ContractArtifact, ContractData, DoneCallback} from './../src/utils/types';
-import {constructor_args, exchange_binary} from './fixtures/exchange_bin';
-import {constants} from './util/constants';
+import { Compiler } from './../src/compiler';
+import { Deployer } from './../src/deployer';
+import { fsWrapper } from './../src/utils/fs_wrapper';
+import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from './../src/utils/types';
+import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
+import { constants } from './util/constants';
const expect = chai.expect;
const artifactsDir = `${__dirname}/fixtures/artifacts`;
diff --git a/packages/contracts/deploy/test/fixtures/exchange_bin.ts b/packages/contracts/deploy/test/fixtures/exchange_bin.ts
index 0ca87760e..fd887f048 100644
--- a/packages/contracts/deploy/test/fixtures/exchange_bin.ts
+++ b/packages/contracts/deploy/test/fixtures/exchange_bin.ts
@@ -1,4 +1,6 @@
// tslint:disable-next-line:max-line-length
-export const constructor_args = '0x000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f4980000000000000000000000008da0d80f5007ef1e431dd2127178d224e32c2ef4';
+export const constructor_args =
+ '0x000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f4980000000000000000000000008da0d80f5007ef1e431dd2127178d224e32c2ef4';
// tslint:disable-next-line:max-line-length
-export const exchange_binary = '0x6060604052341561000f57600080fd5b604051604080612c4d833981016040528080519060200190919080519060200190919050505b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50505b612b84806100c96000396000f300606060405236156100fa576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806314df96ee146100ff578063288cdc911461014c5780632ac1262214610187578063363349be146101c2578063394c21e7146103bc5780633b30ba591461044b5780634f150787146104a0578063741bcc93146106b25780637e9abb50146107535780638163681e1461078e57806398024a8b14610812578063add1cbc51461085b578063b7b2c7d6146108b0578063baa0181d14610acd578063bc61394a14610c1f578063cfc4d0ec14610cdf578063f06bbf7514610d6d578063ffa1ad7414610d9e575b600080fd5b341561010a57600080fd5b6101326004808035906020019091908035906020019091908035906020019091905050610e2d565b604051808215151515815260200191505060405180910390f35b341561015757600080fd5b610171600480803560001916906020019091905050610e7c565b6040518082815260200191505060405180910390f35b341561019257600080fd5b6101ac600480803560001916906020019091905050610e94565b6040518082815260200191505060405180910390f35b34156101cd57600080fd5b6103a660048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561024857848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610203565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156102c457848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061027f565b5050505050919080359060200190919080351515906020019091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050610eac565b6040518082815260200191505060405180910390f35b34156103c757600080fd5b6104356004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091905050611013565b6040518082815260200191505060405180910390f35b341561045657600080fd5b61045e6114fb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104ab57600080fd5b6106b060048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561052657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906104e1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156105a257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061055d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050611520565b005b34156106bd57600080fd5b6107516004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c00190600680602002604051908101604052809291908260066020028082843782019150505050509190803590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506115df565b005b341561075e57600080fd5b610778600480803560001916906020019091905050611605565b6040518082815260200191505060405180910390f35b341561079957600080fd5b6107f8600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080356000191690602001909190803560ff16906020019091908035600019169060200190919080356000191690602001909190505061164f565b604051808215151515815260200191505060405180910390f35b341561081d57600080fd5b6108456004808035906020019091908035906020019091908035906020019091905050611757565b6040518082815260200191505060405180910390f35b341561086657600080fd5b61086e611776565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156108bb57600080fd5b610acb60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561093657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906108f1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156109b257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061096d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035151590602001909190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061179c565b005b3415610ad857600080fd5b610c1d60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610b5357848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610b0e565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610bcf57848483905060c002016006806020026040519081016040528092919082600660200280828437820191505050505081526020019060010190610b8a565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061185e565b005b3415610c2a57600080fd5b610cc96004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091908035151590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506118d3565b6040518082815260200191505060405180910390f35b3415610cea57600080fd5b610d4f6004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091905050612073565b60405180826000191660001916815260200191505060405180910390f35b3415610d7857600080fd5b610d8061231f565b604051808261ffff1661ffff16815260200191505060405180910390f35b3415610da957600080fd5b610db1612325565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610df25780820151818401525b602081019050610dd6565b50505050905090810190601f168015610e1f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008060008486850991506000821415610e4a5760009250610e73565b610e69610e5a83620f424061235e565b610e64888761235e565b612392565b90506103e8811192505b50509392505050565b60026020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b6000806000809150600090505b895181101561100257896000815181101515610ed157fe5b906020019060200201516003600581101515610ee957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff168a82815181101515610f1257fe5b906020019060200201516003600581101515610f2a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16141515610f5157600080fd5b610fe582610fe08c84815181101515610f6657fe5b906020019060200201518c85815181101515610f7e57fe5b90602001906020020151610f928d886123ae565b8c8c88815181101515610fa157fe5b906020019060200201518c89815181101515610fb957fe5b906020019060200201518c8a815181101515610fd157fe5b906020019060200201516118d3565b6123c8565b915087821415610ff457611002565b5b8080600101915050610eb9565b8192505b5050979650505050505050565b600061101d612a8c565b6000806101606040519081016040528088600060058110151561103c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600160058110151561106b57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600260058110151561109a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860036005811015156110c957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860046005811015156110f857fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200187600060068110151561112757fe5b6020020151815260200187600160068110151561114057fe5b6020020151815260200187600260068110151561115957fe5b6020020151815260200187600360068110151561117257fe5b6020020151815260200187600460068110151561118b57fe5b6020020151815260200161119f8989612073565b6000191681525092503373ffffffffffffffffffffffffffffffffffffffff16836000015173ffffffffffffffffffffffffffffffffffffffff161415156111e657600080fd5b60008360a001511180156111fe575060008360c00151115b801561120a5750600085115b151561121557600080fd5b8261012001514210151561127257826101400151600019166000600381111561123a57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61128d8360c00151611288856101400151611605565b6123ae565b915061129985836123e7565b905060008114156112f35782610140015160001916600160038111156112bb57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61131d600360008561014001516000191660001916815260200190815260200160002054826123c8565b60036000856101400151600019166000191681526020019081526020016000208190555082604001518360600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916836080015173ffffffffffffffffffffffffffffffffffffffff16846000015173ffffffffffffffffffffffffffffffffffffffff167f67d66f160bc93d925d05dae1794c90d2d6d6688b29b84ff069398a9b0458713186604001518760600151611455878a60c001518b60a00151611757565b878a6101400151604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182600019166000191681526020019550505050505060405180910390a48093505b5050509392505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b86518110156115d5576115c7878281518110151561154057fe5b90602001906020020151878381518110151561155857fe5b90602001906020020151878481518110151561157057fe5b90602001906020020151878581518110151561158857fe5b9060200190602002015187868151811015156115a057fe5b9060200190602002015187878151811015156115b857fe5b906020019060200201516115df565b5b8080600101915050611526565b5b50505050505050565b836115f087878760008888886118d3565b1415156115fc57600080fd5b5b505050505050565b600061164760026000846000191660001916815260200190815260200160002054600360008560001916600019168152602001908152602001600020546123c8565b90505b919050565b600060018560405180807f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250601c0182600019166000191681526020019150506040518091039020858585604051600081526020016040526000604051602001526040518085600019166000191681526020018460ff1660ff16815260200183600019166000191681526020018260001916600019168152602001945050505050602060405160208103908084039060008661646e5a03f1151561171457600080fd5b50506020604051035173ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161490505b95945050505050565b600061176c611766858461235e565b84612392565b90505b9392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b87518110156118535761184488828151811015156117bc57fe5b9060200190602002015188838151811015156117d457fe5b9060200190602002015188848151811015156117ec57fe5b9060200190602002015188888681518110151561180557fe5b90602001906020020151888781518110151561181d57fe5b90602001906020020151888881518110151561183557fe5b906020019060200201516118d3565b505b80806001019150506117a2565b5b5050505050505050565b60008090505b83518110156118cc576118bd848281518110151561187e57fe5b90602001906020020151848381518110151561189657fe5b9060200190602002015184848151811015156118ae57fe5b90602001906020020151611013565b505b8080600101915050611864565b5b50505050565b60006118dd612a8c565b600080600080610160604051908101604052808e60006005811015156118ff57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600160058110151561192e57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600260058110151561195d57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600360058110151561198c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e60046005811015156119bb57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018d60006006811015156119ea57fe5b602002015181526020018d6001600681101515611a0357fe5b602002015181526020018d6002600681101515611a1c57fe5b602002015181526020018d6003600681101515611a3557fe5b602002015181526020018d6004600681101515611a4e57fe5b60200201518152602001611a628f8f612073565b600019168152509450600073ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff161480611ad957503373ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff16145b1515611ae457600080fd5b60008560a00151118015611afc575060008560c00151115b8015611b08575060008b115b1515611b1357600080fd5b611b2985600001518661014001518b8b8b61164f565b1515611b3457600080fd5b84610120015142101515611b91578461014001516000191660006003811115611b5957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611bac8560c00151611ba7876101400151611605565b6123ae565b9350611bb88b856123e7565b95506000861415611c12578461014001516000191660016003811115611bda57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611c25868660c001518760a00151610e2d565b15611c79578461014001516000191660026003811115611c4157fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b89158015611c8e5750611c8c8587612401565b155b15611ce15784610140015160001916600380811115611ca957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611cf4868660c001518760a00151611757565b9250611d20600260008761014001516000191660001916815260200190815260200160002054876123c8565b600260008761014001516000191660001916815260200190815260200160002081905550611d58856040015186600001513386612751565b1515611d6357600080fd5b611d77856060015133876000015189612751565b1515611d8257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16856080015173ffffffffffffffffffffffffffffffffffffffff16141515611e815760008560e001511115611e1f57611ddc868660c001518760e00151611757565b9150611e136000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168660000151876080015185612751565b1515611e1e57600080fd5b5b60008561010001511115611e8057611e41868660c00151876101000151611757565b9050611e746000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633876080015184612751565b1515611e7f57600080fd5b5b5b84604001518560600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916856080015173ffffffffffffffffffffffffffffffffffffffff16866000015173ffffffffffffffffffffffffffffffffffffffff167f0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb33389604001518a60600151898d8a8a8f6101400151604051808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200186815260200185815260200184815260200183815260200182600019166000191681526020019850505050505050505060405180910390a48595505b5050505050979650505050505050565b60003083600060058110151561208557fe5b602002015184600160058110151561209957fe5b60200201518560026005811015156120ad57fe5b60200201518660036005811015156120c157fe5b60200201518760046005811015156120d557fe5b60200201518760006006811015156120e957fe5b60200201518860016006811015156120fd57fe5b602002015189600260068110151561211157fe5b60200201518a600360068110151561212557fe5b60200201518b600460068110151561213957fe5b60200201518c600560068110151561214d57fe5b6020020151604051808d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018781526020018681526020018581526020018481526020018381526020018281526020019c50505050505050505050505050604051809103902090505b92915050565b61138781565b6040805190810160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b6000808284029050600084148061237f575082848281151561237c57fe5b04145b151561238757fe5b8091505b5092915050565b60008082848115156123a057fe5b0490508091505b5092915050565b60008282111515156123bc57fe5b81830390505b92915050565b60008082840190508381101515156123dc57fe5b8091505b5092915050565b60008183106123f657816123f8565b825b90505b92915050565b60008060008060008060008060003397506124258a8c60c001518d60a00151611757565b9650600073ffffffffffffffffffffffffffffffffffffffff168b6080015173ffffffffffffffffffffffffffffffffffffffff161415156126d2576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6040015173ffffffffffffffffffffffffffffffffffffffff161495506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6060015173ffffffffffffffffffffffffffffffffffffffff161494506125208a8c60c001518d60e00151611757565b93506125368a8c60c001518d6101000151611757565b925085612543578361254e565b61254d87856123c8565b5b91508461255b5782612566565b6125658a846123c8565b5b9050816125986000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d600001516128ae565b10806125d15750816125cf6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d60000151612972565b105b806126055750806126036000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a6128ae565b105b806126395750806126376000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a612972565b105b156126475760009850612743565b851580156126805750866126638c604001518d600001516128ae565b108061267f57508661267d8c604001518d60000151612972565b105b5b1561268e5760009850612743565b841580156126bf5750896126a68c606001518a6128ae565b10806126be5750896126bc8c606001518a612972565b105b5b156126cd5760009850612743565b61273e565b866126e58c604001518d600001516128ae565b10806127015750866126ff8c604001518d60000151612972565b105b806127185750896127168c606001518a6128ae565b105b8061272f57508961272d8c606001518a612972565b105b1561273d5760009850612743565b5b600198505b505050505050505092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166315dacbea868686866000604051602001526040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050602060405180830381600087803b151561288857600080fd5b6102c65a03f1151561289957600080fd5b5050506040518051905090505b949350505050565b60008273ffffffffffffffffffffffffffffffffffffffff166370a0823161138761ffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600088803b151561295157600080fd5b87f1151561295e57600080fd5b505050506040518051905090505b92915050565b60008273ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e61138761ffff1684600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600088803b1515612a6b57600080fd5b87f11515612a7857600080fd5b505050506040518051905090505b92915050565b61016060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000801916815250905600a165627a7a72305820df5cabdc3a116e993e10bfb14823d18d9b798038d4c463a1703f9a584c456b7e0029';
+export const exchange_binary =
+ '0x6060604052341561000f57600080fd5b604051604080612c4d833981016040528080519060200190919080519060200190919050505b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50505b612b84806100c96000396000f300606060405236156100fa576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806314df96ee146100ff578063288cdc911461014c5780632ac1262214610187578063363349be146101c2578063394c21e7146103bc5780633b30ba591461044b5780634f150787146104a0578063741bcc93146106b25780637e9abb50146107535780638163681e1461078e57806398024a8b14610812578063add1cbc51461085b578063b7b2c7d6146108b0578063baa0181d14610acd578063bc61394a14610c1f578063cfc4d0ec14610cdf578063f06bbf7514610d6d578063ffa1ad7414610d9e575b600080fd5b341561010a57600080fd5b6101326004808035906020019091908035906020019091908035906020019091905050610e2d565b604051808215151515815260200191505060405180910390f35b341561015757600080fd5b610171600480803560001916906020019091905050610e7c565b6040518082815260200191505060405180910390f35b341561019257600080fd5b6101ac600480803560001916906020019091905050610e94565b6040518082815260200191505060405180910390f35b34156101cd57600080fd5b6103a660048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561024857848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610203565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156102c457848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061027f565b5050505050919080359060200190919080351515906020019091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050610eac565b6040518082815260200191505060405180910390f35b34156103c757600080fd5b6104356004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091905050611013565b6040518082815260200191505060405180910390f35b341561045657600080fd5b61045e6114fb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104ab57600080fd5b6106b060048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561052657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906104e1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156105a257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061055d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050611520565b005b34156106bd57600080fd5b6107516004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c00190600680602002604051908101604052809291908260066020028082843782019150505050509190803590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506115df565b005b341561075e57600080fd5b610778600480803560001916906020019091905050611605565b6040518082815260200191505060405180910390f35b341561079957600080fd5b6107f8600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080356000191690602001909190803560ff16906020019091908035600019169060200190919080356000191690602001909190505061164f565b604051808215151515815260200191505060405180910390f35b341561081d57600080fd5b6108456004808035906020019091908035906020019091908035906020019091905050611757565b6040518082815260200191505060405180910390f35b341561086657600080fd5b61086e611776565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156108bb57600080fd5b610acb60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561093657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906108f1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156109b257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061096d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035151590602001909190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061179c565b005b3415610ad857600080fd5b610c1d60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610b5357848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610b0e565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610bcf57848483905060c002016006806020026040519081016040528092919082600660200280828437820191505050505081526020019060010190610b8a565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061185e565b005b3415610c2a57600080fd5b610cc96004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091908035151590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506118d3565b6040518082815260200191505060405180910390f35b3415610cea57600080fd5b610d4f6004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091905050612073565b60405180826000191660001916815260200191505060405180910390f35b3415610d7857600080fd5b610d8061231f565b604051808261ffff1661ffff16815260200191505060405180910390f35b3415610da957600080fd5b610db1612325565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610df25780820151818401525b602081019050610dd6565b50505050905090810190601f168015610e1f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008060008486850991506000821415610e4a5760009250610e73565b610e69610e5a83620f424061235e565b610e64888761235e565b612392565b90506103e8811192505b50509392505050565b60026020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b6000806000809150600090505b895181101561100257896000815181101515610ed157fe5b906020019060200201516003600581101515610ee957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff168a82815181101515610f1257fe5b906020019060200201516003600581101515610f2a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16141515610f5157600080fd5b610fe582610fe08c84815181101515610f6657fe5b906020019060200201518c85815181101515610f7e57fe5b90602001906020020151610f928d886123ae565b8c8c88815181101515610fa157fe5b906020019060200201518c89815181101515610fb957fe5b906020019060200201518c8a815181101515610fd157fe5b906020019060200201516118d3565b6123c8565b915087821415610ff457611002565b5b8080600101915050610eb9565b8192505b5050979650505050505050565b600061101d612a8c565b6000806101606040519081016040528088600060058110151561103c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600160058110151561106b57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600260058110151561109a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860036005811015156110c957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860046005811015156110f857fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200187600060068110151561112757fe5b6020020151815260200187600160068110151561114057fe5b6020020151815260200187600260068110151561115957fe5b6020020151815260200187600360068110151561117257fe5b6020020151815260200187600460068110151561118b57fe5b6020020151815260200161119f8989612073565b6000191681525092503373ffffffffffffffffffffffffffffffffffffffff16836000015173ffffffffffffffffffffffffffffffffffffffff161415156111e657600080fd5b60008360a001511180156111fe575060008360c00151115b801561120a5750600085115b151561121557600080fd5b8261012001514210151561127257826101400151600019166000600381111561123a57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61128d8360c00151611288856101400151611605565b6123ae565b915061129985836123e7565b905060008114156112f35782610140015160001916600160038111156112bb57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61131d600360008561014001516000191660001916815260200190815260200160002054826123c8565b60036000856101400151600019166000191681526020019081526020016000208190555082604001518360600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916836080015173ffffffffffffffffffffffffffffffffffffffff16846000015173ffffffffffffffffffffffffffffffffffffffff167f67d66f160bc93d925d05dae1794c90d2d6d6688b29b84ff069398a9b0458713186604001518760600151611455878a60c001518b60a00151611757565b878a6101400151604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182600019166000191681526020019550505050505060405180910390a48093505b5050509392505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b86518110156115d5576115c7878281518110151561154057fe5b90602001906020020151878381518110151561155857fe5b90602001906020020151878481518110151561157057fe5b90602001906020020151878581518110151561158857fe5b9060200190602002015187868151811015156115a057fe5b9060200190602002015187878151811015156115b857fe5b906020019060200201516115df565b5b8080600101915050611526565b5b50505050505050565b836115f087878760008888886118d3565b1415156115fc57600080fd5b5b505050505050565b600061164760026000846000191660001916815260200190815260200160002054600360008560001916600019168152602001908152602001600020546123c8565b90505b919050565b600060018560405180807f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250601c0182600019166000191681526020019150506040518091039020858585604051600081526020016040526000604051602001526040518085600019166000191681526020018460ff1660ff16815260200183600019166000191681526020018260001916600019168152602001945050505050602060405160208103908084039060008661646e5a03f1151561171457600080fd5b50506020604051035173ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161490505b95945050505050565b600061176c611766858461235e565b84612392565b90505b9392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b87518110156118535761184488828151811015156117bc57fe5b9060200190602002015188838151811015156117d457fe5b9060200190602002015188848151811015156117ec57fe5b9060200190602002015188888681518110151561180557fe5b90602001906020020151888781518110151561181d57fe5b90602001906020020151888881518110151561183557fe5b906020019060200201516118d3565b505b80806001019150506117a2565b5b5050505050505050565b60008090505b83518110156118cc576118bd848281518110151561187e57fe5b90602001906020020151848381518110151561189657fe5b9060200190602002015184848151811015156118ae57fe5b90602001906020020151611013565b505b8080600101915050611864565b5b50505050565b60006118dd612a8c565b600080600080610160604051908101604052808e60006005811015156118ff57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600160058110151561192e57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600260058110151561195d57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600360058110151561198c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e60046005811015156119bb57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018d60006006811015156119ea57fe5b602002015181526020018d6001600681101515611a0357fe5b602002015181526020018d6002600681101515611a1c57fe5b602002015181526020018d6003600681101515611a3557fe5b602002015181526020018d6004600681101515611a4e57fe5b60200201518152602001611a628f8f612073565b600019168152509450600073ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff161480611ad957503373ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff16145b1515611ae457600080fd5b60008560a00151118015611afc575060008560c00151115b8015611b08575060008b115b1515611b1357600080fd5b611b2985600001518661014001518b8b8b61164f565b1515611b3457600080fd5b84610120015142101515611b91578461014001516000191660006003811115611b5957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611bac8560c00151611ba7876101400151611605565b6123ae565b9350611bb88b856123e7565b95506000861415611c12578461014001516000191660016003811115611bda57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611c25868660c001518760a00151610e2d565b15611c79578461014001516000191660026003811115611c4157fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b89158015611c8e5750611c8c8587612401565b155b15611ce15784610140015160001916600380811115611ca957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611cf4868660c001518760a00151611757565b9250611d20600260008761014001516000191660001916815260200190815260200160002054876123c8565b600260008761014001516000191660001916815260200190815260200160002081905550611d58856040015186600001513386612751565b1515611d6357600080fd5b611d77856060015133876000015189612751565b1515611d8257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16856080015173ffffffffffffffffffffffffffffffffffffffff16141515611e815760008560e001511115611e1f57611ddc868660c001518760e00151611757565b9150611e136000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168660000151876080015185612751565b1515611e1e57600080fd5b5b60008561010001511115611e8057611e41868660c00151876101000151611757565b9050611e746000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633876080015184612751565b1515611e7f57600080fd5b5b5b84604001518560600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916856080015173ffffffffffffffffffffffffffffffffffffffff16866000015173ffffffffffffffffffffffffffffffffffffffff167f0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb33389604001518a60600151898d8a8a8f6101400151604051808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200186815260200185815260200184815260200183815260200182600019166000191681526020019850505050505050505060405180910390a48595505b5050505050979650505050505050565b60003083600060058110151561208557fe5b602002015184600160058110151561209957fe5b60200201518560026005811015156120ad57fe5b60200201518660036005811015156120c157fe5b60200201518760046005811015156120d557fe5b60200201518760006006811015156120e957fe5b60200201518860016006811015156120fd57fe5b602002015189600260068110151561211157fe5b60200201518a600360068110151561212557fe5b60200201518b600460068110151561213957fe5b60200201518c600560068110151561214d57fe5b6020020151604051808d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018781526020018681526020018581526020018481526020018381526020018281526020019c50505050505050505050505050604051809103902090505b92915050565b61138781565b6040805190810160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b6000808284029050600084148061237f575082848281151561237c57fe5b04145b151561238757fe5b8091505b5092915050565b60008082848115156123a057fe5b0490508091505b5092915050565b60008282111515156123bc57fe5b81830390505b92915050565b60008082840190508381101515156123dc57fe5b8091505b5092915050565b60008183106123f657816123f8565b825b90505b92915050565b60008060008060008060008060003397506124258a8c60c001518d60a00151611757565b9650600073ffffffffffffffffffffffffffffffffffffffff168b6080015173ffffffffffffffffffffffffffffffffffffffff161415156126d2576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6040015173ffffffffffffffffffffffffffffffffffffffff161495506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6060015173ffffffffffffffffffffffffffffffffffffffff161494506125208a8c60c001518d60e00151611757565b93506125368a8c60c001518d6101000151611757565b925085612543578361254e565b61254d87856123c8565b5b91508461255b5782612566565b6125658a846123c8565b5b9050816125986000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d600001516128ae565b10806125d15750816125cf6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d60000151612972565b105b806126055750806126036000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a6128ae565b105b806126395750806126376000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a612972565b105b156126475760009850612743565b851580156126805750866126638c604001518d600001516128ae565b108061267f57508661267d8c604001518d60000151612972565b105b5b1561268e5760009850612743565b841580156126bf5750896126a68c606001518a6128ae565b10806126be5750896126bc8c606001518a612972565b105b5b156126cd5760009850612743565b61273e565b866126e58c604001518d600001516128ae565b10806127015750866126ff8c604001518d60000151612972565b105b806127185750896127168c606001518a6128ae565b105b8061272f57508961272d8c606001518a612972565b105b1561273d5760009850612743565b5b600198505b505050505050505092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166315dacbea868686866000604051602001526040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050602060405180830381600087803b151561288857600080fd5b6102c65a03f1151561289957600080fd5b5050506040518051905090505b949350505050565b60008273ffffffffffffffffffffffffffffffffffffffff166370a0823161138761ffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600088803b151561295157600080fd5b87f1151561295e57600080fd5b505050506040518051905090505b92915050565b60008273ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e61138761ffff1684600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600088803b1515612a6b57600080fd5b87f11515612a7857600080fd5b505050506040518051905090505b92915050565b61016060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000801916815250905600a165627a7a72305820df5cabdc3a116e993e10bfb14823d18d9b798038d4c463a1703f9a584c456b7e0029';
diff --git a/packages/contracts/deploy/test/util/constants.ts b/packages/contracts/deploy/test/util/constants.ts
index 65525a1f7..1bd062725 100644
--- a/packages/contracts/deploy/test/util/constants.ts
+++ b/packages/contracts/deploy/test/util/constants.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from 'bignumber.js';
export const constants = {
networkId: 0,
diff --git a/packages/contracts/globalsAugment.d.ts b/packages/contracts/globalsAugment.d.ts
index 21f3742ae..c3ea54ffe 100644
--- a/packages/contracts/globalsAugment.d.ts
+++ b/packages/contracts/globalsAugment.d.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from 'bignumber.js';
// HACK: This module overrides the Chai namespace so that we can use BigNumber types inside.
// Source: https://github.com/Microsoft/TypeScript/issues/7352#issuecomment-191547232
@@ -16,4 +16,4 @@ declare global {
}
}
/* tslint:enable */
-} \ No newline at end of file
+}
diff --git a/packages/contracts/migrations/1_initial_migration.ts b/packages/contracts/migrations/1_initial_migration.ts
index b34bbc2a1..8661ee218 100644
--- a/packages/contracts/migrations/1_initial_migration.ts
+++ b/packages/contracts/migrations/1_initial_migration.ts
@@ -1,5 +1,5 @@
-import {Artifacts} from '../util/artifacts';
-const {Migrations} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+const { Migrations } = new Artifacts(artifacts);
module.exports = (deployer: any) => {
deployer.deploy(Migrations);
diff --git a/packages/contracts/migrations/2_deploy_independent_contracts.ts b/packages/contracts/migrations/2_deploy_independent_contracts.ts
index b465db7db..ac1752347 100644
--- a/packages/contracts/migrations/2_deploy_independent_contracts.ts
+++ b/packages/contracts/migrations/2_deploy_independent_contracts.ts
@@ -1,11 +1,6 @@
-import {Artifacts} from '../util/artifacts';
-import {MultiSigConfigByNetwork} from '../util/types';
-const {
- MultiSigWalletWithTimeLock,
- TokenTransferProxy,
- EtherToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+import { MultiSigConfigByNetwork } from '../util/types';
+const { MultiSigWalletWithTimeLock, TokenTransferProxy, EtherToken, TokenRegistry } = new Artifacts(artifacts);
let multiSigConfigByNetwork: MultiSigConfigByNetwork;
try {
@@ -25,13 +20,15 @@ module.exports = (deployer: any, network: string, accounts: string[]) => {
};
const config = multiSigConfigByNetwork[network] || defaultConfig;
if (network !== 'live') {
- deployer.deploy(MultiSigWalletWithTimeLock, config.owners,
- config.confirmationsRequired, config.secondsRequired)
+ deployer
+ .deploy(MultiSigWalletWithTimeLock, config.owners, config.confirmationsRequired, config.secondsRequired)
.then(() => {
return deployer.deploy(TokenTransferProxy);
- }).then(() => {
+ })
+ .then(() => {
return deployer.deploy(TokenRegistry);
- }).then(() => {
+ })
+ .then(() => {
return deployer.deploy(EtherToken);
});
} else {
diff --git a/packages/contracts/migrations/3_register_tokens.ts b/packages/contracts/migrations/3_register_tokens.ts
index f81693628..d5cf63f94 100644
--- a/packages/contracts/migrations/3_register_tokens.ts
+++ b/packages/contracts/migrations/3_register_tokens.ts
@@ -1,86 +1,95 @@
import * as Bluebird from 'bluebird';
import * as _ from 'lodash';
-import {Artifacts} from '../util/artifacts';
-import {constants} from '../util/constants';
-import {ContractInstance, Token} from '../util/types';
+import { Artifacts } from '../util/artifacts';
+import { constants } from '../util/constants';
+import { ContractInstance, Token } from '../util/types';
-import {tokenInfo} from './config/token_info';
-const {
- DummyToken,
- EtherToken,
- ZRXToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+import { tokenInfo } from './config/token_info';
+const { DummyToken, EtherToken, ZRXToken, TokenRegistry } = new Artifacts(artifacts);
module.exports = (deployer: any, network: string) => {
const tokens = network === 'live' ? tokenInfo.live : tokenInfo.development;
- deployer.then(() => {
- return TokenRegistry.deployed();
- }).then((tokenRegistry: ContractInstance) => {
- if (network !== 'live') {
- const totalSupply = Math.pow(10, 18) * 1000000000;
- return Bluebird.each(tokens.map((token: Token) => DummyToken.new(
- token.name,
- token.symbol,
- token.decimals,
- totalSupply,
- )), _.noop).then((dummyTokens: ContractInstance[]) => {
- const weth = {
- address: EtherToken.address,
- name: 'Ether Token',
- symbol: 'WETH',
- url: '',
+ deployer
+ .then(() => {
+ return TokenRegistry.deployed();
+ })
+ .then((tokenRegistry: ContractInstance) => {
+ if (network !== 'live') {
+ const totalSupply = Math.pow(10, 18) * 1000000000;
+ return Bluebird.each(
+ tokens.map((token: Token) => DummyToken.new(token.name, token.symbol, token.decimals, totalSupply)),
+ _.noop,
+ ).then((dummyTokens: ContractInstance[]) => {
+ const weth = {
+ address: EtherToken.address,
+ name: 'Ether Token',
+ symbol: 'WETH',
+ url: '',
+ decimals: 18,
+ ipfsHash: constants.NULL_BYTES,
+ swarmHash: constants.NULL_BYTES,
+ };
+ return Bluebird.each(
+ dummyTokens
+ .map((tokenContract: ContractInstance, i: number) => {
+ const token = tokens[i];
+ return tokenRegistry.addToken(
+ tokenContract.address,
+ token.name,
+ token.symbol,
+ token.decimals,
+ token.ipfsHash,
+ token.swarmHash,
+ );
+ })
+ .concat(
+ tokenRegistry.addToken(
+ weth.address,
+ weth.name,
+ weth.symbol,
+ weth.decimals,
+ weth.ipfsHash,
+ weth.swarmHash,
+ ),
+ ),
+ _.noop,
+ );
+ });
+ } else {
+ const zrx = {
+ address: ZRXToken.address,
+ name: '0x Protocol Token',
+ symbol: 'ZRX',
+ url: 'https://www.0xproject.com/',
decimals: 18,
ipfsHash: constants.NULL_BYTES,
swarmHash: constants.NULL_BYTES,
};
- return Bluebird.each(dummyTokens.map((tokenContract: ContractInstance, i: number) => {
- const token = tokens[i];
- return tokenRegistry.addToken(
- tokenContract.address,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash,
- );
- }).concat(tokenRegistry.addToken(
- weth.address,
- weth.name,
- weth.symbol,
- weth.decimals,
- weth.ipfsHash,
- weth.swarmHash,
- )), _.noop);
- });
- } else {
- const zrx = {
- address: ZRXToken.address,
- name: '0x Protocol Token',
- symbol: 'ZRX',
- url: 'https://www.0xproject.com/',
- decimals: 18,
- ipfsHash: constants.NULL_BYTES,
- swarmHash: constants.NULL_BYTES,
- };
- return Bluebird.each(tokens.map((token: Token) => {
- return tokenRegistry.addToken(
- token.address,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash,
+ return Bluebird.each(
+ tokens
+ .map((token: Token) => {
+ return tokenRegistry.addToken(
+ token.address,
+ token.name,
+ token.symbol,
+ token.decimals,
+ token.ipfsHash,
+ token.swarmHash,
+ );
+ })
+ .concat(
+ tokenRegistry.addToken(
+ zrx.address,
+ zrx.name,
+ zrx.symbol,
+ zrx.decimals,
+ zrx.ipfsHash,
+ zrx.swarmHash,
+ ),
+ ),
+ _.noop,
);
- }).concat(tokenRegistry.addToken(
- zrx.address,
- zrx.name,
- zrx.symbol,
- zrx.decimals,
- zrx.ipfsHash,
- zrx.swarmHash,
- )), _.noop);
- }
- });
+ }
+ });
};
diff --git a/packages/contracts/migrations/4_configure_proxy.ts b/packages/contracts/migrations/4_configure_proxy.ts
index f4c4a725b..ff3b844d6 100644
--- a/packages/contracts/migrations/4_configure_proxy.ts
+++ b/packages/contracts/migrations/4_configure_proxy.ts
@@ -1,27 +1,22 @@
-import {Artifacts} from '../util/artifacts';
-import {ContractInstance} from '../util/types';
-const {
- TokenTransferProxy,
- Exchange,
- TokenRegistry,
-} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+import { ContractInstance } from '../util/types';
+const { TokenTransferProxy, Exchange, TokenRegistry } = new Artifacts(artifacts);
let tokenTransferProxy: ContractInstance;
module.exports = (deployer: any) => {
- deployer.then(async () => {
- return Promise.all([
- TokenTransferProxy.deployed(),
- TokenRegistry.deployed(),
- ]);
- })
- .then((instances: ContractInstance[]) => {
- let tokenRegistry: ContractInstance;
- [tokenTransferProxy, tokenRegistry] = instances;
- return tokenRegistry.getTokenAddressBySymbol('ZRX');
- })
- .then((ptAddress: string) => {
- return deployer.deploy(Exchange, ptAddress, tokenTransferProxy.address);
- }).then(() => {
- return tokenTransferProxy.addAuthorizedAddress(Exchange.address);
- });
+ deployer
+ .then(async () => {
+ return Promise.all([TokenTransferProxy.deployed(), TokenRegistry.deployed()]);
+ })
+ .then((instances: ContractInstance[]) => {
+ let tokenRegistry: ContractInstance;
+ [tokenTransferProxy, tokenRegistry] = instances;
+ return tokenRegistry.getTokenAddressBySymbol('ZRX');
+ })
+ .then((ptAddress: string) => {
+ return deployer.deploy(Exchange, ptAddress, tokenTransferProxy.address);
+ })
+ .then(() => {
+ return tokenTransferProxy.addAuthorizedAddress(Exchange.address);
+ });
};
diff --git a/packages/contracts/migrations/5_transfer_ownership.ts b/packages/contracts/migrations/5_transfer_ownership.ts
index 17de9bc7b..a27801de3 100644
--- a/packages/contracts/migrations/5_transfer_ownership.ts
+++ b/packages/contracts/migrations/5_transfer_ownership.ts
@@ -1,25 +1,20 @@
-import {Artifacts} from '../util/artifacts';
-import {ContractInstance} from '../util/types';
-const {
- TokenTransferProxy,
- MultiSigWalletWithTimeLock,
- TokenRegistry,
-} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+import { ContractInstance } from '../util/types';
+const { TokenTransferProxy, MultiSigWalletWithTimeLock, TokenRegistry } = new Artifacts(artifacts);
let tokenRegistry: ContractInstance;
module.exports = (deployer: any, network: string) => {
if (network !== 'development') {
deployer.then(async () => {
- return Promise.all([
- TokenTransferProxy.deployed(),
- TokenRegistry.deployed(),
- ]).then((instances: ContractInstance[]) => {
- let tokenTransferProxy: ContractInstance;
- [tokenTransferProxy, tokenRegistry] = instances;
- return tokenTransferProxy.transferOwnership(MultiSigWalletWithTimeLock.address);
- }).then(() => {
- return tokenRegistry.transferOwnership(MultiSigWalletWithTimeLock.address);
- });
+ return Promise.all([TokenTransferProxy.deployed(), TokenRegistry.deployed()])
+ .then((instances: ContractInstance[]) => {
+ let tokenTransferProxy: ContractInstance;
+ [tokenTransferProxy, tokenRegistry] = instances;
+ return tokenTransferProxy.transferOwnership(MultiSigWalletWithTimeLock.address);
+ })
+ .then(() => {
+ return tokenRegistry.transferOwnership(MultiSigWalletWithTimeLock.address);
+ });
});
}
};
diff --git a/packages/contracts/migrations/config/multisig_sample.ts b/packages/contracts/migrations/config/multisig_sample.ts
index eca54ba28..97cdc2eae 100644
--- a/packages/contracts/migrations/config/multisig_sample.ts
+++ b/packages/contracts/migrations/config/multisig_sample.ts
@@ -1,4 +1,4 @@
-import {MultiSigConfigByNetwork} from '../../util/types';
+import { MultiSigConfigByNetwork } from '../../util/types';
// Make a copy of this file named `multisig.js` and input custom params as needed
export const multiSig: MultiSigConfigByNetwork = {
diff --git a/packages/contracts/migrations/config/token_info.ts b/packages/contracts/migrations/config/token_info.ts
index 766a28664..6ae67175e 100644
--- a/packages/contracts/migrations/config/token_info.ts
+++ b/packages/contracts/migrations/config/token_info.ts
@@ -1,5 +1,5 @@
-import {constants} from '../../util/constants';
-import {TokenInfoByNetwork} from '../../util/types';
+import { constants } from '../../util/constants';
+import { TokenInfoByNetwork } from '../../util/types';
export const tokenInfo: TokenInfoByNetwork = {
development: [
diff --git a/packages/contracts/test/ts/ether_token.ts b/packages/contracts/test/ts/ether_token.ts
index 99630583f..98f477838 100644
--- a/packages/contracts/test/ts/ether_token.ts
+++ b/packages/contracts/test/ts/ether_token.ts
@@ -1,15 +1,15 @@
-import {ZeroEx, ZeroExError} from '0x.js';
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx, ZeroExError } from '0x.js';
+import { promisify } from '@0xproject/utils';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import Web3 = require('web3');
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {EtherToken} = new Artifacts(artifacts);
+const { EtherToken } = new Artifacts(artifacts);
chaiSetup.configure();
const expect = chai.expect;
@@ -44,8 +44,9 @@ contract('EtherToken', (accounts: string[]) => {
const initEthBalance = await getEthBalanceAsync(account);
const ethToDeposit = initEthBalance.plus(1);
- return expect(zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account))
- .to.be.rejectedWith(ZeroExError.InsufficientEthBalanceForDeposit);
+ return expect(zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account)).to.be.rejectedWith(
+ ZeroExError.InsufficientEthBalanceForDeposit,
+ );
});
it('should convert deposited Ether to wrapped Ether tokens', async () => {
@@ -71,8 +72,9 @@ contract('EtherToken', (accounts: string[]) => {
const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
const ethTokensToWithdraw = initEthTokenBalance.plus(1);
- return expect(zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account))
- .to.be.rejectedWith(ZeroExError.InsufficientWEthBalanceForWithdrawal);
+ return expect(
+ zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account),
+ ).to.be.rejectedWith(ZeroExError.InsufficientWEthBalanceForWithdrawal);
});
it('should convert ether tokens to ether with sufficient balance', async () => {
@@ -89,8 +91,9 @@ contract('EtherToken', (accounts: string[]) => {
const finalEthBalance = await getEthBalanceAsync(account);
const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
- expect(finalEthBalance).to.be.bignumber
- .equal(initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)));
+ expect(finalEthBalance).to.be.bignumber.equal(
+ initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)),
+ );
expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.minus(ethTokensToWithdraw));
});
});
diff --git a/packages/contracts/test/ts/exchange/core.ts b/packages/contracts/test/ts/exchange/core.ts
index aef2b5a5d..19887a3e6 100644
--- a/packages/contracts/test/ts/exchange/core.ts
+++ b/packages/contracts/test/ts/exchange/core.ts
@@ -1,28 +1,22 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
-import {Artifacts} from '../../../util/artifacts';
-import {Balances} from '../../../util/balances';
-import {constants} from '../../../util/constants';
-import {crypto} from '../../../util/crypto';
-import {ExchangeWrapper} from '../../../util/exchange_wrapper';
-import {Order} from '../../../util/order';
-import {OrderFactory} from '../../../util/order_factory';
-import {BalancesByOwner, ContractInstance, ExchangeContractErrs} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { Balances } from '../../../util/balances';
+import { constants } from '../../../util/constants';
+import { crypto } from '../../../util/crypto';
+import { ExchangeWrapper } from '../../../util/exchange_wrapper';
+import { Order } from '../../../util/order';
+import { OrderFactory } from '../../../util/order_factory';
+import { BalancesByOwner, ContractInstance, ExchangeContractErrs } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- Exchange,
- TokenTransferProxy,
- DummyToken,
- TokenRegistry,
- MaliciousToken,
-} = new Artifacts(artifacts);
+const { Exchange, TokenTransferProxy, DummyToken, TokenRegistry, MaliciousToken } = new Artifacts(artifacts);
// In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle
// with type `any` to a variable of type `Web3`.
@@ -52,10 +46,7 @@ contract('Exchange', (accounts: string[]) => {
let zeroEx: ZeroEx;
before(async () => {
- [tokenRegistry, exchange] = await Promise.all([
- TokenRegistry.deployed(),
- Exchange.deployed(),
- ]);
+ [tokenRegistry, exchange] = await Promise.all([TokenRegistry.deployed(), Exchange.deployed()]);
exWrapper = new ExchangeWrapper(exchange);
zeroEx = new ZeroEx(web3.currentProvider, {
exchangeContractAddress: exchange.address,
@@ -88,18 +79,30 @@ contract('Exchange', (accounts: string[]) => {
]);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
- rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker}),
- rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker}),
- rep.setBalance(maker, INITIAL_BALANCE, {from: tokenOwner}),
- rep.setBalance(taker, INITIAL_BALANCE, {from: tokenOwner}),
- dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker}),
- dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker}),
- dgd.setBalance(maker, INITIAL_BALANCE, {from: tokenOwner}),
- dgd.setBalance(taker, INITIAL_BALANCE, {from: tokenOwner}),
- zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker}),
- zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker}),
- zrx.setBalance(maker, INITIAL_BALANCE, {from: tokenOwner}),
- zrx.setBalance(taker, INITIAL_BALANCE, {from: tokenOwner}),
+ rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ }),
+ rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ }),
+ rep.setBalance(maker, INITIAL_BALANCE, { from: tokenOwner }),
+ rep.setBalance(taker, INITIAL_BALANCE, { from: tokenOwner }),
+ dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ }),
+ dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ }),
+ dgd.setBalance(maker, INITIAL_BALANCE, { from: tokenOwner }),
+ dgd.setBalance(taker, INITIAL_BALANCE, { from: tokenOwner }),
+ zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ }),
+ zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ }),
+ zrx.setBalance(maker, INITIAL_BALANCE, { from: tokenOwner }),
+ zrx.setBalance(taker, INITIAL_BALANCE, { from: tokenOwner }),
]);
});
@@ -133,22 +136,29 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(3),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount1 = new BigNumber(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: fillTakerTokenAmount1});
+ await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: fillTakerTokenAmount1,
+ });
- const filledTakerTokenAmountAfter1 =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
const fillTakerTokenAmount2 = new BigNumber(1);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: fillTakerTokenAmount2});
+ await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: fillTakerTokenAmount2,
+ });
- const filledTakerTokenAmountAfter2 =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter2).to.be.bignumber.equal(filledTakerTokenAmountAfter1);
});
@@ -158,42 +168,51 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should transfer the correct amounts when makerTokenAmount > takerTokenAmount', async () => {
@@ -202,42 +221,51 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should transfer the correct amounts when makerTokenAmount < takerTokenAmount', async () => {
@@ -246,42 +274,51 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should transfer the correct amounts when taker is specified and order is claimed by taker', async () => {
@@ -291,78 +328,95 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount});
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount,
+ });
- expect(res.logs[0].args.filledTakerTokenAmount)
- .to.be.bignumber.equal(order.params.takerTokenAmount.minus(fillTakerTokenAmount));
+ expect(res.logs[0].args.filledTakerTokenAmount).to.be.bignumber.equal(
+ order.params.takerTokenAmount.minus(fillTakerTokenAmount),
+ );
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(order.params.makerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(order.params.takerTokenAmount));
- expect(newBalances[maker][zrx.address])
- .to.be.bignumber.equal(balances[maker][zrx.address].minus(order.params.makerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(order.params.takerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(order.params.makerTokenAmount));
- expect(newBalances[taker][zrx.address])
- .to.be.bignumber.equal(balances[taker][zrx.address].minus(order.params.takerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee)),
- );
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(order.params.makerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(order.params.takerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(order.params.makerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(order.params.takerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(order.params.makerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(order.params.takerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee)),
+ );
});
it('should log 1 event with the correct arguments when order has a feeRecipient', async () => {
const divisor = 2;
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor)});
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ });
expect(res.logs).to.have.length(1);
const logArgs = res.logs[0].args;
@@ -391,8 +445,9 @@ contract('Exchange', (accounts: string[]) => {
feeRecipient: ZeroEx.NULL_ADDRESS,
});
const divisor = 2;
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor)});
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ });
expect(res.logs).to.have.length(1);
const logArgs = res.logs[0].args;
@@ -455,13 +510,15 @@ contract('Exchange', (accounts: string[]) => {
it('should throw if fillTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
- return expect(exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: new BigNumber(0)}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: new BigNumber(0),
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if maker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
order = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
@@ -472,19 +529,20 @@ contract('Exchange', (accounts: string[]) => {
});
it('should throw if maker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
order = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
- return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if taker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
order = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
@@ -495,59 +553,70 @@ contract('Exchange', (accounts: string[]) => {
});
it('should throw if taker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
order = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
- return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if maker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
- await rep.approve(TokenTransferProxy.address, 0, {from: maker});
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
+ await rep.approve(TokenTransferProxy.address, 0, { from: maker });
await exWrapper.fillOrderAsync(order, taker);
- await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker});
+ await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if maker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
- await rep.approve(TokenTransferProxy.address, 0, {from: maker});
- expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.REVERT);
- await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker});
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
+ await rep.approve(TokenTransferProxy.address, 0, { from: maker });
+ expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
+ await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ });
});
it('should not change balances if taker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
- await dgd.approve(TokenTransferProxy.address, 0, {from: taker});
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
+ await dgd.approve(TokenTransferProxy.address, 0, { from: taker });
await exWrapper.fillOrderAsync(order, taker);
- await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker});
+ await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if taker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
- await dgd.approve(TokenTransferProxy.address, 0, {from: taker});
- expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.REVERT);
- await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker});
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
+ await dgd.approve(TokenTransferProxy.address, 0, { from: taker });
+ expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
+ await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ });
});
it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker balance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXBalance = new BigNumber(balances[maker][zrx.address]);
order = await orderFactory.newSignedOrderAsync({
makerToken: zrx.address,
@@ -560,8 +629,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker allowance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXAllowance = await zrx.allowance(maker, TokenTransferProxy.address);
order = await orderFactory.newSignedOrderAsync({
makerToken: zrx.address,
@@ -574,8 +642,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker balance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXBalance = new BigNumber(balances[taker][zrx.address]);
order = await orderFactory.newSignedOrderAsync({
takerToken: zrx.address,
@@ -588,8 +655,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker allowance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXAllowance = await zrx.allowance(taker, TokenTransferProxy.address);
order = await orderFactory.newSignedOrderAsync({
takerToken: zrx.address,
@@ -604,14 +670,17 @@ contract('Exchange', (accounts: string[]) => {
it('should throw if getBalance or getAllowance attempts to change state and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const maliciousToken = await MaliciousToken.new();
- await maliciousToken.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker});
+ await maliciousToken.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, { from: taker });
order = await orderFactory.newSignedOrderAsync({
takerToken: maliciousToken.address,
});
- return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: false}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: false,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if an order is expired', async () => {
@@ -674,13 +743,18 @@ contract('Exchange', (accounts: string[]) => {
it('should throw if cancelTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
- return expect(exWrapper.cancelOrderAsync(order, maker, {cancelTakerTokenAmount: new BigNumber(0)}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ exWrapper.cancelOrderAsync(order, maker, {
+ cancelTakerTokenAmount: new BigNumber(0),
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should be able to cancel a full order', async () => {
await exWrapper.cancelOrderAsync(order, maker);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: order.params.takerTokenAmount.div(2)});
+ await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -688,43 +762,55 @@ contract('Exchange', (accounts: string[]) => {
it('should be able to cancel part of an order', async () => {
const cancelTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.cancelOrderAsync(order, maker, {cancelTakerTokenAmount});
+ await exWrapper.cancelOrderAsync(order, maker, {
+ cancelTakerTokenAmount,
+ });
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount});
- expect(res.logs[0].args.filledTakerTokenAmount)
- .to.be.bignumber.equal(order.params.takerTokenAmount.minus(cancelTakerTokenAmount));
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount,
+ });
+ expect(res.logs[0].args.filledTakerTokenAmount).to.be.bignumber.equal(
+ order.params.takerTokenAmount.minus(cancelTakerTokenAmount),
+ );
const newBalances = await dmyBalances.getAsync();
const cancelMakerTokenAmount = cancelTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(cancelMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(cancelMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(cancelMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(cancelMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(cancelTakerTokenAmount));
- expect(newBalances[maker][zrx.address])
- .to.be.bignumber.equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(cancelTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(cancelMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(cancelMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(cancelMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(cancelTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(cancelTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(cancelMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should log 1 event with correct arguments', async () => {
const divisor = 2;
- const res = await exWrapper.cancelOrderAsync(order, maker,
- {cancelTakerTokenAmount: order.params.takerTokenAmount.div(divisor)});
+ const res = await exWrapper.cancelOrderAsync(order, maker, {
+ cancelTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ });
expect(res.logs).to.have.length(1);
const logArgs = res.logs[0].args;
diff --git a/packages/contracts/test/ts/exchange/helpers.ts b/packages/contracts/test/ts/exchange/helpers.ts
index a39f4d9e2..5c5b656b5 100644
--- a/packages/contracts/test/ts/exchange/helpers.ts
+++ b/packages/contracts/test/ts/exchange/helpers.ts
@@ -1,21 +1,18 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
-import {Artifacts} from '../../../util/artifacts';
-import {ExchangeWrapper} from '../../../util/exchange_wrapper';
-import {Order} from '../../../util/order';
-import {OrderFactory} from '../../../util/order_factory';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { ExchangeWrapper } from '../../../util/exchange_wrapper';
+import { Order } from '../../../util/order';
+import { OrderFactory } from '../../../util/order_factory';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- Exchange,
- TokenRegistry,
-} = new Artifacts(artifacts);
+const { Exchange, TokenRegistry } = new Artifacts(artifacts);
contract('Exchange', (accounts: string[]) => {
const maker = accounts[0];
@@ -26,10 +23,7 @@ contract('Exchange', (accounts: string[]) => {
let orderFactory: OrderFactory;
before(async () => {
- const [tokenRegistry, exchange] = await Promise.all([
- TokenRegistry.deployed(),
- Exchange.deployed(),
- ]);
+ const [tokenRegistry, exchange] = await Promise.all([TokenRegistry.deployed(), Exchange.deployed()]);
exchangeWrapper = new ExchangeWrapper(exchange);
const [repAddress, dgdAddress] = await Promise.all([
tokenRegistry.getTokenAddressBySymbol('REP'),
diff --git a/packages/contracts/test/ts/exchange/wrapper.ts b/packages/contracts/test/ts/exchange/wrapper.ts
index 13a0b6058..77cd03388 100644
--- a/packages/contracts/test/ts/exchange/wrapper.ts
+++ b/packages/contracts/test/ts/exchange/wrapper.ts
@@ -1,25 +1,20 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import * as _ from 'lodash';
-import {Artifacts} from '../../../util/artifacts';
-import {Balances} from '../../../util/balances';
-import {constants} from '../../../util/constants';
-import {ExchangeWrapper} from '../../../util/exchange_wrapper';
-import {Order} from '../../../util/order';
-import {OrderFactory} from '../../../util/order_factory';
-import {BalancesByOwner, ContractInstance} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { Balances } from '../../../util/balances';
+import { constants } from '../../../util/constants';
+import { ExchangeWrapper } from '../../../util/exchange_wrapper';
+import { Order } from '../../../util/order';
+import { OrderFactory } from '../../../util/order_factory';
+import { BalancesByOwner, ContractInstance } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- Exchange,
- TokenTransferProxy,
- DummyToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+const { Exchange, TokenTransferProxy, DummyToken, TokenRegistry } = new Artifacts(artifacts);
contract('Exchange', (accounts: string[]) => {
const maker = accounts[0];
@@ -43,10 +38,7 @@ contract('Exchange', (accounts: string[]) => {
let orderFactory: OrderFactory;
before(async () => {
- [tokenRegistry, exchange] = await Promise.all([
- TokenRegistry.deployed(),
- Exchange.deployed(),
- ]);
+ [tokenRegistry, exchange] = await Promise.all([TokenRegistry.deployed(), Exchange.deployed()]);
exWrapper = new ExchangeWrapper(exchange);
const [repAddress, dgdAddress, zrxAddress] = await Promise.all([
tokenRegistry.getTokenAddressBySymbol('REP'),
@@ -74,18 +66,18 @@ contract('Exchange', (accounts: string[]) => {
]);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: maker}),
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: taker}),
- rep.setBalance(maker, INIT_BAL, {from: tokenOwner}),
- rep.setBalance(taker, INIT_BAL, {from: tokenOwner}),
- dgd.approve(TokenTransferProxy.address, INIT_ALLOW, {from: maker}),
- dgd.approve(TokenTransferProxy.address, INIT_ALLOW, {from: taker}),
- dgd.setBalance(maker, INIT_BAL, {from: tokenOwner}),
- dgd.setBalance(taker, INIT_BAL, {from: tokenOwner}),
- zrx.approve(TokenTransferProxy.address, INIT_ALLOW, {from: maker}),
- zrx.approve(TokenTransferProxy.address, INIT_ALLOW, {from: taker}),
- zrx.setBalance(maker, INIT_BAL, {from: tokenOwner}),
- zrx.setBalance(taker, INIT_BAL, {from: tokenOwner}),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, { from: maker }),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, { from: taker }),
+ rep.setBalance(maker, INIT_BAL, { from: tokenOwner }),
+ rep.setBalance(taker, INIT_BAL, { from: tokenOwner }),
+ dgd.approve(TokenTransferProxy.address, INIT_ALLOW, { from: maker }),
+ dgd.approve(TokenTransferProxy.address, INIT_ALLOW, { from: taker }),
+ dgd.setBalance(maker, INIT_BAL, { from: tokenOwner }),
+ dgd.setBalance(taker, INIT_BAL, { from: tokenOwner }),
+ zrx.approve(TokenTransferProxy.address, INIT_ALLOW, { from: maker }),
+ zrx.approve(TokenTransferProxy.address, INIT_ALLOW, { from: taker }),
+ zrx.setBalance(maker, INIT_BAL, { from: tokenOwner }),
+ zrx.setBalance(taker, INIT_BAL, { from: tokenOwner }),
]);
});
@@ -100,31 +92,38 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrKillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrKillOrderAsync(order, taker, {
+ fillTakerTokenAmount,
+ });
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(balances[maker][zrx.address].minus(makerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)));
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)),
+ );
});
it('should throw if an order is expired', async () => {
@@ -132,18 +131,18 @@ contract('Exchange', (accounts: string[]) => {
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- return expect(exWrapper.fillOrKillOrderAsync(order, taker))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if entire fillTakerTokenAmount not filled', async () => {
const order = await orderFactory.newSignedOrderAsync();
const from = taker;
- await exWrapper.fillOrderAsync(order, from, {fillTakerTokenAmount: order.params.takerTokenAmount.div(2)});
+ await exWrapper.fillOrderAsync(order, from, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
+ });
- return expect(exWrapper.fillOrKillOrderAsync(order, taker))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
});
@@ -166,14 +165,14 @@ contract('Exchange', (accounts: string[]) => {
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
@@ -181,11 +180,14 @@ contract('Exchange', (accounts: string[]) => {
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
- balances[feeRecipient][zrx.address] =
- balances[feeRecipient][zrx.address].add(makerFee.add(takerFee));
+ balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
+ makerFee.add(takerFee),
+ );
});
- await exWrapper.batchFillOrdersAsync(orders, taker, {fillTakerTokenAmounts});
+ await exWrapper.batchFillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -200,14 +202,14 @@ contract('Exchange', (accounts: string[]) => {
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
@@ -215,11 +217,14 @@ contract('Exchange', (accounts: string[]) => {
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
- balances[feeRecipient][zrx.address] =
- balances[feeRecipient][zrx.address].add(makerFee.add(takerFee));
+ balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
+ makerFee.add(takerFee),
+ );
});
- await exWrapper.batchFillOrKillOrdersAsync(orders, taker, {fillTakerTokenAmounts});
+ await exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -234,57 +239,77 @@ contract('Exchange', (accounts: string[]) => {
await exWrapper.fillOrKillOrderAsync(orders[0], taker);
- return expect(exWrapper.batchFillOrKillOrdersAsync(orders, taker, {fillTakerTokenAmounts}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
describe('fillOrdersUpTo', () => {
it('should stop when the entire fillTakerTokenAmount is filled', async () => {
- const fillTakerTokenAmount =
- orders[0].params.takerTokenAmount.plus(orders[1].params.takerTokenAmount.div(2));
- await exWrapper.fillOrdersUpToAsync(orders, taker, {fillTakerTokenAmount});
+ const fillTakerTokenAmount = orders[0].params.takerTokenAmount.plus(
+ orders[1].params.takerTokenAmount.div(2),
+ );
+ await exWrapper.fillOrdersUpToAsync(orders, taker, {
+ fillTakerTokenAmount,
+ });
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = orders[0].params.makerTokenAmount.add(
- orders[1].params.makerTokenAmount.dividedToIntegerBy(2));
+ orders[1].params.makerTokenAmount.dividedToIntegerBy(2),
+ );
const makerFee = orders[0].params.makerFee.add(orders[1].params.makerFee.dividedToIntegerBy(2));
const takerFee = orders[0].params.takerFee.add(orders[1].params.takerFee.dividedToIntegerBy(2));
- expect(newBalances[maker][orders[0].params.makerToken])
- .to.be.bignumber.equal(balances[maker][orders[0].params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][orders[0].params.takerToken])
- .to.be.bignumber.equal(balances[maker][orders[0].params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(makerFee));
- expect(newBalances[taker][orders[0].params.takerToken])
- .to.be.bignumber.equal(balances[taker][orders[0].params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][orders[0].params.makerToken])
- .to.be.bignumber.equal(balances[taker][orders[0].params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(takerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)));
+ expect(newBalances[maker][orders[0].params.makerToken]).to.be.bignumber.equal(
+ balances[maker][orders[0].params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][orders[0].params.takerToken]).to.be.bignumber.equal(
+ balances[maker][orders[0].params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(makerFee),
+ );
+ expect(newBalances[taker][orders[0].params.takerToken]).to.be.bignumber.equal(
+ balances[taker][orders[0].params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][orders[0].params.makerToken]).to.be.bignumber.equal(
+ balances[taker][orders[0].params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(takerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)),
+ );
});
it('should fill all orders if cannot fill entire fillTakerTokenAmount', async () => {
const fillTakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
orders.forEach(order => {
- balances[maker][order.params.makerToken] = balances[maker][order.params.makerToken]
- .minus(order.params.makerTokenAmount);
- balances[maker][order.params.takerToken] = balances[maker][order.params.takerToken]
- .add(order.params.takerTokenAmount);
- balances[maker][zrx.address] = balances[maker][zrx.address]
- .minus(order.params.makerFee);
- balances[taker][order.params.makerToken] = balances[taker][order.params.makerToken]
- .add(order.params.makerTokenAmount);
- balances[taker][order.params.takerToken] = balances[taker][order.params.takerToken]
- .minus(order.params.takerTokenAmount);
+ balances[maker][order.params.makerToken] = balances[maker][order.params.makerToken].minus(
+ order.params.makerTokenAmount,
+ );
+ balances[maker][order.params.takerToken] = balances[maker][order.params.takerToken].add(
+ order.params.takerTokenAmount,
+ );
+ balances[maker][zrx.address] = balances[maker][zrx.address].minus(order.params.makerFee);
+ balances[taker][order.params.makerToken] = balances[taker][order.params.makerToken].add(
+ order.params.makerTokenAmount,
+ );
+ balances[taker][order.params.takerToken] = balances[taker][order.params.takerToken].minus(
+ order.params.takerTokenAmount,
+ );
balances[taker][zrx.address] = balances[taker][zrx.address].minus(order.params.takerFee);
- balances[feeRecipient][zrx.address] =
- balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee));
+ balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
+ order.params.makerFee.add(order.params.takerFee),
+ );
+ });
+ await exWrapper.fillOrdersUpToAsync(orders, taker, {
+ fillTakerTokenAmount,
});
- await exWrapper.fillOrdersUpToAsync(orders, taker, {fillTakerTokenAmount});
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -293,13 +318,14 @@ contract('Exchange', (accounts: string[]) => {
it('should throw when an order does not use the same takerToken', async () => {
orders = await Promise.all([
orderFactory.newSignedOrderAsync(),
- orderFactory.newSignedOrderAsync({takerToken: zrx.address}),
+ orderFactory.newSignedOrderAsync({ takerToken: zrx.address }),
orderFactory.newSignedOrderAsync(),
]);
return expect(
- exWrapper.fillOrdersUpToAsync(
- orders, taker, {fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18)}),
+ exWrapper.fillOrdersUpToAsync(orders, taker, {
+ fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ }),
).to.be.rejectedWith(constants.REVERT);
});
});
@@ -307,10 +333,13 @@ contract('Exchange', (accounts: string[]) => {
describe('batchCancelOrders', () => {
it('should be able to cancel multiple orders', async () => {
const cancelTakerTokenAmounts = _.map(orders, order => order.params.takerTokenAmount);
- await exWrapper.batchCancelOrdersAsync(orders, maker, {cancelTakerTokenAmounts});
+ await exWrapper.batchCancelOrdersAsync(orders, maker, {
+ cancelTakerTokenAmounts,
+ });
- await exWrapper.batchFillOrdersAsync(
- orders, taker, {fillTakerTokenAmounts: cancelTakerTokenAmounts});
+ await exWrapper.batchFillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts: cancelTakerTokenAmounts,
+ });
const newBalances = await dmyBalances.getAsync();
expect(balances).to.be.deep.equal(newBalances);
});
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock.ts b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
index d92c5967f..19f9390d8 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
@@ -1,19 +1,19 @@
-import {RPC} from '@0xproject/dev-utils';
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+import { RPC } from '@0xproject/dev-utils';
+import { promisify } from '@0xproject/utils';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import Web3 = require('web3');
import * as multiSigWalletJSON from '../../build/contracts/MultiSigWalletWithTimeLock.json';
import * as truffleConf from '../../truffle.js';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {MultiSigWrapper} from '../../util/multi_sig_wrapper';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { MultiSigWrapper } from '../../util/multi_sig_wrapper';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {MultiSigWalletWithTimeLock} = new Artifacts(artifacts);
+const { MultiSigWalletWithTimeLock } = new Artifacts(artifacts);
const MULTI_SIG_ABI = (multiSigWalletJSON as any).abi;
chaiSetup.configure();
@@ -45,8 +45,9 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
describe('changeTimeLock', () => {
it('should throw when not called by wallet', async () => {
- return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, {from: owners[0]}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, { from: owners[0] })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw without enough confirmations', async () => {
@@ -64,7 +65,7 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
});
it('should set confirmation time with enough confirmations', async () => {
- const res = await multiSig.confirmTransaction(txId, {from: owners[1]});
+ const res = await multiSig.confirmTransaction(txId, { from: owners[1] });
expect(res.logs).to.have.length(2);
const blockNum = await promisify<number>(web3.eth.getBlockNumber)();
const blockInfo = await promisify<Web3.BlockWithoutTransactionData>(web3.eth.getBlock)(blockNum);
@@ -96,7 +97,9 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
txId = subRes.logs[0].args.transactionId.toNumber();
- const confRes = await multiSig.confirmTransaction(txId, {from: owners[1]});
+ const confRes = await multiSig.confirmTransaction(txId, {
+ from: owners[1],
+ });
expect(confRes.logs).to.have.length(2);
return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT);
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts b/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
index 6f7aaa6cd..62aa625fe 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
@@ -1,14 +1,14 @@
import * as chai from 'chai';
import * as tokenTransferProxyJSON from '../../build/contracts/TokenTransferProxy.json';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {crypto} from '../../util/crypto';
-import {MultiSigWrapper} from '../../util/multi_sig_wrapper';
-import {ContractInstance, TransactionDataParams} from '../../util/types';
-
-import {chaiSetup} from './utils/chai_setup';
-const {TokenTransferProxy, MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress} = new Artifacts(artifacts);
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { crypto } from '../../util/crypto';
+import { MultiSigWrapper } from '../../util/multi_sig_wrapper';
+import { ContractInstance, TransactionDataParams } from '../../util/types';
+
+import { chaiSetup } from './utils/chai_setup';
+const { TokenTransferProxy, MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress } = new Artifacts(artifacts);
const PROXY_ABI = (tokenTransferProxyJSON as any).abi;
chaiSetup.configure();
@@ -20,8 +20,14 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
const SECONDS_TIME_LOCKED = 1000000;
// initialize fake addresses
- const authorizedAddress = `0x${crypto.solSHA3([accounts[0]]).slice(0, 20).toString('hex')}`;
- const unauthorizedAddress = `0x${crypto.solSHA3([accounts[1]]).slice(0, 20).toString('hex')}`;
+ const authorizedAddress = `0x${crypto
+ .solSHA3([accounts[0]])
+ .slice(0, 20)
+ .toString('hex')}`;
+ const unauthorizedAddress = `0x${crypto
+ .solSHA3([accounts[1]])
+ .slice(0, 20)
+ .toString('hex')}`;
let tokenTransferProxy: ContractInstance;
let multiSig: ContractInstance;
@@ -31,11 +37,19 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
beforeEach(async () => {
const initialOwner = accounts[0];
- tokenTransferProxy = await TokenTransferProxy.new({from: initialOwner});
- await tokenTransferProxy.addAuthorizedAddress(authorizedAddress, {from: initialOwner});
+ tokenTransferProxy = await TokenTransferProxy.new({ from: initialOwner });
+ await tokenTransferProxy.addAuthorizedAddress(authorizedAddress, {
+ from: initialOwner,
+ });
multiSig = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.new(
- owners, requiredApprovals, SECONDS_TIME_LOCKED, tokenTransferProxy.address);
- await tokenTransferProxy.transferOwnership(multiSig.address, {from: initialOwner});
+ owners,
+ requiredApprovals,
+ SECONDS_TIME_LOCKED,
+ tokenTransferProxy.address,
+ );
+ await tokenTransferProxy.transferOwnership(multiSig.address, {
+ from: initialOwner,
+ });
multiSigWrapper = new MultiSigWrapper(multiSig);
validDestination = tokenTransferProxy.address;
});
@@ -43,8 +57,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
describe('isFunctionRemoveAuthorizedAddress', () => {
it('should throw if data is not for removeAuthorizedAddress', async () => {
const data = MultiSigWrapper.encodeFnArgs('addAuthorizedAddress', PROXY_ABI, [owners[0]]);
- return expect(multiSig.isFunctionRemoveAuthorizedAddress.call(data))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(multiSig.isFunctionRemoveAuthorizedAddress.call(data)).to.be.rejectedWith(constants.REVERT);
});
it('should return true if data is for removeAuthorizedAddress', async () => {
@@ -77,7 +90,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(invalidDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
@@ -92,7 +105,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
@@ -107,7 +120,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
await multiSig.executeRemoveAuthorizedAddress(txId);
@@ -124,7 +137,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
await multiSig.executeRemoveAuthorizedAddress(txId);
diff --git a/packages/contracts/test/ts/token_registry.ts b/packages/contracts/test/ts/token_registry.ts
index 36f3edcfc..d1c551565 100644
--- a/packages/contracts/test/ts/token_registry.ts
+++ b/packages/contracts/test/ts/token_registry.ts
@@ -1,16 +1,16 @@
-import {ZeroEx} from '0x.js';
+import { ZeroEx } from '0x.js';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {TokenRegWrapper} from '../../util/token_registry_wrapper';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { TokenRegWrapper } from '../../util/token_registry_wrapper';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {TokenRegistry} = new Artifacts(artifacts);
+const { TokenRegistry } = new Artifacts(artifacts);
chaiSetup.configure();
const expect = chai.expect;
@@ -79,18 +79,22 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- const duplicateNameToken = _.assign({}, token2, {name: token1.name});
+ const duplicateNameToken = _.assign({}, token2, { name: token1.name });
- return expect(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner)).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw if symbol already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- const duplicateSymbolToken = _.assign({}, token2, {symbol: token1.symbol});
+ const duplicateSymbolToken = _.assign({}, token2, {
+ symbol: token1.symbol,
+ });
- return expect(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner)).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
});
@@ -115,19 +119,22 @@ contract('TokenRegistry', (accounts: string[]) => {
describe('setTokenName', () => {
it('should throw when not called by owner', async () => {
- return expect(tokenReg.setTokenName(token1.address, token2.name, {from: notOwner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ tokenReg.setTokenName(token1.address, token2.name, { from: notOwner }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should change the token name when called by owner', async () => {
- const res = await tokenReg.setTokenName(token1.address, token2.name, {from: owner});
+ const res = await tokenReg.setTokenName(token1.address, token2.name, {
+ from: owner,
+ });
expect(res.logs).to.have.length(1);
const [newData, oldData] = await Promise.all([
tokenRegWrapper.getTokenByNameAsync(token2.name),
tokenRegWrapper.getTokenByNameAsync(token1.name),
]);
- const expectedNewData = _.assign({}, token1, {name: token2.name});
+ const expectedNewData = _.assign({}, token1, { name: token2.name });
const expectedOldData = nullToken;
expect(newData).to.be.deep.equal(expectedNewData);
expect(oldData).to.be.deep.equal(expectedOldData);
@@ -136,31 +143,36 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if the name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expect(tokenReg.setTokenName(token1.address, token2.name, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenReg.setTokenName(token1.address, token2.name, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw if token does not exist', async () => {
- return expect(tokenReg.setTokenName(nullToken.address, token2.name, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ tokenReg.setTokenName(nullToken.address, token2.name, { from: owner }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
describe('setTokenSymbol', () => {
it('should throw when not called by owner', async () => {
- return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: notOwner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ tokenReg.setTokenSymbol(token1.address, token2.symbol, {
+ from: notOwner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should change the token symbol when called by owner', async () => {
- const res = await tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: owner});
+ const res = await tokenReg.setTokenSymbol(token1.address, token2.symbol, { from: owner });
expect(res.logs).to.have.length(1);
const [newData, oldData] = await Promise.all([
tokenRegWrapper.getTokenBySymbolAsync(token2.symbol),
tokenRegWrapper.getTokenBySymbolAsync(token1.symbol),
]);
- const expectedNewData = _.assign({}, token1, {symbol: token2.symbol});
+ const expectedNewData = _.assign({}, token1, { symbol: token2.symbol });
const expectedOldData = nullToken;
expect(newData).to.be.deep.equal(expectedNewData);
expect(oldData).to.be.deep.equal(expectedOldData);
@@ -169,26 +181,35 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if the symbol already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ tokenReg.setTokenSymbol(token1.address, token2.symbol, {
+ from: owner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should throw if token does not exist', async () => {
- return expect(tokenReg.setTokenSymbol(nullToken.address, token2.symbol, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ tokenReg.setTokenSymbol(nullToken.address, token2.symbol, {
+ from: owner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
describe('removeToken', () => {
it('should throw if not called by owner', async () => {
const index = 0;
- return expect(tokenReg.removeToken(token1.address, index, {from: notOwner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenReg.removeToken(token1.address, index, { from: notOwner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should remove token metadata when called by owner', async () => {
const index = 0;
- const res = await tokenReg.removeToken(token1.address, index, {from: owner});
+ const res = await tokenReg.removeToken(token1.address, index, {
+ from: owner,
+ });
expect(res.logs).to.have.length(1);
const tokenData = await tokenRegWrapper.getTokenMetaDataAsync(token1.address);
expect(tokenData).to.be.deep.equal(nullToken);
@@ -196,17 +217,18 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if token does not exist', async () => {
const index = 0;
- return expect(tokenReg.removeToken(nullToken.address, index, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenReg.removeToken(nullToken.address, index, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw if token at given index does not match address', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
const incorrectIndex = 0;
- return expect(tokenReg.removeToken(token2.address, incorrectIndex, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenReg.removeToken(token2.address, incorrectIndex, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
-
});
});
});
diff --git a/packages/contracts/test/ts/token_transfer_proxy/auth.ts b/packages/contracts/test/ts/token_transfer_proxy/auth.ts
index 7c0a3d231..9ae0a8fc3 100644
--- a/packages/contracts/test/ts/token_transfer_proxy/auth.ts
+++ b/packages/contracts/test/ts/token_transfer_proxy/auth.ts
@@ -1,8 +1,8 @@
import * as chai from 'chai';
-import {constants} from '../../../util/constants';
-import {ContractInstance} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { constants } from '../../../util/constants';
+import { ContractInstance } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
@@ -22,12 +22,15 @@ contract('TokenTransferProxy', (accounts: string[]) => {
describe('addAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- return expect(tokenTransferProxy.addAuthorizedAddress(notOwner, {from: notOwner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenTransferProxy.addAuthorizedAddress(notOwner, { from: notOwner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should allow owner to add an authorized address', async () => {
- await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {from: owner});
+ await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {
+ from: owner,
+ });
authorized = notAuthorized;
notAuthorized = null;
const isAuthorized = await tokenTransferProxy.authorized.call(authorized);
@@ -35,19 +38,25 @@ contract('TokenTransferProxy', (accounts: string[]) => {
});
it('should throw if owner attempts to authorize a duplicate address', async () => {
- return expect(tokenTransferProxy.addAuthorizedAddress(authorized, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(tokenTransferProxy.addAuthorizedAddress(authorized, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
});
describe('removeAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- return expect(tokenTransferProxy.removeAuthorizedAddress(authorized, {from: notOwner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ tokenTransferProxy.removeAuthorizedAddress(authorized, {
+ from: notOwner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should allow owner to remove an authorized address', async () => {
- await tokenTransferProxy.removeAuthorizedAddress(authorized, {from: owner});
+ await tokenTransferProxy.removeAuthorizedAddress(authorized, {
+ from: owner,
+ });
notAuthorized = authorized;
authorized = null;
@@ -56,8 +65,11 @@ contract('TokenTransferProxy', (accounts: string[]) => {
});
it('should throw if owner attempts to remove an address that is not authorized', async () => {
- return expect(tokenTransferProxy.removeAuthorizedAddress(notAuthorized, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ tokenTransferProxy.removeAuthorizedAddress(notAuthorized, {
+ from: owner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
@@ -65,7 +77,9 @@ contract('TokenTransferProxy', (accounts: string[]) => {
it('should return all authorized addresses', async () => {
const initial = await tokenTransferProxy.getAuthorizedAddresses();
expect(initial).to.have.length(1);
- await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {from: owner});
+ await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {
+ from: owner,
+ });
authorized = notAuthorized;
notAuthorized = null;
@@ -73,7 +87,9 @@ contract('TokenTransferProxy', (accounts: string[]) => {
expect(afterAdd).to.have.length(2);
expect(afterAdd).to.include(authorized);
- await tokenTransferProxy.removeAuthorizedAddress(authorized, {from: owner});
+ await tokenTransferProxy.removeAuthorizedAddress(authorized, {
+ from: owner,
+ });
notAuthorized = authorized;
authorized = null;
const afterRemove = await tokenTransferProxy.getAuthorizedAddresses();
diff --git a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts b/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
index 8b40bfb1e..e1aff6dae 100644
--- a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
+++ b/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
@@ -1,18 +1,14 @@
import * as chai from 'chai';
-import {Artifacts} from '../../../util/artifacts';
-import {Balances} from '../../../util/balances';
-import {constants} from '../../../util/constants';
-import {ContractInstance} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { Balances } from '../../../util/balances';
+import { constants } from '../../../util/constants';
+import { ContractInstance } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- TokenTransferProxy,
- DummyToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+const { TokenTransferProxy, DummyToken, TokenRegistry } = new Artifacts(artifacts);
contract('TokenTransferProxy', (accounts: string[]) => {
const INIT_BAL = 100000000;
@@ -36,32 +32,42 @@ contract('TokenTransferProxy', (accounts: string[]) => {
dmyBalances = new Balances([rep], [accounts[0], accounts[1]]);
await Promise.all([
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: accounts[0]}),
- rep.setBalance(accounts[0], INIT_BAL, {from: owner}),
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: accounts[1]}),
- rep.setBalance(accounts[1], INIT_BAL, {from: owner}),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, {
+ from: accounts[0],
+ }),
+ rep.setBalance(accounts[0], INIT_BAL, { from: owner }),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, {
+ from: accounts[1],
+ }),
+ rep.setBalance(accounts[1], INIT_BAL, { from: owner }),
]);
});
describe('transferFrom', () => {
it('should throw when called by an unauthorized address', async () => {
- expect(tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], 1000, {from: notAuthorized}))
- .to.be.rejectedWith(constants.REVERT);
+ expect(
+ tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], 1000, { from: notAuthorized }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should allow an authorized address to transfer', async () => {
const balances = await dmyBalances.getAsync();
- await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {from: owner});
+ await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {
+ from: owner,
+ });
const transferAmt = 10000;
- await tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1],
- transferAmt, {from: notAuthorized});
+ await tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], transferAmt, {
+ from: notAuthorized,
+ });
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[accounts[0]][rep.address])
- .to.be.bignumber.equal(balances[accounts[0]][rep.address].minus(transferAmt));
- expect(newBalances[accounts[1]][rep.address])
- .to.be.bignumber.equal(balances[accounts[1]][rep.address].add(transferAmt));
+ expect(newBalances[accounts[0]][rep.address]).to.be.bignumber.equal(
+ balances[accounts[0]][rep.address].minus(transferAmt),
+ );
+ expect(newBalances[accounts[1]][rep.address]).to.be.bignumber.equal(
+ balances[accounts[1]][rep.address].add(transferAmt),
+ );
});
});
});
diff --git a/packages/contracts/test/ts/unlimited_allowance_token.ts b/packages/contracts/test/ts/unlimited_allowance_token.ts
index 33b2a5721..008ee7ecd 100644
--- a/packages/contracts/test/ts/unlimited_allowance_token.ts
+++ b/packages/contracts/test/ts/unlimited_allowance_token.ts
@@ -1,15 +1,15 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import * as Web3 from 'web3';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {DummyToken} = new Artifacts(artifacts);
+const { DummyToken } = new Artifacts(artifacts);
const web3: Web3 = (global as any).web3;
chaiSetup.configure();
const expect = chai.expect;
@@ -27,8 +27,8 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
let token: ContractInstance;
beforeEach(async () => {
- token = await DummyToken.new({from: owner});
- await token.mint(MAX_MINT_VALUE, {from: owner});
+ token = await DummyToken.new({ from: owner });
+ await token.mint(MAX_MINT_VALUE, { from: owner });
tokenAddress = token.address;
});
@@ -48,7 +48,9 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
});
it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await token.transfer.call(spender, 0, {from: owner});
+ const didReturnTrue = await token.transfer.call(spender, 0, {
+ from: owner,
+ });
expect(didReturnTrue).to.be.true();
});
});
@@ -58,7 +60,7 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
@@ -70,13 +72,13 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
it('should return true on a 0 value transfer', async () => {
const amountToTransfer = 0;
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.true();
});
diff --git a/packages/contracts/test/ts/unlimited_allowance_token_v2.ts b/packages/contracts/test/ts/unlimited_allowance_token_v2.ts
index 4fa06e483..0053aedd5 100644
--- a/packages/contracts/test/ts/unlimited_allowance_token_v2.ts
+++ b/packages/contracts/test/ts/unlimited_allowance_token_v2.ts
@@ -1,15 +1,15 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import * as Web3 from 'web3';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {DummyTokenV2} = new Artifacts(artifacts);
+const { DummyTokenV2 } = new Artifacts(artifacts);
const web3: Web3 = (global as any).web3;
chaiSetup.configure();
const expect = chai.expect;
@@ -27,8 +27,8 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => {
let token: ContractInstance;
beforeEach(async () => {
- token = await DummyTokenV2.new({from: owner});
- await token.mint(MAX_MINT_VALUE, {from: owner});
+ token = await DummyTokenV2.new({ from: owner });
+ await token.mint(MAX_MINT_VALUE, { from: owner });
tokenAddress = token.address;
});
@@ -36,8 +36,9 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => {
it('should throw if owner has insufficient balance', async () => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
- return expect(token.transfer.call(spender, amountToTransfer, {from: owner}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(token.transfer.call(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should transfer balance from sender to receiver', async () => {
@@ -55,7 +56,9 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => {
});
it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await token.transfer.call(spender, 0, {from: owner});
+ const didReturnTrue = await token.transfer.call(spender, 0, {
+ from: owner,
+ });
expect(didReturnTrue).to.be.true();
});
});
@@ -65,8 +68,11 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
- return expect(token.transferFrom.call(owner, spender, amountToTransfer, {from: spender}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should throw if spender has insufficient allowance', async () => {
@@ -77,13 +83,16 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- return expect(token.transferFrom.call(owner, spender, amountToTransfer, {from: spender}))
- .to.be.rejectedWith(constants.REVERT);
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should return true on a 0 value transfer', async () => {
const amountToTransfer = 0;
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.true();
});
diff --git a/packages/contracts/test/ts/zrx_token.ts b/packages/contracts/test/ts/zrx_token.ts
index 89e3c3ae2..3122060c0 100644
--- a/packages/contracts/test/ts/zrx_token.ts
+++ b/packages/contracts/test/ts/zrx_token.ts
@@ -1,17 +1,17 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from 'bignumber.js';
import * as chai from 'chai';
import Web3 = require('web3');
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {Exchange, ZRXToken} = new Artifacts(artifacts);
+const { Exchange, ZRXToken } = new Artifacts(artifacts);
const web3: Web3 = (global as any).web3;
contract('ZRXToken', (accounts: string[]) => {
@@ -85,7 +85,9 @@ contract('ZRXToken', (accounts: string[]) => {
});
it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await zrx.transfer.call(spender, 0, {from: owner});
+ const didReturnTrue = await zrx.transfer.call(spender, 0, {
+ from: owner,
+ });
expect(didReturnTrue).to.be.true();
});
});
@@ -98,7 +100,7 @@ contract('ZRXToken', (accounts: string[]) => {
gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
});
await zeroEx.awaitTransactionMinedAsync(txHash);
- const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
@@ -110,13 +112,13 @@ contract('ZRXToken', (accounts: string[]) => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
it('should return true on a 0 value transfer', async () => {
const amountToTransfer = 0;
- const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.true();
});
diff --git a/packages/contracts/util/artifacts.ts b/packages/contracts/util/artifacts.ts
index 14acd32a1..ecb18cbce 100644
--- a/packages/contracts/util/artifacts.ts
+++ b/packages/contracts/util/artifacts.ts
@@ -21,7 +21,8 @@ export class Artifacts {
this.DummyTokenV2 = artifacts.require('DummyToken_v2');
this.EtherToken = artifacts.require('WETH9');
this.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress = artifacts.require(
- 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress');
+ 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
+ );
this.MaliciousToken = artifacts.require('MaliciousToken');
}
}
diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts
index 5800a2008..eaeecf1c4 100644
--- a/packages/contracts/util/balances.ts
+++ b/packages/contracts/util/balances.ts
@@ -1,8 +1,8 @@
-import {bigNumberConfigs} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+import { bigNumberConfigs } from '@0xproject/utils';
+import { BigNumber } from 'bignumber.js';
import * as _ from 'lodash';
-import {BalancesByOwner, ContractInstance} from './types';
+import { BalancesByOwner, ContractInstance } from './types';
bigNumberConfigs.configure();
diff --git a/packages/contracts/util/crypto.ts b/packages/contracts/util/crypto.ts
index 2e43ae816..9173df643 100644
--- a/packages/contracts/util/crypto.ts
+++ b/packages/contracts/util/crypto.ts
@@ -18,14 +18,14 @@ export const crypto = {
const isNumber = _.isFinite(arg);
if (isNumber) {
argTypes.push('uint8');
- } else if ((arg).isBigNumber) {
+ } else if (arg.isBigNumber) {
argTypes.push('uint256');
args[i] = new BN(arg.toString(10), 10);
} else if (ethUtil.isValidAddress(arg)) {
argTypes.push('address');
} else if (_.isString(arg)) {
argTypes.push('string');
- } else if (_.isBoolean(arg)) {
+ } else if (_.isBoolean(arg)) {
argTypes.push('bool');
} else {
throw new Error(`Unable to guess arg type: ${arg}`);
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts
index 9545710cd..200b0fb1e 100644
--- a/packages/contracts/util/exchange_wrapper.ts
+++ b/packages/contracts/util/exchange_wrapper.ts
@@ -1,20 +1,23 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from 'bignumber.js';
import * as _ from 'lodash';
-import {formatters} from './formatters';
-import {Order} from './order';
-import {ContractInstance} from './types';
+import { formatters } from './formatters';
+import { Order } from './order';
+import { ContractInstance } from './types';
export class ExchangeWrapper {
private _exchange: ContractInstance;
constructor(exchangeContractInstance: ContractInstance) {
this._exchange = exchangeContractInstance;
}
- public async fillOrderAsync(order: Order, from: string,
- opts: {
- fillTakerTokenAmount?: BigNumber;
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {}) {
+ public async fillOrderAsync(
+ order: Order,
+ from: string,
+ opts: {
+ fillTakerTokenAmount?: BigNumber;
+ shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
+ } = {},
+ ) {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
const tx = await this._exchange.fillOrder(
@@ -25,25 +28,23 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async cancelOrderAsync(order: Order, from: string,
- opts: {cancelTakerTokenAmount?: BigNumber} = {}) {
+ public async cancelOrderAsync(order: Order, from: string, opts: { cancelTakerTokenAmount?: BigNumber } = {}) {
const params = order.createCancel(opts.cancelTakerTokenAmount);
const tx = await this._exchange.cancelOrder(
params.orderAddresses,
params.orderValues,
params.cancelTakerTokenAmount,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async fillOrKillOrderAsync(order: Order, from: string,
- opts: {fillTakerTokenAmount?: BigNumber} = {}) {
+ public async fillOrKillOrderAsync(order: Order, from: string, opts: { fillTakerTokenAmount?: BigNumber } = {}) {
const shouldThrowOnInsufficientBalanceOrAllowance = true;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
const tx = await this._exchange.fillOrKillOrder(
@@ -53,19 +54,25 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async batchFillOrdersAsync(orders: Order[], from: string,
- opts: {
- fillTakerTokenAmounts?: BigNumber[];
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {}) {
+ public async batchFillOrdersAsync(
+ orders: Order[],
+ from: string,
+ opts: {
+ fillTakerTokenAmounts?: BigNumber[];
+ shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
+ } = {},
+ ) {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = formatters.createBatchFill(
- orders, shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmounts);
+ orders,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ opts.fillTakerTokenAmounts,
+ );
const tx = await this._exchange.batchFillOrders(
params.orderAddresses,
params.orderValues,
@@ -74,13 +81,16 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async batchFillOrKillOrdersAsync(orders: Order[], from: string,
- opts: {fillTakerTokenAmounts?: BigNumber[]} = {}) {
+ public async batchFillOrKillOrdersAsync(
+ orders: Order[],
+ from: string,
+ opts: { fillTakerTokenAmounts?: BigNumber[] } = {},
+ ) {
const params = formatters.createBatchFill(orders, undefined, opts.fillTakerTokenAmounts);
const tx = await this._exchange.batchFillOrKillOrders(
params.orderAddresses,
@@ -89,20 +99,25 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async fillOrdersUpToAsync(orders: Order[], from: string,
- opts: {
- fillTakerTokenAmount?: BigNumber;
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {}) {
+ public async fillOrdersUpToAsync(
+ orders: Order[],
+ from: string,
+ opts: {
+ fillTakerTokenAmount?: BigNumber;
+ shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
+ } = {},
+ ) {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = formatters.createFillUpTo(orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount);
+ const params = formatters.createFillUpTo(
+ orders,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ opts.fillTakerTokenAmount,
+ );
const tx = await this._exchange.fillOrdersUpTo(
params.orderAddresses,
params.orderValues,
@@ -111,19 +126,22 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async batchCancelOrdersAsync(orders: Order[], from: string,
- opts: {cancelTakerTokenAmounts?: BigNumber[]} = {}) {
+ public async batchCancelOrdersAsync(
+ orders: Order[],
+ from: string,
+ opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
+ ) {
const params = formatters.createBatchCancel(orders, opts.cancelTakerTokenAmounts);
const tx = await this._exchange.batchCancelOrders(
params.orderAddresses,
params.orderValues,
params.cancelTakerTokenAmounts,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
@@ -144,13 +162,19 @@ export class ExchangeWrapper {
);
return isValidSignature;
}
- public async isRoundingErrorAsync(numerator: BigNumber, denominator: BigNumber,
- target: BigNumber): Promise<boolean> {
+ public async isRoundingErrorAsync(
+ numerator: BigNumber,
+ denominator: BigNumber,
+ target: BigNumber,
+ ): Promise<boolean> {
const isRoundingError = await this._exchange.isRoundingError(numerator, denominator, target);
return isRoundingError;
}
- public async getPartialAmountAsync(numerator: BigNumber, denominator: BigNumber,
- target: BigNumber): Promise<BigNumber> {
+ public async getPartialAmountAsync(
+ numerator: BigNumber,
+ denominator: BigNumber,
+ target: BigNumber,
+ ): Promise<BigNumber> {
const partialAmount = new BigNumber(await this._exchange.getPartialAmount(numerator, denominator, target));
return partialAmount;
}
diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts
index 0ad44481a..ab3558ee7 100644
--- a/packages/contracts/util/formatters.ts
+++ b/packages/contracts/util/formatters.ts
@@ -1,13 +1,15 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from 'bignumber.js';
import * as _ from 'lodash';
-import {Order} from './order';
-import {BatchCancelOrders, BatchFillOrders, FillOrdersUpTo} from './types';
+import { Order } from './order';
+import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
export const formatters = {
- createBatchFill(orders: Order[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- fillTakerTokenAmounts: BigNumber[] = []) {
+ createBatchFill(
+ orders: Order[],
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ fillTakerTokenAmounts: BigNumber[] = [],
+ ) {
const batchFill: BatchFillOrders = {
orderAddresses: [],
orderValues: [],
@@ -18,11 +20,21 @@ export const formatters = {
s: [],
};
_.forEach(orders, order => {
- batchFill.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken,
- order.params.takerToken, order.params.feeRecipient]);
- batchFill.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount,
- order.params.makerFee, order.params.takerFee,
- order.params.expirationTimestampInSec, order.params.salt]);
+ batchFill.orderAddresses.push([
+ order.params.maker,
+ order.params.taker,
+ order.params.makerToken,
+ order.params.takerToken,
+ order.params.feeRecipient,
+ ]);
+ batchFill.orderValues.push([
+ order.params.makerTokenAmount,
+ order.params.takerTokenAmount,
+ order.params.makerFee,
+ order.params.takerFee,
+ order.params.expirationTimestampInSec,
+ order.params.salt,
+ ]);
batchFill.v.push(order.params.v);
batchFill.r.push(order.params.r);
batchFill.s.push(order.params.s);
@@ -32,9 +44,11 @@ export const formatters = {
});
return batchFill;
},
- createFillUpTo(orders: Order[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- fillTakerTokenAmount: BigNumber) {
+ createFillUpTo(
+ orders: Order[],
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ fillTakerTokenAmount: BigNumber,
+ ) {
const fillUpTo: FillOrdersUpTo = {
orderAddresses: [],
orderValues: [],
@@ -45,11 +59,21 @@ export const formatters = {
s: [],
};
orders.forEach(order => {
- fillUpTo.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken,
- order.params.takerToken, order.params.feeRecipient]);
- fillUpTo.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount,
- order.params.makerFee, order.params.takerFee,
- order.params.expirationTimestampInSec, order.params.salt]);
+ fillUpTo.orderAddresses.push([
+ order.params.maker,
+ order.params.taker,
+ order.params.makerToken,
+ order.params.takerToken,
+ order.params.feeRecipient,
+ ]);
+ fillUpTo.orderValues.push([
+ order.params.makerTokenAmount,
+ order.params.takerTokenAmount,
+ order.params.makerFee,
+ order.params.takerFee,
+ order.params.expirationTimestampInSec,
+ order.params.salt,
+ ]);
fillUpTo.v.push(order.params.v);
fillUpTo.r.push(order.params.r);
fillUpTo.s.push(order.params.s);
@@ -63,11 +87,21 @@ export const formatters = {
cancelTakerTokenAmounts,
};
orders.forEach(order => {
- batchCancel.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken,
- order.params.takerToken, order.params.feeRecipient]);
- batchCancel.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount,
- order.params.makerFee, order.params.takerFee,
- order.params.expirationTimestampInSec, order.params.salt]);
+ batchCancel.orderAddresses.push([
+ order.params.maker,
+ order.params.taker,
+ order.params.makerToken,
+ order.params.takerToken,
+ order.params.feeRecipient,
+ ]);
+ batchCancel.orderValues.push([
+ order.params.makerTokenAmount,
+ order.params.takerTokenAmount,
+ order.params.makerFee,
+ order.params.takerFee,
+ order.params.expirationTimestampInSec,
+ order.params.salt,
+ ]);
if (cancelTakerTokenAmounts.length < orders.length) {
batchCancel.cancelTakerTokenAmounts.push(order.params.takerTokenAmount);
}
diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts
index 2e4174436..0e2e671ec 100644
--- a/packages/contracts/util/multi_sig_wrapper.ts
+++ b/packages/contracts/util/multi_sig_wrapper.ts
@@ -3,12 +3,12 @@ import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {ContractInstance, TransactionDataParams} from './types';
+import { ContractInstance, TransactionDataParams } from './types';
export class MultiSigWrapper {
private _multiSig: ContractInstance;
public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) {
- const abiEntity = _.find(abi, {name}) as Web3.MethodAbi;
+ const abiEntity = _.find(abi, { name }) as Web3.MethodAbi;
if (_.isUndefined(abiEntity)) {
throw new Error(`Did not find abi entry for name: ${name}`);
}
@@ -24,11 +24,16 @@ export class MultiSigWrapper {
constructor(multiSigContractInstance: ContractInstance) {
this._multiSig = multiSigContractInstance;
}
- public async submitTransactionAsync(destination: string, from: string,
- dataParams: TransactionDataParams,
- value: number = 0) {
- const {name, abi, args = []} = dataParams;
+ public async submitTransactionAsync(
+ destination: string,
+ from: string,
+ dataParams: TransactionDataParams,
+ value: number = 0,
+ ) {
+ const { name, abi, args = [] } = dataParams;
const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args);
- return this._multiSig.submitTransaction(destination, value, encoded, {from});
+ return this._multiSig.submitTransaction(destination, value, encoded, {
+ from,
+ });
}
}
diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts
index 52d611ade..2427ffb87 100644
--- a/packages/contracts/util/order.ts
+++ b/packages/contracts/util/order.ts
@@ -1,11 +1,11 @@
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+import { promisify } from '@0xproject/utils';
+import { BigNumber } from 'bignumber.js';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import Web3 = require('web3');
-import {crypto} from './crypto';
-import {OrderParams} from './types';
+import { crypto } from './crypto';
+import { OrderParams } from './types';
// In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle
// with type `any` to a variable of type `Web3`.
@@ -17,7 +17,7 @@ export class Order {
this.params = params;
}
public isValidSignature() {
- const {v, r, s} = this.params;
+ const { v, r, s } = this.params;
if (_.isUndefined(v) || _.isUndefined(r) || _.isUndefined(s)) {
throw new Error('Cannot call isValidSignature on unsigned order');
}
@@ -34,7 +34,7 @@ export class Order {
public async signAsync() {
const orderHash = this._getOrderHash();
const signature = await promisify<string>(web3.eth.sign)(this.params.maker, orderHash);
- const {v, r, s} = ethUtil.fromRpcSig(signature);
+ const { v, r, s } = ethUtil.fromRpcSig(signature);
this.params = _.assign(this.params, {
orderHashHex: orderHash,
v,
diff --git a/packages/contracts/util/order_factory.ts b/packages/contracts/util/order_factory.ts
index 9d96a8394..3ae06a335 100644
--- a/packages/contracts/util/order_factory.ts
+++ b/packages/contracts/util/order_factory.ts
@@ -1,9 +1,9 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from 'bignumber.js';
import * as _ from 'lodash';
-import {Order} from './order';
-import {DefaultOrderParams, OptionalOrderParams, OrderParams} from './types';
+import { Order } from './order';
+import { DefaultOrderParams, OptionalOrderParams, OrderParams } from './types';
export class OrderFactory {
private _defaultOrderParams: DefaultOrderParams;
@@ -11,12 +11,17 @@ export class OrderFactory {
this._defaultOrderParams = defaultOrderParams;
}
public async newSignedOrderAsync(customOrderParams: OptionalOrderParams = {}) {
- const randomExpiration = new BigNumber(Math.floor((Date.now() + (Math.random() * 100000000000)) / 1000));
- const orderParams: OrderParams = _.assign({}, {
- expirationTimestampInSec: randomExpiration,
- salt: ZeroEx.generatePseudoRandomSalt(),
- taker: ZeroEx.NULL_ADDRESS,
- }, this._defaultOrderParams, customOrderParams);
+ const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000));
+ const orderParams: OrderParams = _.assign(
+ {},
+ {
+ expirationTimestampInSec: randomExpiration,
+ salt: ZeroEx.generatePseudoRandomSalt(),
+ taker: ZeroEx.NULL_ADDRESS,
+ },
+ this._defaultOrderParams,
+ customOrderParams,
+ );
const order = new Order(orderParams);
await order.signAsync();
return order;
diff --git a/packages/contracts/util/token_registry_wrapper.ts b/packages/contracts/util/token_registry_wrapper.ts
index c10cf4f5f..07a577dea 100644
--- a/packages/contracts/util/token_registry_wrapper.ts
+++ b/packages/contracts/util/token_registry_wrapper.ts
@@ -1,4 +1,4 @@
-import {ContractInstance, Token} from './types';
+import { ContractInstance, Token } from './types';
export class TokenRegWrapper {
private _tokenReg: ContractInstance;
@@ -13,7 +13,7 @@ export class TokenRegWrapper {
token.decimals,
token.ipfsHash,
token.swarmHash,
- {from},
+ { from },
);
return tx;
}
diff --git a/packages/contracts/util/types.ts b/packages/contracts/util/types.ts
index b2cf786df..9b225cb0b 100644
--- a/packages/contracts/util/types.ts
+++ b/packages/contracts/util/types.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from 'bignumber.js';
import * as Web3 from 'web3';
export interface BalancesByOwner {