-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-recv-packet-name
- Loading branch information
Showing
6 changed files
with
105 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ | |
)] | ||
#![forbid(unsafe_code)] | ||
|
||
extern crate alloc; | ||
|
||
pub mod api; | ||
pub mod context; | ||
pub mod handlers; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,3 @@ | ||
mod codec; | ||
|
||
pub use codec::*; | ||
use ibc_core::client::types::error::ClientError; | ||
use ibc_core::client::types::{Height, HeightError}; | ||
|
||
/// Decodes a `Height` from a UTF-8 encoded byte array. | ||
pub fn parse_height(encoded_height: Vec<u8>) -> Result<Option<Height>, ClientError> { | ||
let height_str = match alloc::str::from_utf8(encoded_height.as_slice()) { | ||
Ok(s) => s, | ||
// In cases where the height is unavailable, the encoded representation | ||
// might not be valid UTF-8, resulting in an invalid string. In such | ||
// instances, we return None. | ||
Err(_) => return Ok(None), | ||
}; | ||
match Height::try_from(height_str) { | ||
Ok(height) => Ok(Some(height)), | ||
// This is a valid case, as the key may contain other data. We just skip | ||
// it. | ||
Err(HeightError::InvalidFormat { .. }) => Ok(None), | ||
Err(e) => Err(ClientError::Other { | ||
description: e.to_string(), | ||
}), | ||
} | ||
} |