@solana/web3.js 2.0.0-experimental.bea19d2 → 2.0.0-experimental.c067018

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.
@@ -127,7 +127,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
127
127
 
128
128
  // ../errors/dist/index.browser.js
129
129
  init_env_shim();
130
- var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
131
130
  var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
132
131
  var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
133
132
  var SOLANA_ERROR__NONCE_INVALID = 6;
@@ -137,8 +136,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
137
136
  var SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT = 10;
138
137
  var SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT = 11;
139
138
  var SOLANA_ERROR__NOT_ALL_ACCOUNTS_DECODED = 12;
140
- var SOLANA_ERROR__INCORRECT_BASE58_ADDRESS_LENGTH = 13;
141
- var SOLANA_ERROR__INCORRECT_BASE58_ADDRESS_BYTE_LENGTH = 14;
139
+ var SOLANA_ERROR__ADDRESS_BYTE_LENGTH_OUT_OF_RANGE = 13;
140
+ var SOLANA_ERROR__ADDRESS_STRING_LENGTH_OUT_OF_RANGE = 14;
142
141
  var SOLANA_ERROR__NOT_A_BASE58_ENCODED_ADDRESS = 15;
143
142
  var SOLANA_ERROR__NOT_AN_ED25519_PUBLIC_KEY = 16;
144
143
  var SOLANA_ERROR__MALFORMED_PROGRAM_DERIVED_ADDRESS = 17;
