Class: SystemConfigVersion
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SystemConfigVersion
- Defined in:
- lib/facetq/models/system_config_version.rb
Overview
Schema Information
Table name: system_config_versions
id :bigint not null, primary key
transaction_hash :string not null
block_number :bigint not null
transaction_index :bigint not null
supported_contracts :jsonb not null
start_block_number :bigint
admin_address :string
created_at :datetime not null
updated_at :datetime not null
Indexes
idx_on_block_number_transaction_index_efc8dd9c1d (block_number,transaction_index) UNIQUE
index_system_config_versions_on_transaction_hash (transaction_hash) UNIQUE
Foreign Keys
fk_rails_... (block_number => eth_blocks.block_number) ON DELETE => cascade
fk_rails_... (transaction_hash => ethscriptions.transaction_hash) ON DELETE => cascade
Class Method Summary collapse
- .current ⇒ Object
-
.current_admin_address ⇒ Object
def as_json(options = {}) super( options.merge( only: [ :supported_contracts, :block_number, :transaction_index, ] ) ) end.
- .latest_tx_hash ⇒ Object
- .system_mimetype ⇒ Object
Instance Method Summary collapse
Class Method Details
.current ⇒ Object
50 51 52 |
# File 'lib/facetq/models/system_config_version.rb', line 50 def self.current (newest_first.first || new).freeze end |
.current_admin_address ⇒ Object
def as_json(options = {})
super(
options.merge(
only: [
:supported_contracts,
:block_number,
:transaction_index,
]
)
)
end
68 69 70 |
# File 'lib/facetq/models/system_config_version.rb', line 68 def self.current_admin_address current.admin_address || ENV.fetch("INITIAL_SYSTEM_CONFIG_ADMIN_ADDRESS").downcase end |
.latest_tx_hash ⇒ Object
34 35 36 |
# File 'lib/facetq/models/system_config_version.rb', line 34 def self.latest_tx_hash newest_first.limit(1).pluck(:transaction_hash).first end |
.system_mimetype ⇒ Object
38 39 40 |
# File 'lib/facetq/models/system_config_version.rb', line 38 def self.system_mimetype "application/vnd.facet.system+json" end |
Instance Method Details
#operation_data ⇒ Object
43 44 45 46 47 |
# File 'lib/facetq/models/system_config_version.rb', line 43 def operation_data JSON.parse(ethscription.content).fetch('data') rescue JSON::ParserError => e raise "JSON parse error: #{e.}" end |