外部选项卡中没有可用的 `kitties` 模块
No `kitties` module available in the extrinsics tab
我正在关注 Substrate Kitties 研讨会。在 1/Viewing a Storage Mapping
中,我无法在 Polkadot UI 的 #extrinsics
选项卡上访问我的 kitties
模块:
我试过多次重新加载它。这是我的 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 运行时注册我的模块还需要什么?
这里的问题可能是您的链尚未升级 运行time,因此您无法在 现有 链上看到新模块。当您 运行 开发和注册新模块时 运行 链会发生这种情况。
要解决此问题并确保正确注册所有模块,您必须清除链并使用最新代码启动新的开发链。要清除,运行:
❯ target/release/substratekitties purge-chain --dev
重启一条新链:
❯ target/release/substratekitties --dev
并且 kitties 模块应该在外部选项卡中可用。
我正在关注 Substrate Kitties 研讨会。在 1/Viewing a Storage Mapping
中,我无法在 Polkadot UI 的 #extrinsics
选项卡上访问我的 kitties
模块:
我试过多次重新加载它。这是我的 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 运行时注册我的模块还需要什么?
这里的问题可能是您的链尚未升级 运行time,因此您无法在 现有 链上看到新模块。当您 运行 开发和注册新模块时 运行 链会发生这种情况。
要解决此问题并确保正确注册所有模块,您必须清除链并使用最新代码启动新的开发链。要清除,运行:
❯ target/release/substratekitties purge-chain --dev
重启一条新链:
❯ target/release/substratekitties --dev
并且 kitties 模块应该在外部选项卡中可用。