@@ -148,6 +147,29 @@ this.globalThis.solanaWeb3 = (function (exports) {
148
147
  var SOLANA_ERROR__INVALID_SEEDS_POINT_ON_CURVE = 21;
149
148
  var SOLANA_ERROR__COULD_NOT_FIND_VIABLE_PDA_BUMP_SEED = 22;
150
149
  var SOLANA_ERROR__PROGRAM_ADDRESS_ENDS_WITH_PDA_MARKER = 23;
150
+ var SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE = 48;
151
+ var SOLANA_ERROR__BLOCKHASH_BYTE_LENGTH_OUT_OF_RANGE = 49;
152
+ var SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE = 50;
153
+ var SOLANA_ERROR__MALFORMED_BIGINT_STRING = 51;
154
+ var SOLANA_ERROR__MALFORMED_NUMBER_STRING = 52;
155
+ var SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE = 53;
156
+ var SOLANA_ERROR__INVARIANT_VIOLATION_WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING = 3507e3;
157
+ var SOLANA_ERROR__INVARIANT_VIOLATION_WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 3507001;
158
+ var SOLANA_ERROR__INVARIANT_VIOLATION_CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 3507002;
159
+ var SOLANA_ERROR__INVARIANT_VIOLATION_SWITCH_MUST_BE_EXHAUSTIVE = 3507003;
160
+ var SOLANA_ERROR__SUBTLE_CRYPTO_MISSING = 361e4;
161
+ var SOLANA_ERROR__SUBTLE_CRYPTO_DIGEST_MISSING = 3610001;
162
+ var SOLANA_ERROR__SUBTLE_CRYPTO_ED25519_ALGORITHM_MISSING = 3610002;
163
+ var SOLANA_ERROR__SUBTLE_CRYPTO_EXPORT_FUNCTION_MISSING = 3610003;
164
+ var SOLANA_ERROR__SUBTLE_CRYPTO_GENERATE_FUNCTION_MISSING = 3610004;
165
+ var SOLANA_ERROR__SUBTLE_CRYPTO_SIGN_FUNCTION_MISSING = 3610005;
166
+ var SOLANA_ERROR__SUBTLE_CRYPTO_VERIFY_FUNCTION_MISSING = 3610006;
167
+ var SOLANA_ERROR__KEYS_INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704e3;
168
+ var SOLANA_ERROR__KEYS_INVALID_SIGNATURE_BYTE_LENGTH = 3704001;
169
+ var SOLANA_ERROR__KEYS_SIGNATURE_STRING_LENGTH_OUT_OF_RANGE = 3704002;
170
+ var SOLANA_ERROR__INSTRUCTION_EXPECTED_TO_HAVE_ACCOUNTS = 4128e3;
171
+ var SOLANA_ERROR__INSTRUCTION_EXPECTED_TO_HAVE_DATA = 4128001;
172
+ var SOLANA_ERROR__INSTRUCTION_PROGRAM_ID_MISMATCH = 4128002;
151
173
  var SOLANA_ERROR__INSTRUCTION_ERROR_UNKNOWN = 4615e3;
152
174
  var SOLANA_ERROR__INSTRUCTION_ERROR_GENERIC_ERROR = 4615001;
153
175
  var SOLANA_ERROR__INSTRUCTION_ERROR_INVALID_ARGUMENT = 4615002;
@@ -203,6 +225,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
203
225
  var SOLANA_ERROR__INSTRUCTION_ERROR_MAX_ACCOUNTS_EXCEEDED = 4615052;
204
226
  var SOLANA_ERROR__INSTRUCTION_ERROR_MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 4615053;
205
227
  var SOLANA_ERROR__INSTRUCTION_ERROR_BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 4615054;
228
+ var SOLANA_ERROR__SIGNER_ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS = 5508e3;
229
+ var SOLANA_ERROR__SIGNER_EXPECTED_KEY_PAIR_SIGNER = 5508001;
230
+ var SOLANA_ERROR__SIGNER_EXPECTED_MESSAGE_SIGNER = 5508002;
231
+ var SOLANA_ERROR__SIGNER_EXPECTED_MESSAGE_MODIFYING_SIGNER = 5508003;
232
+ var SOLANA_ERROR__SIGNER_EXPECTED_MESSAGE_PARTIAL_SIGNER = 5508004;
233
+ var SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_SIGNER = 5508005;
234
+ var SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_MODIFYING_SIGNER = 5508006;
235
+ var SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_PARTIAL_SIGNER = 5508007;
236
+ var SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_SENDING_SIGNER = 5508008;
237
+ var SOLANA_ERROR__SIGNER_TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = 5508009;
238
+ var SOLANA_ERROR__SIGNER_TRANSACTION_SENDING_SIGNER_MISSING = 5508010;
206
239
  var SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663001;
207
240
  var SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663002;
208
241
  var SOLANA_ERROR__TRANSACTION_EXPECTED_BLOCKHASH_LIFETIME = 5663003;
@@ -214,6 +247,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
214
247
  var SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = 5663009;
215
248
  var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 5663010;
216
249
  var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 5663011;
250
+ var SOLANA_ERROR__TRANSACTION_MISSING_ADDRESS = 5663012;
251
+ var SOLANA_ERROR__TRANSACTION_MISSING_FEE_PAYER = 5663013;
252
+ var SOLANA_ERROR__TRANSACTION_INVALID_NONCE_TRANSACTION_NO_INSTRUCTIONS = 5663014;
253
+ var SOLANA_ERROR__TRANSACTION_INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_NOT_ADVANCE_NONCE = 5663015;
217
254
  var SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN = 705e4;
218
255
  var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE = 7050001;
219
256
  var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE = 7050002;
@@ -251,14 +288,50 @@ this.globalThis.solanaWeb3 = (function (exports) {
251
288
  var SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED = 7050034;
252
289
  var SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
253
290
  var SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION = 7050036;
291
+ var SOLANA_ERROR__CODECS_CANNOT_DECODE_EMPTY_BYTE_ARRAY = 8078e3;
292
+ var SOLANA_ERROR__CODECS_WRONG_NUMBER_OF_BYTES = 8078001;
293
+ var SOLANA_ERROR__CODECS_EXPECTED_FIXED_LENGTH_GOT_VARIABLE_LENGTH = 8078002;
294
+ var SOLANA_ERROR__CODECS_EXPECTED_VARIABLE_LENGTH_GOT_FIXED_LENGTH = 8078003;
295
+ var SOLANA_ERROR__CODECS_ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH = 8078004;
296
+ var SOLANA_ERROR__CODECS_FIXED_SIZE_ENCODER_DECODER_SIZE_MISMATCH = 8078005;
297
+ var SOLANA_ERROR__CODECS_VARIABLE_SIZE_ENCODER_DECODER_MAX_SIZE_MISMATCH = 8078006;
298
+ var SOLANA_ERROR__CODECS_WRONG_NUMBER_OF_ITEMS = 8078007;
299
+ var SOLANA_ERROR__CODECS_ENUM_DISCRIMINATOR_OUT_OF_RANGE = 8078008;
300
+ var SOLANA_ERROR__CODECS_INVALID_DATA_ENUM_VARIANT = 8078009;
301
+ var SOLANA_ERROR__CODECS_INVALID_SCALAR_ENUM_VARIANT = 8078010;
302
+ var SOLANA_ERROR__CODECS_NUMBER_OUT_OF_RANGE = 8078011;
303
+ var SOLANA_ERROR__CODECS_INVALID_STRING_FOR_BASE = 8078012;
304
+ var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 81e5;
305
+ var SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN = 8100001;
306
+ var SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR = 8100002;
307
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS_CANNOT_CREATE_SUBSCRIPTION_REQUEST = 819e4;
308
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS_EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
309
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
310
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_CONNECTION_CLOSED = 8190003;
311
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_FAILED_TO_CONNECT = 8190004;
254
312
  var SolanaErrorMessages = {
255
313
  [SOLANA_ERROR__ACCOUNT_NOT_FOUND]: "Account not found at address: $address",
314
+ [SOLANA_ERROR__ADDRESS_BYTE_LENGTH_OUT_OF_RANGE]: "Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",
315
+ [SOLANA_ERROR__ADDRESS_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",
316
+ [SOLANA_ERROR__BLOCKHASH_BYTE_LENGTH_OUT_OF_RANGE]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
317
+ [SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",
256
318
  [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
319
+ [SOLANA_ERROR__CODECS_CANNOT_DECODE_EMPTY_BYTE_ARRAY]: "Codec [$codecDescription] cannot decode empty byte arrays.",
320
+ [SOLANA_ERROR__CODECS_ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH]: "Encoder and decoder must either both be fixed-size or variable-size.",
321
+ [SOLANA_ERROR__CODECS_ENUM_DISCRIMINATOR_OUT_OF_RANGE]: "Enum discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",
322
+ [SOLANA_ERROR__CODECS_EXPECTED_FIXED_LENGTH_GOT_VARIABLE_LENGTH]: "Expected a fixed-size codec, got a variable-size one.",
323
+ [SOLANA_ERROR__CODECS_EXPECTED_VARIABLE_LENGTH_GOT_FIXED_LENGTH]: "Expected a variable-size codec, got a fixed-size one.",
324
+ [SOLANA_ERROR__CODECS_FIXED_SIZE_ENCODER_DECODER_SIZE_MISMATCH]: "Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",
325
+ [SOLANA_ERROR__CODECS_INVALID_DATA_ENUM_VARIANT]: "Invalid data enum variant. Expected one of [$variants], got $value.",
326
+ [SOLANA_ERROR__CODECS_INVALID_SCALAR_ENUM_VARIANT]: "Invalid scalar enum variant. Expected one of [$variants] or a number between $minRange and $maxRange, got $value.",
327
+ [SOLANA_ERROR__CODECS_INVALID_STRING_FOR_BASE]: "Invalid value $value for base $base with alphabet $alphabet.",
328
+ [SOLANA_ERROR__CODECS_NUMBER_OUT_OF_RANGE]: "Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",
329
+ [SOLANA_ERROR__CODECS_VARIABLE_SIZE_ENCODER_DECODER_MAX_SIZE_MISMATCH]: "Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",
330
+ [SOLANA_ERROR__CODECS_WRONG_NUMBER_OF_BYTES]: "Codec [$codecDescription] expected $expected bytes, got $bytesLength.",
331
+ [SOLANA_ERROR__CODECS_WRONG_NUMBER_OF_ITEMS]: "Expected [$codecDescription] to have $expected items, got $actual.",
257
332
  [SOLANA_ERROR__COULD_NOT_FIND_VIABLE_PDA_BUMP_SEED]: "Unable to find a viable program address bump seed.",
258
333
  [SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT]: "Expected decoded account at address: $address",
259
334
  [SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT]: "Failed to decode account data at address: $address",
260
- [SOLANA_ERROR__INCORRECT_BASE58_ADDRESS_BYTE_LENGTH]: "Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",
261
- [SOLANA_ERROR__INCORRECT_BASE58_ADDRESS_LENGTH]: "Expected base58-encoded string of length between 32 and 44, got $actualLength.",
262
335
  [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_ALREADY_INITIALIZED]: "instruction requires an uninitialized account",
263
336
  [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_BORROW_FAILED]: "instruction tries to borrow reference for an account which is already borrowed",
264
337
  [SOLANA_ERROR__INSTRUCTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "instruction left account with an outstanding borrowed reference",
@@ -314,8 +387,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
314
387
  [SOLANA_ERROR__INSTRUCTION_ERROR_UNKNOWN]: "",
315
388
  [SOLANA_ERROR__INSTRUCTION_ERROR_UNSUPPORTED_PROGRAM_ID]: "Unsupported program id",
316
389
  [SOLANA_ERROR__INSTRUCTION_ERROR_UNSUPPORTED_SYSVAR]: "Unsupported sysvar",
390
+ [SOLANA_ERROR__INSTRUCTION_EXPECTED_TO_HAVE_ACCOUNTS]: "The instruction does not have any accounts.",
391
+ [SOLANA_ERROR__INSTRUCTION_EXPECTED_TO_HAVE_DATA]: "The instruction does not have any data.",
392
+ [SOLANA_ERROR__INSTRUCTION_PROGRAM_ID_MISMATCH]: "Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",
317
393
  [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
318
394
  [SOLANA_ERROR__INVALID_SEEDS_POINT_ON_CURVE]: "Invalid seeds; point must fall off the Ed25519 curve.",
395
+ [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",
396
+ [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",
397
+ [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",
398
+ [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",
399
+ [SOLANA_ERROR__KEYS_INVALID_PRIVATE_KEY_BYTE_LENGTH]: "Expected private key bytes with length 32. Actual length: $actualLength.",
400
+ [SOLANA_ERROR__KEYS_INVALID_SIGNATURE_BYTE_LENGTH]: "Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",
401
+ [SOLANA_ERROR__KEYS_SIGNATURE_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",
402
+ [SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE]: "Lamports value must be in the range [0, 2e64-1]",
403
+ [SOLANA_ERROR__MALFORMED_BIGINT_STRING]: "`$value` cannot be parsed as a `BigInt`",
404
+ [SOLANA_ERROR__MALFORMED_NUMBER_STRING]: "`$value` cannot be parsed as a `Number`",
319
405
  [SOLANA_ERROR__MALFORMED_PROGRAM_DERIVED_ADDRESS]: "Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",
320
406
  [SOLANA_ERROR__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED]: "A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",
321
407
  [SOLANA_ERROR__MAX_PDA_SEED_LENGTH_EXCEEDED]: "The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",
@@ -328,6 +414,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
328
414
  [SOLANA_ERROR__PROGRAM_ADDRESS_ENDS_WITH_PDA_MARKER]: "Program address cannot end with PDA marker.",
329
415
  [SOLANA_ERROR__PROGRAM_DERIVED_ADDRESS_BUMP_SEED_OUT_OF_RANGE]: "Expected program derived address bump to be in the range [0, 255], got: $bump.",
330
416
  [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`.",
417
+ [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.",
418
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS_EXPECTED_SERVER_SUBSCRIPTION_ID]: "Failed to obtain a subscription id from the server",
419
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
420
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_CONNECTION_CLOSED]: "WebSocket connection closed",
421
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_FAILED_TO_CONNECT]: "WebSocket failed to connect",
422
+ [SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN]: "HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",
423
+ [SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR]: "HTTP error ($statusCode): $message",
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_MISSING]: "No digest implementation could be found.",
436
+ [SOLANA_ERROR__SUBTLE_CRYPTO_ED25519_ALGORITHM_MISSING]: "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.",
437
+ [SOLANA_ERROR__SUBTLE_CRYPTO_EXPORT_FUNCTION_MISSING]: "No signature verification implementation could be found.",
438
+ [SOLANA_ERROR__SUBTLE_CRYPTO_GENERATE_FUNCTION_MISSING]: "No key generation implementation could be found.",
439
+ [SOLANA_ERROR__SUBTLE_CRYPTO_MISSING]: "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",
440
+ [SOLANA_ERROR__SUBTLE_CRYPTO_SIGN_FUNCTION_MISSING]: "No signing implementation could be found.",
441
+ [SOLANA_ERROR__SUBTLE_CRYPTO_VERIFY_FUNCTION_MISSING]: "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",
331
443
  [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
332
444
  [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: "Account in use",
333
445
  [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: "Account loaded twice",
@@ -371,8 +483,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
371
483
  [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",
372
484
  [SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
373
485
  [SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
486
+ [SOLANA_ERROR__TRANSACTION_INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_NOT_ADVANCE_NONCE]: "Transaction first instruction is not advance nonce account instruction.",
487
+ [SOLANA_ERROR__TRANSACTION_INVALID_NONCE_TRANSACTION_NO_INSTRUCTIONS]: "Transaction with no instructions cannot be durable nonce transaction.",
374
488
  [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",
375
489
  [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",
490
+ [SOLANA_ERROR__TRANSACTION_MISSING_ADDRESS]: "Transaction is missing an address at index: $index.",
491
+ [SOLANA_ERROR__TRANSACTION_MISSING_FEE_PAYER]: "Transaction is missing a fee payer.",
376
492
  [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
377
493
  [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.",
378
494
  [SOLANA_ERROR__TRANSACTION_VERSION_NUMBER_OUT_OF_RANGE]: "Transaction version must be in the range [0, 127]. `$actualVersion` given"
@@ -401,9 +517,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
401
517
  return false;
402
518
  }
403
519
  var SolanaError = class extends Error {
404
- constructor(...[code, context]) {
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
+ }
405
532
  const message = getErrorMessage(code, context);
406
- super(message);
533
+ super(message, errorOptions);
407
534
  __publicField(this, "context");
408
535
  this.context = {
409
536
  __code: code,
@@ -600,13 +727,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
600
727
  init_env_shim();
601
728
  function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
602
729
  if (bytes.length - offset <= 0) {
603
- 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
+ });
604
733
  }
605
734
  }
606
735
  function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
607
736
  const bytesLength = bytes.length - offset;
608
737
  if (bytesLength < expected) {
609
- throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
738
+ throw new SolanaError(SOLANA_ERROR__CODECS_WRONG_NUMBER_OF_BYTES, {
739
+ bytesLength,
740
+ codecDescription,
741
+ expected
742
+ });
610
743
  }
611
744
  }
612
745
  var mergeBytes = (byteArrays) => {
@@ -667,32 +800,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
667
800
  function isFixedSize(codec) {
668
801
  return "fixedSize" in codec && typeof codec.fixedSize === "number";
669
802
  }
670
- function assertIsFixedSize(codec, message) {
803
+ function assertIsFixedSize(codec) {
671
804
  if (!isFixedSize(codec)) {
672
- 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_GOT_VARIABLE_LENGTH);
673
806
  }
674
807
  }
675
808
  function isVariableSize(codec) {
676
809
  return !isFixedSize(codec);
677
810
  }
678
- function assertIsVariableSize(codec, message) {
811
+ function assertIsVariableSize(codec) {
679
812
  if (!isVariableSize(codec)) {
680
- 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_GOT_FIXED_LENGTH);
681
814
  }
682
815
  }
683
816
  function combineCodec(encoder, decoder) {
684
817
  if (isFixedSize(encoder) !== isFixedSize(decoder)) {
685
- 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);
686
819
  }
687
820
  if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
688
- throw new Error(
689
- `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
690
- );
821
+ throw new SolanaError(SOLANA_ERROR__CODECS_FIXED_SIZE_ENCODER_DECODER_SIZE_MISMATCH, {
822
+ decoderFixedSize: decoder.fixedSize,
823
+ encoderFixedSize: encoder.fixedSize
824
+ });
691
825
  }
692
826
  if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
693
- throw new Error(
694
- `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
695
- );
827
+ throw new SolanaError(SOLANA_ERROR__CODECS_VARIABLE_SIZE_ENCODER_DECODER_MAX_SIZE_MISMATCH, {
828
+ decoderMaxSize: decoder.maxSize,
829
+ encoderMaxSize: encoder.maxSize
830
+ });
696
831
  }
697
832
  return {
698
833
  ...decoder,
@@ -755,7 +890,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
755
890
  });
756
891
  }
757
892
  function reverseEncoder(encoder) {
758
- assertIsFixedSize(encoder, "Cannot reverse a codec of variable size.");
893
+ assertIsFixedSize(encoder);
759
894
  return createEncoder({
760
895
  ...encoder,
761
896
  write: (value, bytes, offset) => {
@@ -767,7 +902,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
767
902
  });
768
903
  }
769
904
  function reverseDecoder(decoder) {
770
- assertIsFixedSize(decoder, "Cannot reverse a codec of variable size.");
905
+ assertIsFixedSize(decoder);
771
906
  return createDecoder({
772
907
  ...decoder,
773
908
  read: (bytes, offset) => {
@@ -789,9 +924,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
789
924
  init_env_shim();
790
925
  function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
791
926
  if (value < min || value > max) {
792
- throw new Error(
793
- `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
794
- );
927
+ throw new SolanaError(SOLANA_ERROR__CODECS_NUMBER_OUT_OF_RANGE, {
928
+ codecDescription,
929
+ max,
930
+ min,
931
+ value
932
+ });
795
933
  }
796
934
  }
797
935
  var Endian = /* @__PURE__ */ ((Endian2) => {
@@ -986,7 +1124,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
986
1124
  var getU128Encoder = (config = {}) => numberEncoderFactory({
987
1125
  config,
988
1126
  name: "u128",
989
- range: [0, BigInt("0xffffffffffffffffffffffffffffffff")],
1127
+ range: [0n, BigInt("0xffffffffffffffffffffffffffffffff")],
990
1128
  set: (view, value, le) => {
991
1129
  const leftOffset = le ? 8 : 0;
992
1130
  const rightOffset = le ? 0 : 8;
@@ -1040,7 +1178,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1040
1178
  var getU64Encoder = (config = {}) => numberEncoderFactory({
1041
1179
  config,
1042
1180
  name: "u64",
1043
- range: [0, BigInt("0xffffffffffffffff")],
1181
+ range: [0n, BigInt("0xffffffffffffffff")],
1044
1182
  set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),
1045
1183
  size: 8
1046
1184
  });
@@ -1067,7 +1205,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1067
1205
  // ../codecs-strings/dist/index.browser.js
1068
1206
  function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
1069
1207
  if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
1070
- 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
+ });
1071
1213
  }
1072
1214
  }
1073
1215
  var getBaseXEncoder = (alphabet4) => {
@@ -1206,6 +1348,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1206
1348
  }
1207
1349
  return output;
1208
1350
  }
1351
+ var alphabet3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1209
1352
  var getBase64Encoder = () => {
1210
1353
  {
1211
1354
  return createEncoder({
@@ -1213,7 +1356,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1213
1356
  try {
1214
1357
  return atob(value).length;
1215
1358
  } catch (e22) {
1216
- 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
+ });
1217
1364
  }
1218
1365
  },
1219
1366
  write(value, bytes, offset) {
@@ -1222,7 +1369,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1222
1369
  bytes.set(bytesToAdd, offset);
1223
1370
  return bytesToAdd.length + offset;
1224
1371
  } catch (e22) {
1225
- 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
+ });
1226
1377
  }
1227
1378
  }
1228
1379
  });
@@ -1418,9 +1569,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1418
1569
  init_env_shim();
1419
1570
  function assertIsSecureContext() {
1420
1571
  if (!globalThis.isSecureContext) {
1421
- throw new Error(
1422
- "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
1423
- );
1572
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO_MISSING);
1424
1573
  }
1425
1574
  }
1426
1575
  var cachedEd25519Decision;
@@ -1449,40 +1598,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
1449
1598
  var _a;
1450
1599
  assertIsSecureContext();
1451
1600
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.digest) !== "function") {
1452
- throw new Error("No digest implementation could be found");
1601
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO_DIGEST_MISSING);
1453
1602
  }
1454
1603
  }
1455
1604
  async function assertKeyGenerationIsAvailable() {
1456
1605
  var _a;
1457
1606
  assertIsSecureContext();
1458
1607
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.generateKey) !== "function") {
1459
- throw new Error("No key generation implementation could be found");
1608
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO_GENERATE_FUNCTION_MISSING);
1460
1609
  }
