Coverage Report

Created: 2022-11-10 19:56

/home/runner/work/creditcoin/creditcoin/node/src/rpc.rs
Line
Count
Source (jump to first uncovered line)
1
//! A collection of node-specific RPC methods.
2
//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer
3
//! used by Substrate nodes. This file extends those RPC definitions with
4
//! capabilities that are specific to this project's runtime configuration.
5
6
#![warn(missing_docs)]
7
8
use std::sync::Arc;
9
10
use creditcoin_node_runtime::{opaque::Block, AccountId, Balance, Index};
11
pub use sc_rpc_api::DenyUnsafe;
12
use sc_transaction_pool_api::TransactionPool;
13
use sp_api::ProvideRuntimeApi;
14
use sp_block_builder::BlockBuilder;
15
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
16
17
/// Full client dependencies.
18
pub struct FullDeps<C, P> {
19
  /// The client instance to use.
20
  pub client: Arc<C>,
21
  /// Transaction pool instance.
22
  pub pool: Arc<P>,
23
  /// Whether to deny unsafe calls
24
  pub deny_unsafe: DenyUnsafe,
25
  /// Metrics about mining.
26
  pub mining_metrics: primitives::metrics::MiningMetrics,
27
}
28
29
/// Instantiate all full RPC extensions.
30
0
pub fn create_full<C, P>(deps: FullDeps<C, P>) -> jsonrpc_core::IoHandler<sc_rpc::Metadata>
31
0
where
32
0
  C: ProvideRuntimeApi<Block>,
33
0
  C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
34
0
  C: Send + Sync + 'static,
35
0
  C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
36
0
  C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
37
0
  C::Api: BlockBuilder<Block>,
38
0
  C::Api: creditcoin_runtime_api::TaskApi<Block, AccountId>,
39
0
  P: TransactionPool + 'static,
40
0
{
41
0
  use creditcoin_node_rpc::{CreditcoinApi, CreditcoinRpc, Task, TaskRpc};
42
0
  use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
43
0
  use substrate_frame_rpc_system::{FullSystem, SystemApi};
44
0
45
0
  let mut io = jsonrpc_core::IoHandler::default();
46
0
  let FullDeps { client, pool, deny_unsafe, mining_metrics } = deps;
47
0
48
0
  io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe)));
49
0
50
0
  io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone())));
51
0
52
0
  io.extend_with(CreditcoinApi::to_delegate(CreditcoinRpc::new(mining_metrics)));
53
0
54
0
  io.extend_with(TaskRpc::to_delegate(Task::new(client, deny_unsafe)));
55
0
56
0
  io
57
0
}