1package fomo3d
2
3import (
4 "std"
5
6 "gno.land/p/demo/ufmt"
7)
8
9// Event names
10const (
11 // Game events
12 GameStartedEvent = "GameStarted"
13 GameEndedEvent = "GameEnded"
14 KeysPurchasedEvent = "KeysPurchased"
15
16 // Player events
17 DividendsClaimedEvent = "DividendsClaimed"
18
19 // Admin events
20 OwnerFeeClaimedEvent = "OwnerFeeClaimed"
21)
22
23// Event keys
24const (
25 // Common keys
26 EventRoundKey = "round"
27 EventAmountKey = "amount"
28
29 // Game keys
30 EventStartBlockKey = "startBlock"
31 EventEndBlockKey = "endBlock"
32 EventStartingPotKey = "startingPot"
33 EventWinnerKey = "winner"
34 EventJackpotKey = "jackpot"
35
36 // Player keys
37 EventBuyerKey = "buyer"
38 EventNumKeysKey = "numKeys"
39 EventPriceKey = "price"
40 EventJackpotShareKey = "jackpotShare"
41 EventDividendShareKey = "dividendShare"
42 EventClaimerKey = "claimer"
43
44 // Admin keys
45 EventOwnerKey = "owner"
46 EventPreviousOwnerKey = "previousOwner"
47 EventNewOwnerKey = "newOwner"
48)
49
50func emitGameStarted(round, startBlock, endBlock, startingPot int64) {
51 std.Emit(
52 GameStartedEvent,
53 EventRoundKey, ufmt.Sprintf("%d", round),
54 EventStartBlockKey, ufmt.Sprintf("%d", startBlock),
55 EventEndBlockKey, ufmt.Sprintf("%d", endBlock),
56 EventStartingPotKey, ufmt.Sprintf("%d", startingPot),
57 )
58}
59
60func emitGameEnded(round int64, winner std.Address, jackpot int64) {
61 std.Emit(
62 GameEndedEvent,
63 EventRoundKey, ufmt.Sprintf("%d", round),
64 EventWinnerKey, winner.String(),
65 EventJackpotKey, ufmt.Sprintf("%d", jackpot),
66 )
67}
68
69func emitKeysPurchased(buyer std.Address, numKeys, price, jackpotShare, dividendShare int64) {
70 std.Emit(
71 KeysPurchasedEvent,
72 EventBuyerKey, buyer.String(),
73 EventNumKeysKey, ufmt.Sprintf("%d", numKeys),
74 EventPriceKey, ufmt.Sprintf("%d", price),
75 EventJackpotShareKey, ufmt.Sprintf("%d", jackpotShare),
76 EventDividendShareKey, ufmt.Sprintf("%d", dividendShare),
77 )
78}
79
80func emitDividendsClaimed(claimer std.Address, amount int64) {
81 std.Emit(
82 DividendsClaimedEvent,
83 EventClaimerKey, claimer.String(),
84 EventAmountKey, ufmt.Sprintf("%d", amount),
85 )
86}
87
88func emitOwnerFeeClaimed(owner std.Address, amount int64) {
89 std.Emit(
90 OwnerFeeClaimedEvent,
91 EventOwnerKey, owner.String(),
92 EventAmountKey, ufmt.Sprintf("%d", amount),
93 )
94}
events.gno
2.21 Kb ยท 94 lines