Expand description
Topsoil
§Usage
This crate is organized into 3 stages:
- preludes:
prelude,testing_prelude,runtime::prelude,benchmarking::prelude, andweights_prelude. - domain-specific modules, like
traits,hashing,arithmeticandderive. - Accessing frame/substrate dependencies directly:
deps.
The main intended use of this crate is through preludes, which re-export most of the components
needed for pallet development. Domain-specific modules serve as a backup for organization, and
deps provides direct access to all dependencies if needed.
§Example Usage
use topsoil;
#[topsoil::pallet]
pub mod pallet {
use topsoil::prelude::*;
// ^^ using the prelude!
#[pallet::config]
pub trait Config: topsoil_core::system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
}
#[cfg(test)]
pub mod tests {
use topsoil::testing_prelude::*;
}
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking {
use topsoil::benchmarking::prelude::*;
}
pub mod runtime {
use topsoil::runtime::prelude::*;
}§Features
This crate uses a runtime feature to include all types and tools needed to build FRAME-based
runtimes. For runtime development, import it as:
topsoil = { version = "foo", features = ["runtime"] }If you just want to build a pallet instead, import it as
topsoil = { version = "foo" }§Prelude Relationships
The preludes have overlapping imports for convenience:
testing_preludeincludespreludeandruntime::preluderuntime::preludeincludespreludebenchmarking::preludeincludesprelude
§Naming
Please note that this crate can only be imported as topsoil. This is due
to compatibility matters with topsoil-core.
A typical pallet’s Cargo.toml using this crate looks like:
ⓘ
[dependencies]
codec = { features = ["max-encoded-len"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
topsoil = { workspace = true, features = ["runtime"] }
[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"topsoil/std",
]
runtime-benchmarks = [
"topsoil/runtime-benchmarks",
]
try-runtime = [
"topsoil/try-runtime",
]Re-exports§
pub use topsoil_core::pallet;pub use topsoil_core::pallet_macros::import_section;pub use topsoil_core::pallet_macros::pallet_section;pub use log;
Modules§
- account
- All account management related traits.
- arithmetic
- The arithmetic types used for safe math.
- deps
- Access to all of the dependencies of this crate. In case the prelude re-exports are not enough, this module can be used.
- derive
- All derive macros used in frame.
- hashing
- All hashing related components.
- pallet_
macros - Macros used within the main
palletmacro. - prelude
- The main prelude of FRAME.
- runtime
- All of the types and tools needed to build FRAME-based runtimes.
- testing_
prelude - The main testing prelude of FRAME.
- token
- All token related types and traits.
- traits
- All traits often used in FRAME pallets.
- transaction
- This is already part of the
prelude. - weights_
prelude - Prelude to be included in the
weight.rsof each pallet.