diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c95d5ea9..0a04bd4a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -## 🛠️ Contributing to art/peace 🛠️ +# 🛠️ Contributing to art/peace 🛠️ Welcome, contributing to `art/peace` is easy! @@ -8,7 +8,7 @@ Welcome, contributing to `art/peace` is easy! 1. Submit your PR against `main` 1. Address PR Review -### Issue +## Issue Project tracking is done via GitHub [issues](https://github.com/keep-starknet-strange/art-peace/issues). First look at open issues to see if your request is already submitted. @@ -26,12 +26,12 @@ These labels are used as prefixes as follows for `issue`, `branch name`, `pr tit - `[bug]` -> `bug/{issue #}-{issue name}` -> `bug:` - `[dev]` -> `dev/{issue #}-{issue name}` -> `dev:` -#### TODO +### TODO If your PR includes a `TODO` comment please open an issue and comment the relevant code with `TODO(#ISSUE_NUM):`. -### Submit PR +## Submit PR Ensure your code is well formatted, well tested and well documented. A core contributor will review your work. Address changes, ensure ci passes, @@ -49,7 +49,7 @@ Scarb linter: scarb fmt ``` -### Additional Resources +## Additional Resources - [Cairo Book](https://book.cairo-lang.org/) - [Starknet Book](https://book.starknet.io/) @@ -58,6 +58,4 @@ scarb fmt - [Starkli Book](https://book.starkli.rs/) - [Syncing a Fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) -## - Thank you for your contribution! diff --git a/README.md b/README.md index b4d9cd4d..8fd5ec2a 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,8 @@ > Art Peace Round 2 is live! - > Check live stats on this cool [Dune Dashboard](https://dune.com/hessish/artpeace) - -> And go place some pixels and draw cool shit you mfer! ==> https://www.art-peace.net/ +> And go place some pixels and draw cool shit you mfer! ==> [art-peace.net](https://www.art-peace.net) ## Overview diff --git a/backend/routes/indexer/nft.go b/backend/routes/indexer/nft.go index 2d698310..b70e5371 100644 --- a/backend/routes/indexer/nft.go +++ b/backend/routes/indexer/nft.go @@ -162,32 +162,33 @@ func processNFTMintedEvent(event IndexerEvent) { } // TODO: Check if file exists - if _, err := os.Stat("nfts"); os.IsNotExist(err) { - err = os.MkdirAll("nfts", os.ModePerm) - if err != nil { - PrintIndexerError("processNFTMintedEvent", "Error creating nfts directory", tokenIdLowHex, positionHex, widthHex, heightHex, nameHex, imageHashHex, blockNumberHex, minter) - return - } + roundNumber := os.Getenv("ROUND_NUMBER") + if roundNumber == "" { + PrintIndexerError("processNFTMintedEvent", "Error getting round number from environment", tokenIdLowHex, positionHex, widthHex, heightHex, nameHex, imageHashHex, blockNumberHex, minter) + return } + roundDir := fmt.Sprintf("round-%s", roundNumber) - if _, err := os.Stat("nfts/images"); os.IsNotExist(err) { - err = os.MkdirAll("nfts/images", os.ModePerm) - if err != nil { - PrintIndexerError("processNFTMintedEvent", "Error creating nfts/images directory", tokenIdLowHex, positionHex, widthHex, heightHex, nameHex, imageHashHex, blockNumberHex, minter) - return - } + // Create base directories if they don't exist + dirs := []string{ + "nfts", + fmt.Sprintf("nfts/%s", roundDir), + fmt.Sprintf("nfts/%s/images", roundDir), + fmt.Sprintf("nfts/%s/metadata", roundDir), } - if _, err := os.Stat("nfts/meta"); os.IsNotExist(err) { - err = os.MkdirAll("nfts/meta", os.ModePerm) - if err != nil { - PrintIndexerError("processNFTMintedEvent", "Error creating nfts/meta directory", tokenIdLowHex, positionHex, widthHex, heightHex, nameHex, imageHashHex, blockNumberHex, minter) - return + for _, dir := range dirs { + if _, err := os.Stat(dir); os.IsNotExist(err) { + err = os.MkdirAll(dir, os.ModePerm) + if err != nil { + PrintIndexerError("processNFTMintedEvent", fmt.Sprintf("Error creating %s directory", dir), tokenIdLowHex, positionHex, widthHex, heightHex, nameHex, imageHashHex, blockNumberHex, minter) + return + } } } // Save image to disk - filename := fmt.Sprintf("nfts/images/nft-%d.png", tokenId) + filename := fmt.Sprintf("nfts/%s/images/nft-%d.png", roundDir, tokenId) file, err := os.Create(filename) if err != nil { PrintIndexerError("processNFTMintedEvent", "Error creating file", tokenIdLowHex, tokenIdHighHex, positionHex, widthHex, heightHex, nameHex, imageHashHex, blockNumberHex, minter) @@ -207,15 +208,15 @@ func processNFTMintedEvent(event IndexerEvent) { metadata := map[string]interface{}{ "name": name, "description": "User minted art/peace NFT from the canvas.", - "image": fmt.Sprintf("%s/nft-images/nft-%d.png", core.ArtPeaceBackend.GetBackendUrl(), tokenId), + "image": fmt.Sprintf("%s/nft/%s/image/nft-%d.png", core.ArtPeaceBackend.GetBackendUrl(), roundDir, tokenId), "attributes": []map[string]interface{}{ { "trait_type": "Width", - "value": fmt.Sprintf("%d", scaledWidth), + "value": fmt.Sprintf("%d", width), }, { "trait_type": "Height", - "value": fmt.Sprintf("%d", scaledHeight), + "value": fmt.Sprintf("%d", height), }, { "trait_type": "Position", @@ -242,7 +243,7 @@ func processNFTMintedEvent(event IndexerEvent) { return } - metadataFilename := fmt.Sprintf("nfts/meta/nft-%d.json", tokenId) + metadataFilename := fmt.Sprintf("nfts/%s/metadata/nft-%d.json", roundDir, tokenId) err = os.WriteFile(metadataFilename, metadataFile, 0644) if err != nil { PrintIndexerError("processNFTMintedEvent", "Error writing NFT metadata file", tokenIdLowHex, positionHex, widthHex, heightHex, nameHex, imageHashHex, blockNumberHex, minter) diff --git a/backend/routes/nft.go b/backend/routes/nft.go index 9d2e70e4..e27aaefa 100644 --- a/backend/routes/nft.go +++ b/backend/routes/nft.go @@ -33,8 +33,7 @@ func InitNFTRoutes() { } func InitNFTStaticRoutes() { - http.Handle("/nft-images/", http.StripPrefix("/nft-images/", http.FileServer(http.Dir("./nfts/images")))) - http.Handle("/nft-meta/", http.StripPrefix("/nft-meta/", http.FileServer(http.Dir("./nfts/meta")))) + http.Handle("/nft/", http.StripPrefix("/nft/", http.FileServer(http.Dir("./nfts")))) } func getCanvasNFTAddress(w http.ResponseWriter, r *http.Request) { diff --git a/docker-compose.yml b/docker-compose.yml index 1b827f76..55e12a46 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,6 +35,7 @@ services: - POSTGRES_PASSWORD=password - ART_PEACE_END_TIME=3000000000 - ART_PEACE_HOST=0328ced46664355fc4b885ae7011af202313056a7e3d44827fb24c9d3206aaa0 + - ROUND_NUMBER=1 consumer: build: dockerfile: backend/Dockerfile.consumer @@ -47,6 +48,7 @@ services: restart: always environment: - POSTGRES_PASSWORD=password + - ROUND_NUMBER=1 volumes: - nfts:/app/nfts devnet: @@ -138,6 +140,7 @@ services: - devnet environment: - REACT_APP_BASE_PIXEL_TIMER=30000 + - REACT_APP_ROUND_NUMBER=1 volumes: - ./frontend/package.json:/app/package.json - ./frontend/package-lock.json:/app/package-lock.json diff --git a/frontend/src/tabs/nfts/NFTs.js b/frontend/src/tabs/nfts/NFTs.js index 9febad4e..414a1089 100644 --- a/frontend/src/tabs/nfts/NFTs.js +++ b/frontend/src/tabs/nfts/NFTs.js @@ -14,7 +14,9 @@ import { import { PaginationView } from '../../ui/pagination.js'; const NFTsMainSection = (props) => { - const imageURL = nftUrl + '/nft-images/'; + const roundNumber = process.env.REACT_APP_ROUND_NUMBER || '0'; + const imageURL = `${nftUrl}/nft/round-${roundNumber}/images/`; + const metadataURL = `${nftUrl}/nft/round-${roundNumber}/metadata/`; return (
{ tokenId={nft.tokenId} position={nft.position} image={imageURL + 'nft-' + nft.tokenId + '.png'} + metadata={metadataURL + 'nft-' + nft.tokenId + '.json'} width={nft.width} height={nft.height} name={nft.name} @@ -86,7 +89,9 @@ const NFTsMainSection = (props) => { }; const NFTsExpandedSection = (props) => { - const imageURL = nftUrl + '/nft-images/'; + const roundNumber = process.env.REACT_APP_ROUND_NUMBER || '0'; + const imageURL = `${nftUrl}/nft/round-${roundNumber}/images/`; + const metadataURL = `${nftUrl}/nft/round-${roundNumber}/metadata/`; return (
@@ -121,6 +126,7 @@ const NFTsExpandedSection = (props) => { tokenId={nft.tokenId} position={nft.position} image={imageURL + 'nft-' + nft.tokenId + '.png'} + metadata={metadataURL + 'nft-' + nft.tokenId + '.json'} width={nft.width} height={nft.height} name={nft.name} diff --git a/infra/instructions/kube-deploy-steps.txt b/infra/instructions/kube-deploy-steps.txt index 0259b30b..dac2624c 100644 --- a/infra/instructions/kube-deploy-steps.txt +++ b/infra/instructions/kube-deploy-steps.txt @@ -8,12 +8,12 @@ deploy username store to sepolia save address deploy art peace to sepolia vim ./tests/integration/sepolia/deploy.sh - change end time + change end time & round number ./tests/integration/sepolia/deploy.sh save address deploy canvas nft to sepolia ./tests/integration/sepolia/deploy-canvas-nft.sh - save address + save address & round number and set in art_peace contract deploy quests vim ./tests/integration/sepolia/deploy-daily-quests.sh diff --git a/onchain/README.md b/onchain/README.md index 51198add..2f15b9bb 100644 --- a/onchain/README.md +++ b/onchain/README.md @@ -4,12 +4,12 @@ This directory contains the onchain Starknet contract components for `art/peace` ## Build -``` +```bash scarb build ``` ## Test -``` +```bash scarb test ``` diff --git a/onchain/src/art_peace.cairo b/onchain/src/art_peace.cairo index d1ce12b0..7735dcba 100644 --- a/onchain/src/art_peace.cairo +++ b/onchain/src/art_peace.cairo @@ -636,7 +636,8 @@ pub mod ArtPeace { } let member_metadata = self.users_faction_meta.read(user); if member_metadata.member_pixels > 0 { - // TODO: If member_pixels > 0 && < allocation && enough time has passed, return allocation instead of member_pixels + // TODO: If member_pixels > 0 && < allocation && enough time has passed, return + // allocation instead of member_pixels return member_metadata.member_pixels; } else { let time_since_last_pixel = now - member_metadata.member_placed_time; diff --git a/onchain/src/nfts/canvas_nft.cairo b/onchain/src/nfts/canvas_nft.cairo index 2bdb1f51..b63749b4 100644 --- a/onchain/src/nfts/canvas_nft.cairo +++ b/onchain/src/nfts/canvas_nft.cairo @@ -70,8 +70,12 @@ mod CanvasNFT { #[constructor] - fn constructor(ref self: ContractState, name: ByteArray, symbol: ByteArray) { - let base_uri = "https://api.art-peace.net/nft-meta/nft-"; + fn constructor( + ref self: ContractState, name: ByteArray, symbol: ByteArray, round_number: felt252 + ) { + let base_uri = format!( + "https://api.art-peace.net/nft/round-{}/metadata/nft-", round_number + ); self.erc721.initializer(name, symbol, base_uri); } diff --git a/onchain/src/tests/art_peace.cairo b/onchain/src/tests/art_peace.cairo index 5e211af3..e7d74f73 100644 --- a/onchain/src/tests/art_peace.cairo +++ b/onchain/src/tests/art_peace.cairo @@ -70,7 +70,7 @@ pub(crate) fn deploy_contract() -> ContractAddress { start_time: 0, end_time: 1000000, daily_quests_count: 3, - devmode: false + devmode: false, } .serialize(ref calldata); let contract_addr = contract.deploy_at(@calldata, utils::ART_PEACE_CONTRACT()).unwrap(); @@ -162,6 +162,8 @@ fn deploy_nft_contract() -> ContractAddress { let symbol: ByteArray = "A/P"; name.serialize(ref calldata); symbol.serialize(ref calldata); + let round_number: u32 = 1; + round_number.serialize(ref calldata); contract.deploy_at(@calldata, utils::NFT_CONTRACT()).unwrap() } @@ -398,7 +400,7 @@ fn nft_mint_test() { assert!(nft.balance_of(utils::PLAYER2()) == 1, "NFT balance is not correct after transfer"); let nft_meta = IERC721MetadataDispatcher { contract_address: nft.contract_address }; - let expected_uri = "https://api.art-peace.net/nft-meta/nft-0.json"; + let expected_uri = "https://api.art-peace.net/nft/round-1/metadata/nft-0.json"; assert!(nft_meta.token_uri(0) == expected_uri, "NFT URI is not correct"); } @@ -416,8 +418,8 @@ fn nft_set_base_uri_test() { nft_minter.mint_nft(mint_params); snf::stop_prank(CheatTarget::One(nft_minter.contract_address)); - let _base_uri: ByteArray = "https://api.art-peace.net/nft-meta/nft-"; - let expected_uri: ByteArray = "https://api.art-peace.net/nft-meta/nft-0.json"; + let _base_uri: ByteArray = "https://api.art-peace.net/nft/round-1/metadata/nft-"; + let expected_uri: ByteArray = "https://api.art-peace.net/nft/round-1/metadata/nft-0.json"; let nft_meta = IERC721MetadataDispatcher { contract_address: nft.contract_address }; assert!(nft_meta.token_uri(0) == expected_uri, "NFT URI is not correct before change"); diff --git a/onchain/src/tests/vote_quest.cairo b/onchain/src/tests/vote_quest.cairo index e1b3b6d6..11e43d58 100644 --- a/onchain/src/tests/vote_quest.cairo +++ b/onchain/src/tests/vote_quest.cairo @@ -97,7 +97,7 @@ fn vote_quest_double_claim_test() { art_peace_dispatcher.claim_main_quest(0, utils::EMPTY_CALLDATA()); } -// When the `votable_colors` storage variable is not set for a particular day index, trying to +// When the `votable_colors` storage variable is not set for a particular day index, trying to // vote for a color at that day panics with 'Color out of bounds' error #[test] #[should_panic(expected: 'Color out of bounds')] diff --git a/tests/integration/docker/award_pixels.sh b/tests/integration/docker/award_pixels.sh new file mode 100755 index 00000000..76afa311 --- /dev/null +++ b/tests/integration/docker/award_pixels.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Load environment variables from `.env` file +if [ -f ../.env ]; then + export $(grep -v '^#' ../.env | xargs) +fi + +# Set environment and network details +ENVIRONMENT="local" +NETWORK_URL="http://localhost:5050" # Use the URL from your console output +ART_PEACE_CONTRACT="0x6fe75e8821863019aa3e7b824cceaa8a42265bbf1374e3c92eebc698036d438" + +# Define the JSON file path from command line argument +JSON_FILE_PATH="$1" + +# Verify contract exists before proceeding +echo "Verifying contract at $ART_PEACE_CONTRACT..." +if ! starkli class-hash-at $ART_PEACE_CONTRACT --rpc $NETWORK_URL > /dev/null 2>&1; then + echo "Error: ArtPeace contract not found at $ART_PEACE_CONTRACT" + echo "Please verify the contract address is correct" + exit 1 +fi + +echo "Contract verified successfully!" + +# Iterate through each user address and amount in the JSON file +jq -c '.[]' "$JSON_FILE_PATH" | while read -r entry; do + USER_ADDRESS=$(echo "$entry" | jq -r '.address') + AMOUNT=$(echo "$entry" | jq -r '.amount') + echo "Awarding $AMOUNT pixels to $USER_ADDRESS..." + + # Invoke the host_award_user function using starkli + starkli invoke --rpc $NETWORK_URL --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT \ + --watch $ART_PEACE_CONTRACT host_award_user $USER_ADDRESS $AMOUNT +done diff --git a/tests/integration/docker/deploy.sh b/tests/integration/docker/deploy.sh index 2eab87f2..fc99d764 100755 --- a/tests/integration/docker/deploy.sh +++ b/tests/integration/docker/deploy.sh @@ -74,7 +74,8 @@ echo "Declared class \"$NFT_CLASS_NAME\" with hash $NFT_CLASS_HASH" NFT_NAME="0 318195848183955342120051 10" NFT_SYMBOL="0 4271952 3" -CALLDATA=$(echo -n $NFT_NAME $NFT_SYMBOL) +ROUND_NUMBER=3 +CALLDATA=$(echo -n $NFT_NAME $NFT_SYMBOL $ROUND_NUMBER) echo "Deploying contract \"$NFT_CLASS_NAME\"..." echo "/root/.local/bin/sncast --url $RPC_URL --accounts-file $ACCOUNT_FILE --account $ACCOUNT_NAME --wait --json deploy --class-hash $NFT_CLASS_HASH --constructor-calldata $CALLDATA" diff --git a/tests/integration/docker/rewards.json b/tests/integration/docker/rewards.json new file mode 100644 index 00000000..f23b5a8f --- /dev/null +++ b/tests/integration/docker/rewards.json @@ -0,0 +1,10 @@ +[ + { + "address": "0x328ced46664355fc4b885ae7011af202313056a7e3d44827fb24c9d3206aaa0", + "amount": 10 + }, + { + "address": "0x05e01dB693CBF7461a016343042786DaC5A6000104813cF134a1E8B1D0a6810b", + "amount": 20 + } +] diff --git a/tests/integration/local/deploy.sh b/tests/integration/local/deploy.sh index e2fd77df..b7855341 100755 --- a/tests/integration/local/deploy.sh +++ b/tests/integration/local/deploy.sh @@ -69,7 +69,8 @@ echo "Deployed contract \"$ART_PEACE_CLASS_NAME\" with address $ART_PEACE_CONTRA NFT_NAME="0 318195848183955342120051 10" NFT_SYMBOL="0 4271952 3" -CALLDATA=$(echo -n $NFT_NAME $NFT_SYMBOL) +ROUND_NUMBER=3 +CALLDATA=$(echo -n $NFT_NAME $NFT_SYMBOL $ROUND_NUMBER) echo "Deploying contract \"$NFT_CLASS_NAME\"..." echo "sncast --url $RPC_URL --accounts-file $ACCOUNT_FILE --account $ACCOUNT_NAME --wait --json deploy --class-hash $NFT_CLASS_HASH --constructor-calldata $CALLDATA" diff --git a/tests/integration/mainnet/award_pixels.sh b/tests/integration/mainnet/award_pixels.sh new file mode 100755 index 00000000..47f2e62f --- /dev/null +++ b/tests/integration/mainnet/award_pixels.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Award pixels to users + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +WORK_DIR=$SCRIPT_DIR/../../.. +PROJECT_ROOT=$WORK_DIR + +# Load environment variables from `.env` file +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=0x067883deb1c1cb60756eb6e60d500081352441a040d5039d0e4ce9fed35d68c1 +NETWORK=mainnet + +# Define the JSON file path from command line argument +JSON_FILE_PATH="$1" + +# Verify contract exists before proceeding +echo "Verifying contract at $ART_PEACE_CONTRACT..." +if ! starkli class-hash-at $ART_PEACE_CONTRACT --network $NETWORK > /dev/null 2>&1; then + echo "Error: ArtPeace contract not found at $ART_PEACE_CONTRACT" + echo "Please verify the contract address is correct" + exit 1 +fi + +# Iterate through each user address and amount in the JSON file +jq -c '.[]' "$JSON_FILE_PATH" | while read -r entry; do + USER_ADDRESS=$(echo "$entry" | jq -r '.address') + AMOUNT=$(echo "$entry" | jq -r '.amount') + echo "Awarding $AMOUNT pixels to $USER_ADDRESS..." + + # Invoke the host_award_user function using starkli + echo "starkli invoke --network $NETWORK --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT \ + --watch $ART_PEACE_CONTRACT host_award_user $USER_ADDRESS $AMOUNT" + starkli invoke --network $NETWORK --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT \ + --watch $ART_PEACE_CONTRACT host_award_user $USER_ADDRESS $AMOUNT +done diff --git a/tests/integration/mainnet/deploy-canvas-nft.sh b/tests/integration/mainnet/deploy-canvas-nft.sh index ff2fcf8e..2bf41e8a 100755 --- a/tests/integration/mainnet/deploy-canvas-nft.sh +++ b/tests/integration/mainnet/deploy-canvas-nft.sh @@ -77,8 +77,10 @@ CANVAS_NFT_DECLARE_OUTPUT=$(starkli declare --network mainnet --keystore $STARKN CANVAS_NFT_CONTRACT_CLASSHASH=$(echo $CANVAS_NFT_DECLARE_OUTPUT | tail -n 1 | awk '{print $NF}') echo "Contract class hash: $CANVAS_NFT_CONTRACT_CLASSHASH" +ROUND_NUMBER=3 + # Deploying the contract -CALLDATA=$(echo 0 81458137135092567582733106 11 0 4271952 3) +CALLDATA=$(echo 0 81458137135092567582733106 11 0 4271952 $ROUND_NUMBER) echo "Deploying the contract..." echo "starkli deploy --network mainnet --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CANVAS_NFT_CONTRACT_CLASSHASH $CALLDATA" starkli deploy --network mainnet --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CANVAS_NFT_CONTRACT_CLASSHASH $CALLDATA diff --git a/tests/integration/sepolia/award_pixels.sh b/tests/integration/sepolia/award_pixels.sh new file mode 100755 index 00000000..6fcd3c14 --- /dev/null +++ b/tests/integration/sepolia/award_pixels.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Award pixels to users + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +WORK_DIR=$SCRIPT_DIR/../../.. +PROJECT_ROOT=$WORK_DIR + +# Load environment variables from `.env` file +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=0x078f4e772300472a68a19f2b1aedbcb7cf2acd6f67a2236372310a528c7eaa67 +NETWORK=sepolia + +# Define the JSON file path from command line argument +JSON_FILE_PATH="$1" + +# Verify contract exists before proceeding +echo "Verifying contract at $ART_PEACE_CONTRACT..." +if ! starkli class-hash-at $ART_PEACE_CONTRACT --network $NETWORK > /dev/null 2>&1; then + echo "Error: ArtPeace contract not found at $ART_PEACE_CONTRACT" + echo "Please verify the contract address is correct" + exit 1 +fi + +# Iterate through each user address and amount in the JSON file +jq -c '.[]' "$JSON_FILE_PATH" | while read -r entry; do + USER_ADDRESS=$(echo "$entry" | jq -r '.address') + AMOUNT=$(echo "$entry" | jq -r '.amount') + echo "Awarding $AMOUNT pixels to $USER_ADDRESS..." + + # Invoke the host_award_user function using starkli + echo "starkli invoke --network $NETWORK --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT \ + --watch $ART_PEACE_CONTRACT host_award_user $USER_ADDRESS $AMOUNT" + starkli invoke --network $NETWORK --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT \ + --watch $ART_PEACE_CONTRACT host_award_user $USER_ADDRESS $AMOUNT +done diff --git a/tests/integration/sepolia/deploy-canvas-nft.sh b/tests/integration/sepolia/deploy-canvas-nft.sh index 1d5262ef..f70febd3 100755 --- a/tests/integration/sepolia/deploy-canvas-nft.sh +++ b/tests/integration/sepolia/deploy-canvas-nft.sh @@ -77,8 +77,10 @@ CANVAS_NFT_DECLARE_OUTPUT=$(starkli declare --network sepolia --keystore $STARKN CANVAS_NFT_CONTRACT_CLASSHASH=$(echo $CANVAS_NFT_DECLARE_OUTPUT | tail -n 1 | awk '{print $NF}') echo "Contract class hash: $CANVAS_NFT_CONTRACT_CLASSHASH" +ROUND_NUMBER=3 + # Deploying the contract -CALLDATA=$(echo 0 318195848183955342120051 10 0 4271952 3) +CALLDATA=$(echo 0 318195848183955342120051 10 0 4271952 $ROUND_NUMBER) echo "Deploying the contract..." echo "starkli deploy --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CANVAS_NFT_CONTRACT_CLASSHASH $CALLDATA" starkli deploy --network sepolia --keystore $STARKNET_KEYSTORE --account $STARKNET_ACCOUNT --watch $CANVAS_NFT_CONTRACT_CLASSHASH $CALLDATA