- I want to implement a base contract that multiple contracts should implement.
- I decided to use "#[openbrush::trait_definition]" because "[#ink(message)]" cannot be added in the normal implementation of traits.
- However, traits declared in another library crate cannot be referenced.
- If you remove "#[openbrush::trait_definition]" as a trial, you can refer to it.
- Could you tell me what is wrong?
definition of trait: commons/lib.rs
#[openbrush::trait_definition]
pub trait Destination {
#[ink(message)]
fn execute_function(&mut self) -> Result<(), ()>;
}
use of trait: destination_base/lib.rs
#[openbrush::contract]
mod destination_base {
use commons::Destination;
/// Defines the storage of your contract.
/// Add new fields to the below struct in order
/// to add new static storage fields to your contract.
#[ink(storage)]
pub struct DestinationBase {
/// Stores a single `bool` value on the storage.
value: bool,
}
impl Destination for DestinationBase {
#[ink(message)]
fn execute_function(&mut self) -> Result<(),()> {
self.flip();
Ok(())
}
}
error:
Checking destination_base v0.1.0 (/Users/shin.takahashi/develop/work/delegate_test2/contracts/destination_base)
error[E0432]: unresolved import `commons::Destination`
--> src/lib.rs:9:9
|
9 | use commons::Destination;
| ^^^^^^^^^^^^^^^^^^^^ no `Destination` in the root
commons = { path = "../../commons", default-features = false }
inside dependencies ofdestination_base
cargo.toml. also don't forgot to include"commons/std"
inside std