Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts for ics721 setup #94

Merged
merged 8 commits into from
Apr 16, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
script for executing WL msgs on outgoing proxy
taitruong committed Apr 12, 2024
commit c6d2bdbd1a8c349aff0dc6a3ee3cd07819cabafc
13 changes: 11 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ Below scripts use [select-chain.sh](./select-chain.sh). For each selected chain
## Scripts

### Initial Setup

Scripts for setup must be executed in this order:

1. ICS721 without proxies: [instantiate-ics721.sh](./instantiate-ics721.sh)
@@ -29,8 +30,16 @@ After instantiation:
2. Incoming Proxy: [migrate-incoming-proxy.sh](./migrate-incoming-proxy.sh)
3. Outgoing Proxy: [migrate-outgoing-proxy.sh](.migrate-outgoing-proxy.sh)

### Outgoing Proxy Messages

### Proxy Messages
Usage:

```sh
$ ./scripts/whitelist-outgoing-proxy.sh
Usage: ./scripts/whitelist-outgoing-proxy.sh stargaze|osmosis [--add WHITELIST|--remove WHITELIST|--enable true_or_false] --type collection|channel|checksum|fees
Example:
./scripts/whitelist-outgoing-proxy.sh stargaze|osmosis --add channel-1 --type channel
./scripts/whitelist-outgoing-proxy.sh stargaze|osmosis --enable false --type collection
```

TBD
The owner of the outgoing proxy contract can add, remove and enable whitelists for collections, channels, collection checksums, and collection fees.
2 changes: 1 addition & 1 deletion scripts/instantiate-ics721.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# ----------------------------------------------------
# - exports CHAIN_NET and CHAIN based on user input -
# Instantiates the ICS721 contract with cw721_base_code_id and pauser
# ----------------------------------------------------

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
3 changes: 2 additions & 1 deletion scripts/instantiate-incoming-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# ----------------------------------------------------
# - exports CHAIN_NET and CHAIN based on user input -
# Instantiates the Incoming Whitelist Channel Proxy contract
# with the whitelist channels and reference to the ICS721 contract
# ----------------------------------------------------

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
3 changes: 2 additions & 1 deletion scripts/instantiate-outgoing-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# ----------------------------------------------------
# - exports CHAIN_NET and CHAIN based on user input -
# Instantiates the ICS721 Outgoing Whitelist Channel Proxy contract
# with the (channels, collections, checksums, collection fees) whitelist and reference to the ICS721 contract
# ----------------------------------------------------

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
7 changes: 6 additions & 1 deletion scripts/migrate-ics721.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
# ----------------------------------------------------
# - exports CHAIN_NET and CHAIN based on user input -
# Migrates the ICS721 contract, and sets optional:
# - incoming proxy
# - outgoing proxy
# - cw721 code id
# - pauser
# - cw721 admin
# ----------------------------------------------------

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
4 changes: 3 additions & 1 deletion scripts/migrate-incoming-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# ----------------------------------------------------
# - exports CHAIN_NET and CHAIN based on user input -
# Migrate the Incoming Whitelist Channel Proxy contract, and sets:
# - origin
# - optional channels
# ----------------------------------------------------

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
9 changes: 5 additions & 4 deletions scripts/migrate-outgoing-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
# ----------------------------------------------------
# - exports CHAIN_NET and CHAIN based on user input -
# Migrate the ICS721 Outgoing Whitelist Channel Proxy contract, and sets:
# - config with origin (ICS721) and owner
# - optional channels
# - optional collections
# - proxy with optional channels and collections whitelist
# ----------------------------------------------------

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
@@ -81,9 +85,6 @@ printf -v MSG '{
"owner": "%s"
},
"proxy": {
"rate_limit": {
"per_block": 100
}
%s
%s
}
6 changes: 5 additions & 1 deletion scripts/select-chain.sh
Original file line number Diff line number Diff line change
@@ -2,10 +2,14 @@
# ----------------------------------------------------
# - exports CHAIN based on user input -
# ----------------------------------------------------
export CHAIN_CHOICES=("stargaze" "osmosis")
export CHAIN_CHOICES_STR=$(
IFS=\|
echo "${CHAIN_CHOICES[*]}"
)

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
148 changes: 148 additions & 0 deletions scripts/whitelist-outgoing-proxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/bin/bash
# ----------------------------------------------------
# execute messages on the outgoing proxy contract, for whitelist management:
# - add/remove collection
# - add/remove channel
# - add/remove collection checksum
# - enable/disable collection|channel|checksum|fees
# ----------------------------------------------------

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
set -o pipefail

# get CHAIN_CHOICES
source "$SCRIPT_DIR"/select-chain.sh

function query_config() {
echo "config: $($CLI query wasm contract-state smart $ADDR_OUTGOING_PROXY '{"get_config": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE --output json | jq)" >&2
echo "contract: $($CLI query wasm contract $ADDR_OUTGOING_PROXY --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2
echo "rate limit: $($CLI query wasm contract-state smart $ADDR_OUTGOING_PROXY '{"get_rate_limit": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2
echo "channels whitelist: $($CLI query wasm contract-state smart $ADDR_OUTGOING_PROXY '{"get_channels_whitelist": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2
echo "collections whitelist: $($CLI query wasm contract-state smart $ADDR_OUTGOING_PROXY '{"get_collections_whitelist": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2
echo "collection checkums whitelist: $($CLI query wasm contract-state smart $ADDR_OUTGOING_PROXY '{"get_collection_checksums_whitelist": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2
echo "fees collection map: $($CLI query wasm contract-state smart $ADDR_OUTGOING_PROXY '{"get_fees_collection_map": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2
}

ACTION=""
CHAIN=""
VALUE=""
TYPE=""

