diff --git a/.changeset/calm-swans-stay.md b/.changeset/calm-swans-stay.md new file mode 100644 index 000000000..b1e53c382 --- /dev/null +++ b/.changeset/calm-swans-stay.md @@ -0,0 +1,5 @@ +--- +'@solana/errors': minor +--- + +Add `SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED` and `SOLANA_ERROR__WALLET__SIGNER_NOT_AVAILABLE` error codes for wallet-signer availability checks. diff --git a/packages/errors/src/codes.ts b/packages/errors/src/codes.ts index 11a9101d4..798e6c18e 100644 --- a/packages/errors/src/codes.ts +++ b/packages/errors/src/codes.ts @@ -371,6 +371,8 @@ export const SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT = 8500006 // Wallet-related errors. // Reserve error codes in the range [8900000-8900999]. export const SOLANA_ERROR__WALLET__NOT_CONNECTED = 8900000; +export const SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED = 8900001; +export const SOLANA_ERROR__WALLET__SIGNER_NOT_AVAILABLE = 8900002; // Invariant violation errors. // Reserve error codes in the range [9900000-9900999]. @@ -692,7 +694,9 @@ export type SolanaErrorCode = | typeof SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT - | typeof SOLANA_ERROR__WALLET__NOT_CONNECTED; + | typeof SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED + | typeof SOLANA_ERROR__WALLET__NOT_CONNECTED + | typeof SOLANA_ERROR__WALLET__SIGNER_NOT_AVAILABLE; /** * Errors of this type are understood to have an optional {@link SolanaError} nested inside as diff --git a/packages/errors/src/context.ts b/packages/errors/src/context.ts index 0b3ef4ce0..b81b4d875 100644 --- a/packages/errors/src/context.ts +++ b/packages/errors/src/context.ts @@ -211,6 +211,7 @@ import { SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT, SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED, SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN, + SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED, SOLANA_ERROR__WALLET__NOT_CONNECTED, SolanaErrorCode, } from './codes'; @@ -874,6 +875,9 @@ export type SolanaErrorContext = ReadonlyContextValue< [SOLANA_ERROR__WALLET__NOT_CONNECTED]: { operation: string; }; + [SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED]: { + status: string; + }; } > >; diff --git a/packages/errors/src/messages.ts b/packages/errors/src/messages.ts index 08e579bb6..8d6879617 100644 --- a/packages/errors/src/messages.ts +++ b/packages/errors/src/messages.ts @@ -298,7 +298,9 @@ import { SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT, + SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED, SOLANA_ERROR__WALLET__NOT_CONNECTED, + SOLANA_ERROR__WALLET__SIGNER_NOT_AVAILABLE, SolanaErrorCode, } from './codes'; @@ -823,4 +825,6 @@ export const SolanaErrorMessages: Readonly<{ [SOLANA_ERROR__TRANSACTION__TOO_MANY_ACCOUNTS_IN_INSTRUCTION]: 'The instruction at index $instructionIndex has $actualCount account references but the maximum allowed is $maxAllowed', [SOLANA_ERROR__WALLET__NOT_CONNECTED]: 'Cannot $operation: no wallet connected', + [SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED]: 'No signing wallet connected (status: $status)', + [SOLANA_ERROR__WALLET__SIGNER_NOT_AVAILABLE]: 'Connected wallet does not support signing', };