Skip to content

Commit

Permalink
Update versions and deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
b-j-roberts committed Jun 29, 2024
1 parent d9b2286 commit 4784376
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 8 deletions.
5 changes: 3 additions & 2 deletions configs/sepolia-contracts.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"usernameStore": "0x073128a9f7b38d2bcdb6c1f9ef4fea357de4dfe2fab5832c1e7b51e9aae97c51",
"artPeace": "0x0465839f32ba6b9969d4e08e508e432fd136d019fcc078a06691807a7b22eb47",
"canvasNFT": "0x01db23066e7d6d65cf5b8dfe0f0e1591b5c34a4585108464dbe12e7c7850437b",
"artPeace": "0x075381b84dd86e87836c257615e59cc46bb78bfae45e56d35595e4253e555e80",
"canvasNFT": "0x026774a47ab295f393201403ac8d2a5a7c9befc25c63dc91305a944373a5323a",

"pixelQuest": "0x0715004f8805f938b1d42b0bce12a9b1dc49ec55bb2c401ea9c4695461960576"
}
2 changes: 1 addition & 1 deletion indexer/prod-script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const config = {
streamUrl: Deno.env.get("APIBARA_STREAM_URL"),
startingBlock: 65_000,
startingBlock: 60_000,
network: "starknet",
finality: "DATA_STATUS_PENDING",
filter: {
Expand Down
2 changes: 1 addition & 1 deletion infra/art-peace-infra/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: Helm charts for the art/peace infrastructure

type: application
version: 0.1.0
appVersion: "v0.3.0"
appVersion: "v0.5.0"
4 changes: 2 additions & 2 deletions infra/art-peace-infra/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ apibara:
authToken: dna_aabbcc

contracts:
artPeace: 0x0465839f32ba6b9969d4e08e508e432fd136d019fcc078a06691807a7b22eb47
artPeace: 0x075381b84dd86e87836c257615e59cc46bb78bfae45e56d35595e4253e555e80
usernameStore: 0x073128a9f7b38d2bcdb6c1f9ef4fea357de4dfe2fab5832c1e7b51e9aae97c51
nft: 0x01db23066e7d6d65cf5b8dfe0f0e1591b5c34a4585108464dbe12e7c7850437b
nft: 0x026774a47ab295f393201403ac8d2a5a7c9befc25c63dc91305a944373a5323a
2 changes: 1 addition & 1 deletion tests/integration/sepolia/deploy-daily-quests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ echo "Contract class hash: $QUEST_CONTRACT_CLASSHASH"
# Deploying the contract
QUESTS_CONFIG=$PROJECT_ROOT/configs/quests.config.json

ART_PEACE='0x075ceac501d747749d289cd588f07601b3caad223f4fcfcc803a77311118b1cf'
ART_PEACE='0x075381b84dd86e87836c257615e59cc46bb78bfae45e56d35595e4253e555e80'
REWARD=3
PIXELS_NEEDED=5
IS_DAILY=1
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/sepolia/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ COLORS=$(jq -r '.colors[]' $CANVAS_CONFIG | sed 's/^/0x/')
VOTABLE_COLOR_COUNT=$(jq -r '.votableColors[]' $CANVAS_CONFIG | wc -l | tr -d ' ')
VOTABLE_COLORS=$(jq -r '.votableColors[]' $CANVAS_CONFIG | sed 's/^/0x/')
DAILY_NEW_COLORS_COUNT=3
END_TIME=1719296301
END_TIME=1720276200
DEVNET_MODE=0

DAILY_QUESTS_COUNT=$(jq -r '.daily.dailyQuestsCount' $QUESTS_CONFIG)
Expand Down
141 changes: 141 additions & 0 deletions tests/integration/sepolia/deploy_quests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/bin/bash
#
# This script deploys the ArtPeace contract to the StarkNet devnet in docker

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PROJECT_ROOT=$SCRIPT_DIR/../../..
WORK_DIR=$PROJECT_ROOT

# Load env variable from `.env` only if they're not already set
if [ -z "$STARKNET_KEYSTORE" ] || [ -z "$STARKNET_ACCOUNT" ]; then
source $PROJECT_ROOT/.env
fi

# Check if required env variables are set, if not exit
if [ -z "$STARKNET_KEYSTORE" ]; then
echo "Error: STARKNET_KEYSTORE is not set."
exit 1
elif [ -z "$STARKNET_ACCOUNT" ]; then
echo "Error: STARKNET_ACCOUNT is not set."
exit 1
fi

ART_PEACE_CONTRACT_ADDRESS=0x075381b84dd86e87836c257615e59cc46bb78bfae45e56d35595e4253e555e80
CANVAS_NFT_CONTRACT=0x026774a47ab295f393201403ac8d2a5a7c9befc25c63dc91305a944373a5323a
USERNAME_STORE_CONTRACT=0x073128a9f7b38d2bcdb6c1f9ef4fea357de4dfe2fab5832c1e7b51e9aae97c51

CONTRACT_DIR=$WORK_DIR/onchain

QUESTS_CONFIG=$WORK_DIR/configs/production-quests.config.json
echo "Declaring quest contracts..."
echo
CONTRACT_TYPES=$(jq -r '[.daily.dailyQuests[].quests[].questContract.type,.main.mainQuests[].questContract.type] | unique | .[]' $QUESTS_CONFIG)
DECLARED_CONTRACT_TYPES=( )
DECLARED_CONTRACT_HASHES=( )
# For each contract type echo
for CONTRACT_TYPE in $CONTRACT_TYPES; do
echo " Declaring $CONTRACT_TYPE contract..."
QUEST_SIERRA_FILE=$CONTRACT_DIR/target/dev/art_peace_$CONTRACT_TYPE.contract_class.json
echo "starkli declare --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $QUEST_SIERRA_FILE"
QUEST_DECLARE_OUTPUT=$(starkli declare --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $QUEST_SIERRA_FILE 2>&1)
CLASS_HASH=$(echo $QUEST_DECLARE_OUTPUT | tail -n 1 | awk '{print $NF}')
echo " Declared class \"$CONTRACT_TYPE\" with hash $CLASS_HASH"
if [[ ! -z $CLASS_HASH && $CLASS_HASH != "null" ]]; then
DECLARED_CONTRACT_TYPES+=( $CONTRACT_TYPE )
DECLARED_CONTRACT_HASHES+=( $CLASS_HASH )
fi
done
echo "Declared contracts: ${DECLARED_CONTRACT_TYPES[@]}"
echo "Class hashes: ${DECLARED_CONTRACT_HASHES[@]}"

echo
echo "Deploying daily quest contracts..."
echo
DAILY_QUESTS=$(jq -r '[.daily.dailyQuests[]]' $QUESTS_CONFIG)
for entry in $(echo $DAILY_QUESTS | jq -r '.[] | @base64'); do
_jq() {
echo ${entry} | base64 --decode | jq -r ${1}
}
QUEST_DAY=$(_jq '.day')
DAY_IDX=$(($QUEST_DAY-1))
echo " Deploying daily quest for day $QUEST_DAY..."
echo
QUESTS=$(_jq '[.quests[]]')
DAILY_QUEST_CONTRACTS=( )
for quest in $(echo $QUESTS | jq -r '.[] | @base64'); do
_jq() {
echo ${quest} | base64 --decode | jq -r ${1}
}
QUEST_NAME=$(_jq '.name')
QUEST_REWARD=$(_jq '.reward')
QUEST_TYPE=$(_jq '.questContract.type')
QUEST_INIT_PARAMS=$(_jq '.questContract.initParams')
# Do init params substitutions for $ART_PEACE_CONTRACT,$REWARD,$DAY_IDX
QUEST_INIT_PARAMS=$(echo $QUEST_INIT_PARAMS | sed "s/\$ART_PEACE_CONTRACT/$ART_PEACE_CONTRACT_ADDRESS/g" | sed "s/\$REWARD/$QUEST_REWARD/g" | sed "s/\$DAY_IDX/$DAY_IDX/g" | sed "s/\$USERNAME_STORE_CONTRACT/$USERNAME_STORE_CONTRACT/g" | sed "s/\$CANVAS_NFT_CONTRACT/$CANVAS_NFT_CONTRACT/g")
if [[ ! " ${DECLARED_CONTRACT_TYPES[@]} " =~ " ${QUEST_TYPE} " ]]; then
echo " Contract type \"$QUEST_TYPE\" not declared, skipping deployment..."
DAILY_QUEST_CONTRACTS+=( "0x0" )
continue
fi
echo " Deploying \"$QUEST_NAME\" quest's contract..."
echo " Day: $QUEST_DAY -- $DAY_IDX"
echo " Contract type: $QUEST_TYPE"
CALLDATA=$(echo -n $QUEST_INIT_PARAMS | jq -r '[.[]] | join(" ")')
echo " Contract calldata: $CALLDATA"
CLASS_HASH_IDX=$(echo ${DECLARED_CONTRACT_TYPES[@]} | tr ' ' '\n' | grep -n ^$QUEST_TYPE$ | cut -d: -f1)
CLASS_HASH=${DECLARED_CONTRACT_HASHES[$CLASS_HASH_IDX-1]}
echo " Using class hash $CLASS_HASH"
echo "starkli deploy --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CLASS_HASH $CALLDATA"
QUEST_DEPLOY_OUTPUT=$(starkli deploy --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CLASS_HASH $CALLDATA 2>&1)
CONTRACT_ADDRESS=$(echo $QUEST_DEPLOY_OUTPUT | tail -n 1 | awk '{print $NF}')
echo " Deployed contract \"$QUEST_NAME\" with address $CONTRACT_ADDRESS"
DAILY_QUEST_CONTRACTS+=( $CONTRACT_ADDRESS )
echo
done
echo " Deployed daily quest contracts: ${DAY_IDX} -- ${DAILY_QUEST_CONTRACTS[@]}"
echo "starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS add_daily_quests $DAY_IDX ${#DAILY_QUEST_CONTRACTS[@]} ${DAILY_QUEST_CONTRACTS[@]}"
starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS add_daily_quests $DAY_IDX ${#DAILY_QUEST_CONTRACTS[@]} ${DAILY_QUEST_CONTRACTS[@]}
DAILY_QUEST_CONTRACTS=( )
done

echo
echo "Deploying main quest contracts..."
echo
MAIN_QUESTS=$(jq -r '[.main.mainQuests[]]' $QUESTS_CONFIG)
MAIN_QUEST_CONTRACTS=( )
for entry in $(echo $MAIN_QUESTS | jq -r '.[] | @base64'); do
_jq() {
echo ${entry} | base64 --decode | jq -r ${1}
}
QUEST_NAME=$(_jq '.name')
QUEST_REWARD=$(_jq '.reward')
QUEST_TYPE=$(_jq '.questContract.type')
QUEST_INIT_PARAMS=$(_jq '.questContract.initParams')
# Do init params substitutions for $ART_PEACE_CONTRACT,$REWARD
QUEST_INIT_PARAMS=$(echo $QUEST_INIT_PARAMS | sed "s/\$ART_PEACE_CONTRACT/$ART_PEACE_CONTRACT_ADDRESS/g" | sed "s/\$REWARD/$QUEST_REWARD/g" | sed "s/\$USERNAME_STORE_CONTRACT/$USERNAME_STORE_CONTRACT/g" | sed "s/\$CANVAS_NFT_CONTRACT/$CANVAS_NFT_CONTRACT/g")
if [[ ! " ${DECLARED_CONTRACT_TYPES[@]} " =~ " ${QUEST_TYPE} " ]]; then
echo " Contract type \"$QUEST_TYPE\" not declared, skipping deployment..."
MAIN_QUEST_CONTRACTS+=( "0x0" )
continue
fi
echo " Deploying \"$QUEST_NAME\" quest's contract..."
echo " Contract type: $QUEST_TYPE"
CALLDATA=$(echo -n $QUEST_INIT_PARAMS | jq -r '[.[]] | join(" ")')
echo " Contract calldata: $CALLDATA"
CLASS_HASH_IDX=$(echo ${DECLARED_CONTRACT_TYPES[@]} | tr ' ' '\n' | grep -n ^$QUEST_TYPE$ | cut -d: -f1)
CLASS_HASH=${DECLARED_CONTRACT_HASHES[$CLASS_HASH_IDX-1]}
echo " Using class hash $CLASS_HASH"
echo "starkli deploy --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CLASS_HASH $CALLDATA"
QUEST_DEPLOY_OUTPUT=$(starkli deploy --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CLASS_HASH $CALLDATA 2>&1)
CONTRACT_ADDRESS=$(echo $QUEST_DEPLOY_OUTPUT | tail -n 1 | awk '{print $NF}')
echo " Deployed contract \"$QUEST_NAME\" with address $CONTRACT_ADDRESS"
MAIN_QUEST_CONTRACTS+=( $CONTRACT_ADDRESS )
echo
done
echo "Deployed main quest contracts: ${MAIN_QUEST_CONTRACTS[@]}"
echo "starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS add_main_quests ${#MAIN_QUEST_CONTRACTS[@]} ${MAIN_QUEST_CONTRACTS[@]}"
starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS add_main_quests ${#MAIN_QUEST_CONTRACTS[@]} ${MAIN_QUEST_CONTRACTS[@]}

#echo "Setting up contract \"$ART_PEACE_CLASS_NAME\"..."
#echo "/root/.local/bin/sncast --url $RPC_URL --accounts-file $ACCOUNT_FILE --account $ACCOUNT_NAME --wait --json invoke --contract-address $ART_PEACE_CONTRACT_ADDRESS --function set_nft_contract --calldata $NFT_CONTRACT_ADDRESS"
#/root/.local/bin/sncast --url $RPC_URL --accounts-file $ACCOUNT_FILE --account $ACCOUNT_NAME --wait --json invoke --contract-address $ART_PEACE_CONTRACT_ADDRESS --function add_nft_contract --calldata $NFT_CONTRACT_ADDRESS

0 comments on commit 4784376

Please sign in to comment.