Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/queryClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { QueryClient } from '@tanstack/react-query';
import { queryKeys } from './query-keys';
import toast from 'react-hot-toast';

export function makeQueryClient(): QueryClient {
return new QueryClient({
Expand Down Expand Up @@ -47,5 +48,6 @@ export async function refreshStreamData(): Promise<void> {
]);
} catch (error) {
console.warn('Failed to refresh stream data after a transaction.', error);
toast.error('Failed to refresh data. Please refresh the page manually.');
}
}
63 changes: 29 additions & 34 deletions lib/soroban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,45 +549,40 @@ export async function simulateReadOnly(
validateTimeout(timeoutMs);
if (signal?.aborted) throw new OperationAbortedError();

return withRetry(async () => {
const account = await withTimeout(
getServer().getAccount(source),
timeoutMs,
'simulateReadOnly/getAccount',
signal,
);
const fee = await getInclusionFee(timeoutMs, signal);
const contract = new Contract(contractId);
const tx = new TransactionBuilder(account, {
fee,
networkPassphrase: getNetworkPassphrase(),
})
.addOperation(contract.call(method, ...args))
.setTimeout(60)
.build();
const account = await withTimeout(
getServer().getAccount(source),
timeoutMs,
'simulateReadOnly/getAccount',
signal,
);
const fee = await getInclusionFee(timeoutMs, signal);
const contract = new Contract(contractId);
const tx = new TransactionBuilder(account, {
fee,
networkPassphrase: getNetworkPassphrase(),
})
.addOperation(contract.call(method, ...args))
.setTimeout(60)
.build();

if (signal?.aborted) throw new OperationAbortedError();
if (signal?.aborted) throw new OperationAbortedError();

const result = await withTimeout(
getServer().simulateTransaction(tx),
timeoutMs,
'simulateTransaction',
signal,
);
const result = await withTimeout(
getServer().simulateTransaction(tx),
timeoutMs,
'simulateTransaction',
signal,
);

if (signal?.aborted) throw new OperationAbortedError();
if (signal?.aborted) throw new OperationAbortedError();

if (SorobanRpc.Api.isSimulationError(result)) {
throw new Error(`Simulation error: ${result.error}`);
}
const retval = result.result?.retval;
if (!retval) throw new Error('No result returned from simulation');
if (SorobanRpc.Api.isSimulationError(result)) {
throw new Error(`Simulation error: ${result.error}`);
}
const retval = result.result?.retval;
if (!retval) throw new Error('No result returned from simulation');

return xdr.ScVal.fromXDR(retval.toXDR());
}, {
context: `simulateReadOnly(${method})`,
signal,
});
return xdr.ScVal.fromXDR(retval.toXDR());
}

// ── Helpers ───────────────────────────────────────────────────────────────────
Expand Down