Skip to content

Commit

Permalink
Merge branch 'feature/lum-843' of github.com:lum-network/chain into f…
Browse files Browse the repository at this point in the history
…eature/lum-843
  • Loading branch information
Segfaultd committed Oct 20, 2023
2 parents c38a317 + 7c5019e commit 692971b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
16 changes: 3 additions & 13 deletions x/beam/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package beam

import (
"encoding/json"
"fmt"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -60,11 +59,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {

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

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
Expand Down Expand Up @@ -126,17 +121,12 @@ func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
// InitGenesis performs the capability module's genesis initialization It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
var genState types.GenesisState
// Initialize global index to index in genesis state
cdc.MustUnmarshalJSON(gs, &genState)

return InitGenesis(ctx, am.keeper, genState)
return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
genState := ExportGenesis(ctx, am.keeper)
return cdc.MustMarshalJSON(genState)
return nil
}

// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
Expand Down
15 changes: 1 addition & 14 deletions x/dfract/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dfract

import (
"encoding/json"
"fmt"

"github.com/lum-network/chain/x/dfract/migrations"

Expand All @@ -16,7 +15,6 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"github.com/lum-network/chain/x/dfract/client/rest"
"github.com/lum-network/chain/x/dfract/keeper"
"github.com/lum-network/chain/x/dfract/types"
)
Expand Down Expand Up @@ -56,16 +54,10 @@ func (a AppModuleBasic) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessag
}

func (a AppModuleBasic) ValidateGenesis(jsonCodec codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error {
var data types.GenesisState
if err := jsonCodec.UnmarshalJSON(message, &data); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
}

return nil
}

func (a AppModuleBasic) RegisterRESTRoutes(context client.Context, router *mux.Router) {
rest.RegisterRoutes(context, router)
}

func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
Expand Down Expand Up @@ -101,16 +93,11 @@ func (a AppModule) Name() string {
}

func (a AppModule) InitGenesis(context sdk.Context, jsonCodec codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate {
var genState types.GenesisState
jsonCodec.MustUnmarshalJSON(message, &genState)

InitGenesis(context, a.keeper, genState)
return []abci.ValidatorUpdate{}
}

func (a AppModule) ExportGenesis(context sdk.Context, jsonCodec codec.JSONCodec) json.RawMessage {
genState := ExportGenesis(context, a.keeper)
return jsonCodec.MustMarshalJSON(genState)
return nil
}

func (a AppModule) RegisterInvariants(registry sdk.InvariantRegistry) {}
Expand Down

0 comments on commit 692971b

Please sign in to comment.