Skip to content

Commit

Permalink
feat: support another xudt compatible (#2137)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
  • Loading branch information
zmcNotafraid committed Aug 19, 2024
1 parent d2baaf2 commit 0755668
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/models/ckb_sync/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/utils/ckb_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/settings.testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0755668

Please sign in to comment.