Skip to content

Commit

Permalink
Merge pull request #1657 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
zmcNotafraid authored Feb 28, 2024
2 parents df55a8f + 1cbf149 commit 45034de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,24 +631,24 @@ def build_udts!(local_block, outputs, outputs_data)
next unless cell_type.in?(%w(udt m_nft_token nrc_721_token spore_cell
omiga_inscription_info omiga_inscription))

type_hash, parsed_udt_type =
type_hash, parsed_udt_type, published =
if cell_type == "omiga_inscription_info"
info = CkbUtils.parse_omiga_inscription_info(outputs_data[tx_index][index])
info_type_hash = output.type.compute_hash
attrs = info.merge(output.type.to_h, type_hash: info_type_hash)
pre_closed_info = OmigaInscriptionInfo.find_by(
pre_closed_info = OmigaInscriptionInfo.includes(:udt).find_by(
type_hash: info_type_hash, mint_status: :closed,
)
attrs =
attrs, published =
if pre_closed_info
attrs.merge(pre_udt_hash: pre_closed_info.udt_hash)
[attrs.merge(pre_udt_hash: pre_closed_info.udt_hash), pre_closed_info.udt&.published == true]
else
attrs
[attrs, false]
end
OmigaInscriptionInfo.upsert(attrs, unique_by: :udt_hash)
[info[:udt_hash], "omiga_inscription"]
[info[:udt_hash], "omiga_inscription", published]
else
[output.type.compute_hash, udt_type(cell_type)]
[output.type.compute_hash, udt_type(cell_type), false]
end

if cell_type == "omiga_inscription"
Expand Down Expand Up @@ -712,7 +712,7 @@ def build_udts!(local_block, outputs, outputs_data)
nft_token_attr[:full_name] = info[:name]
nft_token_attr[:symbol] = info[:symbol]
nft_token_attr[:decimal] = info[:decimal]
unless Udt.where(symbol: info[:symbol].strip, udt_type: :omiga_inscription).exists?
if published || !Udt.where(symbol: info[:symbol].strip, udt_type: :omiga_inscription).exists?
nft_token_attr[:published] = true
end
end
Expand Down
1 change: 1 addition & 0 deletions test/models/ckb_sync/node_data_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4147,6 +4147,7 @@ class NodeDataProcessorTest < ActiveSupport::TestCase
node_data_processor.process_block(node_block)
assert_equal 2, Udt.count
assert_equal info.udt_hash, OmigaInscriptionInfo.last.pre_udt_hash
assert_equal true, Udt.last.published
end
end

Expand Down

0 comments on commit 45034de

Please sign in to comment.