@solana/web3.js 2.0.0-experimental.eb14acd → 2.0.0-experimental.eb951b0

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.
@@ -125,6 +125,601 @@ this.globalThis.solanaWeb3 = (function (exports) {
125
125
  // ../accounts/dist/index.browser.js
126
126
  init_env_shim();
127
127
 
128
+ // ../errors/dist/index.browser.js
129
+ init_env_shim();
130
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
131
+ var SOLANA_ERROR__INVALID_NONCE = 2;
132
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 3;
133
+ var SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE = 4;
134
+ var SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH = 5;
135
+ var SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE = 6;
136
+ var SOLANA_ERROR__MALFORMED_BIGINT_STRING = 7;
137
+ var SOLANA_ERROR__MALFORMED_NUMBER_STRING = 8;
138
+ var SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE = 9;
139
+ var SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH = 28e5;
140
+ var SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE = 2800001;
141
+ var SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS = 2800002;
142
+ var SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY = 2800003;
143
+ var SOLANA_ERROR__ADDRESSES__MALFORMED_PDA = 2800004;
144
+ var SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE = 2800005;
145
+ var SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED = 2800006;
146
+ var SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED = 2800007;
147
+ var SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE = 2800008;
148
+ var SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED = 2800009;
149
+ var SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER = 2800010;
150
+ var SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND = 323e4;
151
+ var SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND = 32300001;
152
+ var SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT = 3230002;
153
+ var SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT = 3230003;
154
+ var SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED = 3230004;
155
+ var SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT = 361e4;
156
+ var SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED = 3610001;
157
+ var SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED = 3610002;
158
+ var SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED = 3610003;
159
+ var SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED = 3610004;
160
+ var SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED = 3610005;
161
+ var SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED = 3610006;
162
+ var SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH = 3704e3;
163
+ var SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704001;
164
+ var SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH = 3704002;
165
+ var SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE = 3704003;
166
+ var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS = 4128e3;
167
+ var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA = 4128001;
168
+ var SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH = 4128002;
169
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN = 4615e3;
170
+ var SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR = 4615001;
171
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT = 4615002;
172
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA = 4615003;
173
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA = 4615004;
174
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL = 4615005;
175
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS = 4615006;
176
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID = 4615007;
177
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE = 4615008;
178
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED = 4615009;
179
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT = 4615010;
180
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION = 4615011;
181
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID = 4615012;
182
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND = 4615013;
183
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED = 4615014;
184
+ var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE = 4615015;
185
+ var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED = 4615016;
186
+ var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX = 4615017;
187
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED = 4615018;
188
+ var SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED = 4615019;
189
+ var SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 4615020;
190
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED = 4615021;
191
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE = 4615022;
192
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED = 4615023;
193
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 4615024;
194
+ var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC = 4615025;
195
+ var SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM = 4615026;
196
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR = 4615027;
197
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED = 4615028;
198
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE = 4615029;
199
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT = 4615030;
200
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID = 4615031;
201
+ var SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH = 4615032;
202
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT = 4615033;
203
+ var SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED = 4615034;
204
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4615035;
205
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS = 4615036;
206
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC = 4615037;
207
+ var SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED = 4615038;
208
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION = 4615039;
209
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE = 4615040;
210
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE = 4615041;
211
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE = 4615042;
212
+ var SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE = 4615043;
213
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY = 4615044;
214
+ var SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR = 4615045;
215
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT = 4615046;
216
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER = 4615047;
217
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW = 4615048;
218
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR = 4615049;
219
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER = 4615050;
220
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED = 4615051;
221
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED = 4615052;
222
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 4615053;
223
+ var SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 4615054;
224
+ var SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS = 5508e3;
225
+ var SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER = 5508001;
226
+ var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER = 5508002;
227
+ var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER = 5508003;
228
+ var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER = 5508004;
229
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER = 5508005;
230
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER = 5508006;
231
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER = 5508007;
232
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER = 5508008;
233
+ var SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = 5508009;
234
+ var SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING = 5508010;
235
+ var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663e3;
236
+ var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663001;
237
+ var SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = 5663002;
238
+ var SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME = 5663003;
239
+ var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE = 5663004;
240
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING = 5663005;
241
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE = 5663006;
242
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = 5663007;
243
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = 5663008;
244
+ var SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING = 5663009;
245
+ var SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING = 5663010;
246
+ var SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = 5663011;
247
+ var SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = 5663012;
248
+ var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING = 5663013;
249
+ var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = 5663014;
250
+ var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
251
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
252
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
253
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND = 7050003;
254
+ var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
255
+ var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
256
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE = 7050006;
257
+ var SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED = 7050007;
258
+ var SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND = 7050008;
259
+ var SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP = 7050009;
260
+ var SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE = 7050010;
261
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX = 7050011;
262
+ var SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE = 7050012;
263
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION = 7050013;
264
+ var SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE = 7050014;
265
+ var SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE = 7050015;
266
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 7050016;
267
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
268
+ var SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION = 7050018;
269
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT = 7050019;
270
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
271
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
272
+ var SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS = 7050022;
273
+ var SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
274
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
275
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
276
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
277
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT = 7050027;
278
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
279
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
280
+ var SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION = 7050030;
281
+ var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
282
+ var SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
283
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
284
+ var SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED = 7050034;
285
+ var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
286
+ var SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION = 7050036;
287
+ var SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY = 8078e3;
288
+ var SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH = 8078001;
289
+ var SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH = 8078002;
290
+ var SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH = 8078003;
291
+ var SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH = 8078004;
292
+ var SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH = 8078005;
293
+ var SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH = 8078006;
294
+ var SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS = 8078007;
295
+ var SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE = 8078008;
296
+ var SOLANA_ERROR__CODECS__INVALID_DATA_ENUM_VARIANT = 8078009;
297
+ var SOLANA_ERROR__CODECS__INVALID_SCALAR_ENUM_VARIANT = 8078010;
298
+ var SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = 8078011;
299
+ var SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE = 8078012;
300
+ var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
301
+ var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
302
+ var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
303
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST = 819e4;
304
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
305
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
306
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED = 8190003;
307
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT = 8190004;
308
+ var SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING = 99e5;
309
+ var SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
310
+ var SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 9900002;
311
+ var SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = 9900003;
312
+ var SolanaErrorMessages = {
313
+ [SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND]: "Account not found at address: $address",
314
+ [SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED]: "Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",
315
+ [SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT]: "Expected decoded account at address: $address",
316
+ [SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT]: "Failed to decode account data at address: $address",
317
+ [SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND]: "Accounts not found at addresses: $addresses",
318
+ [SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED]: "Unable to find a viable program address bump seed.",
319
+ [SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS]: "$putativeAddress is not a base58-encoded address.",
320
+ [SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH]: "Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",
321
+ [SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY]: "The `CryptoKey` must be an `Ed25519` public key.",
322
+ [SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE]: "Invalid seeds; point must fall off the Ed25519 curve.",
323
+ [SOLANA_ERROR__ADDRESSES__MALFORMED_PDA]: "Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",
324
+ [SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED]: "A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",
325
+ [SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED]: "The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",
326
+ [SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE]: "Expected program derived address bump to be in the range [0, 255], got: $bump.",
327
+ [SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER]: "Program address cannot end with PDA marker.",
328
+ [SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",
329
+ [SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",
330
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
331
+ [SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY]: "Codec [$codecDescription] cannot decode empty byte arrays.",
332
+ [SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH]: "Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",
333
+ [SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH]: "Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",
334
+ [SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH]: "Encoder and decoder must either both be fixed-size or variable-size.",
335
+ [SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE]: "Enum discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",
336
+ [SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH]: "Expected a fixed-size codec, got a variable-size one.",
337
+ [SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH]: "Expected a variable-size codec, got a fixed-size one.",
338
+ [SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH]: "Codec [$codecDescription] expected $expected bytes, got $bytesLength.",
339
+ [SOLANA_ERROR__CODECS__INVALID_DATA_ENUM_VARIANT]: "Invalid data enum variant. Expected one of [$variants], got $value.",
340
+ [SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS]: "Expected [$codecDescription] to have $expected items, got $actual.",
341
+ [SOLANA_ERROR__CODECS__INVALID_SCALAR_ENUM_VARIANT]: "Invalid scalar enum variant. Expected one of [$variants] or a number between $minRange and $maxRange, got $value.",
342
+ [SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE]: "Invalid value $value for base $base with alphabet $alphabet.",
343
+ [SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE]: "Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",
344
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED]: "instruction requires an uninitialized account",
345
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED]: "instruction tries to borrow reference for an account which is already borrowed",
346
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "instruction left account with an outstanding borrowed reference",
347
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED]: "program other than the account's owner changed the size of the account data",
348
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL]: "account data too small for instruction",
349
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE]: "instruction expected an executable account",
350
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT]: "An account does not have enough lamports to be rent-exempt",
351
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW]: "Program arithmetic overflowed",
352
+ [SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR]: "Failed to serialize or deserialize account data: $encodedData",
353
+ [SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS]: "Builtin programs must consume compute units",
354
+ [SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH]: "Cross-program invocation call depth too deep",
355
+ [SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED]: "Computational budget exceeded",
356
+ [SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM]: "custom program error: #$code",
357
+ [SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX]: "instruction contains duplicate accounts",
358
+ [SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC]: "instruction modifications of multiply-passed account differ",
359
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT]: "executable accounts must be rent exempt",
360
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED]: "instruction changed executable accounts data",
361
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE]: "instruction changed the balance of an executable account",
362
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED]: "instruction changed executable bit of an account",
363
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED]: "instruction modified data of an account it does not own",
364
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND]: "instruction spent from the balance of an account it does not own",
365
+ [SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR]: "generic instruction error",
366
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER]: "Provided owner is not allowed",
367
+ [SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE]: "Account is immutable",
368
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY]: "Incorrect authority provided",
369
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID]: "incorrect program id for instruction",
370
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS]: "insufficient funds for instruction",
371
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA]: "invalid account data for instruction",
372
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER]: "Invalid account owner",
373
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT]: "invalid program argument",
374
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR]: "program returned invalid error code",
375
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA]: "invalid instruction data",
376
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC]: "Failed to reallocate account data",
377
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS]: "Provided seeds do not result in a valid address",
378
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED]: "Accounts data allocations exceeded the maximum allowed per transaction",
379
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED]: "Max accounts exceeded",
380
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED]: "Max instruction trace length exceeded",
381
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED]: "Length of the seed is too long for address generation",
382
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT]: "An account required by the instruction is missing",
383
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE]: "missing required signature for instruction",
384
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID]: "instruction illegally modified the program id of an account",
385
+ [SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS]: "insufficient account keys for instruction",
386
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION]: "Cross-program invocation with unauthorized signer or writable account",
387
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE]: "Failed to create program execution environment",
388
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE]: "Program failed to compile",
389
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE]: "Program failed to complete",
390
+ [SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED]: "instruction modified data of a read-only account",
391
+ [SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE]: "instruction changed the balance of a read-only account",
392
+ [SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED]: "Cross-program invocation reentrancy not allowed for this instruction",
393
+ [SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED]: "instruction modified rent epoch of an account",
394
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION]: "sum of account balances before and after instruction do not match",
395
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT]: "instruction requires an initialized account",
396
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN]: "",
397
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID]: "Unsupported program id",
398
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR]: "Unsupported sysvar",
399
+ [SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS]: "The instruction does not have any accounts.",
400
+ [SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA]: "The instruction does not have any data.",
401
+ [SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH]: "Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",
402
+ [SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
403
+ [SOLANA_ERROR__INVALID_NONCE]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
404
+ [SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING]: "Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
405
+ [SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE]: "Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
406
+ [SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE]: "Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
407
+ [SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING]: "Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
408
+ [SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH]: "Key pair bytes must be of length 64, got $byteLength.",
409
+ [SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH]: "Expected private key bytes with length 32. Actual length: $actualLength.",
410
+ [SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH]: "Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",
411
+ [SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",
412
+ [SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE]: "Lamports value must be in the range [0, 2e64-1]",
413
+ [SOLANA_ERROR__MALFORMED_BIGINT_STRING]: "`$value` cannot be parsed as a `BigInt`",
414
+ [SOLANA_ERROR__MALFORMED_NUMBER_STRING]: "`$value` cannot be parsed as a `Number`",
415
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
416
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST]: "Either the notification name must end in 'Notifications' or the API must supply a subscription creator function for the notification '$notificationName' to map between the notification name and the subscribe/unsubscribe method names.",
417
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID]: "Failed to obtain a subscription id from the server",
418
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
419
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED]: "WebSocket connection closed",
420
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT]: "WebSocket failed to connect",
421
+ [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`.",
422
+ [SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR]: "HTTP error ($statusCode): $message",
423
+ [SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN]: "HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",
424
+ [SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS]: "Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",
425
+ [SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER]: "The provided value does not implement the `KeyPairSigner` interface",
426
+ [SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER]: "The provided value does not implement the `MessageModifyingSigner` interface",
427
+ [SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER]: "The provided value does not implement the `MessagePartialSigner` interface",
428
+ [SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER]: "The provided value does not implement any of the `MessageSigner` interfaces",
429
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER]: "The provided value does not implement the `TransactionModifyingSigner` interface",
430
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER]: "The provided value does not implement the `TransactionPartialSigner` interface",
431
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER]: "The provided value does not implement the `TransactionSendingSigner` interface",
432
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER]: "The provided value does not implement any of the `TransactionSigner` interfaces",
433
+ [SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS]: "More than one `TransactionSendingSigner` was identified.",
434
+ [SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",
435
+ [SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED]: "No digest implementation could be found.",
436
+ [SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT]: "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",
437
+ [SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED]: "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.",
438
+ [SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED]: "No signature verification implementation could be found.",
439
+ [SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED]: "No key generation implementation could be found.",
440
+ [SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED]: "No signing implementation could be found.",
441
+ [SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED]: "No key export implementation could be found.",
442
+ [SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-8.64e15, 8.64e15]. `$value` given",
443
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
444
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE]: "Account in use",
445
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE]: "Account loaded twice",
446
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.",
447
+ [SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist",
448
+ [SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED]: "This transaction has already been processed",
449
+ [SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND]: "Blockhash not found",
450
+ [SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep",
451
+ [SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance",
452
+ [SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed",
453
+ [SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee",
454
+ [SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
455
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees",
456
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference",
457
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data",
458
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index",
459
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner",
460
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
461
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions",
462
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
463
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written",
464
+ [SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap",
465
+ [SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present",
466
+ [SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist",
467
+ [SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
468
+ [SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED]: "ResanitizationNeeded",
469
+ [SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly",
470
+ [SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE]: "Transaction did not pass signature verification",
471
+ [SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts",
472
+ [SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match",
473
+ [SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN]: "The transaction failed with the error `$errorName`",
474
+ [SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION]: "Transaction version is unsupported",
475
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block",
476
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit",
477
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block",
478
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit",
479
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit",
480
+ [SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING]: "Transaction is missing an address at index: $index.",
481
+ [SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME]: "Transaction does not have a blockhash lifetime",
482
+ [SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME]: "Transaction is not a durable nonce transaction",
483
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING]: "Contents of these address lookup tables unknown: $lookupTableAddresses",
484
+ [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",
485
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
486
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
487
+ [SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING]: "Transaction is missing a fee payer.",
488
+ [SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",
489
+ [SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE]: "Transaction first instruction is not advance nonce account instruction.",
490
+ [SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING]: "Transaction with no instructions cannot be durable nonce transaction.",
491
+ [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",
492
+ [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",
493
+ [SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING]: "Transaction is missing signatures for addresses: $addresses.",
494
+ [SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE]: "Transaction version must be in the range [0, 127]. `$actualVersion` given"
495
+ };
496
+ function getHumanReadableErrorMessage(code, context = {}) {
497
+ const messageFormatString = SolanaErrorMessages[code];
498
+ const message = messageFormatString.replace(
499
+ new RegExp("(?<!\\\\)\\$(\\w+)", "g"),
500
+ (substring, variableName) => variableName in context ? `${context[variableName]}` : substring
501
+ );
502
+ return message;
503
+ }
504
+ function getErrorMessage(code, context = {}) {
505
+ {
506
+ return getHumanReadableErrorMessage(code, context);
507
+ }
508
+ }
509
+ function isSolanaError(e3, code) {
510
+ const isSolanaError2 = e3 instanceof Error && e3.name === "SolanaError";
511
+ if (isSolanaError2) {
512
+ if (code !== void 0) {
513
+ return e3.context.__code === code;
514
+ }
515
+ return true;
516
+ }
517
+ return false;
518
+ }
519
+ var SolanaError = class extends Error {
520
+ constructor(...[code, contextAndErrorOptions]) {
521
+ let context;
522
+ let errorOptions;
523
+ if (contextAndErrorOptions) {
524
+ const { cause, ...contextRest } = contextAndErrorOptions;
525
+ if (cause) {
526
+ errorOptions = { cause };
527
+ }
528
+ if (Object.keys(contextRest).length > 0) {
529
+ context = contextRest;
530
+ }
531
+ }
532
+ const message = getErrorMessage(code, context);
533
+ super(message, errorOptions);
534
+ __publicField(this, "context");
535
+ this.context = {
536
+ __code: code,
537
+ ...context
538
+ };
539
+ this.name = "SolanaError";
540
+ }
541
+ };
542
+ function getSolanaErrorFromRpcError({ errorCodeBaseOffset, getErrorContext, orderedErrorNames, rpcEnumError }, constructorOpt) {
543
+ let rpcErrorName;
544
+ let rpcErrorContext;
545
+ if (typeof rpcEnumError === "string") {
546
+ rpcErrorName = rpcEnumError;
547
+ } else {
548
+ rpcErrorName = Object.keys(rpcEnumError)[0];
549
+ rpcErrorContext = rpcEnumError[rpcErrorName];
550
+ }
551
+ const codeOffset = orderedErrorNames.indexOf(rpcErrorName);
552
+ const errorCode = errorCodeBaseOffset + codeOffset;
553
+ const errorContext = getErrorContext(errorCode, rpcErrorName, rpcErrorContext);
554
+ const err = new SolanaError(errorCode, errorContext);
555
+ if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
556
+ Error.captureStackTrace(err, constructorOpt);
557
+ }
558
+ return err;
559
+ }
560
+ var ORDERED_ERROR_NAMES = [
561
+ // Keep synced with RPC source: https://github.com/anza-xyz/agave/blob/master/sdk/program/src/instruction.rs
562
+ // If this list ever gets too large, consider implementing a compression strategy like this:
563
+ // https://gist.github.com/steveluscher/aaa7cbbb5433b1197983908a40860c47
564
+ "GenericError",
565
+ "InvalidArgument",
566
+ "InvalidInstructionData",
567
+ "InvalidAccountData",
568
+ "AccountDataTooSmall",
569
+ "InsufficientFunds",
570
+ "IncorrectProgramId",
571
+ "MissingRequiredSignature",
572
+ "AccountAlreadyInitialized",
573
+ "UninitializedAccount",
574
+ "UnbalancedInstruction",
575
+ "ModifiedProgramId",
576
+ "ExternalAccountLamportSpend",
577
+ "ExternalAccountDataModified",
578
+ "ReadonlyLamportChange",
579
+ "ReadonlyDataModified",
580
+ "DuplicateAccountIndex",
581
+ "ExecutableModified",
582
+ "RentEpochModified",
583
+ "NotEnoughAccountKeys",
584
+ "AccountDataSizeChanged",
585
+ "AccountNotExecutable",
586
+ "AccountBorrowFailed",
587
+ "AccountBorrowOutstanding",
588
+ "DuplicateAccountOutOfSync",
589
+ "Custom",
590
+ "InvalidError",
591
+ "ExecutableDataModified",
592
+ "ExecutableLamportChange",
593
+ "ExecutableAccountNotRentExempt",
594
+ "UnsupportedProgramId",
595
+ "CallDepth",
596
+ "MissingAccount",
597
+ "ReentrancyNotAllowed",
598
+ "MaxSeedLengthExceeded",
599
+ "InvalidSeeds",
600
+ "InvalidRealloc",
601
+ "ComputationalBudgetExceeded",
602
+ "PrivilegeEscalation",
603
+ "ProgramEnvironmentSetupFailure",
604
+ "ProgramFailedToComplete",
605
+ "ProgramFailedToCompile",
606
+ "Immutable",
607
+ "IncorrectAuthority",
608
+ "BorshIoError",
609
+ "AccountNotRentExempt",
610
+ "InvalidAccountOwner",
611
+ "ArithmeticOverflow",
612
+ "UnsupportedSysvar",
613
+ "IllegalOwner",
614
+ "MaxAccountsDataAllocationsExceeded",
615
+ "MaxAccountsExceeded",
616
+ "MaxInstructionTraceLengthExceeded",
617
+ "BuiltinProgramsMustConsumeComputeUnits"
618
+ ];
619
+ function getSolanaErrorFromInstructionError(index, instructionError) {
620
+ return getSolanaErrorFromRpcError(
621
+ {
622
+ errorCodeBaseOffset: 4615001,
623
+ getErrorContext(errorCode, rpcErrorName, rpcErrorContext) {
624
+ if (errorCode === SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN) {
625
+ return {
626
+ errorName: rpcErrorName,
627
+ index,
628
+ ...rpcErrorContext !== void 0 ? { instructionErrorContext: rpcErrorContext } : null
629
+ };
630
+ } else if (errorCode === SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM) {
631
+ return {
632
+ code: rpcErrorContext,
633
+ index
634
+ };
635
+ } else if (errorCode === SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR) {
636
+ return {
637
+ encodedData: rpcErrorContext,
638
+ index
639
+ };
640
+ }
641
+ return { index };
642
+ },
643
+ orderedErrorNames: ORDERED_ERROR_NAMES,
644
+ rpcEnumError: instructionError
645
+ },
646
+ getSolanaErrorFromInstructionError
647
+ );
648
+ }
649
+ var ORDERED_ERROR_NAMES2 = [
650
+ // Keep synced with RPC source: https://github.com/anza-xyz/agave/blob/master/sdk/src/transaction/error.rs
651
+ // If this list ever gets too large, consider implementing a compression strategy like this:
652
+ // https://gist.github.com/steveluscher/aaa7cbbb5433b1197983908a40860c47
653
+ "AccountInUse",
654
+ "AccountLoadedTwice",
655
+ "AccountNotFound",
656
+ "ProgramAccountNotFound",
657
+ "InsufficientFundsForFee",
658
+ "InvalidAccountForFee",
659
+ "AlreadyProcessed",
660
+ "BlockhashNotFound",
661
+ // `InstructionError` intentionally omitted; delegated to `getSolanaErrorFromInstructionError`
662
+ "CallChainTooDeep",
663
+ "MissingSignatureForFee",
664
+ "InvalidAccountIndex",
665
+ "SignatureFailure",
666
+ "InvalidProgramForExecution",
667
+ "SanitizeFailure",
668
+ "ClusterMaintenance",
669
+ "AccountBorrowOutstanding",
670
+ "WouldExceedMaxBlockCostLimit",
671
+ "UnsupportedVersion",
672
+ "InvalidWritableAccount",
673
+ "WouldExceedMaxAccountCostLimit",
674
+ "WouldExceedAccountDataBlockLimit",
675
+ "TooManyAccountLocks",
676
+ "AddressLookupTableNotFound",
677
+ "InvalidAddressLookupTableOwner",
678
+ "InvalidAddressLookupTableData",
679
+ "InvalidAddressLookupTableIndex",
680
+ "InvalidRentPayingAccount",
681
+ "WouldExceedMaxVoteCostLimit",
682
+ "WouldExceedAccountDataTotalLimit",
683
+ "DuplicateInstruction",
684
+ "InsufficientFundsForRent",
685
+ "MaxLoadedAccountsDataSizeExceeded",
686
+ "InvalidLoadedAccountsDataSizeLimit",
687
+ "ResanitizationNeeded",
688
+ "ProgramExecutionTemporarilyRestricted",
689
+ "UnbalancedTransaction"
690
+ ];
691
+ function getSolanaErrorFromTransactionError(transactionError) {
692
+ if (typeof transactionError === "object" && "InstructionError" in transactionError) {
693
+ return getSolanaErrorFromInstructionError(
694
+ ...transactionError.InstructionError
695
+ );
696
+ }
697
+ return getSolanaErrorFromRpcError(
698
+ {
699
+ errorCodeBaseOffset: 7050001,
700
+ getErrorContext(errorCode, rpcErrorName, rpcErrorContext) {
701
+ if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN) {
702
+ return {
703
+ errorName: rpcErrorName,
704
+ ...rpcErrorContext !== void 0 ? { transactionErrorContext: rpcErrorContext } : null
705
+ };
706
+ } else if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION) {
707
+ return {
708
+ index: rpcErrorContext
709
+ };
710
+ } else if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT || errorCode === SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED) {
711
+ return {
712
+ accountIndex: rpcErrorContext.account_index
713
+ };
714
+ }
715
+ },
716
+ orderedErrorNames: ORDERED_ERROR_NAMES2,
717
+ rpcEnumError: transactionError
718
+ },
719
+ getSolanaErrorFromTransactionError
720
+ );
721
+ }
722
+
128
723
  // ../codecs-strings/dist/index.browser.js
129
724
  init_env_shim();
130
725
 
@@ -132,13 +727,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
132
727
  init_env_shim();
133
728
  function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
134
729
  if (bytes.length - offset <= 0) {
135
- throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
730
+ throw new SolanaError(SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY, {
731
+ codecDescription
732
+ });
136
733
  }
137
734
  }
138
735
  function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
139
736
  const bytesLength = bytes.length - offset;
140
737
  if (bytesLength < expected) {
141
- throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
738
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH, {
739
+ bytesLength,
740
+ codecDescription,
741
+ expected
742
+ });
142
743
  }
143
744
  }
144
745
  var mergeBytes = (byteArrays) => {
@@ -199,32 +800,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
199
800
  function isFixedSize(codec) {
200
801
  return "fixedSize" in codec && typeof codec.fixedSize === "number";
201
802
  }
202
- function assertIsFixedSize(codec, message) {
803
+ function assertIsFixedSize(codec) {
203
804
  if (!isFixedSize(codec)) {
204
- throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
805
+ throw new SolanaError(SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH);
205
806
  }
206
807
  }
207
808
  function isVariableSize(codec) {
208
809
  return !isFixedSize(codec);
209
810
  }
210
- function assertIsVariableSize(codec, message) {
811
+ function assertIsVariableSize(codec) {
211
812
  if (!isVariableSize(codec)) {
212
- throw new Error(message != null ? message : "Expected a variable-size codec, got a fixed-size one.");
813
+ throw new SolanaError(SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH);
213
814
  }
214
815
  }
215
816
  function combineCodec(encoder, decoder) {
216
817
  if (isFixedSize(encoder) !== isFixedSize(decoder)) {
217
- throw new Error(`Encoder and decoder must either both be fixed-size or variable-size.`);
818
+ throw new SolanaError(SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH);
218
819
  }
219
820
  if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
220
- throw new Error(
221
- `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
222
- );
821
+ throw new SolanaError(SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH, {
822
+ decoderFixedSize: decoder.fixedSize,
823
+ encoderFixedSize: encoder.fixedSize
824
+ });
223
825
  }
