Skip to content

Commit 1119423

Browse files
committed
refactor(mint): migrate keeper accordingly to cosmos v0.50.6
1 parent 1760eff commit 1119423

File tree

6 files changed

+34
-110
lines changed

6 files changed

+34
-110
lines changed

x/mint/keeper/genesis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (s *GenesisTestSuite) SetupTest() {
7070

7171
func (s *GenesisTestSuite) TestImportExportGenesis() {
7272
genesisState := types.DefaultGenesisState()
73-
genesisState.Minter = types.NewMinter(math.LegacyOneDec(), math.LegacyNewDecWithPrec(20, 2))
73+
genesisState.Minter = types.NewMinter(math.LegacyNewDecWithPrec(20, 2), math.LegacyNewDec(1))
7474
genesisState.Params = types.NewParams(
7575
"testDenom",
7676
math.LegacyNewDecWithPrec(69, 2),

x/mint/keeper/keeper.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package keeper
22

33
import (
44
"context"
5+
"fmt"
56

67
"cosmossdk.io/collections"
7-
"cosmossdk.io/core/store"
8+
storetypes "cosmossdk.io/core/store"
89
"cosmossdk.io/log"
910
"cosmossdk.io/math"
1011

@@ -14,25 +15,27 @@ import (
1415
"github.com/axone-protocol/axoned/v8/x/mint/types"
1516
)
1617

17-
// Keeper of the mint store.
18+
// Keeper of the mint store
1819
type Keeper struct {
19-
cdc codec.BinaryCodec
20-
storeService store.KVStoreService
21-
// the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account.
22-
authority string
20+
cdc codec.BinaryCodec
21+
storeService storetypes.KVStoreService
2322
stakingKeeper types.StakingKeeper
2423
bankKeeper types.BankKeeper
2524
feeCollectorName string
2625

26+
// the address capable of executing a MsgUpdateParams message. Typically, this
27+
// should be the x/gov module account.
28+
authority string
29+
2730
Schema collections.Schema
2831
Params collections.Item[types.Params]
2932
Minter collections.Item[types.Minter]
3033
}
3134

32-
// NewKeeper creates a new mint Keeper instance.
35+
// NewKeeper creates a new mint Keeper instance
3336
func NewKeeper(
3437
cdc codec.BinaryCodec,
35-
storeService store.KVStoreService,
38+
storeService storetypes.KVStoreService,
3639
sk types.StakingKeeper,
3740
ak types.AccountKeeper,
3841
bk types.BankKeeper,
@@ -41,17 +44,17 @@ func NewKeeper(
4144
) Keeper {
4245
// ensure mint module account is set
4346
if addr := ak.GetModuleAddress(types.ModuleName); addr == nil {
44-
panic("the mint module account has not been set")
47+
panic(fmt.Sprintf("the x/%s module account has not been set", types.ModuleName))
4548
}
4649

4750
sb := collections.NewSchemaBuilder(storeService)
4851
k := Keeper{
4952
cdc: cdc,
5053
storeService: storeService,
51-
authority: authority,
5254
stakingKeeper: sk,
5355
bankKeeper: bk,
5456
feeCollectorName: feeCollectorName,
57+
authority: authority,
5558
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
5659
Minter: collections.NewItem(sb, types.MinterKey, "minter", codec.CollValue[types.Minter](cdc)),
5760
}
@@ -61,17 +64,16 @@ func NewKeeper(
6164
panic(err)
6265
}
6366
k.Schema = schema
64-
6567
return k
6668
}
6769

6870
// GetAuthority returns the x/mint module's authority.
69-
func (keeper Keeper) GetAuthority() string {
70-
return keeper.authority
71+
func (k Keeper) GetAuthority() string {
72+
return k.authority
7173
}
7274

7375
// Logger returns a module-specific logger.
74-
func (keeper Keeper) Logger(ctx context.Context) log.Logger {
76+
func (k Keeper) Logger(ctx context.Context) log.Logger {
7577
sdkCtx := sdk.UnwrapSDKContext(ctx)
7678
return sdkCtx.Logger().With("module", "x/"+types.ModuleName)
7779
}
@@ -84,29 +86,29 @@ func (keeper Keeper) TokenSupply(ctx context.Context, denom string) math.Int {
8486

8587
// StakingTokenSupply implements an alias call to the underlying staking keeper's
8688
// StakingTokenSupply to be used in BeginBlocker.
87-
func (keeper Keeper) StakingTokenSupply(ctx context.Context) (math.Int, error) {
88-
return keeper.stakingKeeper.StakingTokenSupply(ctx)
89+
func (k Keeper) StakingTokenSupply(ctx context.Context) (math.Int, error) {
90+
return k.stakingKeeper.StakingTokenSupply(ctx)
8991
}
9092

9193
// BondedRatio implements an alias call to the underlying staking keeper's
9294
// BondedRatio to be used in BeginBlocker.
93-
func (keeper Keeper) BondedRatio(ctx context.Context) (math.LegacyDec, error) {
94-
return keeper.stakingKeeper.BondedRatio(ctx)
95+
func (k Keeper) BondedRatio(ctx context.Context) (math.LegacyDec, error) {
96+
return k.stakingKeeper.BondedRatio(ctx)
9597
}
9698

9799
// MintCoins implements an alias call to the underlying supply keeper's
98100
// MintCoins to be used in BeginBlocker.
99-
func (keeper Keeper) MintCoins(ctx context.Context, newCoins sdk.Coins) error {
101+
func (k Keeper) MintCoins(ctx context.Context, newCoins sdk.Coins) error {
100102
if newCoins.Empty() {
101103
// skip as no coins need to be minted
102104
return nil
103105
}
104106

105-
return keeper.bankKeeper.MintCoins(ctx, types.ModuleName, newCoins)
107+
return k.bankKeeper.MintCoins(ctx, types.ModuleName, newCoins)
106108
}
107109

108110
// AddCollectedFees implements an alias call to the underlying supply keeper's
109111
// AddCollectedFees to be used in BeginBlocker.
110-
func (keeper Keeper) AddCollectedFees(ctx context.Context, fees sdk.Coins) error {
111-
return keeper.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, keeper.feeCollectorName, fees)
112+
func (k Keeper) AddCollectedFees(ctx context.Context, fees sdk.Coins) error {
113+
return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, fees)
112114
}

x/mint/keeper/keeper_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestKeeperTestSuite(t *testing.T) {
3939
func (s *IntegrationTestSuite) SetupTest() {
4040
encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{})
4141
key := storetypes.NewKVStoreKey(types.StoreKey)
42+
storeService := runtime.NewKVStoreService(key)
4243
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
4344
s.ctx = testCtx.Ctx
4445

@@ -52,7 +53,7 @@ func (s *IntegrationTestSuite) SetupTest() {
5253

5354
s.mintKeeper = keeper.NewKeeper(
5455
encCfg.Codec,
55-
runtime.NewKVStoreService(key),
56+
storeService,
5657
stakingKeeper,
5758
accountKeeper,
5859
bankKeeper,

x/mint/keeper/msg_server.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@ import (
1212

1313
var _ types.MsgServer = msgServer{}
1414

15+
// msgServer is a wrapper of Keeper.
1516
type msgServer struct {
1617
Keeper
1718
}
1819

19-
// NewMsgServerImpl returns an implementation of the MsgServer interface
20-
// for the provided Keeper.
21-
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
22-
return &msgServer{Keeper: keeper}
20+
// NewMsgServerImpl returns an implementation of the x/mint MsgServer interface.
21+
func NewMsgServerImpl(k Keeper) types.MsgServer {
22+
return &msgServer{
23+
Keeper: k,
24+
}
2325
}
2426

25-
// UpdateParams implements the gRPC MsgServer interface. When an UpdateParams
26-
// proposal passes, it updates the module parameters. The update can only be
27-
// performed if the requested authority is the Cosmos SDK governance module
28-
// account.
27+
// UpdateParams updates the params.
2928
func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
3029
if ms.authority != msg.Authority {
3130
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, msg.Authority)

x/mint/simulation/decoder.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

x/mint/simulation/decoder_test.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)