Skip to content

Amount route consolidation#281

Draft
gemdev111 wants to merge 18 commits intomainfrom
android-amount-route-consolidation
Draft

Amount route consolidation#281
gemdev111 wants to merge 18 commits intomainfrom
android-amount-route-consolidation

Conversation

@gemdev111
Copy link
Copy Markdown
Contributor

@gemdev111 gemdev111 commented May 7, 2026

Replaces the dual-route amount flow (AmountRoute + PerpetualAmountRoute backed by AmountViewModel + AmountBaseViewModel + PerpetualAmountViewModel) with a single AmountRoute, AmountScreen, and AmountViewModel that delegates per-flow logic to a sealed AmountDataProvider strategy. Mirrors iOS's AmountSceneViewModel + AmountDataProvidable architecture using Kotlin idioms (sealed interfaces, Hilt, StateFlow).

AmountParams becomes a sealed interface with one variant per flow (Transfer, Stake.Delegate/Undelegate/Redelegate/Withdraw/Rewards, Freeze, Perpetual); polymorphic JSON via @SerialName preserves route packing. Each provider (AmountTransferProvider, AmountStakeProvider, AmountFreezeProvider, AmountPerpetualProvider) owns its title, capability flags, balance flow, and ConfirmParams construction. AmountProviderFactory dispatches variants to the right provider via Hilt.

AmountViewModel holds amount input, validation, currency toggle, and max/equivalent state and forwards everything else to the injected provider. Read-only flows (Withdraw, Rewards) auto-prefill via combine(provider.assetInfo.filterNotNull(), provider.availableBalance) so subsequent balance updates keep the displayed amount in sync. AmountScene takes canSwitchInputType, readOnly, and showsAssetBalance booleans plus a slot for provider-specific controls (validator picker for Stake, Bandwidth/Energy tabs for Freeze, leverage row for Perpetual). The validator picker overlay moved to AmountScreen via AnimatedContent + BackHandler. Stake.Rewards keeps the balance row visible to mirror iOS.

Other fixes:

  • Stake.Undelegate and Stake.Withdraw carry validatorId; the DAO query joins delegation_id and validator.id, so the previously-empty validator argument returned null. DelegationViewModel.buildUndelegate now passes delegation.validator.id.
  • AmountStakeProvider falls back to stakeRepository.getRecommended(chain) when the user opens Stake.Delegate without an explicit validator and refreshes the rewards delegation when the user picks a different validator on Stake.Rewards.
  • AmountDataProvider.buildConfirmParams is suspend so a future AmountEarnProvider can fetch yield data before constructing ConfirmParams (mirrors iOS async makeTransferData).

Removes AmountBaseViewModel, PerpetualAmountViewModel, PerpetualAmountRoute, and the obsolete txType helpers and presentation models.

closes #258

@gemdev111 gemdev111 changed the title Android amount route consolidation Amount route consolidation May 7, 2026
@gemdev111 gemdev111 self-assigned this May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove PerpetualAmountRoute and consolidate with AmountRoute

1 participant