/** * 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, getU128Decoder, getU128Encoder, getU16Decoder, getU16Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, 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 VESTING_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 100, 149, 66, 138, 95, 200, 128, 241, ]); export function getVestingDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode(VESTING_DISCRIMINATOR); } export type Vesting = { discriminator: ReadonlyUint8Array; position: Address; cliffPoint: bigint; periodFrequency: bigint; cliffUnlockLiquidity: bigint; liquidityPerPeriod: bigint; totalReleasedLiquidity: bigint; numberOfPeriod: number; padding: Array; padding2: Array; }; export type VestingArgs = { position: Address; cliffPoint: number | bigint; periodFrequency: number | bigint; cliffUnlockLiquidity: number | bigint; liquidityPerPeriod: number | bigint; totalReleasedLiquidity: number | bigint; numberOfPeriod: number; padding: Array; padding2: Array; }; /** Gets the encoder for {@link VestingArgs} account data. */ export function getVestingEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["position", getAddressEncoder()], ["cliffPoint", getU64Encoder()], ["periodFrequency", getU64Encoder()], ["cliffUnlockLiquidity", getU128Encoder()], ["liquidityPerPeriod", getU128Encoder()], ["totalReleasedLiquidity", getU128Encoder()], ["numberOfPeriod", getU16Encoder()], ["padding", getArrayEncoder(getU8Encoder(), { size: 14 })], ["padding2", getArrayEncoder(getU128Encoder(), { size: 4 })], ]), (value) => ({ ...value, discriminator: VESTING_DISCRIMINATOR }), ); } /** Gets the decoder for {@link Vesting} account data. */ export function getVestingDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["position", getAddressDecoder()], ["cliffPoint", getU64Decoder()], ["periodFrequency", getU64Decoder()], ["cliffUnlockLiquidity", getU128Decoder()], ["liquidityPerPeriod", getU128Decoder()], ["totalReleasedLiquidity", getU128Decoder()], ["numberOfPeriod", getU16Decoder()], ["padding", getArrayDecoder(getU8Decoder(), { size: 14 })], ["padding2", getArrayDecoder(getU128Decoder(), { size: 4 })], ]); } /** Gets the codec for {@link Vesting} account data. */ export function getVestingCodec(): FixedSizeCodec { return combineCodec(getVestingEncoder(), getVestingDecoder()); } export function decodeVesting( encodedAccount: EncodedAccount, ): Account; export function decodeVesting( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeVesting( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getVestingDecoder(), ); } export async function fetchVesting( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeVesting(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeVesting( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeVesting(maybeAccount); } export async function fetchAllVesting( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeVesting(rpc, addresses, config); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeVesting( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeVesting(maybeAccount)); }