From 423b9e11488b031104ac8bcaec707ab98e5c8672 Mon Sep 17 00:00:00 2001 From: VolodymyrK Date: Mon, 3 Jun 2024 16:52:07 +0200 Subject: [PATCH] feat: Add jackpot amount for play --- client/public/config.js.local | 2 +- server/src/entity/play.entity.ts | 3 +++ server/src/event-handler.ts | 3 ++- server/src/events.ts | 3 ++- server/src/migration/1711623923370-Init.ts | 1 + server/src/migration/1713372155154-CreateRoundsView.ts | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client/public/config.js.local b/client/public/config.js.local index 6f5f8fb..2e46437 100644 --- a/client/public/config.js.local +++ b/client/public/config.js.local @@ -1,5 +1,5 @@ const config = { - lottery_app_contract_package_hash: '2987e0d36693cc4547d7623b5e50eec9f3e58623a3832e61d6f2c05a709deaa1', + lottery_app_contract_package_hash: '2fb56551f9015a28d83c16461cd57bbec66a0dfc51b737634ad874888b6cb15d', lottery_play_payment_amount: '1000000', lottery_api_url: 'https://cspr-lottery-demo-api.dev.make.services', lottery_api_ws_url: 'wss://cspr-lottery-demo-api.dev.make.services/deploys', diff --git a/server/src/entity/play.entity.ts b/server/src/entity/play.entity.ts index 099ecd4..6781edd 100644 --- a/server/src/entity/play.entity.ts +++ b/server/src/entity/play.entity.ts @@ -16,6 +16,9 @@ export class Play { @Column({ name: 'prize_amount' }) prizeAmount: string; + @Column({ name: 'jackpot_amount' }) + jackpotAmount: string; + @Column({ name: 'is_jackpot' }) isJackpot: boolean; diff --git a/server/src/event-handler.ts b/server/src/event-handler.ts index c29352f..6539fa2 100644 --- a/server/src/event-handler.ts +++ b/server/src/event-handler.ts @@ -40,7 +40,8 @@ async function main() { playId: event.data.data.play_id, roundId: event.data.data.round_id.toString(), playerAccountHash: event.data.data.player.replace(/^account-hash-/, ''), - prizeAmount: event.data.data.prize, + prizeAmount: event.data.data.prize_amount, + jackpotAmount: event.data.data.jackpot_amount, isJackpot: event.data.data.is_jackpot, deployHash: event.extra.deploy_hash, timestamp: new Date(event.data.data.timestamp), diff --git a/server/src/events.ts b/server/src/events.ts index 008a65a..cedfb76 100644 --- a/server/src/events.ts +++ b/server/src/events.ts @@ -2,7 +2,8 @@ export interface PlayEventPayload { is_jackpot: boolean; play_id: string; player: string; - prize: string; + prize_amount: string; + jackpot_amount: string; round_id: number; timestamp: number; } diff --git a/server/src/migration/1711623923370-Init.ts b/server/src/migration/1711623923370-Init.ts index e32d359..0a43270 100644 --- a/server/src/migration/1711623923370-Init.ts +++ b/server/src/migration/1711623923370-Init.ts @@ -9,6 +9,7 @@ export class Init1711623923370 implements MigrationInterface { play_id bigint(20) UNSIGNED NOT NULL, player_account_hash varchar(64) NOT NULL, prize_amount varchar(128) NOT NULL, + jackpot_amount varchar(128) NOT NULL, is_jackpot bool NOT NULL, timestamp datetime NOT NULL, diff --git a/server/src/migration/1713372155154-CreateRoundsView.ts b/server/src/migration/1713372155154-CreateRoundsView.ts index 8369aed..d99f7fe 100644 --- a/server/src/migration/1713372155154-CreateRoundsView.ts +++ b/server/src/migration/1713372155154-CreateRoundsView.ts @@ -9,7 +9,7 @@ export class CreateRoundsView1713372155154 implements MigrationInterface { select p.round_id, w.plays_num, - p.prize_amount as jackpot_amount, + p.jackpot_amount, p.player_account_hash as winner_account_hash, p.timestamp as ended_at from plays p