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
10 changes: 5 additions & 5 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
"prepublishOnly": "pnpm build"
},
"dependencies": {
"@solana-program/system": "^0.15.0"
"@solana-program/system": "^0.16.0"
},
"devDependencies": {
"@solana-config/oxc": "^0.1.1",
"@solana/kit": "^8.3.0",
"@solana/kit-plugin-litesvm": "^0.18.0",
"@solana/kit-plugin-signer": "^0.18.0",
"@solana/kit": "^8.5.0",
"@solana/kit-plugin-litesvm": "^0.19.0",
"@solana/kit-plugin-signer": "^0.19.0",
"@types/node": "^24",
"oxfmt": "^0.55.0",
"oxlint": "^1.70.0",
Expand All @@ -62,7 +62,7 @@
"vitest": "^4.0.15"
},
"peerDependencies": {
"@solana/kit": "^8.3.0"
"@solana/kit": "^8.5.0"
},
"devEngines": {
"runtime": {
Expand Down
1,594 changes: 797 additions & 797 deletions clients/js/pnpm-lock.yaml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions clients/js/src/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ export type BatchInstruction<

export function getBatchInstruction<TProgramAddress extends Address = typeof TOKEN_PROGRAM_ADDRESS>(
instructions: BatchableInstruction<TProgramAddress>[],
config?: { programAddress?: TProgramAddress },
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
): BatchInstruction<TProgramAddress, AccountMeta<string>[]> {
const programAddress = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;
const programAddressInput = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
const hasNestedBatchInstruction = instructions.some(
instruction => instruction.programAddress === programAddress && instruction.data?.[0] === BATCH_DISCRIMINATOR,
);
Expand Down
9 changes: 5 additions & 4 deletions clients/js/src/createMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getCreateAccountInstruction } from '@solana-program/system';
import {
Address,
ClientWithGetMinimumBalance,
HasAddress,
InstructionPlan,
OptionOrNullable,
sequentialInstructionPlan,
Expand All @@ -18,9 +19,9 @@ export type CreateMintInstructionPlanInput = {
/** Number of base 10 digits to the right of the decimal place. */
decimals: number;
/** The authority/multisignature to mint tokens. */
mintAuthority: Address;
mintAuthority: Address | HasAddress;
/** The optional freeze authority/multisignature of the mint. */
freezeAuthority?: OptionOrNullable<Address>;
freezeAuthority?: OptionOrNullable<Address | HasAddress>;
/**
* Optional override for the amount of Lamports to fund the mint account with.
* @default enough to make the account rent-exempt (currently 1,461,600 Lamports)
Expand All @@ -29,8 +30,8 @@ export type CreateMintInstructionPlanInput = {
};

export type CreateMintInstructionPlanConfig = {
systemProgram?: Address;
tokenProgram?: Address;
systemProgram?: Address | HasAddress;
tokenProgram?: Address | HasAddress;
};

export async function getCreateMintInstructionPlan(
Expand Down
25 changes: 17 additions & 8 deletions clients/js/src/generated/accounts/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
type FixedSizeCodec,
type FixedSizeDecoder,
type FixedSizeEncoder,
type HasAddress,
type MaybeAccount,
type MaybeEncodedAccount,
type Option,
Expand Down Expand Up @@ -64,15 +65,15 @@ export type MintArgs = {
* be provided during mint creation. If no mint authority is present
* then the mint has a fixed supply and no further tokens may be minted.
*/
mintAuthority: OptionOrNullable<Address>;
mintAuthority: OptionOrNullable<Address | HasAddress>;
/** Total supply of tokens. */
supply: number | bigint;
/** Number of base 10 digits to the right of the decimal place. */
decimals: number;
/** Is `true` if this structure has been initialized. */
isInitialized: boolean;
/** Optional authority to freeze token accounts. */
freezeAuthority: OptionOrNullable<Address>;
freezeAuthority: OptionOrNullable<Address | HasAddress>;
};

/** Gets the encoder for {@link MintArgs} account data. */
Expand Down Expand Up @@ -116,7 +117,7 @@ export function decodeMint<TAddress extends string = string>(

export async function fetchMint<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
address: Address<TAddress> | HasAddress<TAddress>,
config?: FetchAccountConfig,
): Promise<Account<Mint, TAddress>> {
const maybeAccount = await fetchMaybeMint(rpc, address, config);
Expand All @@ -126,16 +127,20 @@ export async function fetchMint<TAddress extends string = string>(

export async function fetchMaybeMint<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
address: Address<TAddress> | HasAddress<TAddress>,
config?: FetchAccountConfig,
): Promise<MaybeAccount<Mint, TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
const maybeAccount = await fetchEncodedAccount(
rpc,
typeof address === 'string' ? address : address.address,
config,
);
return decodeMint(maybeAccount);
}

export async function fetchAllMint(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
addresses: Array<Address | HasAddress>,
config?: FetchAccountsConfig,
): Promise<Account<Mint>[]> {
const maybeAccounts = await fetchAllMaybeMint(rpc, addresses, config);
Expand All @@ -145,10 +150,14 @@ export async function fetchAllMint(

export async function fetchAllMaybeMint(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
addresses: Array<Address | HasAddress>,
config?: FetchAccountsConfig,
): Promise<MaybeAccount<Mint>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
const maybeAccounts = await fetchEncodedAccounts(
rpc,
addresses.map(a => (typeof a === 'string' ? a : a.address)),
config,
);
return maybeAccounts.map(maybeAccount => decodeMint(maybeAccount));
}

Expand Down
32 changes: 25 additions & 7 deletions clients/js/src/generated/accounts/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
type FixedSizeCodec,
type FixedSizeDecoder,
type FixedSizeEncoder,
type HasAddress,
type MaybeAccount,
type MaybeEncodedAccount,
} from '@solana/kit';
Expand All @@ -46,7 +47,16 @@ export type Multisig = {
signers: Array<Address>;
};

export type MultisigArgs = Multisig;
export type MultisigArgs = {
/** Number of signers required. */
m: number;
/** Number of valid signers. */
n: number;
/** Is `true` if this structure has been initialized. */
isInitialized: boolean;
/** Signer public keys. */
signers: Array<Address | HasAddress>;
};

/** Gets the encoder for {@link MultisigArgs} account data. */
export function getMultisigEncoder(): FixedSizeEncoder<MultisigArgs> {
Expand Down Expand Up @@ -87,7 +97,7 @@ export function decodeMultisig<TAddress extends string = string>(

export async function fetchMultisig<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
address: Address<TAddress> | HasAddress<TAddress>,
config?: FetchAccountConfig,
): Promise<Account<Multisig, TAddress>> {
const maybeAccount = await fetchMaybeMultisig(rpc, address, config);
Expand All @@ -97,16 +107,20 @@ export async function fetchMultisig<TAddress extends string = string>(

export async function fetchMaybeMultisig<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
address: Address<TAddress> | HasAddress<TAddress>,
config?: FetchAccountConfig,
): Promise<MaybeAccount<Multisig, TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
const maybeAccount = await fetchEncodedAccount(
rpc,
typeof address === 'string' ? address : address.address,
config,
);
return decodeMultisig(maybeAccount);
}

export async function fetchAllMultisig(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
addresses: Array<Address | HasAddress>,
config?: FetchAccountsConfig,
): Promise<Account<Multisig>[]> {
const maybeAccounts = await fetchAllMaybeMultisig(rpc, addresses, config);
Expand All @@ -116,10 +130,14 @@ export async function fetchAllMultisig(

export async function fetchAllMaybeMultisig(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
addresses: Array<Address | HasAddress>,
config?: FetchAccountsConfig,
): Promise<MaybeAccount<Multisig>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
const maybeAccounts = await fetchEncodedAccounts(
rpc,
addresses.map(a => (typeof a === 'string' ? a : a.address)),
config,
);
return maybeAccounts.map(maybeAccount => decodeMultisig(maybeAccount));
}

Expand Down
29 changes: 19 additions & 10 deletions clients/js/src/generated/accounts/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
type FixedSizeCodec,
type FixedSizeDecoder,
type FixedSizeEncoder,
type HasAddress,
type MaybeAccount,
type MaybeEncodedAccount,
type Option,
Expand Down Expand Up @@ -67,16 +68,16 @@ export type Token = {

export type TokenArgs = {
/** The mint associated with this account. */
mint: Address;
mint: Address | HasAddress;
/** The owner of this account. */
owner: Address;
owner: Address | HasAddress;
/** The amount of tokens this account holds. */
amount: number | bigint;
/**
* If `delegate` is `Some` then `delegated_amount` represents
* the amount authorized by the delegate.
*/
delegate: OptionOrNullable<Address>;
delegate: OptionOrNullable<Address | HasAddress>;
/** The account's state. */
state: AccountStateArgs;
/**
Expand All @@ -89,7 +90,7 @@ export type TokenArgs = {
/** The amount delegated. */
delegatedAmount: number | bigint;
/** Optional authority to close the account. */
closeAuthority: OptionOrNullable<Address>;
closeAuthority: OptionOrNullable<Address | HasAddress>;
};

/** Gets the encoder for {@link TokenArgs} account data. */
Expand Down Expand Up @@ -139,7 +140,7 @@ export function decodeToken<TAddress extends string = string>(

export async function fetchToken<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
address: Address<TAddress> | HasAddress<TAddress>,
config?: FetchAccountConfig,
): Promise<Account<Token, TAddress>> {
const maybeAccount = await fetchMaybeToken(rpc, address, config);
Expand All @@ -149,16 +150,20 @@ export async function fetchToken<TAddress extends string = string>(

export async function fetchMaybeToken<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
address: Address<TAddress> | HasAddress<TAddress>,
config?: FetchAccountConfig,
): Promise<MaybeAccount<Token, TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
const maybeAccount = await fetchEncodedAccount(
rpc,
typeof address === 'string' ? address : address.address,
config,
);
return decodeToken(maybeAccount);
}

export async function fetchAllToken(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
addresses: Array<Address | HasAddress>,
config?: FetchAccountsConfig,
): Promise<Account<Token>[]> {
const maybeAccounts = await fetchAllMaybeToken(rpc, addresses, config);
Expand All @@ -168,10 +173,14 @@ export async function fetchAllToken(

export async function fetchAllMaybeToken(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
addresses: Array<Address | HasAddress>,
config?: FetchAccountsConfig,
): Promise<MaybeAccount<Token>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
const maybeAccounts = await fetchEncodedAccounts(
rpc,
addresses.map(a => (typeof a === 'string' ? a : a.address)),
config,
);
return maybeAccounts.map(maybeAccount => decodeToken(maybeAccount));
}

Expand Down
6 changes: 5 additions & 1 deletion clients/js/src/generated/errors/associatedToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
isProgramError,
type Address,
type HasAddress,
type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
type SolanaError,
} from '@solana/kit';
Expand Down Expand Up @@ -38,7 +39,10 @@ export function isAssociatedTokenError<TProgramErrorCode extends AssociatedToken
error: unknown,
transactionMessage: { instructions: Record<number, { programAddress: Address }> },
code?: TProgramErrorCode,
config: { programAddress?: Address | HasAddress } = {},
): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> &
Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
return isProgramError<TProgramErrorCode>(error, transactionMessage, ASSOCIATED_TOKEN_PROGRAM_ADDRESS, code);
const programAddressInput = config.programAddress ?? ASSOCIATED_TOKEN_PROGRAM_ADDRESS;
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
return isProgramError<TProgramErrorCode>(error, transactionMessage, programAddress, code);
}
6 changes: 5 additions & 1 deletion clients/js/src/generated/errors/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
isProgramError,
type Address,
type HasAddress,
type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
type SolanaError,
} from '@solana/kit';
Expand Down Expand Up @@ -115,7 +116,10 @@ export function isTokenError<TProgramErrorCode extends TokenError>(
error: unknown,
transactionMessage: { instructions: Record<number, { programAddress: Address }> },
code?: TProgramErrorCode,
config: { programAddress?: Address | HasAddress } = {},
): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> &
Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
return isProgramError<TProgramErrorCode>(error, transactionMessage, TOKEN_PROGRAM_ADDRESS, code);
const programAddressInput = config.programAddress ?? TOKEN_PROGRAM_ADDRESS;
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
return isProgramError<TProgramErrorCode>(error, transactionMessage, programAddress, code);
}
5 changes: 3 additions & 2 deletions clients/js/src/generated/instructions/amountToUiAmount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ export function getAmountToUiAmountInstruction<
TProgramAddress extends Address = typeof TOKEN_PROGRAM_ADDRESS,
>(
input: AmountToUiAmountInput<TAccountMint>,
config?: { programAddress?: TProgramAddress },
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
): AmountToUiAmountInstruction<
TProgramAddress,
ResolvedInstructionAccountMeta<TAccountMint, InstructionAccountInputAddress<TAccountMint>>
> {
// Program address.
const programAddress = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;
const programAddressInput = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;

// Account meta helper.
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
Expand Down
5 changes: 3 additions & 2 deletions clients/js/src/generated/instructions/approve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function getApproveInstruction<
TProgramAddress extends Address = typeof TOKEN_PROGRAM_ADDRESS,
>(
input: ApproveInput<TAccountSource, TAccountDelegate, TAccountOwner>,
config?: { programAddress?: TProgramAddress },
config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
): ApproveInstruction<
TProgramAddress,
ResolvedInstructionAccountMeta<TAccountSource, InstructionAccountInputAddress<TAccountSource>>,
Expand All @@ -133,7 +133,8 @@ export function getApproveInstruction<
>
> {
// Program address.
const programAddress = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;
const programAddressInput = config?.programAddress ?? TOKEN_PROGRAM_ADDRESS;
const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;

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