From c881887796522b35ffeff8fcfda18284f7e1dc3e Mon Sep 17 00:00:00 2001 From: Sushil-19 Date: Fri, 17 Apr 2026 00:40:19 +0530 Subject: [PATCH 1/4] fix: surface detailed simulation errors including InsufficientFundsForFee --- .../model/use-simulation.ts | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/app/features/instruction-simulation/model/use-simulation.ts b/app/features/instruction-simulation/model/use-simulation.ts index 2677b5691..57b69d731 100644 --- a/app/features/instruction-simulation/model/use-simulation.ts +++ b/app/features/instruction-simulation/model/use-simulation.ts @@ -27,6 +27,30 @@ import { getMintDecimals, isTokenProgramBase58 } from '../lib/tokenAccountParsin import type { SolBalanceChange } from '../lib/types'; import { useEpochInfo } from './use-epoch-info'; +function parseSimulationError(err: any, logs?: string[]): string { + if (!err) return ''; + + if (logs?.some(l => l.includes('InsufficientFundsForFee'))) { + return 'Insufficient funds for transaction fee'; + } + + if (typeof err === 'string') { + if (err.includes('InsufficientFundsForFee')) { + return 'Insufficient funds for transaction fee'; + } + return err; + } + + if (typeof err === 'object') { + if ('InsufficientFundsForFee' in err) { + return 'Insufficient funds for transaction fee'; + } + return JSON.stringify(err); + } + + return 'Transaction failed'; +} + export function useSimulation( message: VersionedMessage, accountBalances?: { @@ -223,7 +247,6 @@ export function useSimulation( if (resp.value.logs.length === 0 && typeof resp.value.err === 'string') { setLogs(null); - setError(resp.value.err); } else { // Prettify logs setLogs(parseProgramLogs(resp.value.logs, resp.value.err, cluster)); @@ -234,7 +257,7 @@ export function useSimulation( } // If the response has an error, the logs will say what it it, so no need to parse here. if (resp.value.err) { - setError('TransactionError'); + setError(parseSimulationError(resp.value.err, resp.value.logs ?? undefined)); } } catch (err) { Logger.error(err); From 633f87b2f1ac2ffe8ab711cd3424354edce31aa6 Mon Sep 17 00:00:00 2001 From: Sushil-19 <96721697+Sushil-19@users.noreply.github.com> Date: Fri, 17 Apr 2026 00:44:59 +0530 Subject: [PATCH 2/4] Update app/features/instruction-simulation/model/use-simulation.ts added recommended comment Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- app/features/instruction-simulation/model/use-simulation.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/features/instruction-simulation/model/use-simulation.ts b/app/features/instruction-simulation/model/use-simulation.ts index 57b69d731..f15a2f245 100644 --- a/app/features/instruction-simulation/model/use-simulation.ts +++ b/app/features/instruction-simulation/model/use-simulation.ts @@ -255,7 +255,8 @@ export function useSimulation( if (resp.value.unitsConsumed !== undefined) { setUnitsConsumed(resp.value.unitsConsumed); } - // If the response has an error, the logs will say what it it, so no need to parse here. + // Parse the error to provide a human-readable message. + if (resp.value.err) { if (resp.value.err) { setError(parseSimulationError(resp.value.err, resp.value.logs ?? undefined)); } From 7fea9b40681e8a41ae00a8cad79eb8d03bbd4621 Mon Sep 17 00:00:00 2001 From: Sushil-19 <96721697+Sushil-19@users.noreply.github.com> Date: Fri, 17 Apr 2026 00:46:35 +0530 Subject: [PATCH 3/4] Update app/features/instruction-simulation/model/use-simulation.ts added the recommended preferred types instead of using any Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- app/features/instruction-simulation/model/use-simulation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/features/instruction-simulation/model/use-simulation.ts b/app/features/instruction-simulation/model/use-simulation.ts index f15a2f245..e9abec1a4 100644 --- a/app/features/instruction-simulation/model/use-simulation.ts +++ b/app/features/instruction-simulation/model/use-simulation.ts @@ -27,7 +27,7 @@ import { getMintDecimals, isTokenProgramBase58 } from '../lib/tokenAccountParsin import type { SolBalanceChange } from '../lib/types'; import { useEpochInfo } from './use-epoch-info'; -function parseSimulationError(err: any, logs?: string[]): string { +function parseSimulationError(err: object | string | null, logs?: string[]): string { if (!err) return ''; if (logs?.some(l => l.includes('InsufficientFundsForFee'))) { From 7dc1ae58c078354346d04c227fb2045ad28d9411 Mon Sep 17 00:00:00 2001 From: Sushil-19 Date: Fri, 17 Apr 2026 00:58:48 +0530 Subject: [PATCH 4/4] fix: prioritize structured error before log scanning --- .../instruction-simulation/model/use-simulation.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/features/instruction-simulation/model/use-simulation.ts b/app/features/instruction-simulation/model/use-simulation.ts index e9abec1a4..1e4030e0d 100644 --- a/app/features/instruction-simulation/model/use-simulation.ts +++ b/app/features/instruction-simulation/model/use-simulation.ts @@ -30,10 +30,6 @@ import { useEpochInfo } from './use-epoch-info'; function parseSimulationError(err: object | string | null, logs?: string[]): string { if (!err) return ''; - if (logs?.some(l => l.includes('InsufficientFundsForFee'))) { - return 'Insufficient funds for transaction fee'; - } - if (typeof err === 'string') { if (err.includes('InsufficientFundsForFee')) { return 'Insufficient funds for transaction fee'; @@ -48,6 +44,10 @@ function parseSimulationError(err: object | string | null, logs?: string[]): str return JSON.stringify(err); } + if (logs?.some(l => l.includes('InsufficientFundsForFee'))) { + return 'Insufficient funds for transaction fee'; + } + return 'Transaction failed'; } @@ -255,8 +255,7 @@ export function useSimulation( if (resp.value.unitsConsumed !== undefined) { setUnitsConsumed(resp.value.unitsConsumed); } - // Parse the error to provide a human-readable message. - if (resp.value.err) { + // If the response has an error, the logs will say what it it, so no need to parse here. if (resp.value.err) { setError(parseSimulationError(resp.value.err, resp.value.logs ?? undefined)); }