package Ġio . nova foundation . nova . feature _ account _ impl . data . map pers Ċ Ċ import Ġio . nova foundation . nova . common . resources . ResourceManager Ċ import Ġio . nova foundation . nova . common . utils . filter NotNull Ċ import Ġio . nova foundation . nova . core . model . Crypto Type Ċ import Ġio . nova foundation . nova . core . model . Node Ċ import Ġio . nova foundation . nova . core . model . Node . Network Type Ċ import Ġio . nova foundation . nova . core _ db . model . Node Local Ċ import Ġio . nova foundation . nova . core _ db . model . chain . Chain Account Local Ċ import Ġio . nova foundation . nova . core _ db . model . chain . Joined Meta Account Info Ċ import Ġio . nova foundation . nova . core _ db . model . chain . Meta Account Local Ċ import Ġio . nova foundation . nova . feature _ account _ api . data . map pers . stub Network Ċ import Ġio . nova foundation . nova . feature _ account _ api . domain . model . Account Ċ import Ġio . nova foundation . nova . feature _ account _ api . domain . model . Add Account Type Ċ import Ġio . nova foundation . nova . feature _ account _ api . domain . model . Light Meta Account Ċ import Ġio . nova foundation . nova . feature _ account _ api . domain . model . Meta Account Ċ import Ġio . nova foundation . nova . feature _ account _ api . domain . model . address In Ċ import Ġio . nova foundation . nova . feature _ account _ api . pres en at ation . account . add . Add Account Payload Ċ import Ġio . nova foundation . nova . feature _ account _ impl . R Ċ import Ġio . nova foundation . nova . feature _ account _ impl . presentation . common . mixin . api . AccountName Chooser Mixin Ċ import Ġio . nova foundation . nova . feature _ account _ impl . presentation . node . model . Node Model Ċ import Ġio . nova foundation . nova . feature _ account _ impl . presentation . view . advanced . encryption . model . Crypto Type Model Ċ import Ġio . nova foundation . nova . feature _ account _ impl . presentation . view . advanced . network . model . Network Model Ċ import Ġio . nova foundation . nova . runtime . ext . address Of Ċ import Ġio . nova foundation . nova . runtime . ext . hex AccountId Of Ċ import Ġio . nova foundation . nova . runtime . multi Network . chain . model . Chain Ċ import Ġio . nova foundation . nova . runtime . multi Network . chain . model . Chain Id Ċ import Ġjp . co . sor am its u . fe ar less _ utils . extensions . to HexString Ċ Ċ fun Ġmap Network Type To Network Model ( network Type : ĠNetwork Type ): ĠNetwork Model Ġ{ ĊĠĠĠ Ġval Ġtype Ġ= Ġwhen Ġ( network Type ) Ġ{ ĊĠĠĠĠĠĠĠ ĠNetwork Type . K USA MA Ġ-> ĠNetwork Model . Network Type UI . K us ama ĊĠĠĠĠĠĠĠ ĠNetwork Type . POL K AD OT Ġ-> ĠNetwork Model . Network Type UI . Pol kad ot ĊĠĠĠĠĠĠĠ ĠNetwork Type . WEST END Ġ-> ĠNetwork Model . Network Type UI . West end ĊĠĠĠĠĠĠĠ ĠNetwork Type . RO CO CO Ġ-> ĠNetwork Model . Network Type UI . Ro coco ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn ĠNetwork Model ( network Type . readable Name , Ġtype ) Ċ } Ċ Ċ fun Ġmap Crypto Type To Crypto Type Model ( ĊĠĠĠ Ġresource Manager : ĠResourceManager , ĊĠĠĠ Ġencryption Type : ĠCrypto Type Ċ ): ĠCrypto Type Model Ġ{ ĊĊĠĠĠ Ġval Ġname Ġ= Ġwhen Ġ( encryption Type ) Ġ{ ĊĠĠĠĠĠĠĠ ĠCrypto Type . SR 2 5 5 1 9 Ġ-> Ġ"${ resource Manager . getString ( R . string . sr 2 5 5 1 9 _ selection _ title )} Ġ${ resource Manager . getString ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . string . sr 2 5 5 1 9 _ selection _ subtitle ĊĠĠĠĠĠĠĠ Ġ) }" ĊĠĠĠĠĠĠĠ ĠCrypto Type . ED 2 5 5 1 9 Ġ-> Ġ"${ resource Manager . getString ( R . string . ed 2 5 5 1 9 _ selection _ title )} Ġ${ resource Manager . getString ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . string . ed 2 5 5 1 9 _ selection _ subtitle ĊĠĠĠĠĠĠĠ Ġ) }" ĊĠĠĠĠĠĠĠ ĠCrypto Type . ECD SA Ġ-> Ġ"${ resource Manager . getString ( R . string . ecd sa _ selection _ title )} Ġ${ resource Manager . getString ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . string . ecd sa _ selection _ subtitle ĊĠĠĠĠĠĠĠ Ġ) }" ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn ĠCrypto Type Model ( name , Ġencryption Type ) Ċ } Ċ Ċ fun Ġmap Node To Node Model ( node : ĠNode ): ĠNode Model Ġ{ ĊĠĠĠ Ġval Ġnetwork Model Type Ġ= Ġmap Network Type To Network Model ( node . network Type ) ĊĊĠĠĠ Ġreturn Ġwith ( node ) Ġ{ ĊĠĠĠĠĠĠĠ ĠNode Model ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġid , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġname , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlink Ġ= Ġlink , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnetwork Model Type Ġ= Ġnetwork Model Type . network Type UI , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Default Ġ= Ġis Default , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠisActive Ġ= ĠisActive ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġmap Node Local To Node ( node Local : ĠNode Local ): ĠNode Ġ{ ĊĠĠĠ Ġreturn Ġwith ( node Local ) Ġ{ ĊĠĠĠĠĠĠĠ ĠNode ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġid , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġname , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnetwork Type Ġ= ĠNetwork Type . values ()[ node Local . network Type ], ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlink Ġ= Ġlink , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠisActive Ġ= ĠisActive , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Default Ġ= Ġis Default ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġmap Meta Account Local To Light Meta Account ( ĊĠĠĠ Ġmeta Account Local : ĠMeta Account Local Ċ ): ĠLight Meta Account Ġ= Ġwith ( meta Account Local ) Ġ{ ĊĠĠĠ ĠLight Meta Account ( ĊĠĠĠĠĠĠĠ Ġid Ġ= Ġid , ĊĠĠĠĠĠĠĠ Ġsubstr ate PublicKey Ġ= Ġsubstr ate PublicKey , ĊĠĠĠĠĠĠĠ Ġsubstr ate Crypto Type Ġ= Ġsubstr ate Crypto Type , ĊĠĠĠĠĠĠĠ Ġsubstr ate AccountId Ġ= Ġsubstr ate AccountId , ĊĠĠĠĠĠĠĠ Ġe thereum Address Ġ= Ġe thereum Address , ĊĠĠĠĠĠĠĠ Ġe thereum PublicKey Ġ= Ġe thereum PublicKey , ĊĠĠĠĠĠĠĠ Ġis Selected Ġ= Ġis Selected , ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġname ĊĠĠĠ Ġ) Ċ } Ċ Ċ fun Ġmap Meta Account Local To Meta Account ( ĊĠĠĠ Ġchains ById : ĠMap < Chain Id , ĠChain >, ĊĠĠĠ Ġjoined Meta Account Info : ĠJo ined Meta Account Info Ċ ): ĠMeta Account Ġ{ ĊĠĠĠ Ġval Ġchain Accounts Ġ= Ġjoined Meta Account Info . chain Accounts . associate By ( ĊĠĠĠĠĠĠĠ Ġkey Selector Ġ= ĠChain Account Local :: chain Id , ĊĠĠĠĠĠĠĠ Ġvalue Transform Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġignore Ġchain Accounts Ġwith Ġunknown Ġchain Id ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġchain Ġ= Ġchains ById [ it . chain Id ] Ġ?: Ġreturn @ associate By Ġnull ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠMeta Account . Chain Account ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeta Id Ġ= Ġjoined Meta Account Info . meta Account . id , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġchain Ġ= Ġchain , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠpublicKey Ġ= Ġit . publicKey , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠaccountId Ġ= Ġit . accountId , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcrypto Type Ġ= Ġit . crypto Type ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ). filter NotNull () ĊĊĠĠĠ Ġreturn Ġwith ( joined Meta Account Info . meta Account ) Ġ{ ĊĠĠĠĠĠĠĠ ĠMeta Account ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġid , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchain Accounts Ġ= Ġchain Accounts , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubstr ate PublicKey Ġ= Ġsubstr ate PublicKey , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubstr ate Crypto Type Ġ= Ġsubstr ate Crypto Type , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubstr ate AccountId Ġ= Ġsubstr ate AccountId , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġe thereum Address Ġ= Ġe thereum Address , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġe thereum PublicKey Ġ= Ġe thereum PublicKey , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Selected Ġ= Ġis Selected , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġname ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġmap Meta Account To Account ( chain : ĠChain , Ġmeta Account : ĠMeta Account ): ĠAccount ? Ġ{ ĊĠĠĠ Ġreturn Ġmeta Account . address In ( chain )?. let Ġ{ Ġaddress Ġ-> ĊĊĠĠĠĠĠĠĠ Ġval ĠaccountId Ġ= Ġchain . hex AccountId Of ( address ) ĊĊĠĠĠĠĠĠĠ ĠAccount ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress Ġ= Ġaddress , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġmeta Account . name , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠaccountId Hex Ġ= ĠaccountId , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcrypto Type Ġ= Ġmeta Account . substr ate Crypto Type , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġposition Ġ= Ġ 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnetwork Ġ= Ġstub Network ( chain . id ), ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġmap Chain Account To Account ( ĊĠĠĠ Ġparent : ĠMeta Account , ĊĠĠĠ Ġchain Account : ĠMeta Account . Chain Account , Ċ ): ĠAccount Ġ{ ĊĠĠĠ Ġval Ġchain Ġ= Ġchain Account . chain ĊĊĠĠĠ Ġreturn ĠAccount ( ĊĠĠĠĠĠĠĠ Ġaddress Ġ= Ġchain . address Of ( chain Account . accountId ), ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġparent . name , ĊĠĠĠĠĠĠĠ ĠaccountId Hex Ġ= Ġchain Account . accountId . to HexString (), ĊĠĠĠĠĠĠĠ Ġcrypto Type Ġ= Ġchain Account . crypto Type , ĊĠĠĠĠĠĠĠ Ġposition Ġ= Ġ 0 , ĊĠĠĠĠĠĠĠ Ġnetwork Ġ= Ġstub Network ( chain . id ), ĊĠĠĠ Ġ) Ċ } Ċ Ċ fun Ġmap Add Account Payload ToAdd Account Type ( ĊĠĠĠ Ġpayload : ĠAdd Account Payload , ĊĠĠĠ Ġaccount Name State : ĠAccount Name Chooser Mixin . State , Ċ ): ĠAdd Account Type Ġ{ ĊĠĠĠ Ġreturn Ġwhen Ġ( payload ) Ġ{ ĊĠĠĠĠĠĠĠ ĠAdd Account Payload . Meta Account Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrequire ( account Name State Ġis ĠAccount Name Chooser Mixin . State . Input ) Ġ{ Ġ" Name Ġinput Ġshould Ġbe Ġpresent Ġfor Ġmeta Ġaccount " Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠAdd Account Type . Meta Account ( account Name State . value ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġis ĠAdd Account Payload . Chain Account Ġ-> ĠAdd Account Type . Chain Account ( payload . chain Id , Ġpayload . meta Id ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġmap Name Chooser State To Optional Name ( state : ĠAccount Name Chooser Mixin . State ) Ġ= Ġ( state Ġas ? ĠAccount Name Chooser Mixin . State . Input )?. value Ċ Ċ fun Ġmap Optional Name To Name Chooser State ( name : ĠString ?) Ġ= Ġwhen Ġ( name ) Ġ{ ĊĠĠĠ Ġnull Ġ-> ĠAccount Name Chooser Mixin . State . No Input ĊĠĠĠ Ġelse Ġ-> ĠAccount Name Chooser Mixin . State . Input ( name ) Ċ } Ċ