Merge branch 'tadeohepperle/subxt-metadata-no-std' into tadeohepperle/subxt-core-2

This commit is contained in:
Tadeo hepperle
2024-02-02 09:16:06 +01:00
35 changed files with 4017 additions and 1232 deletions
+4 -7
View File
@@ -6,11 +6,13 @@ use super::{rpc::LightClientRpc, LightClient, LightClientError};
use crate::backend::rpc::RpcClient;
use crate::client::RawLightClient;
use crate::macros::{cfg_jsonrpsee_native, cfg_jsonrpsee_web};
use crate::utils::validate_url_is_secure;
use crate::{config::Config, error::Error, OnlineClient};
use std::num::NonZeroU32;
use subxt_lightclient::{smoldot, AddedChain};
#[cfg(feature = "jsonrpsee")]
use crate::utils::validate_url_is_secure;
/// Builder for [`LightClient`].
#[derive(Clone, Debug)]
pub struct LightClientBuilder<T: Config> {
@@ -186,16 +188,11 @@ impl<T: Config> LightClientBuilder<T> {
}
/// Raw builder for [`RawLightClient`].
#[derive(Default)]
pub struct RawLightClientBuilder {
chains: Vec<AddedChain>,
}
impl Default for RawLightClientBuilder {
fn default() -> Self {
Self { chains: Vec::new() }
}
}
impl RawLightClientBuilder {
/// Create a new [`RawLightClientBuilder`].
pub fn new() -> RawLightClientBuilder {
+3 -4
View File
@@ -56,8 +56,7 @@ impl LightClientRpc {
pub fn new(
config: smoldot::AddChainConfig<'_, (), impl Iterator<Item = smoldot::ChainId>>,
) -> Result<LightClientRpc, Error> {
let rpc = subxt_lightclient::LightClientRpc::new(config)
.map_err(|err| LightClientError::Rpc(err))?;
let rpc = subxt_lightclient::LightClientRpc::new(config).map_err(LightClientError::Rpc)?;
Ok(LightClientRpc(rpc))
}
@@ -106,7 +105,7 @@ impl RpcClientT for LightClientRpc {
&'a self,
sub: &'a str,
params: Option<Box<RawValue>>,
_unsub: &'a str,
unsub: &'a str,
) -> RawRpcFuture<'a, RawRpcSubscription> {
let client = self.clone();
let chain_id = self.chain_id();
@@ -130,7 +129,7 @@ impl RpcClientT for LightClientRpc {
// Fails if the background is closed.
let (sub_id, notif) = client
.0
.subscription_request(sub.to_string(), params)
.subscription_request(sub.to_string(), params, unsub.to_string())
.map_err(|_| RpcError::ClientError(Box::new(LightClientError::BackgroundClosed)))?;
// Fails if the background is closed.