@solana-program/system 0.12.0 → 0.12.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.
Files changed (59) hide show
  1. package/README.md +7 -9
  2. package/dist/src/index.js +4 -5
  3. package/dist/src/index.js.map +1 -1
  4. package/dist/src/index.mjs +5 -6
  5. package/dist/src/index.mjs.map +1 -1
  6. package/dist/types/generated/instructions/advanceNonceAccount.d.ts +1 -1
  7. package/dist/types/generated/instructions/advanceNonceAccount.d.ts.map +1 -1
  8. package/dist/types/generated/instructions/allocate.d.ts +1 -1
  9. package/dist/types/generated/instructions/allocate.d.ts.map +1 -1
  10. package/dist/types/generated/instructions/allocateWithSeed.d.ts +1 -1
  11. package/dist/types/generated/instructions/allocateWithSeed.d.ts.map +1 -1
  12. package/dist/types/generated/instructions/assign.d.ts +1 -1
  13. package/dist/types/generated/instructions/assign.d.ts.map +1 -1
  14. package/dist/types/generated/instructions/assignWithSeed.d.ts +1 -1
  15. package/dist/types/generated/instructions/assignWithSeed.d.ts.map +1 -1
  16. package/dist/types/generated/instructions/authorizeNonceAccount.d.ts +1 -1
  17. package/dist/types/generated/instructions/authorizeNonceAccount.d.ts.map +1 -1
  18. package/dist/types/generated/instructions/createAccount.d.ts +1 -1
  19. package/dist/types/generated/instructions/createAccount.d.ts.map +1 -1
  20. package/dist/types/generated/instructions/createAccountWithSeed.d.ts +1 -1
  21. package/dist/types/generated/instructions/createAccountWithSeed.d.ts.map +1 -1
  22. package/dist/types/generated/instructions/initializeNonceAccount.d.ts +1 -1
  23. package/dist/types/generated/instructions/initializeNonceAccount.d.ts.map +1 -1
  24. package/dist/types/generated/instructions/transferSol.d.ts +1 -1
  25. package/dist/types/generated/instructions/transferSol.d.ts.map +1 -1
  26. package/dist/types/generated/instructions/transferSolWithSeed.d.ts +1 -1
  27. package/dist/types/generated/instructions/transferSolWithSeed.d.ts.map +1 -1
  28. package/dist/types/generated/instructions/upgradeNonceAccount.d.ts +1 -1
  29. package/dist/types/generated/instructions/upgradeNonceAccount.d.ts.map +1 -1
  30. package/dist/types/generated/instructions/withdrawNonceAccount.d.ts +1 -1
  31. package/dist/types/generated/instructions/withdrawNonceAccount.d.ts.map +1 -1
  32. package/dist/types/generated/programs/system.d.ts +1 -1
  33. package/dist/types/generated/programs/system.d.ts.map +1 -1
  34. package/package.json +31 -28
  35. package/src/generated/accounts/index.ts +9 -0
  36. package/src/generated/accounts/nonce.ts +139 -0
  37. package/src/generated/errors/index.ts +9 -0
  38. package/src/generated/errors/system.ts +77 -0
  39. package/src/generated/index.ts +13 -0
  40. package/src/generated/instructions/advanceNonceAccount.ts +186 -0
  41. package/src/generated/instructions/allocate.ts +148 -0
  42. package/src/generated/instructions/allocateWithSeed.ts +189 -0
  43. package/src/generated/instructions/assign.ts +145 -0
  44. package/src/generated/instructions/assignWithSeed.ts +177 -0
  45. package/src/generated/instructions/authorizeNonceAccount.ts +169 -0
  46. package/src/generated/instructions/createAccount.ts +184 -0
  47. package/src/generated/instructions/createAccountWithSeed.ts +221 -0
  48. package/src/generated/instructions/index.ts +21 -0
  49. package/src/generated/instructions/initializeNonceAccount.ts +202 -0
  50. package/src/generated/instructions/transferSol.ts +157 -0
  51. package/src/generated/instructions/transferSolWithSeed.ts +191 -0
  52. package/src/generated/instructions/upgradeNonceAccount.ts +135 -0
  53. package/src/generated/instructions/withdrawNonceAccount.ts +235 -0
  54. package/src/generated/programs/index.ts +9 -0
  55. package/src/generated/programs/system.ts +355 -0
  56. package/src/generated/types/index.ts +10 -0
  57. package/src/generated/types/nonceState.ts +37 -0
  58. package/src/generated/types/nonceVersion.ts +37 -0
  59. package/src/index.ts +1 -0
