UNPKG

stratis-strapjs

Version:

Library for interacting with Stratis smart contracts.

48 lines 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); var LocalMethodCallOptions = /** @class */ (function () { function LocalMethodCallOptions(amount, sender, gasPrice, gasLimit) { if (amount === void 0) { amount = 0; } if (sender === void 0) { sender = Contract.base58Zero; } if (gasPrice === void 0) { gasPrice = 1; } if (gasLimit === void 0) { gasLimit = 20000; } this.amount = amount; this.sender = sender; this.gasPrice = gasPrice; this.gasLimit = gasLimit; } return LocalMethodCallOptions; }()); exports.LocalMethodCallOptions = LocalMethodCallOptions; var Contract = /** @class */ (function () { function Contract(address, provider) { this.address = address; this.provider = provider; } Contract.prototype.balance = function () { return this.provider.getContractBalance(this.address); }; Contract.prototype.callMethodLocally = function (methodName, parameters, options) { if (parameters === void 0) { parameters = []; } if (options === void 0) { options = new LocalMethodCallOptions(); } var localCall = { contractAddress: this.address, methodName: methodName, parameters: parameters, amount: options.amount, gasPrice: options.gasPrice, gasLimit: options.gasLimit, sender: options.sender }; return this.provider.callLocal(localCall) .pipe(operators_1.map(function (r) { return r.Return; })); }; /* This is the Base58 representation of Address.Zero on SmartContractPoATestNetwork. */ Contract.base58Zero = "mfWxJ45yp2SFn7UciZyNpvDKrzbhyfKrY8"; return Contract; }()); exports.Contract = Contract; //# sourceMappingURL=Contract.js.map