Skip to content

Commit 908a173

Browse files
authored
Upgrade JS client to Kit v3 (#65)
1 parent 3793854 commit 908a173

File tree

11 files changed

+636
-769
lines changed

11 files changed

+636
-769
lines changed

clients/js/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
},
4343
"homepage": "https://github.com/solana-program/address-lookup-table#readme",
4444
"peerDependencies": {
45-
"@solana/kit": "^2.1.0"
45+
"@solana/kit": "^3.0"
4646
},
4747
"devDependencies": {
4848
"@ava/typescript": "^4.1.0",
4949
"@solana/eslint-config-solana": "^3.0.3",
50-
"@solana/kit": "^2.1.0",
51-
"@types/node": "^20",
50+
"@solana/kit": "^3.0",
51+
"@types/node": "^24",
5252
"@typescript-eslint/eslint-plugin": "^7.16.1",
5353
"@typescript-eslint/parser": "^7.16.1",
5454
"ava": "^6.1.3",

clients/js/pnpm-lock.yaml

Lines changed: 366 additions & 325 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/js/src/generated/instructions/closeLookupTable.ts

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ import {
1313
getU32Decoder,
1414
getU32Encoder,
1515
transformEncoder,
16+
type AccountMeta,
17+
type AccountSignerMeta,
1618
type Address,
17-
type Codec,
18-
type Decoder,
19-
type Encoder,
20-
type IAccountMeta,
21-
type IAccountSignerMeta,
22-
type IInstruction,
23-
type IInstructionWithAccounts,
24-
type IInstructionWithData,
19+
type FixedSizeCodec,
20+
type FixedSizeDecoder,
21+
type FixedSizeEncoder,
22+
type Instruction,
23+
type InstructionWithAccounts,
24+
type InstructionWithData,
2525
type ReadonlySignerAccount,
26+
type ReadonlyUint8Array,
2627
type TransactionSigner,
2728
type WritableAccount,
2829
} from '@solana/kit';
@@ -37,20 +38,20 @@ export function getCloseLookupTableDiscriminatorBytes() {
3738

3839
export type CloseLookupTableInstruction<
3940
TProgram extends string = typeof ADDRESS_LOOKUP_TABLE_PROGRAM_ADDRESS,
40-
TAccountAddress extends string | IAccountMeta<string> = string,
41-
TAccountAuthority extends string | IAccountMeta<string> = string,
42-
TAccountRecipient extends string | IAccountMeta<string> = string,
43-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
44-
> = IInstruction<TProgram> &
45-
IInstructionWithData<Uint8Array> &
46-
IInstructionWithAccounts<
41+
TAccountAddress extends string | AccountMeta<string> = string,
42+
TAccountAuthority extends string | AccountMeta<string> = string,
43+
TAccountRecipient extends string | AccountMeta<string> = string,
44+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
45+
> = Instruction<TProgram> &
46+
InstructionWithData<ReadonlyUint8Array> &
47+
InstructionWithAccounts<
4748
[
4849
TAccountAddress extends string
4950
? WritableAccount<TAccountAddress>
5051
: TAccountAddress,
5152
TAccountAuthority extends string
5253
? ReadonlySignerAccount<TAccountAuthority> &
53-
IAccountSignerMeta<TAccountAuthority>
54+
AccountSignerMeta<TAccountAuthority>
5455
: TAccountAuthority,
5556
TAccountRecipient extends string
5657
? WritableAccount<TAccountRecipient>
@@ -63,18 +64,18 @@ export type CloseLookupTableInstructionData = { discriminator: number };
6364

6465
export type CloseLookupTableInstructionDataArgs = {};
6566

66-
export function getCloseLookupTableInstructionDataEncoder(): Encoder<CloseLookupTableInstructionDataArgs> {
67+
export function getCloseLookupTableInstructionDataEncoder(): FixedSizeEncoder<CloseLookupTableInstructionDataArgs> {
6768
return transformEncoder(
6869
getStructEncoder([['discriminator', getU32Encoder()]]),
6970
(value) => ({ ...value, discriminator: CLOSE_LOOKUP_TABLE_DISCRIMINATOR })
7071
);
7172
}
7273

73-
export function getCloseLookupTableInstructionDataDecoder(): Decoder<CloseLookupTableInstructionData> {
74+
export function getCloseLookupTableInstructionDataDecoder(): FixedSizeDecoder<CloseLookupTableInstructionData> {
7475
return getStructDecoder([['discriminator', getU32Decoder()]]);
7576
}
7677

77-
export function getCloseLookupTableInstructionDataCodec(): Codec<
78+
export function getCloseLookupTableInstructionDataCodec(): FixedSizeCodec<
7879
CloseLookupTableInstructionDataArgs,
7980
CloseLookupTableInstructionData
8081
> {
@@ -148,7 +149,7 @@ export function getCloseLookupTableInstruction<
148149

149150
export type ParsedCloseLookupTableInstruction<
150151
TProgram extends string = typeof ADDRESS_LOOKUP_TABLE_PROGRAM_ADDRESS,
151-
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
152+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
152153
> = {
153154
programAddress: Address<TProgram>;
154155
accounts: {
@@ -161,19 +162,19 @@ export type ParsedCloseLookupTableInstruction<
161162

162163
export function parseCloseLookupTableInstruction<
163164
TProgram extends string,
164-
TAccountMetas extends readonly IAccountMeta[],
165+
TAccountMetas extends readonly AccountMeta[],
165166
>(
166-
instruction: IInstruction<TProgram> &
167-
IInstructionWithAccounts<TAccountMetas> &
168-
IInstructionWithData<Uint8Array>
167+
instruction: Instruction<TProgram> &
168+
InstructionWithAccounts<TAccountMetas> &
169+
InstructionWithData<ReadonlyUint8Array>
169170
): ParsedCloseLookupTableInstruction<TProgram, TAccountMetas> {
170171
if (instruction.accounts.length < 3) {
171172
// TODO: Coded error.
172173
throw new Error('Not enough accounts');
173174
}
174175
let accountIndex = 0;
175176
const getNextAccount = () => {
176-
const accountMeta = instruction.accounts![accountIndex]!;
177+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
177178
accountIndex += 1;
178179
return accountMeta;
179180
};

clients/js/src/generated/instructions/createLookupTable.ts

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ import {
1818
getU8Decoder,
1919
getU8Encoder,
2020
transformEncoder,
21+
type AccountMeta,
22+
type AccountSignerMeta,
2123
type Address,
22-
type Codec,
23-
type Decoder,
24-
type Encoder,
25-
type IAccountMeta,
26-
type IAccountSignerMeta,
27-
type IInstruction,
28-
type IInstructionWithAccounts,
29-
type IInstructionWithData,
24+
type FixedSizeCodec,
25+
type FixedSizeDecoder,
26+
type FixedSizeEncoder,
27+
type Instruction,
28+
type InstructionWithAccounts,
29+
type InstructionWithData,
3030
type ProgramDerivedAddress,
3131
type ReadonlyAccount,
3232
type ReadonlySignerAccount,
33+
type ReadonlyUint8Array,
3334
type TransactionSigner,
3435
type WritableAccount,
3536
type WritableSignerAccount,
@@ -41,7 +42,7 @@ import {
4142
expectProgramDerivedAddress,
4243
expectSome,
4344
getAccountMetaFactory,
44-
type IInstructionWithByteDelta,
45+
type InstructionWithByteDelta,
4546
type ResolvedAccount,
4647
} from '../shared';
4748

@@ -53,27 +54,27 @@ export function getCreateLookupTableDiscriminatorBytes() {
5354

5455
export type CreateLookupTableInstruction<
5556
TProgram extends string = typeof ADDRESS_LOOKUP_TABLE_PROGRAM_ADDRESS,
56-
TAccountAddress extends string | IAccountMeta<string> = string,
57-
TAccountAuthority extends string | IAccountMeta<string> = string,
58-
TAccountPayer extends string | IAccountMeta<string> = string,
57+
TAccountAddress extends string | AccountMeta<string> = string,
58+
TAccountAuthority extends string | AccountMeta<string> = string,
59+
TAccountPayer extends string | AccountMeta<string> = string,
5960
TAccountSystemProgram extends
6061
| string
61-
| IAccountMeta<string> = '11111111111111111111111111111111',
62-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
63-
> = IInstruction<TProgram> &
64-
IInstructionWithData<Uint8Array> &
65-
IInstructionWithAccounts<
62+
| AccountMeta<string> = '11111111111111111111111111111111',
63+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
64+
> = Instruction<TProgram> &
65+
InstructionWithData<ReadonlyUint8Array> &
66+
InstructionWithAccounts<
6667
[
6768
TAccountAddress extends string
6869
? WritableAccount<TAccountAddress>
6970
: TAccountAddress,
7071
TAccountAuthority extends string
7172
? ReadonlySignerAccount<TAccountAuthority> &
72-
IAccountSignerMeta<TAccountAuthority>
73+
AccountSignerMeta<TAccountAuthority>
7374
: TAccountAuthority,
7475
TAccountPayer extends string
7576
? WritableSignerAccount<TAccountPayer> &
76-
IAccountSignerMeta<TAccountPayer>
77+
AccountSignerMeta<TAccountPayer>
7778
: TAccountPayer,
7879
TAccountSystemProgram extends string
7980
? ReadonlyAccount<TAccountSystemProgram>
@@ -93,7 +94,7 @@ export type CreateLookupTableInstructionDataArgs = {
9394
bump: number;
9495
};
9596

96-
export function getCreateLookupTableInstructionDataEncoder(): Encoder<CreateLookupTableInstructionDataArgs> {
97+
export function getCreateLookupTableInstructionDataEncoder(): FixedSizeEncoder<CreateLookupTableInstructionDataArgs> {
9798
return transformEncoder(
9899
getStructEncoder([
99100
['discriminator', getU32Encoder()],
@@ -104,15 +105,15 @@ export function getCreateLookupTableInstructionDataEncoder(): Encoder<CreateLook
104105
);
105106
}
106107

107-
export function getCreateLookupTableInstructionDataDecoder(): Decoder<CreateLookupTableInstructionData> {
108+
export function getCreateLookupTableInstructionDataDecoder(): FixedSizeDecoder<CreateLookupTableInstructionData> {
108109
return getStructDecoder([
109110
['discriminator', getU32Decoder()],
110111
['recentSlot', getU64Decoder()],
111112
['bump', getU8Decoder()],
112113
]);
113114
}
114115

115-
export function getCreateLookupTableInstructionDataCodec(): Codec<
116+
export function getCreateLookupTableInstructionDataCodec(): FixedSizeCodec<
116117
CreateLookupTableInstructionDataArgs,
117118
CreateLookupTableInstructionData
118119
> {
@@ -158,7 +159,7 @@ export async function getCreateLookupTableInstructionAsync<
158159
TAccountPayer,
159160
TAccountSystemProgram
160161
> &
161-
IInstructionWithByteDelta
162+
InstructionWithByteDelta
162163
> {
163164
// Program address.
164165
const programAddress =
@@ -258,7 +259,7 @@ export function getCreateLookupTableInstruction<
258259
TAccountPayer,
259260
TAccountSystemProgram
260261
> &
261-
IInstructionWithByteDelta {
262+
InstructionWithByteDelta {
262263
// Program address.
263264
const programAddress =
264265
config?.programAddress ?? ADDRESS_LOOKUP_TABLE_PROGRAM_ADDRESS;
@@ -318,7 +319,7 @@ export function getCreateLookupTableInstruction<
318319

319320
export type ParsedCreateLookupTableInstruction<
320321
TProgram extends string = typeof ADDRESS_LOOKUP_TABLE_PROGRAM_ADDRESS,
321-
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
322+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
322323
> = {
323324
programAddress: Address<TProgram>;
324325
accounts: {
@@ -332,19 +333,19 @@ export type ParsedCreateLookupTableInstruction<
332333

333334
export function parseCreateLookupTableInstruction<
334335
TProgram extends string,
335-
TAccountMetas extends readonly IAccountMeta[],
336+
TAccountMetas extends readonly AccountMeta[],
336337
>(
337-
instruction: IInstruction<TProgram> &
338-
IInstructionWithAccounts<TAccountMetas> &
339-
IInstructionWithData<Uint8Array>
338+
instruction: Instruction<TProgram> &
339+
InstructionWithAccounts<TAccountMetas> &
340+
InstructionWithData<ReadonlyUint8Array>
340341
): ParsedCreateLookupTableInstruction<TProgram, TAccountMetas> {
341342
if (instruction.accounts.length < 4) {
342343
// TODO: Coded error.
343344
throw new Error('Not enough accounts');
344345
}
345346
let accountIndex = 0;
346347
const getNextAccount = () => {
347-
const accountMeta = instruction.accounts![accountIndex]!;
348+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
348349
accountIndex += 1;
349350
return accountMeta;
350351
};

clients/js/src/generated/instructions/deactivateLookupTable.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ import {
1313
getU32Decoder,
1414
getU32Encoder,
1515
transformEncoder,
16+
type AccountMeta,
17+
type AccountSignerMeta,
1618
type Address,
17-
type Codec,
18-
type Decoder,
19-
type Encoder,
20-
type IAccountMeta,
21-
type IAccountSignerMeta,
22-
type IInstruction,
23-
type IInstructionWithAccounts,
24-
type IInstructionWithData,
19+
type FixedSizeCodec,
20+
type FixedSizeDecoder,
21+
type FixedSizeEncoder,
22+
type Instruction,
23+
type InstructionWithAccounts,
24+
type InstructionWithData,
2525
type ReadonlySignerAccount,
26+
type ReadonlyUint8Array,
2627
type TransactionSigner,
2728
type WritableAccount,
2829
} from '@solana/kit';
@@ -37,19 +38,19 @@ export function getDeactivateLookupTableDiscriminatorBytes() {
3738

3839
export type DeactivateLookupTableInstruction<
3940
TProgram extends string = typeof ADDRESS_LOOKUP_TABLE_PROGRAM_ADDRESS,
40-
TAccountAddress extends string | IAccountMeta<string> = string,
41-
TAccountAuthority extends string | IAccountMeta<string> = string,
42-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
43-
> = IInstruction<TProgram> &
44-
IInstructionWithData<Uint8Array> &
45-
IInstructionWithAccounts<
41+
TAccountAddress extends string | AccountMeta<string> = string,
42+
TAccountAuthority extends string | AccountMeta<string> = string,
43+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
44+
> = Instruction<TProgram> &
45+
InstructionWithData<ReadonlyUint8Array> &
46+
InstructionWithAccounts<
4647
[
4748
TAccountAddress extends string
4849
? WritableAccount<TAccountAddress>
4950
: TAccountAddress,
5051
TAccountAuthority extends string
5152
? ReadonlySignerAccount<TAccountAuthority> &
52-
IAccountSignerMeta<TAccountAuthority>
53+
AccountSignerMeta<TAccountAuthority>
5354
: TAccountAuthority,
5455
...TRemainingAccounts,
5556
]
@@ -59,7 +60,7 @@ export type DeactivateLookupTableInstructionData = { discriminator: number };
5960

6061
export type DeactivateLookupTableInstructionDataArgs = {};
6162

62-
export function getDeactivateLookupTableInstructionDataEncoder(): Encoder<DeactivateLookupTableInstructionDataArgs> {
63+
export function getDeactivateLookupTableInstructionDataEncoder(): FixedSizeEncoder<DeactivateLookupTableInstructionDataArgs> {
6364
return transformEncoder(
6465
getStructEncoder([['discriminator', getU32Encoder()]]),
6566
(value) => ({
@@ -69,11 +70,11 @@ export function getDeactivateLookupTableInstructionDataEncoder(): Encoder<Deacti
6970
);
7071
}
7172

72-
export function getDeactivateLookupTableInstructionDataDecoder(): Decoder<DeactivateLookupTableInstructionData> {
73+
export function getDeactivateLookupTableInstructionDataDecoder(): FixedSizeDecoder<DeactivateLookupTableInstructionData> {
7374
return getStructDecoder([['discriminator', getU32Decoder()]]);
7475
}
7576

76-
export function getDeactivateLookupTableInstructionDataCodec(): Codec<
77+
export function getDeactivateLookupTableInstructionDataCodec(): FixedSizeCodec<
7778
DeactivateLookupTableInstructionDataArgs,
7879
DeactivateLookupTableInstructionData
7980
> {
@@ -136,7 +137,7 @@ export function getDeactivateLookupTableInstruction<
136137

137138
export type ParsedDeactivateLookupTableInstruction<
138139
TProgram extends string = typeof ADDRESS_LOOKUP_TABLE_PROGRAM_ADDRESS,
139-
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
140+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
140141
> = {
141142
programAddress: Address<TProgram>;
142143
accounts: {
@@ -148,19 +149,19 @@ export type ParsedDeactivateLookupTableInstruction<
148149

149150
export function parseDeactivateLookupTableInstruction<
150151
TProgram extends string,
151-
TAccountMetas extends readonly IAccountMeta[],
152+
TAccountMetas extends readonly AccountMeta[],
152153
>(
153-
instruction: IInstruction<TProgram> &
154-
IInstructionWithAccounts<TAccountMetas> &
155-
IInstructionWithData<Uint8Array>
154+
instruction: Instruction<TProgram> &
155+
InstructionWithAccounts<TAccountMetas> &
156+
InstructionWithData<ReadonlyUint8Array>
156157
): ParsedDeactivateLookupTableInstruction<TProgram, TAccountMetas> {
157158
if (instruction.accounts.length < 2) {
158159
// TODO: Coded error.
159160
throw new Error('Not enough accounts');
160161
}
161162
let accountIndex = 0;
162163
const getNextAccount = () => {
163-
const accountMeta = instruction.accounts![accountIndex]!;
164+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
164165
accountIndex += 1;
165166
return accountMeta;
166167
};

0 commit comments

Comments
 (0)