2018-09-17 20:02:15 -07:00
|
|
|
package types
|
|
|
|
|
2018-12-06 16:22:24 -08:00
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
2018-10-04 15:29:03 -07:00
|
|
|
|
2020-09-25 03:25:37 -07:00
|
|
|
//nolint:interfacer
|
2020-01-10 12:08:14 -08:00
|
|
|
func NewGenesisState(
|
|
|
|
params Params, fp FeePool, dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress, r []ValidatorOutstandingRewardsRecord,
|
2019-01-16 13:38:05 -08:00
|
|
|
acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord,
|
2020-01-10 12:08:14 -08:00
|
|
|
cur []ValidatorCurrentRewardsRecord, dels []DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord,
|
2020-08-11 07:22:30 -07:00
|
|
|
) *GenesisState {
|
2018-10-04 17:20:43 -07:00
|
|
|
|
2020-08-11 07:22:30 -07:00
|
|
|
return &GenesisState{
|
2020-01-10 12:08:14 -08:00
|
|
|
Params: params,
|
|
|
|
FeePool: fp,
|
2019-01-16 13:38:05 -08:00
|
|
|
DelegatorWithdrawInfos: dwis,
|
2020-09-25 03:25:37 -07:00
|
|
|
PreviousProposer: pp.String(),
|
2019-01-16 13:38:05 -08:00
|
|
|
OutstandingRewards: r,
|
|
|
|
ValidatorAccumulatedCommissions: acc,
|
|
|
|
ValidatorHistoricalRewards: historical,
|
|
|
|
ValidatorCurrentRewards: cur,
|
|
|
|
DelegatorStartingInfos: dels,
|
|
|
|
ValidatorSlashEvents: slashes,
|
2018-09-17 20:02:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get raw genesis raw message for testing
|
2020-08-11 07:22:30 -07:00
|
|
|
func DefaultGenesisState() *GenesisState {
|
|
|
|
return &GenesisState{
|
2019-01-16 13:38:05 -08:00
|
|
|
FeePool: InitialFeePool(),
|
2020-01-10 12:08:14 -08:00
|
|
|
Params: DefaultParams(),
|
2019-01-16 13:38:05 -08:00
|
|
|
DelegatorWithdrawInfos: []DelegatorWithdrawInfo{},
|
2020-09-25 03:25:37 -07:00
|
|
|
PreviousProposer: "",
|
2019-03-06 10:54:12 -08:00
|
|
|
OutstandingRewards: []ValidatorOutstandingRewardsRecord{},
|
2019-01-16 13:38:05 -08:00
|
|
|
ValidatorAccumulatedCommissions: []ValidatorAccumulatedCommissionRecord{},
|
|
|
|
ValidatorHistoricalRewards: []ValidatorHistoricalRewardsRecord{},
|
|
|
|
ValidatorCurrentRewards: []ValidatorCurrentRewardsRecord{},
|
|
|
|
DelegatorStartingInfos: []DelegatorStartingInfoRecord{},
|
|
|
|
ValidatorSlashEvents: []ValidatorSlashEventRecord{},
|
2018-10-05 17:32:06 -07:00
|
|
|
}
|
|
|
|
}
|
2018-12-06 16:22:24 -08:00
|
|
|
|
|
|
|
// ValidateGenesis validates the genesis state of distribution genesis input
|
2020-08-11 07:22:30 -07:00
|
|
|
func ValidateGenesis(gs *GenesisState) error {
|
2020-01-10 12:08:14 -08:00
|
|
|
if err := gs.Params.ValidateBasic(); err != nil {
|
|
|
|
return err
|
2018-12-06 16:22:24 -08:00
|
|
|
}
|
2020-01-10 12:08:14 -08:00
|
|
|
return gs.FeePool.ValidateGenesis()
|
2018-12-06 16:22:24 -08:00
|
|
|
}
|