import * as anchor from "@project-serum/anchor"; import { getOptionState, getCollectionIdentifier, getStrikr, getShellProvider } from "../utils"; /** * Fetch CollectionIdentifier account * @param connection Solana Web3 connection object * @param collectionIdentifierKey collectionIdentifierKey representing an NFT collection uniquely * @returns Promise resolving to the OptionState account contents */ export const getCollection = async ( connection: anchor.web3.Connection, collectionIdentifierKey: anchor.web3.PublicKey ) => { const collectionIdentifierAddress = await getCollectionIdentifier(collectionIdentifierKey); const provider = getShellProvider(connection); const strikr = getStrikr(provider); return await strikr.account.collectionIdentifier.fetch(collectionIdentifierAddress); }; /** * Fetch all CollectionIdentifier accounts * @param connection Solana Web3 connection object * @returns Promise resolving to the OptionState account contents */ export const getAllCollections = async (connection: anchor.web3.Connection) => { const provider = getShellProvider(connection); const strikr = getStrikr(provider); return await strikr.account.collectionIdentifier.all(); };