@@ -51,6 +51,7 @@ pub struct JsSubstrateConfig {
51
51
pub struct JsHyperbridgeConfig {
52
52
pub state_machine : String ,
53
53
pub rpc_url : String ,
54
+ pub consensus_state_id : String ,
54
55
}
55
56
56
57
#[ derive( Clone , Eq , PartialEq , Debug , Deserialize , Serialize ) ]
@@ -138,7 +139,14 @@ impl TryFrom<JsClientConfig> for ClientConfig {
138
139
let conf = SubstrateConfig {
139
140
rpc_url : val. rpc_url . clone ( ) ,
140
141
state_machine,
141
- consensus_state_id : [ 0u8 ; 4 ] ,
142
+ consensus_state_id : {
143
+ if val. consensus_state_id . len ( ) != 4 {
144
+ Err ( anyhow ! ( "Invalid consensus state id: {:?}" , val. consensus_state_id) ) ?
145
+ }
146
+ let mut dest = [ 0u8 ; 4 ] ;
147
+ dest. copy_from_slice ( & val. consensus_state_id . as_bytes ( ) ) ;
148
+ dest
149
+ } ,
142
150
hash_algo : HashAlgorithm :: Keccak ,
143
151
} ;
144
152
@@ -366,6 +374,7 @@ mod tests {
366
374
367
375
let js_hyperbridge = JsHyperbridgeConfig {
368
376
rpc_url : "ws://127.0.0.1:9990" . to_string ( ) ,
377
+ consensus_state_id : "PARA" . into ( ) ,
369
378
state_machine : "KUSAMA-4009" . into ( ) ,
370
379
} ;
371
380
0 commit comments