Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"prepublishOnly": "pnpm build"
},
"dependencies": {
"@solana-program/system": "^0.14.0"
"@solana-program/system": "^0.15.0"
},
"devDependencies": {
"@solana-config/oxc": "^0.1.1",
"@solana/kit": "^8.0.0",
"@solana/kit": "^8.3.0",
"@solana/kit-plugin-litesvm": "^0.18.0",
"@solana/kit-plugin-signer": "^0.18.0",
"@types/node": "^24",
Expand All @@ -62,7 +62,7 @@
"vitest": "^4.0.15"
},
"peerDependencies": {
"@solana/kit": "^8.0.0"
"@solana/kit": "^8.3.0"
},
"devEngines": {
"runtime": {
Expand Down
2,350 changes: 748 additions & 1,602 deletions clients/js/pnpm-lock.yaml

Large diffs are not rendered by default.

30 changes: 22 additions & 8 deletions clients/js/src/generated/instructions/amountToUiAmount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ import {
type ReadonlyAccount,
type ReadonlyUint8Array,
} from '@solana/kit';
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
import {
getAccountMetaFactory,
type InstructionAccountInput,
type InstructionAccountInputAddress,
type ResolvedInstructionAccount,
type ResolvedInstructionAccountMeta,
} from '@solana/kit/program-client-core';
import { TOKEN_PROGRAM_ADDRESS } from '../programs';

export const AMOUNT_TO_UI_AMOUNT_DISCRIMINATOR = 23;
Expand Down Expand Up @@ -82,35 +88,43 @@ export function getAmountToUiAmountInstructionDataCodec(): FixedSizeCodec<
return combineCodec(getAmountToUiAmountInstructionDataEncoder(), getAmountToUiAmountInstructionDataDecoder());
}

export type AmountToUiAmountInput<TAccountMint extends string = string> = {
export type AmountToUiAmountInput<TAccountMint extends InstructionAccountInput = InstructionAccountInput> = {
/** The mint to calculate for. */
mint: Address<TAccountMint>;
mint: TAccountMint;
amount: AmountToUiAmountInstructionDataArgs['amount'];
};

export function getAmountToUiAmountInstruction<
TAccountMint extends string,
TAccountMint extends InstructionAccountInput,
TProgramAddress extends Address = typeof TOKEN_PROGRAM_ADDRESS,
>(
input: AmountToUiAmountInput<TAccountMint>,
config?: { programAddress?: TProgramAddress },
): AmountToUiAmountInstruction<TProgramAddress, TAccountMint> {
): AmountToUiAmountInstruction<
TProgramAddress,
ResolvedInstructionAccountMeta<TAccountMint, InstructionAccountInputAddress<TAccountMint>>
> {
// Program address.
const programAddress = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;

// Account meta helper.
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');

// Original accounts.
const originalAccounts = { mint: { value: input.mint ?? null, isWritable: false } };
const originalAccounts = { mint: { value: input.mint ?? null, isSigner: false, isWritable: false } };
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;

// Original args.
const args = { ...input };

const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [getAccountMeta('mint', accounts.mint)],
data: getAmountToUiAmountInstructionDataEncoder().encode(args as AmountToUiAmountInstructionDataArgs),
programAddress,
} as AmountToUiAmountInstruction<TProgramAddress, TAccountMint>);
} as AmountToUiAmountInstruction<
TProgramAddress,
ResolvedInstructionAccountMeta<TAccountMint, InstructionAccountInputAddress<TAccountMint>>
>);
}

export type ParsedAmountToUiAmountInstruction<
Expand Down
80 changes: 48 additions & 32 deletions clients/js/src/generated/instructions/approve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import {
AccountRole,
combineCodec,
getStructDecoder,
getStructEncoder,
Expand All @@ -30,10 +29,17 @@ import {
type ReadonlyAccount,
type ReadonlySignerAccount,
type ReadonlyUint8Array,
type TransactionSigner,
type WritableAccount,
} from '@solana/kit';
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
import {
getAccountMetaFactory,
getNonNullResolvedInstructionInput,
type InstructionAccountInput,
type InstructionAccountInputAddress,
type InstructionSignerInput,
type ResolvedInstructionAccount,
type ResolvedInstructionAccountMeta,
} from '@solana/kit/program-client-core';
import { TOKEN_PROGRAM_ADDRESS } from '../programs';

export const APPROVE_DISCRIMINATOR = 4;
Expand Down Expand Up @@ -92,58 +98,65 @@ export function getApproveInstructionDataCodec(): FixedSizeCodec<ApproveInstruct
}

