@solana/errors
Version:
Throw, identify, and decode Solana JavaScript errors
571 lines (562 loc) • 49.6 kB
JavaScript
import chalk from 'chalk';
import { Command, InvalidArgumentError } from 'commander';
// src/cli.ts
// package.json
var version = "2.1.0";
// src/context.ts
function decodeEncodedContext(encodedContext) {
const decodedUrlString = Buffer.from(encodedContext, "base64").toString("utf8") ;
return Object.fromEntries(new URLSearchParams(decodedUrlString).entries());
}
// src/codes.ts
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
var SOLANA_ERROR__INVALID_NONCE = 2;
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 3;
var SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE = 4;
var SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH = 5;
var SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE = 6;
var SOLANA_ERROR__MALFORMED_BIGINT_STRING = 7;
var SOLANA_ERROR__MALFORMED_NUMBER_STRING = 8;
var SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE = 9;
var SOLANA_ERROR__MALFORMED_JSON_RPC_ERROR = 10;
var SOLANA_ERROR__JSON_RPC__PARSE_ERROR = -32700;
var SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR = -32603;
var SOLANA_ERROR__JSON_RPC__INVALID_PARAMS = -32602;
var SOLANA_ERROR__JSON_RPC__METHOD_NOT_FOUND = -32601;
var SOLANA_ERROR__JSON_RPC__INVALID_REQUEST = -32600;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED = -32016;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION = -32015;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET = -32014;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH = -32013;
var SOLANA_ERROR__JSON_RPC__SCAN_ERROR = -32012;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE = -32011;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX = -32010;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED = -32009;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NO_SNAPSHOT = -32008;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED = -32007;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE = -32006;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY = -32005;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE = -32004;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE = -32003;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE = -32002;
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP = -32001;
var SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH = 28e5;
var SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE = 2800001;
var SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS = 2800002;
var SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY = 2800003;
var SOLANA_ERROR__ADDRESSES__MALFORMED_PDA = 2800004;
var SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE = 2800005;
var SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED = 2800006;
var SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED = 2800007;
var SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE = 2800008;
var SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED = 2800009;
var SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER = 2800010;
var SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND = 323e4;
var SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND = 32300001;
var SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT = 3230002;
var SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT = 3230003;
var SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED = 3230004;
var SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT = 361e4;
var SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED = 3610001;
var SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED = 3610002;
var SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED = 3610003;
var SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED = 3610004;
var SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED = 3610005;
var SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED = 3610006;
var SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = 3610007;
var SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED = 3611e3;
var SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH = 3704e3;
var SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704001;
var SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH = 3704002;
var SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE = 3704003;
var SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY = 3704004;
var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS = 4128e3;
var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA = 4128001;
var SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH = 4128002;
var SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN = 4615e3;
var SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR = 4615001;
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT = 4615002;
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA = 4615003;
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA = 4615004;
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL = 4615005;
var SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS = 4615006;
var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID = 4615007;
var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE = 4615008;
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED = 4615009;
var SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT = 4615010;
var SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION = 4615011;
var SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID = 4615012;
var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND = 4615013;
var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED = 4615014;
var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE = 4615015;
var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED = 4615016;
var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX = 4615017;
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED = 4615018;
var SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED = 4615019;
var SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 4615020;
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED = 4615021;
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE = 4615022;
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED = 4615023;
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 4615024;
var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC = 4615025;
var SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM = 4615026;
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR = 4615027;
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED = 4615028;
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE = 4615029;
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT = 4615030;
var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID = 4615031;
var SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH = 4615032;
var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT = 4615033;
var SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED = 4615034;
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4615035;
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS = 4615036;
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC = 4615037;
var SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED = 4615038;
var SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION = 4615039;
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE = 4615040;
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE = 4615041;
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE = 4615042;
var SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE = 4615043;
var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY = 4615044;
var SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR = 4615045;
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT = 4615046;
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER = 4615047;
var SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW = 4615048;
var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR = 4615049;
var SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER = 4615050;
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED = 4615051;
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED = 4615052;
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 4615053;
var SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 4615054;
var SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS = 5508e3;
var SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER = 5508001;
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER = 5508002;
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER = 5508003;
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER = 5508004;
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER = 5508005;
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER = 5508006;
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER = 5508007;
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER = 5508008;
var SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = 5508009;
var SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING = 5508010;
var SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED = 5508011;
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663e3;
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663001;
var SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = 5663002;
var SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME = 5663003;
var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE = 5663004;
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING = 5663005;
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE = 5663006;
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = 5663007;
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = 5663008;
var SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING = 5663009;
var SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING = 5663010;
var SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = 5663011;
var SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = 5663012;
var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING = 5663013;
var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = 5663014;
var SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION = 5663015;
var SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = 5663016;
var SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = 5663017;
var SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = 5663018;
var SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = 5663019;
var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND = 7050003;
var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE = 7050006;
var SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED = 7050007;
var SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND = 7050008;
var SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP = 7050009;
var SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE = 7050010;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX = 7050011;
var SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE = 7050012;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION = 7050013;
var SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE = 7050014;
var SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE = 7050015;
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 7050016;
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
var SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION = 7050018;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT = 7050019;
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
var SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS = 7050022;
var SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT = 7050027;
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
var SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION = 7050030;
var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
var SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
var SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED = 7050034;
var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
var SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION = 7050036;
var SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY = 8078e3;
var SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH = 8078001;
var SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH = 8078002;
var SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH = 8078003;
var SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH = 8078004;
var SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH = 8078005;
var SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH = 8078006;
var SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS = 8078007;
var SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE = 8078008;
var SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT = 8078009;
var SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT = 8078010;
var SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = 8078011;
var SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE = 8078012;
var SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH = 8078013;
var SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE = 8078014;
var SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT = 8078015;
var SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE = 8078016;
var SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE = 8078017;
var SOLANA_ERROR__CODECS__INVALID_CONSTANT = 8078018;
var SOLANA_ERROR__CODECS__EXPECTED_ZERO_VALUE_TO_MATCH_ITEM_FIXED_SIZE = 8078019;
var SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL = 8078020;
var SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES = 8078021;
var SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS = 8078022;
var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
var SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = 8100003;
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = 819e4;
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = 8190003;
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = 8190004;
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = 99e5;
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
var SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 9900002;
var SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = 9900003;
var SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = 9900004;
// src/messages.ts
var SolanaErrorMessages = {
[ ]: "Account not found at address: $address",
[ ]: "Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",
[ ]: "Expected decoded account at address: $address",
[ ]: "Failed to decode account data at address: $address",
[ ]: "Accounts not found at addresses: $addresses",
[ ]: "Unable to find a viable program address bump seed.",
[ ]: "$putativeAddress is not a base58-encoded address.",
[ ]: "Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",
[ ]: "The `CryptoKey` must be an `Ed25519` public key.",
[ ]: "Invalid seeds; point must fall off the Ed25519 curve.",
[ ]: "Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",
[ ]: "A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",
[ ]: "The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",
[ ]: "Expected program derived address bump to be in the range [0, 255], got: $bump.",
[ ]: "Program address cannot end with PDA marker.",
[ ]: "Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",
[ ]: "Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",
[ ]: "The network has progressed past the last block for which this transaction could have been committed.",
[ ]: "Codec [$codecDescription] cannot decode empty byte arrays.",
[ ]: "Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",
[ ]: "Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",
[ ]: "Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",
[ ]: "Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",
[ ]: "Encoder and decoder must either both be fixed-size or variable-size.",
[ ]: "Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",
[ ]: "Expected a fixed-size codec, got a variable-size one.",
[ ]: "Codec [$codecDescription] expected a positive byte length, got $bytesLength.",
[ ]: "Expected a variable-size codec, got a fixed-size one.",
[ ]: "Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",
[ ]: "Codec [$codecDescription] expected $expected bytes, got $bytesLength.",
[ ]: "Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",
[ ]: "Invalid discriminated union variant. Expected one of [$variants], got $value.",
[ ]: "Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",
[ ]: "Invalid literal union variant. Expected one of [$variants], got $value.",
[ ]: "Expected [$codecDescription] to have $expected items, got $actual.",
[ ]: "Invalid value $value for base $base with alphabet $alphabet.",
[ ]: "Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",
[ ]: "Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",
[ ]: "Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",
[ ]: "Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",
[ ]: "Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",
[ ]: "No random values implementation could be found.",
[ ]: "instruction requires an uninitialized account",
[ ]: "instruction tries to borrow reference for an account which is already borrowed",
[ ]: "instruction left account with an outstanding borrowed reference",
[ ]: "program other than the account's owner changed the size of the account data",
[ ]: "account data too small for instruction",
[ ]: "instruction expected an executable account",
[ ]: "An account does not have enough lamports to be rent-exempt",
[ ]: "Program arithmetic overflowed",
[ ]: "Failed to serialize or deserialize account data: $encodedData",
[ ]: "Builtin programs must consume compute units",
[ ]: "Cross-program invocation call depth too deep",
[ ]: "Computational budget exceeded",
[ ]: "custom program error: #$code",
[ ]: "instruction contains duplicate accounts",
[ ]: "instruction modifications of multiply-passed account differ",
[ ]: "executable accounts must be rent exempt",
[ ]: "instruction changed executable accounts data",
[ ]: "instruction changed the balance of an executable account",
[ ]: "instruction changed executable bit of an account",
[ ]: "instruction modified data of an account it does not own",
[ ]: "instruction spent from the balance of an account it does not own",
[ ]: "generic instruction error",
[ ]: "Provided owner is not allowed",
[ ]: "Account is immutable",
[ ]: "Incorrect authority provided",
[ ]: "incorrect program id for instruction",
[ ]: "insufficient funds for instruction",
[ ]: "invalid account data for instruction",
[ ]: "Invalid account owner",
[ ]: "invalid program argument",
[ ]: "program returned invalid error code",
[ ]: "invalid instruction data",
[ ]: "Failed to reallocate account data",
[ ]: "Provided seeds do not result in a valid address",
[ ]: "Accounts data allocations exceeded the maximum allowed per transaction",
[ ]: "Max accounts exceeded",
[ ]: "Max instruction trace length exceeded",
[ ]: "Length of the seed is too long for address generation",
[ ]: "An account required by the instruction is missing",
[ ]: "missing required signature for instruction",
[ ]: "instruction illegally modified the program id of an account",
[ ]: "insufficient account keys for instruction",
[ ]: "Cross-program invocation with unauthorized signer or writable account",
[ ]: "Failed to create program execution environment",
[ ]: "Program failed to compile",
[ ]: "Program failed to complete",
[ ]: "instruction modified data of a read-only account",
[ ]: "instruction changed the balance of a read-only account",
[ ]: "Cross-program invocation reentrancy not allowed for this instruction",
[ ]: "instruction modified rent epoch of an account",
[ ]: "sum of account balances before and after instruction do not match",
[ ]: "instruction requires an initialized account",
[ ]: "",
[ ]: "Unsupported program id",
[ ]: "Unsupported sysvar",
[ ]: "The instruction does not have any accounts.",
[ ]: "The instruction does not have any data.",
[ ]: "Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",
[ ]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
[ ]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
[ ]: "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",
[ ]: "Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",
[ ]: "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",
[ ]: "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",
[ ]: "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",
[ ]: "JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",
[ ]: "JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",
[ ]: "JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",
[ ]: "JSON-RPC error: The method does not exist / is not available ($__serverMessage)",
[ ]: "JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",
[ ]: "$__serverMessage",
[ ]: "$__serverMessage",
[ ]: "$__serverMessage",
[ ]: "$__serverMessage",
[ ]: "$__serverMessage",
[ ]: "$__serverMessage",
[ ]: "Minimum context slot has not been reached",
[ ]: "Node is unhealthy; behind by $numSlotsBehind slots",
[ ]: "No snapshot",
[ ]: "Transaction simulation failed",
[ ]: "$__serverMessage",
[ ]: "Transaction history is not available from this node",
[ ]: "$__serverMessage",
[ ]: "Transaction signature length mismatch",
[ ]: "Transaction signature verification failure",
[ ]: "$__serverMessage",
[ ]: "Key pair bytes must be of length 64, got $byteLength.",
[ ]: "Expected private key bytes with length 32. Actual length: $actualLength.",
[ ]: "Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",
[ ]: "The provided private key does not match the provided public key.",
[ ]: "Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",
[ ]: "Lamports value must be in the range [0, 2e64-1]",
[ ]: "`$value` cannot be parsed as a `BigInt`",
[ ]: "$message",
[ ]: "`$value` cannot be parsed as a `Number`",
[ ]: "No nonce account could be found at address `$nonceAccountAddress`",
[ ]: "The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",
[ ]: "WebSocket was closed before payload could be added to the send buffer",
[ ]: "WebSocket connection closed",
[ ]: "WebSocket failed to connect",
[ ]: "Failed to obtain a subscription id from the server",
[ ]: "Could not find an API plan for RPC method: `$method`",
[ ]: "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`.",
[ ]: "HTTP error ($statusCode): $message",
[ ]: "HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",
[ ]: "Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",
[ ]: "The provided value does not implement the `KeyPairSigner` interface",
[ ]: "The provided value does not implement the `MessageModifyingSigner` interface",
[ ]: "The provided value does not implement the `MessagePartialSigner` interface",
[ ]: "The provided value does not implement any of the `MessageSigner` interfaces",
[ ]: "The provided value does not implement the `TransactionModifyingSigner` interface",
[ ]: "The provided value does not implement the `TransactionPartialSigner` interface",
[ ]: "The provided value does not implement the `TransactionSendingSigner` interface",
[ ]: "The provided value does not implement any of the `TransactionSigner` interfaces",
[ ]: "More than one `TransactionSendingSigner` was identified.",
[ ]: "No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",
[ ]: "Wallet account signers do not support signing multiple messages/transactions in a single operation",
[ ]: "Cannot export a non-extractable key.",
[ ]: "No digest implementation could be found.",
[ ]: "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",
[ ]: "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall @solana/webcrypto-ed25519-polyfill and call its `install` function 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.",
[ ]: "No signature verification implementation could be found.",
[ ]: "No key generation implementation could be found.",
[ ]: "No signing implementation could be found.",
[ ]: "No key export implementation could be found.",
[ ]: "Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",
[ ]: "Transaction processing left an account with an outstanding borrowed reference",
[ ]: "Account in use",
[ ]: "Account loaded twice",
[ ]: "Attempt to debit an account but found no record of a prior credit.",
[ ]: "Transaction loads an address table account that doesn't exist",
[ ]: "This transaction has already been processed",
[ ]: "Blockhash not found",
[ ]: "Loader call chain is too deep",
[ ]: "Transactions are currently disabled due to cluster maintenance",
[ ]: "Transaction contains a duplicate instruction ($index) that is not allowed",
[ ]: "Insufficient funds for fee",
[ ]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
[ ]: "This account may not be used to pay transaction fees",
[ ]: "Transaction contains an invalid account reference",
[ ]: "Transaction loads an address table account with invalid data",
[ ]: "Transaction address table lookup uses an invalid index",
[ ]: "Transaction loads an address table account with an invalid owner",
[ ]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
[ ]: "This program may not be used for executing instructions",
[ ]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
[ ]: "Transaction loads a writable account that cannot be written",
[ ]: "Transaction exceeded max loaded accounts data size cap",
[ ]: "Transaction requires a fee but has no signature present",
[ ]: "Attempt to load a program that does not exist",
[ ]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
[ ]: "ResanitizationNeeded",
[ ]: "Transaction failed to sanitize accounts offsets correctly",
[ ]: "Transaction did not pass signature verification",
[ ]: "Transaction locked too many accounts",
[ ]: "Sum of account balances before and after transaction do not match",
[ ]: "The transaction failed with the error `$errorName`",
[ ]: "Transaction version is unsupported",
[ ]: "Transaction would exceed account data limit within the block",
[ ]: "Transaction would exceed total account data limit",
[ ]: "Transaction would exceed max account limit within the block",
[ ]: "Transaction would exceed max Block Cost Limit",
[ ]: "Transaction would exceed max Vote Cost Limit",
[ ]: "Attempted to sign a transaction with an address that is not a signer for it",
[ ]: "Transaction is missing an address at index: $index.",
[ ]: "Transaction has no expected signers therefore it cannot be encoded",
[ ]: "Transaction does not have a blockhash lifetime",
[ ]: "Transaction is not a durable nonce transaction",
[ ]: "Contents of these address lookup tables unknown: $lookupTableAddresses",
[ ]: "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",
[ ]: "No fee payer set in CompiledTransaction",
[ ]: "Could not find program address at index $index",
[ ]: "Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",
[ ]: "Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",
[ ]: "Transaction is missing a fee payer.",
[ ]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",
[ ]: "Transaction first instruction is not advance nonce account instruction.",
[ ]: "Transaction with no instructions cannot be durable nonce transaction.",
[ ]: "This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",
[ ]: "This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",
[ ]: "The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",
[ ]: "Transaction is missing signatures for addresses: $addresses.",
[ ]: "Transaction version must be in the range [0, 127]. `$actualVersion` given"
};
// src/message-formatter.ts
var START_INDEX = "i";
var TYPE = "t";
function getHumanReadableErrorMessage(code, context = {}) {
const messageFormatString = SolanaErrorMessages[code];
if (messageFormatString.length === 0) {
return "";
}
let state;
function commitStateUpTo(endIndex) {
if (state[TYPE] === 2 /* Variable */) {
const variableName = messageFormatString.slice(state[START_INDEX] + 1, endIndex);
fragments.push(
variableName in context ? (
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${context[variableName]}`
) : `$${variableName}`
);
} else if (state[TYPE] === 1 /* Text */) {
fragments.push(messageFormatString.slice(state[START_INDEX], endIndex));
}
}
const fragments = [];
messageFormatString.split("").forEach((char, ii) => {
if (ii === 0) {
state = {
[ ]: 0,
[ ]: messageFormatString[0] === "\\" ? 0 /* EscapeSequence */ : messageFormatString[0] === "$" ? 2 /* Variable */ : 1 /* Text */
};
return;
}
let nextState;
switch (state[TYPE]) {
case 0 /* EscapeSequence */:
nextState = { [START_INDEX]: ii, [TYPE]: 1 /* Text */ };
break;
case 1 /* Text */:
if (char === "\\") {
nextState = { [START_INDEX]: ii, [TYPE]: 0 /* EscapeSequence */ };
} else if (char === "$") {
nextState = { [START_INDEX]: ii, [TYPE]: 2 /* Variable */ };
}
break;
case 2 /* Variable */:
if (char === "\\") {
nextState = { [START_INDEX]: ii, [TYPE]: 0 /* EscapeSequence */ };
} else if (char === "$") {
nextState = { [START_INDEX]: ii, [TYPE]: 2 /* Variable */ };
} else if (!char.match(/\w/)) {
nextState = { [START_INDEX]: ii, [TYPE]: 1 /* Text */ };
}
break;
}
if (nextState) {
if (state !== nextState) {
commitStateUpTo(ii);
}
state = nextState;
}
});
commitStateUpTo();
return fragments.join("");
}
// src/cli.ts
var program = new Command();
program.name("@solana/errors").description("Decode Solana JavaScript errors thrown in production").version(version);
program.command("decode").description("Decode a `SolanaErrorCode` to a human-readable message").argument("<code>", "numeric error code to decode", (rawCode) => {
const code = parseInt(rawCode, 10);
if (isNaN(code) || `${code}` !== rawCode) {
throw new InvalidArgumentError("It must be an integer");
}
if (!(code in SolanaErrorMessages)) {
throw new InvalidArgumentError("There exists no error with that code");
}
return code;
}).argument("[encodedContext]", "encoded context to interpolate into the error message", (encodedContext) => {
try {
return decodeEncodedContext(encodedContext);
} catch {
throw new InvalidArgumentError("Encoded context malformed");
}
}).action((code, context) => {
const message = getHumanReadableErrorMessage(code, context);
console.log(`
${chalk.bold(
chalk.rgb(154, 71, 255)("[") + chalk.rgb(144, 108, 244)("D") + chalk.rgb(134, 135, 233)("e") + chalk.rgb(122, 158, 221)("c") + chalk.rgb(110, 178, 209)("o") + chalk.rgb(95, 195, 196)("d") + chalk.rgb(79, 212, 181)("e") + chalk.rgb(57, 227, 166)("d") + chalk.rgb(19, 241, 149)("]")
) + chalk.rgb(19, 241, 149)(" Solana error code #" + code)}
- ${message}`);
if (context) {
console.log(`
${chalk.yellowBright(chalk.bold("[Context]"))}
${JSON.stringify(context, null, 4).split("\n").join("\n ")}`);
}
});
function run(argv) {
program.parse(argv);
}
export { run };