【发布时间】:2021-11-03 21:05:32
【问题描述】:
我知道这可能很容易,但对于 Rust 和 Substrate 新手来说却不是。
我正在尝试实现基板教程中的 POE 模板。 tutorial
当我尝试使用其他 POE 函数编译模板/lib.rs 并枚举它时出现以下错误。
当我尝试使用cargo build --release编译时
error: Missing `#[pallet::config]`
--> /Users/pavlos/projects/substrate-node/substrate-node-
template/runtime/src/lib.rs:12:1
|
12 | / pub mod pallet {
13 | | use frame_support::pallet_prelude::*;
14 | | use frame_system::pallet_prelude::*;
15 | | use sp_std::vec::Vec; // Step 3.1 will include this in `Cargo.toml`
|
94 | | }
95 | | }
| |_^
error: could not compile `node-template-runtime` due to previous error
不明白上面的微存在pub mod pallet {}
#[frame_support::pallet]
pub mod pallet {
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_std::vec::Vec;
#[pallet::config]
pub trait Config: frame_system::Config {
type Event: From<Event<Self>> + IsType<<Self as
frame_system::Config>::Event>;
}
已编辑
【问题讨论】:
-
在this pallet template 中,配置特征在模块内部。您可以尝试在模块中移动配置。
-
@forgetso 我更新了这个问题。它没有很好地描述。配置宏在模块内。
-
我已经与教程仓库进行了交叉检查,我所拥有的内容是相同的。 substrate
-
你使用的是教程中提到的node吗?
-
@forgetso 是的,我在教程中使用了参考存储库,但它不起作用。但是我尝试了 org node-template,正如我的答案中所发布的,它工作正常。我错过了这个`use frame_support::{dispatch::DispatchResult,pallet_prelude::*};`