Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tangle subxt #505

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ members = [
"precompiles/proxy",
"precompiles/preimage",
"precompiles/jobs",
"tangle-subxt"
# "relayer-gadget",
# "relayer-gadget/cli",
]
Expand Down
29 changes: 29 additions & 0 deletions tangle-subxt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "tangle-subxt"
version ={ workspace = true }
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[dependencies]
parity-scale-codec = { workspace = true, optional = true }
scale-info = { workspace = true, optional = true }
subxt = { version = "0.31.0", optional = true }
subxt-metadata = { version = "0.31.0", optional = true }
subxt-codegen = { version = "0.31.0", optional = true }
serde_json = "1"
syn = { version = "2", features = ["full", "parsing"], optional = true }


[features]
default = [
"subxt",
"subxt-codegen",
"subxt-metadata",
"parity-scale-codec",
"scale-info",
"syn"
]

33 changes: 33 additions & 0 deletions tangle-subxt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<h1 align="center">Tangle-Subxt</h1>

<p align="center">
<strong>Rust interface to interact with tangle node via RPC</strong>
<br />
</p>

<br />

### Downloading metadata from a Substrate node

Use the [`subxt-cli`](https://lib.rs/crates/subxt-cli) tool to download the metadata for your target runtime from a node.

1. Install:
```bash
cargo install subxt-cli
```

2. To Save the metadata of `tangle`:
Run the release build of the `tangle` node, then on another terminal run:

```bash
subxt metadata -f bytes > ./metadata/tangle-runtime.scale
```

3. Generating the subxt code from the metadata:

```bash
subxt codegen --file metadata/tangle-runtime.scale > src/tangle_runtime.rs
```



Binary file added tangle-subxt/metadata/tangle-runtime.scale
Binary file not shown.
14 changes: 14 additions & 0 deletions tangle-subxt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![deny(
trivial_casts,
trivial_numeric_casts,
stable_features,
non_shorthand_field_patterns,
renamed_and_removed_lints,
unsafe_code,
clippy::exhaustive_enums
)]
#![allow(clippy::all, clippy::exhaustive_enums)]
pub mod tangle_runtime;
pub use parity_scale_codec;
pub use scale_info;
pub use subxt;
Loading
Loading