123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- /**
- * 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<Address>;
- /** 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<Address>;
- };
- 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<Address>;
- /** 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<Address>;
- };
- export function getMintEncoder(): FixedSizeEncoder<MintArgs> {
- 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<Mint> {
- 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<MintArgs, Mint> {
- return combineCodec(getMintEncoder(), getMintDecoder());
- }
- export function decodeMint<TAddress extends string = string>(
- encodedAccount: EncodedAccount<TAddress>
- ): Account<Mint, TAddress>;
- export function decodeMint<TAddress extends string = string>(
- encodedAccount: MaybeEncodedAccount<TAddress>
- ): MaybeAccount<Mint, TAddress>;
- export function decodeMint<TAddress extends string = string>(
- encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>
- ): Account<Mint, TAddress> | MaybeAccount<Mint, TAddress> {
- return decodeAccount(
- encodedAccount as MaybeEncodedAccount<TAddress>,
- getMintDecoder()
- );
- }
- export async function fetchMint<TAddress extends string = string>(
- rpc: Parameters<typeof fetchEncodedAccount>[0],
- address: Address<TAddress>,
- config?: FetchAccountConfig
- ): Promise<Account<Mint, TAddress>> {
- const maybeAccount = await fetchMaybeMint(rpc, address, config);
- assertAccountExists(maybeAccount);
- return maybeAccount;
- }
- export async function fetchMaybeMint<TAddress extends string = string>(
- rpc: Parameters<typeof fetchEncodedAccount>[0],
- address: Address<TAddress>,
- config?: FetchAccountConfig
- ): Promise<MaybeAccount<Mint, TAddress>> {
- const maybeAccount = await fetchEncodedAccount(rpc, address, config);
- return decodeMint(maybeAccount);
- }
- export async function fetchAllMint(
- rpc: Parameters<typeof fetchEncodedAccounts>[0],
- addresses: Array<Address>,
- config?: FetchAccountsConfig
- ): Promise<Account<Mint>[]> {
- const maybeAccounts = await fetchAllMaybeMint(rpc, addresses, config);
- assertAccountsExist(maybeAccounts);
- return maybeAccounts;
- }
- export async function fetchAllMaybeMint(
- rpc: Parameters<typeof fetchEncodedAccounts>[0],
- addresses: Array<Address>,
- config?: FetchAccountsConfig
- ): Promise<MaybeAccount<Mint>[]> {
- const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
- return maybeAccounts.map((maybeAccount) => decodeMint(maybeAccount));
- }
- export function getMintSize(): number {
- return 82;
- }
|