@frakt-protocol/frakt-sdk
Version:
Frakt SDK for interacting with frakt.xyz protocols
36 lines (35 loc) • 2.01 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.initializeFee = void 0;
const anchor_1 = require("@project-serum/anchor");
const accounts_1 = require("../../contract_model/accounts");
const initializeFee = (params) => __awaiter(void 0, void 0, void 0, function* () {
const { programId, connection, userPubkey, depositFeeAdmin, depositFeePool, getLotteryFeeAdmin, getLotteryFeePool, sendTxn, communityPool = new anchor_1.web3.PublicKey('11111111111111111111111111111111'), } = params;
const config = anchor_1.web3.Keypair.generate();
const transaction = new anchor_1.web3.Transaction();
const signers = [config];
const program = yield (0, accounts_1.returnCommunityPoolsAnchorProgram)(programId, connection);
const instruction = yield program.instruction.initializeFee(depositFeeAdmin, depositFeePool, getLotteryFeeAdmin, getLotteryFeePool, {
accounts: {
config: config.publicKey,
admin: userPubkey,
communityPool,
rent: anchor_1.web3.SYSVAR_RENT_PUBKEY,
systemProgram: anchor_1.web3.SystemProgram.programId,
},
signers: [config],
});
transaction.add(instruction);
yield sendTxn(transaction, signers);
return config.publicKey;
});
exports.initializeFee = initializeFee;