-
Notifications
You must be signed in to change notification settings - Fork 34
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 #1771 from novasamatech/myth_staking/setup_start_s…
…taking Myth staking/setup start staking
- Loading branch information
Showing
108 changed files
with
2,309 additions
and
642 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ava/io/novafoundation/nova/app/di/app/navigation/staking/MythosStakingNavigationModule.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,20 @@ | ||
package io.novafoundation.nova.app.di.app.navigation.staking | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import io.novafoundation.nova.app.root.navigation.navigators.NavigationHoldersRegistry | ||
import io.novafoundation.nova.app.root.navigation.navigators.staking.mythos.MythosStakingNavigator | ||
import io.novafoundation.nova.common.di.scope.ApplicationScope | ||
import io.novafoundation.nova.feature_staking_impl.presentation.MythosStakingRouter | ||
|
||
@Module | ||
class MythosStakingNavigationModule { | ||
|
||
@Provides | ||
@ApplicationScope | ||
fun provideMythosStakingRouter( | ||
navigationHoldersRegistry: NavigationHoldersRegistry, | ||
): MythosStakingRouter { | ||
return MythosStakingNavigator(navigationHoldersRegistry) | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
...vafoundation/nova/app/root/navigation/navigators/staking/mythos/MythosStakingNavigator.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.app.root.navigation.navigators.staking.mythos | ||
|
||
import io.novafoundation.nova.app.root.navigation.navigators.BaseNavigator | ||
import io.novafoundation.nova.app.root.navigation.navigators.NavigationHoldersRegistry | ||
import io.novafoundation.nova.feature_staking_impl.presentation.MythosStakingRouter | ||
|
||
class MythosStakingNavigator( | ||
navigationHoldersRegistry: NavigationHoldersRegistry, | ||
) : BaseNavigator(navigationHoldersRegistry), MythosStakingRouter |
22 changes: 22 additions & 0 deletions
22
app/src/main/res/navigation/staking_mythos_start_graph.xml
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,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<navigation xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/staking_mythos_start_graph" | ||
app:startDestination="@id/startMythosStakingFragment"> | ||
|
||
<action | ||
android:id="@+id/action_return_to_start_staking" | ||
app:enterAnim="@anim/fragment_close_enter" | ||
app:exitAnim="@anim/fragment_close_exit" | ||
app:popEnterAnim="@anim/fragment_open_enter" | ||
app:popExitAnim="@anim/fragment_open_exit" | ||
app:popUpTo="@id/startMythosStakingFragment" /> | ||
|
||
<fragment | ||
android:id="@+id/startMythosStakingFragment" | ||
android:name="io.novafoundation.nova.feature_staking_impl.presentation.mythos.start.setup.SetupStartMythosStakingFragment" | ||
android:label="StartMythosStakingFragment" | ||
tools:layout="@layout/fragment_parachain_staking_start"> | ||
</fragment> | ||
</navigation> |
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
9 changes: 9 additions & 0 deletions
9
common/src/main/java/io/novafoundation/nova/common/mixin/hints/NoHintsMixin.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.common.mixin.hints | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flowOf | ||
|
||
class NoHintsMixin : HintsMixin { | ||
|
||
override val hintsFlow: Flow<List<CharSequence>> = flowOf(emptyList()) | ||
} |
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
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
50 changes: 50 additions & 0 deletions
50
...on/nova/feature_staking_impl/data/mythos/network/blockchain/calls/CollatorStakingCalls.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,50 @@ | ||
package io.novafoundation.nova.feature_staking_impl.data.mythos.network.blockchain.calls | ||
|
||
import io.novafoundation.nova.common.address.AccountIdKey | ||
import io.novafoundation.nova.common.utils.Modules | ||
import io.novafoundation.nova.common.utils.structOf | ||
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.types.Balance | ||
import io.novasama.substrate_sdk_android.runtime.extrinsic.ExtrinsicBuilder | ||
|
||
@JvmInline | ||
value class CollatorStakingCalls(val builder: ExtrinsicBuilder) | ||
|
||
val ExtrinsicBuilder.collatorStaking: CollatorStakingCalls | ||
get() = CollatorStakingCalls(this) | ||
|
||
fun CollatorStakingCalls.lock(amount: Balance) { | ||
builder.call( | ||
moduleName = Modules.COLLATOR_STAKING, | ||
callName = "lock", | ||
arguments = mapOf( | ||
"amount" to amount | ||
) | ||
) | ||
} | ||
|
||
data class StakingIntent(val candidate: AccountIdKey, val stake: Balance) { | ||
|
||
companion object { | ||
|
||
fun zero(candidate: AccountIdKey) = StakingIntent(candidate, Balance.ZERO) | ||
} | ||
} | ||
|
||
fun CollatorStakingCalls.stake(intents: List<StakingIntent>) { | ||
val targets = intents.map(StakingIntent::toEncodableInstance) | ||
|
||
builder.call( | ||
moduleName = Modules.COLLATOR_STAKING, | ||
callName = "stake", | ||
arguments = mapOf( | ||
"targets" to targets | ||
) | ||
) | ||
} | ||
|
||
private fun StakingIntent.toEncodableInstance(): Any? { | ||
return structOf( | ||
"candidate" to candidate.value, | ||
"stake" to stake | ||
) | ||
} |
22 changes: 22 additions & 0 deletions
22
...ation/nova/feature_staking_impl/data/mythos/network/blockchain/model/MythCandidateInfo.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,22 @@ | ||
package io.novafoundation.nova.feature_staking_impl.data.mythos.network.blockchain.model | ||
|
||
import io.novafoundation.nova.common.data.network.runtime.binding.bindInt | ||
import io.novafoundation.nova.common.data.network.runtime.binding.bindNumber | ||
import io.novafoundation.nova.common.data.network.runtime.binding.castToStruct | ||
import io.novafoundation.nova.feature_account_api.data.model.AccountIdKeyMap | ||
import io.novafoundation.nova.feature_wallet_api.data.network.blockhain.types.Balance | ||
|
||
class MythCandidateInfo( | ||
val stake: Balance, | ||
val stakers: Int | ||
) | ||
|
||
typealias MythCandidateInfos = AccountIdKeyMap<MythCandidateInfo> | ||
|
||
fun bindMythCandidateInfo(decoded: Any?): MythCandidateInfo { | ||
val asStruct = decoded.castToStruct() | ||
return MythCandidateInfo( | ||
stake = bindNumber(asStruct["stake"]), | ||
stakers = bindInt(asStruct["stakers"]) | ||
) | ||
} |
Oops, something went wrong.