/** * 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 { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array, } from '@solana/kit'; import { CareerXpMigrationConfigSeeds, findCareerXpMigrationConfigPda, } from '../pdas'; export const CAREER_XP_MIGRATION_CONFIG_DISCRIMINATOR = new Uint8Array([ 91, 194, 154, 118, 25, 141, 55, 172, ]); export function getCareerXpMigrationConfigDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( CAREER_XP_MIGRATION_CONFIG_DISCRIMINATOR, ); } /** * Game-scoped record of one legacy-to-v1 migration. Seeded * `[b"CareerXpMigrationConfig", game_id]`, created by the seal instruction. */ export type CareerXpMigrationConfig = { discriminator: ReadonlyUint8Array; /** Current irreversible phase (`XpMigrationPhase` wire value). */ phase: number; /** 1 once the finalized-seal manifest has been committed (one-shot). */ manifestCommitted: number; /** This account's PDA bump. */ bump: number; /** Reserved phase flags. */ pad: Array; /** Game this migration belongs to. */ gameId: Address; /** * Independently approved digest of the staged payload, supplied to the * seal instruction and immutable afterwards. Migration and activation * both recompute against this value; a self-reported hash is never * sufficient. */ targetDefinitionsPayloadSha256: Array; /** Slot at which the game was sealed (the finalized manifest boundary). */ sealedSlot: bigint; /** * `Game.xp_definitions.seq_id` every reconciled Character is stamped * with and that activation installs, so ordinary sync becomes a no-op * for the migrated cohort after activation. */ targetSeqId: number; /** Source (legacy) threshold version = 0, target version = 1. */ sourceThresholdVersion: number; targetThresholdVersion: number; pad2: Array; /** Merkle root of the finalized-slot Character pubkey manifest. */ manifestMerkleRoot: Array; /** Total Characters in the manifest. */ manifestCount: bigint; /** Characters whose marker went 0 -> 1 while sealed. */ migratedCount: bigint; /** Characters whose in-transaction post-state audit passed. */ auditedCount: bigint; /** Members of the mandatory high-XP audit cohort seen so far. */ highXpCount: bigint; /** * One-way HYE manifest incident repair marker (0 = untouched; 1 = first * repair, superseded; 2 = canonical-root correction). * Carved from reserved space; existing fields and account size are unchanged. */ manifestRepairVersion: number; /** Additive growth budget — carve typed fields from the FRONT; NEVER append. */ reserved: Array; }; export type CareerXpMigrationConfigArgs = { /** Current irreversible phase (`XpMigrationPhase` wire value). */ phase: number; /** 1 once the finalized-seal manifest has been committed (one-shot). */ manifestCommitted: number; /** This account's PDA bump. */ bump: number; /** Reserved phase flags. */ pad: Array; /** Game this migration belongs to. */ gameId: Address; /** * Independently approved digest of the staged payload, supplied to the * seal instruction and immutable afterwards. Migration and activation * both recompute against this value; a self-reported hash is never * sufficient. */ targetDefinitionsPayloadSha256: Array; /** Slot at which the game was sealed (the finalized manifest boundary). */ sealedSlot: number | bigint; /** * `Game.xp_definitions.seq_id` every reconciled Character is stamped * with and that activation installs, so ordinary sync becomes a no-op * for the migrated cohort after activation. */ targetSeqId: number; /** Source (legacy) threshold version = 0, target version = 1. */ sourceThresholdVersion: number; targetThresholdVersion: number; pad2: Array; /** Merkle root of the finalized-slot Character pubkey manifest. */ manifestMerkleRoot: Array; /** Total Characters in the manifest. */ manifestCount: number | bigint; /** Characters whose marker went 0 -> 1 while sealed. */ migratedCount: number | bigint; /** Characters whose in-transaction post-state audit passed. */ auditedCount: number | bigint; /** Members of the mandatory high-XP audit cohort seen so far. */ highXpCount: number | bigint; /** * One-way HYE manifest incident repair marker (0 = untouched; 1 = first * repair, superseded; 2 = canonical-root correction). * Carved from reserved space; existing fields and account size are unchanged. */ manifestRepairVersion: number; /** Additive growth budget — carve typed fields from the FRONT; NEVER append. */ reserved: Array; }; /** Gets the encoder for {@link CareerXpMigrationConfigArgs} account data. */ export function getCareerXpMigrationConfigEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['phase', getU8Encoder()], ['manifestCommitted', getU8Encoder()], ['bump', getU8Encoder()], ['pad', getArrayEncoder(getU8Encoder(), { size: 5 })], ['gameId', getAddressEncoder()], [ 'targetDefinitionsPayloadSha256', getArrayEncoder(getU8Encoder(), { size: 32 }), ], ['sealedSlot', getU64Encoder()], ['targetSeqId', getU32Encoder()], ['sourceThresholdVersion', getU32Encoder()], ['targetThresholdVersion', getU32Encoder()], ['pad2', getArrayEncoder(getU8Encoder(), { size: 4 })], ['manifestMerkleRoot', getArrayEncoder(getU8Encoder(), { size: 32 })], ['manifestCount', getU64Encoder()], ['migratedCount', getU64Encoder()], ['auditedCount', getU64Encoder()], ['highXpCount', getU64Encoder()], ['manifestRepairVersion', getU8Encoder()], ['reserved', getArrayEncoder(getU8Encoder(), { size: 31 })], ]), (value) => ({ ...value, discriminator: CAREER_XP_MIGRATION_CONFIG_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link CareerXpMigrationConfig} account data. */ export function getCareerXpMigrationConfigDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['phase', getU8Decoder()], ['manifestCommitted', getU8Decoder()], ['bump', getU8Decoder()], ['pad', getArrayDecoder(getU8Decoder(), { size: 5 })], ['gameId', getAddressDecoder()], [ 'targetDefinitionsPayloadSha256', getArrayDecoder(getU8Decoder(), { size: 32 }), ], ['sealedSlot', getU64Decoder()], ['targetSeqId', getU32Decoder()], ['sourceThresholdVersion', getU32Decoder()], ['targetThresholdVersion', getU32Decoder()], ['pad2', getArrayDecoder(getU8Decoder(), { size: 4 })], ['manifestMerkleRoot', getArrayDecoder(getU8Decoder(), { size: 32 })], ['manifestCount', getU64Decoder()], ['migratedCount', getU64Decoder()], ['auditedCount', getU64Decoder()], ['highXpCount', getU64Decoder()], ['manifestRepairVersion', getU8Decoder()], ['reserved', getArrayDecoder(getU8Decoder(), { size: 31 })], ]); } /** Gets the codec for {@link CareerXpMigrationConfig} account data. */ export function getCareerXpMigrationConfigCodec(): FixedSizeCodec< CareerXpMigrationConfigArgs, CareerXpMigrationConfig > { return combineCodec( getCareerXpMigrationConfigEncoder(), getCareerXpMigrationConfigDecoder(), ); } export function decodeCareerXpMigrationConfig( encodedAccount: EncodedAccount, ): Account; export function decodeCareerXpMigrationConfig( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeCareerXpMigrationConfig( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getCareerXpMigrationConfigDecoder(), ); } export async function fetchCareerXpMigrationConfig< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeCareerXpMigrationConfig( rpc, address, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeCareerXpMigrationConfig< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeCareerXpMigrationConfig(maybeAccount); } export async function fetchAllCareerXpMigrationConfig( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeCareerXpMigrationConfig( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeCareerXpMigrationConfig( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeCareerXpMigrationConfig(maybeAccount), ); } export async function fetchCareerXpMigrationConfigFromSeeds( rpc: Parameters[0], seeds: CareerXpMigrationConfigSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const maybeAccount = await fetchMaybeCareerXpMigrationConfigFromSeeds( rpc, seeds, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeCareerXpMigrationConfigFromSeeds( rpc: Parameters[0], seeds: CareerXpMigrationConfigSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const { programAddress, ...fetchConfig } = config; const [address] = await findCareerXpMigrationConfigPda(seeds, { programAddress, }); return await fetchMaybeCareerXpMigrationConfig(rpc, address, fetchConfig); }