Skip to content

Commit 0731c82

Browse files
authored
fix(upgrade): handle the case of no validator commission (#641)
This PR is to handle the case that the validator has no commission to withdraw. issue: #635
1 parent 6410311 commit 0731c82

File tree

7 files changed

+2577
-273
lines changed

7 files changed

+2577
-273
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package horace
2+
3+
import (
4+
"context"
5+
"cosmossdk.io/core/address"
6+
sdk "github.com/cosmos/cosmos-sdk/types"
7+
dtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
8+
stypes "github.com/cosmos/cosmos-sdk/x/staking/types"
9+
minttypes "github.com/piplabs/story/client/x/mint/types"
10+
)
11+
12+
// StakingKeeper is a test-only interface for upgrade handlers.
13+
type StakingKeeper interface {
14+
GetParams(ctx context.Context) (stypes.Params, error)
15+
SetParams(ctx context.Context, params stypes.Params) error
16+
17+
GetAllValidators(ctx context.Context) ([]stypes.Validator, error)
18+
GetValidator(ctx context.Context, valAddr sdk.ValAddress) (stypes.Validator, error)
19+
SetValidator(ctx context.Context, val stypes.Validator) error
20+
21+
GetValidatorDelegations(ctx context.Context, valAddr sdk.ValAddress) ([]stypes.Delegation, error)
22+
GetDelegation(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (stypes.Delegation, error)
23+
SetDelegation(ctx context.Context, del stypes.Delegation) error
24+
25+
GetPeriodDelegation(
26+
ctx context.Context,
27+
delAddr sdk.AccAddress,
28+
valAddr sdk.ValAddress,
29+
periodDelegationID string,
30+
) (stypes.PeriodDelegation, error)
31+
32+
SetPeriodDelegation(
33+
ctx context.Context,
34+
delAddr sdk.AccAddress,
35+
valAddr sdk.ValAddress,
36+
pd stypes.PeriodDelegation,
37+
) error
38+
}
39+
40+
// DistributionKeeper is a test-only interface for upgrade handlers.
41+
type DistributionKeeper interface {
42+
WithdrawValidatorCommission(
43+
ctx context.Context,
44+
valAddr sdk.ValAddress,
45+
) (sdk.Coins, error)
46+
47+
WithdrawDelegationRewards(
48+
ctx context.Context,
49+
delAddr sdk.AccAddress,
50+
valAddr sdk.ValAddress,
51+
) (sdk.Coins, error)
52+
53+
GetDelegatorStartingInfo(
54+
ctx context.Context,
55+
valAddr sdk.ValAddress,
56+
delAddr sdk.AccAddress,
57+
) (dtypes.DelegatorStartingInfo, error)
58+
59+
SetDelegatorStartingInfo(
60+
ctx context.Context,
61+
valAddr sdk.ValAddress,
62+
delAddr sdk.AccAddress,
63+
info dtypes.DelegatorStartingInfo,
64+
) error
65+
}
66+
67+
// MintKeeper is a test-only interface for upgrade handlers.
68+
type MintKeeper interface {
69+
GetParams(ctx context.Context) (minttypes.Params, error)
70+
SetParams(ctx context.Context, params minttypes.Params) error
71+
}
72+
73+
// AccountKeeper is a test-only interface for upgrade handlers.
74+
type AccountKeeper interface {
75+
AddressCodec() address.Codec
76+
}

0 commit comments

Comments
 (0)