forked from evmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
60 lines (51 loc) · 1.81 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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// bank module event types
const (
EventTypeTransfer = "transfer"
AttributeKeyRecipient = "recipient"
AttributeKeySender = sdk.AttributeKeySender
// 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
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
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
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
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()),
)
}