Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
b-j-roberts committed Dec 4, 2024
2 parents 54aed76 + d3a6b42 commit 91bfc90
Show file tree
Hide file tree
Showing 32 changed files with 994 additions and 322 deletions.
117 changes: 117 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,123 @@
"contributions": [
"code"
]
},
{
"login": "lfgtwo",
"name": "lfg2",
"avatar_url": "https://avatars.githubusercontent.com/u/171595475?v=4",
"profile": "https://github.com/lfgtwo",
"contributions": [
"code"
]
},
{
"login": "zintarh",
"name": "Zintarh",
"avatar_url": "https://avatars.githubusercontent.com/u/35270183?v=4",
"profile": "https://github.com/zintarh",
"contributions": [
"code"
]
},
{
"login": "Mystic-Nayy",
"name": "Naomi",
"avatar_url": "https://avatars.githubusercontent.com/u/149405096?v=4",
"profile": "https://github.com/Mystic-Nayy",
"contributions": [
"code"
]
},
{
"login": "supreme2580",
"name": "Supreme Labs",
"avatar_url": "https://avatars.githubusercontent.com/u/100731397?v=4",
"profile": "https://github.com/supreme2580",
"contributions": [
"code"
]
},
{
"login": "AbdelStark",
"name": "A₿del ∞/21M",
"avatar_url": "https://avatars.githubusercontent.com/u/45264458?v=4",
"profile": "https://github.com/AbdelStark",
"contributions": [
"code"
]
},
{
"login": "jjjike2021",
"name": "jike",
"avatar_url": "https://avatars.githubusercontent.com/u/171845810?v=4",
"profile": "https://github.com/jjjike2021",
"contributions": [
"code"
]
},
{
"login": "bloomingpeach",
"name": "Rumia",
"avatar_url": "https://avatars.githubusercontent.com/u/177087057?v=4",
"profile": "https://github.com/bloomingpeach",
"contributions": [
"code"
]
},
{
"login": "OkoliEvans",
"name": "Okoli Evans",
"avatar_url": "https://avatars.githubusercontent.com/u/95226065?v=4",
"profile": "https://github.com/OkoliEvans",
"contributions": [
"code"
]
},
{
"login": "Iwueseiter",
"name": "Iwueseiter",
"avatar_url": "https://avatars.githubusercontent.com/u/156322726?v=4",
"profile": "https://github.com/Iwueseiter",
"contributions": [
"code"
]
},
{
"login": "Shoetan",
"name": "Emmanuel Soetan",
"avatar_url": "https://avatars.githubusercontent.com/u/17912134?v=4",
"profile": "https://soetandev.netlify.app/",
"contributions": [
"code"
]
},
{
"login": "EmmanuelAR",
"name": "Emmanuel Agüero ",
"avatar_url": "https://avatars.githubusercontent.com/u/54730752?v=4",
"profile": "https://github.com/EmmanuelAR",
"contributions": [
"code"
]
},
{
"login": "muheebyusufbaba1",
"name": "Babs",
"avatar_url": "https://avatars.githubusercontent.com/u/134698940?v=4",
"profile": "https://github.com/muheebyusufbaba1",
"contributions": [
"code"
]
},
{
"login": "adrianvrj",
"name": "ADR!AN",
"avatar_url": "https://avatars.githubusercontent.com/u/111903096?v=4",
"profile": "https://github.com/adrianvrj",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ Thanks goes to these wonderful people. Follow the [contributors guide](https://g
<td align="center" valign="top" width="14.28%"><a href="https://github.com/BillXJ"><img src="https://avatars.githubusercontent.com/u/91419841?v=4?s=100" width="100px;" alt="BillXJ"/><br /><sub><b>BillXJ</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=BillXJ" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Jemiiah"><img src="https://avatars.githubusercontent.com/u/160767568?v=4?s=100" width="100px;" alt="Jemiiah"/><br /><sub><b>Jemiiah</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=Jemiiah" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/UmarSalihu"><img src="https://avatars.githubusercontent.com/u/56638850?v=4?s=100" width="100px;" alt="Umar I Salihu"/><br /><sub><b>Umar I Salihu</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=UmarSalihu" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lfgtwo"><img src="https://avatars.githubusercontent.com/u/171595475?v=4?s=100" width="100px;" alt="lfg2"/><br /><sub><b>lfg2</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=lfgtwo" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zintarh"><img src="https://avatars.githubusercontent.com/u/35270183?v=4?s=100" width="100px;" alt="Zintarh"/><br /><sub><b>Zintarh</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=zintarh" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Mystic-Nayy"><img src="https://avatars.githubusercontent.com/u/149405096?v=4?s=100" width="100px;" alt="Naomi"/><br /><sub><b>Naomi</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=Mystic-Nayy" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/supreme2580"><img src="https://avatars.githubusercontent.com/u/100731397?v=4?s=100" width="100px;" alt="Supreme Labs"/><br /><sub><b>Supreme Labs</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=supreme2580" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AbdelStark"><img src="https://avatars.githubusercontent.com/u/45264458?v=4?s=100" width="100px;" alt="A₿del ∞/21M"/><br /><sub><b>A₿del ∞/21M</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=AbdelStark" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jjjike2021"><img src="https://avatars.githubusercontent.com/u/171845810?v=4?s=100" width="100px;" alt="jike"/><br /><sub><b>jike</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=jjjike2021" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bloomingpeach"><img src="https://avatars.githubusercontent.com/u/177087057?v=4?s=100" width="100px;" alt="Rumia"/><br /><sub><b>Rumia</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=bloomingpeach" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/OkoliEvans"><img src="https://avatars.githubusercontent.com/u/95226065?v=4?s=100" width="100px;" alt="Okoli Evans"/><br /><sub><b>Okoli Evans</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=OkoliEvans" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Iwueseiter"><img src="https://avatars.githubusercontent.com/u/156322726?v=4?s=100" width="100px;" alt="Iwueseiter"/><br /><sub><b>Iwueseiter</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=Iwueseiter" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://soetandev.netlify.app/"><img src="https://avatars.githubusercontent.com/u/17912134?v=4?s=100" width="100px;" alt="Emmanuel Soetan"/><br /><sub><b>Emmanuel Soetan</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=Shoetan" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/EmmanuelAR"><img src="https://avatars.githubusercontent.com/u/54730752?v=4?s=100" width="100px;" alt="Emmanuel Agüero "/><br /><sub><b>Emmanuel Agüero </b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=EmmanuelAR" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/muheebyusufbaba1"><img src="https://avatars.githubusercontent.com/u/134698940?v=4?s=100" width="100px;" alt="Babs"/><br /><sub><b>Babs</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=muheebyusufbaba1" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/adrianvrj"><img src="https://avatars.githubusercontent.com/u/111903096?v=4?s=100" width="100px;" alt="ADR!AN"/><br /><sub><b>ADR!AN</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=adrianvrj" title="Code">💻</a></td>
</tr>
</tbody>
<tfoot>
Expand Down
62 changes: 62 additions & 0 deletions backend/routes/nft.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package routes

import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
Expand All @@ -19,6 +21,7 @@ func InitNFTRoutes() {
http.HandleFunc("/get-new-nfts", getNewNFTs)
http.HandleFunc("/get-my-nfts", getMyNFTs)
http.HandleFunc("/get-nft-likes", getNftLikeCount)
http.HandleFunc("/get-nft-pixel-data", getNftPixelData)
// http.HandleFunc("/like-nft", LikeNFT)
// http.HandleFunc("/unlike-nft", UnLikeNFT)
http.HandleFunc("/get-top-nfts", getTopNFTs)
Expand Down Expand Up @@ -220,6 +223,65 @@ func getNewNFTs(w http.ResponseWriter, r *http.Request) {
routeutils.WriteDataJson(w, string(nfts))
}

func getNftPixelData(w http.ResponseWriter, r *http.Request) {
tokenId := r.URL.Query().Get("tokenId")
if tokenId == "" {
routeutils.WriteErrorJson(w, http.StatusBadRequest, "TokenId parameter is required")
return
}

// First get the NFT data to access the imageHash
nft, err := core.PostgresQueryOneJson[NFTData]("SELECT * FROM nfts WHERE token_id = $1", tokenId)
if err != nil {
routeutils.WriteErrorJson(w, http.StatusNotFound, "NFT not found")
return
}

var nftData NFTData
if err := json.Unmarshal([]byte(nft), &nftData); err != nil {
routeutils.WriteErrorJson(w, http.StatusInternalServerError, "Failed to parse NFT data")
return
}

// Try to read from file first
roundNumber := os.Getenv("ROUND_NUMBER")
if roundNumber == "" {
roundNumber = "1" // Default to round 1 if not set
}

filename := fmt.Sprintf("nfts/round-%s/images/nft-%s.png", roundNumber, tokenId)
fileBytes, err := os.ReadFile(filename)
if err != nil {
routeutils.WriteErrorJson(w, http.StatusInternalServerError, "Failed to read image file")
return
}

// If we have the file, process it using imageToPixelData
pixelData, err := imageToPixelData(fileBytes, 10)
if err != nil {
routeutils.WriteErrorJson(w, http.StatusInternalServerError, "Failed to process image")
return
}

response := struct {
Width int `json:"width"`
Height int `json:"height"`
PixelData []int `json:"pixelData"`
}{
Width: nftData.Width,
Height: nftData.Height,
PixelData: pixelData,
}

jsonResponse, err := json.Marshal(response)
if err != nil {
routeutils.WriteErrorJson(w, http.StatusInternalServerError, "Failed to create response")
return
}

routeutils.WriteDataJson(w, string(jsonResponse))
}

func mintNFTDevnet(w http.ResponseWriter, r *http.Request) {
// Disable this in production
if routeutils.NonProductionMiddleware(w, r) {
Expand Down
6 changes: 3 additions & 3 deletions backend/routes/stencils.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func addStencilImg(w http.ResponseWriter, r *http.Request) {
}
bounds := img.Bounds()
width, height := bounds.Max.X-bounds.Min.X, bounds.Max.Y-bounds.Min.Y
if width < 5 || width > 64 || height < 5 || height > 64 {
if width < 5 || width > 256 || height < 5 || height > 256 {
routeutils.WriteErrorJson(w, http.StatusBadRequest, "Invalid image dimensions")
return
}
Expand All @@ -402,7 +402,7 @@ func addStencilImg(w http.ResponseWriter, r *http.Request) {

r.Body.Close()

imageData, err := imageToPixelData(fileBytes)
imageData, err := imageToPixelData(fileBytes, 1)
if err != nil {
routeutils.WriteErrorJson(w, http.StatusInternalServerError, "Failed to convert image to pixel data")
return
Expand Down Expand Up @@ -466,7 +466,7 @@ func addStencilData(w http.ResponseWriter, r *http.Request) {
return
}

if width < 5 || width > 64 || height < 5 || height > 64 {
if width < 5 || width > 256 || height < 5 || height > 256 {
routeutils.WriteErrorJson(w, http.StatusBadRequest, "Invalid image dimensions")
return
}
Expand Down
Loading

0 comments on commit 91bfc90

Please sign in to comment.