Skip to content
Draft
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
214 changes: 214 additions & 0 deletions clients/js/src/generated/instructions/applyPendingBurn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/**
* 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_PENDING_BURN_DISCRIMINATOR = 42;

export function getApplyPendingBurnDiscriminatorBytes() {
return getU8Encoder().encode(APPLY_PENDING_BURN_DISCRIMINATOR);
}

export const APPLY_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR = 5;

export function getApplyPendingBurnConfidentialMintBurnDiscriminatorBytes() {
return getU8Encoder().encode(
APPLY_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR
);
}

export type ApplyPendingBurnInstruction<
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 ApplyPendingBurnInstructionData = {
discriminator: number;
confidentialMintBurnDiscriminator: number;
};

export type ApplyPendingBurnInstructionDataArgs = {};

export function getApplyPendingBurnInstructionDataEncoder(): FixedSizeEncoder<ApplyPendingBurnInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['confidentialMintBurnDiscriminator', getU8Encoder()],
]),
(value) => ({
...value,
discriminator: APPLY_PENDING_BURN_DISCRIMINATOR,
confidentialMintBurnDiscriminator:
APPLY_PENDING_BURN_CONFIDENTIAL_MINT_BURN_DISCRIMINATOR,
})
);
}

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

export function getApplyPendingBurnInstructionDataCodec(): FixedSizeCodec<
ApplyPendingBurnInstructionDataArgs,
ApplyPendingBurnInstructionData
> {
return combineCodec(
getApplyPendingBurnInstructionDataEncoder(),
getApplyPendingBurnInstructionDataDecoder()
);
}

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

export function getApplyPendingBurnInstruction<
TAccountMint extends string,
TAccountAuthority extends string,
TProgramAddress extends Address = typeof TOKEN_2022_PROGRAM_ADDRESS,
>(
input: ApplyPendingBurnInput<TAccountMint, TAccountAuthority>,
config?: { programAddress?: TProgramAddress }
): ApplyPendingBurnInstruction<
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: getApplyPendingBurnInstructionDataEncoder().encode({}),
programAddress,
} as ApplyPendingBurnInstruction<
TProgramAddress,
TAccountMint,
(typeof input)['authority'] extends TransactionSigner<TAccountAuthority>
? ReadonlySignerAccount<TAccountAuthority> &
AccountSignerMeta<TAccountAuthority>
: TAccountAuthority
>);
}

export type ParsedApplyPendingBurnInstruction<
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's minting authority or its multisignature account. */
authority: TAccountMetas[1];
};
data: ApplyPendingBurnInstructionData;
};

export function parseApplyPendingBurnInstruction<
TProgram extends string,
TAccountMetas extends readonly AccountMeta[],
>(
instruction: Instruction<TProgram> &
InstructionWithAccounts<TAccountMetas> &
InstructionWithData<ReadonlyUint8Array>
): ParsedApplyPendingBurnInstruction<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: getApplyPendingBurnInstructionDataDecoder().decode(instruction.data),
};
}
Loading
Loading