From 0f4460580ea9894be4ae819f52a52e9bfd9e0a4d Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Mon, 14 Oct 2024 14:19:17 +0800 Subject: [PATCH 1/3] feat: support xudt_compatible symbol query (#2235) Signed-off-by: Miles Zhang --- app/models/suggest_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/suggest_query.rb b/app/models/suggest_query.rb index 7f3e90a9f..e61740cda 100644 --- a/app/models/suggest_query.rb +++ b/app/models/suggest_query.rb @@ -133,7 +133,7 @@ def find_bitcoin_transaction_by_txid end def find_udts_by_name_or_symbol - udts = Udt.where(udt_type: %i[sudt xudt omiga_inscription], published: true). + udts = Udt.where(udt_type: %i[sudt xudt xudt_compatible omiga_inscription], published: true). where("LOWER(full_name) LIKE LOWER(:query_key) OR LOWER(symbol) LIKE LOWER(:query_key)", query_key: "%#{query_key}%") UdtSerializer.new(udts) if udts.present? end From fc92ef57df31e7b44aa2f935bfc927390e148902 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Mon, 14 Oct 2024 20:55:57 +0800 Subject: [PATCH 2/3] feat: unique udt attributes by type_hash (#2238) Signed-off-by: Miles Zhang --- app/models/ckb_sync/new_node_data_processor.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index d65903bd5..4d73a77d9 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -692,9 +692,8 @@ def build_udts!(local_block, outputs, outputs_data) end end if udts_attributes.present? - returning_attrs = Udt.insert_all!(udts_attributes.map! do |attr| - attr.merge!(created_at: Time.current, updated_at: Time.current) - end, returning: %w[id udt_type type_hash]) + unique_udt_attributes = udts_attributes.uniq { |ua| ua[:type_hash] } + returning_attrs = Udt.insert_all!(unique_udt_attributes, record_timestamps: true, returning: %w[id udt_type type_hash]) omiga_inscription_info_attrs = returning_attrs.rows.filter do |r| r[1] == 4 end.map do |k| From 498fa1e2ccf0be76ad07726f4f0719f558538e4d Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Mon, 14 Oct 2024 21:02:54 +0800 Subject: [PATCH 3/3] feat: support xudt data1 hash on testnet (#2239) Signed-off-by: Miles Zhang --- app/models/ckb_sync/api.rb | 4 ++++ app/utils/ckb_utils.rb | 9 ++++++--- config/settings.mainnet.yml | 3 +-- config/settings.testnet.yml | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/models/ckb_sync/api.rb b/app/models/ckb_sync/api.rb index 0453976ce..55638428b 100644 --- a/app/models/ckb_sync/api.rb +++ b/app/models/ckb_sync/api.rb @@ -103,6 +103,10 @@ def xudt_code_hash Settings.xudt_code_hash end + def xudt_data_hash + Settings.xudt_data_hash + end + def xudt_compatible_code_hashes [Settings.xudt_compatible_code_hash, Settings.xudt_compatible2_code_hash] end diff --git a/app/utils/ckb_utils.rb b/app/utils/ckb_utils.rb index 125ea5f1a..7c7aa2851 100644 --- a/app/utils/ckb_utils.rb +++ b/app/utils/ckb_utils.rb @@ -419,9 +419,10 @@ def self.cell_type(type_script, output_data) [ *CkbSync::Api.instance.spore_cluster_code_hashes, *CkbSync::Api.instance.spore_cell_code_hashes, - ].include?(type_script&.code_hash) && type_script&.hash_type == "data1" || - CkbSync::Api.instance.mode == CKB::MODE::MAINNET && [CkbSync::Api.instance.xudt_code_hash, - CkbSync::Api.instance.unique_cell_code_hash].include?(type_script&.code_hash) && type_script&.hash_type == "data1" + CkbSync::Api.instance.xudt_data_hash, + CkbSync::Api.instance.xudt_code_hash, + CkbSync::Api.instance.unique_cell_code_hash, + ].include?(type_script&.code_hash) && type_script&.hash_type == "data1" case type_script&.code_hash when Settings.dao_code_hash, Settings.dao_type_hash @@ -464,6 +465,8 @@ def self.cell_type(type_script, output_data) "xudt" end end + when CkbSync::Api.instance.xudt_data_hash + "xudt" when CkbSync::Api.instance.unique_cell_code_hash "unique_cell" else diff --git a/config/settings.mainnet.yml b/config/settings.mainnet.yml index 5f44accc2..35b4d85c7 100644 --- a/config/settings.mainnet.yml +++ b/config/settings.mainnet.yml @@ -33,13 +33,12 @@ omiga_inscription_code_hash: "0x7490970e6af9b9fe63fc19fc523a12b2ec69027e6ae484ed # xudt xudt_code_hash: "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95" +unique_cell_code_hash: "0x2c8c11c985da60b0a330c61a85507416d6382c130ba67f0c47ab071e00aec628" # xudt compatible xudt_compatible_code_hash: "0x092c2c4a26ea475a8e860c29cf00502103add677705e2ccd8d6fe5af3caa5ae3" xudt_compatible2_code_hash: "0x26a33e0815888a4a0614a0b7d09fa951e0993ff21e55905510104a0b1312032b" -unique_cell_code_hash: "0x2c8c11c985da60b0a330c61a85507416d6382c130ba67f0c47ab071e00aec628" - # hash length of an attribute(especially which comes from bytea column), # e.g. Block.uncle_block_hashes: "0x587f354162afd133b4a4f7a4b621d11e043c3c08b0af2801f1686b5403b14953", which has a length of 66 ( 2 + 64) default_hash_length: "64" diff --git a/config/settings.testnet.yml b/config/settings.testnet.yml index 3fc0aac99..15e6306f1 100644 --- a/config/settings.testnet.yml +++ b/config/settings.testnet.yml @@ -36,6 +36,7 @@ omiga_inscription_info_code_hash: "0x50fdea2d0030a8d0b3d69f883b471cab2a29cae6f01 omiga_inscription_code_hash: "0x3a241ceceede72a5f55c8fb985652690f09a517d6c9070f0df0d3572fa03fb70" # xudt xudt_code_hash: "0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb" +xudt_data_hash: "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95" unique_cell_code_hash: "0x8e341bcfec6393dcd41e635733ff2dca00a6af546949f70c57a706c0f344df8b" # xudt compatible