1461
1610
  if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) {
1462
- throw new Error(
1463
- "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"
1464
- );
1611
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO_ED25519_ALGORITHM_MISSING);
1465
1612
  }
1466
1613
  }
1467
1614
  async function assertKeyExporterIsAvailable() {
1468
1615
  var _a;
1469
1616
  assertIsSecureContext();
1470
1617
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
1471
- throw new Error("No key export implementation could be found");
1618
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO_EXPORT_FUNCTION_MISSING);
1472
1619
  }
1473
1620
  }
1474
1621
  async function assertSigningCapabilityIsAvailable() {
1475
1622
  var _a;
1476
1623
  assertIsSecureContext();
1477
1624
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
1478
- throw new Error("No signing implementation could be found");
1625
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO_SIGN_FUNCTION_MISSING);
1479
1626
  }
1480
1627
  }
1481
1628
  async function assertVerificationCapabilityIsAvailable() {
1482
1629
  var _a;
1483
1630
  assertIsSecureContext();
1484
1631
  if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.verify) !== "function") {
1485
- throw new Error("No signature verification implementation could be found");
1632
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO_VERIFY_FUNCTION_MISSING);
1486
1633
  }
1487
1634
  }
1488
1635
 
@@ -1516,26 +1663,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
1516
1663
  return true;
