aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-05-29 15:06:24 +0800
committerFabio Berger <me@fabioberger.com>2017-05-29 15:06:24 +0800
commit281b9eaa5d207d32ae38fbab25cbca83fe81efa1 (patch)
tree4cb70a78a76b2e38466273bf33a39cb45ca204b5
parentf338c68f126cba0f1b49c2928f276158b64d8ee7 (diff)
downloaddexon-sol-tools-281b9eaa5d207d32ae38fbab25cbca83fe81efa1.tar
dexon-sol-tools-281b9eaa5d207d32ae38fbab25cbca83fe81efa1.tar.gz
dexon-sol-tools-281b9eaa5d207d32ae38fbab25cbca83fe81efa1.tar.bz2
dexon-sol-tools-281b9eaa5d207d32ae38fbab25cbca83fe81efa1.tar.lz
dexon-sol-tools-281b9eaa5d207d32ae38fbab25cbca83fe81efa1.tar.xz
dexon-sol-tools-281b9eaa5d207d32ae38fbab25cbca83fe81efa1.tar.zst
dexon-sol-tools-281b9eaa5d207d32ae38fbab25cbca83fe81efa1.zip
Move bigNumberToBN to utils module
-rw-r--r--src/ts/0x.js.ts24
-rw-r--r--src/ts/utils/utils.ts13
2 files changed, 20 insertions, 17 deletions
diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts
index ba922d3db..67e7c2fdd 100644
--- a/src/ts/0x.js.ts
+++ b/src/ts/0x.js.ts
@@ -1,9 +1,9 @@
import * as BigNumber from 'bignumber.js';
-import * as BN from 'bn.js';
import * as ethUtil from 'ethereumjs-util';
import * as ethABI from 'ethereumjs-abi';
import * as _ from 'lodash';
import {constants} from './utils/constants';
+import {utils} from './utils/utils';
import {assert} from './utils/assert';
import {ECSignatureSchema} from './schemas/ec_signature_schema';
import {SolidityTypes} from './types';
@@ -49,12 +49,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);
@@ -129,14 +129,4 @@ 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);
- }
}
diff --git a/src/ts/utils/utils.ts b/src/ts/utils/utils.ts
new file mode 100644
index 000000000..bde1e7aba
--- /dev/null
+++ b/src/ts/utils/utils.ts
@@ -0,0 +1,13 @@
+import * as BN from 'bn.js';
+
+export const utils = {
+ /**
+ * 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.
+ */
+ bigNumberToBN(value: BigNumber.BigNumber) {
+ return new BN(value.toString(), 10);
+ },
+};