UNPKG

@ledgerhq/live-common

Version:
48 lines 2.08 kB
import { getMainAccount } from "@ledgerhq/ledger-wallet-framework/account/helpers"; import { isEditableOperation as isEditableOperationEvm, isStuckOperation as isStuckOperationEvm, getStuckAccountAndOperation as getStuckAccountAndOperationEvm, } from "@ledgerhq/coin-evm/operation"; import { isStuckOperation as isStuckOperationBitcoin, getStuckAccountAndOperation as getStuckAccountAndOperationBitcoin, isEditableOperation as isEditableOperationBitcoin, } from "@ledgerhq/coin-bitcoin/operation"; import { getCurrencyConfiguration } from "./config"; export * from "@ledgerhq/ledger-wallet-framework/operation"; function hasGasTracker(currency) { const config = getCurrencyConfiguration(currency); return !!config.gasTracker; } /** * Return whether an operation is editable or not. */ export const isEditableOperation = ({ account, operation, }) => { if (account.currency.family === "evm") { return isEditableOperationEvm(account, operation, hasGasTracker); } else if (account.currency.family === "bitcoin") { return isEditableOperationBitcoin(account, operation); } return false; }; /** * Return whether an operation is considered stuck or not. */ export const isStuckOperation = ({ family, operation, }) => { if (family === "evm") { return isStuckOperationEvm(operation); } else if (family === "bitcoin") { return isStuckOperationBitcoin(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); } else if (mainAccount.currency.family === "bitcoin") { return getStuckAccountAndOperationBitcoin(account, parentAccount); } return undefined; }; //# sourceMappingURL=operation.js.map