fix: return nil instead of empty byte slice (#878)

This commit is contained in:
Kevin Davis 2021-03-15 08:41:36 -06:00 committed by GitHub
parent 12f5a67d6d
commit 2611d48b77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,7 @@ func queryPrice(ctx sdk.Context, req abci.RequestQuery, keeper Keeper) (res []by
}
_, found := keeper.GetMarket(ctx, requestParams.MarketID)
if !found {
return []byte{}, sdkerrors.Wrap(types.ErrAssetNotFound, requestParams.MarketID)
return nil, sdkerrors.Wrap(types.ErrAssetNotFound, requestParams.MarketID)
}
currentPrice, sdkErr := keeper.GetCurrentPrice(ctx, requestParams.MarketID)
if sdkErr != nil {
@ -72,7 +72,7 @@ func queryRawPrices(ctx sdk.Context, req abci.RequestQuery, keeper Keeper) (res
}
_, found := keeper.GetMarket(ctx, requestParams.MarketID)
if !found {
return []byte{}, sdkerrors.Wrap(types.ErrAssetNotFound, requestParams.MarketID)
return nil, sdkerrors.Wrap(types.ErrAssetNotFound, requestParams.MarketID)
}
rawPrices, err := keeper.GetRawPrices(ctx, requestParams.MarketID)
@ -97,7 +97,7 @@ func queryOracles(ctx sdk.Context, req abci.RequestQuery, keeper Keeper) (res []
oracles, err := keeper.GetOracles(ctx, requestParams.MarketID)
if err != nil {
return []byte{}, sdkerrors.Wrap(types.ErrAssetNotFound, requestParams.MarketID)
return nil, sdkerrors.Wrap(types.ErrAssetNotFound, requestParams.MarketID)
}
bz, err := codec.MarshalJSONIndent(types.ModuleCdc, oracles)