mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
try-runtime - support all state versions (#12089)
* Add argument * Apply * More verbose parsing * fmt * fmt again * Invalid state version * reuse parsing * type mismatch
This commit is contained in:
committed by
GitHub
parent
75a76d967b
commit
9e5b211828
@@ -17,6 +17,8 @@
|
||||
|
||||
//! Utils for parsing user input
|
||||
|
||||
use sp_version::StateVersion;
|
||||
|
||||
pub(crate) fn hash(block_hash: &str) -> Result<String, String> {
|
||||
let (block_hash, offset) = if let Some(block_hash) = block_hash.strip_prefix("0x") {
|
||||
(block_hash, 2)
|
||||
@@ -42,3 +44,10 @@ pub(crate) fn url(s: &str) -> Result<String, &'static str> {
|
||||
Err("not a valid WS(S) url: must start with 'ws://' or 'wss://'")
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn state_version(s: &str) -> Result<StateVersion, &'static str> {
|
||||
s.parse::<u8>()
|
||||
.map_err(|_| ())
|
||||
.and_then(StateVersion::try_from)
|
||||
.map_err(|_| "Invalid state version.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user