Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: spore cluster and cell query should be mapping #1638

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading