-
Notifications
You must be signed in to change notification settings - Fork 40
/
hooks.go
38 lines (32 loc) · 1013 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 keeper
import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/stablestake/types"
)
var _ types.StableStakeHooks = MultiStableStakeHooks{}
// combine multiple stablestake hooks, all hook functions are run in array sequence
type MultiStableStakeHooks []types.StableStakeHooks
func NewMultiStableStakeHooks(hooks ...types.StableStakeHooks) MultiStableStakeHooks {
return hooks
}
// Committed is called when staker committed his token
func (mh MultiStableStakeHooks) AfterBond(ctx sdk.Context, sender string, shareAmount math.Int) error {
for i := range mh {
err := mh[i].AfterBond(ctx, sender, shareAmount)
if err != nil {
return err
}
}
return nil
}
// Committed is called when staker committed his token
func (mh MultiStableStakeHooks) AfterUnbond(ctx sdk.Context, sender string, shareAmount math.Int) error {
for i := range mh {
err := mh[i].AfterUnbond(ctx, sender, shareAmount)
if err != nil {
return err
}
}
return nil
}