Skip to content

Commit

Permalink
Merge pull request #1697 from nervosnetwork/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Mar 22, 2024
2 parents 51c6a70 + 34cdd09 commit 5ef91de
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/merge-master-to-develop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Merge master to develop

permissions:
pull-requests: write

on:
push:
branches:
Expand All @@ -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 }}
13 changes: 8 additions & 5 deletions .github/workflows/request-to-deploy-mainnet.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Request to deploy mainnet

permissions:
pull-requests: write

on:
push:
branches: [testnet]
Expand All @@ -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 }}
13 changes: 8 additions & 5 deletions .github/workflows/request-to-deploy-testnet.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Request to deploy testnet

permissions:
pull-requests: write

on:
push:
branches: [develop]
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion app/jobs/import_transaction_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 11 additions & 11 deletions app/models/deployed_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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*")
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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|
Expand Down

0 comments on commit 5ef91de

Please sign in to comment.