yay it compiles

This commit is contained in:
rigelrozanski 2018-09-20 00:53:48 -04:00
parent 5790f33159
commit 251a81f589
9 changed files with 47 additions and 36 deletions

View File

@ -97,24 +97,29 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
)
// add handlers
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
app.bankKeeper = bank.NewBaseKeeper(app.accountMapper)
app.ibcMapper = ibc.NewMapper(app.cdc, app.keyIBC, app.RegisterCodespace(ibc.DefaultCodespace))
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.distrKeeper = distr.NewKeeper(app.cdc, app.keyDistr, app.tkeyStake, app.bankKeeper, 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))
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.tkeyStake,
app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.distrKeeper = distr.NewKeeper(app.cdc, app.keyDistr, app.tkeyStake,
app.paramsKeeper.Setter(), app.bankKeeper, app.stakeKeeper,
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
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
app.Router().
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)).
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("gov", gov.NewHandler(app.govKeeper))
@ -257,7 +262,7 @@ type Hooks struct {
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}
}
@ -276,8 +281,8 @@ func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) {
func (h Hooks) OnValidatorBonded(ctx sdk.Context, addr sdk.ConsAddress) {
h.sh.OnValidatorBonded(ctx, addr)
}
func (h Hooks) OnValidatorBeginBonded(ctx sdk.Context, addr sdk.ConsAddress) {
h.sh.OnValidatorBeginBonding(ctx, addr)
func (h Hooks) OnValidatorBeginUnbonding(ctx sdk.Context, addr sdk.ConsAddress) {
h.sh.OnValidatorBeginUnbonding(ctx, addr)
}
func (h Hooks) OnDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
h.dh.OnDelegationCreated(ctx, delAddr, valAddr)

View File

@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/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"
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
@ -108,8 +109,8 @@ func main() {
}
distrCmd.AddCommand(
client.PostCommands(
stakecmd.GetCmdWithdrawDelegationRewardsAll(cdc),
stakecmd.GetCmdSetWithdrawAddr(cdc),
distr.GetCmdWithdrawRewards(cdc),
distr.GetCmdSetWithdrawAddr(cdc),
)...)
rootCmd.AddCommand(
distrCmd,

View File

@ -2,10 +2,10 @@
package distribution
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/tags"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/stake/querier"
)
type (
@ -27,8 +27,7 @@ type (
)
var (
NewKeeper = keeper.NewKeeper
NewQuerier = querier.NewQuerier
NewKeeper = keeper.NewKeeper
GetValidatorDistInfoKey = keeper.GetValidatorDistInfoKey
GetDelegationDistInfoKey = keeper.GetDelegationDistInfoKey
@ -51,6 +50,9 @@ var (
NewMsgWithdrawDelegatorRewardsAll = types.NewMsgWithdrawDelegatorRewardsAll
NewMsgWithdrawDelegationReward = types.NewMsgWithdrawDelegatorReward
NewMsgWithdrawValidatorRewardsAll = types.NewMsgWithdrawValidatorRewardsAll
GetCmdWithdrawRewards = cli.GetCmdWithdrawRewards
GetCmdSetWithdrawAddr = cli.GetCmdSetWithdrawAddr
)
const (

View File

@ -12,7 +12,10 @@ import (
"github.com/cosmos/cosmos-sdk/client/utils"
"github.com/cosmos/cosmos-sdk/codec"
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 (
@ -21,7 +24,7 @@ var (
)
// command to withdraw rewards
func GetCmdWithdrawDelegationRewardsAll(cdc *codec.Codec) *cobra.Command {
func GetCmdWithdrawRewards(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw-rewards",
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)
}
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
@ -49,8 +52,8 @@ func GetCmdWithdrawDelegationRewardsAll(cdc *codec.Codec) *cobra.Command {
if err != nil {
return err
}
valAddr := sdk.ValAddress{addr.Bytes()}
msg := distr.NewMsgWithdrawValidatorRewardsAll(valAddr)
valAddr := sdk.ValAddress(addr.Bytes())
msg = types.NewMsgWithdrawValidatorRewardsAll(valAddr)
case onlyFromVal != "":
delAddr, err := cliCtx.GetFromAddress()
if err != nil {
@ -62,17 +65,17 @@ func GetCmdWithdrawDelegationRewardsAll(cdc *codec.Codec) *cobra.Command {
return err
}
msg := distr.NewMsgWithdrawDelegationReward(delAddr, valAddr)
msg = types.NewMsgWithdrawDelegatorReward(delAddr, valAddr)
default:
delAddr, err := cliCtx.GetFromAddress()
if err != nil {
return err
}
msg := distr.NewMsgWithdrawDelegationRewardsAll(delAddr)
msg = types.NewMsgWithdrawDelegatorRewardsAll(delAddr)
}
// 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)")
@ -88,7 +91,7 @@ func GetCmdSetWithdrawAddr(cdc *codec.Codec) *cobra.Command {
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
txCtx := authctx.NewTxContextFromCLI().WithCodec(cdc)
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
@ -104,10 +107,10 @@ func GetCmdSetWithdrawAddr(cdc *codec.Codec) *cobra.Command {
return err
}
msg := distr.NewMsgSetWithdrawAddress(delAddr, withdrawAddr)
msg := types.NewMsgSetWithdrawAddress(delAddr, withdrawAddr)
// 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

View File

@ -10,7 +10,7 @@ func (k Keeper) AllocateFees(ctx sdk.Context) {
// get the proposer of this block
proposerConsAddr := k.GetProposerConsAddr(ctx)
proserValidator := k.stakeKeeper.GetValidatorFromConsAddr(ctx, proposerConsAddr)
proserValidator := k.stakeKeeper.ValidatorByConsAddr(ctx, proposerConsAddr)
proposerDist := k.GetValidatorDistInfo(ctx, proserValidator.GetOperator())
// get the fees which have been getting collected through all the

View File

@ -71,8 +71,8 @@ func (k Keeper) WithdrawDelegationReward(ctx sdk.Context, delegatorAddr sdk.AccA
feePool := k.GetFeePool(ctx)
delInfo := k.GetDelegatorDistInfo(ctx, delegatorAddr, validatorAddr)
valInfo := k.GetValidatorDistInfo(ctx, validatorAddr)
validator := k.stakeKeeper.GetValidator(ctx, validatorAddr)
delegation := k.stakeKeeper.GetDelegation(ctx, delegatorAddr, validatorAddr)
validator := k.stakeKeeper.Validator(ctx, validatorAddr)
delegation := k.stakeKeeper.Delegation(ctx, delegatorAddr, validatorAddr)
delInfo, feePool, withdraw := delInfo.WithdrawRewards(feePool, valInfo, height, bondedTokens,
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()
delInfo := k.GetDelegatorDistInfo(ctx, delAddr, valAddr)
valInfo := k.GetValidatorDistInfo(ctx, valAddr)
validator := k.stakeKeeper.GetValidator(ctx, valAddr)
delegation := k.stakeKeeper.GetDelegation(ctx, delAddr, valAddr)
validator := k.stakeKeeper.Validator(ctx, valAddr)
delegation := k.stakeKeeper.Delegation(ctx, delAddr, valAddr)
delInfo, feePool, diWithdraw := delInfo.WithdrawRewards(feePool, valInfo, height, bondedTokens,
validator.GetTokens(), validator.GetDelegatorShares(), delegation.GetShares(), validator.GetCommission())

View File

@ -65,7 +65,7 @@ type Hooks struct {
}
// New Validator Hooks
func (k Keeper) ValidatorHooks() Hooks { return Hooks{k} }
func (k Keeper) Hooks() Hooks { return Hooks{k} }
// nolint
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {

View File

@ -38,7 +38,7 @@ func (k Keeper) WithdrawValidatorRewardsAll(ctx sdk.Context, operatorAddr sdk.Va
// withdraw self-delegation
height := ctx.BlockHeight()
validator := k.stakeKeeper.GetValidator(ctx, operatorAddr)
validator := k.stakeKeeper.Validator(ctx, operatorAddr)
accAddr := sdk.AccAddress(operatorAddr.Bytes())
withdraw := k.GetDelegatorRewardsAll(ctx, accAddr, height)

View File

@ -6,9 +6,9 @@ import sdk "github.com/cosmos/cosmos-sdk/types"
type StakeKeeper interface {
IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress,
fn func(index int64, delegation sdk.Delegation) (stop bool))
GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation
GetValidator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Validator
GetValidatorFromConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) sdk.Validator
Delegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation
Validator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Validator
ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) sdk.Validator
TotalPower(ctx sdk.Context) sdk.Dec
}