feat: block Bridge swap when send amount exceeds available balance

The Bridge screen let a user type any amount and enabled the Swap
button regardless of what they actually held, unlike the Swap screen
which shows a live "Max: X" and disables on overflow. The confirm-step
ValidationSystem would still catch it before signing, but only after
routing through Send - no immediate feedback on the Bridge screen
itself.

Wires WalletInteractor.assetFlow(chainId, assetId) to the currently
selected origin side (re-subscribed on every direction/pair change),
tracking Asset.transferable - the same field the real transfer
validation checks. Reuses the existing MaxAmountView/MaxAvailableView
widget the Swap screen already uses for the "Max: X" display, and adds
a matching error-bordered state to BridgeAssetInputView. The
"Insufficient balance" string (bridge_insufficient_balance) was
already translated into every locale but never wired to any code.
This commit is contained in:
2026-07-13 12:10:16 -07:00
parent e0cd1f5def
commit 7401783436
6 changed files with 111 additions and 9 deletions
@@ -25,13 +25,27 @@
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/bridgeFromLabel"
style="@style/TextAppearance.NovaFoundation.Regular.Footnote"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bridge_you_send"
android:textColor="@color/text_secondary" />
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/bridgeFromLabel"
style="@style/TextAppearance.NovaFoundation.Regular.Footnote"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/bridge_you_send"
android:textColor="@color/text_secondary" />
<io.novafoundation.nova.feature_wallet_api.presentation.view.amount.MaxAmountView
android:id="@+id/bridgeFromMaxAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<io.novafoundation.nova.feature_assets.presentation.bridge.view.BridgeAssetInputView
android:id="@+id/bridgeFromCard"
@@ -110,4 +110,15 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/bridgeAssetInputError"
style="@style/TextAppearance.NovaFoundation.Regular.Caption1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="@color/text_negative"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bridgeAssetInputContainer" />
</merge>