shawntabrizi / substrate-collectables-workshop

A guided tutorial for building an NFT marketplace with the Polkadot SDK
https://www.shawntabrizi.com/substrate-collectables-workshop/
MIT License
237 stars 101 forks source link

Unable to compile at the very beginning at "Creating a Module" #53

Closed st00d25 closed 5 years ago

st00d25 commented 5 years ago

Hi,

I got an compiler error below when I execute ./build.sh following the tutorial.

st00d25-no-MacBook-Pro:substratekitties st00d25$ ./build.sh
Building webassembly binary in runtime/wasm...
   Compiling node-template-runtime v0.9.0 (/Users/st00d25/Qsync/documents/toudai_kifukouza/application_task/substratekitties/runtime)
error: cannot find macro `decl_storage!` in this scope
 --> /Users/st00d25/Qsync/documents/toudai_kifukouza/application_task/substratekitties/runtime/src/substratekitties.rs:5:1
  |
5 | decl_storage! {
  | ^^^^^^^^^^^^

error: cannot find macro `decl_module!` in this scope
  --> /Users/st00d25/Qsync/documents/toudai_kifukouza/application_task/substratekitties/runtime/src/substratekitties.rs:11:1
   |
11 | decl_module! {
   | ^^^^^^^^^^^

error[E0433]: failed to resolve: could not find `Module` in `substratekitties`
   --> /Users/st00d25/Qsync/documents/toudai_kifukouza/application_task/substratekitties/runtime/src/lib.rs:180:1
    |
180 | / construct_runtime!(
181 | |     pub enum Runtime with Log(InternalLog: DigestItem<Hash, Ed25519AuthorityId>) where
182 | |         Block = Block,
183 | |         NodeBlock = opaque::Block,
...   |
194 | |     }
195 | | );
    | |__^ could not find `Module` in `substratekitties`
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0412]: cannot find type `Module` in module `substratekitties`
   --> /Users/st00d25/Qsync/documents/toudai_kifukouza/application_task/substratekitties/runtime/src/lib.rs:180:1
    |
180 | / construct_runtime!(
181 | |     pub enum Runtime with Log(InternalLog: DigestItem<Hash, Ed25519AuthorityId>) where
182 | |         Block = Block,
183 | |         NodeBlock = opaque::Block,
...   |
194 | |     }
195 | | );
    | |__^ not found in `substratekitties`
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: possible candidates are found in other modules, you can import them into scope
    |
15  | use aura::Module;
    |
15  | use balances::Module;
    |
15  | use consensus::Module;
    |
15  | use indices::Module;
    |
and 3 other candidates

error: duplicate lang item in crate `std`: `panic_impl`.
  |
  = note: first defined in crate `sr_io`.

error: duplicate lang item in crate `std`: `oom`.
  |
  = note: first defined in crate `sr_io`.

error: aborting due to 6 previous errors

Some errors occurred: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: Could not compile `node-template-runtime`.

I have added "use" in substratekitties.rs to avoid this error like below.

//add this
use support::{decl_module, decl_storage};

pub trait Trait: system::Trait {}

decl_storage! {
    trait Store for Module<T: Trait> as KittyStorage {
        // Declare storage and getter functions here
    }
}

decl_module! {
    pub struct Module<T: Trait> for enum Call where origin: T::Origin {
        // Declare public functions here
    }
}

I would like to share this tips for others. Thank you

st00d25 commented 5 years ago

This is just a reminder for me and others.