UNPKG

@frakt-protocol/frakt-sdk

Version:

Frakt SDK for interacting with frakt.xyz protocols

42 lines (41 loc) 2.45 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAllProgramAccounts = void 0; const anchor_1 = require("@project-serum/anchor"); const accounts_1 = require("../contract_model/accounts"); const common_1 = require("../../common"); const getAllProgramAccounts = (programId, connection) => __awaiter(void 0, void 0, void 0, function* () { const provider = new anchor_1.AnchorProvider(connection, (0, common_1.createFakeWallet)(), anchor_1.AnchorProvider.defaultOptions()); const program = yield (0, accounts_1.returnCommunityPoolsAnchorProgram)(programId, connection); const communityPools = yield program.account.communityPool.all(); const lotteryTickets = yield program.account.lotteryTicket.all(); const poolWhitelists = yield program.account.poolWhitelist.all(); const safetyDepositBoxes = yield program.account.safetyDepositBox.all(); const boardEntrysRaw = yield program.account.boardEntry.all(); const poolConfigsRaw = yield program.account.poolConfig.all(); const permissionsRaw = yield program.account.permission.all(); const feeConfig = yield program.account.feeConfig.all(); const boardEntrys = boardEntrysRaw.map((raw) => (0, accounts_1.decodedBoardEntry)(raw.account, raw.publicKey)); const poolConfigs = poolConfigsRaw.map((raw) => (0, accounts_1.decodedPoolConfig)(raw.account, raw.publicKey)); const permissions = permissionsRaw.map((raw) => (0, accounts_1.decodedPermission)(raw.account, raw.publicKey)); return { communityPools, lotteryTickets, poolWhitelists, safetyDepositBoxes, boardEntrys, poolConfigs, permissions, feeConfig, }; }); exports.getAllProgramAccounts = getAllProgramAccounts;