diff --git a/Procfile.pug b/Procfile.pug index 6045bef..62b04c5 100644 --- a/Procfile.pug +++ b/Procfile.pug @@ -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]" diff --git a/README.md b/README.md index db9d684..56a0c3f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/config/ormpscan2.yml b/config/ormpscan2.yml index ccaae8c..c1aef07 100644 --- a/config/ormpscan2.yml +++ b/config/ormpscan2.yml @@ -3,6 +3,7 @@ development: - 1 - 42161 - 46 + - 44 test: @@ -11,3 +12,4 @@ production: - 1 - 42161 - 46 + - 44 diff --git a/lib/tasks/contracts.rake b/lib/tasks/contracts.rake index 6b543f7..53d107c 100644 --- a/lib/tasks/contracts.rake +++ b/lib/tasks/contracts.rake @@ -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) @@ -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