Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
add crab
Browse files Browse the repository at this point in the history
  • Loading branch information
wuminzhe committed Dec 13, 2023
1 parent b7f57c4 commit 9b5cd97
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 30 deletions.
1 change: 1 addition & 0 deletions Procfile.pug
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
eth: bin/rails "pug:track_logs[1]"
arb1: bin/rails "pug:track_logs[42161]"
darwinia: bin/rails "pug:track_logs[46]"
crab: bin/rails "pug:track_logs[44]"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
NOTE3: `ETHERSCAN_API_KEY` is optional, but without it, the api is limited to a small requests per second.

4. update Procfile.pug, then rerun `bin/pug`.
`rails pug:procfile`
`bin/rails pug:procfile`

5. rerun `bin/rails messages:trace`

## add new contract to an existing network
1. add the contract to the network.
2 changes: 2 additions & 0 deletions config/ormpscan2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ development:
- 1
- 42161
- 46
- 44

test:

Expand All @@ -11,3 +12,4 @@ production:
- 1
- 42161
- 46
- 44
70 changes: 41 additions & 29 deletions lib/tasks/contracts.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,50 @@ require 'dotenv'
Dotenv.load

namespace :contracts do
desc 'Update contracts of configurated networks'
task add: :environment do
desc 'Add ormp contracts of all configurated networks'
task add_all_ormp_contracts: :environment do
puts '-- Update Pug::EvmContract records'
chain_ids = Rails.application.config.ormpscan2['chains']
chain_ids.each_with_index do |chain_id, i|
puts "#{i}. Chain ID: #{chain_id}"
network = Pug::Network.find_by(chain_id:)

latest = JSON.parse URI.open("https://raw.githubusercontent.com/darwinia-network/ORMP/main/script/output/#{chain_id}/deploy.a-latest.json").read
puts 'ORMP'
add_contract(network, latest['ORMP'])
puts 'ORACLE'
add_contract(network, latest['ORACLE'])
puts 'RELAYER'
add_contract(network, latest['RELAYER'])

puts 'SUBAPI'
lastest_subapi = JSON.parse URI.open("https://raw.githubusercontent.com/subapidao/subapi/main/script/output/#{chain_id}/deploy.a-latest.json").read
add_contract(network, lastest_subapi['SUBAPI'])

puts 'ORMP LINE'
lastest_ormp_line = JSON.parse URI.open("https://raw.githubusercontent.com/darwinia-network/darwinia-msgport/main/script/output/#{chain_id}/deploy_ormp_line.a-latest.json").read
add_contract(network, lastest_ormp_line['ORMP_LINE'])

begin
puts 'ORMP LINE EXT'
lastest_ormp_line_ext = JSON.parse(URI.open("https://raw.githubusercontent.com/darwinia-network/darwinia-msgport/main/script/output/#{chain_id}/deploy_ormp_line_ext.a-latest.json").read)
add_contract(network, lastest_ormp_line_ext['ORMP_LINE_EXT'])
rescue StandardError => e
puts e.message
end

chain_ids.each do |chain_id|
add_ormp_contracts(chain_id)
end
end

desc 'Add ormp contracts of a network'
task :add_ormp_contracts, [:chain_id] => :environment do |_, args|
chain_id = args[:chain_id].to_i
add_ormp_contracts(chain_id)
end
end

def add_ormp_contracts(chain_id)
network = Pug::Network.find_by(chain_id:)
puts "== Chain: #{network.display_name}(#{chain_id}) ==="

latest = JSON.parse URI.open("https://raw.githubusercontent.com/darwinia-network/ORMP/main/script/output/#{chain_id}/deploy.a-latest.json").read
puts 'ORMP'
add_contract(network, latest['ORMP'])
puts 'ORACLE'
add_contract(network, latest['ORACLE'])
puts 'RELAYER'
add_contract(network, latest['RELAYER'])

puts 'SUBAPI'
lastest_subapi = JSON.parse URI.open("https://raw.githubusercontent.com/subapidao/subapi/main/script/output/#{chain_id}/deploy.a-latest.json").read
add_contract(network, lastest_subapi['SUBAPI'])

puts 'ORMP LINE'
lastest_ormp_line = JSON.parse URI.open("https://raw.githubusercontent.com/darwinia-network/darwinia-msgport/main/script/output/#{chain_id}/deploy_ormp_line.a-latest.json").read
add_contract(network, lastest_ormp_line['ORMP_LINE'])

begin
puts 'ORMP LINE EXT'
lastest_ormp_line_ext = JSON.parse(URI.open("https://raw.githubusercontent.com/darwinia-network/darwinia-msgport/main/script/output/#{chain_id}/deploy_ormp_line_ext.a-latest.json").read)
add_contract(network, lastest_ormp_line_ext['ORMP_LINE_EXT'])
rescue StandardError => e
puts e.message
end
end

def add_contract(network, contract_address)
Expand All @@ -48,5 +59,6 @@ def add_contract(network, contract_address)
else
puts `rails 'pug:add_contract[#{network.chain_id},#{contract_address}]'`
end
puts "\n"
sleep(10)
end

0 comments on commit 9b5cd97

Please sign in to comment.