Skip to content

Commit

Permalink
fix: spore cluster and cell query should be mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid committed Feb 22, 2024
1 parent 8bb8267 commit 5768696
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions app/models/ckb_sync/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions app/workers/token_transfer_detect_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5768696

Please sign in to comment.