export type ApproveInput<
TAccountSource extends string = string,
TAccountDelegate extends string = string,
TAccountOwner extends string = string,
TAccountSource extends InstructionAccountInput = InstructionAccountInput,
TAccountDelegate extends InstructionAccountInput = InstructionAccountInput,
TAccountOwner extends InstructionAccountInput | InstructionSignerInput =
InstructionAccountInput | InstructionSignerInput,
> = {
/** The source account. */
source: Address<TAccountSource>;
source: TAccountSource;
/** The delegate. */
delegate: Address<TAccountDelegate>;
delegate: TAccountDelegate;
/** The source account owner or its multisignature account. */
owner: Address<TAccountOwner> | TransactionSigner<TAccountOwner>;
owner: TAccountOwner;
amount: ApproveInstructionDataArgs['amount'];
multiSigners?: Array<TransactionSigner>;
multiSigners?: Array<InstructionSignerInput>;
};

export function getApproveInstruction<
TAccountSource extends string,
TAccountDelegate extends string,
TAccountOwner extends string,
TAccountSource extends InstructionAccountInput,
TAccountDelegate extends InstructionAccountInput,
TAccountOwner extends InstructionAccountInput | InstructionSignerInput,
TProgramAddress extends Address = typeof TOKEN_PROGRAM_ADDRESS,
>(
input: ApproveInput<TAccountSource, TAccountDelegate, TAccountOwner>,
config?: { programAddress?: TProgramAddress },
): ApproveInstruction<
TProgramAddress,
TAccountSource,
TAccountDelegate,
(typeof input)['owner'] extends TransactionSigner<TAccountOwner>
? ReadonlySignerAccount<TAccountOwner> & AccountSignerMeta<TAccountOwner>
: TAccountOwner
ResolvedInstructionAccountMeta<TAccountSource, InstructionAccountInputAddress<TAccountSource>>,
ResolvedInstructionAccountMeta<TAccountDelegate, InstructionAccountInputAddress<TAccountDelegate>>,
ResolvedInstructionAccountMeta<
TAccountOwner,
InstructionAccountInputAddress<TAccountOwner>,
ReadonlySignerAccount<InstructionAccountInputAddress<TAccountOwner>> &
AccountSignerMeta<InstructionAccountInputAddress<TAccountOwner>>
>
> {
// Program address.
const programAddress = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;

// Account meta helper.
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');

// Original accounts.
const originalAccounts = {
source: { value: input.source ?? null, isWritable: true },
delegate: { value: input.delegate ?? null, isWritable: false },
owner: { value: input.owner ?? null, isWritable: false },
source: { value: input.source ?? null, isSigner: false, isWritable: true },
delegate: { value: input.delegate ?? null, isSigner: false, isWritable: false },
owner: { value: input.owner ?? null, isSigner: 'either', isWritable: false },
};
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;

// Original args.
const args = { ...input };

// Remaining accounts.
const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map(signer => ({
address: signer.address,
role: AccountRole.READONLY_SIGNER,
signer,
}));
const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map(value =>
getNonNullResolvedInstructionInput(
'multiSigners',
getAccountMeta('multiSigners', { value, isSigner: true, isWritable: false }),
),
);

const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta('source', accounts.source),
Expand All @@ -155,11 +168,14 @@ export function getApproveInstruction<
programAddress,
} as ApproveInstruction<
TProgramAddress,
TAccountSource,
TAccountDelegate,
(typeof input)['owner'] extends TransactionSigner<TAccountOwner>
? ReadonlySignerAccount<TAccountOwner> & AccountSignerMeta<TAccountOwner>
: TAccountOwner
ResolvedInstructionAccountMeta<TAccountSource, InstructionAccountInputAddress<TAccountSource>>,
ResolvedInstructionAccountMeta<TAccountDelegate, InstructionAccountInputAddress<TAccountDelegate>>,
ResolvedInstructionAccountMeta<
TAccountOwner,
InstructionAccountInputAddress<TAccountOwner>,
ReadonlySignerAccount<InstructionAccountInputAddress<TAccountOwner>> &
AccountSignerMeta<InstructionAccountInputAddress<TAccountOwner>>
>
>);
}

Expand Down
92 changes: 54 additions & 38 deletions clients/js/src/generated/instructions/approveChecked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import {
AccountRole,
combineCodec,
getStructDecoder,
getStructEncoder,
Expand All @@ -30,10 +29,17 @@ import {
type ReadonlyAccount,
type ReadonlySignerAccount,
type ReadonlyUint8Array,
type TransactionSigner,
type WritableAccount,
} from '@solana/kit';
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
import {
getAccountMetaFactory,
getNonNullResolvedInstructionInput,
type InstructionAccountInput,
type InstructionAccountInputAddress,
type InstructionSignerInput,
type ResolvedInstructionAccount,
type ResolvedInstructionAccountMeta,
} from '@solana/kit/program-client-core';
import { TOKEN_PROGRAM_ADDRESS } from '../programs';

export const APPROVE_CHECKED_DISCRIMINATOR = 13;
Expand Down Expand Up @@ -103,65 +109,72 @@ export function getApproveCheckedInstructionDataCodec(): FixedSizeCodec<
}

