diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-02-06 05:16:46 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-02-06 05:16:46 +0800 |
commit | 99b1f81e89e3ac929c7829552ea7ae19998524e9 (patch) | |
tree | 534161a9fa8bcf8bb5572d7ef0aa311fe9b9d116 /packages/utils | |
parent | 6577d607332e2fb1a442d663e260ecb969457c36 (diff) | |
parent | 46ad7b1b38df0f302821258629ffa749e7dd00b9 (diff) | |
download | dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.gz dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.zst dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.zip |
Merge branch 'development' into feature/testnet-faucets/order-dispenser
* development: (37 commits)
Add dates to CHANGELOGs
Change CHANGELOGs
Add .editorconfig
Fix a typo
Temp
Use forEach instead of map
Add PR number
Fix an exception when a signature collision happens
Fix prettier
Add regression tests
Improve the comment and fix an exception
Add missing comas
Lerna-ignore tslint and tsconfig
Update contract versions, fix tests
Rename directories
Rename previous contracts, fix imports, add nested file structure
Move all contracts into a single directory
Update import
Fix import
Get rid of suffixed contract versioning and replace it with a poor-mans package manager. Versions are stored locally, and are generated in a copy-on-write basis as required
...
Diffstat (limited to 'packages/utils')
-rw-r--r-- | packages/utils/CHANGELOG.md | 8 | ||||
-rw-r--r-- | packages/utils/README.md | 6 | ||||
-rw-r--r-- | packages/utils/package.json | 11 | ||||
-rw-r--r-- | packages/utils/src/abi_decoder.ts | 23 |
4 files changed, 34 insertions, 14 deletions
diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index efee30dd1..b94e2ccee 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,6 +1,10 @@ # CHANGELOG +## v0.3.0 - _February 5, 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/README.md b/packages/utils/README.md index d6cacfa11..ffb0d0190 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -40,6 +40,12 @@ yarn install yarn build ``` +or + +```bash +yarn build:watch +``` + ### Lint ```bash diff --git a/packages/utils/package.json b/packages/utils/package.json index db82f8040..e276d5e5a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,10 +1,11 @@ { "name": "@0xproject/utils", - "version": "0.2.3", + "version": "0.2.4", "description": "0x TS utils", "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { + "build:watch": "tsc -w", "build": "tsc", "clean": "shx rm -rf lib", "lint": "tslint --project . 'src/**/*.ts'" @@ -19,14 +20,14 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/utils/README.md", "devDependencies": { - "@0xproject/tslint-config": "^0.4.5", - "@0xproject/types": "^0.1.5", + "@0xproject/tslint-config": "^0.4.6", + "@0xproject/types": "^0.1.8", "@types/lodash": "^4.14.86", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "tslint": "5.8.0", - "web3-typescript-typings": "^0.9.5", - "typescript": "~2.6.1" + "typescript": "2.7.1", + "web3-typescript-typings": "^0.9.8" }, "dependencies": { "bignumber.js": "~4.1.0", 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) => { |