UNPKG

test-triam-base-contract

Version:

Low level triam smart cotnract support library

32 lines (26 loc) 1.01 kB
import {default as xdr} from "../generated/stellar-xdr_generated"; import {Keypair} from "../keypair"; import {StrKey} from "../strkey"; /** * Check a Tx contains the contract ops. * @function * @alias Operation.checkContract * @param {object} opts * @param {(number|string)} opts.isContract - Check: is contract * The source account for the payment. Defaults to the transaction's source account. * @param {string} [opts.source] * @returns {xdr.CheckContractOp} */ export const checkContract = function(opts) { let attributes = {}; attributes.isContract = this._checkUnsignedIntValue("isContract", opts.isContract); if (attributes.isContract != 0 && attributes.isContract != 1) { throw new Error("IsContract must be 0 or 1."); } let checkContract = new xdr.CheckContractOp(attributes); let opAttributes = {}; opAttributes.body = xdr.OperationBody.checkContract(checkContract); this.setSourceAccount(opAttributes, opts); return new xdr.Operation(opAttributes); };