Skip to content
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

Problem with zero in unit256 indexed event #2728

Closed
1 task done
sstepanchuk opened this issue Sep 16, 2024 · 8 comments
Closed
1 task done

Problem with zero in unit256 indexed event #2728

sstepanchuk opened this issue Sep 16, 2024 · 8 comments
Labels
needs reproduction Misc: Needs Reproduction

Comments

@sstepanchuk
Copy link

sstepanchuk commented Sep 16, 2024

Check existing issues

Viem Version

2.21.7

Current Behavior

Event filter ignore prop, if prop = 0, so filter not work properly

Expected Behavior

Event filter should filter events by this prop if prop = 0, filter should return events with prop = 0

Steps To Reproduce

emit any event with indexed unit256 property with 0 value.
emit any event with indexed unit256 property with value diffrent from 0.

try to get event log that have value 0, you will recive all logs, not only this log

Link to Minimal Reproducible Example

No response

Anything else?

My event

struct Pixel { address owner; uint24 color; } event PixelChanged( uint256 indexed Y, uint256 indexed X, address indexed changer, Pixel old, Pixel current );

part of my TS code

`(BigInt.prototype as any).toJSON = function () {
return this.toString();
};

async function deployBoardFixture() {
const [owner, otherAccount] = await hre.viem.getWalletClients();

const board = await hre.viem.deployContract("Board");

const publicClient = await hre.viem.getPublicClient();

await board.write.setPixels([
  pixels
]);

return {
  board,
  owner,
  otherAccount,
  publicClient,
};

}

const { board, owner } = await loadFixture(deployBoardFixture);

const changes = await board.getEvents.PixelChanged({
Y: 0,
X: 0,
changer: owner.account.address
}, {
strict: true
});
console.log(JSON.stringify(changes, null, ' '));

`

JSON that return console log:

[ { "eventName": "PixelChanged", "args": { "Y": "0", "X": "0", "changer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "old": { "owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "color": 1 }, "current": { "owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "color": 1 } }, "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "blockHash": "0x11f6502c9d8dcef7ecddfc259ccef94de8893883399834b49c772836abfdf6ce", "blockNumber": "2", "data": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000001", "logIndex": 0, "removed": false, "topics": [ "0x84b3faa68b847ee5bd2633b3149d770ed66d387f87b8bfcf7fe5bffc28a59ddf", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" ], "transactionHash": "0xde8652351b4eb0f3a0bbb99ec5bb0c605de7cfc9f2ca9e99cb278ca0916fe4e3", "transactionIndex": 0 }, { "eventName": "PixelChanged", "args": { "Y": "0", "X": "1", "changer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "old": { "owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "color": 2 }, "current": { "owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "color": 2 } }, "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "blockHash": "0x11f6502c9d8dcef7ecddfc259ccef94de8893883399834b49c772836abfdf6ce", "blockNumber": "2", "data": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000002", "logIndex": 1, "removed": false, "topics": [ "0x84b3faa68b847ee5bd2633b3149d770ed66d387f87b8bfcf7fe5bffc28a59ddf", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" ], "transactionHash": "0xde8652351b4eb0f3a0bbb99ec5bb0c605de7cfc9f2ca9e99cb278ca0916fe4e3", "transactionIndex": 0 } ]

@jxom jxom added the needs reproduction Misc: Needs Reproduction label Sep 16, 2024
Copy link
Contributor

Hello @sstepanchuk.

Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository.

Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster.

Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
@sstepanchuk
Copy link
Author

@sstepanchuk
Copy link
Author

@jxom

@jxom
Copy link
Member

jxom commented Sep 16, 2024

Thanks. Fixing now.

@sstepanchuk
Copy link
Author

nice, thank you!

@jxom also. can you pls open this issue?

@jxom
Copy link
Member

jxom commented Sep 17, 2024

should be fixed in latest version

@sstepanchuk
Copy link
Author

okay

Copy link
Contributor

github-actions bot commented Oct 3, 2024

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs reproduction Misc: Needs Reproduction
Projects
None yet
Development

No branches or pull requests

2 participants