From 89588cb27d9c10e746db4e65685a688f8f1dd70e Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Mon, 3 Jun 2024 17:29:03 +0200 Subject: [PATCH 1/9] refactor: parachain template --- .../parachain/pallets/template/src/lib.rs | 38 ++++++++++--------- .../parachain/pallets/template/src/mock.rs | 28 ++++++-------- .../parachain/pallets/template/src/weights.rs | 2 +- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/templates/parachain/pallets/template/src/lib.rs b/templates/parachain/pallets/template/src/lib.rs index 11587d1df426..d228d46667c4 100644 --- a/templates/parachain/pallets/template/src/lib.rs +++ b/templates/parachain/pallets/template/src/lib.rs @@ -1,8 +1,5 @@ #![cfg_attr(not(feature = "std"), no_std)] -/// Edit this file to define custom logic or remove it if it is not needed. -/// Learn more about FRAME and the core library of Substrate FRAME pallets: -/// pub use pallet::*; #[cfg(test)] @@ -16,6 +13,8 @@ pub mod weights; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html +// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html #[frame_support::pallet] pub mod pallet { use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; @@ -25,7 +24,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. + /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_runtime_types/index.html type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// A type representing the weights required by the dispatchables of this pallet. type WeightInfo: crate::weights::WeightInfo; } @@ -33,24 +34,23 @@ pub mod pallet { #[pallet::pallet] pub struct Pallet(_); - // The pallet's runtime storage items. - // https://docs.substrate.io/v3/runtime/storage + /// The pallet's storage items. + /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#storage + /// https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.storage.html #[pallet::storage] - // Learn more about declaring storage items: - // https://docs.substrate.io/v3/runtime/storage#declaring-storage-items pub type Something = StorageValue<_, u32>; - // Pallets use events to inform users when important changes are made. - // https://docs.substrate.io/v3/runtime/events-and-errors + /// Pallets use events to inform users when important changes are made. + /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#event-and-error #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - /// Event documentation should end with an array that provides descriptive names for event - /// parameters. [something, who] - SomethingStored(u32, T::AccountId), + /// We usually use passive tense for events. + SomethingStored { something: u32, who: T::AccountId }, } - // Errors inform users that something went wrong. + /// Errors inform users that something went wrong. + /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#event-and-error #[pallet::error] pub enum Error { /// Error names should be descriptive. @@ -62,9 +62,10 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet {} - // Dispatchable functions allows users to interact with the pallet and invoke state changes. - // These functions materialize as "extrinsics", which are often compared to transactions. - // Dispatchable functions must be annotated with a weight and must return a DispatchResult. + /// Dispatchable functions allows users to interact with the pallet and invoke state changes. + /// These functions materialize as "extrinsics", which are often compared to transactions. + /// Dispatchable functions must be annotated with a weight and must return a DispatchResult. + /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#dispatchables #[pallet::call] impl Pallet { /// An example dispatchable that takes a singles value as a parameter, writes the value to @@ -74,14 +75,15 @@ pub mod pallet { pub fn do_something(origin: OriginFor, something: u32) -> DispatchResultWithPostInfo { // Check that the extrinsic was signed and get the signer. // This function will return an error if the extrinsic is not signed. - // https://docs.substrate.io/v3/runtime/origins + // https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html let who = ensure_signed(origin)?; // Update storage. >::put(something); // Emit an event. - Self::deposit_event(Event::SomethingStored(something, who)); + Self::deposit_event(Event::SomethingStored { something, who }); + // Return a successful DispatchResultWithPostInfo Ok(().into()) } diff --git a/templates/parachain/pallets/template/src/mock.rs b/templates/parachain/pallets/template/src/mock.rs index ebb0598df97b..3ef731d32e76 100644 --- a/templates/parachain/pallets/template/src/mock.rs +++ b/templates/parachain/pallets/template/src/mock.rs @@ -1,25 +1,21 @@ -use frame_support::{derive_impl, parameter_types}; -use frame_system as system; -use sp_runtime::BuildStorage; - -type Block = frame_system::mocking::MockBlock; +use frame_support::{derive_impl, weights::constants::RocksDbWeight}; +use frame_system::{GenesisConfig, mocking::MockBlock}; +use sp_runtime::{traits::ConstU64, BuildStorage}; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - TemplateModule: crate::{Pallet, Call, Storage, Event}, + pub enum Test { + System: frame_system, + TemplateModule: crate, } ); -parameter_types! { - pub const SS58Prefix: u8 = 42; -} - #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] -impl system::Config for Test { - type Block = Block; +impl frame_system::Config for Test { + type Nonce = u64; + type Block = MockBlock; + type BlockHashCount = ConstU64<250>; + type DbWeight = RocksDbWeight; } impl crate::Config for Test { @@ -29,5 +25,5 @@ impl crate::Config for Test { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::::default().build_storage().unwrap().into() + GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/templates/parachain/pallets/template/src/weights.rs b/templates/parachain/pallets/template/src/weights.rs index 7c42936e09f2..5bfe28e8b71e 100644 --- a/templates/parachain/pallets/template/src/weights.rs +++ b/templates/parachain/pallets/template/src/weights.rs @@ -4,7 +4,7 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `` +//! HOSTNAME: `_`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: From 8addecb312a78ce77e45435a93cf38f54d86c683 Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Mon, 3 Jun 2024 17:57:06 +0200 Subject: [PATCH 2/9] fmt --- templates/parachain/pallets/template/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/parachain/pallets/template/src/mock.rs b/templates/parachain/pallets/template/src/mock.rs index 3ef731d32e76..022519fb66c5 100644 --- a/templates/parachain/pallets/template/src/mock.rs +++ b/templates/parachain/pallets/template/src/mock.rs @@ -1,5 +1,5 @@ use frame_support::{derive_impl, weights::constants::RocksDbWeight}; -use frame_system::{GenesisConfig, mocking::MockBlock}; +use frame_system::{mocking::MockBlock, GenesisConfig}; use sp_runtime::{traits::ConstU64, BuildStorage}; // Configure a mock runtime to test the pallet. From bc1b5a615aa0ab09ecb0a67bfd3cce290fbd75b4 Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Tue, 4 Jun 2024 15:43:18 +0200 Subject: [PATCH 3/9] docs: add two links --- templates/parachain/pallets/template/src/lib.rs | 4 ++++ templates/parachain/pallets/template/src/mock.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/parachain/pallets/template/src/lib.rs b/templates/parachain/pallets/template/src/lib.rs index d228d46667c4..390f2954ce4b 100644 --- a/templates/parachain/pallets/template/src/lib.rs +++ b/templates/parachain/pallets/template/src/lib.rs @@ -15,6 +15,10 @@ mod benchmarking; // https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html // https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html +// +// To see a full list of `pallet` macros and their use cases, see: +// https://paritytech.github.io/polkadot-sdk/master/pallet_example_kitchensink/index.html +// https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/index.html #[frame_support::pallet] pub mod pallet { use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; diff --git a/templates/parachain/pallets/template/src/mock.rs b/templates/parachain/pallets/template/src/mock.rs index 022519fb66c5..662ed055e176 100644 --- a/templates/parachain/pallets/template/src/mock.rs +++ b/templates/parachain/pallets/template/src/mock.rs @@ -4,7 +4,7 @@ use sp_runtime::{traits::ConstU64, BuildStorage}; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test { + pub struct Test { System: frame_system, TemplateModule: crate, } From 768af06fa75489451e6a7905820790ebc0f37071 Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Sat, 15 Jun 2024 18:11:02 +0200 Subject: [PATCH 4/9] chore: use construct runtime v2 --- prdoc/pr_4684.prdoc | 9 ++ .../parachain/pallets/template/Cargo.toml | 2 +- .../parachain/pallets/template/src/mock.rs | 27 +++-- templates/parachain/runtime/Cargo.toml | 2 +- templates/parachain/runtime/src/lib.rs | 99 ++++++++++++------- 5 files changed, 95 insertions(+), 44 deletions(-) create mode 100644 prdoc/pr_4684.prdoc diff --git a/prdoc/pr_4684.prdoc b/prdoc/pr_4684.prdoc new file mode 100644 index 000000000000..ce7608f88ba6 --- /dev/null +++ b/prdoc/pr_4684.prdoc @@ -0,0 +1,9 @@ +title: "Refactor of the parachain template" + +doc: + - audience: Runtime Dev + description: | + Introduce the construct runtime V2 to the parachain template runtime. In addition, url links in the parachain pallet + template now direct to the polkadot sdk docs. + +crates: [ ] diff --git a/templates/parachain/pallets/template/Cargo.toml b/templates/parachain/pallets/template/Cargo.toml index 6c549c2c4a9b..afb52987ba3b 100644 --- a/templates/parachain/pallets/template/Cargo.toml +++ b/templates/parachain/pallets/template/Cargo.toml @@ -22,7 +22,7 @@ scale-info = { version = "2.11.1", default-features = false, features = [ # frame deps frame-benchmarking = { path = "../../../../substrate/frame/benchmarking", default-features = false, optional = true } -frame-support = { path = "../../../../substrate/frame/support", default-features = false } +frame-support = { path = "../../../../substrate/frame/support", default-features = false, features = ["experimental"] } frame-system = { path = "../../../../substrate/frame/system", default-features = false } [dev-dependencies] diff --git a/templates/parachain/pallets/template/src/mock.rs b/templates/parachain/pallets/template/src/mock.rs index 662ed055e176..46e3117596f5 100644 --- a/templates/parachain/pallets/template/src/mock.rs +++ b/templates/parachain/pallets/template/src/mock.rs @@ -3,12 +3,27 @@ use frame_system::{mocking::MockBlock, GenesisConfig}; use sp_runtime::{traits::ConstU64, BuildStorage}; // Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub struct Test { - System: frame_system, - TemplateModule: crate, - } -); +#[frame_support::runtime] +mod test_runtime { + #[runtime::runtime] + #[runtime::derive( + RuntimeCall, + RuntimeEvent, + RuntimeError, + RuntimeOrigin, + RuntimeFreezeReason, + RuntimeHoldReason, + RuntimeSlashReason, + RuntimeLockId, + RuntimeTask + )] + pub struct Test; + + #[runtime::pallet_index(0)] + pub type System = frame_system; + #[runtime::pallet_index(1)] + pub type TemplateModule = crate; +} #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { diff --git a/templates/parachain/runtime/Cargo.toml b/templates/parachain/runtime/Cargo.toml index 059c79367969..48d9f6912894 100644 --- a/templates/parachain/runtime/Cargo.toml +++ b/templates/parachain/runtime/Cargo.toml @@ -35,7 +35,7 @@ pallet-parachain-template = { path = "../pallets/template", default-features = f frame-benchmarking = { path = "../../../substrate/frame/benchmarking", default-features = false, optional = true } frame-executive = { path = "../../../substrate/frame/executive", default-features = false } frame-metadata-hash-extension = { path = "../../../substrate/frame/metadata-hash-extension", default-features = false } -frame-support = { path = "../../../substrate/frame/support", default-features = false } +frame-support = { path = "../../../substrate/frame/support", default-features = false, features = ["experimental"] } frame-system = { path = "../../../substrate/frame/system", default-features = false } frame-system-benchmarking = { path = "../../../substrate/frame/system/benchmarking", default-features = false, optional = true } frame-system-rpc-runtime-api = { path = "../../../substrate/frame/system/rpc/runtime-api", default-features = false } diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index 987b88af8444..76a7fc42fed8 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -7,6 +7,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod apis; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; mod configs; mod weights; @@ -23,7 +25,6 @@ use sp_version::NativeVersion; use sp_version::RuntimeVersion; use frame_support::{ - construct_runtime, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, @@ -232,43 +233,69 @@ pub fn native_version() -> NativeVersion { } // Create the runtime by composing the FRAME pallets that were previously configured. -construct_runtime!( - pub enum Runtime { - // System support stuff. - System: frame_system = 0, - ParachainSystem: cumulus_pallet_parachain_system = 1, - Timestamp: pallet_timestamp = 2, - ParachainInfo: parachain_info = 3, - - // Monetary stuff. - Balances: pallet_balances = 10, - TransactionPayment: pallet_transaction_payment = 11, - - // Governance - Sudo: pallet_sudo = 15, - - // Collator support. The order of these 4 are important and shall not change. - Authorship: pallet_authorship = 20, - CollatorSelection: pallet_collator_selection = 21, - Session: pallet_session = 22, - Aura: pallet_aura = 23, - AuraExt: cumulus_pallet_aura_ext = 24, - - // XCM helpers. - XcmpQueue: cumulus_pallet_xcmp_queue = 30, - PolkadotXcm: pallet_xcm = 31, - CumulusXcm: cumulus_pallet_xcm = 32, - MessageQueue: pallet_message_queue = 33, - - // Template - TemplatePallet: pallet_parachain_template = 50, - } -); +#[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 ParachainSystem = cumulus_pallet_parachain_system ; + #[runtime::pallet_index(2)] + pub type Timestamp = pallet_timestamp; + #[runtime::pallet_index(3)] + pub type ParachainInfo = parachain_info; + + // Monetary stuff. + #[runtime::pallet_index(10)] + pub type Balances = pallet_balances; + #[runtime::pallet_index(11)] + pub type TransactionPayment = pallet_transaction_payment; + + // Governance + #[runtime::pallet_index(15)] + pub type Sudo = pallet_sudo; + + // Collator support. The order of these 4 are important and shall not change. + #[runtime::pallet_index(20)] + pub type Authorship = pallet_authorship; + #[runtime::pallet_index(21)] + pub type CollatorSelection = pallet_collator_selection; + #[runtime::pallet_index(22)] + pub type Session = pallet_session; + #[runtime::pallet_index(23)] + pub type Aura = pallet_aura; + #[runtime::pallet_index(24)] + pub type AuraExt = cumulus_pallet_aura_ext; + + // XCM helpers. + #[runtime::pallet_index(30)] + pub type XcmpQueue = cumulus_pallet_xcmp_queue; + #[runtime::pallet_index(31)] + pub type PolkadotXcm = pallet_xcm; + #[runtime::pallet_index(32)] + pub type CumulusXcm = cumulus_pallet_xcm; + #[runtime::pallet_index(33)] + pub type MessageQueue = pallet_message_queue; + #[runtime::pallet_index(50)] + + // Include the custom logic from the pallet-template in the runtime. + pub type TemplatePallet = pallet_parachain_template; +} cumulus_pallet_parachain_system::register_validate_block! { Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, } - -#[cfg(feature = "runtime-benchmarks")] -mod benchmarks; From d59e4efb88e1944266636e44ab24bf2a1c6c116d Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Sat, 15 Jun 2024 18:50:35 +0200 Subject: [PATCH 5/9] fix: prdoc --- prdoc/pr_4684.prdoc | 10 +++++++--- templates/parachain/runtime/src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/prdoc/pr_4684.prdoc b/prdoc/pr_4684.prdoc index ce7608f88ba6..b1c429c57822 100644 --- a/prdoc/pr_4684.prdoc +++ b/prdoc/pr_4684.prdoc @@ -3,7 +3,11 @@ title: "Refactor of the parachain template" doc: - audience: Runtime Dev description: | - Introduce the construct runtime V2 to the parachain template runtime. In addition, url links in the parachain pallet - template now direct to the polkadot sdk docs. + Introduce the construct runtime V2 to the parachain template runtime. In addition, url links in the parachain pallet + template now direct to the polkadot sdk docs. -crates: [ ] +crates: + - name: pallet-parachain-template + bump: none + - name: parachain-template-runtime + bump: none diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index 76a7fc42fed8..dfa090a6ff05 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -291,7 +291,7 @@ mod runtime { pub type MessageQueue = pallet_message_queue; #[runtime::pallet_index(50)] - // Include the custom logic from the pallet-template in the runtime. + // Template pub type TemplatePallet = pallet_parachain_template; } From 6589d13c1f9b38ab2f021ddf531d6cde6407badc Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Sat, 15 Jun 2024 18:54:15 +0200 Subject: [PATCH 6/9] fmt --- templates/parachain/runtime/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index dfa090a6ff05..ccbf9b3339be 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -24,11 +24,9 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use frame_support::{ - weights::{ - constants::WEIGHT_REF_TIME_PER_SECOND, Weight, WeightToFeeCoefficient, - WeightToFeeCoefficients, WeightToFeePolynomial, - }, +use frame_support::weights::{ + constants::WEIGHT_REF_TIME_PER_SECOND, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, + WeightToFeePolynomial, }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; @@ -252,7 +250,7 @@ mod runtime { #[runtime::pallet_index(0)] pub type System = frame_system; #[runtime::pallet_index(1)] - pub type ParachainSystem = cumulus_pallet_parachain_system ; + pub type ParachainSystem = cumulus_pallet_parachain_system; #[runtime::pallet_index(2)] pub type Timestamp = pallet_timestamp; #[runtime::pallet_index(3)] From a25e7a36a6bba7053f3ee0320208cc50024ccdcd Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Sun, 16 Jun 2024 18:13:13 +0200 Subject: [PATCH 7/9] docs: add '<' to links --- .../parachain/pallets/template/src/lib.rs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/templates/parachain/pallets/template/src/lib.rs b/templates/parachain/pallets/template/src/lib.rs index 390f2954ce4b..0420e2b90821 100644 --- a/templates/parachain/pallets/template/src/lib.rs +++ b/templates/parachain/pallets/template/src/lib.rs @@ -13,12 +13,12 @@ pub mod weights; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html -// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html +// +// // // To see a full list of `pallet` macros and their use cases, see: -// https://paritytech.github.io/polkadot-sdk/master/pallet_example_kitchensink/index.html -// https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/index.html +// +// #[frame_support::pallet] pub mod pallet { use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; @@ -28,7 +28,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. - /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_runtime_types/index.html + /// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A type representing the weights required by the dispatchables of this pallet. @@ -39,13 +39,13 @@ pub mod pallet { pub struct Pallet(_); /// The pallet's storage items. - /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#storage - /// https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/attr.storage.html + /// + /// #[pallet::storage] pub type Something = StorageValue<_, u32>; /// Pallets use events to inform users when important changes are made. - /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#event-and-error + /// #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { @@ -54,7 +54,7 @@ pub mod pallet { } /// Errors inform users that something went wrong. - /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#event-and-error + /// #[pallet::error] pub enum Error { /// Error names should be descriptive. @@ -69,7 +69,7 @@ pub mod pallet { /// Dispatchable functions allows users to interact with the pallet and invoke state changes. /// These functions materialize as "extrinsics", which are often compared to transactions. /// Dispatchable functions must be annotated with a weight and must return a DispatchResult. - /// https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html#dispatchables + /// #[pallet::call] impl Pallet { /// An example dispatchable that takes a singles value as a parameter, writes the value to @@ -79,7 +79,7 @@ pub mod pallet { pub fn do_something(origin: OriginFor, something: u32) -> DispatchResultWithPostInfo { // Check that the extrinsic was signed and get the signer. // This function will return an error if the extrinsic is not signed. - // https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_origin/index.html + // let who = ensure_signed(origin)?; // Update storage. From 47a87794c0e8157c3ec0bd596a9cc802c4fc3791 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:15:35 +0800 Subject: [PATCH 8/9] Update templates/parachain/pallets/template/Cargo.toml --- templates/parachain/pallets/template/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/parachain/pallets/template/Cargo.toml b/templates/parachain/pallets/template/Cargo.toml index afb52987ba3b..6c549c2c4a9b 100644 --- a/templates/parachain/pallets/template/Cargo.toml +++ b/templates/parachain/pallets/template/Cargo.toml @@ -22,7 +22,7 @@ scale-info = { version = "2.11.1", default-features = false, features = [ # frame deps frame-benchmarking = { path = "../../../../substrate/frame/benchmarking", default-features = false, optional = true } -frame-support = { path = "../../../../substrate/frame/support", default-features = false, features = ["experimental"] } +frame-support = { path = "../../../../substrate/frame/support", default-features = false } frame-system = { path = "../../../../substrate/frame/system", default-features = false } [dev-dependencies] From 693f825c9fe6c339e7c0b6d8db2b97a172041091 Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Tue, 18 Jun 2024 08:53:07 +0200 Subject: [PATCH 9/9] fix: formatting template in runtime config --- templates/parachain/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index ccbf9b3339be..6e6491a19adf 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -287,9 +287,9 @@ mod runtime { pub type CumulusXcm = cumulus_pallet_xcm; #[runtime::pallet_index(33)] pub type MessageQueue = pallet_message_queue; - #[runtime::pallet_index(50)] // Template + #[runtime::pallet_index(50)] pub type TemplatePallet = pallet_parachain_template; }