@frakt-protocol/frakt-sdk
Version:
Frakt SDK for interacting with frakt.xyz protocols
33 lines (32 loc) • 1.86 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.initPermission = void 0;
const anchor_1 = require("@project-serum/anchor");
const accounts_1 = require("../../contract_model/accounts");
const initPermission = (params) => __awaiter(void 0, void 0, void 0, function* () {
const { programId, connection, admin, programPubkey, expiration, canAdd, canHarvest, sendTxn } = params;
const encoder = new TextEncoder();
const program = yield (0, accounts_1.returnCommunityPoolsAnchorProgram)(programId, connection);
const [permission] = yield anchor_1.web3.PublicKey.findProgramAddress([encoder.encode('Permission'), programPubkey.toBuffer()], program.programId);
const instruction = program.instruction.initializePermission(expiration, canAdd, canHarvest, {
accounts: {
admin,
programPubkey,
permission,
rent: anchor_1.web3.SYSVAR_RENT_PUBKEY,
systemProgram: anchor_1.web3.SystemProgram.programId,
},
});
const transaction = new anchor_1.web3.Transaction().add(instruction);
yield sendTxn(transaction);
});
exports.initPermission = initPermission;