-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
indexed parameters are shifted by one when decoding logs #2368
Comments
Small example to reproduce, querying past
The output is:
Compare this with the transfer information on Etherscan here. The transfer goes from |
I'm seeing something similar with beta.46. When I subscribe to Transfer events, i'm seeing the to and from values being swapped. The event signature is:
The raw event log is:
Decoded return values:
|
I have the same issue: //New offer
event NewOffer(
address indexed maker,
uint256 indexed offerId,
address indexed tokenAddress,
uint256 offerType,
uint128 startDate,
uint128 endDate,
uint256 amount,
uint256 price,
uint256 minimum
); Expected result: {
'0': '0x12583F7627099D8C89A68112C15B83628E72CBE7',
'1': '0',
'2': '0x5562779B00A8Ad6344586E23F940d9e4E202F849',
'3': '13',
'4': '1550123168',
'5': '2414123168',
'6': '1000000',
'7': '1000',
'8': '100',
maker: '0x12583F7627099D8C89A68112C15B83628E72CBE7',
offerId: '0',
tokenAddress: '0x5562779B00A8Ad6344586E23F940d9e4E202F849',
offerType: '13',
startDate: '1550123168',
endDate: '2414123168',
amount: '1000000',
price: '1000',
minimum: '100'
} Which was I received: {
'0': '0x5562779B00A8Ad6344586E23F940d9e4E202F849',
'1': '104729827731522621819118954356228975471770127335',
'2': '0x0000000000000000000000000000000000000000',
'3': '13',
'4': '1550123168',
'5': '2414123168',
'6': '1000000',
'7': '1000',
'8': '100',
maker: '0x5562779B00A8Ad6344586E23F940d9e4E202F849',
offerId: '104729827731522621819118954356228975471770127335',
tokenAddress: '0x0000000000000000000000000000000000000000',
offerType: '13',
startDate: '1550123168',
endDate: '2414123168',
amount: '1000000',
price: '1000',
minimum: '100'
} To me, it was happened to both 1.0.0beta45 and 1.0.0beta46. |
Thanks all for the detailed information! I will fix and release it asap. |
I think I'm still seeing this error in web3 1.2.6 const data = '0x000000000000000000000000000000000000000000000004eee0f1dc808c0000';
const inputs = [ { indexed: true, name: 'user', type: 'address' },
{ indexed: false, name: 'amount', type: 'uint256' },
{ indexed: true, name: 'depositIndex', type: 'uint256' } ];
const topics = [ 'd9acabe6e09d178728ba5c366661c5be0621b4770f216305b059ec175b37e0b4',
'000000000000000000000000a8a07f09def5e6a4462df90068c11abf6224e865',
'000000000000000000000000000000000000000000000000000000000000000f' ];
const res = web3.eth.abi.decodeLog(inputs, data, topics);
console.log(res);
/*
Result {
'0': '0x6661C5bE0621b4770F216305B059EC175B37e0B4',
'1': '91000000000000000000',
'2': '962689635349389981377523555802656161741058402405',
__length__: 3,
user: '0x6661C5bE0621b4770F216305B059EC175B37e0B4',
amount: '91000000000000000000',
depositIndex: '962689635349389981377523555802656161741058402405' }
*/
// depositIndex should be a small integer... |
Error is still occuring for me as well on web3 1.2.6 using web3.eth.abi.decodeLog()... 0: "17" _loanID / _communityID / _borrower are the 3 indexed params |
I fixed above error by adjusting the order of logs sent into the decodeLog in 3rd param: result.logs[0].topics[1], |
Expected behavior
decodeLog
inAbiCoder.js
(here) should return a map from all event parameter names to their decoded data with respect to the type specified in the ABI.Actual behavior
The data used to decode indexed parameters of events is shifted by one topic (i.e. the first indexed parameter uses the data from
topics[0]
when it should in fact usetopics[1]
). Note that the first topic (topics[0]
) is always defined to be the hash of the event signature.Steps to reproduce the behavior
Use
getPastEvents
to query for an event with at least one indexed parameter and compare the result value of the event with the raw value.Error Logs
no error
Versions
web3.js 1.0.0-beta.46
The text was updated successfully, but these errors were encountered: