From 13af18b3c0d753d0e030cce6e5580b94290eab89 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Thu, 21 Mar 2024 13:34:39 +0800 Subject: [PATCH 1/2] fix: contract with data1 hash_type needs to handle Signed-off-by: Miles Zhang --- app/jobs/import_transaction_job.rb | 2 +- app/models/deployed_cell.rb | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/jobs/import_transaction_job.rb b/app/jobs/import_transaction_job.rb index a85d5c2a1..0470de72c 100644 --- a/app/jobs/import_transaction_job.rb +++ b/app/jobs/import_transaction_job.rb @@ -186,7 +186,7 @@ def process_deployed_cell(lock_script_or_type_script) dep = case lock_script_or_type_script.hash_type - when "data" + when "data", "data1" by_data_hash[lock_script_or_type_script.code_hash] when "type" by_type_hash[lock_script_or_type_script.code_hash] diff --git a/app/models/deployed_cell.rb b/app/models/deployed_cell.rb index 45c3ce6cc..1ceefa11f 100644 --- a/app/models/deployed_cell.rb +++ b/app/models/deployed_cell.rb @@ -8,7 +8,7 @@ class DeployedCell < ApplicationRecord # @param cell_output_id [Integer] deployed cell output id def self.cell_output_id_to_contract_id(cell_output_id) Rails.cache.fetch(["cell_output_id_to_contract_id", cell_output_id], expires_in: 1.day) do - DeployedCell.where(cell_output_id: cell_output_id).pick(:contract_id) + DeployedCell.where(cell_output_id:).pick(:contract_id) end end @@ -73,7 +73,7 @@ def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) dep_type: cell_dep["dep_type"], ckb_transaction_id: ckb_transaction.id, contract_id: DeployedCell.cell_output_id_to_contract_id(cell_output.id), # check if we already known the relationship between the contract cell and contract - implicit: cell_dep["implicit"] || false + implicit: cell_dep["implicit"] || false, } # we don't know how the cells in transaction may refer to the contract cell @@ -106,7 +106,7 @@ def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) dep_type: cell_dep["dep_type"], ckb_transaction_id: ckb_transaction.id, contract_id: nil, - implicit: false + implicit: false, } binary_data = mid_cell.binary_data # binary_data = [hex_data[2..-1]].pack("H*") @@ -121,10 +121,10 @@ def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) co = parse_code_dep[{ "out_point" => { "tx_hash" => "0x#{tx_hash}", - "index" => cell_index + "index" => cell_index, }, "dep_type" => "code", - "implicit" => true # this is an implicit dependency + "implicit" => true, # this is an implicit dependency }] end end @@ -138,10 +138,10 @@ def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) scripts.each do |lock_script_or_type_script| dep = case lock_script_or_type_script.hash_type - when "data" - by_data_hash[lock_script_or_type_script.code_hash] - when "type" - by_type_hash[lock_script_or_type_script.code_hash] + when "data", "data1" + by_data_hash[lock_script_or_type_script.code_hash] + when "type" + by_type_hash[lock_script_or_type_script.code_hash] end next unless dep @@ -158,7 +158,7 @@ def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) deployed_cells_attrs << { contract_id: contract.id, - cell_output_id: dep[:contract_cell_id] + cell_output_id: dep[:contract_cell_id], } end end @@ -168,7 +168,7 @@ def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) if cell_dependencies_attrs.present? CellDependency.upsert_all cell_dependencies_attrs.uniq { |a| a[:contract_cell_id] - }, unique_by: [:ckb_transaction_id, :contract_cell_id] + }, unique_by: %i[ckb_transaction_id contract_cell_id] end DeployedCell.upsert_all deployed_cells_attrs, unique_by: [:cell_output_id] if deployed_cells_attrs.present? deployed_cells_attrs.each do |deployed_cell_attr| From e196e457c85ad2cc798ca58067b014574f3cb7ec Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Thu, 21 Mar 2024 17:36:03 +0800 Subject: [PATCH 2/2] chore: update permission of auto-merge action Signed-off-by: Miles Zhang --- .github/workflows/merge-master-to-develop.yml | 7 +++++-- .github/workflows/request-to-deploy-mainnet.yml | 13 ++++++++----- .github/workflows/request-to-deploy-testnet.yml | 13 ++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/merge-master-to-develop.yml b/.github/workflows/merge-master-to-develop.yml index d5e8a7de3..e4ec51d67 100644 --- a/.github/workflows/merge-master-to-develop.yml +++ b/.github/workflows/merge-master-to-develop.yml @@ -1,5 +1,8 @@ name: Merge master to develop +permissions: + pull-requests: write + on: push: branches: @@ -16,8 +19,8 @@ jobs: with: source_branch: master destination_branch: develop - pr_title: 'Merge released ${{ github.ref }} into develop' + pr_title: "Merge released ${{ github.ref }} into develop" pr_reviewer: keith-cy pr_label: auto-pr - pr_body: ':crown: *Anautomated PR*' + pr_body: ":crown: *Anautomated PR*" github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/request-to-deploy-mainnet.yml b/.github/workflows/request-to-deploy-mainnet.yml index 3703c9d21..f4821c86b 100644 --- a/.github/workflows/request-to-deploy-mainnet.yml +++ b/.github/workflows/request-to-deploy-mainnet.yml @@ -1,5 +1,8 @@ name: Request to deploy mainnet +permissions: + pull-requests: write + on: push: branches: [testnet] @@ -13,9 +16,9 @@ jobs: - name: Request PR uses: repo-sync/pull-request@v2 with: - source_branch: 'testnet' - destination_branch: 'master' - pr_title: 'Deploy to mainnet' - pr_reviewer: 'rabbitz,zmcNotafraid,keith-cy' - pr_label: 'auto-pr' + source_branch: "testnet" + destination_branch: "master" + pr_title: "Deploy to mainnet" + pr_reviewer: "rabbitz,zmcNotafraid,keith-cy" + pr_label: "auto-pr" github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/request-to-deploy-testnet.yml b/.github/workflows/request-to-deploy-testnet.yml index 440f4586c..fdd1a1938 100644 --- a/.github/workflows/request-to-deploy-testnet.yml +++ b/.github/workflows/request-to-deploy-testnet.yml @@ -1,5 +1,8 @@ name: Request to deploy testnet +permissions: + pull-requests: write + on: push: branches: [develop] @@ -13,9 +16,9 @@ jobs: - name: Request PR uses: repo-sync/pull-request@v2 with: - source_branch: 'develop' - destination_branch: 'testnet' - pr_title: 'Deploy to testnet' - pr_reviewer: 'rabbitz,zmcNotafraid,keith-cy' - pr_label: 'auto-pr' + source_branch: "develop" + destination_branch: "testnet" + pr_title: "Deploy to testnet" + pr_reviewer: "rabbitz,zmcNotafraid,keith-cy" + pr_label: "auto-pr" github_token: ${{ secrets.GITHUB_TOKEN }}