Skip to content

Commit

Permalink
minor: add validate genesis for transmiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed May 18, 2023
1 parent 32706f5 commit 87e8592
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x/transfermiddleware/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GetCmdParaTokenInfo() *cobra.Command {
Use: "para-token-info",
Short: "Query the current transfer middleware para-token-info based on denom",
Long: "Query the current transfer middleware para-token-info based on denom",
Args: cobra.NoArgs,
Args: cobra.ExactValidArgs(1),
Example: fmt.Sprintf("%s query transfermiddleware para-token-info atom", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
Expand Down
14 changes: 13 additions & 1 deletion x/transfermiddleware/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package transfermiddleware
import (
"context"
"encoding/json"
"fmt"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -72,7 +73,8 @@ type AppModule struct {
// NewAppModule creates a new router module
func NewAppModule(k *keeper.Keeper) AppModule {
return AppModule{
keeper: k,
AppModuleBasic: AppModuleBasic{},
keeper: k,
}
}

Expand All @@ -95,6 +97,16 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
return []abci.ValidatorUpdate{}
}

// ValidateGenesis performs genesis state validation for the mint module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
var data types.GenesisState
if err := cdc.UnmarshalJSON(bz, &data); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
}

return types.ValidateGenesis(data)
}

// ExportGenesis returns the exported genesis state as raw bytes for the ibc-router
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
Expand Down
6 changes: 6 additions & 0 deletions x/transfermiddleware/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ package types
func DefaultGenesisState() *GenesisState {
return &GenesisState{}
}

// ValidateGenesis validates the provided genesis state to ensure the
// expected invariants holds.
func ValidateGenesis(data GenesisState) error {
return nil
}

0 comments on commit 87e8592

Please sign in to comment.