224
826
  if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
225
- throw new Error(
226
- `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
227
- );
827
+ throw new SolanaError(SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH, {
828
+ decoderMaxSize: decoder.maxSize,
829
+ encoderMaxSize: encoder.maxSize
830
+ });
228
831
  }
229
832
  return {
230
833
  ...decoder,
@@ -287,7 +890,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
287
890
  });
288
891
  }
289
892
  function reverseEncoder(encoder) {
290
- assertIsFixedSize(encoder, "Cannot reverse a codec of variable size.");
893
+ assertIsFixedSize(encoder);
291
894
  return createEncoder({
292
895
  ...encoder,
293
896
  write: (value, bytes, offset) => {
@@ -299,7 +902,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
299
902
  });
300
903
  }
301
904
  function reverseDecoder(decoder) {
302
- assertIsFixedSize(decoder, "Cannot reverse a codec of variable size.");
905
+ assertIsFixedSize(decoder);
303
906
  return createDecoder({
304
907
  ...decoder,
305
908
  read: (bytes, offset) => {
@@ -321,9 +924,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
321
924
  init_env_shim();
322
925
  function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
323
926
  if (value < min || value > max) {
324
- throw new Error(
325
- `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
326
- );
927
+ throw new SolanaError(SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE, {
928
+ codecDescription,
929
+ max,
930
+ min,
931
+ value
932
+ });
327
933
  }
