-
Notifications
You must be signed in to change notification settings - Fork 28
/
events.go
161 lines (147 loc) · 6.41 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package keeper
import (
"fmt"
"github.com/OmniFlix/omniflixhub/v4/x/marketplace/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func (k *Keeper) createListNftEvent(ctx sdk.Context, owner sdk.AccAddress, listingId, denomId, nftId string, price sdk.Coin) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeListNFT,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(types.AttributeKeyOwner, owner.String()),
sdk.NewAttribute(types.AttributeKeyListingId, listingId),
sdk.NewAttribute(types.AttributeKeyDenomId, denomId),
sdk.NewAttribute(types.AttributeKeyNftId, nftId),
sdk.NewAttribute(types.AttributeKeyAmount, price.String()),
),
})
}
func (k *Keeper) createDeListNftEvent(ctx sdk.Context, sender sdk.AccAddress, listingId string) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeDeListNFT,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyListingId, listingId),
),
})
}
func (k *Keeper) createEditListingEvent(ctx sdk.Context, sender sdk.AccAddress, listingId string, price sdk.Coin) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeEditListing,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyListingId, listingId),
sdk.NewAttribute(types.AttributeKeyAmount, price.String()),
),
})
}
func (k *Keeper) createBuyNftEvent(ctx sdk.Context, buyer sdk.AccAddress, listId, nftId string, price sdk.Coin) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeBuyNFT,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(types.AttributeKeyBuyer, buyer.String()),
sdk.NewAttribute(types.AttributeKeyListingId, listId),
sdk.NewAttribute(types.AttributeKeyNftId, nftId),
sdk.NewAttribute(types.AttributeKeyAmount, price.String()),
),
})
}
func (k *Keeper) createRoyaltyShareTransferEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, amount sdk.Coin) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeRoyaltyShareTransfer,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyRecipient, recipient.String()),
sdk.NewAttribute(types.AttributeKeyAmount, amount.String()),
),
})
}
func (k *Keeper) createSplitShareTransferEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, amount sdk.Coin) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSplitShareTransfer,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyRecipient, recipient.String()),
sdk.NewAttribute(types.AttributeKeyAmount, amount.String()),
),
})
}
func (k *Keeper) createSaleCommissionTransferEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, amount sdk.Coin) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSaleCommissionTransfer,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyRecipient, recipient.String()),
sdk.NewAttribute(types.AttributeKeyAmount, amount.String()),
),
})
}
func (k *Keeper) createAuctionEvent(ctx sdk.Context, auction types.AuctionListing) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeCreateAuction,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(types.AttributeKeyOwner, auction.GetOwner().String()),
sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())),
sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()),
sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()),
sdk.NewAttribute(types.AttributeKeyStartPrice, auction.GetStartPrice().String()),
),
})
}
func (k *Keeper) cancelAuctionEvent(ctx sdk.Context, auction types.AuctionListing) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeCancelAuction,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(types.AttributeKeyOwner, auction.GetOwner().String()),
sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())),
sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()),
sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()),
),
})
}
func (k *Keeper) placeBidEvent(ctx sdk.Context, auction types.AuctionListing, bid types.Bid) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypePlaceBid,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(types.AttributeKeyBidder, bid.GetBidder().String()),
sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())),
sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()),
sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()),
sdk.NewAttribute(types.AttributeKeyAmount, bid.GetAmount().String()),
),
})
}
func (k *Keeper) removeAuctionEvent(ctx sdk.Context, auction types.AuctionListing) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeRemoveAuction,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())),
sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()),
sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()),
),
})
}
func (k *Keeper) processBidEvent(ctx sdk.Context, auction types.AuctionListing, bid types.Bid) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeProcessBid,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(types.AttributeKeyAuctionId, fmt.Sprint(auction.GetId())),
sdk.NewAttribute(types.AttributeKeyDenomId, auction.GetDenomId()),
sdk.NewAttribute(types.AttributeKeyNftId, auction.GetNftId()),
sdk.NewAttribute(types.AttributeKeyBidder, bid.GetBidder().String()),
sdk.NewAttribute(types.AttributeKeyAmount, bid.GetAmount().String()),
),
})
}