test-triam-base-contract
Version:
Low level triam smart cotnract support library
34 lines (27 loc) • 1.23 kB
JavaScript
import {default as xdr} from "../generated/stellar-xdr_generated";
import {Keypair} from "../keypair";
import {StrKey} from "../strkey";
import clone from "lodash/clone";
import isUndefined from 'lodash/isUndefined';
import isString from 'lodash/isString';
/**
* Create and fund a non existent contract.
* @function
* @alias Operation.testContract
* @param {object} opts
* @param {string} opts.startingBalance - Amount in XLM the account should be funded for. Must be greater
* than the [reserve balance amount](https://www.stellar.org/developers/learn/concepts/fees.html).
*
* @param {string} [opts.source] - The source account for the create contract. Defaults to the transaction's source account.
* @returns {xdr.TestContractOp}
*/
export const testContract = function(opts) {
let attributes = {};
attributes.startingBalance = this._checkUnsignedIntValue("startingBalance", opts.startingBalance);
// thuannd notes end
let testContract = new xdr.TestContractOp(attributes);
let opAttributes = {};
opAttributes.body = xdr.OperationBody.testContract(testContract);
this.setSourceAccount(opAttributes, opts);
return new xdr.Operation(opAttributes);
};