/** * 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 { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount, } from '@solana/kit'; import { getAccountMetaFactory, type ResolvedInstructionAccount, } from '@solana/program-client-core'; import { SAGE_PROGRAM_ADDRESS } from '../programs'; export const DESTROY_STARBASE_PLAYER_DISCRIMINATOR = new Uint8Array([ 250, 78, 36, 209, 106, 226, 9, 144, ]); export function getDestroyStarbasePlayerDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( DESTROY_STARBASE_PLAYER_DISCRIMINATOR, ); } export type DestroyStarbasePlayerInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountProfile extends string | AccountMeta = string, TAccountStarSystem extends string | AccountMeta = string, TAccountStarbasePlayer extends string | AccountMeta = string, TAccountFunder extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountProfile extends string ? WritableAccount : TAccountProfile, TAccountStarSystem extends string ? ReadonlyAccount : TAccountStarSystem, TAccountStarbasePlayer extends string ? WritableAccount : TAccountStarbasePlayer, TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountGame extends string ? ReadonlyAccount : TAccountGame, ...TRemainingAccounts, ] >; export type DestroyStarbasePlayerInstructionData = { discriminator: ReadonlyUint8Array; }; export type DestroyStarbasePlayerInstructionDataArgs = {}; export function getDestroyStarbasePlayerInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: DESTROY_STARBASE_PLAYER_DISCRIMINATOR, }), ); } export function getDestroyStarbasePlayerInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getDestroyStarbasePlayerInstructionDataCodec(): FixedSizeCodec< DestroyStarbasePlayerInstructionDataArgs, DestroyStarbasePlayerInstructionData > { return combineCodec( getDestroyStarbasePlayerInstructionDataEncoder(), getDestroyStarbasePlayerInstructionDataDecoder(), ); } export type DestroyStarbasePlayerInput< TAccountProfile extends string = string, TAccountStarSystem extends string = string, TAccountStarbasePlayer extends string = string, TAccountFunder extends string = string, TAccountGame extends string = string, > = { /** The profile that owns the `StarbasePlayer` */ profile: Address; /** The [`StarSystem`] account */ starSystem: Address; /** The [`crate::state::StarbasePlayer`] Account */ starbasePlayer: Address; /** The funder for any Solana rent payments. */ funder: TransactionSigner; /** The game account */ game: Address; }; export function getDestroyStarbasePlayerInstruction< TAccountProfile extends string, TAccountStarSystem extends string, TAccountStarbasePlayer extends string, TAccountFunder extends string, TAccountGame extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: DestroyStarbasePlayerInput< TAccountProfile, TAccountStarSystem, TAccountStarbasePlayer, TAccountFunder, TAccountGame >, config?: { programAddress?: TProgramAddress }, ): DestroyStarbasePlayerInstruction< TProgramAddress, TAccountProfile, TAccountStarSystem, TAccountStarbasePlayer, TAccountFunder, TAccountGame > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { profile: { value: input.profile ?? null, isWritable: true }, starSystem: { value: input.starSystem ?? null, isWritable: false }, starbasePlayer: { value: input.starbasePlayer ?? null, isWritable: true }, funder: { value: input.funder ?? null, isWritable: true }, game: { value: input.game ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta('profile', accounts.profile), getAccountMeta('starSystem', accounts.starSystem), getAccountMeta('starbasePlayer', accounts.starbasePlayer), getAccountMeta('funder', accounts.funder), getAccountMeta('game', accounts.game), ], data: getDestroyStarbasePlayerInstructionDataEncoder().encode({}), programAddress, } as DestroyStarbasePlayerInstruction< TProgramAddress, TAccountProfile, TAccountStarSystem, TAccountStarbasePlayer, TAccountFunder, TAccountGame >); } export type ParsedDestroyStarbasePlayerInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { /** The profile that owns the `StarbasePlayer` */ profile: TAccountMetas[0]; /** The [`StarSystem`] account */ starSystem: TAccountMetas[1]; /** The [`crate::state::StarbasePlayer`] Account */ starbasePlayer: TAccountMetas[2]; /** The funder for any Solana rent payments. */ funder: TAccountMetas[3]; /** The game account */ game: TAccountMetas[4]; }; data: DestroyStarbasePlayerInstructionData; }; export function parseDestroyStarbasePlayerInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedDestroyStarbasePlayerInstruction { if (instruction.accounts.length < 5) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 5, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { profile: getNextAccount(), starSystem: getNextAccount(), starbasePlayer: getNextAccount(), funder: getNextAccount(), game: getNextAccount(), }, data: getDestroyStarbasePlayerInstructionDataDecoder().decode( instruction.data, ), }; }