/** * 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, getU8Decoder, getU8Encoder, 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, } from '@solana/kit'; import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount, } from '@solana/program-client-core'; import { SAGE_PROGRAM_ADDRESS } from '../programs'; import { getMinorFactionIdDecoder, getMinorFactionIdEncoder, getNameDecoder, getNameEncoder, type MinorFactionId, type MinorFactionIdArgs, type Name, type NameArgs, } from '../types'; export const MINT_NPC_FLEET_DISCRIMINATOR = new Uint8Array([ 70, 84, 99, 63, 237, 206, 69, 66, ]); export function getMintNpcFleetDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( MINT_NPC_FLEET_DISCRIMINATOR, ); } export type MintNpcFleetInstruction< 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', TAccountAdminSigner extends string | AccountMeta = string, TAccountAdminProfile extends string | AccountMeta = string, TAccountAdminCertificate extends string | AccountMeta = string, TAccountAdminProgram extends string | AccountMeta = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u', TAccountProfileFaction extends string | AccountMeta = string, TAccountCharacter extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TAccountFleet extends string | AccountMeta = string, TAccountFactionAccount extends string | AccountMeta = string, TAccountFactionOwnership extends string | AccountMeta = string, TAccountFactionTreasury extends string | AccountMeta = string, TAccountFactionEconomicsConfig extends string | AccountMeta = string, TAccountSystemAndStarbasePlayerSystem extends string | AccountMeta = string, TAccountSystemAndStarbasePlayerStarbasePlayer extends | string | AccountMeta = string, TAccountSystemProgram extends string | AccountMeta = '11111111111111111111111111111111', 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, TAccountAdminSigner extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountAdminSigner, TAccountAdminProfile extends string ? WritableAccount : TAccountAdminProfile, TAccountAdminCertificate extends string ? ReadonlyAccount : TAccountAdminCertificate, TAccountAdminProgram extends string ? ReadonlyAccount : TAccountAdminProgram, TAccountProfileFaction extends string ? ReadonlyAccount : TAccountProfileFaction, TAccountCharacter extends string ? WritableAccount : TAccountCharacter, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountFleet extends string ? WritableAccount : TAccountFleet, TAccountFactionAccount extends string ? WritableAccount : TAccountFactionAccount, TAccountFactionOwnership extends string ? WritableAccount : TAccountFactionOwnership, TAccountFactionTreasury extends string ? WritableAccount : TAccountFactionTreasury, TAccountFactionEconomicsConfig extends string ? ReadonlyAccount : TAccountFactionEconomicsConfig, TAccountSystemAndStarbasePlayerSystem extends string ? ReadonlyAccount : TAccountSystemAndStarbasePlayerSystem, TAccountSystemAndStarbasePlayerStarbasePlayer extends string ? WritableAccount : TAccountSystemAndStarbasePlayerStarbasePlayer, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, ...TRemainingAccounts, ] >; export type MintNpcFleetInstructionData = { discriminator: ReadonlyUint8Array; /** The fleet label (the operator profile's fleet seed component — clone of `CreateFleet::fleet_label`). */ fleetLabel: Name; /** The OPERATOR profile's signing key index (the fleet owner + treasury spender). */ operatorKeyIndex: number; /** The ADMIN (`MANAGE_FACTIONS`) profile's signing key index (the co-signer that authorizes the spawn). */ adminKeyIndex: number; /** The faction to mint for (seeds the faction account / treasury; must be `Active` and own the operator). */ factionId: MinorFactionId; /** Initial directive kind byte (`FleetDirectiveKind`; `NemesisHunt`/unknown rejected). Run-only. */ initialDirective: number; /** Initial off-chain aggression dial (0–100; no on-chain rate consequence). Run-only. */ aggression: number; }; export type MintNpcFleetInstructionDataArgs = { /** The fleet label (the operator profile's fleet seed component — clone of `CreateFleet::fleet_label`). */ fleetLabel: NameArgs; /** The OPERATOR profile's signing key index (the fleet owner + treasury spender). */ operatorKeyIndex: number; /** The ADMIN (`MANAGE_FACTIONS`) profile's signing key index (the co-signer that authorizes the spawn). */ adminKeyIndex: number; /** The faction to mint for (seeds the faction account / treasury; must be `Active` and own the operator). */ factionId: MinorFactionIdArgs; /** Initial directive kind byte (`FleetDirectiveKind`; `NemesisHunt`/unknown rejected). Run-only. */ initialDirective: number; /** Initial off-chain aggression dial (0–100; no on-chain rate consequence). Run-only. */ aggression: number; }; export function getMintNpcFleetInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['fleetLabel', getNameEncoder()], ['operatorKeyIndex', getU16Encoder()], ['adminKeyIndex', getU16Encoder()], ['factionId', getMinorFactionIdEncoder()], ['initialDirective', getU8Encoder()], ['aggression', getU8Encoder()], ]), (value) => ({ ...value, discriminator: MINT_NPC_FLEET_DISCRIMINATOR }), ); } export function getMintNpcFleetInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['fleetLabel', getNameDecoder()], ['operatorKeyIndex', getU16Decoder()], ['adminKeyIndex', getU16Decoder()], ['factionId', getMinorFactionIdDecoder()], ['initialDirective', getU8Decoder()], ['aggression', getU8Decoder()], ]); } export function getMintNpcFleetInstructionDataCodec(): FixedSizeCodec< MintNpcFleetInstructionDataArgs, MintNpcFleetInstructionData > { return combineCodec( getMintNpcFleetInstructionDataEncoder(), getMintNpcFleetInstructionDataDecoder(), ); } export type MintNpcFleetAsyncInput< TAccountProfileValidationSigner extends string = string, TAccountProfileValidationProfile extends string = string, TAccountProfileValidationCertificate extends string = string, TAccountProfileValidationProgram extends string = string, TAccountAdminSigner extends string = string, TAccountAdminProfile extends string = string, TAccountAdminCertificate extends string = string, TAccountAdminProgram extends string = string, TAccountProfileFaction extends string = string, TAccountCharacter extends string = string, TAccountGame extends string = string, TAccountFleet extends string = string, TAccountFactionAccount extends string = string, TAccountFactionOwnership extends string = string, TAccountFactionTreasury extends string = string, TAccountFactionEconomicsConfig extends string = string, TAccountSystemAndStarbasePlayerSystem extends string = string, TAccountSystemAndStarbasePlayerStarbasePlayer extends string = string, TAccountSystemProgram extends string = string, > = { profileValidationSigner: TransactionSigner; profileValidationProfile: Address; profileValidationCertificate?: Address; profileValidationProgram?: Address; adminSigner: TransactionSigner; adminProfile: Address; adminCertificate?: Address; adminProgram?: Address; /** * The OPERATOR profile's faction account (supplies the legacy `Faction` alignment stamped onto the fleet, * verbatim `CreateFleet`). */ profileFaction: Address; /** * The OPERATOR's character that belongs to [`Self::game`] (the fleet-registration concurrency bump), * verbatim `CreateFleet`. */ character?: Address; /** The game account. */ game: Address; /** The [`Fleet`] account — initialized exactly as `CreateFleet` does (owner = operator profile). */ fleet: Address; /** * The faction's registry account (`Mut` — `npc_fleet_count` is bumped). Game-scoped here; its PDA is * re-derived from `faction_id` and `ensure_eq!`-bound in `process()` (the `ClaimTerritoryYield` idiom for * a faction account that is both game-scoped AND identity-pinned — `ValidatedAccount`'s validate arg is * the `AccountValidate` arg only, so the seed proof is done in-handler). */ factionAccount: Address; /** * The FLEET dynamic-ownership sidecar — created here (the fleet's faction tag + directive payload). PDA * derived from the freshly-init fleet's key under the FLEET asset-kind, so it cannot collide with a * starbase sidecar over the same raw key. */ factionOwnership: Address; /** * The faction's treasury (`Mut` — `spend_metered` rolls the per-epoch ATLAS-out meter AND debits the * vault). Game-scoped * here; its PDA is re-derived from `faction_id` and `ensure_eq!`-bound in `process()` (verbatim the * `fund_treasury` load form + the `ClaimTerritoryYield` seed-bind). One treasury per faction. */ factionTreasury: Address; /** * The per-game NPC-economy dials (supplies `npc_mint_cost_atlas`). Game-scoped here (the * `AccountValidate` impl asserts `game_id == game`); its PDA is per-game (`[seed, game_id]`) so the * game-scope alone pins identity — re-derived + `ensure_eq!`-bound in `process()` as defense in depth. */ factionEconomicsConfig: Address; /** The [`StarSystem`] account */ systemAndStarbasePlayerSystem: Address; /** The [`StarbasePlayer`] Account */ systemAndStarbasePlayerStarbasePlayer: Address; /** The Solana System program. */ systemProgram?: Address; fleetLabel: MintNpcFleetInstructionDataArgs['fleetLabel']; operatorKeyIndex: MintNpcFleetInstructionDataArgs['operatorKeyIndex']; adminKeyIndex: MintNpcFleetInstructionDataArgs['adminKeyIndex']; factionId: MintNpcFleetInstructionDataArgs['factionId']; initialDirective: MintNpcFleetInstructionDataArgs['initialDirective']; aggression: MintNpcFleetInstructionDataArgs['aggression']; }; export async function getMintNpcFleetInstructionAsync< TAccountProfileValidationSigner extends string, TAccountProfileValidationProfile extends string, TAccountProfileValidationCertificate extends string, TAccountProfileValidationProgram extends string, TAccountAdminSigner extends string, TAccountAdminProfile extends string, TAccountAdminCertificate extends string, TAccountAdminProgram extends string, TAccountProfileFaction extends string, TAccountCharacter extends string, TAccountGame extends string, TAccountFleet extends string, TAccountFactionAccount extends string, TAccountFactionOwnership extends string, TAccountFactionTreasury extends string, TAccountFactionEconomicsConfig extends string, TAccountSystemAndStarbasePlayerSystem extends string, TAccountSystemAndStarbasePlayerStarbasePlayer extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: MintNpcFleetAsyncInput< TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountAdminSigner, TAccountAdminProfile, TAccountAdminCertificate, TAccountAdminProgram, TAccountProfileFaction, TAccountCharacter, TAccountGame, TAccountFleet, TAccountFactionAccount, TAccountFactionOwnership, TAccountFactionTreasury, TAccountFactionEconomicsConfig, TAccountSystemAndStarbasePlayerSystem, TAccountSystemAndStarbasePlayerStarbasePlayer, TAccountSystemProgram >, config?: { programAddress?: TProgramAddress }, ): Promise< MintNpcFleetInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountAdminSigner, TAccountAdminProfile, TAccountAdminCertificate, TAccountAdminProgram, TAccountProfileFaction, TAccountCharacter, TAccountGame, TAccountFleet, TAccountFactionAccount, TAccountFactionOwnership, TAccountFactionTreasury, TAccountFactionEconomicsConfig, TAccountSystemAndStarbasePlayerSystem, TAccountSystemAndStarbasePlayerStarbasePlayer, TAccountSystemProgram > > { // 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, }, adminSigner: { value: input.adminSigner ?? null, isWritable: false }, adminProfile: { value: input.adminProfile ?? null, isWritable: true }, adminCertificate: { value: input.adminCertificate ?? null, isWritable: false, }, adminProgram: { value: input.adminProgram ?? null, isWritable: false }, profileFaction: { value: input.profileFaction ?? null, isWritable: false }, character: { value: input.character ?? null, isWritable: true }, game: { value: input.game ?? null, isWritable: false }, fleet: { value: input.fleet ?? null, isWritable: true }, factionAccount: { value: input.factionAccount ?? null, isWritable: true }, factionOwnership: { value: input.factionOwnership ?? null, isWritable: true, }, factionTreasury: { value: input.factionTreasury ?? null, isWritable: true }, factionEconomicsConfig: { value: input.factionEconomicsConfig ?? null, isWritable: false, }, systemAndStarbasePlayerSystem: { value: input.systemAndStarbasePlayerSystem ?? null, isWritable: false, }, systemAndStarbasePlayerStarbasePlayer: { value: input.systemAndStarbasePlayerStarbasePlayer ?? null, isWritable: true, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; 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.adminProgram.value) { accounts.adminProgram.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.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('adminSigner', accounts.adminSigner), getAccountMeta('adminProfile', accounts.adminProfile), getAccountMeta('adminCertificate', accounts.adminCertificate), getAccountMeta('adminProgram', accounts.adminProgram), getAccountMeta('profileFaction', accounts.profileFaction), getAccountMeta('character', accounts.character), getAccountMeta('game', accounts.game), getAccountMeta('fleet', accounts.fleet), getAccountMeta('factionAccount', accounts.factionAccount), getAccountMeta('factionOwnership', accounts.factionOwnership), getAccountMeta('factionTreasury', accounts.factionTreasury), getAccountMeta('factionEconomicsConfig', accounts.factionEconomicsConfig), getAccountMeta( 'systemAndStarbasePlayerSystem', accounts.systemAndStarbasePlayerSystem, ), getAccountMeta( 'systemAndStarbasePlayerStarbasePlayer', accounts.systemAndStarbasePlayerStarbasePlayer, ), getAccountMeta('systemProgram', accounts.systemProgram), ], data: getMintNpcFleetInstructionDataEncoder().encode( args as MintNpcFleetInstructionDataArgs, ), programAddress, } as MintNpcFleetInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountAdminSigner, TAccountAdminProfile, TAccountAdminCertificate, TAccountAdminProgram, TAccountProfileFaction, TAccountCharacter, TAccountGame, TAccountFleet, TAccountFactionAccount, TAccountFactionOwnership, TAccountFactionTreasury, TAccountFactionEconomicsConfig, TAccountSystemAndStarbasePlayerSystem, TAccountSystemAndStarbasePlayerStarbasePlayer, TAccountSystemProgram >); } export type MintNpcFleetInput< TAccountProfileValidationSigner extends string = string, TAccountProfileValidationProfile extends string = string, TAccountProfileValidationCertificate extends string = string, TAccountProfileValidationProgram extends string = string, TAccountAdminSigner extends string = string, TAccountAdminProfile extends string = string, TAccountAdminCertificate extends string = string, TAccountAdminProgram extends string = string, TAccountProfileFaction extends string = string, TAccountCharacter extends string = string, TAccountGame extends string = string, TAccountFleet extends string = string, TAccountFactionAccount extends string = string, TAccountFactionOwnership extends string = string, TAccountFactionTreasury extends string = string, TAccountFactionEconomicsConfig extends string = string, TAccountSystemAndStarbasePlayerSystem extends string = string, TAccountSystemAndStarbasePlayerStarbasePlayer extends string = string, TAccountSystemProgram extends string = string, > = { profileValidationSigner: TransactionSigner; profileValidationProfile: Address; profileValidationCertificate?: Address; profileValidationProgram?: Address; adminSigner: TransactionSigner; adminProfile: Address; adminCertificate?: Address; adminProgram?: Address; /** * The OPERATOR profile's faction account (supplies the legacy `Faction` alignment stamped onto the fleet, * verbatim `CreateFleet`). */ profileFaction: Address; /** * The OPERATOR's character that belongs to [`Self::game`] (the fleet-registration concurrency bump), * verbatim `CreateFleet`. */ character: Address; /** The game account. */ game: Address; /** The [`Fleet`] account — initialized exactly as `CreateFleet` does (owner = operator profile). */ fleet: Address; /** * The faction's registry account (`Mut` — `npc_fleet_count` is bumped). Game-scoped here; its PDA is * re-derived from `faction_id` and `ensure_eq!`-bound in `process()` (the `ClaimTerritoryYield` idiom for * a faction account that is both game-scoped AND identity-pinned — `ValidatedAccount`'s validate arg is * the `AccountValidate` arg only, so the seed proof is done in-handler). */ factionAccount: Address; /** * The FLEET dynamic-ownership sidecar — created here (the fleet's faction tag + directive payload). PDA * derived from the freshly-init fleet's key under the FLEET asset-kind, so it cannot collide with a * starbase sidecar over the same raw key. */ factionOwnership: Address; /** * The faction's treasury (`Mut` — `spend_metered` rolls the per-epoch ATLAS-out meter AND debits the * vault). Game-scoped * here; its PDA is re-derived from `faction_id` and `ensure_eq!`-bound in `process()` (verbatim the * `fund_treasury` load form + the `ClaimTerritoryYield` seed-bind). One treasury per faction. */ factionTreasury: Address; /** * The per-game NPC-economy dials (supplies `npc_mint_cost_atlas`). Game-scoped here (the * `AccountValidate` impl asserts `game_id == game`); its PDA is per-game (`[seed, game_id]`) so the * game-scope alone pins identity — re-derived + `ensure_eq!`-bound in `process()` as defense in depth. */ factionEconomicsConfig: Address; /** The [`StarSystem`] account */ systemAndStarbasePlayerSystem: Address; /** The [`StarbasePlayer`] Account */ systemAndStarbasePlayerStarbasePlayer: Address; /** The Solana System program. */ systemProgram?: Address; fleetLabel: MintNpcFleetInstructionDataArgs['fleetLabel']; operatorKeyIndex: MintNpcFleetInstructionDataArgs['operatorKeyIndex']; adminKeyIndex: MintNpcFleetInstructionDataArgs['adminKeyIndex']; factionId: MintNpcFleetInstructionDataArgs['factionId']; initialDirective: MintNpcFleetInstructionDataArgs['initialDirective']; aggression: MintNpcFleetInstructionDataArgs['aggression']; }; export function getMintNpcFleetInstruction< TAccountProfileValidationSigner extends string, TAccountProfileValidationProfile extends string, TAccountProfileValidationCertificate extends string, TAccountProfileValidationProgram extends string, TAccountAdminSigner extends string, TAccountAdminProfile extends string, TAccountAdminCertificate extends string, TAccountAdminProgram extends string, TAccountProfileFaction extends string, TAccountCharacter extends string, TAccountGame extends string, TAccountFleet extends string, TAccountFactionAccount extends string, TAccountFactionOwnership extends string, TAccountFactionTreasury extends string, TAccountFactionEconomicsConfig extends string, TAccountSystemAndStarbasePlayerSystem extends string, TAccountSystemAndStarbasePlayerStarbasePlayer extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: MintNpcFleetInput< TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountAdminSigner, TAccountAdminProfile, TAccountAdminCertificate, TAccountAdminProgram, TAccountProfileFaction, TAccountCharacter, TAccountGame, TAccountFleet, TAccountFactionAccount, TAccountFactionOwnership, TAccountFactionTreasury, TAccountFactionEconomicsConfig, TAccountSystemAndStarbasePlayerSystem, TAccountSystemAndStarbasePlayerStarbasePlayer, TAccountSystemProgram >, config?: { programAddress?: TProgramAddress }, ): MintNpcFleetInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountAdminSigner, TAccountAdminProfile, TAccountAdminCertificate, TAccountAdminProgram, TAccountProfileFaction, TAccountCharacter, TAccountGame, TAccountFleet, TAccountFactionAccount, TAccountFactionOwnership, TAccountFactionTreasury, TAccountFactionEconomicsConfig, TAccountSystemAndStarbasePlayerSystem, TAccountSystemAndStarbasePlayerStarbasePlayer, TAccountSystemProgram > { // 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, }, adminSigner: { value: input.adminSigner ?? null, isWritable: false }, adminProfile: { value: input.adminProfile ?? null, isWritable: true }, adminCertificate: { value: input.adminCertificate ?? null, isWritable: false, }, adminProgram: { value: input.adminProgram ?? null, isWritable: false }, profileFaction: { value: input.profileFaction ?? null, isWritable: false }, character: { value: input.character ?? null, isWritable: true }, game: { value: input.game ?? null, isWritable: false }, fleet: { value: input.fleet ?? null, isWritable: true }, factionAccount: { value: input.factionAccount ?? null, isWritable: true }, factionOwnership: { value: input.factionOwnership ?? null, isWritable: true, }, factionTreasury: { value: input.factionTreasury ?? null, isWritable: true }, factionEconomicsConfig: { value: input.factionEconomicsConfig ?? null, isWritable: false, }, systemAndStarbasePlayerSystem: { value: input.systemAndStarbasePlayerSystem ?? null, isWritable: false, }, systemAndStarbasePlayerStarbasePlayer: { value: input.systemAndStarbasePlayerStarbasePlayer ?? null, isWritable: true, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; 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.adminProgram.value) { accounts.adminProgram.value = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u' as Address<'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u'>; } 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('adminSigner', accounts.adminSigner), getAccountMeta('adminProfile', accounts.adminProfile), getAccountMeta('adminCertificate', accounts.adminCertificate), getAccountMeta('adminProgram', accounts.adminProgram), getAccountMeta('profileFaction', accounts.profileFaction), getAccountMeta('character', accounts.character), getAccountMeta('game', accounts.game), getAccountMeta('fleet', accounts.fleet), getAccountMeta('factionAccount', accounts.factionAccount), getAccountMeta('factionOwnership', accounts.factionOwnership), getAccountMeta('factionTreasury', accounts.factionTreasury), getAccountMeta('factionEconomicsConfig', accounts.factionEconomicsConfig), getAccountMeta( 'systemAndStarbasePlayerSystem', accounts.systemAndStarbasePlayerSystem, ), getAccountMeta( 'systemAndStarbasePlayerStarbasePlayer', accounts.systemAndStarbasePlayerStarbasePlayer, ), getAccountMeta('systemProgram', accounts.systemProgram), ], data: getMintNpcFleetInstructionDataEncoder().encode( args as MintNpcFleetInstructionDataArgs, ), programAddress, } as MintNpcFleetInstruction< TProgramAddress, TAccountProfileValidationSigner, TAccountProfileValidationProfile, TAccountProfileValidationCertificate, TAccountProfileValidationProgram, TAccountAdminSigner, TAccountAdminProfile, TAccountAdminCertificate, TAccountAdminProgram, TAccountProfileFaction, TAccountCharacter, TAccountGame, TAccountFleet, TAccountFactionAccount, TAccountFactionOwnership, TAccountFactionTreasury, TAccountFactionEconomicsConfig, TAccountSystemAndStarbasePlayerSystem, TAccountSystemAndStarbasePlayerStarbasePlayer, TAccountSystemProgram >); } export type ParsedMintNpcFleetInstruction< 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]; adminSigner: TAccountMetas[4]; adminProfile: TAccountMetas[5]; adminCertificate?: TAccountMetas[6] | undefined; adminProgram: TAccountMetas[7]; /** * The OPERATOR profile's faction account (supplies the legacy `Faction` alignment stamped onto the fleet, * verbatim `CreateFleet`). */ profileFaction: TAccountMetas[8]; /** * The OPERATOR's character that belongs to [`Self::game`] (the fleet-registration concurrency bump), * verbatim `CreateFleet`. */ character: TAccountMetas[9]; /** The game account. */ game: TAccountMetas[10]; /** The [`Fleet`] account — initialized exactly as `CreateFleet` does (owner = operator profile). */ fleet: TAccountMetas[11]; /** * The faction's registry account (`Mut` — `npc_fleet_count` is bumped). Game-scoped here; its PDA is * re-derived from `faction_id` and `ensure_eq!`-bound in `process()` (the `ClaimTerritoryYield` idiom for * a faction account that is both game-scoped AND identity-pinned — `ValidatedAccount`'s validate arg is * the `AccountValidate` arg only, so the seed proof is done in-handler). */ factionAccount: TAccountMetas[12]; /** * The FLEET dynamic-ownership sidecar — created here (the fleet's faction tag + directive payload). PDA * derived from the freshly-init fleet's key under the FLEET asset-kind, so it cannot collide with a * starbase sidecar over the same raw key. */ factionOwnership: TAccountMetas[13]; /** * The faction's treasury (`Mut` — `spend_metered` rolls the per-epoch ATLAS-out meter AND debits the * vault). Game-scoped * here; its PDA is re-derived from `faction_id` and `ensure_eq!`-bound in `process()` (verbatim the * `fund_treasury` load form + the `ClaimTerritoryYield` seed-bind). One treasury per faction. */ factionTreasury: TAccountMetas[14]; /** * The per-game NPC-economy dials (supplies `npc_mint_cost_atlas`). Game-scoped here (the * `AccountValidate` impl asserts `game_id == game`); its PDA is per-game (`[seed, game_id]`) so the * game-scope alone pins identity — re-derived + `ensure_eq!`-bound in `process()` as defense in depth. */ factionEconomicsConfig: TAccountMetas[15]; /** The [`StarSystem`] account */ systemAndStarbasePlayerSystem: TAccountMetas[16]; /** The [`StarbasePlayer`] Account */ systemAndStarbasePlayerStarbasePlayer: TAccountMetas[17]; /** The Solana System program. */ systemProgram: TAccountMetas[18]; }; data: MintNpcFleetInstructionData; }; export function parseMintNpcFleetInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedMintNpcFleetInstruction { if (instruction.accounts.length < 19) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 19, }, ); } 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(), adminSigner: getNextAccount(), adminProfile: getNextAccount(), adminCertificate: getNextOptionalAccount(), adminProgram: getNextAccount(), profileFaction: getNextAccount(), character: getNextAccount(), game: getNextAccount(), fleet: getNextAccount(), factionAccount: getNextAccount(), factionOwnership: getNextAccount(), factionTreasury: getNextAccount(), factionEconomicsConfig: getNextAccount(), systemAndStarbasePlayerSystem: getNextAccount(), systemAndStarbasePlayerStarbasePlayer: getNextAccount(), systemProgram: getNextAccount(), }, data: getMintNpcFleetInstructionDataDecoder().decode(instruction.data), }; }