Skip to content

Commit 8f3cdb8

Browse files
authored
Merge pull request #645 from axone-protocol/refactor/update-mint
⬆️ Update mint module to align on latest cosmos-sdk v0.50.6
2 parents 44f1152 + 039a1eb commit 8f3cdb8

18 files changed

+172
-160
lines changed

docs/command/axoned_query.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ axoned query [flags]
3333
* [axoned query ibc-transfer](axoned_query_ibc-transfer.md) - IBC fungible token transfer query subcommands
3434
* [axoned query interchain-accounts](axoned_query_interchain-accounts.md) - IBC interchain accounts query subcommands
3535
* [axoned query logic](axoned_query_logic.md) - Querying commands for the logic module
36-
* [axoned query mint](axoned_query_mint.md) - Querying commands for the minting module
36+
* [axoned query mint](axoned_query_mint.md) - Querying commands for the mint module
3737
* [axoned query params](axoned_query_params.md) - Querying commands for the params module
3838
* [axoned query slashing](axoned_query_slashing.md) - Querying commands for the slashing module
3939
* [axoned query staking](axoned_query_staking.md) - Querying commands for the staking module

docs/command/axoned_query_mint.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## axoned query mint
22

3-
Querying commands for the minting module
3+
Querying commands for the mint module
44

55
```
66
axoned query mint [flags]
@@ -15,6 +15,6 @@ axoned query mint [flags]
1515
### SEE ALSO
1616

1717
* [axoned query](axoned_query.md) - Querying subcommands
18-
* [axoned query mint annual-provisions](axoned_query_mint_annual-provisions.md) - Query the current minting annual provisions value
19-
* [axoned query mint inflation](axoned_query_mint_inflation.md) - Query the current minting inflation value
20-
* [axoned query mint params](axoned_query_mint_params.md) - Query the current minting parameters
18+
* [axoned query mint annual-provisions](axoned_query_mint_annual-provisions.md) - Execute the AnnualProvisions RPC method
19+
* [axoned query mint inflation](axoned_query_mint_inflation.md) - Execute the Inflation RPC method
20+
* [axoned query mint params](axoned_query_mint_params.md) - Execute the Params RPC method

docs/command/axoned_query_mint_annual-provisions.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## axoned query mint annual-provisions
22

3-
Query the current minting annual provisions value
3+
Execute the AnnualProvisions RPC method
44

55
```
66
axoned query mint annual-provisions [flags]
@@ -13,10 +13,11 @@ axoned query mint annual-provisions [flags]
1313
--grpc-insecure allow gRPC over insecure channels, if not the server must use TLS
1414
--height int Use a specific height to query state at (this can error if the node is pruning state)
1515
-h, --help help for annual-provisions
16+
--no-indent Do not indent JSON output
1617
--node string <host>:<port> to CometBFT RPC interface for this chain (default "tcp://localhost:26657")
1718
-o, --output string Output format (text|json) (default "text")
1819
```
1920

2021
### SEE ALSO
2122

22-
* [axoned query mint](axoned_query_mint.md) - Querying commands for the minting module
23+
* [axoned query mint](axoned_query_mint.md) - Querying commands for the mint module

docs/command/axoned_query_mint_inflation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## axoned query mint inflation
22

3-
Query the current minting inflation value
3+
Execute the Inflation RPC method
44

55
```
66
axoned query mint inflation [flags]
@@ -13,10 +13,11 @@ axoned query mint inflation [flags]
1313
--grpc-insecure allow gRPC over insecure channels, if not the server must use TLS
1414
--height int Use a specific height to query state at (this can error if the node is pruning state)
1515
-h, --help help for inflation
16+
--no-indent Do not indent JSON output
1617
--node string <host>:<port> to CometBFT RPC interface for this chain (default "tcp://localhost:26657")
1718
-o, --output string Output format (text|json) (default "text")
1819
```
1920

2021
### SEE ALSO
2122

22-
* [axoned query mint](axoned_query_mint.md) - Querying commands for the minting module
23+
* [axoned query mint](axoned_query_mint.md) - Querying commands for the mint module

docs/command/axoned_query_mint_params.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## axoned query mint params
22

3-
Query the current minting parameters
3+
Execute the Params RPC method
44

55
```
66
axoned query mint params [flags]
@@ -13,10 +13,11 @@ axoned query mint params [flags]
1313
--grpc-insecure allow gRPC over insecure channels, if not the server must use TLS
1414
--height int Use a specific height to query state at (this can error if the node is pruning state)
1515
-h, --help help for params
16+
--no-indent Do not indent JSON output
1617
--node string <host>:<port> to CometBFT RPC interface for this chain (default "tcp://localhost:26657")
1718
-o, --output string Output format (text|json) (default "text")
1819
```
1920

2021
### SEE ALSO
2122

22-
* [axoned query mint](axoned_query_mint.md) - Querying commands for the minting module
23+
* [axoned query mint](axoned_query_mint.md) - Querying commands for the mint module

x/mint/keeper/genesis.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ import (
77
)
88

99
// InitGenesis new mint genesis.
10-
func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) {
11-
if err := keeper.Minter.Set(ctx, data.Minter); err != nil {
10+
func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) {
11+
if err := k.Minter.Set(ctx, data.Minter); err != nil {
1212
panic(err)
1313
}
1414

15-
if err := keeper.Params.Set(ctx, data.Params); err != nil {
15+
if err := k.Params.Set(ctx, data.Params); err != nil {
1616
panic(err)
1717
}
1818

1919
ak.GetModuleAccount(ctx, types.ModuleName)
2020
}
2121

2222
// ExportGenesis returns a GenesisState for a given context and keeper.
23-
func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
24-
minter, err := keeper.Minter.Get(ctx)
23+
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
24+
minter, err := k.Minter.Get(ctx)
2525
if err != nil {
2626
panic(err)
2727
}
2828

29-
params, err := keeper.Params.Get(ctx)
29+
params, err := k.Params.Get(ctx)
3030
if err != nil {
3131
panic(err)
3232
}

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

@@ -16,14 +17,16 @@ import (
1617

1718
// 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]
@@ -32,7 +35,7 @@ type Keeper struct {
3235
// 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,52 +64,51 @@ 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
}
7880

7981
// TokenSupply implements an alias call to the underlying bank keeper's
8082
// TokenSupply to be used in BeginBlocker.
81-
func (keeper Keeper) TokenSupply(ctx context.Context, denom string) math.Int {
82-
return keeper.bankKeeper.GetSupply(ctx, denom).Amount
83+
func (k Keeper) TokenSupply(ctx context.Context, denom string) math.Int {
84+
return k.bankKeeper.GetSupply(ctx, denom).Amount
8385
}
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)

0 commit comments

Comments
 (0)