@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
|
@@ -27,10 +27,16 @@ import {
|
|
|
27
27
|
type ReadonlyAccount,
|
|
28
28
|
type ReadonlySignerAccount,
|
|
29
29
|
type ReadonlyUint8Array,
|
|
30
|
-
type TransactionSigner,
|
|
31
30
|
type WritableAccount,
|
|
32
31
|
} from '@solana/kit';
|
|
33
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
getAccountMetaFactory,
|
|
34
|
+
type InstructionAccountInput,
|
|
35
|
+
type InstructionAccountInputAddress,
|
|
36
|
+
type InstructionSignerInput,
|
|
37
|
+
type ResolvedInstructionAccount,
|
|
38
|
+
type ResolvedInstructionAccountMeta,
|
|
39
|
+
} from '@solana/kit/program-client-core';
|
|
34
40
|
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
|
|
35
41
|
|
|
36
42
|
export const ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR = 4;
|
|
@@ -84,37 +90,44 @@ export function getAdvanceNonceAccountInstructionDataCodec(): FixedSizeCodec<
|
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
export type AdvanceNonceAccountInput<
|
|
87
|
-
TAccountNonceAccount extends
|
|
88
|
-
TAccountRecentBlockhashesSysvar extends
|
|
89
|
-
TAccountNonceAuthority extends
|
|
93
|
+
TAccountNonceAccount extends InstructionAccountInput = InstructionAccountInput,
|
|
94
|
+
TAccountRecentBlockhashesSysvar extends InstructionAccountInput = InstructionAccountInput,
|
|
95
|
+
TAccountNonceAuthority extends InstructionSignerInput = InstructionSignerInput,
|
|
90
96
|
> = {
|
|
91
|
-
nonceAccount:
|
|
92
|
-
recentBlockhashesSysvar?:
|
|
93
|
-
nonceAuthority:
|
|
97
|
+
nonceAccount: TAccountNonceAccount;
|
|
98
|
+
recentBlockhashesSysvar?: TAccountRecentBlockhashesSysvar;
|
|
99
|
+
nonceAuthority: TAccountNonceAuthority;
|
|
94
100
|
};
|
|
95
101
|
|
|
96
102
|
export function getAdvanceNonceAccountInstruction<
|
|
97
|
-
TAccountNonceAccount extends
|
|
98
|
-
TAccountRecentBlockhashesSysvar extends
|
|
99
|
-
TAccountNonceAuthority extends
|
|
103
|
+
TAccountNonceAccount extends InstructionAccountInput,
|
|
104
|
+
TAccountRecentBlockhashesSysvar extends InstructionAccountInput,
|
|
105
|
+
TAccountNonceAuthority extends InstructionSignerInput,
|
|
100
106
|
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
|
|
101
107
|
>(
|
|
102
108
|
input: AdvanceNonceAccountInput<TAccountNonceAccount, TAccountRecentBlockhashesSysvar, TAccountNonceAuthority>,
|
|
103
|
-
config?: { programAddress?: TProgramAddress },
|
|
109
|
+
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
|
|
104
110
|
): AdvanceNonceAccountInstruction<
|
|
105
111
|
TProgramAddress,
|
|
106
|
-
TAccountNonceAccount,
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
ResolvedInstructionAccountMeta<TAccountNonceAccount, InstructionAccountInputAddress<TAccountNonceAccount>>,
|
|
113
|
+
ResolvedInstructionAccountMeta<
|
|
114
|
+
TAccountRecentBlockhashesSysvar,
|
|
115
|
+
InstructionAccountInputAddress<TAccountRecentBlockhashesSysvar>
|
|
116
|
+
>,
|
|
117
|
+
ResolvedInstructionAccountMeta<TAccountNonceAuthority, InstructionAccountInputAddress<TAccountNonceAuthority>>
|
|
109
118
|
> {
|
|
110
119
|
// Program address.
|
|
111
|
-
const
|
|
120
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
121
|
+
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
|
|
122
|
+
|
|
123
|
+
// Account meta helper.
|
|
124
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
112
125
|
|
|
113
126
|
// Original accounts.
|
|
114
127
|
const originalAccounts = {
|
|
115
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
116
|
-
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isWritable: false },
|
|
117
|
-
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false },
|
|
128
|
+
nonceAccount: { value: input.nonceAccount ?? null, isSigner: false, isWritable: true },
|
|
129
|
+
recentBlockhashesSysvar: { value: input.recentBlockhashesSysvar ?? null, isSigner: false, isWritable: false },
|
|
130
|
+
nonceAuthority: { value: input.nonceAuthority ?? null, isSigner: true, isWritable: false },
|
|
118
131
|
};
|
|
119
132
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
120
133
|
|
|
@@ -124,7 +137,6 @@ export function getAdvanceNonceAccountInstruction<
|
|
|
124
137
|
'SysvarRecentB1ockHashes11111111111111111111' as Address<'SysvarRecentB1ockHashes11111111111111111111'>;
|
|
125
138
|
}
|
|
126
139
|
|
|
127
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
128
140
|
return Object.freeze({
|
|
129
141
|
accounts: [
|
|
130
142
|
getAccountMeta('nonceAccount', accounts.nonceAccount),
|
|
@@ -135,9 +147,12 @@ export function getAdvanceNonceAccountInstruction<
|
|
|
135
147
|
programAddress,
|
|
136
148
|
} as AdvanceNonceAccountInstruction<
|
|
137
149
|
TProgramAddress,
|
|
138
|
-
TAccountNonceAccount,
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
ResolvedInstructionAccountMeta<TAccountNonceAccount, InstructionAccountInputAddress<TAccountNonceAccount>>,
|
|
151
|
+
ResolvedInstructionAccountMeta<
|
|
152
|
+
TAccountRecentBlockhashesSysvar,
|
|
153
|
+
InstructionAccountInputAddress<TAccountRecentBlockhashesSysvar>
|
|
154
|
+
>,
|
|
155
|
+
ResolvedInstructionAccountMeta<TAccountNonceAuthority, InstructionAccountInputAddress<TAccountNonceAuthority>>
|
|
141
156
|
>);
|
|
142
157
|
}
|
|
143
158
|
|
|
@@ -27,10 +27,15 @@ import {
|
|
|
27
27
|
type InstructionWithAccounts,
|
|
28
28
|
type InstructionWithData,
|
|
29
29
|
type ReadonlyUint8Array,
|
|
30
|
-
type TransactionSigner,
|
|
31
30
|
type WritableSignerAccount,
|
|
32
31
|
} from '@solana/kit';
|
|
33
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
getAccountMetaFactory,
|
|
34
|
+
type InstructionAccountInputAddress,
|
|
35
|
+
type InstructionSignerInput,
|
|
36
|
+
type ResolvedInstructionAccount,
|
|
37
|
+
type ResolvedInstructionAccountMeta,
|
|
38
|
+
} from '@solana/kit/program-client-core';
|
|
34
39
|
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
|
|
35
40
|
|
|
36
41
|
export const ALLOCATE_DISCRIMINATOR = 8;
|
|
@@ -82,34 +87,43 @@ export function getAllocateInstructionDataCodec(): FixedSizeCodec<
|
|
|
82
87
|
return combineCodec(getAllocateInstructionDataEncoder(), getAllocateInstructionDataDecoder());
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
export type AllocateInput<TAccountNewAccount extends
|
|
86
|
-
newAccount:
|
|
90
|
+
export type AllocateInput<TAccountNewAccount extends InstructionSignerInput = InstructionSignerInput> = {
|
|
91
|
+
newAccount: TAccountNewAccount;
|
|
87
92
|
space: AllocateInstructionDataArgs['space'];
|
|
88
93
|
};
|
|
89
94
|
|
|
90
95
|
export function getAllocateInstruction<
|
|
91
|
-
TAccountNewAccount extends
|
|
96
|
+
TAccountNewAccount extends InstructionSignerInput,
|
|
92
97
|
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
|
|
93
98
|
>(
|
|
94
99
|
input: AllocateInput<TAccountNewAccount>,
|
|
95
|
-
config?: { programAddress?: TProgramAddress },
|
|
96
|
-
): AllocateInstruction<
|
|
100
|
+
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
|
|
101
|
+
): AllocateInstruction<
|
|
102
|
+
TProgramAddress,
|
|
103
|
+
ResolvedInstructionAccountMeta<TAccountNewAccount, InstructionAccountInputAddress<TAccountNewAccount>>
|
|
104
|
+
> {
|
|
97
105
|
// Program address.
|
|
98
|
-
const
|
|
106
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
107
|
+
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
|
|
108
|
+
|
|
109
|
+
// Account meta helper.
|
|
110
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
99
111
|
|
|
100
112
|
// Original accounts.
|
|
101
|
-
const originalAccounts = { newAccount: { value: input.newAccount ?? null, isWritable: true } };
|
|
113
|
+
const originalAccounts = { newAccount: { value: input.newAccount ?? null, isSigner: true, isWritable: true } };
|
|
102
114
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
103
115
|
|
|
104
116
|
// Original args.
|
|
105
117
|
const args = { ...input };
|
|
106
118
|
|
|
107
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
108
119
|
return Object.freeze({
|
|
109
120
|
accounts: [getAccountMeta('newAccount', accounts.newAccount)],
|
|
110
121
|
data: getAllocateInstructionDataEncoder().encode(args as AllocateInstructionDataArgs),
|
|
111
122
|
programAddress,
|
|
112
|
-
} as AllocateInstruction<
|
|
123
|
+
} as AllocateInstruction<
|
|
124
|
+
TProgramAddress,
|
|
125
|
+
ResolvedInstructionAccountMeta<TAccountNewAccount, InstructionAccountInputAddress<TAccountNewAccount>>
|
|
126
|
+
>);
|
|
113
127
|
}
|
|
114
128
|
|
|
115
129
|
export type ParsedAllocateInstruction<
|
|
@@ -29,15 +29,22 @@ import {
|
|
|
29
29
|
type Codec,
|
|
30
30
|
type Decoder,
|
|
31
31
|
type Encoder,
|
|
32
|
+
type HasAddress,
|
|
32
33
|
type Instruction,
|
|
33
34
|
type InstructionWithAccounts,
|
|
34
35
|
type InstructionWithData,
|
|
35
36
|
type ReadonlySignerAccount,
|
|
36
37
|
type ReadonlyUint8Array,
|
|
37
|
-
type TransactionSigner,
|
|
38
38
|
type WritableAccount,
|
|
39
39
|
} from '@solana/kit';
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
getAccountMetaFactory,
|
|
42
|
+
type InstructionAccountInput,
|
|
43
|
+
type InstructionAccountInputAddress,
|
|
44
|
+
type InstructionSignerInput,
|
|
45
|
+
type ResolvedInstructionAccount,
|
|
46
|
+
type ResolvedInstructionAccountMeta,
|
|
47
|
+
} from '@solana/kit/program-client-core';
|
|
41
48
|
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
|
|
42
49
|
|
|
43
50
|
export const ALLOCATE_WITH_SEED_DISCRIMINATOR = 9;
|
|
@@ -72,10 +79,10 @@ export type AllocateWithSeedInstructionData = {
|
|
|
72
79
|
};
|
|
73
80
|
|
|
74
81
|
export type AllocateWithSeedInstructionDataArgs = {
|
|
75
|
-
base: Address;
|
|
82
|
+
base: Address | HasAddress;
|
|
76
83
|
seed: string;
|
|
77
84
|
space: number | bigint;
|
|
78
|
-
programAddress: Address;
|
|
85
|
+
programAddress: Address | HasAddress;
|
|
79
86
|
};
|
|
80
87
|
|
|
81
88
|
export function getAllocateWithSeedInstructionDataEncoder(): Encoder<AllocateWithSeedInstructionDataArgs> {
|
|
@@ -109,11 +116,11 @@ export function getAllocateWithSeedInstructionDataCodec(): Codec<
|
|
|
109
116
|
}
|
|
110
117
|
|
|
111
118
|
export type AllocateWithSeedInput<
|
|
112
|
-
TAccountNewAccount extends
|
|
113
|
-
TAccountBaseAccount extends
|
|
119
|
+
TAccountNewAccount extends InstructionAccountInput = InstructionAccountInput,
|
|
120
|
+
TAccountBaseAccount extends InstructionSignerInput = InstructionSignerInput,
|
|
114
121
|
> = {
|
|
115
|
-
newAccount:
|
|
116
|
-
baseAccount:
|
|
122
|
+
newAccount: TAccountNewAccount;
|
|
123
|
+
baseAccount: TAccountBaseAccount;
|
|
117
124
|
base: AllocateWithSeedInstructionDataArgs['base'];
|
|
118
125
|
seed: AllocateWithSeedInstructionDataArgs['seed'];
|
|
119
126
|
space: AllocateWithSeedInstructionDataArgs['space'];
|
|
@@ -121,27 +128,34 @@ export type AllocateWithSeedInput<
|
|
|
121
128
|
};
|
|
122
129
|
|
|
123
130
|
export function getAllocateWithSeedInstruction<
|
|
124
|
-
TAccountNewAccount extends
|
|
125
|
-
TAccountBaseAccount extends
|
|
131
|
+
TAccountNewAccount extends InstructionAccountInput,
|
|
132
|
+
TAccountBaseAccount extends InstructionSignerInput,
|
|
126
133
|
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
|
|
127
134
|
>(
|
|
128
135
|
input: AllocateWithSeedInput<TAccountNewAccount, TAccountBaseAccount>,
|
|
129
|
-
config?: { programAddress?: TProgramAddress },
|
|
130
|
-
): AllocateWithSeedInstruction<
|
|
136
|
+
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
|
|
137
|
+
): AllocateWithSeedInstruction<
|
|
138
|
+
TProgramAddress,
|
|
139
|
+
ResolvedInstructionAccountMeta<TAccountNewAccount, InstructionAccountInputAddress<TAccountNewAccount>>,
|
|
140
|
+
ResolvedInstructionAccountMeta<TAccountBaseAccount, InstructionAccountInputAddress<TAccountBaseAccount>>
|
|
141
|
+
> {
|
|
131
142
|
// Program address.
|
|
132
|
-
const
|
|
143
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
144
|
+
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
|
|
145
|
+
|
|
146
|
+
// Account meta helper.
|
|
147
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
133
148
|
|
|
134
149
|
// Original accounts.
|
|
135
150
|
const originalAccounts = {
|
|
136
|
-
newAccount: { value: input.newAccount ?? null, isWritable: true },
|
|
137
|
-
baseAccount: { value: input.baseAccount ?? null, isWritable: false },
|
|
151
|
+
newAccount: { value: input.newAccount ?? null, isSigner: false, isWritable: true },
|
|
152
|
+
baseAccount: { value: input.baseAccount ?? null, isSigner: true, isWritable: false },
|
|
138
153
|
};
|
|
139
154
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
140
155
|
|
|
141
156
|
// Original args.
|
|
142
157
|
const args = { ...input };
|
|
143
158
|
|
|
144
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
145
159
|
return Object.freeze({
|
|
146
160
|
accounts: [
|
|
147
161
|
getAccountMeta('newAccount', accounts.newAccount),
|
|
@@ -149,7 +163,11 @@ export function getAllocateWithSeedInstruction<
|
|
|
149
163
|
],
|
|
150
164
|
data: getAllocateWithSeedInstructionDataEncoder().encode(args as AllocateWithSeedInstructionDataArgs),
|
|
151
165
|
programAddress,
|
|
152
|
-
} as AllocateWithSeedInstruction<
|
|
166
|
+
} as AllocateWithSeedInstruction<
|
|
167
|
+
TProgramAddress,
|
|
168
|
+
ResolvedInstructionAccountMeta<TAccountNewAccount, InstructionAccountInputAddress<TAccountNewAccount>>,
|
|
169
|
+
ResolvedInstructionAccountMeta<TAccountBaseAccount, InstructionAccountInputAddress<TAccountBaseAccount>>
|
|
170
|
+
>);
|
|
153
171
|
}
|
|
154
172
|
|
|
155
173
|
export type ParsedAllocateWithSeedInstruction<
|
|
@@ -23,14 +23,20 @@ import {
|
|
|
23
23
|
type FixedSizeCodec,
|
|
24
24
|
type FixedSizeDecoder,
|
|
25
25
|
type FixedSizeEncoder,
|
|
26
|
+
type HasAddress,
|
|
26
27
|
type Instruction,
|
|
27
28
|
type InstructionWithAccounts,
|
|
28
29
|
type InstructionWithData,
|
|
29
30
|
type ReadonlyUint8Array,
|
|
30
|
-
type TransactionSigner,
|
|
31
31
|
type WritableSignerAccount,
|
|
32
32
|
} from '@solana/kit';
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
getAccountMetaFactory,
|
|
35
|
+
type InstructionAccountInputAddress,
|
|
36
|
+
type InstructionSignerInput,
|
|
37
|
+
type ResolvedInstructionAccount,
|
|
38
|
+
type ResolvedInstructionAccountMeta,
|
|
39
|
+
} from '@solana/kit/program-client-core';
|
|
34
40
|
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
|
|
35
41
|
|
|
36
42
|
export const ASSIGN_DISCRIMINATOR = 1;
|
|
@@ -56,7 +62,7 @@ export type AssignInstruction<
|
|
|
56
62
|
|
|
57
63
|
export type AssignInstructionData = { discriminator: number; programAddress: Address };
|
|
58
64
|
|
|
59
|
-
export type AssignInstructionDataArgs = { programAddress: Address };
|
|
65
|
+
export type AssignInstructionDataArgs = { programAddress: Address | HasAddress };
|
|
60
66
|
|
|
61
67
|
export function getAssignInstructionDataEncoder(): FixedSizeEncoder<AssignInstructionDataArgs> {
|
|
62
68
|
return transformEncoder(
|
|
@@ -79,34 +85,43 @@ export function getAssignInstructionDataCodec(): FixedSizeCodec<AssignInstructio
|
|
|
79
85
|
return combineCodec(getAssignInstructionDataEncoder(), getAssignInstructionDataDecoder());
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
export type AssignInput<TAccountAccount extends
|
|
83
|
-
account:
|
|
88
|
+
export type AssignInput<TAccountAccount extends InstructionSignerInput = InstructionSignerInput> = {
|
|
89
|
+
account: TAccountAccount;
|
|
84
90
|
programAddress: AssignInstructionDataArgs['programAddress'];
|
|
85
91
|
};
|
|
86
92
|
|
|
87
93
|
export function getAssignInstruction<
|
|
88
|
-
TAccountAccount extends
|
|
94
|
+
TAccountAccount extends InstructionSignerInput,
|
|
89
95
|
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
|
|
90
96
|
>(
|
|
91
97
|
input: AssignInput<TAccountAccount>,
|
|
92
|
-
config?: { programAddress?: TProgramAddress },
|
|
93
|
-
): AssignInstruction<
|
|
98
|
+
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
|
|
99
|
+
): AssignInstruction<
|
|
100
|
+
TProgramAddress,
|
|
101
|
+
ResolvedInstructionAccountMeta<TAccountAccount, InstructionAccountInputAddress<TAccountAccount>>
|
|
102
|
+
> {
|
|
94
103
|
// Program address.
|
|
95
|
-
const
|
|
104
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
105
|
+
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
|
|
106
|
+
|
|
107
|
+
// Account meta helper.
|
|
108
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
96
109
|
|
|
97
110
|
// Original accounts.
|
|
98
|
-
const originalAccounts = { account: { value: input.account ?? null, isWritable: true } };
|
|
111
|
+
const originalAccounts = { account: { value: input.account ?? null, isSigner: true, isWritable: true } };
|
|
99
112
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
100
113
|
|
|
101
114
|
// Original args.
|
|
102
115
|
const args = { ...input };
|
|
103
116
|
|
|
104
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
105
117
|
return Object.freeze({
|
|
106
118
|
accounts: [getAccountMeta('account', accounts.account)],
|
|
107
119
|
data: getAssignInstructionDataEncoder().encode(args as AssignInstructionDataArgs),
|
|
108
120
|
programAddress,
|
|
109
|
-
} as AssignInstruction<
|
|
121
|
+
} as AssignInstruction<
|
|
122
|
+
TProgramAddress,
|
|
123
|
+
ResolvedInstructionAccountMeta<TAccountAccount, InstructionAccountInputAddress<TAccountAccount>>
|
|
124
|
+
>);
|
|
110
125
|
}
|
|
111
126
|
|
|
112
127
|
export type ParsedAssignInstruction<
|
|
@@ -29,15 +29,22 @@ import {
|
|
|
29
29
|
type Codec,
|
|
30
30
|
type Decoder,
|
|
31
31
|
type Encoder,
|
|
32
|
+
type HasAddress,
|
|
32
33
|
type Instruction,
|
|
33
34
|
type InstructionWithAccounts,
|
|
34
35
|
type InstructionWithData,
|
|
35
36
|
type ReadonlySignerAccount,
|
|
36
37
|
type ReadonlyUint8Array,
|
|
37
|
-
type TransactionSigner,
|
|
38
38
|
type WritableAccount,
|
|
39
39
|
} from '@solana/kit';
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
getAccountMetaFactory,
|
|
42
|
+
type InstructionAccountInput,
|
|
43
|
+
type InstructionAccountInputAddress,
|
|
44
|
+
type InstructionSignerInput,
|
|
45
|
+
type ResolvedInstructionAccount,
|
|
46
|
+
type ResolvedInstructionAccountMeta,
|
|
47
|
+
} from '@solana/kit/program-client-core';
|
|
41
48
|
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
|
|
42
49
|
|
|
43
50
|
export const ASSIGN_WITH_SEED_DISCRIMINATOR = 10;
|
|
@@ -70,7 +77,11 @@ export type AssignWithSeedInstructionData = {
|
|
|
70
77
|
programAddress: Address;
|
|
71
78
|
};
|
|
72
79
|
|
|
73
|
-
export type AssignWithSeedInstructionDataArgs = {
|
|
80
|
+
export type AssignWithSeedInstructionDataArgs = {
|
|
81
|
+
base: Address | HasAddress;
|
|
82
|
+
seed: string;
|
|
83
|
+
programAddress: Address | HasAddress;
|
|
84
|
+
};
|
|
74
85
|
|
|
75
86
|
export function getAssignWithSeedInstructionDataEncoder(): Encoder<AssignWithSeedInstructionDataArgs> {
|
|
76
87
|
return transformEncoder(
|
|
@@ -101,43 +112,54 @@ export function getAssignWithSeedInstructionDataCodec(): Codec<
|
|
|
101
112
|
}
|
|
102
113
|
|
|
103
114
|
export type AssignWithSeedInput<
|
|
104
|
-
TAccountAccount extends
|
|
105
|
-
TAccountBaseAccount extends
|
|
115
|
+
TAccountAccount extends InstructionAccountInput = InstructionAccountInput,
|
|
116
|
+
TAccountBaseAccount extends InstructionSignerInput = InstructionSignerInput,
|
|
106
117
|
> = {
|
|
107
|
-
account:
|
|
108
|
-
baseAccount:
|
|
118
|
+
account: TAccountAccount;
|
|
119
|
+
baseAccount: TAccountBaseAccount;
|
|
109
120
|
base: AssignWithSeedInstructionDataArgs['base'];
|
|
110
121
|
seed: AssignWithSeedInstructionDataArgs['seed'];
|
|
111
122
|
programAddress: AssignWithSeedInstructionDataArgs['programAddress'];
|
|
112
123
|
};
|
|
113
124
|
|
|
114
125
|
export function getAssignWithSeedInstruction<
|
|
115
|
-
TAccountAccount extends
|
|
116
|
-
TAccountBaseAccount extends
|
|
126
|
+
TAccountAccount extends InstructionAccountInput,
|
|
127
|
+
TAccountBaseAccount extends InstructionSignerInput,
|
|
117
128
|
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
|
|
118
129
|
>(
|
|
119
130
|
input: AssignWithSeedInput<TAccountAccount, TAccountBaseAccount>,
|
|
120
|
-
config?: { programAddress?: TProgramAddress },
|
|
121
|
-
): AssignWithSeedInstruction<
|
|
131
|
+
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
|
|
132
|
+
): AssignWithSeedInstruction<
|
|
133
|
+
TProgramAddress,
|
|
134
|
+
ResolvedInstructionAccountMeta<TAccountAccount, InstructionAccountInputAddress<TAccountAccount>>,
|
|
135
|
+
ResolvedInstructionAccountMeta<TAccountBaseAccount, InstructionAccountInputAddress<TAccountBaseAccount>>
|
|
136
|
+
> {
|
|
122
137
|
// Program address.
|
|
123
|
-
const
|
|
138
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
139
|
+
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
|
|
140
|
+
|
|
141
|
+
// Account meta helper.
|
|
142
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
124
143
|
|
|
125
144
|
// Original accounts.
|
|
126
145
|
const originalAccounts = {
|
|
127
|
-
account: { value: input.account ?? null, isWritable: true },
|
|
128
|
-
baseAccount: { value: input.baseAccount ?? null, isWritable: false },
|
|
146
|
+
account: { value: input.account ?? null, isSigner: false, isWritable: true },
|
|
147
|
+
baseAccount: { value: input.baseAccount ?? null, isSigner: true, isWritable: false },
|
|
129
148
|
};
|
|
130
149
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
131
150
|
|
|
132
151
|
// Original args.
|
|
133
152
|
const args = { ...input };
|
|
134
153
|
|
|
135
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
136
154
|
return Object.freeze({
|
|
137
155
|
accounts: [getAccountMeta('account', accounts.account), getAccountMeta('baseAccount', accounts.baseAccount)],
|
|
138
156
|
data: getAssignWithSeedInstructionDataEncoder().encode(args as AssignWithSeedInstructionDataArgs),
|
|
139
157
|
programAddress,
|
|
140
|
-
} as AssignWithSeedInstruction<
|
|
158
|
+
} as AssignWithSeedInstruction<
|
|
159
|
+
TProgramAddress,
|
|
160
|
+
ResolvedInstructionAccountMeta<TAccountAccount, InstructionAccountInputAddress<TAccountAccount>>,
|
|
161
|
+
ResolvedInstructionAccountMeta<TAccountBaseAccount, InstructionAccountInputAddress<TAccountBaseAccount>>
|
|
162
|
+
>);
|
|
141
163
|
}
|
|
142
164
|
|
|
143
165
|
export type ParsedAssignWithSeedInstruction<
|
|
@@ -23,15 +23,22 @@ import {
|
|
|
23
23
|
type FixedSizeCodec,
|
|
24
24
|
type FixedSizeDecoder,
|
|
25
25
|
type FixedSizeEncoder,
|
|
26
|
+
type HasAddress,
|
|
26
27
|
type Instruction,
|
|
27
28
|
type InstructionWithAccounts,
|
|
28
29
|
type InstructionWithData,
|
|
29
30
|
type ReadonlySignerAccount,
|
|
30
31
|
type ReadonlyUint8Array,
|
|
31
|
-
type TransactionSigner,
|
|
32
32
|
type WritableAccount,
|
|
33
33
|
} from '@solana/kit';
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
getAccountMetaFactory,
|
|
36
|
+
type InstructionAccountInput,
|
|
37
|
+
type InstructionAccountInputAddress,
|
|
38
|
+
type InstructionSignerInput,
|
|
39
|
+
type ResolvedInstructionAccount,
|
|
40
|
+
type ResolvedInstructionAccountMeta,
|
|
41
|
+
} from '@solana/kit/program-client-core';
|
|
35
42
|
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
|
|
36
43
|
|
|
37
44
|
export const AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR = 7;
|
|
@@ -59,7 +66,7 @@ export type AuthorizeNonceAccountInstruction<
|
|
|
59
66
|
|
|
60
67
|
export type AuthorizeNonceAccountInstructionData = { discriminator: number; newNonceAuthority: Address };
|
|
61
68
|
|
|
62
|
-
export type AuthorizeNonceAccountInstructionDataArgs = { newNonceAuthority: Address };
|
|
69
|
+
export type AuthorizeNonceAccountInstructionDataArgs = { newNonceAuthority: Address | HasAddress };
|
|
63
70
|
|
|
64
71
|
export function getAuthorizeNonceAccountInstructionDataEncoder(): FixedSizeEncoder<AuthorizeNonceAccountInstructionDataArgs> {
|
|
65
72
|
return transformEncoder(
|
|
@@ -89,36 +96,43 @@ export function getAuthorizeNonceAccountInstructionDataCodec(): FixedSizeCodec<
|
|
|
89
96
|
}
|
|
90
97
|
|
|
91
98
|
export type AuthorizeNonceAccountInput<
|
|
92
|
-
TAccountNonceAccount extends
|
|
93
|
-
TAccountNonceAuthority extends
|
|
99
|
+
TAccountNonceAccount extends InstructionAccountInput = InstructionAccountInput,
|
|
100
|
+
TAccountNonceAuthority extends InstructionSignerInput = InstructionSignerInput,
|
|
94
101
|
> = {
|
|
95
|
-
nonceAccount:
|
|
96
|
-
nonceAuthority:
|
|
102
|
+
nonceAccount: TAccountNonceAccount;
|
|
103
|
+
nonceAuthority: TAccountNonceAuthority;
|
|
97
104
|
newNonceAuthority: AuthorizeNonceAccountInstructionDataArgs['newNonceAuthority'];
|
|
98
105
|
};
|
|
99
106
|
|
|
100
107
|
export function getAuthorizeNonceAccountInstruction<
|
|
101
|
-
TAccountNonceAccount extends
|
|
102
|
-
TAccountNonceAuthority extends
|
|
108
|
+
TAccountNonceAccount extends InstructionAccountInput,
|
|
109
|
+
TAccountNonceAuthority extends InstructionSignerInput,
|
|
103
110
|
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
|
|
104
111
|
>(
|
|
105
112
|
input: AuthorizeNonceAccountInput<TAccountNonceAccount, TAccountNonceAuthority>,
|
|
106
|
-
config?: { programAddress?: TProgramAddress },
|
|
107
|
-
): AuthorizeNonceAccountInstruction<
|
|
113
|
+
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
|
|
114
|
+
): AuthorizeNonceAccountInstruction<
|
|
115
|
+
TProgramAddress,
|
|
116
|
+
ResolvedInstructionAccountMeta<TAccountNonceAccount, InstructionAccountInputAddress<TAccountNonceAccount>>,
|
|
117
|
+
ResolvedInstructionAccountMeta<TAccountNonceAuthority, InstructionAccountInputAddress<TAccountNonceAuthority>>
|
|
118
|
+
> {
|
|
108
119
|
// Program address.
|
|
109
|
-
const
|
|
120
|
+
const programAddressInput = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;
|
|
121
|
+
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
|
|
122
|
+
|
|
123
|
+
// Account meta helper.
|
|
124
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
110
125
|
|
|
111
126
|
// Original accounts.
|
|
112
127
|
const originalAccounts = {
|
|
113
|
-
nonceAccount: { value: input.nonceAccount ?? null, isWritable: true },
|
|
114
|
-
nonceAuthority: { value: input.nonceAuthority ?? null, isWritable: false },
|
|
128
|
+
nonceAccount: { value: input.nonceAccount ?? null, isSigner: false, isWritable: true },
|
|
129
|
+
nonceAuthority: { value: input.nonceAuthority ?? null, isSigner: true, isWritable: false },
|
|
115
130
|
};
|
|
116
131
|
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
117
132
|
|
|
118
133
|
// Original args.
|
|
119
134
|
const args = { ...input };
|
|
120
135
|
|
|
121
|
-
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
|
|
122
136
|
return Object.freeze({
|
|
123
137
|
accounts: [
|
|
124
138
|
getAccountMeta('nonceAccount', accounts.nonceAccount),
|
|
@@ -126,7 +140,11 @@ export function getAuthorizeNonceAccountInstruction<
|
|
|
126
140
|
],
|
|
127
141
|
data: getAuthorizeNonceAccountInstructionDataEncoder().encode(args as AuthorizeNonceAccountInstructionDataArgs),
|
|
128
142
|
programAddress,
|
|
129
|
-
} as AuthorizeNonceAccountInstruction<
|
|
143
|
+
} as AuthorizeNonceAccountInstruction<
|
|
144
|
+
TProgramAddress,
|
|
145
|
+
ResolvedInstructionAccountMeta<TAccountNonceAccount, InstructionAccountInputAddress<TAccountNonceAccount>>,
|
|
146
|
+
ResolvedInstructionAccountMeta<TAccountNonceAuthority, InstructionAccountInputAddress<TAccountNonceAuthority>>
|
|
147
|
+
>);
|
|
130
148
|
}
|
|
131
149
|
|
|
132
150
|
export type ParsedAuthorizeNonceAccountInstruction<
|