From 372bbed39d814ab429782b17789fa6ab6dc9b900 Mon Sep 17 00:00:00 2001 From: mr-t Date: Thu, 11 Apr 2024 11:35:37 +0200 Subject: [PATCH] scripts for ics721 setup --- scripts/README.md | 27 ++++++++++++++++++ scripts/instantiate-ics721.sh | 24 ++++++++++++++++ scripts/instantiate-incoming-proxy.sh | 26 +++++++++++++++++ scripts/instantiate-outgoing-proxy.sh | 40 +++++++++++++++++++++++++++ scripts/osmosis.env | 34 +++++++++++++++++++++++ scripts/select-chain.sh | 29 +++++++++++++++++++ scripts/stargaze.env | 34 +++++++++++++++++++++++ ts-relayer-tests/build.sh | 2 +- 8 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 scripts/README.md create mode 100755 scripts/instantiate-ics721.sh create mode 100755 scripts/instantiate-incoming-proxy.sh create mode 100755 scripts/instantiate-outgoing-proxy.sh create mode 100644 scripts/osmosis.env create mode 100755 scripts/select-chain.sh create mode 100644 scripts/stargaze.env diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..f85da7f7 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,27 @@ +# Setup ICS721 + +For ICS721 it requires these contracts: + +- ICS721: the bridge itself +- Incoming Proxy: optional contract for filtering incoming packets +- Outgoing Proxy: optional contract for filtering incoming packets + +## Scripts + +Scripts for setup must be executed in this order: + +1. ICS721 without proxies: [instantiate-ics721.sh](./instantiate-ics721.sh) +2. Incoming Proxy: [instantiate-incoming-proxy.sh](./instantiate-incoming-proxy.sh) +3. Outgoing Proxy: [instantiate-outgoing-proxy.sh](instantiate-outgoing-proxy.sh) + +In case proxies are used, ICS721 must be migrated for setting incoming and outgoing proxies: + +4. Migrate ICS721: TBD + +Once running, there are execute messages for proxies, allowing to add and remove channels and collections. + +5. WL Collection: TBD +6. WL Channel: TBD + +NOTE: +Above scripts use [select-chain.sh](./select-chain.sh). For each selected chain there is an `.env` file like `stargaze.env` and `osmosis.env`. diff --git a/scripts/instantiate-ics721.sh b/scripts/instantiate-ics721.sh new file mode 100755 index 00000000..7baded51 --- /dev/null +++ b/scripts/instantiate-ics721.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# ---------------------------------------------------- +# - exports CHAIN_NET and CHAIN based on user input - +# ---------------------------------------------------- + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) + +# select chain +if [[ -z "$CHAIN" ]]; then + source "$SCRIPT_DIR"/select-chain.sh + CHAIN=$(select_chain) + export CHAIN +fi +echo "reading $SCRIPT_DIR/$CHAIN.env" +source "$SCRIPT_DIR"/"$CHAIN".env + +printf -v MSG '{"cw721_base_code_id": %s, "pauser": "%s"}' $CODE_ID_CW721 $WALLET_OWNER +CMD="$CLI tx wasm instantiate $CODE_ID_ICS721 '$MSG' --label 'ICS721 with rate limiter outgoing proxy'" +CMD+=" --from $WALLET --admin $WALLET_ADMIN" +CMD+=" --gas $CLI_GAS --gas-prices $CLI_GAS_PRICES --gas-adjustment $CLI_GAS_ADJUSTMENT" +CMD+=" --chain-id $CHAIN_ID --node $CHAIN_NODE -y" + +echo "executing: $CMD" >&2 +eval $CMD \ No newline at end of file diff --git a/scripts/instantiate-incoming-proxy.sh b/scripts/instantiate-incoming-proxy.sh new file mode 100755 index 00000000..16da2729 --- /dev/null +++ b/scripts/instantiate-incoming-proxy.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# ---------------------------------------------------- +# - exports CHAIN_NET and CHAIN based on user input - +# ---------------------------------------------------- + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) + +# select chain +if [[ -z "$CHAIN" ]]; then + source "$SCRIPT_DIR"/select-chain.sh + CHAIN=$(select_chain) + export CHAIN +fi +echo "reading $SCRIPT_DIR/$CHAIN.env" +source "$SCRIPT_DIR"/"$CHAIN".env + +printf -v MSG '{"origin": "%s", "channels": %s}' $ADDR_ICS721 $CHANNELS +LABEL="ICS721 Incoming Whitelist Channel Proxy, Managed by Ark Protocol" +CMD="$CLI tx wasm instantiate $CODE_ID_INCOMING_PROXY '$MSG'" +CMD+=" --label '$LABEL'" +CMD+=" --from $WALLET --admin $WALLET_ADMIN" +CMD+=" --gas $CLI_GAS --gas-prices $CLI_GAS_PRICES --gas-adjustment $CLI_GAS_ADJUSTMENT" +CMD+=" --chain-id $CHAIN_ID --node $CHAIN_NODE -y" + +echo "executing: $CMD" >&2 +eval $CMD \ No newline at end of file diff --git a/scripts/instantiate-outgoing-proxy.sh b/scripts/instantiate-outgoing-proxy.sh new file mode 100755 index 00000000..dab0e631 --- /dev/null +++ b/scripts/instantiate-outgoing-proxy.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# ---------------------------------------------------- +# - exports CHAIN_NET and CHAIN based on user input - +# ---------------------------------------------------- + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) + +# select chain +if [[ -z "$CHAIN" ]]; then + source "$SCRIPT_DIR"/select-chain.sh + CHAIN=$(select_chain) + export CHAIN +fi +echo "reading $SCRIPT_DIR/$CHAIN.env" +source "$SCRIPT_DIR"/"$CHAIN".env + +MSG=$( + cat <&2 +eval $CMD \ No newline at end of file diff --git a/scripts/osmosis.env b/scripts/osmosis.env new file mode 100644 index 00000000..163b3b1f --- /dev/null +++ b/scripts/osmosis.env @@ -0,0 +1,34 @@ +export CLI=osmosisd +export CLI_OUTPUT=json +export CLI_DENOM=uosmo +export CLI_GAS=auto +export CLI_GAS_PRICE=0.1 +export CLI_GAS_PRICES=$CLI_GAS_PRICE$CLI_DENOM +export CLI_GAS_ADJUSTMENT=1.1 +export CLI_BROADCAST_MODE=sync + +export CHAIN=osmosis +export CHAIN_ID=osmo-test-5 # osmosis-1 +export CHAIN_NODE=https://osmosis-testnet-rpc.polkachu.com:443 # https://osmosis-rpc.polkachu.com:443 + +# wallets +export WALLET=YOUR_WALLET_ADDR # wallet executed the tx +# - owner of contract +# - ics721: used for pauser being able to pause ics721 +# - incoming and outgoing proxy: used for owner to execute msgs +export WALLET_OWNER=WALLET_OWNER +# - admin of contract for migrating contract +export WALLET_ADMIN=WALLET_ADMIN + +export CODE_ID_CW721=CODE_ID_CW721 +export CODE_ID_ICS721=CODE_ID_ICS721 +export ADDR_ICS721=ADDR_ICS721 + +# proxies +export CODE_ID_INCOMING_PROXY=7786 +export CODE_ID_OUTGOING_PROXY=7788 + +# Proxy configs +# - channels: used as WLs for incoming and outgoing proxy +export CHANNELS="[\"channel-1\",\"channel-2\"]" +export COLLECTIONS="[\"ADDR1\",\"ADDR2\"]" diff --git a/scripts/select-chain.sh b/scripts/select-chain.sh new file mode 100755 index 00000000..527c14ca --- /dev/null +++ b/scripts/select-chain.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# ---------------------------------------------------- +# - exports CHAIN based on user input - +# ---------------------------------------------------- + +function select_chain() { + # Read chains from the file into an array + CHAIN_CHOICES=("stargaze" "osmosis") + echo "Available chains: ${CHAIN_CHOICES[*]}" >&2 + + echo "Please select the chain:" >&2 + select SELECTED_CHAIN in "${CHAIN_CHOICES[@]}" "Exit"; do + case $SELECTED_CHAIN in + "Exit") echo "Exiting..." >&2; return 0 ;; + *) if [[ " ${CHAIN_CHOICES[*]} " =~ " ${SELECTED_CHAIN} " ]]; then + echo "Selected chain: $SELECTED_CHAIN" >&2 + export CHAIN="$SELECTED_CHAIN" + break + else + echo "Invalid choice. Please try again." >&2 + fi ;; + esac + done + + export CHAIN="$SELECTED_CHAIN" + echo $CHAIN +} + +export -f select_chain \ No newline at end of file diff --git a/scripts/stargaze.env b/scripts/stargaze.env new file mode 100644 index 00000000..bbf03da0 --- /dev/null +++ b/scripts/stargaze.env @@ -0,0 +1,34 @@ +export CLI=starsd +export CLI_OUTPUT=json +export CLI_DENOM=ustars +export CLI_GAS=auto +export CLI_GAS_PRICE=1.2 +export CLI_GAS_PRICES=$CLI_GAS_PRICE$CLI_DENOM +export CLI_GAS_ADJUSTMENT=1.1 +export CLI_BROADCAST_MODE=sync + +export CHAIN=stargaze +export CHAIN_ID=elgafar-1 # stargaze-1 +export CHAIN_NODE=https://rpc.elgafar-1.stargaze-apis.com:443 # https://stargaze-rpc.polkachu.com:443 https://rpc.stargaze-apis.com:443 https://stargaze-rpc.publicnode.com:443 + +# wallets +export WALLET=YOUR_WALLET_ADDR # wallet executed the tx +# - owner of contract +# - ics721: used for pauser being able to pause ics721 +# - incoming and outgoing proxy: used for owner to execute msgs +export WALLET_OWNER=WALLET_OWNER +# - admin of contract for migrating contract +export WALLET_ADMIN=WALLET_ADMIN + +export CODE_ID_CW721=CODE_ID_CW721 +export CODE_ID_ICS721=CODE_ID_ICS721 +export ADDR_ICS721=ADDR_ICS721 + +# proxies +export CODE_ID_INCOMING_PROXY=7786 +export CODE_ID_OUTGOING_PROXY=7788 + +# Proxy configs +# - channels: used as WLs for incoming and outgoing proxy +export CHANNELS="[\"channel-1\",\"channel-2\"]" +export COLLECTIONS="[\"ADDR1\",\"ADDR2\"]" diff --git a/ts-relayer-tests/build.sh b/ts-relayer-tests/build.sh index bcef98c7..ca76ecb4 100755 --- a/ts-relayer-tests/build.sh +++ b/ts-relayer-tests/build.sh @@ -11,7 +11,7 @@ cd "$(git rev-parse --show-toplevel)" docker run --rm -v "$(pwd)":/code --platform linux/amd64 \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/workspace-optimizer:0.15.0 + cosmwasm/workspace-optimizer:0.15.1 mkdir -p ./ts-relayer-tests/internal cp ./artifacts/*.wasm ./ts-relayer-tests/internal