UNPKG

@mavrykdynamics/taquito

Version:

High level functionality that builds upon the other packages in the Mavryk Typescript Library Suite.

58 lines (57 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DelegateOperation = void 0; const bignumber_js_1 = require("bignumber.js"); const operations_1 = require("./operations"); /** * @description Delegation operation provide utility function to fetch newly issued delegation * * @warn Currently support only one delegation per operation */ class DelegateOperation extends operations_1.Operation { constructor(hash, params, source, raw, results, context) { super(hash, raw, results, context); this.params = params; this.source = source; } get operationResults() { const delegationOp = Array.isArray(this.results) && this.results.find((op) => op.kind === 'delegation'); const result = delegationOp && delegationOp.metadata && delegationOp.metadata.operation_result; return result ? result : undefined; } get status() { var _a, _b; return (_b = (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'unknown'; } get delegate() { return this.params.delegate; } get isRegisterOperation() { return this.delegate === this.source; } get fee() { return Number(this.params.fee); } get gasLimit() { return Number(this.params.gas_limit); } get storageLimit() { return Number(this.params.storage_limit); } get consumedGas() { bignumber_js_1.BigNumber.config({ DECIMAL_PLACES: 0, ROUNDING_MODE: bignumber_js_1.BigNumber.ROUND_UP }); return this.consumedMilliGas ? new bignumber_js_1.BigNumber(this.consumedMilliGas).dividedBy(1000).toString() : undefined; } get consumedMilliGas() { var _a; return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.consumed_milligas; } get errors() { var _a; return (_a = this.operationResults) === null || _a === void 0 ? void 0 : _a.errors; } } exports.DelegateOperation = DelegateOperation;