Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed wrong logic for the `hasEnoughFunds` variable in allocate flow [#932]

## [1.7.1] - 2026-02-17

### Added
Expand Down Expand Up @@ -640,6 +642,7 @@ dusk-network/rusk#3958: https://github.com/dusk-network/rusk/issues/3958
dusk-network/rusk#3982: https://github.com/dusk-network/rusk/issues/3982
dusk-network/rusk#3984: https://github.com/dusk-network/rusk/issues/3984
[#928]: https://github.com/dusk-network/web-wallet/issues/928
[#932]: https://github.com/dusk-network/web-wallet/issues/932

<!-- VERSIONS -->

Expand Down
29 changes: 17 additions & 12 deletions src/lib/components/Allocate/Allocate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
let screenWidth = window.innerWidth;

let hasInvalidInput = false;
let hasEnoughFunds = true;

// Constant total
const totalBalance = shieldedBalance.spendable + unshieldedBalance;
Expand All @@ -125,17 +124,23 @@
$: unshieldedNumber = luxToDusk(unshielded);

$: isShielding = difference > 0n;
$: isUnshielding = !isShielding;

$: fee = gasLimit * gasPrice;
$: difference = shielded - initialShielded;

$: hasEnoughFunds = isUnshielding
? shieldedBalance.spendable - difference - fee >= 0n
: unshieldedBalance + difference - fee >= 0n;
$: hasEnoughFundsForFees =
difference === 0n ||
(isShielding
? unshieldedBalance - difference - fee >= 0n
: shieldedBalance.spendable + difference - fee >= 0n);
$: fundsErrorMessage = hasEnoughFundsForFees
? ""
: shielded < 0n || unshielded < 0n
? "Not enough funds for the transaction."
: "Your balance is too low to cover the allocation fees.";

$: isNextButtonDisabled =
!hasEnoughFunds ||
!hasEnoughFundsForFees ||
!isGasValid ||
difference === 0n || // No change in balance
shielded < 0n || // Shielded balance is negative
Expand Down Expand Up @@ -254,11 +259,11 @@
}}
/>

{#if !hasEnoughFunds}
{#if fundsErrorMessage}
<Banner title="Insufficient Funds" variant="error">
<p>
Your balance is too low to cover the allocation fees. Please
adjust your transaction or add more funds to proceed.
{fundsErrorMessage} Please adjust your transaction or add more funds
to proceed.
</p>
</Banner>
{/if}
Expand Down Expand Up @@ -312,21 +317,21 @@
<dl class="operation__review-transaction">
<dt class="review-transaction__label">
<Icon
path={isUnshielding ? mdiShieldLockOpenOutline : mdiShieldLock}
path={isShielding ? mdiShieldLock : mdiShieldLockOpenOutline}
/>
<span>To</span>
</dt>
<dd class="operation__review-address">
<span>
{isUnshielding ? unshieldedAddress : shieldedAddress}
{isShielding ? shieldedAddress : unshieldedAddress}
</span>
</dd>
</dl>
<GasFee {formatter} {fee} />
<Banner title="Fee Details" variant="info">
<p>
The fee will be deducted from your <b
>{isUnshielding ? "shielded" : "public"}</b
>{isShielding ? "public" : "shielded"}</b
> balance.
</p>
</Banner>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,33 +241,6 @@ exports[`Allocate > should render the allocation page 1`] = `

</div>

<div
class="banner banner--error"
>
<svg
class="dusk-icon dusk-icon--size--large banner__icon banner__icon--error"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M23,12L20.56,14.78L20.9,18.46L17.29,19.28L15.4,22.46L12,21L8.6,22.47L6.71,19.29L3.1,18.47L3.44,14.78L1,12L3.44,9.21L3.1,5.53L6.71,4.72L8.6,1.54L12,3L15.4,1.54L17.29,4.72L20.9,5.54L20.56,9.22L23,12M20.33,12L18.5,9.89L18.74,7.1L16,6.5L14.58,4.07L12,5.18L9.42,4.07L8,6.5L5.26,7.09L5.5,9.88L3.67,12L5.5,14.1L5.26,16.9L8,17.5L9.42,19.93L12,18.81L14.58,19.92L16,17.5L18.74,16.89L18.5,14.1L20.33,12M11,15H13V17H11V15M11,7H13V13H11V7"
/>
</svg>


<div>
<strong
class="banner__title"
>
Insufficient Funds
</strong>

<p>
Your balance is too low to cover the allocation fees. Please
adjust your transaction or add more funds to proceed.
</p>
</div>
</div>
</div>

<div
Expand Down