aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2018-02-06 04:56:04 +0800
committerGitHub <noreply@github.com>2018-02-06 04:56:04 +0800
commit156e85a6b3347c8c7f3751632ef98757194a5ab0 (patch)
treec9a750032e3bd1664d66b94aeb91c072cf1de49d
parent4ddb86df53802fe5c965724d965d281528a97971 (diff)
parent6fce02d25e8133da16b1965cbd51b1edb74fcf7a (diff)
downloaddexon-sol-tools-156e85a6b3347c8c7f3751632ef98757194a5ab0.tar
dexon-sol-tools-156e85a6b3347c8c7f3751632ef98757194a5ab0.tar.gz
dexon-sol-tools-156e85a6b3347c8c7f3751632ef98757194a5ab0.tar.bz2
dexon-sol-tools-156e85a6b3347c8c7f3751632ef98757194a5ab0.tar.lz
dexon-sol-tools-156e85a6b3347c8c7f3751632ef98757194a5ab0.tar.xz
dexon-sol-tools-156e85a6b3347c8c7f3751632ef98757194a5ab0.tar.zst
dexon-sol-tools-156e85a6b3347c8c7f3751632ef98757194a5ab0.zip
Merge pull request #366 from 0xProject/fix/abi_decoder_colision
Fix an exception when a signature collision happens
-rw-r--r--packages/0x.js/CHANGELOG.md3
-rw-r--r--packages/utils/CHANGELOG.md8
-rw-r--r--packages/utils/src/abi_decoder.ts23
3 files changed, 24 insertions, 10 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index 06b11cba8..b23756986 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -1,8 +1,9 @@
# CHANGELOG
-## v0.x.0 - _TBD, 2018_
+## v0.x.x - _TBD, 2018_
* Add `zeroEx.etherToken.getContractAddressIfExists` (#350)
+ * Fixed the bug causing order watcher to throw if there is an event with the same signature but different indexed fields (#366)
## v0.31.1 - _February 1, 2018_
diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md
index efee30dd1..d1c3264fa 100644
--- a/packages/utils/CHANGELOG.md
+++ b/packages/utils/CHANGELOG.md
@@ -1,6 +1,10 @@
# CHANGELOG
+## v0.x.x - _TBD, 2018_
+
+ * Fix a bug related to event signature collisions (argument indexes aren't included in event signatures) in the abi_decoder. The decoder used to throw on unknown events with identical signatures as a known event (except indexes). (#366)
+
## v0.2.0 - _January 17, 2018_
-* Add `onError` parameter to `intervalUtils.setAsyncExcludingInterval` (#312)
-* Add `intervalUtils.setInterval` (#312)
+ * Add `onError` parameter to `intervalUtils.setAsyncExcludingInterval` (#312)
+ * Add `intervalUtils.setInterval` (#312)
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index f96ee2edb..368973b1b 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -18,7 +18,7 @@ export class AbiDecoder {
return `0x${formatted}`;
}
constructor(abiArrays: Web3.AbiDefinition[][]) {
- _.map(abiArrays, this._addABI.bind(this));
+ _.forEach(abiArrays, this._addABI.bind(this));
}
// This method can only decode logs from the 0x & ERC20 smart contracts
public tryToDecodeLogOrNoop<ArgsType>(log: Web3.LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
@@ -36,9 +36,14 @@ export class AbiDecoder {
const dataTypes = _.map(nonIndexedInputs, input => input.type);
const decodedData = SolidityCoder.decodeParams(dataTypes, logData.slice('0x'.length));
- _.map(event.inputs, (param: Web3.EventParameter) => {
+ let failedToDecode = false;
+ _.forEach(event.inputs, (param: Web3.EventParameter) => {
// Indexed parameters are stored in topics. Non-indexed ones in decodedData
let value: BigNumber | string = param.indexed ? log.topics[topicsIndex++] : decodedData[dataIndex++];
+ if (_.isUndefined(value)) {
+ failedToDecode = true;
+ return;
+ }
if (param.type === SolidityTypes.Address) {
value = AbiDecoder._padZeros(new BigNumber(value).toString(16));
} else if (
@@ -51,11 +56,15 @@ export class AbiDecoder {
decodedParams[param.name] = value;
});
- return {
- ...log,
- event: event.name,
- args: decodedParams,
- };
+ if (failedToDecode) {
+ return log;
+ } else {
+ return {
+ ...log,
+ event: event.name,
+ args: decodedParams,
+ };
+ }
}
private _addABI(abiArray: Web3.AbiDefinition[]): void {
_.map(abiArray, (abi: Web3.AbiDefinition) => {