Class: TransactionReceipt

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/facetq/models/transaction_receipt.rb

Overview

ApplicationRecord

Instance Method Summary collapse

Instance Method Details

#addressObject



65
66
67
# File 'lib/facetq/models/transaction_receipt.rb', line 65

def address
  effective_contract_address
end

#as_json(options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/facetq/models/transaction_receipt.rb', line 85

def as_json(options = {})
  super(
    options.merge(
      only: [
        :transaction_hash,
        :call_type,
        :runtime_ms,
        :block_timestamp,
        :status,
        :function,
        :args,
        :error,
        :logs,
        :block_blockhash,
        :block_number,
        :transaction_index,
        :gas_price,
        :gas_used,
        :transaction_fee,
        :return_value,
        :effective_contract_address
      ],
      methods: [:to, :from, :contract_address, :to_or_contract_address]
    )
  ).with_indifferent_access
end

#contractObject



61
62
63
# File 'lib/facetq/models/transaction_receipt.rb', line 61

def contract
  Contract.find_by_address(address)
end

#contract_addressObject



77
78
79
# File 'lib/facetq/models/transaction_receipt.rb', line 77

def contract_address
  created_contract_address
end

#failure?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/facetq/models/transaction_receipt.rb', line 112

def failure?
  status.to_s == 'failure'
end

#fromObject



73
74
75
# File 'lib/facetq/models/transaction_receipt.rb', line 73

def from
  from_address
end

#success?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/facetq/models/transaction_receipt.rb', line 116

def success?
  status.to_s == 'success'
end

#toObject



69
70
71
# File 'lib/facetq/models/transaction_receipt.rb', line 69

def to
  to_contract_address
end

#to_or_contract_addressObject



81
82
83
# File 'lib/facetq/models/transaction_receipt.rb', line 81

def to_or_contract_address
  to || contract_address
end