prev_arg=""
for arg in "$@"; do
case $arg in
--add | --remove | --enable)
ACTION="$arg"
;;
--fees) ;;
--type) ;;
collection | channel | fees | checksum)
if [[ "$prev_arg" != "--type" ]]; then
echo "Invalid argument order. Use --type before specifying 'collection' or 'channel'." >&2
exit 1
fi
TYPE="$arg"
;;
*)
if [[ " ${CHAIN_CHOICES[*]} " =~ " $arg " ]]; then
CHAIN="$arg"
elif [[ "$prev_arg" == "--generate-only" || "$prev_arg" == "--broadcast" ]]; then
FILE="$arg"
elif [[ "$prev_arg" == "--add" || "$prev_arg" == "--remove" || "$prev_arg" == "--enable" ]]; then
VALUE="$arg"
elif [[ "$prev_arg" == "--fees" ]]; then
FEES="$arg"
else
echo "Invalid argument: $arg" >&2
echo "Usage: $0 ${CHAIN_CHOICES_STR// /|} [--add WHITELIST|--remove WHITELIST|--enable true_or_false] --type collection|channel|checksum|fees" >&2
exit 1
fi
;;
esac
prev_arg="$arg"
done

# Check if all required arguments are provided
if [[ -z "$ACTION" || -z "$CHAIN" || -z "$VALUE" ]]; then
echo "Usage: $0 ${CHAIN_CHOICES_STR// /|} [--add WHITELIST|--remove WHITELIST|--enable true_or_false] --type collection|channel|checksum|fees" >&2
echo "Example:" >&2
echo "$0 ${CHAIN_CHOICES_STR// /|} --add channel-1 --type channel" >&2
echo "$0 ${CHAIN_CHOICES_STR// /|} --enable false --type collection" >&2
exit 1
fi

echo "reading $SCRIPT_DIR/$CHAIN.env"
source "$SCRIPT_DIR"/"$CHAIN".env

case $ACTION in
--add)
if [ "$TYPE" == "collection" ]; then
printf -v MSG '{"update_config": {"add_collection_to_whitelist": {"collection": "%s"}}}' $VALUE
elif [ "$TYPE" == "channel" ]; then
printf -v MSG '{"update_config": {"add_channel_to_whitelist": {"channel": "%s"}}}' $VALUE
elif [ "$TYPE" == "fees" ]; then
printf -v MSG '{"update_config": {"add_fees_collection": {"collection": "%s", "fees": {"amount": "%s", "denom": "%s"}}}}' $VALUE $FEES $CLI_DENOM
elif [ "$TYPE" == "checksum" ]; then
printf -v MSG '{"update_config": {"add_collection_checksum_to_whitelist": {"checksum": "%s"}}}' $VALUE
fi
;;
--remove)
if [ "$TYPE" == "collection" ]; then
printf -v MSG '{"update_config": {"remove_collection_from_whitelist": {"collection": "%s"}}}' $VALUE
elif [ "$TYPE" == "channel" ]; then
printf -v MSG '{"update_config": {"remove_channel_from_whitelist": {"channel": "%s"}}}' $VALUE
elif [ "$TYPE" == "fees" ]; then
printf -v MSG '{"update_config": {"remove_fees_collection": {"collection": "%s"}}}' $VALUE
elif [ "$TYPE" == "checksum" ]; then
printf -v MSG '{"update_config": {"remove_collection_checksum_from_whitelist": {"checksum": "%s"}}}' $VALUE
fi
;;
--enable)
if [ "$TYPE" == "collection" ]; then
printf -v MSG '{"update_config": {"enable_collections_whitelist": %s}}' $VALUE
elif [ "$TYPE" == "channel" ]; then
printf -v MSG '{"update_config": {"enable_channels_whitelist": %s}}' $VALUE
elif [ "$TYPE" == "fees" ]; then
printf -v MSG '{"update_config": {"enable_fees_collections_whitelist": %s}}' $VALUE
elif [ "$TYPE" == "checksum" ]; then
printf -v MSG '{"update_config": {"enable_collection_checksums_whitelist": %s}}' $VALUE
fi
;;
*)
echo "Invalid action $ACTION. Use --add, --remove, or --enable." >&2
exit 1
;;
esac

echo "==========================================================================================" >&2
echo "=============== updating $ADDR_OUTGOING_PROXY using dev wallet $WALLET_DEV" >&2
CMD="$CLI tx wasm execute $ADDR_OUTGOING_PROXY '$MSG'"
CMD+=" --from $WALLET"
CMD+=" --gas $CLI_GAS --gas-prices $CLI_GAS_PRICES --gas-adjustment $CLI_GAS_ADJUSTMENT"
CMD+=" --chain-id $CHAIN_ID --node $CHAIN_NODE -y"
echo "$CMD" >&2
echo "Execute TX?" >&2
select yn in "Yes" "No"; do
case $yn in
Yes)
break
;;
No)
exit 0
;;
*)
echo "Please select Yes or No." >&2
;;
esac
done
eval $CMD
ERROR_CODE=${PIPESTATUS[0]}
if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR executing" >&2
exit $ERROR_CODE
fi

echo "==========================================================================================" >&2
echo "config before change $ADDR_OUTGOING_PROXY=$ADDR_OUTGOING_PROXY:" >&2
sleep 10
query_config

Unchanged files with check annotations Beta

const osmosis = { ...oldOsmo, minFee: "0.025uosmo" };
export function bigIntReplacer(_key: string, value: any) {

Check warning on line 29 in ts-relayer-tests/src/utils.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type

Check warning on line 29 in ts-relayer-tests/src/utils.ts

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
if (typeof value === "bigint") {
return value.toString();
}