Skip to content

Commit

Permalink
fix: delete holder allocation if holder count is zero (#2040)
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz authored Jul 8, 2024
1 parent e92fb43 commit 4c8cc5d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/workers/generate_udt_holder_allocation_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def update_contract_holder_allocation(udt)
unique_ckb_address_ids = fetch_unique_ckb_address_ids(udt)
allocation_data = calculate_holder_allocation_data(unique_ckb_address_ids)

existing_allocations = udt.udt_holder_allocations.where.not(contract_id: nil)
existing_allocations.each do |allocation|
unless allocation_data.key?(allocation.contract.code_hash)
allocation.destroy!
end
end

allocation_data.each do |code_hash, count|
contract = Contract.find_by(code_hash:, role: ["LockScript", "lock_script"])
next unless contract
Expand Down

0 comments on commit 4c8cc5d

Please sign in to comment.