/** * 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 COMPLETE_CARGO_RESPAWN_DISCRIMINATOR = new Uint8Array([ 85, 76, 118, 141, 106, 53, 70, 172, ]); export function getCompleteCargoRespawnDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( COMPLETE_CARGO_RESPAWN_DISCRIMINATOR, ); } export type CompleteCargoRespawnInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountFunder extends string | AccountMeta = string, TAccountProfile extends string | AccountMeta = string, TAccountStarSystem extends string | AccountMeta = string, TAccountStarbasePlayer extends string | AccountMeta = string, TAccountCssStarSystem extends string | AccountMeta = string, TAccountCssStarbasePlayer extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountProfile extends string ? WritableAccount : TAccountProfile, TAccountStarSystem extends string ? ReadonlyAccount : TAccountStarSystem, TAccountStarbasePlayer extends string ? WritableAccount : TAccountStarbasePlayer, TAccountCssStarSystem extends string ? ReadonlyAccount : TAccountCssStarSystem, TAccountCssStarbasePlayer extends string ? WritableAccount : TAccountCssStarbasePlayer, TAccountGame extends string ? ReadonlyAccount : TAccountGame, ...TRemainingAccounts, ] >; export type CompleteCargoRespawnInstructionData = { discriminator: ReadonlyUint8Array; }; export type CompleteCargoRespawnInstructionDataArgs = {}; export function getCompleteCargoRespawnInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: COMPLETE_CARGO_RESPAWN_DISCRIMINATOR, }), ); } export function getCompleteCargoRespawnInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getCompleteCargoRespawnInstructionDataCodec(): FixedSizeCodec< CompleteCargoRespawnInstructionDataArgs, CompleteCargoRespawnInstructionData > { return combineCodec( getCompleteCargoRespawnInstructionDataEncoder(), getCompleteCargoRespawnInstructionDataDecoder(), ); } export type CompleteCargoRespawnInput< TAccountFunder extends string = string, TAccountProfile extends string = string, TAccountStarSystem extends string = string, TAccountStarbasePlayer extends string = string, TAccountCssStarSystem extends string = string, TAccountCssStarbasePlayer extends string = string, TAccountGame extends string = string, > = { /** The funder for any Solana rent. */ funder: TransactionSigner; /** The profile that owns the `StarbasePlayer` */ profile: Address; /** The [`StarSystem`] account */ starSystem: Address; /** The [`crate::state::StarbasePlayer`] Account */ starbasePlayer: Address; /** The CSS [`StarSystem`] account */ cssStarSystem: Address; /** The CSS [`crate::state::StarbasePlayer`] Account */ cssStarbasePlayer: Address; /** The game account */ game: Address; }; export function getCompleteCargoRespawnInstruction< TAccountFunder extends string, TAccountProfile extends string, TAccountStarSystem extends string, TAccountStarbasePlayer extends string, TAccountCssStarSystem extends string, TAccountCssStarbasePlayer extends string, TAccountGame extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: CompleteCargoRespawnInput< TAccountFunder, TAccountProfile, TAccountStarSystem, TAccountStarbasePlayer, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame >, config?: { programAddress?: TProgramAddress }, ): CompleteCargoRespawnInstruction< TProgramAddress, TAccountFunder, TAccountProfile, TAccountStarSystem, TAccountStarbasePlayer, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { funder: { value: input.funder ?? null, isWritable: true }, profile: { value: input.profile ?? null, isWritable: true }, starSystem: { value: input.starSystem ?? null, isWritable: false }, starbasePlayer: { value: input.starbasePlayer ?? null, isWritable: true }, cssStarSystem: { value: input.cssStarSystem ?? null, isWritable: false }, cssStarbasePlayer: { value: input.cssStarbasePlayer ?? 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('funder', accounts.funder), getAccountMeta('profile', accounts.profile), getAccountMeta('starSystem', accounts.starSystem), getAccountMeta('starbasePlayer', accounts.starbasePlayer), getAccountMeta('cssStarSystem', accounts.cssStarSystem), getAccountMeta('cssStarbasePlayer', accounts.cssStarbasePlayer), getAccountMeta('game', accounts.game), ], data: getCompleteCargoRespawnInstructionDataEncoder().encode({}), programAddress, } as CompleteCargoRespawnInstruction< TProgramAddress, TAccountFunder, TAccountProfile, TAccountStarSystem, TAccountStarbasePlayer, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame >); } export type ParsedCompleteCargoRespawnInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { /** The funder for any Solana rent. */ funder: TAccountMetas[0]; /** The profile that owns the `StarbasePlayer` */ profile: TAccountMetas[1]; /** The [`StarSystem`] account */ starSystem: TAccountMetas[2]; /** The [`crate::state::StarbasePlayer`] Account */ starbasePlayer: TAccountMetas[3]; /** The CSS [`StarSystem`] account */ cssStarSystem: TAccountMetas[4]; /** The CSS [`crate::state::StarbasePlayer`] Account */ cssStarbasePlayer: TAccountMetas[5]; /** The game account */ game: TAccountMetas[6]; }; data: CompleteCargoRespawnInstructionData; }; export function parseCompleteCargoRespawnInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedCompleteCargoRespawnInstruction { if (instruction.accounts.length < 7) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 7, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { funder: getNextAccount(), profile: getNextAccount(), starSystem: getNextAccount(), starbasePlayer: getNextAccount(), cssStarSystem: getNextAccount(), cssStarbasePlayer: getNextAccount(), game: getNextAccount(), }, data: getCompleteCargoRespawnInstructionDataDecoder().decode( instruction.data, ), }; }