/** * 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, getAddressEncoder, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, 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, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount, } from '@solana/program-client-core'; import { SAGE_PROGRAM_ADDRESS } from '../programs'; import { getShipIdDecoder, getShipIdEncoder, type ShipId, type ShipIdArgs, } from '../types'; export const FORCED_DISBAND_FLEET_DISCRIMINATOR = new Uint8Array([ 18, 245, 53, 119, 155, 57, 1, 78, ]); export function getForcedDisbandFleetDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( FORCED_DISBAND_FLEET_DISCRIMINATOR, ); } export type ForcedDisbandFleetInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountFunder extends string | AccountMeta = string, TAccountFleet extends string | AccountMeta = string, TAccountProfile extends string | AccountMeta = string, TAccountCharacter extends string | AccountMeta = string, TAccountCssSystemAndStarbasePlayerSystem extends | string | AccountMeta = string, TAccountCssSystemAndStarbasePlayerStarbasePlayer extends | string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TAccountAsteroid extends string | AccountMeta = string, TAccountFleetFactionOwnership extends string | AccountMeta = string, TAccountOwnerFactionAccount extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountFleet extends string ? WritableAccount : TAccountFleet, TAccountProfile extends string ? WritableAccount : TAccountProfile, TAccountCharacter extends string ? WritableAccount : TAccountCharacter, TAccountCssSystemAndStarbasePlayerSystem extends string ? ReadonlyAccount : TAccountCssSystemAndStarbasePlayerSystem, TAccountCssSystemAndStarbasePlayerStarbasePlayer extends string ? WritableAccount : TAccountCssSystemAndStarbasePlayerStarbasePlayer, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountAsteroid extends string ? WritableAccount : TAccountAsteroid, TAccountFleetFactionOwnership extends string ? WritableAccount : TAccountFleetFactionOwnership, TAccountOwnerFactionAccount extends string ? WritableAccount : TAccountOwnerFactionAccount, ...TRemainingAccounts, ] >; export type ForcedDisbandFleetInstructionData = { discriminator: ReadonlyUint8Array; /** Index of `FleetShipsInfo` in remaining data of `FleetShips` */ invalidShipId: ShipId; }; export type ForcedDisbandFleetInstructionDataArgs = { /** Index of `FleetShipsInfo` in remaining data of `FleetShips` */ invalidShipId: ShipIdArgs; }; export function getForcedDisbandFleetInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['invalidShipId', getShipIdEncoder()], ]), (value) => ({ ...value, discriminator: FORCED_DISBAND_FLEET_DISCRIMINATOR, }), ); } export function getForcedDisbandFleetInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['invalidShipId', getShipIdDecoder()], ]); } export function getForcedDisbandFleetInstructionDataCodec(): FixedSizeCodec< ForcedDisbandFleetInstructionDataArgs, ForcedDisbandFleetInstructionData > { return combineCodec( getForcedDisbandFleetInstructionDataEncoder(), getForcedDisbandFleetInstructionDataDecoder(), ); } export type ForcedDisbandFleetAsyncInput< TAccountFunder extends string = string, TAccountFleet extends string = string, TAccountProfile extends string = string, TAccountCharacter extends string = string, TAccountCssSystemAndStarbasePlayerSystem extends string = string, TAccountCssSystemAndStarbasePlayerStarbasePlayer extends string = string, TAccountGame extends string = string, TAccountAsteroid extends string = string, TAccountFleetFactionOwnership extends string = string, TAccountOwnerFactionAccount extends string = string, > = { /** The funder - pays for account rent */ funder: TransactionSigner; /** The [`Fleet`] account */ fleet: Address; /** The player profile */ profile: Address; /** The character that owns the fleet */ character?: Address; /** The [`StarSystem`] account */ cssSystemAndStarbasePlayerSystem: Address; /** The [`StarbasePlayer`] Account */ cssSystemAndStarbasePlayerStarbasePlayer: Address; /** The game account */ game: Address; /** * If mining, provide the asteroid being mined * CHECK: validated against fleet mining state */ asteroid?: Address; /** * P5b CONCURRENT-CAP (best-effort): the fleet's FLEET-kind `FactionOwnership` sidecar (optional, * writable) — present ⇔ an NPC fleet; supplies the controlling faction so its live `npc_fleet_count` is * freed on teardown. PDA seed-bound to `fleet`. Omitted ⇒ no-op, byte-identical. * ROOT-CAUSE FIX (C4 JOR orphan): now `Mut` + closed atomically when supplied — a read-only sidecar * leaked rent and blocked `AdminSetNpcFleetId`'s `Init` on the respawned fleet (Custom(0)). */ fleetFactionOwnership?: Address; /** * P5b CONCURRENT-CAP: the controlling faction's registry account (Optional, Mut) — decremented when an * NPC fleet is released. REQUIRED ⇔ the sidecar names a dynamic faction (id > 3); PDA-bound in-handler. */ ownerFactionAccount?: Address; invalidShipId: ForcedDisbandFleetInstructionDataArgs['invalidShipId']; }; export async function getForcedDisbandFleetInstructionAsync< TAccountFunder extends string, TAccountFleet extends string, TAccountProfile extends string, TAccountCharacter extends string, TAccountCssSystemAndStarbasePlayerSystem extends string, TAccountCssSystemAndStarbasePlayerStarbasePlayer extends string, TAccountGame extends string, TAccountAsteroid extends string, TAccountFleetFactionOwnership extends string, TAccountOwnerFactionAccount extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: ForcedDisbandFleetAsyncInput< TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssSystemAndStarbasePlayerSystem, TAccountCssSystemAndStarbasePlayerStarbasePlayer, TAccountGame, TAccountAsteroid, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >, config?: { programAddress?: TProgramAddress }, ): Promise< ForcedDisbandFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssSystemAndStarbasePlayerSystem, TAccountCssSystemAndStarbasePlayerStarbasePlayer, TAccountGame, TAccountAsteroid, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount > > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { funder: { value: input.funder ?? null, isWritable: true }, fleet: { value: input.fleet ?? null, isWritable: true }, profile: { value: input.profile ?? null, isWritable: true }, character: { value: input.character ?? null, isWritable: true }, cssSystemAndStarbasePlayerSystem: { value: input.cssSystemAndStarbasePlayerSystem ?? null, isWritable: false, }, cssSystemAndStarbasePlayerStarbasePlayer: { value: input.cssSystemAndStarbasePlayerStarbasePlayer ?? null, isWritable: true, }, game: { value: input.game ?? null, isWritable: false }, asteroid: { value: input.asteroid ?? null, isWritable: true }, fleetFactionOwnership: { value: input.fleetFactionOwnership ?? null, isWritable: true, }, ownerFactionAccount: { value: input.ownerFactionAccount ?? null, isWritable: true, }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.character.value) { accounts.character.value = await getProgramDerivedAddress({ programAddress, seeds: [ getBytesEncoder().encode( new Uint8Array([67, 104, 97, 114, 97, 99, 116, 101, 114]), ), getAddressEncoder().encode( getAddressFromResolvedInstructionAccount( 'profile', accounts.profile.value, ), ), getAddressEncoder().encode( getAddressFromResolvedInstructionAccount('game', accounts.game.value), ), ], }); } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta('funder', accounts.funder), getAccountMeta('fleet', accounts.fleet), getAccountMeta('profile', accounts.profile), getAccountMeta('character', accounts.character), getAccountMeta( 'cssSystemAndStarbasePlayerSystem', accounts.cssSystemAndStarbasePlayerSystem, ), getAccountMeta( 'cssSystemAndStarbasePlayerStarbasePlayer', accounts.cssSystemAndStarbasePlayerStarbasePlayer, ), getAccountMeta('game', accounts.game), getAccountMeta('asteroid', accounts.asteroid), getAccountMeta('fleetFactionOwnership', accounts.fleetFactionOwnership), getAccountMeta('ownerFactionAccount', accounts.ownerFactionAccount), ], data: getForcedDisbandFleetInstructionDataEncoder().encode( args as ForcedDisbandFleetInstructionDataArgs, ), programAddress, } as ForcedDisbandFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssSystemAndStarbasePlayerSystem, TAccountCssSystemAndStarbasePlayerStarbasePlayer, TAccountGame, TAccountAsteroid, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >); } export type ForcedDisbandFleetInput< TAccountFunder extends string = string, TAccountFleet extends string = string, TAccountProfile extends string = string, TAccountCharacter extends string = string, TAccountCssSystemAndStarbasePlayerSystem extends string = string, TAccountCssSystemAndStarbasePlayerStarbasePlayer extends string = string, TAccountGame extends string = string, TAccountAsteroid extends string = string, TAccountFleetFactionOwnership extends string = string, TAccountOwnerFactionAccount extends string = string, > = { /** The funder - pays for account rent */ funder: TransactionSigner; /** The [`Fleet`] account */ fleet: Address; /** The player profile */ profile: Address; /** The character that owns the fleet */ character: Address; /** The [`StarSystem`] account */ cssSystemAndStarbasePlayerSystem: Address; /** The [`StarbasePlayer`] Account */ cssSystemAndStarbasePlayerStarbasePlayer: Address; /** The game account */ game: Address; /** * If mining, provide the asteroid being mined * CHECK: validated against fleet mining state */ asteroid?: Address; /** * P5b CONCURRENT-CAP (best-effort): the fleet's FLEET-kind `FactionOwnership` sidecar (optional, * writable) — present ⇔ an NPC fleet; supplies the controlling faction so its live `npc_fleet_count` is * freed on teardown. PDA seed-bound to `fleet`. Omitted ⇒ no-op, byte-identical. * ROOT-CAUSE FIX (C4 JOR orphan): now `Mut` + closed atomically when supplied — a read-only sidecar * leaked rent and blocked `AdminSetNpcFleetId`'s `Init` on the respawned fleet (Custom(0)). */ fleetFactionOwnership?: Address; /** * P5b CONCURRENT-CAP: the controlling faction's registry account (Optional, Mut) — decremented when an * NPC fleet is released. REQUIRED ⇔ the sidecar names a dynamic faction (id > 3); PDA-bound in-handler. */ ownerFactionAccount?: Address; invalidShipId: ForcedDisbandFleetInstructionDataArgs['invalidShipId']; }; export function getForcedDisbandFleetInstruction< TAccountFunder extends string, TAccountFleet extends string, TAccountProfile extends string, TAccountCharacter extends string, TAccountCssSystemAndStarbasePlayerSystem extends string, TAccountCssSystemAndStarbasePlayerStarbasePlayer extends string, TAccountGame extends string, TAccountAsteroid extends string, TAccountFleetFactionOwnership extends string, TAccountOwnerFactionAccount extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: ForcedDisbandFleetInput< TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssSystemAndStarbasePlayerSystem, TAccountCssSystemAndStarbasePlayerStarbasePlayer, TAccountGame, TAccountAsteroid, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >, config?: { programAddress?: TProgramAddress }, ): ForcedDisbandFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssSystemAndStarbasePlayerSystem, TAccountCssSystemAndStarbasePlayerStarbasePlayer, TAccountGame, TAccountAsteroid, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { funder: { value: input.funder ?? null, isWritable: true }, fleet: { value: input.fleet ?? null, isWritable: true }, profile: { value: input.profile ?? null, isWritable: true }, character: { value: input.character ?? null, isWritable: true }, cssSystemAndStarbasePlayerSystem: { value: input.cssSystemAndStarbasePlayerSystem ?? null, isWritable: false, }, cssSystemAndStarbasePlayerStarbasePlayer: { value: input.cssSystemAndStarbasePlayerStarbasePlayer ?? null, isWritable: true, }, game: { value: input.game ?? null, isWritable: false }, asteroid: { value: input.asteroid ?? null, isWritable: true }, fleetFactionOwnership: { value: input.fleetFactionOwnership ?? null, isWritable: true, }, ownerFactionAccount: { value: input.ownerFactionAccount ?? null, isWritable: true, }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta('funder', accounts.funder), getAccountMeta('fleet', accounts.fleet), getAccountMeta('profile', accounts.profile), getAccountMeta('character', accounts.character), getAccountMeta( 'cssSystemAndStarbasePlayerSystem', accounts.cssSystemAndStarbasePlayerSystem, ), getAccountMeta( 'cssSystemAndStarbasePlayerStarbasePlayer', accounts.cssSystemAndStarbasePlayerStarbasePlayer, ), getAccountMeta('game', accounts.game), getAccountMeta('asteroid', accounts.asteroid), getAccountMeta('fleetFactionOwnership', accounts.fleetFactionOwnership), getAccountMeta('ownerFactionAccount', accounts.ownerFactionAccount), ], data: getForcedDisbandFleetInstructionDataEncoder().encode( args as ForcedDisbandFleetInstructionDataArgs, ), programAddress, } as ForcedDisbandFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssSystemAndStarbasePlayerSystem, TAccountCssSystemAndStarbasePlayerStarbasePlayer, TAccountGame, TAccountAsteroid, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >); } export type ParsedForcedDisbandFleetInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { /** The funder - pays for account rent */ funder: TAccountMetas[0]; /** The [`Fleet`] account */ fleet: TAccountMetas[1]; /** The player profile */ profile: TAccountMetas[2]; /** The character that owns the fleet */ character: TAccountMetas[3]; /** The [`StarSystem`] account */ cssSystemAndStarbasePlayerSystem: TAccountMetas[4]; /** The [`StarbasePlayer`] Account */ cssSystemAndStarbasePlayerStarbasePlayer: TAccountMetas[5]; /** The game account */ game: TAccountMetas[6]; /** * If mining, provide the asteroid being mined * CHECK: validated against fleet mining state */ asteroid?: TAccountMetas[7] | undefined; /** * P5b CONCURRENT-CAP (best-effort): the fleet's FLEET-kind `FactionOwnership` sidecar (optional, * writable) — present ⇔ an NPC fleet; supplies the controlling faction so its live `npc_fleet_count` is * freed on teardown. PDA seed-bound to `fleet`. Omitted ⇒ no-op, byte-identical. * ROOT-CAUSE FIX (C4 JOR orphan): now `Mut` + closed atomically when supplied — a read-only sidecar * leaked rent and blocked `AdminSetNpcFleetId`'s `Init` on the respawned fleet (Custom(0)). */ fleetFactionOwnership?: TAccountMetas[8] | undefined; /** * P5b CONCURRENT-CAP: the controlling faction's registry account (Optional, Mut) — decremented when an * NPC fleet is released. REQUIRED ⇔ the sidecar names a dynamic faction (id > 3); PDA-bound in-handler. */ ownerFactionAccount?: TAccountMetas[9] | undefined; }; data: ForcedDisbandFleetInstructionData; }; export function parseForcedDisbandFleetInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedForcedDisbandFleetInstruction { if (instruction.accounts.length < 10) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 10, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; const getNextOptionalAccount = () => { const accountMeta = getNextAccount(); return accountMeta.address === SAGE_PROGRAM_ADDRESS ? undefined : accountMeta; }; return { programAddress: instruction.programAddress, accounts: { funder: getNextAccount(), fleet: getNextAccount(), profile: getNextAccount(), character: getNextAccount(), cssSystemAndStarbasePlayerSystem: getNextAccount(), cssSystemAndStarbasePlayerStarbasePlayer: getNextAccount(), game: getNextAccount(), asteroid: getNextOptionalAccount(), fleetFactionOwnership: getNextOptionalAccount(), ownerFactionAccount: getNextOptionalAccount(), }, data: getForcedDisbandFleetInstructionDataDecoder().decode( instruction.data, ), }; }