paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

construct_runtime: default doesn't work #2892

Closed JoshOrndorff closed 5 years ago

JoshOrndorff commented 5 years ago

Today in Substrate Collaborative Learning, we added the contract module to the node template.

Everything worked perfectly until I made this change

- Contract: contract::{Module, Call, Storage, Event<T>, Config<T>},
+ Contract: contract::{ default },

I have the complete repository available for for reproduction https://github.com/JoshOrndorff/contract-chain/commits/master

bkchr commented 5 years ago

What is the error?

gui1117 commented 5 years ago

I'll take a look, error is

error[E0412]: cannot find type `Contract` in this scope
   --> runtime/src/lib.rs:184:28
    |
184 |     type OnFreeBalanceZero = (Contract);
    |                               ^^^^^^^^ not found in this scope
help: there is an enum variant `contract::RawEvent::Contract`; try using the variant's enum
    |
184 |     type OnFreeBalanceZero = (contract::RawEvent);
    |                               ^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `Event: std::convert::From<srml_contract::RawEvent<u128, substrate_primitives::sr25519::Public, primitive_types::H256>>` is not satisfied
   --> runtime/src/lib.rs:137:6
    |
137 | impl contract::Trait for Runtime {
    |      ^^^^^^^^^^^^^^^ the trait `std::convert::From<srml_contract::RawEvent<u128, substrate_primitives::sr25519::Public, primitive_types::H256>>` is not implemented for `Event`
    |
    = help: the following implementations were found:
              <Event as std::convert::From<srml_balances::RawEvent<substrate_primitives::sr25519::Public, u128, srml_balances::DefaultInstance>>>
              <Event as std::convert::From<srml_indices::RawEvent<substrate_primitives::sr25519::Public, u32>>>
              <Event as std::convert::From<srml_sudo::RawEvent<substrate_primitives::sr25519::Public>>>
              <Event as std::convert::From<srml_system::Event>>
              <Event as std::convert::From<template::RawEvent<substrate_primitives::sr25519::Public>>>

error: aborting due to 2 previous errors