Module: Istox::BlockchainReceiptQuery

Extended by:
ActiveSupport::Concern
Defined in:
lib/istox/models/concerns/blockchain_receipt_query.rb

Instance Method Summary collapse

Instance Method Details

#handle_confirm(resource_action) ⇒ Object

overrideable, when blockchain transaction has confirmed



6
7
8
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 6

def handle_confirm(resource_action)
  self
end

#handle_extraObject

overrideable, extra data that will be published back to frontend



16
17
18
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 16

def handle_extra
  nil
end

#handle_fail(resource_action) ⇒ Object

overrideable, when blockchain transaction has failed



11
12
13
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 11

def handle_fail(resource_action)
  self
end

#outcomeObject

outcome of the blockchain transaction, can be “pending” / “confirmed” / “failed”



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 21

def outcome
  @blockchain_receipts = get_blockchain_receipts

  return "confirmed" if @blockchain_receipts.empty?
  
  txids = @blockchain_receipts.map do |blockchain_receipt|
    blockchain_receipt.txid
  end.compact

  @blocks = get_block_transactions(txids)

  return "failed" if blocks_failed?
  return "pending" if blocks_pending?
  return "confirmed" if blocks_confirmed?
end