UNPKG

@okxweb3/coin-stellar

Version:

@ok/coin-stellar is a Stellar SDK for building Web3 wallets and applications. It supports Stellar and PI blockchains, enabling private key management, address generation, transaction signing, trustline creation, and asset transfers

30 lines 1.45 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createClaimableBalance = void 0; const xdr_1 = __importDefault(require("../xdr")); const asset_1 = require("../asset"); function createClaimableBalance(opts) { if (!(opts.asset instanceof asset_1.Asset)) { throw new Error('must provide an asset for create claimable balance operation'); } if (!this.isValidAmount(opts.amount)) { throw new TypeError(this.constructAmountRequirementsError('amount')); } if (!Array.isArray(opts.claimants) || opts.claimants.length === 0) { throw new Error('must provide at least one claimant'); } const attributes = {}; attributes.asset = opts.asset.toXDRObject(); attributes.amount = this._toXDRAmount(opts.amount); attributes.claimants = Object.values(opts.claimants).map((c) => c.toXDRObject()); const createClaimableBalanceOp = new xdr_1.default.CreateClaimableBalanceOp(attributes); const opAttributes = {}; opAttributes.body = xdr_1.default.OperationBody.createClaimableBalance(createClaimableBalanceOp); this.setSourceAccount(opAttributes, opts); return new xdr_1.default.Operation(opAttributes); } exports.createClaimableBalance = createClaimableBalance; //# sourceMappingURL=create_claimable_balance.js.map