@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
68 lines • 2.89 kB
JavaScript
;
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/ledger-wallet-framework/account/helpers");
const operation_1 = require("@ledgerhq/coin-evm/operation");
const operation_2 = require("@ledgerhq/coin-bitcoin/operation");
const config_1 = require("./config");
__exportStar(require("@ledgerhq/ledger-wallet-framework/operation"), exports);
function hasGasTracker(currency) {
const config = (0, config_1.getCurrencyConfiguration)(currency);
return !!config.gasTracker;
}
/**
* Return whether an operation is editable or not.
*/
const isEditableOperation = ({ account, operation, }) => {
if (account.currency.family === "evm") {
return (0, operation_1.isEditableOperation)(account, operation, hasGasTracker);
}
else if (account.currency.family === "bitcoin") {
return (0, operation_2.isEditableOperation)(account, operation);
}
return false;
};
exports.isEditableOperation = isEditableOperation;
/**
* Return whether an operation is considered stuck or not.
*/
const isStuckOperation = ({ family, operation, }) => {
if (family === "evm") {
return (0, operation_1.isStuckOperation)(operation);
}
else if (family === "bitcoin") {
return (0, operation_2.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);
}
else if (mainAccount.currency.family === "bitcoin") {
return (0, operation_2.getStuckAccountAndOperation)(account, parentAccount);
}
return undefined;
};
exports.getStuckAccountAndOperation = getStuckAccountAndOperation;
//# sourceMappingURL=operation.js.map