mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 22:45:40 +00:00
Pallet proc macro doc improvements (#7955)
* Fix weight syntax in comments * Mention to add `IsType` bound * Link to subsee * Fix link * Update frame/support/procedural/src/pallet/parse/call.rs Co-authored-by: David <dvdplm@gmail.com> * Apply review suggestion from @dvdplm, make StorageInstance doc link * fix ui test Co-authored-by: David <dvdplm@gmail.com> Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -57,7 +57,7 @@ pub struct CallVariantDef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Attributes for functions in call impl block.
|
/// Attributes for functions in call impl block.
|
||||||
/// Parse for `#[pallet::weight = expr]`
|
/// Parse for `#[pallet::weight(expr)]`
|
||||||
pub struct FunctionAttr {
|
pub struct FunctionAttr {
|
||||||
weight: syn::Expr,
|
weight: syn::Expr,
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ impl CallDef {
|
|||||||
|
|
||||||
if call_var_attrs.len() != 1 {
|
if call_var_attrs.len() != 1 {
|
||||||
let msg = if call_var_attrs.is_empty() {
|
let msg = if call_var_attrs.is_empty() {
|
||||||
"Invalid pallet::call, require weight attribute i.e. `#[pallet::weight = $expr]`"
|
"Invalid pallet::call, requires weight attribute i.e. `#[pallet::weight($expr)]`"
|
||||||
} else {
|
} else {
|
||||||
"Invalid pallet::call, too many weight attributes given"
|
"Invalid pallet::call, too many weight attributes given"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1388,8 +1388,9 @@ pub mod pallet_prelude {
|
|||||||
/// ### Macro expansion
|
/// ### Macro expansion
|
||||||
///
|
///
|
||||||
/// For each storage item the macro generates a struct named
|
/// For each storage item the macro generates a struct named
|
||||||
/// `_GeneratedPrefixForStorage$NameOfStorage`, implements `StorageInstance` on it using the
|
/// `_GeneratedPrefixForStorage$NameOfStorage`, and implements [`StorageInstance`](traits::StorageInstance)
|
||||||
/// pallet and storage name. It then uses it as the first generic of the aliased type.
|
/// on it using the pallet and storage name. It then uses it as the first generic of the aliased
|
||||||
|
/// type.
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// The macro implements the function `storage_metadata` on `Pallet` implementing the metadata for
|
/// The macro implements the function `storage_metadata` on `Pallet` implementing the metadata for
|
||||||
@@ -1909,7 +1910,8 @@ pub mod pallet_prelude {
|
|||||||
/// ```
|
/// ```
|
||||||
/// 5. **migrate Config**: move trait into the module with
|
/// 5. **migrate Config**: move trait into the module with
|
||||||
/// * all const in decl_module to `#[pallet::constant]`
|
/// * all const in decl_module to `#[pallet::constant]`
|
||||||
/// 6. **migrate decl_module**: write:
|
/// * add bound `IsType<<Self as frame_system::Config>::Event>` to `type Event`
|
||||||
|
/// 7. **migrate decl_module**: write:
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// #[pallet::hooks]
|
/// #[pallet::hooks]
|
||||||
/// impl<T: Config> Hooks for Pallet<T> {
|
/// impl<T: Config> Hooks for Pallet<T> {
|
||||||
@@ -1996,8 +1998,9 @@ pub mod pallet_prelude {
|
|||||||
///
|
///
|
||||||
/// ## Checking upgrade guidelines:
|
/// ## Checking upgrade guidelines:
|
||||||
///
|
///
|
||||||
/// * compare metadata. This checks for:
|
/// * compare metadata. Use [subsee](https://github.com/ascjones/subsee) to fetch the metadata
|
||||||
/// * call, names, signature, doc
|
/// and do a diff of the resulting json before and after migration. This checks for:
|
||||||
|
/// * call, names, signature, docs
|
||||||
/// * event names, docs
|
/// * event names, docs
|
||||||
/// * error names, docs
|
/// * error names, docs
|
||||||
/// * storage names, hasher, prefixes, default value
|
/// * storage names, hasher, prefixes, default value
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
error: Invalid pallet::call, require weight attribute i.e. `#[pallet::weight = $expr]`
|
error: Invalid pallet::call, requires weight attribute i.e. `#[pallet::weight($expr)]`
|
||||||
--> $DIR/call_missing_weight.rs:17:3
|
--> $DIR/call_missing_weight.rs:17:3
|
||||||
|
|
|
|
||||||
17 | fn foo(origin: OriginFor<T>) -> DispatchResultWithPostInfo {}
|
17 | fn foo(origin: OriginFor<T>) -> DispatchResultWithPostInfo {}
|
||||||
|
|||||||
Reference in New Issue
Block a user