-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec99f2f
commit 5c50240
Showing
6 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
{ | ||
"host": "api.art-peace.net", | ||
"host": "localhost", | ||
"port": 8080, | ||
"consumer_port": 8081, | ||
"scripts": { | ||
"place_pixel_devnet": "../tests/integration/local/place_pixel.sh", | ||
"place_extra_pixels_devnet": "../tests/integration/local/place_extra_pixels.sh", | ||
"add_template_devnet": "../tests/integration/local/add_template.sh", | ||
"mint_nft_devnet": "../tests/integration/local/mint_nft.sh" | ||
"mint_nft_devnet": "../tests/integration/local/mint_nft.sh", | ||
"like_nft_devnet": "../tests/integration/local/like_nft.sh", | ||
"unlike_nft_devnet": "../tests/integration/local/unlike_nft.sh", | ||
"vote_color_devnet": "../tests/integration/local/vote_color.sh", | ||
"increase_day_devnet": "../tests/integration/local/increase_day_index.sh", | ||
"join_chain_faction_devnet": "../tests/integration/local/join_chain_faction.sh", | ||
"join_faction_devnet": "../tests/integration/local/join_faction.sh", | ||
"leave_faction_devnet": "../tests/integration/local/leave_faction.sh", | ||
"add_faction_template_devnet": "../tests/integration/local/add_faction_template.sh", | ||
"remove_faction_template_devnet": "../tests/integration/local/remove_faction_template.sh" | ||
}, | ||
"production": true, | ||
"production": false, | ||
"websocket": { | ||
"read_buffer_size": 1024, | ||
"write_buffer_size": 1024 | ||
}, | ||
"http_config": { | ||
"allow_origin": ["*"], | ||
"allow_methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"], | ||
"allow_headers": ["Content-Type"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
ENVIRONMENT="docker" | ||
RPC_URL="http://localhost:5050" | ||
ACCOUNT_FILE="~/.art-peace-tests/tmp/starknet_accounts.json" | ||
ACCOUNT_NAME="art_peace_acct" | ||
ART_PEACE_CONTRACT="" # Add contract address | ||
|
||
source "$(dirname "$0")/reward.sh" "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
ENVIRONMENT="mainnet" | ||
NETWORK="mainnet" | ||
ART_PEACE_CONTRACT="0x067883deb1c1cb60756eb6e60d500081352441a040d5039d0e4ce9fed35d68c1" | ||
|
||
export STARKNET_RPC="https://starknet-mainnet.public.blastapi.io" | ||
|
||
source "$(dirname "$0")/reward.sh" "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
|
||
# Check if JSON file is provided | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <rewards.json>" | ||
exit 1 | ||
fi | ||
|
||
REWARDS_FILE=$1 | ||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
PROJECT_ROOT=$SCRIPT_DIR/../.. | ||
|
||
# Check if required commands exist | ||
command -v jq >/dev/null 2>&1 || { echo "Error: jq is required but not installed. Please install jq first using 'brew install jq'"; exit 1; } | ||
|
||
# Check if rewards file exists and is valid JSON | ||
if [ ! -f "$REWARDS_FILE" ]; then | ||
echo "Error: Rewards file not found at: $REWARDS_FILE" | ||
echo "Please create a rewards.json file with the following format:" | ||
echo '{ | ||
"rewards": [ | ||
{ | ||
"address": "0x123...", | ||
"amount": 10 | ||
} | ||
] | ||
}' | ||
exit 1 | ||
fi | ||
|
||
# Validate environment variables | ||
if [ "$ENVIRONMENT" = "docker" ]; then | ||
if [ -z "$RPC_URL" ] || [ -z "$ACCOUNT_FILE" ] || [ -z "$ACCOUNT_NAME" ]; then | ||
echo "Error: Docker environment variables not set" | ||
exit 1 | ||
fi | ||
else | ||
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 | ||
fi | ||
|
||
# Read and process rewards JSON | ||
REWARDS=$(cat $REWARDS_FILE | jq -r '.rewards[] | "\(.address) \(.amount)"') | ||
|
||
while IFS= read -r line; do | ||
if [ -z "$line" ]; then | ||
continue | ||
fi | ||
|
||
ADDRESS=$(echo $line | cut -d' ' -f1) | ||
AMOUNT=$(echo $line | cut -d' ' -f2) | ||
|
||
echo "Awarding $AMOUNT pixels to $ADDRESS..." | ||
|
||
# Call contract based on environment | ||
if [ "$ENVIRONMENT" = "docker" ]; then | ||
echo "Running docker command:" | ||
echo "sncast --account $ACCOUNT_NAME call --url $RPC_URL --contract-address $ART_PEACE_CONTRACT --function host_award_user --calldata $ADDRESS $AMOUNT" | ||
sncast --account $ACCOUNT_NAME \ | ||
call \ | ||
--url $RPC_URL \ | ||
--contract-address $ART_PEACE_CONTRACT \ | ||
--function host_award_user \ | ||
--calldata $ADDRESS $AMOUNT \ | ||
--block-id latest | ||
else | ||
echo "Running starkli command:" | ||
echo "starkli invoke $ART_PEACE_CONTRACT host_award_user $ADDRESS $AMOUNT --network $NETWORK --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch" | ||
if ! starkli invoke $ART_PEACE_CONTRACT host_award_user $ADDRESS $AMOUNT \ | ||
--network $NETWORK --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch; then | ||
echo "Error: Failed to award pixels. Make sure:" | ||
echo "1. The contract address is correct: $ART_PEACE_CONTRACT" | ||
echo "2. Your account has host privileges" | ||
echo "3. The address format is correct: $ADDRESS" | ||
echo "4. The amount is valid: $AMOUNT" | ||
exit 1 | ||
fi | ||
fi | ||
done <<< "$REWARDS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"rewards": [ | ||
{ | ||
"address": "0x05e01dB693CBF7461a016343042786DaC5A6000104813cF134a1E8B1D0a6810b", | ||
"amount": 10 | ||
}, | ||
{ | ||
"address": "0x05e01dB693CBF7461a016343042786DaC5A6000104813cF134a1E8B1D0a6810b", | ||
"amount": 5 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
ENVIRONMENT="sepolia" | ||
NETWORK="sepolia" | ||
ART_PEACE_CONTRACT="0x078f4e772300472a68a19f2b1aedbcb7cf2acd6f67a2236372310a528c7eaa67" | ||
|
||
export STARKNET_RPC="https://starknet-sepolia.public.blastapi.io" | ||
|
||
source "$(dirname "$0")/reward.sh" "$1" |