1517
1664
  }
1518
1665
  function assertIsAddress(putativeAddress) {
1519
- try {
1520
- if (
1521
- // Lowest address (32 bytes of zeroes)
1522
- putativeAddress.length < 32 || // Highest address (32 bytes of 255)
1523
- putativeAddress.length > 44
1524
- ) {
1525
- throw new SolanaError(SOLANA_ERROR__INCORRECT_BASE58_ADDRESS_LENGTH, {
1526
- actualLength: putativeAddress.length
1527
- });
1528
- }
1529
- const base58Encoder4 = getMemoizedBase58Encoder();
1530
- const bytes = base58Encoder4.encode(putativeAddress);
1531
- const numBytes = bytes.byteLength;
1532
- if (numBytes !== 32) {
1533
- throw new SolanaError(SOLANA_ERROR__INCORRECT_BASE58_ADDRESS_BYTE_LENGTH, {
1534
- actualLength: numBytes
1535
- });
1536
- }
1537
- } catch (e4) {
1538
- throw new SolanaError(SOLANA_ERROR__NOT_A_BASE58_ENCODED_ADDRESS, { putativeAddress });
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__ADDRESS_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__ADDRESS_BYTE_LENGTH_OUT_OF_RANGE, {
1680
+ actualLength: numBytes
1681
+ });
1539
1682
  }
1540
1683
  }
1541
1684
  function address(putativeAddress) {
@@ -1780,7 +1923,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1780
1923
  init_env_shim();
1781
1924
  function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1782
1925
  if (expected !== actual) {
1783
- throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1926
+ throw new SolanaError(SOLANA_ERROR__CODECS_WRONG_NUMBER_OF_ITEMS, {
1927
+ actual,
1928
+ codecDescription,
1929
+ expected
1930
+ });
1784
1931
  }
1785
1932
  }
