/** * 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, getBytesDecoder, getBytesEncoder, getI64Decoder, getI64Encoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, 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 { getCargoPodDecoder, getCargoPodEncoder, getGovernanceFeeSnapshotDecoder, getGovernanceFeeSnapshotEncoder, getRecipeFeeRecipientDecoder, getRecipeFeeRecipientEncoder, type CargoPod, type CargoPodArgs, type GovernanceFeeSnapshot, type GovernanceFeeSnapshotArgs, type RecipeFeeRecipient, type RecipeFeeRecipientArgs, } from '../types'; export const CRAFTING_PROCESS_DISCRIMINATOR = new Uint8Array([ 105, 184, 5, 105, 175, 112, 13, 169, ]); export function getCraftingProcessDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( CRAFTING_PROCESS_DISCRIMINATOR, ); } /** This account represents crafting in progress */ export type CraftingProcess = { discriminator: ReadonlyUint8Array; /** The data version of this account. */ version: number; /** the recipe */ recipe: Address; /** The `Profile` key */ profile: Address; /** The `System` key */ system: Address; /** the owner/authority of this crafting process */ starbasePlayer: Address; starbaseSeqId: bigint; /** the crafting hab */ craftingHab: Address; /** Quantity of outputs to craft */ quantity: bigint; /** the number of crew taking part in the crafting process */ numCrew: number; /** the start timestamp */ startTime: bigint; /** the end timestamp */ endTime: bigint; /** The recipe fee held in escrow */ feeEscrow: bigint; /** Original recipe fee destination when governance is not active. */ feeRecipient: RecipeFeeRecipient; /** Governance account whose fee routing was snapshotted at start, if any. */ feeGovernance: Address; /** Fee routing snapshot captured when the process started. */ feeSnapshot: GovernanceFeeSnapshot; inputs: CargoPod; }; export type CraftingProcessArgs = { /** The data version of this account. */ version: number; /** the recipe */ recipe: Address; /** The `Profile` key */ profile: Address; /** The `System` key */ system: Address; /** the owner/authority of this crafting process */ starbasePlayer: Address; starbaseSeqId: number | bigint; /** the crafting hab */ craftingHab: Address; /** Quantity of outputs to craft */ quantity: number | bigint; /** the number of crew taking part in the crafting process */ numCrew: number; /** the start timestamp */ startTime: number | bigint; /** the end timestamp */ endTime: number | bigint; /** The recipe fee held in escrow */ feeEscrow: number | bigint; /** Original recipe fee destination when governance is not active. */ feeRecipient: RecipeFeeRecipientArgs; /** Governance account whose fee routing was snapshotted at start, if any. */ feeGovernance: Address; /** Fee routing snapshot captured when the process started. */ feeSnapshot: GovernanceFeeSnapshotArgs; inputs: CargoPodArgs; }; /** Gets the encoder for {@link CraftingProcessArgs} account data. */ export function getCraftingProcessEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['recipe', getAddressEncoder()], ['profile', getAddressEncoder()], ['system', getAddressEncoder()], ['starbasePlayer', getAddressEncoder()], ['starbaseSeqId', getU64Encoder()], ['craftingHab', getAddressEncoder()], ['quantity', getU64Encoder()], ['numCrew', getU32Encoder()], ['startTime', getI64Encoder()], ['endTime', getI64Encoder()], ['feeEscrow', getU64Encoder()], ['feeRecipient', getRecipeFeeRecipientEncoder()], ['feeGovernance', getAddressEncoder()], ['feeSnapshot', getGovernanceFeeSnapshotEncoder()], ['inputs', getCargoPodEncoder()], ]), (value) => ({ ...value, discriminator: CRAFTING_PROCESS_DISCRIMINATOR }), ); } /** Gets the decoder for {@link CraftingProcess} account data. */ export function getCraftingProcessDecoder(): Decoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['recipe', getAddressDecoder()], ['profile', getAddressDecoder()], ['system', getAddressDecoder()], ['starbasePlayer', getAddressDecoder()], ['starbaseSeqId', getU64Decoder()], ['craftingHab', getAddressDecoder()], ['quantity', getU64Decoder()], ['numCrew', getU32Decoder()], ['startTime', getI64Decoder()], ['endTime', getI64Decoder()], ['feeEscrow', getU64Decoder()], ['feeRecipient', getRecipeFeeRecipientDecoder()], ['feeGovernance', getAddressDecoder()], ['feeSnapshot', getGovernanceFeeSnapshotDecoder()], ['inputs', getCargoPodDecoder()], ]); } /** Gets the codec for {@link CraftingProcess} account data. */ export function getCraftingProcessCodec(): Codec< CraftingProcessArgs, CraftingProcess > { return combineCodec(getCraftingProcessEncoder(), getCraftingProcessDecoder()); } export function decodeCraftingProcess( encodedAccount: EncodedAccount, ): Account; export function decodeCraftingProcess( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeCraftingProcess( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getCraftingProcessDecoder(), ); } export async function fetchCraftingProcess( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeCraftingProcess(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeCraftingProcess< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeCraftingProcess(maybeAccount); } export async function fetchAllCraftingProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeCraftingProcess( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeCraftingProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeCraftingProcess(maybeAccount), ); }