Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ case "$1" in
"$GLOBAL_CONSENSUS_WESTEND_SOVEREIGN_ACCOUNT" \
10000000000 \
true
# create foreign asset pool
force_create_pool \
Comment thread
bkontur marked this conversation as resolved.
Outdated
"ws://127.0.0.1:9910" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to use variables here instead of raw addresses ? like "${WESTEND_RPC_URL}" vs "ws://127.0.0.1:9910" so its clear which chain this is targetting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karolk91 actually, a very good point :), yes, we could do this, but I am also thinking about rewriting this scripts to PAPI, so I would keep it this way for now

"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')"
# Create liquidity in the pool
force_add_liquidity \
"ws://127.0.0.1:9910" \
"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }')" \
10000000000 \
10000000000

# HRMP
open_hrmp_channels \
"ws://127.0.0.1:9942" \
Expand Down Expand Up @@ -309,6 +324,20 @@ case "$1" in
"$GLOBAL_CONSENSUS_ROCOCO_SOVEREIGN_ACCOUNT" \
10000000000 \
true
# create foreign asset pool
force_create_pool \
"ws://127.0.0.1:9010" \
"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')"
# Create liquidity in the pool
force_add_liquidity \
"ws://127.0.0.1:9010" \
"//Alice" \
"$(jq --null-input '{ "parents": 1, "interior": "Here" }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }')" \
10000000000 \
10000000000
# HRMP
open_hrmp_channels \
"ws://127.0.0.1:9945" \
Expand Down
34 changes: 34 additions & 0 deletions bridges/testing/framework/utils/bridges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,40 @@ function force_create_foreign_asset() {
send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000
}

function force_create_pool() {
local runtime_para_endpoint=$1
local seed=$2
local native_asset_id=$3
local foreign_asset_id=$4

call_polkadot_js_api \
--ws "${runtime_para_endpoint?}" \
--seed "${seed?}" \
tx.assetConversion.createPool \
"${native_asset_id}" \
"${foreign_asset_id}"
}

function force_add_liquidity() {
local runtime_para_endpoint=$1
local seed=$2
local native_asset_id=$3
local foreign_asset_id=$4
local native_asset_amount=$5
local foreign_asset_amount=$6

call_polkadot_js_api \
--ws "${runtime_para_endpoint?}" \
--seed "${seed?}" \
tx.assetConversion.addLiquidity \
"${native_asset_id}" \
"${foreign_asset_id}" \
"${native_asset_amount}" \
"${foreign_asset_amount}" \
"1" \
"1" \
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
Comment thread
bkontur marked this conversation as resolved.
Outdated
}
function limited_reserve_transfer_assets() {
local url=$1
local seed=$2
Expand Down
35 changes: 35 additions & 0 deletions bridges/testing/framework/utils/generate_hex_encoded_call/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,35 @@ function forceXcmVersion(endpoint, outputFile, dest, xcm_version) {
});
}

function forceCreatePool(endpoint, outputFile, nativeAssetId, foreignAssetId) {
console.log(`Generating forceCreatePool from RPC endpoint: ${endpoint} to outputFile: ${outputFile}, nativeAssetId: ${nativeAssetId}, foreignAssetId: ${foreignAssetId}`);
connect(endpoint)
.then((api) => {
const call = api.tx.assetConversion.createPool(JSON.parse(nativeAssetId), JSON.parse(foreignAssetId));
writeHexEncodedBytesToOutput(call.method, outputFile);
exit(0);
})
.catch((e) => {
console.error(e);
exit(1);
});
}

function forceAddLiquidity(endpoint, outputFile, poolOwner, nativeAssetId, foreignAssetId, nativeAssetAmount, foreignAssetAmount) {
console.log(`Generating forceAddLiquidity from RPC endpoint: ${endpoint} to outputFile: ${outputFile}, poolOwner: ${poolOwner}, nativeAssetId: ${nativeAssetId}, foreignAssetId: ${foreignAssetId}, nativeAssetAmount: ${nativeAssetAmount}, foreignAssetAmount: ${foreignAssetAmount}`);
connect(endpoint)
.then((api) => {
const call = api.tx.assetConversion.addLiquidity(JSON.parse(nativeAssetId), JSON.parse(foreignAssetId), nativeAssetAmount, foreignAssetAmount, 1, 1, poolOwner);
writeHexEncodedBytesToOutput(call.method, outputFile);
exit(0);
})
.catch((e) => {
console.error(e);
exit(1);
});
}


Comment thread
bkontur marked this conversation as resolved.
Outdated
if (!process.argv[2] || !process.argv[3]) {
console.log("usage: node ./script/generate_hex_encoded_call <type> <endpoint> <output hex-encoded data file> <input message>");
exit(1);
Expand Down Expand Up @@ -157,6 +186,12 @@ switch (type) {
case 'force-xcm-version':
forceXcmVersion(rpcEndpoint, output, inputArgs[0], inputArgs[1]);
break;
case 'force-create-pool':
forceCreatePool(rpcEndpoint, output, inputArgs[0], inputArgs[1]);
break;
case 'force-add-liquidity':
forceAddLiquidity(rpcEndpoint, output, inputArgs[0], inputArgs[1], inputArgs[2], inputArgs[3], inputArgs[4]);
break;
Comment thread
bkontur marked this conversation as resolved.
Outdated
case 'check':
console.log(`Checking nodejs installation, if you see this everything is ready!`);
break;
Expand Down