aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/utils/log_decoder.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-03-10 07:47:21 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:16 +0800
commit6db0b2e39821f27f6f31a8247159864dacd1d2bd (patch)
treebe4b6b6cc5cb098446a3a82016931173642faf5b /packages/contracts/src/utils/log_decoder.ts
parent2bd1ddd1296b4b3706bf91934e00c02508ca7c6f (diff)
downloaddexon-sol-tools-6db0b2e39821f27f6f31a8247159864dacd1d2bd.tar.gz
dexon-sol-tools-6db0b2e39821f27f6f31a8247159864dacd1d2bd.tar.zst
dexon-sol-tools-6db0b2e39821f27f6f31a8247159864dacd1d2bd.zip
Address feedback and lint
Diffstat (limited to 'packages/contracts/src/utils/log_decoder.ts')
-rw-r--r--packages/contracts/src/utils/log_decoder.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/contracts/src/utils/log_decoder.ts b/packages/contracts/src/utils/log_decoder.ts
index d8685e3d7..845e025fe 100644
--- a/packages/contracts/src/utils/log_decoder.ts
+++ b/packages/contracts/src/utils/log_decoder.ts
@@ -1,5 +1,5 @@
import { LogWithDecodedArgs, RawLog } from '@0xproject/types';
-import { AbiDecoder } from '@0xproject/utils';
+import { AbiDecoder, BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -27,6 +27,17 @@ export class LogDecoder {
if (_.isUndefined((logWithDecodedArgsOrLog as LogWithDecodedArgs<ArgsType>).args)) {
throw new Error(`Unable to decode log: ${JSON.stringify(log)}`);
}
+ wrapLogBigNumbers(logWithDecodedArgsOrLog);
return logWithDecodedArgsOrLog;
}
}
+
+function wrapLogBigNumbers(log: any): any {
+ const argNames = _.keys(log.args);
+ for (const argName of argNames) {
+ const isWeb3BigNumber = _.startsWith(log.args[argName].constructor.toString(), 'function BigNumber(');
+ if (isWeb3BigNumber) {
+ log.args[argName] = new BigNumber(log.args[argName]);
+ }
+ }
+}