1786
1933
  function maxCodecSizes(sizes) {
@@ -1926,13 +2073,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
1926
2073
  function getBooleanEncoder(config = {}) {
1927
2074
  var _a;
1928
2075
  const size = (_a = config.size) != null ? _a : getU8Encoder();
1929
- assertIsFixedSize(size, "Codec [bool] requires a fixed size.");
2076
+ assertIsFixedSize(size);
1930
2077
  return mapEncoder(size, (value) => value ? 1 : 0);
1931
2078
  }
1932
2079
  function getBooleanDecoder(config = {}) {
1933
2080
  var _a;
1934
2081
  const size = (_a = config.size) != null ? _a : getU8Decoder();
1935
- assertIsFixedSize(size, "Codec [bool] requires a fixed size.");
2082
+ assertIsFixedSize(size);
1936
2083
  return mapDecoder(size, (value) => Number(value) === 1);
1937
2084
  }
1938
2085
  function getBooleanCodec(config = {}) {
@@ -2028,9 +2175,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2028
2175
  offset = dOffset;
2029
2176
  const variantField = (_a2 = variants[Number(discriminator)]) != null ? _a2 : null;
2030
2177
  if (!variantField) {
2031
- throw new Error(
2032
- `Enum discriminator out of range. Expected a number between 0 and ${variants.length - 1}, got ${discriminator}.`
2033
- );
2178
+ throw new SolanaError(SOLANA_ERROR__CODECS_ENUM_DISCRIMINATOR_OUT_OF_RANGE, {
2179
+ discriminator,
2180
+ maxRange: variants.length - 1,
2181
+ minRange: 0
2182
+ });
2034
2183
  }
2035
2184
  const [variant, vOffset] = variantField[1].read(bytes, offset);
2036
2185
  offset = vOffset;
@@ -2065,9 +2214,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
2065
2214
  function getVariantDiscriminator(variants, variant) {
2066
2215
  const discriminator = variants.findIndex(([key]) => variant.__kind === key);
2067
2216
  if (discriminator < 0) {
2068
- throw new Error(
2069
- `Invalid data enum variant. Expected one of [${variants.map(([key]) => key).join(", ")}], got "${variant.__kind}".`
2070
- );
2217
+ throw new SolanaError(SOLANA_ERROR__CODECS_INVALID_DATA_ENUM_VARIANT, {
2218
+ value: variant.__kind,
2219
+ variants: variants.map(([key]) => key)
2220
+ });
2071
2221
  }
2072
2222
  return discriminator;
2073
2223
  }
@@ -2133,8 +2283,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
2133
2283
  const fixed = (_b = config.fixed) != null ? _b : false;
2134
2284
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
2135
2285
  if (fixed || isZeroSizeItem) {
2136
- assertIsFixedSize(item, "Fixed nullables can only be used with fixed-size codecs.");
2137
- assertIsFixedSize(prefix, "Fixed nullables can only be used with fixed-size prefix.");
2286
+ assertIsFixedSize(item);
2287
+ assertIsFixedSize(prefix);
2138
2288
  const fixedSize = prefix.fixedSize + item.fixedSize;
2139
2289
  return createEncoder({
2140
2290
  fixedSize,
@@ -2166,8 +2316,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
2166
2316
  let fixedSize = null;
2167
2317
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
2168
2318
  if (fixed || isZeroSizeItem) {
2169
- assertIsFixedSize(item, "Fixed nullables can only be used with fixed-size codecs.");
2170
- assertIsFixedSize(prefix, "Fixed nullables can only be used with fixed-size prefix.");
2319
+ assertIsFixedSize(item);
2320
+ assertIsFixedSize(prefix);
2171
2321
  fixedSize = prefix.fixedSize + item.fixedSize;
2172
2322
  }
2173
2323
  return createDecoder({
@@ -2197,9 +2347,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
2197
2347
  const isInvalidNumber = typeof value === "number" && (value < minRange || value > maxRange);
2198
2348
  const isInvalidString = typeof value === "string" && !allStringInputs.includes(value);
2199
2349
  if (isInvalidNumber || isInvalidString) {
2200
- throw new Error(
2201
- `Invalid scalar enum variant. Expected one of [${allStringInputs.join(", ")}] or a number between ${minRange} and ${maxRange}, got "${value}".`
2202
- );
2350
+ throw new SolanaError(SOLANA_ERROR__CODECS_INVALID_SCALAR_ENUM_VARIANT, {
2351
+ maxRange,
2352
+ minRange,
2353
+ value,
2354
+ variants: allStringInputs
2355
+ });
2203
2356
  }
2204
2357
  if (typeof value === "number")
2205
2358
  return value;
@@ -2216,9 +2369,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2216
2369
  return mapDecoder(prefix, (value) => {
2217
2370
  const valueAsNumber = Number(value);
2218
2371
  if (valueAsNumber < minRange || valueAsNumber > maxRange) {
2219
- throw new Error(
2220
- `Enum discriminator out of range. Expected a number between ${minRange} and ${maxRange}, got ${valueAsNumber}.`
2221
- );
2372
+ throw new SolanaError(SOLANA_ERROR__CODECS_ENUM_DISCRIMINATOR_OUT_OF_RANGE, {
2373
+ discriminator: valueAsNumber,
2374
+ maxRange,
2375
+ minRange
2376
+ });
2222
2377
  }
2223
2378
  return constructor[enumKeys[valueAsNumber]];
2224
2379
  });
@@ -2332,8 +2487,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
2332
2487
  const fixed = (_b = config.fixed) != null ? _b : false;
2333
2488
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
2334
2489
  if (fixed || isZeroSizeItem) {
2335
- assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs.");
2336
- assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix.");
2490
+ assertIsFixedSize(item);
2491
+ assertIsFixedSize(prefix);
2337
2492
  const fixedSize = prefix.fixedSize + item.fixedSize;
2338
2493
  return createEncoder({
2339
2494
  fixedSize,
@@ -2370,8 +2525,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
2370
2525
  let fixedSize = null;
2371
2526
  const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;
2372
2527
  if (fixed || isZeroSizeItem) {
2373
- assertIsFixedSize(item, "Fixed options can only be used with fixed-size codecs.");
2374
- assertIsFixedSize(prefix, "Fixed options can only be used with fixed-size prefix.");
2528
+ assertIsFixedSize(item);
2529
+ assertIsFixedSize(prefix);
2375
2530
  fixedSize = prefix.fixedSize + item.fixedSize;
2376
2531
  }
2377
2532
  return createDecoder({
@@ -2426,6 +2581,40 @@ this.globalThis.solanaWeb3 = (function (exports) {
2426
2581
 
2427
2582
  // ../instructions/dist/index.browser.js
2428
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
+ }
2429
2618
  var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
2430
2619
  AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
2431
2620
  3] = "WRITABLE_SIGNER";
@@ -2510,8 +2699,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2510
2699
  ]);
2511
2700
  }
2512
2701
  async function createPrivateKeyFromBytes(bytes, extractable) {
2513
- if (bytes.byteLength !== 32) {
2514
- 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
+ });
2515
2707
  }
2516
2708
  const privateKeyBytesPkcs8 = addPkcs8Header(bytes);
2517
2709
  return await crypto.subtle.importKey("pkcs8", privateKeyBytesPkcs8, "Ed25519", extractable != null ? extractable : false, ["sign"]);
@@ -2551,22 +2743,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
2551
2743
  function assertIsSignature(putativeSignature) {
2552
2744
  if (!base58Encoder)
2553
2745
  base58Encoder = getBase58Encoder();
2554
- try {
2555
- if (
2556
- // Lowest value (64 bytes of zeroes)
2557
- putativeSignature.length < 64 || // Highest value (64 bytes of 255)
2558
- putativeSignature.length > 88
2559
- ) {
2560
- throw new Error("Expected input string to decode to a byte array of length 64.");
2561
- }
2562
- const bytes = base58Encoder.encode(putativeSignature);
2563
- const numBytes = bytes.byteLength;
2564
- if (numBytes !== 64) {
2565
- throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
2566
- }
2567
- } catch (e4) {
2568
- throw new Error(`\`${putativeSignature}\` is not a signature`, {
2569
- 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
2570
2760
  });
2571
2761
  }
2572
2762
  }
@@ -3162,17 +3352,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3162
3352
  // ../rpc-transport-http/dist/index.browser.js
3163
3353
  init_env_shim();
3164
3354
  var e2 = globalThis.fetch;
3165
- var SolanaHttpError = class extends Error {
3166
- constructor(details) {
3167
- super(`HTTP error (${details.statusCode}): ${details.message}`);
3168
- __publicField(this, "statusCode");
3169
- Error.captureStackTrace(this, this.constructor);
3170
- this.statusCode = details.statusCode;
3171
- }
3172
- get name() {
3173
- return "SolanaHttpError";
3174
- }
3175
- };
3176
3355
  var DISALLOWED_HEADERS = {
3177
3356
  accept: true,
3178
3357
  "content-length": true,
@@ -3209,9 +3388,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3209
3388
  return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
3210
3389
  });
3211
3390
  if (badHeaders.length > 0) {
3212
- throw new Error(
3213
- `${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.`
3214
- );
3391
+ throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN, {
3392
+ headers: badHeaders
3393
+ });
3215
3394
  }
3216
3395
  }
3217
3396
  function normalizeHeaders(headers) {
@@ -3261,7 +3440,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3261
3440
  };
3262
3441
  const response = await e2(url, requestInfo);
3263
3442
  if (!response.ok) {
3264
- throw new SolanaHttpError({
3443
+ throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR, {
3265
3444
  message: response.statusText,
3266
3445
  statusCode: response.status
3267
3446
  });
@@ -3310,10 +3489,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3310
3489
  throw createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
3311
3490
  }
3312
3491
  };
3313
- function createSolanaRpc(config) {
3314
- const api = createSolanaRpcApi(DEFAULT_RPC_CONFIG);
3315
- return createRpc({ ...config, api });
3316
- }
3317
3492
  var EXPLICIT_ABORT_TOKEN = Symbol(
3318
3493
  "This symbol is thrown from the request that underlies a series of coalesced requests when the last request in that series aborts"
3319
3494
  );
@@ -3408,6 +3583,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
3408
3583
  (transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
3409
3584
  );
3410
3585
  }
3586
+ function createSolanaRpc(clusterUrl, config) {
3587
+ return createSolanaRpcFromTransport(createDefaultRpcTransport({ url: clusterUrl, ...config }));
3588
+ }
3589
+ function createSolanaRpcFromTransport(transport) {
3590
+ return createRpc({
3591
+ api: createSolanaRpcApi(DEFAULT_RPC_CONFIG),
3592
+ transport
3593
+ });
3594
+ }
3411
3595
 
3412
3596
  // ../rpc-subscriptions/dist/index.browser.js
3413
3597
  init_env_shim();
@@ -3430,17 +3614,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
3430
3614
  },
3431
3615
  get(target, p, receiver) {
3432
3616
  return function(...rawParams) {
3433
- const methodName = p.toString();
3434
- const createRpcSubscription = Reflect.get(target, methodName, receiver);
3617
+ const notificationName = p.toString();
3618
+ const createRpcSubscription = Reflect.get(target, notificationName, receiver);
3435
3619
  if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
3436
- throw new Error(
3437
- "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."
3438
- );
3620
+ throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS_CANNOT_CREATE_SUBSCRIPTION_REQUEST, {
3621
+ notificationName
3622
+ });
3439
3623
  }
3440
3624
  const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
3441
3625
  params: rawParams,
3442
- subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
3443
- unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
3626
+ subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
3627
+ unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
3444
3628
  };
3445
3629
  return createPendingRpcSubscription(rpcConfig, newRequest);
3446
3630
  };
@@ -3495,7 +3679,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3495
3679
  }
