From acbcf41f558b7cb9db6a4a402872a958891a9d2b Mon Sep 17 00:00:00 2001 From: Nino Lipartiia Date: Thu, 22 Dec 2022 16:15:36 +0200 Subject: [PATCH] Script for the task that executes passed proposals --- .../create-auto-execute-dao-task.sh | 79 +++++++++++++++++++ scripts/uni-testnet/proxy-call-with-query.sh | 28 +++++++ 2 files changed, 107 insertions(+) create mode 100644 scripts/uni-testnet/create-auto-execute-dao-task.sh create mode 100644 scripts/uni-testnet/proxy-call-with-query.sh diff --git a/scripts/uni-testnet/create-auto-execute-dao-task.sh b/scripts/uni-testnet/create-auto-execute-dao-task.sh new file mode 100644 index 00000000..f0d4b5bc --- /dev/null +++ b/scripts/uni-testnet/create-auto-execute-dao-task.sh @@ -0,0 +1,79 @@ +set -e + +SH_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" +SH_DIR="$(cd -P "$(dirname "${SH_PATH}")";pwd)" +. $SH_DIR/base/init-vars.sh + +if [ -z "$1" ]; then + echo "Must provide contract address" + exit 1 +elif [ -z "$2" ]; then + echo "Must provide user address" + exit 1 +elif [ -z "$3" ]; then + echo "Must provide rules address" + exit 1 +elif [ -z "$4" ]; then + echo "Must provide dao address" + exit 1 +elif [ -z "$5" ]; then + echo "Must provide agent address" + exit 1 +fi + +CONTRACT="$1" +USER="$2" +RULES="$3" +DAO="$4" +AGENT="$5" + +EXECUTE_MSG='{"execute":{"proposal_id":""}}' +ENCODED_EXECUTE_MSG=$(printf $EXECUTE_MSG | base64) + +DAODAO='{ + "create_task": { + "task": { + "interval": "Immediate", + "cw20_coins": [], + "stop_on_fail": false, + "actions": [ + { + "msg": { + "wasm": { + "execute": { + "contract_addr": "'$DAO'", + "msg": "'$ENCODED_EXECUTE_MSG'", + "funds": [] + } + } + }, + "gas_limit": 300000 + } + ], + "queries": [ + { + "check_passed_proposals": { + "dao_address": "'$DAO'" + } + } + ], + "transforms": [ + { + "action_idx": 0, + "query_idx": 0, + "action_path": [ + { + "key": "execute" + }, + { + "key": "proposal_id" + } + ], + "query_response_path": [] + } + ] + } + } +}' + +junod tx wasm execute $CONTRACT "$DAODAO" --amount 1000000ujunox --from "$USER" $TXFLAG -y diff --git a/scripts/uni-testnet/proxy-call-with-query.sh b/scripts/uni-testnet/proxy-call-with-query.sh new file mode 100644 index 00000000..022a75fc --- /dev/null +++ b/scripts/uni-testnet/proxy-call-with-query.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +SH_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" +SH_DIR="$(cd -P "$(dirname "${SH_PATH}")";pwd)" +. $SH_DIR/base/init-vars.sh + +if [ -z "$1" ] +then + echo "Must provide contract address" + exit 1 +elif [ -z "$2" ] +then + echo "Must provide address of the agent" + exit 1 +elif [ -z "$3" ] +then + echo "Must provide the task hash" + exit 1 +else + CONTRACT="$1" + AGENT="$2" + HASH="$3" +fi + + +PROXY_CALL='{"proxy_call":{"task_hash": "'$HASH'"}}' +junod tx wasm execute $CONTRACT "$PROXY_CALL" --from $AGENT $TXFLAG -y