/** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount, } from '@solana/kit'; import { getAccountMetaFactory, type ResolvedInstructionAccount, } from '@solana/program-client-core'; import { SAGE_PROGRAM_ADDRESS } from '../programs'; export const REGISTER_STARBASE_PLAYER_DISCRIMINATOR = new Uint8Array([ 60, 18, 158, 19, 208, 147, 83, 226, ]); export function getRegisterStarbasePlayerDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( REGISTER_STARBASE_PLAYER_DISCRIMINATOR, ); } export type RegisterStarbasePlayerInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountFunder extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TAccountCharacter extends string | AccountMeta = string, TAccountProfileFaction extends string | AccountMeta = string, TAccountSystem extends string | AccountMeta = string, TAccountStarbasePlayer extends string | AccountMeta = string, TAccountSystemProgram extends string | AccountMeta = '11111111111111111111111111111111', TAccountFactionRelationTracker extends string | AccountMeta = string, TAccountFactionStanding extends string | AccountMeta = string, TAccountFactionConfig extends string | AccountMeta = string, TAccountFactionOwnership extends string | AccountMeta = string, TAccountOwnerFactionAccount extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountCharacter extends string ? ReadonlyAccount : TAccountCharacter, TAccountProfileFaction extends string ? ReadonlyAccount : TAccountProfileFaction, TAccountSystem extends string ? ReadonlyAccount : TAccountSystem, TAccountStarbasePlayer extends string ? WritableAccount : TAccountStarbasePlayer, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, TAccountFactionRelationTracker extends string ? ReadonlyAccount : TAccountFactionRelationTracker, TAccountFactionStanding extends string ? ReadonlyAccount : TAccountFactionStanding, TAccountFactionConfig extends string ? ReadonlyAccount : TAccountFactionConfig, TAccountFactionOwnership extends string ? ReadonlyAccount : TAccountFactionOwnership, TAccountOwnerFactionAccount extends string ? ReadonlyAccount : TAccountOwnerFactionAccount, ...TRemainingAccounts, ] >; export type RegisterStarbasePlayerInstructionData = { discriminator: ReadonlyUint8Array; }; export type RegisterStarbasePlayerInstructionDataArgs = {}; export function getRegisterStarbasePlayerInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: REGISTER_STARBASE_PLAYER_DISCRIMINATOR, }), ); } export function getRegisterStarbasePlayerInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getRegisterStarbasePlayerInstructionDataCodec(): FixedSizeCodec< RegisterStarbasePlayerInstructionDataArgs, RegisterStarbasePlayerInstructionData > { return combineCodec( getRegisterStarbasePlayerInstructionDataEncoder(), getRegisterStarbasePlayerInstructionDataDecoder(), ); } export type RegisterStarbasePlayerInput< TAccountFunder extends string = string, TAccountGame extends string = string, TAccountCharacter extends string = string, TAccountProfileFaction extends string = string, TAccountSystem extends string = string, TAccountStarbasePlayer extends string = string, TAccountSystemProgram extends string = string, TAccountFactionRelationTracker extends string = string, TAccountFactionStanding extends string = string, TAccountFactionConfig extends string = string, TAccountFactionOwnership extends string = string, TAccountOwnerFactionAccount extends string = string, > = { /** The funder -- pays account rent */ funder: TransactionSigner; /** The game account */ game: Address; /** The [`Character`] account */ character: Address; /** The faction that the player belongs to. */ profileFaction: Address; /** The [`StarSystem`] account */ system: Address; /** The [`crate::state::StarbasePlayer`] account to initialize */ starbasePlayer: Address; /** The system program */ systemProgram?: Address; /** * P3 dock-compose gate (OPTIONAL for legacy clients). A supplied tracker controls both * territory admission and the dynamic-capture regime. When omitted, capture state cannot * be proven OFF, so the required PDA-bound sidecar remains authoritative; callers cannot * omit the tracker to recover legacy ownership after capture. Supplying the tracker with * dynamic capture OFF resolves the legacy `Starbase.owner`, matching `IdleToDocked`. * When supplied + territory access ON, Allied / high-standing players may be admitted. */ factionRelationTracker?: Address; /** * OPTIONAL: the player's standing vs the STARBASE-OWNER faction. Omit ⇒ no standing override. Read-only * (no fee/accrual). PDA + identity bound (game, player profile, owner faction id) in process(). */ factionStanding?: Address; /** OPTIONAL: per-game reputation dials (supplies dock_min_band + decay). Supply WITH faction_standing. */ factionConfig?: Address; /** * P5 Bridge #1 (REQUIRED, PDA-bound): the starbase's maybe-uninitialized ownership sidecar. * An absent relation tracker cannot prove the capture switch is off, so registration * resolves this sidecar fail-closed. With a present tracker explicitly disabling capture, * registration ignores sidecar state and uses the legacy `Starbase.owner`, like docking. * With capture enabled, fresh sidecars control access; Level0 keeps its stale fallback. */ factionOwnership: Address; /** * OPTIONAL dynamic-operator admission bridge. For a dynamically controlled starbase, supply the resolved * owner's [`FactionAccount`] to admit that faction's configured `operator_profile`. Omit ⇒ no operator * admission (the existing own / Allied / standing paths are unchanged). When supplied for a dynamic owner, * process() re-derives its PDA from (game, resolved owner id) before reading it. This account is deliberately * appended after the pre-existing required accounts so legacy clients keep their account ordering. */ ownerFactionAccount?: Address; }; export function getRegisterStarbasePlayerInstruction< TAccountFunder extends string, TAccountGame extends string, TAccountCharacter extends string, TAccountProfileFaction extends string, TAccountSystem extends string, TAccountStarbasePlayer extends string, TAccountSystemProgram extends string, TAccountFactionRelationTracker extends string, TAccountFactionStanding extends string, TAccountFactionConfig extends string, TAccountFactionOwnership extends string, TAccountOwnerFactionAccount extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: RegisterStarbasePlayerInput< TAccountFunder, TAccountGame, TAccountCharacter, TAccountProfileFaction, TAccountSystem, TAccountStarbasePlayer, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionStanding, TAccountFactionConfig, TAccountFactionOwnership, TAccountOwnerFactionAccount >, config?: { programAddress?: TProgramAddress }, ): RegisterStarbasePlayerInstruction< TProgramAddress, TAccountFunder, TAccountGame, TAccountCharacter, TAccountProfileFaction, TAccountSystem, TAccountStarbasePlayer, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionStanding, TAccountFactionConfig, TAccountFactionOwnership, TAccountOwnerFactionAccount > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { funder: { value: input.funder ?? null, isWritable: true }, game: { value: input.game ?? null, isWritable: false }, character: { value: input.character ?? null, isWritable: false }, profileFaction: { value: input.profileFaction ?? null, isWritable: false }, system: { value: input.system ?? null, isWritable: false }, starbasePlayer: { value: input.starbasePlayer ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, factionRelationTracker: { value: input.factionRelationTracker ?? null, isWritable: false, }, factionStanding: { value: input.factionStanding ?? null, isWritable: false, }, factionConfig: { value: input.factionConfig ?? null, isWritable: false }, factionOwnership: { value: input.factionOwnership ?? null, isWritable: false, }, ownerFactionAccount: { value: input.ownerFactionAccount ?? null, isWritable: false, }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Resolve default values. if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta('funder', accounts.funder), getAccountMeta('game', accounts.game), getAccountMeta('character', accounts.character), getAccountMeta('profileFaction', accounts.profileFaction), getAccountMeta('system', accounts.system), getAccountMeta('starbasePlayer', accounts.starbasePlayer), getAccountMeta('systemProgram', accounts.systemProgram), getAccountMeta('factionRelationTracker', accounts.factionRelationTracker), getAccountMeta('factionStanding', accounts.factionStanding), getAccountMeta('factionConfig', accounts.factionConfig), getAccountMeta('factionOwnership', accounts.factionOwnership), getAccountMeta('ownerFactionAccount', accounts.ownerFactionAccount), ], data: getRegisterStarbasePlayerInstructionDataEncoder().encode({}), programAddress, } as RegisterStarbasePlayerInstruction< TProgramAddress, TAccountFunder, TAccountGame, TAccountCharacter, TAccountProfileFaction, TAccountSystem, TAccountStarbasePlayer, TAccountSystemProgram, TAccountFactionRelationTracker, TAccountFactionStanding, TAccountFactionConfig, TAccountFactionOwnership, TAccountOwnerFactionAccount >); } export type ParsedRegisterStarbasePlayerInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { /** The funder -- pays account rent */ funder: TAccountMetas[0]; /** The game account */ game: TAccountMetas[1]; /** The [`Character`] account */ character: TAccountMetas[2]; /** The faction that the player belongs to. */ profileFaction: TAccountMetas[3]; /** The [`StarSystem`] account */ system: TAccountMetas[4]; /** The [`crate::state::StarbasePlayer`] account to initialize */ starbasePlayer: TAccountMetas[5]; /** The system program */ systemProgram: TAccountMetas[6]; /** * P3 dock-compose gate (OPTIONAL for legacy clients). A supplied tracker controls both * territory admission and the dynamic-capture regime. When omitted, capture state cannot * be proven OFF, so the required PDA-bound sidecar remains authoritative; callers cannot * omit the tracker to recover legacy ownership after capture. Supplying the tracker with * dynamic capture OFF resolves the legacy `Starbase.owner`, matching `IdleToDocked`. * When supplied + territory access ON, Allied / high-standing players may be admitted. */ factionRelationTracker?: TAccountMetas[7] | undefined; /** * OPTIONAL: the player's standing vs the STARBASE-OWNER faction. Omit ⇒ no standing override. Read-only * (no fee/accrual). PDA + identity bound (game, player profile, owner faction id) in process(). */ factionStanding?: TAccountMetas[8] | undefined; /** OPTIONAL: per-game reputation dials (supplies dock_min_band + decay). Supply WITH faction_standing. */ factionConfig?: TAccountMetas[9] | undefined; /** * P5 Bridge #1 (REQUIRED, PDA-bound): the starbase's maybe-uninitialized ownership sidecar. * An absent relation tracker cannot prove the capture switch is off, so registration * resolves this sidecar fail-closed. With a present tracker explicitly disabling capture, * registration ignores sidecar state and uses the legacy `Starbase.owner`, like docking. * With capture enabled, fresh sidecars control access; Level0 keeps its stale fallback. */ factionOwnership: TAccountMetas[10]; /** * OPTIONAL dynamic-operator admission bridge. For a dynamically controlled starbase, supply the resolved * owner's [`FactionAccount`] to admit that faction's configured `operator_profile`. Omit ⇒ no operator * admission (the existing own / Allied / standing paths are unchanged). When supplied for a dynamic owner, * process() re-derives its PDA from (game, resolved owner id) before reading it. This account is deliberately * appended after the pre-existing required accounts so legacy clients keep their account ordering. */ ownerFactionAccount?: TAccountMetas[11] | undefined; }; data: RegisterStarbasePlayerInstructionData; }; export function parseRegisterStarbasePlayerInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedRegisterStarbasePlayerInstruction { if (instruction.accounts.length < 12) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 12, }, ); } 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(), game: getNextAccount(), character: getNextAccount(), profileFaction: getNextAccount(), system: getNextAccount(), starbasePlayer: getNextAccount(), systemProgram: getNextAccount(), factionRelationTracker: getNextOptionalAccount(), factionStanding: getNextOptionalAccount(), factionConfig: getNextOptionalAccount(), factionOwnership: getNextAccount(), ownerFactionAccount: getNextOptionalAccount(), }, data: getRegisterStarbasePlayerInstructionDataDecoder().decode( instruction.data, ), }; }