我正在参加Substrate Kitties研讨会。在1/Viewing a Storage Mapping
中,我无法访问Polkadot UI的kitties
标签上的#extrinsics
模块:
我尝试多次重新加载。这是我的kitties.rs
(可以正常编译):
use support::{decl_storage, decl_module, StorageMap, dispatch::Result};
use system::ensure_signed;
pub trait Trait: balances::Trait {}
decl_storage! {
trait Store for Module<T: Trait> as KittyStorage {
Value: map T::AccountId => u64;
}
}
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
fn set_value(origin, value: u64) -> Result {
let sender = ensure_signed(origin)?;
<Value<T>>::insert(sender, value);
Ok(())
}
}
}
我在lib.rs
/// Used for the Substrate Kitties in `./kitties.rs`
mod kitties;
[...]
/// Used for the Substrate Kitties in `./kitties.rs`
impl kitties::Trait for Runtime {}
并将其添加到运行时。
construct_runtime!(
pub enum Runtime with Log(InternalLog: DigestItem<Hash, AuthorityId, AuthoritySignature>) where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{default, Log(ChangesTrieRoot)},
Timestamp: timestamp::{Module, Call, Storage, Config<T>, Inherent},
Consensus: consensus::{Module, Call, Storage, Config<T>, Log(AuthoritiesChange), Inherent},
Aura: aura::{Module},
Indices: indices,
Balances: balances,
Sudo: sudo,
Kitties: kitties::{Module, Call, Storage},
// Used for the module template in `./template.rs`
TemplateModule: template::{Module, Call, Storage, Event<T>},
ExampleModule: substrate_module_template::{Module, Call, Storage, Event<T>},
}
);
我想念什么?将我的模块注册到Substrate运行时还需要什么?
答案 0 :(得分:1)
这里的问题可能是您的链尚未升级运行时,因此您无法在现有链上看到新模块。当您在运行时开发和注册新模块时运行链时,会发生这种情况。
要解决此问题并确保所有模块都已正确注册,您将必须清除链并使用最新代码启动新的开发链。要清除,请运行:
❯ target/release/substratekitties purge-chain --dev
重新启动新链:
❯ target/release/substratekitties --dev
“小猫”模块应该在“外部”选项卡中可用。