-
Notifications
You must be signed in to change notification settings - Fork 31
/
events.go
64 lines (55 loc) · 1.89 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
package types
import (
sdk "github.com/Finschia/finschia-sdk/types"
)
// bank module event types
const (
EventTypeTransfer = "transfer"
AttributeKeyRecipient = "recipient"
AttributeKeySender = "sender"
// supply and balance tracking events name and attributes
EventTypeCoinSpent = "coin_spent"
EventTypeCoinReceived = "coin_received"
EventTypeCoinMint = "coinbase" // NOTE(fdymylja): using mint clashes with mint module event
EventTypeCoinBurn = "burn"
AttributeKeySpender = "spender"
AttributeKeyReceiver = "receiver"
AttributeKeyMinter = "minter"
AttributeKeyBurner = "burner"
)
// NewCoinSpentEvent constructs a new coin spent sdk.Event
// nolint: interfacer
func NewCoinSpentEvent(spender sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent(
EventTypeCoinSpent,
sdk.NewAttribute(AttributeKeySpender, spender.String()),
sdk.NewAttribute(sdk.AttributeKeyAmount, amount.String()),
)
}
// NewCoinReceivedEvent constructs a new coin received sdk.Event
// nolint: interfacer
func NewCoinReceivedEvent(receiver sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent(
EventTypeCoinReceived,
sdk.NewAttribute(AttributeKeyReceiver, receiver.String()),
sdk.NewAttribute(sdk.AttributeKeyAmount, amount.String()),
)
}
// NewCoinMintEvent construct a new coin minted sdk.Event
// nolint: interfacer
func NewCoinMintEvent(minter sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent(
EventTypeCoinMint,
sdk.NewAttribute(AttributeKeyMinter, minter.String()),
sdk.NewAttribute(sdk.AttributeKeyAmount, amount.String()),
)
}
// NewCoinBurnEvent constructs a new coin burned sdk.Event
// nolint: interfacer
func NewCoinBurnEvent(burner sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent(
EventTypeCoinBurn,
sdk.NewAttribute(AttributeKeyBurner, burner.String()),
sdk.NewAttribute(sdk.AttributeKeyAmount, amount.String()),
)
}