3496
3680
  }
3497
3681
  if (subscriptionId == null) {
3498
- throw new Error("Failed to obtain a subscription id from the server");
3682
+ throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS_EXPECTED_SERVER_SUBSCRIPTION_ID);
3499
3683
  }
3500
3684
  return {
3501
3685
  async *[Symbol.asyncIterator]() {
@@ -3775,8 +3959,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3775
3959
  function handleError(ev) {
3776
3960
  if (!hasConnected) {
3777
3961
  reject(
3778
- // TODO: Coded error
3779
- new Error("WebSocket failed to connect", { cause: ev })
3962
+ new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_FAILED_TO_CONNECT, {
3963
+ errorEvent: ev
3964
+ })
3780
3965
  );
3781
3966
  }
3782
3967
  }
@@ -3801,8 +3986,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3801
3986
  bufferDrainWatcher = void 0;
3802
3987
  clearInterval(intervalId);
3803
3988
  reject2(
3804
- // TODO: Coded error
3805
- new Error("WebSocket was closed before payload could be sent")
3989
+ new SolanaError(
3990
+ SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED
3991
+ )
3806
3992
  );
3807
3993
  };
3808
3994
  });
@@ -3825,11 +4011,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
3825
4011
  while (true) {
3826
4012
  const state = iteratorState.get(iteratorKey);
3827
4013
  if (!state) {
3828
- throw new Error("Invariant: WebSocket message iterator is missing state storage");
4014
+ throw new SolanaError(
4015
+ SOLANA_ERROR__INVARIANT_VIOLATION_WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING
4016
+ );
3829
4017
  }
3830
4018
  if (state.__hasPolled) {
3831
- throw new Error(
3832
- "Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
4019
+ throw new SolanaError(
4020
+ SOLANA_ERROR__INVARIANT_VIOLATION_WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE
3833
4021
  );
3834
4022
  }
3835
4023
  const queuedMessages = state.queuedMessages;
@@ -3849,7 +4037,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
3849
4037
  if (e22 === EXPLICIT_ABORT_TOKEN2) {
3850
4038
  return;
3851
4039
  } else {
3852
- throw new Error("WebSocket connection closed", { cause: e22 });
4040
+ throw new SolanaError(
4041
+ SOLANA_ERROR__RPC_SUBSCRIPTIONS_TRANSPORT_CONNECTION_CLOSED,
4042
+ {
4043
+ cause: e22
4044
+ }
4045
+ );
3853
4046
  }
3854
4047
  }
3855
4048
  }
@@ -3952,7 +4145,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3952
4145
  }
3953
4146
  function getCachedAbortableIterableFactory({
3954
4147
  getAbortSignalFromInputArgs,
3955
- getCacheEntryMissingError,
3956
4148
  getCacheKeyFromInputArgs,
3957
4149
  onCacheHit,
3958
4150
  onCreateIterable
@@ -3961,7 +4153,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3961
4153
  function getCacheEntryOrThrow(cacheKey) {
3962
4154
  const currentCacheEntry = cache.get(cacheKey);
3963
4155
  if (!currentCacheEntry) {
3964
- throw getCacheEntryMissingError(cacheKey);
4156
+ throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION_CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING, {
4157
+ cacheKey: cacheKey.toString()
4158
+ });
3965
4159
  }
3966
4160
  return currentCacheEntry;
3967
4161
  }
@@ -4060,11 +4254,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
4060
4254
  }
4061
4255
  const iterableFactory = getCachedAbortableIterableFactory({
4062
4256
  getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
4063
- getCacheEntryMissingError(deduplicationKey2) {
4064
- return new Error(
4065
- `Found no cache entry for subscription with deduplication key \`${deduplicationKey2 == null ? void 0 : deduplicationKey2.toString()}\``
4066
- );
4067
- },
4068
4257
  getCacheKeyFromInputArgs: () => deduplicationKey,
4069
4258
  async onCacheHit(_iterable, _config) {
4070
4259
  },
@@ -4122,24 +4311,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
4122
4311
  }
4123
4312
  });
4124
4313
  }
4125
- function createSolanaRpcSubscriptions(config) {
4126
- return pipe(
4127
- createSubscriptionRpc({
4128
- ...config,
4129
- api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG2)
4130
- }),
4131
- (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
4132
- getDeduplicationKey: (...args) => (0, import_fast_stable_stringify2.default)(args),
4133
- rpcSubscriptions
4134
- })
4135
- );
4136
- }
4137
- function createSolanaRpcSubscriptions_UNSTABLE(config) {
4138
- return createSubscriptionRpc({
4139
- ...config,
4140
- api: createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG2)
4141
- });
4142
- }
4143
4314
  var PING_PAYLOAD = {
4144
4315
  jsonrpc: "2.0",
4145
4316
  method: "ping"
@@ -4213,9 +4384,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
4213
4384
  }) {
4214
4385
  return getCachedAbortableIterableFactory({
4215
4386
  getAbortSignalFromInputArgs: ({ signal }) => signal,
4216
- getCacheEntryMissingError(shardKey) {
4217
- return new Error(`Found no cache entry for connection with shard key \`${shardKey == null ? void 0 : shardKey.toString()}\``);
4218
- },
4219
4387
  getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
4220
4388
  onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
4221
4389
  onCreateIterable: (abortSignal, config) => transport({
@@ -4245,6 +4413,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
4245
4413
  })
4246
4414
  );
4247
4415
  }
4416
+ function createSolanaRpcSubscriptions(clusterUrl, config) {
4417
+ const transport = createDefaultRpcSubscriptionsTransport({ url: clusterUrl, ...config });
4418
+ return createSolanaRpcSubscriptionsFromTransport(transport);
4419
+ }
4420
+ function createSolanaRpcSubscriptions_UNSTABLE(clusterUrl, config) {
4421
+ return createSolanaRpcSubscriptions(
4422
+ clusterUrl,
4423
+ config
4424
+ );
4425
+ }
4426
+ function createSolanaRpcSubscriptionsFromTransport(transport) {
4427
+ return pipe(
4428
+ createSubscriptionRpc({
4429
+ api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG2),
4430
+ transport
4431
+ }),
4432
+ (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
4433
+ getDeduplicationKey: (...args) => (0, import_fast_stable_stringify2.default)(args),
4434
+ rpcSubscriptions
4435
+ })
4436
+ );
4437
+ }
4438
+ function createSolanaRpcSubscriptionsFromTransport_UNSTABLE(transport) {
4439
+ return createSolanaRpcSubscriptionsFromTransport(transport);
4440
+ }
4248
4441
 
