fix(core): enable getTransaction query for blockNumber 0 (genesis) - #5224
Open
official-burak wants to merge 1 commit into
Open
fix(core): enable getTransaction query for blockNumber 0 (genesis)#5224official-burak wants to merge 1 commit into
official-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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.