-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1690 from novasamatech/fix/swipe-gov-proxy-chain-…
…restrictions Block swipe gov for unsupported chains when proxied is using
- Loading branch information
Showing
8 changed files
with
114 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
14 changes: 14 additions & 0 deletions
14
...rnance_impl/domain/referendum/tindergov/validation/StartStakingLandingValidationSystem.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.validation | ||
|
||
import io.novafoundation.nova.common.validation.ValidationSystem | ||
import io.novafoundation.nova.feature_account_api.domain.validation.hasChainAccount | ||
|
||
typealias StartStakingLandingValidationSystem = ValidationSystem<StartSwipeGovValidationPayload, StartSwipeGovValidationFailure> | ||
|
||
fun ValidationSystem.Companion.startSwipeGovValidation(): StartStakingLandingValidationSystem = ValidationSystem { | ||
hasChainAccount( | ||
chain = { it.chain }, | ||
metaAccount = { it.metaAccount }, | ||
error = StartSwipeGovValidationFailure::NoChainAccountFound | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
..._governance_impl/domain/referendum/tindergov/validation/StartSwipeGovValidationFailure.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.validation | ||
|
||
import io.novafoundation.nova.feature_account_api.domain.model.MetaAccount | ||
import io.novafoundation.nova.feature_account_api.domain.validation.NoChainAccountFoundError | ||
import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain | ||
|
||
sealed class StartSwipeGovValidationFailure { | ||
|
||
class NoChainAccountFound( | ||
override val chain: Chain, | ||
override val account: MetaAccount, | ||
override val addAccountState: NoChainAccountFoundError.AddAccountState | ||
) : StartSwipeGovValidationFailure(), NoChainAccountFoundError | ||
} |
9 changes: 9 additions & 0 deletions
9
..._governance_impl/domain/referendum/tindergov/validation/StartSwipeGovValidationPayload.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.validation | ||
|
||
import io.novafoundation.nova.feature_account_api.domain.model.MetaAccount | ||
import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain | ||
|
||
class StartSwipeGovValidationPayload( | ||
val chain: Chain, | ||
val metaAccount: MetaAccount | ||
) |
This file contains 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
This file contains 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
This file contains 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
24 changes: 24 additions & 0 deletions
24
...ature_governance_impl/presentation/referenda/list/validation/StartSwipeGovValidationUi.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.novafoundation.nova.feature_governance_impl.presentation.referenda.list.validation | ||
|
||
import io.novafoundation.nova.common.resources.ResourceManager | ||
import io.novafoundation.nova.common.validation.TransformedFailure | ||
import io.novafoundation.nova.common.validation.ValidationStatus | ||
import io.novafoundation.nova.feature_account_api.domain.validation.handleChainAccountNotFound | ||
import io.novafoundation.nova.feature_governance_impl.R | ||
import io.novafoundation.nova.feature_governance_impl.domain.referendum.tindergov.validation.StartSwipeGovValidationFailure | ||
import io.novafoundation.nova.feature_governance_impl.presentation.GovernanceRouter | ||
|
||
fun handleStartSwipeGovValidationFailure( | ||
resourceManager: ResourceManager, | ||
validationStatus: ValidationStatus.NotValid<StartSwipeGovValidationFailure>, | ||
router: GovernanceRouter | ||
): TransformedFailure { | ||
return when (val reason = validationStatus.reason) { | ||
is StartSwipeGovValidationFailure.NoChainAccountFound -> handleChainAccountNotFound( | ||
failure = reason, | ||
addAccountDescriptionRes = R.string.common_network_not_supported, | ||
resourceManager = resourceManager, | ||
goToWalletDetails = { router.openWalletDetails(reason.account.id) } | ||
) | ||
} | ||
} |