@solana/errors 2.0.0-experimental.6cea83c → 2.0.0-experimental.75a18e3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env -S node
2
+
3
+ import process from 'node:process';
4
+
5
+ import { run } from '../dist/cli.js';
6
+
7
+ run(process.argv);
package/dist/cli.js ADDED
@@ -0,0 +1,274 @@
1
+ // src/cli.ts
2
+ import chalk from "chalk";
3
+ import { Command, InvalidArgumentError } from "commander";
4
+
5
+ // package.json
6
+ var version = "2.0.0-development";
7
+
8
+ // src/codes.ts
9
+ var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
10
+ var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
11
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
12
+ var SOLANA_ERROR__NONCE_INVALID = 6;
13
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
14
+ var SOLANA_ERROR__INSTRUCTION_ERROR_UNKNOWN = 4615e3;
15
+ var SOLANA_ERROR__INSTRUCTION_ERROR_GENERIC_ERROR = 4615001;
16
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ARGUMENT = 4615002;
17
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_INSTRUCTION_DATA = 4615003;
18
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ACCOUNT_DATA = 4615004;
19
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_DATA_TOO_SMALL = 4615005;
20
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INSUFFICIENT_FUNDS = 4615006;
21
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INCORRECT_PROGRAM_ID = 4615007;
22
+ var SOLANA_ERROR__INSTRUCTION_ERROR_MISSING_REQUIRED_SIGNATURE = 4615008;
23
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_ALREADY_INITIALIZED = 4615009;
24
+ var SOLANA_ERROR__INSTRUCTION_ERROR_UNINITIALIZED_ACCOUNT = 4615010;
25
+ var SOLANA_ERROR__INSTRUCTION_ERROR_UNBALANCED_INSTRUCTION = 4615011;
26
+ var SOLANA_ERROR__INSTRUCTION_ERROR_MODIFIED_PROGRAM_ID = 4615012;
27
+ var SOLANA_ERROR__INSTRUCTION_ERROR_EXTERNAL_ACCOUNT_LAMPORT_SPEND = 4615013;
28
+ var SOLANA_ERROR__INSTRUCTION_ERROR_EXTERNAL_ACCOUNT_DATA_MODIFIED = 4615014;
29
+ var SOLANA_ERROR__INSTRUCTION_ERROR_READONLY_LAMPORT_CHANGE = 4615015;
30
+ var SOLANA_ERROR__INSTRUCTION_ERROR_READONLY_DATA_MODIFIED = 4615016;
31
+ var SOLANA_ERROR__INSTRUCTION_ERROR_DUPLICATE_ACCOUNT_INDEX = 4615017;
32
+ var SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_MODIFIED = 4615018;
33
+ var SOLANA_ERROR__INSTRUCTION_ERROR_RENT_EPOCH_MODIFIED = 4615019;
34
+ var SOLANA_ERROR__INSTRUCTION_ERROR_NOT_ENOUGH_ACCOUNT_KEYS = 4615020;
35
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_DATA_SIZE_CHANGED = 4615021;
36
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_NOT_EXECUTABLE = 4615022;
37
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_BORROW_FAILED = 4615023;
38
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_BORROW_OUTSTANDING = 4615024;
39
+ var SOLANA_ERROR__INSTRUCTION_ERROR_DUPLICATE_ACCOUNT_OUT_OF_SYNC = 4615025;
40
+ var SOLANA_ERROR__INSTRUCTION_ERROR_CUSTOM = 4615026;
41
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ERROR = 4615027;
42
+ var SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_DATA_MODIFIED = 4615028;
43
+ var SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_LAMPORT_CHANGE = 4615029;
44
+ var SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT = 4615030;
45
+ var SOLANA_ERROR__INSTRUCTION_ERROR_UNSUPPORTED_PROGRAM_ID = 4615031;
46
+ var SOLANA_ERROR__INSTRUCTION_ERROR_CALL_DEPTH = 4615032;
47
+ var SOLANA_ERROR__INSTRUCTION_ERROR_MISSING_ACCOUNT = 4615033;
48
+ var SOLANA_ERROR__INSTRUCTION_ERROR_REENTRANCY_NOT_ALLOWED = 4615034;
49
+ var SOLANA_ERROR__INSTRUCTION_ERROR_MAX_SEED_LENGTH_EXCEEDED = 4615035;
50
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_SEEDS = 4615036;
51
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_REALLOC = 4615037;
52
+ var SOLANA_ERROR__INSTRUCTION_ERROR_COMPUTATIONAL_BUDGET_EXCEEDED = 4615038;
53
+ var SOLANA_ERROR__INSTRUCTION_ERROR_PRIVILEGE_ESCALATION = 4615039;
54
+ var SOLANA_ERROR__INSTRUCTION_ERROR_PROGRAM_ENVIRONMENT_SETUP_FAILURE = 4615040;
55
+ var SOLANA_ERROR__INSTRUCTION_ERROR_PROGRAM_FAILED_TO_COMPLETE = 4615041;
56
+ var SOLANA_ERROR__INSTRUCTION_ERROR_PROGRAM_FAILED_TO_COMPILE = 4615042;
57
+ var SOLANA_ERROR__INSTRUCTION_ERROR_IMMUTABLE = 4615043;
58
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INCORRECT_AUTHORITY = 4615044;
59
+ var SOLANA_ERROR__INSTRUCTION_ERROR_BORSH_IO_ERROR = 4615045;
60
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_NOT_RENT_EXEMPT = 4615046;
61
+ var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ACCOUNT_OWNER = 4615047;
62
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ARITHMETIC_OVERFLOW = 4615048;
63
+ var SOLANA_ERROR__INSTRUCTION_ERROR_UNSUPPORTED_SYSVAR = 4615049;
64
+ var SOLANA_ERROR__INSTRUCTION_ERROR_ILLEGAL_OWNER = 4615050;
65
+ var SOLANA_ERROR__INSTRUCTION_ERROR_MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED = 4615051;
66
+ var SOLANA_ERROR__INSTRUCTION_ERROR_MAX_ACCOUNTS_EXCEEDED = 4615052;
67
+ var SOLANA_ERROR__INSTRUCTION_ERROR_MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 4615053;
68
+ var SOLANA_ERROR__INSTRUCTION_ERROR_BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 4615054;
69
+ var SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663001;
70
+ var SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663002;
71
+ var SOLANA_ERROR__TRANSACTION_EXPECTED_BLOCKHASH_LIFETIME = 5663003;
72
+ var SOLANA_ERROR__TRANSACTION_EXPECTED_NONCE_LIFETIME = 5663004;
73
+ var SOLANA_ERROR__TRANSACTION_VERSION_NUMBER_OUT_OF_RANGE = 5663005;
74
+ var SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING = 5663006;
75
+ var SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE = 5663007;
76
+ var SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = 5663008;
77
+ var SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = 5663009;
78
+ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 5663010;
79
+ var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 5663011;
80
+ var SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN = 705e4;
81
+ var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE = 7050001;
82
+ var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE = 7050002;
83
+ var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND = 7050003;
84
+ var SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
85
+ var SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
86
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE = 7050006;
87
+ var SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED = 7050007;
88
+ var SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND = 7050008;
89
+ var SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP = 7050009;
90
+ var SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE = 7050010;
91
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX = 7050011;
92
+ var SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE = 7050012;
93
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION = 7050013;
94
+ var SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE = 7050014;
95
+ var SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE = 7050015;
96
+ var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING = 7050016;
97
+ var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
98
+ var SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION = 7050018;
99
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT = 7050019;
100
+ var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
101
+ var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
102
+ var SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS = 7050022;
103
+ var SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
104
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
105
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
106
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
107
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT = 7050027;
108
+ var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
109
+ var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
110
+ var SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION = 7050030;
111
+ var SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
112
+ var SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
113
+ var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
114
+ var SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED = 7050034;
115
+ var SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
116
+ var SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION = 7050036;
117
+
118
+ // src/messages.ts
119
+ var SolanaErrorMessages = {
120
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
121
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_ALREADY_INITIALIZED]: "instruction requires an uninitialized account",
122
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_BORROW_FAILED]: "instruction tries to borrow reference for an account which is already borrowed",
123
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "instruction left account with an outstanding borrowed reference",
124
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_DATA_SIZE_CHANGED]: "program other than the account's owner changed the size of the account data",
125
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_DATA_TOO_SMALL]: "account data too small for instruction",
126
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_NOT_EXECUTABLE]: "instruction expected an executable account",
127
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_NOT_RENT_EXEMPT]: "An account does not have enough lamports to be rent-exempt",
128
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ARITHMETIC_OVERFLOW]: "Program arithmetic overflowed",
129
+ [SOLANA_ERROR__INSTRUCTION_ERROR_BORSH_IO_ERROR]: "Failed to serialize or deserialize account data: $encodedData",
130
+ [SOLANA_ERROR__INSTRUCTION_ERROR_BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS]: "Builtin programs must consume compute units",
131
+ [SOLANA_ERROR__INSTRUCTION_ERROR_CALL_DEPTH]: "Cross-program invocation call depth too deep",
132
+ [SOLANA_ERROR__INSTRUCTION_ERROR_COMPUTATIONAL_BUDGET_EXCEEDED]: "Computational budget exceeded",
133
+ [SOLANA_ERROR__INSTRUCTION_ERROR_CUSTOM]: "custom program error: #$code",
134
+ [SOLANA_ERROR__INSTRUCTION_ERROR_DUPLICATE_ACCOUNT_INDEX]: "instruction contains duplicate accounts",
135
+ [SOLANA_ERROR__INSTRUCTION_ERROR_DUPLICATE_ACCOUNT_OUT_OF_SYNC]: "instruction modifications of multiply-passed account differ",
136
+ [SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT]: "executable accounts must be rent exempt",
137
+ [SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_DATA_MODIFIED]: "instruction changed executable accounts data",
138
+ [SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_LAMPORT_CHANGE]: "instruction changed the balance of an executable account",
139
+ [SOLANA_ERROR__INSTRUCTION_ERROR_EXECUTABLE_MODIFIED]: "instruction changed executable bit of an account",
140
+ [SOLANA_ERROR__INSTRUCTION_ERROR_EXTERNAL_ACCOUNT_DATA_MODIFIED]: "instruction modified data of an account it does not own",
141
+ [SOLANA_ERROR__INSTRUCTION_ERROR_EXTERNAL_ACCOUNT_LAMPORT_SPEND]: "instruction spent from the balance of an account it does not own",
142
+ [SOLANA_ERROR__INSTRUCTION_ERROR_GENERIC_ERROR]: "generic instruction error",
143
+ [SOLANA_ERROR__INSTRUCTION_ERROR_ILLEGAL_OWNER]: "Provided owner is not allowed",
144
+ [SOLANA_ERROR__INSTRUCTION_ERROR_IMMUTABLE]: "Account is immutable",
145
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INCORRECT_AUTHORITY]: "Incorrect authority provided",
146
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INCORRECT_PROGRAM_ID]: "incorrect program id for instruction",
147
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INSUFFICIENT_FUNDS]: "insufficient funds for instruction",
148
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ACCOUNT_DATA]: "invalid account data for instruction",
149
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ACCOUNT_OWNER]: "Invalid account owner",
150
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ARGUMENT]: "invalid program argument",
151
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ERROR]: "program returned invalid error code",
152
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_INSTRUCTION_DATA]: "invalid instruction data",
153
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_REALLOC]: "Failed to reallocate account data",
154
+ [SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_SEEDS]: "Provided seeds do not result in a valid address",
155
+ [SOLANA_ERROR__INSTRUCTION_ERROR_MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED]: "Accounts data allocations exceeded the maximum allowed per transaction",
156
+ [SOLANA_ERROR__INSTRUCTION_ERROR_MAX_ACCOUNTS_EXCEEDED]: "Max accounts exceeded",
157
+ [SOLANA_ERROR__INSTRUCTION_ERROR_MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED]: "Max instruction trace length exceeded",
158
+ [SOLANA_ERROR__INSTRUCTION_ERROR_MAX_SEED_LENGTH_EXCEEDED]: "Length of the seed is too long for address generation",
159
+ [SOLANA_ERROR__INSTRUCTION_ERROR_MISSING_ACCOUNT]: "An account required by the instruction is missing",
160
+ [SOLANA_ERROR__INSTRUCTION_ERROR_MISSING_REQUIRED_SIGNATURE]: "missing required signature for instruction",
161
+ [SOLANA_ERROR__INSTRUCTION_ERROR_MODIFIED_PROGRAM_ID]: "instruction illegally modified the program id of an account",
162
+ [SOLANA_ERROR__INSTRUCTION_ERROR_NOT_ENOUGH_ACCOUNT_KEYS]: "insufficient account keys for instruction",
163
+ [SOLANA_ERROR__INSTRUCTION_ERROR_PRIVILEGE_ESCALATION]: "Cross-program invocation with unauthorized signer or writable account",
164
+ [SOLANA_ERROR__INSTRUCTION_ERROR_PROGRAM_ENVIRONMENT_SETUP_FAILURE]: "Failed to create program execution environment",
165
+ [SOLANA_ERROR__INSTRUCTION_ERROR_PROGRAM_FAILED_TO_COMPILE]: "Program failed to compile",
166
+ [SOLANA_ERROR__INSTRUCTION_ERROR_PROGRAM_FAILED_TO_COMPLETE]: "Program failed to complete",
167
+ [SOLANA_ERROR__INSTRUCTION_ERROR_READONLY_DATA_MODIFIED]: "instruction modified data of a read-only account",
168
+ [SOLANA_ERROR__INSTRUCTION_ERROR_READONLY_LAMPORT_CHANGE]: "instruction changed the balance of a read-only account",
169
+ [SOLANA_ERROR__INSTRUCTION_ERROR_REENTRANCY_NOT_ALLOWED]: "Cross-program invocation reentrancy not allowed for this instruction",
170
+ [SOLANA_ERROR__INSTRUCTION_ERROR_RENT_EPOCH_MODIFIED]: "instruction modified rent epoch of an account",
171
+ [SOLANA_ERROR__INSTRUCTION_ERROR_UNBALANCED_INSTRUCTION]: "sum of account balances before and after instruction do not match",
172
+ [SOLANA_ERROR__INSTRUCTION_ERROR_UNINITIALIZED_ACCOUNT]: "instruction requires an initialized account",
173
+ [SOLANA_ERROR__INSTRUCTION_ERROR_UNKNOWN]: "",
174
+ [SOLANA_ERROR__INSTRUCTION_ERROR_UNSUPPORTED_PROGRAM_ID]: "Unsupported program id",
175
+ [SOLANA_ERROR__INSTRUCTION_ERROR_UNSUPPORTED_SYSVAR]: "Unsupported sysvar",
176
+ [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
177
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
178
+ [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
179
+ [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
180
+ [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
181
+ [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: "Account in use",
182
+ [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: "Account loaded twice",
183
+ [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.",
184
+ [SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist",
185
+ [SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED]: "This transaction has already been processed",
186
+ [SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND]: "Blockhash not found",
187
+ [SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep",
188
+ [SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance",
189
+ [SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed",
190
+ [SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee",
191
+ [SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
192
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees",
193
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference",
194
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data",
195
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index",
196
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner",
197
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
198
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions",
199
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
200
+ [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written",
201
+ [SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap",
202
+ [SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present",
203
+ [SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist",
204
+ [SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
205
+ [SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED]: "ResanitizationNeeded",
206
+ [SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly",
207
+ [SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE]: "Transaction did not pass signature verification",
208
+ [SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts",
209
+ [SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match",
210
+ [SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: "The transaction failed with the error `$errorName`",
211
+ [SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION]: "Transaction version is unsupported",
212
+ [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block",
213
+ [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit",
214
+ [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block",
215
+ [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit",
216
+ [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit",
217
+ [SOLANA_ERROR__TRANSACTION_EXPECTED_BLOCKHASH_LIFETIME]: "Transaction does not have a blockhash lifetime",
218
+ [SOLANA_ERROR__TRANSACTION_EXPECTED_NONCE_LIFETIME]: "Transaction is not a durable nonce transaction",
219
+ [SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING]: "Contents of these address lookup tables unknown: $lookupTableAddresses",
220
+ [SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE]: "Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",
221
+ [SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
222
+ [SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
223
+ [SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_CANNOT_PAY_FEES]: "This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",
224
+ [SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE]: "This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",
225
+ [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
226
+ [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",
227
+ [SOLANA_ERROR__TRANSACTION_VERSION_NUMBER_OUT_OF_RANGE]: "Transaction version must be in the range [0, 127]. `$actualVersion` given"
228
+ };
229
+
230
+ // src/message-formatter.ts
231
+ function getHumanReadableErrorMessage(code, context = {}) {
232
+ const messageFormatString = SolanaErrorMessages[code];
233
+ const message = messageFormatString.replace(
234
+ /(?<!\\)\$(\w+)/g,
235
+ (substring, variableName) => variableName in context ? `${context[variableName]}` : substring
236
+ );
237
+ return message;
238
+ }
239
+
240
+ // src/cli.ts
241
+ var program = new Command();
242
+ program.name("@solana/errors").description("Decode Solana JavaScript errors thrown in production").version(version);
243
+ program.command("decode").description("Decode a `SolanaErrorCode` to a human-readable message").argument("<code>", "numeric error code to decode", (rawCode) => {
244
+ const code = parseInt(rawCode, 10);
245
+ if (isNaN(code) || `${code}` !== rawCode) {
246
+ throw new InvalidArgumentError("It must be an integer");
247
+ }
248
+ if (!(code in SolanaErrorMessages)) {
249
+ throw new InvalidArgumentError("There exists no error with that code");
250
+ }
251
+ return code;
252
+ }).argument(
253
+ "[encodedContext]",
254
+ "encoded context to interpolate into the error message",
255
+ (encodedContext) => Object.fromEntries(new URLSearchParams(encodedContext).entries())
256
+ ).action((code, context) => {
257
+ const message = getHumanReadableErrorMessage(code, context);
258
+ console.log(`
259
+ ${chalk.bold(
260
+ chalk.rgb(154, 71, 255)("[") + chalk.rgb(144, 108, 244)("D") + chalk.rgb(134, 135, 233)("e") + chalk.rgb(122, 158, 221)("c") + chalk.rgb(110, 178, 209)("o") + chalk.rgb(95, 195, 196)("d") + chalk.rgb(79, 212, 181)("e") + chalk.rgb(57, 227, 166)("d") + chalk.rgb(19, 241, 149)("]")
261
+ ) + chalk.rgb(19, 241, 149)(" Solana error code #" + code)}
262
+ - ${message}`);
263
+ if (context) {
264
+ console.log(`
265
+ ${chalk.yellowBright(chalk.bold("[Context]"))}
266
+ ${JSON.stringify(context, null, 4).split("\n").join("\n ")}`);
267
+ }
268
+ });
269
+ function run(argv) {
270
+ program.parse(argv);
271
+ }
272
+ export {
273
+ run
274
+ };