1
pub fn create_full<C, P>(
    deps: FullDeps<C, P>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
    C: ProvideRuntimeApi<Block>
        + HeaderBackend<Block>
        + AuxStore
        + HeaderMetadata<Block, Error = BlockChainError>
        + Send
        + Sync
        + 'static,
    C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
    C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
    C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
    C::Api: BlockBuilder<Block>,
    P: TransactionPool + Sync + Send + 'static,
{
    use pallet_contracts_rpc::{Contracts, ContractsApiServer};
    use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
    use substrate_frame_rpc_system::{System, SystemApiServer};

    let mut module = RpcExtension::new(());
    let FullDeps { client, pool, deny_unsafe } = deps;

    module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
    module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
    module.merge(Contracts::new(client).into_rpc())?;

    Ok(module)
}

I inserted a constraint to the standard rpc.rs create_full function:

C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,

I got an error:

C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `create_full`
 -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>, <RuntimeApi as ConstructRuntimeApi<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>, sc_service::client::client::Client<sc_client_db::Backend<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>>, LocalCallExecutor<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>, sc_client_db::Backend<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>>, NativeElseWasmExecutor<Executor>>, sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>, RuntimeApi>>>::RuntimeApi: ContractsRuntimeApi<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic>, sp_runtime::AccountId32, u128, u32, H256>

Any suggestion what should I do is greatly appreciated.

1 Answer 1

1

It means that C doesn't implement this trait.

Check the C, the create_fuill<C, P>'s C.


After taking a look at your code.

I think you missed the trait bound here https://github.com/hgminerva/humidefi-parachain/blob/015d477ee6a73479760d4ea072ce871e970a0d43/node/src/service.rs#L86-L93.

pseudo-code:

RuntimeApi::RuntimeApi: ContractApi

Made a PR to your repo https://github.com/hgminerva/humidefi-parachain/pull/1.

16
  • Sorry for being so novice, any hint will help on how to check C, all seems to match existing code in contract nodes, etc.
    – hgminerva
    Oct 30, 2022 at 11:16
  • Without the full code, I can't do any further diagnosis. Maybe you missed github.com/paritytech/substrate/blob/…. Oct 30, 2022 at 11:19
  • in my runtime i am using this: impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
    – hgminerva
    Oct 30, 2022 at 11:28
  • I posted the code above.
    – hgminerva
    Oct 30, 2022 at 11:33
  • 1
    No, you don't. Check github.com/hgminerva/humidefi-parachain/pull/1. Still recommending you learn some Rust first. I have already given the answer to you and you said you have tried that... Oct 31, 2022 at 3:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.