@solana-program/system 0.14.1 → 0.16.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 +171 -81
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +171 -81
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/generated/accounts/nonce.d.ts +7 -7
- package/dist/types/generated/accounts/nonce.d.ts.map +1 -1
- package/dist/types/generated/errors/system.d.ts +4 -2
- package/dist/types/generated/errors/system.d.ts.map +1 -1
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts +11 -8
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocate.d.ts +9 -6
- package/dist/types/generated/instructions/allocate.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocateWithSeed.d.ts +12 -9
- package/dist/types/generated/instructions/allocateWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/assign.d.ts +10 -7
- package/dist/types/generated/instructions/assign.d.ts.map +1 -1
- package/dist/types/generated/instructions/assignWithSeed.d.ts +12 -9
- package/dist/types/generated/instructions/assignWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts +11 -8
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccount.d.ts +11 -9
- package/dist/types/generated/instructions/createAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccountAllowPrefund.d.ts +11 -9
- package/dist/types/generated/instructions/createAccountAllowPrefund.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts +13 -10
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts +12 -9
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSol.d.ts +10 -7
- package/dist/types/generated/instructions/transferSol.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts +12 -9
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts +8 -5
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts +13 -10
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/programs/system.d.ts +46 -16
- package/dist/types/generated/programs/system.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/generated/accounts/nonce.ts +17 -8
- package/src/generated/errors/system.ts +5 -1
- package/src/generated/instructions/advanceNonceAccount.ts +38 -23
- package/src/generated/instructions/allocate.ts +25 -11
- package/src/generated/instructions/allocateWithSeed.ts +35 -17
- package/src/generated/instructions/assign.ts +27 -12
- package/src/generated/instructions/assignWithSeed.ts +38 -16
- package/src/generated/instructions/authorizeNonceAccount.ts +34 -16
- package/src/generated/instructions/createAccount.ts +33 -14
- package/src/generated/instructions/createAccountAllowPrefund.ts +30 -15
- package/src/generated/instructions/createAccountWithSeed.ts +41 -21
- package/src/generated/instructions/initializeNonceAccount.ts +39 -23
- package/src/generated/instructions/transferSol.ts +34 -14
- package/src/generated/instructions/transferSolWithSeed.ts +44 -20
- package/src/generated/instructions/upgradeNonceAccount.ts +25 -10
- package/src/generated/instructions/withdrawNonceAccount.ts +53 -35
- package/src/generated/programs/system.ts +119 -28
package/dist/src/index.mjs
CHANGED
|
@@ -62,7 +62,11 @@ async function fetchNonce(rpc, address, config) {
|
|
|
62
62
|
return maybeAccount;
|
|
63
63
|
}
|
|
64
64
|
async function fetchMaybeNonce(rpc, address, config) {
|
|
65
|
-
const maybeAccount = await fetchEncodedAccount(
|
|
65
|
+
const maybeAccount = await fetchEncodedAccount(
|
|
66
|
+
rpc,
|
|
67
|
+
typeof address === "string" ? address : address.address,
|
|
68
|
+
config
|
|
69
|
+
);
|
|
66
70
|
return decodeNonce(maybeAccount);
|
|
67
71
|
}
|
|
68
72
|
async function fetchAllNonce(rpc, addresses, config) {
|
|
@@ -71,7 +75,11 @@ async function fetchAllNonce(rpc, addresses, config) {
|
|
|
71
75
|
return maybeAccounts;
|
|
72
76
|
}
|
|
73
77
|
async function fetchAllMaybeNonce(rpc, addresses, config) {
|
|
74
|
-
const maybeAccounts = await fetchEncodedAccounts(
|
|
78
|
+
const maybeAccounts = await fetchEncodedAccounts(
|
|
79
|
+
rpc,
|
|
80
|
+
addresses.map((a) => typeof a === "string" ? a : a.address),
|
|
81
|
+
config
|
|
82
|
+
);
|
|
75
83
|
return maybeAccounts.map((maybeAccount) => decodeNonce(maybeAccount));
|
|
76
84
|
}
|
|
77
85
|
function getNonceSize() {
|
|
@@ -94,17 +102,18 @@ function getAdvanceNonceAccountInstructionDataCodec() {
|
|
|
94
102
|
return combineCodec(getAdvanceNonceAccountInstructionDataEncoder(), getAdvanceNonceAccountInstructionDataDecoder());
|
|
95
103
|
}
|
|
96
104
|
function getAdvanceNonceAccountInstruction(input, config) {
|
|
97
|
-
const
|
|
105
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
106
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
107
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
98
108
|
const originalAccounts = {
|
|
99
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
100
|
-
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
101
|
-
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
|
|
109
|
+
nonceAccount: { value: input.nonceAccount ?? null, isSigner: false, isWritable: true },
|
|
110
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isSigner: false, isWritable: false },
|
|
111
|
+
nonceAuthority: { value: input.nonceAuthority ?? null, isSigner: true, isWritable: false }
|
|
102
112
|
};
|
|
103
113
|
const accounts = originalAccounts;
|
|
104
114
|
if (!accounts.recentBlockhashesSysvar.value) {
|
|
105
115
|
accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
|
|
106
116
|
}
|
|
107
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
108
117
|
return Object.freeze({
|
|
109
118
|
accounts: [
|
|
110
119
|
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
@@ -161,11 +170,12 @@ function getAllocateInstructionDataCodec() {
|
|
|
161
170
|
return combineCodec(getAllocateInstructionDataEncoder(), getAllocateInstructionDataDecoder());
|
|
162
171
|
}
|
|
163
172
|
function getAllocateInstruction(input, config) {
|
|
164
|
-
const
|
|
165
|
-
const
|
|
173
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
174
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
175
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
176
|
+
const originalAccounts = { newAccount: { value: input.newAccount ?? null, isSigner: true, isWritable: true } };
|
|
166
177
|
const accounts = originalAccounts;
|
|
167
178
|
const args = { ...input };
|
|
168
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
169
179
|
return Object.freeze({
|
|
170
180
|
accounts: [getAccountMeta("newAccount", accounts.newAccount)],
|
|
171
181
|
data: getAllocateInstructionDataEncoder().encode(args),
|
|
@@ -220,14 +230,15 @@ function getAllocateWithSeedInstructionDataCodec() {
|
|
|
220
230
|
return combineCodec(getAllocateWithSeedInstructionDataEncoder(), getAllocateWithSeedInstructionDataDecoder());
|
|
221
231
|
}
|
|
222
232
|
function getAllocateWithSeedInstruction(input, config) {
|
|
223
|
-
const
|
|
233
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
234
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
235
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
224
236
|
const originalAccounts = {
|
|
225
|
-
newAccount: { value: input.newAccount ?? null, isWritable: true },
|
|
226
|
-
baseAccount: { value: input.baseAccount ?? null, isWritable: false }
|
|
237
|
+
newAccount: { value: input.newAccount ?? null, isSigner: false, isWritable: true },
|
|
238
|
+
baseAccount: { value: input.baseAccount ?? null, isSigner: true, isWritable: false }
|
|
227
239
|
};
|
|
228
240
|
const accounts = originalAccounts;
|
|
229
241
|
const args = { ...input };
|
|
230
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
231
242
|
return Object.freeze({
|
|
232
243
|
accounts: [
|
|
233
244
|
getAccountMeta("newAccount", accounts.newAccount),
|
|
@@ -279,11 +290,12 @@ function getAssignInstructionDataCodec() {
|
|
|
279
290
|
return combineCodec(getAssignInstructionDataEncoder(), getAssignInstructionDataDecoder());
|
|
280
291
|
}
|
|
281
292
|
function getAssignInstruction(input, config) {
|
|
282
|
-
const
|
|
283
|
-
const
|
|
293
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
294
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
295
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
296
|
+
const originalAccounts = { account: { value: input.account ?? null, isSigner: true, isWritable: true } };
|
|
284
297
|
const accounts = originalAccounts;
|
|
285
298
|
const args = { ...input };
|
|
286
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
287
299
|
return Object.freeze({
|
|
288
300
|
accounts: [getAccountMeta("account", accounts.account)],
|
|
289
301
|
data: getAssignInstructionDataEncoder().encode(args),
|
|
@@ -336,14 +348,15 @@ function getAssignWithSeedInstructionDataCodec() {
|
|
|
336
348
|
return combineCodec(getAssignWithSeedInstructionDataEncoder(), getAssignWithSeedInstructionDataDecoder());
|
|
337
349
|
}
|
|
338
350
|
function getAssignWithSeedInstruction(input, config) {
|
|
339
|
-
const
|
|
351
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
352
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
353
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
340
354
|
const originalAccounts = {
|
|
341
|
-
account: { value: input.account ?? null, isWritable: true },
|
|
342
|
-
baseAccount: { value: input.baseAccount ?? null, isWritable: false }
|
|
355
|
+
account: { value: input.account ?? null, isSigner: false, isWritable: true },
|
|
356
|
+
baseAccount: { value: input.baseAccount ?? null, isSigner: true, isWritable: false }
|
|
343
357
|
};
|
|
344
358
|
const accounts = originalAccounts;
|
|
345
359
|
const args = { ...input };
|
|
346
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
347
360
|
return Object.freeze({
|
|
348
361
|
accounts: [getAccountMeta("account", accounts.account), getAccountMeta("baseAccount", accounts.baseAccount)],
|
|
349
362
|
data: getAssignWithSeedInstructionDataEncoder().encode(args),
|
|
@@ -395,14 +408,15 @@ function getAuthorizeNonceAccountInstructionDataCodec() {
|
|
|
395
408
|
);
|
|
396
409
|
}
|
|
397
410
|
function getAuthorizeNonceAccountInstruction(input, config) {
|
|
398
|
-
const
|
|
411
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
412
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
413
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
399
414
|
const originalAccounts = {
|
|
400
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
401
|
-
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
|
|
415
|
+
nonceAccount: { value: input.nonceAccount ?? null, isSigner: false, isWritable: true },
|
|
416
|
+
nonceAuthority: { value: input.nonceAuthority ?? null, isSigner: true, isWritable: false }
|
|
402
417
|
};
|
|
403
418
|
const accounts = originalAccounts;
|
|
404
419
|
const args = { ...input };
|
|
405
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
406
420
|
return Object.freeze({
|
|
407
421
|
accounts: [
|
|
408
422
|
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
@@ -458,15 +472,16 @@ function getCreateAccountInstructionDataCodec() {
|
|
|
458
472
|
return combineCodec(getCreateAccountInstructionDataEncoder(), getCreateAccountInstructionDataDecoder());
|
|
459
473
|
}
|
|
460
474
|
function getCreateAccountInstruction(input, config) {
|
|
461
|
-
const
|
|
475
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
476
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
477
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
462
478
|
const originalAccounts = {
|
|
463
|
-
payer: { value: input.payer ?? null, isWritable: true },
|
|
464
|
-
newAccount: { value: input.newAccount ?? null, isWritable: true }
|
|
479
|
+
payer: { value: input.payer ?? null, isSigner: true, isWritable: true },
|
|
480
|
+
newAccount: { value: input.newAccount ?? null, isSigner: true, isWritable: true }
|
|
465
481
|
};
|
|
466
482
|
const accounts = originalAccounts;
|
|
467
483
|
const args = { ...input };
|
|
468
484
|
const byteDelta = [Number(args.space) + BASE_ACCOUNT_SIZE].reduce((a, b) => a + b, 0);
|
|
469
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
470
485
|
return Object.freeze({
|
|
471
486
|
accounts: [getAccountMeta("payer", accounts.payer), getAccountMeta("newAccount", accounts.newAccount)],
|
|
472
487
|
byteDelta,
|
|
@@ -527,15 +542,16 @@ function getCreateAccountAllowPrefundInstructionDataCodec() {
|
|
|
527
542
|
);
|
|
528
543
|
}
|
|
529
544
|
function getCreateAccountAllowPrefundInstruction(input, config) {
|
|
530
|
-
const
|
|
545
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
546
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
547
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
531
548
|
const originalAccounts = {
|
|
532
|
-
newAccount: { value: input.newAccount ?? null, isWritable: true },
|
|
533
|
-
payer: { value: input.payer ?? null, isWritable: true }
|
|
549
|
+
newAccount: { value: input.newAccount ?? null, isSigner: true, isWritable: true },
|
|
550
|
+
payer: { value: input.payer ?? null, isSigner: true, isWritable: true }
|
|
534
551
|
};
|
|
535
552
|
const accounts = originalAccounts;
|
|
536
553
|
const args = { ...input };
|
|
537
554
|
const byteDelta = [Number(args.space) + BASE_ACCOUNT_SIZE].reduce((a, b) => a + b, 0);
|
|
538
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
539
555
|
return Object.freeze({
|
|
540
556
|
accounts: [getAccountMeta("newAccount", accounts.newAccount), getAccountMeta("payer", accounts.payer)].filter(
|
|
541
557
|
(x) => x !== void 0
|
|
@@ -606,15 +622,16 @@ function getCreateAccountWithSeedInstructionDataCodec() {
|
|
|
606
622
|
);
|
|
607
623
|
}
|
|
608
624
|
function getCreateAccountWithSeedInstruction(input, config) {
|
|
609
|
-
const
|
|
625
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
626
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
627
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
610
628
|
const originalAccounts = {
|
|
611
|
-
payer: { value: input.payer ?? null, isWritable: true },
|
|
612
|
-
newAccount: { value: input.newAccount ?? null, isWritable: true },
|
|
613
|
-
baseAccount: { value: input.baseAccount ?? null, isWritable: false }
|
|
629
|
+
payer: { value: input.payer ?? null, isSigner: true, isWritable: true },
|
|
630
|
+
newAccount: { value: input.newAccount ?? null, isSigner: false, isWritable: true },
|
|
631
|
+
baseAccount: { value: input.baseAccount ?? null, isSigner: true, isWritable: false }
|
|
614
632
|
};
|
|
615
633
|
const accounts = originalAccounts;
|
|
616
634
|
const args = { ...input };
|
|
617
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
618
635
|
return Object.freeze({
|
|
619
636
|
accounts: [
|
|
620
637
|
getAccountMeta("payer", accounts.payer),
|
|
@@ -676,11 +693,13 @@ function getInitializeNonceAccountInstructionDataCodec() {
|
|
|
676
693
|
);
|
|
677
694
|
}
|
|
678
695
|
function getInitializeNonceAccountInstruction(input, config) {
|
|
679
|
-
const
|
|
696
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
697
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
698
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
680
699
|
const originalAccounts = {
|
|
681
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
682
|
-
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
683
|
-
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false }
|
|
700
|
+
nonceAccount: { value: input.nonceAccount ?? null, isSigner: false, isWritable: true },
|
|
701
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isSigner: false, isWritable: false },
|
|
702
|
+
rentSysvar: { value: input.rentSysvar ?? null, isSigner: false, isWritable: false }
|
|
684
703
|
};
|
|
685
704
|
const accounts = originalAccounts;
|
|
686
705
|
const args = { ...input };
|
|
@@ -690,7 +709,6 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
690
709
|
if (!accounts.rentSysvar.value) {
|
|
691
710
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
692
711
|
}
|
|
693
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
694
712
|
return Object.freeze({
|
|
695
713
|
accounts: [
|
|
696
714
|
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
@@ -749,14 +767,15 @@ function getTransferSolInstructionDataCodec() {
|
|
|
749
767
|
return combineCodec(getTransferSolInstructionDataEncoder(), getTransferSolInstructionDataDecoder());
|
|
750
768
|
}
|
|
751
769
|
function getTransferSolInstruction(input, config) {
|
|
752
|
-
const
|
|
770
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
771
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
772
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
753
773
|
const originalAccounts = {
|
|
754
|
-
source: { value: input.source ?? null, isWritable: true },
|
|
755
|
-
destination: { value: input.destination ?? null, isWritable: true }
|
|
774
|
+
source: { value: input.source ?? null, isSigner: true, isWritable: true },
|
|
775
|
+
destination: { value: input.destination ?? null, isSigner: false, isWritable: true }
|
|
756
776
|
};
|
|
757
777
|
const accounts = originalAccounts;
|
|
758
778
|
const args = { ...input };
|
|
759
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
760
779
|
return Object.freeze({
|
|
761
780
|
accounts: [getAccountMeta("source", accounts.source), getAccountMeta("destination", accounts.destination)],
|
|
762
781
|
data: getTransferSolInstructionDataEncoder().encode(args),
|
|
@@ -809,15 +828,16 @@ function getTransferSolWithSeedInstructionDataCodec() {
|
|
|
809
828
|
return combineCodec(getTransferSolWithSeedInstructionDataEncoder(), getTransferSolWithSeedInstructionDataDecoder());
|
|
810
829
|
}
|
|
811
830
|
function getTransferSolWithSeedInstruction(input, config) {
|
|
812
|
-
const
|
|
831
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
832
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
833
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
813
834
|
const originalAccounts = {
|
|
814
|
-
source: { value: input.source ?? null, isWritable: true },
|
|
815
|
-
baseAccount: { value: input.baseAccount ?? null, isWritable: false },
|
|
816
|
-
destination: { value: input.destination ?? null, isWritable: true }
|
|
835
|
+
source: { value: input.source ?? null, isSigner: false, isWritable: true },
|
|
836
|
+
baseAccount: { value: input.baseAccount ?? null, isSigner: true, isWritable: false },
|
|
837
|
+
destination: { value: input.destination ?? null, isSigner: false, isWritable: true }
|
|
817
838
|
};
|
|
818
839
|
const accounts = originalAccounts;
|
|
819
840
|
const args = { ...input };
|
|
820
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
821
841
|
return Object.freeze({
|
|
822
842
|
accounts: [
|
|
823
843
|
getAccountMeta("source", accounts.source),
|
|
@@ -864,10 +884,11 @@ function getUpgradeNonceAccountInstructionDataCodec() {
|
|
|
864
884
|
return combineCodec(getUpgradeNonceAccountInstructionDataEncoder(), getUpgradeNonceAccountInstructionDataDecoder());
|
|
865
885
|
}
|
|
866
886
|
function getUpgradeNonceAccountInstruction(input, config) {
|
|
867
|
-
const
|
|
868
|
-
const
|
|
869
|
-
const accounts = originalAccounts;
|
|
887
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
888
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
870
889
|
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
890
|
+
const originalAccounts = { nonceAccount: { value: input.nonceAccount ?? null, isSigner: false, isWritable: true } };
|
|
891
|
+
const accounts = originalAccounts;
|
|
871
892
|
return Object.freeze({
|
|
872
893
|
accounts: [getAccountMeta("nonceAccount", accounts.nonceAccount)],
|
|
873
894
|
data: getUpgradeNonceAccountInstructionDataEncoder().encode({}),
|
|
@@ -919,13 +940,15 @@ function getWithdrawNonceAccountInstructionDataCodec() {
|
|
|
919
940
|
);
|
|
920
941
|
}
|
|
921
942
|
function getWithdrawNonceAccountInstruction(input, config) {
|
|
922
|
-
const
|
|
943
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
944
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
945
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
923
946
|
const originalAccounts = {
|
|
924
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
925
|
-
recipientAccount: { value: input.recipientAccount ?? null, isWritable: true },
|
|
926
|
-
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
927
|
-
rentSysvar: { value: input.rentSysvar ?? null, isWritable: false },
|
|
928
|
-
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false }
|
|
947
|
+
nonceAccount: { value: input.nonceAccount ?? null, isSigner: false, isWritable: true },
|
|
948
|
+
recipientAccount: { value: input.recipientAccount ?? null, isSigner: false, isWritable: true },
|
|
949
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isSigner: false, isWritable: false },
|
|
950
|
+
rentSysvar: { value: input.rentSysvar ?? null, isSigner: false, isWritable: false },
|
|
951
|
+
nonceAuthority: { value: input.nonceAuthority ?? null, isSigner: true, isWritable: false }
|
|
929
952
|
};
|
|
930
953
|
const accounts = originalAccounts;
|
|
931
954
|
const args = { ...input };
|
|
@@ -935,7 +958,6 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
935
958
|
if (!accounts.rentSysvar.value) {
|
|
936
959
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
937
960
|
}
|
|
938
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, "omitted");
|
|
939
961
|
return Object.freeze({
|
|
940
962
|
accounts: [
|
|
941
963
|
getAccountMeta("nonceAccount", accounts.nonceAccount),
|
|
@@ -1142,32 +1164,98 @@ function parseSystemInstruction(instruction) {
|
|
|
1142
1164
|
});
|
|
1143
1165
|
}
|
|
1144
1166
|
}
|
|
1145
|
-
function systemProgram() {
|
|
1167
|
+
function systemProgram(config = {}) {
|
|
1146
1168
|
return (client) => {
|
|
1147
1169
|
return extendClient(client, {
|
|
1148
1170
|
system: {
|
|
1149
1171
|
accounts: { nonce: addSelfFetchFunctions(client, getNonceCodec()) },
|
|
1150
1172
|
instructions: {
|
|
1151
|
-
createAccount: (input) => addSelfPlanAndSendFunctions(
|
|
1173
|
+
createAccount: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1174
|
+
client,
|
|
1175
|
+
getCreateAccountInstruction(
|
|
1176
|
+
{ ...input, payer: input.payer ?? client.payer },
|
|
1177
|
+
{ programAddress: instructionConfig?.programAddress ?? config.programAddress }
|
|
1178
|
+
)
|
|
1179
|
+
),
|
|
1180
|
+
assign: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1181
|
+
client,
|
|
1182
|
+
getAssignInstruction(input, {
|
|
1183
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1184
|
+
})
|
|
1185
|
+
),
|
|
1186
|
+
transferSol: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1187
|
+
client,
|
|
1188
|
+
getTransferSolInstruction(input, {
|
|
1189
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1190
|
+
})
|
|
1191
|
+
),
|
|
1192
|
+
createAccountWithSeed: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1193
|
+
client,
|
|
1194
|
+
getCreateAccountWithSeedInstruction(
|
|
1195
|
+
{ ...input, payer: input.payer ?? client.payer },
|
|
1196
|
+
{ programAddress: instructionConfig?.programAddress ?? config.programAddress }
|
|
1197
|
+
)
|
|
1198
|
+
),
|
|
1199
|
+
advanceNonceAccount: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1200
|
+
client,
|
|
1201
|
+
getAdvanceNonceAccountInstruction(input, {
|
|
1202
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1203
|
+
})
|
|
1204
|
+
),
|
|
1205
|
+
withdrawNonceAccount: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1152
1206
|
client,
|
|
1153
|
-
|
|
1207
|
+
getWithdrawNonceAccountInstruction(input, {
|
|
1208
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1209
|
+
})
|
|
1154
1210
|
),
|
|
1155
|
-
|
|
1156
|
-
transferSol: (input) => addSelfPlanAndSendFunctions(client, getTransferSolInstruction(input)),
|
|
1157
|
-
createAccountWithSeed: (input) => addSelfPlanAndSendFunctions(
|
|
1211
|
+
initializeNonceAccount: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1158
1212
|
client,
|
|
1159
|
-
|
|
1213
|
+
getInitializeNonceAccountInstruction(input, {
|
|
1214
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1215
|
+
})
|
|
1160
1216
|
),
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1217
|
+
authorizeNonceAccount: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1218
|
+
client,
|
|
1219
|
+
getAuthorizeNonceAccountInstruction(input, {
|
|
1220
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1221
|
+
})
|
|
1222
|
+
),
|
|
1223
|
+
allocate: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1224
|
+
client,
|
|
1225
|
+
getAllocateInstruction(input, {
|
|
1226
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1227
|
+
})
|
|
1228
|
+
),
|
|
1229
|
+
allocateWithSeed: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1230
|
+
client,
|
|
1231
|
+
getAllocateWithSeedInstruction(input, {
|
|
1232
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1233
|
+
})
|
|
1234
|
+
),
|
|
1235
|
+
assignWithSeed: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1236
|
+
client,
|
|
1237
|
+
getAssignWithSeedInstruction(input, {
|
|
1238
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1239
|
+
})
|
|
1240
|
+
),
|
|
1241
|
+
transferSolWithSeed: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1242
|
+
client,
|
|
1243
|
+
getTransferSolWithSeedInstruction(input, {
|
|
1244
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1245
|
+
})
|
|
1246
|
+
),
|
|
1247
|
+
upgradeNonceAccount: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1248
|
+
client,
|
|
1249
|
+
getUpgradeNonceAccountInstruction(input, {
|
|
1250
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1251
|
+
})
|
|
1252
|
+
),
|
|
1253
|
+
createAccountAllowPrefund: (input, instructionConfig) => addSelfPlanAndSendFunctions(
|
|
1254
|
+
client,
|
|
1255
|
+
getCreateAccountAllowPrefundInstruction(input, {
|
|
1256
|
+
programAddress: instructionConfig?.programAddress ?? config.programAddress
|
|
1257
|
+
})
|
|
1258
|
+
)
|
|
1171
1259
|
},
|
|
1172
1260
|
identifyInstruction: identifySystemInstruction,
|
|
1173
1261
|
parseInstruction: parseSystemInstruction
|
|
@@ -1206,8 +1294,10 @@ function getSystemErrorMessage(code) {
|
|
|
1206
1294
|
}
|
|
1207
1295
|
return "Error message not available in production bundles.";
|
|
1208
1296
|
}
|
|
1209
|
-
function isSystemError(error, transactionMessage, code) {
|
|
1210
|
-
|
|
1297
|
+
function isSystemError(error, transactionMessage, code, config = {}) {
|
|
1298
|
+
const programAddressInput = config.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
1299
|
+
const programAddress = typeof programAddressInput === "string" ? programAddressInput : programAddressInput.address;
|
|
1300
|
+
return isProgramError(error, transactionMessage, programAddress, code);
|
|
1211
1301
|
}
|
|
1212
1302
|
|
|
1213
1303
|
export { ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR, ALLOCATE_DISCRIMINATOR, ALLOCATE_WITH_SEED_DISCRIMINATOR, ASSIGN_DISCRIMINATOR, ASSIGN_WITH_SEED_DISCRIMINATOR, AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR, CREATE_ACCOUNT_ALLOW_PREFUND_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, getCreateAccountAllowPrefundDiscriminatorBytes, getCreateAccountAllowPrefundInstruction, getCreateAccountAllowPrefundInstructionDataCodec, getCreateAccountAllowPrefundInstructionDataDecoder, getCreateAccountAllowPrefundInstructionDataEncoder, 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, parseCreateAccountAllowPrefundInstruction, parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, parseSystemInstruction, parseTransferSolInstruction, parseTransferSolWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction, systemProgram };
|