2018-09-17 20:02:15 -07:00
|
|
|
package distribution
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2018-09-19 20:01:55 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
2018-09-17 20:02:15 -07:00
|
|
|
)
|
|
|
|
|
2018-09-18 21:42:05 -07:00
|
|
|
// InitGenesis sets distribution information for genesis
|
2018-09-18 09:46:04 -07:00
|
|
|
func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) {
|
2018-09-17 20:02:15 -07:00
|
|
|
keeper.SetFeePool(ctx, data.FeePool)
|
2018-10-04 17:20:43 -07:00
|
|
|
keeper.SetCommunityTax(ctx, data.CommunityTax)
|
2018-10-15 14:03:06 -07:00
|
|
|
keeper.SetBaseProposerReward(ctx, data.BaseProposerReward)
|
|
|
|
keeper.SetBonusProposerReward(ctx, data.BonusProposerReward)
|
2018-09-17 20:02:15 -07:00
|
|
|
|
|
|
|
for _, vdi := range data.ValidatorDistInfos {
|
|
|
|
keeper.SetValidatorDistInfo(ctx, vdi)
|
|
|
|
}
|
2018-10-05 17:32:06 -07:00
|
|
|
for _, ddi := range data.DelegationDistInfos {
|
|
|
|
keeper.SetDelegationDistInfo(ctx, ddi)
|
2018-09-17 20:02:15 -07:00
|
|
|
}
|
2018-09-19 20:01:55 -07:00
|
|
|
for _, dw := range data.DelegatorWithdrawInfos {
|
2018-09-17 20:02:15 -07:00
|
|
|
keeper.SetDelegatorWithdrawAddr(ctx, dw.DelegatorAddr, dw.WithdrawAddr)
|
|
|
|
}
|
2018-11-08 16:28:28 -08:00
|
|
|
keeper.SetPreviousProposerConsAddr(ctx, data.PreviousProposer)
|
2018-09-17 20:02:15 -07:00
|
|
|
}
|
|
|
|
|
2018-11-08 16:28:28 -08:00
|
|
|
// ExportGenesis returns a GenesisState for a given context and keeper. The
|
2018-09-17 20:02:15 -07:00
|
|
|
// GenesisState will contain the pool, and validator/delegator distribution info's
|
2018-11-08 16:28:28 -08:00
|
|
|
func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
|
2018-09-17 20:02:15 -07:00
|
|
|
feePool := keeper.GetFeePool(ctx)
|
2018-10-04 17:20:43 -07:00
|
|
|
communityTax := keeper.GetCommunityTax(ctx)
|
2018-10-15 13:12:42 -07:00
|
|
|
baseProposerRewards := keeper.GetBaseProposerReward(ctx)
|
|
|
|
bonusProposerRewards := keeper.GetBonusProposerReward(ctx)
|
2018-10-15 12:51:51 -07:00
|
|
|
vdis := keeper.GetAllValidatorDistInfos(ctx)
|
|
|
|
ddis := keeper.GetAllDelegationDistInfos(ctx)
|
|
|
|
dwis := keeper.GetAllDelegatorWithdrawInfos(ctx)
|
2018-11-08 16:28:28 -08:00
|
|
|
pp := keeper.GetPreviousProposerConsAddr(ctx)
|
2018-10-15 13:12:42 -07:00
|
|
|
return NewGenesisState(feePool, communityTax, baseProposerRewards,
|
2018-11-08 16:28:28 -08:00
|
|
|
bonusProposerRewards, vdis, ddis, dwis, pp)
|
2018-09-17 20:02:15 -07:00
|
|
|
}
|