fix(examples): skip simulateContract for bid to avoid stale RPC allowance error#87
Closed
WillSewell wants to merge 1 commit into
Closed
fix(examples): skip simulateContract for bid to avoid stale RPC allowance error#87WillSewell wants to merge 1 commit into
WillSewell wants to merge 1 commit into
Conversation
…ance error The bid flow approves the ERC20, waits for the receipt, then runs simulateContract (eth_call at block "latest") before writing the bid. On load-balanced RPCs like sepolia.base.org, the eth_call can be served by a node that hasn't yet seen the approval block, returning "transfer amount exceeds allowance" and forcing the user to click Commit a second time. The on-chain execution always sees the confirmed approval, so calling writeContractAsync directly is safe. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
|
Switching approach — keeping the pre-flight simulation and adding a code comment instead, since this only affects load-balanced public RPCs and the right production fix is to configure a dedicated RPC. New PR incoming. |
2 tasks
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.
Summary
simulateContract(aneth_callat block"latest") right after the ERC20 approval is confirmed. On load-balanced RPCs likesepolia.base.org, theeth_callcan be routed to a node that hasn't yet seen the approval block, so it reverts withtransfer amount exceeds allowanceand the user has to click Commit a second time.writeContractAsyncdirectly with the bid args. The on-chain execution runs after the approval is confirmed and always sees the correct allowance.nextjs-evmandreact-evm. TheapproveandcancelBidsimulations are unchanged — they don't depend on a just-confirmed block.Resolves SONAR-5.
Test Plan
tsc --noEmitpasses fornextjs-evmtsc -bpasses forreact-evmeslintpasses on both modified filessepolia.base.org, click Commit on a fresh permit, confirm it goes through on the first attempt without the allowance revert