diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-08 09:35:07 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-07-11 15:30:14 +0800 |
commit | 183ea1b33da3cbe0c0babffca8eaefd4568d0e37 (patch) | |
tree | d6dbc8e7724d126feb7d1a9e2220c1d0e3124645 /src/utils | |
parent | 994b51590f0aef06b3022dc170150ba7d3f6579f (diff) | |
download | dexon-sol-tools-183ea1b33da3cbe0c0babffca8eaefd4568d0e37.tar dexon-sol-tools-183ea1b33da3cbe0c0babffca8eaefd4568d0e37.tar.gz dexon-sol-tools-183ea1b33da3cbe0c0babffca8eaefd4568d0e37.tar.bz2 dexon-sol-tools-183ea1b33da3cbe0c0babffca8eaefd4568d0e37.tar.lz dexon-sol-tools-183ea1b33da3cbe0c0babffca8eaefd4568d0e37.tar.xz dexon-sol-tools-183ea1b33da3cbe0c0babffca8eaefd4568d0e37.tar.zst dexon-sol-tools-183ea1b33da3cbe0c0babffca8eaefd4568d0e37.zip |
Simplify BigNumber hack
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/event_utils.ts | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/utils/event_utils.ts b/src/utils/event_utils.ts index 07418cbc4..e8f30e1a8 100644 --- a/src/utils/event_utils.ts +++ b/src/utils/event_utils.ts @@ -1,5 +1,4 @@ import * as _ from 'lodash'; -import * as Web3 from 'web3'; import {EventCallback, ContractEventArg, ContractEvent, ContractEventObj, ContractEventEmitter} from '../types'; import * as BigNumber from 'bignumber.js'; import promisify = require('es6-promisify'); @@ -29,10 +28,8 @@ export const eventUtils = { const wrapIfBigNumber = (value: ContractEventArg): ContractEventArg => { // HACK: The old version of BigNumber used by Web3@0.19.0 does not support the `isBigNumber` // and checking for a BigNumber instance using `instanceof` does not work either. We therefore - // compare the constructor functions of the possible BigNumber instance and the BigNumber used by - // Web3. - const web3BigNumber = (Web3.prototype as any).BigNumber; - const isWeb3BigNumber = web3BigNumber.toString() === value.constructor.toString(); + // check if the value constructor is a bignumber constructor. + const isWeb3BigNumber = _.startsWith(value.constructor.toString(), 'function BigNumber('); return isWeb3BigNumber ? new BigNumber(value) : value; }; event.args = _.mapValues(event.args, wrapIfBigNumber); |