diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-08 09:35:07 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-08 09:35:07 +0800 |
commit | 643a7e6b3a753e51e80f05eaaaab43167999c8f9 (patch) | |
tree | 93e2dc47ca1ed01befcf3451c5f2b84cc02000a2 | |
parent | baa7668cdaba5629345338c5ecbeaa40f0ae0a16 (diff) | |
download | dexon-sol-tools-643a7e6b3a753e51e80f05eaaaab43167999c8f9.tar.gz dexon-sol-tools-643a7e6b3a753e51e80f05eaaaab43167999c8f9.tar.zst dexon-sol-tools-643a7e6b3a753e51e80f05eaaaab43167999c8f9.zip |
Simplify BigNumber hack
-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); |