export type ApproveCheckedInput<
TAccountSource extends string = string,
TAccountMint extends string = string,
TAccountDelegate extends string = string,
TAccountOwner extends string = string,
TAccountSource extends InstructionAccountInput = InstructionAccountInput,
TAccountMint extends InstructionAccountInput = InstructionAccountInput,
TAccountDelegate extends InstructionAccountInput = InstructionAccountInput,
TAccountOwner extends InstructionAccountInput | InstructionSignerInput =
InstructionAccountInput | InstructionSignerInput,
> = {
/** The source account. */
source: Address<TAccountSource>;
source: TAccountSource;
/** The token mint. */
mint: Address<TAccountMint>;
mint: TAccountMint;
/** The delegate. */
delegate: Address<TAccountDelegate>;
delegate: TAccountDelegate;
/** The source account owner or its multisignature account. */
owner: Address<TAccountOwner> | TransactionSigner<TAccountOwner>;
owner: TAccountOwner;
amount: ApproveCheckedInstructionDataArgs['amount'];
decimals: ApproveCheckedInstructionDataArgs['decimals'];
multiSigners?: Array<TransactionSigner>;
multiSigners?: Array<InstructionSignerInput>;
};

export function getApproveCheckedInstruction<
TAccountSource extends string,
TAccountMint extends string,
TAccountDelegate extends string,
TAccountOwner extends string,
TAccountSource extends InstructionAccountInput,
TAccountMint extends InstructionAccountInput,
TAccountDelegate extends InstructionAccountInput,
TAccountOwner extends InstructionAccountInput | InstructionSignerInput,
TProgramAddress extends Address = typeof TOKEN_PROGRAM_ADDRESS,
>(
input: ApproveCheckedInput<TAccountSource, TAccountMint, TAccountDelegate, TAccountOwner>,
config?: { programAddress?: TProgramAddress },
): ApproveCheckedInstruction<
TProgramAddress,
TAccountSource,
TAccountMint,
TAccountDelegate,
(typeof input)['owner'] extends TransactionSigner<TAccountOwner>
? ReadonlySignerAccount<TAccountOwner> & AccountSignerMeta<TAccountOwner>
: TAccountOwner
ResolvedInstructionAccountMeta<TAccountSource, InstructionAccountInputAddress<TAccountSource>>,
ResolvedInstructionAccountMeta<TAccountMint, InstructionAccountInputAddress<TAccountMint>>,
ResolvedInstructionAccountMeta<TAccountDelegate, InstructionAccountInputAddress<TAccountDelegate>>,
ResolvedInstructionAccountMeta<
TAccountOwner,
InstructionAccountInputAddress<TAccountOwner>,
ReadonlySignerAccount<InstructionAccountInputAddress<TAccountOwner>> &
AccountSignerMeta<InstructionAccountInputAddress<TAccountOwner>>
>
> {
// Program address.
const programAddress = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;

// Account meta helper.
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');

// Original accounts.
const originalAccounts = {
source: { value: input.source ?? null, isWritable: true },
mint: { value: input.mint ?? null, isWritable: false },
delegate: { value: input.delegate ?? null, isWritable: false },
owner: { value: input.owner ?? null, isWritable: false },
source: { value: input.source ?? null, isSigner: false, isWritable: true },
mint: { value: input.mint ?? null, isSigner: false, isWritable: false },
delegate: { value: input.delegate ?? null, isSigner: false, isWritable: false },
owner: { value: input.owner ?? null, isSigner: 'either', isWritable: false },
};
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;

// Original args.
const args = { ...input };

// Remaining accounts.
const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map(signer => ({
address: signer.address,
role: AccountRole.READONLY_SIGNER,
signer,
}));
const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map(value =>
getNonNullResolvedInstructionInput(
'multiSigners',
getAccountMeta('multiSigners', { value, isSigner: true, isWritable: false }),
),
);

const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta('source', accounts.source),
Expand All @@ -174,12 +187,15 @@ export function getApproveCheckedInstruction<
programAddress,
} as ApproveCheckedInstruction<
TProgramAddress,
TAccountSource,
TAccountMint,
TAccountDelegate,
(typeof input)['owner'] extends TransactionSigner<TAccountOwner>
? ReadonlySignerAccount<TAccountOwner> & AccountSignerMeta<TAccountOwner>
: TAccountOwner
ResolvedInstructionAccountMeta<TAccountSource, InstructionAccountInputAddress<TAccountSource>>,
ResolvedInstructionAccountMeta<TAccountMint, InstructionAccountInputAddress<TAccountMint>>,
ResolvedInstructionAccountMeta<TAccountDelegate, InstructionAccountInputAddress<TAccountDelegate>>,
ResolvedInstructionAccountMeta<
TAccountOwner,
InstructionAccountInputAddress<TAccountOwner>,
ReadonlySignerAccount<InstructionAccountInputAddress<TAccountOwner>> &
AccountSignerMeta<InstructionAccountInputAddress<TAccountOwner>>
>
>);
}

Expand Down
Loading
Loading