@frakt-protocol/frakt-sdk
Version:
Frakt SDK for interacting with frakt.xyz protocols
45 lines (44 loc) • 2.57 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());
});
};
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 initializeCollectionInfo = ({ programId, provider, liquidityPool, admin, creatorAddress, pricingLookupAddress, loanToValue, collaterizationRate, royaltyAddress, royaltyFeeTime, royaltyFeePrice, expirationTime, isPriceBased, sendTxn, }) => __awaiter(void 0, void 0, void 0, function* () {
const program = yield (0, accounts_1.returnAnchorProgram)(programId, provider);
const collectionInfo = web3_js_1.Keypair.generate();
const instruction = yield program.instruction.initializeCollectionInfo({
loanToValue: new anchor_1.default.BN(loanToValue),
collaterizationRate: new anchor_1.default.BN(collaterizationRate),
royaltyFeeTime: new anchor_1.default.BN(royaltyFeeTime),
royaltyFeePrice: new anchor_1.default.BN(royaltyFeePrice),
expirationTime: new anchor_1.default.BN(expirationTime),
isPriceBased,
}, {
accounts: {
liquidityPool: liquidityPool,
collectionInfo: collectionInfo.publicKey,
admin: admin,
creatorAddress: creatorAddress,
royaltyAddress,
pricingLookupAddress: pricingLookupAddress,
rent: anchor_1.default.web3.SYSVAR_RENT_PUBKEY,
systemProgram: anchor_1.default.web3.SystemProgram.programId,
},
});
const transaction = new web3_js_1.Transaction().add(instruction);
yield sendTxn(transaction, [collectionInfo]);
return collectionInfo.publicKey;
});
exports.default = initializeCollectionInfo;