Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit f06a6d0

Browse files
authored
fix: CLI is broke (#415)
* init * nit * example * nits
1 parent c6d20c1 commit f06a6d0

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

x/marketmap/client/cli/query.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func CmdQueryParams() *cobra.Command {
4242
}
4343

4444
queryClient := types.NewQueryClient(clientCtx)
45-
res, err := queryClient.Params(clientCtx.CmdContext, &types.ParamsRequest{})
45+
res, err := queryClient.Params(cmd.Context(), &types.ParamsRequest{})
4646
if err != nil {
4747
return err
4848
}
@@ -67,7 +67,7 @@ func CmdQueryMarketMap() *cobra.Command {
6767
}
6868

6969
queryClient := types.NewQueryClient(clientCtx)
70-
res, err := queryClient.MarketMap(clientCtx.CmdContext, &types.MarketMapRequest{})
70+
res, err := queryClient.MarketMap(cmd.Context(), &types.MarketMapRequest{})
7171
if err != nil {
7272
return err
7373
}
@@ -82,22 +82,19 @@ func CmdQueryMarketMap() *cobra.Command {
8282

8383
func CmdQueryMarket() *cobra.Command {
8484
cmd := &cobra.Command{
85-
Use: "market",
85+
Use: "market [base] [quote]",
8686
Short: "Query the a market using the given currency pair",
87-
Args: cobra.ExactArgs(1),
87+
Args: cobra.ExactArgs(2),
8888
RunE: func(cmd *cobra.Command, args []string) error {
8989
clientCtx, err := client.GetClientQueryContext(cmd)
9090
if err != nil {
9191
return err
9292
}
9393

94-
cp, err := slinkytypes.CurrencyPairFromString(args[0])
95-
if err != nil {
96-
return err
97-
}
94+
cp := slinkytypes.NewCurrencyPair(args[0], args[1])
9895

9996
queryClient := types.NewQueryClient(clientCtx)
100-
res, err := queryClient.Market(clientCtx.CmdContext, &types.MarketRequest{
97+
res, err := queryClient.Market(cmd.Context(), &types.MarketRequest{
10198
CurrencyPair: cp,
10299
})
103100
if err != nil {
@@ -124,7 +121,7 @@ func CmdQueryLastUpdated() *cobra.Command {
124121
}
125122

126123
queryClient := types.NewQueryClient(clientCtx)
127-
res, err := queryClient.LastUpdated(clientCtx.CmdContext, &types.LastUpdatedRequest{})
124+
res, err := queryClient.LastUpdated(cmd.Context(), &types.LastUpdatedRequest{})
128125
if err != nil {
129126
return err
130127
}

x/oracle/keeper/keeper.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package keeper
22

33
import (
44
"errors"
5-
"fmt"
65

76
"cosmossdk.io/collections"
87
"cosmossdk.io/collections/indexes"
@@ -326,7 +325,11 @@ func (k *Keeper) GetDecimalsForCurrencyPair(ctx sdk.Context, cp slinkytypes.Curr
326325

327326
market, err := k.mmKeeper.GetMarket(ctx, cp.String())
328327
if err != nil {
329-
return 0, fmt.Errorf("no market for CurrencyPair: %w", err)
328+
if errors.Is(err, collections.ErrNotFound) {
329+
return uint64(cp.LegacyDecimals()), nil
330+
}
331+
332+
return 0, err
330333
}
331334

332335
return market.Ticker.Decimals, nil

0 commit comments

Comments
 (0)