Skip to content

Commit

Permalink
Bump jsonrpsee from de7cbf2 to a0bea41 (paritytech#28)
Browse files Browse the repository at this point in the history
* Bump jsonrpsee from `de7cbf2` to `a0bea41`

Bumps [jsonrpsee](https://github.com/paritytech/jsonrpsee) from `de7cbf2` to `a0bea41`.
- [Release notes](https://github.com/paritytech/jsonrpsee/releases)
- [Commits](paritytech/jsonrpsee@de7cbf2...a0bea41)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* Fix imports.

* Update client code.

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Tomasz Drwięga <[email protected]>
  • Loading branch information
2 people authored and serban300 committed Apr 9, 2024
1 parent 2a00dbe commit f840e48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
20 changes: 12 additions & 8 deletions bridges/relays/substrate/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ use crate::params::{RPCUrlParam, Params};

use futures::{prelude::*, channel::{mpsc, oneshot}, future, select};
use jsonrpsee::{
core::client::{RawClientError, RawClientEvent, RawClientRequestId, RawClientSubscription},
ws::{WsRawClient, WsConnecError, ws_raw_client},
raw::client::{RawClient, RawClientError, RawClientEvent, RawClientRequestId, RawClientSubscription},
transport::{
TransportClient,
ws::{WsTransportClient, WsConnecError},
},
};
use node_primitives::{Hash, Header};
use std::cell::RefCell;
Expand All @@ -47,7 +50,7 @@ enum Event {

struct Chain {
url: String,
client: WsRawClient,
client: RawClient<WsTransportClient>,
sender: mpsc::Sender<Event>,
receiver: mpsc::Receiver<Event>,
genesis_hash: Hash,
Expand All @@ -60,10 +63,11 @@ async fn init_rpc_connection(url: &RPCUrlParam) -> Result<Chain, Error> {

// Skip the leading "ws://" and trailing "/".
let url_without_scheme = &url_str[5..(url_str.len() - 1)];
let mut client = ws_raw_client(url_without_scheme)
let transport = WsTransportClient::new(url_without_scheme)
.await
.map_err(|err| Error::WsConnectionError(err.to_string()))?;

let mut client = RawClient::new(transport);
let genesis_hash = rpc::genesis_block_hash(&mut client)
.await
.map_err(|e| Error::RPCError(e.to_string()))?
Expand Down Expand Up @@ -252,15 +256,15 @@ async fn setup_subscriptions(chain: &mut Chain)
let new_heads_subscription_id = chain.client
.start_subscription(
"chain_subscribeNewHeads",
jsonrpsee::core::common::Params::None,
jsonrpsee::common::Params::None,
)
.await
.map_err(RawClientError::Inner)?;

let finalized_heads_subscription_id = chain.client
.start_subscription(
"chain_subscribeFinalizedHeads",
jsonrpsee::core::common::Params::None,
jsonrpsee::common::Params::None,
)
.await
.map_err(RawClientError::Inner)?;
Expand Down Expand Up @@ -350,9 +354,9 @@ async fn handle_rpc_event(
}

// Let's say this never sends over a channel (ie. cannot block on another task).
async fn handle_bridge_event(
async fn handle_bridge_event<R: TransportClient>(
chain_id: ChainId,
rpc_client: &mut WsRawClient,
rpc_client: &mut RawClient<R>,
event: Event,
) -> Result<(), Error>
{
Expand Down
5 changes: 4 additions & 1 deletion bridges/relays/substrate/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

use jsonrpsee::core::client::{RawClient, RawClientError, TransportClient};
use jsonrpsee::{
raw::client::{RawClient, RawClientError},
transport::TransportClient,
};
use node_primitives::{BlockNumber, Hash, Header};
use sp_core::Bytes;
use sp_rpc::number::NumberOrHex;
Expand Down

0 comments on commit f840e48

Please sign in to comment.