@@ -22,10 +22,10 @@ use parity_scale_codec::{Decode, Encode};
2222use send_wrapper:: SendWrapper ;
2323use truapi:: v01;
2424use truapi_platform:: {
25- AuthPresenter , AuthState , ChainProvider , CoreStorage , CoreStorageKey , Features ,
26- JsonRpcConnection , Navigation , Notifications , Permissions , PreimageHost , ProductStorage ,
27- RuntimeConfig , RuntimeConfigValidationError , SessionUiInfo , ThemeHost , UserConfirmation ,
28- UserConfirmationReview ,
25+ AuthPresenter , AuthState , ChainProvider , CoreStorage , CoreStorageKey , Features , HostInfo ,
26+ JsonRpcConnection , Navigation , Notifications , Permissions , PlatformInfo , PreimageHost ,
27+ ProductStorage , RuntimeConfig , RuntimeConfigValidationError , SessionUiInfo , ThemeHost ,
28+ UserConfirmation , UserConfirmationReview ,
2929} ;
3030use wasm_bindgen:: JsCast ;
3131use wasm_bindgen:: prelude:: * ;
@@ -780,35 +780,45 @@ fn runtime_config_from_js(value: &JsValue) -> Result<RuntimeConfig, JsValue> {
780780 let people = get_required_object ( value, "people" , "runtimeConfig.people" ) ?;
781781 let pairing = get_required_object ( value, "pairing" , "runtimeConfig.pairing" ) ?;
782782
783- RuntimeConfig :: new ( RuntimeConfig {
784- product_id : get_required_string_at ( value, "productId" , "runtimeConfig.productId" ) ?,
785- host_name : get_required_string_at ( & host , "name" , "runtimeConfig.host.name" ) ? ,
786- host_icon : get_optional_string_at ( & host, "icon " , "runtimeConfig.host.icon " ) ?,
787- host_version : get_optional_string_at ( & host, "version " , "runtimeConfig.host.version " ) ?,
788- platform_type : platform
789- . as_ref ( )
790- . map ( |p| get_optional_string_at ( p , "type" , "runtimeConfig.platform.type" ) )
791- . transpose ( ) ?
792- . flatten ( ) ,
793- platform_version : platform
794- . as_ref ( )
795- . map ( |p| get_optional_string_at ( p , "version" , "runtimeConfig.platform.version" ) )
796- . transpose ( ) ?
797- . flatten ( ) ,
798- people_chain_genesis_hash : get_required_bytes32_at (
799- & people ,
800- "genesisHash" ,
801- "runtimeConfig.people.genesisHash" ,
802- ) ?,
803- pairing_deeplink_scheme : get_required_string_at (
783+ RuntimeConfig :: new (
784+ get_required_string_at ( value, "productId" , "runtimeConfig.productId" ) ?,
785+ HostInfo {
786+ name : get_required_string_at ( & host, "name " , "runtimeConfig.host.name " ) ?,
787+ icon : get_optional_string_at ( & host, "icon " , "runtimeConfig.host.icon " ) ?,
788+ version : get_optional_string_at ( & host , "version" , "runtimeConfig.host.version" ) ? ,
789+ } ,
790+ PlatformInfo {
791+ kind : platform
792+ . as_ref ( )
793+ . map ( |p| get_optional_string_at ( p , "type" , "runtimeConfig. platform.type" ) )
794+ . transpose ( ) ?
795+ . flatten ( ) ,
796+ version : platform
797+ . as_ref ( )
798+ . map ( |p| get_optional_string_at ( p , "version" , "runtimeConfig.platform.version" ) )
799+ . transpose ( ) ?
800+ . flatten ( ) ,
801+ } ,
802+ get_required_bytes32_at ( & people , "genesisHash" , "runtimeConfig.people.genesisHash" ) ?,
803+ get_required_string_at (
804804 & pairing,
805805 "deeplinkScheme" ,
806806 "runtimeConfig.pairing.deeplinkScheme" ,
807807 ) ?,
808- } )
808+ )
809809 . map_err ( runtime_config_validation_to_js)
810810}
811811
812+ fn runtime_config_field_to_js ( field : & str ) -> & str {
813+ match field {
814+ "product_id" => "productId" ,
815+ "host_info.name" => "host.name" ,
816+ "pairing_deeplink_scheme" => "pairing.deeplinkScheme" ,
817+ "people_chain_genesis_hash" => "people.genesisHash" ,
818+ other => other,
819+ }
820+ }
821+
812822fn runtime_config_validation_to_js ( err : RuntimeConfigValidationError ) -> JsValue {
813823 match err {
814824 RuntimeConfigValidationError :: EmptyField { field } => JsValue :: from_str ( & format ! (
@@ -827,16 +837,6 @@ fn runtime_config_validation_to_js(err: RuntimeConfigValidationError) -> JsValue
827837 }
828838}
829839
830- fn runtime_config_field_to_js ( field : & str ) -> & str {
831- match field {
832- "product_id" => "productId" ,
833- "host_name" => "host.name" ,
834- "pairing_deeplink_scheme" => "pairing.deeplinkScheme" ,
835- "people_chain_genesis_hash" => "people.genesisHash" ,
836- other => other,
837- }
838- }
839-
840840fn get_required_object ( value : & JsValue , name : & str , path : & str ) -> Result < JsValue , JsValue > {
841841 let property = Reflect :: get ( value, & JsValue :: from_str ( name) ) ?;
842842 if property. is_null ( ) || property. is_undefined ( ) {
0 commit comments