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/proud-results-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@solana/errors': minor
---

Add `SOLANA_ERROR__WALLET__NOT_CONNECTED` error code for when a wallet operation is attempted without a connected wallet.
7 changes: 6 additions & 1 deletion packages/errors/src/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ export const SOLANA_ERROR__PROGRAM_CLIENTS__RESOLVED_INSTRUCTION_INPUT_MUST_BE_N
export const SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_ACCOUNT_TYPE = 8500005;
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;

// Invariant violation errors.
// Reserve error codes in the range [9900000-9900999].
// These errors should only be thrown when there is a bug with the
Expand Down Expand Up @@ -678,7 +682,8 @@ export type SolanaErrorCode =
| typeof SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT
| 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__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT
| typeof SOLANA_ERROR__WALLET__NOT_CONNECTED;

/**
* 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 @@ -209,6 +209,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__NOT_CONNECTED,
SolanaErrorCode,
} from './codes';
import { RpcSimulateTransactionResult } from './json-rpc-error';
Expand Down Expand Up @@ -861,6 +862,9 @@ export type SolanaErrorContext = ReadonlyContextValue<
firstByte: number;
transactionBytes: ReadonlyUint8Array;
};
[SOLANA_ERROR__WALLET__NOT_CONNECTED]: {
operation: string;
};
}
>
>;
Expand Down
2 changes: 2 additions & 0 deletions packages/errors/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ 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__NOT_CONNECTED,
SolanaErrorCode,
} from './codes';

Expand Down Expand Up @@ -812,4 +813,5 @@ export const SolanaErrorMessages: Readonly<{
'Transaction has $actualCount instructions but the maximum allowed is $maxAllowed',
[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',
};
Loading