Skip to content

Commit 2f8f078

Browse files
committed
Upgrade JS client to Kit v3
1 parent 238034b commit 2f8f078

20 files changed

+693
-798
lines changed

clients/js/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
},
4444
"homepage": "https://github.com/solana-program/compute-budget#readme",
4545
"peerDependencies": {
46-
"@solana/kit": "^2.1.0"
46+
"@solana/kit": "^3.0"
4747
},
4848
"devDependencies": {
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
"eslint": "^8.57.0",

clients/js/pnpm-lock.yaml

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

clients/js/src/estimateAndSetComputeLimit.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
2-
CompilableTransactionMessage,
3-
ITransactionMessageWithFeePayer,
4-
TransactionMessage,
2+
BaseTransactionMessage,
3+
TransactionMessageWithFeePayer,
54
} from '@solana/kit';
65
import {
76
MAX_COMPUTE_UNIT_LIMIT,
@@ -15,9 +14,8 @@ import { getSetComputeUnitLimitInstructionIndexAndUnits } from './internal';
1514
import { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';
1615

1716
type EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction = <
18-
TTransactionMessage extends
19-
| CompilableTransactionMessage
20-
| (TransactionMessage & ITransactionMessageWithFeePayer),
17+
TTransactionMessage extends BaseTransactionMessage &
18+
TransactionMessageWithFeePayer,
2119
>(
2220
transactionMessage: TTransactionMessage,
2321
config?: EstimateComputeUnitLimitFactoryFunctionConfig

clients/js/src/estimateComputeLimitInternal.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import {
2+
BaseTransactionMessage,
23
Commitment,
3-
CompilableTransactionMessage,
44
compileTransaction,
55
getBase64EncodedWireTransaction,
6-
isDurableNonceTransaction,
76
isSolanaError,
8-
ITransactionMessageWithFeePayer,
7+
isTransactionMessageWithDurableNonceLifetime,
98
pipe,
109
Rpc,
1110
SimulateTransactionApi,
@@ -14,21 +13,18 @@ import {
1413
SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,
1514
SolanaError,
1615
Transaction,
17-
TransactionMessage,
16+
TransactionMessageWithFeePayer,
1817
} from '@solana/kit';
1918
import { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';
2019
import { MAX_COMPUTE_UNIT_LIMIT } from './constants';
21-
import { fillMissingTransactionMessageLifetimeUsingProvisoryBlockhash } from './internalMoveToKit';
2220

2321
export type EstimateComputeUnitLimitFactoryConfig = Readonly<{
2422
/** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */
2523
rpc: Rpc<SimulateTransactionApi>;
2624
}>;
2725

2826
export type EstimateComputeUnitLimitFactoryFunction = (
29-
transactionMessage:
30-
| CompilableTransactionMessage
31-
| (TransactionMessage & ITransactionMessageWithFeePayer),
27+
transactionMessage: BaseTransactionMessage & TransactionMessageWithFeePayer,
3228
config?: EstimateComputeUnitLimitFactoryFunctionConfig
3329
) => Promise<number>;
3430

@@ -54,9 +50,8 @@ type EstimateComputeUnitLimitConfig =
5450
EstimateComputeUnitLimitFactoryFunctionConfig &
5551
Readonly<{
5652
rpc: Rpc<SimulateTransactionApi>;
57-
transactionMessage:
58-
| CompilableTransactionMessage
59-
| (TransactionMessage & ITransactionMessageWithFeePayer);
53+
transactionMessage: BaseTransactionMessage &
54+
TransactionMessageWithFeePayer;
6055
}>;
6156

6257
/**
@@ -120,10 +115,10 @@ export async function estimateComputeUnitLimit({
120115
transactionMessage,
121116
...configs
122117
}: EstimateComputeUnitLimitConfig): Promise<number> {
123-
const replaceRecentBlockhash = !isDurableNonceTransaction(transactionMessage);
118+
const replaceRecentBlockhash =
119+
!isTransactionMessageWithDurableNonceLifetime(transactionMessage);
124120
const transaction = pipe(
125121
transactionMessage,
126-
fillMissingTransactionMessageLifetimeUsingProvisoryBlockhash,
127122
(m) =>
128123
updateOrAppendSetComputeUnitLimitInstruction(MAX_COMPUTE_UNIT_LIMIT, m),
129124
compileTransaction

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import {
1515
getU8Decoder,
1616
getU8Encoder,
1717
transformEncoder,
18+
type AccountMeta,
1819
type Address,
19-
type Codec,
20-
type Decoder,
21-
type Encoder,
22-
type IAccountMeta,
23-
type IInstruction,
24-
type IInstructionWithAccounts,
25-
type IInstructionWithData,
20+
type FixedSizeCodec,
21+
type FixedSizeDecoder,
22+
type FixedSizeEncoder,
23+
type Instruction,
24+
type InstructionWithAccounts,
25+
type InstructionWithData,
26+
type ReadonlyUint8Array,
2627
} from '@solana/kit';
2728
import { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';
2829

@@ -34,10 +35,10 @@ export function getRequestHeapFrameDiscriminatorBytes() {
3435

3536
export type RequestHeapFrameInstruction<
3637
TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,
37-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
38-
> = IInstruction<TProgram> &
39-
IInstructionWithData<Uint8Array> &
40-
IInstructionWithAccounts<TRemainingAccounts>;
38+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
39+
> = Instruction<TProgram> &
40+
InstructionWithData<ReadonlyUint8Array> &
41+
InstructionWithAccounts<TRemainingAccounts>;
4142

4243
export type RequestHeapFrameInstructionData = {
4344
discriminator: number;
@@ -56,7 +57,7 @@ export type RequestHeapFrameInstructionDataArgs = {
5657
bytes: number;
5758
};
5859

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

69-
export function getRequestHeapFrameInstructionDataDecoder(): Decoder<RequestHeapFrameInstructionData> {
70+
export function getRequestHeapFrameInstructionDataDecoder(): FixedSizeDecoder<RequestHeapFrameInstructionData> {
7071
return getStructDecoder([
7172
['discriminator', getU8Decoder()],
7273
['bytes', getU32Decoder()],
7374
]);
7475
}
7576

76-
export function getRequestHeapFrameInstructionDataCodec(): Codec<
77+
export function getRequestHeapFrameInstructionDataCodec(): FixedSizeCodec<
7778
RequestHeapFrameInstructionDataArgs,
7879
RequestHeapFrameInstructionData
7980
> {
@@ -118,7 +119,7 @@ export type ParsedRequestHeapFrameInstruction<
118119
};
119120

120121
export function parseRequestHeapFrameInstruction<TProgram extends string>(
121-
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
122+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
122123
): ParsedRequestHeapFrameInstruction<TProgram> {
123124
return {
124125
programAddress: instruction.programAddress,

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import {
1515
getU8Decoder,
1616
getU8Encoder,
1717
transformEncoder,
18+
type AccountMeta,
1819
type Address,
19-
type Codec,
20-
type Decoder,
21-
type Encoder,
22-
type IAccountMeta,
23-
type IInstruction,
24-
type IInstructionWithAccounts,
25-
type IInstructionWithData,
20+
type FixedSizeCodec,
21+
type FixedSizeDecoder,
22+
type FixedSizeEncoder,
23+
type Instruction,
24+
type InstructionWithAccounts,
25+
type InstructionWithData,
26+
type ReadonlyUint8Array,
2627
} from '@solana/kit';
2728
import { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';
2829

@@ -34,10 +35,10 @@ export function getRequestUnitsDiscriminatorBytes() {
3435

3536
export type RequestUnitsInstruction<
3637
TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,
37-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
38-
> = IInstruction<TProgram> &
39-
IInstructionWithData<Uint8Array> &
40-
IInstructionWithAccounts<TRemainingAccounts>;
38+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
39+
> = Instruction<TProgram> &
40+
InstructionWithData<ReadonlyUint8Array> &
41+
InstructionWithAccounts<TRemainingAccounts>;
4142

4243
export type RequestUnitsInstructionData = {
4344
discriminator: number;
@@ -54,7 +55,7 @@ export type RequestUnitsInstructionDataArgs = {
5455
additionalFee: number;
5556
};
5657

57-
export function getRequestUnitsInstructionDataEncoder(): Encoder<RequestUnitsInstructionDataArgs> {
58+
export function getRequestUnitsInstructionDataEncoder(): FixedSizeEncoder<RequestUnitsInstructionDataArgs> {
5859
return transformEncoder(
5960
getStructEncoder([
6061
['discriminator', getU8Encoder()],
@@ -65,15 +66,15 @@ export function getRequestUnitsInstructionDataEncoder(): Encoder<RequestUnitsIns
6566
);
6667
}
6768

68-
export function getRequestUnitsInstructionDataDecoder(): Decoder<RequestUnitsInstructionData> {
69+
export function getRequestUnitsInstructionDataDecoder(): FixedSizeDecoder<RequestUnitsInstructionData> {
6970
return getStructDecoder([
7071
['discriminator', getU8Decoder()],
7172
['units', getU32Decoder()],
7273
['additionalFee', getU32Decoder()],
7374
]);
7475
}
7576

76-
export function getRequestUnitsInstructionDataCodec(): Codec<
77+
export function getRequestUnitsInstructionDataCodec(): FixedSizeCodec<
7778
RequestUnitsInstructionDataArgs,
7879
RequestUnitsInstructionData
7980
> {
@@ -119,7 +120,7 @@ export type ParsedRequestUnitsInstruction<
119120
};
120121

121122
export function parseRequestUnitsInstruction<TProgram extends string>(
122-
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
123+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
123124
): ParsedRequestUnitsInstruction<TProgram> {
124125
return {
125126
programAddress: instruction.programAddress,

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import {
1515
getU8Decoder,
1616
getU8Encoder,
1717
transformEncoder,
18+
type AccountMeta,
1819
type Address,
19-
type Codec,
20-
type Decoder,
21-
type Encoder,
22-
type IAccountMeta,
23-
type IInstruction,
24-
type IInstructionWithAccounts,
25-
type IInstructionWithData,
20+
type FixedSizeCodec,
21+
type FixedSizeDecoder,
22+
type FixedSizeEncoder,
23+
type Instruction,
24+
type InstructionWithAccounts,
25+
type InstructionWithData,
26+
type ReadonlyUint8Array,
2627
} from '@solana/kit';
2728
import { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';
2829

@@ -34,10 +35,10 @@ export function getSetComputeUnitLimitDiscriminatorBytes() {
3435

3536
export type SetComputeUnitLimitInstruction<
3637
TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,
37-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
38-
> = IInstruction<TProgram> &
39-
IInstructionWithData<Uint8Array> &
40-
IInstructionWithAccounts<TRemainingAccounts>;
38+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
39+
> = Instruction<TProgram> &
40+
InstructionWithData<ReadonlyUint8Array> &
41+
InstructionWithAccounts<TRemainingAccounts>;
4142

4243
export type SetComputeUnitLimitInstructionData = {
4344
discriminator: number;
@@ -50,7 +51,7 @@ export type SetComputeUnitLimitInstructionDataArgs = {
5051
units: number;
5152
};
5253

53-
export function getSetComputeUnitLimitInstructionDataEncoder(): Encoder<SetComputeUnitLimitInstructionDataArgs> {
54+
export function getSetComputeUnitLimitInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitLimitInstructionDataArgs> {
5455
return transformEncoder(
5556
getStructEncoder([
5657
['discriminator', getU8Encoder()],
@@ -63,14 +64,14 @@ export function getSetComputeUnitLimitInstructionDataEncoder(): Encoder<SetCompu
6364
);
6465
}
6566

66-
export function getSetComputeUnitLimitInstructionDataDecoder(): Decoder<SetComputeUnitLimitInstructionData> {
67+
export function getSetComputeUnitLimitInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitLimitInstructionData> {
6768
return getStructDecoder([
6869
['discriminator', getU8Decoder()],
6970
['units', getU32Decoder()],
7071
]);
7172
}
7273

73-
export function getSetComputeUnitLimitInstructionDataCodec(): Codec<
74+
export function getSetComputeUnitLimitInstructionDataCodec(): FixedSizeCodec<
7475
SetComputeUnitLimitInstructionDataArgs,
7576
SetComputeUnitLimitInstructionData
7677
> {
@@ -115,7 +116,7 @@ export type ParsedSetComputeUnitLimitInstruction<
115116
};
116117

117118
export function parseSetComputeUnitLimitInstruction<TProgram extends string>(
118-
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
119+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
119120
): ParsedSetComputeUnitLimitInstruction<TProgram> {
120121
return {
121122
programAddress: instruction.programAddress,

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import {
1515
getU8Decoder,
1616
getU8Encoder,
1717
transformEncoder,
18+
type AccountMeta,
1819
type Address,
19-
type Codec,
20-
type Decoder,
21-
type Encoder,
22-
type IAccountMeta,
23-
type IInstruction,
24-
type IInstructionWithAccounts,
25-
type IInstructionWithData,
20+
type FixedSizeCodec,
21+
type FixedSizeDecoder,
22+
type FixedSizeEncoder,
23+
type Instruction,
24+
type InstructionWithAccounts,
25+
type InstructionWithData,
26+
type ReadonlyUint8Array,
2627
} from '@solana/kit';
2728
import { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';
2829

@@ -34,10 +35,10 @@ export function getSetComputeUnitPriceDiscriminatorBytes() {
3435

3536
export type SetComputeUnitPriceInstruction<
3637
TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,
37-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
38-
> = IInstruction<TProgram> &
39-
IInstructionWithData<Uint8Array> &
40-
IInstructionWithAccounts<TRemainingAccounts>;
38+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
39+
> = Instruction<TProgram> &
40+
InstructionWithData<ReadonlyUint8Array> &
41+
InstructionWithAccounts<TRemainingAccounts>;
4142

4243
export type SetComputeUnitPriceInstructionData = {
4344
discriminator: number;
@@ -50,7 +51,7 @@ export type SetComputeUnitPriceInstructionDataArgs = {
5051
microLamports: number | bigint;
5152
};
5253

53-
export function getSetComputeUnitPriceInstructionDataEncoder(): Encoder<SetComputeUnitPriceInstructionDataArgs> {
54+
export function getSetComputeUnitPriceInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitPriceInstructionDataArgs> {
5455
return transformEncoder(
5556
getStructEncoder([
5657
['discriminator', getU8Encoder()],
@@ -63,14 +64,14 @@ export function getSetComputeUnitPriceInstructionDataEncoder(): Encoder<SetCompu
6364
);
6465
}
6566

66-
export function getSetComputeUnitPriceInstructionDataDecoder(): Decoder<SetComputeUnitPriceInstructionData> {
67+
export function getSetComputeUnitPriceInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitPriceInstructionData> {
6768
return getStructDecoder([
6869
['discriminator', getU8Decoder()],
6970
['microLamports', getU64Decoder()],
7071
]);
7172
}
7273

73-
export function getSetComputeUnitPriceInstructionDataCodec(): Codec<
74+
export function getSetComputeUnitPriceInstructionDataCodec(): FixedSizeCodec<
7475
SetComputeUnitPriceInstructionDataArgs,
7576
SetComputeUnitPriceInstructionData
7677
> {
@@ -115,7 +116,7 @@ export type ParsedSetComputeUnitPriceInstruction<
115116
};
116117

117118
export function parseSetComputeUnitPriceInstruction<TProgram extends string>(
118-
instruction: IInstruction<TProgram> & IInstructionWithData<Uint8Array>
119+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
119120
): ParsedSetComputeUnitPriceInstruction<TProgram> {
120121
return {
121122
programAddress: instruction.programAddress,

0 commit comments

Comments
 (0)