From 22c26f968d765626c51cdc116581e172de019df9 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Tue, 11 Jun 2024 00:31:47 -0500 Subject: [PATCH 1/3] Latest sepolia deployment --- configs/sepolia-contracts.config.json | 4 +- frontend/src/contracts/art_peace.abi.json | 119 ++++++++++++++++++---- infra/art-peace-infra/Chart.yaml | 2 +- tests/integration/sepolia/deploy.sh | 2 +- 4 files changed, 103 insertions(+), 24 deletions(-) diff --git a/configs/sepolia-contracts.config.json b/configs/sepolia-contracts.config.json index e32f48c7..624a176f 100644 --- a/configs/sepolia-contracts.config.json +++ b/configs/sepolia-contracts.config.json @@ -1,6 +1,6 @@ { "usernameStore": "0x073128a9f7b38d2bcdb6c1f9ef4fea357de4dfe2fab5832c1e7b51e9aae97c51", - "artPeace": "0x075ceac501d747749d289cd588f07601b3caad223f4fcfcc803a77311118b1cf", - "canvasNFT": "0x0408344d68130bf550d5fe1b70637b270bca09ec1461fecfb953d3d49fd3f2ac", + "artPeace": "0x0465839f32ba6b9969d4e08e508e432fd136d019fcc078a06691807a7b22eb47", + "canvasNFT": "0x01db23066e7d6d65cf5b8dfe0f0e1591b5c34a4585108464dbe12e7c7850437b", "pixelQuest": "0x0715004f8805f938b1d42b0bce12a9b1dc49ec55bb2c401ea9c4695461960576" } diff --git a/frontend/src/contracts/art_peace.abi.json b/frontend/src/contracts/art_peace.abi.json index bc97f7f4..1a0ffd3c 100644 --- a/frontend/src/contracts/art_peace.abi.json +++ b/frontend/src/contracts/art_peace.abi.json @@ -444,6 +444,22 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "get_user_factions_count", + "inputs": [ + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "get_faction", @@ -626,6 +642,26 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "get_user_vote", + "inputs": [ + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "day", + "type": "core::integer::u32" + } + ], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "get_votable_colors", @@ -801,26 +837,6 @@ "outputs": [], "state_mutability": "external" }, - { - "type": "function", - "name": "claim_daily_quest", - "inputs": [ - { - "name": "day_index", - "type": "core::integer::u32" - }, - { - "name": "quest_id", - "type": "core::integer::u32" - }, - { - "name": "calldata", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, { "type": "function", "name": "claim_today_quest", @@ -1023,6 +1039,38 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "complete_template_with_rewards", + "inputs": [ + { + "name": "template_id", + "type": "core::integer::u32" + }, + { + "name": "template_image", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "compute_template_hash", + "inputs": [ + { + "name": "template", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" } ] }, @@ -1213,6 +1261,10 @@ { "name": "daily_quests_count", "type": "core::integer::u32" + }, + { + "name": "devmode", + "type": "core::bool" } ] }, @@ -1466,6 +1518,28 @@ } ] }, + { + "type": "event", + "name": "art_peace::art_peace::ArtPeace::VotableColorAdded", + "kind": "struct", + "members": [ + { + "name": "day", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "color_key", + "type": "core::integer::u8", + "kind": "key" + }, + { + "name": "color", + "type": "core::integer::u32", + "kind": "data" + } + ] + }, { "type": "event", "name": "art_peace::templates::component::TemplateStoreComponent::TemplateAdded", @@ -1567,6 +1641,11 @@ "type": "art_peace::art_peace::ArtPeace::MemberReplaced", "kind": "nested" }, + { + "name": "VotableColorAdded", + "type": "art_peace::art_peace::ArtPeace::VotableColorAdded", + "kind": "nested" + }, { "name": "TemplateEvent", "type": "art_peace::templates::component::TemplateStoreComponent::Event", diff --git a/infra/art-peace-infra/Chart.yaml b/infra/art-peace-infra/Chart.yaml index 494a3fb0..47c867b0 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.2.1" +appVersion: "v0.3.0" diff --git a/tests/integration/sepolia/deploy.sh b/tests/integration/sepolia/deploy.sh index b8ed8f54..7667c9df 100755 --- a/tests/integration/sepolia/deploy.sh +++ b/tests/integration/sepolia/deploy.sh @@ -104,7 +104,7 @@ COLORS=$(jq -r '.colors[]' $CANVAS_CONFIG | sed 's/^/0x/') VOTABLE_COLOR_COUNT=$(jq -r '.votableColors[]' $CANVAS_CONFIG | wc -l | tr -d ' ') VOTABLE_COLORS=$(jq -r '.votableColors[]' $CANVAS_CONFIG | sed 's/^/0x/') DAILY_NEW_COLORS_COUNT=3 -END_TIME=1717165800 +END_TIME=1719296301 DEVNET_MODE=0 DAILY_QUESTS_COUNT=$(jq -r '.daily.dailyQuestsCount' $QUESTS_CONFIG) From 54b6790e6646dc1ba268abd4aa05d480dc08803f Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Tue, 11 Jun 2024 02:12:57 -0500 Subject: [PATCH 2/3] Patch nft volume mount --- Makefile | 5 ++--- backend/cmd/consumer/consumer.go | 1 + backend/routes/nft.go | 3 +++ .../admin-backend/admin-backend-deployment.yaml | 7 ------- .../templates/backend/backend-deployment.yaml | 7 ------- .../templates/backend/backend-ingress.yaml | 14 ++++++++++++++ infra/art-peace-infra/values.yaml | 4 ++-- tests/integration/sepolia/deploy.sh | 2 +- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 4d90e96d..369c860c 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ helm-uninstall: helm-install: $(eval COMMIT_SHA := $(shell git rev-parse --short HEAD)) @echo "Installing helm chart..." - helm install --set postgres.password=$(POSTGRES_PASSWORD) --set apibara.authToken=$(AUTH_TOKEN) art-peace-infra infra/art-peace-infra + helm install --set postgres.password=$(POSTGRES_PASSWORD) --set deployments.sha=$(COMMIT_SHA) --set apibara.authToken=$(AUTH_TOKEN) art-peace-infra infra/art-peace-infra helm-template: $(eval COMMIT_SHA := $(shell git rev-parse --short HEAD)) @@ -68,5 +68,4 @@ init-infra-prod: @echo "Initializing infra..." curl https://api.art-peace.net/init-canvas -X POST curl https://api.art-peace.net/init-colors -X POST -d "[$(COLORS)]" - curl https://api.art-peace.net/init-votable-colors -X POST -d "[$(VOTABLE_COLORS)]" - curl https://api.art-peace.net/init-quests -X POST -d "@configs/quests.config.json" + curl https://api.art-peace.net/init-quests -X POST -d "@configs/production-quests.config.json" diff --git a/backend/cmd/consumer/consumer.go b/backend/cmd/consumer/consumer.go index f76d981e..68795959 100644 --- a/backend/cmd/consumer/consumer.go +++ b/backend/cmd/consumer/consumer.go @@ -54,6 +54,7 @@ func main() { routes.InitBaseRoutes() indexer.InitIndexerRoutes() routes.InitWebsocketRoutes() + routes.InitNFTStaticRoutes() indexer.StartMessageProcessor() core.ArtPeaceBackend.Start(core.ArtPeaceBackend.BackendConfig.ConsumerPort) diff --git a/backend/routes/nft.go b/backend/routes/nft.go index 84fd768f..62404789 100644 --- a/backend/routes/nft.go +++ b/backend/routes/nft.go @@ -24,6 +24,9 @@ func InitNFTRoutes() { } // Create a static file server for the nft images // TODO: Versioning here? +} + +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")))) } diff --git a/infra/art-peace-infra/templates/admin-backend/admin-backend-deployment.yaml b/infra/art-peace-infra/templates/admin-backend/admin-backend-deployment.yaml index d41fccb8..af18c19d 100644 --- a/infra/art-peace-infra/templates/admin-backend/admin-backend-deployment.yaml +++ b/infra/art-peace-infra/templates/admin-backend/admin-backend-deployment.yaml @@ -22,10 +22,3 @@ spec: envFrom: - configMapRef: name: {{ .Values.labels.backend.name }}-secret - volumeMounts: - - mountPath: /app/nfts - name: {{ .Values.volumes.nfts.name }} - volumes: - - name: {{ .Values.volumes.nfts.name }} - persistentVolumeClaim: - claimName: {{ .Values.volumes.nfts.claim }} diff --git a/infra/art-peace-infra/templates/backend/backend-deployment.yaml b/infra/art-peace-infra/templates/backend/backend-deployment.yaml index 68f0cbc3..33f6014b 100644 --- a/infra/art-peace-infra/templates/backend/backend-deployment.yaml +++ b/infra/art-peace-infra/templates/backend/backend-deployment.yaml @@ -22,10 +22,3 @@ spec: envFrom: - configMapRef: name: {{ .Values.labels.backend.name }}-secret - volumeMounts: - - mountPath: /app/nfts - name: {{ .Values.volumes.nfts.name }} - volumes: - - name: {{ .Values.volumes.nfts.name }} - persistentVolumeClaim: - claimName: {{ .Values.volumes.nfts.claim }} diff --git a/infra/art-peace-infra/templates/backend/backend-ingress.yaml b/infra/art-peace-infra/templates/backend/backend-ingress.yaml index 1d2f3b4a..d5ecb7ab 100644 --- a/infra/art-peace-infra/templates/backend/backend-ingress.yaml +++ b/infra/art-peace-infra/templates/backend/backend-ingress.yaml @@ -15,6 +15,20 @@ spec: name: {{ .Values.labels.consumer.name }} port: number: {{ .Values.ports.consumer }} + - path: /nft-images + pathType: Prefix + backend: + service: + name: {{ .Values.labels.consumer.name }} + port: + number: {{ .Values.ports.consumer }} + - path: /nft-meta + pathType: Prefix + backend: + service: + name: {{ .Values.labels.consumer.name }} + port: + number: {{ .Values.ports.consumer }} - http: paths: - path: / diff --git a/infra/art-peace-infra/values.yaml b/infra/art-peace-infra/values.yaml index f217932b..3c54485e 100644 --- a/infra/art-peace-infra/values.yaml +++ b/infra/art-peace-infra/values.yaml @@ -68,6 +68,6 @@ apibara: authToken: dna_aabbcc contracts: - artPeace: 0x075ceac501d747749d289cd588f07601b3caad223f4fcfcc803a77311118b1cf + artPeace: 0x0465839f32ba6b9969d4e08e508e432fd136d019fcc078a06691807a7b22eb47 usernameStore: 0x073128a9f7b38d2bcdb6c1f9ef4fea357de4dfe2fab5832c1e7b51e9aae97c51 - nft: 0x072f12a6056df3e4c683d3a7fba1e1a1a702c51e1b1928fb058e91294c738984 + nft: 0x01db23066e7d6d65cf5b8dfe0f0e1591b5c34a4585108464dbe12e7c7850437b diff --git a/tests/integration/sepolia/deploy.sh b/tests/integration/sepolia/deploy.sh index 7667c9df..d934afd4 100755 --- a/tests/integration/sepolia/deploy.sh +++ b/tests/integration/sepolia/deploy.sh @@ -93,7 +93,7 @@ echo "Contract class hash: $ART_PEACE_CONTRACT_CLASSHASH" # Deploying the contract CANVAS_CONFIG=$PROJECT_ROOT/configs/canvas.config.json -QUESTS_CONFIG=$PROJECT_ROOT/configs/quests.config.json +QUESTS_CONFIG=$PROJECT_ROOT/configs/production-quests.config.json ACCOUNT_ADDRESS=$(cat $STARKNET_ACCOUNT | jq -r '.deployment.address') WIDTH=$(jq -r '.canvas.width' $CANVAS_CONFIG) From 0d5a8b3c4ecb4f69baca44fe27349fb9a8a8c23a Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Tue, 11 Jun 2024 02:38:00 -0500 Subject: [PATCH 3/3] Patch timing on frontend --- Makefile | 1 - frontend/src/App.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 369c860c..27bc5a5b 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,6 @@ helm-upgrade: init-infra-prod: $(eval COLORS := $(shell cat configs/canvas.config.json | jq -r '.colors | map("\"\(.)\"") | join(",")')) - $(eval VOTABLE_COLORS := $(shell cat configs/canvas.config.json | jq -r '.votableColors | map("\"\(.)\"") | join(",")')) @echo "Initializing infra..." curl https://api.art-peace.net/init-canvas -X POST curl https://api.art-peace.net/init-colors -X POST -d "[$(COLORS)]" diff --git a/frontend/src/App.js b/frontend/src/App.js index a824e87a..9654a6ca 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -191,7 +191,7 @@ function App() { fetchGetLastPlacedPixel(); }, [queryAddress]); - const updateInterval = 1000; // 1 second + const updateInterval = 120000; // 1 second // TODO: make this a config const timeBetweenPlacements = 1000; // 2 minutes const [basePixelTimer, setBasePixelTimer] = useState('XX:XX');