From 15742f04564156df43e92af2980e4b6fb7112b45 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 6 Oct 2023 09:34:48 +0100 Subject: [PATCH] Update to subxt `0.32.1`, use account_nonce API (#1934) * Update to subxt 0.32.1, use account_nonce API * Comment --- Cargo.toml | 6 ++--- crates/e2e/src/xts.rs | 26 ++++--------------- integration-tests/e2e-call-runtime/Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1e9ba3eebc2..ccd02ea5b0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,9 +66,9 @@ serde_json = { version = "1.0.81" } sha2 = { version = "0.10" } sha3 = { version = "0.10" } static_assertions = { version = "1.1" } -subxt = { version = "0.32.0" } -subxt-metadata = { version = "0.32.0" } -subxt-signer = { version = "0.32.0" } +subxt = { version = "0.32.1" } +subxt-metadata = { version = "0.32.1" } +subxt-signer = { version = "0.32.1" } syn = { version = "2" } synstructure = { version = "0.13.0" } tokio = { version = "1.18.2" } diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index 2a16fbf0298..e95621d0c30 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -373,34 +373,18 @@ where } /// Return the account nonce at the *best* block for an account ID. - /// - /// Replace this with the new `account_id` query available in the next `subxt` - /// release. async fn get_account_nonce( &self, account_id: &C::AccountId, ) -> Result { let best_block = self.best_block().await; - - let account_nonce_bytes = self + let account_nonce = self .client - .backend() - .call( - "AccountNonceApi_account_nonce", - Some(&scale::Encode::encode(&account_id)), - best_block, - ) + .blocks() + .at(best_block) + .await? + .account_nonce(account_id) .await?; - - // custom decoding from a u16/u32/u64 into a u64, based on the number of bytes we - // got back. - let cursor = &mut &account_nonce_bytes[..]; - let account_nonce: u64 = match account_nonce_bytes.len() { - 2 => ::decode(cursor)?.into(), - 4 => ::decode(cursor)?.into(), - 8 => ::decode(cursor)?, - _ => return Err(subxt::Error::Decode(subxt::error::DecodeError::custom_string(format!("state call AccountNonceApi_account_nonce returned an unexpected number of bytes: {} (expected 2, 4 or 8)", account_nonce_bytes.len())))) - }; Ok(account_nonce) } diff --git a/integration-tests/e2e-call-runtime/Cargo.toml b/integration-tests/e2e-call-runtime/Cargo.toml index 3a6724f3324..aba6b35386e 100644 --- a/integration-tests/e2e-call-runtime/Cargo.toml +++ b/integration-tests/e2e-call-runtime/Cargo.toml @@ -10,7 +10,7 @@ ink = { path = "../../crates/ink", default-features = false } [dev-dependencies] ink_e2e = { path = "../../crates/e2e" } -subxt = { version = "0.32.0", default-features = false } +subxt = { version = "0.32.1", default-features = false } [lib] path = "lib.rs"