Skip to content

Organize feature/confirm#140

Merged
DRadmir merged 4 commits intomainfrom
feature/organize-confirm
Apr 14, 2026
Merged

Organize feature/confirm#140
DRadmir merged 4 commits intomainfrom
feature/organize-confirm

Conversation

@DRadmir
Copy link
Copy Markdown
Contributor

@DRadmir DRadmir commented Apr 13, 2026

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

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
@DRadmir DRadmir self-assigned this Apr 13, 2026
else -> null
}

private fun resolveFinishRoute(input: ConfirmParams): String = when (input) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

combine cases

is ConfirmParams.NftParams -> jsonEncoder.encodeToString(
TransactionNFTTransferMetadata(input.nftAsset.id, input.nftAsset.name)
)
else -> null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let json = jsonEncoder.encodeToString(value)

TransactionType.EarnWithdraw,
TransactionType.StakeUnfreeze,
TransactionType.TransferNFT -> amount
TransactionType.SmartContractCall -> TODO()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

combine cases


private fun List<AssetInfo>.getByAssetId(assetId: AssetId): AssetInfo? {
val str = assetId.toIdentifier()
return firstOrNull { it.id().toIdentifier() == str }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

combine cases

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move to another place

@DRadmir
Copy link
Copy Markdown
Contributor Author

DRadmir commented Apr 13, 2026

  • Test

DRadmir added 2 commits April 13, 2026 23:42
- 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
@DRadmir DRadmir merged commit 14a546c into main Apr 14, 2026
3 checks passed
@DRadmir DRadmir deleted the feature/organize-confirm branch April 14, 2026 09:02
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.

2 participants