UNPKG

@frakt-protocol/frakt-sdk

Version:

Frakt SDK for interacting with frakt.xyz protocols

49 lines (48 loc) 2.77 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.initBoardEntryInstruction = exports.initBoardEntry = void 0; const anchor_1 = require("@project-serum/anchor"); const accounts_1 = require("../../contract_model/accounts"); const initBoardEntry = (params) => __awaiter(void 0, void 0, void 0, function* () { const { programId, connection, user, nftMint, message, sendTxn, initialBalance = new anchor_1.BN(0) } = params; const encoder = new TextEncoder(); const program = yield (0, accounts_1.returnCommunityPoolsAnchorProgram)(programId, connection); const [boardEntry] = yield anchor_1.web3.PublicKey.findProgramAddress([encoder.encode('BoardEntry'), user.toBuffer()], program.programId); const instruction = yield program.instruction.initializeBoardEntry(initialBalance, message, { accounts: { user: user, nftMint: nftMint, boardEntry, 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.initBoardEntry = initBoardEntry; const initBoardEntryInstruction = (params) => __awaiter(void 0, void 0, void 0, function* () { const { programId, connection, user, nftMint, message, initialBalance = new anchor_1.BN(0) } = params; const encoder = new TextEncoder(); const program = yield (0, accounts_1.returnCommunityPoolsAnchorProgram)(programId, connection); const [boardEntry] = yield anchor_1.web3.PublicKey.findProgramAddress([encoder.encode('BoardEntry'), user.toBuffer()], program.programId); return program.instruction.initializeBoardEntry(initialBalance, message, { accounts: { user: user, nftMint: nftMint, boardEntry, rent: anchor_1.web3.SYSVAR_RENT_PUBKEY, systemProgram: anchor_1.web3.SystemProgram.programId, }, }); }); exports.initBoardEntryInstruction = initBoardEntryInstruction;