-
Notifications
You must be signed in to change notification settings - Fork 4
/
hooks.go
38 lines (30 loc) · 973 Bytes
/
hooks.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
type ICAHooks interface {
AfterDelegateEnd(sdk.Context, stakingtypes.MsgDelegate)
AfterUndelegateEnd(sdk.Context, stakingtypes.MsgUndelegate, *stakingtypes.MsgUndelegateResponse)
AfterAutoStakingEnd()
}
var _ ICAHooks = MultiICAHooks{}
type MultiICAHooks []ICAHooks
func NewMultiICAHooks(hooks ...ICAHooks) MultiICAHooks {
return hooks
}
func (h MultiICAHooks) AfterDelegateEnd(ctx sdk.Context, delegateMsg stakingtypes.MsgDelegate) {
for i := range h {
h[i].AfterDelegateEnd(ctx, delegateMsg)
}
}
func (h MultiICAHooks) AfterUndelegateEnd(ctx sdk.Context, undelegateMsg stakingtypes.MsgUndelegate, response *stakingtypes.MsgUndelegateResponse) {
for i := range h {
h[i].AfterUndelegateEnd(ctx, undelegateMsg, response)
}
}
func (h MultiICAHooks) AfterAutoStakingEnd() {
for i := range h {
h[i].AfterAutoStakingEnd()
}
}