import { getMainAccount } from "@ledgerhq/coin-framework/account/helpers";
import { isEditableOperation as isEditableOperationEvm, isStuckOperation as isStuckOperationEvm, getStuckAccountAndOperation as getStuckAccountAndOperationEvm, } from "@ledgerhq/coin-evm/operation";
import { getCurrencyConfiguration } from "./config";
export * from "@ledgerhq/coin-framework/operation";
function hasGasTracker(currency) {
    const config = getCurrencyConfiguration(currency);
    return !!config.gasTracker;
}
/**
 * Return weather an operation is editable or not.
 */
export const isEditableOperation = ({ account, operation, }) => {
    if (account.currency.family === "evm") {
        return isEditableOperationEvm(account, operation, hasGasTracker);
    }
    return false;
};
/**
 * Return weather an operation is considered stuck or not.
 */
export const isStuckOperation = ({ family, operation, }) => {
    if (family === "evm") {
        return isStuckOperationEvm(operation);
    }
    return false;
};
/**
 * Return the oldest stuck pending operation and its corresponding account.
 * If no stuck pending operation is found, returns undefined
 */
export const getStuckAccountAndOperation = (account, parentAccount) => {
    const mainAccount = getMainAccount(account, parentAccount);
    if (mainAccount.currency.family === "evm") {
        return getStuckAccountAndOperationEvm(account, parentAccount, hasGasTracker);
    }
    return undefined;
};
//# sourceMappingURL=operation.js.map