Skip to content

Commit

Permalink
chore: Update rpc get_live_cell interface
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWaWaR committed Sep 21, 2019
1 parent eaa0725 commit df1cd48
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ckb-sdk/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jsonrpc_client!(pub struct RpcClient {
pub fn get_epoch_by_number(&mut self, number: EpochNumber) -> RpcRequest<OptionEpochView>;
pub fn get_header(&mut self, hash: H256) -> RpcRequest<OptionHeaderView>;
pub fn get_header_by_number(&mut self, number: BlockNumber) -> RpcRequest<OptionHeaderView>;
pub fn get_live_cell(&mut self, out_point: OutPoint) -> RpcRequest<CellWithStatus>;
pub fn get_live_cell(&mut self, out_point: OutPoint, with_data: bool) -> RpcRequest<CellWithStatus>;
pub fn get_tip_block_number(&mut self) -> RpcRequest<BlockNumber>;
pub fn get_tip_header(&mut self) -> RpcRequest<HeaderView>;
pub fn get_transaction(&mut self, hash: H256) -> RpcRequest<OptionTransactionWithStatus>;
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/mock_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<'a> MockResourceLoader for Loader<'a> {
) -> Result<Option<(CellOutput, Bytes)>, String> {
let output: Option<CellOutput> = self
.rpc_client
.get_live_cell(out_point.clone().into())
.get_live_cell(out_point.clone().into(), true)
.call()
.map(|resp| resp.cell.map(|info| info.output.into()))
.map_err(|err| err.to_string())?;
Expand Down
8 changes: 7 additions & 1 deletion src/subcommands/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ impl<'a> RpcSubCommand<'a> {
.validator(|input| FromStrParser::<u32>::default().validate(input))
.required(true)
.help("Output index"),
)
.arg(
Arg::with_name("with-data")
.long("with-data")
.help("Get live cell with data")
),
SubCommand::with_name("get_tip_block_number").about("Get tip block number"),
SubCommand::with_name("get_tip_header").about("Get tip header"),
Expand Down Expand Up @@ -330,14 +335,15 @@ impl<'a> CliSubCommand for RpcSubCommand<'a> {
let tx_hash: H256 =
FixedHashParser::<H256>::default().from_matches(m, "tx-hash")?;
let index: u32 = FromStrParser::<u32>::default().from_matches(m, "index")?;
let with_data = m.is_present("with-data");
let out_point = OutPoint {
tx_hash,
index: Uint32::from(index),
};

let resp = self
.rpc_client
.get_live_cell(out_point)
.get_live_cell(out_point, with_data)
.call()
.map_err(|err| err.to_string())?;
Ok(resp.render(format, color))
Expand Down
6 changes: 3 additions & 3 deletions src/subcommands/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<'a> WalletSubCommand<'a> {
let out_point = info.out_point();
let resp: CellWithStatus = self
.rpc_client
.get_live_cell(out_point.into())
.get_live_cell(out_point.into(), true)
.call()
.expect("get_live_cell by RPC call failed");
if is_live_cell(&resp) && is_secp_cell(&resp) {
Expand Down Expand Up @@ -317,7 +317,7 @@ impl<'a> WalletSubCommand<'a> {
let out_point = info.out_point();
let resp: CellWithStatus = self
.rpc_client
.get_live_cell(out_point.into())
.get_live_cell(out_point.into(), true)
.call()
.expect("get_live_cell by RPC call failed");
if is_live_cell(&resp) && is_secp_cell(&resp) {
Expand Down Expand Up @@ -427,7 +427,7 @@ impl<'a> WalletSubCommand<'a> {
let out_point = info.out_point();
let resp: CellWithStatus = self
.rpc_client
.get_live_cell(out_point.into())
.get_live_cell(out_point.into(), true)
.call()
.expect("get_live_cell by RPC call failed");
if is_live_cell(&resp) && is_dao_cell(&resp, genesis_info.dao_type_hash()) {
Expand Down

0 comments on commit df1cd48

Please sign in to comment.