328
934
  }
329
935
  var Endian = /* @__PURE__ */ ((Endian2) => {
@@ -518,7 +1124,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
518
1124
  var getU128Encoder = (config = {}) => numberEncoderFactory({
519
1125
  config,
520
1126
  name: "u128",
521
- range: [0, BigInt("0xffffffffffffffffffffffffffffffff")],
1127
+ range: [0n, BigInt("0xffffffffffffffffffffffffffffffff")],
522
1128
  set: (view, value, le) => {
523
1129
  const leftOffset = le ? 8 : 0;
524
1130
  const rightOffset = le ? 0 : 8;
@@ -572,7 +1178,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
572
1178
  var getU64Encoder = (config = {}) => numberEncoderFactory({
573
1179
  config,
574
1180
  name: "u64",
575
- range: [0, BigInt("0xffffffffffffffff")],
1181
+ range: [0n, BigInt("0xffffffffffffffff")],
576
1182
  set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),
577
1183
  size: 8
578
1184
  });
@@ -599,7 +1205,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
599
1205
  // ../codecs-strings/dist/index.browser.js
600
1206
  function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
601
1207
  if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
602
- throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
1208
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
1209
+ alphabet: alphabet4,
1210
+ base: alphabet4.length,
1211
+ value: givenValue
1212
+ });
603
1213
  }
604
1214
  }
605
1215
  var getBaseXEncoder = (alphabet4) => {
@@ -738,6 +1348,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
738
1348
  }
739
1349
  return output;
740
1350
  }
1351
+ var alphabet3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
741
1352
  var getBase64Encoder = () => {
742
1353
  {
743
1354
  return createEncoder({
@@ -745,7 +1356,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
745
1356
  try {
746
1357
  return atob(value).length;
747
1358
  } catch (e22) {
748
- throw new Error(`Expected a string of base 64, got [${value}].`);
1359
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
1360
+ alphabet: alphabet3,
1361
+ base: 64,
1362
+ value
1363
+ });
749
1364
  }
750
1365
  },
751
1366
  write(value, bytes, offset) {
@@ -754,7 +1369,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
754
1369
  bytes.set(bytesToAdd, offset);
755
1370
  return bytesToAdd.length + offset;
756
1371
  } catch (e22) {
757
- throw new Error(`Expected a string of base 64, got [${value}].`);
1372
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
1373
+ alphabet: alphabet3,
1374
+ base: 64,
1375
+ value
1376
+ });
758
1377
  }
759
1378
  }
760
1379
  });
@@ -858,10 +1477,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
858
1477
  return encodedAccount;
859
1478
  }
860
1479
  return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) });
861
- } catch (error) {
862
- const newError = new Error(`Failed to decode account [${encodedAccount.address}].`);
863
- newError.cause = error;
864
- throw newError;
1480
+ } catch (e3) {
1481
+ throw new SolanaError(SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT, {
1482
+ address: encodedAccount.address
1483
+ });
865
1484
  }
866
1485
  }
867
1486
  function accountExists(account) {
@@ -869,14 +1488,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
869
1488
  }
870
1489
  function assertAccountDecoded(account) {
871
1490
  if (accountExists(account) && account.data instanceof Uint8Array) {
872
- throw new Error(`Expected account [${account.address}] to be decoded.`);
1491
+ throw new SolanaError(SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT, {
1492
+ address: account.address
1493
+ });
873
1494
  }
874
1495
  }
875
1496
  function assertAccountsDecoded(accounts) {
876
1497
  const encoded = accounts.filter((a) => accountExists(a) && a.data instanceof Uint8Array);
877
1498
  if (encoded.length > 0) {
878
- const encodedAddresses = encoded.map((a) => a.address).join(", ");
879
- throw new Error(`Expected accounts [${encodedAddresses}] to be decoded.`);
1499
+ const encodedAddresses = encoded.map((a) => a.address);
1500
+ throw new SolanaError(SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED, {
1501
+ addresses: encodedAddresses
1502
+ });
880
1503
  }
881
1504
  }
882
1505
  function parseBase64RpcAccount(address2, rpcAccount) {
@@ -928,14 +1551,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
928
1551
  }
929
1552
  function assertAccountExists(account) {
930
1553
  if (!account.exists) {
931
- throw new Error(`Expected account [${account.address}] to exist.`);
1554
+ throw new SolanaError(SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND, { address: account.address });
932
1555
  }
933
1556
  }
934
1557
  function assertAccountsExist(accounts) {
935
1558
  const missingAccounts = accounts.filter((a) => !a.exists);
936
1559
  if (missingAccounts.length > 0) {
937
1560
  const missingAddresses = missingAccounts.map((a) => a.address);
938
- throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`);
1561
+ throw new SolanaError(SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND, { addresses: missingAddresses });
939
1562
  }
940
1563
  }
941
1564
 
@@ -946,9 +1569,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
946
1569
  init_env_shim();
947
1570
  function assertIsSecureContext() {
948
1571
  if (!globalThis.isSecureContext) {
949
- throw new Error(
950
- "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
951
- );
1572
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT);
952
1573
  }
953
1574
  }
954
1575
  var cachedEd25519Decision;
@@ -977,40 +1598,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
977
1598
  var _a;
978
1599
  assertIsSecureContext();
979
1600
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.digest) !== "function") {
980
- throw new Error("No digest implementation could be found");
1601
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED);
981
1602
  }
982
1603
  }
983
1604
  async function assertKeyGenerationIsAvailable() {
984
1605
  var _a;
985
1606
  assertIsSecureContext();
986
1607
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.generateKey) !== "function") {
987
- throw new Error("No key generation implementation could be found");
1608
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED);
988
1609
  }
989
1610
  if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) {
990
- throw new Error(
991
- "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20"
992
- );
1611
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED);
993
1612
  }
994
1613
  }
995
1614
  async function assertKeyExporterIsAvailable() {
996
1615
  var _a;
997
1616
  assertIsSecureContext();
998
1617
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
999
- throw new Error("No key export implementation could be found");
1618
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED);
1000
1619
  }
1001
1620
  }
1002
1621
  async function assertSigningCapabilityIsAvailable() {
1003
1622
  var _a;
1004
1623
  assertIsSecureContext();
1005
1624
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
1006
- throw new Error("No signing implementation could be found");
1625
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED);
1007
1626
  }
1008
1627
  }
1009
1628
  async function assertVerificationCapabilityIsAvailable() {
1010
1629
  var _a;
1011
1630
  assertIsSecureContext();
1012
1631
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.verify) !== "function") {
1013
- throw new Error("No signature verification implementation could be found");
1632
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED);
1014
1633
  }
1015
1634
  }
1016
1635
 
@@ -1044,23 +1663,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
1044
1663
  return true;
1045
1664
  }
1046
1665
  function assertIsAddress(putativeAddress) {
1047
- try {
1048
- if (
1049
- // Lowest address (32 bytes of zeroes)
1050
- putativeAddress.length < 32 || // Highest address (32 bytes of 255)
1051
- putativeAddress.length > 44
1052
- ) {
1053
- throw new Error("Expected input string to decode to a byte array of length 32.");
1054
- }
1055
- const base58Encoder4 = getMemoizedBase58Encoder();
1056
- const bytes = base58Encoder4.encode(putativeAddress);
1057
- const numBytes = bytes.byteLength;
1058
- if (numBytes !== 32) {
1059
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
1060
- }
1061
- } catch (e4) {
1062
- throw new Error(`\`${putativeAddress}\` is not a base-58 encoded address`, {
1063
- cause: e4
1666
+ if (
1667
+ // Lowest address (32 bytes of zeroes)
1668
+ putativeAddress.length < 32 || // Highest address (32 bytes of 255)
1669
+ putativeAddress.length > 44
1670
+ ) {
1671
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE, {
1672
+ actualLength: putativeAddress.length
1673
+ });
1674
+ }
1675
+ const base58Encoder4 = getMemoizedBase58Encoder();
1676
+ const bytes = base58Encoder4.encode(putativeAddress);
1677
+ const numBytes = bytes.byteLength;
1678
+ if (numBytes !== 32) {
1679
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH, {
1680
+ actualLength: numBytes
1064
1681
  });
1065
1682
  }
1066
1683
  }
