-
Notifications
You must be signed in to change notification settings - Fork 0
/
emit.go
151 lines (124 loc) · 3.91 KB
/
emit.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
package events
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/merlinslair/merlin/osmoutils"
"github.com/merlinslair/merlin/x/superfluid/types"
)
func EmitSetSuperfluidAssetEvent(ctx sdk.Context, denom string, assetType types.SuperfluidAssetType) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newSetSuperfluidAssetEvent(denom, assetType),
})
}
func newSetSuperfluidAssetEvent(denom string, assetType types.SuperfluidAssetType) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSetSuperfluidAsset,
sdk.NewAttribute(types.AttributeDenom, denom),
sdk.NewAttribute(types.AttributeSuperfluidAssetType, assetType.String()),
)
}
func EmitRemoveSuperfluidAsset(ctx sdk.Context, denom string) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newRemoveSuperfluidAssetEvent(denom),
})
}
func newRemoveSuperfluidAssetEvent(denom string) sdk.Event {
return sdk.NewEvent(
types.TypeEvtRemoveSuperfluidAsset,
sdk.NewAttribute(types.AttributeDenom, denom),
)
}
func EmitSuperfluidDelegateEvent(ctx sdk.Context, lockId uint64, valAddress string) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newSuperfluidDelegateEvent(lockId, valAddress),
})
}
func newSuperfluidDelegateEvent(lockId uint64, valAddress string) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSuperfluidDelegate,
sdk.NewAttribute(types.AttributeLockId, osmoutils.Uint64ToString(lockId)),
sdk.NewAttribute(types.AttributeValidator, valAddress),
)
}
func EmitSuperfluidIncreaseDelegationEvent(ctx sdk.Context, lockId uint64, amount sdk.Coins) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newSuperfluidIncreaseDelegationEvent(lockId, amount),
})
}
func newSuperfluidIncreaseDelegationEvent(lockId uint64, amount sdk.Coins) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSuperfluidIncreaseDelegation,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", lockId)),
sdk.NewAttribute(types.AttributeAmount, amount.String()),
)
}
func EmitSuperfluidUndelegateEvent(ctx sdk.Context, lockId uint64) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newSuperfluidUndelegateEvent(lockId),
})
}
func newSuperfluidUndelegateEvent(lockId uint64) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSuperfluidUndelegate,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", lockId)),
)
}
func EmitSuperfluidUnbondLockEvent(ctx sdk.Context, lockId uint64) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newSuperfluidUnbondLockEvent(lockId),
})
}
func newSuperfluidUnbondLockEvent(lockId uint64) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSuperfluidUnbondLock,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", lockId)),
)
}
func EmitSuperfluidUndelegateAndUnbondLockEvent(ctx sdk.Context, lockId uint64) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newSuperfluidUndelegateAndUnbondLockEvent(lockId),
})
}
func newSuperfluidUndelegateAndUnbondLockEvent(lockId uint64) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSuperfluidUndelegateAndUnbondLock,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", lockId)),
)
}
func EmitUnpoolIdEvent(ctx sdk.Context, sender string, lpShareDenom string, allExitedLockIDsSerialized []byte) {
if ctx.EventManager() == nil {
return
}
ctx.EventManager().EmitEvents(sdk.Events{
newUnpoolIdEvent(sender, lpShareDenom, allExitedLockIDsSerialized),
})
}
func newUnpoolIdEvent(sender string, lpShareDenom string, allExitedLockIDsSerialized []byte) sdk.Event {
return sdk.NewEvent(
types.TypeEvtUnpoolId,
sdk.NewAttribute(sdk.AttributeKeySender, sender),
sdk.NewAttribute(types.AttributeDenom, lpShareDenom),
sdk.NewAttribute(types.AttributeNewLockIds, string(allExitedLockIDsSerialized)),
)
}