/** * 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 { DemocracyPtrLegacyObligationSeeds, findDemocracyPtrLegacyObligationPda, } from '../pdas'; export const DEMOCRACY_PTR_LEGACY_OBLIGATION_DISCRIMINATOR = new Uint8Array([ 205, 145, 134, 250, 200, 59, 236, 68, ]); export function getDemocracyPtrLegacyObligationDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( DEMOCRACY_PTR_LEGACY_OBLIGATION_DISCRIMINATOR, ); } export type DemocracyPtrLegacyObligation = { discriminator: ReadonlyUint8Array; version: number; bump: number; domain: Array; routeObligations: Address; delegation: Address; governance: Address; system: Address; starbaseSeqId: bigint; playerProfile: Address; treasury: Address; claimState: Address; delegationBump: number; diplomatCrew: number; activeAmount: bigint; pendingAmount: bigint; pendingEffectiveRewardEpoch: bigint; rewardEpochDurationSecs: number; }; export type DemocracyPtrLegacyObligationArgs = { version: number; bump: number; domain: Array; routeObligations: Address; delegation: Address; governance: Address; system: Address; starbaseSeqId: number | bigint; playerProfile: Address; treasury: Address; claimState: Address; delegationBump: number; diplomatCrew: number; activeAmount: number | bigint; pendingAmount: number | bigint; pendingEffectiveRewardEpoch: number | bigint; rewardEpochDurationSecs: number; }; /** Gets the encoder for {@link DemocracyPtrLegacyObligationArgs} account data. */ export function getDemocracyPtrLegacyObligationEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['bump', getU8Encoder()], ['domain', getArrayEncoder(getU8Encoder(), { size: 8 })], ['routeObligations', getAddressEncoder()], ['delegation', getAddressEncoder()], ['governance', getAddressEncoder()], ['system', getAddressEncoder()], ['starbaseSeqId', getU64Encoder()], ['playerProfile', getAddressEncoder()], ['treasury', getAddressEncoder()], ['claimState', getAddressEncoder()], ['delegationBump', getU8Encoder()], ['diplomatCrew', getU32Encoder()], ['activeAmount', getU64Encoder()], ['pendingAmount', getU64Encoder()], ['pendingEffectiveRewardEpoch', getU64Encoder()], ['rewardEpochDurationSecs', getU32Encoder()], ]), (value) => ({ ...value, discriminator: DEMOCRACY_PTR_LEGACY_OBLIGATION_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link DemocracyPtrLegacyObligation} account data. */ export function getDemocracyPtrLegacyObligationDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['bump', getU8Decoder()], ['domain', getArrayDecoder(getU8Decoder(), { size: 8 })], ['routeObligations', getAddressDecoder()], ['delegation', getAddressDecoder()], ['governance', getAddressDecoder()], ['system', getAddressDecoder()], ['starbaseSeqId', getU64Decoder()], ['playerProfile', getAddressDecoder()], ['treasury', getAddressDecoder()], ['claimState', getAddressDecoder()], ['delegationBump', getU8Decoder()], ['diplomatCrew', getU32Decoder()], ['activeAmount', getU64Decoder()], ['pendingAmount', getU64Decoder()], ['pendingEffectiveRewardEpoch', getU64Decoder()], ['rewardEpochDurationSecs', getU32Decoder()], ]); } /** Gets the codec for {@link DemocracyPtrLegacyObligation} account data. */ export function getDemocracyPtrLegacyObligationCodec(): FixedSizeCodec< DemocracyPtrLegacyObligationArgs, DemocracyPtrLegacyObligation > { return combineCodec( getDemocracyPtrLegacyObligationEncoder(), getDemocracyPtrLegacyObligationDecoder(), ); } export function decodeDemocracyPtrLegacyObligation< TAddress extends string = string, >( encodedAccount: EncodedAccount, ): Account; export function decodeDemocracyPtrLegacyObligation< TAddress extends string = string, >( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeDemocracyPtrLegacyObligation< TAddress extends string = string, >( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getDemocracyPtrLegacyObligationDecoder(), ); } export async function fetchDemocracyPtrLegacyObligation< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeDemocracyPtrLegacyObligation( rpc, address, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeDemocracyPtrLegacyObligation< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeDemocracyPtrLegacyObligation(maybeAccount); } export async function fetchAllDemocracyPtrLegacyObligation( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeDemocracyPtrLegacyObligation( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeDemocracyPtrLegacyObligation( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeDemocracyPtrLegacyObligation(maybeAccount), ); } export async function fetchDemocracyPtrLegacyObligationFromSeeds( rpc: Parameters[0], seeds: DemocracyPtrLegacyObligationSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const maybeAccount = await fetchMaybeDemocracyPtrLegacyObligationFromSeeds( rpc, seeds, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeDemocracyPtrLegacyObligationFromSeeds( rpc: Parameters[0], seeds: DemocracyPtrLegacyObligationSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const { programAddress, ...fetchConfig } = config; const [address] = await findDemocracyPtrLegacyObligationPda(seeds, { programAddress, }); return await fetchMaybeDemocracyPtrLegacyObligation( rpc, address, fetchConfig, ); }