/** * 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, getAddressDecoder, getAddressEncoder, getBooleanDecoder, getBooleanEncoder, getOptionDecoder, getOptionEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type Option, type OptionOrNullable, } from '@solana/kit'; export type Mint = { /** * Optional authority used to mint new tokens. The mint authority may only * be provided during mint creation. If no mint authority is present * then the mint has a fixed supply and no further tokens may be minted. */ mintAuthority: Option
; /** Total supply of tokens. */ supply: bigint; /** Number of base 10 digits to the right of the decimal place. */ decimals: number; /** Is `true` if this structure has been initialized. */ isInitialized: boolean; /** Optional authority to freeze token accounts. */ freezeAuthority: Option
; }; export type MintArgs = { /** * Optional authority used to mint new tokens. The mint authority may only * be provided during mint creation. If no mint authority is present * then the mint has a fixed supply and no further tokens may be minted. */ mintAuthority: OptionOrNullable
; /** Total supply of tokens. */ supply: number | bigint; /** Number of base 10 digits to the right of the decimal place. */ decimals: number; /** Is `true` if this structure has been initialized. */ isInitialized: boolean; /** Optional authority to freeze token accounts. */ freezeAuthority: OptionOrNullable
; }; export function getMintEncoder(): FixedSizeEncoder { return getStructEncoder([ [ 'mintAuthority', getOptionEncoder(getAddressEncoder(), { prefix: getU32Encoder(), noneValue: 'zeroes', }), ], ['supply', getU64Encoder()], ['decimals', getU8Encoder()], ['isInitialized', getBooleanEncoder()], [ 'freezeAuthority', getOptionEncoder(getAddressEncoder(), { prefix: getU32Encoder(), noneValue: 'zeroes', }), ], ]); } export function getMintDecoder(): FixedSizeDecoder { return getStructDecoder([ [ 'mintAuthority', getOptionDecoder(getAddressDecoder(), { prefix: getU32Decoder(), noneValue: 'zeroes', }), ], ['supply', getU64Decoder()], ['decimals', getU8Decoder()], ['isInitialized', getBooleanDecoder()], [ 'freezeAuthority', getOptionDecoder(getAddressDecoder(), { prefix: getU32Decoder(), noneValue: 'zeroes', }), ], ]); } export function getMintCodec(): FixedSizeCodec { return combineCodec(getMintEncoder(), getMintDecoder()); } export function decodeMint( encodedAccount: EncodedAccount ): Account; export function decodeMint( encodedAccount: MaybeEncodedAccount ): MaybeAccount; export function decodeMint( encodedAccount: EncodedAccount | MaybeEncodedAccount ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getMintDecoder() ); } export async function fetchMint( rpc: Parameters[0], address: Address, config?: FetchAccountConfig ): Promise> { const maybeAccount = await fetchMaybeMint(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeMint( rpc: Parameters[0], address: Address, config?: FetchAccountConfig ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeMint(maybeAccount); } export async function fetchAllMint( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig ): Promise[]> { const maybeAccounts = await fetchAllMaybeMint(rpc, addresses, config); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeMint( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeMint(maybeAccount)); } export function getMintSize(): number { return 82; }