JoshOrndorff / recipes

A Hands-On Cookbook for Aspiring Blockchain Chefs
GNU General Public License v3.0
376 stars 186 forks source link

Getting error while implementing RPC [Substrate] #380

Closed jaxter03 closed 3 years ago

jaxter03 commented 3 years ago

Hi all, I am getting error while implementing custom RPC for my Runtime API :-

error[E0277]: the trait bound `<C as sp_api::ProvideRuntimeApi<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>, sp_runtime::OpaqueExtrinsic>>>::Api: runtime_api::DexStorageApi<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>, sp_runtime::OpaqueExtrinsic>>` is not satisfied
  --> node/src/rpc.rs:54:17
   |
54 |     io.extend_with(rpc::DexStorageApi::to_delegate(
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `runtime_api::DexStorageApi<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>, sp_runtime::OpaqueExtrinsic>>` is not implemented for `<C as sp_api::ProvideRuntimeApi<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>, sp_runtime::OpaqueExtrinsic>>>::Api`
JoshOrndorff commented 3 years ago

The error makes it sound like your custom RPC needs a corresponding custom runtime API which is not installed in your runtime. If you do need this custom runtime API please install it. If you don't know what custom runtime API I'm talking about then you probably copied the recipe code and modified it incorrectly.

In either case, we can help you but we will need to see you complete code. Is it on github somewhere?

jaxter03 commented 3 years ago

Thanks @JoshOrndorff