@taquito/taquito
Version:
High level functionality that builds upon the other packages in the Tezos Typescript Library Suite.
50 lines • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransferTicketOperation = void 0;
const rpc_1 = require("@taquito/rpc");
const bignumber_js_1 = require("bignumber.js");
const operations_1 = require("../operations");
/**
*
* @description Transfer tickets from a Tezos address (tz1, tz2 or tz3) to a smart contract address (KT1) (everything on layer 1 at this step)
*
* @warn Currently only supports one L2 ticket holder transfer at once. ie. one collection of tickets owned by tz1, tz2 or tz3 to a smart contract.
*/
class TransferTicketOperation 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 transferOp = Array.isArray(this.results) &&
this.results.find((op) => op.kind === rpc_1.OpKind.TRANSFER_TICKET);
const result = transferOp && transferOp.metadata && transferOp.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 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;
}
}
exports.TransferTicketOperation = TransferTicketOperation;
//# sourceMappingURL=transfer-ticket-operation.js.map