@ledgerhq/coin-casper
Version:
Ledger Casper integration
16 lines • 724 B
JavaScript
import BigNumber from "bignumber.js";
import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
import { getEstimatedFees } from "./bridgeHelpers/fee";
export const estimateMaxSpendable = async ({ account, parentAccount, transaction, }) => {
const mainAccount = getMainAccount(account, parentAccount);
let balance = mainAccount.spendableBalance;
if (balance.eq(0))
return balance;
const estimatedFees = transaction?.fees ?? getEstimatedFees();
if (balance.lte(estimatedFees))
return new BigNumber(0);
balance = balance.minus(estimatedFees);
// log("debug", "[estimateMaxSpendable] finish fn");
return balance;
};
//# sourceMappingURL=estimateMaxSpendable.js.map