In the project we are currently working on, we declared some runtime apis in our custom pallet, we tried to update the dependencies from 0.9.28
to 0.9.42
but the build fails with the following error:
error[E0277]: the trait bound `R: pallet::Config` is not satisfied
--> pallet/src/lib.rs:196:2
|
196 | / sp_api::decl_runtime_apis! {
197 | | /// Get extrinsic ids from a vector of extrinsics
198 | | /// that should be used to quickly retrieve all the event ids (hashes) given a vector of
199 | | /// extrinsics currently used to inspect the proposed block event ids and whether they are
... |
210 | | }
211 | | }
| |_____^ the trait `pallet::Config` is not implemented for `R`
|
= note: this error originates in the macro `sp_api::decl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting type parameter `R`
|
211 | }, R: pallet::Config
| +++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
this error is a bit misleading as far as I understand since I'm already implementing pallet::Config
, so I decided to run a minimal setup with substrate-node-template and see if there are any problems with the macro itself.
In the latest version in substrate-node-template, I tried adding the following runtime api in the template pallet:
sp_api::decl_runtime_apis! {
pub trait ExtrinsicDetails<R> where R:crate::Config
{
fn dummy_test(runtime: R::length) -> R;
}
}
given that I declare length in the pallet::Config like this:
#[pallet::config]
pub trait Config: frame_system::Config {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Type representing the weight of this pallet
type WeightInfo: WeightInfo;
#[pallet::constant]
type length: Get<u32>;
}
and implemented like this:
impl pallet_template::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_template::weights::SubstrateWeight<Runtime>;
type length = ConstU32<100>;
}
it kept throwing this error:
error[E0220]: associated type `length` not found for `R`
--> /home/coder/project/substrate-node-template/pallets/template/src/lib.rs:114:30
|
114 | fn dummy_test(runtime: R::length) -> R;
| ^^^^^^ there is a similarly named associated type `length` in the trait `pallet::Config`
even though it has the same name, i also tried using pallet::Config
instead of crate::Config
and also just Config
, all have the same error.
Ps: same code was working in 0.9.28