Method: Contract#as_json

Defined in:
lib/facetq/models/contract.rb

#as_json(options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/facetq/models/contract.rb', line 56

def as_json(options = {})
  super(
    options.merge(
      only: [
        :address,
        :transaction_hash,
        :current_init_code_hash,
        :current_type
      ]
    )
  ).tap do |json|
    
    if association(:transaction_receipt).loaded?
      json['deployment_transaction'] = transaction_receipt
    end
    
    json['current_state'] = if options[:include_current_state]
      current_state
    else
      {}
    end
    
    json['current_state']['contract_type'] = current_type    
  end
end