4249
4442
  // ../rpc-types/dist/index.browser.js
4250
4443
  init_env_shim();
@@ -4252,22 +4445,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
4252
4445
  function assertIsBlockhash(putativeBlockhash) {
4253
4446
  if (!base58Encoder2)
4254
4447
  base58Encoder2 = getBase58Encoder();
4255
- try {
4256
- if (
4257
- // Lowest value (32 bytes of zeroes)
4258
- putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
4259
- putativeBlockhash.length > 44
4260
- ) {
4261
- throw new Error("Expected input string to decode to a byte array of length 32.");
4262
- }
4263
- const bytes = base58Encoder2.encode(putativeBlockhash);
4264
- const numBytes = bytes.byteLength;
4265
- if (numBytes !== 32) {
4266
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
4267
- }
4268
- } catch (e4) {
4269
- throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
4270
- cause: e4
4448
+ if (
4449
+ // Lowest value (32 bytes of zeroes)
4450
+ putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
4451
+ putativeBlockhash.length > 44
4452
+ ) {
4453
+ throw new SolanaError(SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE, {
4454
+ actualLength: putativeBlockhash.length
4455
+ });
4456
+ }
4457
+ const bytes = base58Encoder2.encode(putativeBlockhash);
4458
+ const numBytes = bytes.byteLength;
4459
+ if (numBytes !== 32) {
4460
+ throw new SolanaError(SOLANA_ERROR__BLOCKHASH_BYTE_LENGTH_OUT_OF_RANGE, {
4461
+ actualLength: numBytes
4271
4462
  });
4272
4463
  }
4273
4464
  }
@@ -4289,9 +4480,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4289
4480
  case "processed":
4290
4481
  return 0;
4291
4482
  default:
4292
- return ((_) => {
4293
- throw new Error(`Unrecognized commitment \`${commitment}\`.`);
4294
- })();
4483
+ throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION_SWITCH_MUST_BE_EXHAUSTIVE, {
4484
+ unexpectedValue: commitment
4485
+ });
4295
4486
  }
4296
4487
  }
4297
4488
  function commitmentComparator(a, b) {
@@ -4305,11 +4496,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
4305
4496
  return putativeLamports >= 0 && putativeLamports <= maxU64Value;
4306
4497
  }
