88use std:: sync:: Arc ;
99
1010use contracts_node_runtime:: { opaque:: Block , AccountId , Balance , BlockNumber , Hash , Index } ;
11- use pallet_contracts_rpc:: { Contracts , ContractsApi } ;
12- pub use sc_rpc_api:: DenyUnsafe ;
11+ use jsonrpsee:: RpcModule ;
1312use sc_transaction_pool_api:: TransactionPool ;
1413use sp_api:: ProvideRuntimeApi ;
1514use sp_block_builder:: BlockBuilder ;
1615use sp_blockchain:: { Error as BlockChainError , HeaderBackend , HeaderMetadata } ;
1716
17+ pub use sc_rpc_api:: DenyUnsafe ;
18+
1819/// Full client dependencies.
1920pub struct FullDeps < C , P > {
2021 /// The client instance to use.
@@ -26,7 +27,9 @@ pub struct FullDeps<C, P> {
2627}
2728
2829/// Instantiate all full RPC extensions.
29- pub fn create_full < C , P > ( deps : FullDeps < C , P > ) -> jsonrpc_core:: IoHandler < sc_rpc:: Metadata >
30+ pub fn create_full < C , P > (
31+ deps : FullDeps < C , P > ,
32+ ) -> Result < RpcModule < ( ) > , Box < dyn std:: error:: Error + Send + Sync > >
3033where
3134 C : ProvideRuntimeApi < Block > ,
3235 C : HeaderBackend < Block > + HeaderMetadata < Block , Error = BlockChainError > + ' static ,
@@ -37,23 +40,23 @@ where
3740 C :: Api : BlockBuilder < Block > ,
3841 P : TransactionPool + ' static ,
3942{
40- use pallet_transaction_payment_rpc:: { TransactionPayment , TransactionPaymentApi } ;
41- use substrate_frame_rpc_system:: { FullSystem , SystemApi } ;
43+ use pallet_contracts_rpc:: { ContractsApiServer , ContractsRpc } ;
44+ use pallet_transaction_payment_rpc:: { TransactionPaymentApiServer , TransactionPaymentRpc } ;
45+ use substrate_frame_rpc_system:: { SystemApiServer , SystemRpc } ;
4246
43- let mut io = jsonrpc_core :: IoHandler :: default ( ) ;
47+ let mut module = RpcModule :: new ( ( ) ) ;
4448 let FullDeps { client, pool, deny_unsafe } = deps;
4549
46- io. extend_with ( SystemApi :: to_delegate ( FullSystem :: new ( client. clone ( ) , pool, deny_unsafe) ) ) ;
47-
48- io. extend_with ( TransactionPaymentApi :: to_delegate ( TransactionPayment :: new ( client. clone ( ) ) ) ) ;
50+ module. merge ( SystemRpc :: new ( client. clone ( ) , pool. clone ( ) , deny_unsafe) . into_rpc ( ) ) ?;
51+ module. merge ( TransactionPaymentRpc :: new ( client. clone ( ) ) . into_rpc ( ) ) ?;
4952
5053 // Extend this RPC with a custom API by using the following syntax.
5154 // `YourRpcStruct` should have a reference to a client, which is needed
5255 // to call into the runtime.
53- // `io.extend_with (YourRpcTrait::to_delegate (YourRpcStruct::new(ReferenceToClient, ...)));`
56+ // `module.merge (YourRpcTrait::into_rpc (YourRpcStruct::new(ReferenceToClient, ...)))? ;`
5457
5558 // Contracts RPC API extension
56- io . extend_with ( ContractsApi :: to_delegate ( Contracts :: new ( client. clone ( ) ) ) ) ;
59+ module . merge ( ContractsRpc :: new ( client. clone ( ) ) . into_rpc ( ) ) ? ;
5760
58- io
61+ Ok ( module )
5962}
0 commit comments