@frakt-protocol/frakt-sdk
Version:
Frakt SDK for interacting with frakt.xyz protocols
36 lines (35 loc) • 2.05 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.updateLeaderboardReward = void 0;
const anchor_1 = require("@project-serum/anchor");
const accounts_1 = require("../../contract_model/accounts");
const updateLeaderboardReward = (params) => __awaiter(void 0, void 0, void 0, function* () {
const { communityPool, fractionMint, depositReward, withdrawReward, programId, admin, connection, sendTxn } = params;
const encoder = new TextEncoder();
const program = yield (0, accounts_1.returnCommunityPoolsAnchorProgram)(programId, connection);
const [leaderboardAccount, bump] = yield anchor_1.web3.PublicKey.findProgramAddress([communityPool.toBuffer(), encoder.encode('leaderBoard')], program.programId);
const instruction = program.instruction.updateLeaderboard(bump, depositReward, withdrawReward, {
accounts: {
communityPool,
fractionMint,
admin,
systemProgram: anchor_1.web3.SystemProgram.programId,
rent: anchor_1.web3.SYSVAR_RENT_PUBKEY,
tokenProgram: anchor_1.utils.token.TOKEN_PROGRAM_ID,
leaderboardAccount,
},
});
const transaction = new anchor_1.web3.Transaction();
transaction.add(instruction);
yield sendTxn(transaction, []);
});
exports.updateLeaderboardReward = updateLeaderboardReward;