@solana-program/system 0.9.1 → 0.11.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 +243 -293
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +244 -295
- 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 +1 -1
- 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 +2 -1
- package/dist/types/generated/programs/system.d.ts.map +1 -1
- package/dist/types/generated/shared/index.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 +14 -27
package/dist/src/index.js
CHANGED
|
@@ -55,10 +55,7 @@ function getNonceCodec() {
|
|
|
55
55
|
return kit.combineCodec(getNonceEncoder(), getNonceDecoder());
|
|
56
56
|
}
|
|
57
57
|
function decodeNonce(encodedAccount) {
|
|
58
|
-
return kit.decodeAccount(
|
|
59
|
-
encodedAccount,
|
|
60
|
-
getNonceDecoder()
|
|
61
|
-
);
|
|
58
|
+
return kit.decodeAccount(encodedAccount, getNonceDecoder());
|
|
62
59
|
}
|
|
63
60
|
async function fetchNonce(rpc, address, config) {
|
|
64
61
|
const maybeAccount = await fetchMaybeNonce(rpc, address, config);
|
|
@@ -81,111 +78,6 @@ async function fetchAllMaybeNonce(rpc, addresses, config) {
|
|
|
81
78
|
function getNonceSize() {
|
|
82
79
|
return 80;
|
|
83
80
|
}
|
|
84
|
-
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
85
|
-
var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
|
|
86
|
-
SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
|
|
87
|
-
return SystemAccount2;
|
|
88
|
-
})(SystemAccount || {});
|
|
89
|
-
var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
|
|
90
|
-
SystemInstruction2[SystemInstruction2["CreateAccount"] = 0] = "CreateAccount";
|
|
91
|
-
SystemInstruction2[SystemInstruction2["Assign"] = 1] = "Assign";
|
|
92
|
-
SystemInstruction2[SystemInstruction2["TransferSol"] = 2] = "TransferSol";
|
|
93
|
-
SystemInstruction2[SystemInstruction2["CreateAccountWithSeed"] = 3] = "CreateAccountWithSeed";
|
|
94
|
-
SystemInstruction2[SystemInstruction2["AdvanceNonceAccount"] = 4] = "AdvanceNonceAccount";
|
|
95
|
-
SystemInstruction2[SystemInstruction2["WithdrawNonceAccount"] = 5] = "WithdrawNonceAccount";
|
|
96
|
-
SystemInstruction2[SystemInstruction2["InitializeNonceAccount"] = 6] = "InitializeNonceAccount";
|
|
97
|
-
SystemInstruction2[SystemInstruction2["AuthorizeNonceAccount"] = 7] = "AuthorizeNonceAccount";
|
|
98
|
-
SystemInstruction2[SystemInstruction2["Allocate"] = 8] = "Allocate";
|
|
99
|
-
SystemInstruction2[SystemInstruction2["AllocateWithSeed"] = 9] = "AllocateWithSeed";
|
|
100
|
-
SystemInstruction2[SystemInstruction2["AssignWithSeed"] = 10] = "AssignWithSeed";
|
|
101
|
-
SystemInstruction2[SystemInstruction2["TransferSolWithSeed"] = 11] = "TransferSolWithSeed";
|
|
102
|
-
SystemInstruction2[SystemInstruction2["UpgradeNonceAccount"] = 12] = "UpgradeNonceAccount";
|
|
103
|
-
return SystemInstruction2;
|
|
104
|
-
})(SystemInstruction || {});
|
|
105
|
-
function identifySystemInstruction(instruction) {
|
|
106
|
-
const data = "data" in instruction ? instruction.data : instruction;
|
|
107
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(0), 0)) {
|
|
108
|
-
return 0 /* CreateAccount */;
|
|
109
|
-
}
|
|
110
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(1), 0)) {
|
|
111
|
-
return 1 /* Assign */;
|
|
112
|
-
}
|
|
113
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(2), 0)) {
|
|
114
|
-
return 2 /* TransferSol */;
|
|
115
|
-
}
|
|
116
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(3), 0)) {
|
|
117
|
-
return 3 /* CreateAccountWithSeed */;
|
|
118
|
-
}
|
|
119
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(4), 0)) {
|
|
120
|
-
return 4 /* AdvanceNonceAccount */;
|
|
121
|
-
}
|
|
122
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(5), 0)) {
|
|
123
|
-
return 5 /* WithdrawNonceAccount */;
|
|
124
|
-
}
|
|
125
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(6), 0)) {
|
|
126
|
-
return 6 /* InitializeNonceAccount */;
|
|
127
|
-
}
|
|
128
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(7), 0)) {
|
|
129
|
-
return 7 /* AuthorizeNonceAccount */;
|
|
130
|
-
}
|
|
131
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(8), 0)) {
|
|
132
|
-
return 8 /* Allocate */;
|
|
133
|
-
}
|
|
134
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(9), 0)) {
|
|
135
|
-
return 9 /* AllocateWithSeed */;
|
|
136
|
-
}
|
|
137
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(10), 0)) {
|
|
138
|
-
return 10 /* AssignWithSeed */;
|
|
139
|
-
}
|
|
140
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(11), 0)) {
|
|
141
|
-
return 11 /* TransferSolWithSeed */;
|
|
142
|
-
}
|
|
143
|
-
if (kit.containsBytes(data, kit.getU32Encoder().encode(12), 0)) {
|
|
144
|
-
return 12 /* UpgradeNonceAccount */;
|
|
145
|
-
}
|
|
146
|
-
throw new Error(
|
|
147
|
-
"The provided instruction could not be identified as a system instruction."
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/generated/errors/system.ts
|
|
152
|
-
var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
|
|
153
|
-
var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
|
|
154
|
-
var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
|
|
155
|
-
var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
|
|
156
|
-
var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
|
|
157
|
-
var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
|
|
158
|
-
var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
|
|
159
|
-
var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
|
|
160
|
-
var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
|
|
161
|
-
var systemErrorMessages;
|
|
162
|
-
if (process.env.NODE_ENV !== "production") {
|
|
163
|
-
systemErrorMessages = {
|
|
164
|
-
[SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
|
|
165
|
-
[SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
|
|
166
|
-
[SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
|
|
167
|
-
[SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
|
|
168
|
-
[SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
|
|
169
|
-
[SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
|
|
170
|
-
[SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
|
|
171
|
-
[SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
|
|
172
|
-
[SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function getSystemErrorMessage(code) {
|
|
176
|
-
if (process.env.NODE_ENV !== "production") {
|
|
177
|
-
return systemErrorMessages[code];
|
|
178
|
-
}
|
|
179
|
-
return "Error message not available in production bundles.";
|
|
180
|
-
}
|
|
181
|
-
function isSystemError(error, transactionMessage, code) {
|
|
182
|
-
return kit.isProgramError(
|
|
183
|
-
error,
|
|
184
|
-
transactionMessage,
|
|
185
|
-
SYSTEM_PROGRAM_ADDRESS,
|
|
186
|
-
code
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
81
|
function expectAddress(value) {
|
|
190
82
|
if (!value) {
|
|
191
83
|
throw new Error("Expected a Address.");
|
|
@@ -221,31 +113,22 @@ function getAdvanceNonceAccountDiscriminatorBytes() {
|
|
|
221
113
|
return kit.getU32Encoder().encode(ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR);
|
|
222
114
|
}
|
|
223
115
|
function getAdvanceNonceAccountInstructionDataEncoder() {
|
|
224
|
-
return kit.transformEncoder(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
discriminator: ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
229
|
-
})
|
|
230
|
-
);
|
|
116
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU32Encoder()]]), (value) => ({
|
|
117
|
+
...value,
|
|
118
|
+
discriminator: ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
119
|
+
}));
|
|
231
120
|
}
|
|
232
121
|
function getAdvanceNonceAccountInstructionDataDecoder() {
|
|
233
122
|
return kit.getStructDecoder([["discriminator", kit.getU32Decoder()]]);
|
|
234
123
|
}
|
|
235
124
|
function getAdvanceNonceAccountInstructionDataCodec() {
|
|
236
|
-
return kit.combineCodec(
|
|
237
|
-
getAdvanceNonceAccountInstructionDataEncoder(),
|
|
238
|
-
getAdvanceNonceAccountInstructionDataDecoder()
|
|
239
|
-
);
|
|
125
|
+
return kit.combineCodec(getAdvanceNonceAccountInstructionDataEncoder(), getAdvanceNonceAccountInstructionDataDecoder());
|
|
240
126
|
}
|
|
241
127
|
function getAdvanceNonceAccountInstruction(input, config) {
|
|
242
128
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
243
129
|
const originalAccounts = {
|
|
244
130
|
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
245
|
-
recentBlockhashesSysvar: {
|
|
246
|
-
value: input.recentBlockhashesSysvar ?? null,
|
|
247
|
-
isWritable: false
|
|
248
|
-
},
|
|
131
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
249
132
|
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
|
|
250
133
|
};
|
|
251
134
|
const accounts = originalAccounts;
|
|
@@ -280,9 +163,7 @@ function parseAdvanceNonceAccountInstruction(instruction) {
|
|
|
280
163
|
recentBlockhashesSysvar: getNextAccount(),
|
|
281
164
|
nonceAuthority: getNextAccount()
|
|
282
165
|
},
|
|
283
|
-
data: getAdvanceNonceAccountInstructionDataDecoder().decode(
|
|
284
|
-
instruction.data
|
|
285
|
-
)
|
|
166
|
+
data: getAdvanceNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
286
167
|
};
|
|
287
168
|
}
|
|
288
169
|
var ALLOCATE_DISCRIMINATOR = 8;
|
|
@@ -305,24 +186,17 @@ function getAllocateInstructionDataDecoder() {
|
|
|
305
186
|
]);
|
|
306
187
|
}
|
|
307
188
|
function getAllocateInstructionDataCodec() {
|
|
308
|
-
return kit.combineCodec(
|
|
309
|
-
getAllocateInstructionDataEncoder(),
|
|
310
|
-
getAllocateInstructionDataDecoder()
|
|
311
|
-
);
|
|
189
|
+
return kit.combineCodec(getAllocateInstructionDataEncoder(), getAllocateInstructionDataDecoder());
|
|
312
190
|
}
|
|
313
191
|
function getAllocateInstruction(input, config) {
|
|
314
192
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
315
|
-
const originalAccounts = {
|
|
316
|
-
newAccount: { value: input.newAccount ?? null, isWritable: true }
|
|
317
|
-
};
|
|
193
|
+
const originalAccounts = { newAccount: { value: input.newAccount ?? null, isWritable: true } };
|
|
318
194
|
const accounts = originalAccounts;
|
|
319
195
|
const args = { ...input };
|
|
320
196
|
const getAccountMeta = getAccountMetaFactory();
|
|
321
197
|
return Object.freeze({
|
|
322
198
|
accounts: [getAccountMeta(accounts.newAccount)],
|
|
323
|
-
data: getAllocateInstructionDataEncoder().encode(
|
|
324
|
-
args
|
|
325
|
-
),
|
|
199
|
+
data: getAllocateInstructionDataEncoder().encode(args),
|
|
326
200
|
programAddress
|
|
327
201
|
});
|
|
328
202
|
}
|
|
@@ -368,10 +242,7 @@ function getAllocateWithSeedInstructionDataDecoder() {
|
|
|
368
242
|
]);
|
|
369
243
|
}
|
|
370
244
|
function getAllocateWithSeedInstructionDataCodec() {
|
|
371
|
-
return kit.combineCodec(
|
|
372
|
-
getAllocateWithSeedInstructionDataEncoder(),
|
|
373
|
-
getAllocateWithSeedInstructionDataDecoder()
|
|
374
|
-
);
|
|
245
|
+
return kit.combineCodec(getAllocateWithSeedInstructionDataEncoder(), getAllocateWithSeedInstructionDataDecoder());
|
|
375
246
|
}
|
|
376
247
|
function getAllocateWithSeedInstruction(input, config) {
|
|
377
248
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -383,13 +254,8 @@ function getAllocateWithSeedInstruction(input, config) {
|
|
|
383
254
|
const args = { ...input };
|
|
384
255
|
const getAccountMeta = getAccountMetaFactory();
|
|
385
256
|
return Object.freeze({
|
|
386
|
-
accounts: [
|
|
387
|
-
|
|
388
|
-
getAccountMeta(accounts.baseAccount)
|
|
389
|
-
],
|
|
390
|
-
data: getAllocateWithSeedInstructionDataEncoder().encode(
|
|
391
|
-
args
|
|
392
|
-
),
|
|
257
|
+
accounts: [getAccountMeta(accounts.newAccount), getAccountMeta(accounts.baseAccount)],
|
|
258
|
+
data: getAllocateWithSeedInstructionDataEncoder().encode(args),
|
|
393
259
|
programAddress
|
|
394
260
|
});
|
|
395
261
|
}
|
|
@@ -429,24 +295,17 @@ function getAssignInstructionDataDecoder() {
|
|
|
429
295
|
]);
|
|
430
296
|
}
|
|
431
297
|
function getAssignInstructionDataCodec() {
|
|
432
|
-
return kit.combineCodec(
|
|
433
|
-
getAssignInstructionDataEncoder(),
|
|
434
|
-
getAssignInstructionDataDecoder()
|
|
435
|
-
);
|
|
298
|
+
return kit.combineCodec(getAssignInstructionDataEncoder(), getAssignInstructionDataDecoder());
|
|
436
299
|
}
|
|
437
300
|
function getAssignInstruction(input, config) {
|
|
438
301
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
439
|
-
const originalAccounts = {
|
|
440
|
-
account: { value: input.account ?? null, isWritable: true }
|
|
441
|
-
};
|
|
302
|
+
const originalAccounts = { account: { value: input.account ?? null, isWritable: true } };
|
|
442
303
|
const accounts = originalAccounts;
|
|
443
304
|
const args = { ...input };
|
|
444
305
|
const getAccountMeta = getAccountMetaFactory();
|
|
445
306
|
return Object.freeze({
|
|
446
307
|
accounts: [getAccountMeta(accounts.account)],
|
|
447
|
-
data: getAssignInstructionDataEncoder().encode(
|
|
448
|
-
args
|
|
449
|
-
),
|
|
308
|
+
data: getAssignInstructionDataEncoder().encode(args),
|
|
450
309
|
programAddress
|
|
451
310
|
});
|
|
452
311
|
}
|
|
@@ -490,10 +349,7 @@ function getAssignWithSeedInstructionDataDecoder() {
|
|
|
490
349
|
]);
|
|
491
350
|
}
|
|
492
351
|
function getAssignWithSeedInstructionDataCodec() {
|
|
493
|
-
return kit.combineCodec(
|
|
494
|
-
getAssignWithSeedInstructionDataEncoder(),
|
|
495
|
-
getAssignWithSeedInstructionDataDecoder()
|
|
496
|
-
);
|
|
352
|
+
return kit.combineCodec(getAssignWithSeedInstructionDataEncoder(), getAssignWithSeedInstructionDataDecoder());
|
|
497
353
|
}
|
|
498
354
|
function getAssignWithSeedInstruction(input, config) {
|
|
499
355
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -505,13 +361,8 @@ function getAssignWithSeedInstruction(input, config) {
|
|
|
505
361
|
const args = { ...input };
|
|
506
362
|
const getAccountMeta = getAccountMetaFactory();
|
|
507
363
|
return Object.freeze({
|
|
508
|
-
accounts: [
|
|
509
|
-
|
|
510
|
-
getAccountMeta(accounts.baseAccount)
|
|
511
|
-
],
|
|
512
|
-
data: getAssignWithSeedInstructionDataEncoder().encode(
|
|
513
|
-
args
|
|
514
|
-
),
|
|
364
|
+
accounts: [getAccountMeta(accounts.account), getAccountMeta(accounts.baseAccount)],
|
|
365
|
+
data: getAssignWithSeedInstructionDataEncoder().encode(args),
|
|
515
366
|
programAddress
|
|
516
367
|
});
|
|
517
368
|
}
|
|
@@ -541,10 +392,7 @@ function getAuthorizeNonceAccountInstructionDataEncoder() {
|
|
|
541
392
|
["discriminator", kit.getU32Encoder()],
|
|
542
393
|
["newNonceAuthority", kit.getAddressEncoder()]
|
|
543
394
|
]),
|
|
544
|
-
(value) => ({
|
|
545
|
-
...value,
|
|
546
|
-
discriminator: AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
547
|
-
})
|
|
395
|
+
(value) => ({ ...value, discriminator: AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR })
|
|
548
396
|
);
|
|
549
397
|
}
|
|
550
398
|
function getAuthorizeNonceAccountInstructionDataDecoder() {
|
|
@@ -569,13 +417,8 @@ function getAuthorizeNonceAccountInstruction(input, config) {
|
|
|
569
417
|
const args = { ...input };
|
|
570
418
|
const getAccountMeta = getAccountMetaFactory();
|
|
571
419
|
return Object.freeze({
|
|
572
|
-
accounts: [
|
|
573
|
-
|
|
574
|
-
getAccountMeta(accounts.nonceAuthority)
|
|
575
|
-
],
|
|
576
|
-
data: getAuthorizeNonceAccountInstructionDataEncoder().encode(
|
|
577
|
-
args
|
|
578
|
-
),
|
|
420
|
+
accounts: [getAccountMeta(accounts.nonceAccount), getAccountMeta(accounts.nonceAuthority)],
|
|
421
|
+
data: getAuthorizeNonceAccountInstructionDataEncoder().encode(args),
|
|
579
422
|
programAddress
|
|
580
423
|
});
|
|
581
424
|
}
|
|
@@ -591,13 +434,8 @@ function parseAuthorizeNonceAccountInstruction(instruction) {
|
|
|
591
434
|
};
|
|
592
435
|
return {
|
|
593
436
|
programAddress: instruction.programAddress,
|
|
594
|
-
accounts: {
|
|
595
|
-
|
|
596
|
-
nonceAuthority: getNextAccount()
|
|
597
|
-
},
|
|
598
|
-
data: getAuthorizeNonceAccountInstructionDataDecoder().decode(
|
|
599
|
-
instruction.data
|
|
600
|
-
)
|
|
437
|
+
accounts: { nonceAccount: getNextAccount(), nonceAuthority: getNextAccount() },
|
|
438
|
+
data: getAuthorizeNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
601
439
|
};
|
|
602
440
|
}
|
|
603
441
|
var CREATE_ACCOUNT_DISCRIMINATOR = 0;
|
|
@@ -624,10 +462,7 @@ function getCreateAccountInstructionDataDecoder() {
|
|
|
624
462
|
]);
|
|
625
463
|
}
|
|
626
464
|
function getCreateAccountInstructionDataCodec() {
|
|
627
|
-
return kit.combineCodec(
|
|
628
|
-
getCreateAccountInstructionDataEncoder(),
|
|
629
|
-
getCreateAccountInstructionDataDecoder()
|
|
630
|
-
);
|
|
465
|
+
return kit.combineCodec(getCreateAccountInstructionDataEncoder(), getCreateAccountInstructionDataDecoder());
|
|
631
466
|
}
|
|
632
467
|
function getCreateAccountInstruction(input, config) {
|
|
633
468
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -637,20 +472,12 @@ function getCreateAccountInstruction(input, config) {
|
|
|
637
472
|
};
|
|
638
473
|
const accounts = originalAccounts;
|
|
639
474
|
const args = { ...input };
|
|
640
|
-
const byteDelta = [Number(args.space) + kit.BASE_ACCOUNT_SIZE].reduce(
|
|
641
|
-
(a, b) => a + b,
|
|
642
|
-
0
|
|
643
|
-
);
|
|
475
|
+
const byteDelta = [Number(args.space) + kit.BASE_ACCOUNT_SIZE].reduce((a, b) => a + b, 0);
|
|
644
476
|
const getAccountMeta = getAccountMetaFactory();
|
|
645
477
|
return Object.freeze({
|
|
646
|
-
accounts: [
|
|
647
|
-
getAccountMeta(accounts.payer),
|
|
648
|
-
getAccountMeta(accounts.newAccount)
|
|
649
|
-
],
|
|
478
|
+
accounts: [getAccountMeta(accounts.payer), getAccountMeta(accounts.newAccount)],
|
|
650
479
|
byteDelta,
|
|
651
|
-
data: getCreateAccountInstructionDataEncoder().encode(
|
|
652
|
-
args
|
|
653
|
-
),
|
|
480
|
+
data: getCreateAccountInstructionDataEncoder().encode(args),
|
|
654
481
|
programAddress
|
|
655
482
|
});
|
|
656
483
|
}
|
|
@@ -684,10 +511,7 @@ function getCreateAccountWithSeedInstructionDataEncoder() {
|
|
|
684
511
|
["space", kit.getU64Encoder()],
|
|
685
512
|
["programAddress", kit.getAddressEncoder()]
|
|
686
513
|
]),
|
|
687
|
-
(value) => ({
|
|
688
|
-
...value,
|
|
689
|
-
discriminator: CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR
|
|
690
|
-
})
|
|
514
|
+
(value) => ({ ...value, discriminator: CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR })
|
|
691
515
|
);
|
|
692
516
|
}
|
|
693
517
|
function getCreateAccountWithSeedInstructionDataDecoder() {
|
|
@@ -722,9 +546,7 @@ function getCreateAccountWithSeedInstruction(input, config) {
|
|
|
722
546
|
getAccountMeta(accounts.newAccount),
|
|
723
547
|
getAccountMeta(accounts.baseAccount)
|
|
724
548
|
].filter((x) => x !== void 0),
|
|
725
|
-
data: getCreateAccountWithSeedInstructionDataEncoder().encode(
|
|
726
|
-
args
|
|
727
|
-
),
|
|
549
|
+
data: getCreateAccountWithSeedInstructionDataEncoder().encode(args),
|
|
728
550
|
programAddress
|
|
729
551
|
});
|
|
730
552
|
}
|
|
@@ -746,14 +568,8 @@ function parseCreateAccountWithSeedInstruction(instruction) {
|
|
|
746
568
|
};
|
|
747
569
|
return {
|
|
748
570
|
programAddress: instruction.programAddress,
|
|
749
|
-
accounts: {
|
|
750
|
-
|
|
751
|
-
newAccount: getNextAccount(),
|
|
752
|
-
baseAccount: getNextOptionalAccount()
|
|
753
|
-
},
|
|
754
|
-
data: getCreateAccountWithSeedInstructionDataDecoder().decode(
|
|
755
|
-
instruction.data
|
|
756
|
-
)
|
|
571
|
+
accounts: { payer: getNextAccount(), newAccount: getNextAccount(), baseAccount: getNextOptionalAccount() },
|
|
572
|
+
data: getCreateAccountWithSeedInstructionDataDecoder().decode(instruction.data)
|
|
757
573
|
};
|
|
758
574
|
}
|
|
759
575
|
var INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR = 6;
|
|
@@ -766,10 +582,7 @@ function getInitializeNonceAccountInstructionDataEncoder() {
|
|
|
766
582
|
["discriminator", kit.getU32Encoder()],
|
|
767
583
|
["nonceAuthority", kit.getAddressEncoder()]
|
|
768
584
|
]),
|
|
769
|
-
(value) => ({
|
|
770
|
-
...value,
|
|
771
|
-
discriminator: INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
772
|
-
})
|
|
585
|
+
(value) => ({ ...value, discriminator: INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR })
|
|
773
586
|
);
|
|
774
587
|
}
|
|
775
588
|
function getInitializeNonceAccountInstructionDataDecoder() {
|
|
@@ -788,10 +601,7 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
788
601
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
789
602
|
const originalAccounts = {
|
|
790
603
|
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
791
|
-
recentBlockhashesSysvar: {
|
|
792
|
-
value: input.recentBlockhashesSysvar ?? null,
|
|
793
|
-
isWritable: false
|
|
794
|
-
},
|
|
604
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
795
605
|
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false }
|
|
796
606
|
};
|
|
797
607
|
const accounts = originalAccounts;
|
|
@@ -832,9 +642,7 @@ function parseInitializeNonceAccountInstruction(instruction) {
|
|
|
832
642
|
recentBlockhashesSysvar: getNextAccount(),
|
|
833
643
|
rentSysvar: getNextAccount()
|
|
834
644
|
},
|
|
835
|
-
data: getInitializeNonceAccountInstructionDataDecoder().decode(
|
|
836
|
-
instruction.data
|
|
837
|
-
)
|
|
645
|
+
data: getInitializeNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
838
646
|
};
|
|
839
647
|
}
|
|
840
648
|
var TRANSFER_SOL_DISCRIMINATOR = 2;
|
|
@@ -857,10 +665,7 @@ function getTransferSolInstructionDataDecoder() {
|
|
|
857
665
|
]);
|
|
858
666
|
}
|
|
859
667
|
function getTransferSolInstructionDataCodec() {
|
|
860
|
-
return kit.combineCodec(
|
|
861
|
-
getTransferSolInstructionDataEncoder(),
|
|
862
|
-
getTransferSolInstructionDataDecoder()
|
|
863
|
-
);
|
|
668
|
+
return kit.combineCodec(getTransferSolInstructionDataEncoder(), getTransferSolInstructionDataDecoder());
|
|
864
669
|
}
|
|
865
670
|
function getTransferSolInstruction(input, config) {
|
|
866
671
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -872,13 +677,8 @@ function getTransferSolInstruction(input, config) {
|
|
|
872
677
|
const args = { ...input };
|
|
873
678
|
const getAccountMeta = getAccountMetaFactory();
|
|
874
679
|
return Object.freeze({
|
|
875
|
-
accounts: [
|
|
876
|
-
|
|
877
|
-
getAccountMeta(accounts.destination)
|
|
878
|
-
],
|
|
879
|
-
data: getTransferSolInstructionDataEncoder().encode(
|
|
880
|
-
args
|
|
881
|
-
),
|
|
680
|
+
accounts: [getAccountMeta(accounts.source), getAccountMeta(accounts.destination)],
|
|
681
|
+
data: getTransferSolInstructionDataEncoder().encode(args),
|
|
882
682
|
programAddress
|
|
883
683
|
});
|
|
884
684
|
}
|
|
@@ -910,10 +710,7 @@ function getTransferSolWithSeedInstructionDataEncoder() {
|
|
|
910
710
|
["fromSeed", kit.addEncoderSizePrefix(kit.getUtf8Encoder(), kit.getU64Encoder())],
|
|
911
711
|
["fromOwner", kit.getAddressEncoder()]
|
|
912
712
|
]),
|
|
913
|
-
(value) => ({
|
|
914
|
-
...value,
|
|
915
|
-
discriminator: TRANSFER_SOL_WITH_SEED_DISCRIMINATOR
|
|
916
|
-
})
|
|
713
|
+
(value) => ({ ...value, discriminator: TRANSFER_SOL_WITH_SEED_DISCRIMINATOR })
|
|
917
714
|
);
|
|
918
715
|
}
|
|
919
716
|
function getTransferSolWithSeedInstructionDataDecoder() {
|
|
@@ -925,10 +722,7 @@ function getTransferSolWithSeedInstructionDataDecoder() {
|
|
|
925
722
|
]);
|
|
926
723
|
}
|
|
927
724
|
function getTransferSolWithSeedInstructionDataCodec() {
|
|
928
|
-
return kit.combineCodec(
|
|
929
|
-
getTransferSolWithSeedInstructionDataEncoder(),
|
|
930
|
-
getTransferSolWithSeedInstructionDataDecoder()
|
|
931
|
-
);
|
|
725
|
+
return kit.combineCodec(getTransferSolWithSeedInstructionDataEncoder(), getTransferSolWithSeedInstructionDataDecoder());
|
|
932
726
|
}
|
|
933
727
|
function getTransferSolWithSeedInstruction(input, config) {
|
|
934
728
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
@@ -946,9 +740,7 @@ function getTransferSolWithSeedInstruction(input, config) {
|
|
|
946
740
|
getAccountMeta(accounts.baseAccount),
|
|
947
741
|
getAccountMeta(accounts.destination)
|
|
948
742
|
],
|
|
949
|
-
data: getTransferSolWithSeedInstructionDataEncoder().encode(
|
|
950
|
-
args
|
|
951
|
-
),
|
|
743
|
+
data: getTransferSolWithSeedInstructionDataEncoder().encode(args),
|
|
952
744
|
programAddress
|
|
953
745
|
});
|
|
954
746
|
}
|
|
@@ -964,14 +756,8 @@ function parseTransferSolWithSeedInstruction(instruction) {
|
|
|
964
756
|
};
|
|
965
757
|
return {
|
|
966
758
|
programAddress: instruction.programAddress,
|
|
967
|
-
accounts: {
|
|
968
|
-
|
|
969
|
-
baseAccount: getNextAccount(),
|
|
970
|
-
destination: getNextAccount()
|
|
971
|
-
},
|
|
972
|
-
data: getTransferSolWithSeedInstructionDataDecoder().decode(
|
|
973
|
-
instruction.data
|
|
974
|
-
)
|
|
759
|
+
accounts: { source: getNextAccount(), baseAccount: getNextAccount(), destination: getNextAccount() },
|
|
760
|
+
data: getTransferSolWithSeedInstructionDataDecoder().decode(instruction.data)
|
|
975
761
|
};
|
|
976
762
|
}
|
|
977
763
|
var UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR = 12;
|
|
@@ -979,28 +765,20 @@ function getUpgradeNonceAccountDiscriminatorBytes() {
|
|
|
979
765
|
return kit.getU32Encoder().encode(UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR);
|
|
980
766
|
}
|
|
981
767
|
function getUpgradeNonceAccountInstructionDataEncoder() {
|
|
982
|
-
return kit.transformEncoder(
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
discriminator: UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
987
|
-
})
|
|
988
|
-
);
|
|
768
|
+
return kit.transformEncoder(kit.getStructEncoder([["discriminator", kit.getU32Encoder()]]), (value) => ({
|
|
769
|
+
...value,
|
|
770
|
+
discriminator: UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR
|
|
771
|
+
}));
|
|
989
772
|
}
|
|
990
773
|
function getUpgradeNonceAccountInstructionDataDecoder() {
|
|
991
774
|
return kit.getStructDecoder([["discriminator", kit.getU32Decoder()]]);
|
|
992
775
|
}
|
|
993
776
|
function getUpgradeNonceAccountInstructionDataCodec() {
|
|
994
|
-
return kit.combineCodec(
|
|
995
|
-
getUpgradeNonceAccountInstructionDataEncoder(),
|
|
996
|
-
getUpgradeNonceAccountInstructionDataDecoder()
|
|
997
|
-
);
|
|
777
|
+
return kit.combineCodec(getUpgradeNonceAccountInstructionDataEncoder(), getUpgradeNonceAccountInstructionDataDecoder());
|
|
998
778
|
}
|
|
999
779
|
function getUpgradeNonceAccountInstruction(input, config) {
|
|
1000
780
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
1001
|
-
const originalAccounts = {
|
|
1002
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true }
|
|
1003
|
-
};
|
|
781
|
+
const originalAccounts = { nonceAccount: { value: input.nonceAccount ?? null, isWritable: true } };
|
|
1004
782
|
const accounts = originalAccounts;
|
|
1005
783
|
const getAccountMeta = getAccountMetaFactory();
|
|
1006
784
|
return Object.freeze({
|
|
@@ -1022,9 +800,7 @@ function parseUpgradeNonceAccountInstruction(instruction) {
|
|
|
1022
800
|
return {
|
|
1023
801
|
programAddress: instruction.programAddress,
|
|
1024
802
|
accounts: { nonceAccount: getNextAccount() },
|
|
1025
|
-
data: getUpgradeNonceAccountInstructionDataDecoder().decode(
|
|
1026
|
-
instruction.data
|
|
1027
|
-
)
|
|
803
|
+
data: getUpgradeNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
1028
804
|
};
|
|
1029
805
|
}
|
|
1030
806
|
var WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR = 5;
|
|
@@ -1037,10 +813,7 @@ function getWithdrawNonceAccountInstructionDataEncoder() {
|
|
|
1037
813
|
["discriminator", kit.getU32Encoder()],
|
|
1038
814
|
["withdrawAmount", kit.getU64Encoder()]
|
|
1039
815
|
]),
|
|
1040
|
-
(value) => ({
|
|
1041
|
-
...value,
|
|
1042
|
-
discriminator: WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR
|
|
1043
|
-
})
|
|
816
|
+
(value) => ({ ...value, discriminator: WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR })
|
|
1044
817
|
);
|
|
1045
818
|
}
|
|
1046
819
|
function getWithdrawNonceAccountInstructionDataDecoder() {
|
|
@@ -1059,14 +832,8 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
1059
832
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
1060
833
|
const originalAccounts = {
|
|
1061
834
|
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
1062
|
-
recipientAccount: {
|
|
1063
|
-
|
|
1064
|
-
isWritable: true
|
|
1065
|
-
},
|
|
1066
|
-
recentBlockhashesSysvar: {
|
|
1067
|
-
value: input.recentBlockhashesSysvar ?? null,
|
|
1068
|
-
isWritable: false
|
|
1069
|
-
},
|
|
835
|
+
recipientAccount: { value: input.recipientAccount ?? null, isWritable: true },
|
|
836
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
1070
837
|
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false },
|
|
1071
838
|
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
|
|
1072
839
|
};
|
|
@@ -1087,9 +854,7 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
1087
854
|
getAccountMeta(accounts.rentSysvar),
|
|
1088
855
|
getAccountMeta(accounts.nonceAuthority)
|
|
1089
856
|
],
|
|
1090
|
-
data: getWithdrawNonceAccountInstructionDataEncoder().encode(
|
|
1091
|
-
args
|
|
1092
|
-
),
|
|
857
|
+
data: getWithdrawNonceAccountInstructionDataEncoder().encode(args),
|
|
1093
858
|
programAddress
|
|
1094
859
|
});
|
|
1095
860
|
}
|
|
@@ -1112,12 +877,196 @@ function parseWithdrawNonceAccountInstruction(instruction) {
|
|
|
1112
877
|
rentSysvar: getNextAccount(),
|
|
1113
878
|
nonceAuthority: getNextAccount()
|
|
1114
879
|
},
|
|
1115
|
-
data: getWithdrawNonceAccountInstructionDataDecoder().decode(
|
|
1116
|
-
instruction.data
|
|
1117
|
-
)
|
|
880
|
+
data: getWithdrawNonceAccountInstructionDataDecoder().decode(instruction.data)
|
|
1118
881
|
};
|
|
1119
882
|
}
|
|
1120
883
|
|
|
884
|
+
// src/generated/programs/system.ts
|
|
885
|
+
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
886
|
+
var SystemAccount = /* @__PURE__ */ ((SystemAccount2) => {
|
|
887
|
+
SystemAccount2[SystemAccount2["Nonce"] = 0] = "Nonce";
|
|
888
|
+
return SystemAccount2;
|
|
889
|
+
})(SystemAccount || {});
|
|
890
|
+
var SystemInstruction = /* @__PURE__ */ ((SystemInstruction2) => {
|
|
891
|
+
SystemInstruction2[SystemInstruction2["CreateAccount"] = 0] = "CreateAccount";
|
|
892
|
+
SystemInstruction2[SystemInstruction2["Assign"] = 1] = "Assign";
|
|
893
|
+
SystemInstruction2[SystemInstruction2["TransferSol"] = 2] = "TransferSol";
|
|
894
|
+
SystemInstruction2[SystemInstruction2["CreateAccountWithSeed"] = 3] = "CreateAccountWithSeed";
|
|
895
|
+
SystemInstruction2[SystemInstruction2["AdvanceNonceAccount"] = 4] = "AdvanceNonceAccount";
|
|
896
|
+
SystemInstruction2[SystemInstruction2["WithdrawNonceAccount"] = 5] = "WithdrawNonceAccount";
|
|
897
|
+
SystemInstruction2[SystemInstruction2["InitializeNonceAccount"] = 6] = "InitializeNonceAccount";
|
|
898
|
+
SystemInstruction2[SystemInstruction2["AuthorizeNonceAccount"] = 7] = "AuthorizeNonceAccount";
|
|
899
|
+
SystemInstruction2[SystemInstruction2["Allocate"] = 8] = "Allocate";
|
|
900
|
+
SystemInstruction2[SystemInstruction2["AllocateWithSeed"] = 9] = "AllocateWithSeed";
|
|
901
|
+
SystemInstruction2[SystemInstruction2["AssignWithSeed"] = 10] = "AssignWithSeed";
|
|
902
|
+
SystemInstruction2[SystemInstruction2["TransferSolWithSeed"] = 11] = "TransferSolWithSeed";
|
|
903
|
+
SystemInstruction2[SystemInstruction2["UpgradeNonceAccount"] = 12] = "UpgradeNonceAccount";
|
|
904
|
+
return SystemInstruction2;
|
|
905
|
+
})(SystemInstruction || {});
|
|
906
|
+
function identifySystemInstruction(instruction) {
|
|
907
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
908
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(0), 0)) {
|
|
909
|
+
return 0 /* CreateAccount */;
|
|
910
|
+
}
|
|
911
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(1), 0)) {
|
|
912
|
+
return 1 /* Assign */;
|
|
913
|
+
}
|
|
914
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(2), 0)) {
|
|
915
|
+
return 2 /* TransferSol */;
|
|
916
|
+
}
|
|
917
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(3), 0)) {
|
|
918
|
+
return 3 /* CreateAccountWithSeed */;
|
|
919
|
+
}
|
|
920
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(4), 0)) {
|
|
921
|
+
return 4 /* AdvanceNonceAccount */;
|
|
922
|
+
}
|
|
923
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(5), 0)) {
|
|
924
|
+
return 5 /* WithdrawNonceAccount */;
|
|
925
|
+
}
|
|
926
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(6), 0)) {
|
|
927
|
+
return 6 /* InitializeNonceAccount */;
|
|
928
|
+
}
|
|
929
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(7), 0)) {
|
|
930
|
+
return 7 /* AuthorizeNonceAccount */;
|
|
931
|
+
}
|
|
932
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(8), 0)) {
|
|
933
|
+
return 8 /* Allocate */;
|
|
934
|
+
}
|
|
935
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(9), 0)) {
|
|
936
|
+
return 9 /* AllocateWithSeed */;
|
|
937
|
+
}
|
|
938
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(10), 0)) {
|
|
939
|
+
return 10 /* AssignWithSeed */;
|
|
940
|
+
}
|
|
941
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(11), 0)) {
|
|
942
|
+
return 11 /* TransferSolWithSeed */;
|
|
943
|
+
}
|
|
944
|
+
if (kit.containsBytes(data, kit.getU32Encoder().encode(12), 0)) {
|
|
945
|
+
return 12 /* UpgradeNonceAccount */;
|
|
946
|
+
}
|
|
947
|
+
throw new Error("The provided instruction could not be identified as a system instruction.");
|
|
948
|
+
}
|
|
949
|
+
function parseSystemInstruction(instruction) {
|
|
950
|
+
const instructionType = identifySystemInstruction(instruction);
|
|
951
|
+
switch (instructionType) {
|
|
952
|
+
case 0 /* CreateAccount */: {
|
|
953
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
954
|
+
return { instructionType: 0 /* CreateAccount */, ...parseCreateAccountInstruction(instruction) };
|
|
955
|
+
}
|
|
956
|
+
case 1 /* Assign */: {
|
|
957
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
958
|
+
return { instructionType: 1 /* Assign */, ...parseAssignInstruction(instruction) };
|
|
959
|
+
}
|
|
960
|
+
case 2 /* TransferSol */: {
|
|
961
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
962
|
+
return { instructionType: 2 /* TransferSol */, ...parseTransferSolInstruction(instruction) };
|
|
963
|
+
}
|
|
964
|
+
case 3 /* CreateAccountWithSeed */: {
|
|
965
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
966
|
+
return {
|
|
967
|
+
instructionType: 3 /* CreateAccountWithSeed */,
|
|
968
|
+
...parseCreateAccountWithSeedInstruction(instruction)
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
case 4 /* AdvanceNonceAccount */: {
|
|
972
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
973
|
+
return {
|
|
974
|
+
instructionType: 4 /* AdvanceNonceAccount */,
|
|
975
|
+
...parseAdvanceNonceAccountInstruction(instruction)
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
case 5 /* WithdrawNonceAccount */: {
|
|
979
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
980
|
+
return {
|
|
981
|
+
instructionType: 5 /* WithdrawNonceAccount */,
|
|
982
|
+
...parseWithdrawNonceAccountInstruction(instruction)
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
case 6 /* InitializeNonceAccount */: {
|
|
986
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
987
|
+
return {
|
|
988
|
+
instructionType: 6 /* InitializeNonceAccount */,
|
|
989
|
+
...parseInitializeNonceAccountInstruction(instruction)
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
case 7 /* AuthorizeNonceAccount */: {
|
|
993
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
994
|
+
return {
|
|
995
|
+
instructionType: 7 /* AuthorizeNonceAccount */,
|
|
996
|
+
...parseAuthorizeNonceAccountInstruction(instruction)
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
case 8 /* Allocate */: {
|
|
1000
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
1001
|
+
return { instructionType: 8 /* Allocate */, ...parseAllocateInstruction(instruction) };
|
|
1002
|
+
}
|
|
1003
|
+
case 9 /* AllocateWithSeed */: {
|
|
1004
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
1005
|
+
return {
|
|
1006
|
+
instructionType: 9 /* AllocateWithSeed */,
|
|
1007
|
+
...parseAllocateWithSeedInstruction(instruction)
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
case 10 /* AssignWithSeed */: {
|
|
1011
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
1012
|
+
return {
|
|
1013
|
+
instructionType: 10 /* AssignWithSeed */,
|
|
1014
|
+
...parseAssignWithSeedInstruction(instruction)
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
case 11 /* TransferSolWithSeed */: {
|
|
1018
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
1019
|
+
return {
|
|
1020
|
+
instructionType: 11 /* TransferSolWithSeed */,
|
|
1021
|
+
...parseTransferSolWithSeedInstruction(instruction)
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
case 12 /* UpgradeNonceAccount */: {
|
|
1025
|
+
kit.assertIsInstructionWithAccounts(instruction);
|
|
1026
|
+
return {
|
|
1027
|
+
instructionType: 12 /* UpgradeNonceAccount */,
|
|
1028
|
+
...parseUpgradeNonceAccountInstruction(instruction)
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
default:
|
|
1032
|
+
throw new Error(`Unrecognized instruction type: ${instructionType}`);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// src/generated/errors/system.ts
|
|
1037
|
+
var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
|
|
1038
|
+
var SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS = 1;
|
|
1039
|
+
var SYSTEM_ERROR__INVALID_PROGRAM_ID = 2;
|
|
1040
|
+
var SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH = 3;
|
|
1041
|
+
var SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4;
|
|
1042
|
+
var SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH = 5;
|
|
1043
|
+
var SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES = 6;
|
|
1044
|
+
var SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED = 7;
|
|
1045
|
+
var SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE = 8;
|
|
1046
|
+
var systemErrorMessages;
|
|
1047
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1048
|
+
systemErrorMessages = {
|
|
1049
|
+
[SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
|
|
1050
|
+
[SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
|
|
1051
|
+
[SYSTEM_ERROR__INVALID_ACCOUNT_DATA_LENGTH]: `cannot allocate account data of this length`,
|
|
1052
|
+
[SYSTEM_ERROR__INVALID_PROGRAM_ID]: `cannot assign account to this program id`,
|
|
1053
|
+
[SYSTEM_ERROR__MAX_SEED_LENGTH_EXCEEDED]: `length of requested seed is too long`,
|
|
1054
|
+
[SYSTEM_ERROR__NONCE_BLOCKHASH_NOT_EXPIRED]: `stored nonce is still in recent_blockhashes`,
|
|
1055
|
+
[SYSTEM_ERROR__NONCE_NO_RECENT_BLOCKHASHES]: `advancing stored nonce requires a populated RecentBlockhashes sysvar`,
|
|
1056
|
+
[SYSTEM_ERROR__NONCE_UNEXPECTED_BLOCKHASH_VALUE]: `specified nonce does not match stored nonce`,
|
|
1057
|
+
[SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS]: `account does not have enough SOL to perform the operation`
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
function getSystemErrorMessage(code) {
|
|
1061
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1062
|
+
return systemErrorMessages[code];
|
|
1063
|
+
}
|
|
1064
|
+
return "Error message not available in production bundles.";
|
|
1065
|
+
}
|
|
1066
|
+
function isSystemError(error, transactionMessage, code) {
|
|
1067
|
+
return kit.isProgramError(error, transactionMessage, SYSTEM_PROGRAM_ADDRESS, code);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1121
1070
|
exports.ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR = ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR;
|
|
1122
1071
|
exports.ALLOCATE_DISCRIMINATOR = ALLOCATE_DISCRIMINATOR;
|
|
1123
1072
|
exports.ALLOCATE_WITH_SEED_DISCRIMINATOR = ALLOCATE_WITH_SEED_DISCRIMINATOR;
|
|
@@ -1237,6 +1186,7 @@ exports.parseAuthorizeNonceAccountInstruction = parseAuthorizeNonceAccountInstru
|
|
|
1237
1186
|
exports.parseCreateAccountInstruction = parseCreateAccountInstruction;
|
|
1238
1187
|
exports.parseCreateAccountWithSeedInstruction = parseCreateAccountWithSeedInstruction;
|
|
1239
1188
|
exports.parseInitializeNonceAccountInstruction = parseInitializeNonceAccountInstruction;
|
|
1189
|
+
exports.parseSystemInstruction = parseSystemInstruction;
|
|
1240
1190
|
exports.parseTransferSolInstruction = parseTransferSolInstruction;
|
|
1241
1191
|
exports.parseTransferSolWithSeedInstruction = parseTransferSolWithSeedInstruction;
|
|
1242
1192
|
exports.parseUpgradeNonceAccountInstruction = parseUpgradeNonceAccountInstruction;
|