mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Merge remote-tracking branch 'origin/master' into lexnv/metadata_v15
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
+10
-10
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "subxt"
|
||||
version = "0.27.1"
|
||||
version = "0.28.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
@@ -53,21 +53,21 @@ frame-metadata = { version = "15.1.0", features = ["v14", "v15-unstable", "std"]
|
||||
derivative = "2.2.0"
|
||||
either = "1.8.1"
|
||||
|
||||
subxt-macro = { version = "0.27.1", path = "../macro" }
|
||||
subxt-metadata = { version = "0.27.1", path = "../metadata" }
|
||||
subxt-macro = { version = "0.28.0", path = "../macro" }
|
||||
subxt-metadata = { version = "0.28.0", path = "../metadata" }
|
||||
|
||||
# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
|
||||
impl-serde = { version = "0.4.0" }
|
||||
primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "scale-info", "serde"] }
|
||||
sp-core-hashing = "7.0.0"
|
||||
sp-core-hashing = "8.0.0"
|
||||
|
||||
# For ss58 encoding AccountId32 to serialize them properly:
|
||||
base58 = { version = "0.2.0" }
|
||||
blake2 = { version = "0.10.4", default-features = false }
|
||||
|
||||
# These are only included is "substrate-compat" is enabled.
|
||||
sp-core = { version = "18.0.0", default-features = false, optional = true }
|
||||
sp-runtime = { version = "20.0.0", optional = true }
|
||||
sp-core = { version = "20.0.0", default-features = false, optional = true }
|
||||
sp-runtime = { version = "23.0.0", optional = true }
|
||||
|
||||
[target.wasm32-unknown-unknown.dependencies]
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
@@ -77,7 +77,7 @@ bitvec = "1"
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] }
|
||||
scale-info = { version = "2.5.0", features = ["bit-vec"] }
|
||||
tokio = { version = "1.27", features = ["macros", "time", "rt-multi-thread"] }
|
||||
sp-core = { version = "18.0.0", default-features = false }
|
||||
sp-runtime = "20.0.0"
|
||||
sp-keyring = "20.0.0"
|
||||
sp-version = "18.0.0"
|
||||
sp-core = { version = "20.0.0", default-features = false }
|
||||
sp-runtime = "23.0.0"
|
||||
sp-keyring = "23.0.0"
|
||||
sp-version = "21.0.0"
|
||||
|
||||
@@ -287,7 +287,7 @@ where
|
||||
Some(events) => events.clone(),
|
||||
None => {
|
||||
events::EventsClient::new(client.clone())
|
||||
.at(Some(block_hash))
|
||||
.at(block_hash)
|
||||
.await?
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,8 +39,7 @@ where
|
||||
T: Config,
|
||||
Client: OnlineClientT<T>,
|
||||
{
|
||||
/// Obtain block details given the provided block hash, or the latest block if `None` is
|
||||
/// provided.
|
||||
/// Obtain block details given the provided block hash.
|
||||
///
|
||||
/// # Warning
|
||||
///
|
||||
@@ -48,6 +47,22 @@ where
|
||||
/// runtime upgrade. You can attempt to retrieve older blocks,
|
||||
/// but may run into errors attempting to work with them.
|
||||
pub fn at(
|
||||
&self,
|
||||
block_hash: T::Hash,
|
||||
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static {
|
||||
self.at_or_latest(Some(block_hash))
|
||||
}
|
||||
|
||||
/// Obtain block details of the latest block hash.
|
||||
pub fn at_latest(
|
||||
&self,
|
||||
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static {
|
||||
self.at_or_latest(None)
|
||||
}
|
||||
|
||||
/// Obtain block details given the provided block hash, or the latest block if `None` is
|
||||
/// provided.
|
||||
fn at_or_latest(
|
||||
&self,
|
||||
block_hash: Option<T::Hash>,
|
||||
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static {
|
||||
|
||||
@@ -37,6 +37,19 @@ where
|
||||
/// runtime upgrade. You can attempt to retrieve events from older blocks,
|
||||
/// but may run into errors attempting to work with them.
|
||||
pub fn at(
|
||||
&self,
|
||||
block_hash: T::Hash,
|
||||
) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static {
|
||||
self.at_or_latest(Some(block_hash))
|
||||
}
|
||||
|
||||
/// Obtain events at the latest block hash.
|
||||
pub fn at_latest(&self) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static {
|
||||
self.at_or_latest(None)
|
||||
}
|
||||
|
||||
/// Obtain events at some block hash.
|
||||
fn at_or_latest(
|
||||
&self,
|
||||
block_hash: Option<T::Hash>,
|
||||
) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static {
|
||||
|
||||
@@ -31,23 +31,25 @@ where
|
||||
T: Config,
|
||||
Client: OnlineClientT<T>,
|
||||
{
|
||||
/// Obtain a runtime API at some block hash.
|
||||
pub fn at(
|
||||
/// Obtain a runtime API interface at some block hash.
|
||||
pub fn at(&self, block_hash: T::Hash) -> RuntimeApi<T, Client> {
|
||||
RuntimeApi::new(self.client.clone(), block_hash)
|
||||
}
|
||||
|
||||
/// Obtain a runtime API interface at the latest block hash.
|
||||
pub fn at_latest(
|
||||
&self,
|
||||
block_hash: Option<T::Hash>,
|
||||
) -> impl Future<Output = Result<RuntimeApi<T, Client>, Error>> + Send + 'static {
|
||||
// Clone and pass the client in like this so that we can explicitly
|
||||
// return a Future that's Send + 'static, rather than tied to &self.
|
||||
let client = self.client.clone();
|
||||
async move {
|
||||
// If block hash is not provided, get the hash
|
||||
// for the latest block and use that.
|
||||
let block_hash = match block_hash {
|
||||
Some(hash) => hash,
|
||||
None => client.rpc().block_hash(None).await?.expect(
|
||||
"substrate RPC returns the best block when no block number is provided; qed",
|
||||
),
|
||||
};
|
||||
// get the hash for the latest block and use that.
|
||||
let block_hash = client
|
||||
.rpc()
|
||||
.block_hash(None)
|
||||
.await?
|
||||
.expect("didn't pass a block number; qed");
|
||||
|
||||
Ok(RuntimeApi::new(client, block_hash))
|
||||
}
|
||||
|
||||
@@ -71,24 +71,24 @@ where
|
||||
Client: OnlineClientT<T>,
|
||||
{
|
||||
/// Obtain storage at some block hash.
|
||||
pub fn at(
|
||||
pub fn at(&self, block_hash: T::Hash) -> Storage<T, Client> {
|
||||
Storage::new(self.client.clone(), block_hash)
|
||||
}
|
||||
|
||||
/// Obtain storage at the latest block hash.
|
||||
pub fn at_latest(
|
||||
&self,
|
||||
block_hash: Option<T::Hash>,
|
||||
) -> impl Future<Output = Result<Storage<T, Client>, Error>> + Send + 'static {
|
||||
// Clone and pass the client in like this so that we can explicitly
|
||||
// return a Future that's Send + 'static, rather than tied to &self.
|
||||
let client = self.client.clone();
|
||||
async move {
|
||||
// If block hash is not provided, get the hash
|
||||
// for the latest block and use that.
|
||||
let block_hash = match block_hash {
|
||||
Some(hash) => hash,
|
||||
None => client
|
||||
.rpc()
|
||||
.block_hash(None)
|
||||
.await?
|
||||
.expect("didn't pass a block number; qed"),
|
||||
};
|
||||
// get the hash for the latest block and use that.
|
||||
let block_hash = client
|
||||
.rpc()
|
||||
.block_hash(None)
|
||||
.await?
|
||||
.expect("didn't pass a block number; qed");
|
||||
|
||||
Ok(Storage::new(client, block_hash))
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ where
|
||||
/// // Fetch just the keys, returning up to 10 keys.
|
||||
/// let value = api
|
||||
/// .storage()
|
||||
/// .at(None)
|
||||
/// .at_latest()
|
||||
/// .await
|
||||
/// .unwrap()
|
||||
/// .fetch(&address)
|
||||
@@ -185,7 +185,7 @@ where
|
||||
/// // Iterate over keys and values at that address.
|
||||
/// let mut iter = api
|
||||
/// .storage()
|
||||
/// .at(None)
|
||||
/// .at_latest()
|
||||
/// .await
|
||||
/// .unwrap()
|
||||
/// .iter(address, 10)
|
||||
|
||||
@@ -397,7 +397,7 @@ impl<T: Config, C: OnlineClientT<T>> TxInBlock<T, C> {
|
||||
.ok_or(Error::Transaction(TransactionError::BlockNotFound))?;
|
||||
|
||||
let events = EventsClient::new(self.client.clone())
|
||||
.at(Some(self.block_hash))
|
||||
.at(self.block_hash)
|
||||
.await?;
|
||||
|
||||
Ok(crate::blocks::ExtrinsicEvents::new(
|
||||
|
||||
Reference in New Issue
Block a user