mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
make remote-ext work with ws and safe RPCs (#8889)
* make remote-ext work with ws and safe RPCs * Update docs. * Update utils/frame/remote-externalities/Cargo.toml Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Fix test * Update lock file * Update utils/frame/remote-externalities/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix build again. * revert lifetime stuff Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -86,7 +86,7 @@ pub enum State {
|
||||
modules: Option<Vec<String>>,
|
||||
|
||||
/// The url to connect to.
|
||||
#[structopt(default_value = "http://localhost:9933", parse(try_from_str = parse_url))]
|
||||
#[structopt(default_value = "ws://localhost:9944", parse(try_from_str = parse_url))]
|
||||
url: String,
|
||||
},
|
||||
}
|
||||
@@ -109,11 +109,11 @@ fn parse_hash(block_number: &str) -> Result<String, String> {
|
||||
}
|
||||
|
||||
fn parse_url(s: &str) -> Result<String, &'static str> {
|
||||
if s.starts_with("http://") {
|
||||
if s.starts_with("ws://") || s.starts_with("wss://") {
|
||||
// could use Url crate as well, but lets keep it simple for now.
|
||||
Ok(s.to_string())
|
||||
} else {
|
||||
Err("not a valid HTTP url: must start with 'http://'")
|
||||
Err("not a valid WS(S) url: must start with 'ws://' or 'wss://'")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ impl TryRuntimeCmd {
|
||||
block_at,
|
||||
modules
|
||||
} => Builder::<B>::new().mode(Mode::Online(OnlineConfig {
|
||||
uri: url.into(),
|
||||
transport: url.to_owned().into(),
|
||||
state_snapshot: snapshot_path.as_ref().map(SnapshotConfig::new),
|
||||
modules: modules.clone().unwrap_or_default(),
|
||||
modules: modules.to_owned().unwrap_or_default(),
|
||||
at: block_at.as_ref()
|
||||
.map(|b| b.parse().map_err(|e| format!("Could not parse hash: {:?}", e))).transpose()?,
|
||||
..Default::default()
|
||||
|
||||
Reference in New Issue
Block a user