From 183ea1b33da3cbe0c0babffca8eaefd4568d0e37 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 7 Jul 2017 18:35:07 -0700 Subject: Simplify BigNumber hack --- src/utils/event_utils.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') 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); -- cgit