Files
pezkuwi-subxt/substrate/frame/support/Cargo.toml
T
gupnik 82f3c3e2e8 Construct Runtime v2 (#1378)
Moved from https://github.com/paritytech/substrate/pull/14788

----

Fixes https://github.com/paritytech/polkadot-sdk/issues/232

This PR introduces outer-macro approach for `construct_runtime` as
discussed in the linked issue. It looks like the following:
```rust
#[frame_support::runtime]
mod runtime {
	#[runtime::runtime]
        #[runtime::derive(
		RuntimeCall,
		RuntimeEvent,
		RuntimeError,
		RuntimeOrigin,
		RuntimeFreezeReason,
		RuntimeHoldReason,
		RuntimeSlashReason,
		RuntimeLockId,
                RuntimeTask,
	)]
	pub struct Runtime;

	#[runtime::pallet_index(0)]
	pub type System = frame_system;

	#[runtime::pallet_index(1)]
	pub type Timestamp = pallet_timestamp;

	#[runtime::pallet_index(2)]
	pub type Aura = pallet_aura;

	#[runtime::pallet_index(3)]
	pub type Grandpa = pallet_grandpa;

	#[runtime::pallet_index(4)]
	pub type Balances = pallet_balances;

	#[runtime::pallet_index(5)]
	pub type TransactionPayment = pallet_transaction_payment;

	#[runtime::pallet_index(6)]
	pub type Sudo = pallet_sudo;

	// Include the custom logic from the pallet-template in the runtime.
	#[runtime::pallet_index(7)]
	pub type TemplateModule = pallet_template;
}
```

## Features
- `#[runtime::runtime]` attached to a struct defines the main runtime
- `#[runtime::derive]` attached to this struct defines the types
generated by runtime
- `#[runtime::pallet_index]` must be attached to a pallet to define its
index
- `#[runtime::disable_call]` can be optionally attached to a pallet to
disable its calls
- `#[runtime::disable_unsigned]` can be optionally attached to a pallet
to disable unsigned calls
- A pallet instance can be defined as `TemplateModule:
pallet_template<Instance>`
- An optional attribute can be defined as
`#[frame_support::runtime(legacy_ordering)]` to ensure that the order of
hooks is same as the order of pallets (and not based on the
pallet_index). This is to support legacy runtimes and should be avoided
for new ones.

## Todo
- [x] Update the latest syntax in kitchensink and tests
- [x] Update UI tests
- [x] Docs

## Extension
- Abstract away the Executive similar to
https://github.com/paritytech/substrate/pull/14742
- Optionally avoid the need to specify all runtime types (TBD)

---------

Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: Nikhil Gupta <>
2024-03-13 07:01:01 +00:00

128 lines
4.2 KiB
TOML

[package]
name = "frame-support"
version = "28.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage = "https://substrate.io"
repository.workspace = true
description = "Support code for the runtime."
readme = "README.md"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
array-bytes = { version = "6.1", default-features = false }
serde = { features = ["alloc", "derive"], workspace = true }
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
"derive",
"max-encoded-len",
] }
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
] }
frame-metadata = { version = "16.0.0", default-features = false, features = [
"current",
] }
sp-api = { path = "../../primitives/api", default-features = false, features = [
"frame-metadata",
] }
sp-std = { path = "../../primitives/std", default-features = false }
sp-io = { path = "../../primitives/io", default-features = false }
sp-runtime = { path = "../../primitives/runtime", default-features = false, features = [
"serde",
] }
sp-tracing = { path = "../../primitives/tracing", default-features = false }
sp-core = { path = "../../primitives/core", default-features = false }
sp-arithmetic = { path = "../../primitives/arithmetic", default-features = false }
sp-inherents = { path = "../../primitives/inherents", default-features = false }
sp-staking = { path = "../../primitives/staking", default-features = false }
sp-weights = { path = "../../primitives/weights", default-features = false }
sp-debug-derive = { path = "../../primitives/debug-derive", default-features = false }
sp-metadata-ir = { path = "../../primitives/metadata-ir", default-features = false }
tt-call = "1.0.8"
macro_magic = "0.5.0"
frame-support-procedural = { path = "procedural", default-features = false }
paste = "1.0"
sp-state-machine = { path = "../../primitives/state-machine", default-features = false, optional = true }
bitflags = "1.3"
impl-trait-for-tuples = "0.2.2"
smallvec = "1.11.0"
log = { workspace = true }
sp-crypto-hashing-proc-macro = { path = "../../primitives/crypto/hashing/proc-macro" }
k256 = { version = "0.13.1", default-features = false, features = ["ecdsa"] }
environmental = { version = "1.1.4", default-features = false }
sp-genesis-builder = { path = "../../primitives/genesis-builder", default-features = false }
serde_json = { features = ["alloc"], workspace = true }
docify = "0.2.7"
static_assertions = "1.1.0"
aquamarine = { version = "0.5.0" }
[dev-dependencies]
assert_matches = "1.3.0"
pretty_assertions = "1.2.1"
sp-timestamp = { path = "../../primitives/timestamp", default-features = false }
frame-system = { path = "../system" }
sp-crypto-hashing = { path = "../../primitives/crypto/hashing" }
[features]
default = ["std"]
std = [
"codec/std",
"environmental/std",
"frame-metadata/std",
"frame-support-procedural/std",
"frame-system/std",
"k256/std",
"log/std",
"scale-info/std",
"serde/std",
"serde_json/std",
"sp-api/std",
"sp-arithmetic/std",
"sp-core/std",
"sp-debug-derive/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-io/std",
"sp-metadata-ir/std",
"sp-runtime/std",
"sp-staking/std",
"sp-state-machine/std",
"sp-std/std",
"sp-timestamp/std",
"sp-tracing/std",
"sp-weights/std",
]
runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
]
try-runtime = [
"frame-system/try-runtime",
"sp-debug-derive/force-debug",
"sp-runtime/try-runtime",
]
experimental = [
"frame-support-procedural/experimental",
]
# By default some types have documentation, `no-metadata-docs` allows to reduce the documentation
# in the metadata.
no-metadata-docs = [
"frame-support-procedural/no-metadata-docs",
"sp-api/no-metadata-docs",
]
# By default some types have documentation, `full-metadata-docs` allows to add documentation to
# more types in the metadata.
full-metadata-docs = ["scale-info/docs"]
# Generate impl-trait for tuples with the given number of tuples. Will be needed as the number of
# pallets in a runtime grows. Does increase the compile time!
tuples-96 = ["frame-support-procedural/tuples-96"]
tuples-128 = ["frame-support-procedural/tuples-128"]