@solana-program/system 0.4.0 → 0.5.0
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/README.md +1 -2
- package/dist/src/index.js +42 -33
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +43 -35
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/generated/errors/system.d.ts +10 -0
- package/dist/types/generated/errors/system.d.ts.map +1 -1
- package/dist/types/generated/programs/system.d.ts +3 -3
- package/dist/types/generated/programs/system.d.ts.map +1 -1
- package/package.json +9 -6
package/dist/src/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEnumEncoder, getU32Encoder, getEnumDecoder, getU32Decoder, combineCodec, getStructEncoder, getAddressEncoder, getU64Encoder, getStructDecoder, getAddressDecoder, getU64Decoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, transformEncoder, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, BASE_ACCOUNT_SIZE, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/web3.js';
|
|
1
|
+
import { getEnumEncoder, getU32Encoder, getEnumDecoder, getU32Decoder, combineCodec, getStructEncoder, getAddressEncoder, getU64Encoder, getStructDecoder, getAddressDecoder, getU64Decoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, isProgramError, transformEncoder, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, BASE_ACCOUNT_SIZE, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/web3.js';
|
|
2
2
|
|
|
3
3
|
// src/generated/accounts/nonce.ts
|
|
4
4
|
var NonceState = /* @__PURE__ */ ((NonceState2) => {
|
|
@@ -79,37 +79,6 @@ async function fetchAllMaybeNonce(rpc, addresses, config) {
|
|
|
79
79
|
function getNonceSize() {
|
|
80
80
|
return 80;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
// src/generated/errors/system.ts
|
|
84
|
-
var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
|
|
85
|
-
var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
|
|
86
|
-
var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
|
|
87
|
-
var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
|
|
88
|
-
var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
|
|
89
|
-
var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
|
|
90
|
-
var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
|
|
91
|
-
var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
|
|
92
|
-
var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
|
|
93
|
-
var systemErrorMessages;
|
|
94
|
-
if (process.env.NODE_ENV !== "production") {
|
|
95
|
-
systemErrorMessages = {
|
|
96
|
-
[SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
|
|
97
|
-
[SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
|
|
98
|
-
[SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
|
|
99
|
-
[SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
|
|
100
|
-
[SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
|
|
101
|
-
[SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
|
|
102
|
-
[SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
|
|
103
|
-
[SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
|
|
104
|
-
[SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function getSystemErrorMessage(code) {
|
|
108
|
-
if (process.env.NODE_ENV !== "production") {
|
|
109
|
-
return systemErrorMessages[code];
|
|
110
|
-
}
|
|
111
|
-
return "Error message not available in production bundles.";
|
|
112
|
-
}
|
|
113
82
|
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
114
83
|
var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
|
|
115
84
|
SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
|
|
@@ -132,7 +101,7 @@ var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
|
|
|
132
101
|
return SystemInstruction2;
|
|
133
102
|
})(SystemInstruction || {});
|
|
134
103
|
function identifySystemInstruction(instruction) {
|
|
135
|
-
const data =
|
|
104
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
136
105
|
if (containsBytes(data, getU32Encoder().encode(0), 0)) {
|
|
137
106
|
return 0 /* CreateAccount */;
|
|
138
107
|
}
|
|
@@ -176,6 +145,45 @@ function identifySystemInstruction(instruction) {
|
|
|
176
145
|
"The provided instruction could not be identified as a system instruction."
|
|
177
146
|
);
|
|
178
147
|
}
|
|
148
|
+
|
|
149
|
+
// src/generated/errors/system.ts
|
|
150
|
+
var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
|
|
151
|
+
var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
|
|
152
|
+
var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
|
|
153
|
+
var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
|
|
154
|
+
var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
|
|
155
|
+
var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
|
|
156
|
+
var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
|
|
157
|
+
var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
|
|
158
|
+
var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
|
|
159
|
+
var systemErrorMessages;
|
|
160
|
+
if (process.env.NODE_ENV !== "production") {
|
|
161
|
+
systemErrorMessages = {
|
|
162
|
+
[SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
|
|
163
|
+
[SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
|
|
164
|
+
[SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
|
|
165
|
+
[SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
|
|
166
|
+
[SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
|
|
167
|
+
[SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
|
|
168
|
+
[SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
|
|
169
|
+
[SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
|
|
170
|
+
[SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function getSystemErrorMessage(code) {
|
|
174
|
+
if (process.env.NODE_ENV !== "production") {
|
|
175
|
+
return systemErrorMessages[code];
|
|
176
|
+
}
|
|
177
|
+
return "Error message not available in production bundles.";
|
|
178
|
+
}
|
|
179
|
+
function isSystemError(error, transactionMessage, code) {
|
|
180
|
+
return isProgramError(
|
|
181
|
+
error,
|
|
182
|
+
transactionMessage,
|
|
183
|
+
SYSTEM_PROGRAM_ADDRESS,
|
|
184
|
+
code
|
|
185
|
+
);
|
|
186
|
+
}
|
|
179
187
|
function expectAddress(value) {
|
|
180
188
|
if (!value) {
|
|
181
189
|
throw new Error("Expected a Address.");
|
|
@@ -1062,6 +1070,6 @@ function parseWithdrawNonceAccountInstruction(instruction) {
|
|
|
1062
1070
|
};
|
|
1063
1071
|
}
|
|
1064
1072
|
|
|
1065
|
-
export { NonceState, NonceVersion, SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE, SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH, SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH, SYSTEM_ERROR__INVALID_PROGRAM_ID, SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED, SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED, SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES, SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE, SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS, SYSTEM_PROGRAM_ADDRESS, SystemAccount, SystemInstruction, decodeNonce, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceCodec, getNonceDecoder, getNonceEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemErrorMessage, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction };
|
|
1066
|
-
//# sourceMappingURL=
|
|
1073
|
+
export { NonceState, NonceVersion, SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE, SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH, SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH, SYSTEM_ERROR__INVALID_PROGRAM_ID, SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED, SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED, SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES, SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE, SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS, SYSTEM_PROGRAM_ADDRESS, SystemAccount, SystemInstruction, decodeNonce, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceCodec, getNonceDecoder, getNonceEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemErrorMessage, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, isSystemError, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction };
|
|
1074
|
+
//# sourceMappingURL=index.mjs.map
|
|
1067
1075
|
//# sourceMappingURL=index.mjs.map
|