I have replicate this error using the MultiContractCaller from the ink-examples
In the multi_contract_caller we have a FakeEvent.
#[ink(event)]
pub struct FakeEvent {
account_id: AccountId,
}
Which is being emitted in the multi_contract_caller change
#[ink(message)]
pub fn change(&mut self, by: i32) {
let caller = self.env().caller();
self.env().emit_event(FakeEvent { account_id: caller });
match self.which {
Which::Adder => self.adder.inc(by),
Which::Subber => self.subber.dec(by),
}
}
In the accumulator we have another FakeEvent.
#[ink(event)]
pub struct FakeEvent {
account_id: AccountId,
}
Which is being emitted in the accumulator inc
#[ink(message)]
pub fn inc(&mut self, by: i32) {
let caller = self.env().caller();
self.env().emit_event(FakeEvent { account_id: caller });
self.value += by;
}
In theory this should have been solved by the "Events 2.0"
But the result is this below. Nevertheless, anyone knows why or what magic trick should I do to make this work?
error[E0284]: type annotations needed
--> /home/projects/crap/ink-examples-main/multi_contract_caller/lib.rs:101:24
|
101 | self.env().emit_event(FakeEvent { account_id: caller });
| ^^^^^^^^^^
|
= note: cannot satisfy `<_ as ContractEventBase>::Type == _`
help: try using a fully qualified path to specify the expected types
|
101 | <EnvAccess<'_, DefaultEnvironment> as EmitEvent<C>>::emit_event::<FakeEvent>(self.env(), FakeEvent { account_id: caller });
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> /home/projects/crap/ink-examples-main/multi_contract_caller/lib.rs:101:24
|
101 | self.env().emit_event(FakeEvent { account_id: caller });
| ^^^^^^^^^^
|
note: multiple `impl`s satisfying `EnvAccess<'_, DefaultEnvironment>: EmitEvent<_>` found
--> /home/projects/crap/ink-examples-main/multi_contract_caller/lib.rs:3:1
|
3 | #[ink::contract]
| ^^^^^^^^^^^^^^^^
= note: and another `impl` found in the `accumulator` crate: `impl<'a> EmitEvent<Accumulator> for EnvAccess<'a, <Accumulator as ContractEnv>::Env>;`
= note: this error originates in the attribute macro `ink::contract` (in Nightly builds, run with -Z macro-backtrace for more info)
help: try using a fully qualified path to specify the expected types
|
101 | <EnvAccess<'_, DefaultEnvironment> as EmitEvent<C>>::emit_event::<FakeEvent>(self.env(), FakeEvent { account_id: caller });
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ~
Some errors have detailed explanations: E0283, E0284.
For more information about an error, try `rustc --explain E0283`.
error: could not compile `multi_contract_caller` (bin "multi_contract_caller") due to 2 prevERROR: command ["/home/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo", "build", "--color=always", "--target=wasm32-unknown-unknown", "-Zbuild-std=core,alloc", "--no-default-features", "--release", "--target-dir=/home/projects/crap/ink-examples-main/multi_contract_caller/target/ink", "-Zbuild-std-features=panic_immediate_abort"] exited with code 101
Whit this bug there are at least two other posts: