Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Fix calculation of fees in multi-asset transactions (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
dguenther authored Sep 22, 2023
1 parent e22d9bd commit dcbdd9c
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/routes/Send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,29 @@ const Send: FC = () => {
if (balance?.available === BigInt(0)) {
return setError(HAS_PENDING_TRANSACTIONS)
}
if (balance?.confirmed === BigInt(0)) {
return setError(NOT_ENOUGH_FUNDS)
}

const amountInIron = decodeIron(amount || 0)
const fee = selectedFee?.value || BigInt(0)
const ironAmount = decodeIron(amount || 0)
if (balance?.confirmed < ironAmount + fee) {

const totalIron =
balance?.asset.id === account?.balances.default.asset.id
? amountInIron + fee
: fee

if (
account?.balances.default.confirmed < totalIron ||
balance?.confirmed < amountInIron
) {
return setError(NOT_ENOUGH_FUNDS)
}
setError('')
}, [balance?.available, balance?.confirmed, amount, selectedFee?.value])
}, [
balance?.asset?.id,
balance?.available,
balance?.confirmed,
amount,
selectedFee?.value,
])

const hasInvalidData = useMemo(() => {
return !(
Expand Down

1 comment on commit dcbdd9c

@vercel
Copy link

@vercel vercel bot commented on dcbdd9c Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wallet-app – ./

wallet-app-ironfish.vercel.app
wallet-app-git-master-ironfish.vercel.app
wallet-app-foo.vercel.app

Please sign in to comment.