/** * 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 type { Account, Address, EncodedAccount, FetchAccountConfig, FetchAccountsConfig, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, MaybeAccount, MaybeEncodedAccount, ReadonlyUint8Array, } from "@solana/kit"; import { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, transformEncoder, } from "@solana/kit"; export const WHIRLPOOLS_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([157, 20, 49, 224, 217, 87, 193, 254]); export function getWhirlpoolsConfigDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( WHIRLPOOLS_CONFIG_DISCRIMINATOR, ); } export interface WhirlpoolsConfig { discriminator: ReadonlyUint8Array; feeAuthority: Address; collectProtocolFeesAuthority: Address; rewardEmissionsSuperAuthority: Address; defaultProtocolFeeRate: number; } export interface WhirlpoolsConfigArgs { feeAuthority: Address; collectProtocolFeesAuthority: Address; rewardEmissionsSuperAuthority: Address; defaultProtocolFeeRate: number; } /** Gets the encoder for {@link WhirlpoolsConfigArgs} account data. */ export function getWhirlpoolsConfigEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["feeAuthority", getAddressEncoder()], ["collectProtocolFeesAuthority", getAddressEncoder()], ["rewardEmissionsSuperAuthority", getAddressEncoder()], ["defaultProtocolFeeRate", getU16Encoder()], ]), (value) => ({ ...value, discriminator: WHIRLPOOLS_CONFIG_DISCRIMINATOR }), ); } /** Gets the decoder for {@link WhirlpoolsConfig} account data. */ export function getWhirlpoolsConfigDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["feeAuthority", getAddressDecoder()], ["collectProtocolFeesAuthority", getAddressDecoder()], ["rewardEmissionsSuperAuthority", getAddressDecoder()], ["defaultProtocolFeeRate", getU16Decoder()], ]); } /** Gets the codec for {@link WhirlpoolsConfig} account data. */ export function getWhirlpoolsConfigCodec(): FixedSizeCodec< WhirlpoolsConfigArgs, WhirlpoolsConfig > { return combineCodec( getWhirlpoolsConfigEncoder(), getWhirlpoolsConfigDecoder(), ); } export function decodeWhirlpoolsConfig( encodedAccount: EncodedAccount, ): Account; export function decodeWhirlpoolsConfig( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeWhirlpoolsConfig( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getWhirlpoolsConfigDecoder(), ); } export async function fetchWhirlpoolsConfig( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeWhirlpoolsConfig(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeWhirlpoolsConfig< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeWhirlpoolsConfig(maybeAccount); } export async function fetchAllWhirlpoolsConfig( rpc: Parameters[0], addresses: Address[], config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeWhirlpoolsConfig( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeWhirlpoolsConfig( rpc: Parameters[0], addresses: Address[], config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeWhirlpoolsConfig(maybeAccount), ); }