/** * 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, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, 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"; export const SCOPE_CHAIN_ACCOUNT_DISCRIMINATOR = new Uint8Array([ 180, 51, 138, 247, 240, 173, 119, 79, ]); export function getScopeChainAccountDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( SCOPE_CHAIN_ACCOUNT_DISCRIMINATOR, ); } export type ScopeChainAccount = { discriminator: ReadonlyUint8Array; chainArray: Array>; }; export type ScopeChainAccountArgs = { chainArray: Array> }; /** Gets the encoder for {@link ScopeChainAccountArgs} account data. */ export function getScopeChainAccountEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], [ "chainArray", getArrayEncoder(getArrayEncoder(getU16Encoder(), { size: 4 }), { size: 512, }), ], ]), (value) => ({ ...value, discriminator: SCOPE_CHAIN_ACCOUNT_DISCRIMINATOR }), ); } /** Gets the decoder for {@link ScopeChainAccount} account data. */ export function getScopeChainAccountDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], [ "chainArray", getArrayDecoder(getArrayDecoder(getU16Decoder(), { size: 4 }), { size: 512, }), ], ]); } /** Gets the codec for {@link ScopeChainAccount} account data. */ export function getScopeChainAccountCodec(): FixedSizeCodec< ScopeChainAccountArgs, ScopeChainAccount > { return combineCodec( getScopeChainAccountEncoder(), getScopeChainAccountDecoder(), ); } export function decodeScopeChainAccount( encodedAccount: EncodedAccount, ): Account; export function decodeScopeChainAccount( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeScopeChainAccount( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getScopeChainAccountDecoder(), ); } export async function fetchScopeChainAccount( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeScopeChainAccount(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeScopeChainAccount< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeScopeChainAccount(maybeAccount); } export async function fetchAllScopeChainAccount( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeScopeChainAccount( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeScopeChainAccount( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeScopeChainAccount(maybeAccount), ); } export function getScopeChainAccountSize(): number { return 4104; }