UNPKG

@frakt-protocol/frakt-sdk

Version:

Frakt SDK for interacting with frakt.xyz protocols

34 lines (33 loc) 1.84 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const anchor_1 = __importDefault(require("@project-serum/anchor")); const web3_js_1 = require("@solana/web3.js"); const accounts_1 = require("../../contract_model/accounts"); const encoder = new TextEncoder(); const closeLoanByAdmin = ({ programId, provider, loan, admin, sendTxn, }) => __awaiter(void 0, void 0, void 0, function* () { const program = yield (0, accounts_1.returnAnchorProgram)(programId, provider); const [communityPoolsAuthority, bumpPoolsAuth] = yield anchor_1.default.web3.PublicKey.findProgramAddress([encoder.encode('nftlendingv2'), programId.toBuffer()], programId); const instruction = yield program.methods .closeLoan(bumpPoolsAuth) .accounts({ loan: loan, admin: admin, communityPoolsAuthority, }) .instruction(); const transaction = new web3_js_1.Transaction().add(instruction); yield sendTxn(transaction); }); exports.default = closeLoanByAdmin;