-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from arkprotocol/main
scripts for ics721 setup
- Loading branch information
Showing
13 changed files
with
756 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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 | ||
|
||
NOTE: | ||
Below scripts use [select-chain.sh](./select-chain.sh). For each selected chain there is an `.env` file like `stargaze.env` and `osmosis.env`. | ||
|
||
## Scripts | ||
|
||
### Initial Setup | ||
|
||
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) | ||
|
||
After instantiation: | ||
|
||
- update `ADDR_ICS721`, `ADDR_INCOMING_PROXY`, `ADDR_OUTGOING_PROXY` in env file | ||
- Note: ICS721 is instantiated without(!) proxies, proxies are added via migration (velow) | ||
|
||
### Migration | ||
|
||
1. ICS721 : [migrate-ics721.sh](./migrate-ics721.sh) | ||
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 | ||
|
||
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 | ||
``` | ||
|
||
The owner of the outgoing proxy contract can add, remove and enable whitelists for collections, channels, collection checksums, and collection fees. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# ---------------------------------------------------- | ||
# Instantiates the ICS721 contract with cw721_base_code_id and pauser | ||
# ---------------------------------------------------- | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
# ---------------------------------------------------- | ||
# 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) | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
# ---------------------------------------------------- | ||
# 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) | ||
|
||
# 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 <<EOF | ||
{ | ||
"config": { | ||
"origin": "$ADDR_ICS721", | ||
"owner": "$WALLET_OWNER" | ||
}, | ||
"proxy": { | ||
"rate_limit": {"per_block": 100}, | ||
"channels": $CHANNELS, | ||
"collections": $COLLECTIONS | ||
} | ||
} | ||
EOF | ||
) | ||
LABEL="ICS721 Outgoing Whitelist Channel Proxy" | ||
CMD="$CLI tx wasm instantiate $CODE_ID_OUTGOING_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
# ---------------------------------------------------- | ||
# 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) | ||
|
||
# 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 | ||
|
||
function query_config() { | ||
echo "cw721 code id: $($CLI query wasm contract-state smart $ADDR_ICS721 '{"cw721_code_id": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2 | ||
echo "cw721 admin: $($CLI query wasm contract-state smart $ADDR_ICS721 '{"cw721_admin": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2 | ||
echo "outgoing proxy: $($CLI query wasm contract-state smart $ADDR_ICS721 '{"outgoing_proxy": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2 | ||
echo "incoming proxy: $($CLI query wasm contract-state smart $ADDR_ICS721 '{"incoming_proxy": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2 | ||
echo "pauser: $($CLI query wasm contract-state smart $ADDR_ICS721 '{"pauser": {}}' --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2 | ||
echo "contract: $($CLI query wasm contract $ADDR_ICS721 --chain-id $CHAIN_ID --node $CHAIN_NODE | jq)" >&2 | ||
} | ||
|
||
echo "==========================================================================================" >&2 | ||
echo "configs before migration $ADDR_ICS721:" >&2 | ||
query_config | ||
|
||
echo "==========================================================================================" >&2 | ||
echo "!!! migrating $ADDR_ICS721 data: proxy: $ADDR_OUTGOING_PROXY, cw721 code id: $CODE_ID_CW721 !!!" >&2 # use CW721 if not set | ||
MSG=$( | ||
cat <<EOF | ||
{"with_update":{ | ||
"incoming_proxy": "$ADDR_INCOMING_PROXY", | ||
"outgoing_proxy": "$ADDR_OUTGOING_PROXY", | ||
"cw721_base_code_id": $CODE_ID_CW721, | ||
"pauser": "$WALLET_OWNER", | ||
"cw721_admin": "$WALLET_ADMIN" | ||
} | ||
} | ||
EOF | ||
) | ||
CMD="$CLI tx wasm migrate $ADDR_ICS721 $CODE_ID_ICS721 '$MSG'" | ||
CMD+=" --from $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 | ||
if [ $? -ne 0 ]; then | ||
echo "failed to migrate $ADDR_ICS721" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "==========================================================================================" >&2 | ||
echo "configs after migration $ADDR_ICS721:" >&2 | ||
sleep 10 | ||
query_config |
Oops, something went wrong.