Skip to content

Commit

Permalink
fixes #1044 and adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frozeman committed Sep 20, 2017
1 parent 48c6386 commit 499b1cb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/web3-eth-abi/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ ABICoder.prototype.decodeLog = function (inputs, data, topics) {
returnValue.__length__ = 0;

inputs.forEach(function (res, i) {
returnValue[i] = (res.type === 'string') ? '' : null;

if (notIndexedParams[i]) {
returnValue[i] = notIndexedParams[i];
}
Expand Down
50 changes: 50 additions & 0 deletions test/eth.abi.decodeLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,56 @@ var tests = [{
myNumber: '62224',
"__length__": 2
}
},{
params: [[{
indexed: true, name: "from", type: "address"
},
{
indexed: true, name: "to", type: "address"
},
{
indexed: false, name: "amount", type: "uint256"
},
{
indexed: false, name: "narrative", type: "string"
}], '0x0000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000067465737420780000000000000000000000000000000000000000000000000000',
['0x000000000000000000000000ae653250b4220835050b75d3bc91433246903a95', '0x00000000000000000000000094011c67bc1e6448ed4b8682047358ca6cd09470']],
result: {
'0': '0xae653250B4220835050B75D3bC91433246903A95',
'1': '0x94011c67BC1E6448ed4b8682047358ca6cD09470',
'2': '10000',
'3': 'test x',
from: '0xae653250B4220835050B75D3bC91433246903A95',
to: '0x94011c67BC1E6448ed4b8682047358ca6cD09470',
amount: '10000',
narrative: 'test x',
__length__: 4
}
},{
params: [[{
indexed: true, name: "from", type: "address"
},
{
indexed: true, name: "to", type: "address"
},
{
indexed: false, name: "amount", type: "uint256"
},
{
indexed: false, name: "narrative", type: "string"
}], '0x000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
['0x000000000000000000000000ae653250b4220835050b75d3bc91433246903a95', '0x00000000000000000000000094011c67bc1e6448ed4b8682047358ca6cd09470']],
result: {
'0': '0xae653250B4220835050B75D3bC91433246903A95',
'1': '0x94011c67BC1E6448ed4b8682047358ca6cD09470',
'2': '10000',
'3': '',
from: '0xae653250B4220835050B75D3bC91433246903A95',
to: '0x94011c67BC1E6448ed4b8682047358ca6cD09470',
amount: '10000',
narrative: '',
__length__: 4
}
}];

describe('decodeLog', function () {
Expand Down

0 comments on commit 499b1cb

Please sign in to comment.