@solana-program/system 0.11.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 +137 -83
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +138 -85
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocate.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocateWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/assign.d.ts.map +1 -1
- package/dist/types/generated/instructions/assignWithSeed.d.ts.map +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.map +1 -1
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSol.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/programs/system.d.ts +32 -2
- package/dist/types/generated/programs/system.d.ts.map +1 -1
- package/package.json +4 -3
- 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, transformEncoder, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, containsBytes,
|
|
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) => {
|
|
@@ -76,36 +77,6 @@ async function fetchAllMaybeNonce(rpc, addresses, config) {
|
|
|
76
77
|
function getNonceSize() {
|
|
77
78
|
return 80;
|
|
78
79
|
}
|
|
79
|
-
function expectAddress(value) {
|
|
80
|
-
if (!value) {
|
|
81
|
-
throw new Error("Expected a Address.");
|
|
82
|
-
}
|
|
83
|
-
if (typeof value === "object" && "address" in value) {
|
|
84
|
-
return value.address;
|
|
85
|
-
}
|
|
86
|
-
if (Array.isArray(value)) {
|
|
87
|
-
return value[0];
|
|
88
|
-
}
|
|
89
|
-
return value;
|
|
90
|
-
}
|
|
91
|
-
function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
|
|
92
|
-
return (account) => {
|
|
93
|
-
if (!account.value) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const writableRole = account.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
|
|
97
|
-
return Object.freeze({
|
|
98
|
-
address: expectAddress(account.value),
|
|
99
|
-
role: isTransactionSigner(account.value) ? upgradeRoleToSigner(writableRole) : writableRole,
|
|
100
|
-
...isTransactionSigner(account.value) ? { signer: account.value } : {}
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function isTransactionSigner(value) {
|
|
105
|
-
return !!value && typeof value === "object" && "address" in value && isTransactionSigner$1(value);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// src/generated/instructions/advanceNonceAccount.ts
|
|
109
80
|
var ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR = 4;
|
|
110
81
|
function getAdvanceNonceAccountDiscriminatorBytes() {
|
|
111
82
|
return getU32Encoder().encode(ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR);
|
|
@@ -133,12 +104,12 @@ function getAdvanceNonceAccountInstruction(input, config) {
|
|
|
133
104
|
if (!accounts.recentBlockhashesSysvar.value) {
|
|
134
105
|
accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
|
|
135
106
|
}
|
|
136
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
107
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
137
108
|
return Object.freeze({
|
|
138
109
|
accounts: [
|
|
139
|
-
getAccountMeta(accounts.nonceAccount),
|
|
140
|
-
getAccountMeta(accounts.recentBlockhashesSysvar),
|
|
141
|
-
getAccountMeta(accounts.nonceAuthority)
|
|
110
|
+
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
111
|
+
getAccountMeta("recentBlockhashesSysvar", accounts.recentBlockhashesSysvar),
|
|
112
|
+
getAccountMeta("nonceAuthority", accounts.nonceAuthority)
|
|
142
113
|
],
|
|
143
114
|
data: getAdvanceNonceAccountInstructionDataEncoder().encode({}),
|
|
144
115
|
programAddress
|
|
@@ -146,7 +117,10 @@ function getAdvanceNonceAccountInstruction(input, config) {
|
|
|
146
117
|
}
|
|
147
118
|
function parseAdvanceNonceAccountInstruction(instruction) {
|
|
148
119
|
if (instruction.accounts.length < 3) {
|
|
149
|
-
throw new
|
|
120
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
121
|
+
actualAccountMetas: instruction.accounts.length,
|
|
122
|
+
expectedAccountMetas: 3
|
|
123
|
+
});
|
|
150
124
|
}
|
|
151
125
|
let accountIndex = 0;
|
|
152
126
|
const getNextAccount = () => {
|
|
@@ -191,16 +165,19 @@ function getAllocateInstruction(input, config) {
|
|
|
191
165
|
const originalAccounts = { newAccount: { value: input.newAccount ?? null, isWritable: true } };
|
|
192
166
|
const accounts = originalAccounts;
|
|
193
167
|
const args = { ...input };
|
|
194
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
168
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
195
169
|
return Object.freeze({
|
|
196
|
-
accounts: [getAccountMeta(accounts.newAccount)],
|
|
170
|
+
accounts: [getAccountMeta("newAccount", accounts.newAccount)],
|
|
197
171
|
data: getAllocateInstructionDataEncoder().encode(args),
|
|
198
172
|
programAddress
|
|
199
173
|
});
|
|
200
174
|
}
|
|
201
175
|
function parseAllocateInstruction(instruction) {
|
|
202
176
|
if (instruction.accounts.length < 1) {
|
|
203
|
-
throw new
|
|
177
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
178
|
+
actualAccountMetas: instruction.accounts.length,
|
|
179
|
+
expectedAccountMetas: 1
|
|
180
|
+
});
|
|
204
181
|
}
|
|
205
182
|
let accountIndex = 0;
|
|
206
183
|
const getNextAccount = () => {
|
|
@@ -250,16 +227,22 @@ function getAllocateWithSeedInstruction(input, config) {
|
|
|
250
227
|
};
|
|
251
228
|
const accounts = originalAccounts;
|
|
252
229
|
const args = { ...input };
|
|
253
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
230
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
254
231
|
return Object.freeze({
|
|
255
|
-
accounts: [
|
|
232
|
+
accounts: [
|
|
233
|
+
getAccountMeta("newAccount", accounts.newAccount),
|
|
234
|
+
getAccountMeta("baseAccount", accounts.baseAccount)
|
|
235
|
+
],
|
|
256
236
|
data: getAllocateWithSeedInstructionDataEncoder().encode(args),
|
|
257
237
|
programAddress
|
|
258
238
|
});
|
|
259
239
|
}
|
|
260
240
|
function parseAllocateWithSeedInstruction(instruction) {
|
|
261
241
|
if (instruction.accounts.length < 2) {
|
|
262
|
-
throw new
|
|
242
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
243
|
+
actualAccountMetas: instruction.accounts.length,
|
|
244
|
+
expectedAccountMetas: 2
|
|
245
|
+
});
|
|
263
246
|
}
|
|
264
247
|
let accountIndex = 0;
|
|
265
248
|
const getNextAccount = () => {
|
|
@@ -300,16 +283,19 @@ function getAssignInstruction(input, config) {
|
|
|
300
283
|
const originalAccounts = { account: { value: input.account ?? null, isWritable: true } };
|
|
301
284
|
const accounts = originalAccounts;
|
|
302
285
|
const args = { ...input };
|
|
303
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
286
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
304
287
|
return Object.freeze({
|
|
305
|
-
accounts: [getAccountMeta(accounts.account)],
|
|
288
|
+
accounts: [getAccountMeta("account", accounts.account)],
|
|
306
289
|
data: getAssignInstructionDataEncoder().encode(args),
|
|
307
290
|
programAddress
|
|
308
291
|
});
|
|
309
292
|
}
|
|
310
293
|
function parseAssignInstruction(instruction) {
|
|
311
294
|
if (instruction.accounts.length < 1) {
|
|
312
|
-
throw new
|
|
295
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
296
|
+
actualAccountMetas: instruction.accounts.length,
|
|
297
|
+
expectedAccountMetas: 1
|
|
298
|
+
});
|
|
313
299
|
}
|
|
314
300
|
let accountIndex = 0;
|
|
315
301
|
const getNextAccount = () => {
|
|
@@ -357,16 +343,19 @@ function getAssignWithSeedInstruction(input, config) {
|
|
|
357
343
|
};
|
|
358
344
|
const accounts = originalAccounts;
|
|
359
345
|
const args = { ...input };
|
|
360
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
346
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
361
347
|
return Object.freeze({
|
|
362
|
-
accounts: [getAccountMeta(accounts.account), getAccountMeta(accounts.baseAccount)],
|
|
348
|
+
accounts: [getAccountMeta("account", accounts.account), getAccountMeta("baseAccount", accounts.baseAccount)],
|
|
363
349
|
data: getAssignWithSeedInstructionDataEncoder().encode(args),
|
|
364
350
|
programAddress
|
|
365
351
|
});
|
|
366
352
|
}
|
|
367
353
|
function parseAssignWithSeedInstruction(instruction) {
|
|
368
354
|
if (instruction.accounts.length < 2) {
|
|
369
|
-
throw new
|
|
355
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
356
|
+
actualAccountMetas: instruction.accounts.length,
|
|
357
|
+
expectedAccountMetas: 2
|
|
358
|
+
});
|
|
370
359
|
}
|
|
371
360
|
let accountIndex = 0;
|
|
372
361
|
const getNextAccount = () => {
|
|
@@ -413,16 +402,22 @@ function getAuthorizeNonceAccountInstruction(input, config) {
|
|
|
413
402
|
};
|
|
414
403
|
const accounts = originalAccounts;
|
|
415
404
|
const args = { ...input };
|
|
416
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
405
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
417
406
|
return Object.freeze({
|
|
418
|
-
accounts: [
|
|
407
|
+
accounts: [
|
|
408
|
+
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
409
|
+
getAccountMeta("nonceAuthority", accounts.nonceAuthority)
|
|
410
|
+
],
|
|
419
411
|
data: getAuthorizeNonceAccountInstructionDataEncoder().encode(args),
|
|
420
412
|
programAddress
|
|
421
413
|
});
|
|
422
414
|
}
|
|
423
415
|
function parseAuthorizeNonceAccountInstruction(instruction) {
|
|
424
416
|
if (instruction.accounts.length < 2) {
|
|
425
|
-
throw new
|
|
417
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
418
|
+
actualAccountMetas: instruction.accounts.length,
|
|
419
|
+
expectedAccountMetas: 2
|
|
420
|
+
});
|
|
426
421
|
}
|
|
427
422
|
let accountIndex = 0;
|
|
428
423
|
const getNextAccount = () => {
|
|
@@ -471,9 +466,9 @@ function getCreateAccountInstruction(input, config) {
|
|
|
471
466
|
const accounts = originalAccounts;
|
|
472
467
|
const args = { ...input };
|
|
473
468
|
const byteDelta = [Number(args.space) + BASE_ACCOUNT_SIZE].reduce((a, b) => a + b, 0);
|
|
474
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
469
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
475
470
|
return Object.freeze({
|
|
476
|
-
accounts: [getAccountMeta(accounts.payer), getAccountMeta(accounts.newAccount)],
|
|
471
|
+
accounts: [getAccountMeta("payer", accounts.payer), getAccountMeta("newAccount", accounts.newAccount)],
|
|
477
472
|
byteDelta,
|
|
478
473
|
data: getCreateAccountInstructionDataEncoder().encode(args),
|
|
479
474
|
programAddress
|
|
@@ -481,7 +476,10 @@ function getCreateAccountInstruction(input, config) {
|
|
|
481
476
|
}
|
|
482
477
|
function parseCreateAccountInstruction(instruction) {
|
|
483
478
|
if (instruction.accounts.length < 2) {
|
|
484
|
-
throw new
|
|
479
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
480
|
+
actualAccountMetas: instruction.accounts.length,
|
|
481
|
+
expectedAccountMetas: 2
|
|
482
|
+
});
|
|
485
483
|
}
|
|
486
484
|
let accountIndex = 0;
|
|
487
485
|
const getNextAccount = () => {
|
|
@@ -537,12 +535,12 @@ function getCreateAccountWithSeedInstruction(input, config) {
|
|
|
537
535
|
};
|
|
538
536
|
const accounts = originalAccounts;
|
|
539
537
|
const args = { ...input };
|
|
540
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
538
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
541
539
|
return Object.freeze({
|
|
542
540
|
accounts: [
|
|
543
|
-
getAccountMeta(accounts.payer),
|
|
544
|
-
getAccountMeta(accounts.newAccount),
|
|
545
|
-
getAccountMeta(accounts.baseAccount)
|
|
541
|
+
getAccountMeta("payer", accounts.payer),
|
|
542
|
+
getAccountMeta("newAccount", accounts.newAccount),
|
|
543
|
+
getAccountMeta("baseAccount", accounts.baseAccount)
|
|
546
544
|
].filter((x) => x !== void 0),
|
|
547
545
|
data: getCreateAccountWithSeedInstructionDataEncoder().encode(args),
|
|
548
546
|
programAddress
|
|
@@ -550,7 +548,10 @@ function getCreateAccountWithSeedInstruction(input, config) {
|
|
|
550
548
|
}
|
|
551
549
|
function parseCreateAccountWithSeedInstruction(instruction) {
|
|
552
550
|
if (instruction.accounts.length < 2) {
|
|
553
|
-
throw new
|
|
551
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
552
|
+
actualAccountMetas: instruction.accounts.length,
|
|
553
|
+
expectedAccountMetas: 2
|
|
554
|
+
});
|
|
554
555
|
}
|
|
555
556
|
let accountIndex = 0;
|
|
556
557
|
const getNextAccount = () => {
|
|
@@ -610,12 +611,12 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
610
611
|
if (!accounts.rentSysvar.value) {
|
|
611
612
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
612
613
|
}
|
|
613
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
614
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
614
615
|
return Object.freeze({
|
|
615
616
|
accounts: [
|
|
616
|
-
getAccountMeta(accounts.nonceAccount),
|
|
617
|
-
getAccountMeta(accounts.recentBlockhashesSysvar),
|
|
618
|
-
getAccountMeta(accounts.rentSysvar)
|
|
617
|
+
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
618
|
+
getAccountMeta("recentBlockhashesSysvar", accounts.recentBlockhashesSysvar),
|
|
619
|
+
getAccountMeta("rentSysvar", accounts.rentSysvar)
|
|
619
620
|
],
|
|
620
621
|
data: getInitializeNonceAccountInstructionDataEncoder().encode(
|
|
621
622
|
args
|
|
@@ -625,7 +626,10 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
625
626
|
}
|
|
626
627
|
function parseInitializeNonceAccountInstruction(instruction) {
|
|
627
628
|
if (instruction.accounts.length < 3) {
|
|
628
|
-
throw new
|
|
629
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
630
|
+
actualAccountMetas: instruction.accounts.length,
|
|
631
|
+
expectedAccountMetas: 3
|
|
632
|
+
});
|
|
629
633
|
}
|
|
630
634
|
let accountIndex = 0;
|
|
631
635
|
const getNextAccount = () => {
|
|
@@ -673,16 +677,19 @@ function getTransferSolInstruction(input, config) {
|
|
|
673
677
|
};
|
|
674
678
|
const accounts = originalAccounts;
|
|
675
679
|
const args = { ...input };
|
|
676
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
680
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
677
681
|
return Object.freeze({
|
|
678
|
-
accounts: [getAccountMeta(accounts.source), getAccountMeta(accounts.destination)],
|
|
682
|
+
accounts: [getAccountMeta("source", accounts.source), getAccountMeta("destination", accounts.destination)],
|
|
679
683
|
data: getTransferSolInstructionDataEncoder().encode(args),
|
|
680
684
|
programAddress
|
|
681
685
|
});
|
|
682
686
|
}
|
|
683
687
|
function parseTransferSolInstruction(instruction) {
|
|
684
688
|
if (instruction.accounts.length < 2) {
|
|
685
|
-
throw new
|
|
689
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
690
|
+
actualAccountMetas: instruction.accounts.length,
|
|
691
|
+
expectedAccountMetas: 2
|
|
692
|
+
});
|
|
686
693
|
}
|
|
687
694
|
let accountIndex = 0;
|
|
688
695
|
const getNextAccount = () => {
|
|
@@ -731,12 +738,12 @@ function getTransferSolWithSeedInstruction(input, config) {
|
|
|
731
738
|
};
|
|
732
739
|
const accounts = originalAccounts;
|
|
733
740
|
const args = { ...input };
|
|
734
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
741
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
735
742
|
return Object.freeze({
|
|
736
743
|
accounts: [
|
|
737
|
-
getAccountMeta(accounts.source),
|
|
738
|
-
getAccountMeta(accounts.baseAccount),
|
|
739
|
-
getAccountMeta(accounts.destination)
|
|
744
|
+
getAccountMeta("source", accounts.source),
|
|
745
|
+
getAccountMeta("baseAccount", accounts.baseAccount),
|
|
746
|
+
getAccountMeta("destination", accounts.destination)
|
|
740
747
|
],
|
|
741
748
|
data: getTransferSolWithSeedInstructionDataEncoder().encode(args),
|
|
742
749
|
programAddress
|
|
@@ -744,7 +751,10 @@ function getTransferSolWithSeedInstruction(input, config) {
|
|
|
744
751
|
}
|
|
745
752
|
function parseTransferSolWithSeedInstruction(instruction) {
|
|
746
753
|
if (instruction.accounts.length < 3) {
|
|
747
|
-
throw new
|
|
754
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
755
|
+
actualAccountMetas: instruction.accounts.length,
|
|
756
|
+
expectedAccountMetas: 3
|
|
757
|
+
});
|
|
748
758
|
}
|
|
749
759
|
let accountIndex = 0;
|
|
750
760
|
const getNextAccount = () => {
|
|
@@ -778,16 +788,19 @@ function getUpgradeNonceAccountInstruction(input, config) {
|
|
|
778
788
|
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
779
789
|
const originalAccounts = { nonceAccount: { value: input.nonceAccount ?? null, isWritable: true } };
|
|
780
790
|
const accounts = originalAccounts;
|
|
781
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
791
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
782
792
|
return Object.freeze({
|
|
783
|
-
accounts: [getAccountMeta(accounts.nonceAccount)],
|
|
793
|
+
accounts: [getAccountMeta("nonceAccount", accounts.nonceAccount)],
|
|
784
794
|
data: getUpgradeNonceAccountInstructionDataEncoder().encode({}),
|
|
785
795
|
programAddress
|
|
786
796
|
});
|
|
787
797
|
}
|
|
788
798
|
function parseUpgradeNonceAccountInstruction(instruction) {
|
|
789
799
|
if (instruction.accounts.length < 1) {
|
|
790
|
-
throw new
|
|
800
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
801
|
+
actualAccountMetas: instruction.accounts.length,
|
|
802
|
+
expectedAccountMetas: 1
|
|
803
|
+
});
|
|
791
804
|
}
|
|
792
805
|
let accountIndex = 0;
|
|
793
806
|
const getNextAccount = () => {
|
|
@@ -843,14 +856,14 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
843
856
|
if (!accounts.rentSysvar.value) {
|
|
844
857
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
845
858
|
}
|
|
846
|
-
const getAccountMeta = getAccountMetaFactory();
|
|
859
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
847
860
|
return Object.freeze({
|
|
848
861
|
accounts: [
|
|
849
|
-
getAccountMeta(accounts.nonceAccount),
|
|
850
|
-
getAccountMeta(accounts.recipientAccount),
|
|
851
|
-
getAccountMeta(accounts.recentBlockhashesSysvar),
|
|
852
|
-
getAccountMeta(accounts.rentSysvar),
|
|
853
|
-
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)
|
|
854
867
|
],
|
|
855
868
|
data: getWithdrawNonceAccountInstructionDataEncoder().encode(args),
|
|
856
869
|
programAddress
|
|
@@ -858,7 +871,10 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
858
871
|
}
|
|
859
872
|
function parseWithdrawNonceAccountInstruction(instruction) {
|
|
860
873
|
if (instruction.accounts.length < 5) {
|
|
861
|
-
throw new
|
|
874
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
|
|
875
|
+
actualAccountMetas: instruction.accounts.length,
|
|
876
|
+
expectedAccountMetas: 5
|
|
877
|
+
});
|
|
862
878
|
}
|
|
863
879
|
let accountIndex = 0;
|
|
864
880
|
const getNextAccount = () => {
|
|
@@ -942,7 +958,10 @@ function identifySystemInstruction(instruction) {
|
|
|
942
958
|
if (containsBytes(data, getU32Encoder().encode(12), 0)) {
|
|
943
959
|
return 12 /* UpgradeNonceAccount */;
|
|
944
960
|
}
|
|
945
|
-
throw new
|
|
961
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
|
|
962
|
+
instructionData: data,
|
|
963
|
+
programName: "system"
|
|
964
|
+
});
|
|
946
965
|
}
|
|
947
966
|
function parseSystemInstruction(instruction) {
|
|
948
967
|
const instructionType = identifySystemInstruction(instruction);
|
|
@@ -1027,9 +1046,43 @@ function parseSystemInstruction(instruction) {
|
|
|
1027
1046
|
};
|
|
1028
1047
|
}
|
|
1029
1048
|
default:
|
|
1030
|
-
throw new
|
|
1049
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
|
|
1050
|
+
instructionType,
|
|
1051
|
+
programName: "system"
|
|
1052
|
+
});
|
|
1031
1053
|
}
|
|
1032
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
|
+
}
|
|
1033
1086
|
|
|
1034
1087
|
// src/generated/errors/system.ts
|
|
1035
1088
|
var SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE = 0;
|
|
@@ -1065,6 +1118,6 @@ function isSystemError(error, transactionMessage, code) {
|
|
|
1065
1118
|
return isProgramError(error, transactionMessage, SYSTEM_PROGRAM_ADDRESS, code);
|
|
1066
1119
|
}
|
|
1067
1120
|
|
|
1068
|
-
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 };
|
|
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 };
|
|
1069
1122
|
//# sourceMappingURL=index.mjs.map
|
|
1070
1123
|
//# sourceMappingURL=index.mjs.map
|