"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStuckAccountAndOperation = exports.isStuckOperation = exports.isEditableOperation = void 0;
const helpers_1 = require("@ledgerhq/coin-framework/account/helpers");
const operation_1 = require("@ledgerhq/coin-evm/operation");
const config_1 = require("./config");
__exportStar(require("@ledgerhq/coin-framework/operation"), exports);
function hasGasTracker(currency) {
    const config = (0, config_1.getCurrencyConfiguration)(currency);
    return !!config.gasTracker;
}
/**
 * Return weather an operation is editable or not.
 */
const isEditableOperation = ({ account, operation, }) => {
    if (account.currency.family === "evm") {
        return (0, operation_1.isEditableOperation)(account, operation, hasGasTracker);
    }
    return false;
};
exports.isEditableOperation = isEditableOperation;
/**
 * Return weather an operation is considered stuck or not.
 */
const isStuckOperation = ({ family, operation, }) => {
    if (family === "evm") {
        return (0, operation_1.isStuckOperation)(operation);
    }
    return false;
};
exports.isStuckOperation = isStuckOperation;
/**
 * Return the oldest stuck pending operation and its corresponding account.
 * If no stuck pending operation is found, returns undefined
 */
const getStuckAccountAndOperation = (account, parentAccount) => {
    const mainAccount = (0, helpers_1.getMainAccount)(account, parentAccount);
    if (mainAccount.currency.family === "evm") {
        return (0, operation_1.getStuckAccountAndOperation)(account, parentAccount, hasGasTracker);
    }
    return undefined;
};
exports.getStuckAccountAndOperation = getStuckAccountAndOperation;
//# sourceMappingURL=operation.js.map