import { AccountLayout as SplTokenAccountLayout, MintLayout as SplMintAccountLayout, RawAccount as SplTokenAccount, RawMint as SplMintAccount, } from '@solana/spl-token'; import { MintInfo } from '@convergence-rfq/rfq'; import { NotYetImplementedError } from '../../errors'; import { Account, SolitaType, getAccountParsingAndAssertingFunction, getAccountParsingFunction, } from '../../types'; const mintAccountParser: SolitaType = { name: 'MintAccount', deserialize: (data: Buffer, offset?: number) => { const span = SplMintAccountLayout.getSpan(data, offset); const decoded = SplMintAccountLayout.decode(data, offset); return [decoded, span]; }, fromArgs() { throw new NotYetImplementedError(); }, }; /** @group Accounts */ export type MintAccount = Account; /** @group Account Helpers */ export const parseMintAccount = getAccountParsingFunction(mintAccountParser); /** @group Account Helpers */ export const toMintAccount = getAccountParsingAndAssertingFunction(mintAccountParser); /** @group Accounts */ export type MintInfoAccount = Account; /** @group Account Helpers */ export const parseMintInfoAccount = getAccountParsingFunction(MintInfo); /** @group Account Helpers */ export const toMintInfoAccount = getAccountParsingAndAssertingFunction(MintInfo); const tokenAccountParser: SolitaType = { name: 'TokenAccount', deserialize: (data: Buffer, offset?: number) => { const span = SplTokenAccountLayout.getSpan(data, offset); const decoded = SplTokenAccountLayout.decode(data, offset); return [decoded, span]; }, fromArgs() { throw new NotYetImplementedError(); }, }; /** @group Accounts */ export type TokenAccount = Account; /** @group Account Helpers */ export const parseTokenAccount = getAccountParsingFunction(tokenAccountParser); /** @group Account Helpers */ export const toTokenAccount = getAccountParsingAndAssertingFunction(tokenAccountParser);