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
8 changes: 4 additions & 4 deletions examples/react-wallet-connect/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* React wallet-connect example β€” UI layer (#react-wallet-connect).
/*
* React wallet-connect example -- UI layer (#react-wallet-connect).
*
* Renders connect/disconnect, a balance list, and a payment form.
* All sorokit-core calls are in useSorokit.ts β€” this file only reads state
* All sorokit-core calls are in useSorokit.ts -- this file only reads state
* and calls the callbacks the hook exposes.
*/

Expand Down Expand Up @@ -93,7 +93,7 @@ export default function App() {
</div>
)}

{/* Payment form β€” only shown when connected */}
{/* Payment form -- only shown when connected */}
{isConnected && (
<form onSubmit={handleSend} style={{ marginTop: "1.5rem" }}>
<h2>Send XLM</h2>
Expand Down
4 changes: 2 additions & 2 deletions src/shared/response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* SorokitResult β€” the single response format for every public function.
*
* All public operations return a discriminated result. Error metadata is
Expand Down Expand Up @@ -74,7 +74,7 @@ export enum SorokitErrorCode {
ROUTER_INVALID_PATH = "ROUTER_INVALID_PATH",
ROUTER_INSUFFICIENT_LIQUIDITY = "ROUTER_INSUFFICIENT_LIQUIDITY",
ROUTER_SLIPPAGE_EXCEEDED = "ROUTER_SLIPPAGE_EXCEEDED",
ROUTER_SWAP_FAILED = "ROUTER_SWAP_FAILED",
ROUTER_SWAPc_FAILED = "ROUTER_SWAP_FAILED",
CONTRACT_INVOKE_FAILED = "CONTRACT_INVOKE_FAILED",
CONTRACT_READ_FAILED = "CONTRACT_READ_FAILED",
CONTRACT_PREPARE_FAILED = "CONTRACT_PREPARE_FAILED",
Expand Down
15 changes: 15 additions & 0 deletions src/soroban/rpcErrorMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
const text = extractRpcErrorMessage(cause).toLowerCase();
if (status === 429 || /rate.?limit|too many requests|429/.test(text)) return SorokitErrorCode.RATE_LIMITED;
if (/invalid auth|auth.*invalid|signature.*invalid|authorization/.test(text)) return SorokitErrorCode.INVALID_AUTH;
if (/tx_bad_seq|bad.?seq|sequence.*(mismatch|invalid|too (low|high))|txbadseq/.test(text)) return SorokitErrorCode.TX_BAD_SEQ;

Check failure on line 47 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_BAD_SEQ' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 47 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_BAD_SEQ' does not exist on type 'typeof SorokitErrorCode'.
if (/tx_bad_auth|bad.?auth|txbadauth|missing.*signature|wrong.*signer/.test(text)) return SorokitErrorCode.TX_BAD_AUTH;

Check failure on line 48 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_BAD_AUTH' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 48 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_BAD_AUTH' does not exist on type 'typeof SorokitErrorCode'.
if (/tx_no_account|no.?account|account.*(not found|does not exist)|txnoaccount/.test(text)) return SorokitErrorCode.TX_NO_ACCOUNT;

Check failure on line 49 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_NO_ACCOUNT' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 49 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_NO_ACCOUNT' does not exist on type 'typeof SorokitErrorCode'.
if (/tx_too_late|too.?late|time.?bound.*(expired|past)|txtoolate/.test(text)) return SorokitErrorCode.TX_TOO_LATE;

Check failure on line 50 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_TOO_LATE' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 50 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_TOO_LATE' does not exist on type 'typeof SorokitErrorCode'.
if (/tx_too_early|too.?early|time.?bound.*(not yet|future)|txtooearly/.test(text)) return SorokitErrorCode.TX_TOO_EARLY;

Check failure on line 51 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_TOO_EARLY' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 51 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_TOO_EARLY' does not exist on type 'typeof SorokitErrorCode'.
if (/insufficient fee|fee.*insufficient|insufficient.*base fee|fee bid/.test(text)) return SorokitErrorCode.INSUFFICIENT_FEE;
if (/resource exhausted|resource limit|budget exceeded|cpu.*limit|memory.*limit|limit exceeded/.test(text)) return SorokitErrorCode.RESOURCE_LIMIT_EXCEEDED;
if (/xdr|invalid transaction|malformed.*transaction|decode/.test(text)) return SorokitErrorCode.XDR_INVALID;
Expand All @@ -60,6 +65,16 @@
? { retryable: true, action: "Increase the transaction fee using a fresh network estimate, then retry." }
: code === SorokitErrorCode.RESOURCE_LIMIT_EXCEEDED
? { retryable: false, action: "Reduce contract work or split the operation before retrying." }
: code === SorokitErrorCode.TX_BAD_SEQ

Check failure on line 68 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_BAD_SEQ' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 68 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_BAD_SEQ' does not exist on type 'typeof SorokitErrorCode'.
? { retryable: true, action: "Re-fetch the source account sequence number and rebuild the transaction before retrying." }
: code === SorokitErrorCode.TX_BAD_AUTH

Check failure on line 70 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_BAD_AUTH' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 70 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_BAD_AUTH' does not exist on type 'typeof SorokitErrorCode'.
? { retryable: false, action: "Verify the signer, signing key, and signature coverage; rebuild and re-sign the transaction." }
: code === SorokitErrorCode.TX_NO_ACCOUNT

Check failure on line 72 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_NO_ACCOUNT' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 72 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_NO_ACCOUNT' does not exist on type 'typeof SorokitErrorCode'.
? { retryable: false, action: "Fund or create the source account (or correct the account ID) before retrying." }
: code === SorokitErrorCode.TX_TOO_LATE

Check failure on line 74 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_TOO_LATE' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 74 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_TOO_LATE' does not exist on type 'typeof SorokitErrorCode'.
? { retryable: true, action: "Rebuild the transaction with a fresh, later time bound and retry." }
: code === SorokitErrorCode.TX_TOO_EARLY

Check failure on line 76 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'TX_TOO_EARLY' does not exist on type 'typeof SorokitErrorCode'.

Check failure on line 76 in src/soroban/rpcErrorMapper.ts

View workflow job for this annotation

GitHub Actions / Build

Property 'TX_TOO_EARLY' does not exist on type 'typeof SorokitErrorCode'.
? { retryable: true, action: "Wait until the transaction's time bound becomes valid, then retry." }
: { retryable: false, action: "Inspect the Soroban RPC details and correct the transaction or contract inputs." };
const result = err(code, `Soroban RPC error: ${message}`, cause, undefined, { recovery });
if (result.status === "error") return result.error;
Expand Down
Loading