-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Light Client validator set hash calculation (#834)
* Remove unused file Signed-off-by: Thane Thomson <connect@thanethomson.com> * Refactor validators RPC endpoint interface This commit adds pagination to the `validators` method on the `Client` trait (BREAKING). Signed-off-by: Thane Thomson <connect@thanethomson.com> * Ensure "total" response field is a string Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add serializer for optional types that need to be converted to/from a string (like page numbers/per page counts) Signed-off-by: Thane Thomson <connect@thanethomson.com> * Refactor to ensure page numbers and per-page values are converted to/from strings first Signed-off-by: Thane Thomson <connect@thanethomson.com> * Convert tcp:// scheme to http:// for RPC addresses Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add Light Client support for RPC URLs instead of net::Address Signed-off-by: Thane Thomson <connect@thanethomson.com> * Revert 14ad69f for now Signed-off-by: Thane Thomson <connect@thanethomson.com> * Revert f0c26f7 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add CHANGELOG Signed-off-by: Thane Thomson <connect@thanethomson.com> * Convert infallible TryFroms to Froms Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove all non_exhaustive struct attributes Signed-off-by: Thane Thomson <connect@thanethomson.com> * Attempt to fix broken wasm_bindgen dependency Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fixate syn dependency for light-client-js Signed-off-by: Thane Thomson <connect@thanethomson.com>
- Loading branch information
1 parent
2221f4c
commit 5b0c9b5
Showing
13 changed files
with
272 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! De/serialize an optional type that must be converted from/to a string. | ||
|
||
use serde::de::Error; | ||
use serde::{Deserialize, Deserializer, Serializer}; | ||
use std::str::FromStr; | ||
|
||
pub fn serialize<S, T>(value: &Option<T>, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
T: ToString, | ||
{ | ||
match value { | ||
Some(t) => serializer.serialize_some(&t.to_string()), | ||
None => serializer.serialize_none(), | ||
} | ||
} | ||
|
||
pub fn deserialize<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
T: FromStr, | ||
T::Err: std::error::Error, | ||
{ | ||
let s = match Option::<String>::deserialize(deserializer)? { | ||
Some(s) => s, | ||
None => return Ok(None), | ||
}; | ||
Ok(Some(s.parse().map_err(|e: <T as FromStr>::Err| { | ||
D::Error::custom(e.to_string()) | ||
})?)) | ||
} |
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
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
Oops, something went wrong.