From 2a491c56629a96c74a8ea6d9495e553e5d6f9411 Mon Sep 17 00:00:00 2001 From: Boyu Yang Date: Mon, 19 Feb 2024 09:41:24 +0800 Subject: [PATCH] feat(rpc): add ckb light client rpc method `estimate_cycles` --- Cargo.toml | 2 +- src/rpc/ckb_light_client.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 95213920..668046f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ rustls-tls = ["reqwest/rustls-tls"] test = [] [dev-dependencies] -clap = { version = "4.1.8", features = ["derive"] } +clap = { version = "~4.4.18", features = ["derive"] } # TODO clap v4.5 requires rustc v1.74.0+ httpmock = "0.6" async-global-executor = "2.3.1" hex = "0.4" diff --git a/src/rpc/ckb_light_client.rs b/src/rpc/ckb_light_client.rs index 2e8672e4..3d7c6670 100644 --- a/src/rpc/ckb_light_client.rs +++ b/src/rpc/ckb_light_client.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; use ckb_jsonrpc_types::{ - BlockNumber, BlockView, Cycle, HeaderView, JsonBytes, NodeAddress, RemoteNodeProtocol, Script, - Transaction, TransactionView, TxStatus, Uint32, Uint64, + BlockNumber, BlockView, Cycle, EstimateCycles, HeaderView, JsonBytes, NodeAddress, + RemoteNodeProtocol, Script, Transaction, TransactionView, TxStatus, Uint32, Uint64, }; use ckb_types::H256; @@ -152,6 +152,7 @@ crate::jsonrpc!(pub struct LightClientRpcClient { pub fn get_genesis_block(&self) -> BlockView; pub fn get_header(&self, block_hash: H256) -> Option; pub fn get_transaction(&self, tx_hash: H256) -> Option; + pub fn estimate_cycles(&self, tx: Transaction)-> EstimateCycles; /// Fetch a header from remote node. If return status is `not_found` will re-sent fetching request immediately. /// /// Returns: FetchStatus