-
Notifications
You must be signed in to change notification settings - Fork 196
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
feat(store-sync): add status and block number to return type of waitForTransaction #2668
Conversation
🦋 Changeset detectedLatest commit: 4e35c97 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 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 |
return lastBlock.blockNumber >= receipt.blockNumber; | ||
const { status, blockNumber } = await publicClient.getTransactionReceipt({ hash: tx }); | ||
if (lastBlock.blockNumber >= blockNumber) { | ||
return { status, blockNumber }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return everything from getTransactionReceipt
? Then this is like a wrapper for that function and users can use everything it returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we don't have access to most of this information in the early return case above and it feels wrong to only include this information in some cases based on a race condition
for (const block of blocks) { | ||
const txs = block.logs.map((op) => op.transactionHash); | ||
// If the transaction caused a log, it must have succeeded | ||
if (txs.includes(tx)) return { blockNumber: block.blockNumber, status: "success" as const }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (txs.includes(tx)) return { blockNumber: block.blockNumber, status: "success" as const }; | |
if (txs.includes(tx)) { | |
return { blockNumber: block.blockNumber, status: "success" as const }; | |
} |
const receipt = await publicClient.getTransactionReceipt({ hash: tx }); | ||
return lastBlock.blockNumber >= receipt.blockNumber; | ||
const { status, blockNumber, transactionHash } = await publicClient.getTransactionReceipt({ hash: tx }); | ||
if (lastBlock.blockNumber >= blockNumber) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at this now, I wonder if this is maybe the cause of infinite spinning sometimes
if we get a receipt, we only sometimes return it?
I think this might be here to make sure the syncing is caught up to where the block for this receipt came through, but just want to check/confirm that we would refetch this transaction receipt while waiting, or if this would cause it to sort of "fall out" of the loop and ~wait indefinitely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would refetch it when processing the next block. Agree we should add caching to fetching tx receipts though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.