2018-10-05 03:41:38 -07:00
|
|
|
package types
|
|
|
|
|
2019-06-04 15:06:58 -07:00
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-10-23 02:14:45 -07:00
|
|
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
2019-06-04 15:06:58 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
2019-06-28 13:11:27 -07:00
|
|
|
stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported"
|
2019-06-04 15:06:58 -07:00
|
|
|
)
|
2018-10-05 03:41:38 -07:00
|
|
|
|
2019-10-23 02:14:45 -07:00
|
|
|
// AccountKeeper defines the expected account keeper used for simulations (noalias)
|
|
|
|
type AccountKeeper interface {
|
|
|
|
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authexported.Account
|
2020-04-20 12:32:10 -07:00
|
|
|
|
|
|
|
GetModuleAddress(name string) sdk.AccAddress
|
|
|
|
GetModuleAccount(ctx sdk.Context, name string) authexported.ModuleAccountI
|
|
|
|
|
|
|
|
// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
|
|
|
|
SetModuleAccount(sdk.Context, authexported.ModuleAccountI)
|
2019-10-23 02:14:45 -07:00
|
|
|
}
|
|
|
|
|
2020-01-30 13:31:16 -08:00
|
|
|
// BankKeeper defines the expected interface needed to retrieve account balances.
|
|
|
|
type BankKeeper interface {
|
|
|
|
GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
|
|
|
|
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
|
|
|
|
SetBalances(ctx sdk.Context, addr sdk.AccAddress, balances sdk.Coins) error
|
|
|
|
LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
|
|
|
|
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
|
2020-04-20 08:22:12 -07:00
|
|
|
|
|
|
|
SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error
|
|
|
|
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
|
|
|
|
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
2020-01-30 13:31:16 -08:00
|
|
|
}
|
|
|
|
|
2019-06-28 13:11:27 -07:00
|
|
|
// StakingKeeper expected staking keeper (noalias)
|
2019-01-11 12:08:01 -08:00
|
|
|
type StakingKeeper interface {
|
2019-06-04 15:06:58 -07:00
|
|
|
// iterate through validators by operator address, execute func for each validator
|
|
|
|
IterateValidators(sdk.Context,
|
2019-06-28 13:11:27 -07:00
|
|
|
func(index int64, validator stakingexported.ValidatorI) (stop bool))
|
2019-06-04 15:06:58 -07:00
|
|
|
|
|
|
|
// iterate through bonded validators by operator address, execute func for each validator
|
|
|
|
IterateBondedValidatorsByPower(sdk.Context,
|
2019-06-28 13:11:27 -07:00
|
|
|
func(index int64, validator stakingexported.ValidatorI) (stop bool))
|
2019-06-04 15:06:58 -07:00
|
|
|
|
|
|
|
// iterate through the consensus validator set of the last block by operator address, execute func for each validator
|
|
|
|
IterateLastValidators(sdk.Context,
|
2019-06-28 13:11:27 -07:00
|
|
|
func(index int64, validator stakingexported.ValidatorI) (stop bool))
|
2019-06-04 15:06:58 -07:00
|
|
|
|
2019-06-28 13:11:27 -07:00
|
|
|
Validator(sdk.Context, sdk.ValAddress) stakingexported.ValidatorI // get a particular validator by operator address
|
|
|
|
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingexported.ValidatorI // get a particular validator by consensus address
|
2019-06-04 15:06:58 -07:00
|
|
|
|
|
|
|
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
|
|
|
|
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec)
|
|
|
|
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
|
|
|
|
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
|
|
|
|
|
|
|
|
// Delegation allows for getting a particular delegation for a given validator
|
|
|
|
// and delegator outside the scope of the staking module.
|
2019-06-28 13:11:27 -07:00
|
|
|
Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingexported.DelegationI
|
2019-06-04 15:06:58 -07:00
|
|
|
|
|
|
|
// MaxValidators returns the maximum amount of bonded validators
|
2020-02-06 11:21:02 -08:00
|
|
|
MaxValidators(sdk.Context) uint32
|
2019-06-04 15:06:58 -07:00
|
|
|
|
2018-10-05 03:41:38 -07:00
|
|
|
IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress,
|
2019-06-28 13:11:27 -07:00
|
|
|
fn func(index int64, delegation stakingexported.DelegationI) (stop bool))
|
2019-06-04 15:06:58 -07:00
|
|
|
|
2018-10-23 11:48:50 -07:00
|
|
|
GetLastTotalPower(ctx sdk.Context) sdk.Int
|
2019-02-08 15:57:33 -08:00
|
|
|
GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64
|
2019-02-13 15:01:50 -08:00
|
|
|
|
2019-06-04 15:06:58 -07:00
|
|
|
GetAllSDKDelegations(ctx sdk.Context) []staking.Delegation
|
|
|
|
}
|
|
|
|
|
2019-06-28 13:11:27 -07:00
|
|
|
// StakingHooks event hooks for staking validator object (noalias)
|
2019-06-04 15:06:58 -07:00
|
|
|
type StakingHooks interface {
|
|
|
|
AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created
|
|
|
|
AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted
|
|
|
|
|
|
|
|
BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation is created
|
|
|
|
BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation's shares are modified
|
|
|
|
AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)
|
|
|
|
BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec)
|
2018-10-05 03:41:38 -07:00
|
|
|
}
|