Skip to content

Commit 328d541

Browse files
authored
fix live cell (#2868)
1 parent a56a7c7 commit 328d541

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/interactions/addresses/live_cells.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def fetch_cell_output_scope(address)
3939
scope =
4040
if bound_status
4141
vout_ids = BitcoinVout.where(address_id: address_ids, status: bound_status).pluck(:cell_output_id)
42-
CellOutput.live.includes(:type_script, :lock_script, :block).where(id: vout_ids)
42+
CellOutput.live.where(id: vout_ids)
4343
else
44-
CellOutput.live.includes(:type_script, :lock_script, :block).where(address_id: address_ids)
44+
CellOutput.live.where(address_id: address_ids)
4545
end
4646

4747
tag.present? ? filter_by_tag(scope) : scope
@@ -50,22 +50,25 @@ def fetch_cell_output_scope(address)
5050
def filter_by_tag(scope)
5151
case tag
5252
when "fiber"
53+
scope2 = scope
5354
lock_script_ids = scope.where.not(lock_script_id: nil).distinct.pluck(:lock_script_id)
5455
filtered_ids = LockScript.where(id: lock_script_ids, code_hash: Settings.fiber_funding_code_hash).pluck(:id)
55-
scope.where(lock_script_id: filtered_ids)
56+
scope2.includes(:type_script, :lock_script, :block).where(lock_script_id: filtered_ids)
5657
when "multisig"
58+
scope2 = scope
5759
lock_script_ids = scope.where.not(lock_script_id: nil).distinct.pluck(:lock_script_id)
5860
filtered_ids = LockScript.where(id: lock_script_ids).where(
5961
"(code_hash = ? AND hash_type = ?) OR (code_hash = ? AND hash_type = ?)",
6062
Settings.multisig_code_hash, "data1",
6163
Settings.secp_multisig_cell_type_hash, "type"
6264
).pluck(:id)
63-
scope.where(lock_script_id: filtered_ids)
65+
scope2.includes(:type_script, :lock_script, :block).where(lock_script_id: filtered_ids)
6466
when "deployment"
67+
scope2 = scope
6568
scope_ids = scope.pluck(:id)
6669
deployed_ids = Contract.pluck(:deployed_cell_output_id)
6770
matched_ids = scope_ids & deployed_ids
68-
scope.where(id: matched_ids)
71+
scope2.includes(:type_script, :lock_script, :block).where(id: matched_ids)
6972
else
7073
CellOutput.none
7174
end

0 commit comments

Comments
 (0)