Skip to content

Commit

Permalink
chore: set cell_output_id when create cell datum (#1389)
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz committed Aug 16, 2023
1 parent 8765f91 commit 6e31433
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/jobs/import_transaction_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@ def perform(tx_hash, extra_data = {})
)
cell.lock_script = lock
cell.type_script = t
cell.data = output_data
cell.update!(
address_id: lock.address_id,
capacity: output.capacity,
occupied_capacity: cell.calculate_min_capacity,
status: "pending"
)
puts "output cell created tx_hash: #{tx_hash}, index: #{index}, cell_id: #{cell.id}"
# after the cell is created, create a datum
if output_data.present? && output_data != "0x"
(cell.cell_datum || cell.build_cell_datum).update(data: [output_data[2..]].pack("H*"))
end

process_output cell
process_deployed_cell(cell.lock_script)
Expand Down
2 changes: 1 addition & 1 deletion app/models/cell_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def data=(new_data)
if new_data
d = CKB::Utils.hex_to_bin(new_data)
if d.size > 0
datum = cell_datum || build_cell_datum(cell_output_id: id)
datum = cell_datum || build_cell_datum
datum.data = d
datum.save
end
Expand Down

0 comments on commit 6e31433

Please sign in to comment.