Conversation
Move confirm domain models (ConfirmError, ConfirmState, ConfirmProperty, AmountUIModel, FeeUIModel, FeeRateUIModel) from feature module to gemcore/domains/confirm. Extract business logic from ConfirmViewModel into coordinator interfaces (ValidateBalance, ConfirmTransaction, BuildConfirmProperties) with implementations in data/coordinators and Hilt DI wiring. ConfirmViewModel now injects coordinator interfaces instead of raw repositories and operators, reducing it from 622 to 338 LOC. Closes #18
gemcoder21
approved these changes
Apr 13, 2026
| else -> null | ||
| } | ||
|
|
||
| private fun resolveFinishRoute(input: ConfirmParams): String = when (input) { |
Contributor
There was a problem hiding this comment.
Suggested change
| private fun resolveFinishRoute(input: ConfirmParams): String = when (input) { | |
| private fun getFinishRoute(input: ConfirmParams): String = when (input) { |
| is ConfirmParams.SwapParams, | ||
| is ConfirmParams.TokenApprovalParams -> "swap" | ||
| is ConfirmParams.TransferParams -> "asset" | ||
| is ConfirmParams.Activate -> "asset" |
| is ConfirmParams.NftParams -> jsonEncoder.encodeToString( | ||
| TransactionNFTTransferMetadata(input.nftAsset.id, input.nftAsset.name) | ||
| ) | ||
| else -> null |
Contributor
There was a problem hiding this comment.
let json = jsonEncoder.encodeToString(value)
| TransactionType.EarnWithdraw, | ||
| TransactionType.StakeUnfreeze, | ||
| TransactionType.TransferNFT -> amount | ||
| TransactionType.SmartContractCall -> TODO() |
|
|
||
| private fun List<AssetInfo>.getByAssetId(assetId: AssetId): AssetInfo? { | ||
| val str = assetId.toIdentifier() | ||
| return firstOrNull { it.id().toIdentifier() == str } |
Contributor
There was a problem hiding this comment.
Suggested change
| return firstOrNull { it.id().toIdentifier() == str } | |
| return firstOrNull { it.id().toIdentifier() == assetId.toIdentifier() } |
| val validatorId = when (params) { | ||
| is ConfirmParams.Stake.DelegateParams -> params.validator.id | ||
| is ConfirmParams.Stake.RedelegateParams -> params.dstValidator.id | ||
| is ConfirmParams.Stake.UndelegateParams -> params.delegation.base.validatorId |
| private suspend fun getValidator(params: ConfirmParams): DelegationValidator? { | ||
| val validatorId = when (params) { | ||
| is ConfirmParams.Stake.DelegateParams -> params.validator.id | ||
| is ConfirmParams.Stake.RedelegateParams -> params.dstValidator.id |
Contributor
There was a problem hiding this comment.
Suggested change
| is ConfirmParams.Stake.RedelegateParams -> params.dstValidator.id | |
| is ConfirmParams.Stake.RedelegateParams -> params.destinationValidator.id |
| } | ||
|
|
||
| internal fun GemGasPriceType.totalFee(): BigInteger = when (this) { | ||
| fun GemGasPriceType.totalFee(): BigInteger = when (this) { |
Contributor
Author
|
- Rename resolveFinishRoute to getFinishRoute - Combine when cases returning the same value - Inline assetId.toIdentifier() in getByAssetId - Rename dstValidator to destinationValidator - Move GemGasPriceType extensions to ext/ layer - Use val json pattern in assembleMetadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move confirm domain models (ConfirmError, ConfirmState, ConfirmProperty, AmountUIModel, FeeUIModel, FeeRateUIModel) from feature module to gemcore/domains/confirm.
Extract business logic from ConfirmViewModel into coordinator interfaces (ValidateBalance, ConfirmTransaction, BuildConfirmProperties) with implementations in data/coordinators and Hilt DI wiring.
ConfirmViewModel now injects coordinator interfaces instead of raw repositories and operators
Closes: https://github.com/gemwalletcom/gem-android-issues/issues/18