@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
22 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.maybeKeepTronAccountAlive = void 0;
const errors_1 = require("@ledgerhq/errors");
const maybeKeepTronAccountAlive = (swapTransaction) => {
const isTron = swapTransaction?.swap?.from?.currency?.id === "tron";
const balance = swapTransaction.swap.from.account?.balance;
const swapAmount = swapTransaction.swap.from?.amount;
if (isTron &&
balance &&
swapAmount?.lte(balance) &&
balance.minus(swapAmount || 0).lt(1_200_000) // keep 1.1 TRX for fees and 0.1 TRX for keeping the account alive
) {
return new errors_1.MaybeKeepTronAccountAlive("PREVENT_RECEIVING_TRC20_ON_EMPTY_ACCOUNT", {
links: [
"https://support.ledger.com/hc/en-us/articles/6516823445533-Activate-Tron-account-to-send-or-receive-Tron-tokens?support=true",
],
});
}
};
exports.maybeKeepTronAccountAlive = maybeKeepTronAccountAlive;
//# sourceMappingURL=maybeKeepTronAccountAlive.js.map