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(_receipt) ⇒ Object

overrideable, when blockchain transaction has confirmed



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

def handle_confirm(_receipt)
  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(_receipt) ⇒ Object

overrideable, when blockchain transaction has failed



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

def handle_fail(_receipt)
  self
end

#outcomeObject

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



21
22
23
24
25
26
27
28
29
# File 'lib/istox/models/concerns/blockchain_receipt_query.rb', line 21

def outcome
  blockchain_receipt = ::Istox::BlockchainReceipt.where(resource_id: id, resource_name: self.class.name).first

  return 'confirmed' unless blockchain_receipt.present?

  return 'confirmed' if blockchain_receipt.status.blank?

  blockchain_receipt.status
end