Skip to content

Commit

Permalink
Merge 465a80a into 8bb8267
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz authored Feb 7, 2024
2 parents 8bb8267 + 465a80a commit 56d35dd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/controllers/concerns/cell_data_comparator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ def diff_normal_nft_cells(inputs, outputs)
transfers = Hash.new { |h, k| h[k] = Array.new }
cell_types = %w(m_nft_token nrc_721_token spore_cell)

process_nft = ->(c, h) {
process_nft = ->(c, h, o) {
k = [c.address_id, c.cell_type, c.type_hash]
h[k] ||= { capacity: 0.0, count: 0 }
h[k][:capacity] += c.capacity
h[k][:count] -= 1
h[k][:count] += o
}
inputs = inputs.where(cell_type: cell_types).each_with_object({}) { |c, h| process_nft.call(c, h) }
outputs = outputs.where(cell_type: cell_types).each_with_object({}) { |c, h| process_nft.call(c, h) }
inputs = inputs.where(cell_type: cell_types).each_with_object({}) { |c, h| process_nft.call(c, h, -1) }
outputs = outputs.where(cell_type: cell_types).each_with_object({}) { |c, h| process_nft.call(c, h, 1) }

(inputs.keys | outputs.keys).each do |k|
address_id, cell_type, type_hash = k
Expand Down Expand Up @@ -136,10 +136,10 @@ def cota_info(transaction, address_id)
process_transfer = ->(item, count) {
collection = item.collection
info << CkbUtils.hash_value_to_s({
collection_name: collection.name,
count:,
token_id: item.token_id,
})
collection_name: collection.name,
count:,
token_id: item.token_id,
})
}

transaction.token_transfers.each do |t|
Expand Down

0 comments on commit 56d35dd

Please sign in to comment.