UNPKG

test-triam-base-contract

Version:

Low level triam smart cotnract support library

37 lines (31 loc) 1.2 kB
import {default as xdr} from "../generated/stellar-xdr_generated"; import {Keypair} from "../keypair"; import {Hyper} from "js-xdr"; import {StrKey} from "../strkey"; /** * Create a LimitAsset operation. * @function * @alias Operation.limitAsset * @param {object} opts * @param {Asset} opts.asset - The asset to create. * @param {(number|string)} opts.islimited - The amount to send. * @param {string} [opts.source] - The source account for the payment. Defaults to the transaction's source account. * @returns {xdr.LimitAssetOp} */ export const limitAsset = function(opts) { if (!opts.asset) { throw new Error("Must provide an asset for a limitAsset operation"); } let attributes = {}; attributes.asset = opts.asset.toXDRObject(); attributes.islimited = this._checkUnsignedIntValue("islimited", opts.islimited); if (attributes.islimited != 0 && attributes.islimited != 1) { throw new Error("Islimited must be 0 or 1."); } let limitAsset = new xdr.LimitAssetOp(attributes); let opAttributes = {}; opAttributes.body = xdr.OperationBody.limitAsset(limitAsset); this.setSourceAccount(opAttributes, opts); return new xdr.Operation(opAttributes); };