diff --git a/backend/routes/quests.go b/backend/routes/quests.go
index 66033863..0a403376 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/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"
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