Skip to content

Commit

Permalink
feat: only set first unique symbol published true (#1649)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid authored Feb 26, 2024
1 parent e7127d9 commit f7b98fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
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

0 comments on commit f7b98fa

Please sign in to comment.