diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ts/0x.js.ts | 23 | ||||
-rw-r--r-- | src/ts/utils/utils.ts | 11 |
2 files changed, 18 insertions, 16 deletions
diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index bd4978c96..1ebafc604 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -1,12 +1,12 @@ import * as _ from 'lodash'; import * as BigNumber from 'bignumber.js'; -import * as BN from 'bn.js'; import * as ethUtil from 'ethereumjs-util'; import contract = require('truffle-contract'); import * as Web3 from 'web3'; import * as ethABI from 'ethereumjs-abi'; import {Web3Wrapper} from './web3_wrapper'; import {constants} from './utils/constants'; +import {utils} from './utils/utils'; import {assert} from './utils/assert'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; import {ECSignatureSchema} from './schemas/ec_signature_schema'; @@ -46,12 +46,12 @@ export class ZeroEx { {value: tokenMAddress, type: SolidityTypes.address}, {value: tokenTAddress, type: SolidityTypes.address}, {value: feeRecipient, type: SolidityTypes.address}, - {value: this.bigNumberToBN(valueM), type: SolidityTypes.uint256}, - {value: this.bigNumberToBN(valueT), type: SolidityTypes.uint256}, - {value: this.bigNumberToBN(makerFee), type: SolidityTypes.uint256}, - {value: this.bigNumberToBN(takerFee), type: SolidityTypes.uint256}, - {value: this.bigNumberToBN(expiration), type: SolidityTypes.uint256}, - {value: this.bigNumberToBN(salt), type: SolidityTypes.uint256}, + {value: utils.bigNumberToBN(valueM), type: SolidityTypes.uint256}, + {value: utils.bigNumberToBN(valueT), type: SolidityTypes.uint256}, + {value: utils.bigNumberToBN(makerFee), type: SolidityTypes.uint256}, + {value: utils.bigNumberToBN(takerFee), type: SolidityTypes.uint256}, + {value: utils.bigNumberToBN(expiration), type: SolidityTypes.uint256}, + {value: utils.bigNumberToBN(salt), type: SolidityTypes.uint256}, ]; const types = _.map(orderParts, o => o.type); const values = _.map(orderParts, o => o.value); @@ -127,15 +127,6 @@ export class ZeroEx { const baseUnitAmount = amount.times(unit); return baseUnitAmount; } - /** - * Converts BigNumber instance to BN - * The only we convert to BN is to remain compatible with `ethABI. soliditySHA3 ` that - * expects values of Solidity type `uint` to be of type `BN`. - * We do not use BN anywhere else in the codebase. - */ - private static bigNumberToBN(value: BigNumber.BigNumber) { - return new BN(value.toString(), 10); - } constructor(web3: Web3) { this.web3Wrapper = new Web3Wrapper(web3); this.exchange = new ExchangeWrapper(this.web3Wrapper); diff --git a/src/ts/utils/utils.ts b/src/ts/utils/utils.ts index 04ac36b54..b514b702d 100644 --- a/src/ts/utils/utils.ts +++ b/src/ts/utils/utils.ts @@ -1,4 +1,15 @@ +import * as BN from 'bn.js'; + export const utils = { + /** + * Converts BigNumber instance to BN + * The only reason we convert to BN is to remain compatible with `ethABI. soliditySHA3` that + * expects values of Solidity type `uint` to be passed as type `BN`. + * We do not use BN anywhere else in the codebase. + */ + bigNumberToBN(value: BigNumber.BigNumber) { + return new BN(value.toString(), 10); + }, consoleLog(message: string): void { /* tslint:disable */ console.log(message); |