/
event_type.go
79 lines (67 loc) Β· 3.43 KB
/
event_type.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
package degendb
import (
mapset "github.com/deckarep/golang-set/v2"
)
type EventType interface {
String() string
ActionName() string
Icon() string
OpenseaEventName() string
}
type GBEventType struct {
name string
actionName string
icon string
openseaEventName string
}
func GetEventType(name string) *GBEventType {
if eventType, ok := eventTypes[name]; ok {
return eventType
}
return nil
}
func (et *GBEventType) String() string {
return et.name
}
func (et *GBEventType) ActionName() string {
return et.actionName
}
func (et *GBEventType) Icon() string {
return et.icon
}
func (et *GBEventType) OpenseaEventName() string {
return et.openseaEventName
}
var (
// event types.
Unknown = &GBEventType{name: "Unknown", actionName: "did something", icon: "β", openseaEventName: ""}
Transfer = &GBEventType{name: "Transfer", actionName: "transferred", icon: "π¦", openseaEventName: "item_transferred"}
Sale = &GBEventType{name: "Sale", actionName: "sold", icon: "π°", openseaEventName: "item_sold"}
Purchase = &GBEventType{name: "Purchase", actionName: "purchased", icon: "ποΈ", openseaEventName: "item_sold"}
Mint = &GBEventType{name: "Mint", actionName: "minted", icon: "βοΈ", openseaEventName: ""}
Airdrop = &GBEventType{name: "Airdrop", actionName: "got airdropped", icon: "π", openseaEventName: ""}
Burn = &GBEventType{name: "Burn", actionName: "burned", icon: "π₯", openseaEventName: ""}
BurnRedeem = &GBEventType{name: "BurnRedeem", actionName: "redeemed burned", icon: "π₯", openseaEventName: ""}
Loan = &GBEventType{name: "Loan", actionName: "loaned", icon: "πΈ", openseaEventName: ""}
RepayLoan = &GBEventType{name: "RepayLoan", actionName: "repaid loan", icon: "πΈ", openseaEventName: ""}
Listing = &GBEventType{name: "Listing", actionName: "listed", icon: "π’", openseaEventName: "item_listed"}
Bid = &GBEventType{name: "Bid", actionName: "(got) bid", icon: "π¦", openseaEventName: "item_received_bid"}
OwnBid = &GBEventType{name: "OwnBid", actionName: "bid", icon: "π€", openseaEventName: ""}
AcceptedOffer = &GBEventType{name: "AcceptedOffer", actionName: "accepted offer", icon: "π€", openseaEventName: ""}
CollectionOffer = &GBEventType{name: "CollectionOffer", actionName: "(got) collection-offered", icon: "βοΈ", openseaEventName: "collection_offer"} // π§
AcceptedCollectionOffer = &GBEventType{name: "AcceptedCollectionOffer", actionName: "accepted collection offer", icon: "π€", openseaEventName: ""}
MetadataUpdated = &GBEventType{name: "MetadataUpdated", actionName: "metadata updated", icon: "β»οΈ", openseaEventName: "item_metadata_updated"}
Cancelled = &GBEventType{name: "Cancelled", actionName: "cancelled", icon: "β", openseaEventName: "item_cancelled"}
// event type sets.
SaleTypes = mapset.NewSet[EventType](Sale, Purchase)
// map of lowercase_with_underscores openseaEventName to event type.
eventTypes = map[string]*GBEventType{
"item_transferred": Transfer,
"item_sold": Sale,
"item_listed": Listing,
"item_received_bid": Bid,
"item_metadata_updated": MetadataUpdated,
"item_cancelled": Cancelled,
"collection_offer": CollectionOffer,
}
)