-
Notifications
You must be signed in to change notification settings - Fork 170
Viem Migration - Failed onchain TXs are not detected #7421
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
base: develop
Are you sure you want to change the base?
Changes from all commits
6764398
ef37ee5
1426f98
5a0893c
2e1e315
057034b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,7 +9,10 @@ interface Market<T = string> { | |||||
| quoteToken: T | ||||||
| } | ||||||
|
|
||||||
| const PROVIDER_REJECT_REQUEST_CODES = [4001, -32000] // See https://eips.ethereum.org/EIPS/eip-1193 | ||||||
| // 4001 is the standard EIP-1193 user rejection code. | ||||||
| // -32000 is a generic server error used by nodes for things like "intrinsic gas too low"; | ||||||
| // it is NOT included here because relying on it alone causes node errors to be silently swallowed. | ||||||
| const PROVIDER_REJECT_REQUEST_CODES = [4001] // See https://eips.ethereum.org/EIPS/eip-1193 | ||||||
| const PROVIDER_REJECT_REQUEST_ERROR_MESSAGES = [ | ||||||
| 'User denied message signature', | ||||||
| 'User rejected', | ||||||
|
|
@@ -123,7 +126,12 @@ export function getChainIdValues(): ChainId[] { | |||||
| */ | ||||||
| export function getProviderErrorMessage(error: unknown): string | undefined { | ||||||
| if (typeof error === 'string') return error | ||||||
| if (error && typeof error === 'object' && 'message' in error) return error.message as string | ||||||
| if (error && typeof error === 'object') { | ||||||
| // Prefer viem's shortMessage (concise, human-readable) over the full message | ||||||
| // which includes verbose request arguments and hex data. | ||||||
| if ('shortMessage' in error && typeof error.shortMessage === 'string') return error.shortMessage | ||||||
| if ('message' in error) return error.message as string | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard At Line 130, Suggested fix- if ('message' in error) return error.message as string
+ if ('message' in error && typeof error.message === 'string') return error.message📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| } | ||||||
| return error?.toString() | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
Don’t map nonce-fetch failures to
0Line 39 turns RPC failure into a valid nonce value, which makes the replacement check indistinguishable from a true fresh-account state. That can suppress replacement detection while the RPC is degraded.
Suggested direction
Then type
transactionsCountasnumber | undefinedinCheckEthereumTransactionsand guard downstream replacement logic withtransactionsCount !== undefined.🤖 Prompt for AI Agents
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.
Agree with the bot, it's better to have it as null or something
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.
🧩 Analysis chain
🏁 Script executed:
Length of output: 5669
@shoom3301Agreed —nullis the cleanest signal here since it clearly means "unknown" rather than "zero". Here are all three spots that need to move together:1.
types.ts— widen the type2.
usePendingTransactionsContext.ts— usenullas the fallback3.
checkOnChainTransaction.tsline 77 — guard the replacement checkThe existing
transaction.nonce !== undefinedguard already prevents a false positive when the nonce is missing; addingtransactionsCount !== nullmakes the symmetric case explicit — when the RPC count is unknown, the replacement check is simply skipped rather than silently evaluated against0.