When updating to use the latest Substrate with V14 metadata, your runtime will fail to compile.
The following steps are required to make your pallets/runtime compatible. The compiler will guide you...
- Remove any
#[pallet::metadata(..)]
attributes from the pallet Event definition. - Add
scale-info
dependency to pallet and runtime crates:scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
std = [ "scale-info/std" ]
- Derive
scale_info::TypeInfo
for any types which deriveDecode, Encode
.- If the type is in a separate crate to the pallet, add the
scale-info
dependency as above.
- If the type is in a separate crate to the pallet, add the
- Update any pallet Call variant constructors to use named structs (previously unnamed tuple structs).
- Update the metadata runtime API call:
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into())
}
}
See the cumulus and polkadot PRs (linked below) for examples of the above conversion.
- Substrate PR: paritytech/substrate#8615
- Polkadot PR: paritytech/polkadot#3336
- Cumulus PR: paritytech/cumulus#564
- scale-info repo: https://github.com/paritytech/scale-info/
- frame-metadata repo: https://github.com/paritytech/frame-metadata/
Shouldn't
scale-info
version be1.0
?