diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-02-13 10:25:45 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:16 +0800 |
commit | f12e4f8889d887952c2cd0b129fa926d1f3b9044 (patch) | |
tree | 97aad58f3713842378fb17ab414b6731a8a94249 /packages/contracts/src/utils/log_decoder.ts | |
parent | df99a360fb3467b80952416ed1d1802f3599ee8d (diff) | |
download | dexon-0x-contracts-f12e4f8889d887952c2cd0b129fa926d1f3b9044.tar dexon-0x-contracts-f12e4f8889d887952c2cd0b129fa926d1f3b9044.tar.gz dexon-0x-contracts-f12e4f8889d887952c2cd0b129fa926d1f3b9044.tar.bz2 dexon-0x-contracts-f12e4f8889d887952c2cd0b129fa926d1f3b9044.tar.lz dexon-0x-contracts-f12e4f8889d887952c2cd0b129fa926d1f3b9044.tar.xz dexon-0x-contracts-f12e4f8889d887952c2cd0b129fa926d1f3b9044.tar.zst dexon-0x-contracts-f12e4f8889d887952c2cd0b129fa926d1f3b9044.zip |
Use new logDecoder interface
Diffstat (limited to 'packages/contracts/src/utils/log_decoder.ts')
-rw-r--r-- | packages/contracts/src/utils/log_decoder.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/contracts/src/utils/log_decoder.ts b/packages/contracts/src/utils/log_decoder.ts index 89f641078..d8685e3d7 100644 --- a/packages/contracts/src/utils/log_decoder.ts +++ b/packages/contracts/src/utils/log_decoder.ts @@ -22,8 +22,11 @@ export class LogDecoder { }); this._abiDecoder = new AbiDecoder(abiArrays); } - public tryToDecodeLogOrNoop<ArgsType>(log: Web3.LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { - const logWithDecodedArgs = this._abiDecoder.tryToDecodeLogOrNoop(log); - return logWithDecodedArgs; + public decodeLogOrThrow<ArgsType>(log: Web3.LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { + const logWithDecodedArgsOrLog = this._abiDecoder.tryToDecodeLogOrNoop(log); + if (_.isUndefined((logWithDecodedArgsOrLog as LogWithDecodedArgs<ArgsType>).args)) { + throw new Error(`Unable to decode log: ${JSON.stringify(log)}`); + } + return logWithDecodedArgsOrLog; } } |