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

35 lines 1.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.manageSellOffer = void 0; const js_xdr_1 = require("@stellar/js-xdr"); const xdr_1 = __importDefault(require("../xdr")); function manageSellOffer(opts) { const attributes = {}; attributes.selling = opts.selling.toXDRObject(); attributes.buying = opts.buying.toXDRObject(); if (!this.isValidAmount(opts.amount, true)) { throw new TypeError(this.constructAmountRequirementsError('amount')); } attributes.amount = this._toXDRAmount(opts.amount); if (opts.price === undefined) { throw new TypeError('price argument is required'); } attributes.price = this._toXDRPrice(opts.price); if (opts.offerId !== undefined) { opts.offerId = opts.offerId.toString(); } else { opts.offerId = '0'; } attributes.offerId = js_xdr_1.Hyper.fromString(opts.offerId); const manageSellOfferOp = new xdr_1.default.ManageSellOfferOp(attributes); const opAttributes = {}; opAttributes.body = xdr_1.default.OperationBody.manageSellOffer(manageSellOfferOp); this.setSourceAccount(opAttributes, opts); return new xdr_1.default.Operation(opAttributes); } exports.manageSellOffer = manageSellOffer; //# sourceMappingURL=manage_sell_offer.js.map