@@ -1182,12 +1799,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
1182
1799
  function assertIsProgramDerivedAddress(value) {
1183
1800
  const validFormat = Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number";
1184
1801
  if (!validFormat) {
1185
- throw new Error(
1186
- `Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].`
1187
- );
1802
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__MALFORMED_PDA);
1188
1803
  }
1189
1804
  if (value[1] < 0 || value[1] > 255) {
1190
- throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${value[1]}.`);
1805
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE, {
1806
+ bump: value[1]
1807
+ });
1191
1808
  }
1192
1809
  assertIsAddress(value[0]);
1193
1810
  }
@@ -1217,18 +1834,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
1217
1834
  115,
1218
1835
  115
1219
1836
  ];
1220
- var PointOnCurveError = class extends Error {
1221
- };
1222
1837
  async function createProgramDerivedAddress({ programAddress, seeds }) {
1223
1838
  await assertDigestCapabilityIsAvailable();
1224
1839
  if (seeds.length > MAX_SEEDS) {
1225
- throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
1840
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED, {
1841
+ actual: seeds.length,
1842
+ maxSeeds: MAX_SEEDS
1843
+ });
1226
1844
  }
1227
1845
  let textEncoder;
1228
1846
  const seedBytes = seeds.reduce((acc, seed, ii) => {
1229
1847
  const bytes = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
1230
1848
  if (bytes.byteLength > MAX_SEED_LENGTH) {
1231
- throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
1849
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED, {
1850
+ actual: bytes.byteLength,
1851
+ index: ii,
1852
+ maxSeedLength: MAX_SEED_LENGTH
1853
+ });
1232
1854
  }
1233
1855
  acc.push(...bytes);
1234
1856
  return acc;
@@ -1241,7 +1863,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1241
1863
  );
1242
1864
  const addressBytes = new Uint8Array(addressBytesBuffer);
1243
1865
  if (await compressedPointBytesAreOnCurve(addressBytes)) {
1244
- throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
1866
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE);
1245
1867
  }
1246
1868
  return base58EncodedAddressCodec.decode(addressBytes);
1247
1869
  }
@@ -1257,25 +1879,29 @@ this.globalThis.solanaWeb3 = (function (exports) {
1257
1879
  seeds: [...seeds, new Uint8Array([bumpSeed])]
1258
1880
  });
1259
1881
  return [address2, bumpSeed];
1260
- } catch (e4) {
1261
- if (e4 instanceof PointOnCurveError) {
1882
+ } catch (e3) {
1883
+ if (isSolanaError(e3, SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE)) {
1262
1884
  bumpSeed--;
1263
1885
  } else {
1264
- throw e4;
1886
+ throw e3;
1265
1887
  }
1266
1888
  }
1267
1889
  }
1268
- throw new Error("Unable to find a viable program address bump seed");
1890
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED);
1269
1891
  }
1270
1892
  async function createAddressWithSeed({ baseAddress, programAddress, seed }) {
1271
1893
  const { encode, decode } = getAddressCodec();
1272
1894
  const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
1273
1895
  if (seedBytes.byteLength > MAX_SEED_LENGTH) {
1274
- throw new Error(`The seed exceeds the maximum length of 32 bytes`);
1896
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED, {
1897
+ actual: seedBytes.byteLength,
1898
+ index: 0,
1899
+ maxSeedLength: MAX_SEED_LENGTH
1900
+ });
1275
1901
  }
1276
1902
  const programAddressBytes = encode(programAddress);
1277
1903
  if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
1278
- throw new Error(`programAddress cannot end with the PDA marker`);
1904
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER);
1279
1905
  }
1280
1906
  const addressBytesBuffer = await crypto.subtle.digest(
1281
1907
  "SHA-256",
@@ -1287,7 +1913,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1287
1913
  async function getAddressFromPublicKey(publicKey) {
1288
1914
  await assertKeyExporterIsAvailable();
1289
1915
  if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
1290
- throw new Error("The `CryptoKey` must be an `Ed25519` public key");
1916
+ throw new SolanaError(SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY);
1291
1917
  }
1292
1918
  const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
1293
1919
  return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
@@ -1297,7 +1923,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1297
1923
  init_env_shim();
1298
1924
  function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1299
1925
  if (expected !== actual) {
1300
- throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1926
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS, {
1927
+ actual,
1928
+ codecDescription,
1929
+ expected
1930
+ });
1301
1931
  }
1302
1932
  }
1303
1933
  function maxCodecSizes(sizes) {
@@ -1443,13 +2073,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
1443
2073
  function getBooleanEncoder(config = {}) {
1444
2074
  var _a;
1445
2075
  const size = (_a = config.size) != null ? _a : getU8Encoder();
1446
- assertIsFixedSize(size, "Codec [bool] requires a fixed size.");
2076
+ assertIsFixedSize(size);
1447
2077
  return mapEncoder(size, (value) => value ? 1 : 0);
1448
2078
  }
1449
2079
  function getBooleanDecoder(config = {}) {
1450
2080
  var _a;
1451
2081
  const size = (_a = config.size) != null ? _a : getU8Decoder();
1452
- assertIsFixedSize(size, "Codec [bool] requires a fixed size.");
2082
+ assertIsFixedSize(size);
1453
2083
  return mapDecoder(size, (value) => Number(value) === 1);
1454
2084
  }
1455
2085
  function getBooleanCodec(config = {}) {
@@ -1545,9 +2175,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1545
2175
  offset = dOffset;
1546
2176
  const variantField = (_a2 = variants[Number(discriminator)]) != null ? _a2 : null;
1547
2177
  if (!variantField) {
1548
- throw new Error(
1549
- `Enum discriminator out of range. Expected a number between 0 and ${variants.length - 1}, got ${discriminator}.`
1550
- );
2178
+ throw new SolanaError(SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE, {
2179
+ discriminator,
2180
+ maxRange: variants.length - 1,
2181
+ minRange: 0
2182
+ });
1551
2183
  }
1552
2184
  const [variant, vOffset] = variantField[1].read(bytes, offset);
1553
2185
  offset = vOffset;
@@ -1556,7 +2188,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1556
2188
  });
1557
2189
  }
1558
2190
  function getDataEnumCodec(variants, config = {}) {
1559
- return combineCodec(getDataEnumEncoder(variants, config), getDataEnumDecoder(variants, config));
2191
+ return combineCodec(
2192
+ getDataEnumEncoder(variants, config),
2193
+ getDataEnumDecoder(variants, config)
2194
+ );
1560
2195
  }
1561
2196
  function getDataEnumFixedSize(variants, prefix) {
1562
2197
  if (variants.length === 0)
@@ -1579,9 +2214,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1579
2214
  function getVariantDiscriminator(variants, variant) {
1580
2215
  const discriminator = variants.findIndex(([key]) => variant.__kind === key);
1581
2216
  if (discriminator < 0) {
1582
- throw new Error(
1583
- `Invalid data enum variant. Expected one of [${variants.map(([key]) => key).join(", ")}], got "${variant.__kind}".`
1584
- );
2217
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_DATA_ENUM_VARIANT, {
2218
+ value: variant.__kind,
2219
+ variants: variants.map(([key]) => key)
2220
+ });
1585
2221
  }
1586
2222
  return discriminator;
1587
2223
  }
@@ -1647,8 +2283,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1647
2283
  const fixed = (_b = config.fixed) != null ? _b : false;
1648
2284
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
1649
2285
  if (fixed || isZeroSizeItem) {
1650
- assertIsFixedSize(item, "Fixed nullables can only be used with fixed-size codecs.");
1651
- assertIsFixedSize(prefix, "Fixed nullables can only be used with fixed-size prefix.");
2286
+ assertIsFixedSize(item);
2287
+ assertIsFixedSize(prefix);
1652
2288
  const fixedSize = prefix.fixedSize + item.fixedSize;
1653
2289
  return createEncoder({
1654
2290
  fixedSize,
@@ -1680,8 +2316,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1680
2316
  let fixedSize = null;
1681
2317
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
1682
2318
  if (fixed || isZeroSizeItem) {
1683
- assertIsFixedSize(item, "Fixed nullables can only be used with fixed-size codecs.");
1684
- assertIsFixedSize(prefix, "Fixed nullables can only be used with fixed-size prefix.");
2319
+ assertIsFixedSize(item);
2320
+ assertIsFixedSize(prefix);
1685
2321
  fixedSize = prefix.fixedSize + item.fixedSize;
1686
2322
  }
1687
2323
  return createDecoder({
@@ -1711,9 +2347,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
1711
2347
  const isInvalidNumber = typeof value === "number" && (value < minRange || value > maxRange);
1712
2348
  const isInvalidString = typeof value === "string" && !allStringInputs.includes(value);
1713
2349
  if (isInvalidNumber || isInvalidString) {
1714
- throw new Error(
1715
- `Invalid scalar enum variant. Expected one of [${allStringInputs.join(", ")}] or a number between ${minRange} and ${maxRange}, got "${value}".`
1716
- );
2350
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_SCALAR_ENUM_VARIANT, {
2351
+ maxRange,
2352
+ minRange,
2353
+ value,
2354
+ variants: allStringInputs
2355
+ });
1717
2356
  }
1718
2357
  if (typeof value === "number")
1719
2358
  return value;
@@ -1730,9 +2369,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1730
2369
  return mapDecoder(prefix, (value) => {
1731
2370
  const valueAsNumber = Number(value);
1732
2371
  if (valueAsNumber < minRange || valueAsNumber > maxRange) {
1733
- throw new Error(
1734
- `Enum discriminator out of range. Expected a number between ${minRange} and ${maxRange}, got ${valueAsNumber}.`
1735
- );
2372
+ throw new SolanaError(SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE, {
2373
+ discriminator: valueAsNumber,
2374
+ maxRange,
2375
+ minRange
2376
+ });
1736
2377
  }
1737
2378
  return constructor[enumKeys[valueAsNumber]];
1738
2379
  });
@@ -1806,7 +2447,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1806
2447
  });
1807
2448
  }
1808
2449
  function getStructCodec(fields) {
1809
- return combineCodec(getStructEncoder(fields), getStructDecoder(fields));
2450
+ return combineCodec(
2451
+ getStructEncoder(fields),
2452
+ getStructDecoder(fields)
2453
+ );
1810
2454
  }
1811
2455
  function getUnitEncoder() {
1812
2456
  return createEncoder({
@@ -1843,8 +2487,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1843
2487
  const fixed = (_b = config.fixed) != null ? _b : false;
1844
2488
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
1845
2489
  if (fixed || isZeroSizeItem) {
1846
- assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs.");
1847
- assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix.");
2490
+ assertIsFixedSize(item);
2491
+ assertIsFixedSize(prefix);
1848
2492
  const fixedSize = prefix.fixedSize + item.fixedSize;
1849
2493
  return createEncoder({
1850
2494
  fixedSize,
@@ -1881,8 +2525,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1881
2525
  let fixedSize = null;
1882
2526
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
1883
2527
  if (fixed || isZeroSizeItem) {
1884
- assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs.");
1885
- assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix.");
2528
+ assertIsFixedSize(item);
2529
+ assertIsFixedSize(prefix);
1886
2530
  fixedSize = prefix.fixedSize + item.fixedSize;
1887
2531
  }
1888
2532
  return createDecoder({
@@ -1937,6 +2581,40 @@ this.globalThis.solanaWeb3 = (function (exports) {
1937
2581
 
1938
2582
  // ../instructions/dist/index.browser.js
1939
2583
  init_env_shim();
2584
+ function isInstructionForProgram(instruction, programAddress) {
2585
+ return instruction.programAddress === programAddress;
2586
+ }
2587
+ function assertIsInstructionForProgram(instruction, programAddress) {
2588
+ if (instruction.programAddress !== programAddress) {
2589
+ throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {
2590
+ actualProgramAddress: instruction.programAddress,
2591
+ expectedProgramAddress: programAddress
2592
+ });
2593
+ }
2594
+ }
2595
+ function isInstructionWithAccounts(instruction) {
2596
+ return instruction.accounts !== void 0;
2597
+ }
2598
+ function assertIsInstructionWithAccounts(instruction) {
2599
+ if (instruction.accounts === void 0) {
2600
+ throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {
2601
+ data: instruction.data,
2602
+ programAddress: instruction.programAddress
2603
+ });
2604
+ }
2605
+ }
2606
+ function isInstructionWithData(instruction) {
2607
+ return instruction.data !== void 0;
2608
+ }
2609
+ function assertIsInstructionWithData(instruction) {
2610
+ var _a;
2611
+ if (instruction.data === void 0) {
2612
+ throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {
2613
+ accountAddresses: (_a = instruction.accounts) == null ? void 0 : _a.map((a) => a.address),
2614
+ programAddress: instruction.programAddress
2615
+ });
2616
+ }
2617
+ }
1940
2618
  var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
1941
2619
  AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
1942
2620
  3] = "WRITABLE_SIGNER";
@@ -1974,52 +2652,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
1974
2652
 
1975
2653
  // ../keys/dist/index.browser.js
1976
2654
  init_env_shim();
1977
-
1978
- // ../errors/dist/index.browser.js
1979
- init_env_shim();
1980
- var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
1981
- var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
1982
- var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
1983
- var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
1984
- var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
1985
- var SOLANA_ERROR__NONCE_INVALID = 6;
1986
- var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
1987
- var SolanaErrorMessages = {
1988
- [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
1989
- [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
1990
- [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
1991
- [SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
1992
- [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`.",
1993
- [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
1994
- [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."
1995
- };
1996
- function getHumanReadableErrorMessage(code, context = {}) {
1997
- const messageFormatString = SolanaErrorMessages[code];
1998
- const message = messageFormatString.replace(
1999
- new RegExp("(?<!\\\\)\\$(\\w+)", "g"),
2000
- (substring, variableName) => variableName in context ? `${context[variableName]}` : substring
2001
- );
2002
- return message;
2003
- }
2004
- function getErrorMessage(code, context = {}) {
2005
- {
2006
- return getHumanReadableErrorMessage(code, context);
2007
- }
2008
- }
2009
- var SolanaError = class extends Error {
2010
- constructor(...[code, context]) {
2011
- const message = getErrorMessage(code, context);
2012
- super(message);
2013
- __publicField(this, "context");
2014
- this.context = {
2015
- __code: code,
2016
- ...context
2017
- };
2018
- this.name = "SolanaError";
2019
- }
2020
- };
2021
-
2022
- // ../keys/dist/index.browser.js
2023
2655
  function addPkcs8Header(bytes) {
2024
2656
  return new Uint8Array([
2025
2657
  /**
@@ -2067,8 +2699,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2067
2699
  ]);
2068
2700
  }
2069
2701
  async function createPrivateKeyFromBytes(bytes, extractable) {
2070
- if (bytes.byteLength !== 32) {
2071
- throw new Error("Private key bytes must be of length 32");
2702
+ const actualLength = bytes.byteLength;
2703
+ if (actualLength !== 32) {
2704
+ throw new SolanaError(SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH, {
2705
+ actualLength
2706
+ });
2072
2707
  }
2073
2708
  const privateKeyBytesPkcs8 = addPkcs8Header(bytes);
2074
2709
  return await crypto.subtle.importKey("pkcs8", privateKeyBytesPkcs8, "Ed25519", extractable != null ? extractable : false, ["sign"]);
@@ -2089,7 +2724,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2089
2724
  }
2090
2725
  async function createKeyPairFromBytes(bytes, extractable) {
2091
2726
  if (bytes.byteLength !== 64) {
2092
- throw new SolanaError(SOLANA_ERROR__INVALID_KEYPAIR_BYTES, { byteLength: bytes.byteLength });
2727
+ throw new SolanaError(SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH, { byteLength: bytes.byteLength });
2093
2728
  }
2094
2729
  const [publicKey, privateKey] = await Promise.all([
2095
2730
  crypto.subtle.importKey(
@@ -2108,22 +2743,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
2108
2743
  function assertIsSignature(putativeSignature) {
2109
2744
  if (!base58Encoder)
2110
2745
  base58Encoder = getBase58Encoder();
2111
- try {
2112
- if (
2113
- // Lowest value (64 bytes of zeroes)
2114
- putativeSignature.length < 64 || // Highest value (64 bytes of 255)
2115
- putativeSignature.length > 88
2116
- ) {
2117
- throw new Error("Expected input string to decode to a byte array of length 64.");
2118
- }
2119
- const bytes = base58Encoder.encode(putativeSignature);
2120
- const numBytes = bytes.byteLength;
2121
- if (numBytes !== 64) {
2122
- throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
2123
- }
2124
- } catch (e4) {
2125
- throw new Error(`\`${putativeSignature}\` is not a signature`, {
2126
- cause: e4
2746
+ if (
2747
+ // Lowest value (64 bytes of zeroes)
2748
+ putativeSignature.length < 64 || // Highest value (64 bytes of 255)
2749
+ putativeSignature.length > 88
2750
+ ) {
2751
+ throw new SolanaError(SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE, {
2752
+ actualLength: putativeSignature.length
2753
+ });
2754
+ }
2755
+ const bytes = base58Encoder.encode(putativeSignature);
2756
+ const numBytes = bytes.byteLength;
2757
+ if (numBytes !== 64) {
2758
+ throw new SolanaError(SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH, {
2759
+ actualLength: numBytes
2127
2760
  });
2128
2761
  }
2129
2762
  }
@@ -2718,18 +3351,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
2718
3351
 
2719
3352
  // ../rpc-transport-http/dist/index.browser.js
2720
3353
  init_env_shim();
2721
- var e2 = globalThis.fetch;
2722
- var SolanaHttpError = class extends Error {
2723
- constructor(details) {
2724
- super(`HTTP error (${details.statusCode}): ${details.message}`);
2725
- __publicField(this, "statusCode");
2726
- Error.captureStackTrace(this, this.constructor);
2727
- this.statusCode = details.statusCode;
2728
- }
2729
- get name() {
2730
- return "SolanaHttpError";
2731
- }
2732
- };
2733
3354
  var DISALLOWED_HEADERS = {
2734
3355
  accept: true,
2735
3356
  "content-length": true,
@@ -2750,9 +3371,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
2750
3371
  "keep-alive": true,
2751
3372
  origin: true,
2752
3373
  "permissions-policy": true,
2753
- // No currently available Typescript technique allows you to match on a prefix.
2754
- // 'proxy-':true,
2755
- // 'sec-':true,
3374
+ // Prefix matching is implemented in code, below.
3375
+ // 'proxy-': true,
3376
+ // 'sec-': true,
2756
3377
  referer: true,
2757
3378
  te: true,
2758
3379
  trailer: true,
@@ -2766,9 +3387,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
2766
3387
  return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
2767
3388
  });
2768
3389
  if (badHeaders.length > 0) {
2769
- throw new Error(
2770
- `${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
2771
- );
3390
+ throw new SolanaError(SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN, {
3391
+ headers: badHeaders
3392
+ });
2772
3393
  }
2773
3394
  }
2774
3395
  function normalizeHeaders(headers) {
@@ -2778,10 +3399,25 @@ this.globalThis.solanaWeb3 = (function (exports) {
2778
3399
  }
2779
3400
  return out;
2780
3401
  }
2781
- function createHttpTransport({ headers, url }) {
3402
+ var didWarnDispatcherWasSuppliedInNonNodeEnvironment = false;
3403
+ function warnDispatcherWasSuppliedInNonNodeEnvironment() {
3404
+ if (didWarnDispatcherWasSuppliedInNonNodeEnvironment) {
3405
+ return;
3406
+ }
3407
+ didWarnDispatcherWasSuppliedInNonNodeEnvironment = true;
3408
+ console.warn(
3409
+ "You have supplied a `Dispatcher` to `createHttpTransport()`. It has been ignored because Undici dispatchers only work in Node environments. To eliminate this warning, omit the `dispatcher_NODE_ONLY` property from your config when running in a non-Node environment."
3410
+ );
3411
+ }
3412
+ function createHttpTransport(config) {
3413
+ if ("dispatcher_NODE_ONLY" in config) {
3414
+ warnDispatcherWasSuppliedInNonNodeEnvironment();
3415
+ }
3416
+ const { headers, url } = config;
2782
3417
  if (headers) {
2783
3418
  assertIsAllowedHttpRequestHeaders(headers);
2784
3419
  }
3420
+ let dispatcherConfig;
2785
3421
  const customHeaders = headers && normalizeHeaders(headers);
2786
3422
  return async function makeHttpRequest({
2787
3423
  payload,
@@ -2789,6 +3425,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2789
3425
  }) {
2790
3426
  const body = JSON.stringify(payload);
2791
3427
  const requestInfo = {
3428
+ ...dispatcherConfig,
2792
3429
  body,
2793
3430
  headers: {
2794
3431
  ...customHeaders,
@@ -2800,9 +3437,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
2800
3437
  method: "POST",
2801
3438
  signal
2802
3439
  };
2803
- const response = await e2(url, requestInfo);
3440
+ const response = await fetch(url, requestInfo);
2804
3441
  if (!response.ok) {
2805
- throw new SolanaHttpError({
3442
+ throw new SolanaError(SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, {
2806
3443
  message: response.statusText,
2807
3444
  statusCode: response.status
2808
3445
  });
@@ -2832,7 +3469,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2832
3469
  argumentLabel = `\`${keyPath[0].toString()}\``;
2833
3470
  }
2834
3471
  const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
2835
- const error = new SolanaError(SOLANA_ERROR__RPC_INTEGER_OVERFLOW, {
3472
+ const error = new SolanaError(SOLANA_ERROR__RPC__INTEGER_OVERFLOW, {
2836
3473
  argumentLabel,
2837
3474
  keyPath,
2838
3475
  methodName,
@@ -2851,10 +3488,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
2851
3488
  throw createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
2852
3489
  }
2853
3490
  };
2854
- function createSolanaRpc(config) {
2855
- const api = createSolanaRpcApi(DEFAULT_RPC_CONFIG);
2856
- return createRpc({ ...config, api });
2857
- }
3491
+ var EXPLICIT_ABORT_TOKEN = Symbol(
3492
+ "This symbol is thrown from the request that underlies a series of coalesced requests when the last request in that series aborts"
3493
+ );
2858
3494
  function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
2859
3495
  let coalescedRequestsByDeduplicationKey;
2860
3496
  return async function makeCoalescedHttpRequest(config) {
@@ -2877,11 +3513,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2877
3513
  ...config,
2878
3514
  signal: abortController.signal
2879
3515
  });
2880
- } catch (e4) {
2881
- if (e4 && typeof e4 === "object" && "name" in e4 && e4.name === "AbortError") {
3516
+ } catch (e3) {
3517
+ if (e3 === EXPLICIT_ABORT_TOKEN) {
2882
3518
  return;
2883
3519
  }
2884
- throw e4;
3520
+ throw e3;
2885
3521
  }
2886
3522
  })();
2887
3523
  coalescedRequestsByDeduplicationKey[deduplicationKey] = {
@@ -2895,15 +3531,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
2895
3531
  if (signal) {
2896
3532
  const responsePromise = coalescedRequest.responsePromise;
2897
3533
  return await new Promise((resolve, reject) => {
2898
- const handleAbort = (e4) => {
3534
+ const handleAbort = (e3) => {
2899
3535
  signal.removeEventListener("abort", handleAbort);
2900
3536
  coalescedRequest.numConsumers -= 1;
2901
3537
  if (coalescedRequest.numConsumers === 0) {
2902
3538
  const abortController = coalescedRequest.abortController;
2903
- abortController.abort();
3539
+ abortController.abort(EXPLICIT_ABORT_TOKEN);
2904
3540
  }
2905
- const abortError = new DOMException(e4.target.reason, "AbortError");
2906
- reject(abortError);
3541
+ reject(e3.target.reason);
2907
3542
  };
2908
3543
  signal.addEventListener("abort", handleAbort);
2909
3544
  responsePromise.then(resolve).finally(() => {
@@ -2947,6 +3582,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
2947
3582
  (transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
2948
3583
  );
2949
3584
  }
3585
+ function createSolanaRpc(clusterUrl, config) {
3586
+ return createSolanaRpcFromTransport(createDefaultRpcTransport({ url: clusterUrl, ...config }));
3587
+ }
3588
+ function createSolanaRpcFromTransport(transport) {
3589
+ return createRpc({
3590
+ api: createSolanaRpcApi(DEFAULT_RPC_CONFIG),
3591
+ transport
3592
+ });
3593
+ }
2950
3594
 
2951
3595
  // ../rpc-subscriptions/dist/index.browser.js
2952
3596
  init_env_shim();
@@ -2969,17 +3613,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
2969
3613
  },
2970
3614
  get(target, p, receiver) {
2971
3615
  return function(...rawParams) {
2972
- const methodName = p.toString();
2973
- const createRpcSubscription = Reflect.get(target, methodName, receiver);
3616
+ const notificationName = p.toString();
3617
+ const createRpcSubscription = Reflect.get(target, notificationName, receiver);
2974
3618
  if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
2975
- throw new Error(
2976
- "Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
2977
- );
3619
+ throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST, {
3620
+ notificationName
3621
+ });
2978
3622
  }
2979
3623
  const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
2980
3624
  params: rawParams,
2981
- subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
2982
- unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
3625
+ subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
3626
+ unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
2983
3627
  };
2984
3628
  return createPendingRpcSubscription(rpcConfig, newRequest);
2985
3629
  };
@@ -3034,7 +3678,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3034
3678
  }
3035
3679
  }
3036
3680
  if (subscriptionId == null) {
3037
- throw new Error("Failed to obtain a subscription id from the server");
3681
+ throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID);
3038
3682
  }
3039
3683
  return {
3040
3684
  async *[Symbol.asyncIterator]() {
@@ -3274,8 +3918,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
3274
3918
 
3275
3919
  // ../rpc-subscriptions-transport-websocket/dist/index.browser.js
3276
3920
  init_env_shim();
3277
- var e3 = globalThis.WebSocket;
3278
- var EXPLICIT_ABORT_TOKEN = Symbol(
3921
+ var e2 = globalThis.WebSocket;
3922
+ var EXPLICIT_ABORT_TOKEN2 = Symbol(
3279
3923
  "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
3280
3924
  );
3281
3925
  async function createWebSocketConnection({
@@ -3297,8 +3941,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
3297
3941
  });
3298
3942
  }
3299
3943
  function handleAbort() {
3300
- errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
3301
- if (webSocket.readyState !== e3.CLOSED && webSocket.readyState !== e3.CLOSING) {
3944
+ errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN2);
3945
+ if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
3302
3946
  webSocket.close(1e3);
3303
3947
  }
3304
3948
  }
@@ -3314,8 +3958,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3314
3958
  function handleError(ev) {
3315
3959
  if (!hasConnected) {
3316
3960
  reject(
3317
- // TODO: Coded error
3318
- new Error("WebSocket failed to connect", { cause: ev })
3961
+ new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT, {
3962
+ errorEvent: ev
3963
+ })
3319
3964
  );
3320
3965
  }
3321
3966
  }
@@ -3326,11 +3971,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
3326
3971
  resolve({
3327
3972
  async send(payload) {
3328
3973
  const message = JSON.stringify(payload);
3329
- if (!bufferDrainWatcher && webSocket.readyState === e3.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
3974
+ if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
3330
3975
  let onCancel;
3331
3976
  const promise = new Promise((resolve2, reject2) => {
3332
3977
  const intervalId = setInterval(() => {
3333
- if (webSocket.readyState !== e3.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
3978
+ if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
3334
3979
  clearInterval(intervalId);
3335
3980
  bufferDrainWatcher = void 0;
3336
3981
  resolve2();
@@ -3340,8 +3985,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3340
3985
  bufferDrainWatcher = void 0;
3341
3986
  clearInterval(intervalId);
3342
3987
  reject2(
3343
- // TODO: Coded error
3344
- new Error("WebSocket was closed before payload could be sent")
3988
+ new SolanaError(
3989
+ SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED
3990
+ )
3345
3991
  );
3346
3992
  };
3347
3993
  });
@@ -3364,11 +4010,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
3364
4010
  while (true) {
3365
4011
  const state = iteratorState.get(iteratorKey);
3366
4012
  if (!state) {
3367
- throw new Error("Invariant: WebSocket message iterator is missing state storage");
4013
+ throw new SolanaError(
4014
+ SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING
4015
+ );
3368
4016
  }
3369
4017
  if (state.__hasPolled) {
3370
- throw new Error(
3371
- "Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
4018
+ throw new SolanaError(
4019
+ SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE
3372
4020
  );
3373
4021
  }
3374
4022
  const queuedMessages = state.queuedMessages;
@@ -3385,10 +4033,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
3385
4033
  });
3386
4034
  });
3387
4035
  } catch (e22) {
3388
- if (e22 === EXPLICIT_ABORT_TOKEN) {
4036
+ if (e22 === EXPLICIT_ABORT_TOKEN2) {
3389
4037
  return;
3390
4038
  } else {
3391
- throw new Error("WebSocket connection closed", { cause: e22 });
4039
+ throw new SolanaError(
4040
+ SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED,
4041
+ {
4042
+ cause: e22
4043
+ }
4044
+ );
3392
4045
  }
3393
4046
  }
3394
4047
  }
@@ -3411,7 +4064,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3411
4064
  }
3412
4065
  });
3413
4066
  }
3414
- const webSocket = new e3(url);
4067
+ const webSocket = new e2(url);
3415
4068
  webSocket.addEventListener("close", handleClose);
3416
4069
  webSocket.addEventListener("error", handleError);
3417
4070
  webSocket.addEventListener("open", handleOpen);
@@ -3459,7 +4112,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3459
4112
  argumentLabel = `\`${keyPath[0].toString()}\``;
3460
4113
  }
3461
4114
  const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
3462
- const error = new SolanaError(SOLANA_ERROR__RPC_INTEGER_OVERFLOW, {
4115
+ const error = new SolanaError(SOLANA_ERROR__RPC__INTEGER_OVERFLOW, {
3463
4116
  argumentLabel,
3464
4117
  keyPath,
3465
4118
  methodName,
@@ -3491,7 +4144,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3491
4144
  }
3492
4145
  function getCachedAbortableIterableFactory({
3493
4146
  getAbortSignalFromInputArgs,
3494
- getCacheEntryMissingError,
3495
4147
  getCacheKeyFromInputArgs,
3496
4148
  onCacheHit,
3497
4149
  onCreateIterable
@@ -3500,7 +4152,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3500
4152
  function getCacheEntryOrThrow(cacheKey) {
3501
4153
  const currentCacheEntry = cache.get(cacheKey);
3502
4154
  if (!currentCacheEntry) {
3503
- throw getCacheEntryMissingError(cacheKey);
4155
+ throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING, {
4156
+ cacheKey: cacheKey.toString()
4157
+ });
3504
4158
  }
3505
4159
  return currentCacheEntry;
3506
4160
  }
@@ -3552,13 +4206,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
3552
4206
  await onCacheHit(cachedIterable, ...args);
3553
4207
  return cachedIterable;
3554
4208
  }
3555
- } catch (e4) {
4209
+ } catch (e3) {
3556
4210
  cleanup();
3557
- throw e4;
4211
+ throw e3;
3558
4212
  }
3559
4213
  };
3560
4214
  }
3561
- var EXPLICIT_ABORT_TOKEN2 = Symbol(
4215
+ var EXPLICIT_ABORT_TOKEN3 = Symbol(
3562
4216
  "This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
3563
4217
  );
3564
4218
  function registerIterableCleanup22(iterable, cleanupFn) {
@@ -3599,11 +4253,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3599
4253
  }
3600
4254
  const iterableFactory = getCachedAbortableIterableFactory({
3601
4255
  getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
3602
- getCacheEntryMissingError(deduplicationKey2) {
3603
- return new Error(
3604
- `Found no cache entry for subscription with deduplication key \`${deduplicationKey2 == null ? void 0 : deduplicationKey2.toString()}\``
3605
- );
3606
- },
3607
4256
  getCacheKeyFromInputArgs: () => deduplicationKey,
3608
4257
  async onCacheHit(_iterable, _config) {
3609
4258
  },
@@ -3629,9 +4278,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3629
4278
  return {
3630
4279
  ...iterable,
3631
4280
  async *[Symbol.asyncIterator]() {
3632
- abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN2) : new Promise((_, reject) => {
4281
+ abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN3) : new Promise((_, reject) => {
3633
4282
  abortSignal.addEventListener("abort", () => {
3634
- reject(EXPLICIT_ABORT_TOKEN2);
4283
+ reject(EXPLICIT_ABORT_TOKEN3);
3635
4284
  });
3636
4285
  }));
3637
4286
  try {
@@ -3644,12 +4293,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
3644
4293
  yield iteratorResult.value;
3645
4294
  }
3646
4295
  }
3647
- } catch (e4) {
3648
- if (e4 === EXPLICIT_ABORT_TOKEN2) {
4296
+ } catch (e3) {
4297
+ if (e3 === EXPLICIT_ABORT_TOKEN3) {
3649
4298
  return;
3650
4299
  }
3651
4300
  cache.delete(deduplicationKey);
3652
- throw e4;
4301
+ throw e3;
3653
4302
  }
3654
4303
  }
3655
4304
  };
@@ -3661,24 +4310,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3661
4310
  }
3662
4311
  });
3663
4312
  }
3664
- function createSolanaRpcSubscriptions(config) {
3665
- return pipe(
3666
- createSubscriptionRpc({
3667
- ...config,
3668
- api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG2)
3669
- }),
3670
- (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
3671
- getDeduplicationKey: (...args) => (0, import_fast_stable_stringify2.default)(args),
3672
- rpcSubscriptions
3673
- })
3674
- );
3675
- }
3676
- function createSolanaRpcSubscriptions_UNSTABLE(config) {
3677
- return createSubscriptionRpc({
3678
- ...config,
3679
- api: createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG2)
3680
- });
3681
- }
3682
4313
  var PING_PAYLOAD = {
3683
4314
  jsonrpc: "2.0",
3684
4315
  method: "ping"
@@ -3752,9 +4383,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3752
4383
  }) {
3753
4384
  return getCachedAbortableIterableFactory({
3754
4385
  getAbortSignalFromInputArgs: ({ signal }) => signal,
3755
- getCacheEntryMissingError(shardKey) {
3756
- return new Error(`Found no cache entry for connection with shard key \`${shardKey == null ? void 0 : shardKey.toString()}\``);
3757
- },
3758
4386
  getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
3759
4387
  onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
3760
4388
  onCreateIterable: (abortSignal, config) => transport({
@@ -3784,6 +4412,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
3784
4412
  })
3785
4413
  );
3786
4414
  }
4415
+ function createSolanaRpcSubscriptions(clusterUrl, config) {
4416
+ const transport = createDefaultRpcSubscriptionsTransport({ url: clusterUrl, ...config });
4417
+ return createSolanaRpcSubscriptionsFromTransport(transport);
4418
+ }
4419
+ function createSolanaRpcSubscriptions_UNSTABLE(clusterUrl, config) {
4420
+ return createSolanaRpcSubscriptions(
4421
+ clusterUrl,
4422
+ config
4423
+ );
4424
+ }
4425
+ function createSolanaRpcSubscriptionsFromTransport(transport) {
4426
+ return pipe(
4427
+ createSubscriptionRpc({
4428
+ api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG2),
4429
+ transport
4430
+ }),
4431
+ (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
4432
+ getDeduplicationKey: (...args) => (0, import_fast_stable_stringify2.default)(args),
4433
+ rpcSubscriptions
4434
+ })
4435
+ );
4436
+ }
4437
+ function createSolanaRpcSubscriptionsFromTransport_UNSTABLE(transport) {
4438
+ return createSolanaRpcSubscriptionsFromTransport(transport);
4439
+ }
3787
4440
 
3788
4441
  // ../rpc-types/dist/index.browser.js
3789
4442
  init_env_shim();
@@ -3791,22 +4444,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
3791
4444
  function assertIsBlockhash(putativeBlockhash) {
3792
4445
  if (!base58Encoder2)
3793
4446
  base58Encoder2 = getBase58Encoder();
3794
- try {
3795
- if (
3796
- // Lowest value (32 bytes of zeroes)
3797
- putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
3798
- putativeBlockhash.length > 44
3799
- ) {
3800
- throw new Error("Expected input string to decode to a byte array of length 32.");
3801
- }
3802
- const bytes = base58Encoder2.encode(putativeBlockhash);
3803
- const numBytes = bytes.byteLength;
3804
- if (numBytes !== 32) {
3805
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
3806
- }
3807
- } catch (e4) {
3808
- throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
3809
- cause: e4
4447
+ if (
4448
+ // Lowest value (32 bytes of zeroes)
4449
+ putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
4450
+ putativeBlockhash.length > 44
4451
+ ) {
4452
+ throw new SolanaError(SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE, {
4453
+ actualLength: putativeBlockhash.length
4454
+ });
4455
+ }
4456
+ const bytes = base58Encoder2.encode(putativeBlockhash);
4457
+ const numBytes = bytes.byteLength;
4458
+ if (numBytes !== 32) {
4459
+ throw new SolanaError(SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH, {
4460
+ actualLength: numBytes
3810
4461
  });
3811
4462
  }
3812
4463
  }
@@ -3828,9 +4479,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3828
4479
  case "processed":
3829
4480
  return 0;
3830
4481
  default:
3831
- return ((_) => {
3832
- throw new Error(`Unrecognized commitment \`${commitment}\`.`);
3833
- })();
4482
+ throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE, {
4483
+ unexpectedValue: commitment
4484
+ });
3834
4485
  }
3835
4486
  }
3836
4487
  function commitmentComparator(a, b) {
@@ -3844,11 +4495,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
3844
4495
  return putativeLamports >= 0 && putativeLamports <= maxU64Value;
3845
4496
  }
3846
4497
  function assertIsLamports(putativeLamports) {
3847
- if (putativeLamports < 0) {
3848
- throw new Error("Input for 64-bit unsigned integer cannot be negative");
3849
- }
3850
- if (putativeLamports > maxU64Value) {
3851
- throw new Error("Input number is too large to be represented as a 64-bit unsigned integer");
4498
+ if (putativeLamports < 0 || putativeLamports > maxU64Value) {
4499
+ throw new SolanaError(SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE);
3852
4500
  }
3853
4501
  }
3854
4502
  function lamports(putativeLamports) {
@@ -3885,9 +4533,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3885
4533
  function assertIsStringifiedBigInt(putativeBigInt) {
3886
4534
  try {
3887
4535
  BigInt(putativeBigInt);
3888
- } catch (e4) {
3889
- throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, {
3890
- cause: e4
4536
+ } catch {
4537
+ throw new SolanaError(SOLANA_ERROR__MALFORMED_BIGINT_STRING, {
4538
+ value: putativeBigInt
3891
4539
  });
3892
4540
  }
3893
4541
  }
@@ -3900,7 +4548,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3900
4548
  }
3901
4549
  function assertIsStringifiedNumber(putativeNumber) {
3902
4550
  if (Number.isNaN(Number(putativeNumber))) {
3903
- throw new Error(`\`${putativeNumber}\` cannot be parsed as a Number`);
4551
+ throw new SolanaError(SOLANA_ERROR__MALFORMED_NUMBER_STRING, {
4552
+ value: putativeNumber
4553
+ });
3904
4554
  }
3905
4555
  }
3906
4556
  function stringifiedNumber(putativeNumber) {
@@ -3914,13 +4564,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3914
4564
  return true;
3915
4565
  }
3916
4566
  function assertIsUnixTimestamp(putativeTimestamp) {
3917
- try {
3918
- if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
3919
- throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]");
3920
- }
3921
- } catch (e4) {
3922
- throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, {
3923
- cause: e4
4567
+ if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
4568
+ throw new SolanaError(SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE, {
4569
+ value: putativeTimestamp
3924
4570
  });
3925
4571
  }
3926
4572
  }
@@ -3938,22 +4584,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
3938
4584
  function assertIsBlockhash2(putativeBlockhash) {
3939
4585
  if (!base58Encoder3)
3940
4586
  base58Encoder3 = getBase58Encoder();
3941
- try {
3942
- if (
3943
- // Lowest value (32 bytes of zeroes)
3944
- putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
3945
- putativeBlockhash.length > 44
3946
- ) {
3947
- throw new Error("Expected input string to decode to a byte array of length 32.");
3948
- }
3949
- const bytes = base58Encoder3.encode(putativeBlockhash);
3950
- const numBytes = bytes.byteLength;
3951
- if (numBytes !== 32) {
3952
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
3953
- }
3954
- } catch (e4) {
3955
- throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
3956
- cause: e4
4587
+ if (
4588
+ // Lowest value (32 bytes of zeroes)
4589
+ putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
4590
+ putativeBlockhash.length > 44
4591
+ ) {
4592
+ throw new SolanaError(SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE, {
4593
+ actualLength: putativeBlockhash.length
4594
+ });
4595
+ }
4596
+ const bytes = base58Encoder3.encode(putativeBlockhash);
4597
+ const numBytes = bytes.byteLength;
4598
+ if (numBytes !== 32) {
4599
+ throw new SolanaError(SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH, {
4600
+ actualLength: numBytes
3957
4601
  });
3958
4602
  }
3959
4603
  }
@@ -3982,7 +4626,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3982
4626
  }
3983
4627
  function assertIsTransactionWithBlockhashLifetime(transaction) {
3984
4628
  if (!isTransactionWithBlockhashLifetime(transaction)) {
3985
- throw new Error("Transaction does not have a blockhash lifetime");
4629
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME);
3986
4630
  }
3987
4631
  }
3988
4632
  function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
@@ -4031,7 +4675,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4031
4675
  var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
4032
4676
  function assertIsDurableNonceTransaction(transaction) {
4033
4677
  if (!isDurableNonceTransaction(transaction)) {
4034
- throw new Error("Transaction is not a durable nonce transaction");
4678
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME);
4035
4679
  }
4036
4680
  }
4037
4681
  function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
@@ -4175,8 +4819,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4175
4819
  const compiledAddressTableLookupAddresses = compiledAddressTableLookups.map((l) => l.lookupTableAddress);
4176
4820
  const missing = compiledAddressTableLookupAddresses.filter((a) => addressesByLookupTableAddress[a] === void 0);
4177
4821
  if (missing.length > 0) {
4178
- const missingAddresses = missing.join(", ");
4179
- throw new Error(`Addresses not provided for lookup tables: [${missingAddresses}]`);
4822
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING, {
4823
+ lookupTableAddresses: missing
4824
+ });
4180
4825
  }
4181
4826
  const readOnlyMetas = [];
4182
4827
  const writableMetas = [];
@@ -4184,8 +4829,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
4184
4829
  const addresses = addressesByLookupTableAddress[lookup.lookupTableAddress];
4185
4830
  const highestIndex = Math.max(...lookup.readableIndices, ...lookup.writableIndices);
4186
4831
  if (highestIndex >= addresses.length) {
4187
- throw new Error(
4188
- `Cannot look up index ${highestIndex} in lookup table [${lookup.lookupTableAddress}]. The lookup table may have been extended since the addresses provided were retrieved.`
4832
+ throw new SolanaError(
4833
+ SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE,
4834
+ {
4835
+ highestKnownIndex: addresses.length - 1,
4836
+ highestRequestedIndex: highestIndex,
4837
+ lookupTableAddress: lookup.lookupTableAddress
4838
+ }
4189
4839
  );
4190
4840
  }
4191
4841
  const readOnlyForLookup = lookup.readableIndices.map((r) => ({
@@ -4209,7 +4859,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4209
4859
  var _a, _b;
4210
4860
  const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
4211
4861
  if (!programAddress) {
4212
- throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
4862
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND, {
4863
+ index: instruction.programAddressIndex
4864
+ });
4213
4865
  }
4214
4866
  const accounts = (_b = instruction.accountIndices) == null ? void 0 : _b.map((accountIndex) => accountMetas[accountIndex]);
4215
4867
  const { data } = instruction;
@@ -4255,8 +4907,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4255
4907
  var _a;
4256
4908
  const { compiledMessage } = compiledTransaction;
4257
4909
  const feePayer = compiledMessage.staticAccounts[0];
4258
- if (!feePayer)
4259
- throw new Error("No fee payer set in CompiledTransaction");
4910
+ if (!feePayer) {
4911
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING);
4912
+ }
4260
4913
  const accountMetas = getAccountMetas(compiledMessage);
4261
4914
  const accountLookupMetas = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? getAddressLookupMetas(compiledMessage.addressTableLookups, (_a = config == null ? void 0 : config.addressesByLookupTableAddress) != null ? _a : {}) : [];
4262
4915
  const transactionMetas = [...accountMetas, ...accountLookupMetas];
@@ -4297,13 +4950,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
4297
4950
  if (isWritableRole2(entry.role)) {
4298
4951
  switch (entry[TYPE]) {
4299
4952
  case 0:
4300
- throw new Error(
4301
- `This transaction includes an address (\`${instruction.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`
4302
- );
4953
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES, {
4954
+ programAddress: instruction.programAddress
4955
+ });
4303
4956
  default:
4304
- throw new Error(
4305
- `This transaction includes an address (\`${instruction.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`
4306
- );
4957
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE, {
4958
+ programAddress: instruction.programAddress
4959
+ });
4307
4960
  }
4308
4961
  }
4309
4962
  if (entry[TYPE] === 2) {
@@ -4368,8 +5021,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
4368
5021
  addressesOfInvokedPrograms.has(account.address)
4369
5022
  ) {
4370
5023
  if (isWritableRole2(accountMeta.role)) {
4371
- throw new Error(
4372
- `This transaction includes an address (\`${account.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`
5024
+ throw new SolanaError(
5025
+ SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE,
5026
+ {
5027
+ programAddress: account.address
5028
+ }
4373
5029
  );
4374
5030
  }
4375
5031
  if (entry.role !== nextRole) {
@@ -4653,7 +5309,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4653
5309
  return offset;
4654
5310
  }
4655
5311
  if (value < 0 || value > 127) {
4656
- throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
5312
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE, {
5313
+ actualVersion: value
5314
+ });
4657
5315
  }
4658
5316
  bytes.set([value | VERSION_FLAG_MASK], offset);
4659
5317
  return offset + 1;
@@ -4739,12 +5397,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
4739
5397
  });
4740
5398
  }
4741
5399
  function getCompiledMessageDecoder() {
4742
- return mapDecoder(getStructDecoder(getPreludeStructDecoderTuple()), ({ addressTableLookups, ...restOfMessage }) => {
4743
- if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
4744
- return restOfMessage;
5400
+ return mapDecoder(
5401
+ getStructDecoder(getPreludeStructDecoderTuple()),
5402
+ ({ addressTableLookups, ...restOfMessage }) => {
5403
+ if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
5404
+ return restOfMessage;
5405
+ }
5406
+ return { ...restOfMessage, addressTableLookups };
4745
5407
  }
4746
- return { ...restOfMessage, addressTableLookups };
4747
- });
5408
+ );
4748
5409
  }
4749
5410
  function getCompiledMessageCodec() {
4750
5411
  return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
@@ -4801,7 +5462,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4801
5462
  base58Decoder = getBase58Decoder();
4802
5463
  const signatureBytes = transaction.signatures[transaction.feePayer];
4803
5464
  if (!signatureBytes) {
4804
- throw new SolanaError(SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE);
5465
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING);
4805
5466
  }
4806
5467
  const transactionSignature = base58Decoder.decode(signatureBytes);
4807
5468
  return transactionSignature;
@@ -4844,7 +5505,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4844
5505
  }
4845
5506
  });
4846
5507
  if (missingSigs.length > 0) {
4847
- throw new SolanaError(SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, {
5508
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING, {
4848
5509
  addresses: missingSigs
4849
5510
  });
4850
5511
  }
@@ -4861,9 +5522,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4861
5522
  if (!deduplicated[signer.address]) {
4862
5523
  deduplicated[signer.address] = signer;
4863
5524
  } else if (deduplicated[signer.address] !== signer) {
4864
- throw new Error(
4865
- `Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
4866
- );
5525
+ throw new SolanaError(SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS, {
5526
+ address: signer.address
5527
+ });
4867
5528
  }
4868
5529
  });
4869
5530
  return Object.values(deduplicated);
@@ -4926,7 +5587,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4926
5587
  }
4927
5588
  function assertIsMessagePartialSigner(value) {
4928
5589
  if (!isMessagePartialSigner(value)) {
4929
- throw new Error("The provided value does not implement the MessagePartialSigner interface");
5590
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, {
5591
+ address: value.address
5592
+ });
4930
5593
  }
4931
5594
  }
4932
5595
  function isTransactionPartialSigner(value) {
@@ -4934,7 +5597,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4934
5597
  }
4935
5598
  function assertIsTransactionPartialSigner(value) {
4936
5599
  if (!isTransactionPartialSigner(value)) {
4937
- throw new Error("The provided value does not implement the TransactionPartialSigner interface");
5600
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
5601
+ address: value.address
5602
+ });
4938
5603
  }
4939
5604
  }
4940
5605
  function isKeyPairSigner(value) {
@@ -4942,7 +5607,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4942
5607
  }
4943
5608
  function assertIsKeyPairSigner(value) {
4944
5609
  if (!isKeyPairSigner(value)) {
4945
- throw new Error("The provided value does not implement the KeyPairSigner interface");
5610
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, {
5611
+ address: value.address
5612
+ });
4946
5613
  }
4947
5614
  }
4948
5615
  async function createSignerFromKeyPair(keyPair) {
@@ -4975,7 +5642,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4975
5642
  }
4976
5643
  function assertIsMessageModifyingSigner(value) {
4977
5644
  if (!isMessageModifyingSigner(value)) {
4978
- throw new Error("The provided value does not implement the MessageModifyingSigner interface");
5645
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, {
5646
+ address: value.address
5647
+ });
4979
5648
  }
4980
5649
  }
4981
5650
  function isMessageSigner(value) {
@@ -4983,7 +5652,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4983
5652
  }
4984
5653
  function assertIsMessageSigner(value) {
4985
5654
  if (!isMessageSigner(value)) {
4986
- throw new Error("The provided value does not implement any of the MessageSigner interfaces");
5655
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, {
5656
+ address: value.address
5657
+ });
4987
5658
  }
4988
5659
  }
4989
5660
  function createNoopSigner(address2) {
@@ -4999,7 +5670,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4999
5670
  }
5000
5671
  function assertIsTransactionModifyingSigner(value) {
5001
5672
  if (!isTransactionModifyingSigner(value)) {
5002
- throw new Error("The provided value does not implement the TransactionModifyingSigner interface");
5673
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
5674
+ address: value.address
5675
+ });
5003
5676
  }
5004
5677
  }
5005
5678
  function isTransactionSendingSigner(value) {
@@ -5007,7 +5680,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5007
5680
  }
5008
5681
  function assertIsTransactionSendingSigner(value) {
5009
5682
  if (!isTransactionSendingSigner(value)) {
5010
- throw new Error("The provided value does not implement the TransactionSendingSigner interface");
5683
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
5684
+ address: value.address
5685
+ });
5011
5686
  }
5012
5687
  }
5013
5688
  function isTransactionSigner(value) {
@@ -5015,7 +5690,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5015
5690
  }
5016
5691
  function assertIsTransactionSigner(value) {
5017
5692
  if (!isTransactionSigner(value)) {
5018
- throw new Error("The provided value does not implement any of the TransactionSigner interfaces");
5693
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
5694
+ address: value.address
5695
+ });
5019
5696
  }
5020
5697
  }
5021
5698
  async function partiallySignTransactionWithSigners(transaction, config = {}) {
@@ -5043,9 +5720,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
5043
5720
  abortSignal
5044
5721
  );
5045
5722
  if (!sendingSigner) {
5046
- throw new Error(
5047
- "No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction."
5048
- );
5723
+ throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
5049
5724
  }
5050
5725
  abortSignal == null ? void 0 : abortSignal.throwIfAborted();
5051
5726
  const [signature2] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal });
@@ -5130,17 +5805,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
5130
5805
  const signers = getSignersFromTransaction(transaction);
5131
5806
  const sendingSigners = signers.filter(isTransactionSendingSigner);
5132
5807
  if (sendingSigners.length === 0) {
5133
- const error = new Error("No `TransactionSendingSigner` was identified.");
5134
- error.name = "MissingTransactionSendingSignerError";
5135
- throw error;
5808
+ throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
5136
5809
  }
5137
5810
  const sendingOnlySigners = sendingSigners.filter(
5138
5811
  (signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer)
5139
5812
  );
5140
5813
  if (sendingOnlySigners.length > 1) {
5141
- const error = new Error("More than one `TransactionSendingSigner` was identified.");
5142
- error.name = "MultipleTransactionSendingSignersError";
5143
- throw error;
5814
+ throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS);
5144
5815
  }
5145
5816
  }
5146
5817
 
@@ -5230,7 +5901,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
5230
5901
  for await (const accountNotification of accountNotifications) {
5231
5902
  const nonceValue = getNonceFromAccountData(accountNotification.value.data);
5232
5903
  if (nonceValue !== expectedNonceValue) {
5233
- throw new SolanaError(SOLANA_ERROR__NONCE_INVALID, {
5904
+ throw new SolanaError(SOLANA_ERROR__INVALID_NONCE, {
5234
5905
  actualNonceValue: nonceValue,
5235
5906
  expectedNonceValue
5236
5907
  });
@@ -5254,7 +5925,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
5254
5925
  nonceAccount.data[0]
5255
5926
  );
5256
5927
  if (nonceValue !== expectedNonceValue) {
5257
- throw new SolanaError(SOLANA_ERROR__NONCE_INVALID, {
5928
+ throw new SolanaError(SOLANA_ERROR__INVALID_NONCE, {
5258
5929
  actualNonceValue: nonceValue,
5259
5930
  expectedNonceValue
5260
5931
  });
@@ -5285,9 +5956,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
5285
5956
  const signatureDidCommitPromise = (async () => {
5286
5957
  for await (const signatureStatusNotification of signatureStatusNotifications) {
5287
5958
  if (signatureStatusNotification.value.err) {
5288
- throw new Error(`The transaction with signature \`${signature2}\` failed.`, {
5289
- cause: signatureStatusNotification.value.err
5290
- });
5959
+ throw getSolanaErrorFromTransactionError(signatureStatusNotification.value.err);
5291
5960
  } else {
5292
5961
  return;
5293
5962
  }
@@ -5312,9 +5981,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5312
5981
  }
5313
5982
  async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
5314
5983
  return await new Promise((_, reject) => {
5315
- const handleAbort = (e4) => {
5984
+ const handleAbort = (e3) => {
5316
5985
  clearTimeout(timeoutId);
5317
- const abortError = new DOMException(e4.target.reason, "AbortError");
5986
+ const abortError = new DOMException(e3.target.reason, "AbortError");
5318
5987
  reject(abortError);
5319
5988
  };
5320
5989
  callerAbortSignal.addEventListener("abort", handleAbort);
@@ -5653,6 +6322,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5653
6322
  exports.assertIsBlockhash = assertIsBlockhash;
5654
6323
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
5655
6324
  exports.assertIsFixedSize = assertIsFixedSize;
6325
+ exports.assertIsInstructionForProgram = assertIsInstructionForProgram;
6326
+ exports.assertIsInstructionWithAccounts = assertIsInstructionWithAccounts;
6327
+ exports.assertIsInstructionWithData = assertIsInstructionWithData;
5656
6328
  exports.assertIsKeyPairSigner = assertIsKeyPairSigner;
5657
6329
  exports.assertIsLamports = assertIsLamports;
5658
6330
  exports.assertIsMessageModifyingSigner = assertIsMessageModifyingSigner;
@@ -5694,9 +6366,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
5694
6366
  exports.createSignerFromKeyPair = createSignerFromKeyPair;
5695
6367
  exports.createSolanaRpc = createSolanaRpc;
5696
6368
  exports.createSolanaRpcApi = createSolanaRpcApi;
6369
+ exports.createSolanaRpcFromTransport = createSolanaRpcFromTransport;
5697
6370
  exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
5698
6371
  exports.createSolanaRpcSubscriptionsApi = createSolanaRpcSubscriptionsApi;
5699
6372
  exports.createSolanaRpcSubscriptionsApi_UNSTABLE = createSolanaRpcSubscriptionsApi_UNSTABLE;
6373
+ exports.createSolanaRpcSubscriptionsFromTransport = createSolanaRpcSubscriptionsFromTransport;
6374
+ exports.createSolanaRpcSubscriptionsFromTransport_UNSTABLE = createSolanaRpcSubscriptionsFromTransport_UNSTABLE;
5700
6375
  exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
5701
6376
  exports.createSubscriptionRpc = createSubscriptionRpc;
5702
6377
  exports.createTransaction = createTransaction;
@@ -5840,6 +6515,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5840
6515
  exports.isAddress = isAddress;
5841
6516
  exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
5842
6517
  exports.isFixedSize = isFixedSize;
6518
+ exports.isInstructionForProgram = isInstructionForProgram;
6519
+ exports.isInstructionWithAccounts = isInstructionWithAccounts;
6520
+ exports.isInstructionWithData = isInstructionWithData;
5843
6521
  exports.isKeyPairSigner = isKeyPairSigner;
5844
6522
  exports.isLamports = isLamports;
5845
6523
  exports.isMessageModifyingSigner = isMessageModifyingSigner;