Skip to content

Commit

Permalink
feat: add with_data to get_live_cell
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Sep 12, 2019
1 parent 8b47dcb commit 40e85d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/ckb/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ def get_transaction(tx_hash)
end

# @param out_point [CKB::Types::OutPoint]
# @param with_data [Boolean]
#
# @return [CKB::Types::CellWithStatus]
def get_live_cell(out_point)
cell_h = rpc.get_live_cell(out_point.to_h)
def get_live_cell(out_point, with_data = false)
cell_h = rpc.get_live_cell(out_point.to_h, with_data)
Types::CellWithStatus.from_h(cell_h)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ckb/rpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def get_transaction(tx_hash)
rpc_request("get_transaction", params: [tx_hash])
end

def get_live_cell(out_point)
rpc_request("get_live_cell", params: [out_point])
def get_live_cell(out_point, with_data = false)
rpc_request("get_live_cell", params: [out_point, with_data])
end

def send_transaction(transaction)
Expand Down
4 changes: 2 additions & 2 deletions lib/ckb/types/cell_with_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Types
class CellWithStatus
attr_accessor :cell, :status

# @param cell [CKB::Types::Output]
# @param cell [CKB::Types::CellInfo | nil]
# @param status [String]
def initialize(cell:, status:)
@cell = cell
Expand All @@ -23,7 +23,7 @@ def self.from_h(hash)
return if hash.nil?

new(
cell: Output.from_h(hash[:cell]),
cell: CellInfo.from_h(hash[:cell]),
status: hash[:status]
)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/ckb/types/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
require_relative "block_reward"
require_relative "banned_address"
require_relative "cell_dep"
require_relative "cell_data"
require_relative "cell_info"

module CKB
module Types
Expand Down

0 comments on commit 40e85d3

Please sign in to comment.