package Ġjp . co . sor am its u . feature _ account _ impl . domain . account . details Ċ Ċ import Ġjp . co . sor am its u . common . data . secrets . v 2 . Meta Account Secrets Ċ import Ġjp . co . sor am its u . common . list . Group edList Ċ import Ġjp . co . sor am its u . fe ar less _ utils . scale . En codable Struct Ċ import Ġjp . co . sor am its u . feature _ account _ api . domain . interfaces . Account Repository Ċ import Ġjp . co . sor am its u . feature _ account _ api . domain . model . Meta Account Ċ import Ġjp . co . sor am its u . feature _ account _ api . domain . model . accountId Ċ import Ġjp . co . sor am its u . feature _ account _ api . domain . model . address Ċ import Ġjp . co . sor am its u . feature _ account _ api . domain . model . has Chain Account Ċ import Ġjp . co . sor am its u . feature _ account _ impl . domain . account . details . Account In Chain . From Ċ import Ġjp . co . sor am its u . runtime . multi Network . Chain Registry Ċ import Ġjp . co . sor am its u . runtime . multi Network . chain . model . Chain Ċ import Ġjp . co . sor am its u . runtime . multi Network . chain . model . is Pol kad ot Or K us ama Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . with Context Ċ Ċ class ĠAccount Details Interactor ( ĊĠĠĠ Ġprivate Ġval Ġaccount Repository : ĠAccount Repository , ĊĠĠĠ Ġprivate Ġval Ġchain Registry : ĠChain Registry Ċ ) Ġ{ ĊĊĠĠĠ Ġsuspend Ġfun Ġget Meta Account ( meta Id : ĠLong ): ĠMeta Account Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġaccount Repository . get Meta Account ( meta Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġupdate Name ( meta Id : ĠLong , ĠnewName : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġaccount Repository . update Meta AccountName ( meta Id , ĠnewName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġget Chain Projection s ( meta Account : ĠMeta Account ): ĠGroup edList < From , ĠAccount In Chain > Ġ= Ġwith Context ( Dispatch ers . Default ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchains Ġ= Ġchain Registry . current Ch ains . first (). sorted With ( chain Sort ()) ĊĊĠĠĠĠĠĠĠ Ġchains . map Ġ{ Ġchain Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġmeta Account . address ( chain ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġmeta Account . accountId ( chain ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġprojection Ġ= Ġif Ġ( address Ġ!= Ġnull Ġ&& ĠaccountId Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAccount In Chain . Projection ( address , ĠaccountId ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠAccount In Chain ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġchain Ġ= Ġchain , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprojection Ġ= Ġprojection , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfrom Ġ= Ġif Ġ( meta Account . has Chain Account ( chain . id )) ĠFrom . CHAIN _ ACCOUNT Ġelse ĠFrom . META _ ACCOUNT ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ}. groupBy ( Account In Chain :: from ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġget Meta Account Secrets ( meta Id : ĠLong ): ĠEn codable Struct < Meta Account Secrets >? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġaccount Repository . get Meta Account Secrets ( meta Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġchain Sort () Ġ= Ġcompare By Descending < Chain > Ġ{ Ġit . id . is Pol kad ot Or K us ama () Ġ} ĊĠĠĠĠĠĠĠ Ġ. then By Ġ{ Ġit . name Ġ} Ċ } Ċ