-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
decoder issue with 0x
#559
Comments
What is the ABI you are parsing? |
We're still on 4.0.27 obviously... If this fix makes it in, I will upgrade to the latest |
The last example you give certainly has an invalid data for Transfer... The data is “0x”, but it should be the 32 byte (64 nibble) token id. Can you include an example log (pasted text, not an image, so I can copy paste :)) that doesn’t work? |
(my first guess is that you either need to add “indexed” to tokenId in your ABI or remove it from your event declaration in the Solidity, which ever makes sense for your case, i.e. ERC-20 vs ERC-721) |
confirmed: the script that generates the ABI is not pulling the |
Actually, I see this: |
{
transactionIndex: 0,
blockHash: "0x9d8fd1e7ae89294b37c4cb76376659972fa20023009d00354d997d74f7985731",
blockNumber: 18231,
data: "0x",
logIndex: 0,
transactionHash: "0x4086c613b943dd8dc53e68abd96b57deeb2d7dc5062f7354cd287946503880d0",
address: "0x8276A24C03B7ff9307c5bb9c0f31aa60d284375f",
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000a62a4e71336526b7e52b2c461076125c9f14a2c8",
"0x0000000000000000000000000000000000000000000000000000000000000001",
],
transactionLogIndex: 0
} |
Can you provide a log (only the data and topics are necessary) that is not being parsed? |
I believe that is the log in #559 (comment), none of the others have data of |
If I'm reading https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges right, the data field should be |
That is correct, and in the log you provided it is. And you are saying it isn’t parsing when you use the signature “event Transfer(address indexed from, address indexed to, uint indexed tokenId)”? What is the error you get? |
I traced into ethers.min.js, and it appears this happens because it is looking at |
I'm at your service for debugging this one |
Right, which means the ABI it is using is incorrect. It will only look at data in the event the parameter is not indexed. This works fine for me: let data = "0x";
let topics = [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x0000000000000000000000000000000000000000000000000000000000000000',
'0x000000000000000000000000a62a4e71336526b7e52b2c461076125c9f14a2c8',
'0x0000000000000000000000000000000000000000000000000000000000000001'
];
let iface = new ethers.utils.Interface([ "event Transfer(address indexed from, address indexed to, uint indexed tokenId)" ]);
iface.parseLog({ data, topics });
/* Result:
_LogDescription {
decode: [Function],
name: 'Transfer',
signature: 'Transfer(address,address,uint256)',
topic:
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
values:
Result {
'0': '0x0000000000000000000000000000000000000000',
'1': '0xA62a4e71336526b7E52B2C461076125C9F14a2c8',
'2': BigNumber { _hex: '0x01' },
from: '0x0000000000000000000000000000000000000000',
to: '0xA62a4e71336526b7E52B2C461076125C9F14a2c8',
tokenId: BigNumber { _hex: '0x01' },
length: 3 } }
*/ So, I'm pretty sure it's just the ABI you are using is not matching the Solidity you are calling... :s |
ok, I'll keep digging and report back when I find what is going on |
You can try printing out your If you are using truffle or some tools like that, make sure you try a clean build, sometimes it doesn't update artifacts correctly. |
the plot thickens: that wasn't the log that was failing! It was this one: {
address: "0x591AD9066603f5499d12fF4bC207e2f577448c46",
blockHash: "0x9d8fd1e7ae89294b37c4cb76376659972fa20023009d00354d997d74f7985731",
blockNumber: 18231,
data: "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
logIndex: 1,
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000e29ec42f0b620b1c9a716f79a02e9dc5a5f5f98a",
"0x0000000000000000000000008276a24c03b7ff9307c5bb9c0f31aa60d284375f"
],
transactionHash: "0x4086c613b943dd8dc53e68abd96b57deeb2d7dc5062f7354cd287946503880d0",
transactionIndex: 0,
transactionLogIndex: 1,
} |
and look at that, the tokenid is missing!! I think we found the bug, it may be in the smart contract after all |
OK! I just talked to our smart contract dev for a bit, and I finally understand what is going on. Our ERC721 contract is emitting the first event. But because this transaction is using DAI to do the actual purchase, the ERC20 contract is emitting the 2nd event (and the Thanks for the help looking into this, it's definitely a bug on our side, ethers is fabulous, as always :) |
I am seeing an error when parsing a transactionReceipt log
The error is
Error: insufficient data for uint256 type (arg="_tokenId", coderType="uint256", value="0x", version=4.0.27)
I noticed the transaction:
has 3 logs, the first has this form:
So it looks like the decoder is not handling a valid data type returned from ganache. I have also seen this value returned from transaction receipts in the wild.
The text was updated successfully, but these errors were encountered: