-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added the color * feat: added Color event * feat: Added the ColorEvent * feat:Added ColorAdded event * onchain/src/art_peace.cairo * src/art_peace.cairo * feat:fixs * fix: hot fixes * Finish integration of new colors added --------- Co-authored-by: Immanuelolivia1 <[email protected]>
- Loading branch information
1 parent
2e5fa84
commit 38ed003
Showing
16 changed files
with
151 additions
and
64 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
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
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,45 @@ | ||
package indexer | ||
|
||
import ( | ||
"context" | ||
"strconv" | ||
|
||
"github.com/keep-starknet-strange/art-peace/backend/core" | ||
) | ||
|
||
func processColorAddedEvent(event IndexerEvent) { | ||
colorKeyHex := event.Event.Keys[1] | ||
colorHex := event.Event.Data[0] | ||
|
||
colorKey, err := strconv.ParseInt(colorKeyHex, 0, 64) | ||
if err != nil { | ||
PrintIndexerError("processColorAddedEvent", "Error converting color key hex to int", colorKeyHex, colorHex) | ||
return | ||
} | ||
|
||
color := colorHex[len(colorHex)-6:] | ||
|
||
// Set color in postgres | ||
_, err = core.ArtPeaceBackend.Databases.Postgres.Exec(context.Background(), "INSERT INTO Colors (color_key, hex) VALUES ($1, $2)", colorKey, color) | ||
if err != nil { | ||
PrintIndexerError("processColorAddedEvent", "Error inserting color into postgres", colorKey, color) | ||
return | ||
} | ||
} | ||
|
||
func revertColorAddedEvent(event IndexerEvent) { | ||
colorIdxHex := event.Event.Keys[1] | ||
|
||
colorIdx, err := strconv.ParseInt(colorIdxHex, 0, 64) | ||
if err != nil { | ||
PrintIndexerError("revertColorAddedEvent", "Error converting color index hex to int", colorIdxHex) | ||
return | ||
} | ||
|
||
// Delete color from postgres | ||
_, err = core.ArtPeaceBackend.Databases.Postgres.Exec(context.Background(), "DELETE FROM colors WHERE color_key = $1", colorIdx) | ||
if err != nil { | ||
PrintIndexerError("revertColorAddedEvent", "Error deleting color from postgres", colorIdx) | ||
return | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.