start fixing examples and cleaning up interface

This commit is contained in:
Tadeo hepperle
2024-02-02 16:50:41 +01:00
parent 4e2d3fd9cf
commit fce85c4af0
20 changed files with 48 additions and 95 deletions
+1 -6
View File
@@ -10,7 +10,7 @@ use codec::Decode;
use derivative::Derivative;
use primitive_types::U256;
use serde::{Deserialize, Serialize};
use subxt_core::metadata::Metadata;
use subxt_core::{metadata::Metadata, to_hex};
/// An interface to call the legacy RPC methods. This interface is instantiated with
/// some `T: Config` trait which determines some of the types that the RPC methods will
@@ -656,11 +656,6 @@ impl From<U256> for NumberOrHex {
}
}
/// A quick helper to encode some bytes to hex.
fn to_hex(bytes: impl AsRef<[u8]>) -> String {
format!("0x{}", hex::encode(bytes.as_ref()))
}
/// Hex-serialized shim for `Vec<u8>`.
#[derive(PartialEq, Eq, Clone, Serialize, Deserialize, Hash, PartialOrd, Ord, Debug)]
pub struct Bytes(#[serde(with = "impl_serde::serialize")] pub Vec<u8>);
+1 -4
View File
@@ -14,6 +14,7 @@ use futures::{Stream, StreamExt};
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, VecDeque};
use std::task::Poll;
use subxt_core::to_hex;
/// An interface to call the unstable RPC methods. This interface is instantiated with
/// some `T: Config` trait which determines some of the types that the RPC methods will
@@ -739,10 +740,6 @@ impl From<Vec<u8>> for Bytes {
}
}
fn to_hex(bytes: impl AsRef<[u8]>) -> String {
format!("0x{}", hex::encode(bytes.as_ref()))
}
/// Attempt to deserialize either a string or integer into an integer.
/// See <https://github.com/paritytech/json-rpc-interface-spec/issues/83>
pub(crate) mod unsigned_number_as_string {
+8 -4
View File
@@ -118,7 +118,7 @@ impl<T: Config> LightClient<T> {
// traits to use these things:
/// Return the [`subxt_core::metadata`] used in this client.
fn metadata(&self) -> subxt_core::metadata {
fn metadata(&self) -> subxt_core::Metadata {
self.client.metadata()
}
@@ -128,7 +128,7 @@ impl<T: Config> LightClient<T> {
}
/// Return the runtime version.
fn runtime_version(&self) -> crate::backend::RuntimeVersion {
fn runtime_version(&self) -> subxt_core::RuntimeVersion {
self.client.runtime_version()
}
@@ -180,7 +180,7 @@ impl<T: Config> OnlineClientT<T> for LightClient<T> {
}
impl<T: Config> OfflineClientT<T> for LightClient<T> {
fn metadata(&self) -> subxt_core::metadata {
fn metadata(&self) -> subxt_core::Metadata {
self.metadata()
}
@@ -188,7 +188,11 @@ impl<T: Config> OfflineClientT<T> for LightClient<T> {
self.genesis_hash()
}
fn runtime_version(&self) -> crate::backend::RuntimeVersion {
fn runtime_version(&self) -> subxt_core::RuntimeVersion {
self.runtime_version()
}
fn base(&self) -> subxt_core::ClientBase<T> {
self.client.base()
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ use crate::{
};
use derivative::Derivative;
use futures::future;
use std::borrow::Borrow;
use std::sync::{Arc, RwLock};
use subxt_core::{ClientBase, RuntimeVersion};
+1 -6
View File
@@ -3,14 +3,9 @@
// see LICENSE for license details.
use super::ConstantAddress;
use crate::{
client::OfflineClientT,
error::{Error, MetadataError},
Config,
};
use crate::{client::OfflineClientT, error::Error, Config};
use derivative::Derivative;
use subxt_core::metadata::DecodeWithMetadata;
/// A client for accessing constants.
#[derive(Derivative)]
-31
View File
@@ -1,31 +0,0 @@
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
//! This module provides the entry points to create dynamic
//! transactions, storage and constant lookups.
use crate::error::Error;
use scale_decode::DecodeAsType;
use subxt_core::metadata::{DecodeWithMetadata, Metadata};
pub use scale_value::{At, Value};
/// A [`scale_value::Value`] type endowed with contextual information
/// regarding what type was used to decode each part of it. This implements
/// [`subxt_core::metadata::DecodeWithMetadata`], and is used as a return type
/// for dynamic requests.
pub type DecodedValue = scale_value::Value<scale_value::scale::TypeId>;
// Submit dynamic transactions.
pub use crate::tx::dynamic as tx;
// Lookup constants dynamically.
pub use crate::constants::dynamic as constant;
// Lookup storage values dynamically.
pub use crate::storage::dynamic as storage;
// Execute runtime API function call dynamically.
pub use crate::runtime_api::dynamic as runtime_api_call;
+4 -5
View File
@@ -47,7 +47,6 @@ pub mod blocks;
pub mod client;
pub mod constants;
pub mod custom_values;
pub mod dynamic;
pub mod error;
pub mod events;
pub mod runtime_api;
@@ -66,10 +65,10 @@ pub use crate::{
error::Error,
};
pub use subxt_core::config;
pub use subxt_core::config::{Config, PolkadotConfig, SubstrateConfig};
use subxt_core::metadata::Metadata;
// pub use subxt_core::config;
// pub use subxt_core::config::{Config, PolkadotConfig, SubstrateConfig};
// pub use subxt_core::dynamic;
pub use subxt_core::*;
/// Re-export external crates that are made use of in the subxt API.
pub mod ext {
+1 -1
View File
@@ -52,7 +52,7 @@ macro_rules! cfg_jsonrpsee_web {
}
}
pub(crate) use {cfg_feature, cfg_jsonrpsee, cfg_substrate_compat, cfg_unstable_light_client};
pub(crate) use {cfg_feature, cfg_jsonrpsee, cfg_unstable_light_client};
// Only used by light-client.
#[allow(unused)]
-2
View File
@@ -9,8 +9,6 @@
//! additional and signed extra parameters are used when constructing an extrinsic, and is a part
//! of the chain configuration (see [`crate::config::Config`]).
use crate::macros::cfg_substrate_compat;
mod tx_client;
mod tx_progress;
+1 -1
View File
@@ -124,7 +124,7 @@ impl<T: Config, C: OfflineClientT<T>> TxClient<T, C> {
// 3. Construct our custom additional/extra params.
let additional_and_extra_params = <T::ExtrinsicParams as ExtrinsicParams<T>>::new(
account_nonce,
&self.client.base(),
self.client.base(),
other_params,
)?;