pub struct OnlineClient<T>where
T: Config,{ /* private fields */ }Expand description
A client that can be used to perform API calls (that is, either those
requiring an OfflineClientT or those requiring an OnlineClientT).
Implementations§
Source§impl<T> OnlineClient<T>where
T: Config,
impl<T> OnlineClient<T>where
T: Config,
Sourcepub async fn new() -> Result<OnlineClient<T>, Error>
pub async fn new() -> Result<OnlineClient<T>, Error>
Construct a new OnlineClient using default settings which
point to a locally running node on ws://127.0.0.1:9944.
Sourcepub async fn from_url(url: impl AsRef<str>) -> Result<OnlineClient<T>, Error>
pub async fn from_url(url: impl AsRef<str>) -> Result<OnlineClient<T>, Error>
Construct a new OnlineClient, providing a URL to connect to.
Sourcepub async fn from_insecure_url(
url: impl AsRef<str>,
) -> Result<OnlineClient<T>, Error>
pub async fn from_insecure_url( url: impl AsRef<str>, ) -> Result<OnlineClient<T>, Error>
Construct a new OnlineClient, providing a URL to connect to.
Allows insecure URLs without SSL encryption, e.g. (http:// and ws:// URLs).
Source§impl<T> OnlineClient<T>where
T: Config,
impl<T> OnlineClient<T>where
T: Config,
Sourcepub async fn from_rpc_client(
rpc_client: impl Into<RpcClient>,
) -> Result<OnlineClient<T>, Error>
pub async fn from_rpc_client( rpc_client: impl Into<RpcClient>, ) -> Result<OnlineClient<T>, Error>
Construct a new OnlineClient by providing an RpcClient to drive the connection.
This will use the current default Backend, which may change in future releases.
Sourcepub fn from_rpc_client_with(
genesis_hash: <<T as Config>::Hasher as Hasher>::Output,
runtime_version: RuntimeVersion,
metadata: impl Into<Metadata>,
rpc_client: impl Into<RpcClient>,
) -> Result<OnlineClient<T>, Error>
pub fn from_rpc_client_with( genesis_hash: <<T as Config>::Hasher as Hasher>::Output, runtime_version: RuntimeVersion, metadata: impl Into<Metadata>, rpc_client: impl Into<RpcClient>, ) -> Result<OnlineClient<T>, Error>
Construct a new OnlineClient by providing an RPC client along with the other
necessary details. This will use the current default Backend, which may change
in future releases.
§Warning
This is considered the most primitive and also error prone way to instantiate a client; the genesis hash, metadata and runtime version provided will entirely determine which node and blocks this client will be able to interact with, and whether it will be able to successfully do things like submit transactions.
If you’re unsure what you’re doing, prefer one of the alternate methods to instantiate a client.
Sourcepub async fn from_backend<B>(backend: Arc<B>) -> Result<OnlineClient<T>, Error>where
B: Backend<T>,
pub async fn from_backend<B>(backend: Arc<B>) -> Result<OnlineClient<T>, Error>where
B: Backend<T>,
Construct a new OnlineClient by providing an underlying Backend
implementation to power it. Other details will be obtained from the chain.
Sourcepub fn from_backend_with<B>(
genesis_hash: <<T as Config>::Hasher as Hasher>::Output,
runtime_version: RuntimeVersion,
metadata: impl Into<Metadata>,
backend: Arc<B>,
) -> Result<OnlineClient<T>, Error>where
B: Backend<T>,
pub fn from_backend_with<B>(
genesis_hash: <<T as Config>::Hasher as Hasher>::Output,
runtime_version: RuntimeVersion,
metadata: impl Into<Metadata>,
backend: Arc<B>,
) -> Result<OnlineClient<T>, Error>where
B: Backend<T>,
Construct a new OnlineClient by providing all of the underlying details needed
to make it work.
§Warning
This is considered the most primitive and also error prone way to instantiate a client; the genesis hash, metadata and runtime version provided will entirely determine which node and blocks this client will be able to interact with, and whether it will be able to successfully do things like submit transactions.
If you’re unsure what you’re doing, prefer one of the alternate methods to instantiate a client.
Sourcepub fn updater(&self) -> ClientRuntimeUpdater<T>
pub fn updater(&self) -> ClientRuntimeUpdater<T>
Create an object which can be used to keep the runtime up to date in a separate thread.
§Example
use subxt::{ OnlineClient, PolkadotConfig };
let client = OnlineClient::<PolkadotConfig>::new().await.unwrap();
// high level API.
let update_task = client.updater();
tokio::spawn(async move {
update_task.perform_runtime_updates().await;
});
// low level API.
let updater = client.updater();
tokio::spawn(async move {
let mut update_stream = updater.runtime_updates().await.unwrap();
while let Some(Ok(update)) = update_stream.next().await {
let version = update.runtime_version().spec_version;
match updater.apply_update(update) {
Ok(()) => {
println!("Upgrade to version: {} successful", version)
}
Err(e) => {
println!("Upgrade to version {} failed {:?}", version, e);
}
};
}
});Sourcepub fn hasher(&self) -> <T as Config>::Hasher
pub fn hasher(&self) -> <T as Config>::Hasher
Return the hasher configured for hashing blocks and extrinsics.
Sourcepub fn set_metadata(&self, metadata: impl Into<Metadata>)
pub fn set_metadata(&self, metadata: impl Into<Metadata>)
Sourcepub fn genesis_hash(&self) -> <<T as Config>::Hasher as Hasher>::Output
pub fn genesis_hash(&self) -> <<T as Config>::Hasher as Hasher>::Output
Return the genesis hash.
Sourcepub fn set_genesis_hash(
&self,
genesis_hash: <<T as Config>::Hasher as Hasher>::Output,
)
pub fn set_genesis_hash( &self, genesis_hash: <<T as Config>::Hasher as Hasher>::Output, )
Change the genesis hash used in this client.
§Warning
Setting a custom genesis hash may leave Subxt unable to submit valid transactions.
Sourcepub fn runtime_version(&self) -> RuntimeVersion
pub fn runtime_version(&self) -> RuntimeVersion
Return the runtime version.
Sourcepub fn set_runtime_version(&self, runtime_version: RuntimeVersion)
pub fn set_runtime_version(&self, runtime_version: RuntimeVersion)
Change the RuntimeVersion used in this client.
§Warning
Setting a custom runtime version may leave Subxt unable to submit valid transactions.
Sourcepub fn backend(&self) -> &(dyn Backend<T> + 'static)
pub fn backend(&self) -> &(dyn Backend<T> + 'static)
Return an RPC client to make raw requests with.
Sourcepub fn offline(&self) -> OfflineClient<T>
pub fn offline(&self) -> OfflineClient<T>
Return an offline client with the same configuration as this.
Sourcepub fn tx(&self) -> TxClient<T, OnlineClient<T>>
pub fn tx(&self) -> TxClient<T, OnlineClient<T>>
Work with transactions.
Sourcepub fn events(&self) -> EventsClient<T, OnlineClient<T>>
pub fn events(&self) -> EventsClient<T, OnlineClient<T>>
Work with events.
Sourcepub fn storage(&self) -> StorageClient<T, OnlineClient<T>>
pub fn storage(&self) -> StorageClient<T, OnlineClient<T>>
Work with storage.
Sourcepub fn constants(&self) -> ConstantsClient<T, OnlineClient<T>>
pub fn constants(&self) -> ConstantsClient<T, OnlineClient<T>>
Access constants.
Sourcepub fn blocks(&self) -> BlocksClient<T, OnlineClient<T>>
pub fn blocks(&self) -> BlocksClient<T, OnlineClient<T>>
Work with blocks.
Sourcepub fn runtime_api(&self) -> RuntimeApiClient<T, OnlineClient<T>>
pub fn runtime_api(&self) -> RuntimeApiClient<T, OnlineClient<T>>
Work with runtime API.
Sourcepub fn view_functions(&self) -> ViewFunctionsClient<T, OnlineClient<T>>
pub fn view_functions(&self) -> ViewFunctionsClient<T, OnlineClient<T>>
Work with View Functions.
Sourcepub fn custom_values(&self) -> CustomValuesClient<T, OnlineClient<T>>
pub fn custom_values(&self) -> CustomValuesClient<T, OnlineClient<T>>
Access custom types.
Trait Implementations§
Source§impl<Config> ClientFromUrl for OnlineClient<Config>
impl<Config> ClientFromUrl for OnlineClient<Config>
fn from_secure_url<'life0, 'async_trait>(
url: &'life0 str,
) -> Pin<Box<dyn Future<Output = Result<OnlineClient<Config>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OnlineClient<Config>: 'async_trait,
fn from_insecure_url<'life0, 'async_trait>(
url: &'life0 str,
) -> Pin<Box<dyn Future<Output = Result<OnlineClient<Config>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OnlineClient<Config>: 'async_trait,
Source§impl<T> Clone for OnlineClient<T>where
T: Config,
impl<T> Clone for OnlineClient<T>where
T: Config,
Source§fn clone(&self) -> OnlineClient<T>
fn clone(&self) -> OnlineClient<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for OnlineClient<T>where
T: Config,
impl<T> Debug for OnlineClient<T>where
T: Config,
Source§impl<T> OfflineClientT<T> for OnlineClient<T>where
T: Config,
impl<T> OfflineClientT<T> for OnlineClient<T>where
T: Config,
Source§fn genesis_hash(&self) -> <<T as Config>::Hasher as Hasher>::Output
fn genesis_hash(&self) -> <<T as Config>::Hasher as Hasher>::Output
Source§fn runtime_version(&self) -> RuntimeVersion
fn runtime_version(&self) -> RuntimeVersion
RuntimeVersion.Source§fn client_state(&self) -> ClientState<T>
fn client_state(&self) -> ClientState<T>
Source§fn events(&self) -> EventsClient<T, Self>
fn events(&self) -> EventsClient<T, Self>
Source§fn storage(&self) -> StorageClient<T, Self>
fn storage(&self) -> StorageClient<T, Self>
Source§fn constants(&self) -> ConstantsClient<T, Self>
fn constants(&self) -> ConstantsClient<T, Self>
Source§fn blocks(&self) -> BlocksClient<T, Self>
fn blocks(&self) -> BlocksClient<T, Self>
Source§fn runtime_api(&self) -> RuntimeApiClient<T, Self>
fn runtime_api(&self) -> RuntimeApiClient<T, Self>
Source§fn view_functions(&self) -> ViewFunctionsClient<T, Self>
fn view_functions(&self) -> ViewFunctionsClient<T, Self>
Source§fn custom_values(&self) -> CustomValuesClient<T, Self>
fn custom_values(&self) -> CustomValuesClient<T, Self>
Source§impl<T> OnlineClientT<T> for OnlineClient<T>where
T: Config,
impl<T> OnlineClientT<T> for OnlineClient<T>where
T: Config,
Auto Trait Implementations§
impl<T> Freeze for OnlineClient<T>
impl<T> !RefUnwindSafe for OnlineClient<T>
impl<T> Send for OnlineClient<T>
impl<T> Sync for OnlineClient<T>
impl<T> Unpin for OnlineClient<T>
impl<T> UnsafeUnpin for OnlineClient<T>
impl<T> !UnwindSafe for OnlineClient<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
Source§fn defensive_truncate_into(self) -> U
fn defensive_truncate_into(self) -> U
Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
Source§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.