fix(core): enable getTransaction query for blockNumber 0 (genesis) - #5224
fix(core): enable getTransaction query for blockNumber 0 (genesis)#5224official-burak wants to merge 1 commit into
Conversation
The `enabled` guard and the `queryFn` precondition in
`getTransactionQueryOptions` tested `blockNumber` for truthiness, so the
genesis block `0n` was treated as absent. `{ blockNumber: 0n, index }`
computed `enabled: false` and the query never fetched; forcing it to run
threw "hash OR index AND blockHash, blockNumber, blockTag is required".
This is the remaining half of the same falsy check corrected for `index`
in wevm#5197. viem's `getTransaction` accepts `blockNumber: 0n`, and
`filterQueryOptions` already preserves it in the query key.
|
@official-burak is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 64f024a The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
promiseeuler
left a comment
There was a problem hiding this comment.
While testing this fix locally on commit 64f024ad, I confirmed that the two new genesis-block cases exercise both index: 0 and a non-zero index, so the regression is isolated to the falsy blockNumber: 0n check. The same explicit !== undefined guard is applied consistently in query enablement and the query-function precondition.
Validation:
vitest run packages/core/src/query/getTransaction.test.ts: 5 passed.biome checkon both changed TypeScript files: clean.git show --check HEAD: passed.
I also ran the test from the main checkout as a control before noticing the worktree path: main collects only the original 3 cases, while this branch collects and passes all 5.
getTransactionQueryOptionstestsblockNumberfor truthiness in both theenabledguard and thequeryFnprecondition, so the genesis block0nis treated as absent:With
{ blockNumber: 0n, index: 0 }the inner group evaluates toundefined, soenabledisfalseand the query never fetches. The user cannot override it either, sincequery.enabledis ANDed with the same expression, souseTransaction({ blockNumber: 0n, index: 0 })sits permanently idle with no error. If thequeryFnis invoked directly it throws the misleadinghash OR index AND blockHash, blockNumber, blockTag is required. Any other block number works, which masks the bug.This is the remaining half of the same falsy check: #5197 corrected
indexon this exact expression but leftblockNumber, and #5203 correctedblockNumber: 0ningetBalance/getTransactionCountfor the same reason.Nothing downstream blocks the value: viem's
getTransactionacceptsblockNumber: 0n, andfilterQueryOptionsuses rest destructuring so0nis preserved in the query key.Change
Compare
blockNumberagainstundefinedinstead of testing truthiness, in both theenabledguard and thequeryFnprecondition, matching the treatmentindexalready received.blockHashandblockTagare left as-is since they are non-empty strings when present.Tests
Added two cases to
packages/core/src/query/getTransaction.test.tscoveringblockNumber: 0nwithindex: 0and with a non-zero index, so the assertion isolatesblockNumberrather thanindex.Both fail on
mainand pass with this change:The full
packages/core/src/querysuite passes: 54 files, 123 tests.biome checkis clean on both changed files.