Skip to content

Commit 7c4bc45

Browse files
authored
Update codama + js client deps (#262)
* Update codama + js client deps * Deps + review updates * Add changesets
1 parent a4751b7 commit 7c4bc45

File tree

18 files changed

+738
-1537
lines changed

18 files changed

+738
-1537
lines changed

.changeset/polite-women-dream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solana-program/token-wrap": patch
3+
---
4+
5+
Update CreateMint helper to support token-2022 extension sizing

.changeset/tiny-dancers-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solana-program/token-wrap": minor
3+
---
4+
5+
Bump deps to Kit 3.0

clients/js/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@
4242
"url": "https://github.com/solana-program/token-wrap/issues"
4343
},
4444
"peerDependencies": {
45-
"@solana/kit": "^2.2.1"
45+
"@solana/kit": "^3.0.1"
4646
},
4747
"dependencies": {
48-
"@solana-program/system": "^0.7.0",
48+
"@solana-program/system": "^0.8.0",
4949
"@solana-program/token": "^0.5.1",
5050
"@solana-program/token-2022": "^0.4.2",
5151
"@solana/accounts": "^3.0.1",
52-
"@solana/rpc-types": "^2.3.0"
52+
"@solana/rpc-types": "^3.0.1"
5353
},
5454
"devDependencies": {
5555
"@eslint/js": "^9.34.0",
56-
"@solana/kit": "^2.2.1",
56+
"@solana/kit": "^3.0.1",
5757
"@tsconfig/strictest": "^2.0.5",
5858
"@types/node": "^24.3.0",
5959
"eslint": "^9.34.0",
@@ -65,5 +65,5 @@
6565
"typescript": "^5.9.2",
6666
"typescript-eslint": "^8.41.0"
6767
},
68-
"packageManager": "pnpm@9.1.0"
68+
"packageManager": "pnpm@10.15.0"
6969
}

