Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions app/interactions/addresses/live_cells.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ def execute
raise AddressNotFoundError if address.is_a?(NullAddress)

order_by, asc_or_desc = live_cells_ordering
cell_outputs = CellOutput.includes(:bitcoin_vout).where(
cell_outputs: { status: "live", address_id: address.map(&:id) },
)
cell_outputs = cell_outputs.where(bitcoin_vouts: { status: bound_status }) if bound_status
cell_output_ids = cell_outputs.pluck("cell_outputs.id")
records = CellOutput.where(id: cell_output_ids).order(order_by => asc_or_desc).
page(page).per(page_size).fast_page
options = FastJsonapi::PaginationMetaGenerator.new(
request:, records:, page:, page_size:,
).call
if bound_status
bitcoin_vouts = BitcoinVout.where(address_id: address.map(&:id), status: bound_status)
records = CellOutput.live.where(id: bitcoin_vouts.map(&:cell_output_id)).order(order_by => asc_or_desc).
page(page).per(page_size).fast_page
else
records = CellOutput.live.where(address_id: address.map(&:id)).order(order_by => asc_or_desc).
page(page).per(page_size).fast_page
end

options = FastJsonapi::PaginationMetaGenerator.new(request:, records:, page:, page_size:).call
CellOutputSerializer.new(records, options).serialized_json
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/bitcoin_vout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class BitcoinVout < ApplicationRecord
def commitment
return unless op_return?

script_pubkey = Bitcoin::Script.parse_from_payload(data.htb)
script_pubkey.op_return_data.bth
script_pub_key = Bitcoin::Script.parse_from_payload(data.htb)
script_pub_key.op_return_data.bth
end
end

Expand Down
Loading