/** * 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 type { LockTypeLabel, LockTypeLabelArgs } from "../types/index.js"; import { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, transformEncoder, } from "@solana/kit"; import { getLockTypeLabelDecoder, getLockTypeLabelEncoder, } from "../types/index.js"; export const LOCK_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 106, 47, 238, 159, 124, 12, 160, 192, ]); export function getLockConfigDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode(LOCK_CONFIG_DISCRIMINATOR); } export interface LockConfig { discriminator: ReadonlyUint8Array; position: Address; positionOwner: Address; whirlpool: Address; lockedTimestamp: bigint; lockType: LockTypeLabel; } export interface LockConfigArgs { position: Address; positionOwner: Address; whirlpool: Address; lockedTimestamp: number | bigint; lockType: LockTypeLabelArgs; } /** Gets the encoder for {@link LockConfigArgs} account data. */ export function getLockConfigEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["position", getAddressEncoder()], ["positionOwner", getAddressEncoder()], ["whirlpool", getAddressEncoder()], ["lockedTimestamp", getU64Encoder()], ["lockType", getLockTypeLabelEncoder()], ]), (value) => ({ ...value, discriminator: LOCK_CONFIG_DISCRIMINATOR }), ); } /** Gets the decoder for {@link LockConfig} account data. */ export function getLockConfigDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["position", getAddressDecoder()], ["positionOwner", getAddressDecoder()], ["whirlpool", getAddressDecoder()], ["lockedTimestamp", getU64Decoder()], ["lockType", getLockTypeLabelDecoder()], ]); } /** Gets the codec for {@link LockConfig} account data. */ export function getLockConfigCodec(): FixedSizeCodec< LockConfigArgs, LockConfig > { return combineCodec(getLockConfigEncoder(), getLockConfigDecoder()); } export function decodeLockConfig( encodedAccount: EncodedAccount, ): Account; export function decodeLockConfig( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeLockConfig( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getLockConfigDecoder(), ); } export async function fetchLockConfig( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeLockConfig(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeLockConfig( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeLockConfig(maybeAccount); } export async function fetchAllLockConfig( rpc: Parameters[0], addresses: Address[], config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeLockConfig(rpc, addresses, config); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeLockConfig( rpc: Parameters[0], addresses: Address[], config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeLockConfig(maybeAccount)); }