paritytech / subport

Parity Substrate(-based) chains usage and development support
https://docs.substrate.io
Apache License 2.0
83 stars 13 forks source link

Pallet-Nicks Tutorial - error: unexpected token #319

Closed Inux131 closed 2 years ago

Inux131 commented 2 years ago

Hi,

added dependencies & features in the Cargo.toml then: $ cargo build --release

how can I fix this?

A lot of errors are occurring:

Compiling node-template-runtime v4.0.0-dev (/home/robert/substrate-node-template/runtime)
   Compiling pallet-nicks v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.17#22d40c76)
error: failed to run custom build command for `node-template-runtime v4.0.0-dev (/home/robert/substrate-node-template/runtime)`

Caused by:
  process didn't exit successfully: `/home/robert/substrate-node-template/target/release/build/node-template-runtime-6e84ec0a3716120c/build-script-build` (exit status: 1)
  --- stdout
  Information that should be included in a bug report.
  Executing build command: "rustup" "run" "nightly" "cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/home/robert/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--profile" "release"
  Using rustc version: rustc 1.61.0-nightly (38a0b81b1 2022-03-06)

  --- stderr
     Compiling pallet-nicks v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.17#22d40c76)
     Compiling node-template-runtime v4.0.0-dev (/home/robert/substrate-node-template/runtime)
  error: unexpected token
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:326:2
      |
  326 | /     {
  327 | |         /* --snip-- */
  328 | |         Balances: pallet_balances,
  329 | |
  330 | |         /*** Add This Line ***/
  331 | |         Nicks: pallet_nicks,
  332 | |     }
      | |_____^

  error[E0433]: failed to resolve: use of undeclared type `Runtime`
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:396:24
      |
  396 |             OpaqueMetadata::new(Runtime::metadata().into())
      |                                 ^^^^^^^ use of undeclared type `Runtime`

  error[E0433]: failed to resolve: use of undeclared type `Aura`
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:439:49
      |
  439 |             sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
      |                                                          ^^^^ use of undeclared type `Aura`

  error[E0433]: failed to resolve: use of undeclared type `Aura`
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:443:4
      |
  443 |             Aura::authorities().into_inner()
      |             ^^^^ use of undeclared type `Aura`

  error[E0433]: failed to resolve: use of undeclared type `Grandpa`
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:461:4
      |
  461 |             Grandpa::grandpa_authorities()
      |             ^^^^^^^ use of undeclared type `Grandpa`

  error[E0433]: failed to resolve: use of undeclared type `Grandpa`
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:465:4
      |
  465 |             Grandpa::current_set_id()
      |             ^^^^^^^ use of undeclared type `Grandpa`

  error[E0433]: failed to resolve: use of undeclared type `System`
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:491:4
      |
  491 |             System::account_nonce(account)
      |             ^^^^^^ use of undeclared type `System`

  error[E0433]: failed to resolve: use of undeclared type `TransactionPayment`
     --> /home/robert/substrate-node-template/runtime/src/lib.rs:500:4
      |
  500 |             TransactionPayment::query_info(uxt, len)
      |             ^^^^^^^^^^^^^^^^^^ use of undeclared type `TransactionPayment`

and so on...

Genysys commented 2 years ago

I think what you are doing is replacing the entire construct_runtime with

/     {
  327 | |         /* --snip-- */
  328 | |         Balances: pallet_balances,
  329 | |
  330 | |         /*** Add This Line ***/
  331 | |         Nicks: pallet_nicks,
  332 | |     }

You are just meant to add this line to it

     Nicks: pallet_nicks,

So it should look like this:

  construct_runtime!(
    pub enum Runtime where
        Block = Block,
        NodeBlock = opaque::Block,
        UncheckedExtrinsic = UncheckedExtrinsic
    {
        System: frame_system,
        RandomnessCollectiveFlip: pallet_randomness_collective_flip,
        Timestamp: pallet_timestamp,
        Aura: pallet_aura,
        Grandpa: pallet_grandpa,
        Balances: pallet_balances,
        Nick: pallet_nicks,   <== Add this to it.
        TransactionPayment: pallet_transaction_payment,
        Sudo: pallet_sudo,
        // Include the custom logic from the pallet-template in the runtime.
        TemplateModule: pallet_template,
    }
);

Hope this helps

Inux131 commented 2 years ago

Hey,

thank you very much, it helped. At first it showed another error. I closed the Terminal and reopened. Then the next Error was:

`~/substrate-node-template$ cargo check -p node-template-runtime Compiling node-template-runtime v4.0.0-dev (/home/robert/substrate-node-template/runtime) warning: unused doc comment --> runtime/src/lib.rs:251:1 251 /// Add this code block to your template for Nicks: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macro invocations
= note: `#[warn(unused_doc_comments)]` on by default
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion

warning: node-template-runtime (lib) generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 9.47s ` I changed the /// to // and now everything works fine. Can you tell me why /// is a problem in rust?

I assume, that /// and // are comments and can be put at will.

Thanks so far for your help!

Genysys commented 2 years ago

This should help : https://stackoverflow.com/questions/53028926/what-does-the-warning-doc-comment-not-used-by-rustdoc-mean-and-how-do-i-fix-it

shawntabrizi commented 2 years ago

Thanks @Genysys for providing support.