Skip to content

Commit c21ea51

Browse files
authored
Bump Kit and Codama (#35)
* Bump Kit and Codama * Ignore Prettier in generated folder This has already been Prettified by the JS renderer using the same Prettier options as the project but a slight difference in Prettier version can cause mismatches. This prevent these small mismatches to cause a CI failure.
1 parent b2c8798 commit c21ea51

14 files changed

Lines changed: 902 additions & 586 deletions

File tree

clients/js/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/generated/**

clients/js/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"homepage": "https://github.com/solana-program/program-metadata#readme",
4646
"license": "MIT",
4747
"peerDependencies": {
48-
"@solana/kit": "^4.0"
48+
"@solana/kit": "^6.0.0"
4949
},
5050
"dependencies": {
5151
"@iarna/toml": "^2.2.5",
52-
"@solana-program/compute-budget": "^0.10.0",
53-
"@solana-program/system": "^0.9.0",
52+
"@solana-program/compute-budget": "^0.12.0",
53+
"@solana-program/system": "^0.10.0",
5454
"commander": "^13.0.0",
5555
"pako": "^2.1.0",
5656
"picocolors": "^1.1.1",
@@ -59,7 +59,7 @@
5959
"devDependencies": {
6060
"@ava/typescript": "^4.1.0",
6161
"@solana/eslint-config-solana": "^3.0.3",
62-
"@solana/kit": "^4.0",
62+
"@solana/kit": "^6.0.0",
6363
"@types/node": "^24",
6464
"@types/pako": "^2.0.3",
6565
"@typescript-eslint/eslint-plugin": "^7.16.1",

clients/js/pnpm-lock.yaml

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

clients/js/src/cli/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import {
66
Account,
77
Address,
88
address,
9-
BaseTransactionMessage,
109
Commitment,
1110
compileTransaction,
1211
createKeyPairSignerFromBytes,
1312
createNoopSigner,
1413
createSolanaRpc,
1514
createSolanaRpcSubscriptions,
16-
getAllSingleTransactionPlans,
15+
flattenTransactionPlan,
1716
getTransactionEncoder,
1817
InstructionPlan,
1918
MessageSigner,
@@ -23,6 +22,7 @@ import {
2322
setTransactionMessageLifetimeUsingBlockhash,
2423
SolanaRpcApi,
2524
SolanaRpcSubscriptionsApi,
25+
TransactionMessage,
2626
TransactionMessageWithFeePayer,
2727
TransactionPlan,
2828
TransactionPlanExecutor,
@@ -120,7 +120,7 @@ async function exportTransactionPlan(
120120
client: Pick<Client, 'rpc'>,
121121
options: GlobalOptions
122122
) {
123-
const singleTransactions = getAllSingleTransactionPlans(transactionPlan);
123+
const singleTransactions = flattenTransactionPlan(transactionPlan);
124124
const transactionEncoder = getTransactionEncoder();
125125

126126
logExports(singleTransactions.length, options);
@@ -146,7 +146,7 @@ async function exportTransactionPlan(
146146
}
147147

148148
function removeComputeUnitLimitInstruction<
149-
TTransactionMessage extends BaseTransactionMessage &
149+
TTransactionMessage extends TransactionMessage &
150150
TransactionMessageWithFeePayer,
151151
>(message: TTransactionMessage): TTransactionMessage {
152152
const index = getSetComputeUnitLimitInstructionIndex(message);
@@ -158,7 +158,7 @@ function removeComputeUnitLimitInstruction<
158158
}
159159

160160
export function getSetComputeUnitLimitInstructionIndex(
161-
transactionMessage: BaseTransactionMessage
161+
transactionMessage: TransactionMessage
162162
) {
163163
return transactionMessage.instructions.findIndex((ix) => {
164164
return (

clients/js/src/generated/accounts/buffer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export type BufferArgs = {
6868
data: ReadonlyUint8Array;
6969
};
7070

71+
/** Gets the encoder for {@link BufferArgs} account data. */
7172
export function getBufferEncoder(): Encoder<BufferArgs> {
7273
return transformEncoder(
7374
getStructEncoder([
@@ -94,6 +95,7 @@ export function getBufferEncoder(): Encoder<BufferArgs> {
9495
);
9596
}
9697

98+
/** Gets the decoder for {@link Buffer} account data. */
9799
export function getBufferDecoder(): Decoder<Buffer> {
98100
return getStructDecoder([
99101
['discriminator', getAccountDiscriminatorDecoder()],
@@ -117,6 +119,7 @@ export function getBufferDecoder(): Decoder<Buffer> {
117119
]);
118120
}
119121

122+
/** Gets the codec for {@link Buffer} account data. */
120123
export function getBufferCodec(): Codec<BufferArgs, Buffer> {
121124
return combineCodec(getBufferEncoder(), getBufferDecoder());
122125
}

clients/js/src/generated/accounts/metadata.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export type MetadataArgs = {
9898
data: ReadonlyUint8Array;
9999
};
100100

101+
/** Gets the encoder for {@link MetadataArgs} account data. */
101102
export function getMetadataEncoder(): Encoder<MetadataArgs> {
102103
return transformEncoder(
103104
getStructEncoder([
@@ -124,6 +125,7 @@ export function getMetadataEncoder(): Encoder<MetadataArgs> {
124125
);
125126
}
126127

128+
/** Gets the decoder for {@link Metadata} account data. */
127129
export function getMetadataDecoder(): Decoder<Metadata> {
128130
return getStructDecoder([
129131
['discriminator', getAccountDiscriminatorDecoder()],
@@ -147,6 +149,7 @@ export function getMetadataDecoder(): Decoder<Metadata> {
147149
]);
148150
}
149151

152+
/** Gets the codec for {@link Metadata} account data. */
150153
export function getMetadataCodec(): Codec<MetadataArgs, Metadata> {
151154
return combineCodec(getMetadataEncoder(), getMetadataDecoder());
152155
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ export type AllocateInstruction<
5454
TAccountAuthority extends string | AccountMeta<string> = string,
5555
TAccountProgram extends string | AccountMeta<string> = string,
5656
TAccountProgramData extends string | AccountMeta<string> = string,
57-
TAccountSystem extends
58-
| string
59-
| AccountMeta<string> = '11111111111111111111111111111111',
57+
TAccountSystem extends string | AccountMeta<string> =
58+
'11111111111111111111111111111111',
6059
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
6160
> = Instruction<TProgram> &
6261
InstructionWithData<ReadonlyUint8Array> &

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ export type InitializeInstruction<
7878
TAccountAuthority extends string | AccountMeta<string> = string,
7979
TAccountProgram extends string | AccountMeta<string> = string,
8080
TAccountProgramData extends string | AccountMeta<string> = string,
81-
TAccountSystem extends
82-
| string
83-
| AccountMeta<string> = '11111111111111111111111111111111',
81+
TAccountSystem extends string | AccountMeta<string> =
82+
'11111111111111111111111111111111',
8483
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
8584
> = Instruction<TProgram> &
8685
InstructionWithData<ReadonlyUint8Array> &

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ export type TrimInstruction<
4444
TAccountProgram extends string | AccountMeta<string> = string,
4545
TAccountProgramData extends string | AccountMeta<string> = string,
4646
TAccountDestination extends string | AccountMeta<string> = string,
47-
TAccountRent extends
48-
| string
49-
| AccountMeta<string> = 'SysvarRent111111111111111111111111111111111',
47+
TAccountRent extends string | AccountMeta<string> =
48+
'SysvarRent111111111111111111111111111111111',
5049
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
5150
> = Instruction<TProgram> &
5251
InstructionWithData<ReadonlyUint8Array> &

clients/js/src/generated/programs/programMetadata.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@
77
*/
88

99
import {
10+
assertIsInstructionWithAccounts,
1011
containsBytes,
1112
getU8Encoder,
1213
type Address,
14+
type Instruction,
15+
type InstructionWithData,
1316
type ReadonlyUint8Array,
1417
} from '@solana/kit';
1518
import {
19+
parseAllocateInstruction,
20+
parseCloseInstruction,
21+
parseExtendInstruction,
22+
parseInitializeInstruction,
23+
parseSetAuthorityInstruction,
24+
parseSetDataInstruction,
25+
parseSetImmutableInstruction,
26+
parseTrimInstruction,
27+
parseWriteInstruction,
1628
type ParsedAllocateInstruction,
1729
type ParsedCloseInstruction,
1830
type ParsedExtendInstruction,
@@ -110,3 +122,78 @@ export type ParsedProgramMetadataInstruction<
110122
| ({
111123
instructionType: ProgramMetadataInstruction.Extend;
112124
} & ParsedExtendInstruction<TProgram>);
125+
126+
export function parseProgramMetadataInstruction<TProgram extends string>(
127+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
128+
): ParsedProgramMetadataInstruction<TProgram> {
129+
const instructionType = identifyProgramMetadataInstruction(instruction);
130+
switch (instructionType) {
131+
case ProgramMetadataInstruction.Write: {
132+
assertIsInstructionWithAccounts(instruction);
133+
return {
134+
instructionType: ProgramMetadataInstruction.Write,
135+
...parseWriteInstruction(instruction),
136+
};
137+
}
138+
case ProgramMetadataInstruction.Initialize: {
139+
assertIsInstructionWithAccounts(instruction);
140+
return {
141+
instructionType: ProgramMetadataInstruction.Initialize,
142+
...parseInitializeInstruction(instruction),
143+
};
144+
}
145+
case ProgramMetadataInstruction.SetAuthority: {
146+
assertIsInstructionWithAccounts(instruction);
147+
return {
148+
instructionType: ProgramMetadataInstruction.SetAuthority,
149+
...parseSetAuthorityInstruction(instruction),
150+
};
151+
}
152+
case ProgramMetadataInstruction.SetData: {
153+
assertIsInstructionWithAccounts(instruction);
154+
return {
155+
instructionType: ProgramMetadataInstruction.SetData,
156+
...parseSetDataInstruction(instruction),
157+
};
158+
}
159+
case ProgramMetadataInstruction.SetImmutable: {
160+
assertIsInstructionWithAccounts(instruction);
161+
return {
162+
instructionType: ProgramMetadataInstruction.SetImmutable,
163+
...parseSetImmutableInstruction(instruction),
164+
};
165+
}
166+
case ProgramMetadataInstruction.Trim: {
167+
assertIsInstructionWithAccounts(instruction);
168+
return {
169+
instructionType: ProgramMetadataInstruction.Trim,
170+
...parseTrimInstruction(instruction),
171+
};
172+
}
173+
case ProgramMetadataInstruction.Close: {
174+
assertIsInstructionWithAccounts(instruction);
175+
return {
176+
instructionType: ProgramMetadataInstruction.Close,
177+
...parseCloseInstruction(instruction),
178+
};
179+
}
180+
case ProgramMetadataInstruction.Allocate: {
181+
assertIsInstructionWithAccounts(instruction);
182+
return {
183+
instructionType: ProgramMetadataInstruction.Allocate,
184+
...parseAllocateInstruction(instruction),
185+
};
186+
}
187+
case ProgramMetadataInstruction.Extend: {
188+
assertIsInstructionWithAccounts(instruction);
189+
return {
190+
instructionType: ProgramMetadataInstruction.Extend,
191+
...parseExtendInstruction(instruction),
192+
};
193+
}
194+
default:
195+
throw new Error(
196+
`Unrecognized instruction type: ${instructionType as string}`
197+
);
198+
}
199+
}

0 commit comments

Comments
 (0)