diff --git a/Cargo.toml b/Cargo.toml index 698ab1a179..ca36ea9297 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,53 +1,10 @@ [workspace] -members = [".", "cli", "codegen", "macro", "test-runtime"] -[package] -name = "subxt" -version = "0.16.0" -authors = ["Parity Technologies "] -edition = "2021" - -license = "GPL-3.0" -readme = "README.md" -repository = "https://github.com/paritytech/subxt" -documentation = "https://docs.rs/subxt" -homepage = "https://www.parity.io/" -description = "Submit extrinsics (transactions) to a substrate node via RPC" -keywords = ["parity", "substrate", "blockchain"] -include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"] - -[dependencies] -async-trait = "0.1.49" -bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] } -codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] } -chameleon = "0.1.0" -scale-info = { version = "1.0.0", features = ["bit-vec"] } -futures = "0.3.13" -hex = "0.4.3" -jsonrpsee = { version = "0.8.0", features = ["ws-client", "http-client"] } -log = "0.4.14" -num-traits = { version = "0.2.14", default-features = false } -serde = { version = "1.0.124", features = ["derive"] } -serde_json = "1.0.64" -thiserror = "1.0.24" -url = "2.2.1" - -subxt-macro = { version = "0.16.0", path = "macro" } - -sp-core = { version = "4.0.0", default-features = false } -sp-runtime = { version = "4.0.0", default-features = false } -sp-version = "4.0.0" - -frame-metadata = "14.0.0" -derivative = "2.2.0" - -[dev-dependencies] -sp-arithmetic = { version = "4.0.0", default-features = false } -assert_matches = "1.5.0" -async-std = { version = "1.9.0", features = ["attributes", "tokio1"] } -env_logger = "0.9.0" -tempdir = "0.3.7" -wabt = "0.10.0" -which = "4.0.2" -test-runtime = { path = "test-runtime" } -sp-keyring = "4.0.0" +members = [ + "cli", + "codegen", + "examples", + "macro", + "subxt", + "test-runtime" +] diff --git a/README.md b/README.md index cffff5cac1..a5bafce790 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ A library to **sub**mit e**xt**rinsics to a [substrate](https://github.com/parit ## Usage +Take a look in the [examples](./examples/examples) folder for various `subxt` usage examples. + ### Downloading metadata from a Substrate node Use the [`subxt-cli`](./cli) tool to download the metadata for your target runtime from a node. @@ -26,7 +28,7 @@ a different node then the `metadata` command accepts a `--url` argument. ### Generating the runtime API from the downloaded metadata -Declare a module and decorate it with the `subxt` attribute which points at the downloaded metadata for the +Declare a module and decorate it with the `subxt` attribute which points at the downloaded metadata for the target runtime: ```rust @@ -34,20 +36,20 @@ target runtime: pub mod node_runtime { } ``` -**Important:** `runtime_metadata_path` resolves to a path relative to the directory where your crate's `Cargo.toml` +**Important:** `runtime_metadata_path` resolves to a path relative to the directory where your crate's `Cargo.toml` resides ([`CARGO_MANIFEST_DIR`](https://doc.rust-lang.org/cargo/reference/environment-variables.html)), *not* relative to the source file. ### Initializing the API client -API is still a work in progress. See [examples](./examples) for the current usage. +API is still a work in progress. See [examples](./examples/examples) for the current usage. ### Querying Storage -API is still a work in progress. See [tests](./tests/integration/frame) for the current usage. +API is still a work in progress. See [tests](./subxt/tests/integration/frame) for the current usage. ### Submitting Extrinsics -API is still a work in progress. See [examples](./examples/polkadot_balance_transfer.rs) for the current usage. +API is still a work in progress. See [examples](./examples/examples/polkadot_balance_transfer.rs) for the current usage. ## Integration Testing diff --git a/RELEASING.md b/RELEASING.md index ffc325eb1e..53ff0cf34d 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -55,7 +55,7 @@ We also assume that ongoing work done is being merged directly to the `master` b sleep 10 && \ (cd macro && cargo hack publish --no-dev-deps --allow-dirty) && \ sleep 10 && \ - cargo publish && \ + (cd subxt && cargo publish) && \ sleep 10 && \ (cd cli && cargo publish); ``` diff --git a/cli/src/main.rs b/cli/src/main.rs index 14a5f2949a..465755b573 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -161,7 +161,7 @@ fn codegen( let p = raw_derives .iter() - .map(|raw| syn::parse_str(&raw)) + .map(|raw| syn::parse_str(raw)) .collect::, _>>()?; let mut derives = GeneratedTypeDerives::default(); derives.append(p.into_iter()); diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 0000000000..e30ba4d7f0 --- /dev/null +++ b/examples/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "subxt-examples" +version = "0.16.0" +authors = ["Parity Technologies "] +edition = "2021" +publish = false + +license = "GPL-3.0" +repository = "https://github.com/paritytech/subxt" +documentation = "https://docs.rs/subxt" +homepage = "https://www.parity.io/" +description = "Subxt example usage" + +[dev-dependencies] +subxt = { path = "../subxt" } +async-std = { version = "1.9.0", features = ["attributes", "tokio1"] } +sp-keyring = "4.0.0" +env_logger = "0.9.0" +futures = "0.3.13" +codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] } +hex = "0.4.3" diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000000..30ae9c8b65 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,3 @@ +# Subxt Examples + +Take a look in the [examples](./examples) subfolder for various `subxt` usage examples. \ No newline at end of file diff --git a/examples/custom_config.rs b/examples/examples/custom_config.rs similarity index 100% rename from examples/custom_config.rs rename to examples/examples/custom_config.rs diff --git a/examples/custom_type_derives.rs b/examples/examples/custom_type_derives.rs similarity index 100% rename from examples/custom_type_derives.rs rename to examples/examples/custom_type_derives.rs diff --git a/examples/fetch_all_accounts.rs b/examples/examples/fetch_all_accounts.rs similarity index 100% rename from examples/fetch_all_accounts.rs rename to examples/examples/fetch_all_accounts.rs diff --git a/examples/fetch_remote.rs b/examples/examples/fetch_remote.rs similarity index 100% rename from examples/fetch_remote.rs rename to examples/examples/fetch_remote.rs diff --git a/examples/polkadot_balance_transfer.rs b/examples/examples/polkadot_balance_transfer.rs similarity index 100% rename from examples/polkadot_balance_transfer.rs rename to examples/examples/polkadot_balance_transfer.rs diff --git a/examples/polkadot_metadata.scale b/examples/examples/polkadot_metadata.scale similarity index 100% rename from examples/polkadot_metadata.scale rename to examples/examples/polkadot_metadata.scale diff --git a/examples/submit_and_watch.rs b/examples/examples/submit_and_watch.rs similarity index 100% rename from examples/submit_and_watch.rs rename to examples/examples/submit_and_watch.rs diff --git a/examples/transfer_subscribe.rs b/examples/examples/transfer_subscribe.rs similarity index 96% rename from examples/transfer_subscribe.rs rename to examples/examples/transfer_subscribe.rs index 033c0533af..316d27248b 100644 --- a/examples/transfer_subscribe.rs +++ b/examples/examples/transfer_subscribe.rs @@ -58,7 +58,7 @@ async fn main() -> Result<(), Box> { .await?; let raw = sub.next().await.unwrap().unwrap(); - let event = ::decode( + let event = ::decode( &mut &raw.data[..], ); if let Ok(e) = event { diff --git a/macro/Cargo.toml b/macro/Cargo.toml index 0cbb23fd2f..43b2534841 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -31,6 +31,6 @@ subxt-codegen = { path = "../codegen", version = "0.16.0" } [dev-dependencies] pretty_assertions = "1.0.0" -subxt = { path = "..", version = "0.16.0" } +subxt = { path = "../subxt", version = "0.16.0" } trybuild = "1.0.38" sp-keyring = "4.0.0" diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml new file mode 100644 index 0000000000..4f3903908c --- /dev/null +++ b/subxt/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "subxt" +version = "0.16.0" +authors = ["Parity Technologies "] +edition = "2021" + +license = "GPL-3.0" +readme = "../README.md" +repository = "https://github.com/paritytech/subxt" +documentation = "https://docs.rs/subxt" +homepage = "https://www.parity.io/" +description = "Submit extrinsics (transactions) to a substrate node via RPC" +keywords = ["parity", "substrate", "blockchain"] + +[dependencies] +async-trait = "0.1.49" +bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] } +codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] } +chameleon = "0.1.0" +scale-info = { version = "1.0.0", features = ["bit-vec"] } +futures = "0.3.13" +hex = "0.4.3" +jsonrpsee = { version = "0.8.0", features = ["ws-client", "http-client"] } +log = "0.4.14" +num-traits = { version = "0.2.14", default-features = false } +serde = { version = "1.0.124", features = ["derive"] } +serde_json = "1.0.64" +thiserror = "1.0.24" +url = "2.2.1" + +subxt-macro = { version = "0.16.0", path = "../macro" } + +sp-core = { version = "4.0.0", default-features = false } +sp-runtime = { version = "4.0.0", default-features = false } +sp-version = "4.0.0" + +frame-metadata = "14.0.0" +derivative = "2.2.0" + +[dev-dependencies] +sp-arithmetic = { version = "4.0.0", default-features = false } +assert_matches = "1.5.0" +async-std = { version = "1.9.0", features = ["attributes", "tokio1"] } +env_logger = "0.9.0" +tempdir = "0.3.7" +wabt = "0.10.0" +which = "4.0.2" +test-runtime = { path = "../test-runtime" } +sp-keyring = "4.0.0" diff --git a/src/client.rs b/subxt/src/client.rs similarity index 100% rename from src/client.rs rename to subxt/src/client.rs diff --git a/src/config.rs b/subxt/src/config.rs similarity index 100% rename from src/config.rs rename to subxt/src/config.rs diff --git a/src/error.rs b/subxt/src/error.rs similarity index 100% rename from src/error.rs rename to subxt/src/error.rs diff --git a/src/events.rs b/subxt/src/events.rs similarity index 100% rename from src/events.rs rename to subxt/src/events.rs diff --git a/src/extrinsic/extra.rs b/subxt/src/extrinsic/extra.rs similarity index 100% rename from src/extrinsic/extra.rs rename to subxt/src/extrinsic/extra.rs diff --git a/src/extrinsic/mod.rs b/subxt/src/extrinsic/mod.rs similarity index 100% rename from src/extrinsic/mod.rs rename to subxt/src/extrinsic/mod.rs diff --git a/src/extrinsic/signer.rs b/subxt/src/extrinsic/signer.rs similarity index 100% rename from src/extrinsic/signer.rs rename to subxt/src/extrinsic/signer.rs diff --git a/src/lib.rs b/subxt/src/lib.rs similarity index 100% rename from src/lib.rs rename to subxt/src/lib.rs diff --git a/src/metadata.rs b/subxt/src/metadata.rs similarity index 100% rename from src/metadata.rs rename to subxt/src/metadata.rs diff --git a/src/rpc.rs b/subxt/src/rpc.rs similarity index 100% rename from src/rpc.rs rename to subxt/src/rpc.rs diff --git a/src/storage.rs b/subxt/src/storage.rs similarity index 100% rename from src/storage.rs rename to subxt/src/storage.rs diff --git a/src/subscription.rs b/subxt/src/subscription.rs similarity index 100% rename from src/subscription.rs rename to subxt/src/subscription.rs diff --git a/src/transaction.rs b/subxt/src/transaction.rs similarity index 100% rename from src/transaction.rs rename to subxt/src/transaction.rs diff --git a/tests/integration/client.rs b/subxt/tests/integration/client.rs similarity index 100% rename from tests/integration/client.rs rename to subxt/tests/integration/client.rs diff --git a/tests/integration/codegen/mod.rs b/subxt/tests/integration/codegen/mod.rs similarity index 100% rename from tests/integration/codegen/mod.rs rename to subxt/tests/integration/codegen/mod.rs diff --git a/tests/integration/codegen/polkadot.rs b/subxt/tests/integration/codegen/polkadot.rs similarity index 100% rename from tests/integration/codegen/polkadot.rs rename to subxt/tests/integration/codegen/polkadot.rs diff --git a/tests/integration/frame/balances.rs b/subxt/tests/integration/frame/balances.rs similarity index 100% rename from tests/integration/frame/balances.rs rename to subxt/tests/integration/frame/balances.rs diff --git a/tests/integration/frame/contracts.rs b/subxt/tests/integration/frame/contracts.rs similarity index 100% rename from tests/integration/frame/contracts.rs rename to subxt/tests/integration/frame/contracts.rs diff --git a/tests/integration/frame/mod.rs b/subxt/tests/integration/frame/mod.rs similarity index 100% rename from tests/integration/frame/mod.rs rename to subxt/tests/integration/frame/mod.rs diff --git a/tests/integration/frame/staking.rs b/subxt/tests/integration/frame/staking.rs similarity index 100% rename from tests/integration/frame/staking.rs rename to subxt/tests/integration/frame/staking.rs diff --git a/tests/integration/frame/sudo.rs b/subxt/tests/integration/frame/sudo.rs similarity index 100% rename from tests/integration/frame/sudo.rs rename to subxt/tests/integration/frame/sudo.rs diff --git a/tests/integration/frame/system.rs b/subxt/tests/integration/frame/system.rs similarity index 100% rename from tests/integration/frame/system.rs rename to subxt/tests/integration/frame/system.rs diff --git a/tests/integration/frame/timestamp.rs b/subxt/tests/integration/frame/timestamp.rs similarity index 100% rename from tests/integration/frame/timestamp.rs rename to subxt/tests/integration/frame/timestamp.rs diff --git a/tests/integration/main.rs b/subxt/tests/integration/main.rs similarity index 100% rename from tests/integration/main.rs rename to subxt/tests/integration/main.rs diff --git a/tests/integration/utils/context.rs b/subxt/tests/integration/utils/context.rs similarity index 100% rename from tests/integration/utils/context.rs rename to subxt/tests/integration/utils/context.rs diff --git a/tests/integration/utils/mod.rs b/subxt/tests/integration/utils/mod.rs similarity index 100% rename from tests/integration/utils/mod.rs rename to subxt/tests/integration/utils/mod.rs diff --git a/tests/integration/utils/node_proc.rs b/subxt/tests/integration/utils/node_proc.rs similarity index 100% rename from tests/integration/utils/node_proc.rs rename to subxt/tests/integration/utils/node_proc.rs diff --git a/test-runtime/Cargo.toml b/test-runtime/Cargo.toml index f609defe30..8848fdcd7b 100644 --- a/test-runtime/Cargo.toml +++ b/test-runtime/Cargo.toml @@ -4,12 +4,12 @@ version = "0.16.0" edition = "2021" [dependencies] -subxt = { path = ".." } +subxt = { path = "../subxt" } sp-runtime = "4.0.0" codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] } [build-dependencies] -subxt = { path = "..", version = "0.16.0" } +subxt = { path = "../subxt", version = "0.16.0" } sp-core = "4.0.0" async-std = { version = "1.9.0", features = ["attributes", "tokio1"] } which = "4.2.2"