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

Dev/deployment testing #242

Merged
merged 4 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions backend/routes/quests.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func InitQuests(w http.ResponseWriter, r *http.Request) {
for idx, questConfig := range dailyQuestConfig.Quests {
_, err := core.ArtPeaceBackend.Databases.Postgres.Exec(context.Background(), "INSERT INTO DailyQuests (name, description, reward, day_index, quest_id, quest_type) VALUES ($1, $2, $3, $4, $5, $6)", questConfig.Name, questConfig.Description, questConfig.Reward, dailyQuestConfig.Day-1, idx, questConfig.ContractConfig.Type)
if err != nil {
fmt.Println("Error inserting daily quest, ", idx, err)
routeutils.WriteErrorJson(w, http.StatusInternalServerError, "Failed to insert daily quest")
return
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/contracts/art_peace.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,10 @@
{
"name": "height",
"type": "core::integer::u128"
},
{
"name": "name",
"type": "core::felt252"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/contracts/canvas_nft.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
"name": "height",
"type": "core::integer::u128"
},
{
"name": "name",
"type": "core::felt252"
},
{
"name": "image_hash",
"type": "core::felt252"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/tabs/TabPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ const TabPanel = (props) => {
{props.activeTab === 'Factions' && (
<div>
<Factions
address={props.address}
artPeaceContract={props.artPeaceContract}
queryAddress={props.queryAddress}
setActiveTab={props.setActiveTab}
chainFaction={props.chainFaction}
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.5.0"
appVersion: "v0.5.1"
59 changes: 59 additions & 0 deletions tests/integration/sepolia/setup_factions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
#
# This script runs the integration tests.

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

# 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

FACTIONS_CONFIG_FILE=$WORK_DIR/configs/factions.config.json

for entry in $(cat $FACTIONS_CONFIG_FILE | jq -r '.factions.[] | @base64'); do
_jq() {
echo ${entry} | base64 --decode | jq -r ${1}
}

FACTION_ID=$(_jq '.id')
FACTION_NAME=$(_jq '.name')
FACTION_LEADER=$(_jq '.leader')
JOINABLE=$(_jq '.joinable')
ALLOCATION=$(_jq '.allocation')

# Add faction onchain
FACTION_NAME_HEX=0x$(echo -n $FACTION_NAME | xxd -p)
FACTION_JOINABLE_HEX=1
if [ "$JOINABLE" = "false" ]; then
FACTION_JOINABLE_HEX=0
fi

CALLDATA="$FACTION_NAME_HEX $FACTION_LEADER $FACTION_JOINABLE_HEX $ALLOCATION"
echo "starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS init_faction $CALLDATA"
starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS init_faction $CALLDATA
done

for entry in $(cat $FACTIONS_CONFIG_FILE | jq -r '.chain_factions.[]'); do
FACTION_NAME=$entry
FACTION_NAME_HEX=0x$(echo -n $FACTION_NAME | xxd -p)

CALLDATA="$FACTION_NAME_HEX"
echo "starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS init_chain_faction $CALLDATA"
starkli invoke --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $ART_PEACE_CONTRACT_ADDRESS init_chain_faction $CALLDATA
done

# #TODO: rename script and make more generic