yay it compiles
This commit is contained in:
parent
5790f33159
commit
251a81f589
|
@ -97,24 +97,29 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
|
||||||
)
|
)
|
||||||
|
|
||||||
// add handlers
|
// add handlers
|
||||||
|
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
|
||||||
app.bankKeeper = bank.NewBaseKeeper(app.accountMapper)
|
app.bankKeeper = bank.NewBaseKeeper(app.accountMapper)
|
||||||
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
|
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
|
||||||
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
|
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
|
||||||
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.tkeyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.tkeyStake,
|
||||||
app.distrKeeper = distr.NewKeeper(app.cdc, app.keyDistr, app.tkeyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
||||||
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
|
app.distrKeeper = distr.NewKeeper(app.cdc, app.keyDistr, app.tkeyStake,
|
||||||
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(), app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
|
app.paramsKeeper.Setter(), app.bankKeeper, app.stakeKeeper,
|
||||||
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
|
app.feeCollectionKeeper, app.RegisterCodespace(stake.DefaultCodespace))
|
||||||
|
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper,
|
||||||
|
app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
|
||||||
|
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(),
|
||||||
|
app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
|
||||||
|
|
||||||
// register the staking hooks
|
// register the staking hooks
|
||||||
app.stakeKeeper = app.stakeKeeper.WithValidatorHooks(NewHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()))
|
app.stakeKeeper = app.stakeKeeper.WithHooks(NewHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()))
|
||||||
|
|
||||||
// register message routes
|
// register message routes
|
||||||
app.Router().
|
app.Router().
|
||||||
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
|
||||||
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
|
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
|
||||||
AddRoute("stake", stake.NewHandler(app.stakeKeeper)).
|
AddRoute("stake", stake.NewHandler(app.stakeKeeper)).
|
||||||
AddRoute("distr", stake.NewHandler(app.distrKeeper)).
|
AddRoute("distr", distr.NewHandler(app.distrKeeper)).
|
||||||
AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)).
|
AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)).
|
||||||
AddRoute("gov", gov.NewHandler(app.govKeeper))
|
AddRoute("gov", gov.NewHandler(app.govKeeper))
|
||||||
|
|
||||||
|
@ -257,7 +262,7 @@ type Hooks struct {
|
||||||
sh slashing.Hooks
|
sh slashing.Hooks
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHooks(dh distr.Hooks, sh slashing.ValidatorHooks) Hooks {
|
func NewHooks(dh distr.Hooks, sh slashing.Hooks) Hooks {
|
||||||
return Hooks{dh, sh}
|
return Hooks{dh, sh}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,8 +281,8 @@ func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) {
|
||||||
func (h Hooks) OnValidatorBonded(ctx sdk.Context, addr sdk.ConsAddress) {
|
func (h Hooks) OnValidatorBonded(ctx sdk.Context, addr sdk.ConsAddress) {
|
||||||
h.sh.OnValidatorBonded(ctx, addr)
|
h.sh.OnValidatorBonded(ctx, addr)
|
||||||
}
|
}
|
||||||
func (h Hooks) OnValidatorBeginBonded(ctx sdk.Context, addr sdk.ConsAddress) {
|
func (h Hooks) OnValidatorBeginUnbonding(ctx sdk.Context, addr sdk.ConsAddress) {
|
||||||
h.sh.OnValidatorBeginBonding(ctx, addr)
|
h.sh.OnValidatorBeginUnbonding(ctx, addr)
|
||||||
}
|
}
|
||||||
func (h Hooks) OnDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
|
func (h Hooks) OnDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
|
||||||
h.dh.OnDelegationCreated(ctx, delAddr, valAddr)
|
h.dh.OnDelegationCreated(ctx, delAddr, valAddr)
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||||
|
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||||
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||||
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
|
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
|
||||||
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
||||||
|
@ -108,8 +109,8 @@ func main() {
|
||||||
}
|
}
|
||||||
distrCmd.AddCommand(
|
distrCmd.AddCommand(
|
||||||
client.PostCommands(
|
client.PostCommands(
|
||||||
stakecmd.GetCmdWithdrawDelegationRewardsAll(cdc),
|
distr.GetCmdWithdrawRewards(cdc),
|
||||||
stakecmd.GetCmdSetWithdrawAddr(cdc),
|
distr.GetCmdSetWithdrawAddr(cdc),
|
||||||
)...)
|
)...)
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
distrCmd,
|
distrCmd,
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
package distribution
|
package distribution
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/tags"
|
"github.com/cosmos/cosmos-sdk/x/distribution/tags"
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/stake/querier"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -27,8 +27,7 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
NewKeeper = keeper.NewKeeper
|
NewKeeper = keeper.NewKeeper
|
||||||
NewQuerier = querier.NewQuerier
|
|
||||||
|
|
||||||
GetValidatorDistInfoKey = keeper.GetValidatorDistInfoKey
|
GetValidatorDistInfoKey = keeper.GetValidatorDistInfoKey
|
||||||
GetDelegationDistInfoKey = keeper.GetDelegationDistInfoKey
|
GetDelegationDistInfoKey = keeper.GetDelegationDistInfoKey
|
||||||
|
@ -51,6 +50,9 @@ var (
|
||||||
NewMsgWithdrawDelegatorRewardsAll = types.NewMsgWithdrawDelegatorRewardsAll
|
NewMsgWithdrawDelegatorRewardsAll = types.NewMsgWithdrawDelegatorRewardsAll
|
||||||
NewMsgWithdrawDelegationReward = types.NewMsgWithdrawDelegatorReward
|
NewMsgWithdrawDelegationReward = types.NewMsgWithdrawDelegatorReward
|
||||||
NewMsgWithdrawValidatorRewardsAll = types.NewMsgWithdrawValidatorRewardsAll
|
NewMsgWithdrawValidatorRewardsAll = types.NewMsgWithdrawValidatorRewardsAll
|
||||||
|
|
||||||
|
GetCmdWithdrawRewards = cli.GetCmdWithdrawRewards
|
||||||
|
GetCmdSetWithdrawAddr = cli.GetCmdSetWithdrawAddr
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -12,7 +12,10 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -21,7 +24,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// command to withdraw rewards
|
// command to withdraw rewards
|
||||||
func GetCmdWithdrawDelegationRewardsAll(cdc *codec.Codec) *cobra.Command {
|
func GetCmdWithdrawRewards(cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "withdraw-rewards",
|
Use: "withdraw-rewards",
|
||||||
Short: "withdraw rewards for either: all-delegations, a delegation, or a validator",
|
Short: "withdraw rewards for either: all-delegations, a delegation, or a validator",
|
||||||
|
@ -36,7 +39,7 @@ func GetCmdWithdrawDelegationRewardsAll(cdc *codec.Codec) *cobra.Command {
|
||||||
flagOnlyFromValidator, flagIsValidator)
|
flagOnlyFromValidator, flagIsValidator)
|
||||||
}
|
}
|
||||||
|
|
||||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||||
cliCtx := context.NewCLIContext().
|
cliCtx := context.NewCLIContext().
|
||||||
WithCodec(cdc).
|
WithCodec(cdc).
|
||||||
WithLogger(os.Stdout).
|
WithLogger(os.Stdout).
|
||||||
|
@ -49,8 +52,8 @@ func GetCmdWithdrawDelegationRewardsAll(cdc *codec.Codec) *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
valAddr := sdk.ValAddress{addr.Bytes()}
|
valAddr := sdk.ValAddress(addr.Bytes())
|
||||||
msg := distr.NewMsgWithdrawValidatorRewardsAll(valAddr)
|
msg = types.NewMsgWithdrawValidatorRewardsAll(valAddr)
|
||||||
case onlyFromVal != "":
|
case onlyFromVal != "":
|
||||||
delAddr, err := cliCtx.GetFromAddress()
|
delAddr, err := cliCtx.GetFromAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -62,17 +65,17 @@ func GetCmdWithdrawDelegationRewardsAll(cdc *codec.Codec) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := distr.NewMsgWithdrawDelegationReward(delAddr, valAddr)
|
msg = types.NewMsgWithdrawDelegatorReward(delAddr, valAddr)
|
||||||
default:
|
default:
|
||||||
delAddr, err := cliCtx.GetFromAddress()
|
delAddr, err := cliCtx.GetFromAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
msg := distr.NewMsgWithdrawDelegationRewardsAll(delAddr)
|
msg = types.NewMsgWithdrawDelegatorRewardsAll(delAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// build and sign the transaction, then broadcast to Tendermint
|
// build and sign the transaction, then broadcast to Tendermint
|
||||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().String(flagOnlyFromValidator, "", "only withdraw from this validator address (in bech)")
|
cmd.Flags().String(flagOnlyFromValidator, "", "only withdraw from this validator address (in bech)")
|
||||||
|
@ -88,7 +91,7 @@ func GetCmdSetWithdrawAddr(cdc *codec.Codec) *cobra.Command {
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
|
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
||||||
cliCtx := context.NewCLIContext().
|
cliCtx := context.NewCLIContext().
|
||||||
WithCodec(cdc).
|
WithCodec(cdc).
|
||||||
WithLogger(os.Stdout).
|
WithLogger(os.Stdout).
|
||||||
|
@ -104,10 +107,10 @@ func GetCmdSetWithdrawAddr(cdc *codec.Codec) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := distr.NewMsgSetWithdrawAddress(delAddr, withdrawAddr)
|
msg := types.NewMsgSetWithdrawAddress(delAddr, withdrawAddr)
|
||||||
|
|
||||||
// build and sign the transaction, then broadcast to Tendermint
|
// build and sign the transaction, then broadcast to Tendermint
|
||||||
return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg})
|
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return cmd
|
return cmd
|
||||||
|
|
|
@ -10,7 +10,7 @@ func (k Keeper) AllocateFees(ctx sdk.Context) {
|
||||||
|
|
||||||
// get the proposer of this block
|
// get the proposer of this block
|
||||||
proposerConsAddr := k.GetProposerConsAddr(ctx)
|
proposerConsAddr := k.GetProposerConsAddr(ctx)
|
||||||
proserValidator := k.stakeKeeper.GetValidatorFromConsAddr(ctx, proposerConsAddr)
|
proserValidator := k.stakeKeeper.ValidatorByConsAddr(ctx, proposerConsAddr)
|
||||||
proposerDist := k.GetValidatorDistInfo(ctx, proserValidator.GetOperator())
|
proposerDist := k.GetValidatorDistInfo(ctx, proserValidator.GetOperator())
|
||||||
|
|
||||||
// get the fees which have been getting collected through all the
|
// get the fees which have been getting collected through all the
|
||||||
|
|
|
@ -71,8 +71,8 @@ func (k Keeper) WithdrawDelegationReward(ctx sdk.Context, delegatorAddr sdk.AccA
|
||||||
feePool := k.GetFeePool(ctx)
|
feePool := k.GetFeePool(ctx)
|
||||||
delInfo := k.GetDelegatorDistInfo(ctx, delegatorAddr, validatorAddr)
|
delInfo := k.GetDelegatorDistInfo(ctx, delegatorAddr, validatorAddr)
|
||||||
valInfo := k.GetValidatorDistInfo(ctx, validatorAddr)
|
valInfo := k.GetValidatorDistInfo(ctx, validatorAddr)
|
||||||
validator := k.stakeKeeper.GetValidator(ctx, validatorAddr)
|
validator := k.stakeKeeper.Validator(ctx, validatorAddr)
|
||||||
delegation := k.stakeKeeper.GetDelegation(ctx, delegatorAddr, validatorAddr)
|
delegation := k.stakeKeeper.Delegation(ctx, delegatorAddr, validatorAddr)
|
||||||
|
|
||||||
delInfo, feePool, withdraw := delInfo.WithdrawRewards(feePool, valInfo, height, bondedTokens,
|
delInfo, feePool, withdraw := delInfo.WithdrawRewards(feePool, valInfo, height, bondedTokens,
|
||||||
validator.GetTokens(), validator.GetDelegatorShares(), delegation.GetShares(), validator.GetCommission())
|
validator.GetTokens(), validator.GetDelegatorShares(), delegation.GetShares(), validator.GetCommission())
|
||||||
|
@ -104,8 +104,8 @@ func (k Keeper) GetDelegatorRewardsAll(ctx sdk.Context, delAddr sdk.AccAddress,
|
||||||
valAddr := del.GetValidator()
|
valAddr := del.GetValidator()
|
||||||
delInfo := k.GetDelegatorDistInfo(ctx, delAddr, valAddr)
|
delInfo := k.GetDelegatorDistInfo(ctx, delAddr, valAddr)
|
||||||
valInfo := k.GetValidatorDistInfo(ctx, valAddr)
|
valInfo := k.GetValidatorDistInfo(ctx, valAddr)
|
||||||
validator := k.stakeKeeper.GetValidator(ctx, valAddr)
|
validator := k.stakeKeeper.Validator(ctx, valAddr)
|
||||||
delegation := k.stakeKeeper.GetDelegation(ctx, delAddr, valAddr)
|
delegation := k.stakeKeeper.Delegation(ctx, delAddr, valAddr)
|
||||||
|
|
||||||
delInfo, feePool, diWithdraw := delInfo.WithdrawRewards(feePool, valInfo, height, bondedTokens,
|
delInfo, feePool, diWithdraw := delInfo.WithdrawRewards(feePool, valInfo, height, bondedTokens,
|
||||||
validator.GetTokens(), validator.GetDelegatorShares(), delegation.GetShares(), validator.GetCommission())
|
validator.GetTokens(), validator.GetDelegatorShares(), delegation.GetShares(), validator.GetCommission())
|
||||||
|
|
|
@ -65,7 +65,7 @@ type Hooks struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Validator Hooks
|
// New Validator Hooks
|
||||||
func (k Keeper) ValidatorHooks() Hooks { return Hooks{k} }
|
func (k Keeper) Hooks() Hooks { return Hooks{k} }
|
||||||
|
|
||||||
// nolint
|
// nolint
|
||||||
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
|
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (k Keeper) WithdrawValidatorRewardsAll(ctx sdk.Context, operatorAddr sdk.Va
|
||||||
|
|
||||||
// withdraw self-delegation
|
// withdraw self-delegation
|
||||||
height := ctx.BlockHeight()
|
height := ctx.BlockHeight()
|
||||||
validator := k.stakeKeeper.GetValidator(ctx, operatorAddr)
|
validator := k.stakeKeeper.Validator(ctx, operatorAddr)
|
||||||
accAddr := sdk.AccAddress(operatorAddr.Bytes())
|
accAddr := sdk.AccAddress(operatorAddr.Bytes())
|
||||||
withdraw := k.GetDelegatorRewardsAll(ctx, accAddr, height)
|
withdraw := k.GetDelegatorRewardsAll(ctx, accAddr, height)
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ import sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
type StakeKeeper interface {
|
type StakeKeeper interface {
|
||||||
IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress,
|
IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress,
|
||||||
fn func(index int64, delegation sdk.Delegation) (stop bool))
|
fn func(index int64, delegation sdk.Delegation) (stop bool))
|
||||||
GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation
|
Delegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation
|
||||||
GetValidator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Validator
|
Validator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Validator
|
||||||
GetValidatorFromConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) sdk.Validator
|
ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) sdk.Validator
|
||||||
TotalPower(ctx sdk.Context) sdk.Dec
|
TotalPower(ctx sdk.Context) sdk.Dec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue