import { BorshCoder } from "@project-serum/anchor"; import type { MergeMinerData, MergePoolData, MinerData, MinterData, MintWrapperData, OperatorData, QuarryData, RedeemerData, RegistryData, RewarderData, } from "@quarryprotocol/quarry-sdk"; import { QuarryMergeMineJSON, QuarryMineJSON, QuarryMintWrapperJSON, QuarryOperatorJSON, QuarryRedeemerJSON, QuarryRegistryJSON, } from "@quarryprotocol/quarry-sdk"; import type { KeyedAccountInfo } from "@solana/web3.js"; const MERGE_MINE_CODER = new BorshCoder(QuarryMergeMineJSON); const MINT_WRAPPER_CODER = new BorshCoder(QuarryMintWrapperJSON); const MINE_CODER = new BorshCoder(QuarryMineJSON); const OPERATOR_CODER = new BorshCoder(QuarryOperatorJSON); const REDEEMER_CODER = new BorshCoder(QuarryRedeemerJSON); const REGISTRY_CODER = new BorshCoder(QuarryRegistryJSON); export const PARSE_MINT_WRAPPER = (d: KeyedAccountInfo): MintWrapperData => MINT_WRAPPER_CODER.accounts.decode( "MintWrapper", d.accountInfo.data ); export const PARSE_MINTER = (d: KeyedAccountInfo): MinterData => MINT_WRAPPER_CODER.accounts.decode("Minter", d.accountInfo.data); export const PARSE_MINER = (d: KeyedAccountInfo): MinerData => MINE_CODER.accounts.decode("Miner", d.accountInfo.data); export const PARSE_QUARRY = (d: KeyedAccountInfo): QuarryData => MINE_CODER.accounts.decode("Quarry", d.accountInfo.data); export const PARSE_REWARDER = (d: KeyedAccountInfo): RewarderData => MINE_CODER.accounts.decode("Rewarder", d.accountInfo.data); export const PARSE_REGISTRY = (d: KeyedAccountInfo): RegistryData => REGISTRY_CODER.accounts.decode("Registry", d.accountInfo.data); export const PARSE_OPERATOR = (d: KeyedAccountInfo): OperatorData => OPERATOR_CODER.accounts.decode("Operator", d.accountInfo.data); export const PARSE_REDEEMER = (d: KeyedAccountInfo): RedeemerData => REDEEMER_CODER.accounts.decode("Redeemer", d.accountInfo.data); export const PARSE_MERGE_POOL = (d: KeyedAccountInfo): MergePoolData => MERGE_MINE_CODER.accounts.decode( "MergePool", d.accountInfo.data ); export const PARSE_MERGE_MINER = (d: KeyedAccountInfo): MergeMinerData => MERGE_MINE_CODER.accounts.decode( "MergeMiner", d.accountInfo.data );