x/distribution: remove alias.go usage (#6436)
This commit is contained in:
parent
cc42a82c86
commit
190bee27cb
|
@ -23,6 +23,9 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/capability"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis"
|
||||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
|
||||
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
|
||||
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
|
@ -80,7 +83,7 @@ var (
|
|||
mint.AppModuleBasic{},
|
||||
distr.AppModuleBasic{},
|
||||
gov.NewAppModuleBasic(
|
||||
paramsclient.ProposalHandler, distr.ProposalHandler, upgradeclient.ProposalHandler,
|
||||
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler,
|
||||
),
|
||||
params.AppModuleBasic{},
|
||||
crisis.AppModuleBasic{},
|
||||
|
@ -94,7 +97,7 @@ var (
|
|||
// module account permissions
|
||||
maccPerms = map[string][]string{
|
||||
auth.FeeCollectorName: nil,
|
||||
distr.ModuleName: nil,
|
||||
distrtypes.ModuleName: nil,
|
||||
minttypes.ModuleName: {auth.Minter},
|
||||
stakingtypes.BondedPoolName: {auth.Burner, auth.Staking},
|
||||
stakingtypes.NotBondedPoolName: {auth.Burner, auth.Staking},
|
||||
|
@ -104,7 +107,7 @@ var (
|
|||
|
||||
// module accounts that are allowed to receive tokens
|
||||
allowedReceivingModAcc = map[string]bool{
|
||||
distr.ModuleName: true,
|
||||
distrtypes.ModuleName: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -135,7 +138,7 @@ type SimApp struct {
|
|||
StakingKeeper stakingkeeper.Keeper
|
||||
SlashingKeeper slashingkeeper.Keeper
|
||||
MintKeeper mintkeeper.Keeper
|
||||
DistrKeeper distr.Keeper
|
||||
DistrKeeper distrkeeper.Keeper
|
||||
GovKeeper govkeeper.Keeper
|
||||
CrisisKeeper crisis.Keeper
|
||||
UpgradeKeeper upgradekeeper.Keeper
|
||||
|
@ -170,7 +173,7 @@ func NewSimApp(
|
|||
|
||||
keys := sdk.NewKVStoreKeys(
|
||||
auth.StoreKey, bank.StoreKey, stakingtypes.StoreKey,
|
||||
minttypes.StoreKey, distr.StoreKey, slashingtypes.StoreKey,
|
||||
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
|
||||
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
|
||||
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capability.StoreKey,
|
||||
)
|
||||
|
@ -194,7 +197,7 @@ func NewSimApp(
|
|||
app.subspaces[bank.ModuleName] = app.ParamsKeeper.Subspace(bank.DefaultParamspace)
|
||||
app.subspaces[stakingtypes.ModuleName] = app.ParamsKeeper.Subspace(stakingkeeper.DefaultParamspace)
|
||||
app.subspaces[minttypes.ModuleName] = app.ParamsKeeper.Subspace(minttypes.DefaultParamspace)
|
||||
app.subspaces[distr.ModuleName] = app.ParamsKeeper.Subspace(distr.DefaultParamspace)
|
||||
app.subspaces[distrtypes.ModuleName] = app.ParamsKeeper.Subspace(distrtypes.DefaultParamspace)
|
||||
app.subspaces[slashingtypes.ModuleName] = app.ParamsKeeper.Subspace(slashingtypes.DefaultParamspace)
|
||||
app.subspaces[govtypes.ModuleName] = app.ParamsKeeper.Subspace(govtypes.DefaultParamspace).WithKeyTable(govtypes.ParamKeyTable())
|
||||
app.subspaces[crisis.ModuleName] = app.ParamsKeeper.Subspace(crisis.DefaultParamspace)
|
||||
|
@ -221,8 +224,8 @@ func NewSimApp(
|
|||
appCodec, keys[minttypes.StoreKey], app.subspaces[minttypes.ModuleName], &stakingKeeper,
|
||||
app.AccountKeeper, app.BankKeeper, auth.FeeCollectorName,
|
||||
)
|
||||
app.DistrKeeper = distr.NewKeeper(
|
||||
appCodec, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.AccountKeeper, app.BankKeeper,
|
||||
app.DistrKeeper = distrkeeper.NewKeeper(
|
||||
appCodec, keys[distrtypes.StoreKey], app.subspaces[distrtypes.ModuleName], app.AccountKeeper, app.BankKeeper,
|
||||
&stakingKeeper, auth.FeeCollectorName, app.ModuleAccountAddrs(),
|
||||
)
|
||||
app.SlashingKeeper = slashingkeeper.NewKeeper(
|
||||
|
@ -237,7 +240,7 @@ func NewSimApp(
|
|||
govRouter := govtypes.NewRouter()
|
||||
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
|
||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
|
||||
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
|
||||
app.GovKeeper = govkeeper.NewKeeper(
|
||||
appCodec, keys[govtypes.StoreKey], app.subspaces[govtypes.ModuleName], app.AccountKeeper, app.BankKeeper,
|
||||
|
@ -305,7 +308,7 @@ func NewSimApp(
|
|||
// CanWithdrawInvariant invariant.
|
||||
// NOTE: staking module is required if HistoricalEntries param > 0
|
||||
app.mm.SetOrderBeginBlockers(
|
||||
upgradetypes.ModuleName, minttypes.ModuleName, distr.ModuleName, slashingtypes.ModuleName,
|
||||
upgradetypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
|
||||
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
|
||||
)
|
||||
app.mm.SetOrderEndBlockers(crisis.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName)
|
||||
|
@ -316,7 +319,7 @@ func NewSimApp(
|
|||
// so that other modules that want to create or claim capabilities afterwards in InitChain
|
||||
// can do so safely.
|
||||
app.mm.SetOrderInitGenesis(
|
||||
capability.ModuleName, auth.ModuleName, distr.ModuleName, stakingtypes.ModuleName, bank.ModuleName,
|
||||
capability.ModuleName, auth.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, bank.ModuleName,
|
||||
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisis.ModuleName,
|
||||
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
|
||||
)
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/capability"
|
||||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
|
||||
|
@ -156,7 +156,7 @@ func TestAppImportExport(t *testing.T) {
|
|||
}}, // ordering may change but it doesn't matter
|
||||
{app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}},
|
||||
{app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}},
|
||||
{app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}},
|
||||
{app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}},
|
||||
{app.keys[bank.StoreKey], newApp.keys[bank.StoreKey], [][]byte{bank.BalancesPrefix}},
|
||||
{app.keys[paramtypes.StoreKey], newApp.keys[paramtypes.StoreKey], [][]byte{}},
|
||||
{app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}},
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
|
@ -146,7 +146,7 @@ func TestSendToModuleAcc(t *testing.T) {
|
|||
{
|
||||
name: "Allowed module account can be the recipient of bank sends",
|
||||
fromBalance: coins,
|
||||
msg: types.NewMsgSend(addr1, auth.NewModuleAddress(distribution.ModuleName), coins),
|
||||
msg: types.NewMsgSend(addr1, auth.NewModuleAddress(distrtypes.ModuleName), coins),
|
||||
expPass: true,
|
||||
expSimPass: true,
|
||||
expFromBalance: sdk.NewCoins(),
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis"
|
||||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
|
@ -35,7 +35,7 @@ func createTestApp() (*simapp.SimApp, sdk.Context, []sdk.AccAddress) {
|
|||
app.CrisisKeeper.RegisterRoute(testModuleName, dummyRouteWhichPasses.Route, dummyRouteWhichPasses.Invar)
|
||||
app.CrisisKeeper.RegisterRoute(testModuleName, dummyRouteWhichFails.Route, dummyRouteWhichFails.Invar)
|
||||
|
||||
feePool := distr.InitialFeePool()
|
||||
feePool := distrtypes.InitialFeePool()
|
||||
feePool.CommunityPool = sdk.NewDecCoinsFromCoins(sdk.NewCoins(constantFee)...)
|
||||
app.DistrKeeper.SetFeePool(ctx, feePool)
|
||||
app.BankKeeper.SetSupply(ctx, bank.NewSupply(sdk.Coins{}))
|
||||
|
|
|
@ -1,153 +0,0 @@
|
|||
package distribution
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/client"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
const (
|
||||
ModuleName = types.ModuleName
|
||||
StoreKey = types.StoreKey
|
||||
RouterKey = types.RouterKey
|
||||
QuerierRoute = types.QuerierRoute
|
||||
ProposalTypeCommunityPoolSpend = types.ProposalTypeCommunityPoolSpend
|
||||
QueryParams = types.QueryParams
|
||||
QueryValidatorOutstandingRewards = types.QueryValidatorOutstandingRewards
|
||||
QueryValidatorCommission = types.QueryValidatorCommission
|
||||
QueryValidatorSlashes = types.QueryValidatorSlashes
|
||||
QueryDelegationRewards = types.QueryDelegationRewards
|
||||
QueryDelegatorTotalRewards = types.QueryDelegatorTotalRewards
|
||||
QueryDelegatorValidators = types.QueryDelegatorValidators
|
||||
QueryWithdrawAddr = types.QueryWithdrawAddr
|
||||
QueryCommunityPool = types.QueryCommunityPool
|
||||
DefaultParamspace = types.DefaultParamspace
|
||||
TypeMsgFundCommunityPool = types.TypeMsgFundCommunityPool
|
||||
)
|
||||
|
||||
var (
|
||||
// functions aliases
|
||||
RegisterInvariants = keeper.RegisterInvariants
|
||||
AllInvariants = keeper.AllInvariants
|
||||
NonNegativeOutstandingInvariant = keeper.NonNegativeOutstandingInvariant
|
||||
CanWithdrawInvariant = keeper.CanWithdrawInvariant
|
||||
ReferenceCountInvariant = keeper.ReferenceCountInvariant
|
||||
ModuleAccountInvariant = keeper.ModuleAccountInvariant
|
||||
NewKeeper = keeper.NewKeeper
|
||||
GetValidatorOutstandingRewardsAddress = types.GetValidatorOutstandingRewardsAddress
|
||||
GetDelegatorWithdrawInfoAddress = types.GetDelegatorWithdrawInfoAddress
|
||||
GetDelegatorStartingInfoAddresses = types.GetDelegatorStartingInfoAddresses
|
||||
GetValidatorHistoricalRewardsAddressPeriod = types.GetValidatorHistoricalRewardsAddressPeriod
|
||||
GetValidatorCurrentRewardsAddress = types.GetValidatorCurrentRewardsAddress
|
||||
GetValidatorAccumulatedCommissionAddress = types.GetValidatorAccumulatedCommissionAddress
|
||||
GetValidatorSlashEventAddressHeight = types.GetValidatorSlashEventAddressHeight
|
||||
GetValidatorOutstandingRewardsKey = types.GetValidatorOutstandingRewardsKey
|
||||
GetDelegatorWithdrawAddrKey = types.GetDelegatorWithdrawAddrKey
|
||||
GetDelegatorStartingInfoKey = types.GetDelegatorStartingInfoKey
|
||||
GetValidatorHistoricalRewardsPrefix = types.GetValidatorHistoricalRewardsPrefix
|
||||
GetValidatorHistoricalRewardsKey = types.GetValidatorHistoricalRewardsKey
|
||||
GetValidatorCurrentRewardsKey = types.GetValidatorCurrentRewardsKey
|
||||
GetValidatorAccumulatedCommissionKey = types.GetValidatorAccumulatedCommissionKey
|
||||
GetValidatorSlashEventPrefix = types.GetValidatorSlashEventPrefix
|
||||
GetValidatorSlashEventKeyPrefix = types.GetValidatorSlashEventKeyPrefix
|
||||
GetValidatorSlashEventKey = types.GetValidatorSlashEventKey
|
||||
HandleCommunityPoolSpendProposal = keeper.HandleCommunityPoolSpendProposal
|
||||
NewQuerier = keeper.NewQuerier
|
||||
ParamKeyTable = types.ParamKeyTable
|
||||
DefaultParams = types.DefaultParams
|
||||
RegisterCodec = types.RegisterCodec
|
||||
NewDelegatorStartingInfo = types.NewDelegatorStartingInfo
|
||||
ErrEmptyDelegatorAddr = types.ErrEmptyDelegatorAddr
|
||||
ErrEmptyWithdrawAddr = types.ErrEmptyWithdrawAddr
|
||||
ErrEmptyValidatorAddr = types.ErrEmptyValidatorAddr
|
||||
ErrEmptyDelegationDistInfo = types.ErrEmptyDelegationDistInfo
|
||||
ErrNoValidatorDistInfo = types.ErrNoValidatorDistInfo
|
||||
ErrNoValidatorExists = types.ErrNoValidatorExists
|
||||
ErrNoDelegationExists = types.ErrNoDelegationExists
|
||||
ErrNoValidatorCommission = types.ErrNoValidatorCommission
|
||||
ErrSetWithdrawAddrDisabled = types.ErrSetWithdrawAddrDisabled
|
||||
ErrBadDistribution = types.ErrBadDistribution
|
||||
ErrInvalidProposalAmount = types.ErrInvalidProposalAmount
|
||||
ErrEmptyProposalRecipient = types.ErrEmptyProposalRecipient
|
||||
InitialFeePool = types.InitialFeePool
|
||||
NewGenesisState = types.NewGenesisState
|
||||
DefaultGenesisState = types.DefaultGenesisState
|
||||
ValidateGenesis = types.ValidateGenesis
|
||||
NewMsgSetWithdrawAddress = types.NewMsgSetWithdrawAddress
|
||||
NewMsgWithdrawDelegatorReward = types.NewMsgWithdrawDelegatorReward
|
||||
NewMsgWithdrawValidatorCommission = types.NewMsgWithdrawValidatorCommission
|
||||
MsgFundCommunityPool = types.NewMsgFundCommunityPool
|
||||
NewCommunityPoolSpendProposal = types.NewCommunityPoolSpendProposal
|
||||
NewQueryValidatorOutstandingRewardsParams = types.NewQueryValidatorOutstandingRewardsParams
|
||||
NewQueryValidatorCommissionParams = types.NewQueryValidatorCommissionParams
|
||||
NewQueryValidatorSlashesParams = types.NewQueryValidatorSlashesParams
|
||||
NewQueryDelegationRewardsParams = types.NewQueryDelegationRewardsParams
|
||||
NewQueryDelegatorParams = types.NewQueryDelegatorParams
|
||||
NewQueryDelegatorWithdrawAddrParams = types.NewQueryDelegatorWithdrawAddrParams
|
||||
NewQueryDelegatorTotalRewardsResponse = types.NewQueryDelegatorTotalRewardsResponse
|
||||
NewDelegationDelegatorReward = types.NewDelegationDelegatorReward
|
||||
NewValidatorHistoricalRewards = types.NewValidatorHistoricalRewards
|
||||
NewValidatorCurrentRewards = types.NewValidatorCurrentRewards
|
||||
InitialValidatorAccumulatedCommission = types.InitialValidatorAccumulatedCommission
|
||||
NewValidatorSlashEvent = types.NewValidatorSlashEvent
|
||||
|
||||
// variable aliases
|
||||
FeePoolKey = types.FeePoolKey
|
||||
ProposerKey = types.ProposerKey
|
||||
ValidatorOutstandingRewardsPrefix = types.ValidatorOutstandingRewardsPrefix
|
||||
DelegatorWithdrawAddrPrefix = types.DelegatorWithdrawAddrPrefix
|
||||
DelegatorStartingInfoPrefix = types.DelegatorStartingInfoPrefix
|
||||
ValidatorHistoricalRewardsPrefix = types.ValidatorHistoricalRewardsPrefix
|
||||
ValidatorCurrentRewardsPrefix = types.ValidatorCurrentRewardsPrefix
|
||||
ValidatorAccumulatedCommissionPrefix = types.ValidatorAccumulatedCommissionPrefix
|
||||
ValidatorSlashEventPrefix = types.ValidatorSlashEventPrefix
|
||||
ParamStoreKeyCommunityTax = types.ParamStoreKeyCommunityTax
|
||||
ParamStoreKeyBaseProposerReward = types.ParamStoreKeyBaseProposerReward
|
||||
ParamStoreKeyBonusProposerReward = types.ParamStoreKeyBonusProposerReward
|
||||
ParamStoreKeyWithdrawAddrEnabled = types.ParamStoreKeyWithdrawAddrEnabled
|
||||
ModuleCdc = types.ModuleCdc
|
||||
EventTypeSetWithdrawAddress = types.EventTypeSetWithdrawAddress
|
||||
EventTypeRewards = types.EventTypeRewards
|
||||
EventTypeCommission = types.EventTypeCommission
|
||||
EventTypeWithdrawRewards = types.EventTypeWithdrawRewards
|
||||
EventTypeWithdrawCommission = types.EventTypeWithdrawCommission
|
||||
EventTypeProposerReward = types.EventTypeProposerReward
|
||||
AttributeKeyWithdrawAddress = types.AttributeKeyWithdrawAddress
|
||||
AttributeKeyValidator = types.AttributeKeyValidator
|
||||
AttributeValueCategory = types.AttributeValueCategory
|
||||
ProposalHandler = client.ProposalHandler
|
||||
)
|
||||
|
||||
type (
|
||||
Hooks = keeper.Hooks
|
||||
Keeper = keeper.Keeper
|
||||
DelegatorStartingInfo = types.DelegatorStartingInfo
|
||||
FeePool = types.FeePool
|
||||
DelegatorWithdrawInfo = types.DelegatorWithdrawInfo
|
||||
ValidatorOutstandingRewardsRecord = types.ValidatorOutstandingRewardsRecord
|
||||
ValidatorAccumulatedCommissionRecord = types.ValidatorAccumulatedCommissionRecord
|
||||
ValidatorHistoricalRewardsRecord = types.ValidatorHistoricalRewardsRecord
|
||||
ValidatorCurrentRewardsRecord = types.ValidatorCurrentRewardsRecord
|
||||
DelegatorStartingInfoRecord = types.DelegatorStartingInfoRecord
|
||||
ValidatorSlashEventRecord = types.ValidatorSlashEventRecord
|
||||
Params = types.Params
|
||||
GenesisState = types.GenesisState
|
||||
MsgSetWithdrawAddress = types.MsgSetWithdrawAddress
|
||||
MsgWithdrawDelegatorReward = types.MsgWithdrawDelegatorReward
|
||||
MsgWithdrawValidatorCommission = types.MsgWithdrawValidatorCommission
|
||||
CommunityPoolSpendProposal = types.CommunityPoolSpendProposal
|
||||
QueryValidatorOutstandingRewardsParams = types.QueryValidatorOutstandingRewardsParams
|
||||
QueryValidatorCommissionParams = types.QueryValidatorCommissionParams
|
||||
QueryValidatorSlashesParams = types.QueryValidatorSlashesParams
|
||||
QueryDelegationRewardsParams = types.QueryDelegationRewardsParams
|
||||
QueryDelegatorParams = types.QueryDelegatorParams
|
||||
QueryDelegatorWithdrawAddrParams = types.QueryDelegatorWithdrawAddrParams
|
||||
QueryDelegatorTotalRewardsResponse = types.QueryDelegatorTotalRewardsResponse
|
||||
DelegationDelegatorReward = types.DelegationDelegatorReward
|
||||
ValidatorHistoricalRewards = types.ValidatorHistoricalRewards
|
||||
ValidatorCurrentRewards = types.ValidatorCurrentRewards
|
||||
ValidatorAccumulatedCommission = types.ValidatorAccumulatedCommission
|
||||
ValidatorSlashEvent = types.ValidatorSlashEvent
|
||||
ValidatorSlashEvents = types.ValidatorSlashEvents
|
||||
ValidatorOutstandingRewards = types.ValidatorOutstandingRewards
|
||||
)
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/tests"
|
||||
"github.com/cosmos/cosmos-sdk/tests/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
// TxWithdrawRewards raises a txn to withdraw rewards
|
||||
|
@ -37,56 +37,56 @@ func TxFundCommunityPool(f *cli.Fixtures, from string, amount sdk.Coin, flags ..
|
|||
}
|
||||
|
||||
// QueryRewards returns the rewards of a delegator
|
||||
func QueryRewards(f *cli.Fixtures, delAddr sdk.AccAddress, flags ...string) distribution.QueryDelegatorTotalRewardsResponse {
|
||||
func QueryRewards(f *cli.Fixtures, delAddr sdk.AccAddress, flags ...string) types.QueryDelegatorTotalRewardsResponse {
|
||||
cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.SimcliBinary, delAddr, f.Flags())
|
||||
res, errStr := tests.ExecuteT(f.T, cmd, "")
|
||||
require.Empty(f.T, errStr)
|
||||
|
||||
var rewards distribution.QueryDelegatorTotalRewardsResponse
|
||||
var rewards types.QueryDelegatorTotalRewardsResponse
|
||||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(res), &rewards))
|
||||
return rewards
|
||||
}
|
||||
|
||||
// QueryValidatorOutstandingRewards distribution outstanding (un-withdrawn) rewards
|
||||
func QueryValidatorOutstandingRewards(f *cli.Fixtures, valAddr string) distribution.ValidatorOutstandingRewards {
|
||||
func QueryValidatorOutstandingRewards(f *cli.Fixtures, valAddr string) types.ValidatorOutstandingRewards {
|
||||
cmd := fmt.Sprintf("%s query distribution validator-outstanding-rewards %s %v", f.SimcliBinary, valAddr, f.Flags())
|
||||
res, errStr := tests.ExecuteT(f.T, cmd, "")
|
||||
require.Empty(f.T, errStr)
|
||||
|
||||
var outstandingRewards distribution.ValidatorOutstandingRewards
|
||||
var outstandingRewards types.ValidatorOutstandingRewards
|
||||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(res), &outstandingRewards))
|
||||
return outstandingRewards
|
||||
}
|
||||
|
||||
// QueryParameters is simcli query distribution parameters
|
||||
func QueryParameters(f *cli.Fixtures, flags ...string) distribution.Params {
|
||||
func QueryParameters(f *cli.Fixtures, flags ...string) types.Params {
|
||||
cmd := fmt.Sprintf("%s query distribution params %v", f.SimcliBinary, f.Flags())
|
||||
out, errStr := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "")
|
||||
require.Empty(f.T, errStr)
|
||||
|
||||
var params distribution.Params
|
||||
var params types.Params
|
||||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(out), ¶ms))
|
||||
return params
|
||||
}
|
||||
|
||||
// QueryCommission returns validator commission rewards from delegators to that validator.
|
||||
func QueryCommission(f *cli.Fixtures, valAddr string, flags ...string) distribution.ValidatorAccumulatedCommission {
|
||||
func QueryCommission(f *cli.Fixtures, valAddr string, flags ...string) types.ValidatorAccumulatedCommission {
|
||||
cmd := fmt.Sprintf("%s query distribution commission %s %v", f.SimcliBinary, valAddr, f.Flags())
|
||||
out, errStr := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "")
|
||||
require.Empty(f.T, errStr)
|
||||
|
||||
var commission distribution.ValidatorAccumulatedCommission
|
||||
var commission types.ValidatorAccumulatedCommission
|
||||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(out), &commission))
|
||||
return commission
|
||||
}
|
||||
|
||||
// QuerySlashes returns all slashes of a validator for a given block range.
|
||||
func QuerySlashes(f *cli.Fixtures, valAddr string, flags ...string) []distribution.ValidatorSlashEvent {
|
||||
func QuerySlashes(f *cli.Fixtures, valAddr string, flags ...string) []types.ValidatorSlashEvent {
|
||||
cmd := fmt.Sprintf("%s query distribution slashes %s 0 5 %v ", f.SimcliBinary, valAddr, f.Flags())
|
||||
out, errStr := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "")
|
||||
require.Empty(f.T, errStr)
|
||||
|
||||
var slashes []distribution.ValidatorSlashEvent
|
||||
var slashes []types.ValidatorSlashEvent
|
||||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(out), &slashes))
|
||||
return slashes
|
||||
}
|
||||
|
|
|
@ -4,11 +4,12 @@ import (
|
|||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
// InitGenesis sets distribution information for genesis
|
||||
func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, keeper Keeper, data types.GenesisState) {
|
||||
func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, keeper keeper.Keeper, data types.GenesisState) {
|
||||
var moduleHoldings sdk.DecCoins
|
||||
|
||||
keeper.SetFeePool(ctx, data.FeePool)
|
||||
|
@ -57,7 +58,7 @@ func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k
|
|||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper.
|
||||
func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
|
||||
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
||||
feePool := keeper.GetFeePool(ctx)
|
||||
params := keeper.GetParams(ctx)
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ func handleMsgFundCommunityPool(ctx sdk.Context, msg *types.MsgFundCommunityPool
|
|||
return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil
|
||||
}
|
||||
|
||||
func NewCommunityPoolSpendProposalHandler(k Keeper) govtypes.Handler {
|
||||
func NewCommunityPoolSpendProposalHandler(k keeper.Keeper) govtypes.Handler {
|
||||
return func(ctx sdk.Context, content govtypes.Content) error {
|
||||
switch c := content.(type) {
|
||||
case *types.CommunityPoolSpendProposal:
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
sdkclient "github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
@ -19,6 +19,7 @@ import (
|
|||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/client/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
|
@ -38,43 +39,43 @@ type AppModuleBasic struct {
|
|||
|
||||
// Name returns the distribution module's name.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return ModuleName
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// RegisterCodec registers the distribution module's types for the given codec.
|
||||
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
|
||||
RegisterCodec(cdc)
|
||||
types.RegisterCodec(cdc)
|
||||
}
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the distribution
|
||||
// module.
|
||||
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(DefaultGenesisState())
|
||||
return cdc.MustMarshalJSON(types.DefaultGenesisState())
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the distribution module.
|
||||
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error {
|
||||
var data GenesisState
|
||||
var data types.GenesisState
|
||||
if err := cdc.UnmarshalJSON(bz, &data); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", ModuleName, err)
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
|
||||
return ValidateGenesis(data)
|
||||
return types.ValidateGenesis(data)
|
||||
}
|
||||
|
||||
// RegisterRESTRoutes registers the REST routes for the distribution module.
|
||||
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||
func (AppModuleBasic) RegisterRESTRoutes(clientCtx sdkclient.Context, rtr *mux.Router) {
|
||||
rest.RegisterHandlers(clientCtx, rtr)
|
||||
}
|
||||
|
||||
// GetTxCmd returns the root tx command for the distribution module.
|
||||
func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command {
|
||||
func (AppModuleBasic) GetTxCmd(clientCtx sdkclient.Context) *cobra.Command {
|
||||
return cli.NewTxCmd(clientCtx)
|
||||
}
|
||||
|
||||
// GetQueryCmd returns the root query command for the distribution module.
|
||||
func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
||||
return cli.GetQueryCmd(StoreKey, clientCtx.Codec)
|
||||
func (AppModuleBasic) GetQueryCmd(clientCtx sdkclient.Context) *cobra.Command {
|
||||
return cli.GetQueryCmd(types.StoreKey, clientCtx.Codec)
|
||||
}
|
||||
|
||||
// RegisterInterfaceTypes implements InterfaceModule
|
||||
|
@ -88,7 +89,7 @@ func (b AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegist
|
|||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
|
||||
keeper Keeper
|
||||
keeper keeper.Keeper
|
||||
accountKeeper types.AccountKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
stakingKeeper stakingkeeper.Keeper
|
||||
|
@ -96,7 +97,7 @@ type AppModule struct {
|
|||
|
||||
// NewAppModule creates a new AppModule object
|
||||
func NewAppModule(
|
||||
cdc codec.Marshaler, keeper Keeper, accountKeeper types.AccountKeeper,
|
||||
cdc codec.Marshaler, keeper keeper.Keeper, accountKeeper types.AccountKeeper,
|
||||
bankKeeper types.BankKeeper, stakingKeeper stakingkeeper.Keeper,
|
||||
) AppModule {
|
||||
return AppModule{
|
||||
|
@ -110,27 +111,27 @@ func NewAppModule(
|
|||
|
||||
// Name returns the distribution module's name.
|
||||
func (AppModule) Name() string {
|
||||
return ModuleName
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// RegisterInvariants registers the distribution module invariants.
|
||||
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
||||
RegisterInvariants(ir, am.keeper)
|
||||
keeper.RegisterInvariants(ir, am.keeper)
|
||||
}
|
||||
|
||||
// Route returns the message routing key for the distribution module.
|
||||
func (am AppModule) Route() sdk.Route {
|
||||
return sdk.NewRoute(RouterKey, NewHandler(am.keeper))
|
||||
return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
|
||||
}
|
||||
|
||||
// QuerierRoute returns the distribution module's querier route name.
|
||||
func (AppModule) QuerierRoute() string {
|
||||
return QuerierRoute
|
||||
return types.QuerierRoute
|
||||
}
|
||||
|
||||
// NewQuerierHandler returns the distribution module sdk.Querier.
|
||||
func (am AppModule) NewQuerierHandler() sdk.Querier {
|
||||
return NewQuerier(am.keeper)
|
||||
return keeper.NewQuerier(am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) RegisterQueryService(grpc.Server) {}
|
||||
|
@ -138,7 +139,7 @@ func (am AppModule) RegisterQueryService(grpc.Server) {}
|
|||
// InitGenesis performs genesis initialization for the distribution module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState GenesisState
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
InitGenesis(ctx, am.accountKeeper, am.bankKeeper, am.keeper, genesisState)
|
||||
return []abci.ValidatorUpdate{}
|
||||
|
@ -184,7 +185,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
|
|||
|
||||
// RegisterStoreDecoder registers a decoder for distribution module's types
|
||||
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||
sdr[StoreKey] = simulation.NewDecodeStore(am.cdc)
|
||||
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
|
||||
}
|
||||
|
||||
// WeightedOperations returns the all the gov module operations with their respective weights.
|
||||
|
|
|
@ -4,24 +4,24 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/abci/types"
|
||||
abcitypes "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
||||
app := simapp.Setup(false)
|
||||
ctx := app.BaseApp.NewContext(false, types.Header{})
|
||||
ctx := app.BaseApp.NewContext(false, abcitypes.Header{})
|
||||
|
||||
app.InitChain(
|
||||
types.RequestInitChain{
|
||||
abcitypes.RequestInitChain{
|
||||
AppStateBytes: []byte("{}"),
|
||||
ChainId: "test-chain-id",
|
||||
},
|
||||
)
|
||||
|
||||
acc := app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(distribution.ModuleName))
|
||||
acc := app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(types.ModuleName))
|
||||
require.NotNil(t, acc)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue