Module: Filecoin::Deal::ClassMethods

Included in:
Filecoin::Deal
Defined in:
lib/filecoin/deal.rb

Instance Method Summary collapse

Instance Method Details

#from_deal_info(deal_info) ⇒ Object

rubocop:disable Metrics/MethodLength



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/filecoin/deal.rb', line 17

def from_deal_info(deal_info) # rubocop:disable Metrics/MethodLength
  new(
    deal_id: deal_info["DealID"],
    duration: deal_info["Duration"],
    message: deal_info["Message"],
    piece_cid: deal_info.dig("PieceCID", "/"),
    price_per_epoch: deal_info["PricePerEpoch"],
    proposal_cid: deal_info.dig("ProposalCid", "/"),
    provider: deal_info["Provider"],
    size: deal_info["Size"],
    state: deal_info["State"],
  )
end