Skip to content

Commit

Permalink
fix #101 wss://
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain Brenzikofer committed Oct 18, 2020
1 parent 62afbac commit 359e776
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 51 deletions.
45 changes: 19 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "substrate-api-client"
version = "0.4.9-sub2.0.0"
version = "0.4.10-sub2.0.0"
authors = ["Supercomputing Systems AG <[email protected]>"]
edition = "2018"

[dependencies]
env_logger = { version = "0.7", optional = true }
ws = { version = "0.7", optional = true, features = ["ssl"] }
ws = { version = "0.9.1", optional = true, features = ["ssl"] }
hex = { version = "0.4", default-features = false }
log = { version = "0.4", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
Expand Down
7 changes: 4 additions & 3 deletions src/examples/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ settings:

args:
- node-server:
long: ns
help: Set the node server IP address
short: u
long: url
help: Set the node server IP address including ws:// or wss:// prefix
takes_value: true
- node-port:
short: p
long: node-port
long: port
help: Set the websocket port to listen for substrate events
takes_value: true
4 changes: 2 additions & 2 deletions src/examples/example_benchmark_bulk_xt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {

// initialize api and set the signer (sender) that is used to sign the extrinsics
let from = AccountKeyring::Alice.pair();
let api = Api::new(format!("ws://{}", url)).set_signer(from);
let api = Api::new(url).set_signer(from);

println!(
"[+] Alice's Account Nonce is {}\n",
Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_compose_extrinsic_offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() {

// initialize api and set the signer (sender) that is used to sign the extrinsics
let from = AccountKeyring::Alice.pair();
let api = Api::new(format!("ws://{}", url)).set_signer(from);
let api = Api::new(url).set_signer(from);

// Information for Era for mortal transactions
let head = api.get_finalized_head().unwrap();
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_event_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() {
env_logger::init();
let url = get_node_url_from_cli();

let api = Api::<sr25519::Pair>::new(format!("ws://{}", url));
let api = Api::<sr25519::Pair>::new(url);

println!("Subscribe to events");
let (events_in, events_out) = channel();
Expand Down Expand Up @@ -78,7 +78,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_generic_event_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {
env_logger::init();
let url = get_node_url_from_cli();

let api = Api::<sr25519::Pair>::new(format!("ws://{}", url));
let api = Api::<sr25519::Pair>::new(url);

println!("Subscribe to events");
let (events_in, events_out) = channel();
Expand All @@ -55,7 +55,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_generic_extrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() {

// initialize api and set the signer (sender) that is used to sign the extrinsics
let from = AccountKeyring::Alice.pair();
let api = Api::new(format!("ws://{}", url)).set_signer(from);
let api = Api::new(url).set_signer(from);

// set the recipient
let to = AccountKeyring::Bob.to_account_id();
Expand All @@ -54,7 +54,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_get_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() {
env_logger::init();
let url = get_node_url_from_cli();

let api = Api::<sr25519::Pair>::new(format!("ws://{}", url));
let api = Api::<sr25519::Pair>::new(url);

let head = api.get_finalized_head().unwrap();

Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_get_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {
env_logger::init();
let url = get_node_url_from_cli();

let mut api = Api::new(format!("ws://{}", url));
let mut api = Api::new(url);

// get some plain storage value
let result: u128 = api
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_print_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() {
env_logger::init();
let url = get_node_url_from_cli();

let api = Api::<sr25519::Pair>::new(format!("ws://{}", url));
let api = Api::<sr25519::Pair>::new(url);

let meta = Metadata::try_from(api.get_metadata()).unwrap();

Expand All @@ -52,7 +52,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_sudo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() {

// initialize api and set the signer (sender) that is used to sign the extrinsics
let sudoer = AccountKeyring::Alice.pair();
let api = Api::new(format!("ws://{}", url)).set_signer(sudoer);
let api = Api::new(url).set_signer(sudoer);

// set the recipient of newly issued funds
let to = AccountKeyring::Bob.to_account_id();
Expand Down Expand Up @@ -59,7 +59,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down
4 changes: 2 additions & 2 deletions src/examples/example_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {

// initialize api and set the signer (sender) that is used to sign the extrinsics
let from = AccountKeyring::Alice.pair();
let api = Api::new(format!("ws://{}", url)).set_signer(from.clone());
let api = Api::new(url).set_signer(from.clone());

let to = AccountKeyring::Bob.to_account_id();

Expand Down Expand Up @@ -60,7 +60,7 @@ pub fn get_node_url_from_cli() -> String {
let yml = load_yaml!("../../src/examples/cli.yml");
let matches = App::from_yaml(yml).get_matches();

let node_ip = matches.value_of("node-server").unwrap_or("127.0.0.1");
let node_ip = matches.value_of("node-server").unwrap_or("ws://127.0.0.1");
let node_port = matches.value_of("node-port").unwrap_or("9944");
let url = format!("{}:{}", node_ip, node_port);
println!("Interacting with node on {}\n", url);
Expand Down

0 comments on commit 359e776

Please sign in to comment.