diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c7eef845f7..850db1b017 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -53,8 +53,16 @@ jobs: crate: cargo-hack version: 0.5 - - name: Cargo check - run: cargo hack --exclude-all-features --each-feature check --all-targets --workspace + # A basic check over all targets together. This may lead to features being combined etc, + # and doesn't test combinations of different features. + - name: Cargo check all targets. + run: cargo check --all-targets + + # Next, check each feature on its own and compile each crate separately. This is no good + # for subxt/examples, which expect default features to be enabled, hence the above check + # and why we don'#t do `--all-targets` for this one. + - name: Cargo hack; check each feature/crate on its own + run: cargo hack --exclude-all-features --each-feature check --workspace fmt: name: Cargo fmt diff --git a/Cargo.lock b/Cargo.lock index 4e50e57b9d..02fb6505a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3462,17 +3462,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "subxt-examples" -version = "0.29.0" -dependencies = [ - "futures", - "hex", - "sp-keyring", - "subxt", - "tokio", -] - [[package]] name = "subxt-macro" version = "0.29.0" diff --git a/Cargo.toml b/Cargo.toml index d4f0d9dcf4..f0ac464fcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ members = [ "cli", "codegen", - "examples", "testing/substrate-runner", "testing/test-runtime", "testing/integration-tests", diff --git a/examples/Cargo.toml b/examples/Cargo.toml deleted file mode 100644 index d6972e640c..0000000000 --- a/examples/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "subxt-examples" -version.workspace = true -authors.workspace = true -edition.workspace = true -rust-version.workspace = true -publish = false - -license.workspace = true -repository.workspace = true -documentation.workspace = true -homepage.workspace = true -description = "Subxt example usage" - -[dev-dependencies] -subxt = { workspace = true } -tokio = { workspace = true } -futures = { workspace = true } -hex = { workspace = true } -sp-keyring = { workspace = true } diff --git a/examples/README.md b/examples/README.md index a7c3c186ab..8dd7296d9e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,5 +1,5 @@ # Subxt Examples -Take a look in the [examples](./examples) subfolder for various `subxt` usage examples. +Each folder here contains a complete example which makes use of subxt in some way. -All examples form part of the `subxt` documentation; there should be no examples without corresponding links from the docs. \ No newline at end of file +For smaller single-file examples, see the `./subxt/examples` folder. \ No newline at end of file diff --git a/examples/examples/blocks_subscribing.rs b/subxt/examples/blocks_subscribing.rs similarity index 100% rename from examples/examples/blocks_subscribing.rs rename to subxt/examples/blocks_subscribing.rs diff --git a/examples/examples/constants_dynamic.rs b/subxt/examples/constants_dynamic.rs similarity index 100% rename from examples/examples/constants_dynamic.rs rename to subxt/examples/constants_dynamic.rs diff --git a/examples/examples/constants_static.rs b/subxt/examples/constants_static.rs similarity index 100% rename from examples/examples/constants_static.rs rename to subxt/examples/constants_static.rs diff --git a/examples/examples/events.rs b/subxt/examples/events.rs similarity index 100% rename from examples/examples/events.rs rename to subxt/examples/events.rs diff --git a/examples/examples/runtime_apis_dynamic.rs b/subxt/examples/runtime_apis_dynamic.rs similarity index 100% rename from examples/examples/runtime_apis_dynamic.rs rename to subxt/examples/runtime_apis_dynamic.rs diff --git a/examples/examples/runtime_apis_raw.rs b/subxt/examples/runtime_apis_raw.rs similarity index 100% rename from examples/examples/runtime_apis_raw.rs rename to subxt/examples/runtime_apis_raw.rs diff --git a/examples/examples/runtime_apis_static.rs b/subxt/examples/runtime_apis_static.rs similarity index 100% rename from examples/examples/runtime_apis_static.rs rename to subxt/examples/runtime_apis_static.rs diff --git a/examples/examples/setup_client_custom_config.rs b/subxt/examples/setup_client_custom_config.rs similarity index 100% rename from examples/examples/setup_client_custom_config.rs rename to subxt/examples/setup_client_custom_config.rs diff --git a/examples/examples/setup_client_custom_rpc.rs b/subxt/examples/setup_client_custom_rpc.rs similarity index 100% rename from examples/examples/setup_client_custom_rpc.rs rename to subxt/examples/setup_client_custom_rpc.rs diff --git a/examples/examples/setup_client_offline.rs b/subxt/examples/setup_client_offline.rs similarity index 100% rename from examples/examples/setup_client_offline.rs rename to subxt/examples/setup_client_offline.rs diff --git a/examples/examples/storage_fetch.rs b/subxt/examples/storage_fetch.rs similarity index 100% rename from examples/examples/storage_fetch.rs rename to subxt/examples/storage_fetch.rs diff --git a/examples/examples/storage_fetch_dynamic.rs b/subxt/examples/storage_fetch_dynamic.rs similarity index 100% rename from examples/examples/storage_fetch_dynamic.rs rename to subxt/examples/storage_fetch_dynamic.rs diff --git a/examples/examples/storage_iterating.rs b/subxt/examples/storage_iterating.rs similarity index 100% rename from examples/examples/storage_iterating.rs rename to subxt/examples/storage_iterating.rs diff --git a/examples/examples/storage_iterating_dynamic.rs b/subxt/examples/storage_iterating_dynamic.rs similarity index 100% rename from examples/examples/storage_iterating_dynamic.rs rename to subxt/examples/storage_iterating_dynamic.rs diff --git a/examples/examples/tx_basic.rs b/subxt/examples/tx_basic.rs similarity index 100% rename from examples/examples/tx_basic.rs rename to subxt/examples/tx_basic.rs diff --git a/examples/examples/tx_status_stream.rs b/subxt/examples/tx_status_stream.rs similarity index 100% rename from examples/examples/tx_status_stream.rs rename to subxt/examples/tx_status_stream.rs diff --git a/examples/examples/tx_with_params.rs b/subxt/examples/tx_with_params.rs similarity index 100% rename from examples/examples/tx_with_params.rs rename to subxt/examples/tx_with_params.rs diff --git a/subxt/src/book/mod.rs b/subxt/src/book/mod.rs index 5b8164c612..0123d3a685 100644 --- a/subxt/src/book/mod.rs +++ b/subxt/src/book/mod.rs @@ -64,7 +64,7 @@ //! accounts, Alice to Bob: //! //! ```rust,ignore -#![doc = include_str!("../../../examples/examples/tx_basic.rs")] +#![doc = include_str!("../../examples/tx_basic.rs")] //! ``` //! //! This example assumes that a Polkadot node is running locally (Subxt endeavors to support all diff --git a/subxt/src/book/setup/client.rs b/subxt/src/book/setup/client.rs index 3157914a58..88086d6213 100644 --- a/subxt/src/book/setup/client.rs +++ b/subxt/src/book/setup/client.rs @@ -36,18 +36,18 @@ //! Defining some custom config based off the default Substrate config: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/setup_client_custom_config.rs")] +#![doc = include_str!("../../../examples/setup_client_custom_config.rs")] //! ``` //! //! Writing a custom [`crate::rpc::RpcClientT`] implementation: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/setup_client_custom_rpc.rs")] +#![doc = include_str!("../../../examples/setup_client_custom_rpc.rs")] //! ``` //! //! Creating an [`crate::OfflineClient`]: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/setup_client_offline.rs")] +#![doc = include_str!("../../../examples/setup_client_offline.rs")] //! ``` //! diff --git a/subxt/src/book/usage/blocks.rs b/subxt/src/book/usage/blocks.rs index a020090c29..61f1ae9340 100644 --- a/subxt/src/book/usage/blocks.rs +++ b/subxt/src/book/usage/blocks.rs @@ -34,6 +34,6 @@ //! can decode the extrinsics and access various details, including the associated events: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/blocks_subscribing.rs")] +#![doc = include_str!("../../../examples/blocks_subscribing.rs")] //! ``` //! diff --git a/subxt/src/book/usage/constants.rs b/subxt/src/book/usage/constants.rs index 6e889fafdc..4b21010c6b 100644 --- a/subxt/src/book/usage/constants.rs +++ b/subxt/src/book/usage/constants.rs @@ -49,12 +49,12 @@ //! Here's an example using a static query: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/constants_static.rs")] +#![doc = include_str!("../../../examples/constants_static.rs")] //! ``` //! //! And here's one using a dynamic query: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/constants_dynamic.rs")] +#![doc = include_str!("../../../examples/constants_dynamic.rs")] //! ``` //! diff --git a/subxt/src/book/usage/events.rs b/subxt/src/book/usage/events.rs index 7d7a881539..613819e503 100644 --- a/subxt/src/book/usage/events.rs +++ b/subxt/src/book/usage/events.rs @@ -44,6 +44,6 @@ //! Here's an example which puts this all together: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/events.rs")] +#![doc = include_str!("../../../examples/events.rs")] //! ``` //! diff --git a/subxt/src/book/usage/runtime_apis.rs b/subxt/src/book/usage/runtime_apis.rs index 9279bed078..4fdc19f722 100644 --- a/subxt/src/book/usage/runtime_apis.rs +++ b/subxt/src/book/usage/runtime_apis.rs @@ -58,7 +58,7 @@ //! The easiest way to make a runtime API call is to use the statically generated interface. //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/runtime_apis_static.rs")] +#![doc = include_str!("../../../examples/runtime_apis_static.rs")] //! ``` //! //! ### Making a dynamic Runtime API call @@ -67,7 +67,7 @@ //! [`crate::dynamic::runtime_api_call`] method. //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/runtime_apis_dynamic.rs")] +#![doc = include_str!("../../../examples/runtime_apis_dynamic.rs")] //! ``` //! //! ### Making a raw call @@ -77,6 +77,6 @@ //! the argument bytes and manually provide a type for the response bytes to be decoded into. //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/runtime_apis_raw.rs")] +#![doc = include_str!("../../../examples/runtime_apis_raw.rs")] //! ``` //! diff --git a/subxt/src/book/usage/storage.rs b/subxt/src/book/usage/storage.rs index 23b0dbc1e7..4ffc73d162 100644 --- a/subxt/src/book/usage/storage.rs +++ b/subxt/src/book/usage/storage.rs @@ -75,7 +75,7 @@ //! latter will only work for storage queries that have a default value when empty): //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/storage_fetch.rs")] +#![doc = include_str!("../../../examples/storage_fetch.rs")] //! ``` //! //! For completeness, below is an example using a dynamic query instead. The return type from a @@ -83,7 +83,7 @@ //! [`crate::dynamic::Value`], or else the raw bytes can be accessed instead. //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/storage_fetch_dynamic.rs")] +#![doc = include_str!("../../../examples/storage_fetch_dynamic.rs")] //! ``` //! //! ### Iterating storage entries @@ -92,13 +92,13 @@ //! iterate over all of the values stored at that location: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/storage_iterating.rs")] +#![doc = include_str!("../../../examples/storage_iterating.rs")] //! ``` //! //! Here's the same logic but using dynamically constructed values instead: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/storage_iterating_dynamic.rs")] +#![doc = include_str!("../../../examples/storage_iterating_dynamic.rs")] //! ``` //! //! ### Advanced diff --git a/subxt/src/book/usage/transactions.rs b/subxt/src/book/usage/transactions.rs index 49779228ab..ebabbbb944 100644 --- a/subxt/src/book/usage/transactions.rs +++ b/subxt/src/book/usage/transactions.rs @@ -147,7 +147,7 @@ //! inspection. This looks like: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/tx_basic.rs")] +#![doc = include_str!("../../../examples/tx_basic.rs")] //! ``` //! //! ### Providing transaction parameters @@ -156,7 +156,7 @@ //! [`crate::tx::TxClient::sign_and_submit_then_watch`] instead: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/tx_with_params.rs")] +#![doc = include_str!("../../../examples/tx_with_params.rs")] //! ``` //! //! This example doesn't wait for the transaction to be included in a block; it just submits it and @@ -168,7 +168,7 @@ //! the transaction, you can monitor them as they are emitted and react however you choose: //! //! ```rust,ignore -#![doc = include_str!("../../../../examples/examples/tx_status_stream.rs")] +#![doc = include_str!("../../../examples/tx_status_stream.rs")] //! ``` //! //! Take a look at the API docs for [`crate::tx::TxProgress`], [`crate::tx::TxStatus`] and diff --git a/subxt/src/lib.rs b/subxt/src/lib.rs index ee7e257c6f..0711057ccf 100644 --- a/subxt/src/lib.rs +++ b/subxt/src/lib.rs @@ -5,7 +5,7 @@ //! Subxt is a library for interacting with Substrate based nodes. Using it looks something like this: //! //! ```rust,ignore -#![doc = include_str!("../../examples/examples/tx_basic.rs")] +#![doc = include_str!("../examples/tx_basic.rs")] //! ``` //! //! Take a look at [the Subxt guide](book) to learn more about how to use Subxt.