mirror of
https://github.com/zhigang1992/wallet.git
synced 2026-01-12 22:53:27 +08:00
fix: negative stx available balance, closes #3761
This commit is contained in:
@@ -22,6 +22,7 @@ export function useStxBalance() {
|
||||
const stxEffectiveBalance = isDefined(totalBalance)
|
||||
? subtractMoney(totalBalance, stxOutboundQuery.data)
|
||||
: createMoney(0, 'STX');
|
||||
|
||||
const stxEffectiveUsdBalance = isDefined(totalBalance)
|
||||
? i18nFormatCurrency(baseCurrencyAmountInQuote(stxEffectiveBalance, stxMarketData))
|
||||
: undefined;
|
||||
|
||||
@@ -66,15 +66,19 @@ export function useCurrentAccountMempoolTransactionsBalance() {
|
||||
const address = useCurrentAccountStxAddressState();
|
||||
const { transactions: pendingTransactions } = useStacksPendingTransactions();
|
||||
|
||||
const tokenTransferTxsBalance = (
|
||||
pendingTransactions.filter(
|
||||
tx => tx.tx_type === 'token_transfer' && tx.sender_address === address
|
||||
) as unknown as MempoolTokenTransferTransaction[]
|
||||
).reduce((acc, tx) => acc.plus(tx.token_transfer.amount), new BigNumber(0));
|
||||
const pendingTxsFeesBalance = pendingTransactions.reduce(
|
||||
const pendingOutboundTxs = pendingTransactions.filter(
|
||||
tx => tx.tx_type === 'token_transfer' && tx.sender_address === address
|
||||
) as unknown as MempoolTokenTransferTransaction[];
|
||||
|
||||
const tokenTransferTxsBalance = pendingOutboundTxs.reduce(
|
||||
(acc, tx) => acc.plus(tx.token_transfer.amount),
|
||||
new BigNumber(0)
|
||||
);
|
||||
const pendingTxsFeesBalance = pendingOutboundTxs.reduce(
|
||||
(acc, tx) => acc.plus(tx.fee_rate),
|
||||
new BigNumber(0)
|
||||
);
|
||||
|
||||
return createMoney(tokenTransferTxsBalance.plus(pendingTxsFeesBalance), 'STX');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user