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
196 changes: 196 additions & 0 deletions clients/js/src/generated/instructions/applyConfidentialPendingBurn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
/**
* This code was AUTOGENERATED using the Codama library.
* Please DO NOT EDIT THIS FILE, instead use visitors
* to add features, then rerun Codama to update it.
*
* @see https://github.com/codama-idl/codama
*/

import {
AccountRole,
combineCodec,
getStructDecoder,
getStructEncoder,
getU8Decoder,
getU8Encoder,
transformEncoder,
type AccountMeta,
type AccountSignerMeta,
type Address,
type FixedSizeCodec,
type FixedSizeDecoder,
type FixedSizeEncoder,
type Instruction,
type InstructionWithAccounts,
type InstructionWithData,
type ReadonlyAccount,
type ReadonlySignerAccount,
type ReadonlyUint8Array,
type TransactionSigner,
type WritableAccount,
} from '@solana/kit';
import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

export const APPLY_CONFIDENTIAL_PENDING_BURN_DISCRIMINATOR = 42;

export function getApplyConfidentialPendingBurnDiscriminatorBytes() {
return getU8Encoder().encode(APPLY_CONFIDENTIAL_PENDING_BURN_DISCRIMINATOR);
}

export const APPLY_CONFIDENTIAL_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 5;

export function getApplyConfidentialPendingBurnConfidentialMintBurnDiscriminatorBytes() {
return getU8Encoder().encode(APPLY_CONFIDENTIAL_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR);
}

export type ApplyConfidentialPendingBurnInstruction<
TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS,
TAccountMint extends string | AccountMeta<string> = string,
TAccountAuthority extends string | AccountMeta<string> = string,
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
> = Instruction<TProgram> &
InstructionWithData<ReadonlyUint8Array> &
InstructionWithAccounts<
[
TAccountMint extends string ? WritableAccount<TAccountMint> : TAccountMint,
TAccountAuthority extends string ? ReadonlyAccount<TAccountAuthority> : TAccountAuthority,
...TRemainingAccounts,
]
>;

export type ApplyConfidentialPendingBurnInstructionData = {
discriminator: number;
confidentialMintBurnDiscriminator: number;
};

export type ApplyConfidentialPendingBurnInstructionDataArgs = {};

export function getApplyConfidentialPendingBurnInstructionDataEncoder(): FixedSizeEncoder<ApplyConfidentialPendingBurnInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['confidentialMintBurnDiscriminator', getU8Encoder()],
]),
value => ({
...value,
discriminator: APPLY_CONFIDENTIAL_PENDING_BURN_DISCRIMINATOR,
confidentialMintBurnDiscriminator: APPLY_CONFIDENTIAL_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR,
}),
);
}

export function getApplyConfidentialPendingBurnInstructionDataDecoder(): FixedSizeDecoder<ApplyConfidentialPendingBurnInstructionData> {
return getStructDecoder([
['discriminator', getU8Decoder()],
['confidentialMintBurnDiscriminator', getU8Decoder()],
]);
}

export function getApplyConfidentialPendingBurnInstructionDataCodec(): FixedSizeCodec<
ApplyConfidentialPendingBurnInstructionDataArgs,
ApplyConfidentialPendingBurnInstructionData
> {
return combineCodec(
getApplyConfidentialPendingBurnInstructionDataEncoder(),
getApplyConfidentialPendingBurnInstructionDataDecoder(),
);
}

export type ApplyConfidentialPendingBurnInput<
TAccountMint extends string = string,
TAccountAuthority extends string = string,
> = {
/** The SPL Token mint. */
mint: Address<TAccountMint>;
/** The mint authority or its multisignature account. */
authority: Address<TAccountAuthority> | TransactionSigner<TAccountAuthority>;
multiSigners?: Array<TransactionSigner>;
};

export function getApplyConfidentialPendingBurnInstruction<
TAccountMint extends string,
TAccountAuthority extends string,
TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS,
>(
input: ApplyConfidentialPendingBurnInput<TAccountMint, TAccountAuthority>,
config?: { programAddress?: TProgramAddress },
): ApplyConfidentialPendingBurnInstruction<
TProgramAddress,
TAccountMint,
(typeof input)['authority'] extends TransactionSigner<TAccountAuthority>
? ReadonlySignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority>
: TAccountAuthority
> {
// Program address.
const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS;

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

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

// Remaining accounts.
const remainingAccounts: AccountMeta[] = (args.multiSigners ?? []).map(signer => ({
address: signer.address,
role: AccountRole.READONLY_SIGNER,
signer,
}));

const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [getAccountMeta(accounts.mint), getAccountMeta(accounts.authority), ...remainingAccounts],
data: getApplyConfidentialPendingBurnInstructionDataEncoder().encode({}),
programAddress,
} as ApplyConfidentialPendingBurnInstruction<
TProgramAddress,
TAccountMint,
(typeof input)['authority'] extends TransactionSigner<TAccountAuthority>
? ReadonlySignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority>
: TAccountAuthority
>);
}

