Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Deposit reward when adding new template #34

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
"contributions": [
"code"
]
},
{
"login": "Ayoazeez26",
"name": "Abdulhakeem Abdulazeez Ayodeji",
"avatar_url": "https://avatars.githubusercontent.com/u/44169294?v=4",
"profile": "https://github.com/Ayoazeez26",
"contributions": [
"code"
]
},
{
"login": "tekkac",
"name": "Trunks @ Carbonable",
"avatar_url": "https://avatars.githubusercontent.com/u/98529704?v=4",
"profile": "https://github.com/tekkac",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ jobs:
working-directory: onchain
- run: scarb build
working-directory: onchain
- name: go formatting ( gofmt -s -w . )
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
working-directory: backend
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ build/
node_modules/

# Backend
art-peace-backend
/backend/backend
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ 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/b-j-roberts"><img src="https://avatars.githubusercontent.com/u/54774639?v=4?s=100" width="100px;" alt="Brandon R"/><br /><sub><b>Brandon R</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=b-j-roberts" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://adeyemi.vercel.app/"><img src="https://avatars.githubusercontent.com/u/47580934?v=4?s=100" width="100px;" alt="Adeyemi Gbenga"/><br /><sub><b>Adeyemi Gbenga</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=addegbenga" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://nodeguardians.io/character/98995858fd55"><img src="https://avatars.githubusercontent.com/u/122918260?v=4?s=100" width="100px;" alt="Tristan"/><br /><sub><b>Tristan</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=TAdev0" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Ayoazeez26"><img src="https://avatars.githubusercontent.com/u/44169294?v=4?s=100" width="100px;" alt="Abdulhakeem Abdulazeez Ayodeji"/><br /><sub><b>Abdulhakeem Abdulazeez Ayodeji</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=Ayoazeez26" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tekkac"><img src="https://avatars.githubusercontent.com/u/98529704?v=4?s=100" width="100px;" alt="Trunks @ Carbonable"/><br /><sub><b>Trunks @ Carbonable</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/art-peace/commits?author=tekkac" title="Code">💻</a></td>
</tr>
</tbody>
<tfoot>
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.7-alpine
FROM golang:1.22.2-alpine
# TODO: Add psql to the image?
# TODO: depends on in docker compose?

Expand Down
33 changes: 0 additions & 33 deletions backend/backend/backend.go

This file was deleted.

46 changes: 0 additions & 46 deletions backend/backend/databases.go

This file was deleted.

50 changes: 25 additions & 25 deletions backend/config/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ import (
)

type BackendScriptsConfig struct {
PlacePixelDevnet string `json:"place_pixel_devnet"`
AddTemplateHashDevnet string `json:"add_template_hash_devnet"`
PlacePixelDevnet string `json:"place_pixel_devnet"`
AddTemplateHashDevnet string `json:"add_template_hash_devnet"`
}

type BackendConfig struct {
Host string `json:"host"`
Port int `json:"port"`
Scripts BackendScriptsConfig `json:"scripts"`
Host string `json:"host"`
Port int `json:"port"`
Scripts BackendScriptsConfig `json:"scripts"`
}

var DefaultBackendConfig = BackendConfig{
Host: "localhost",
Port: 8080,
Scripts: BackendScriptsConfig{
PlacePixelDevnet: "../scripts/place_pixel.sh",
AddTemplateHashDevnet: "../scripts/add_template_hash.sh",
},
Host: "localhost",
Port: 8080,
Scripts: BackendScriptsConfig{
PlacePixelDevnet: "../scripts/place_pixel.sh",
AddTemplateHashDevnet: "../scripts/add_template_hash.sh",
},
}

var DefaultBackendConfigPath = "../configs/backend.config.json"

func LoadBackendConfig(backendConfigPath string) (*BackendConfig, error) {
file, err := os.Open(backendConfigPath)
if err != nil {
return nil, err
}
defer file.Close()

decoder := json.NewDecoder(file)
config := BackendConfig{}
err = decoder.Decode(&config)
if err != nil {
return nil, err
}

return &config, nil
file, err := os.Open(backendConfigPath)
if err != nil {
return nil, err
}
defer file.Close()

decoder := json.NewDecoder(file)
config := BackendConfig{}
err = decoder.Decode(&config)
if err != nil {
return nil, err
}

return &config, nil
}
62 changes: 31 additions & 31 deletions backend/config/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,49 @@ import (
)

type CanvasSize struct {
Width uint `json:"width"`
Height uint `json:"height"`
Width uint `json:"width"`
Height uint `json:"height"`
}

type CanvasConfig struct {
Canvas CanvasSize `json:"canvas"`
Colors []string `json:"colors"`
ColorsBitWidth uint `json:"colors_bitwidth"`
Canvas CanvasSize `json:"canvas"`
Colors []string `json:"colors"`
ColorsBitWidth uint `json:"colors_bitwidth"`
}

var DefaultCanvasConfig = &CanvasConfig{
Canvas: CanvasSize{
Width: 100,
Height: 100,
},
Colors: []string{
"#000000",
"#FFFFFF",
"#FF0000",
"#00FF00",
"#0000FF",
"#FFFF00",
"#FF00FF",
"#00FFFF",
},
ColorsBitWidth: 5,
Canvas: CanvasSize{
Width: 100,
Height: 100,
},
Colors: []string{
"#000000",
"#FFFFFF",
"#FF0000",
"#00FF00",
"#0000FF",
"#FFFF00",
"#FF00FF",
"#00FFFF",
},
ColorsBitWidth: 5,
}

var DefaultCanvasConfigPath = "../configs/canvas.config.json"

func LoadCanvasConfig(canvasConfigPath string) (*CanvasConfig, error) {
canvasConfig := &CanvasConfig{}
canvasConfig := &CanvasConfig{}

canvasConfigFile, err := os.Open(canvasConfigPath)
if err != nil {
return nil, err
}
defer canvasConfigFile.Close()
canvasConfigFile, err := os.Open(canvasConfigPath)
if err != nil {
return nil, err
}
defer canvasConfigFile.Close()

jsonParser := json.NewDecoder(canvasConfigFile)
if err = jsonParser.Decode(canvasConfig); err != nil {
return nil, err
}
jsonParser := json.NewDecoder(canvasConfigFile)
if err = jsonParser.Decode(canvasConfig); err != nil {
return nil, err
}

return canvasConfig, nil
return canvasConfig, nil
}
64 changes: 32 additions & 32 deletions backend/config/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,50 @@ import (
)

type RedisConfig struct {
Host string `json:"host"`
Port int `json:"port"`
Host string `json:"host"`
Port int `json:"port"`
}

type PostgresConfig struct {
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user"`
Database string `json:"database"`
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user"`
Database string `json:"database"`
}

type DatabaseConfig struct {
Redis RedisConfig `json:"redis"`
Postgres PostgresConfig `json:"postgres"`
Redis RedisConfig `json:"redis"`
Postgres PostgresConfig `json:"postgres"`
}

var DefaultDatabaseConfig = DatabaseConfig{
Redis: RedisConfig{
Host: "localhost",
Port: 6379,
},
Postgres: PostgresConfig{
Host: "localhost",
Port: 5432,
User: "art-peace-user",
Database: "art-peace-db",
},
Redis: RedisConfig{
Host: "localhost",
Port: 6379,
},
Postgres: PostgresConfig{
Host: "localhost",
Port: 5432,
User: "art-peace-user",
Database: "art-peace-db",
},
}

var DefaultDatabaseConfigPath = "../configs/database.config.json"

func LoadDatabaseConfig(databaseConfigPath string) (*DatabaseConfig, error) {
file, err := os.Open(databaseConfigPath)
if err != nil {
return nil, err
}
defer file.Close()

decoder := json.NewDecoder(file)
config := DatabaseConfig{}
err = decoder.Decode(&config)
if err != nil {
return nil, err
}

return &config, nil
file, err := os.Open(databaseConfigPath)
if err != nil {
return nil, err
}
defer file.Close()

decoder := json.NewDecoder(file)
config := DatabaseConfig{}
err = decoder.Decode(&config)
if err != nil {
return nil, err
}

return &config, nil
}
33 changes: 33 additions & 0 deletions backend/core/backend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package core

import (
"fmt"
"net/http"

"github.com/gorilla/websocket"

"github.com/keep-starknet-strange/art-peace/backend/config"
)

type Backend struct {
Databases *Databases
WSConnections []*websocket.Conn

CanvasConfig *config.CanvasConfig
BackendConfig *config.BackendConfig
}

var ArtPeaceBackend *Backend

func NewBackend(databases *Databases, canvasConfig *config.CanvasConfig, backendConfig *config.BackendConfig) *Backend {
return &Backend{
Databases: databases,
CanvasConfig: canvasConfig,
BackendConfig: backendConfig,
}
}

func (b *Backend) Start() {
fmt.Println("Listening on port", b.BackendConfig.Port)
http.ListenAndServe(fmt.Sprintf(":%d", b.BackendConfig.Port), nil)
}
Loading