diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index f2a7ebc81..d6870de3b 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -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" @@ -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 diff --git a/test/models/ckb_sync/node_data_processor_test.rb b/test/models/ckb_sync/node_data_processor_test.rb index 31b778ae5..286796f5e 100644 --- a/test/models/ckb_sync/node_data_processor_test.rb +++ b/test/models/ckb_sync/node_data_processor_test.rb @@ -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