/** * 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, 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'; import { getCargoIdDecoder, getCargoIdEncoder, type CargoId, type CargoIdArgs, } from '../types'; export const STARBASE_UPGRADE_PROCESS_DISCRIMINATOR = new Uint8Array([ 243, 137, 76, 235, 9, 242, 175, 134, ]); export function getStarbaseUpgradeProcessDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( STARBASE_UPGRADE_PROCESS_DISCRIMINATOR, ); } /** This account represents a starbase upgrade resource being processed */ export type StarbaseUpgradeProcess = { discriminator: ReadonlyUint8Array; /** The data version of this account. */ version: number; /** The `Profile` key */ profile: Address; /** The `System` key */ system: Address; /** the owner/authority of this upgrade process */ starbasePlayer: Address; starbaseSeqId: bigint; /** The resource id */ resourceId: CargoId; /** Quantity of resource to process */ quantity: bigint; /** the number of crew taking part in the processing */ numCrew: number; /** the start timestamp */ startTime: bigint; /** the end timestamp */ endTime: bigint; }; export type StarbaseUpgradeProcessArgs = { /** The data version of this account. */ version: number; /** The `Profile` key */ profile: Address; /** The `System` key */ system: Address; /** the owner/authority of this upgrade process */ starbasePlayer: Address; starbaseSeqId: number | bigint; /** The resource id */ resourceId: CargoIdArgs; /** Quantity of resource to process */ quantity: number | bigint; /** the number of crew taking part in the processing */ numCrew: number; /** the start timestamp */ startTime: number | bigint; /** the end timestamp */ endTime: number | bigint; }; /** Gets the encoder for {@link StarbaseUpgradeProcessArgs} account data. */ export function getStarbaseUpgradeProcessEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['profile', getAddressEncoder()], ['system', getAddressEncoder()], ['starbasePlayer', getAddressEncoder()], ['starbaseSeqId', getU64Encoder()], ['resourceId', getCargoIdEncoder()], ['quantity', getU64Encoder()], ['numCrew', getU16Encoder()], ['startTime', getI64Encoder()], ['endTime', getI64Encoder()], ]), (value) => ({ ...value, discriminator: STARBASE_UPGRADE_PROCESS_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link StarbaseUpgradeProcess} account data. */ export function getStarbaseUpgradeProcessDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['profile', getAddressDecoder()], ['system', getAddressDecoder()], ['starbasePlayer', getAddressDecoder()], ['starbaseSeqId', getU64Decoder()], ['resourceId', getCargoIdDecoder()], ['quantity', getU64Decoder()], ['numCrew', getU16Decoder()], ['startTime', getI64Decoder()], ['endTime', getI64Decoder()], ]); } /** Gets the codec for {@link StarbaseUpgradeProcess} account data. */ export function getStarbaseUpgradeProcessCodec(): FixedSizeCodec< StarbaseUpgradeProcessArgs, StarbaseUpgradeProcess > { return combineCodec( getStarbaseUpgradeProcessEncoder(), getStarbaseUpgradeProcessDecoder(), ); } export function decodeStarbaseUpgradeProcess( encodedAccount: EncodedAccount, ): Account; export function decodeStarbaseUpgradeProcess( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeStarbaseUpgradeProcess( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getStarbaseUpgradeProcessDecoder(), ); } export async function fetchStarbaseUpgradeProcess< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeStarbaseUpgradeProcess( rpc, address, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeStarbaseUpgradeProcess< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeStarbaseUpgradeProcess(maybeAccount); } export async function fetchAllStarbaseUpgradeProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeStarbaseUpgradeProcess( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeStarbaseUpgradeProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeStarbaseUpgradeProcess(maybeAccount), ); }