From dcff4e8dc2a826fa440cc73c7cdb5062a2e29313 Mon Sep 17 00:00:00 2001 From: Dzung Do Date: Wed, 8 May 2024 16:31:45 +0700 Subject: [PATCH] update sdk 47 x folder --- x/asset/genesis_test.go | 8 ++-- x/asset/keeper/keeper.go | 2 +- x/asset/keeper/keeper_test.go | 8 ++-- x/asset/module.go | 21 +--------- x/mint/keeper/keeper.go | 2 +- x/mint/keeper/keeper_test.go | 10 ++--- x/mint/keeper/querier.go | 64 ------------------------------ x/mint/keeper/querier_test.go | 74 ----------------------------------- x/mint/module.go | 21 +--------- x/mint/module_test.go | 2 +- 10 files changed, 18 insertions(+), 194 deletions(-) delete mode 100644 x/mint/keeper/querier.go delete mode 100644 x/mint/keeper/querier_test.go diff --git a/x/asset/genesis_test.go b/x/asset/genesis_test.go index d2b24b19..9ddd8ae4 100644 --- a/x/asset/genesis_test.go +++ b/x/asset/genesis_test.go @@ -7,10 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" feemarkettypes "github.com/evmos/evmos/v18/x/feemarket/types" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/tmhash" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmversion "github.com/tendermint/tendermint/proto/tendermint/version" - "github.com/tendermint/tendermint/version" + "github.com/cometbft/cometbft/crypto/tmhash" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmversion "github.com/cometbft/cometbft/proto/tendermint/version" + "github.com/cometbft/cometbft/version" "github.com/realiotech/realio-network/app" "github.com/realiotech/realio-network/testutil" diff --git a/x/asset/keeper/keeper.go b/x/asset/keeper/keeper.go index 3d7b53eb..abdf1697 100644 --- a/x/asset/keeper/keeper.go +++ b/x/asset/keeper/keeper.go @@ -4,7 +4,7 @@ import ( "fmt" storetypes "github.com/cosmos/cosmos-sdk/store/types" - "github.com/tendermint/tendermint/libs/log" + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/asset/keeper/keeper_test.go b/x/asset/keeper/keeper_test.go index f14d6dd5..f14acd31 100644 --- a/x/asset/keeper/keeper_test.go +++ b/x/asset/keeper/keeper_test.go @@ -9,10 +9,10 @@ import ( "github.com/evmos/evmos/v18/crypto/ethsecp256k1" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/tmhash" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmversion "github.com/tendermint/tendermint/proto/tendermint/version" - "github.com/tendermint/tendermint/version" + "github.com/cometbft/cometbft/crypto/tmhash" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmversion "github.com/cometbft/cometbft/proto/tendermint/version" + "github.com/cometbft/cometbft/version" "github.com/realiotech/realio-network/app" realiotypes "github.com/realiotech/realio-network/types" diff --git a/x/asset/module.go b/x/asset/module.go index 88ad6184..737da2cd 100644 --- a/x/asset/module.go +++ b/x/asset/module.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "math/rand" // this line is used by starport scaffolding # 1 @@ -12,7 +11,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -121,19 +120,9 @@ func (am AppModule) Name() string { return am.AppModuleBasic.Name() } -// Route returns the capability module's message routing key. -func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) -} - // QuerierRoute returns the capability module's query routing key. func (AppModule) QuerierRoute() string { return types.QuerierRoute } -// LegacyQuerierHandler returns the capability module's Querier. -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return nil -} - // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { @@ -176,14 +165,6 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid func (am AppModule) GenerateGenesisState(_ *module.SimulationState) { } -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return []simtypes.WeightedProposalContent{} -} - -func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { - return []simtypes.ParamChange{} -} - func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { } diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 0d53de6e..85ffba56 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -2,7 +2,7 @@ package keeper import ( "cosmossdk.io/math" - "github.com/tendermint/tendermint/libs/log" + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index d2f4a984..74460cad 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -9,10 +9,10 @@ import ( "github.com/evmos/evmos/v18/crypto/ethsecp256k1" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/tmhash" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmversion "github.com/tendermint/tendermint/proto/tendermint/version" - "github.com/tendermint/tendermint/version" + "github.com/cometbft/cometbft/crypto/tmhash" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmversion "github.com/cometbft/cometbft/proto/tendermint/version" + "github.com/cometbft/cometbft/version" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -21,7 +21,7 @@ import ( "github.com/realiotech/realio-network/app" realiotypes "github.com/realiotech/realio-network/types" "github.com/realiotech/realio-network/x/mint/types" - abci "github.com/tendermint/tendermint/abci/types" + abci "github.com/cometbft/cometbft/abci/types" ) type KeeperTestSuite struct { diff --git a/x/mint/keeper/querier.go b/x/mint/keeper/querier.go deleted file mode 100644 index 2b3761af..00000000 --- a/x/mint/keeper/querier.go +++ /dev/null @@ -1,64 +0,0 @@ -package keeper - -import ( - errorsmod "cosmossdk.io/errors" - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/realiotech/realio-network/x/mint/types" -) - -// NewQuerier returns a minting Querier handler. -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, _ abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryParameters: - return queryParams(ctx, k, legacyQuerierCdc) - - case types.QueryInflation: - return queryInflation(ctx, k, legacyQuerierCdc) - - case types.QueryAnnualProvisions: - return queryAnnualProvisions(ctx, k, legacyQuerierCdc) - - default: - return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - params := k.GetParams(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) - if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryInflation(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - minter := k.GetMinter(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.Inflation) - if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryAnnualProvisions(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - minter := k.GetMinter(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.AnnualProvisions) - if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} diff --git a/x/mint/keeper/querier_test.go b/x/mint/keeper/querier_test.go deleted file mode 100644 index 6d7121cb..00000000 --- a/x/mint/keeper/querier_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package keeper_test - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - - keep "github.com/realiotech/realio-network/x/mint/keeper" - "github.com/realiotech/realio-network/x/mint/types" -) - -func (suite *KeeperTestSuite) TestNewQuerier() { - app, ctx, legacyQuerierCdc := suite.app, suite.ctx, suite.legacyQuerierCdc - querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - _, err := querier(ctx, []string{types.QueryParameters}, query) - suite.Require().NoError(err) - - _, err = querier(ctx, []string{types.QueryInflation}, query) - suite.Require().NoError(err) - - _, err = querier(ctx, []string{types.QueryAnnualProvisions}, query) - suite.Require().NoError(err) - - _, err = querier(ctx, []string{"foo"}, query) - suite.Require().Error(err) -} - -func (suite *KeeperTestSuite) TestQueryParams() { - querier := keep.NewQuerier(suite.app.MintKeeper, suite.legacyQuerierCdc.LegacyAmino) - - var params types.Params - - res, sdkErr := querier(suite.ctx, []string{types.QueryParameters}, abci.RequestQuery{}) - suite.Require().NoError(sdkErr) - - err := suite.app.LegacyAmino().UnmarshalJSON(res, ¶ms) - suite.Require().NoError(err) - - suite.Require().Equal(suite.app.MintKeeper.GetParams(suite.ctx), params) -} - -func (suite *KeeperTestSuite) TestQueryInflation() { - querier := keep.NewQuerier(suite.app.MintKeeper, suite.legacyQuerierCdc.LegacyAmino) - - var inflation sdk.Dec - - res, sdkErr := querier(suite.ctx, []string{types.QueryInflation}, abci.RequestQuery{}) - suite.Require().NoError(sdkErr) - - err := suite.app.LegacyAmino().UnmarshalJSON(res, &inflation) - suite.Require().NoError(err) - - suite.Require().Equal(suite.app.MintKeeper.GetMinter(suite.ctx).Inflation, inflation) -} - -func (suite *KeeperTestSuite) TestQueryAnnualProvisions() { - querier := keep.NewQuerier(suite.app.MintKeeper, suite.legacyQuerierCdc.LegacyAmino) - - var annualProvisions sdk.Dec - - res, sdkErr := querier(suite.ctx, []string{types.QueryAnnualProvisions}, abci.RequestQuery{}) - suite.Require().NoError(sdkErr) - - err := suite.app.LegacyAmino().UnmarshalJSON(res, &annualProvisions) - suite.Require().NoError(err) - - suite.Require().Equal(suite.app.MintKeeper.GetMinter(suite.ctx).AnnualProvisions, annualProvisions) -} diff --git a/x/mint/module.go b/x/mint/module.go index 49d993c0..319828e3 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -4,11 +4,10 @@ import ( "context" "encoding/json" "fmt" - "math/rand" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -102,19 +101,11 @@ func (AppModule) Name() string { // RegisterInvariants registers the mint module invariants. func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the mint module. -func (AppModule) Route() sdk.Route { return sdk.Route{} } - // QuerierRoute returns the mint module's querier route name. func (AppModule) QuerierRoute() string { return types.QuerierRoute } -// LegacyQuerierHandler returns the mint module sdk.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) { @@ -152,16 +143,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { func (AppModule) GenerateGenesisState(_ *module.SimulationState) { } -// ProposalContents doesn't return any content functions for governance proposals. -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return []simtypes.WeightedProposalContent{} -} - -// RandomizedParams creates randomized mint param changes for the simulator. -func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { - return []simtypes.ParamChange{} -} - // RegisterStoreDecoder registers a decoder for mint module's types. func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { } diff --git a/x/mint/module_test.go b/x/mint/module_test.go index 7115a762..9302f51b 100644 --- a/x/mint/module_test.go +++ b/x/mint/module_test.go @@ -5,7 +5,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/realiotech/realio-network/app" "github.com/realiotech/realio-network/x/mint/types"