4307
4498
  function assertIsLamports(putativeLamports) {
4308
- if (putativeLamports < 0) {
4309
- throw new Error("Input for 64-bit unsigned integer cannot be negative");
4310
- }
4311
- if (putativeLamports > maxU64Value) {
4312
- throw new Error("Input number is too large to be represented as a 64-bit unsigned integer");
4499
+ if (putativeLamports < 0 || putativeLamports > maxU64Value) {
4500
+ throw new SolanaError(SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE);
4313
4501
  }
4314
4502
  }
4315
4503
  function lamports(putativeLamports) {
@@ -4346,9 +4534,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4346
4534
  function assertIsStringifiedBigInt(putativeBigInt) {
4347
4535
  try {
4348
4536
  BigInt(putativeBigInt);
4349
- } catch (e4) {
4350
- throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, {
4351
- cause: e4
4537
+ } catch {
4538
+ throw new SolanaError(SOLANA_ERROR__MALFORMED_BIGINT_STRING, {
4539
+ value: putativeBigInt
4352
4540
  });
4353
4541
  }
4354
4542
  }
@@ -4361,7 +4549,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4361
4549
  }
4362
4550
  function assertIsStringifiedNumber(putativeNumber) {
4363
4551
  if (Number.isNaN(Number(putativeNumber))) {
4364
- throw new Error(`\`${putativeNumber}\` cannot be parsed as a Number`);
4552
+ throw new SolanaError(SOLANA_ERROR__MALFORMED_NUMBER_STRING, {
4553
+ value: putativeNumber
4554
+ });
4365
4555
  }
4366
4556
  }
4367
4557
  function stringifiedNumber(putativeNumber) {
@@ -4375,13 +4565,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4375
4565
  return true;
4376
4566
  }
4377
4567
  function assertIsUnixTimestamp(putativeTimestamp) {
4378
- try {
4379
- if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
4380
- throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]");
4381
- }
4382
- } catch (e4) {
4383
- throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, {
4384
- cause: e4
4568
+ if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
4569
+ throw new SolanaError(SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE, {
4570
+ value: putativeTimestamp
4385
4571
  });
4386
4572
  }
4387
4573
  }
@@ -4399,22 +4585,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
4399
4585
  function assertIsBlockhash2(putativeBlockhash) {
4400
4586
  if (!base58Encoder3)
4401
4587
  base58Encoder3 = getBase58Encoder();
4402
- try {
4403
- if (
4404
- // Lowest value (32 bytes of zeroes)
4405
- putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
4406
- putativeBlockhash.length > 44
4407
- ) {
4408
- throw new Error("Expected input string to decode to a byte array of length 32.");
4409
- }
4410
- const bytes = base58Encoder3.encode(putativeBlockhash);
4411
- const numBytes = bytes.byteLength;
4412
- if (numBytes !== 32) {
4413
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
4414
- }
4415
- } catch (e4) {
4416
- throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
4417
- cause: e4
4588
+ if (
4589
+ // Lowest value (32 bytes of zeroes)
4590
+ putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
4591
+ putativeBlockhash.length > 44
4592
+ ) {
4593
+ throw new SolanaError(SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE, {
4594
+ actualLength: putativeBlockhash.length
4595
+ });
4596
+ }
4597
+ const bytes = base58Encoder3.encode(putativeBlockhash);
4598
+ const numBytes = bytes.byteLength;
4599
+ if (numBytes !== 32) {
4600
+ throw new SolanaError(SOLANA_ERROR__BLOCKHASH_BYTE_LENGTH_OUT_OF_RANGE, {
4601
+ actualLength: numBytes
4418
4602
  });
4419
4603
  }
4420
4604
  }
@@ -5339,9 +5523,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5339
5523
  if (!deduplicated[signer.address]) {
5340
5524
  deduplicated[signer.address] = signer;
5341
5525
  } else if (deduplicated[signer.address] !== signer) {
5342
- throw new Error(
5343
- `Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
5344
- );
5526
+ throw new SolanaError(SOLANA_ERROR__SIGNER_ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS, {
5527
+ address: signer.address
5528
+ });
5345
5529
  }
5346
5530
  });
5347
5531
  return Object.values(deduplicated);
@@ -5404,7 +5588,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5404
5588
  }
5405
5589
  function assertIsMessagePartialSigner(value) {
5406
5590
  if (!isMessagePartialSigner(value)) {
5407
- throw new Error("The provided value does not implement the MessagePartialSigner interface");
5591
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_MESSAGE_PARTIAL_SIGNER, {
5592
+ address: value.address
5593
+ });
5408
5594
  }
5409
5595
  }
5410
5596
  function isTransactionPartialSigner(value) {
@@ -5412,7 +5598,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5412
5598
  }
5413
5599
  function assertIsTransactionPartialSigner(value) {
5414
5600
  if (!isTransactionPartialSigner(value)) {
5415
- throw new Error("The provided value does not implement the TransactionPartialSigner interface");
5601
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
5602
+ address: value.address
5603
+ });
5416
5604
  }
5417
5605
  }
5418
5606
  function isKeyPairSigner(value) {
@@ -5420,7 +5608,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5420
5608
  }
5421
5609
  function assertIsKeyPairSigner(value) {
5422
5610
  if (!isKeyPairSigner(value)) {
5423
- throw new Error("The provided value does not implement the KeyPairSigner interface");
5611
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_KEY_PAIR_SIGNER, {
5612
+ address: value.address
5613
+ });
5424
5614
  }
5425
5615
  }
5426
5616
  async function createSignerFromKeyPair(keyPair) {
@@ -5453,7 +5643,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5453
5643
  }
5454
5644
  function assertIsMessageModifyingSigner(value) {
5455
5645
  if (!isMessageModifyingSigner(value)) {
5456
- throw new Error("The provided value does not implement the MessageModifyingSigner interface");
5646
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_MESSAGE_MODIFYING_SIGNER, {
5647
+ address: value.address
5648
+ });
5457
5649
  }
5458
5650
  }
5459
5651
  function isMessageSigner(value) {
@@ -5461,7 +5653,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5461
5653
  }
5462
5654
  function assertIsMessageSigner(value) {
5463
5655
  if (!isMessageSigner(value)) {
5464
- throw new Error("The provided value does not implement any of the MessageSigner interfaces");
5656
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_MESSAGE_SIGNER, {
5657
+ address: value.address
5658
+ });
5465
5659
  }
5466
5660
  }
5467
5661
  function createNoopSigner(address2) {
@@ -5477,7 +5671,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5477
5671
  }
5478
5672
  function assertIsTransactionModifyingSigner(value) {
5479
5673
  if (!isTransactionModifyingSigner(value)) {
5480
- throw new Error("The provided value does not implement the TransactionModifyingSigner interface");
5674
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
5675
+ address: value.address
5676
+ });
5481
5677
  }
5482
5678
  }
5483
5679
  function isTransactionSendingSigner(value) {
@@ -5485,7 +5681,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5485
5681
  }
5486
5682
  function assertIsTransactionSendingSigner(value) {
5487
5683
  if (!isTransactionSendingSigner(value)) {
5488
- throw new Error("The provided value does not implement the TransactionSendingSigner interface");
5684
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_SENDING_SIGNER, {
5685
+ address: value.address
5686
+ });
5489
5687
  }
5490
5688
  }
5491
5689
  function isTransactionSigner(value) {
@@ -5493,7 +5691,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
5493
5691
  }
5494
5692
  function assertIsTransactionSigner(value) {
5495
5693
  if (!isTransactionSigner(value)) {
5496
- throw new Error("The provided value does not implement any of the TransactionSigner interfaces");
5694
+ throw new SolanaError(SOLANA_ERROR__SIGNER_EXPECTED_TRANSACTION_SIGNER, {
5695
+ address: value.address
5696
+ });
5497
5697
  }
5498
5698
  }
5499
5699
  async function partiallySignTransactionWithSigners(transaction, config = {}) {
@@ -5521,9 +5721,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
5521
5721
  abortSignal
5522
5722
  );
5523
5723
  if (!sendingSigner) {
5524
- throw new Error(
5525
- "No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction."
5526
- );
5724
+ throw new SolanaError(SOLANA_ERROR__SIGNER_TRANSACTION_SENDING_SIGNER_MISSING);
5527
5725
  }
5528
5726
  abortSignal == null ? void 0 : abortSignal.throwIfAborted();
5529
5727
  const [signature2] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal });
@@ -5608,17 +5806,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
5608
5806
  const signers = getSignersFromTransaction(transaction);
5609
5807
  const sendingSigners = signers.filter(isTransactionSendingSigner);
5610
5808
  if (sendingSigners.length === 0) {
5611
- const error = new Error("No `TransactionSendingSigner` was identified.");
5612
- error.name = "MissingTransactionSendingSignerError";
5613
- throw error;
5809
+ throw new SolanaError(SOLANA_ERROR__SIGNER_TRANSACTION_SENDING_SIGNER_MISSING);
5614
5810
  }
5615
5811
  const sendingOnlySigners = sendingSigners.filter(
5616
5812
  (signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer)
5617
5813
  );
5618
5814
  if (sendingOnlySigners.length > 1) {
5619
- const error = new Error("More than one `TransactionSendingSigner` was identified.");
5620
- error.name = "MultipleTransactionSendingSignersError";
5621
- throw error;
5815
+ throw new SolanaError(SOLANA_ERROR__SIGNER_TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS);
5622
5816
  }
5623
5817
  }
5624
5818
 
@@ -6129,6 +6323,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
6129
6323
  exports.assertIsBlockhash = assertIsBlockhash;
6130
6324
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
6131
6325
  exports.assertIsFixedSize = assertIsFixedSize;
6326
+ exports.assertIsInstructionForProgram = assertIsInstructionForProgram;
6327
+ exports.assertIsInstructionWithAccounts = assertIsInstructionWithAccounts;
6328
+ exports.assertIsInstructionWithData = assertIsInstructionWithData;
6132
6329
  exports.assertIsKeyPairSigner = assertIsKeyPairSigner;
6133
6330
  exports.assertIsLamports = assertIsLamports;
6134
6331
  exports.assertIsMessageModifyingSigner = assertIsMessageModifyingSigner;
@@ -6170,9 +6367,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
6170
6367
  exports.createSignerFromKeyPair = createSignerFromKeyPair;
6171
6368
  exports.createSolanaRpc = createSolanaRpc;
6172
6369
  exports.createSolanaRpcApi = createSolanaRpcApi;
6370
+ exports.createSolanaRpcFromTransport = createSolanaRpcFromTransport;
6173
6371
  exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
6174
6372
  exports.createSolanaRpcSubscriptionsApi = createSolanaRpcSubscriptionsApi;
6175
6373
  exports.createSolanaRpcSubscriptionsApi_UNSTABLE = createSolanaRpcSubscriptionsApi_UNSTABLE;
6374
+ exports.createSolanaRpcSubscriptionsFromTransport = createSolanaRpcSubscriptionsFromTransport;
6375
+ exports.createSolanaRpcSubscriptionsFromTransport_UNSTABLE = createSolanaRpcSubscriptionsFromTransport_UNSTABLE;
6176
6376
  exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
6177
6377
  exports.createSubscriptionRpc = createSubscriptionRpc;
6178
6378
  exports.createTransaction = createTransaction;
@@ -6316,6 +6516,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
6316
6516
  exports.isAddress = isAddress;
6317
6517
  exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
6318
6518
  exports.isFixedSize = isFixedSize;
6519
+ exports.isInstructionForProgram = isInstructionForProgram;
6520
+ exports.isInstructionWithAccounts = isInstructionWithAccounts;
6521
+ exports.isInstructionWithData = isInstructionWithData;
6319
6522
  exports.isKeyPairSigner = isKeyPairSigner;
6320
6523
  exports.isLamports = isLamports;
6321
6524
  exports.isMessageModifyingSigner = isMessageModifyingSigner;