Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: only set first unique symbol published true #1649

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def build_udts!(local_block, outputs, outputs_data)
if parsed_spore_cell[:cluster_id].present?
binary_hashes = CkbUtils.hexes_to_bins_sql(CkbSync::Api.instance.spore_cluster_code_hashes)
spore_cluster_type_ids = TypeScript.where("code_hash IN (#{binary_hashes})").where(hash_type: "data1",
args: parsed_spore_cell[:cluster_id]).pluck(:id)
args: parsed_spore_cell[:cluster_id]).pluck(:id)

spore_cluster_cell = CellOutput.live.where(type_script_id: spore_cluster_type_ids).last
parsed_cluster_data = CkbUtils.parse_spore_cluster_data(spore_cluster_cell.data)
Expand Down Expand Up @@ -712,7 +712,9 @@ 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]
nft_token_attr[:published] = true
unless Udt.where(symbol: info[:symbol].strip, udt_type: :omiga_inscription).exists?
nft_token_attr[:published] = true
end
end
# fill issuer_address after publish the token
udts_attributes << {
Expand Down
22 changes: 12 additions & 10 deletions test/models/ckb_sync/node_data_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1034,15 +1034,15 @@ class NodeDataProcessorTest < ActiveSupport::TestCase
Address.find_or_create_address(lock1, node_block.header.timestamp)
Address.find_or_create_address(lock2, node_block.header.timestamp)
300.times do |i|
if i % 2 == 0
node_block.transactions.first.outputs << CKB::Types::Output.new(
capacity: 30000 * 10**8, lock: lock1,
)
else
node_block.transactions.first.outputs << CKB::Types::Output.new(
capacity: 40000 * 10**8, lock: lock2,
)
end
node_block.transactions.first.outputs << if i % 2 == 0
CKB::Types::Output.new(
capacity: 30000 * 10**8, lock: lock1,
)
else
CKB::Types::Output.new(
capacity: 40000 * 10**8, lock: lock2,
)
end
node_block.transactions.first.outputs_data << "0x"
end
new_local_block = node_data_processor.process_block(node_block)
Expand Down Expand Up @@ -4043,8 +4043,10 @@ class NodeDataProcessorTest < ActiveSupport::TestCase
assert_equal info.mint_limit, 0.1e12
assert_equal info.mint_status, "minting"
assert_equal info.udt_id, Udt.first.id
udt = Udt.first
assert_equal "0x5fa66c8d5f43914f85d3083e0529931883a5b0a14282f891201069f1b5067908",
Udt.first.type_hash
udt.type_hash
assert_equal true, udt.published
end
end

Expand Down
Loading