Skip to content

Commit 6452651

Browse files
authored
Upgrade JS client to Kit v3 (#56)
1 parent 405616b commit 6452651

36 files changed

+928
-870
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/system#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/accounts/nonce.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import {
2121
getU64Encoder,
2222
type Account,
2323
type Address,
24-
type Codec,
25-
type Decoder,
2624
type EncodedAccount,
27-
type Encoder,
2825
type FetchAccountConfig,
2926
type FetchAccountsConfig,
27+
type FixedSizeCodec,
28+
type FixedSizeDecoder,
29+
type FixedSizeEncoder,
3030
type MaybeAccount,
3131
type MaybeEncodedAccount,
3232
} from '@solana/kit';
@@ -57,7 +57,7 @@ export type NonceArgs = {
5757
lamportsPerSignature: number | bigint;
5858
};
5959

60-
export function getNonceEncoder(): Encoder<NonceArgs> {
60+
export function getNonceEncoder(): FixedSizeEncoder<NonceArgs> {
6161
return getStructEncoder([
6262
['version', getNonceVersionEncoder()],
6363
['state', getNonceStateEncoder()],
@@ -67,7 +67,7 @@ export function getNonceEncoder(): Encoder<NonceArgs> {
6767
]);
6868
}
6969

70-
export function getNonceDecoder(): Decoder<Nonce> {
70+
export function getNonceDecoder(): FixedSizeDecoder<Nonce> {
7171
return getStructDecoder([
7272
['version', getNonceVersionDecoder()],
7373
['state', getNonceStateDecoder()],
@@ -77,7 +77,7 @@ export function getNonceDecoder(): Decoder<Nonce> {
7777
]);
7878
}
7979

80-
export function getNonceCodec(): Codec<NonceArgs, Nonce> {
80+
export function getNonceCodec(): FixedSizeCodec<NonceArgs, Nonce> {
8181
return combineCodec(getNonceEncoder(), getNonceDecoder());
8282
}
8383

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

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ 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 ReadonlyAccount,
2626
type ReadonlySignerAccount,
27+
type ReadonlyUint8Array,
2728
type TransactionSigner,
2829
type WritableAccount,
2930
} from '@solana/kit';
@@ -38,15 +39,15 @@ export function getAdvanceNonceAccountDiscriminatorBytes() {
3839

3940
export type AdvanceNonceAccountInstruction<
4041
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
41-
TAccountNonceAccount extends string | IAccountMeta<string> = string,
42+
TAccountNonceAccount extends string | AccountMeta<string> = string,
4243
TAccountRecentBlockhashesSysvar extends
4344
| string
44-
| IAccountMeta<string> = 'SysvarRecentB1ockHashes11111111111111111111',
45-
TAccountNonceAuthority extends string | IAccountMeta<string> = string,
46-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
47-
> = IInstruction<TProgram> &
48-
IInstructionWithData<Uint8Array> &
49-
IInstructionWithAccounts<
45+
| AccountMeta<string> = 'SysvarRecentB1ockHashes11111111111111111111',
46+
TAccountNonceAuthority extends string | AccountMeta<string> = string,
47+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
48+
> = Instruction<TProgram> &
49+
InstructionWithData<ReadonlyUint8Array> &
50+
InstructionWithAccounts<
5051
[
5152
TAccountNonceAccount extends string
5253
? WritableAccount<TAccountNonceAccount>
@@ -56,7 +57,7 @@ export type AdvanceNonceAccountInstruction<
5657
: TAccountRecentBlockhashesSysvar,
5758
TAccountNonceAuthority extends string
5859
? ReadonlySignerAccount<TAccountNonceAuthority> &
59-
IAccountSignerMeta<TAccountNonceAuthority>
60+
AccountSignerMeta<TAccountNonceAuthority>
6061
: TAccountNonceAuthority,
6162
...TRemainingAccounts,
6263
]
@@ -66,7 +67,7 @@ export type AdvanceNonceAccountInstructionData = { discriminator: number };
6667

6768
export type AdvanceNonceAccountInstructionDataArgs = {};
6869

69-
export function getAdvanceNonceAccountInstructionDataEncoder(): Encoder<AdvanceNonceAccountInstructionDataArgs> {
70+
export function getAdvanceNonceAccountInstructionDataEncoder(): FixedSizeEncoder<AdvanceNonceAccountInstructionDataArgs> {
7071
return transformEncoder(
7172
getStructEncoder([['discriminator', getU32Encoder()]]),
7273
(value) => ({
@@ -76,11 +77,11 @@ export function getAdvanceNonceAccountInstructionDataEncoder(): Encoder<AdvanceN
7677
);
7778
}
7879

79-
export function getAdvanceNonceAccountInstructionDataDecoder(): Decoder<AdvanceNonceAccountInstructionData> {
80+
export function getAdvanceNonceAccountInstructionDataDecoder(): FixedSizeDecoder<AdvanceNonceAccountInstructionData> {
8081
return getStructDecoder([['discriminator', getU32Decoder()]]);
8182
}
8283

83-
export function getAdvanceNonceAccountInstructionDataCodec(): Codec<
84+
export function getAdvanceNonceAccountInstructionDataCodec(): FixedSizeCodec<
8485
AdvanceNonceAccountInstructionDataArgs,
8586
AdvanceNonceAccountInstructionData
8687
> {
@@ -162,7 +163,7 @@ export function getAdvanceNonceAccountInstruction<
162163

163164
export type ParsedAdvanceNonceAccountInstruction<
164165
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
165-
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
166+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
166167
> = {
167168
programAddress: Address<TProgram>;
168169
accounts: {
@@ -175,19 +176,19 @@ export type ParsedAdvanceNonceAccountInstruction<
175176

176177
export function parseAdvanceNonceAccountInstruction<
177178
TProgram extends string,
178-
TAccountMetas extends readonly IAccountMeta[],
179+
TAccountMetas extends readonly AccountMeta[],
179180
>(
180-
instruction: IInstruction<TProgram> &
181-
IInstructionWithAccounts<TAccountMetas> &
182-
IInstructionWithData<Uint8Array>
181+
instruction: Instruction<TProgram> &
182+
InstructionWithAccounts<TAccountMetas> &
183+
InstructionWithData<ReadonlyUint8Array>
183184
): ParsedAdvanceNonceAccountInstruction<TProgram, TAccountMetas> {
184185
if (instruction.accounts.length < 3) {
185186
// TODO: Coded error.
186187
throw new Error('Not enough accounts');
187188
}
188189
let accountIndex = 0;
189190
const getNextAccount = () => {
190-
const accountMeta = instruction.accounts![accountIndex]!;
191+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
191192
accountIndex += 1;
192193
return accountMeta;
193194
};

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

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ import {
1515
getU64Decoder,
1616
getU64Encoder,
1717
transformEncoder,
18+
type AccountMeta,
19+
type AccountSignerMeta,
1820
type Address,
19-
type Codec,
20-
type Decoder,
21-
type Encoder,
22-
type IAccountMeta,
23-
type IAccountSignerMeta,
24-
type IInstruction,
25-
type IInstructionWithAccounts,
26-
type IInstructionWithData,
21+
type FixedSizeCodec,
22+
type FixedSizeDecoder,
23+
type FixedSizeEncoder,
24+
type Instruction,
25+
type InstructionWithAccounts,
26+
type InstructionWithData,
27+
type ReadonlyUint8Array,
2728
type TransactionSigner,
2829
type WritableSignerAccount,
2930
} from '@solana/kit';
@@ -38,15 +39,15 @@ export function getAllocateDiscriminatorBytes() {
3839

3940
export type AllocateInstruction<
4041
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
41-
TAccountNewAccount extends string | IAccountMeta<string> = string,
42-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
43-
> = IInstruction<TProgram> &
44-
IInstructionWithData<Uint8Array> &
45-
IInstructionWithAccounts<
42+
TAccountNewAccount extends string | AccountMeta<string> = string,
43+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
44+
> = Instruction<TProgram> &
45+
InstructionWithData<ReadonlyUint8Array> &
46+
InstructionWithAccounts<
4647
[
4748
TAccountNewAccount extends string
4849
? WritableSignerAccount<TAccountNewAccount> &
49-
IAccountSignerMeta<TAccountNewAccount>
50+
AccountSignerMeta<TAccountNewAccount>
5051
: TAccountNewAccount,
5152
...TRemainingAccounts,
5253
]
@@ -56,7 +57,7 @@ export type AllocateInstructionData = { discriminator: number; space: bigint };
5657

5758
export type AllocateInstructionDataArgs = { space: number | bigint };
5859

59-
export function getAllocateInstructionDataEncoder(): Encoder<AllocateInstructionDataArgs> {
60+
export function getAllocateInstructionDataEncoder(): FixedSizeEncoder<AllocateInstructionDataArgs> {
6061
return transformEncoder(
6162
getStructEncoder([
6263
['discriminator', getU32Encoder()],
@@ -66,14 +67,14 @@ export function getAllocateInstructionDataEncoder(): Encoder<AllocateInstruction
6667
);
6768
}
6869

69-
export function getAllocateInstructionDataDecoder(): Decoder<AllocateInstructionData> {
70+
export function getAllocateInstructionDataDecoder(): FixedSizeDecoder<AllocateInstructionData> {
7071
return getStructDecoder([
7172
['discriminator', getU32Decoder()],
7273
['space', getU64Decoder()],
7374
]);
7475
}
7576

76-
export function getAllocateInstructionDataCodec(): Codec<
77+
export function getAllocateInstructionDataCodec(): FixedSizeCodec<
7778
AllocateInstructionDataArgs,
7879
AllocateInstructionData
7980
> {
@@ -124,7 +125,7 @@ export function getAllocateInstruction<
124125

125126
export type ParsedAllocateInstruction<
126127
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
127-
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
128+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
128129
> = {
129130
programAddress: Address<TProgram>;
130131
accounts: {
@@ -135,19 +136,19 @@ export type ParsedAllocateInstruction<
135136

136137
export function parseAllocateInstruction<
137138
TProgram extends string,
138-
TAccountMetas extends readonly IAccountMeta[],
139+
TAccountMetas extends readonly AccountMeta[],
139140
>(
140-
instruction: IInstruction<TProgram> &
141-
IInstructionWithAccounts<TAccountMetas> &
142-
IInstructionWithData<Uint8Array>
141+
instruction: Instruction<TProgram> &
142+
InstructionWithAccounts<TAccountMetas> &
143+
InstructionWithData<ReadonlyUint8Array>
143144
): ParsedAllocateInstruction<TProgram, TAccountMetas> {
144145
if (instruction.accounts.length < 1) {
145146
// TODO: Coded error.
146147
throw new Error('Not enough accounts');
147148
}
148149
let accountIndex = 0;
149150
const getNextAccount = () => {
150-
const accountMeta = instruction.accounts![accountIndex]!;
151+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
151152
accountIndex += 1;
152153
return accountMeta;
153154
};

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ import {
2121
getUtf8Decoder,
2222
getUtf8Encoder,
2323
transformEncoder,
24+
type AccountMeta,
25+
type AccountSignerMeta,
2426
type Address,
2527
type Codec,
2628
type Decoder,
2729
type Encoder,
28-
type IAccountMeta,
29-
type IAccountSignerMeta,
30-
type IInstruction,
31-
type IInstructionWithAccounts,
32-
type IInstructionWithData,
30+
type Instruction,
31+
type InstructionWithAccounts,
32+
type InstructionWithData,
3333
type ReadonlySignerAccount,
34+
type ReadonlyUint8Array,
3435
type TransactionSigner,
3536
type WritableAccount,
3637
} from '@solana/kit';
@@ -45,19 +46,19 @@ export function getAllocateWithSeedDiscriminatorBytes() {
4546

4647
export type AllocateWithSeedInstruction<
4748
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
48-
TAccountNewAccount extends string | IAccountMeta<string> = string,
49-
TAccountBaseAccount extends string | IAccountMeta<string> = string,
50-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
51-
> = IInstruction<TProgram> &
52-
IInstructionWithData<Uint8Array> &
53-
IInstructionWithAccounts<
49+
TAccountNewAccount extends string | AccountMeta<string> = string,
50+
TAccountBaseAccount extends string | AccountMeta<string> = string,
51+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
52+
> = Instruction<TProgram> &
53+
InstructionWithData<ReadonlyUint8Array> &
54+
InstructionWithAccounts<
5455
[
5556
TAccountNewAccount extends string
5657
? WritableAccount<TAccountNewAccount>
5758
: TAccountNewAccount,
5859
TAccountBaseAccount extends string
5960
? ReadonlySignerAccount<TAccountBaseAccount> &
60-
IAccountSignerMeta<TAccountBaseAccount>
61+
AccountSignerMeta<TAccountBaseAccount>
6162
: TAccountBaseAccount,
6263
...TRemainingAccounts,
6364
]
@@ -172,7 +173,7 @@ export function getAllocateWithSeedInstruction<
172173

173174
export type ParsedAllocateWithSeedInstruction<
174175
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
175-
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
176+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
176177
> = {
177178
programAddress: Address<TProgram>;
178179
accounts: {
@@ -184,19 +185,19 @@ export type ParsedAllocateWithSeedInstruction<
184185

185186
export function parseAllocateWithSeedInstruction<
186187
TProgram extends string,
187-
TAccountMetas extends readonly IAccountMeta[],
188+
TAccountMetas extends readonly AccountMeta[],
188189
>(
189-
instruction: IInstruction<TProgram> &
190-
IInstructionWithAccounts<TAccountMetas> &
191-
IInstructionWithData<Uint8Array>
190+
instruction: Instruction<TProgram> &
191+
InstructionWithAccounts<TAccountMetas> &
192+
InstructionWithData<ReadonlyUint8Array>
192193
): ParsedAllocateWithSeedInstruction<TProgram, TAccountMetas> {
193194
if (instruction.accounts.length < 2) {
194195
// TODO: Coded error.
195196
throw new Error('Not enough accounts');
196197
}
197198
let accountIndex = 0;
198199
const getNextAccount = () => {
199-
const accountMeta = instruction.accounts![accountIndex]!;
200+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
200201
accountIndex += 1;
201202
return accountMeta;
202203
};

0 commit comments

Comments
 (0)