package Ġio . nova foundation . nova . feature _ staking _ impl . presentation . staking . main . manage Ċ Ċ import Ġio . nova foundation . nova . common . resources . ResourceManager Ċ import Ġio . nova foundation . nova . common . utils . With Coroutine Scope Extensions Ċ import Ġio . nova foundation . nova . common . validation . Validation Executor Ċ import Ġio . nova foundation . nova . feature _ staking _ api . domain . model . St aking State Ċ import Ġio . nova foundation . nova . feature _ staking _ impl . domain . valid ations . main . Stake Actions Validation Payload Ċ import Ġio . nova foundation . nova . feature _ staking _ impl . domain . valid ations . main . Stake Actions Validation System Ċ import Ġio . nova foundation . nova . feature _ staking _ impl . presentation . St aking Router Ċ import Ġio . nova foundation . nova . feature _ staking _ impl . presentation . staking . main . main St aking Validation Failure Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠManage Stake Mixin Factory ( ĊĠĠĠ Ġprivate Ġval Ġvalidation Executor : ĠValidation Executor , ĊĠĠĠ Ġprivate Ġval Ġresource Manager : ĠResourceManager , ĊĠĠĠ Ġprivate Ġval Ġstake Actions Valid ations : ĠMap < Manage Stake Action , ĠSt ake Actions Validation System >, ĊĠĠĠ Ġprivate Ġval Ġrouter : ĠSt aking Router , Ċ ) Ġ{ ĊĊĠĠĠ Ġfun Ġcreate ( ĊĠĠĠĠĠĠĠ Ġerror Dis player : Ġ( Throwable ) Ġ-> ĠUnit , ĊĠĠĠĠĠĠĠ Ġst ash State : ĠSt aking State . St ash , ĊĠĠĠĠĠĠĠ Ġcoroutine Scope : ĠCor outine Scope ĊĠĠĠ Ġ): ĠManage Stake Mixin . Presentation Ġ= ĠManage Stake Provider ( ĊĠĠĠĠĠĠĠ Ġvalidation Executor Ġ= Ġvalidation Executor , ĊĠĠĠĠĠĠĠ Ġresource Manager Ġ= Ġresource Manager , ĊĠĠĠĠĠĠĠ Ġrouter Ġ= Ġrouter , ĊĠĠĠĠĠĠĠ Ġstake Actions Valid ations Ġ= Ġstake Actions Valid ations , ĊĠĠĠĠĠĠĠ Ġerror Dis player Ġ= Ġerror Dis player , ĊĠĠĠĠĠĠĠ Ġst aking State Ġ= Ġst ash State , ĊĠĠĠĠĠĠĠ Ġcoroutine Scope Ġ= Ġcoroutine Scope ĊĠĠĠ Ġ) Ċ } Ċ Ċ private Ġclass ĠManage Stake Provider ( ĊĠĠĠ Ġprivate Ġval Ġvalidation Executor : ĠValidation Executor , ĊĠĠĠ Ġprivate Ġval Ġresource Manager : ĠResourceManager , ĊĠĠĠ Ġprivate Ġval Ġrouter : ĠSt aking Router , ĊĠĠĠ Ġprivate Ġval Ġstake Actions Valid ations : ĠMap < Manage Stake Action , ĠSt ake Actions Validation System >, ĊĠĠĠ Ġ// ĠFrom ĠParent ĠComponent ĊĠĠĠ Ġprivate Ġval Ġerror Dis player : Ġ( Throwable ) Ġ-> ĠUnit , ĊĠĠĠ Ġprivate Ġval Ġst aking State : ĠSt aking State . St ash , ĊĠĠĠ Ġcoroutine Scope : ĠCor outine Scope , Ċ ) Ġ: ĠManage Stake Mixin . Presentation , ĊĠĠĠ ĠCor outine Scope Ġby Ġcoroutine Scope , ĊĠĠĠ ĠWith Coroutine Scope Extensions Ġby ĠWith Coroutine Scope Extensions ( coroutine Scope ) Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġforbidden Stake Actions Ġ= Ġdetermine Forbidden Actions ( staking State ) ĊĊĠĠĠ Ġoverride Ġval Ġallowed Stake Actions Ġ= ĠManage Stake Action . values (). toSet () Ġ- Ġforbidden Stake Actions ĊĊĠĠĠ Ġoverride Ġfun Ġmanage Action Ch osen ( action : ĠManage Stake Action ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( action Ġin Ġforbidden Stake Actions ) Ġreturn ĊĊĠĠĠĠĠĠĠ Ġval Ġvalidation System Ġ= Ġstake Actions Valid ations [ action ] ĊĊĠĠĠĠĠĠĠ Ġif Ġ( validation System Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġpayload Ġ= ĠSt ake Actions Validation Payload ( staking State ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvalidation Executor . require Valid ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvalidation System Ġ= Ġvalidation System , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpayload Ġ= Ġpayload , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġerror Dis player Ġ= Ġerror Dis player , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvalidation Failure Transformer Default Ġ= Ġ{ Ġmain St aking Validation Failure ( it , Ġresource Manager ) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnavigate ToAction ( action ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnavigate ToAction ( action ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġnavigate ToAction ( action : ĠManage Stake Action ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( action ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠManage Stake Action . PAY OUT S Ġ-> Ġrouter . open Pay outs () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠManage Stake Action . B OND _ MORE Ġ-> Ġrouter . open Bond More () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠManage Stake Action . UN B OND Ġ-> Ġrouter . open Select Un bond () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠManage Stake Action . CONTROLLER Ġ-> Ġrouter . open Controller Account () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠManage Stake Action . VALID ATORS Ġ-> Ġrouter . open Current Validators () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠManage Stake Action . RE WARD _ DEST INATION Ġ-> Ġrouter . open Change Reward Destination () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġdetermine Forbidden Actions ( stash State : ĠSt aking State . St ash ): ĠSet < Manage Stake Action > Ġ= Ġwhen Ġ( stash State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠSt aking State . St ash . Nom inator Ġ-> Ġempty Set () ĊĠĠĠĠĠĠĠ Ġis ĠSt aking State . St ash . None Ġ-> Ġset Of ( Manage Stake Action . PAY OUT S ) ĊĠĠĠĠĠĠĠ Ġis ĠSt aking State . St ash . Validator Ġ-> Ġset Of ( Manage Stake Action . VALID ATORS ) ĊĠĠĠ Ġ} Ċ } Ċ