Skip to content

Commit

Permalink
chore: did module upgrade changes
Browse files Browse the repository at this point in the history
  • Loading branch information
deepan95dev committed Feb 8, 2024
1 parent 7ccb747 commit de7f7d0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 46 deletions.
2 changes: 1 addition & 1 deletion x/did/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"os"

"github.com/cheqd/cheqd-node/x/did/types"
tmcli "github.com/cometbft/cometbft/libs/cli"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/spf13/cobra"
tmcli "github.com/cometbft/cometbft/libs/cli"
)

const (
Expand Down
27 changes: 21 additions & 6 deletions x/did/keeper/keeper_param_change_proposal_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package keeper_test

import (
cheqdparams "github.com/cheqd/cheqd-node/app/params"
dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/suite"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

cheqdsimapp "github.com/cheqd/cheqd-node/simapp"
cheqdapp "github.com/cheqd/cheqd-node/app"
didtypes "github.com/cheqd/cheqd-node/x/did/types"
sdk "github.com/cosmos/cosmos-sdk/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
Expand All @@ -19,18 +24,28 @@ import (
type HandlerTestSuite struct {
suite.Suite

app *cheqdsimapp.SimApp
app *cheqdapp.App
ctx sdk.Context
govHandler govv1beta1.Handler
}

type appCreator struct {
encCfg cheqdparams.EncodingConfig
}

func (suite *HandlerTestSuite) SetupTest() error {
var err error
suite.app, err = cheqdsimapp.Setup(false)
var appOpts servertypes.AppOptions
baseappOptions := server.DefaultBaseappOptions(appOpts)
suite.app = cheqdapp.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, baseappOptions...)

key := sdk.NewKVStoreKey(paramtypes.StoreKey)
tkey := sdk.NewTransientStoreKey("params_transient_test")
ctx := testutil.DefaultContext(key, tkey)
if err != nil {
return err
}
suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{})
suite.ctx = ctx //suite.app.BaseApp.NewContext(false, tmproto.Header{})
suite.govHandler = params.NewParamChangeProposalHandler(suite.app.ParamsKeeper)
return nil
}
Expand Down
52 changes: 26 additions & 26 deletions x/did/keeper/querier.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
package keeper

import (
"github.com/cheqd/cheqd-node/x/did/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
// import (
// "github.com/cheqd/cheqd-node/x/did/types"
// "github.com/cosmos/cosmos-sdk/codec"
// sdk "github.com/cosmos/cosmos-sdk/types"
// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

abci "github.com/cometbft/cometbft/abci/types"
)
// abci "github.com/cometbft/cometbft/abci/types"
// )

func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) {
var (
res []byte
err error
)
// func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
// return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) {
// var (
// res []byte
// err error
// )

switch path[0] {
case types.QueryGetDidDoc:
return getDidDoc(ctx, path[1], k, legacyQuerierCdc)
case types.QueryGetAllDidDocVersions:
return getAllDidDocVersionsMetadata(ctx, path[1], k, legacyQuerierCdc)
case types.QueryGetDidDocVersion:
return getDidDocVersion(ctx, path[1], path[2], k, legacyQuerierCdc)
// switch path[0] {
// case types.QueryGetDidDoc:
// return getDidDoc(ctx, path[1], k, legacyQuerierCdc)
// case types.QueryGetAllDidDocVersions:
// return getAllDidDocVersionsMetadata(ctx, path[1], k, legacyQuerierCdc)
// case types.QueryGetDidDocVersion:
// return getDidDocVersion(ctx, path[1], path[2], k, legacyQuerierCdc)

default:
err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0])
}
// default:
// err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0])
// }

return res, err
}
}
// return res, err
// }
// }
10 changes: 0 additions & 10 deletions x/did/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,9 @@ func (am AppModule) Name() string {
return am.AppModuleBasic.Name()
}

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

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

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

// RegisterServices registers a GRPC query service to respond to the
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
Expand Down
6 changes: 3 additions & 3 deletions x/did/tests/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"github.com/cheqd/cheqd-node/x/did/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"

dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cometbft/cometbft-db"

"github.com/cheqd/cheqd-node/x/did/keeper"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand Down

0 comments on commit de7f7d0

Please sign in to comment.