q9f
q9f

Reputation: 11824

No `kitties` module available in the extrinsics tab

I'm following the Substrate Kitties workshop. In 1/Viewing a Storage Mapping, I cannot access my kitties module on the #extrinsics tab of the Polkadot UI:

Screenshot at 2019-07-18 11-36-02

I tried reloading it multiple times. This is my kitties.rs (compiles fine):

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(())
        }
    }
}

I defined the module in 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 {}

And added it to the 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>},

    }
);

What did I miss? What else is required to register my module with the Substrate runtime?

Upvotes: 2

Views: 102

Answers (1)

q9f
q9f

Reputation: 11824

The issue here potentially is your chain did not upgrade the runtime yet, and therefore you cannot see new modules on an existing chain. This happens when you run the chain while developing and registering new modules with the runtime.

To fix this and ensure all your modules are registered properly, you would have to purge your chain and start a new development chain with your latest code. To purge, run:

❯ target/release/substratekitties purge-chain --dev

Restart a new chain:

❯ target/release/substratekitties --dev

And the kitties module should be available in the extrinsics tab.

Upvotes: 2

Related Questions