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

feat: keeper genesis #12

Merged
merged 28 commits into from
Nov 12, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
init
aljo242 committed Nov 10, 2023

Verified

This commit was signed with the committer’s verified signature.
gavinsimpson Gavin Simpson
commit 039dc35a807568313d319e6b5eb9dbfd4023c678
35 changes: 35 additions & 0 deletions x/feemarket/keeper/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/skip-mev/feemarket/x/feemarket/types"
)

// InitGenesis initializes the feemarket module's state from a given genesis state.
func (k *Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) {
// Set the feemarket module's parameters.
if err := k.SetParams(ctx, gs.Params); err != nil {
panic(err)
}

// set the fee market implementation
if err := k.plugin.Unmarshal(gs.Plugin); err != nil {
panic(err)
}

aljo242 marked this conversation as resolved.
Show resolved Hide resolved
if err := k.Init(ctx); err != nil {
panic(err)
}
}

// ExportGenesis returns a GenesisState for a given context.
func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
// Get the feemarket module's parameters.
params, err := k.GetParams(ctx)
if err != nil {
panic(err)
}
aljo242 marked this conversation as resolved.
Show resolved Hide resolved

return types.NewGenesisState(k.plugin, params)
}
15 changes: 15 additions & 0 deletions x/feemarket/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package keeper_test

func (s *KeeperTestSuite) TestInitGenesis() {
s.Run("valid genesis should not panic", func() {

})

s.Run("invalid params should panic", func() {

})

s.Run("invalid plugin bytes should panic", func() {

})
}