Update at abi_decoder

This commit is contained in:
Bryce 2018-06-22 16:39:58 -07:00
parent 9f8cad93f7
commit f7fe9b0961
6 changed files with 22 additions and 16 deletions

View File

@ -1,11 +1,9 @@
[ [
{ {
"timestamp": 1529701469,
"version": "0.0.7", "version": "0.0.7",
"changes": [ "changes": [
{ {
"note": "Fixes Uncaught Error in OrderWatcher", "note": "Dependencies updated"
"pr": 763
} }
] ]
}, },

View File

@ -85,7 +85,7 @@
"@0xproject/order-utils": "^0.0.7", "@0xproject/order-utils": "^0.0.7",
"@0xproject/types": "^0.8.1", "@0xproject/types": "^0.8.1",
"@0xproject/typescript-typings": "^0.4.1", "@0xproject/typescript-typings": "^0.4.1",
"@0xproject/utils": "^0.7.1", "@0xproject/utils": "^0.7.3",
"@0xproject/web3-wrapper": "^0.7.1", "@0xproject/web3-wrapper": "^0.7.1",
"ethereum-types": "^0.0.1", "ethereum-types": "^0.0.1",
"bintrees": "^1.0.2", "bintrees": "^1.0.2",

View File

@ -16,7 +16,6 @@ import {
} from '@0xproject/types'; } from '@0xproject/types';
import { errorUtils, intervalUtils } from '@0xproject/utils'; import { errorUtils, intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethers from 'ethers';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { artifacts } from '../artifacts'; import { artifacts } from '../artifacts';
@ -242,15 +241,7 @@ export class OrderWatcher {
return; return;
} }
const log = logIfExists as LogEntryEvent; // At this moment we are sure that no error occured and log is defined. const log = logIfExists as LogEntryEvent; // At this moment we are sure that no error occured and log is defined.
let maybeDecodedLog; const maybeDecodedLog = this._web3Wrapper.abiDecoder.tryToDecodeLogOrNoop<ContractEventArgs>(log);
try {
maybeDecodedLog = this._web3Wrapper.abiDecoder.tryToDecodeLogOrNoop<ContractEventArgs>(log);
} catch (error) {
if (error.code === ethers.errors.INVALID_ARGUMENT) {
return; // noop
}
throw error;
}
const isLogDecoded = !_.isUndefined(((maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>).event); const isLogDecoded = !_.isUndefined(((maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>).event);
if (!isLogDecoded) { if (!isLogDecoded) {
return; // noop return; // noop

View File

@ -1,4 +1,13 @@
[ [
{
"version": "0.7.3",
"changes": [
{
"note": "Fixes uncaught Error in abi_decoder",
"pr": 763
}
]
},
{ {
"version": "0.7.2", "version": "0.7.2",
"changes": [ "changes": [

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/utils", "name": "@0xproject/utils",
"version": "0.7.1", "version": "0.7.3",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },

View File

@ -32,7 +32,15 @@ export class AbiDecoder {
const decodedParams: DecodedLogArgs = {}; const decodedParams: DecodedLogArgs = {};
let topicsIndex = 1; let topicsIndex = 1;
const decodedData = ethersInterface.events[event.name].parse(log.data); let decodedData: any[];
try {
decodedData = ethersInterface.events[event.name].parse(log.data);
} catch (error) {
if (error.code === ethers.errors.INVALID_ARGUMENT) {
return log;
}
throw error;
}
let didFailToDecode = false; let didFailToDecode = false;
_.forEach(event.inputs, (param: EventParameter, i: number) => { _.forEach(event.inputs, (param: EventParameter, i: number) => {