@@ -4,7 +4,8 @@ use std::pin::Pin;
44use anyhow:: Context ;
55use did:: transaction:: StorableExecutionResult ;
66use ethers_core:: types:: {
7- Block , BlockNumber , Log , Transaction , TransactionReceipt , H160 , H256 , U256 , U64 ,
7+ Block , BlockNumber , Log , Transaction , TransactionReceipt , TransactionRequest , H160 , H256 , U256 ,
8+ U64 ,
89} ;
910use itertools:: Itertools ;
1011use jsonrpc_core:: { Call , Id , MethodCall , Output , Params , Request , Response , Version } ;
@@ -27,6 +28,7 @@ const ETH_GET_TRANSACTION_COUNT_METHOD: &str = "eth_getTransactionCount";
2728const ETH_GET_BLOCK_BY_NUMBER_METHOD : & str = "eth_getBlockByNumber" ;
2829const ETH_BLOCK_NUMBER_METHOD : & str = "eth_blockNumber" ;
2930const ETH_GET_TRANSACTION_RECEIPT_METHOD : & str = "eth_getTransactionReceipt" ;
31+ const ETH_CALL_METHOD : & str = "eth_call" ;
3032const ETH_SEND_RAW_TRANSACTION_METHOD : & str = "eth_sendRawTransaction" ;
3133const ETH_GET_LOGS_METHOD : & str = "eth_getLogs" ;
3234const IC_GET_TX_EXECUTION_RESULT_BY_HASH_METHOD : & str = "ic_getExeResultByHash" ;
@@ -186,12 +188,26 @@ impl<C: Client> EthJsonRpcClient<C> {
186188 . map ( |v| v. as_u64 ( ) )
187189 }
188190
191+ /// Performs eth call and return the result.
192+ pub async fn eth_call (
193+ & self ,
194+ params : TransactionRequest ,
195+ block : BlockNumber ,
196+ ) -> anyhow:: Result < String > {
197+ self . single_request (
198+ ETH_CALL_METHOD . to_string ( ) ,
199+ make_params_array ! ( params, block) ,
200+ Id :: Str ( "eth_call" . to_string ( ) ) ,
201+ )
202+ . await
203+ }
204+
189205 /// Sends raw transaction and returns transaction hash
190206 pub async fn send_raw_transaction ( & self , transaction : Transaction ) -> anyhow:: Result < H256 > {
191207 let bytes = transaction. rlp ( ) ;
192208 let transaction = format ! ( "0x{}" , hex:: encode( bytes) ) ;
193209
194- self . single_request :: < H256 > (
210+ self . single_request (
195211 ETH_SEND_RAW_TRANSACTION_METHOD . to_string ( ) ,
196212 make_params_array ! ( transaction) ,
197213 Id :: Str ( "send_rawTransaction" . to_string ( ) ) ,
0 commit comments