/** * 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, 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 { DemocracyPtrReconciliationSeeds, findDemocracyPtrReconciliationPda, } from '../pdas'; export const DEMOCRACY_PTR_RECONCILIATION_DISCRIMINATOR = new Uint8Array([ 4, 107, 245, 16, 228, 204, 255, 159, ]); export function getDemocracyPtrReconciliationDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( DEMOCRACY_PTR_RECONCILIATION_DISCRIMINATOR, ); } export type DemocracyPtrReconciliation = { discriminator: ReadonlyUint8Array; version: number; bump: number; domain: Array; migration: Address; expectedProfiles: bigint; reconciledProfiles: bigint; lastProfile: Array; recordedDelegations: bigint; activeDelegated: bigint; pendingDelegated: bigint; /** Sum of per-delegation max(active, pending), NOT a selected daily schedule or new grant. */ conservativePowerBound: bigint; /** Only Crew from recorded delegations. Zero-power omitted locks are deliberately NOT freed. */ recordedDiplomatCrew: bigint; }; export type DemocracyPtrReconciliationArgs = { version: number; bump: number; domain: Array; migration: Address; expectedProfiles: number | bigint; reconciledProfiles: number | bigint; lastProfile: Array; recordedDelegations: number | bigint; activeDelegated: number | bigint; pendingDelegated: number | bigint; /** Sum of per-delegation max(active, pending), NOT a selected daily schedule or new grant. */ conservativePowerBound: number | bigint; /** Only Crew from recorded delegations. Zero-power omitted locks are deliberately NOT freed. */ recordedDiplomatCrew: number | bigint; }; /** Gets the encoder for {@link DemocracyPtrReconciliationArgs} account data. */ export function getDemocracyPtrReconciliationEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['bump', getU8Encoder()], ['domain', getArrayEncoder(getU8Encoder(), { size: 8 })], ['migration', getAddressEncoder()], ['expectedProfiles', getU64Encoder()], ['reconciledProfiles', getU64Encoder()], ['lastProfile', getArrayEncoder(getU8Encoder(), { size: 32 })], ['recordedDelegations', getU64Encoder()], ['activeDelegated', getU64Encoder()], ['pendingDelegated', getU64Encoder()], ['conservativePowerBound', getU64Encoder()], ['recordedDiplomatCrew', getU64Encoder()], ]), (value) => ({ ...value, discriminator: DEMOCRACY_PTR_RECONCILIATION_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link DemocracyPtrReconciliation} account data. */ export function getDemocracyPtrReconciliationDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['bump', getU8Decoder()], ['domain', getArrayDecoder(getU8Decoder(), { size: 8 })], ['migration', getAddressDecoder()], ['expectedProfiles', getU64Decoder()], ['reconciledProfiles', getU64Decoder()], ['lastProfile', getArrayDecoder(getU8Decoder(), { size: 32 })], ['recordedDelegations', getU64Decoder()], ['activeDelegated', getU64Decoder()], ['pendingDelegated', getU64Decoder()], ['conservativePowerBound', getU64Decoder()], ['recordedDiplomatCrew', getU64Decoder()], ]); } /** Gets the codec for {@link DemocracyPtrReconciliation} account data. */ export function getDemocracyPtrReconciliationCodec(): FixedSizeCodec< DemocracyPtrReconciliationArgs, DemocracyPtrReconciliation > { return combineCodec( getDemocracyPtrReconciliationEncoder(), getDemocracyPtrReconciliationDecoder(), ); } export function decodeDemocracyPtrReconciliation< TAddress extends string = string, >( encodedAccount: EncodedAccount, ): Account; export function decodeDemocracyPtrReconciliation< TAddress extends string = string, >( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeDemocracyPtrReconciliation< TAddress extends string = string, >( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getDemocracyPtrReconciliationDecoder(), ); } export async function fetchDemocracyPtrReconciliation< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeDemocracyPtrReconciliation( rpc, address, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeDemocracyPtrReconciliation< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeDemocracyPtrReconciliation(maybeAccount); } export async function fetchAllDemocracyPtrReconciliation( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeDemocracyPtrReconciliation( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeDemocracyPtrReconciliation( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeDemocracyPtrReconciliation(maybeAccount), ); } export async function fetchDemocracyPtrReconciliationFromSeeds( rpc: Parameters[0], seeds: DemocracyPtrReconciliationSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const maybeAccount = await fetchMaybeDemocracyPtrReconciliationFromSeeds( rpc, seeds, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeDemocracyPtrReconciliationFromSeeds( rpc: Parameters[0], seeds: DemocracyPtrReconciliationSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const { programAddress, ...fetchConfig } = config; const [address] = await findDemocracyPtrReconciliationPda(seeds, { programAddress, }); return await fetchMaybeDemocracyPtrReconciliation(rpc, address, fetchConfig); }