fix: surface detailed simulation errors including InsufficientFundsFo…#951
fix: surface detailed simulation errors including InsufficientFundsFo…#951Sushil-19 wants to merge 4 commits into
Conversation
|
@Sushil-19 is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR replaces the hardcoded Confidence Score: 5/5Safe to merge — the change is a clear improvement over the previous hardcoded generic error string, with only minor style-level findings. All findings are P2 (stale comment, loose No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[simulateTransaction response] --> B{resp.value.err?}
B -- no --> C[No error set]
B -- yes --> D[parseSimulationError]
D --> E{logs include InsufficientFundsForFee?}
E -- yes --> F[Return human-readable fee message]
E -- no --> G{typeof err === string?}
G -- yes --> H{err includes InsufficientFundsForFee?}
H -- yes --> F
H -- no --> I[Return err string as-is]
G -- no --> J{typeof err === object?}
J -- yes --> K{InsufficientFundsForFee in err?}
K -- yes --> F
K -- no --> L[Return JSON.stringify err]
J -- no --> M[Return Transaction failed]
F --> N[setError with message]
I --> N
L --> N
M --> N
Reviews (1): Last reviewed commit: "fix: surface detailed simulation errors ..." | Re-trigger Greptile |
| if (logs?.some(l => l.includes('InsufficientFundsForFee'))) { | ||
| return 'Insufficient funds for transaction fee'; | ||
| } |
There was a problem hiding this comment.
Logs scanned before the error object is inspected
The function checks whether any log line contains 'InsufficientFundsForFee' before examining the structured err value. A log line from an inner CPI call or a diagnostic message that merely mentions that string would trigger the wrong human-readable label even if the real top-level error is something different (e.g. InstructionError). Inspecting the structured err first is more reliable; fall back to log-scanning only when the error object doesn't match.
added recommended comment Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
added the recommended preferred types instead of using any Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Updated, prioritizing structured error over logs. |
|
Hey! Thanks for the PR. Please update the PR description according to the template, including examples and screenshots (before and after), so it's clear what changes have been made. Also, please add tests. |
| import type { SolBalanceChange } from '../lib/types'; | ||
| import { useEpochInfo } from './use-epoch-info'; | ||
|
|
||
| function parseSimulationError(err: object | string | null, logs?: string[]): string { |
There was a problem hiding this comment.
Thank you for your contribution, but the current approach looks to me like an ad hoc solution.
I'd prefer to see a generalised approach to adopt @solana/errors, for example. Tests are also always welcome
…rFee
Description
Type of change
Screenshots
Testing
Related Issues
Checklist
build:infoscript to update build informationAdditional Notes