@ledgerhq/coin-tron
Version:
Ledger Tron Coin integration
19 lines • 950 B
JavaScript
import { getMainAccount } from "@ledgerhq/ledger-wallet-framework/account";
import BigNumber from "bignumber.js";
import createTransaction from "./createTransaction";
import getEstimatedFees from "./getEstimateFees";
const estimateMaxSpendable = async ({ account, parentAccount, transaction }) => {
const mainAccount = getMainAccount(account, parentAccount);
const fees = await getEstimatedFees(mainAccount, {
...createTransaction(),
subAccountId: account.type === "Account" ? null : account.id,
...transaction,
recipient: transaction?.recipient || "0x0000000000000000000000000000000000000000",
amount: new BigNumber(0),
}, account.type === "TokenAccount" ? account : undefined);
return account.type === "Account"
? BigNumber.max(0, account.spendableBalance.minus(fees))
: account.balance;
};
export default estimateMaxSpendable;
//# sourceMappingURL=estimateMaxSpendable.js.map