Skip to content

Commit

Permalink
linted, with the exception of unreachable code
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Dec 19, 2023
1 parent 38c7444 commit e187b8e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func NewComposableApp(
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
customstaking.NewAppModule(appCodec, *&app.CustomStakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
customstaking.NewAppModule(appCodec, app.CustomStakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
stakingmiddleware.NewAppModule(appCodec, app.StakingMiddlewareKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
upgrade.NewAppModule(app.UpgradeKeeper),
Expand Down
1 change: 0 additions & 1 deletion custom/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (k msgServer) EditValidator(goCtx context.Context, msg *types.MsgEditValida
}

func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*types.MsgDelegateResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)

// bondDenom := k.BondDenom(ctx)
Expand Down
17 changes: 8 additions & 9 deletions custom/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
stakingmodule "github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/exported"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

// custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper"
customstakingkeeper "github.com/notional-labs/composable/v6/custom/staking/keeper"
Expand All @@ -23,7 +22,7 @@ type AppModule struct {
}

// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ss exported.Subspace) AppModule {
func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKeeper stakingtypes.AccountKeeper, bankKeeper stakingtypes.BankKeeper, ss exported.Subspace) AppModule {
stakingModule := stakingmodule.NewAppModule(cdc, &keeper.Keeper, accountKeeper, bankKeeper, ss)
return AppModule{
AppModule: stakingModule,
Expand All @@ -37,20 +36,20 @@ func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKee
// when trying to force this custom keeper into a bankkeeper.BaseKeeper
func (am AppModule) RegisterServices(cfg module.Configurator) {
// types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper))
types.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper, am.keeper))
querier := keeper.Querier{Keeper: &am.keeper.Keeper}
types.RegisterQueryServer(cfg.QueryServer(), querier)
stakingtypes.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper, am.keeper))
querier := stakingkeeper.Querier{Keeper: &am.keeper.Keeper}
stakingtypes.RegisterQueryServer(cfg.QueryServer(), querier)

m := stakingkeeper.NewMigrator(&am.keeper.Keeper, am.subspace)
if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil {
if err := cfg.RegisterMigration(stakingtypes.ModuleName, 1, m.Migrate1to2); err != nil {
panic(fmt.Sprintf("failed to migrate x/staking from version 1 to 2: %v", err))
}

if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil {
if err := cfg.RegisterMigration(stakingtypes.ModuleName, 2, m.Migrate2to3); err != nil {
panic(fmt.Sprintf("failed to migrate x/staking from version 2 to 3: %v", err))
}

if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
if err := cfg.RegisterMigration(stakingtypes.ModuleName, 3, m.Migrate3to4); err != nil {
panic(fmt.Sprintf("failed to migrate x/staking from version 3 to 4: %v", err))
}
}
12 changes: 5 additions & 7 deletions x/stakingmiddleware/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package keeper

import (
"cosmossdk.io/math"
"github.com/cometbft/cometbft/libs/log"
"github.com/notional-labs/composable/v6/x/stakingmiddleware/types"

"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"

// "github.com/notional-labs/composable/v6/x/mint/types"
sdkmath "cosmossdk.io/math"
)

Expand Down Expand Up @@ -82,18 +80,18 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
// }

// SetLastTotalPower Set the last total validator power.
func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) {
func (k Keeper) SetLastTotalPower(ctx sdk.Context, power sdkmath.Int) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power})
store.Set(types.DelegationKey, bz)
}

func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int {
func (k Keeper) GetLastTotalPower(ctx sdk.Context) sdkmath.Int {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.DelegationKey)

if bz == nil {
return math.ZeroInt()
return sdkmath.ZeroInt()
}

ip := sdk.IntProto{}
Expand All @@ -102,8 +100,8 @@ func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int {
return ip.Int
}

func (k Keeper) SetDelegation(ctx sdk.Context, DelegatorAddress string, ValidatorAddress string, Denom string, Amount sdkmath.Int) {
delegation := types.Delegation{DelegatorAddress: DelegatorAddress, ValidatorAddress: ValidatorAddress, Amount: sdk.NewCoin(Denom, Amount)}
func (k Keeper) SetDelegation(ctx sdk.Context, sourceDelegatorAddress, validatorAddress, denom string, amount sdkmath.Int) {
delegation := types.Delegation{DelegatorAddress: sourceDelegatorAddress, ValidatorAddress: validatorAddress, Amount: sdk.NewCoin(denom, amount)}
delegatorAddress := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress)

store := ctx.KVStore(k.storeKey)
Expand Down
1 change: 0 additions & 1 deletion x/stakingmiddleware/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ func NewMsgServerImpl(k Keeper) types.MsgServer {

// UpdateParams updates the params.
func (ms msgServer) SetPower(goCtx context.Context, req *types.MsgSetPower) (*types.MsgSetPowerResponse, error) {

return &types.MsgSetPowerResponse{}, nil
}
3 changes: 1 addition & 2 deletions x/stakingmiddleware/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/notional-labs/composable/v6/x/stakingmiddleware/client/cli"
"github.com/notional-labs/composable/v6/x/stakingmiddleware/keeper"
"github.com/notional-labs/composable/v6/x/stakingmiddleware/types"
middlewarestaking "github.com/notional-labs/composable/v6/x/stakingmiddleware/types"
)

var (
Expand All @@ -38,7 +37,7 @@ var _ module.AppModuleBasic = AppModuleBasic{}

// Name returns the mint module's name.
func (AppModuleBasic) Name() string {
return middlewarestaking.ModuleName
return types.ModuleName
}

// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec.
Expand Down

0 comments on commit e187b8e

Please sign in to comment.