@taquito/taquito
Version:
High level functionality that builds upon the other packages in the Tezos Typescript Library Suite.
66 lines • 2.46 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RevealOperation = void 0;
const bignumber_js_1 = require("bignumber.js");
const operation_errors_1 = require("./operation-errors");
const operations_1 = require("./operations");
/**
* @description Reveal operation provides utility functions to fetch a newly issued revelation
*/
class RevealOperation 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 revealOp = Array.isArray(this.results) &&
this.results.find((op) => op.kind === 'reveal');
return revealOp ? [revealOp] : [];
}
get status() {
const operationResults = this.operationResults;
const txResult = operationResults[0];
if (txResult) {
return txResult.metadata.operation_result.status;
}
else {
return 'unknown';
}
}
get fee() {
return Number(this.params.fee);
}
get gasLimit() {
return Number(this.params.gas_limit);
}
get storageLimit() {
return Number(this.params.storage_limit);
}
get publicKey() {
return this.params.public_key;
}
sumProp(arr, prop) {
return arr.reduce((prev, current) => {
return prop in current ? Number(current[prop]) + prev : prev;
}, 0);
}
get consumedGas() {
bignumber_js_1.BigNumber.config({ DECIMAL_PLACES: 0, ROUNDING_MODE: bignumber_js_1.BigNumber.ROUND_UP });
return new bignumber_js_1.BigNumber(this.consumedMilliGas).dividedBy(1000).toString();
}
get consumedMilliGas() {
return String(this.sumProp(operation_errors_1.flattenOperationResult({ contents: this.operationResults }), 'consumed_milligas'));
}
get storageDiff() {
return String(this.sumProp(operation_errors_1.flattenOperationResult({ contents: this.operationResults }), 'paid_storage_size_diff'));
}
get storageSize() {
return String(this.sumProp(operation_errors_1.flattenOperationResult({ contents: this.operationResults }), 'storage_size'));
}
get errors() {
return operation_errors_1.flattenErrors({ contents: this.operationResults });
}
}
exports.RevealOperation = RevealOperation;
//# sourceMappingURL=reveal-operation.js.map