/** * 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, getU128Decoder, getU128Encoder, 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 { DemocracyAllocationHistorySeeds, findDemocracyAllocationHistoryPda, } from '../pdas'; import { getGovernanceParamsDecoder, getGovernanceParamsEncoder, type GovernanceParams, type GovernanceParamsArgs, } from '../types'; export const DEMOCRACY_ALLOCATION_HISTORY_DISCRIMINATOR = new Uint8Array([ 204, 180, 192, 241, 6, 198, 98, 38, ]); export function getDemocracyAllocationHistoryDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( DEMOCRACY_ALLOCATION_HISTORY_DISCRIMINATOR, ); } /** * One root × generation contributor, independent of its authorizing Profile route. A pending * transition is materialized against its immutable last-old-power boundary index before any * subsequent edit. Releasing physical backing leaves this historical claim account intact. */ export type DemocracyAllocationHistory = { discriminator: ReadonlyUint8Array; version: number; bump: number; domain: Array; gameId: Address; identity: Address; allocation: Address; generation: Address; allocationRevision: bigint; activePower: bigint; pendingPower: bigint; pendingDay: bigint; hasPreference: number; preference: GovernanceParams; claimedIndex: bigint; pendingAtlas: bigint; remainder: bigint; reserved: Array; }; export type DemocracyAllocationHistoryArgs = { version: number; bump: number; domain: Array; gameId: Address; identity: Address; allocation: Address; generation: Address; allocationRevision: number | bigint; activePower: number | bigint; pendingPower: number | bigint; pendingDay: number | bigint; hasPreference: number; preference: GovernanceParamsArgs; claimedIndex: number | bigint; pendingAtlas: number | bigint; remainder: number | bigint; reserved: Array; }; /** Gets the encoder for {@link DemocracyAllocationHistoryArgs} account data. */ export function getDemocracyAllocationHistoryEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['bump', getU8Encoder()], ['domain', getArrayEncoder(getU8Encoder(), { size: 8 })], ['gameId', getAddressEncoder()], ['identity', getAddressEncoder()], ['allocation', getAddressEncoder()], ['generation', getAddressEncoder()], ['allocationRevision', getU64Encoder()], ['activePower', getU64Encoder()], ['pendingPower', getU64Encoder()], ['pendingDay', getU64Encoder()], ['hasPreference', getU8Encoder()], ['preference', getGovernanceParamsEncoder()], ['claimedIndex', getU128Encoder()], ['pendingAtlas', getU64Encoder()], ['remainder', getU128Encoder()], ['reserved', getArrayEncoder(getU8Encoder(), { size: 32 })], ]), (value) => ({ ...value, discriminator: DEMOCRACY_ALLOCATION_HISTORY_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link DemocracyAllocationHistory} account data. */ export function getDemocracyAllocationHistoryDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['bump', getU8Decoder()], ['domain', getArrayDecoder(getU8Decoder(), { size: 8 })], ['gameId', getAddressDecoder()], ['identity', getAddressDecoder()], ['allocation', getAddressDecoder()], ['generation', getAddressDecoder()], ['allocationRevision', getU64Decoder()], ['activePower', getU64Decoder()], ['pendingPower', getU64Decoder()], ['pendingDay', getU64Decoder()], ['hasPreference', getU8Decoder()], ['preference', getGovernanceParamsDecoder()], ['claimedIndex', getU128Decoder()], ['pendingAtlas', getU64Decoder()], ['remainder', getU128Decoder()], ['reserved', getArrayDecoder(getU8Decoder(), { size: 32 })], ]); } /** Gets the codec for {@link DemocracyAllocationHistory} account data. */ export function getDemocracyAllocationHistoryCodec(): FixedSizeCodec< DemocracyAllocationHistoryArgs, DemocracyAllocationHistory > { return combineCodec( getDemocracyAllocationHistoryEncoder(), getDemocracyAllocationHistoryDecoder(), ); } export function decodeDemocracyAllocationHistory< TAddress extends string = string, >( encodedAccount: EncodedAccount, ): Account; export function decodeDemocracyAllocationHistory< TAddress extends string = string, >( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeDemocracyAllocationHistory< TAddress extends string = string, >( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getDemocracyAllocationHistoryDecoder(), ); } export async function fetchDemocracyAllocationHistory< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeDemocracyAllocationHistory( rpc, address, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeDemocracyAllocationHistory< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeDemocracyAllocationHistory(maybeAccount); } export async function fetchAllDemocracyAllocationHistory( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeDemocracyAllocationHistory( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeDemocracyAllocationHistory( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeDemocracyAllocationHistory(maybeAccount), ); } export async function fetchDemocracyAllocationHistoryFromSeeds( rpc: Parameters[0], seeds: DemocracyAllocationHistorySeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const maybeAccount = await fetchMaybeDemocracyAllocationHistoryFromSeeds( rpc, seeds, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeDemocracyAllocationHistoryFromSeeds( rpc: Parameters[0], seeds: DemocracyAllocationHistorySeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const { programAddress, ...fetchConfig } = config; const [address] = await findDemocracyAllocationHistoryPda(seeds, { programAddress, }); return await fetchMaybeDemocracyAllocationHistory(rpc, address, fetchConfig); }