@solana-program/system 0.3.3 → 0.4.1
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 +51 -43
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +52 -45
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/generated/accounts/index.d.ts +1 -1
- package/dist/types/generated/accounts/nonce.d.ts +3 -3
- package/dist/types/generated/accounts/nonce.d.ts.map +1 -1
- package/dist/types/generated/errors/index.d.ts +1 -1
- package/dist/types/generated/errors/system.d.ts +11 -1
- package/dist/types/generated/errors/system.d.ts.map +1 -1
- package/dist/types/generated/index.d.ts +1 -1
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts +2 -2
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocate.d.ts +2 -2
- package/dist/types/generated/instructions/allocate.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocateWithSeed.d.ts +2 -2
- package/dist/types/generated/instructions/allocateWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/assign.d.ts +2 -2
- package/dist/types/generated/instructions/assign.d.ts.map +1 -1
- package/dist/types/generated/instructions/assignWithSeed.d.ts +2 -2
- package/dist/types/generated/instructions/assignWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts +2 -2
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccount.d.ts +3 -3
- package/dist/types/generated/instructions/createAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts +2 -2
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/index.d.ts +1 -1
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts +2 -2
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSol.d.ts +2 -2
- package/dist/types/generated/instructions/transferSol.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts +2 -2
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts +2 -2
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts +2 -2
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/programs/index.d.ts +1 -1
- package/dist/types/generated/programs/system.d.ts +5 -5
- package/dist/types/generated/programs/system.d.ts.map +1 -1
- package/dist/types/generated/shared/index.d.ts +2 -2
- package/dist/types/generated/shared/index.d.ts.map +1 -1
- package/dist/types/generated/types/index.d.ts +1 -1
- package/dist/types/generated/types/nonceState.d.ts +2 -2
- package/dist/types/generated/types/nonceState.d.ts.map +1 -1
- package/dist/types/generated/types/nonceVersion.d.ts +2 -2
- package/dist/types/generated/types/nonceVersion.d.ts.map +1 -1
- package/package.json +15 -11
package/dist/src/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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
|
-
//
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return NonceState3;
|
|
3
|
+
// src/generated/accounts/nonce.ts
|
|
4
|
+
var NonceState = /* @__PURE__ */ ((NonceState2) => {
|
|
5
|
+
NonceState2[NonceState2["Uninitialized"] = 0] = "Uninitialized";
|
|
6
|
+
NonceState2[NonceState2["Initialized"] = 1] = "Initialized";
|
|
7
|
+
return NonceState2;
|
|
9
8
|
})(NonceState || {});
|
|
10
9
|
function getNonceStateEncoder() {
|
|
11
10
|
return getEnumEncoder(NonceState, { size: getU32Encoder() });
|
|
@@ -16,10 +15,10 @@ function getNonceStateDecoder() {
|
|
|
16
15
|
function getNonceStateCodec() {
|
|
17
16
|
return combineCodec(getNonceStateEncoder(), getNonceStateDecoder());
|
|
18
17
|
}
|
|
19
|
-
var NonceVersion = /* @__PURE__ */ ((
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
18
|
+
var NonceVersion = /* @__PURE__ */ ((NonceVersion2) => {
|
|
19
|
+
NonceVersion2[NonceVersion2["Legacy"] = 0] = "Legacy";
|
|
20
|
+
NonceVersion2[NonceVersion2["Current"] = 1] = "Current";
|
|
21
|
+
return NonceVersion2;
|
|
23
22
|
})(NonceVersion || {});
|
|
24
23
|
function getNonceVersionEncoder() {
|
|
25
24
|
return getEnumEncoder(NonceVersion, { size: getU32Encoder() });
|
|
@@ -80,37 +79,6 @@ async function fetchAllMaybeNonce(rpc, addresses, config) {
|
|
|
80
79
|
function getNonceSize() {
|
|
81
80
|
return 80;
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
// src/generated/errors/system.ts
|
|
85
|
-
var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
|
|
86
|
-
var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
|
|
87
|
-
var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
|
|
88
|
-
var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
|
|
89
|
-
var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
|
|
90
|
-
var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
|
|
91
|
-
var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
|
|
92
|
-
var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
|
|
93
|
-
var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
|
|
94
|
-
var systemErrorMessages;
|
|
95
|
-
if (__DEV__) {
|
|
96
|
-
systemErrorMessages = {
|
|
97
|
-
[SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
|
|
98
|
-
[SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
|
|
99
|
-
[SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
|
|
100
|
-
[SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
|
|
101
|
-
[SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
|
|
102
|
-
[SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
|
|
103
|
-
[SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
|
|
104
|
-
[SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
|
|
105
|
-
[SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function getSystemErrorMessage(code) {
|
|
109
|
-
if (__DEV__) {
|
|
110
|
-
return systemErrorMessages[code];
|
|
111
|
-
}
|
|
112
|
-
return "Error message not available in production bundles. Compile with `__DEV__` set to true to see more information.";
|
|
113
|
-
}
|
|
114
82
|
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
115
83
|
var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
|
|
116
84
|
SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
|
|
@@ -133,7 +101,7 @@ var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
|
|
|
133
101
|
return SystemInstruction2;
|
|
134
102
|
})(SystemInstruction || {});
|
|
135
103
|
function identifySystemInstruction(instruction) {
|
|
136
|
-
const data =
|
|
104
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
137
105
|
if (containsBytes(data, getU32Encoder().encode(0), 0)) {
|
|
138
106
|
return 0 /* CreateAccount */;
|
|
139
107
|
}
|
|
@@ -177,6 +145,45 @@ function identifySystemInstruction(instruction) {
|
|
|
177
145
|
"The provided instruction could not be identified as a system instruction."
|
|
178
146
|
);
|
|
179
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
|
+
}
|
|
180
187
|
function expectAddress(value) {
|
|
181
188
|
if (!value) {
|
|
182
189
|
throw new Error("Expected a Address.");
|
|
@@ -1063,6 +1070,6 @@ function parseWithdrawNonceAccountInstruction(instruction) {
|
|
|
1063
1070
|
};
|
|
1064
1071
|
}
|
|
1065
1072
|
|
|
1066
|
-
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 };
|
|
1067
|
-
//# 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
|
|
1068
1075
|
//# sourceMappingURL=index.mjs.map
|