fbonds-core
Version:
Banx protocol sdk
47 lines (46 loc) • 2.63 kB
JavaScript
;
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.changeBanxAdventureRevAdmin = void 0;
const constants_1 = require("../../../constants");
const helpers_1 = require("../../../helpers");
const anchor_1 = require("@coral-xyz/anchor");
const changeBanxAdventureRevAdmin = (_a) => __awaiter(void 0, [_a], void 0, function* ({ connection, priorityFees, accounts, args, sendTxn, }) {
const program = (0, helpers_1.returnAnchorProgram)(connection);
const instructions = [];
const requestHeap = anchor_1.web3.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFees });
instructions.push(requestHeap);
const [adventure] = yield anchor_1.web3.PublicKey.findProgramAddress([constants_1.ENCODER.encode(constants_1.BANX_ADVENTURE_PREFIX), constants_1.ENCODER.encode(args.week.toString())], program.programId);
const [banxStakingSettings] = yield anchor_1.web3.PublicKey.findProgramAddress([constants_1.ENCODER.encode(constants_1.BANX_STAKING_SETTINGS_PREFIX)], program.programId);
instructions.push(yield program.methods
.syncBanxAdventrure(new anchor_1.BN(args.week), new anchor_1.BN(args.revenueInBanx))
.accountsStrict({
banxAdventure: adventure,
user: accounts.userAdmin,
systemProgram: anchor_1.web3.SystemProgram.programId,
rent: anchor_1.web3.SYSVAR_RENT_PUBKEY,
banxStakingSettings: banxStakingSettings
})
.remainingAccounts([])
.instruction());
const transaction = new anchor_1.web3.Transaction();
for (let instruction of instructions)
transaction.add(instruction);
const signers = [];
yield sendTxn(transaction, signers);
// const optimisticResult = await subscribeBanxAdventrueOptimistics(optimistics,args.weeks);
return {
instructions,
signers,
// optimisticResult,
};
});
exports.changeBanxAdventureRevAdmin = changeBanxAdventureRevAdmin;