/** * 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 Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array, } from "@solana/kit"; import { getMintToScopeChainDecoder, getMintToScopeChainEncoder, type MintToScopeChain, type MintToScopeChainArgs, } from "../types"; export const MINTS_TO_SCOPE_CHAINS_DISCRIMINATOR = new Uint8Array([ 156, 236, 56, 20, 39, 141, 42, 183, ]); export function getMintsToScopeChainsDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( MINTS_TO_SCOPE_CHAINS_DISCRIMINATOR, ); } /** Map of mints to scope chain only valid for a given price feed */ export type MintsToScopeChains = { discriminator: ReadonlyUint8Array; oraclePrices: Address; seedPk: Address; seedId: bigint; bump: number; mapping: Array; }; export type MintsToScopeChainsArgs = { oraclePrices: Address; seedPk: Address; seedId: number | bigint; bump: number; mapping: Array; }; /** Gets the encoder for {@link MintsToScopeChainsArgs} account data. */ export function getMintsToScopeChainsEncoder(): Encoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["oraclePrices", getAddressEncoder()], ["seedPk", getAddressEncoder()], ["seedId", getU64Encoder()], ["bump", getU8Encoder()], ["mapping", getArrayEncoder(getMintToScopeChainEncoder())], ]), (value) => ({ ...value, discriminator: MINTS_TO_SCOPE_CHAINS_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link MintsToScopeChains} account data. */ export function getMintsToScopeChainsDecoder(): Decoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["oraclePrices", getAddressDecoder()], ["seedPk", getAddressDecoder()], ["seedId", getU64Decoder()], ["bump", getU8Decoder()], ["mapping", getArrayDecoder(getMintToScopeChainDecoder())], ]); } /** Gets the codec for {@link MintsToScopeChains} account data. */ export function getMintsToScopeChainsCodec(): Codec< MintsToScopeChainsArgs, MintsToScopeChains > { return combineCodec( getMintsToScopeChainsEncoder(), getMintsToScopeChainsDecoder(), ); } export function decodeMintsToScopeChains( encodedAccount: EncodedAccount, ): Account; export function decodeMintsToScopeChains( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeMintsToScopeChains( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getMintsToScopeChainsDecoder(), ); } export async function fetchMintsToScopeChains( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeMintsToScopeChains(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeMintsToScopeChains< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeMintsToScopeChains(maybeAccount); } export async function fetchAllMintsToScopeChains( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeMintsToScopeChains( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeMintsToScopeChains( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeMintsToScopeChains(maybeAccount), ); }