/** * 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'; export const DISBAND_DESTROYED_FLEET_DISCRIMINATOR = new Uint8Array([ 30, 102, 130, 27, 61, 136, 76, 145, ]); export function getDisbandDestroyedFleetDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( DISBAND_DESTROYED_FLEET_DISCRIMINATOR, ); } export type DisbandDestroyedFleetInstruction< 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, TAccountCssStarSystem extends string | AccountMeta = string, TAccountCssStarbasePlayer extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TAccountCurrencyCache 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, TAccountCssStarSystem extends string ? ReadonlyAccount : TAccountCssStarSystem, TAccountCssStarbasePlayer extends string ? WritableAccount : TAccountCssStarbasePlayer, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountCurrencyCache extends string ? WritableAccount : TAccountCurrencyCache, TAccountFleetFactionOwnership extends string ? WritableAccount : TAccountFleetFactionOwnership, TAccountOwnerFactionAccount extends string ? WritableAccount : TAccountOwnerFactionAccount, ...TRemainingAccounts, ] >; export type DisbandDestroyedFleetInstructionData = { discriminator: ReadonlyUint8Array; }; export type DisbandDestroyedFleetInstructionDataArgs = {}; export function getDisbandDestroyedFleetInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: DISBAND_DESTROYED_FLEET_DISCRIMINATOR, }), ); } export function getDisbandDestroyedFleetInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getDisbandDestroyedFleetInstructionDataCodec(): FixedSizeCodec< DisbandDestroyedFleetInstructionDataArgs, DisbandDestroyedFleetInstructionData > { return combineCodec( getDisbandDestroyedFleetInstructionDataEncoder(), getDisbandDestroyedFleetInstructionDataDecoder(), ); } export type DisbandDestroyedFleetAsyncInput< TAccountFunder extends string = string, TAccountFleet extends string = string, TAccountProfile extends string = string, TAccountCharacter extends string = string, TAccountCssStarSystem extends string = string, TAccountCssStarbasePlayer extends string = string, TAccountGame extends string = string, TAccountCurrencyCache 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 CSS [`StarSystem`] account */ cssStarSystem: Address; /** The CSS [`crate::state::StarbasePlayer`] Account */ cssStarbasePlayer: Address; /** The game account */ game: Address; /** * The currency config cache account — debited the recovery fee when the * wreck is PLAYER-owned. NPC fleets (faction-ownership sidecar present) * disband free: their sidecars have no funded character, and a mandatory * fee would permanently brick permissionless cleanup. */ currencyCache?: 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. ⚠ This is the * PERMISSIONLESS cleanup path: a caller may omit these to leave the slot occupied (best-effort cap). * 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; }; export async function getDisbandDestroyedFleetInstructionAsync< TAccountFunder extends string, TAccountFleet extends string, TAccountProfile extends string, TAccountCharacter extends string, TAccountCssStarSystem extends string, TAccountCssStarbasePlayer extends string, TAccountGame extends string, TAccountCurrencyCache extends string, TAccountFleetFactionOwnership extends string, TAccountOwnerFactionAccount extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: DisbandDestroyedFleetAsyncInput< TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame, TAccountCurrencyCache, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >, config?: { programAddress?: TProgramAddress }, ): Promise< DisbandDestroyedFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame, TAccountCurrencyCache, 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 }, cssStarSystem: { value: input.cssStarSystem ?? null, isWritable: false }, cssStarbasePlayer: { value: input.cssStarbasePlayer ?? null, isWritable: true, }, game: { value: input.game ?? null, isWritable: false }, currencyCache: { value: input.currencyCache ?? 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 >; // 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), ), ], }); } if (!accounts.currencyCache.value) { accounts.currencyCache.value = await getProgramDerivedAddress({ programAddress, seeds: [ getBytesEncoder().encode( new Uint8Array([ 67, 117, 114, 114, 101, 110, 99, 121, 67, 111, 110, 102, 105, 103, ]), ), 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('cssStarSystem', accounts.cssStarSystem), getAccountMeta('cssStarbasePlayer', accounts.cssStarbasePlayer), getAccountMeta('game', accounts.game), getAccountMeta('currencyCache', accounts.currencyCache), getAccountMeta('fleetFactionOwnership', accounts.fleetFactionOwnership), getAccountMeta('ownerFactionAccount', accounts.ownerFactionAccount), ], data: getDisbandDestroyedFleetInstructionDataEncoder().encode({}), programAddress, } as DisbandDestroyedFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame, TAccountCurrencyCache, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >); } export type DisbandDestroyedFleetInput< TAccountFunder extends string = string, TAccountFleet extends string = string, TAccountProfile extends string = string, TAccountCharacter extends string = string, TAccountCssStarSystem extends string = string, TAccountCssStarbasePlayer extends string = string, TAccountGame extends string = string, TAccountCurrencyCache 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 CSS [`StarSystem`] account */ cssStarSystem: Address; /** The CSS [`crate::state::StarbasePlayer`] Account */ cssStarbasePlayer: Address; /** The game account */ game: Address; /** * The currency config cache account — debited the recovery fee when the * wreck is PLAYER-owned. NPC fleets (faction-ownership sidecar present) * disband free: their sidecars have no funded character, and a mandatory * fee would permanently brick permissionless cleanup. */ currencyCache: 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. ⚠ This is the * PERMISSIONLESS cleanup path: a caller may omit these to leave the slot occupied (best-effort cap). * 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; }; export function getDisbandDestroyedFleetInstruction< TAccountFunder extends string, TAccountFleet extends string, TAccountProfile extends string, TAccountCharacter extends string, TAccountCssStarSystem extends string, TAccountCssStarbasePlayer extends string, TAccountGame extends string, TAccountCurrencyCache extends string, TAccountFleetFactionOwnership extends string, TAccountOwnerFactionAccount extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: DisbandDestroyedFleetInput< TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame, TAccountCurrencyCache, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >, config?: { programAddress?: TProgramAddress }, ): DisbandDestroyedFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame, TAccountCurrencyCache, 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 }, cssStarSystem: { value: input.cssStarSystem ?? null, isWritable: false }, cssStarbasePlayer: { value: input.cssStarbasePlayer ?? null, isWritable: true, }, game: { value: input.game ?? null, isWritable: false }, currencyCache: { value: input.currencyCache ?? 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 >; 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('cssStarSystem', accounts.cssStarSystem), getAccountMeta('cssStarbasePlayer', accounts.cssStarbasePlayer), getAccountMeta('game', accounts.game), getAccountMeta('currencyCache', accounts.currencyCache), getAccountMeta('fleetFactionOwnership', accounts.fleetFactionOwnership), getAccountMeta('ownerFactionAccount', accounts.ownerFactionAccount), ], data: getDisbandDestroyedFleetInstructionDataEncoder().encode({}), programAddress, } as DisbandDestroyedFleetInstruction< TProgramAddress, TAccountFunder, TAccountFleet, TAccountProfile, TAccountCharacter, TAccountCssStarSystem, TAccountCssStarbasePlayer, TAccountGame, TAccountCurrencyCache, TAccountFleetFactionOwnership, TAccountOwnerFactionAccount >); } export type ParsedDisbandDestroyedFleetInstruction< 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 CSS [`StarSystem`] account */ cssStarSystem: TAccountMetas[4]; /** The CSS [`crate::state::StarbasePlayer`] Account */ cssStarbasePlayer: TAccountMetas[5]; /** The game account */ game: TAccountMetas[6]; /** * The currency config cache account — debited the recovery fee when the * wreck is PLAYER-owned. NPC fleets (faction-ownership sidecar present) * disband free: their sidecars have no funded character, and a mandatory * fee would permanently brick permissionless cleanup. */ currencyCache: TAccountMetas[7]; /** * 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. ⚠ This is the * PERMISSIONLESS cleanup path: a caller may omit these to leave the slot occupied (best-effort cap). * 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: DisbandDestroyedFleetInstructionData; }; export function parseDisbandDestroyedFleetInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedDisbandDestroyedFleetInstruction { 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(), cssStarSystem: getNextAccount(), cssStarbasePlayer: getNextAccount(), game: getNextAccount(), currencyCache: getNextAccount(), fleetFactionOwnership: getNextOptionalAccount(), ownerFactionAccount: getNextOptionalAccount(), }, data: getDisbandDestroyedFleetInstructionDataDecoder().decode( instruction.data, ), }; }