From 63fd1c0542f3c18640e6f1b6ca551c6bc82719e0 Mon Sep 17 00:00:00 2001 From: dekm Date: Mon, 18 Mar 2024 08:40:27 +0100 Subject: [PATCH] fix kvstore access for gridnode undelegate --- x/gridnode/keeper/query_unobonding_amount.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x/gridnode/keeper/query_unobonding_amount.go b/x/gridnode/keeper/query_unobonding_amount.go index dd68a30..edd219f 100644 --- a/x/gridnode/keeper/query_unobonding_amount.go +++ b/x/gridnode/keeper/query_unobonding_amount.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" + "cosmossdk.io/store/prefix" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/unigrid-project/cosmos-gridnode/x/gridnode/types" "google.golang.org/grpc/codes" @@ -27,8 +29,10 @@ func (k Keeper) UnbondingEntries(goCtx context.Context, req *types.QueryUnbondin key := k.keyForUnBonding(delegatorAddr) // Retrieve the value from the store - store := ctx.KVStore(k.storeKey) + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, []byte(types.StoreKey)) bz := store.Get(key) + if bz == nil { // Return an empty list if no unbonding entries are found for the delegator return &types.QueryUnbondingEntriesResponse{UnbondingEntries: nil}, nil