@solana-program/system 0.10.0 → 0.12.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/dist/src/index.js +369 -365
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +369 -367
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/generated/accounts/nonce.d.ts +3 -0
- package/dist/types/generated/accounts/nonce.d.ts.map +1 -1
- package/dist/types/generated/errors/system.d.ts.map +1 -1
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts +1 -1
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocate.d.ts +1 -1
- package/dist/types/generated/instructions/allocate.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocateWithSeed.d.ts +1 -1
- package/dist/types/generated/instructions/allocateWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/assign.d.ts +1 -1
- package/dist/types/generated/instructions/assign.d.ts.map +1 -1
- package/dist/types/generated/instructions/assignWithSeed.d.ts +1 -1
- package/dist/types/generated/instructions/assignWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts +1 -1
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccount.d.ts +2 -2
- package/dist/types/generated/instructions/createAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts +1 -1
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts +1 -1
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSol.d.ts +1 -1
- package/dist/types/generated/instructions/transferSol.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts +1 -1
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts +1 -1
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts +1 -1
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/programs/system.d.ts +33 -2
- package/dist/types/generated/programs/system.d.ts.map +1 -1
- package/dist/types/generated/types/nonceState.d.ts.map +1 -1
- package/dist/types/generated/types/nonceVersion.d.ts.map +1 -1
- package/package.json +15 -27
- package/dist/types/generated/shared/index.d.ts +0 -50
- package/dist/types/generated/shared/index.d.ts.map +0 -1
package/dist/src/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getEnumEncoder, getU32Encoder, getEnumDecoder, getU32Decoder, combineCodec, getStructEncoder, getAddressEncoder, getU64Encoder, getStructDecoder, getAddressDecoder, getU64Decoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts,
|
|
1
|
+
import { getEnumEncoder, getU32Encoder, getEnumDecoder, getU32Decoder, combineCodec, getStructEncoder, getAddressEncoder, getU64Encoder, getStructDecoder, getAddressDecoder, getU64Decoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, transformEncoder, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, containsBytes, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, assertIsInstructionWithAccounts, isProgramError, BASE_ACCOUNT_SIZE } from '@solana/kit';
|
|
2
|
+
import { getAccountMetaFactory, addSelfFetchFunctions, addSelfPlanAndSendFunctions } from '@solana/kit/program-client-core';
|
|
2
3
|
|
|
3
4
|
// src/generated/accounts/nonce.ts
|
|
4
5
|
var NonceState = /* @__PURE__ */ ((NonceState2) => {
|
|
@@ -53,10 +54,7 @@ function getNonceCodec() {
|
|
|
53
54
|
return combineCodec(getNonceEncoder(), getNonceDecoder());
|
|
54
55
|
}
|
|
55
56
|
function decodeNonce(encodedAccount) {
|
|
56
|
-
return decodeAccount(
|
|
57
|
-
encodedAccount,
|
|
58
|
-
getNonceDecoder()
|
|
59
|
-
);
|
|
57
|
+
return decodeAccount(encodedAccount, getNonceDecoder());
|
|
60
58
|
}
|
|
61
59
|
async function fetchNonce(rpc, address, config) {
|
|
62
60
|
const maybeAccount = await fetchMaybeNonce(rpc, address, config);
|
|
@@ -79,183 +77,39 @@ async function fetchAllMaybeNonce(rpc, addresses, config) {
|
|
|
79
77
|
function getNonceSize() {
|
|
80
78
|
return 80;
|
|
81
79
|
}
|
|
82
|
-
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
83
|
-
var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
|
|
84
|
-
SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
|
|
85
|
-
return SystemAccount2;
|
|
86
|
-
})(SystemAccount || {});
|
|
87
|
-
var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
|
|
88
|
-
SystemInstruction2[SystemInstruction2["CreateAccount"] = 0] = "CreateAccount";
|
|
89
|
-
SystemInstruction2[SystemInstruction2["Assign"] = 1] = "Assign";
|
|
90
|
-
SystemInstruction2[SystemInstruction2["TransferSol"] = 2] = "TransferSol";
|
|
91
|
-
SystemInstruction2[SystemInstruction2["CreateAccountWithSeed"] = 3] = "CreateAccountWithSeed";
|
|
92
|
-
SystemInstruction2[SystemInstruction2["AdvanceNonceAccount"] = 4] = "AdvanceNonceAccount";
|
|
93
|
-
SystemInstruction2[SystemInstruction2["WithdrawNonceAccount"] = 5] = "WithdrawNonceAccount";
|
|
94
|
-
SystemInstruction2[SystemInstruction2["InitializeNonceAccount"] = 6] = "InitializeNonceAccount";
|
|
95
|
-
SystemInstruction2[SystemInstruction2["AuthorizeNonceAccount"] = 7] = "AuthorizeNonceAccount";
|
|
96
|
-
SystemInstruction2[SystemInstruction2["Allocate"] = 8] = "Allocate";
|
|
97
|
-
SystemInstruction2[SystemInstruction2["AllocateWithSeed"] = 9] = "AllocateWithSeed";
|
|
98
|
-
SystemInstruction2[SystemInstruction2["AssignWithSeed"] = 10] = "AssignWithSeed";
|
|
99
|
-
SystemInstruction2[SystemInstruction2["TransferSolWithSeed"] = 11] = "TransferSolWithSeed";
|
|
100
|
-
SystemInstruction2[SystemInstruction2["UpgradeNonceAccount"] = 12] = "UpgradeNonceAccount";
|
|
101
|
-
return SystemInstruction2;
|
|
102
|
-
})(SystemInstruction || {});
|
|
103
|
-
function identifySystemInstruction(instruction) {
|
|
104
|
-
const data = "data" in instruction ? instruction.data : instruction;
|
|
105
|
-
if (containsBytes(data, getU32Encoder().encode(0), 0)) {
|
|
106
|
-
return 0 /* CreateAccount */;
|
|
107
|
-
}
|
|
108
|
-
if (containsBytes(data, getU32Encoder().encode(1), 0)) {
|
|
109
|
-
return 1 /* Assign */;
|
|
110
|
-
}
|
|
111
|
-
if (containsBytes(data, getU32Encoder().encode(2), 0)) {
|
|
112
|
-
return 2 /* TransferSol */;
|
|
113
|
-
}
|
|
114
|
-
if (containsBytes(data, getU32Encoder().encode(3), 0)) {
|
|
115
|
-
return 3 /* CreateAccountWithSeed */;
|
|
116
|
-
}
|
|
117
|
-
if (containsBytes(data, getU32Encoder().encode(4), 0)) {
|
|
118
|
-
return 4 /* AdvanceNonceAccount */;
|
|
119
|
-
}
|
|
120
|
-
if (containsBytes(data, getU32Encoder().encode(5), 0)) {
|
|
121
|
-
return 5 /* WithdrawNonceAccount */;
|
|
122
|
-
}
|
|
123
|
-
if (containsBytes(data, getU32Encoder().encode(6), 0)) {
|
|
124
|
-
return 6 /* InitializeNonceAccount */;
|
|
125
|
-
}
|
|
126
|
-
if (containsBytes(data, getU32Encoder().encode(7), 0)) {
|
|
127
|
-
return 7 /* AuthorizeNonceAccount */;
|
|
128
|
-
}
|
|
129
|
-
if (containsBytes(data, getU32Encoder().encode(8), 0)) {
|
|
130
|
-
return 8 /* Allocate */;
|
|
131
|
-
}
|
|
132
|
-
if (containsBytes(data, getU32Encoder().encode(9), 0)) {
|
|
133
|
-
return 9 /* AllocateWithSeed */;
|
|
134
|
-
}
|
|
135
|
-
if (containsBytes(data, getU32Encoder().encode(10), 0)) {
|
|
136
|
-
return 10 /* AssignWithSeed */;
|
|
137
|
-
}
|
|
138
|
-
if (containsBytes(data, getU32Encoder().encode(11), 0)) {
|
|
139
|
-
return 11 /* TransferSolWithSeed */;
|
|
140
|
-
}
|
|
141
|
-
if (containsBytes(data, getU32Encoder().encode(12), 0)) {
|
|
142
|
-
return 12 /* UpgradeNonceAccount */;
|
|
143
|
-
}
|
|
144
|
-
throw new Error(
|
|
145
|
-
"The provided instruction could not be identified as a system instruction."
|
|
146
|
-
);
|
|
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
|
-
}
|
|
187
|
-
function expectAddress(value) {
|
|
188
|
-
if (!value) {
|
|
189
|
-
throw new Error("Expected a Address.");
|
|
190
|
-
}
|
|
191
|
-
if (typeof value === "object" && "address" in value) {
|
|
192
|
-
return value.address;
|
|
193
|
-
}
|
|
194
|
-
if (Array.isArray(value)) {
|
|
195
|
-
return value[0];
|
|
196
|
-
}
|
|
197
|
-
return value;
|
|
198
|
-
}
|
|
199
|
-
function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
|
|
200
|
-
return (account) => {
|
|
201
|
-
if (!account.value) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const writableRole = account.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
|
|
205
|
-
return Object.freeze({
|
|
206
|
-
address: expectAddress(account.value),
|
|
207
|
-
role: isTransactionSigner(account.value) ? upgradeRoleToSigner(writableRole) : writableRole,
|
|
208
|
-
...isTransactionSigner(account.value) ? { signer: account.value } : {}
|
|
209
|
-
});
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function isTransactionSigner(value) {
|
|
213
|
-
return !!value && typeof value === "object" && "address" in value && isTransactionSigner$1(value);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// src/generated/instructions/advanceNonceAccount.ts
|
|
217
80
|
var ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR = 4;
|
|
218
81
|
function getAdvanceNonceAccountDiscriminatorBytes() {
|
|
219
82
|
return getU32Encoder().encode(ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR);
|
|
220
83
|
}
|
|
221
84
|
function getAdvanceNonceAccountInstructionDataEncoder() {
|
|
222
|
-
return transformEncoder(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
discriminator: ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
227
|
-
})
|
|
228
|
-
);
|
|
85
|
+
return transformEncoder(getStructEncoder([["discriminator", getU32Encoder()]]), (value) => ({
|
|
86
|
+
...value,
|
|
87
|
+
discriminator: ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
88
|
+
}));
|
|
229
89
|
}
|
|
230
90
|
function getAdvanceNonceAccountInstructionDataDecoder() {
|
|
231
91
|
return getStructDecoder([["discriminator", getU32Decoder()]]);
|
|
232
92
|
}
|
|
233
93
|
function getAdvanceNonceAccountInstructionDataCodec() {
|
|
234
|
-
return combineCodec(
|
|
235
|
-
getAdvanceNonceAccountInstructionDataEncoder(),
|
|
236
|
-
getAdvanceNonceAccountInstructionDataDecoder()
|
|
237
|
-
);
|
|
94
|
+
return combineCodec(getAdvanceNonceAccountInstructionDataEncoder(), getAdvanceNonceAccountInstructionDataDecoder());
|
|
238
95
|
}
|
|
239
96
|
function getAdvanceNonceAccountInstruction(input, config) {
|
|
240
97
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
241
98
|
const originalAccounts = {
|
|
242
99
|
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
243
|
-
recentBlockhashesSysvar: {
|
|
244
|
-
value: input.recentBlockhashesSysvar ?? null,
|
|
245
|
-
isWritable: false
|
|
246
|
-
},
|
|
100
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
247
101
|
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
|
|
248
102
|
};
|
|
249
103
|
const accounts = originalAccounts;
|
|
250
104
|
if (!accounts.recentBlockhashesSysvar.value) {
|
|
251
105
|
accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
|
|
252
106
|
}
|
|
253
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
107
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
254
108
|
return Object.freeze({
|
|
255
109
|
accounts: [
|
|
256
|
-
getAccountMeta(accounts.nonceAccount),
|
|
257
|
-
getAccountMeta(accounts.recentBlockhashesSysvar),
|
|
258
|
-
getAccountMeta(accounts.nonceAuthority)
|
|
110
|
+
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
111
|
+
getAccountMeta("recentBlockhashesSysvar", accounts.recentBlockhashesSysvar),
|
|
112
|
+
getAccountMeta("nonceAuthority", accounts.nonceAuthority)
|
|
259
113
|
],
|
|
260
114
|
data: getAdvanceNonceAccountInstructionDataEncoder().encode({}),
|
|
261
115
|
programAddress
|
|
@@ -263,7 +117,10 @@ function getAdvanceNonceAccountInstruction(input, config) {
|
|
|
263
117
|
}
|
|
264
118
|
function parseAdvanceNonceAccountInstruction(instruction) {
|
|
265
119
|
if (instruction.accounts.length < 3) {
|
|
266
|
-
throw new
|
|
120
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
121
|
+
actualAccountMetas: instruction.accounts.length,
|
|
122
|
+
expectedAccountMetas: 3
|
|
123
|
+
});
|
|
267
124
|
}
|
|
268
125
|
let accountIndex = 0;
|
|
269
126
|
const getNextAccount = () => {
|
|
@@ -278,9 +135,7 @@ function parseAdvanceNonceAccountInstruction(instruction) {
|
|
|
278
135
|
recentBlockhashesSysvar: getNextAccount(),
|
|
279
136
|
nonceAuthority: getNextAccount()
|
|
280
137
|
},
|
|
281
|
-
data: getAdvanceNonceAccountInstructionDataDecoder().decode(
|
|
282
|
-
instruction.data
|
|
283
|
-
)
|
|
138
|
+
data: getAdvanceNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
284
139
|
};
|
|
285
140
|
}
|
|
286
141
|
var ALLOCATE_DISCRIMINATOR = 8;
|
|
@@ -303,30 +158,26 @@ function getAllocateInstructionDataDecoder() {
|
|
|
303
158
|
]);
|
|
304
159
|
}
|
|
305
160
|
function getAllocateInstructionDataCodec() {
|
|
306
|
-
return combineCodec(
|
|
307
|
-
getAllocateInstructionDataEncoder(),
|
|
308
|
-
getAllocateInstructionDataDecoder()
|
|
309
|
-
);
|
|
161
|
+
return combineCodec(getAllocateInstructionDataEncoder(), getAllocateInstructionDataDecoder());
|
|
310
162
|
}
|
|
311
163
|
function getAllocateInstruction(input, config) {
|
|
312
164
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
313
|
-
const originalAccounts = {
|
|
314
|
-
newAccount: { value: input.newAccount ?? null, isWritable: true }
|
|
315
|
-
};
|
|
165
|
+
const originalAccounts = { newAccount: { value: input.newAccount ?? null, isWritable: true } };
|
|
316
166
|
const accounts = originalAccounts;
|
|
317
167
|
const args = { ...input };
|
|
318
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
168
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
319
169
|
return Object.freeze({
|
|
320
|
-
accounts: [getAccountMeta(accounts.newAccount)],
|
|
321
|
-
data: getAllocateInstructionDataEncoder().encode(
|
|
322
|
-
args
|
|
323
|
-
),
|
|
170
|
+
accounts: [getAccountMeta("newAccount", accounts.newAccount)],
|
|
171
|
+
data: getAllocateInstructionDataEncoder().encode(args),
|
|
324
172
|
programAddress
|
|
325
173
|
});
|
|
326
174
|
}
|
|
327
175
|
function parseAllocateInstruction(instruction) {
|
|
328
176
|
if (instruction.accounts.length < 1) {
|
|
329
|
-
throw new
|
|
177
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
178
|
+
actualAccountMetas: instruction.accounts.length,
|
|
179
|
+
expectedAccountMetas: 1
|
|
180
|
+
});
|
|
330
181
|
}
|
|
331
182
|
let accountIndex = 0;
|
|
332
183
|
const getNextAccount = () => {
|
|
@@ -366,10 +217,7 @@ function getAllocateWithSeedInstructionDataDecoder() {
|
|
|
366
217
|
]);
|
|
367
218
|
}
|
|
368
219
|
function getAllocateWithSeedInstructionDataCodec() {
|
|
369
|
-
return combineCodec(
|
|
370
|
-
getAllocateWithSeedInstructionDataEncoder(),
|
|
371
|
-
getAllocateWithSeedInstructionDataDecoder()
|
|
372
|
-
);
|
|
220
|
+
return combineCodec(getAllocateWithSeedInstructionDataEncoder(), getAllocateWithSeedInstructionDataDecoder());
|
|
373
221
|
}
|
|
374
222
|
function getAllocateWithSeedInstruction(input, config) {
|
|
375
223
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -379,21 +227,22 @@ function getAllocateWithSeedInstruction(input, config) {
|
|
|
379
227
|
};
|
|
380
228
|
const accounts = originalAccounts;
|
|
381
229
|
const args = { ...input };
|
|
382
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
230
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
383
231
|
return Object.freeze({
|
|
384
232
|
accounts: [
|
|
385
|
-
getAccountMeta(accounts.newAccount),
|
|
386
|
-
getAccountMeta(accounts.baseAccount)
|
|
233
|
+
getAccountMeta("newAccount", accounts.newAccount),
|
|
234
|
+
getAccountMeta("baseAccount", accounts.baseAccount)
|
|
387
235
|
],
|
|
388
|
-
data: getAllocateWithSeedInstructionDataEncoder().encode(
|
|
389
|
-
args
|
|
390
|
-
),
|
|
236
|
+
data: getAllocateWithSeedInstructionDataEncoder().encode(args),
|
|
391
237
|
programAddress
|
|
392
238
|
});
|
|
393
239
|
}
|
|
394
240
|
function parseAllocateWithSeedInstruction(instruction) {
|
|
395
241
|
if (instruction.accounts.length < 2) {
|
|
396
|
-
throw new
|
|
242
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
243
|
+
actualAccountMetas: instruction.accounts.length,
|
|
244
|
+
expectedAccountMetas: 2
|
|
245
|
+
});
|
|
397
246
|
}
|
|
398
247
|
let accountIndex = 0;
|
|
399
248
|
const getNextAccount = () => {
|
|
@@ -427,30 +276,26 @@ function getAssignInstructionDataDecoder() {
|
|
|
427
276
|
]);
|
|
428
277
|
}
|
|
429
278
|
function getAssignInstructionDataCodec() {
|
|
430
|
-
return combineCodec(
|
|
431
|
-
getAssignInstructionDataEncoder(),
|
|
432
|
-
getAssignInstructionDataDecoder()
|
|
433
|
-
);
|
|
279
|
+
return combineCodec(getAssignInstructionDataEncoder(), getAssignInstructionDataDecoder());
|
|
434
280
|
}
|
|
435
281
|
function getAssignInstruction(input, config) {
|
|
436
282
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
437
|
-
const originalAccounts = {
|
|
438
|
-
account: { value: input.account ?? null, isWritable: true }
|
|
439
|
-
};
|
|
283
|
+
const originalAccounts = { account: { value: input.account ?? null, isWritable: true } };
|
|
440
284
|
const accounts = originalAccounts;
|
|
441
285
|
const args = { ...input };
|
|
442
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
286
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
443
287
|
return Object.freeze({
|
|
444
|
-
accounts: [getAccountMeta(accounts.account)],
|
|
445
|
-
data: getAssignInstructionDataEncoder().encode(
|
|
446
|
-
args
|
|
447
|
-
),
|
|
288
|
+
accounts: [getAccountMeta("account", accounts.account)],
|
|
289
|
+
data: getAssignInstructionDataEncoder().encode(args),
|
|
448
290
|
programAddress
|
|
449
291
|
});
|
|
450
292
|
}
|
|
451
293
|
function parseAssignInstruction(instruction) {
|
|
452
294
|
if (instruction.accounts.length < 1) {
|
|
453
|
-
throw new
|
|
295
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
296
|
+
actualAccountMetas: instruction.accounts.length,
|
|
297
|
+
expectedAccountMetas: 1
|
|
298
|
+
});
|
|
454
299
|
}
|
|
455
300
|
let accountIndex = 0;
|
|
456
301
|
const getNextAccount = () => {
|
|
@@ -488,10 +333,7 @@ function getAssignWithSeedInstructionDataDecoder() {
|
|
|
488
333
|
]);
|
|
489
334
|
}
|
|
490
335
|
function getAssignWithSeedInstructionDataCodec() {
|
|
491
|
-
return combineCodec(
|
|
492
|
-
getAssignWithSeedInstructionDataEncoder(),
|
|
493
|
-
getAssignWithSeedInstructionDataDecoder()
|
|
494
|
-
);
|
|
336
|
+
return combineCodec(getAssignWithSeedInstructionDataEncoder(), getAssignWithSeedInstructionDataDecoder());
|
|
495
337
|
}
|
|
496
338
|
function getAssignWithSeedInstruction(input, config) {
|
|
497
339
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -501,21 +343,19 @@ function getAssignWithSeedInstruction(input, config) {
|
|
|
501
343
|
};
|
|
502
344
|
const accounts = originalAccounts;
|
|
503
345
|
const args = { ...input };
|
|
504
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
346
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
505
347
|
return Object.freeze({
|
|
506
|
-
accounts: [
|
|
507
|
-
|
|
508
|
-
getAccountMeta(accounts.baseAccount)
|
|
509
|
-
],
|
|
510
|
-
data: getAssignWithSeedInstructionDataEncoder().encode(
|
|
511
|
-
args
|
|
512
|
-
),
|
|
348
|
+
accounts: [getAccountMeta("account", accounts.account), getAccountMeta("baseAccount", accounts.baseAccount)],
|
|
349
|
+
data: getAssignWithSeedInstructionDataEncoder().encode(args),
|
|
513
350
|
programAddress
|
|
514
351
|
});
|
|
515
352
|
}
|
|
516
353
|
function parseAssignWithSeedInstruction(instruction) {
|
|
517
354
|
if (instruction.accounts.length < 2) {
|
|
518
|
-
throw new
|
|
355
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
356
|
+
actualAccountMetas: instruction.accounts.length,
|
|
357
|
+
expectedAccountMetas: 2
|
|
358
|
+
});
|
|
519
359
|
}
|
|
520
360
|
let accountIndex = 0;
|
|
521
361
|
const getNextAccount = () => {
|
|
@@ -539,10 +379,7 @@ function getAuthorizeNonceAccountInstructionDataEncoder() {
|
|
|
539
379
|
["discriminator", getU32Encoder()],
|
|
540
380
|
["newNonceAuthority", getAddressEncoder()]
|
|
541
381
|
]),
|
|
542
|
-
(value) => ({
|
|
543
|
-
...value,
|
|
544
|
-
discriminator: AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
545
|
-
})
|
|
382
|
+
(value) => ({ ...value, discriminator: AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR })
|
|
546
383
|
);
|
|
547
384
|
}
|
|
548
385
|
function getAuthorizeNonceAccountInstructionDataDecoder() {
|
|
@@ -565,21 +402,22 @@ function getAuthorizeNonceAccountInstruction(input, config) {
|
|
|
565
402
|
};
|
|
566
403
|
const accounts = originalAccounts;
|
|
567
404
|
const args = { ...input };
|
|
568
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
405
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
569
406
|
return Object.freeze({
|
|
570
407
|
accounts: [
|
|
571
|
-
getAccountMeta(accounts.nonceAccount),
|
|
572
|
-
getAccountMeta(accounts.nonceAuthority)
|
|
408
|
+
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
409
|
+
getAccountMeta("nonceAuthority", accounts.nonceAuthority)
|
|
573
410
|
],
|
|
574
|
-
data: getAuthorizeNonceAccountInstructionDataEncoder().encode(
|
|
575
|
-
args
|
|
576
|
-
),
|
|
411
|
+
data: getAuthorizeNonceAccountInstructionDataEncoder().encode(args),
|
|
577
412
|
programAddress
|
|
578
413
|
});
|
|
579
414
|
}
|
|
580
415
|
function parseAuthorizeNonceAccountInstruction(instruction) {
|
|
581
416
|
if (instruction.accounts.length < 2) {
|
|
582
|
-
throw new
|
|
417
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
418
|
+
actualAccountMetas: instruction.accounts.length,
|
|
419
|
+
expectedAccountMetas: 2
|
|
420
|
+
});
|
|
583
421
|
}
|
|
584
422
|
let accountIndex = 0;
|
|
585
423
|
const getNextAccount = () => {
|
|
@@ -589,13 +427,8 @@ function parseAuthorizeNonceAccountInstruction(instruction) {
|
|
|
589
427
|
};
|
|
590
428
|
return {
|
|
591
429
|
programAddress: instruction.programAddress,
|
|
592
|
-
accounts: {
|
|
593
|
-
|
|
594
|
-
nonceAuthority: getNextAccount()
|
|
595
|
-
},
|
|
596
|
-
data: getAuthorizeNonceAccountInstructionDataDecoder().decode(
|
|
597
|
-
instruction.data
|
|
598
|
-
)
|
|
430
|
+
accounts: { nonceAccount: getNextAccount(), nonceAuthority: getNextAccount() },
|
|
431
|
+
data: getAuthorizeNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
599
432
|
};
|
|
600
433
|
}
|
|
601
434
|
var CREATE_ACCOUNT_DISCRIMINATOR = 0;
|
|
@@ -622,10 +455,7 @@ function getCreateAccountInstructionDataDecoder() {
|
|
|
622
455
|
]);
|
|
623
456
|
}
|
|
624
457
|
function getCreateAccountInstructionDataCodec() {
|
|
625
|
-
return combineCodec(
|
|
626
|
-
getCreateAccountInstructionDataEncoder(),
|
|
627
|
-
getCreateAccountInstructionDataDecoder()
|
|
628
|
-
);
|
|
458
|
+
return combineCodec(getCreateAccountInstructionDataEncoder(), getCreateAccountInstructionDataDecoder());
|
|
629
459
|
}
|
|
630
460
|
function getCreateAccountInstruction(input, config) {
|
|
631
461
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -635,26 +465,21 @@ function getCreateAccountInstruction(input, config) {
|
|
|
635
465
|
};
|
|
636
466
|
const accounts = originalAccounts;
|
|
637
467
|
const args = { ...input };
|
|
638
|
-
const byteDelta = [Number(args.space) + BASE_ACCOUNT_SIZE].reduce(
|
|
639
|
-
|
|
640
|
-
0
|
|
641
|
-
);
|
|
642
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
468
|
+
const byteDelta = [Number(args.space) + BASE_ACCOUNT_SIZE].reduce((a, b) => a + b, 0);
|
|
469
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
643
470
|
return Object.freeze({
|
|
644
|
-
accounts: [
|
|
645
|
-
getAccountMeta(accounts.payer),
|
|
646
|
-
getAccountMeta(accounts.newAccount)
|
|
647
|
-
],
|
|
471
|
+
accounts: [getAccountMeta("payer", accounts.payer), getAccountMeta("newAccount", accounts.newAccount)],
|
|
648
472
|
byteDelta,
|
|
649
|
-
data: getCreateAccountInstructionDataEncoder().encode(
|
|
650
|
-
args
|
|
651
|
-
),
|
|
473
|
+
data: getCreateAccountInstructionDataEncoder().encode(args),
|
|
652
474
|
programAddress
|
|
653
475
|
});
|
|
654
476
|
}
|
|
655
477
|
function parseCreateAccountInstruction(instruction) {
|
|
656
478
|
if (instruction.accounts.length < 2) {
|
|
657
|
-
throw new
|
|
479
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
480
|
+
actualAccountMetas: instruction.accounts.length,
|
|
481
|
+
expectedAccountMetas: 2
|
|
482
|
+
});
|
|
658
483
|
}
|
|
659
484
|
let accountIndex = 0;
|
|
660
485
|
const getNextAccount = () => {
|
|
@@ -682,10 +507,7 @@ function getCreateAccountWithSeedInstructionDataEncoder() {
|
|
|
682
507
|
["space", getU64Encoder()],
|
|
683
508
|
["programAddress", getAddressEncoder()]
|
|
684
509
|
]),
|
|
685
|
-
(value) => ({
|
|
686
|
-
...value,
|
|
687
|
-
discriminator: CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR
|
|
688
|
-
})
|
|
510
|
+
(value) => ({ ...value, discriminator: CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR })
|
|
689
511
|
);
|
|
690
512
|
}
|
|
691
513
|
function getCreateAccountWithSeedInstructionDataDecoder() {
|
|
@@ -713,22 +535,23 @@ function getCreateAccountWithSeedInstruction(input, config) {
|
|
|
713
535
|
};
|
|
714
536
|
const accounts = originalAccounts;
|
|
715
537
|
const args = { ...input };
|
|
716
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
538
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
717
539
|
return Object.freeze({
|
|
718
540
|
accounts: [
|
|
719
|
-
getAccountMeta(accounts.payer),
|
|
720
|
-
getAccountMeta(accounts.newAccount),
|
|
721
|
-
getAccountMeta(accounts.baseAccount)
|
|
541
|
+
getAccountMeta("payer", accounts.payer),
|
|
542
|
+
getAccountMeta("newAccount", accounts.newAccount),
|
|
543
|
+
getAccountMeta("baseAccount", accounts.baseAccount)
|
|
722
544
|
].filter((x) => x !== void 0),
|
|
723
|
-
data: getCreateAccountWithSeedInstructionDataEncoder().encode(
|
|
724
|
-
args
|
|
725
|
-
),
|
|
545
|
+
data: getCreateAccountWithSeedInstructionDataEncoder().encode(args),
|
|
726
546
|
programAddress
|
|
727
547
|
});
|
|
728
548
|
}
|
|
729
549
|
function parseCreateAccountWithSeedInstruction(instruction) {
|
|
730
550
|
if (instruction.accounts.length < 2) {
|
|
731
|
-
throw new
|
|
551
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
552
|
+
actualAccountMetas: instruction.accounts.length,
|
|
553
|
+
expectedAccountMetas: 2
|
|
554
|
+
});
|
|
732
555
|
}
|
|
733
556
|
let accountIndex = 0;
|
|
734
557
|
const getNextAccount = () => {
|
|
@@ -744,14 +567,8 @@ function parseCreateAccountWithSeedInstruction(instruction) {
|
|
|
744
567
|
};
|
|
745
568
|
return {
|
|
746
569
|
programAddress: instruction.programAddress,
|
|
747
|
-
accounts: {
|
|
748
|
-
|
|
749
|
-
newAccount: getNextAccount(),
|
|
750
|
-
baseAccount: getNextOptionalAccount()
|
|
751
|
-
},
|
|
752
|
-
data: getCreateAccountWithSeedInstructionDataDecoder().decode(
|
|
753
|
-
instruction.data
|
|
754
|
-
)
|
|
570
|
+
accounts: { payer: getNextAccount(), newAccount: getNextAccount(), baseAccount: getNextOptionalAccount() },
|
|
571
|
+
data: getCreateAccountWithSeedInstructionDataDecoder().decode(instruction.data)
|
|
755
572
|
};
|
|
756
573
|
}
|
|
757
574
|
var INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR = 6;
|
|
@@ -764,10 +581,7 @@ function getInitializeNonceAccountInstructionDataEncoder() {
|
|
|
764
581
|
["discriminator", getU32Encoder()],
|
|
765
582
|
["nonceAuthority", getAddressEncoder()]
|
|
766
583
|
]),
|
|
767
|
-
(value) => ({
|
|
768
|
-
...value,
|
|
769
|
-
discriminator: INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
770
|
-
})
|
|
584
|
+
(value) => ({ ...value, discriminator: INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR })
|
|
771
585
|
);
|
|
772
586
|
}
|
|
773
587
|
function getInitializeNonceAccountInstructionDataDecoder() {
|
|
@@ -786,10 +600,7 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
786
600
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
787
601
|
const originalAccounts = {
|
|
788
602
|
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
789
|
-
recentBlockhashesSysvar: {
|
|
790
|
-
value: input.recentBlockhashesSysvar ?? null,
|
|
791
|
-
isWritable: false
|
|
792
|
-
},
|
|
603
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
793
604
|
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false }
|
|
794
605
|
};
|
|
795
606
|
const accounts = originalAccounts;
|
|
@@ -800,12 +611,12 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
800
611
|
if (!accounts.rentSysvar.value) {
|
|
801
612
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
802
613
|
}
|
|
803
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
614
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
804
615
|
return Object.freeze({
|
|
805
616
|
accounts: [
|
|
806
|
-
getAccountMeta(accounts.nonceAccount),
|
|
807
|
-
getAccountMeta(accounts.recentBlockhashesSysvar),
|
|
808
|
-
getAccountMeta(accounts.rentSysvar)
|
|
617
|
+
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
618
|
+
getAccountMeta("recentBlockhashesSysvar", accounts.recentBlockhashesSysvar),
|
|
619
|
+
getAccountMeta("rentSysvar", accounts.rentSysvar)
|
|
809
620
|
],
|
|
810
621
|
data: getInitializeNonceAccountInstructionDataEncoder().encode(
|
|
811
622
|
args
|
|
@@ -815,7 +626,10 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
815
626
|
}
|
|
816
627
|
function parseInitializeNonceAccountInstruction(instruction) {
|
|
817
628
|
if (instruction.accounts.length < 3) {
|
|
818
|
-
throw new
|
|
629
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
630
|
+
actualAccountMetas: instruction.accounts.length,
|
|
631
|
+
expectedAccountMetas: 3
|
|
632
|
+
});
|
|
819
633
|
}
|
|
820
634
|
let accountIndex = 0;
|
|
821
635
|
const getNextAccount = () => {
|
|
@@ -830,9 +644,7 @@ function parseInitializeNonceAccountInstruction(instruction) {
|
|
|
830
644
|
recentBlockhashesSysvar: getNextAccount(),
|
|
831
645
|
rentSysvar: getNextAccount()
|
|
832
646
|
},
|
|
833
|
-
data: getInitializeNonceAccountInstructionDataDecoder().decode(
|
|
834
|
-
instruction.data
|
|
835
|
-
)
|
|
647
|
+
data: getInitializeNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
836
648
|
};
|
|
837
649
|
}
|
|
838
650
|
var TRANSFER_SOL_DISCRIMINATOR = 2;
|
|
@@ -855,10 +667,7 @@ function getTransferSolInstructionDataDecoder() {
|
|
|
855
667
|
]);
|
|
856
668
|
}
|
|
857
669
|
function getTransferSolInstructionDataCodec() {
|
|
858
|
-
return combineCodec(
|
|
859
|
-
getTransferSolInstructionDataEncoder(),
|
|
860
|
-
getTransferSolInstructionDataDecoder()
|
|
861
|
-
);
|
|
670
|
+
return combineCodec(getTransferSolInstructionDataEncoder(), getTransferSolInstructionDataDecoder());
|
|
862
671
|
}
|
|
863
672
|
function getTransferSolInstruction(input, config) {
|
|
864
673
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -868,21 +677,19 @@ function getTransferSolInstruction(input, config) {
|
|
|
868
677
|
};
|
|
869
678
|
const accounts = originalAccounts;
|
|
870
679
|
const args = { ...input };
|
|
871
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
680
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
872
681
|
return Object.freeze({
|
|
873
|
-
accounts: [
|
|
874
|
-
|
|
875
|
-
getAccountMeta(accounts.destination)
|
|
876
|
-
],
|
|
877
|
-
data: getTransferSolInstructionDataEncoder().encode(
|
|
878
|
-
args
|
|
879
|
-
),
|
|
682
|
+
accounts: [getAccountMeta("source", accounts.source), getAccountMeta("destination", accounts.destination)],
|
|
683
|
+
data: getTransferSolInstructionDataEncoder().encode(args),
|
|
880
684
|
programAddress
|
|
881
685
|
});
|
|
882
686
|
}
|
|
883
687
|
function parseTransferSolInstruction(instruction) {
|
|
884
688
|
if (instruction.accounts.length < 2) {
|
|
885
|
-
throw new
|
|
689
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
690
|
+
actualAccountMetas: instruction.accounts.length,
|
|
691
|
+
expectedAccountMetas: 2
|
|
692
|
+
});
|
|
886
693
|
}
|
|
887
694
|
let accountIndex = 0;
|
|
888
695
|
const getNextAccount = () => {
|
|
@@ -908,10 +715,7 @@ function getTransferSolWithSeedInstructionDataEncoder() {
|
|
|
908
715
|
["fromSeed", addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
|
|
909
716
|
["fromOwner", getAddressEncoder()]
|
|
910
717
|
]),
|
|
911
|
-
(value) => ({
|
|
912
|
-
...value,
|
|
913
|
-
discriminator: TRANSFER_SOL_WITH_SEED_DISCRIMINATOR
|
|
914
|
-
})
|
|
718
|
+
(value) => ({ ...value, discriminator: TRANSFER_SOL_WITH_SEED_DISCRIMINATOR })
|
|
915
719
|
);
|
|
916
720
|
}
|
|
917
721
|
function getTransferSolWithSeedInstructionDataDecoder() {
|
|
@@ -923,10 +727,7 @@ function getTransferSolWithSeedInstructionDataDecoder() {
|
|
|
923
727
|
]);
|
|
924
728
|
}
|
|
925
729
|
function getTransferSolWithSeedInstructionDataCodec() {
|
|
926
|
-
return combineCodec(
|
|
927
|
-
getTransferSolWithSeedInstructionDataEncoder(),
|
|
928
|
-
getTransferSolWithSeedInstructionDataDecoder()
|
|
929
|
-
);
|
|
730
|
+
return combineCodec(getTransferSolWithSeedInstructionDataEncoder(), getTransferSolWithSeedInstructionDataDecoder());
|
|
930
731
|
}
|
|
931
732
|
function getTransferSolWithSeedInstruction(input, config) {
|
|
932
733
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -937,22 +738,23 @@ function getTransferSolWithSeedInstruction(input, config) {
|
|
|
937
738
|
};
|
|
938
739
|
const accounts = originalAccounts;
|
|
939
740
|
const args = { ...input };
|
|
940
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
741
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
941
742
|
return Object.freeze({
|
|
942
743
|
accounts: [
|
|
943
|
-
getAccountMeta(accounts.source),
|
|
944
|
-
getAccountMeta(accounts.baseAccount),
|
|
945
|
-
getAccountMeta(accounts.destination)
|
|
744
|
+
getAccountMeta("source", accounts.source),
|
|
745
|
+
getAccountMeta("baseAccount", accounts.baseAccount),
|
|
746
|
+
getAccountMeta("destination", accounts.destination)
|
|
946
747
|
],
|
|
947
|
-
data: getTransferSolWithSeedInstructionDataEncoder().encode(
|
|
948
|
-
args
|
|
949
|
-
),
|
|
748
|
+
data: getTransferSolWithSeedInstructionDataEncoder().encode(args),
|
|
950
749
|
programAddress
|
|
951
750
|
});
|
|
952
751
|
}
|
|
953
752
|
function parseTransferSolWithSeedInstruction(instruction) {
|
|
954
753
|
if (instruction.accounts.length < 3) {
|
|
955
|
-
throw new
|
|
754
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
755
|
+
actualAccountMetas: instruction.accounts.length,
|
|
756
|
+
expectedAccountMetas: 3
|
|
757
|
+
});
|
|
956
758
|
}
|
|
957
759
|
let accountIndex = 0;
|
|
958
760
|
const getNextAccount = () => {
|
|
@@ -962,14 +764,8 @@ function parseTransferSolWithSeedInstruction(instruction) {
|
|
|
962
764
|
};
|
|
963
765
|
return {
|
|
964
766
|
programAddress: instruction.programAddress,
|
|
965
|
-
accounts: {
|
|
966
|
-
|
|
967
|
-
baseAccount: getNextAccount(),
|
|
968
|
-
destination: getNextAccount()
|
|
969
|
-
},
|
|
970
|
-
data: getTransferSolWithSeedInstructionDataDecoder().decode(
|
|
971
|
-
instruction.data
|
|
972
|
-
)
|
|
767
|
+
accounts: { source: getNextAccount(), baseAccount: getNextAccount(), destination: getNextAccount() },
|
|
768
|
+
data: getTransferSolWithSeedInstructionDataDecoder().decode(instruction.data)
|
|
973
769
|
};
|
|
974
770
|
}
|
|
975
771
|
var UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR = 12;
|
|
@@ -977,39 +773,34 @@ function getUpgradeNonceAccountDiscriminatorBytes() {
|
|
|
977
773
|
return getU32Encoder().encode(UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR);
|
|
978
774
|
}
|
|
979
775
|
function getUpgradeNonceAccountInstructionDataEncoder() {
|
|
980
|
-
return transformEncoder(
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
discriminator: UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
985
|
-
})
|
|
986
|
-
);
|
|
776
|
+
return transformEncoder(getStructEncoder([["discriminator", getU32Encoder()]]), (value) => ({
|
|
777
|
+
...value,
|
|
778
|
+
discriminator: UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
779
|
+
}));
|
|
987
780
|
}
|
|
988
781
|
function getUpgradeNonceAccountInstructionDataDecoder() {
|
|
989
782
|
return getStructDecoder([["discriminator", getU32Decoder()]]);
|
|
990
783
|
}
|
|
991
784
|
function getUpgradeNonceAccountInstructionDataCodec() {
|
|
992
|
-
return combineCodec(
|
|
993
|
-
getUpgradeNonceAccountInstructionDataEncoder(),
|
|
994
|
-
getUpgradeNonceAccountInstructionDataDecoder()
|
|
995
|
-
);
|
|
785
|
+
return combineCodec(getUpgradeNonceAccountInstructionDataEncoder(), getUpgradeNonceAccountInstructionDataDecoder());
|
|
996
786
|
}
|
|
997
787
|
function getUpgradeNonceAccountInstruction(input, config) {
|
|
998
788
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
999
|
-
const originalAccounts = {
|
|
1000
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true }
|
|
1001
|
-
};
|
|
789
|
+
const originalAccounts = { nonceAccount: { value: input.nonceAccount ?? null, isWritable: true } };
|
|
1002
790
|
const accounts = originalAccounts;
|
|
1003
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
791
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
1004
792
|
return Object.freeze({
|
|
1005
|
-
accounts: [getAccountMeta(accounts.nonceAccount)],
|
|
793
|
+
accounts: [getAccountMeta("nonceAccount", accounts.nonceAccount)],
|
|
1006
794
|
data: getUpgradeNonceAccountInstructionDataEncoder().encode({}),
|
|
1007
795
|
programAddress
|
|
1008
796
|
});
|
|
1009
797
|
}
|
|
1010
798
|
function parseUpgradeNonceAccountInstruction(instruction) {
|
|
1011
799
|
if (instruction.accounts.length < 1) {
|
|
1012
|
-
throw new
|
|
800
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
801
|
+
actualAccountMetas: instruction.accounts.length,
|
|
802
|
+
expectedAccountMetas: 1
|
|
803
|
+
});
|
|
1013
804
|
}
|
|
1014
805
|
let accountIndex = 0;
|
|
1015
806
|
const getNextAccount = () => {
|
|
@@ -1020,9 +811,7 @@ function parseUpgradeNonceAccountInstruction(instruction) {
|
|
|
1020
811
|
return {
|
|
1021
812
|
programAddress: instruction.programAddress,
|
|
1022
813
|
accounts: { nonceAccount: getNextAccount() },
|
|
1023
|
-
data: getUpgradeNonceAccountInstructionDataDecoder().decode(
|
|
1024
|
-
instruction.data
|
|
1025
|
-
)
|
|
814
|
+
data: getUpgradeNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
1026
815
|
};
|
|
1027
816
|
}
|
|
1028
817
|
var WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR = 5;
|
|
@@ -1035,10 +824,7 @@ function getWithdrawNonceAccountInstructionDataEncoder() {
|
|
|
1035
824
|
["discriminator", getU32Encoder()],
|
|
1036
825
|
["withdrawAmount", getU64Encoder()]
|
|
1037
826
|
]),
|
|
1038
|
-
(value) => ({
|
|
1039
|
-
...value,
|
|
1040
|
-
discriminator: WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR
|
|
1041
|
-
})
|
|
827
|
+
(value) => ({ ...value, discriminator: WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR })
|
|
1042
828
|
);
|
|
1043
829
|
}
|
|
1044
830
|
function getWithdrawNonceAccountInstructionDataDecoder() {
|
|
@@ -1057,14 +843,8 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
1057
843
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
1058
844
|
const originalAccounts = {
|
|
1059
845
|
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
1060
|
-
recipientAccount: {
|
|
1061
|
-
|
|
1062
|
-
isWritable: true
|
|
1063
|
-
},
|
|
1064
|
-
recentBlockhashesSysvar: {
|
|
1065
|
-
value: input.recentBlockhashesSysvar ?? null,
|
|
1066
|
-
isWritable: false
|
|
1067
|
-
},
|
|
846
|
+
recipientAccount: { value: input.recipientAccount ?? null, isWritable: true },
|
|
847
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
1068
848
|
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false },
|
|
1069
849
|
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
|
|
1070
850
|
};
|
|
@@ -1076,24 +856,25 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
1076
856
|
if (!accounts.rentSysvar.value) {
|
|
1077
857
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
1078
858
|
}
|
|
1079
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
859
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
1080
860
|
return Object.freeze({
|
|
1081
861
|
accounts: [
|
|
1082
|
-
getAccountMeta(accounts.nonceAccount),
|
|
1083
|
-
getAccountMeta(accounts.recipientAccount),
|
|
1084
|
-
getAccountMeta(accounts.recentBlockhashesSysvar),
|
|
1085
|
-
getAccountMeta(accounts.rentSysvar),
|
|
1086
|
-
getAccountMeta(accounts.nonceAuthority)
|
|
862
|
+
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
863
|
+
getAccountMeta("recipientAccount", accounts.recipientAccount),
|
|
864
|
+
getAccountMeta("recentBlockhashesSysvar", accounts.recentBlockhashesSysvar),
|
|
865
|
+
getAccountMeta("rentSysvar", accounts.rentSysvar),
|
|
866
|
+
getAccountMeta("nonceAuthority", accounts.nonceAuthority)
|
|
1087
867
|
],
|
|
1088
|
-
data: getWithdrawNonceAccountInstructionDataEncoder().encode(
|
|
1089
|
-
args
|
|
1090
|
-
),
|
|
868
|
+
data: getWithdrawNonceAccountInstructionDataEncoder().encode(args),
|
|
1091
869
|
programAddress
|
|
1092
870
|
});
|
|
1093
871
|
}
|
|
1094
872
|
function parseWithdrawNonceAccountInstruction(instruction) {
|
|
1095
873
|
if (instruction.accounts.length < 5) {
|
|
1096
|
-
throw new
|
|
874
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
875
|
+
actualAccountMetas: instruction.accounts.length,
|
|
876
|
+
expectedAccountMetas: 5
|
|
877
|
+
});
|
|
1097
878
|
}
|
|
1098
879
|
let accountIndex = 0;
|
|
1099
880
|
const getNextAccount = () => {
|
|
@@ -1110,12 +891,233 @@ function parseWithdrawNonceAccountInstruction(instruction) {
|
|
|
1110
891
|
rentSysvar: getNextAccount(),
|
|
1111
892
|
nonceAuthority: getNextAccount()
|
|
1112
893
|
},
|
|
1113
|
-
data: getWithdrawNonceAccountInstructionDataDecoder().decode(
|
|
1114
|
-
|
|
1115
|
-
|
|
894
|
+
data: getWithdrawNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/generated/programs/system.ts
|
|
899
|
+
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
900
|
+
var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
|
|
901
|
+
SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
|
|
902
|
+
return SystemAccount2;
|
|
903
|
+
})(SystemAccount || {});
|
|
904
|
+
var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
|
|
905
|
+
SystemInstruction2[SystemInstruction2["CreateAccount"] = 0] = "CreateAccount";
|
|
906
|
+
SystemInstruction2[SystemInstruction2["Assign"] = 1] = "Assign";
|
|
907
|
+
SystemInstruction2[SystemInstruction2["TransferSol"] = 2] = "TransferSol";
|
|
908
|
+
SystemInstruction2[SystemInstruction2["CreateAccountWithSeed"] = 3] = "CreateAccountWithSeed";
|
|
909
|
+
SystemInstruction2[SystemInstruction2["AdvanceNonceAccount"] = 4] = "AdvanceNonceAccount";
|
|
910
|
+
SystemInstruction2[SystemInstruction2["WithdrawNonceAccount"] = 5] = "WithdrawNonceAccount";
|
|
911
|
+
SystemInstruction2[SystemInstruction2["InitializeNonceAccount"] = 6] = "InitializeNonceAccount";
|
|
912
|
+
SystemInstruction2[SystemInstruction2["AuthorizeNonceAccount"] = 7] = "AuthorizeNonceAccount";
|
|
913
|
+
SystemInstruction2[SystemInstruction2["Allocate"] = 8] = "Allocate";
|
|
914
|
+
SystemInstruction2[SystemInstruction2["AllocateWithSeed"] = 9] = "AllocateWithSeed";
|
|
915
|
+
SystemInstruction2[SystemInstruction2["AssignWithSeed"] = 10] = "AssignWithSeed";
|
|
916
|
+
SystemInstruction2[SystemInstruction2["TransferSolWithSeed"] = 11] = "TransferSolWithSeed";
|
|
917
|
+
SystemInstruction2[SystemInstruction2["UpgradeNonceAccount"] = 12] = "UpgradeNonceAccount";
|
|
918
|
+
return SystemInstruction2;
|
|
919
|
+
})(SystemInstruction || {});
|
|
920
|
+
function identifySystemInstruction(instruction) {
|
|
921
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
922
|
+
if (containsBytes(data, getU32Encoder().encode(0), 0)) {
|
|
923
|
+
return 0 /* CreateAccount */;
|
|
924
|
+
}
|
|
925
|
+
if (containsBytes(data, getU32Encoder().encode(1), 0)) {
|
|
926
|
+
return 1 /* Assign */;
|
|
927
|
+
}
|
|
928
|
+
if (containsBytes(data, getU32Encoder().encode(2), 0)) {
|
|
929
|
+
return 2 /* TransferSol */;
|
|
930
|
+
}
|
|
931
|
+
if (containsBytes(data, getU32Encoder().encode(3), 0)) {
|
|
932
|
+
return 3 /* CreateAccountWithSeed */;
|
|
933
|
+
}
|
|
934
|
+
if (containsBytes(data, getU32Encoder().encode(4), 0)) {
|
|
935
|
+
return 4 /* AdvanceNonceAccount */;
|
|
936
|
+
}
|
|
937
|
+
if (containsBytes(data, getU32Encoder().encode(5), 0)) {
|
|
938
|
+
return 5 /* WithdrawNonceAccount */;
|
|
939
|
+
}
|
|
940
|
+
if (containsBytes(data, getU32Encoder().encode(6), 0)) {
|
|
941
|
+
return 6 /* InitializeNonceAccount */;
|
|
942
|
+
}
|
|
943
|
+
if (containsBytes(data, getU32Encoder().encode(7), 0)) {
|
|
944
|
+
return 7 /* AuthorizeNonceAccount */;
|
|
945
|
+
}
|
|
946
|
+
if (containsBytes(data, getU32Encoder().encode(8), 0)) {
|
|
947
|
+
return 8 /* Allocate */;
|
|
948
|
+
}
|
|
949
|
+
if (containsBytes(data, getU32Encoder().encode(9), 0)) {
|
|
950
|
+
return 9 /* AllocateWithSeed */;
|
|
951
|
+
}
|
|
952
|
+
if (containsBytes(data, getU32Encoder().encode(10), 0)) {
|
|
953
|
+
return 10 /* AssignWithSeed */;
|
|
954
|
+
}
|
|
955
|
+
if (containsBytes(data, getU32Encoder().encode(11), 0)) {
|
|
956
|
+
return 11 /* TransferSolWithSeed */;
|
|
957
|
+
}
|
|
958
|
+
if (containsBytes(data, getU32Encoder().encode(12), 0)) {
|
|
959
|
+
return 12 /* UpgradeNonceAccount */;
|
|
960
|
+
}
|
|
961
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
|
|
962
|
+
instructionData: data,
|
|
963
|
+
programName: "system"
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
function parseSystemInstruction(instruction) {
|
|
967
|
+
const instructionType = identifySystemInstruction(instruction);
|
|
968
|
+
switch (instructionType) {
|
|
969
|
+
case 0 /* CreateAccount */: {
|
|
970
|
+
assertIsInstructionWithAccounts(instruction);
|
|
971
|
+
return { instructionType: 0 /* CreateAccount */, ...parseCreateAccountInstruction(instruction) };
|
|
972
|
+
}
|
|
973
|
+
case 1 /* Assign */: {
|
|
974
|
+
assertIsInstructionWithAccounts(instruction);
|
|
975
|
+
return { instructionType: 1 /* Assign */, ...parseAssignInstruction(instruction) };
|
|
976
|
+
}
|
|
977
|
+
case 2 /* TransferSol */: {
|
|
978
|
+
assertIsInstructionWithAccounts(instruction);
|
|
979
|
+
return { instructionType: 2 /* TransferSol */, ...parseTransferSolInstruction(instruction) };
|
|
980
|
+
}
|
|
981
|
+
case 3 /* CreateAccountWithSeed */: {
|
|
982
|
+
assertIsInstructionWithAccounts(instruction);
|
|
983
|
+
return {
|
|
984
|
+
instructionType: 3 /* CreateAccountWithSeed */,
|
|
985
|
+
...parseCreateAccountWithSeedInstruction(instruction)
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
case 4 /* AdvanceNonceAccount */: {
|
|
989
|
+
assertIsInstructionWithAccounts(instruction);
|
|
990
|
+
return {
|
|
991
|
+
instructionType: 4 /* AdvanceNonceAccount */,
|
|
992
|
+
...parseAdvanceNonceAccountInstruction(instruction)
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
case 5 /* WithdrawNonceAccount */: {
|
|
996
|
+
assertIsInstructionWithAccounts(instruction);
|
|
997
|
+
return {
|
|
998
|
+
instructionType: 5 /* WithdrawNonceAccount */,
|
|
999
|
+
...parseWithdrawNonceAccountInstruction(instruction)
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
case 6 /* InitializeNonceAccount */: {
|
|
1003
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1004
|
+
return {
|
|
1005
|
+
instructionType: 6 /* InitializeNonceAccount */,
|
|
1006
|
+
...parseInitializeNonceAccountInstruction(instruction)
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
case 7 /* AuthorizeNonceAccount */: {
|
|
1010
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1011
|
+
return {
|
|
1012
|
+
instructionType: 7 /* AuthorizeNonceAccount */,
|
|
1013
|
+
...parseAuthorizeNonceAccountInstruction(instruction)
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
case 8 /* Allocate */: {
|
|
1017
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1018
|
+
return { instructionType: 8 /* Allocate */, ...parseAllocateInstruction(instruction) };
|
|
1019
|
+
}
|
|
1020
|
+
case 9 /* AllocateWithSeed */: {
|
|
1021
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1022
|
+
return {
|
|
1023
|
+
instructionType: 9 /* AllocateWithSeed */,
|
|
1024
|
+
...parseAllocateWithSeedInstruction(instruction)
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
case 10 /* AssignWithSeed */: {
|
|
1028
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1029
|
+
return {
|
|
1030
|
+
instructionType: 10 /* AssignWithSeed */,
|
|
1031
|
+
...parseAssignWithSeedInstruction(instruction)
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
case 11 /* TransferSolWithSeed */: {
|
|
1035
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1036
|
+
return {
|
|
1037
|
+
instructionType: 11 /* TransferSolWithSeed */,
|
|
1038
|
+
...parseTransferSolWithSeedInstruction(instruction)
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
case 12 /* UpgradeNonceAccount */: {
|
|
1042
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1043
|
+
return {
|
|
1044
|
+
instructionType: 12 /* UpgradeNonceAccount */,
|
|
1045
|
+
...parseUpgradeNonceAccountInstruction(instruction)
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
default:
|
|
1049
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
|
|
1050
|
+
instructionType,
|
|
1051
|
+
programName: "system"
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function systemProgram() {
|
|
1056
|
+
return (client) => {
|
|
1057
|
+
return {
|
|
1058
|
+
...client,
|
|
1059
|
+
system: {
|
|
1060
|
+
accounts: { nonce: addSelfFetchFunctions(client, getNonceCodec()) },
|
|
1061
|
+
instructions: {
|
|
1062
|
+
createAccount: (input) => addSelfPlanAndSendFunctions(
|
|
1063
|
+
client,
|
|
1064
|
+
getCreateAccountInstruction({ ...input, payer: input.payer ?? client.payer })
|
|
1065
|
+
),
|
|
1066
|
+
assign: (input) => addSelfPlanAndSendFunctions(client, getAssignInstruction(input)),
|
|
1067
|
+
transferSol: (input) => addSelfPlanAndSendFunctions(client, getTransferSolInstruction(input)),
|
|
1068
|
+
createAccountWithSeed: (input) => addSelfPlanAndSendFunctions(
|
|
1069
|
+
client,
|
|
1070
|
+
getCreateAccountWithSeedInstruction({ ...input, payer: input.payer ?? client.payer })
|
|
1071
|
+
),
|
|
1072
|
+
advanceNonceAccount: (input) => addSelfPlanAndSendFunctions(client, getAdvanceNonceAccountInstruction(input)),
|
|
1073
|
+
withdrawNonceAccount: (input) => addSelfPlanAndSendFunctions(client, getWithdrawNonceAccountInstruction(input)),
|
|
1074
|
+
initializeNonceAccount: (input) => addSelfPlanAndSendFunctions(client, getInitializeNonceAccountInstruction(input)),
|
|
1075
|
+
authorizeNonceAccount: (input) => addSelfPlanAndSendFunctions(client, getAuthorizeNonceAccountInstruction(input)),
|
|
1076
|
+
allocate: (input) => addSelfPlanAndSendFunctions(client, getAllocateInstruction(input)),
|
|
1077
|
+
allocateWithSeed: (input) => addSelfPlanAndSendFunctions(client, getAllocateWithSeedInstruction(input)),
|
|
1078
|
+
assignWithSeed: (input) => addSelfPlanAndSendFunctions(client, getAssignWithSeedInstruction(input)),
|
|
1079
|
+
transferSolWithSeed: (input) => addSelfPlanAndSendFunctions(client, getTransferSolWithSeedInstruction(input)),
|
|
1080
|
+
upgradeNonceAccount: (input) => addSelfPlanAndSendFunctions(client, getUpgradeNonceAccountInstruction(input))
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// src/generated/errors/system.ts
|
|
1088
|
+
var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
|
|
1089
|
+
var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
|
|
1090
|
+
var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
|
|
1091
|
+
var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
|
|
1092
|
+
var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
|
|
1093
|
+
var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
|
|
1094
|
+
var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
|
|
1095
|
+
var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
|
|
1096
|
+
var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
|
|
1097
|
+
var systemErrorMessages;
|
|
1098
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1099
|
+
systemErrorMessages = {
|
|
1100
|
+
[SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
|
|
1101
|
+
[SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
|
|
1102
|
+
[SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
|
|
1103
|
+
[SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
|
|
1104
|
+
[SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
|
|
1105
|
+
[SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
|
|
1106
|
+
[SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
|
|
1107
|
+
[SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
|
|
1108
|
+
[SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
|
|
1116
1109
|
};
|
|
1117
1110
|
}
|
|
1111
|
+
function getSystemErrorMessage(code) {
|
|
1112
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1113
|
+
return systemErrorMessages[code];
|
|
1114
|
+
}
|
|
1115
|
+
return "Error message not available in production bundles.";
|
|
1116
|
+
}
|
|
1117
|
+
function isSystemError(error, transactionMessage, code) {
|
|
1118
|
+
return isProgramError(error, transactionMessage, SYSTEM_PROGRAM_ADDRESS, code);
|
|
1119
|
+
}
|
|
1118
1120
|
|
|
1119
|
-
export { ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR, ALLOCATE_DISCRIMINATOR, ALLOCATE_WITH_SEED_DISCRIMINATOR, ASSIGN_DISCRIMINATOR, ASSIGN_WITH_SEED_DISCRIMINATOR, AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR, INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR, 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, TRANSFER_SOL_DISCRIMINATOR, TRANSFER_SOL_WITH_SEED_DISCRIMINATOR, UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR, WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR, decodeNonce, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAdvanceNonceAccountDiscriminatorBytes, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateDiscriminatorBytes, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedDiscriminatorBytes, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignDiscriminatorBytes, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedDiscriminatorBytes, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountDiscriminatorBytes, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountDiscriminatorBytes, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedDiscriminatorBytes, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountDiscriminatorBytes, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceCodec, getNonceDecoder, getNonceEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemErrorMessage, getTransferSolDiscriminatorBytes, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedDiscriminatorBytes, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountDiscriminatorBytes, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountDiscriminatorBytes, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, isSystemError, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction };
|
|
1121
|
+
export { ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR, ALLOCATE_DISCRIMINATOR, ALLOCATE_WITH_SEED_DISCRIMINATOR, ASSIGN_DISCRIMINATOR, ASSIGN_WITH_SEED_DISCRIMINATOR, AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR, INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR, 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, TRANSFER_SOL_DISCRIMINATOR, TRANSFER_SOL_WITH_SEED_DISCRIMINATOR, UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR, WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR, decodeNonce, fetchAllMaybeNonce, fetchAllNonce, fetchMaybeNonce, fetchNonce, getAdvanceNonceAccountDiscriminatorBytes, getAdvanceNonceAccountInstruction, getAdvanceNonceAccountInstructionDataCodec, getAdvanceNonceAccountInstructionDataDecoder, getAdvanceNonceAccountInstructionDataEncoder, getAllocateDiscriminatorBytes, getAllocateInstruction, getAllocateInstructionDataCodec, getAllocateInstructionDataDecoder, getAllocateInstructionDataEncoder, getAllocateWithSeedDiscriminatorBytes, getAllocateWithSeedInstruction, getAllocateWithSeedInstructionDataCodec, getAllocateWithSeedInstructionDataDecoder, getAllocateWithSeedInstructionDataEncoder, getAssignDiscriminatorBytes, getAssignInstruction, getAssignInstructionDataCodec, getAssignInstructionDataDecoder, getAssignInstructionDataEncoder, getAssignWithSeedDiscriminatorBytes, getAssignWithSeedInstruction, getAssignWithSeedInstructionDataCodec, getAssignWithSeedInstructionDataDecoder, getAssignWithSeedInstructionDataEncoder, getAuthorizeNonceAccountDiscriminatorBytes, getAuthorizeNonceAccountInstruction, getAuthorizeNonceAccountInstructionDataCodec, getAuthorizeNonceAccountInstructionDataDecoder, getAuthorizeNonceAccountInstructionDataEncoder, getCreateAccountDiscriminatorBytes, getCreateAccountInstruction, getCreateAccountInstructionDataCodec, getCreateAccountInstructionDataDecoder, getCreateAccountInstructionDataEncoder, getCreateAccountWithSeedDiscriminatorBytes, getCreateAccountWithSeedInstruction, getCreateAccountWithSeedInstructionDataCodec, getCreateAccountWithSeedInstructionDataDecoder, getCreateAccountWithSeedInstructionDataEncoder, getInitializeNonceAccountDiscriminatorBytes, getInitializeNonceAccountInstruction, getInitializeNonceAccountInstructionDataCodec, getInitializeNonceAccountInstructionDataDecoder, getInitializeNonceAccountInstructionDataEncoder, getNonceCodec, getNonceDecoder, getNonceEncoder, getNonceSize, getNonceStateCodec, getNonceStateDecoder, getNonceStateEncoder, getNonceVersionCodec, getNonceVersionDecoder, getNonceVersionEncoder, getSystemErrorMessage, getTransferSolDiscriminatorBytes, getTransferSolInstruction, getTransferSolInstructionDataCodec, getTransferSolInstructionDataDecoder, getTransferSolInstructionDataEncoder, getTransferSolWithSeedDiscriminatorBytes, getTransferSolWithSeedInstruction, getTransferSolWithSeedInstructionDataCodec, getTransferSolWithSeedInstructionDataDecoder, getTransferSolWithSeedInstructionDataEncoder, getUpgradeNonceAccountDiscriminatorBytes, getUpgradeNonceAccountInstruction, getUpgradeNonceAccountInstructionDataCodec, getUpgradeNonceAccountInstructionDataDecoder, getUpgradeNonceAccountInstructionDataEncoder, getWithdrawNonceAccountDiscriminatorBytes, getWithdrawNonceAccountInstruction, getWithdrawNonceAccountInstructionDataCodec, getWithdrawNonceAccountInstructionDataDecoder, getWithdrawNonceAccountInstructionDataEncoder, identifySystemInstruction, isSystemError, parseAdvanceNonceAccountInstruction, parseAllocateInstruction, parseAllocateWithSeedInstruction, parseAssignInstruction, parseAssignWithSeedInstruction, parseAuthorizeNonceAccountInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseSystemInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction, systemProgram };
|
|
1120
1122
|
//# sourceMappingURL=index.mjs.map
|
|
1121
1123
|
//# sourceMappingURL=index.mjs.map
|