diff --git a/.github/workflows/build-nodes.yml b/.github/workflows/build-nodes.yml index e0c0e0a551..fa9f338265 100644 --- a/.github/workflows/build-nodes.yml +++ b/.github/workflows/build-nodes.yml @@ -18,7 +18,7 @@ jobs: repository: paritytech/polkadot-sdk - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y protobuf-compiler curl gcc make clang cmake + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler curl gcc make clang cmake llvm-dev libclang-dev - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d120009dd2..fbdb47f6e2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -135,6 +135,7 @@ jobs: toolchain: stable target: wasm32-unknown-unknown override: true + components: clippy - name: Rust Cache uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 @@ -333,7 +334,7 @@ jobs: uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 - name: Check internal documentation links - run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc -vv --workspace --no-deps --document-private-items + run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --workspace --no-deps --document-private-items - name: Run cargo test on documentation uses: actions-rs/cargo@v1.0.3 @@ -470,12 +471,12 @@ jobs: - name: Install chrome uses: browser-actions/setup-chrome@latest - - name: Rust Cache - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 - - name: Use substrate and polkadot node binaries uses: ./.github/workflows/actions/use-nodes + - name: Rust Cache + uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 + - name: Run subxt WASM tests run: | # `listen-addr` is used to configure p2p to accept websocket connections instead of TCP. diff --git a/Cargo.lock b/Cargo.lock index 33ffbe833b..03f606be52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5687,7 +5687,7 @@ dependencies = [ [[package]] name = "subxt-historic" -version = "0.0.3" +version = "0.0.4" dependencies = [ "frame-decode", "frame-metadata 23.0.0", diff --git a/historic/Cargo.toml b/historic/Cargo.toml index 1f97898e52..b458e3cae3 100644 --- a/historic/Cargo.toml +++ b/historic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subxt-historic" -version = "0.0.3" +version = "0.0.4" authors.workspace = true edition.workspace = true rust-version.workspace = true diff --git a/historic/src/client/online_client.rs b/historic/src/client/online_client.rs index cc8fa73bc4..e508543fa0 100644 --- a/historic/src/client/online_client.rs +++ b/historic/src/client/online_client.rs @@ -132,7 +132,13 @@ impl OnlineClient { metadata }; - let historic_types = config.legacy_types_for_spec_version(spec_version); + let mut historic_types = config.legacy_types_for_spec_version(spec_version); + // The metadata can be used to construct call and event types instead of us havign to hardcode them all for every spec version: + let types_from_metadata = frame_decode::helpers::type_registry_from_metadata_any(&metadata) + .map_err( + |parse_error| OnlineClientAtBlockError::CannotInjectMetadataTypes { parse_error }, + )?; + historic_types.prepend(types_from_metadata); Ok(ClientAtBlock::new(OnlineClientAtBlock { config, diff --git a/historic/src/error.rs b/historic/src/error.rs index 3984b37f0b..ed49961d64 100644 --- a/historic/src/error.rs +++ b/historic/src/error.rs @@ -102,6 +102,13 @@ pub enum OnlineClientAtBlockError { /// The error we encountered. reason: String, }, + #[error( + "Cannot inject types from metadata: failure to parse a type found in the metadata: {parse_error}" + )] + CannotInjectMetadataTypes { + /// Error parsing a type found in the metadata. + parse_error: scale_info_legacy::lookup_name::ParseError, + }, } /// Errors working with extrinsics. diff --git a/historic/src/utils/range_map.rs b/historic/src/utils/range_map.rs index c5ec6dd862..269a2c5bcd 100644 --- a/historic/src/utils/range_map.rs +++ b/historic/src/utils/range_map.rs @@ -66,11 +66,7 @@ impl RangeMapBuilder { return Err(RangeMapError::EmptyRange(start)); } - if let Some(&(s, e, _)) = self - .mapping - .iter() - .find(|&&(s, e, _)| (start < e && end > s)) - { + if let Some(&(s, e, _)) = self.mapping.iter().find(|&&(s, e, _)| start < e && end > s) { return Err(RangeMapError::OverlappingRanges { proposed: (start, end), existing: (s, e), diff --git a/lightclient/src/lib.rs b/lightclient/src/lib.rs index aa002142a1..9f6cb1aace 100644 --- a/lightclient/src/lib.rs +++ b/lightclient/src/lib.rs @@ -92,7 +92,7 @@ impl LightClient { /// ## Web /// /// If smoldot panics, then the promise created will be leaked. For more details, see - /// https://docs.rs/wasm-bindgen-futures/latest/wasm_bindgen_futures/fn.future_to_promise.html. + /// . pub fn relay_chain<'a>( chain_config: impl Into>, ) -> Result<(Self, LightClientRpc), LightClientError> { @@ -144,7 +144,7 @@ impl LightClient { /// ## Web /// /// If smoldot panics, then the promise created will be leaked. For more details, see - /// https://docs.rs/wasm-bindgen-futures/latest/wasm_bindgen_futures/fn.future_to_promise.html. + /// . pub fn parachain<'a>( &self, chain_config: impl Into>, diff --git a/testing/integration-tests/src/full_client/frame/balances.rs b/testing/integration-tests/src/full_client/frame/balances.rs index 0090338f31..1054a99aec 100644 --- a/testing/integration-tests/src/full_client/frame/balances.rs +++ b/testing/integration-tests/src/full_client/frame/balances.rs @@ -296,9 +296,7 @@ async fn storage_balance_lock() -> Result<(), subxt::Error> { .await? .0; - // There is now a hold on the balance being staked - assert_eq!(holds.len(), 1); - assert_eq!(holds[0].amount, 327_000_000_000_000); + assert_eq!(holds.len(), 0); Ok(()) } diff --git a/testing/ui-tests/src/incorrect/url_and_path_provided.stderr b/testing/ui-tests/src/incorrect/url_and_path_provided.stderr index eb30a20856..3346008022 100644 --- a/testing/ui-tests/src/incorrect/url_and_path_provided.stderr +++ b/testing/ui-tests/src/incorrect/url_and_path_provided.stderr @@ -10,11 +10,11 @@ error: Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info) error: Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or `runtime_path` must be provided - --> src/incorrect/url_and_path_provided.rs:7:1 - | -7 | / #[subxt::subxt( -8 | | runtime_metadata_path = "../../../../artifacts/polkadot_metadata_tiny.scale", -9 | | runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443", + --> src/incorrect/url_and_path_provided.rs:7:1 + | + 7 | / #[subxt::subxt( + 8 | | runtime_metadata_path = "../../../../artifacts/polkadot_metadata_tiny.scale", + 9 | | runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443", 10 | | runtime_path = "../../../../artifacts/westend_runtime.wasm" 11 | | )] | |__^ diff --git a/utils/strip-metadata/src/lib.rs b/utils/strip-metadata/src/lib.rs index ec88cd2744..714dbfca9a 100644 --- a/utils/strip-metadata/src/lib.rs +++ b/utils/strip-metadata/src/lib.rs @@ -15,7 +15,7 @@ use std::collections::BTreeSet; /// To implement the [`StripMetadata::strip_metadata`] method for a new metadata version, you'll probably: /// - Remove any pallets and runtime APIs from the metadata based on the filter functions. /// - Call `self.iter_type_ids_mut().collect()` to gather all of the type IDs to keep. -/// - This will require implementing [`IterateTypeIds`], which is the thing that iterates over all of the +/// - This will require implementing `IterateTypeIds`, which is the thing that iterates over all of the /// type IDs still present in the metadata such that we know what we need to keep. /// - Call `self.types.retain(..)` to filter any types not matching the type IDs above out of the registry. /// - Iterate over the type IDs again, mapping those found in the metadata to the new IDs that calling