I'm a newbie with rust and substrate. I'm currently trying to build a PSP34 compatible smart contract (NFT) for documents. In this contract, I'd like to have the following structure:
#[derive(Default, Debug, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub struct DocumentInfo {
// ...
/// Mapping to check who has signed
pub signatures: Mapping<AccountId, ()>,
}
Then, in the smart contract, I'm using OpenBrush and it has the following storage definition:
#[ink(storage)]
#[derive(SpreadAllocate, PSP34Storage)]
pub struct DocumentContract {
#[PSP34StorageField]
psp34: PSP34Data,
// Fields of current contract
/// mapping from token id to `DocumentInfo`
document_info: Mapping<Id, DocumentInfo>,
/// the id of last document
last_document_id: Id,
/// ids no longer used (can be reused)
freed_ids: Vec<Id>,
}
The problem is that the signatures mapping gives me the following error:
| #[derive(Default, Debug, Clone, Encode, Decode)]
| ----- in this derive macro expansion
...
53 | pub signatures: Mapping<AccountId, ()>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Mapping<ink_env::AccountId, ()>`
|
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Mapping<ink_env::AccountId, ()>: WrapperTypeEncode` is not satisfied
--> traits/document.rs:39:33
|
39 | #[derive(Default, Debug, Clone, Encode, Decode)]
| ^^^^^^ the trait `WrapperTypeEncode` is not implemented for `Mapping<ink_env::AccountId, ()>`
|
= note: required because of the requirements on the impl of `Encode` for `Mapping<ink_env::AccountId, ()>`
= note: this error originates in the derive macro `Encode` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Mapping<ink_env::AccountId, ()>: WrapperTypeDecode` is not satisfied
--> traits/document.rs:53:5
|
53 | pub signatures: Mapping<AccountId, ()>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `Mapping<ink_env::AccountId, ()>`
|
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `Mapping<ink_env::AccountId, ()>`
I kind of understand what the errors mean, but not really and I have no clue how to fix it. Would appreciate if someone could shine a light on this for me.