Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
atheeshp committed Feb 14, 2024
1 parent 4c0311b commit 3132693
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 34 deletions.
31 changes: 29 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"path/filepath"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"github.com/cheqd/cheqd-node/app/migrations"
upgradeV1 "github.com/cheqd/cheqd-node/app/upgrades/v1"
upgradeV2 "github.com/cheqd/cheqd-node/app/upgrades/v2"
Expand All @@ -29,6 +31,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
Expand Down Expand Up @@ -733,6 +736,14 @@ func New(
// Make sure it's called after `app.ModuleManager` and `app.configurator` are set.
app.RegisterUpgradeHandlers()

autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules))

reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
panic(err)
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)

// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
Expand Down Expand Up @@ -777,11 +788,10 @@ func New(
app.SetEndBlocker(app.EndBlocker)
// app.SetPostHandler(postHandler)

// Note: This migration is completed, we can remove these lines.
// Upgrade handler for v1
v1UpgradeHandler := app.upgradeHandlerV1(icaModule, keys[didtypes.StoreKey], keys[resourcetypes.StoreKey])
app.UpgradeKeeper.SetUpgradeHandler(upgradeV1.UpgradeName, v1UpgradeHandler)
// Upgrade handler for v2
app.UpgradeKeeper.SetUpgradeHandler(upgradeV2.UpgradeName, upgradeV2.CreateUpgradeHandler(app.ModuleManager, app.configurator))

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down Expand Up @@ -1151,4 +1161,21 @@ func BlockedAddresses() map[string]bool {
}

func (app *App) RegisterUpgradeHandlers() {
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())

// Upgrade handler for v2
app.UpgradeKeeper.SetUpgradeHandler(
upgradeV2.UpgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Handler for upgrade plan: " + upgradeV2.UpgradeName)
// Migrate Tendermint consensus parameters from x/params module to a
// dedicated x/consensus module.
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper)
return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
},
)
}

func (a *App) Configurator() module.Configurator {
return a.configurator
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
toolchain go1.21.0

require (
cosmossdk.io/api v0.3.1
cosmossdk.io/core v0.5.1
cosmossdk.io/math v1.2.0
filippo.io/edwards25519 v1.0.0
Expand Down Expand Up @@ -41,7 +42,6 @@ require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/storage v1.30.1 // indirect
cosmossdk.io/api v0.3.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.3.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion scripts/protoc-pulsar-gen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# !/usr/bin/env bash
#!/usr/bin/env bash

# this script is for generating protobuf files for the new google.golang.org/protobuf API
set -euox pipefail
Expand Down
48 changes: 18 additions & 30 deletions x/resource/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"fmt"
"log"

"cosmossdk.io/core/appmodule"
didkeeper "github.com/cheqd/cheqd-node/x/did/keeper"

"github.com/cheqd/cheqd-node/x/resource/client/cli"
migrationV3 "github.com/cheqd/cheqd-node/x/resource/migration/v3"
"github.com/cheqd/cheqd-node/x/resource/types"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

abci "github.com/cometbft/cometbft/abci/types"
Expand All @@ -27,12 +27,22 @@ import (
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
)

const ConsensusVersion = 3

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ porttypes.IBCModule = IBCModule{}
_ module.BeginBlockAppModule = AppModule{}
_ module.EndBlockAppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ porttypes.IBCModule = IBCModule{}
_ appmodule.AppModule = AppModule{}
)

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}

// IsAppModule implements the appmodule.AppModule interface.
func (am AppModule) IsAppModule() {}

// ----------------------------------------------------------------------------
// AppModuleBasic
// ----------------------------------------------------------------------------
Expand All @@ -51,10 +61,6 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
}

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
}
Expand All @@ -78,14 +84,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
return genState.Validate()
}

// RegisterRESTRoutes registers the resource module's REST service handlers.
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
// rest.RegisterRoutes(clientCtx, rtr)
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, m *gwruntime.ServeMux) {
err := types.RegisterQueryHandlerClient(context.Background(), m, types.NewQueryClient(clientCtx))
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -126,27 +127,14 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, cheqdKeeper didkeeper.K
// introduced by the module. To avoid wrong/empty versions, the initial version
// should be set to 1.
func (am AppModule) ConsensusVersion() uint64 {
return 3
return ConsensusVersion
}

// Name returns the resource module's name.
func (am AppModule) Name() string {
return am.AppModuleBasic.Name()
}

// // Route returns the resource module's message routing key.
// func (am AppModule) Route() sdk.Route {
// return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper, am.didKeeper))
// }

// QuerierRoute returns the resource module's query routing key.
func (AppModule) QuerierRoute() string { return types.QuerierRoute }

// // LegacyQuerierHandler returns the resource module's Querier.
// func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
// return keeper.NewQuerier(am.keeper, am.didKeeper, legacyQuerierCdc)
// }

// RegisterServices registers a GRPC query service to respond to the
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
Expand Down

0 comments on commit 3132693

Please sign in to comment.