Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix keeper client #288

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,16 @@
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
transferModule,
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.MintKeeper, app.GetSubspace(stakingtypes.ModuleName)),

Check failure on line 362 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

SA4001: *&x will be simplified to x. It will not copy x. (staticcheck)
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
icqModule,
ibcHooksModule,
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
Expand Down
10 changes: 5 additions & 5 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appCodec, appKeepers.keys[stakingtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.CustomStakingKeeper = customstaking.NewBaseKeeper(
appCodec /*appKeepers.keys[customstakingtypes.StoreKey],*/, *appKeepers.StakingKeeper, appKeepers.AccountKeeper, appKeepers.MintKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.MintKeeper = mintkeeper.NewKeeper(
appCodec, appKeepers.keys[minttypes.StoreKey], appKeepers.StakingKeeper,
appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), &appKeepers.TransferMiddlewareKeeper,
)

appKeepers.CustomStakingKeeper = customstaking.NewBaseKeeper(
appCodec, appKeepers.keys[stakingtypes.StoreKey], *appKeepers.StakingKeeper, appKeepers.AccountKeeper, appKeepers.MintKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.DistrKeeper = distrkeeper.NewKeeper(
Expand Down
9 changes: 5 additions & 4 deletions custom/staking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
mintkeeper "github.com/notional-labs/composable/v6/x/mint/keeper"
)

type Keeper struct {
stakingkeeper.Keeper
keys storetypes.StoreKey
cdc codec.BinaryCodec

Check failure on line 15 in custom/staking/keeper/keeper.go

View workflow job for this annotation

GitHub Actions / lint

field `cdc` is unused (unused)
storeKey storetypes.StoreKey
acck accountkeeper.AccountKeeper
mintkeeper mintkeeper.Keeper
acck accountkeeper.AccountKeeper
authority string
}

Expand All @@ -35,14 +35,15 @@

func NewBaseKeeper(
cdc codec.BinaryCodec,
// keys storetypes.StoreKey,
keys storetypes.StoreKey,
staking stakingkeeper.Keeper,
acck accountkeeper.AccountKeeper,
mintkeeper mintkeeper.Keeper,
authority string,
) Keeper {
keeper := Keeper{
Keeper: staking,
keys: keys,
acck: acck,
authority: authority,
mintkeeper: mintkeeper,
Expand Down
15 changes: 9 additions & 6 deletions custom/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@
"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"

Check failure on line 10 in custom/staking/module.go

View workflow job for this annotation

GitHub Actions / lint

ST1019: package "github.com/cosmos/cosmos-sdk/x/staking/keeper" is being imported more than once (stylecheck)
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

Check failure on line 11 in custom/staking/module.go

View workflow job for this annotation

GitHub Actions / lint

ST1019(related information): other import of "github.com/cosmos/cosmos-sdk/x/staking/keeper" (stylecheck)
"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"
minttypes "github.com/notional-labs/composable/v6/custom/staking/types"
)

// AppModule wraps around the bank module and the bank keeper to return the right total supply
type AppModule struct {
stakingmodule.AppModule
keeper customstakingkeeper.Keeper
subspace exported.Subspace
keeper customstakingkeeper.Keeper
mintkeeper minttypes.MintKeeper
subspace exported.Subspace
}

// 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 types.AccountKeeper, bankKeeper types.BankKeeper, mintkeeper minttypes.MintKeeper, ss exported.Subspace) AppModule {
stakingModule := stakingmodule.NewAppModule(cdc, &keeper.Keeper, accountKeeper, bankKeeper, ss)
return AppModule{
AppModule: stakingModule,
keeper: keeper,
subspace: ss,
AppModule: stakingModule,
keeper: keeper,
mintkeeper: mintkeeper,
subspace: ss,
}
}

Expand Down
16 changes: 16 additions & 0 deletions proto/centauri/stakingmiddleware/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package centauri.stakingmiddleware.v1beta1;

import "gogoproto/gogo.proto";

option go_package = "x/stakingmiddleware/types";

// GenesisState defines the stakingmiddleware module's genesis state.
message GenesisState {
// last_total_power tracks the total amounts of bonded tokens recorded during
// the previous end block.
bytes last_total_power = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
39 changes: 24 additions & 15 deletions x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/notional-labs/composable/v6/x/mint/types"
transferMiddlewareKeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"
)

// Keeper of the mint store
type Keeper struct {
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
accountKeeper types.AccountKeeper
stakingKeeper types.StakingKeeper
bankKeeper types.BankKeeper
feeCollectorName string
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
accountKeeper types.AccountKeeper
stakingKeeper types.StakingKeeper
bankKeeper types.BankKeeper
transferMiddlewareKeeper *transferMiddlewareKeeper.Keeper
feeCollectorName string

// the address capable of executing a MsgUpdateParams message. Typically, this
// should be the x/gov module account.
Expand All @@ -37,19 +39,21 @@ func NewKeeper(
bk types.BankKeeper,
feeCollectorName string,
authority string,
transferMiddlewareKeeper *transferMiddlewareKeeper.Keeper,
) Keeper {
// ensure mint module account is set
if addr := ak.GetModuleAddress(types.ModuleName); addr == nil {
panic(fmt.Sprintf("the x/%s module account has not been set", types.ModuleName))
}

return Keeper{
cdc: cdc,
storeKey: key,
stakingKeeper: sk,
bankKeeper: bk,
feeCollectorName: feeCollectorName,
authority: authority,
cdc: cdc,
storeKey: key,
stakingKeeper: sk,
bankKeeper: bk,
feeCollectorName: feeCollectorName,
authority: authority,
transferMiddlewareKeeper: transferMiddlewareKeeper,
}
}

Expand Down Expand Up @@ -168,7 +172,12 @@ func (k Keeper) StoreDelegation(ctx sdk.Context, delegation stakingtypes.Delegat

// SetLastTotalPower Set the last total validator power.
func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) {
// store := ctx.KVStore(k.storeKey)
// bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power})
// store.Set(types.DelegationKey, bz)
log := k.Logger(ctx)
log.Info("k.storeKey", k.storeKey)
log.Info("ctx", ctx)
fmt.Println("k.storeKey", k.storeKey)
fmt.Println("ctx", ctx)
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power})
store.Set(types.DelegationKey, bz)
}
8 changes: 5 additions & 3 deletions x/mint/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"context"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
Expand Down Expand Up @@ -44,10 +43,13 @@
// Unwrap context
ctx := sdk.UnwrapSDKContext(goCtx)

ms.SetLastTotalPower(ctx, math.Int{})
return nil, errorsmod.Wrapf(types.ErrInvalidAddress, "Custom error: nikita")
ms.transferMiddlewareKeeper.AddParachainIBCInfoToRemoveList(ctx, "pica")

// ms.SetLastTotalPower(ctx, math.Int{})
// return nil, errorsmod.Wrapf(types.ErrInvalidAddress, "Custom error: nikita")
return &types.MsgFundModuleAccountResponse{}, nil
// Check sender address
sender, err := sdk.AccAddressFromBech32(req.FromAddress)

Check failure on line 52 in x/mint/keeper/msg_server.go

View workflow job for this annotation

GitHub Actions / lint

unreachable: unreachable code (govet)
if err != nil {
return nil, err
}
Expand Down
8 changes: 5 additions & 3 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type AppModule struct {

keeper keeper.Keeper
authKeeper types.AccountKeeper
// tfmk transferkeeper.Keeper

// inflationCalculator is used to calculate the inflation rate during BeginBlock.
// If inflationCalculator is nil, the default inflation calculation logic is used.
Expand All @@ -102,9 +103,10 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper,
ic = types.DefaultInflationCalculationFn
}
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
authKeeper: ak,
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
authKeeper: ak,
// tfmk: transferMKeeper,
inflationCalculator: ic,
}
}
Expand Down
Loading
Loading