-
Notifications
You must be signed in to change notification settings - Fork 4
/
hooks.go
53 lines (43 loc) · 1.58 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
)
type ICAHooks interface {
AfterDelegateEnd(sdk.Context, stakingtypes.MsgDelegate)
AfterUndelegateEnd(sdk.Context, stakingtypes.MsgUndelegate, *stakingtypes.MsgUndelegateResponse)
AfterDelegateFail(sdk.Context, stakingtypes.MsgDelegate)
AfterUndelegateFail(sdk.Context, stakingtypes.MsgUndelegate)
AfterIcaWithdrawFail(sdk.Context, transfertypes.MsgTransfer)
}
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) AfterDelegateFail(ctx sdk.Context, delegateMsg stakingtypes.MsgDelegate) {
for i := range h {
h[i].AfterDelegateFail(ctx, delegateMsg)
}
}
func (h MultiICAHooks) AfterUndelegateFail(ctx sdk.Context, undelegateMsg stakingtypes.MsgUndelegate) {
for i := range h {
h[i].AfterUndelegateFail(ctx, undelegateMsg)
}
}
func (h MultiICAHooks) AfterIcaWithdrawFail(ctx sdk.Context, transferMsg transfertypes.MsgTransfer) {
for i := range h {
h[i].AfterIcaWithdrawFail(ctx, transferMsg)
}
}