Questions tagged [macro]
The macro tag has no usage guidance.
14
questions
0
votes
0
answers
19
views
How does the benchmarking code add_benchmarks! work on the runtime?
I am trying to understand the runtime-benchmarks gated code on the runtime/src/lib.rs and I realize that we need to "list" and "add" benchmarks that we want to perform : https://...
3
votes
2
answers
111
views
What does #[pallet::compact] do?
What does #[pallet::compact] do?
1
vote
2
answers
100
views
The ensure! macro with a false condition doesn't make an extrinsic fail, why?
In the code of the Nicks pallet, there is some logic to make sure the name passed as parameter is long enough.
ensure!(bounded_name.len() >= T::MinLength::get() as usize, Error::<T>::TooShort)...
2
votes
1
answer
34
views
Invalid generic declaration when using FRAME macro pallet::error
I want to add custom error types to a working pallet (permalink duniter-wot/src/lib.rs). In this current state, cargo check pass successfully.
According to Substrate documentation frame-macros/#...
1
vote
3
answers
37
views
Mixing FRAME macros in a single runtime or pallet
There has been an evolution in how one defines pallets in the Substrate framework over time, and this has left the ecosystem in a state where useful pallets exist in different versions.
This begs the ...
1
vote
1
answer
110
views
Why getter function don't return Result type?
I'm using #[pallet::getter(fn get_balance)] for my StorageMap to generate a getter function, but it returns pure u64 instead of Result type. What is the way to handle missing key cases then?
#[...
0
votes
1
answer
71
views
Error in Substrate "use macros in a custom pallet" tutorial
I'm currently trying this substrate tutorial, but it got stuck.
Following the tutorial, I coded lib.rs file like this.
#![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
#[...
1
vote
1
answer
25
views
Organize Runtime into modules
In the examples I've seen so far I can see that all the [pallet::*] definitions are within the #[frame_support::pallet] module.
Is there any way we can split these into separate modules? For example ...
4
votes
1
answer
82
views
Expose StorageItems to other pallets whose types are bound on an instance of my pallet
I have a pallet pallet-a whose StorageItem should be read/written by other pallets. Let's say that StorageItem is
#[pallet::storage]
#[pallet::getter(fn get_commitments)]
pub type Commits&...
3
votes
1
answer
83
views
Why do runtime APIs have a block_height parameter on the client side but not on the runtime side?
Runtime APIs are declared using the decl_runtime_api! macro. This is typically in a primitives crate. For example:
decl_runtime_apis! {
pub trait ExampleApi {
fn get_info(param1: u32, ...
1
vote
2
answers
159
views
Problems With `app_crypto!` Macro
I have the following error while building:
error[E0599]: no function or associated item named `generate_with_phrase` found for struct `crain_pow::app::Pair` in the current scope
--> node/src/...
3
votes
1
answer
37
views
Adding PaysFee to #[pallet::weight("")] produces unexpected token error
I'm working with the node template and I want a particular type of extrinsic to not have to pay a fee. I followed these instructions but whenever I add another value to the "pallet::weight(10_000)...
7
votes
2
answers
86
views
What are the differences between using declarative and attribute macros in FRAME?
What's the main difference (besides the code) between using the decl_storage! macro rule and using the [pallet::storage] macro?
I've seen pretty much everyone using macro rules, but on the latest ...
6
votes
2
answers
227
views
What is the role of `#[scale_info(skip_type_params(T))]`?
#[derive(Encode,Decode,TypeInfo)
#[scale_info(skip_type_params(T))]
Pub struct Asset<T:Config> {
Id:###
Name:##
}
So in the above example if you don't include the second macro. The compiler ...