mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
Allow generalising over RPC implementation (#634)
* WIP generalising RPC client * WIP: non-object-safe RpcClientT.. aah generics everywhere * WIP object-safe RpcClientT trait and no more extra generics * Get core things compiling again with object-safe RpcClientT trait * Make jsonrpsee optional and get test-runtime working again * cargo fmt * add RpcParams object to enforce correct formatting of rps params * Wee tweaks * clippy fixes * cargo fmt * TWeak a few types * make sure we get jsonrpsee-types, too * Add examples for rpc_params/RpcParams * more doc tweaks * remove a now unneeded dev note * Option<Box<RawValue>> instead to avoid allocations in some cases * update docs * tweak RpcClientT trait docs * Tweak docs around RpcClient and RpcClientT. Don't expose RpcClientT directly * more doc tweaking about RpcParams and undo decision not to expose RpcParamsT * Doc tweak Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> * more doc tweaks * Fix doc thing * Add an example of injecting a custom RPC client * Fix a typo * Address clippy things in example * Fix a silly typo * another clippy fix * rpc_params to panic instead of returning a result, like serde_json::json, and deref on Rpc<T> * fix docs Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>
This commit is contained in:
+8
-3
@@ -15,7 +15,6 @@ pub use crate::metadata::{
|
||||
InvalidMetadataError,
|
||||
MetadataError,
|
||||
};
|
||||
pub use jsonrpsee::core::error::Error as RequestError;
|
||||
pub use scale_value::scale::{
|
||||
DecodeError,
|
||||
EncodeError,
|
||||
@@ -36,7 +35,7 @@ pub enum Error {
|
||||
Codec(#[from] codec::Error),
|
||||
/// Rpc error.
|
||||
#[error("Rpc error: {0}")]
|
||||
Rpc(#[from] RequestError),
|
||||
Rpc(#[from] RpcError),
|
||||
/// Serde serialization error
|
||||
#[error("Serde json error: {0}")]
|
||||
Serialization(#[from] serde_json::error::Error),
|
||||
@@ -102,6 +101,12 @@ impl From<DispatchError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
/// An RPC error. Since we are generic over the RPC client that is used,
|
||||
/// the error is any custom string.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("RPC error: {0}")]
|
||||
pub struct RpcError(pub String);
|
||||
|
||||
/// This is our attempt to decode a runtime DispatchError. We either
|
||||
/// successfully decode it into a [`ModuleError`], or we fail and keep
|
||||
/// hold of the bytes, which we can attempt to decode if we have an
|
||||
@@ -232,7 +237,7 @@ pub enum TransactionError {
|
||||
/// block hasn't yet been finalized).
|
||||
#[error("The finality subscription expired")]
|
||||
FinalitySubscriptionTimeout,
|
||||
/// The block hash that the tranaction was added to could not be found.
|
||||
/// The block hash that the transaction was added to could not be found.
|
||||
/// This is probably because the block was retracted before being finalized.
|
||||
#[error("The block containing the transaction can no longer be found (perhaps it was on a non-finalized fork?)")]
|
||||
BlockHashNotFound,
|
||||
|
||||
Reference in New Issue
Block a user