From 4079934fe5b6fedcb2193353a2fd392c9e7dd888 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Fri, 28 Jun 2024 22:11:18 -0500 Subject: [PATCH 1/4] Debug text --- backend/routes/quests.go | 1 + infra/art-peace-infra/Chart.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/routes/quests.go b/backend/routes/quests.go index 66033863..fbbad431 100644 --- a/backend/routes/quests.go +++ b/backend/routes/quests.go @@ -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 } diff --git a/infra/art-peace-infra/Chart.yaml b/infra/art-peace-infra/Chart.yaml index 47e8e3d0..e11b186c 100644 --- a/infra/art-peace-infra/Chart.yaml +++ b/infra/art-peace-infra/Chart.yaml @@ -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" From a24ce3130200749a9e09547e44c4bd91bb89bfee Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Fri, 28 Jun 2024 23:02:38 -0500 Subject: [PATCH 2/4] Update frontend contracts abi --- frontend/src/contracts/art_peace.abi.json | 4 ++++ frontend/src/contracts/canvas_nft.abi.json | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/frontend/src/contracts/art_peace.abi.json b/frontend/src/contracts/art_peace.abi.json index 2f889e5d..41d93921 100644 --- a/frontend/src/contracts/art_peace.abi.json +++ b/frontend/src/contracts/art_peace.abi.json @@ -951,6 +951,10 @@ { "name": "height", "type": "core::integer::u128" + }, + { + "name": "name", + "type": "core::felt252" } ] }, diff --git a/frontend/src/contracts/canvas_nft.abi.json b/frontend/src/contracts/canvas_nft.abi.json index 4831b772..1039f46f 100644 --- a/frontend/src/contracts/canvas_nft.abi.json +++ b/frontend/src/contracts/canvas_nft.abi.json @@ -101,6 +101,10 @@ "name": "height", "type": "core::integer::u128" }, + { + "name": "name", + "type": "core::felt252" + }, { "name": "image_hash", "type": "core::felt252" From 665e2943112b2c691ff7f0fd046fb1f1e740bd1a Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Fri, 28 Jun 2024 23:30:11 -0500 Subject: [PATCH 3/4] Setup factions sepolia and fix missing args on frontend faction join --- frontend/src/tabs/TabPanel.js | 2 + tests/integration/sepolia/setup_factions.sh | 59 +++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 tests/integration/sepolia/setup_factions.sh diff --git a/frontend/src/tabs/TabPanel.js b/frontend/src/tabs/TabPanel.js index 6e563411..943cca0d 100644 --- a/frontend/src/tabs/TabPanel.js +++ b/frontend/src/tabs/TabPanel.js @@ -136,6 +136,8 @@ const TabPanel = (props) => { {props.activeTab === 'Factions' && (
/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 From a49a5c53ca0782de33d311f2efc2598d2d9ea8b4 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Fri, 28 Jun 2024 23:30:43 -0500 Subject: [PATCH 4/4] go fmt --- backend/routes/quests.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/quests.go b/backend/routes/quests.go index fbbad431..0a403376 100644 --- a/backend/routes/quests.go +++ b/backend/routes/quests.go @@ -151,7 +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) + fmt.Println("Error inserting daily quest, ", idx, err) routeutils.WriteErrorJson(w, http.StatusInternalServerError, "Failed to insert daily quest") return }