From 9b29c956bc670e5b79df17782a4e37640b1ab604 Mon Sep 17 00:00:00 2001 From: Marri Harish Date: Wed, 14 Aug 2024 19:13:54 +0530 Subject: [PATCH] fix ibc v8 migration (#177) * fix ibc v8 migration * fix lint --- app/keepers/keepers.go | 14 ++++++++++---- app/upgrades/v5/constants.go | 2 +- app/upgrades/v5/upgrades.go | 3 ++- x/marketplace/keeper/grpc_query.go | 23 +++++++++++------------ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 31052e0..bc08796 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -4,6 +4,9 @@ import ( "fmt" "path/filepath" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "cosmossdk.io/log" @@ -631,11 +634,14 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName) paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibcexported.ModuleName) - paramsKeeper.Subspace(icahosttypes.SubModuleName) + // register the key tables for legacy param subspaces + keyTable := ibcclienttypes.ParamKeyTable() + keyTable.RegisterParamSet(&ibcconnectiontypes.Params{}) + paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) + paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) + paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable()) paramsKeeper.Subspace(icqtypes.ModuleName) - paramsKeeper.Subspace(packetforwardtypes.ModuleName) + paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable()) paramsKeeper.Subspace(globalfee.ModuleName) paramsKeeper.Subspace(tokenfactorytypes.ModuleName) paramsKeeper.Subspace(wasmtypes.ModuleName) diff --git a/app/upgrades/v5/constants.go b/app/upgrades/v5/constants.go index 61615c7..41eadca 100644 --- a/app/upgrades/v5/constants.go +++ b/app/upgrades/v5/constants.go @@ -1,4 +1,4 @@ -package v4 +package v5 import ( store "cosmossdk.io/store/types" diff --git a/app/upgrades/v5/upgrades.go b/app/upgrades/v5/upgrades.go index ffc08a9..7960244 100644 --- a/app/upgrades/v5/upgrades.go +++ b/app/upgrades/v5/upgrades.go @@ -1,4 +1,4 @@ -package v4 +package v5 import ( "context" @@ -27,6 +27,7 @@ func CreateV5UpgradeHandler( if err != nil { return nil, err } + // Set Gov Params govParams, err := keepers.GovKeeper.Params.Get(ctx) if err != nil { diff --git a/x/marketplace/keeper/grpc_query.go b/x/marketplace/keeper/grpc_query.go index 16dc839..cf4196b 100644 --- a/x/marketplace/keeper/grpc_query.go +++ b/x/marketplace/keeper/grpc_query.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "time" "cosmossdk.io/store/prefix" @@ -26,7 +25,7 @@ func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types func (k Keeper) Listing(goCtx context.Context, req *types.QueryListingRequest) (*types.QueryListingResponse, error) { if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") + return nil, status.Error(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -40,7 +39,7 @@ func (k Keeper) Listing(goCtx context.Context, req *types.QueryListingRequest) ( func (k Keeper) Listings(goCtx context.Context, req *types.QueryListingsRequest) (*types.QueryListingsResponse, error) { if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") + return nil, status.Error(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -53,7 +52,7 @@ func (k Keeper) Listings(goCtx context.Context, req *types.QueryListingsRequest) if len(req.Owner) > 0 { owner, err = sdk.AccAddressFromBech32(req.Owner) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid owner address (%s)", err)) + return nil, status.Errorf(codes.InvalidArgument, "invalid owner address (%s)", err) } listingStore := prefix.NewStore(store, append(types.PrefixListingOwner, owner.Bytes()...)) pageRes, err = query.Paginate(listingStore, req.Pagination, func(key []byte, value []byte) error { @@ -105,7 +104,7 @@ func (k Keeper) ListingsByOwner(goCtx context.Context, req *types.QueryListingsB if len(req.Owner) > 0 { owner, err = sdk.AccAddressFromBech32(req.Owner) if err != nil || owner == nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid owner address (%s)", err)) + return nil, status.Errorf(codes.InvalidArgument, "invalid owner address (%s)", err) } } @@ -266,7 +265,7 @@ func (k Keeper) AuctionsByOwner(goCtx context.Context, req *types.QueryAuctionsB if len(req.Owner) > 0 { owner, err = sdk.AccAddressFromBech32(req.Owner) if err != nil || owner == nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid owner address (%s)", err)) + return nil, status.Errorf(codes.InvalidArgument, "invalid owner address (%s)", err) } } @@ -293,7 +292,7 @@ func (k Keeper) AuctionsByOwner(goCtx context.Context, req *types.QueryAuctionsB func (k Keeper) AuctionsByPriceDenom(goCtx context.Context, req *types.QueryAuctionsByPriceDenomRequest) (*types.QueryAuctionsResponse, error) { if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") + return nil, status.Error(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -322,10 +321,10 @@ func (k Keeper) AuctionsByPriceDenom(goCtx context.Context, req *types.QueryAuct func (k Keeper) AuctionByNftId(goCtx context.Context, req *types.QueryAuctionByNFTIDRequest) (*types.QueryAuctionResponse, error) { if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") + return nil, status.Error(codes.InvalidArgument, "empty request") } if req.NftId == "" { - return nil, status.Errorf(codes.InvalidArgument, "need nft id to request") + return nil, status.Error(codes.InvalidArgument, "need nft id to request") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -339,12 +338,12 @@ func (k Keeper) AuctionByNftId(goCtx context.Context, req *types.QueryAuctionByN } return auction, nil } - return nil, status.Errorf(codes.NotFound, "auction not found with given nft id") + return nil, status.Error(codes.NotFound, "auction not found with given nft id") } func (k Keeper) Bid(goCtx context.Context, req *types.QueryBidRequest) (*types.QueryBidResponse, error) { if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") + return nil, status.Error(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -357,7 +356,7 @@ func (k Keeper) Bid(goCtx context.Context, req *types.QueryBidRequest) (*types.Q func (k Keeper) Bids(goCtx context.Context, req *types.QueryBidsRequest) (*types.QueryBidsResponse, error) { if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") + return nil, status.Error(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx)