import type { Arguments, CommandBuilder } from "yargs"; import * as anchor from "@project-serum/anchor"; import { Rain } from "@rainfi/rain"; export const command = "get_collections"; export const desc = "Get all collections available"; type Options = { details?: string network: string } export const builder: CommandBuilder = (yargs) => { return yargs .options({ 'details': { describe: 'Show details', default: 0, demandOption: false }, 'n': { alias: 'network', describe: 'Network to use', default: 'https://api.mainnet-beta.solana.com', demandOption: false } }) } export const handler = async (argv: Arguments): Promise => { const { details, network } = argv const connection = new anchor.web3.Connection(network); const rain = new Rain() console.log("[i] - Using RPC:", network); console.log("[i] - Using program:", rain.PUBKEY.toBase58()); console.log("[i] - Get Pools Available"); const collections= await rain.utils.getAvailableCollections(connection) if (details) { console.log(collections) } else { const lighter = collections.map(x => { return { collectionAddress:x.collectionAddress, risk:x.risk, creator:x.creator, floorPrice:x.floorPrice, supply:x.supply, nftLocked:x.nftLocked, isLocked:x.isLocked, createdAt:x.createdAt, updatedAt:x.updatedAt, } }) console.log(lighter) } };