UNPKG

fbonds-core

Version:

Banx protocol sdk

43 lines (42 loc) 1.99 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.saveProposal = void 0; const anchor_1 = require("@coral-xyz/anchor"); const helpers_1 = require("../../helpers"); const helpers_2 = require("./helpers"); const saveProposal = (_a) => __awaiter(void 0, [_a], void 0, function* ({ programId, connection, args, accounts, sendTxn }) { const program = (0, helpers_1.returnAnchorProgram)(connection); const instructions = []; instructions.push(yield program.methods .saveProposal({ name: (0, helpers_1.bufferToArray)((0, helpers_2.encodeProposalName)(args)), duration: new anchor_1.BN(args.duration), pointsQuorum: new anchor_1.BN(args.pointsQuorum), }) .accountsStrict({ user: accounts.userPubkey, systemProgram: anchor_1.web3.SystemProgram.programId, rent: anchor_1.web3.SYSVAR_RENT_PUBKEY, proposal: yield (0, helpers_2.getProposalPubkey)(program, args), }) .instruction()); const transaction = new anchor_1.web3.Transaction(); for (const instruction of instructions) transaction.add(instruction); const signers = []; yield sendTxn(transaction, signers); return { instructions, signers, }; }); exports.saveProposal = saveProposal;