Skip to content

Commit

Permalink
Merge branch 'pending-tx-bind-lock-script-address' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
zmcNotafraid committed Oct 16, 2024
2 parents a67537e + 9ffd1c2 commit 73b533b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/ckb_sync/transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def import
tx_mappings = tx_returnings.rows.to_h { |id, tx_hash| [tx_hash.sub(/^\\x/, "0x"), id] }
lock_script_returnings = LockScript.upsert_all(lock_script_attrs.to_a, unique_by: :script_hash, returning: %i[id script_hash])
lock_script_mappings = lock_script_returnings.rows.to_h { |id, script_hash| [script_hash, id] }
address_returnings = Address.upsert_all(addresses_attrs.to_a, unique_by: :lock_hash, returning: %i[id lock_hash])
new_addresses_attrs =
addresses_attrs.to_a.map do |attr|
attr.merge({ lock_script_id: lock_script_mappings[attr[:lock_hash]] })
end
address_returnings = Address.upsert_all(new_addresses_attrs, unique_by: :lock_hash, returning: %i[id lock_hash])
address_mappings = address_returnings.rows.to_h { |id, lock_hash| [[lock_hash.sub(/^\\x/, "")].pack("H*"), id] }
type_script_mappings = {}
if type_script_attrs.present?
Expand Down

0 comments on commit 73b533b

Please sign in to comment.