Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/calm-swans-stay.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 5 additions & 1 deletion packages/errors/src/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/errors/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -874,6 +875,9 @@ export type SolanaErrorContext = ReadonlyContextValue<
[SOLANA_ERROR__WALLET__NOT_CONNECTED]: {
operation: string;
};
[SOLANA_ERROR__WALLET__NO_SIGNER_CONNECTED]: {
status: string;
};
}
>
>;
Expand Down
4 changes: 4 additions & 0 deletions packages/errors/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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',
};
Loading