diff --git a/core/packages/test/scripts/configure-statemine.sh b/core/packages/test/scripts/configure-statemine.sh index 9d602d432b..b064cec029 100755 --- a/core/packages/test/scripts/configure-statemine.sh +++ b/core/packages/test/scripts/configure-statemine.sh @@ -1,7 +1,8 @@ #!/usr/bin/env sh - set -eu +source scripts/xcm-helper.sh + generate_hex_encoded_call_data() { local type=$1 local endpoint=$2 @@ -22,109 +23,29 @@ generate_hex_encoded_call_data() { return $retVal } -send_governance_transact() { - local relay_url=$1 - local relay_chain_seed=$2 - local para_id=$3 - local hex_encoded_data=$4 - local require_weight_at_most_ref_time=$5 - local require_weight_at_most_proof_size=$6 - echo " calling send_governance_transact:" - echo " relay_url: ${relay_url}" - echo " relay_chain_seed: ${relay_chain_seed}" - echo " para_id: ${para_id}" - echo " hex_encoded_data: ${hex_encoded_data}" - echo " require_weight_at_most_ref_time: ${require_weight_at_most_ref_time}" - echo " require_weight_at_most_proof_size: ${require_weight_at_most_proof_size}" - echo " params:" - - local dest=$(jq --null-input \ - --arg para_id "$para_id" \ - '{ "v3": { "parents": 0, "interior": { "x1": { "parachain": $para_id } } } }') - - local message=$(jq --null-input \ - --argjson hex_encoded_data $hex_encoded_data \ - --arg require_weight_at_most_ref_time "$require_weight_at_most_ref_time" \ - --arg require_weight_at_most_proof_size "$require_weight_at_most_proof_size" \ - ' - { - "v3": [ - { - "unpaidexecution": { - "weight_limit": "unlimited" - } - }, - { - "transact": { - "origin_kind": "superuser", - "require_weight_at_most": { - "ref_time": $require_weight_at_most_ref_time, - "proof_size": $require_weight_at_most_proof_size, - }, - "call": { - "encoded": $hex_encoded_data - } - } - } - ] - } - ') - - echo "" - echo " dest:" - echo "${dest}" - echo "" - echo " message:" - echo "${message}" - echo "" - echo "--------------------------------------------------" - - npx polkadot-js-api \ - --ws "${relay_url?}" \ - --seed "${relay_chain_seed?}" \ - --sudo \ - tx.xcmPallet.send \ - "${dest}" \ - "${message}" -} - add_exporter_config() { - local relay_url=$1 - local relay_chain_seed=$2 - local statemine_para_id=$3 - local statemine_para_endpoint=$4 - local bridge_hub_para_id=$5 - local ethereum_chain_id=$6 - echo " calling add_exporter_config:" - echo " relay_url: ${relay_url}" - echo " relay_chain_seed: ${relay_chain_seed}" - echo " statemine_para_id: ${statemine_para_id}" - echo " runtime_para_endpoint: ${statemine_para_endpoint}" - echo " bridge_hub_para_id: ${bridge_hub_para_id}" - echo " ethereum_chain_id: ${ethereum_chain_id}" - echo " params:" local bridged_network=$(jq --null-input \ - --arg ethereum_chain_id "$ethereum_chain_id" \ + --arg eth_chain_id "$eth_chain_id" \ ' { "Ethereum": { - "chainId": $ethereum_chain_id + "chainId": $eth_chain_id } } ' ) # Generate data for Transact (add_exporter_config) local bridge_config=$(jq --null-input \ - --arg bridge_hub_para_id "$bridge_hub_para_id" \ + --arg bridgehub_para_id "$bridgehub_para_id" \ --arg bridged_network "$bridged_network" \ ' { "bridgeLocation": { "parents": 1, "interior": { - "X1": { "Parachain": $bridge_hub_para_id } + "X1": { "Parachain": $bridgehub_para_id } } }, "allowedTargetLocation": { @@ -138,42 +59,103 @@ add_exporter_config() { } ' ) + + echo "" + echo " bridged_network:" + echo "${bridged_network}" + echo "" + echo " bridge_config:" + echo "${bridge_config}" + echo "" + echo "--------------------------------------------------" + local tmp_output_file=$(mktemp) generate_hex_encoded_call_data \ "add-exporter-config" \ - "$statemine_para_endpoint" \ + "$statemine_ws_url" \ "$tmp_output_file" \ "$bridged_network" \ "$bridge_config" local hex_encoded_data=$(cat $tmp_output_file) rm $tmp_output_file - send_governance_transact "${relay_url}" "${relay_chain_seed}" "${statemine_para_id}" "${hex_encoded_data}" 200000000 12000 + send_governance_transact_from_relaychain "${statemine_para_id}" "${hex_encoded_data}" 200000000 12000 } -if [ "$#" -eq 0 ]; then - cat <