Repository: scs/substrate-api-client (language: rust)

Issue:
Deprecate websocket library
ws-rs has not been updated for years and is now breaking the build on `ubuntu-latest`. As we have sufficient other websocket libraries (tungstenite and jsonrpsee), I suggest to deprecated the ws part, remove it from CI and later on remove it from the code completely.


Failing build: https://github.com/scs/substrate-api-client/actions/runs/12919440595/job/36029972296
Successful build, after downgrading Ubuntu: https://github.com/scs/substrate-api-client/actions/runs/12924234972/job/36042899472?pr=813

To solve this issue:
- [ ] Mark Wsclient library as deprecated
- [ ] Remove ws client example



Discussion / hints:
Yes, this library has not been updated in a long time.... Given that using another client is easy I think we can deprecate it 👍 

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 25753e6f2..616711154 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -218,7 +218,6 @@ jobs:
           sudo,
           new_json_rpc_api_calls,
           transfer_with_tungstenite_client,
-          transfer_with_ws_client,
           author_tests,
           chain_tests,
           dispatch_errors_tests,
@@ -229,7 +228,6 @@ jobs:
           pallet_transaction_payment_tests,
           runtime_api_tests,
           tungstenite_client_test,
-          ws_client_test,
           state_tests,
           query_runtime_api,
           runtime_update_sync,
diff --git a/examples/sync/examples/transfer_with_ws_client.rs b/examples/sync/examples/transfer_with_ws_client.rs
deleted file mode 100755
index b52ccad6e..000000000
--- a/examples/sync/examples/transfer_with_ws_client.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-	Copyright 2019 Supercomputing Systems AG
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-
-		http://www.apache.org/licenses/LICENSE-2.0
-
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-//! Very simple example that shows how to use a predefined extrinsic from the extrinsic module.
-
-use sp_core::{
-	crypto::{Pair, Ss58Codec},
-	sr25519,
-};
-use sp_runtime::MultiAddress;
-use substrate_api_client::{
-	ac_primitives::RococoRuntimeConfig, extrinsic::BalancesExtrinsics, rpc::WsRpcClient, Api,
-	GetAccountInformation, SubmitAndWatch, XtStatus,
-};
-
-// To test this example with CI we run it against the Polkadot Rococo node. Remember to switch the Config to match your
-// own runtime if it uses different parameter configurations. Several pre-compiled runtimes are available in the ac-primitives crate.
-
-fn main() {
-	env_logger::init();
-
-	// Alice's seed: subkey inspect //Alice.
-	let alice: sr25519::Pair = Pair::from_string(
-		"0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a",
-		None,
-	)
-	.unwrap();
-	println!("signer account: {}", alice.public().to_ss58check());
-
-	// Initialize api and set the signer (sender) that is used to sign the extrinsics.
-	let client = WsRpcClient::with_default_url();
-	let mut api = Api::<RococoRuntimeConfig, _>::new(client).unwrap();
-	api.set_signer(alice.clone().into());
-
-	// Retrieve bobs current balance.
-	let bob = sr25519::Public::from_ss58check("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty")
-		.unwrap();
-	let bob_balance = api.get_account_data(&bob.into()).unwrap().unwrap_or_default().free;
-	println!("[+] Bob's Free Balance is {}\n", bob_balance);
-
-	// We first generate an extrinsic that will fail to be executed due to missing funds.
-	let xt = api
-		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1)
-		.unwrap();
-	println!(
-		"Sending an extrinsic from Alice (Key = {}),\n\nto Bob (Key = {})\n",
-		alice.public(),
-		bob
-	);
-	println!("[+] Composed extrinsic: {:?}\n", xt);
-
-	// Send and watch extrinsic until it fails onchain.
-	let result = api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock);
-	assert!(result.is_err());
-	println!("[+] Extrinsic did not get included due to: {:?}\n", result);
-
-	// This time, we generate an extrinsic that will succeed.
-	let xt = api
-		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2)
-		.unwrap();
-	println!(
-		"Sending an extrinsic from Alice (Key = {}),\n\nto Bob (Key = {})\n",
-		alice.public(),
-		bob
-	);
-	println!("[+] Composed extrinsic: {:?}\n", xt);
-
-	// Send and watch extrinsic until in block.
-	let block_hash = api
-		.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)
-		.unwrap()
-		.block_hash
-		.unwrap();
-	println!("[+] Extrinsic got included. Block Hash: {:?}\n", block_hash);
-
-	// Verify that Bob's free Balance increased.
-	let bob_new_balance = api.get_account_data(&bob.into()).unwrap().unwrap().free;
-	println!("[+] Bob's Free Balance is now {}\n", bob_new_balance);
-	assert!(bob_new_balance > bob_balance);
-}
diff --git a/src/rpc/ws_client/client.rs b/src/rpc/ws_client/client.rs
index fe218eae1..bb940ca67 100644
--- a/src/rpc/ws_client/client.rs
+++ b/src/rpc/ws_client/client.rs
@@ -31,6 +31,7 @@ use std::{
 use url::Url;
 use ws::{connect, Result as WsResult, Sender as WsSender};
 
+#[deprecated = "Use JsonrpseeClient or TungsteniteRpcClient instead."]
 #[derive(Debug, Clone)]
 pub struct WsRpcClient {
 	url: Url,


Test patch:
diff --git a/testing/sync/examples/ws_client_test.rs b/testing/sync/examples/ws_client_test.rs
deleted file mode 100755
index 13e4a7939..000000000
--- a/testing/sync/examples/ws_client_test.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-	Copyright 2019 Supercomputing Systems AG
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-
-		http://www.apache.org/licenses/LICENSE-2.0
-
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-use sp_core::{
-	crypto::{Pair, Ss58Codec},
-	sr25519,
-};
-use sp_runtime::MultiAddress;
-use substrate_api_client::{
-	ac_primitives::RococoRuntimeConfig, extrinsic::BalancesExtrinsics, rpc::WsRpcClient, Api,
-	GetAccountInformation, SubmitAndWatch, XtStatus,
-};
-
-fn main() {
-	// Setup
-	let alice: sr25519::Pair = Pair::from_string(
-		"0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a",
-		None,
-	)
-	.unwrap();
-	let client = WsRpcClient::with_default_url();
-	let mut api = Api::<RococoRuntimeConfig, _>::new(client).unwrap();
-	api.set_signer(alice.clone().into());
-
-	let bob = sr25519::Public::from_ss58check("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty")
-		.unwrap();
-	let bob_balance = api.get_account_data(&bob.into()).unwrap().unwrap_or_default().free;
-
-	// Check for failed extrinsic failed onchain
-	let xt = api
-		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1)
-		.unwrap();
-	let result = api.submit_and_watch_extrinsic_until(xt.clone(), XtStatus::InBlock);
-	assert!(format!("{:?}", result).contains("FundsUnavailable"));
-
-	// Check directly failed extrinsic (before actually submitted to a block)
-	let result = api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock);
-	assert!(result.is_err());
-	assert!(format!("{:?}", result).contains("ExtrinsicFailed"));
-
-	// Check for successful extrinisc
-	let xt = api
-		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2)
-		.unwrap();
-	let _block_hash = api
-		.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)
-		.unwrap()
-		.block_hash
-		.unwrap();
-	let bob_new_balance = api.get_account_data(&bob.into()).unwrap().unwrap().free;
-	assert!(bob_new_balance > bob_balance);
-}