-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix decodeLog() for non indexed params #2272
Conversation
Fix `decodeLog()` for non indexed params. The issue can be reproduced for events like this: ``` event Authorize( bytes32 indexed platformId, bytes32 indexed uid, address indexed user, AuthorizationRequest request ); ``` It is cause by `_mapTypes(types)` used in `decodeParameters(outputs, bytes)` (`var res = this.ethersAbiCoder.decode(this._mapTypes(outputs), "0x".concat(bytes.replace(/0x/i, '')));`) which returns `[ { indexed: false, name: 'request', type: 'address' } ]` for `types = outputs = [null, null, null, {"indexed":false,"name":"request","type":"address"}]` passed as argument. So when the iteration `outputs.forEach(function (output, i) {}` is performed the `returnValues` do not get `res[i]` assigned correctly because the index is shifted due to empty types cleanup. The fix might be linked to the following issue: web3#2268
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the AbiCoder and AbiCoder test in the eth-abi module? the created test case "calls decodeLog and returns the expected object" should run without a error :-)
@nivida Done |
2 similar comments
@nivida I see Travis failing due to other tests/linting checks performed. How can i help to fix it? |
@AlexanderC Because |
Fix
decodeLog()
for non indexed params.Description
The issue can be reproduced for events like this:
It is cause by
_mapTypes(types)
used indecodeParameters(outputs, bytes)
(var res = this.ethersAbiCoder.decode(this._mapTypes(outputs), "0x".concat(bytes.replace(/0x/i, '')));
) which returns[ { indexed: false, name: 'request', type: 'address' } ]
fortypes = outputs = [null, null, null, {"indexed":false,"name":"request","type":"address"}]
passed as argument.So when the iteration
outputs.forEach(function (output, i) {}
is performed thereturnValues
do not getres[i]
assigned correctly because the index is shifted due to empty types cleanup.Fixes #2268
Type of change
Checklist:
npm run test
in the root folder with success and extended the tests if necessary.npm run build
in the root folder and tested it in the browser and with node.