@@ -17,7 +17,7 @@ use evm_rpc::{
1717 providers:: { find_provider, resolve_rpc_service, PROVIDERS , SERVICE_PROVIDER_MAP } ,
1818 types:: { OverrideProvider , Provider , ProviderId , RpcAccess , RpcAuth } ,
1919} ;
20- use evm_rpc_types:: { Hex32 , HttpOutcallError , MultiRpcResult , RpcConfig , RpcResult } ;
20+ use evm_rpc_types:: { Hex32 , HttpOutcallError , MultiRpcResult , RpcConfig , RpcResult , RpcServices } ;
2121use ic_canister_log:: log;
2222use ic_cdk:: {
2323 api:: {
@@ -46,7 +46,7 @@ pub fn require_api_key_principal_or_controller() -> Result<(), String> {
4646#[ update( name = "eth_getLogs" ) ]
4747#[ candid_method( rename = "eth_getLogs" ) ]
4848pub async fn eth_get_logs (
49- source : evm_rpc_types :: RpcServices ,
49+ source : RpcServices ,
5050 config : Option < evm_rpc_types:: GetLogsRpcConfig > ,
5151 args : evm_rpc_types:: GetLogsArgs ,
5252) -> MultiRpcResult < Vec < evm_rpc_types:: LogEntry > > {
@@ -61,8 +61,8 @@ pub async fn eth_get_logs(
6161#[ update( name = "eth_getBlockByNumber" ) ]
6262#[ candid_method( rename = "eth_getBlockByNumber" ) ]
6363pub async fn eth_get_block_by_number (
64- source : evm_rpc_types :: RpcServices ,
65- config : Option < evm_rpc_types :: RpcConfig > ,
64+ source : RpcServices ,
65+ config : Option < RpcConfig > ,
6666 block : evm_rpc_types:: BlockTag ,
6767) -> MultiRpcResult < evm_rpc_types:: Block > {
6868 match CandidRpcClient :: new ( source, config, now ( ) ) {
@@ -74,8 +74,8 @@ pub async fn eth_get_block_by_number(
7474#[ update( name = "eth_getTransactionReceipt" ) ]
7575#[ candid_method( rename = "eth_getTransactionReceipt" ) ]
7676pub async fn eth_get_transaction_receipt (
77- source : evm_rpc_types :: RpcServices ,
78- config : Option < evm_rpc_types :: RpcConfig > ,
77+ source : RpcServices ,
78+ config : Option < RpcConfig > ,
7979 tx_hash : Hex32 ,
8080) -> MultiRpcResult < Option < evm_rpc_types:: TransactionReceipt > > {
8181 match CandidRpcClient :: new ( source, config, now ( ) ) {
@@ -87,8 +87,8 @@ pub async fn eth_get_transaction_receipt(
8787#[ update( name = "eth_getTransactionCount" ) ]
8888#[ candid_method( rename = "eth_getTransactionCount" ) ]
8989pub async fn eth_get_transaction_count (
90- source : evm_rpc_types :: RpcServices ,
91- config : Option < evm_rpc_types :: RpcConfig > ,
90+ source : RpcServices ,
91+ config : Option < RpcConfig > ,
9292 args : evm_rpc_types:: GetTransactionCountArgs ,
9393) -> MultiRpcResult < evm_rpc_types:: Nat256 > {
9494 match CandidRpcClient :: new ( source, config, now ( ) ) {
@@ -100,8 +100,8 @@ pub async fn eth_get_transaction_count(
100100#[ update( name = "eth_feeHistory" ) ]
101101#[ candid_method( rename = "eth_feeHistory" ) ]
102102pub async fn eth_fee_history (
103- source : evm_rpc_types :: RpcServices ,
104- config : Option < evm_rpc_types :: RpcConfig > ,
103+ source : RpcServices ,
104+ config : Option < RpcConfig > ,
105105 args : evm_rpc_types:: FeeHistoryArgs ,
106106) -> MultiRpcResult < evm_rpc_types:: FeeHistory > {
107107 match CandidRpcClient :: new ( source, config, now ( ) ) {
@@ -113,8 +113,8 @@ pub async fn eth_fee_history(
113113#[ update( name = "eth_sendRawTransaction" ) ]
114114#[ candid_method( rename = "eth_sendRawTransaction" ) ]
115115pub async fn eth_send_raw_transaction (
116- source : evm_rpc_types :: RpcServices ,
117- config : Option < evm_rpc_types :: RpcConfig > ,
116+ source : RpcServices ,
117+ config : Option < RpcConfig > ,
118118 raw_signed_transaction_hex : evm_rpc_types:: Hex ,
119119) -> MultiRpcResult < evm_rpc_types:: SendRawTransactionStatus > {
120120 match CandidRpcClient :: new ( source, config, now ( ) ) {
@@ -130,8 +130,8 @@ pub async fn eth_send_raw_transaction(
130130#[ update( name = "eth_call" ) ]
131131#[ candid_method( rename = "eth_call" ) ]
132132pub async fn eth_call (
133- source : evm_rpc_types :: RpcServices ,
134- config : Option < evm_rpc_types :: RpcConfig > ,
133+ source : RpcServices ,
134+ config : Option < RpcConfig > ,
135135 args : evm_rpc_types:: CallArgs ,
136136) -> MultiRpcResult < evm_rpc_types:: Hex > {
137137 match CandidRpcClient :: new ( source, config, now ( ) ) {
@@ -140,6 +140,19 @@ pub async fn eth_call(
140140 }
141141}
142142
143+ #[ update( name = "json_request" ) ]
144+ #[ candid_method( rename = "json_request" ) ]
145+ pub async fn json_request (
146+ source : RpcServices ,
147+ config : Option < RpcConfig > ,
148+ args : String ,
149+ ) -> MultiRpcResult < String > {
150+ match CandidRpcClient :: new ( source, config, now ( ) ) {
151+ Ok ( source) => source. json_request ( args) . await ,
152+ Err ( err) => Err ( err) . into ( ) ,
153+ }
154+ }
155+
143156#[ update]
144157#[ candid_method]
145158async fn request (
0 commit comments