@solana-program/system 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.js +23 -20
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +23 -20
- package/dist/src/index.mjs.map +1 -1
- package/dist/types/generated/accounts/nonce.d.ts +4 -4
- package/dist/types/generated/accounts/nonce.d.ts.map +1 -1
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts +9 -9
- package/dist/types/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocate.d.ts +9 -9
- package/dist/types/generated/instructions/allocate.d.ts.map +1 -1
- package/dist/types/generated/instructions/allocateWithSeed.d.ts +6 -6
- package/dist/types/generated/instructions/allocateWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/assign.d.ts +9 -9
- package/dist/types/generated/instructions/assign.d.ts.map +1 -1
- package/dist/types/generated/instructions/assignWithSeed.d.ts +6 -6
- package/dist/types/generated/instructions/assignWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts +9 -9
- package/dist/types/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccount.d.ts +12 -12
- package/dist/types/generated/instructions/createAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts +11 -9
- package/dist/types/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts +8 -8
- package/dist/types/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSol.d.ts +9 -9
- package/dist/types/generated/instructions/transferSol.d.ts.map +1 -1
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts +6 -6
- package/dist/types/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts +8 -8
- package/dist/types/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts +9 -9
- package/dist/types/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
- package/dist/types/generated/shared/index.d.ts +3 -3
- package/dist/types/generated/shared/index.d.ts.map +1 -1
- package/dist/types/generated/types/nonceState.d.ts +4 -4
- package/dist/types/generated/types/nonceState.d.ts.map +1 -1
- package/dist/types/generated/types/nonceVersion.d.ts +4 -4
- package/dist/types/generated/types/nonceVersion.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/src/index.js
CHANGED
|
@@ -201,10 +201,7 @@ function expectAddress(value) {
|
|
|
201
201
|
function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
|
|
202
202
|
return (account) => {
|
|
203
203
|
if (!account.value) {
|
|
204
|
-
return
|
|
205
|
-
address: programAddress,
|
|
206
|
-
role: kit.AccountRole.READONLY
|
|
207
|
-
});
|
|
204
|
+
return;
|
|
208
205
|
}
|
|
209
206
|
const writableRole = account.isWritable ? kit.AccountRole.WRITABLE : kit.AccountRole.READONLY;
|
|
210
207
|
return Object.freeze({
|
|
@@ -255,7 +252,7 @@ function getAdvanceNonceAccountInstruction(input, config) {
|
|
|
255
252
|
if (!accounts.recentBlockhashesSysvar.value) {
|
|
256
253
|
accounts.recentBlockhashesSysvar.value = "SysvarRecentB1ockHashes11111111111111111111";
|
|
257
254
|
}
|
|
258
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
255
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
259
256
|
const instruction = {
|
|
260
257
|
accounts: [
|
|
261
258
|
getAccountMeta(accounts.nonceAccount),
|
|
@@ -321,7 +318,7 @@ function getAllocateInstruction(input, config) {
|
|
|
321
318
|
};
|
|
322
319
|
const accounts = originalAccounts;
|
|
323
320
|
const args = { ...input };
|
|
324
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
321
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
325
322
|
const instruction = {
|
|
326
323
|
accounts: [getAccountMeta(accounts.newAccount)],
|
|
327
324
|
programAddress,
|
|
@@ -388,7 +385,7 @@ function getAllocateWithSeedInstruction(input, config) {
|
|
|
388
385
|
};
|
|
389
386
|
const accounts = originalAccounts;
|
|
390
387
|
const args = { ...input };
|
|
391
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
388
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
392
389
|
const instruction = {
|
|
393
390
|
accounts: [
|
|
394
391
|
getAccountMeta(accounts.newAccount),
|
|
@@ -452,7 +449,7 @@ function getAssignInstruction(input, config) {
|
|
|
452
449
|
};
|
|
453
450
|
const accounts = originalAccounts;
|
|
454
451
|
const args = { ...input };
|
|
455
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
452
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
456
453
|
const instruction = {
|
|
457
454
|
accounts: [getAccountMeta(accounts.account)],
|
|
458
455
|
programAddress,
|
|
@@ -517,7 +514,7 @@ function getAssignWithSeedInstruction(input, config) {
|
|
|
517
514
|
};
|
|
518
515
|
const accounts = originalAccounts;
|
|
519
516
|
const args = { ...input };
|
|
520
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
517
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
521
518
|
const instruction = {
|
|
522
519
|
accounts: [
|
|
523
520
|
getAccountMeta(accounts.account),
|
|
@@ -585,7 +582,7 @@ function getAuthorizeNonceAccountInstruction(input, config) {
|
|
|
585
582
|
};
|
|
586
583
|
const accounts = originalAccounts;
|
|
587
584
|
const args = { ...input };
|
|
588
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
585
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
589
586
|
const instruction = {
|
|
590
587
|
accounts: [
|
|
591
588
|
getAccountMeta(accounts.nonceAccount),
|
|
@@ -660,7 +657,7 @@ function getCreateAccountInstruction(input, config) {
|
|
|
660
657
|
(a, b) => a + b,
|
|
661
658
|
0
|
|
662
659
|
);
|
|
663
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
660
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
664
661
|
const instruction = {
|
|
665
662
|
accounts: [
|
|
666
663
|
getAccountMeta(accounts.payer),
|
|
@@ -737,13 +734,13 @@ function getCreateAccountWithSeedInstruction(input, config) {
|
|
|
737
734
|
};
|
|
738
735
|
const accounts = originalAccounts;
|
|
739
736
|
const args = { ...input };
|
|
740
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
737
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
741
738
|
const instruction = {
|
|
742
739
|
accounts: [
|
|
743
740
|
getAccountMeta(accounts.payer),
|
|
744
741
|
getAccountMeta(accounts.newAccount),
|
|
745
742
|
getAccountMeta(accounts.baseAccount)
|
|
746
|
-
],
|
|
743
|
+
].filter((x) => x !== void 0),
|
|
747
744
|
programAddress,
|
|
748
745
|
data: getCreateAccountWithSeedInstructionDataEncoder().encode(
|
|
749
746
|
args
|
|
@@ -752,7 +749,7 @@ function getCreateAccountWithSeedInstruction(input, config) {
|
|
|
752
749
|
return instruction;
|
|
753
750
|
}
|
|
754
751
|
function parseCreateAccountWithSeedInstruction(instruction) {
|
|
755
|
-
if (instruction.accounts.length <
|
|
752
|
+
if (instruction.accounts.length < 2) {
|
|
756
753
|
throw new Error("Not enough accounts");
|
|
757
754
|
}
|
|
758
755
|
let accountIndex = 0;
|
|
@@ -761,12 +758,18 @@ function parseCreateAccountWithSeedInstruction(instruction) {
|
|
|
761
758
|
accountIndex += 1;
|
|
762
759
|
return accountMeta;
|
|
763
760
|
};
|
|
761
|
+
let optionalAccountsRemaining = instruction.accounts.length - 2;
|
|
762
|
+
const getNextOptionalAccount = () => {
|
|
763
|
+
if (optionalAccountsRemaining === 0) return void 0;
|
|
764
|
+
optionalAccountsRemaining -= 1;
|
|
765
|
+
return getNextAccount();
|
|
766
|
+
};
|
|
764
767
|
return {
|
|
765
768
|
programAddress: instruction.programAddress,
|
|
766
769
|
accounts: {
|
|
767
770
|
payer: getNextAccount(),
|
|
768
771
|
newAccount: getNextAccount(),
|
|
769
|
-
baseAccount:
|
|
772
|
+
baseAccount: getNextOptionalAccount()
|
|
770
773
|
},
|
|
771
774
|
data: getCreateAccountWithSeedInstructionDataDecoder().decode(
|
|
772
775
|
instruction.data
|
|
@@ -819,7 +822,7 @@ function getInitializeNonceAccountInstruction(input, config) {
|
|
|
819
822
|
if (!accounts.rentSysvar.value) {
|
|
820
823
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
821
824
|
}
|
|
822
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
825
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
823
826
|
const instruction = {
|
|
824
827
|
accounts: [
|
|
825
828
|
getAccountMeta(accounts.nonceAccount),
|
|
@@ -888,7 +891,7 @@ function getTransferSolInstruction(input, config) {
|
|
|
888
891
|
};
|
|
889
892
|
const accounts = originalAccounts;
|
|
890
893
|
const args = { ...input };
|
|
891
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
894
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
892
895
|
const instruction = {
|
|
893
896
|
accounts: [
|
|
894
897
|
getAccountMeta(accounts.source),
|
|
@@ -961,7 +964,7 @@ function getTransferSolWithSeedInstruction(input, config) {
|
|
|
961
964
|
};
|
|
962
965
|
const accounts = originalAccounts;
|
|
963
966
|
const args = { ...input };
|
|
964
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
967
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
965
968
|
const instruction = {
|
|
966
969
|
accounts: [
|
|
967
970
|
getAccountMeta(accounts.source),
|
|
@@ -1025,7 +1028,7 @@ function getUpgradeNonceAccountInstruction(input, config) {
|
|
|
1025
1028
|
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true }
|
|
1026
1029
|
};
|
|
1027
1030
|
const accounts = originalAccounts;
|
|
1028
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
1031
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
1029
1032
|
const instruction = {
|
|
1030
1033
|
accounts: [getAccountMeta(accounts.nonceAccount)],
|
|
1031
1034
|
programAddress,
|
|
@@ -1104,7 +1107,7 @@ function getWithdrawNonceAccountInstruction(input, config) {
|
|
|
1104
1107
|
if (!accounts.rentSysvar.value) {
|
|
1105
1108
|
accounts.rentSysvar.value = "SysvarRent111111111111111111111111111111111";
|
|
1106
1109
|
}
|
|
1107
|
-
const getAccountMeta = getAccountMetaFactory(
|
|
1110
|
+
const getAccountMeta = getAccountMetaFactory();
|
|
1108
1111
|
const instruction = {
|
|
1109
1112
|
accounts: [
|
|
1110
1113
|
getAccountMeta(accounts.nonceAccount),
|