substrate-deps
is a (experimental) command line tool for managing Parity Substrate runtime module dependencies.
It allows adding a new module to your runtime, and applying a default configuration so you can start hacking right away.
It uses metadata defined in the Cargo.toml manifest of Susbstrate runtime modules.
The following commands are available / planned:
Disclaimer: This is a work in progress ! There are currently a few crucial pieces that are missing / unfinished for this tool to work properly: - [ ] Semantic versioning for Substrate SRML modules - [ ] Substrate SRML modules published on crates.io, or an alternative registry (*) - [ ] cargo loads dependencies from crates.io instead of alt. registry when fetching a crate from an alt. registry
(*) For now, an alternative registry with Substrate SRML modules is available at https://dl.cloudsmith.io/public/steve-degosserie/substrate-mods/cargo/index.git
Install substrate-deps
locally with:
bash
cargo install substrate-deps
substrate-deps add
Add a new module dependency to your Substrate runtime's Cargo.toml
.
To add an hypothetical scml-template-module
that depends on the srml-balances
module:
```sh
$ # Add the module scml-template-module to the runtime whose manifest is specified as argument, using the specified alternative registry.
$ substrate-deps add scml-template-module --manifest-path ../substrate-package/substrate-node-template/runtime/Cargo.toml --registry substrate-mods
Using registry 'substrate-mods' at: https://dl.cloudsmith.io/public/steve-degosserie/substrate-mods/cargo/index.git Updating 'https://dl.cloudsmith.io/public/steve-degosserie/substrate-mods/cargo/index.git' index No metadata found for module srml-balances Added module srml-balances v2.0.0 configuration in your node runtime. Added module scml-template-module v0.2.1 as dependency in your node runtime manifest. Added module scml-template-module v0.2.1 configuration in your node runtime. ```
```plain
$ substrate-deps add --help
USAGE:
substrate-deps add [FLAGS] [OPTIONS]
FLAGS: -h, --help Prints help information -q, --quiet No output printed to stdout -v, --verbose Use verbose output -V, --version Prints version information
OPTIONS:
--manifest-path
ARGS:
This command allows you to add a new module dependency to your Substrate runtime's Cargo.toml manifest file. For now, <module>
should be the name of a module hosted on an alternative metionned in the <registry>
argument. substrate-deps add
will fetch the dmoeul, parse its metadata if any, and add it plus any related depencies, as well as apply default module & trait configuration to your runtime's libs.rs
file.
substrate-deps graph
Generates a dependency graph of the modules used by your Substrate runtime.
This command output a dependency graph for graphviz, please make sure your have it install to be able to generate an image file with the instruction below.
sh
$ # Generate a dependency graph of the modules used by the runtime whose manifest is specified as argument and pipe it to the dot command to generate an image file.
$ substrate-deps graph --manifest-path ../substrate-package/substrate-node-template/runtime/Cargo.toml | dot -Tpng > graph.png
```plain $ substrate-deps graph --help substrate-deps-graph Generate a graph of the Substrate runtime module dependencies.
USAGE: substrate-deps graph [FLAGS] [OPTIONS]
FLAGS: -h, --help Prints help information -I, --include-versions Include the dependency version on nodes -q, --quiet No output printed to stdout -v, --verbose Use verbose output -V, --version Prints version information
OPTIONS:
--manifest-path
substrate-deps
uses metadata defined in module's Cargo.toml manifest to know about module trait dependencies, and to be be able to generate a default configuration for the module's configuration trait.
The metadata are defined in [package.metadata.substrate]
table as follows:
```toml
[package.metadata.substrate]
substrate_version = '2.0'
module_alias = 'template'
module_label = 'Template Module for Substrate'
icon = 'gear.png'
module_categories = ['example']
moduledepsdefaults = ['Balances:srml-balances']
traitdepsdefaults = ['Currency=Balances','Event=Event']
modulecfgdefaults = ['Module','Call','Storage','Event
This project is licensed under either of
at your option.