/** * 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, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU8Decoder, getU8Encoder, transformEncoder, } from "@solana/kit"; export const POSITION_BUNDLE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array( [129, 169, 175, 65, 185, 95, 32, 100], ); export function getPositionBundleDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( POSITION_BUNDLE_DISCRIMINATOR, ); } export interface PositionBundle { discriminator: ReadonlyUint8Array; positionBundleMint: Address; positionBitmap: number[]; } export interface PositionBundleArgs { positionBundleMint: Address; positionBitmap: number[]; } /** Gets the encoder for {@link PositionBundleArgs} account data. */ export function getPositionBundleEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["positionBundleMint", getAddressEncoder()], ["positionBitmap", getArrayEncoder(getU8Encoder(), { size: 32 })], ]), (value) => ({ ...value, discriminator: POSITION_BUNDLE_DISCRIMINATOR }), ); } /** Gets the decoder for {@link PositionBundle} account data. */ export function getPositionBundleDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["positionBundleMint", getAddressDecoder()], ["positionBitmap", getArrayDecoder(getU8Decoder(), { size: 32 })], ]); } /** Gets the codec for {@link PositionBundle} account data. */ export function getPositionBundleCodec(): FixedSizeCodec< PositionBundleArgs, PositionBundle > { return combineCodec(getPositionBundleEncoder(), getPositionBundleDecoder()); } export function decodePositionBundle( encodedAccount: EncodedAccount, ): Account; export function decodePositionBundle( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodePositionBundle( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getPositionBundleDecoder(), ); } export async function fetchPositionBundle( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybePositionBundle(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybePositionBundle< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodePositionBundle(maybeAccount); } export async function fetchAllPositionBundle( rpc: Parameters[0], addresses: Address[], config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybePositionBundle( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybePositionBundle( rpc: Parameters[0], addresses: Address[], config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodePositionBundle(maybeAccount), ); }