diff --git a/app/models/ckb_sync/api.rb b/app/models/ckb_sync/api.rb index 14c0c6b71..d2e39e4d6 100644 --- a/app/models/ckb_sync/api.rb +++ b/app/models/ckb_sync/api.rb @@ -87,6 +87,17 @@ def spore_cell_code_hashes end end + def spore_code_hash_mapping + if mode == CKB::MODE::MAINNET + { Settings.spore_cell1_code_hash => Settings.spore_cluster1_code_hash } + else + { + Settings.spore_cell1_code_hash => Settings.spore_cluster1_code_hash, + Settings.spore_cell2_code_hash => Settings.spore_cluster2_code_hash, + } + end + end + def omiga_inscription_info_code_hash Settings.omiga_inscription_info_code_hash end diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index be99a1794..305e46288 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -673,8 +673,8 @@ def build_udts!(local_block, outputs, outputs_data) if cell_type == "spore_cell" parsed_spore_cell = CkbUtils.parse_spore_cell_data(outputs_data[tx_index][index]) if parsed_spore_cell[:cluster_id].present? - binary_hashes = CkbUtils.hexes_to_bins_sql(CkbSync::Api.instance.spore_cluster_code_hashes) - spore_cluster_type = TypeScript.where("code_hash IN (#{binary_hashes})").where( + cluster_code_hash = CkbSync::Api.instance.spore_code_hash_mapping[output.type.code_hash] + spore_cluster_type = TypeScript.where(code_hash: cluster_code_hash).where( args: parsed_spore_cell[:cluster_id], ).first if spore_cluster_type.present? diff --git a/app/workers/token_transfer_detect_worker.rb b/app/workers/token_transfer_detect_worker.rb index 02c976127..5ade161ee 100644 --- a/app/workers/token_transfer_detect_worker.rb +++ b/app/workers/token_transfer_detect_worker.rb @@ -144,8 +144,8 @@ def find_or_create_m_nft_collection(_cell, type_script) def find_or_create_spore_collection(_cell, type_script) spore_cell = type_script.cell_outputs.order("id desc").first parsed_spore_cell = CkbUtils.parse_spore_cell_data(spore_cell.data) - binary_hashes = CkbUtils.hexes_to_bins_sql(CkbSync::Api.instance.spore_cluster_code_hashes) - spore_cluster_type = TypeScript.where("code_hash IN (#{binary_hashes})").where( + cluster_code_hash = CkbSync::Api.instance.spore_code_hash_mapping[type_script.code_hash] + spore_cluster_type = TypeScript.where(code_hash: cluster_code_hash).where( args: parsed_spore_cell[:cluster_id], ).first coll = TokenCollection.find_or_create_by(