Skip to content

As Event Handler, I should track the plays #37

@melpadden

Description

@melpadden

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions