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

As Event Handler, I should track the plays #37

Open
melpadden opened this issue Mar 25, 2024 · 0 comments
Open

As Event Handler, I should track the plays #37

melpadden opened this issue Mar 25, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@melpadden
Copy link
Collaborator

The event handler is a part of the server application, which we want to be developed in NodeJS. The event handler should be a process that subscribes to the play Lottery contract event via CSPR.cloud Streaming API. The CSPR.cloud keys should be passed to the process via an env variable, and the actual value should not be present in the repository. The lottery contract package hash should be provided via the env variable as well.

Here’s an example of WebSocket subscription to CSPR.cloud https://github.com/mssteuer/rekt-server/blob/master/rekt-server.js#L25. Note, that the WebSocket connection should automatically reconnect when closed.

The play event should be stored as a Play entity, with extra fields:

  • deploy_hash (hash of the deploy)
  • round_id
  • play_id
  • player_account_hash
  • prize_amount
  • is_jackpot
  • timestamp (deploy timestamp)

The event handler should MySQL or PostreSQL as the data storage and interact with it using the https://sequelize.org/ library.

Taking into account that we want developers to be able to use this example on hackathons we should start with the directory structure that allows expansion. It could be something like that:

entity/
    play.ts
repository/
    play.ts
    round.ts
docker/
    event-handler.dockerfile
    api.dockerfile
migrations/
    20240319_initial.sql
.env.example
event-handler.ts
api.ts
package.json
package-lock.json
Makefile
README.md
@melpadden melpadden added this to the MVP milestone Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants