@solana/errors
Advanced tools
Comparing version 2.0.0-experimental.6cea83c to 2.0.0-experimental.8541c2e
@@ -7,6 +7,90 @@ // ../build-scripts/env-shim.ts | ||
var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2; | ||
var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3; | ||
var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4; | ||
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5; | ||
var SOLANA_ERROR__NONCE_INVALID = 6; | ||
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7; | ||
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; | ||
// src/messages.ts | ||
var SolanaErrorMessages = { | ||
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses", | ||
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.", | ||
[SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.", | ||
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`", | ||
[SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`", | ||
[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`.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: "Account in use", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: "Account loaded twice", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED]: "This transaction has already been processed", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND]: "Blockhash not found", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED]: "ResanitizationNeeded", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE]: "Transaction did not pass signature verification", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: "The transaction failed with the error `$errorName`", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION]: "Transaction version is unsupported", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit", | ||
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.", | ||
[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." | ||
@@ -33,3 +117,3 @@ }; | ||
String( | ||
Object.getPrototypeOf(value) === null ? ( | ||
value != null && Object.getPrototypeOf(value) === null ? ( | ||
// Plain objects with no protoype don't have a `toString` method. | ||
@@ -93,4 +177,99 @@ // Convert them before stringifying them. | ||
export { SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError }; | ||
// src/transaction-error.ts | ||
var ORDERED_ERROR_NAMES = [ | ||
// Keep synced with RPC source: https://github.com/anza-xyz/agave/blob/master/sdk/src/transaction/error.rs | ||
// If this list ever gets too large, consider implementing a compression strategy like this: | ||
// https://gist.github.com/steveluscher/aaa7cbbb5433b1197983908a40860c47 | ||
"AccountInUse", | ||
"AccountLoadedTwice", | ||
"AccountNotFound", | ||
"ProgramAccountNotFound", | ||
"InsufficientFundsForFee", | ||
"InvalidAccountForFee", | ||
"AlreadyProcessed", | ||
"BlockhashNotFound", | ||
// `InstructionError` intentionally omitted | ||
"CallChainTooDeep", | ||
"MissingSignatureForFee", | ||
"InvalidAccountIndex", | ||
"SignatureFailure", | ||
"InvalidProgramForExecution", | ||
"SanitizeFailure", | ||
"ClusterMaintenance", | ||
"AccountBorrowOutstanding", | ||
"WouldExceedMaxBlockCostLimit", | ||
"UnsupportedVersion", | ||
"InvalidWritableAccount", | ||
"WouldExceedMaxAccountCostLimit", | ||
"WouldExceedAccountDataBlockLimit", | ||
"TooManyAccountLocks", | ||
"AddressLookupTableNotFound", | ||
"InvalidAddressLookupTableOwner", | ||
"InvalidAddressLookupTableData", | ||
"InvalidAddressLookupTableIndex", | ||
"InvalidRentPayingAccount", | ||
"WouldExceedMaxVoteCostLimit", | ||
"WouldExceedAccountDataTotalLimit", | ||
"DuplicateInstruction", | ||
"InsufficientFundsForRent", | ||
"MaxLoadedAccountsDataSizeExceeded", | ||
"InvalidLoadedAccountsDataSizeLimit", | ||
"ResanitizationNeeded", | ||
"ProgramExecutionTemporarilyRestricted", | ||
"UnbalancedTransaction" | ||
]; | ||
function getSolanaErrorFromTransactionError(transactionError) { | ||
let errorName; | ||
let transactionErrorContext; | ||
if (typeof transactionError === "string") { | ||
errorName = transactionError; | ||
} else { | ||
errorName = Object.keys(transactionError)[0]; | ||
transactionErrorContext = transactionError[errorName]; | ||
} | ||
const codeOffset = ORDERED_ERROR_NAMES.indexOf(errorName); | ||
const errorCode = ( | ||
/** | ||
* Oh, hello. You might wonder what in tarnation is going on here. Allow us to explain. | ||
* | ||
* One of the goals of `@solana/errors` is to allow errors that are not interesting to your | ||
* application to shake out of your app bundle in production. This means that we must never | ||
* export large hardcoded maps of error codes/messages. | ||
* | ||
* Unfortunately, where transaction errors from the RPC are concerned, we have no choice but | ||
* to keep a map between the RPC `TransactionError` enum name and its corresponding | ||
* `SolanaError` code. In the interest of implementing that map in as few bytes of source | ||
* code as possible, we do the following: | ||
* | ||
* 1. Reserve sequential error codes for `TransactionError` in the range [7050000-7050999] | ||
* 2. Hardcode the list of `TransactionError` enum names in that same order | ||
* 3. Match the transaction error name from the RPC with its index in that list, and | ||
* reconstruct the `SolanaError` code by adding 7050001 to that index | ||
*/ | ||
7050001 + codeOffset | ||
); | ||
let errorContext; | ||
if (codeOffset === -1) { | ||
errorContext = { | ||
errorName, | ||
...transactionErrorContext !== void 0 ? { transactionErrorContext } : null | ||
}; | ||
} else if (codeOffset === 29) { | ||
errorContext = { | ||
index: transactionErrorContext | ||
}; | ||
} else if (codeOffset === 30 || codeOffset === 34) { | ||
errorContext = { | ||
accountIndex: transactionErrorContext.account_index | ||
}; | ||
} | ||
const err = new SolanaError(errorCode, errorContext); | ||
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") { | ||
Error.captureStackTrace(err, getSolanaErrorFromTransactionError); | ||
} | ||
return err; | ||
} | ||
export { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED, SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP, SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE, SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION, SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT, SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED, SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED, SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED, SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE, SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE, SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS, SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION, SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN, SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, getSolanaErrorFromTransactionError, isSolanaError }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.browser.js.map |
@@ -7,6 +7,90 @@ // ../build-scripts/env-shim.ts | ||
var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2; | ||
var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3; | ||
var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4; | ||
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5; | ||
var SOLANA_ERROR__NONCE_INVALID = 6; | ||
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7; | ||
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; | ||
// src/messages.ts | ||
var SolanaErrorMessages = { | ||
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses", | ||
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.", | ||
[SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.", | ||
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`", | ||
[SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`", | ||
[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`.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: "Account in use", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: "Account loaded twice", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED]: "This transaction has already been processed", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND]: "Blockhash not found", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED]: "ResanitizationNeeded", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE]: "Transaction did not pass signature verification", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: "The transaction failed with the error `$errorName`", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION]: "Transaction version is unsupported", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit", | ||
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.", | ||
[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." | ||
@@ -33,3 +117,3 @@ }; | ||
String( | ||
Object.getPrototypeOf(value) === null ? ( | ||
value != null && Object.getPrototypeOf(value) === null ? ( | ||
// Plain objects with no protoype don't have a `toString` method. | ||
@@ -93,4 +177,99 @@ // Convert them before stringifying them. | ||
export { SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError }; | ||
// src/transaction-error.ts | ||
var ORDERED_ERROR_NAMES = [ | ||
// Keep synced with RPC source: https://github.com/anza-xyz/agave/blob/master/sdk/src/transaction/error.rs | ||
// If this list ever gets too large, consider implementing a compression strategy like this: | ||
// https://gist.github.com/steveluscher/aaa7cbbb5433b1197983908a40860c47 | ||
"AccountInUse", | ||
"AccountLoadedTwice", | ||
"AccountNotFound", | ||
"ProgramAccountNotFound", | ||
"InsufficientFundsForFee", | ||
"InvalidAccountForFee", | ||
"AlreadyProcessed", | ||
"BlockhashNotFound", | ||
// `InstructionError` intentionally omitted | ||
"CallChainTooDeep", | ||
"MissingSignatureForFee", | ||
"InvalidAccountIndex", | ||
"SignatureFailure", | ||
"InvalidProgramForExecution", | ||
"SanitizeFailure", | ||
"ClusterMaintenance", | ||
"AccountBorrowOutstanding", | ||
"WouldExceedMaxBlockCostLimit", | ||
"UnsupportedVersion", | ||
"InvalidWritableAccount", | ||
"WouldExceedMaxAccountCostLimit", | ||
"WouldExceedAccountDataBlockLimit", | ||
"TooManyAccountLocks", | ||
"AddressLookupTableNotFound", | ||
"InvalidAddressLookupTableOwner", | ||
"InvalidAddressLookupTableData", | ||
"InvalidAddressLookupTableIndex", | ||
"InvalidRentPayingAccount", | ||
"WouldExceedMaxVoteCostLimit", | ||
"WouldExceedAccountDataTotalLimit", | ||
"DuplicateInstruction", | ||
"InsufficientFundsForRent", | ||
"MaxLoadedAccountsDataSizeExceeded", | ||
"InvalidLoadedAccountsDataSizeLimit", | ||
"ResanitizationNeeded", | ||
"ProgramExecutionTemporarilyRestricted", | ||
"UnbalancedTransaction" | ||
]; | ||
function getSolanaErrorFromTransactionError(transactionError) { | ||
let errorName; | ||
let transactionErrorContext; | ||
if (typeof transactionError === "string") { | ||
errorName = transactionError; | ||
} else { | ||
errorName = Object.keys(transactionError)[0]; | ||
transactionErrorContext = transactionError[errorName]; | ||
} | ||
const codeOffset = ORDERED_ERROR_NAMES.indexOf(errorName); | ||
const errorCode = ( | ||
/** | ||
* Oh, hello. You might wonder what in tarnation is going on here. Allow us to explain. | ||
* | ||
* One of the goals of `@solana/errors` is to allow errors that are not interesting to your | ||
* application to shake out of your app bundle in production. This means that we must never | ||
* export large hardcoded maps of error codes/messages. | ||
* | ||
* Unfortunately, where transaction errors from the RPC are concerned, we have no choice but | ||
* to keep a map between the RPC `TransactionError` enum name and its corresponding | ||
* `SolanaError` code. In the interest of implementing that map in as few bytes of source | ||
* code as possible, we do the following: | ||
* | ||
* 1. Reserve sequential error codes for `TransactionError` in the range [7050000-7050999] | ||
* 2. Hardcode the list of `TransactionError` enum names in that same order | ||
* 3. Match the transaction error name from the RPC with its index in that list, and | ||
* reconstruct the `SolanaError` code by adding 7050001 to that index | ||
*/ | ||
7050001 + codeOffset | ||
); | ||
let errorContext; | ||
if (codeOffset === -1) { | ||
errorContext = { | ||
errorName, | ||
...transactionErrorContext !== void 0 ? { transactionErrorContext } : null | ||
}; | ||
} else if (codeOffset === 29) { | ||
errorContext = { | ||
index: transactionErrorContext | ||
}; | ||
} else if (codeOffset === 30 || codeOffset === 34) { | ||
errorContext = { | ||
accountIndex: transactionErrorContext.account_index | ||
}; | ||
} | ||
const err = new SolanaError(errorCode, errorContext); | ||
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") { | ||
Error.captureStackTrace(err, getSolanaErrorFromTransactionError); | ||
} | ||
return err; | ||
} | ||
export { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED, SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP, SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE, SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION, SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT, SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED, SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED, SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED, SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE, SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE, SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS, SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION, SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN, SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, getSolanaErrorFromTransactionError, isSolanaError }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
@@ -7,6 +7,90 @@ // ../build-scripts/env-shim.ts | ||
var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2; | ||
var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3; | ||
var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4; | ||
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5; | ||
var SOLANA_ERROR__NONCE_INVALID = 6; | ||
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7; | ||
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; | ||
// src/messages.ts | ||
var SolanaErrorMessages = { | ||
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses", | ||
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.", | ||
[SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.", | ||
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`", | ||
[SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`", | ||
[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`.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: "Account in use", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: "Account loaded twice", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED]: "This transaction has already been processed", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND]: "Blockhash not found", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED]: "ResanitizationNeeded", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE]: "Transaction did not pass signature verification", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: "The transaction failed with the error `$errorName`", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION]: "Transaction version is unsupported", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit", | ||
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit", | ||
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.", | ||
[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." | ||
@@ -33,3 +117,3 @@ }; | ||
String( | ||
Object.getPrototypeOf(value) === null ? ( | ||
value != null && Object.getPrototypeOf(value) === null ? ( | ||
// Plain objects with no protoype don't have a `toString` method. | ||
@@ -93,4 +177,99 @@ // Convert them before stringifying them. | ||
export { SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, isSolanaError }; | ||
// src/transaction-error.ts | ||
var ORDERED_ERROR_NAMES = [ | ||
// Keep synced with RPC source: https://github.com/anza-xyz/agave/blob/master/sdk/src/transaction/error.rs | ||
// If this list ever gets too large, consider implementing a compression strategy like this: | ||
// https://gist.github.com/steveluscher/aaa7cbbb5433b1197983908a40860c47 | ||
"AccountInUse", | ||
"AccountLoadedTwice", | ||
"AccountNotFound", | ||
"ProgramAccountNotFound", | ||
"InsufficientFundsForFee", | ||
"InvalidAccountForFee", | ||
"AlreadyProcessed", | ||
"BlockhashNotFound", | ||
// `InstructionError` intentionally omitted | ||
"CallChainTooDeep", | ||
"MissingSignatureForFee", | ||
"InvalidAccountIndex", | ||
"SignatureFailure", | ||
"InvalidProgramForExecution", | ||
"SanitizeFailure", | ||
"ClusterMaintenance", | ||
"AccountBorrowOutstanding", | ||
"WouldExceedMaxBlockCostLimit", | ||
"UnsupportedVersion", | ||
"InvalidWritableAccount", | ||
"WouldExceedMaxAccountCostLimit", | ||
"WouldExceedAccountDataBlockLimit", | ||
"TooManyAccountLocks", | ||
"AddressLookupTableNotFound", | ||
"InvalidAddressLookupTableOwner", | ||
"InvalidAddressLookupTableData", | ||
"InvalidAddressLookupTableIndex", | ||
"InvalidRentPayingAccount", | ||
"WouldExceedMaxVoteCostLimit", | ||
"WouldExceedAccountDataTotalLimit", | ||
"DuplicateInstruction", | ||
"InsufficientFundsForRent", | ||
"MaxLoadedAccountsDataSizeExceeded", | ||
"InvalidLoadedAccountsDataSizeLimit", | ||
"ResanitizationNeeded", | ||
"ProgramExecutionTemporarilyRestricted", | ||
"UnbalancedTransaction" | ||
]; | ||
function getSolanaErrorFromTransactionError(transactionError) { | ||
let errorName; | ||
let transactionErrorContext; | ||
if (typeof transactionError === "string") { | ||
errorName = transactionError; | ||
} else { | ||
errorName = Object.keys(transactionError)[0]; | ||
transactionErrorContext = transactionError[errorName]; | ||
} | ||
const codeOffset = ORDERED_ERROR_NAMES.indexOf(errorName); | ||
const errorCode = ( | ||
/** | ||
* Oh, hello. You might wonder what in tarnation is going on here. Allow us to explain. | ||
* | ||
* One of the goals of `@solana/errors` is to allow errors that are not interesting to your | ||
* application to shake out of your app bundle in production. This means that we must never | ||
* export large hardcoded maps of error codes/messages. | ||
* | ||
* Unfortunately, where transaction errors from the RPC are concerned, we have no choice but | ||
* to keep a map between the RPC `TransactionError` enum name and its corresponding | ||
* `SolanaError` code. In the interest of implementing that map in as few bytes of source | ||
* code as possible, we do the following: | ||
* | ||
* 1. Reserve sequential error codes for `TransactionError` in the range [7050000-7050999] | ||
* 2. Hardcode the list of `TransactionError` enum names in that same order | ||
* 3. Match the transaction error name from the RPC with its index in that list, and | ||
* reconstruct the `SolanaError` code by adding 7050001 to that index | ||
*/ | ||
7050001 + codeOffset | ||
); | ||
let errorContext; | ||
if (codeOffset === -1) { | ||
errorContext = { | ||
errorName, | ||
...transactionErrorContext !== void 0 ? { transactionErrorContext } : null | ||
}; | ||
} else if (codeOffset === 29) { | ||
errorContext = { | ||
index: transactionErrorContext | ||
}; | ||
} else if (codeOffset === 30 || codeOffset === 34) { | ||
errorContext = { | ||
accountIndex: transactionErrorContext.account_index | ||
}; | ||
} | ||
const err = new SolanaError(errorCode, errorContext); | ||
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") { | ||
Error.captureStackTrace(err, getSolanaErrorFromTransactionError); | ||
} | ||
return err; | ||
} | ||
export { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE, SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED, SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP, SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE, SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION, SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT, SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT, SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED, SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE, SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND, SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED, SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED, SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE, SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE, SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS, SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION, SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN, SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT, SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE, SolanaError, getSolanaErrorFromTransactionError, isSolanaError }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
/** | ||
* To add a new error, follow the instructions at | ||
* https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error | ||
* https://github.com/solana-labs/solana-web3.js/tree/master/packages/errors/#adding-a-new-error | ||
* | ||
@@ -11,2 +11,44 @@ * WARNING: | ||
export declare const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE: 2; | ||
export declare const SOLANA_ERROR__RPC_INTEGER_OVERFLOW: 3; | ||
export declare const SOLANA_ERROR__INVALID_KEYPAIR_BYTES: 4; | ||
export declare const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED: 5; | ||
export declare const SOLANA_ERROR__NONCE_INVALID: 6; | ||
export declare const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND: 7; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN: 7050000; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE: 7050001; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE: 7050002; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND: 7050003; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND: 7050004; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE: 7050005; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE: 7050006; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED: 7050007; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND: 7050008; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP: 7050009; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE: 7050010; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX: 7050011; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE: 7050012; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION: 7050013; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE: 7050014; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE: 7050015; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING: 7050016; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT: 7050017; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION: 7050018; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT: 7050019; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT: 7050020; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT: 7050021; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS: 7050022; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND: 7050023; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER: 7050024; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA: 7050025; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX: 7050026; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT: 7050027; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT: 7050028; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT: 7050029; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION: 7050030; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT: 7050031; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED: 7050032; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT: 7050033; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED: 7050034; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED: 7050035; | ||
export declare const SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION: 7050036; | ||
/** | ||
@@ -27,3 +69,3 @@ * A union of every Solana error code | ||
*/ | ||
export type SolanaErrorCode = typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE; | ||
export type SolanaErrorCode = typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED | typeof SOLANA_ERROR__NONCE_INVALID | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND | typeof SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND | typeof SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND | typeof SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE | typeof SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED | typeof SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND | typeof SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP | typeof SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX | typeof SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION | typeof SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE | typeof SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS | typeof SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION | typeof SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT | typeof SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT | typeof SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED | typeof SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED | typeof SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION; | ||
//# sourceMappingURL=codes.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SolanaErrorCode } from './codes.js'; | ||
import { SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, SOLANA_ERROR__INVALID_KEYPAIR_BYTES, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND, SOLANA_ERROR__NONCE_INVALID, SOLANA_ERROR__RPC_INTEGER_OVERFLOW, SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION, SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT, SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED, SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN, SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES, SolanaErrorCode } from './codes.js'; | ||
export type DefaultUnspecifiedErrorContextToUndefined<T> = { | ||
@@ -7,3 +7,3 @@ [P in SolanaErrorCode]: P extends keyof T ? T[P] : undefined; | ||
* To add a new error, follow the instructions at | ||
* https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error | ||
* https://github.com/solana-labs/solana-web3.js/tree/master/packages/errors/#adding-a-new-error | ||
* | ||
@@ -14,6 +14,41 @@ * WARNING: | ||
export type SolanaErrorContext = DefaultUnspecifiedErrorContextToUndefined<{ | ||
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: { | ||
currentBlockHeight: bigint; | ||
lastValidBlockHeight: bigint; | ||
}; | ||
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: { | ||
addresses: string[]; | ||
}; | ||
[SOLANA_ERROR__RPC_INTEGER_OVERFLOW]: { | ||
argumentLabel: string; | ||
keyPath: readonly (string | number | symbol)[]; | ||
methodName: string; | ||
optionalPathLabel: string; | ||
path?: string; | ||
value: bigint; | ||
}; | ||
[SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: { | ||
byteLength: number; | ||
}; | ||
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: { | ||
nonceAccountAddress: string; | ||
}; | ||
[SOLANA_ERROR__NONCE_INVALID]: { | ||
actualNonceValue: string; | ||
expectedNonceValue: string; | ||
}; | ||
[SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: { | ||
errorName: string; | ||
transactionErrorContext?: unknown; | ||
}; | ||
[SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]: { | ||
index: number; | ||
}; | ||
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]: { | ||
accountIndex: number; | ||
}; | ||
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: { | ||
accountIndex: number; | ||
}; | ||
}>; | ||
//# sourceMappingURL=context.d.ts.map |
export * from './codes.js'; | ||
export * from './error.js'; | ||
export * from './transaction-error.js'; | ||
//# sourceMappingURL=index.d.ts.map |
import { SolanaErrorCode } from './codes.js'; | ||
/** | ||
* To add a new error, follow the instructions at | ||
* https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error | ||
* https://github.com/solana-labs/solana-web3.js/tree/master/packages/errors#adding-a-new-error | ||
* | ||
@@ -6,0 +6,0 @@ * WARNING: |
173
package.json
{ | ||
"name": "@solana/errors", | ||
"version": "2.0.0-experimental.6cea83c", | ||
"description": "Throw, identify, and decode Solana JavaScript errors", | ||
"exports": { | ||
"browser": { | ||
"import": "./dist/index.browser.js", | ||
"require": "./dist/index.browser.cjs" | ||
}, | ||
"node": { | ||
"import": "./dist/index.node.js", | ||
"require": "./dist/index.node.cjs" | ||
}, | ||
"react-native": "./dist/index.native.js", | ||
"types": "./dist/types/index.d.ts" | ||
}, | ||
"name": "@solana/errors", | ||
"version": "2.0.0-experimental.8541c2e", | ||
"description": "Throw, identify, and decode Solana JavaScript errors", | ||
"exports": { | ||
"browser": { | ||
"./dist/index.node.cjs": "./dist/index.browser.cjs", | ||
"./dist/index.node.js": "./dist/index.browser.js" | ||
"import": "./dist/index.browser.js", | ||
"require": "./dist/index.browser.cjs" | ||
}, | ||
"main": "./dist/index.node.cjs", | ||
"module": "./dist/index.node.js", | ||
"node": { | ||
"import": "./dist/index.node.js", | ||
"require": "./dist/index.node.cjs" | ||
}, | ||
"react-native": "./dist/index.native.js", | ||
"types": "./dist/types/index.d.ts", | ||
"type": "module", | ||
"types": "./dist/types/index.d.ts" | ||
}, | ||
"browser": { | ||
"./dist/index.node.cjs": "./dist/index.browser.cjs", | ||
"./dist/index.node.js": "./dist/index.browser.js" | ||
}, | ||
"main": "./dist/index.node.cjs", | ||
"module": "./dist/index.node.js", | ||
"react-native": "./dist/index.native.js", | ||
"types": "./dist/types/index.d.ts", | ||
"type": "module", | ||
"files": [ | ||
"./dist/" | ||
], | ||
"sideEffects": false, | ||
"keywords": [ | ||
"blockchain", | ||
"solana", | ||
"web3" | ||
], | ||
"bin": "./bin/cli.js", | ||
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/solana-labs/solana-web3.js" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/solana-labs/solana-web3.js/issues" | ||
}, | ||
"browserslist": [ | ||
"supports bigint and not dead", | ||
"maintained node versions" | ||
], | ||
"engine": { | ||
"node": ">=17.4" | ||
}, | ||
"dependencies": { | ||
"chalk": "^5.3.0", | ||
"commander": "^12.0.0" | ||
}, | ||
"bundlewatch": { | ||
"defaultCompression": "gzip", | ||
"files": [ | ||
"./dist/" | ||
], | ||
"sideEffects": false, | ||
"keywords": [ | ||
"blockchain", | ||
"solana", | ||
"web3" | ||
], | ||
"bin": "./bin/cli.ts", | ||
"scripts": { | ||
"compile:js": "tsup --config build-scripts/tsup.config.package.ts", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs", | ||
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"prepublishOnly": "version-from-git --no-git-tag-version --template experimental.short", | ||
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json", | ||
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:treeshakability:browser": "agadoo dist/index.browser.js", | ||
"test:treeshakability:native": "agadoo dist/index.native.js", | ||
"test:treeshakability:node": "agadoo dist/index.node.js", | ||
"test:typecheck": "tsc --noEmit", | ||
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
}, | ||
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/solana-labs/solana-web3.js" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/solana-labs/solana-web3.js/issues" | ||
}, | ||
"browserslist": [ | ||
"supports bigint and not dead", | ||
"maintained node versions" | ||
], | ||
"engine": { | ||
"node": ">=17.4" | ||
}, | ||
"devDependencies": { | ||
"@solana/addresses": "2.0.0-experimental.b93299a", | ||
"@solana/eslint-config-solana": "^1.0.2", | ||
"@swc/jest": "^0.2.29", | ||
"@types/jest": "^29.5.11", | ||
"@types/node": "18.11.19", | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"agadoo": "^3.0.0", | ||
"build-scripts": "0.0.0", | ||
"chalk": "^5.3.0", | ||
"commander": "^11.1.0", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-jest": "^27.4.2", | ||
"eslint-plugin-sort-keys-fix": "^1.1.2", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-runner-eslint": "^2.1.2", | ||
"jest-runner-prettier": "^1.0.0", | ||
"prettier": "^3.1", | ||
"test-config": "0.0.0", | ||
"tsconfig": "0.0.0", | ||
"tsup": "^8.0.1", | ||
"tsx": "^4.7.0", | ||
"typescript": "^5.2.2", | ||
"version-from-git": "^1.1.1" | ||
}, | ||
"bundlewatch": { | ||
"defaultCompression": "gzip", | ||
"files": [ | ||
{ | ||
"path": "./dist/index*.js" | ||
} | ||
] | ||
} | ||
} | ||
{ | ||
"path": "./dist/index*.js" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"compile:js": "tsup --config build-scripts/tsup.config.package.ts && tsup src/cli.ts --format esm", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/@solana/build-scripts/add-js-extension-to-types.mjs", | ||
"dev": "jest -c node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag experimental --access public --no-git-checks", | ||
"publish-packages": "pnpm prepublishOnly && pnpm publish-impl", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json", | ||
"test:lint": "jest -c node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "jest -c node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:treeshakability:browser": "agadoo dist/index.browser.js", | ||
"test:treeshakability:native": "agadoo dist/index.native.js", | ||
"test:treeshakability:node": "agadoo dist/index.node.js", | ||
"test:typecheck": "tsc --noEmit", | ||
"test:unit:browser": "jest -c node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
"test:unit:node": "jest -c node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
303685
0
30
2067
0
2
1
+ Addedchalk@^5.3.0
+ Addedcommander@^12.0.0
+ Addedchalk@5.3.0(transitive)
+ Addedcommander@12.1.0(transitive)