clients/js/src/create-mint.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {
33
fetchEncodedAccount,
44
GetAccountInfoApi,
55
GetMinimumBalanceForRentExemptionApi,
6-
IInstruction,
6+
Instruction,
77
KeyPairSigner,
88
Rpc,
99
} from '@solana/kit';
10-
import { getMintSize } from '@solana-program/token-2022';
10+
import { getMintSize, TOKEN_2022_PROGRAM_ADDRESS, extension } from '@solana-program/token-2022';
1111
import { getTransferSolInstruction } from '@solana-program/system';
1212
import {
1313
findBackpointerPda,
@@ -29,9 +29,25 @@ export interface CreateMintResult {
2929
backpointer: Address;
3030
fundedWrappedMintLamports: bigint;
3131
fundedBackpointerLamports: bigint;
32-
ixs: IInstruction[];
32+
ixs: Instruction[];
3333
}
3434

35+
// The on-chain program adds these two extensions by default. We must account for
36+
// their size here. The `getMintSize` function from the library expects extension
37+
// data objects, but since the size of these extensions is fixed, we can pass
38+
// dummy/default values.
39+
const DEFAULT_EXTENSIONS = [
40+
extension('ConfidentialTransferMint', {
41+
autoApproveNewAccounts: true,
42+
authority: null,
43+
auditorElgamalPubkey: null,
44+
}),
45+
extension('MetadataPointer', {
46+
authority: null,
47+
metadataAddress: null,
48+
}),
49+
];
50+
3551
export async function createMint({
3652
rpc,
3753
unwrappedMint,
@@ -45,12 +61,16 @@ export async function createMint({
4561
});
4662
const [backpointer] = await findBackpointerPda({ wrappedMint });
4763

48-
const instructions: IInstruction[] = [];
64+
const instructions: Instruction[] = [];
4965

5066
// Fund wrapped mint account if needed
5167
let fundedWrappedMintLamports = 0n;
5268

53-
const mintSize = BigInt(getMintSize());
69+
let mintSize = BigInt(getMintSize());
70+
if (wrappedTokenProgram === TOKEN_2022_PROGRAM_ADDRESS) {
71+
mintSize = BigInt(getMintSize(DEFAULT_EXTENSIONS));
72+
}
73+
5474
const [wrappedMintAccount, wrappedMintRent] = await Promise.all([
5575
fetchEncodedAccount(rpc, wrappedMint),
5676
rpc.getMinimumBalanceForRentExemption(mintSize).send(),

clients/js/src/examples/multisig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
address,
33
appendTransactionMessageInstructions,
4+
assertIsSendableTransaction,
45
createKeyPairSignerFromBytes,
56
createNoopSigner,
67
createSolanaRpc,
@@ -78,6 +79,7 @@ async function main() {
7879
tx => appendTransactionMessageInstructions(createMintHelper.ixs, tx),
7980
tx => signTransactionMessageWithSigners(tx),
8081
);
82+
assertIsSendableTransaction(createMintTx);
8183
await sendAndConfirm(createMintTx, { commitment: 'confirmed' });
8284
const createMintSignature = getSignatureFromTransaction(createMintTx);
8385

@@ -105,6 +107,7 @@ async function main() {
105107
tx => appendTransactionMessageInstructions(createEscrowHelper.ixs, tx),
106108
tx => signTransactionMessageWithSigners(tx),
107109
);
110+
assertIsSendableTransaction(createEscrowTx);
108111
await sendAndConfirm(createEscrowTx, { commitment: 'confirmed' });
109112
const createEscrowSignature = getSignatureFromTransaction(createEscrowTx);
110113

@@ -134,6 +137,7 @@ async function main() {
134137
tx => appendTransactionMessageInstructions(recipientTokenAccountHelper.ixs, tx),
135138
tx => signTransactionMessageWithSigners(tx),
136139
);
140+
assertIsSendableTransaction(recipientTokenAccountTx);
137141
await sendAndConfirm(recipientTokenAccountTx, { commitment: 'confirmed' });
138142

139143
const unwrappedTokenProgram = await getOwnerFromAccount(rpc, UNWRAPPED_TOKEN_ACCOUNT);

clients/js/src/examples/single-signer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
address,
33
appendTransactionMessageInstructions,
4+
assertIsSendableTransaction,
45
createKeyPairSignerFromBytes,
56
createSolanaRpc,
67
createSolanaRpcSubscriptions,
@@ -56,6 +57,7 @@ async function main() {
5657
tx => appendTransactionMessageInstructions(createMintHelper.ixs, tx),
5758
tx => signTransactionMessageWithSigners(tx),
5859
);
60+
assertIsSendableTransaction(createMintTx);
5961
await sendAndConfirm(createMintTx, { commitment: 'confirmed' });
6062
const createMintSignature = getSignatureFromTransaction(createMintTx);
6163

@@ -83,6 +85,7 @@ async function main() {
8385
tx => appendTransactionMessageInstructions(createEscrowHelper.ixs, tx),
8486
tx => signTransactionMessageWithSigners(tx),
8587
);
88+
assertIsSendableTransaction(createEscrowTx);
8689
await sendAndConfirm(createEscrowTx, { commitment: 'confirmed' });
8790
const createEscrowSignature = getSignatureFromTransaction(createEscrowTx);
8891

@@ -112,6 +115,7 @@ async function main() {
112115
tx => appendTransactionMessageInstructions(recipientTokenAccountHelper.ixs, tx),
113116
tx => signTransactionMessageWithSigners(tx),
114117
);
118+
assertIsSendableTransaction(recipientTokenAccountTx);
115119
await sendAndConfirm(recipientTokenAccountTx, { commitment: 'confirmed' });
116120

117121
// Execute wrap
@@ -132,6 +136,7 @@ async function main() {
132136
tx => appendTransactionMessageInstructions(wrapHelper.ixs, tx),
133137
tx => signTransactionMessageWithSigners(tx),
134138
);
139+
assertIsSendableTransaction(wrapTx);
135140
await sendAndConfirm(wrapTx, { commitment: 'confirmed' });
136141
const wrapSignature = getSignatureFromTransaction(wrapTx);
137142

@@ -158,6 +163,7 @@ async function main() {
158163
tx => appendTransactionMessageInstructions(unwrapHelper.ixs, tx),
159164
tx => signTransactionMessageWithSigners(tx),
160165
);
166+
assertIsSendableTransaction(unwrapTx);
161167
await sendAndConfirm(unwrapTx, { commitment: 'confirmed' });
162168
const unwrapSignature = getSignatureFromTransaction(unwrapTx);
163169

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import {
1919
getStructEncoder,
2020
type Account,
2121
type Address,
22-
type Codec,
23-
type Decoder,
2422
type EncodedAccount,
25-
type Encoder,
2623
type FetchAccountConfig,
2724
type FetchAccountsConfig,
25+
type FixedSizeCodec,
26+
type FixedSizeDecoder,
27+
type FixedSizeEncoder,
2828
type MaybeAccount,
2929
type MaybeEncodedAccount,
3030
} from '@solana/kit';
@@ -34,15 +34,18 @@ export type Backpointer = { unwrappedMint: Address };
3434

3535
export type BackpointerArgs = Backpointer;
3636

37-
export function getBackpointerEncoder(): Encoder<BackpointerArgs> {
37+
export function getBackpointerEncoder(): FixedSizeEncoder<BackpointerArgs> {
3838
return getStructEncoder([['unwrappedMint', getAddressEncoder()]]);
3939
}
4040

41-
export function getBackpointerDecoder(): Decoder<Backpointer> {
41+
export function getBackpointerDecoder(): FixedSizeDecoder<Backpointer> {
4242
return getStructDecoder([['unwrappedMint', getAddressDecoder()]]);
4343
}
4444

45-
export function getBackpointerCodec(): Codec<BackpointerArgs, Backpointer> {
45+
export function getBackpointerCodec(): FixedSizeCodec<
46+
BackpointerArgs,
47+
Backpointer
48+
> {
4649
return combineCodec(getBackpointerEncoder(), getBackpointerDecoder());
4750
}
4851

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

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ import {
1313
getU8Decoder,
1414
getU8Encoder,
1515
transformEncoder,
16+
type AccountMeta,
1617
type Address,
17-
type Codec,
18-
type Decoder,
19-
type Encoder,
20-
type IAccountMeta,
21-
type IInstruction,
22-
type IInstructionWithAccounts,
23-
type IInstructionWithData,
18+
type FixedSizeCodec,
19+
type FixedSizeDecoder,
20+
type FixedSizeEncoder,
21+
type Instruction,
22+
type InstructionWithAccounts,
23+
type InstructionWithData,
2424
type ReadonlyAccount,
25+
type ReadonlyUint8Array,
2526
type WritableAccount,
2627
} from '@solana/kit';
2728
import { TOKEN_WRAP_PROGRAM_ADDRESS } from '../programs';
@@ -35,18 +36,18 @@ export function getCloseStuckEscrowDiscriminatorBytes() {
3536

3637
export type CloseStuckEscrowInstruction<
3738
TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,
38-
TAccountEscrow extends string | IAccountMeta<string> = string,
39-
TAccountDestination extends string | IAccountMeta<string> = string,
40-
TAccountUnwrappedMint extends string | IAccountMeta<string> = string,
41-
TAccountWrappedMint extends string | IAccountMeta<string> = string,
42-
TAccountWrappedMintAuthority extends string | IAccountMeta<string> = string,
39+
TAccountEscrow extends string | AccountMeta<string> = string,
40+
TAccountDestination extends string | AccountMeta<string> = string,
41+
TAccountUnwrappedMint extends string | AccountMeta<string> = string,
42+
TAccountWrappedMint extends string | AccountMeta<string> = string,
43+
TAccountWrappedMintAuthority extends string | AccountMeta<string> = string,
4344
TAccountToken2022Program extends
4445
| string
45-
| IAccountMeta<string> = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
46-
TRemainingAccounts extends readonly IAccountMeta<string>[] = [],
47-
> = IInstruction<TProgram> &
48-
IInstructionWithData<Uint8Array> &
49-
IInstructionWithAccounts<
46+
| AccountMeta<string> = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
47+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
48+
> = Instruction<TProgram> &
49+
InstructionWithData<ReadonlyUint8Array> &
50+
InstructionWithAccounts<
5051
[
5152
TAccountEscrow extends string
5253
? WritableAccount<TAccountEscrow>
@@ -74,18 +75,18 @@ export type CloseStuckEscrowInstructionData = { discriminator: number };
7475

7576
export type CloseStuckEscrowInstructionDataArgs = {};
7677

77-
export function getCloseStuckEscrowInstructionDataEncoder(): Encoder<CloseStuckEscrowInstructionDataArgs> {
78+
export function getCloseStuckEscrowInstructionDataEncoder(): FixedSizeEncoder<CloseStuckEscrowInstructionDataArgs> {
7879
return transformEncoder(
7980
getStructEncoder([['discriminator', getU8Encoder()]]),
8081
(value) => ({ ...value, discriminator: CLOSE_STUCK_ESCROW_DISCRIMINATOR })
8182
);
8283
}
8384

84-
export function getCloseStuckEscrowInstructionDataDecoder(): Decoder<CloseStuckEscrowInstructionData> {
85+
export function getCloseStuckEscrowInstructionDataDecoder(): FixedSizeDecoder<CloseStuckEscrowInstructionData> {
8586
return getStructDecoder([['discriminator', getU8Decoder()]]);
8687
}
8788

88-
export function getCloseStuckEscrowInstructionDataCodec(): Codec<
89+
export function getCloseStuckEscrowInstructionDataCodec(): FixedSizeCodec<
8990
CloseStuckEscrowInstructionDataArgs,
9091
CloseStuckEscrowInstructionData
9192
> {
@@ -200,7 +201,7 @@ export function getCloseStuckEscrowInstruction<
200201

201202
export type ParsedCloseStuckEscrowInstruction<
202203
TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,
203-
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
204+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
204205
> = {
205206
programAddress: Address<TProgram>;
206207
accounts: {
@@ -222,19 +223,19 @@ export type ParsedCloseStuckEscrowInstruction<
222223

223224
export function parseCloseStuckEscrowInstruction<
224225
TProgram extends string,
225-
TAccountMetas extends readonly IAccountMeta[],
226+
TAccountMetas extends readonly AccountMeta[],
226227
>(
227-
instruction: IInstruction<TProgram> &
228-
IInstructionWithAccounts<TAccountMetas> &
229-
IInstructionWithData<Uint8Array>
228+
instruction: Instruction<TProgram> &
229+
InstructionWithAccounts<TAccountMetas> &
230+
InstructionWithData<ReadonlyUint8Array>
230231
): ParsedCloseStuckEscrowInstruction<TProgram, TAccountMetas> {
231232
if (instruction.accounts.length < 6) {
232233
// TODO: Coded error.
233234
throw new Error('Not enough accounts');
234235
}
235236
let accountIndex = 0;
236237
const getNextAccount = () => {
237-
const accountMeta = instruction.accounts![accountIndex]!;
238+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
238239
accountIndex += 1;
239240
return accountMeta;
240241
};

0 commit comments

Comments
 (0)