export type ParsedApplyConfidentialPendingBurnInstruction<
TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS,
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
> = {
programAddress: Address<TProgram>;
accounts: {
/** The SPL Token mint. */
mint: TAccountMetas[0];
/** The mint authority or its multisignature account. */
authority: TAccountMetas[1];
};
data: ApplyConfidentialPendingBurnInstructionData;
};

export function parseApplyConfidentialPendingBurnInstruction<
TProgram extends string,
TAccountMetas extends readonly AccountMeta[],
>(
instruction: Instruction<TProgram> &
InstructionWithAccounts<TAccountMetas> &
InstructionWithData<ReadonlyUint8Array>,
): ParsedApplyConfidentialPendingBurnInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 2) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
accountIndex += 1;
return accountMeta;
};
return {
programAddress: instruction.programAddress,
accounts: { mint: getNextAccount(), authority: getNextAccount() },
data: getApplyConfidentialPendingBurnInstructionDataDecoder().decode(instruction.data),
};
}
127 changes: 127 additions & 0 deletions clients/js/src/generated/instructions/batch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* This code was AUTOGENERATED using the Codama library.
* Please DO NOT EDIT THIS FILE, instead use visitors
* to add features, then rerun Codama to update it.
*
* @see https://github.com/codama-idl/codama
*/

import {
addDecoderSizePrefix,
addEncoderSizePrefix,
combineCodec,
getArrayDecoder,
getArrayEncoder,
getBytesDecoder,
getBytesEncoder,
getStructDecoder,
getStructEncoder,
getU8Decoder,
getU8Encoder,
transformEncoder,
type AccountMeta,
type Address,
type Codec,
type Decoder,
type Encoder,
type Instruction,
type InstructionWithAccounts,
type InstructionWithData,
type ReadonlyUint8Array,
} from '@solana/kit';
import { TOKEN_2022_PROGRAM_ADDRESS } from '../programs';

export const BATCH_DISCRIMINATOR = 255;

export function getBatchDiscriminatorBytes() {
return getU8Encoder().encode(BATCH_DISCRIMINATOR);
}

export type BatchInstruction<
TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS,
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;

export type BatchInstructionData = {
discriminator: number;
/** Instruction data for batch instructions. */
data: Array<{ numberOfAccounts: number; instructionData: ReadonlyUint8Array }>;
};

export type BatchInstructionDataArgs = {
/** Instruction data for batch instructions. */
data: Array<{ numberOfAccounts: number; instructionData: ReadonlyUint8Array }>;
};

export function getBatchInstructionDataEncoder(): Encoder<BatchInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
[
'data',
getArrayEncoder(
getStructEncoder([
['numberOfAccounts', getU8Encoder()],
['instructionData', addEncoderSizePrefix(getBytesEncoder(), getU8Encoder())],
]),
{ size: 'remainder' },
),
],
]),
value => ({ ...value, discriminator: BATCH_DISCRIMINATOR }),
);
}

export function getBatchInstructionDataDecoder(): Decoder<BatchInstructionData> {
return getStructDecoder([
['discriminator', getU8Decoder()],
[
'data',
getArrayDecoder(
getStructDecoder([
['numberOfAccounts', getU8Decoder()],
['instructionData', addDecoderSizePrefix(getBytesDecoder(), getU8Decoder())],
]),
{ size: 'remainder' },
),
],
]);
}

export function getBatchInstructionDataCodec(): Codec<BatchInstructionDataArgs, BatchInstructionData> {
return combineCodec(getBatchInstructionDataEncoder(), getBatchInstructionDataDecoder());
}

export type BatchInput = {
data: BatchInstructionDataArgs['data'];
};

export function getBatchInstruction<TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS>(
input: BatchInput,
config?: { programAddress?: TProgramAddress },
): BatchInstruction<TProgramAddress> {
// Program address.
const programAddress = config?.programAddress ?? TOKEN_2022_PROGRAM_ADDRESS;

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

return Object.freeze({
data: getBatchInstructionDataEncoder().encode(args as BatchInstructionDataArgs),
programAddress,
} as BatchInstruction<TProgramAddress>);
}

export type ParsedBatchInstruction<TProgram extends string = typeof TOKEN_2022_PROGRAM_ADDRESS> = {
programAddress: Address<TProgram>;
data: BatchInstructionData;
};

export function parseBatchInstruction<TProgram extends string>(
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
): ParsedBatchInstruction<TProgram> {
return {
programAddress: instruction.programAddress,
data: getBatchInstructionDataDecoder().decode(instruction.data),
};
}
Loading
Loading