Skip to content

Commit

Permalink
feat!: remove Minter from x/mint genesis state (backport #2217) (#2266)
Browse files Browse the repository at this point in the history
This is an automatic backport of pull request #2217 done by
[Mergify](https://mergify.com).


---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the
[documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on
`<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you
can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>

Co-authored-by: Rootul P <[email protected]>
  • Loading branch information
mergify[bot] and rootulp authored Aug 14, 2023
1 parent c1e8909 commit d305b80
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type mintModule struct {
// DefaultGenesis returns custom x/mint module genesis state.
func (mintModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := minttypes.DefaultGenesisState()
genState.Minter.BondDenom = BondDenom
genState.BondDenom = BondDenom

return cdc.MustMarshalJSON(genState)
}
Expand Down
9 changes: 4 additions & 5 deletions proto/celestia/mint/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
syntax = "proto3";
package celestia.mint.v1;

import "gogoproto/gogo.proto";
import "celestia/mint/v1/mint.proto";

option go_package = "github.com/celestiaorg/celestia-app/x/mint/types";

// GenesisState defines the mint module's genesis state.
message GenesisState {
// minter is a space for holding current inflation information.
Minter minter = 1 [ (gogoproto.nullable) = false ];
reserved 1; // 1 was previously used for the `Minter` field.

// BondDenom is the denomination of the token that should be minted.
string bond_denom = 2;
}
8 changes: 5 additions & 3 deletions x/mint/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (

// InitGenesis initializes the x/mint store with data from the genesis state.
func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) {
k.SetMinter(ctx, data.Minter)
minter := types.DefaultMinter()
minter.BondDenom = data.BondDenom
k.SetMinter(ctx, minter)
// override the genesis time with the actual genesis time supplied in `InitChain`
blockTime := ctx.BlockTime()
gt := types.GenesisTime{
Expand All @@ -19,6 +21,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types

// ExportGenesis returns a x/mint GenesisState for the given context.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
minter := k.GetMinter(ctx)
return types.NewGenesisState(minter)
bondDenom := k.GetMinter(ctx).BondDenom
return types.NewGenesisState(bondDenom)
}
13 changes: 9 additions & 4 deletions x/mint/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package types

import "errors"

// NewGenesisState creates a new GenesisState object
func NewGenesisState(minter Minter) *GenesisState {
func NewGenesisState(bondDenom string) *GenesisState {
return &GenesisState{
Minter: minter,
BondDenom: bondDenom,
}
}

// DefaultGenesisState creates a default GenesisState object
func DefaultGenesisState() *GenesisState {
return &GenesisState{
Minter: DefaultMinter(),
BondDenom: DefaultBondDenom,
}
}

// ValidateGenesis validates the provided genesis state to ensure the
// expected invariants holds.
func ValidateGenesis(data GenesisState) error {
return data.Minter.Validate()
if data.BondDenom == "" {
return errors.New("bond denom cannot be empty")
}
return nil
}
69 changes: 32 additions & 37 deletions x/mint/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d305b80

Please sign in to comment.