@solana/errors 2.0.0-experimental.4a3c533 → 2.0.0-experimental.4ff4425
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +80 -0
- package/dist/index.browser.cjs +212 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +172 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +172 -2
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +212 -1
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +172 -2
- package/dist/index.node.js.map +1 -1
- package/dist/types/codes.d.ts +42 -2
- package/dist/types/codes.d.ts.map +1 -1
- package/dist/types/context.d.ts +26 -2
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/rpc-enum-errors.d.ts +31 -0
- package/dist/types/rpc-enum-errors.d.ts.map +1 -0
- package/dist/types/transaction-error.d.ts +5 -0
- package/dist/types/transaction-error.d.ts.map +1 -0
- package/package.json +11 -34
package/dist/cli.js
CHANGED
|
@@ -10,11 +10,91 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
|
|
|
10
10
|
var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
|
|
11
11
|
var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
|
|
12
12
|
var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
|
|
13
|
+
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
|
|
14
|
+
var SOLANA_ERROR__NONCE_INVALID = 6;
|
|
15
|
+
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
|
|
16
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN = 705e4;
|
|
17
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE = 7050001;
|
|
18
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE = 7050002;
|
|
19
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND = 7050003;
|
|
20
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
|
|
21
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
|
|
22
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE = 7050006;
|
|
23
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED = 7050007;
|
|
24
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND = 7050008;
|
|
25
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP = 7050009;
|
|
26
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE = 7050010;
|
|
27
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX = 7050011;
|
|
28
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE = 7050012;
|
|
29
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION = 7050013;
|
|
30
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE = 7050014;
|
|
31
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE = 7050015;
|
|
32
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING = 7050016;
|
|
33
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
|
|
34
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION = 7050018;
|
|
35
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT = 7050019;
|
|
36
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
|
|
37
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
|
|
38
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS = 7050022;
|
|
39
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
|
|
40
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
|
|
41
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
|
|
42
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
|
|
43
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT = 7050027;
|
|
44
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
|
|
45
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
|
|
46
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION = 7050030;
|
|
47
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
|
|
48
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
|
|
49
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
|
|
50
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED = 7050034;
|
|
51
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
|
|
52
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION = 7050036;
|
|
13
53
|
|
|
14
54
|
// src/messages.ts
|
|
15
55
|
var SolanaErrorMessages = {
|
|
56
|
+
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
|
|
16
57
|
[SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
|
|
58
|
+
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
|
|
59
|
+
[SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
|
|
17
60
|
[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`.",
|
|
61
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
|
|
62
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: "Account in use",
|
|
63
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: "Account loaded twice",
|
|
64
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.",
|
|
65
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist",
|
|
66
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED]: "This transaction has already been processed",
|
|
67
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND]: "Blockhash not found",
|
|
68
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep",
|
|
69
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance",
|
|
70
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed",
|
|
71
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee",
|
|
72
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
|
|
73
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees",
|
|
74
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference",
|
|
75
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data",
|
|
76
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index",
|
|
77
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner",
|
|
78
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
|
|
79
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions",
|
|
80
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
|
|
81
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written",
|
|
82
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap",
|
|
83
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present",
|
|
84
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist",
|
|
85
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
|
|
86
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED]: "ResanitizationNeeded",
|
|
87
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly",
|
|
88
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE]: "Transaction did not pass signature verification",
|
|
89
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts",
|
|
90
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match",
|
|
91
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: "The transaction failed with the error `$errorName`",
|
|
92
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION]: "Transaction version is unsupported",
|
|
93
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block",
|
|
94
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit",
|
|
95
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block",
|
|
96
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit",
|
|
97
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit",
|
|
18
98
|
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
|
|
19
99
|
[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."
|
|
20
100
|
};
|
package/dist/index.browser.cjs
CHANGED
|
@@ -8,11 +8,91 @@ var SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1;
|
|
|
8
8
|
var SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2;
|
|
9
9
|
var SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3;
|
|
10
10
|
var SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4;
|
|
11
|
+
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5;
|
|
12
|
+
var SOLANA_ERROR__NONCE_INVALID = 6;
|
|
13
|
+
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7;
|
|
14
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN = 705e4;
|
|
15
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE = 7050001;
|
|
16
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE = 7050002;
|
|
17
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND = 7050003;
|
|
18
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
|
|
19
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
|
|
20
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE = 7050006;
|
|
21
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED = 7050007;
|
|
22
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND = 7050008;
|
|
23
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP = 7050009;
|
|
24
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE = 7050010;
|
|
25
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX = 7050011;
|
|
26
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE = 7050012;
|
|
27
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION = 7050013;
|
|
28
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE = 7050014;
|
|
29
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE = 7050015;
|
|
30
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING = 7050016;
|
|
31
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
|
|
32
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION = 7050018;
|
|
33
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT = 7050019;
|
|
34
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
|
|
35
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
|
|
36
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS = 7050022;
|
|
37
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
|
|
38
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
|
|
39
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
|
|
40
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
|
|
41
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT = 7050027;
|
|
42
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
|
|
43
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
|
|
44
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION = 7050030;
|
|
45
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
|
|
46
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
|
|
47
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
|
|
48
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED = 7050034;
|
|
49
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
|
|
50
|
+
var SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION = 7050036;
|
|
11
51
|
|
|
12
52
|
// src/messages.ts
|
|
13
53
|
var SolanaErrorMessages = {
|
|
54
|
+
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
|
|
14
55
|
[SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: "Key pair bytes must be of length 64, got $byteLength.",
|
|
56
|
+
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
|
|
57
|
+
[SOLANA_ERROR__NONCE_INVALID]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
|
|
15
58
|
[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`.",
|
|
59
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
|
|
60
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: "Account in use",
|
|
61
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: "Account loaded twice",
|
|
62
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.",
|
|
63
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist",
|
|
64
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED]: "This transaction has already been processed",
|
|
65
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND]: "Blockhash not found",
|
|
66
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep",
|
|
67
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance",
|
|
68
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed",
|
|
69
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee",
|
|
70
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
|
|
71
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees",
|
|
72
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference",
|
|
73
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data",
|
|
74
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index",
|
|
75
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner",
|
|
76
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
|
|
77
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions",
|
|
78
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
|
|
79
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written",
|
|
80
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap",
|
|
81
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present",
|
|
82
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist",
|
|
83
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
|
|
84
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED]: "ResanitizationNeeded",
|
|
85
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly",
|
|
86
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE]: "Transaction did not pass signature verification",
|
|
87
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts",
|
|
88
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match",
|
|
89
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: "The transaction failed with the error `$errorName`",
|
|
90
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION]: "Transaction version is unsupported",
|
|
91
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block",
|
|
92
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit",
|
|
93
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block",
|
|
94
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit",
|
|
95
|
+
[SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit",
|
|
16
96
|
[SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: "Transaction is missing signatures for addresses: $addresses.",
|
|
17
97
|
[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."
|
|
18
98
|
};
|
|
@@ -35,7 +115,7 @@ function encodeValue(value) {
|
|
|
35
115
|
} else {
|
|
36
116
|
return encodeURIComponent(
|
|
37
117
|
String(
|
|
38
|
-
Object.getPrototypeOf(value) === null ? (
|
|
118
|
+
value != null && Object.getPrototypeOf(value) === null ? (
|
|
39
119
|
// Plain objects with no protoype don't have a `toString` method.
|
|
40
120
|
// Convert them before stringifying them.
|
|
41
121
|
{ ...value }
|
|
@@ -94,11 +174,142 @@ var SolanaError = class extends Error {
|
|
|
94
174
|
}
|
|
95
175
|
};
|
|
96
176
|
|
|
177
|
+
// src/rpc-enum-errors.ts
|
|
178
|
+
function getSolanaErrorFromRpcError({ errorCodeBaseOffset, getErrorContext, orderedErrorNames, rpcEnumError }, constructorOpt) {
|
|
179
|
+
let rpcErrorName;
|
|
180
|
+
let rpcErrorContext;
|
|
181
|
+
if (typeof rpcEnumError === "string") {
|
|
182
|
+
rpcErrorName = rpcEnumError;
|
|
183
|
+
} else {
|
|
184
|
+
rpcErrorName = Object.keys(rpcEnumError)[0];
|
|
185
|
+
rpcErrorContext = rpcEnumError[rpcErrorName];
|
|
186
|
+
}
|
|
187
|
+
const codeOffset = orderedErrorNames.indexOf(rpcErrorName);
|
|
188
|
+
const errorCode = errorCodeBaseOffset + codeOffset;
|
|
189
|
+
const errorContext = getErrorContext(errorCode, rpcErrorName, rpcErrorContext);
|
|
190
|
+
const err = new SolanaError(errorCode, errorContext);
|
|
191
|
+
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
|
|
192
|
+
Error.captureStackTrace(err, constructorOpt);
|
|
193
|
+
}
|
|
194
|
+
return err;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/transaction-error.ts
|
|
198
|
+
var ORDERED_ERROR_NAMES = [
|
|
199
|
+
// Keep synced with RPC source: https://github.com/anza-xyz/agave/blob/master/sdk/src/transaction/error.rs
|
|
200
|
+
// If this list ever gets too large, consider implementing a compression strategy like this:
|
|
201
|
+
// https://gist.github.com/steveluscher/aaa7cbbb5433b1197983908a40860c47
|
|
202
|
+
"AccountInUse",
|
|
203
|
+
"AccountLoadedTwice",
|
|
204
|
+
"AccountNotFound",
|
|
205
|
+
"ProgramAccountNotFound",
|
|
206
|
+
"InsufficientFundsForFee",
|
|
207
|
+
"InvalidAccountForFee",
|
|
208
|
+
"AlreadyProcessed",
|
|
209
|
+
"BlockhashNotFound",
|
|
210
|
+
// `InstructionError` intentionally omitted
|
|
211
|
+
"CallChainTooDeep",
|
|
212
|
+
"MissingSignatureForFee",
|
|
213
|
+
"InvalidAccountIndex",
|
|
214
|
+
"SignatureFailure",
|
|
215
|
+
"InvalidProgramForExecution",
|
|
216
|
+
"SanitizeFailure",
|
|
217
|
+
"ClusterMaintenance",
|
|
218
|
+
"AccountBorrowOutstanding",
|
|
219
|
+
"WouldExceedMaxBlockCostLimit",
|
|
220
|
+
"UnsupportedVersion",
|
|
221
|
+
"InvalidWritableAccount",
|
|
222
|
+
"WouldExceedMaxAccountCostLimit",
|
|
223
|
+
"WouldExceedAccountDataBlockLimit",
|
|
224
|
+
"TooManyAccountLocks",
|
|
225
|
+
"AddressLookupTableNotFound",
|
|
226
|
+
"InvalidAddressLookupTableOwner",
|
|
227
|
+
"InvalidAddressLookupTableData",
|
|
228
|
+
"InvalidAddressLookupTableIndex",
|
|
229
|
+
"InvalidRentPayingAccount",
|
|
230
|
+
"WouldExceedMaxVoteCostLimit",
|
|
231
|
+
"WouldExceedAccountDataTotalLimit",
|
|
232
|
+
"DuplicateInstruction",
|
|
233
|
+
"InsufficientFundsForRent",
|
|
234
|
+
"MaxLoadedAccountsDataSizeExceeded",
|
|
235
|
+
"InvalidLoadedAccountsDataSizeLimit",
|
|
236
|
+
"ResanitizationNeeded",
|
|
237
|
+
"ProgramExecutionTemporarilyRestricted",
|
|
238
|
+
"UnbalancedTransaction"
|
|
239
|
+
];
|
|
240
|
+
function getSolanaErrorFromTransactionError(transactionError) {
|
|
241
|
+
return getSolanaErrorFromRpcError(
|
|
242
|
+
{
|
|
243
|
+
errorCodeBaseOffset: 7050001,
|
|
244
|
+
getErrorContext(errorCode, rpcErrorName, rpcErrorContext) {
|
|
245
|
+
if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN) {
|
|
246
|
+
return {
|
|
247
|
+
errorName: rpcErrorName,
|
|
248
|
+
...rpcErrorContext !== void 0 ? { transactionErrorContext: rpcErrorContext } : null
|
|
249
|
+
};
|
|
250
|
+
} else if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION) {
|
|
251
|
+
return {
|
|
252
|
+
index: rpcErrorContext
|
|
253
|
+
};
|
|
254
|
+
} else if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT || errorCode === SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED) {
|
|
255
|
+
return {
|
|
256
|
+
accountIndex: rpcErrorContext.account_index
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
orderedErrorNames: ORDERED_ERROR_NAMES,
|
|
261
|
+
rpcEnumError: transactionError
|
|
262
|
+
},
|
|
263
|
+
getSolanaErrorFromTransactionError
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
exports.SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED;
|
|
97
268
|
exports.SOLANA_ERROR__INVALID_KEYPAIR_BYTES = SOLANA_ERROR__INVALID_KEYPAIR_BYTES;
|
|
269
|
+
exports.SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;
|
|
270
|
+
exports.SOLANA_ERROR__NONCE_INVALID = SOLANA_ERROR__NONCE_INVALID;
|
|
98
271
|
exports.SOLANA_ERROR__RPC_INTEGER_OVERFLOW = SOLANA_ERROR__RPC_INTEGER_OVERFLOW;
|
|
272
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING = SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING;
|
|
273
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE = SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE;
|
|
274
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE = SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE;
|
|
275
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND = SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND;
|
|
276
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND = SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND;
|
|
277
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED = SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED;
|
|
278
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND = SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND;
|
|
279
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP = SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP;
|
|
280
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE = SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE;
|
|
281
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION = SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION;
|
|
282
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE = SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE;
|
|
283
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT = SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT;
|
|
284
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE;
|
|
285
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX;
|
|
286
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA;
|
|
287
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX;
|
|
288
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER;
|
|
289
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT;
|
|
290
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION;
|
|
291
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT;
|
|
292
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT = SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT;
|
|
293
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED;
|
|
294
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE = SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE;
|
|
295
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND = SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND;
|
|
296
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED;
|
|
297
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED = SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED;
|
|
298
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE = SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE;
|
|
299
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE = SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE;
|
|
300
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS = SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS;
|
|
301
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION = SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION;
|
|
302
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN = SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN;
|
|
303
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION = SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION;
|
|
304
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT;
|
|
305
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT;
|
|
306
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT;
|
|
307
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT;
|
|
308
|
+
exports.SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT = SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT;
|
|
99
309
|
exports.SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES;
|
|
100
310
|
exports.SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE;
|
|
101
311
|
exports.SolanaError = SolanaError;
|
|
312
|
+
exports.getSolanaErrorFromTransactionError = getSolanaErrorFromTransactionError;
|
|
102
313
|
exports.isSolanaError = isSolanaError;
|
|
103
314
|
//# sourceMappingURL=out.js.map
|
|
104
315
|
//# sourceMappingURL=index.browser.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAA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AACT,WAAO,6BAA6B,MAAM,OAAO;AAAA,EACrD,OAAO;AACH,QAAI,wBAAwB,iBAAiB,IAAI,8DAA8D,IAAI;AACnH,QAAI,OAAO,KAAK,OAAO,EAAE,QAAQ;AAM7B,+BAAyB,MAAM,oBAAoB,OAAO,CAAC;AAAA,IAC/D;AACA,WAAO,GAAG,qBAAqB;AAAA,EACnC;AACJ;;;AC7DO,SAAS,cACZ,GACA,MAC4B;AAC5B,QAAMA,iBAAgB,aAAa,SAAS,EAAE,SAAS;AACvD,MAAIA,gBAAe;AACf,QAAI,SAAS,QAAW;AACpB,aAAQ,EAA8B,QAAQ,WAAW;AAAA,IAC7D;AACA,WAAO;AAAA,EACX;AACA,SAAO;AACX;AAQO,IAAM,cAAN,cAAgF,MAAM;AAAA,EAChF;AAAA,EACT,eACO,CAAC,MAAM,OAAO,GAGnB;AACE,UAAM,UAAU,gBAAgB,MAAM,OAAO;AAC7C,UAAM,OAAO;AACb,SAAK,UAAU;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACP;AAGA,SAAK,OAAO;AAAA,EAChB;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES;\n","import {\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/error#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/codes.ts","../src/messages.ts","../src/message-formatter.ts","../src/error.ts","../src/rpc-enum-errors.ts","../src/transaction-error.ts"],"names":["isSolanaError"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACOhG,IAAM,+CAA+C;AACrD,IAAM,qDAAqD;AAC3D,IAAM,qCAAqC;AAC3C,IAAM,sCAAsC;AAC5C,IAAM,sCAAsC;AAC5C,IAAM,8BAA8B;AACpC,IAAM,wCAAwC;AAE9C,IAAM,0CAA0C;AAChD,IAAM,iDAAiD;AACvD,IAAM,uDAAuD;AAC7D,IAAM,oDAAoD;AAC1D,IAAM,4DAA4D;AAClE,IAAM,6DAA6D;AACnE,IAAM,0DAA0D;AAChE,IAAM,oDAAoD;AAC1D,IAAM,sDAAsD;AAE5D,I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BAAgB,IAAI;AAAA,UACvF;AAAA,QACJ,WAAW,cAAc,uDAAuD;AAC5E,iBAAO;AAAA,YACH,OAAO;AAAA,UACX;AAAA,QACJ,WACI,cAAc,+DACd,cAAc,0EAChB;AACE,iBAAO;AAAA,YACH,cAAe,gBAA8C;AAAA,UACjE;AAAA,QACJ;AAAA,MACJ;AAAA,MACA,mBAAmB;AAAA,MACnB,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,EACJ;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/errors/#adding-a-new-error\n *\n * WARNING:\n * - Don't remove error codes\n * - Don't change or reorder error codes.\n */\nexport const SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES = 1 as const;\nexport const SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE = 2 as const;\nexport const SOLANA_ERROR__RPC_INTEGER_OVERFLOW = 3 as const;\nexport const SOLANA_ERROR__INVALID_KEYPAIR_BYTES = 4 as const;\nexport const SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 5 as const;\nexport const SOLANA_ERROR__NONCE_INVALID = 6 as const;\nexport const SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 7 as const;\n// Reserve error codes starting with [7050000-7050999] for the Rust enum `TransactionError`\nexport const SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN = 7050000 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE = 7050001 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE = 7050002 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND = 7050003 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND = 7050004 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE = 7050005 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE = 7050006 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED = 7050007 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND = 7050008 as const;\n// `InstructionError` intentionally omitted\nexport const SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP = 7050009 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE = 7050010 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX = 7050011 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE = 7050012 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION = 7050013 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE = 7050014 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE = 7050015 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING = 7050016 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION = 7050018 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT = 7050019 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS = 7050022 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT = 7050027 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION = 7050030 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT = 7050031 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED = 7050034 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035 as const;\nexport const SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION = 7050036 as const;\n\n/**\n * A union of every Solana error code\n *\n * You might be wondering why this is not a TypeScript enum or const enum.\n *\n * One of the goals of this library is to enable people to use some or none of it without having to\n * bundle all of it.\n *\n * If we made the set of error codes an enum then anyone who imported it (even if to only use a\n * single error code) would be forced to bundle every code and its label.\n *\n * Const enums appear to solve this problem by letting the compiler inline only the codes that are\n * actually used. Unfortunately exporting ambient (const) enums from a library like `@solana/errors`\n * is not safe, for a variety of reasons covered here: https://stackoverflow.com/a/28818850\n */\nexport type SolanaErrorCode =\n | typeof SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES\n | typeof SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE\n | typeof SOLANA_ERROR__RPC_INTEGER_OVERFLOW\n | typeof SOLANA_ERROR__INVALID_KEYPAIR_BYTES\n | typeof SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED\n | typeof SOLANA_ERROR__NONCE_INVALID\n | typeof SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED\n | typeof SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION;\n","import {\n SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED,\n SOLANA_ERROR__INVALID_KEYPAIR_BYTES,\n SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__NONCE_INVALID,\n SOLANA_ERROR__RPC_INTEGER_OVERFLOW,\n SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING,\n SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE,\n SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE,\n SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND,\n SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED,\n SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND,\n SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP,\n SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE,\n SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION,\n SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE,\n SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT,\n SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT,\n SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED,\n SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE,\n SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND,\n SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED,\n SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED,\n SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE,\n SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE,\n SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS,\n SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION,\n SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN,\n SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION,\n SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT,\n SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT,\n SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT,\n SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT,\n SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT,\n SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES,\n SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE,\n SolanaErrorCode,\n} from './codes';\n\n/**\n * To add a new error, follow the instructions at\n * https://github.com/solana-labs/solana-web3.js/tree/master/packages/errors#adding-a-new-error\n *\n * WARNING:\n * - Don't change the meaning of an error message.\n */\nexport const SolanaErrorMessages: Readonly<{\n // This type makes this data structure exhaustive with respect to `SolanaErrorCode`.\n // TypeScript will fail to build this project if add an error code without a message.\n [P in SolanaErrorCode]: string;\n}> = {\n [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]:\n 'The network has progressed past the last block for which this transaction could have been committed.',\n [SOLANA_ERROR__INVALID_KEYPAIR_BYTES]: 'Key pair bytes must be of length 64, got $byteLength.',\n [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: 'No nonce account could be found at address `$nonceAccountAddress`',\n [SOLANA_ERROR__NONCE_INVALID]:\n 'The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`',\n [SOLANA_ERROR__RPC_INTEGER_OVERFLOW]:\n 'The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was ' +\n '`$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds ' +\n '`Number.MAX_SAFE_INTEGER`.',\n [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_BORROW_OUTSTANDING]:\n 'Transaction processing left an account with an outstanding borrowed reference',\n [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_IN_USE]: 'Account in use',\n [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_LOADED_TWICE]: 'Account loaded twice',\n [SOLANA_ERROR__TRANSACTION_ERROR_ACCOUNT_NOT_FOUND]:\n 'Attempt to debit an account but found no record of a prior credit.',\n [SOLANA_ERROR__TRANSACTION_ERROR_ADDRESS_LOOKUP_TABLE_NOT_FOUND]:\n \"Transaction loads an address table account that doesn't exist\",\n [SOLANA_ERROR__TRANSACTION_ERROR_ALREADY_PROCESSED]: 'This transaction has already been processed',\n [SOLANA_ERROR__TRANSACTION_ERROR_BLOCKHASH_NOT_FOUND]: 'Blockhash not found',\n [SOLANA_ERROR__TRANSACTION_ERROR_CALL_CHAIN_TOO_DEEP]: 'Loader call chain is too deep',\n [SOLANA_ERROR__TRANSACTION_ERROR_CLUSTER_MAINTENANCE]:\n 'Transactions are currently disabled due to cluster maintenance',\n [SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION]:\n 'Transaction contains a duplicate instruction ($index) that is not allowed',\n [SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_FEE]: 'Insufficient funds for fee',\n [SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT]:\n 'Transaction results in an account ($accountIndex) with insufficient funds for rent',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_FOR_FEE]: 'This account may not be used to pay transaction fees',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ACCOUNT_INDEX]: 'Transaction contains an invalid account reference',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_DATA]:\n 'Transaction loads an address table account with invalid data',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_INDEX]:\n 'Transaction address table lookup uses an invalid index',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_ADDRESS_LOOKUP_TABLE_OWNER]:\n 'Transaction loads an address table account with an invalid owner',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]:\n 'LoadedAccountsDataSizeLimit set for transaction must be greater than 0.',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_PROGRAM_FOR_EXECUTION]:\n 'This program may not be used for executing instructions',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_RENT_PAYING_ACCOUNT]:\n 'Transaction leaves an account with a lower balance than rent-exempt minimum',\n [SOLANA_ERROR__TRANSACTION_ERROR_INVALID_WRITABLE_ACCOUNT]:\n 'Transaction loads a writable account that cannot be written',\n [SOLANA_ERROR__TRANSACTION_ERROR_MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]:\n 'Transaction exceeded max loaded accounts data size cap',\n [SOLANA_ERROR__TRANSACTION_ERROR_MISSING_SIGNATURE_FOR_FEE]:\n 'Transaction requires a fee but has no signature present',\n [SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_ACCOUNT_NOT_FOUND]: 'Attempt to load a program that does not exist',\n [SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]:\n 'Execution of the program referenced by account at index $accountIndex is temporarily restricted.',\n [SOLANA_ERROR__TRANSACTION_ERROR_RESANITIZATION_NEEDED]: 'ResanitizationNeeded',\n [SOLANA_ERROR__TRANSACTION_ERROR_SANITIZE_FAILURE]: 'Transaction failed to sanitize accounts offsets correctly',\n [SOLANA_ERROR__TRANSACTION_ERROR_SIGNATURE_FAILURE]: 'Transaction did not pass signature verification',\n [SOLANA_ERROR__TRANSACTION_ERROR_TOO_MANY_ACCOUNT_LOCKS]: 'Transaction locked too many accounts',\n [SOLANA_ERROR__TRANSACTION_ERROR_UNBALANCED_TRANSACTION]:\n 'Sum of account balances before and after transaction do not match',\n [SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN]: 'The transaction failed with the error `$errorName`',\n [SOLANA_ERROR__TRANSACTION_ERROR_UNSUPPORTED_VERSION]: 'Transaction version is unsupported',\n [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]:\n 'Transaction would exceed account data limit within the block',\n [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]:\n 'Transaction would exceed total account data limit',\n [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]:\n 'Transaction would exceed max account limit within the block',\n [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]:\n 'Transaction would exceed max Block Cost Limit',\n [SOLANA_ERROR__TRANSACTION_ERROR_WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: 'Transaction would exceed max Vote Cost Limit',\n [SOLANA_ERROR__TRANSACTION_MISSING_SIGNATURES]: 'Transaction is missing signatures for addresses: $addresses.',\n [SOLANA_ERROR__TRANSACTION_SIGNATURE_NOT_COMPUTABLE]:\n \"Could not determine this transaction's signature. Make sure that the transaction has \" +\n 'been signed by its fee payer.',\n};\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorMessages } from './messages';\n\nfunction encodeValue(value: unknown): string {\n if (Array.isArray(value)) {\n return (\n /* \"[\" */ '%5B' +\n value\n .map(element =>\n typeof element === 'string'\n ? encodeURIComponent(`\"${element.replace(/\"/g, '\\\\\"')}\"`)\n : encodeValue(element),\n )\n .join(/* \", \" */ '%2C%20') +\n /* \"]\" */ '%5D'\n );\n } else if (typeof value === 'bigint') {\n return `${value}n`;\n } else {\n return encodeURIComponent(\n String(\n value != null && Object.getPrototypeOf(value) === null\n ? // Plain objects with no protoype don't have a `toString` method.\n // Convert them before stringifying them.\n { ...(value as object) }\n : value,\n ),\n );\n }\n}\n\nfunction encodeObjectContextEntry([key, value]: [string, unknown]): `${typeof key}=${string}` {\n return `${key}=${encodeValue(value)}`;\n}\n\nfunction encodeContextObject(context: object) {\n return Object.entries(context).map(encodeObjectContextEntry).join('&');\n}\n\nexport function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>(\n code: TErrorCode,\n context: object = {},\n): string {\n const messageFormatString = SolanaErrorMessages[code];\n const message = messageFormatString.replace(/(?<!\\\\)\\$(\\w+)/g, (substring, variableName) =>\n variableName in context ? `${context[variableName as keyof typeof context]}` : substring,\n );\n return message;\n}\n\nexport function getErrorMessage<TErrorCode extends SolanaErrorCode>(code: TErrorCode, context: object = {}): string {\n if (__DEV__) {\n return getHumanReadableErrorMessage(code, context);\n } else {\n let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \\`npx @solana/errors decode ${code}`;\n if (Object.keys(context).length) {\n /**\n * DANGER: Be sure that the shell command is escaped in such a way that makes it\n * impossible for someone to craft malicious context values that would result in\n * an exploit against anyone who bindly copy/pastes it into their terminal.\n */\n decodingAdviceMessage += ` $\"${encodeContextObject(context)}\"`;\n }\n return `${decodingAdviceMessage}\\``;\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { getErrorMessage } from './message-formatter';\n\nexport function isSolanaError<TErrorCode extends SolanaErrorCode>(\n e: unknown,\n code?: TErrorCode,\n): e is SolanaError<TErrorCode> {\n const isSolanaError = e instanceof Error && e.name === 'SolanaError';\n if (isSolanaError) {\n if (code !== undefined) {\n return (e as SolanaError<TErrorCode>).context.__code === code;\n }\n return true;\n }\n return false;\n}\n\ntype SolanaErrorCodedContext = Readonly<{\n [P in SolanaErrorCode]: (SolanaErrorContext[P] extends undefined ? object : SolanaErrorContext[P]) & {\n __code: P;\n };\n}>;\n\nexport class SolanaError<TErrorCode extends SolanaErrorCode = SolanaErrorCode> extends Error {\n readonly context: SolanaErrorCodedContext[TErrorCode];\n constructor(\n ...[code, context]: SolanaErrorContext[TErrorCode] extends undefined\n ? [code: TErrorCode]\n : [code: TErrorCode, context: SolanaErrorContext[TErrorCode]]\n ) {\n const message = getErrorMessage(code, context);\n super(message);\n this.context = {\n __code: code,\n ...context,\n } as SolanaErrorCodedContext[TErrorCode];\n // This is necessary so that `isSolanaError()` can identify a `SolanaError` without having\n // to import the class for use in an `instanceof` check.\n this.name = 'SolanaError';\n }\n}\n","import { SolanaErrorCode } from './codes';\nimport { SolanaErrorContext } from './context';\nimport { SolanaError } from './error';\n\ntype Config = Readonly<{\n /**\n * Oh, hello. You might wonder what in tarnation is going on here. Allow us to explain.\n *\n * One of the goals of `@solana/errors` is to allow errors that are not interesting to your\n * application to shake out of your app bundle in production. This means that we must never\n * export large hardcoded maps of error codes/messages.\n *\n * Unfortunately, where instruction and transaction errors from the RPC are concerned, we have\n * no choice but to keep a map between the RPC `rpcEnumError` enum name and its corresponding\n * `SolanaError` code. In the interest of implementing that map in as few bytes of source code\n * as possible, we do the following:\n *\n * 1. Reserve a block of sequential error codes for the enum in question\n * 2. Hardcode the list of enum names in that same order\n * 3. Match the enum error name from the RPC with its index in that list, and reconstruct the\n * `SolanaError` code by adding the `errorCodeBaseOffset` to that index\n */\n errorCodeBaseOffset: number;\n getErrorContext: (\n errorCode: SolanaErrorCode,\n rpcErrorName: string,\n rpcErrorContext?: unknown,\n ) => SolanaErrorContext[SolanaErrorCode];\n orderedErrorNames: string[];\n rpcEnumError: string | { [key: string]: unknown };\n}>;\n\nexport function getSolanaErrorFromRpcError(\n { errorCodeBaseOffset, getErrorContext, orderedErrorNames, rpcEnumError }: Config,\n // eslint-disable-next-line @typescript-eslint/ban-types\n constructorOpt: Function,\n): SolanaError {\n let rpcErrorName;\n let rpcErrorContext;\n if (typeof rpcEnumError === 'string') {\n rpcErrorName = rpcEnumError;\n } else {\n rpcErrorName = Object.keys(rpcEnumError)[0];\n rpcErrorContext = rpcEnumError[rpcErrorName];\n }\n const codeOffset = orderedErrorNames.indexOf(rpcErrorName);\n const errorCode = (errorCodeBaseOffset + codeOffset) as SolanaErrorCode;\n const errorContext = getErrorContext(errorCode, rpcErrorName, rpcErrorContext);\n const err = new SolanaError(errorCode, errorContext);\n if ('captureStackTrace' in Error && typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(err, constructorOpt);\n }\n return err;\n}\n","import {\n SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION,\n SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT,\n SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED,\n SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN,\n} from './codes';\nimport { SolanaError } from './error';\nimport { getSolanaErrorFromRpcError } from './rpc-enum-errors';\n\n/**\n * How to add an error when an entry is added to the RPC `TransactionError` enum:\n *\n * 1. Follow the instructions in `./codes.ts` to add a corresponding Solana error code\n * 2. Add the `TransactionError` enum name in the same order as it appears in `./codes.ts`\n * 3. Add the new error name/code mapping to `./__tests__/transaction-error-test.ts`\n */\nconst ORDERED_ERROR_NAMES = [\n // Keep synced with RPC source: https://github.com/anza-xyz/agave/blob/master/sdk/src/transaction/error.rs\n // If this list ever gets too large, consider implementing a compression strategy like this:\n // https://gist.github.com/steveluscher/aaa7cbbb5433b1197983908a40860c47\n 'AccountInUse',\n 'AccountLoadedTwice',\n 'AccountNotFound',\n 'ProgramAccountNotFound',\n 'InsufficientFundsForFee',\n 'InvalidAccountForFee',\n 'AlreadyProcessed',\n 'BlockhashNotFound',\n // `InstructionError` intentionally omitted\n 'CallChainTooDeep',\n 'MissingSignatureForFee',\n 'InvalidAccountIndex',\n 'SignatureFailure',\n 'InvalidProgramForExecution',\n 'SanitizeFailure',\n 'ClusterMaintenance',\n 'AccountBorrowOutstanding',\n 'WouldExceedMaxBlockCostLimit',\n 'UnsupportedVersion',\n 'InvalidWritableAccount',\n 'WouldExceedMaxAccountCostLimit',\n 'WouldExceedAccountDataBlockLimit',\n 'TooManyAccountLocks',\n 'AddressLookupTableNotFound',\n 'InvalidAddressLookupTableOwner',\n 'InvalidAddressLookupTableData',\n 'InvalidAddressLookupTableIndex',\n 'InvalidRentPayingAccount',\n 'WouldExceedMaxVoteCostLimit',\n 'WouldExceedAccountDataTotalLimit',\n 'DuplicateInstruction',\n 'InsufficientFundsForRent',\n 'MaxLoadedAccountsDataSizeExceeded',\n 'InvalidLoadedAccountsDataSizeLimit',\n 'ResanitizationNeeded',\n 'ProgramExecutionTemporarilyRestricted',\n 'UnbalancedTransaction',\n];\n\nexport function getSolanaErrorFromTransactionError(transactionError: string | { [key: string]: unknown }): SolanaError {\n return getSolanaErrorFromRpcError(\n {\n errorCodeBaseOffset: 7050001,\n getErrorContext(errorCode, rpcErrorName, rpcErrorContext) {\n if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR_UNKNOWN) {\n return {\n errorName: rpcErrorName,\n ...(rpcErrorContext !== undefined ? { transactionErrorContext: rpcErrorContext } : null),\n };\n } else if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR_DUPLICATE_INSTRUCTION) {\n return {\n index: rpcErrorContext as number,\n };\n } else if (\n errorCode === SOLANA_ERROR__TRANSACTION_ERROR_INSUFFICIENT_FUNDS_FOR_RENT ||\n errorCode === SOLANA_ERROR__TRANSACTION_ERROR_PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED\n ) {\n return {\n accountIndex: (rpcErrorContext as { account_index: number }).account_index,\n };\n }\n },\n orderedErrorNames: ORDERED_ERROR_NAMES,\n rpcEnumError: transactionError,\n },\n getSolanaErrorFromTransactionError,\n );\n}\n"]}
|