Skip to content

Commit

Permalink
added -l flags to enable denom-owners query
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 committed Apr 24, 2024
1 parent 57336fc commit b79202b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ func New(

app.NFTKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper)

app.UGovKeeperB = ugovkeeper.NewBuilder(appCodec, keys[ugov.ModuleName], app.BankKeeper)
app.UGovKeeperB = ugovkeeper.NewBuilder(appCodec, keys[ugov.ModuleName], app.BankKeeper,
cast.ToBool(appOpts.Get(leveragetypes.FlagEnableLiquidatorQuery)),
)

app.OracleKeeper = oraclekeeper.NewKeeper(
appCodec,
Expand Down
26 changes: 13 additions & 13 deletions x/ugov/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,27 @@ var _ ugov.Keeper = Keeper{}

// Builder constructs Keeper by perparing all related dependencies (notably the store).
type Builder struct {
storeKey storetypes.StoreKey
Cdc codec.BinaryCodec
BankKeeper keeper.BaseKeeper
storeKey storetypes.StoreKey
Cdc codec.BinaryCodec
BankKeeper keeper.BaseKeeper
enableLiquidatorQuery bool
}

func NewBuilder(
cdc codec.BinaryCodec, key storetypes.StoreKey, bk keeper.BaseKeeper,
cdc codec.BinaryCodec, key storetypes.StoreKey, bk keeper.BaseKeeper, enableLiquidatorQuery bool,
) Builder {
return Builder{
Cdc: cdc,
storeKey: key,
BankKeeper: bk,
Cdc: cdc,
storeKey: key,
BankKeeper: bk,
enableLiquidatorQuery: enableLiquidatorQuery,
}
}

func (kb Builder) Keeper(ctx *sdk.Context) ugov.Keeper {
return Keeper{
store: ctx.KVStore(kb.storeKey),
cdc: kb.Cdc,
BankKeeper: kb.BankKeeper,
store: ctx.KVStore(kb.storeKey),
cdc: kb.Cdc,
}
}

Expand All @@ -43,7 +44,6 @@ func (kb Builder) EmergencyGroup(ctx *sdk.Context) ugov.WithEmergencyGroup { ret

// Keeper provides a light interface for module data access and transformation
type Keeper struct {
store sdk.KVStore
cdc codec.BinaryCodec
BankKeeper keeper.BaseKeeper
store sdk.KVStore
cdc codec.BinaryCodec
}
18 changes: 11 additions & 7 deletions x/ugov/keeper/query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

ltypes "github.com/umee-network/umee/v6/x/leverage/types"
"github.com/umee-network/umee/v6/x/ugov"
)

Expand Down Expand Up @@ -55,12 +56,15 @@ func (q Querier) InflationCycleEnd(ctx context.Context, _ *ugov.QueryInflationCy
// DenomOwners implements ugov.QueryServer.
func (q Querier) DenomOwners(ctx context.Context, req *ugov.QueryDenomOwners) (*banktypes.QueryDenomOwnersResponse,
error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
if req.Height != 0 {
sdkCtx = sdkCtx.WithBlockHeight(req.Height)
if q.enableLiquidatorQuery {
sdkCtx := sdk.UnwrapSDKContext(ctx)
if req.Height != 0 {
sdkCtx = sdkCtx.WithBlockHeight(req.Height)
}
return q.BankKeeper.DenomOwners(sdk.WrapSDKContext(sdkCtx), &banktypes.QueryDenomOwnersRequest{
Denom: req.Denom,
Pagination: req.Pagination,
})
}
return q.BankKeeper.DenomOwners(sdk.WrapSDKContext(sdkCtx), &banktypes.QueryDenomOwnersRequest{
Denom: req.Denom,
Pagination: req.Pagination,
})
return nil, ltypes.ErrNotLiquidatorNode
}

0 comments on commit b79202b

Please sign in to comment.