/** * 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, getU16Decoder, getU16Encoder, 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 ReadonlySignerAccount, 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 { getFleetStanceDecoder, getFleetStanceEncoder, type FleetStance, type FleetStanceArgs, } from '../types'; export const ATTACK_STARBASE_DISCRIMINATOR = new Uint8Array([ 82, 235, 15, 53, 168, 66, 129, 161, ]); export function getAttackStarbaseDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( ATTACK_STARBASE_DISCRIMINATOR, ); } export type AttackStarbaseInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountProfileValidationSigner extends string | AccountMeta = string, TAccountProfileValidationProfile extends string | AccountMeta = string, TAccountProfileValidationCertificate extends string | AccountMeta = string, TAccountProfileValidationProgram extends string | AccountMeta = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u', TAccountCharacter extends string | AccountMeta = string, TAccountFleet extends string | AccountMeta = string, TAccountSystem extends string | AccountMeta = string, TAccountLoot extends string | AccountMeta = string, TAccountRegionTracker extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TAccountInstructionsSysvar extends string | AccountMeta = 'Sysvar1nstructions1111111111111111111111111', TAccountRecentSlothashes extends string | AccountMeta = string, TAccountSystemProgram extends string | AccountMeta = '11111111111111111111111111111111', TAccountFactionRelationTracker extends string | AccountMeta = string, TAccountFactionOwnership extends string | AccountMeta = string, TAccountCrewBinding extends string | AccountMeta = string, TAccountAttackerFleetOwnership extends string | AccountMeta = string, TAccountAttackerFactionAccount extends string | AccountMeta = string, TAccountFactionEconomicsConfig extends string | AccountMeta = string, TAccountCaptorTreasury extends string | AccountMeta = string, TAccountRewardRegistry extends string | AccountMeta = string, TAccountRewardConfig extends string | AccountMeta = string, TAccountKingTracker extends string | AccountMeta = string, TAccountXpBudget extends string | AccountMeta = string, TAccountXpBudgetConfig extends string | AccountMeta = string, TAccountRentCatalog extends string | AccountMeta = string, TAccountRentHead extends string | AccountMeta = string, TAccountRentCurrentPage extends string | AccountMeta = string, TAccountRentNextPage extends string | AccountMeta = string, TAccountDemocracyHistoryHistory extends string | AccountMeta = string, TAccountDemocracyHistoryPolicy extends string | AccountMeta = string, TAccountDemocracyHistoryGeneration extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountProfileValidationSigner extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountProfileValidationSigner, TAccountProfileValidationProfile extends string ? WritableAccount : TAccountProfileValidationProfile, TAccountProfileValidationCertificate extends string ? ReadonlyAccount : TAccountProfileValidationCertificate, TAccountProfileValidationProgram extends string ? ReadonlyAccount : TAccountProfileValidationProgram, TAccountCharacter extends string ? WritableAccount : TAccountCharacter, TAccountFleet extends string ? WritableAccount : TAccountFleet, TAccountSystem extends string ? WritableAccount : TAccountSystem, TAccountLoot extends string ? WritableSignerAccount & AccountSignerMeta : TAccountLoot, TAccountRegionTracker extends string ? WritableAccount : TAccountRegionTracker, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountInstructionsSysvar extends string ? ReadonlyAccount : TAccountInstructionsSysvar, TAccountRecentSlothashes extends string ? ReadonlyAccount : TAccountRecentSlothashes, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, TAccountFactionRelationTracker extends string ? ReadonlyAccount : TAccountFactionRelationTracker, TAccountFactionOwnership extends string ? WritableAccount : TAccountFactionOwnership, TAccountCrewBinding extends string ? WritableAccount : TAccountCrewBinding, TAccountAttackerFleetOwnership extends string ? ReadonlyAccount : TAccountAttackerFleetOwnership, TAccountAttackerFactionAccount extends string ? WritableAccount : TAccountAttackerFactionAccount, TAccountFactionEconomicsConfig extends string ? ReadonlyAccount : TAccountFactionEconomicsConfig, TAccountCaptorTreasury extends string ? WritableAccount : TAccountCaptorTreasury, TAccountRewardRegistry extends string ? ReadonlyAccount : TAccountRewardRegistry, TAccountRewardConfig extends string ? ReadonlyAccount : TAccountRewardConfig, TAccountKingTracker extends string ? WritableAccount : TAccountKingTracker, TAccountXpBudget extends string ? WritableAccount : TAccountXpBudget, TAccountXpBudgetConfig extends string ? ReadonlyAccount : TAccountXpBudgetConfig, TAccountRentCatalog extends string ? ReadonlyAccount : TAccountRentCatalog, TAccountRentHead extends string ? WritableAccount : TAccountRentHead, TAccountRentCurrentPage extends string ? WritableAccount : TAccountRentCurrentPage, TAccountRentNextPage extends string ? WritableAccount : TAccountRentNextPage, TAccountDemocracyHistoryHistory extends string ? WritableAccount : TAccountDemocracyHistoryHistory, TAccountDemocracyHistoryPolicy extends string ? ReadonlyAccount : TAccountDemocracyHistoryPolicy, TAccountDemocracyHistoryGeneration extends string ? WritableAccount : TAccountDemocracyHistoryGeneration, ...TRemainingAccounts, ] >; export type AttackStarbaseInstructionData = { discriminator: ReadonlyUint8Array; /** The index of the key in the player profile */ keyIndex: number; /** * The attacking stance * TODO: actually use this */ stance: FleetStance; }; export type AttackStarbaseInstructionDataArgs = { /** The index of the key in the player profile */ keyIndex: number; /** * The attacking stance * TODO: actually use this */ stance: FleetStanceArgs; }; export function getAttackStarbaseInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['keyIndex', getU16Encoder()], ['stance', getFleetStanceEncoder()], ]), (value) => ({ ...value, discriminator: ATTACK_STARBASE_DISCRIMINATOR }), ); } export function getAttackStarbaseInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['keyIndex', getU16Decoder()], ['stance', getFleetStanceDecoder()], ]); } export function getAttackStarbaseInstructionDataCodec(): FixedSizeCodec< AttackStarbaseInstructionDataArgs, AttackStarbaseInstructionData > { return combineCodec( getAttackStarbaseInstructionDataEncoder(), getAttackStarbaseInstructionDataDecoder(), ); } export type AttackStarbaseAsyncInput< TAccountProfileValidationSigner extends string = string, TAccountProfileValidationProfile extends string = string, TAccountProfileValidationCertificate extends string = string, TAccountProfileValidationProgram extends string = string, TAccountCharacter extends string = string, TAccountFleet extends string = string, TAccountSystem extends string = string, TAccountLoot extends string = string, TAccountRegionTracker extends string = string, TAccountGame extends string = string, TAccountInstructionsSysvar extends string = string, TAccountRecentSlothashes extends string = string, TAccountSystemProgram extends string = string, TAccountFactionRelationTracker extends string = string, TAccountFactionOwnership extends string = string, TAccountCrewBinding extends string = string, TAccountAttackerFleetOwnership extends string = string, TAccountAttackerFactionAccount extends string = string, TAccountFactionEconomicsConfig extends string = string, TAccountCaptorTreasury extends string = string, TAccountRewardRegistry extends string = string, TAccountRewardConfig extends string = string, TAccountKingTracker extends string = string, TAccountXpBudget extends string = string, TAccountXpBudgetConfig extends string = string, TAccountRentCatalog extends string = string, TAccountRentHead extends string = string, TAccountRentCurrentPage extends string = string, TAccountRentNextPage extends string = string, TAccountDemocracyHistoryHistory extends string = string, TAccountDemocracyHistoryPolicy extends string = string, TAccountDemocracyHistoryGeneration extends string = string, > = { profileValidationSigner: TransactionSigner; profileValidationProfile: Address; profileValidationCertificate?: Address; profileValidationProgram?: Address; /** The character of the profile */ character?: Address; /** * The `Fleet` account * Must be alive and have normalized crew */ fleet: Address; /** The system account */ system: Address; /** The loot account */ loot: TransactionSigner; /** Region tracker account */ regionTracker: Address; /** The game account */ game: Address; /** Solana Instructions Sysvar */ instructionsSysvar?: Address; /** Recent slot hashes used to seed combat outcome randomness */ recentSlothashes: Address; /** The Solana System program */ systemProgram?: Address; /** * P3 diplomacy combat-gate (REQUIRED — enforced, non-bypassable). Always passed (one tracker per game). * `combat_gating_enabled == 0` ⇒ no-op (pre-P3 behavior — same-faction still enforced by `validate()`); * `1` ⇒ forbids attacking an Allied/active-Ceasefire faction's starbase inside that faction's OWNED territory. */ factionRelationTracker: Address; /** * P4 dynamic-ownership sidecar for THIS starbase (Optional). REQUIRED ⇔ `dynamic_capture_enabled != 0` * (enforced in `process`, STEP 0). PDA proven by `Seeds` — the `game_id` seed makes the address * game-scoped (a wrong-game sidecar derives a different PDA ⇒ `AddressMismatch`); STEP 0 also asserts * `game_id` directly (defense-in-depth). Absent ⇒ pure legacy combat (pre-P4 behavior, byte-identical). * * NOTE (client SDKs): the seeds use the `starbase_seeds(...)` helper, which the IDL extractor cannot * introspect into a `pdaNode` (a const `asset_kind` seed is not expressible via `#[idl(arg = Seeds)]`). * Callers derive it by hand: `[b"FactionOwnership", game, &[0u8], system.to_bytes()]`. */ factionOwnership?: Address; crewBinding?: Address; /** * P5b: the ATTACKER fleet's `FactionOwnership(FLEET)` sidecar (Optional, read-only). Present ⇔ an NPC * attacker — it resolves `attacker_id` to a dynamic minor id `> 3` so the COMBATANT path activates. PDA * seed-bound to `self.fleet`. Absent / nemesis OFF ⇒ legacy resolution (byte-identical to P4). Appended * AFTER `crew_binding` (canonical tail: faction_ownership → crew_binding → P5b's four). */ attackerFleetOwnership?: Address; /** * P5b: the attacker faction's registry account (Optional, Mut). Serves BOTH the COMBATANT capability * guard for a dynamic NPC attacker AND the per-faction anti-blitz `last_capture_at` stamp on capture. Its * PDA is re-derived from the RESOLVED `attacker_id` in `process()` (capability-forgery defense). */ attackerFactionAccount?: Address; /** * P5b: the per-game NPC-economy dials (Optional, read-only) — the capture cooldown + cost. REQUIRED on a * dynamic NPC capture (so the anti-blitz cannot be dodged by omitting it). */ factionEconomicsConfig?: Address; /** * P5b: the captor faction's treasury (Optional, Mut) — debited `capture_cost_atlas` via the per-epoch * meter on a dynamic NPC capture (skin-in-the-game; a defunded faction cannot pay ⇒ self-quieting). Its * PDA is bound to `attacker_id` in STEP H. */ captorTreasury?: Address; /** * Event-time reward config and King tracker. Mandatory so a caller cannot omit tier rewards or * ownership-count maintenance when a starbase is downgraded/taken over. */ rewardRegistry: Address; rewardConfig: Address; kingTracker: Address; xpBudget?: Address; xpBudgetConfig?: Address; /** The game's rent catalog PDA (REQUIRED, may be uninitialized = Disabled). */ rentCatalog: Address; /** The target system's LEVEL source-head PDA (REQUIRED, may be uninitialized = a legacy source). */ rentHead: Address; /** The page holding the head's latest record (required iff the head exists). */ rentCurrentPage?: Address; /** The following page, created on demand (required iff the head exists). */ rentNextPage?: Address; democracyHistoryHistory: Address; democracyHistoryPolicy?: Address; democracyHistoryGeneration?: Address; keyIndex: AttackStarbaseInstructionDataArgs['keyIndex']; stance: AttackStarbaseInstructionDataArgs['stance']; }; export async function getAttackStarbaseInstructionAsync< TAccountProfileValidationSigner extends string, TAccountProfileValidationProfile extends string, TAccountProfileValidationCertificate extends string, TAccountProfileValidationProgram extends string, TAccountCharacter extends string, TAccountFleet extends string, TAccountSystem extends string, TAccountLoot extends string, TAccountRegionTracker extends string, TAccountGame extends string, TAccountInstructionsSysvar extends string, TAccountRecentSlothashes extends string, TAccountSystemProgram extends string, TAccountFactionRelationTracker extends string, TAccountFactionOwnership extends string, TAccountCrewBinding extends string, TAccountAttackerFleetOwnership extends string, TAccountAttackerFactionAccount extends string, TAccountFactionEconomicsConfig extends string, TAccountCaptorTreasury extends string, TAccountRewardRegistry extends string, TAccountRewardConfig extends string, TAccountKingTracker extends string, TAccountXpBudget extends string, TAccountXpBudgetConfig extends string, TAccountRentCatalog extends string, TAccountRentHead extends string, TAccountRentCurrentPage extends string, TAccountRentNextPage extends string, TAccountDemocracyHistoryHistory extends string, TAccountDemocracyHistoryPolicy extends string, TAccountDemocracyHistoryGeneration extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: AttackStarbaseAsyncInput< TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountCharacter, TAccountFleet, TAccountSystem, TAccountLoot, TAccountRegionTracker, TAccountGame, TAccountInstructionsSysvar, TAccountRecentSlothashes, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionOwnership, TAccountCrewBinding, TAccountAttackerFleetOwnership, TAccountAttackerFactionAccount, TAccountFactionEconomicsConfig, TAccountCaptorTreasury, TAccountRewardRegistry, TAccountRewardConfig, TAccountKingTracker, TAccountXpBudget, TAccountXpBudgetConfig, TAccountRentCatalog, TAccountRentHead, TAccountRentCurrentPage, TAccountRentNextPage, TAccountDemocracyHistoryHistory, TAccountDemocracyHistoryPolicy, TAccountDemocracyHistoryGeneration >, config?: { programAddress?: TProgramAddress }, ): Promise< AttackStarbaseInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountCharacter, TAccountFleet, TAccountSystem, TAccountLoot, TAccountRegionTracker, TAccountGame, TAccountInstructionsSysvar, TAccountRecentSlothashes, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionOwnership, TAccountCrewBinding, TAccountAttackerFleetOwnership, TAccountAttackerFactionAccount, TAccountFactionEconomicsConfig, TAccountCaptorTreasury, TAccountRewardRegistry, TAccountRewardConfig, TAccountKingTracker, TAccountXpBudget, TAccountXpBudgetConfig, TAccountRentCatalog, TAccountRentHead, TAccountRentCurrentPage, TAccountRentNextPage, TAccountDemocracyHistoryHistory, TAccountDemocracyHistoryPolicy, TAccountDemocracyHistoryGeneration > > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { profileValidationSigner: { value: input.profileValidationSigner ?? null, isWritable: false, }, profileValidationProfile: { value: input.profileValidationProfile ?? null, isWritable: true, }, profileValidationCertificate: { value: input.profileValidationCertificate ?? null, isWritable: false, }, profileValidationProgram: { value: input.profileValidationProgram ?? null, isWritable: false, }, character: { value: input.character ?? null, isWritable: true }, fleet: { value: input.fleet ?? null, isWritable: true }, system: { value: input.system ?? null, isWritable: true }, loot: { value: input.loot ?? null, isWritable: true }, regionTracker: { value: input.regionTracker ?? null, isWritable: true }, game: { value: input.game ?? null, isWritable: false }, instructionsSysvar: { value: input.instructionsSysvar ?? null, isWritable: false, }, recentSlothashes: { value: input.recentSlothashes ?? null, isWritable: false, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, factionRelationTracker: { value: input.factionRelationTracker ?? null, isWritable: false, }, factionOwnership: { value: input.factionOwnership ?? null, isWritable: true, }, crewBinding: { value: input.crewBinding ?? null, isWritable: true }, attackerFleetOwnership: { value: input.attackerFleetOwnership ?? null, isWritable: false, }, attackerFactionAccount: { value: input.attackerFactionAccount ?? null, isWritable: true, }, factionEconomicsConfig: { value: input.factionEconomicsConfig ?? null, isWritable: false, }, captorTreasury: { value: input.captorTreasury ?? null, isWritable: true }, rewardRegistry: { value: input.rewardRegistry ?? null, isWritable: false }, rewardConfig: { value: input.rewardConfig ?? null, isWritable: false }, kingTracker: { value: input.kingTracker ?? null, isWritable: true }, xpBudget: { value: input.xpBudget ?? null, isWritable: true }, xpBudgetConfig: { value: input.xpBudgetConfig ?? null, isWritable: false }, rentCatalog: { value: input.rentCatalog ?? null, isWritable: false }, rentHead: { value: input.rentHead ?? null, isWritable: true }, rentCurrentPage: { value: input.rentCurrentPage ?? null, isWritable: true }, rentNextPage: { value: input.rentNextPage ?? null, isWritable: true }, democracyHistoryHistory: { value: input.democracyHistoryHistory ?? null, isWritable: true, }, democracyHistoryPolicy: { value: input.democracyHistoryPolicy ?? null, isWritable: false, }, democracyHistoryGeneration: { value: input.democracyHistoryGeneration ?? null, isWritable: true, }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.profileValidationProgram.value) { accounts.profileValidationProgram.value = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u' as Address<'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u'>; } 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( 'profileValidationProfile', accounts.profileValidationProfile.value, ), ), getAddressEncoder().encode( getAddressFromResolvedInstructionAccount('game', accounts.game.value), ), ], }); } if (!accounts.instructionsSysvar.value) { accounts.instructionsSysvar.value = 'Sysvar1nstructions1111111111111111111111111' as Address<'Sysvar1nstructions1111111111111111111111111'>; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta( 'profileValidationSigner', accounts.profileValidationSigner, ), getAccountMeta( 'profileValidationProfile', accounts.profileValidationProfile, ), getAccountMeta( 'profileValidationCertificate', accounts.profileValidationCertificate, ), getAccountMeta( 'profileValidationProgram', accounts.profileValidationProgram, ), getAccountMeta('character', accounts.character), getAccountMeta('fleet', accounts.fleet), getAccountMeta('system', accounts.system), getAccountMeta('loot', accounts.loot), getAccountMeta('regionTracker', accounts.regionTracker), getAccountMeta('game', accounts.game), getAccountMeta('instructionsSysvar', accounts.instructionsSysvar), getAccountMeta('recentSlothashes', accounts.recentSlothashes), getAccountMeta('systemProgram', accounts.systemProgram), getAccountMeta('factionRelationTracker', accounts.factionRelationTracker), getAccountMeta('factionOwnership', accounts.factionOwnership), getAccountMeta('crewBinding', accounts.crewBinding), getAccountMeta('attackerFleetOwnership', accounts.attackerFleetOwnership), getAccountMeta('attackerFactionAccount', accounts.attackerFactionAccount), getAccountMeta('factionEconomicsConfig', accounts.factionEconomicsConfig), getAccountMeta('captorTreasury', accounts.captorTreasury), getAccountMeta('rewardRegistry', accounts.rewardRegistry), getAccountMeta('rewardConfig', accounts.rewardConfig), getAccountMeta('kingTracker', accounts.kingTracker), getAccountMeta('xpBudget', accounts.xpBudget), getAccountMeta('xpBudgetConfig', accounts.xpBudgetConfig), getAccountMeta('rentCatalog', accounts.rentCatalog), getAccountMeta('rentHead', accounts.rentHead), getAccountMeta('rentCurrentPage', accounts.rentCurrentPage), getAccountMeta('rentNextPage', accounts.rentNextPage), getAccountMeta( 'democracyHistoryHistory', accounts.democracyHistoryHistory, ), getAccountMeta('democracyHistoryPolicy', accounts.democracyHistoryPolicy), getAccountMeta( 'democracyHistoryGeneration', accounts.democracyHistoryGeneration, ), ], data: getAttackStarbaseInstructionDataEncoder().encode( args as AttackStarbaseInstructionDataArgs, ), programAddress, } as AttackStarbaseInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountCharacter, TAccountFleet, TAccountSystem, TAccountLoot, TAccountRegionTracker, TAccountGame, TAccountInstructionsSysvar, TAccountRecentSlothashes, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionOwnership, TAccountCrewBinding, TAccountAttackerFleetOwnership, TAccountAttackerFactionAccount, TAccountFactionEconomicsConfig, TAccountCaptorTreasury, TAccountRewardRegistry, TAccountRewardConfig, TAccountKingTracker, TAccountXpBudget, TAccountXpBudgetConfig, TAccountRentCatalog, TAccountRentHead, TAccountRentCurrentPage, TAccountRentNextPage, TAccountDemocracyHistoryHistory, TAccountDemocracyHistoryPolicy, TAccountDemocracyHistoryGeneration >); } export type AttackStarbaseInput< TAccountProfileValidationSigner extends string = string, TAccountProfileValidationProfile extends string = string, TAccountProfileValidationCertificate extends string = string, TAccountProfileValidationProgram extends string = string, TAccountCharacter extends string = string, TAccountFleet extends string = string, TAccountSystem extends string = string, TAccountLoot extends string = string, TAccountRegionTracker extends string = string, TAccountGame extends string = string, TAccountInstructionsSysvar extends string = string, TAccountRecentSlothashes extends string = string, TAccountSystemProgram extends string = string, TAccountFactionRelationTracker extends string = string, TAccountFactionOwnership extends string = string, TAccountCrewBinding extends string = string, TAccountAttackerFleetOwnership extends string = string, TAccountAttackerFactionAccount extends string = string, TAccountFactionEconomicsConfig extends string = string, TAccountCaptorTreasury extends string = string, TAccountRewardRegistry extends string = string, TAccountRewardConfig extends string = string, TAccountKingTracker extends string = string, TAccountXpBudget extends string = string, TAccountXpBudgetConfig extends string = string, TAccountRentCatalog extends string = string, TAccountRentHead extends string = string, TAccountRentCurrentPage extends string = string, TAccountRentNextPage extends string = string, TAccountDemocracyHistoryHistory extends string = string, TAccountDemocracyHistoryPolicy extends string = string, TAccountDemocracyHistoryGeneration extends string = string, > = { profileValidationSigner: TransactionSigner; profileValidationProfile: Address; profileValidationCertificate?: Address; profileValidationProgram?: Address; /** The character of the profile */ character: Address; /** * The `Fleet` account * Must be alive and have normalized crew */ fleet: Address; /** The system account */ system: Address; /** The loot account */ loot: TransactionSigner; /** Region tracker account */ regionTracker: Address; /** The game account */ game: Address; /** Solana Instructions Sysvar */ instructionsSysvar?: Address; /** Recent slot hashes used to seed combat outcome randomness */ recentSlothashes: Address; /** The Solana System program */ systemProgram?: Address; /** * P3 diplomacy combat-gate (REQUIRED — enforced, non-bypassable). Always passed (one tracker per game). * `combat_gating_enabled == 0` ⇒ no-op (pre-P3 behavior — same-faction still enforced by `validate()`); * `1` ⇒ forbids attacking an Allied/active-Ceasefire faction's starbase inside that faction's OWNED territory. */ factionRelationTracker: Address; /** * P4 dynamic-ownership sidecar for THIS starbase (Optional). REQUIRED ⇔ `dynamic_capture_enabled != 0` * (enforced in `process`, STEP 0). PDA proven by `Seeds` — the `game_id` seed makes the address * game-scoped (a wrong-game sidecar derives a different PDA ⇒ `AddressMismatch`); STEP 0 also asserts * `game_id` directly (defense-in-depth). Absent ⇒ pure legacy combat (pre-P4 behavior, byte-identical). * * NOTE (client SDKs): the seeds use the `starbase_seeds(...)` helper, which the IDL extractor cannot * introspect into a `pdaNode` (a const `asset_kind` seed is not expressible via `#[idl(arg = Seeds)]`). * Callers derive it by hand: `[b"FactionOwnership", game, &[0u8], system.to_bytes()]`. */ factionOwnership?: Address; crewBinding?: Address; /** * P5b: the ATTACKER fleet's `FactionOwnership(FLEET)` sidecar (Optional, read-only). Present ⇔ an NPC * attacker — it resolves `attacker_id` to a dynamic minor id `> 3` so the COMBATANT path activates. PDA * seed-bound to `self.fleet`. Absent / nemesis OFF ⇒ legacy resolution (byte-identical to P4). Appended * AFTER `crew_binding` (canonical tail: faction_ownership → crew_binding → P5b's four). */ attackerFleetOwnership?: Address; /** * P5b: the attacker faction's registry account (Optional, Mut). Serves BOTH the COMBATANT capability * guard for a dynamic NPC attacker AND the per-faction anti-blitz `last_capture_at` stamp on capture. Its * PDA is re-derived from the RESOLVED `attacker_id` in `process()` (capability-forgery defense). */ attackerFactionAccount?: Address; /** * P5b: the per-game NPC-economy dials (Optional, read-only) — the capture cooldown + cost. REQUIRED on a * dynamic NPC capture (so the anti-blitz cannot be dodged by omitting it). */ factionEconomicsConfig?: Address; /** * P5b: the captor faction's treasury (Optional, Mut) — debited `capture_cost_atlas` via the per-epoch * meter on a dynamic NPC capture (skin-in-the-game; a defunded faction cannot pay ⇒ self-quieting). Its * PDA is bound to `attacker_id` in STEP H. */ captorTreasury?: Address; /** * Event-time reward config and King tracker. Mandatory so a caller cannot omit tier rewards or * ownership-count maintenance when a starbase is downgraded/taken over. */ rewardRegistry: Address; rewardConfig: Address; kingTracker: Address; xpBudget?: Address; xpBudgetConfig?: Address; /** The game's rent catalog PDA (REQUIRED, may be uninitialized = Disabled). */ rentCatalog: Address; /** The target system's LEVEL source-head PDA (REQUIRED, may be uninitialized = a legacy source). */ rentHead: Address; /** The page holding the head's latest record (required iff the head exists). */ rentCurrentPage?: Address; /** The following page, created on demand (required iff the head exists). */ rentNextPage?: Address; democracyHistoryHistory: Address; democracyHistoryPolicy?: Address; democracyHistoryGeneration?: Address; keyIndex: AttackStarbaseInstructionDataArgs['keyIndex']; stance: AttackStarbaseInstructionDataArgs['stance']; }; export function getAttackStarbaseInstruction< TAccountProfileValidationSigner extends string, TAccountProfileValidationProfile extends string, TAccountProfileValidationCertificate extends string, TAccountProfileValidationProgram extends string, TAccountCharacter extends string, TAccountFleet extends string, TAccountSystem extends string, TAccountLoot extends string, TAccountRegionTracker extends string, TAccountGame extends string, TAccountInstructionsSysvar extends string, TAccountRecentSlothashes extends string, TAccountSystemProgram extends string, TAccountFactionRelationTracker extends string, TAccountFactionOwnership extends string, TAccountCrewBinding extends string, TAccountAttackerFleetOwnership extends string, TAccountAttackerFactionAccount extends string, TAccountFactionEconomicsConfig extends string, TAccountCaptorTreasury extends string, TAccountRewardRegistry extends string, TAccountRewardConfig extends string, TAccountKingTracker extends string, TAccountXpBudget extends string, TAccountXpBudgetConfig extends string, TAccountRentCatalog extends string, TAccountRentHead extends string, TAccountRentCurrentPage extends string, TAccountRentNextPage extends string, TAccountDemocracyHistoryHistory extends string, TAccountDemocracyHistoryPolicy extends string, TAccountDemocracyHistoryGeneration extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: AttackStarbaseInput< TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountCharacter, TAccountFleet, TAccountSystem, TAccountLoot, TAccountRegionTracker, TAccountGame, TAccountInstructionsSysvar, TAccountRecentSlothashes, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionOwnership, TAccountCrewBinding, TAccountAttackerFleetOwnership, TAccountAttackerFactionAccount, TAccountFactionEconomicsConfig, TAccountCaptorTreasury, TAccountRewardRegistry, TAccountRewardConfig, TAccountKingTracker, TAccountXpBudget, TAccountXpBudgetConfig, TAccountRentCatalog, TAccountRentHead, TAccountRentCurrentPage, TAccountRentNextPage, TAccountDemocracyHistoryHistory, TAccountDemocracyHistoryPolicy, TAccountDemocracyHistoryGeneration >, config?: { programAddress?: TProgramAddress }, ): AttackStarbaseInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountCharacter, TAccountFleet, TAccountSystem, TAccountLoot, TAccountRegionTracker, TAccountGame, TAccountInstructionsSysvar, TAccountRecentSlothashes, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionOwnership, TAccountCrewBinding, TAccountAttackerFleetOwnership, TAccountAttackerFactionAccount, TAccountFactionEconomicsConfig, TAccountCaptorTreasury, TAccountRewardRegistry, TAccountRewardConfig, TAccountKingTracker, TAccountXpBudget, TAccountXpBudgetConfig, TAccountRentCatalog, TAccountRentHead, TAccountRentCurrentPage, TAccountRentNextPage, TAccountDemocracyHistoryHistory, TAccountDemocracyHistoryPolicy, TAccountDemocracyHistoryGeneration > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { profileValidationSigner: { value: input.profileValidationSigner ?? null, isWritable: false, }, profileValidationProfile: { value: input.profileValidationProfile ?? null, isWritable: true, }, profileValidationCertificate: { value: input.profileValidationCertificate ?? null, isWritable: false, }, profileValidationProgram: { value: input.profileValidationProgram ?? null, isWritable: false, }, character: { value: input.character ?? null, isWritable: true }, fleet: { value: input.fleet ?? null, isWritable: true }, system: { value: input.system ?? null, isWritable: true }, loot: { value: input.loot ?? null, isWritable: true }, regionTracker: { value: input.regionTracker ?? null, isWritable: true }, game: { value: input.game ?? null, isWritable: false }, instructionsSysvar: { value: input.instructionsSysvar ?? null, isWritable: false, }, recentSlothashes: { value: input.recentSlothashes ?? null, isWritable: false, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, factionRelationTracker: { value: input.factionRelationTracker ?? null, isWritable: false, }, factionOwnership: { value: input.factionOwnership ?? null, isWritable: true, }, crewBinding: { value: input.crewBinding ?? null, isWritable: true }, attackerFleetOwnership: { value: input.attackerFleetOwnership ?? null, isWritable: false, }, attackerFactionAccount: { value: input.attackerFactionAccount ?? null, isWritable: true, }, factionEconomicsConfig: { value: input.factionEconomicsConfig ?? null, isWritable: false, }, captorTreasury: { value: input.captorTreasury ?? null, isWritable: true }, rewardRegistry: { value: input.rewardRegistry ?? null, isWritable: false }, rewardConfig: { value: input.rewardConfig ?? null, isWritable: false }, kingTracker: { value: input.kingTracker ?? null, isWritable: true }, xpBudget: { value: input.xpBudget ?? null, isWritable: true }, xpBudgetConfig: { value: input.xpBudgetConfig ?? null, isWritable: false }, rentCatalog: { value: input.rentCatalog ?? null, isWritable: false }, rentHead: { value: input.rentHead ?? null, isWritable: true }, rentCurrentPage: { value: input.rentCurrentPage ?? null, isWritable: true }, rentNextPage: { value: input.rentNextPage ?? null, isWritable: true }, democracyHistoryHistory: { value: input.democracyHistoryHistory ?? null, isWritable: true, }, democracyHistoryPolicy: { value: input.democracyHistoryPolicy ?? null, isWritable: false, }, democracyHistoryGeneration: { value: input.democracyHistoryGeneration ?? null, isWritable: true, }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.profileValidationProgram.value) { accounts.profileValidationProgram.value = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u' as Address<'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u'>; } if (!accounts.instructionsSysvar.value) { accounts.instructionsSysvar.value = 'Sysvar1nstructions1111111111111111111111111' as Address<'Sysvar1nstructions1111111111111111111111111'>; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta( 'profileValidationSigner', accounts.profileValidationSigner, ), getAccountMeta( 'profileValidationProfile', accounts.profileValidationProfile, ), getAccountMeta( 'profileValidationCertificate', accounts.profileValidationCertificate, ), getAccountMeta( 'profileValidationProgram', accounts.profileValidationProgram, ), getAccountMeta('character', accounts.character), getAccountMeta('fleet', accounts.fleet), getAccountMeta('system', accounts.system), getAccountMeta('loot', accounts.loot), getAccountMeta('regionTracker', accounts.regionTracker), getAccountMeta('game', accounts.game), getAccountMeta('instructionsSysvar', accounts.instructionsSysvar), getAccountMeta('recentSlothashes', accounts.recentSlothashes), getAccountMeta('systemProgram', accounts.systemProgram), getAccountMeta('factionRelationTracker', accounts.factionRelationTracker), getAccountMeta('factionOwnership', accounts.factionOwnership), getAccountMeta('crewBinding', accounts.crewBinding), getAccountMeta('attackerFleetOwnership', accounts.attackerFleetOwnership), getAccountMeta('attackerFactionAccount', accounts.attackerFactionAccount), getAccountMeta('factionEconomicsConfig', accounts.factionEconomicsConfig), getAccountMeta('captorTreasury', accounts.captorTreasury), getAccountMeta('rewardRegistry', accounts.rewardRegistry), getAccountMeta('rewardConfig', accounts.rewardConfig), getAccountMeta('kingTracker', accounts.kingTracker), getAccountMeta('xpBudget', accounts.xpBudget), getAccountMeta('xpBudgetConfig', accounts.xpBudgetConfig), getAccountMeta('rentCatalog', accounts.rentCatalog), getAccountMeta('rentHead', accounts.rentHead), getAccountMeta('rentCurrentPage', accounts.rentCurrentPage), getAccountMeta('rentNextPage', accounts.rentNextPage), getAccountMeta( 'democracyHistoryHistory', accounts.democracyHistoryHistory, ), getAccountMeta('democracyHistoryPolicy', accounts.democracyHistoryPolicy), getAccountMeta( 'democracyHistoryGeneration', accounts.democracyHistoryGeneration, ), ], data: getAttackStarbaseInstructionDataEncoder().encode( args as AttackStarbaseInstructionDataArgs, ), programAddress, } as AttackStarbaseInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountCharacter, TAccountFleet, TAccountSystem, TAccountLoot, TAccountRegionTracker, TAccountGame, TAccountInstructionsSysvar, TAccountRecentSlothashes, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionOwnership, TAccountCrewBinding, TAccountAttackerFleetOwnership, TAccountAttackerFactionAccount, TAccountFactionEconomicsConfig, TAccountCaptorTreasury, TAccountRewardRegistry, TAccountRewardConfig, TAccountKingTracker, TAccountXpBudget, TAccountXpBudgetConfig, TAccountRentCatalog, TAccountRentHead, TAccountRentCurrentPage, TAccountRentNextPage, TAccountDemocracyHistoryHistory, TAccountDemocracyHistoryPolicy, TAccountDemocracyHistoryGeneration >); } export type ParsedAttackStarbaseInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { profileValidationSigner: TAccountMetas[0]; profileValidationProfile: TAccountMetas[1]; profileValidationCertificate?: TAccountMetas[2] | undefined; profileValidationProgram: TAccountMetas[3]; /** The character of the profile */ character: TAccountMetas[4]; /** * The `Fleet` account * Must be alive and have normalized crew */ fleet: TAccountMetas[5]; /** The system account */ system: TAccountMetas[6]; /** The loot account */ loot: TAccountMetas[7]; /** Region tracker account */ regionTracker: TAccountMetas[8]; /** The game account */ game: TAccountMetas[9]; /** Solana Instructions Sysvar */ instructionsSysvar: TAccountMetas[10]; /** Recent slot hashes used to seed combat outcome randomness */ recentSlothashes: TAccountMetas[11]; /** The Solana System program */ systemProgram: TAccountMetas[12]; /** * P3 diplomacy combat-gate (REQUIRED — enforced, non-bypassable). Always passed (one tracker per game). * `combat_gating_enabled == 0` ⇒ no-op (pre-P3 behavior — same-faction still enforced by `validate()`); * `1` ⇒ forbids attacking an Allied/active-Ceasefire faction's starbase inside that faction's OWNED territory. */ factionRelationTracker: TAccountMetas[13]; /** * P4 dynamic-ownership sidecar for THIS starbase (Optional). REQUIRED ⇔ `dynamic_capture_enabled != 0` * (enforced in `process`, STEP 0). PDA proven by `Seeds` — the `game_id` seed makes the address * game-scoped (a wrong-game sidecar derives a different PDA ⇒ `AddressMismatch`); STEP 0 also asserts * `game_id` directly (defense-in-depth). Absent ⇒ pure legacy combat (pre-P4 behavior, byte-identical). * * NOTE (client SDKs): the seeds use the `starbase_seeds(...)` helper, which the IDL extractor cannot * introspect into a `pdaNode` (a const `asset_kind` seed is not expressible via `#[idl(arg = Seeds)]`). * Callers derive it by hand: `[b"FactionOwnership", game, &[0u8], system.to_bytes()]`. */ factionOwnership?: TAccountMetas[14] | undefined; crewBinding?: TAccountMetas[15] | undefined; /** * P5b: the ATTACKER fleet's `FactionOwnership(FLEET)` sidecar (Optional, read-only). Present ⇔ an NPC * attacker — it resolves `attacker_id` to a dynamic minor id `> 3` so the COMBATANT path activates. PDA * seed-bound to `self.fleet`. Absent / nemesis OFF ⇒ legacy resolution (byte-identical to P4). Appended * AFTER `crew_binding` (canonical tail: faction_ownership → crew_binding → P5b's four). */ attackerFleetOwnership?: TAccountMetas[16] | undefined; /** * P5b: the attacker faction's registry account (Optional, Mut). Serves BOTH the COMBATANT capability * guard for a dynamic NPC attacker AND the per-faction anti-blitz `last_capture_at` stamp on capture. Its * PDA is re-derived from the RESOLVED `attacker_id` in `process()` (capability-forgery defense). */ attackerFactionAccount?: TAccountMetas[17] | undefined; /** * P5b: the per-game NPC-economy dials (Optional, read-only) — the capture cooldown + cost. REQUIRED on a * dynamic NPC capture (so the anti-blitz cannot be dodged by omitting it). */ factionEconomicsConfig?: TAccountMetas[18] | undefined; /** * P5b: the captor faction's treasury (Optional, Mut) — debited `capture_cost_atlas` via the per-epoch * meter on a dynamic NPC capture (skin-in-the-game; a defunded faction cannot pay ⇒ self-quieting). Its * PDA is bound to `attacker_id` in STEP H. */ captorTreasury?: TAccountMetas[19] | undefined; /** * Event-time reward config and King tracker. Mandatory so a caller cannot omit tier rewards or * ownership-count maintenance when a starbase is downgraded/taken over. */ rewardRegistry: TAccountMetas[20]; rewardConfig: TAccountMetas[21]; kingTracker: TAccountMetas[22]; xpBudget?: TAccountMetas[23] | undefined; xpBudgetConfig?: TAccountMetas[24] | undefined; /** The game's rent catalog PDA (REQUIRED, may be uninitialized = Disabled). */ rentCatalog: TAccountMetas[25]; /** The target system's LEVEL source-head PDA (REQUIRED, may be uninitialized = a legacy source). */ rentHead: TAccountMetas[26]; /** The page holding the head's latest record (required iff the head exists). */ rentCurrentPage?: TAccountMetas[27] | undefined; /** The following page, created on demand (required iff the head exists). */ rentNextPage?: TAccountMetas[28] | undefined; democracyHistoryHistory: TAccountMetas[29]; democracyHistoryPolicy?: TAccountMetas[30] | undefined; democracyHistoryGeneration?: TAccountMetas[31] | undefined; }; data: AttackStarbaseInstructionData; }; export function parseAttackStarbaseInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedAttackStarbaseInstruction { if (instruction.accounts.length < 32) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 32, }, ); } 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: { profileValidationSigner: getNextAccount(), profileValidationProfile: getNextAccount(), profileValidationCertificate: getNextOptionalAccount(), profileValidationProgram: getNextAccount(), character: getNextAccount(), fleet: getNextAccount(), system: getNextAccount(), loot: getNextAccount(), regionTracker: getNextAccount(), game: getNextAccount(), instructionsSysvar: getNextAccount(), recentSlothashes: getNextAccount(), systemProgram: getNextAccount(), factionRelationTracker: getNextAccount(), factionOwnership: getNextOptionalAccount(), crewBinding: getNextOptionalAccount(), attackerFleetOwnership: getNextOptionalAccount(), attackerFactionAccount: getNextOptionalAccount(), factionEconomicsConfig: getNextOptionalAccount(), captorTreasury: getNextOptionalAccount(), rewardRegistry: getNextAccount(), rewardConfig: getNextAccount(), kingTracker: getNextAccount(), xpBudget: getNextOptionalAccount(), xpBudgetConfig: getNextOptionalAccount(), rentCatalog: getNextAccount(), rentHead: getNextAccount(), rentCurrentPage: getNextOptionalAccount(), rentNextPage: getNextOptionalAccount(), democracyHistoryHistory: getNextAccount(), democracyHistoryPolicy: getNextOptionalAccount(), democracyHistoryGeneration: getNextOptionalAccount(), }, data: getAttackStarbaseInstructionDataDecoder().decode(instruction.data), }; }