I am trying to define Substrate runtime-api. I am using substrate master branch for dependencies.
Here is code
#![cfg_attr(not(feature = "std"), no_std)]
use codec::Codec;
use codec::{Encode, Decode};
sp_api::decl_runtime_apis! {
/// The API to verify barcode
pub trait BarcodeScannerApi<Hash> where
Hash: Codec, {
/// Verify barcode
fn is_valid_barcode(barcode: Hash) -> bool;
}
}
While building code, I am getting below error:
error[E0277]: the trait bound `Hash: parity_scale_codec::codec::WrapperTypeEncode` is not satisfied
--> pallets/barcode-scanner/runtime-api/src/lib.rs:6:1
|
6 | / sp_api::decl_runtime_apis! {
7 | | /// The API to verify barcode
8 | | pub trait BarcodeScannerApi<Hash> where
9 | | Hash: Codec, {
... |
12 | | }
13 | | }
| |_^ the trait `parity_scale_codec::codec::WrapperTypeEncode` is not implemented for `Hash`
|
= note: required because of the requirements on the impl of `sp_api::Encode` for `Hash`
= note: required because of the requirements on the impl of `sp_api::Encode` for `&Hash`
= note: required by `sp_api::Encode::encode`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting this bound
|
9 | Hash: Codec + parity_scale_codec::codec::WrapperTypeEncode, {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please help me to fix this.