UNPKG

fbonds-core

Version:

Banx protocol sdk

50 lines (49 loc) 3.5 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.getActiveBanxStakingAccounts = void 0; const helpers_1 = require("../../helpers"); const helpers_2 = require("../../helpers"); const getAllPerpetualProgramAccounts_1 = require("./getAllPerpetualProgramAccounts"); const getActiveBanxStakingAccounts = (programId, connection) => __awaiter(void 0, void 0, void 0, function* () { const program = yield (0, helpers_2.returnAnchorProgram)(connection); const banxStakeOffset = 8; const banxTokenStakeOffset = 8; const adventureOffset = 8; const adventureSubscriptionsOffset = 8; const banxAdventureSubscriptionSnapshot = 8; const [banxStakesRaw, banxTokenStakeRaw, adventuresRaw, adventureSubscriptionsRaw, stakingSettingsRaw, banxAdventureSubscriptionSnapshotRaw] = yield Promise.all([ (0, getAllPerpetualProgramAccounts_1.getFilteredAccounts)(program, 'banxStake', banxStakeOffset, [0]), (0, getAllPerpetualProgramAccounts_1.getFilteredAccounts)(program, 'banxTokenStake', banxStakeOffset, [1]), (0, getAllPerpetualProgramAccounts_1.getFilteredAccounts)(program, 'banxAdventure', adventureOffset, [1]), (0, getAllPerpetualProgramAccounts_1.getFilteredAccountsByNumber)(program, 'banxAdventureSubscription', adventureSubscriptionsOffset, [1]), program.account.banxStakingSettings.all(), (0, getAllPerpetualProgramAccounts_1.getFilteredAccounts)(program, 'banxAdventureSubscriptionSnapshot', banxAdventureSubscriptionSnapshot, [1]), ]); // const banxStakesRaw = await program.account.banxStake.all(); const banxStakes = banxStakesRaw.map((acc) => (0, helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)(acc)); const banxTokenStake = banxTokenStakeRaw.map((acc) => (0, helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)(acc)); const adventures = adventuresRaw.map((acc) => (0, helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)(acc)); const adventureSubscriptions = adventureSubscriptionsRaw.map((acc) => (0, helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)(acc)); const stakingSettingsAccounts = stakingSettingsRaw.map((acc) => (0, helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)(acc)); const adventureSubscriptionsSnapshots = banxAdventureSubscriptionSnapshotRaw.map((acc) => (0, helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)(acc)); const banxPointsMaps = (yield program.account.banxPointsMap.all()).map((raw) => (0, helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)(raw)); return { banxStakes, banxTokenStake, adventures, adventureSubscriptions, stakingSettings: stakingSettingsAccounts[0], adventureSubscriptionsSnapshots, banxPointsMaps }; }); exports.getActiveBanxStakingAccounts = getActiveBanxStakingAccounts;