Skip to content

Commit

Permalink
fix hyperclient
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Feb 18, 2025
1 parent 057cd8d commit a4ec6d0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ install-updater = false
inherits = "release"
lto = "thin"

[profile.release]
strip = true

[workspace.dependencies]
polkadot-sdk = { version = "0.9.0", default-features = false }

Expand Down
2 changes: 2 additions & 0 deletions modules/hyperclient/hyperclient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export interface IHyperbridgeConfig {
rpc_url: string;
// state machine identifier as a string
state_machine: string;
// consensus state identifier of hyperbridge on the destination chain
consensus_state_id: string;
}

export interface IPostRequest {
Expand Down
2 changes: 1 addition & 1 deletion modules/hyperclient/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@polytope-labs/hyperclient",
"description": "The hyperclient is a library for managing (in-flight) ISMP requests",
"version": "1.1.0",
"version": "1.2.0",
"author": "Polytope Labs ([email protected])",
"license": "Apache-2.0",
"bugs": {
Expand Down
11 changes: 10 additions & 1 deletion modules/hyperclient/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct JsSubstrateConfig {
pub struct JsHyperbridgeConfig {
pub state_machine: String,
pub rpc_url: String,
pub consensus_state_id: String,
}

#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -138,7 +139,14 @@ impl TryFrom<JsClientConfig> for ClientConfig {
let conf = SubstrateConfig {
rpc_url: val.rpc_url.clone(),
state_machine,
consensus_state_id: [0u8; 4],
consensus_state_id: {
if val.consensus_state_id.len() != 4 {
Err(anyhow!("Invalid consensus state id: {:?}", val.consensus_state_id))?
}
let mut dest = [0u8; 4];
dest.copy_from_slice(&val.consensus_state_id.as_bytes());
dest
},
hash_algo: HashAlgorithm::Keccak,
};

Expand Down Expand Up @@ -366,6 +374,7 @@ mod tests {

let js_hyperbridge = JsHyperbridgeConfig {
rpc_url: "ws://127.0.0.1:9990".to_string(),
consensus_state_id: "PARA".into(),
state_machine: "KUSAMA-4009".into(),
};

Expand Down
2 changes: 1 addition & 1 deletion modules/hyperclient/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl HyperClient {
let _ = tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.with_writer(
// To avoide trace events in the browser from showing their
// To avoid trace events in the browser from showing their
// JS backtrace, which is very annoying, in my opinion
MakeConsoleWriter::default().map_trace_level_to(tracing::Level::INFO),
)
Expand Down

0 comments on commit a4ec6d0

Please sign in to comment.