From 075566841a0c3f8d133f1c7b6889e61caa4dbdc1 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Mon, 19 Aug 2024 17:40:28 +0800 Subject: [PATCH] feat: support another xudt compatible (#2137) Signed-off-by: Miles Zhang --- app/models/ckb_sync/api.rb | 8 ++++++-- app/utils/ckb_utils.rb | 4 ++-- config/settings.testnet.yml | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/ckb_sync/api.rb b/app/models/ckb_sync/api.rb index ecbe2aa26..43e8844cd 100644 --- a/app/models/ckb_sync/api.rb +++ b/app/models/ckb_sync/api.rb @@ -103,8 +103,12 @@ def xudt_code_hash Settings.xudt_code_hash end - def xudt_compatible_code_hash - Settings.xudt_compatible_code_hash + def xudt_compatible_code_hashes + if mode == CKB::MODE::MAINNET + [Settings.xudt_compatible_code_hash] + else + [Settings.xudt_compatible_code_hash, Settings.xudt_compatible2_code_hash] + end end def unique_cell_code_hash diff --git a/app/utils/ckb_utils.rb b/app/utils/ckb_utils.rb index 8941de0cc..96b423d92 100644 --- a/app/utils/ckb_utils.rb +++ b/app/utils/ckb_utils.rb @@ -415,7 +415,7 @@ def self.cell_type(type_script, output_data) CkbSync::Api.instance.issuer_script_code_hash, CkbSync::Api.instance.token_class_script_code_hash, CkbSync::Api.instance.token_script_code_hash, CkbSync::Api.instance.cota_registry_code_hash, CkbSync::Api.instance.cota_regular_code_hash, CkbSync::Api.instance.omiga_inscription_info_code_hash, - CkbSync::Api.instance.xudt_code_hash, CkbSync::Api.instance.unique_cell_code_hash, CkbSync::Api.instance.xudt_compatible_code_hash, CkbSync::Api.instance.did_cell_code_hash + CkbSync::Api.instance.xudt_code_hash, CkbSync::Api.instance.unique_cell_code_hash, *CkbSync::Api.instance.xudt_compatible_code_hashes, CkbSync::Api.instance.did_cell_code_hash ].include?(type_script&.code_hash) && type_script&.hash_type == "type") || is_nrc_721_token_cell?(output_data) || is_nrc_721_factory_cell?(output_data) || @@ -457,7 +457,7 @@ def self.cell_type(type_script, output_data) "did_cell" when CkbSync::Api.instance.omiga_inscription_info_code_hash "omiga_inscription_info" - when CkbSync::Api.instance.xudt_compatible_code_hash + when *CkbSync::Api.instance.xudt_compatible_code_hashes "xudt_compatible" when CkbSync::Api.instance.xudt_code_hash Rails.cache.fetch(type_script.compute_hash) do diff --git a/config/settings.testnet.yml b/config/settings.testnet.yml index 7126e4b5b..3fc0aac99 100644 --- a/config/settings.testnet.yml +++ b/config/settings.testnet.yml @@ -40,6 +40,7 @@ unique_cell_code_hash: "0x8e341bcfec6393dcd41e635733ff2dca00a6af546949f70c57a706 # xudt compatible xudt_compatible_code_hash: "0x98701eaf939113606a8a70013fd2e8f27b8f1e234acdc329f3d71f9e9d3d3233" +xudt_compatible2_code_hash: "0x1142755a044bf2ee358cba9f2da187ce928c91cd4dc8692ded0337efa677d21a" # 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)