@ledgerhq/coin-stellar
Version:
Ledger Stellar Coin integration
20 lines • 1.05 kB
JavaScript
import BigNumber from "bignumber.js";
import { getMainAccount } from "@ledgerhq/coin-framework/account";
import { getTransactionStatus } from "./getTransactionStatus";
import { prepareTransaction } from "./prepareTransaction";
import { createTransaction } from "./createTransaction";
const notCreatedStellarMockAddress = "GAW46JE3SHIAYLNNNQCAZFQ437WB5ZH7LDRDWR5LVDWHCTHCKYB6RCCH";
export const estimateMaxSpendable = async ({ account, parentAccount, transaction, }) => {
const mainAccount = getMainAccount(account, parentAccount);
const preparedTransaction = await prepareTransaction(mainAccount, {
...createTransaction(account),
...transaction,
recipient: transaction?.recipient || notCreatedStellarMockAddress,
// not used address
useAllAmount: true,
});
const status = await getTransactionStatus(mainAccount, preparedTransaction);
return status.amount.gte(0) ? status.amount : new BigNumber(0);
};
export default estimateMaxSpendable;
//# sourceMappingURL=estimateMaxSpendable.js.map