@@ -0,0 +1,189 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ addDecoderSizePrefix,
11
+ addEncoderSizePrefix,
12
+ combineCodec,
13
+ getAddressDecoder,
14
+ getAddressEncoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ getU32Decoder,
18
+ getU32Encoder,
19
+ getU64Decoder,
20
+ getU64Encoder,
21
+ getUtf8Decoder,
22
+ getUtf8Encoder,
23
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
24
+ SolanaError,
25
+ transformEncoder,
26
+ type AccountMeta,
27
+ type AccountSignerMeta,
28
+ type Address,
29
+ type Codec,
30
+ type Decoder,
31
+ type Encoder,
32
+ type Instruction,
33
+ type InstructionWithAccounts,
34
+ type InstructionWithData,
35
+ type ReadonlySignerAccount,
36
+ type ReadonlyUint8Array,
37
+ type TransactionSigner,
38
+ type WritableAccount,
39
+ } from '@solana/kit';
40
+ import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
41
+ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
42
+
43
+ export const ALLOCATE_WITH_SEED_DISCRIMINATOR = 9;
44
+
45
+ export function getAllocateWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
46
+ return getU32Encoder().encode(ALLOCATE_WITH_SEED_DISCRIMINATOR);
47
+ }
48
+
49
+ export type AllocateWithSeedInstruction<
50
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
51
+ TAccountNewAccount extends string | AccountMeta<string> = string,
52
+ TAccountBaseAccount extends string | AccountMeta<string> = string,
53
+ TRemainingAccounts extends readonly AccountMeta<string>[] = [],
54
+ > = Instruction<TProgram> &
55
+ InstructionWithData<ReadonlyUint8Array> &
56
+ InstructionWithAccounts<
57
+ [
58
+ TAccountNewAccount extends string ? WritableAccount<TAccountNewAccount> : TAccountNewAccount,
59
+ TAccountBaseAccount extends string
60
+ ? ReadonlySignerAccount<TAccountBaseAccount> & AccountSignerMeta<TAccountBaseAccount>
61
+ : TAccountBaseAccount,
62
+ ...TRemainingAccounts,
63
+ ]
64
+ >;
65
+
66
+ export type AllocateWithSeedInstructionData = {
67
+ discriminator: number;
68
+ base: Address;
69
+ seed: string;
70
+ space: bigint;
71
+ programAddress: Address;
72
+ };
73
+
74
+ export type AllocateWithSeedInstructionDataArgs = {
75
+ base: Address;
76
+ seed: string;
77
+ space: number | bigint;
78
+ programAddress: Address;
79
+ };
80
+
81
+ export function getAllocateWithSeedInstructionDataEncoder(): Encoder<AllocateWithSeedInstructionDataArgs> {
82
+ return transformEncoder(
83
+ getStructEncoder([
84
+ ['discriminator', getU32Encoder()],
85
+ ['base', getAddressEncoder()],
86
+ ['seed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
87
+ ['space', getU64Encoder()],
88
+ ['programAddress', getAddressEncoder()],
89
+ ]),
90
+ value => ({ ...value, discriminator: ALLOCATE_WITH_SEED_DISCRIMINATOR }),
91
+ );
92
+ }
93
+
94
+ export function getAllocateWithSeedInstructionDataDecoder(): Decoder<AllocateWithSeedInstructionData> {
95
+ return getStructDecoder([
96
+ ['discriminator', getU32Decoder()],
97
+ ['base', getAddressDecoder()],
98
+ ['seed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
99
+ ['space', getU64Decoder()],
100
+ ['programAddress', getAddressDecoder()],
101
+ ]);
102
+ }
103
+
104
+ export function getAllocateWithSeedInstructionDataCodec(): Codec<
105
+ AllocateWithSeedInstructionDataArgs,
106
+ AllocateWithSeedInstructionData
107
+ > {
108
+ return combineCodec(getAllocateWithSeedInstructionDataEncoder(), getAllocateWithSeedInstructionDataDecoder());
109
+ }
110
+
111
+ export type AllocateWithSeedInput<
112
+ TAccountNewAccount extends string = string,
113
+ TAccountBaseAccount extends string = string,
114
+ > = {
115
+ newAccount: Address<TAccountNewAccount>;
116
+ baseAccount: TransactionSigner<TAccountBaseAccount>;
117
+ base: AllocateWithSeedInstructionDataArgs['base'];
118
+ seed: AllocateWithSeedInstructionDataArgs['seed'];
119
+ space: AllocateWithSeedInstructionDataArgs['space'];
120
+ programAddress: AllocateWithSeedInstructionDataArgs['programAddress'];
121
+ };
122
+
123
+ export function getAllocateWithSeedInstruction<
124
+ TAccountNewAccount extends string,
125
+ TAccountBaseAccount extends string,
126
+ TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
127
+ >(
128
+ input: AllocateWithSeedInput<TAccountNewAccount, TAccountBaseAccount>,
129
+ config?: { programAddress?: TProgramAddress },
130
+ ): AllocateWithSeedInstruction<TProgramAddress, TAccountNewAccount, TAccountBaseAccount> {
131
+ // Program address.
132
+ const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
133
+
134
+ // Original accounts.
135
+ const originalAccounts = {
136
+ newAccount: { value: input.newAccount ?? null, isWritable: true },
137
+ baseAccount: { value: input.baseAccount ?? null, isWritable: false },
138
+ };
139
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
140
+
141
+ // Original args.
142
+ const args = { ...input };
143
+
144
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
145
+ return Object.freeze({
146
+ accounts: [
147
+ getAccountMeta('newAccount', accounts.newAccount),
148
+ getAccountMeta('baseAccount', accounts.baseAccount),
149
+ ],
150
+ data: getAllocateWithSeedInstructionDataEncoder().encode(args as AllocateWithSeedInstructionDataArgs),
151
+ programAddress,
152
+ } as AllocateWithSeedInstruction<TProgramAddress, TAccountNewAccount, TAccountBaseAccount>);
153
+ }
154
+
155
+ export type ParsedAllocateWithSeedInstruction<
156
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
157
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
158
+ > = {
159
+ programAddress: Address<TProgram>;
160
+ accounts: {
161
+ newAccount: TAccountMetas[0];
162
+ baseAccount: TAccountMetas[1];
163
+ };
164
+ data: AllocateWithSeedInstructionData;
165
+ };
166
+
167
+ export function parseAllocateWithSeedInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(
168
+ instruction: Instruction<TProgram> &
169
+ InstructionWithAccounts<TAccountMetas> &
170
+ InstructionWithData<ReadonlyUint8Array>,
171
+ ): ParsedAllocateWithSeedInstruction<TProgram, TAccountMetas> {
172
+ if (instruction.accounts.length < 2) {
173
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
174
+ actualAccountMetas: instruction.accounts.length,
175
+ expectedAccountMetas: 2,
176
+ });
177
+ }
178
+ let accountIndex = 0;
179
+ const getNextAccount = () => {
180
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
181
+ accountIndex += 1;
182
+ return accountMeta;
183
+ };
184
+ return {
185
+ programAddress: instruction.programAddress,
186
+ accounts: { newAccount: getNextAccount(), baseAccount: getNextAccount() },
187
+ data: getAllocateWithSeedInstructionDataDecoder().decode(instruction.data),
188
+ };
189
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getAddressDecoder,
12
+ getAddressEncoder,
13
+ getStructDecoder,
14
+ getStructEncoder,
15
+ getU32Decoder,
16
+ getU32Encoder,
17
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
18
+ SolanaError,
19
+ transformEncoder,
20
+ type AccountMeta,
21
+ type AccountSignerMeta,
22
+ type Address,
23
+ type FixedSizeCodec,
24
+ type FixedSizeDecoder,
25
+ type FixedSizeEncoder,
26
+ type Instruction,
27
+ type InstructionWithAccounts,
28
+ type InstructionWithData,
29
+ type ReadonlyUint8Array,
30
+ type TransactionSigner,
31
+ type WritableSignerAccount,
32
+ } from '@solana/kit';
33
+ import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
34
+ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
35
+
36
+ export const ASSIGN_DISCRIMINATOR = 1;
37
+
38
+ export function getAssignDiscriminatorBytes(): ReadonlyUint8Array {
39
+ return getU32Encoder().encode(ASSIGN_DISCRIMINATOR);
40
+ }
41
+
42
+ export type AssignInstruction<
43
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
44
+ TAccountAccount extends string | AccountMeta<string> = string,
45
+ TRemainingAccounts extends readonly AccountMeta<string>[] = [],
46
+ > = Instruction<TProgram> &
47
+ InstructionWithData<ReadonlyUint8Array> &
48
+ InstructionWithAccounts<
49
+ [
50
+ TAccountAccount extends string
51
+ ? WritableSignerAccount<TAccountAccount> & AccountSignerMeta<TAccountAccount>
52
+ : TAccountAccount,
53
+ ...TRemainingAccounts,
54
+ ]
55
+ >;
56
+
57
+ export type AssignInstructionData = { discriminator: number; programAddress: Address };
58
+
59
+ export type AssignInstructionDataArgs = { programAddress: Address };
60
+
61
+ export function getAssignInstructionDataEncoder(): FixedSizeEncoder<AssignInstructionDataArgs> {
62
+ return transformEncoder(
63
+ getStructEncoder([
64
+ ['discriminator', getU32Encoder()],
65
+ ['programAddress', getAddressEncoder()],
66
+ ]),
67
+ value => ({ ...value, discriminator: ASSIGN_DISCRIMINATOR }),
68
+ );
69
+ }
70
+
71
+ export function getAssignInstructionDataDecoder(): FixedSizeDecoder<AssignInstructionData> {
72
+ return getStructDecoder([
73
+ ['discriminator', getU32Decoder()],
74
+ ['programAddress', getAddressDecoder()],
75
+ ]);
76
+ }
77
+
78
+ export function getAssignInstructionDataCodec(): FixedSizeCodec<AssignInstructionDataArgs, AssignInstructionData> {
79
+ return combineCodec(getAssignInstructionDataEncoder(), getAssignInstructionDataDecoder());
80
+ }
81
+
82
+ export type AssignInput<TAccountAccount extends string = string> = {
83
+ account: TransactionSigner<TAccountAccount>;
84
+ programAddress: AssignInstructionDataArgs['programAddress'];
85
+ };
86
+
87
+ export function getAssignInstruction<
88
+ TAccountAccount extends string,
89
+ TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
90
+ >(
91
+ input: AssignInput<TAccountAccount>,
92
+ config?: { programAddress?: TProgramAddress },
93
+ ): AssignInstruction<TProgramAddress, TAccountAccount> {
94
+ // Program address.
95
+ const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
96
+
97
+ // Original accounts.
98
+ const originalAccounts = { account: { value: input.account ?? null, isWritable: true } };
99
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
100
+
101
+ // Original args.
102
+ const args = { ...input };
103
+
104
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
105
+ return Object.freeze({
106
+ accounts: [getAccountMeta('account', accounts.account)],
107
+ data: getAssignInstructionDataEncoder().encode(args as AssignInstructionDataArgs),
108
+ programAddress,
109
+ } as AssignInstruction<TProgramAddress, TAccountAccount>);
110
+ }
111
+
112
+ export type ParsedAssignInstruction<
113
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
114
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
115
+ > = {
116
+ programAddress: Address<TProgram>;
117
+ accounts: {
118
+ account: TAccountMetas[0];
119
+ };
120
+ data: AssignInstructionData;
121
+ };
122
+
123
+ export function parseAssignInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(
124
+ instruction: Instruction<TProgram> &
125
+ InstructionWithAccounts<TAccountMetas> &
126
+ InstructionWithData<ReadonlyUint8Array>,
127
+ ): ParsedAssignInstruction<TProgram, TAccountMetas> {
128
+ if (instruction.accounts.length < 1) {
129
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
130
+ actualAccountMetas: instruction.accounts.length,
131
+ expectedAccountMetas: 1,
132
+ });
133
+ }
134
+ let accountIndex = 0;
135
+ const getNextAccount = () => {
136
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
137
+ accountIndex += 1;
138
+ return accountMeta;
139
+ };
140
+ return {
141
+ programAddress: instruction.programAddress,
142
+ accounts: { account: getNextAccount() },
143
+ data: getAssignInstructionDataDecoder().decode(instruction.data),
144
+ };
145
+ }
@@ -0,0 +1,177 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ addDecoderSizePrefix,
11
+ addEncoderSizePrefix,
12
+ combineCodec,
13
+ getAddressDecoder,
14
+ getAddressEncoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ getU32Decoder,
18
+ getU32Encoder,
19
+ getU64Decoder,
20
+ getU64Encoder,
21
+ getUtf8Decoder,
22
+ getUtf8Encoder,
23
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
24
+ SolanaError,
25
+ transformEncoder,
26
+ type AccountMeta,
27
+ type AccountSignerMeta,
28
+ type Address,
29
+ type Codec,
30
+ type Decoder,
31
+ type Encoder,
32
+ type Instruction,
33
+ type InstructionWithAccounts,
34
+ type InstructionWithData,
35
+ type ReadonlySignerAccount,
36
+ type ReadonlyUint8Array,
37
+ type TransactionSigner,
38
+ type WritableAccount,
39
+ } from '@solana/kit';
40
+ import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
41
+ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
42
+
43
+ export const ASSIGN_WITH_SEED_DISCRIMINATOR = 10;
44
+
45
+ export function getAssignWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
46
+ return getU32Encoder().encode(ASSIGN_WITH_SEED_DISCRIMINATOR);
47
+ }
48
+
49
+ export type AssignWithSeedInstruction<
50
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
51
+ TAccountAccount extends string | AccountMeta<string> = string,
52
+ TAccountBaseAccount extends string | AccountMeta<string> = string,
53
+ TRemainingAccounts extends readonly AccountMeta<string>[] = [],
54
+ > = Instruction<TProgram> &
55
+ InstructionWithData<ReadonlyUint8Array> &
56
+ InstructionWithAccounts<
57
+ [
58
+ TAccountAccount extends string ? WritableAccount<TAccountAccount> : TAccountAccount,
59
+ TAccountBaseAccount extends string
60
+ ? ReadonlySignerAccount<TAccountBaseAccount> & AccountSignerMeta<TAccountBaseAccount>
61
+ : TAccountBaseAccount,
62
+ ...TRemainingAccounts,
63
+ ]
64
+ >;
65
+
66
+ export type AssignWithSeedInstructionData = {
67
+ discriminator: number;
68
+ base: Address;
69
+ seed: string;
70
+ programAddress: Address;
71
+ };
72
+
73
+ export type AssignWithSeedInstructionDataArgs = { base: Address; seed: string; programAddress: Address };
74
+
75
+ export function getAssignWithSeedInstructionDataEncoder(): Encoder<AssignWithSeedInstructionDataArgs> {
76
+ return transformEncoder(
77
+ getStructEncoder([
78
+ ['discriminator', getU32Encoder()],
79
+ ['base', getAddressEncoder()],
80
+ ['seed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
81
+ ['programAddress', getAddressEncoder()],
82
+ ]),
83
+ value => ({ ...value, discriminator: ASSIGN_WITH_SEED_DISCRIMINATOR }),
84
+ );
85
+ }
86
+
87
+ export function getAssignWithSeedInstructionDataDecoder(): Decoder<AssignWithSeedInstructionData> {
88
+ return getStructDecoder([
89
+ ['discriminator', getU32Decoder()],
90
+ ['base', getAddressDecoder()],
91
+ ['seed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
92
+ ['programAddress', getAddressDecoder()],
93
+ ]);
94
+ }
95
+
96
+ export function getAssignWithSeedInstructionDataCodec(): Codec<
97
+ AssignWithSeedInstructionDataArgs,
98
+ AssignWithSeedInstructionData
99
+ > {
100
+ return combineCodec(getAssignWithSeedInstructionDataEncoder(), getAssignWithSeedInstructionDataDecoder());
101
+ }
102
+
103
+ export type AssignWithSeedInput<
104
+ TAccountAccount extends string = string,
105
+ TAccountBaseAccount extends string = string,
106
+ > = {
107
+ account: Address<TAccountAccount>;
108
+ baseAccount: TransactionSigner<TAccountBaseAccount>;
109
+ base: AssignWithSeedInstructionDataArgs['base'];
110
+ seed: AssignWithSeedInstructionDataArgs['seed'];
111
+ programAddress: AssignWithSeedInstructionDataArgs['programAddress'];
112
+ };
113
+
114
+ export function getAssignWithSeedInstruction<
115
+ TAccountAccount extends string,
116
+ TAccountBaseAccount extends string,
117
+ TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
118
+ >(
119
+ input: AssignWithSeedInput<TAccountAccount, TAccountBaseAccount>,
120
+ config?: { programAddress?: TProgramAddress },
121
+ ): AssignWithSeedInstruction<TProgramAddress, TAccountAccount, TAccountBaseAccount> {
122
+ // Program address.
123
+ const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
124
+
125
+ // Original accounts.
126
+ const originalAccounts = {
127
+ account: { value: input.account ?? null, isWritable: true },
128
+ baseAccount: { value: input.baseAccount ?? null, isWritable: false },
129
+ };
130
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
131
+
132
+ // Original args.
133
+ const args = { ...input };
134
+
135
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
136
+ return Object.freeze({
137
+ accounts: [getAccountMeta('account', accounts.account), getAccountMeta('baseAccount', accounts.baseAccount)],
138
+ data: getAssignWithSeedInstructionDataEncoder().encode(args as AssignWithSeedInstructionDataArgs),
139
+ programAddress,
140
+ } as AssignWithSeedInstruction<TProgramAddress, TAccountAccount, TAccountBaseAccount>);
141
+ }
142
+
143
+ export type ParsedAssignWithSeedInstruction<
144
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
145
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
146
+ > = {
147
+ programAddress: Address<TProgram>;
148
+ accounts: {
149
+ account: TAccountMetas[0];
150
+ baseAccount: TAccountMetas[1];
151
+ };
152
+ data: AssignWithSeedInstructionData;
153
+ };
154
+
155
+ export function parseAssignWithSeedInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(
156
+ instruction: Instruction<TProgram> &
157
+ InstructionWithAccounts<TAccountMetas> &
158
+ InstructionWithData<ReadonlyUint8Array>,
159
+ ): ParsedAssignWithSeedInstruction<TProgram, TAccountMetas> {
160
+ if (instruction.accounts.length < 2) {
161
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
162
+ actualAccountMetas: instruction.accounts.length,
163
+ expectedAccountMetas: 2,
164
+ });
165
+ }
166
+ let accountIndex = 0;
167
+ const getNextAccount = () => {
168
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
169
+ accountIndex += 1;
170
+ return accountMeta;
171
+ };
172
+ return {
173
+ programAddress: instruction.programAddress,
174
+ accounts: { account: getNextAccount(), baseAccount: getNextAccount() },
175
+ data: getAssignWithSeedInstructionDataDecoder().decode(instruction.data),
176
+ };
177
+ }
@@ -0,0 +1,169 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getAddressDecoder,
12
+ getAddressEncoder,
13
+ getStructDecoder,
14
+ getStructEncoder,
15
+ getU32Decoder,
16
+ getU32Encoder,
17
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
18
+ SolanaError,
19
+ transformEncoder,
20
+ type AccountMeta,
21
+ type AccountSignerMeta,
22
+ type Address,
23
+ type FixedSizeCodec,
24
+ type FixedSizeDecoder,
25
+ type FixedSizeEncoder,
26
+ type Instruction,
27
+ type InstructionWithAccounts,
28
+ type InstructionWithData,
29
+ type ReadonlySignerAccount,
30
+ type ReadonlyUint8Array,
31
+ type TransactionSigner,
32
+ type WritableAccount,
33
+ } from '@solana/kit';
34
+ import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
35
+ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
36
+
37
+ export const AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR = 7;
38
+
39
+ export function getAuthorizeNonceAccountDiscriminatorBytes(): ReadonlyUint8Array {
40
+ return getU32Encoder().encode(AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR);
41
+ }
42
+
43
+ export type AuthorizeNonceAccountInstruction<
44
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
45
+ TAccountNonceAccount extends string | AccountMeta<string> = string,
46
+ TAccountNonceAuthority extends string | AccountMeta<string> = string,
47
+ TRemainingAccounts extends readonly AccountMeta<string>[] = [],
48
+ > = Instruction<TProgram> &
49
+ InstructionWithData<ReadonlyUint8Array> &
50
+ InstructionWithAccounts<
51
+ [
52
+ TAccountNonceAccount extends string ? WritableAccount<TAccountNonceAccount> : TAccountNonceAccount,
53
+ TAccountNonceAuthority extends string
54
+ ? ReadonlySignerAccount<TAccountNonceAuthority> & AccountSignerMeta<TAccountNonceAuthority>
55
+ : TAccountNonceAuthority,
56
+ ...TRemainingAccounts,
57
+ ]
58
+ >;
59
+
60
+ export type AuthorizeNonceAccountInstructionData = { discriminator: number; newNonceAuthority: Address };
61
+
62
+ export type AuthorizeNonceAccountInstructionDataArgs = { newNonceAuthority: Address };
63
+
64
+ export function getAuthorizeNonceAccountInstructionDataEncoder(): FixedSizeEncoder<AuthorizeNonceAccountInstructionDataArgs> {
65
+ return transformEncoder(
66
+ getStructEncoder([
67
+ ['discriminator', getU32Encoder()],
68
+ ['newNonceAuthority', getAddressEncoder()],
69
+ ]),
70
+ value => ({ ...value, discriminator: AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR }),
71
+ );
72
+ }
73
+
74
+ export function getAuthorizeNonceAccountInstructionDataDecoder(): FixedSizeDecoder<AuthorizeNonceAccountInstructionData> {
75
+ return getStructDecoder([
76
+ ['discriminator', getU32Decoder()],
77
+ ['newNonceAuthority', getAddressDecoder()],
78
+ ]);
79
+ }
80
+
81
+ export function getAuthorizeNonceAccountInstructionDataCodec(): FixedSizeCodec<
82
+ AuthorizeNonceAccountInstructionDataArgs,
83
+ AuthorizeNonceAccountInstructionData
84
+ > {
85
+ return combineCodec(
86
+ getAuthorizeNonceAccountInstructionDataEncoder(),
87
+ getAuthorizeNonceAccountInstructionDataDecoder(),
88
+ );
89
+ }
90
+
91
+ export type AuthorizeNonceAccountInput<
92
+ TAccountNonceAccount extends string = string,
93
+ TAccountNonceAuthority extends string = string,
94
+ > = {
95
+ nonceAccount: Address<TAccountNonceAccount>;
96
+ nonceAuthority: TransactionSigner<TAccountNonceAuthority>;
97
+ newNonceAuthority: AuthorizeNonceAccountInstructionDataArgs['newNonceAuthority'];
98
+ };
99
+
100
+ export function getAuthorizeNonceAccountInstruction<
101
+ TAccountNonceAccount extends string,
102
+ TAccountNonceAuthority extends string,
103
+ TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
104
+ >(
105
+ input: AuthorizeNonceAccountInput<TAccountNonceAccount, TAccountNonceAuthority>,
106
+ config?: { programAddress?: TProgramAddress },
107
+ ): AuthorizeNonceAccountInstruction<TProgramAddress, TAccountNonceAccount, TAccountNonceAuthority> {
108
+ // Program address.
109
+ const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
110
+
111
+ // Original accounts.
112
+ const originalAccounts = {
113
+ nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
114
+ nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false },
115
+ };
116
+ const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
117
+
118
+ // Original args.
119
+ const args = { ...input };
120
+
121
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
122
+ return Object.freeze({
123
+ accounts: [
124
+ getAccountMeta('nonceAccount', accounts.nonceAccount),
125
+ getAccountMeta('nonceAuthority', accounts.nonceAuthority),
126
+ ],
127
+ data: getAuthorizeNonceAccountInstructionDataEncoder().encode(args as AuthorizeNonceAccountInstructionDataArgs),
128
+ programAddress,
129
+ } as AuthorizeNonceAccountInstruction<TProgramAddress, TAccountNonceAccount, TAccountNonceAuthority>);
130
+ }
131
+
132
+ export type ParsedAuthorizeNonceAccountInstruction<
133
+ TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
134
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
135
+ > = {
136
+ programAddress: Address<TProgram>;
137
+ accounts: {
138
+ nonceAccount: TAccountMetas[0];
139
+ nonceAuthority: TAccountMetas[1];
140
+ };
141
+ data: AuthorizeNonceAccountInstructionData;
142
+ };
143
+
144
+ export function parseAuthorizeNonceAccountInstruction<
145
+ TProgram extends string,
146
+ TAccountMetas extends readonly AccountMeta[],
147
+ >(
148
+ instruction: Instruction<TProgram> &
149
+ InstructionWithAccounts<TAccountMetas> &
150
+ InstructionWithData<ReadonlyUint8Array>,
151
+ ): ParsedAuthorizeNonceAccountInstruction<TProgram, TAccountMetas> {
152
+ if (instruction.accounts.length < 2) {
153
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
154
+ actualAccountMetas: instruction.accounts.length,
155
+ expectedAccountMetas: 2,
156
+ });
157
+ }
158
+ let accountIndex = 0;
159
+ const getNextAccount = () => {
160
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
161
+ accountIndex += 1;
162
+ return accountMeta;
163
+ };
164
+ return {
165
+ programAddress: instruction.programAddress,
166
+ accounts: { nonceAccount: getNextAccount(), nonceAuthority: getNextAccount() },
167
+ data: getAuthorizeNonceAccountInstructionDataDecoder().decode(instruction.data),
168
+ };
169
+ }