removed obsolete errors
This commit is contained in:
@@ -3,11 +3,11 @@ package client
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
fxv1 "github.com/tech/sendico/pkg/proto/common/fx/v1"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
tracev1 "github.com/tech/sendico/pkg/proto/common/trace/v1"
|
||||
@@ -88,7 +88,7 @@ type oracleClient struct {
|
||||
func New(ctx context.Context, cfg Config, opts ...grpc.DialOption) (Client, error) {
|
||||
cfg.setDefaults()
|
||||
if strings.TrimSpace(cfg.Address) == "" {
|
||||
return nil, errors.New("oracle: address is required")
|
||||
return nil, merrors.InvalidArgument("oracle: address is required")
|
||||
}
|
||||
|
||||
dialCtx, cancel := context.WithTimeout(ctx, cfg.DialTimeout)
|
||||
@@ -105,7 +105,7 @@ func New(ctx context.Context, cfg Config, opts ...grpc.DialOption) (Client, erro
|
||||
|
||||
conn, err := grpc.DialContext(dialCtx, cfg.Address, dialOpts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("oracle: dial %s: %w", cfg.Address, err)
|
||||
return nil, merrors.InternalWrap(err, fmt.Sprintf("oracle: dial %s", cfg.Address))
|
||||
}
|
||||
|
||||
return &oracleClient{
|
||||
@@ -133,7 +133,7 @@ func (c *oracleClient) Close() error {
|
||||
|
||||
func (c *oracleClient) LatestRate(ctx context.Context, req LatestRateParams) (*RateSnapshot, error) {
|
||||
if req.Pair == nil {
|
||||
return nil, errors.New("oracle: pair is required")
|
||||
return nil, merrors.InvalidArgument("oracle: pair is required")
|
||||
}
|
||||
|
||||
callCtx, cancel := c.callContext(ctx)
|
||||
@@ -145,26 +145,26 @@ func (c *oracleClient) LatestRate(ctx context.Context, req LatestRateParams) (*R
|
||||
Provider: req.Provider,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("oracle: latest rate: %w", err)
|
||||
return nil, merrors.InternalWrap(err, "oracle: latest rate")
|
||||
}
|
||||
if resp.GetRate() == nil {
|
||||
return nil, errors.New("oracle: latest rate: empty payload")
|
||||
return nil, merrors.Internal("oracle: latest rate: empty payload")
|
||||
}
|
||||
return fromProtoRate(resp.GetRate()), nil
|
||||
}
|
||||
|
||||
func (c *oracleClient) GetQuote(ctx context.Context, req GetQuoteParams) (*Quote, error) {
|
||||
if req.Pair == nil {
|
||||
return nil, errors.New("oracle: pair is required")
|
||||
return nil, merrors.InvalidArgument("oracle: pair is required")
|
||||
}
|
||||
if req.Side == fxv1.Side_SIDE_UNSPECIFIED {
|
||||
return nil, errors.New("oracle: side is required")
|
||||
return nil, merrors.InvalidArgument("oracle: side is required")
|
||||
}
|
||||
|
||||
baseSupplied := req.BaseAmount != nil
|
||||
quoteSupplied := req.QuoteAmount != nil
|
||||
if baseSupplied == quoteSupplied {
|
||||
return nil, errors.New("oracle: exactly one of base_amount or quote_amount must be set")
|
||||
return nil, merrors.InvalidArgument("oracle: exactly one of base_amount or quote_amount must be set")
|
||||
}
|
||||
|
||||
callCtx, cancel := c.callContext(ctx)
|
||||
@@ -191,10 +191,10 @@ func (c *oracleClient) GetQuote(ctx context.Context, req GetQuoteParams) (*Quote
|
||||
|
||||
resp, err := c.client.GetQuote(callCtx, protoReq)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("oracle: get quote: %w", err)
|
||||
return nil, merrors.InternalWrap(err, "oracle: get quote")
|
||||
}
|
||||
if resp.GetQuote() == nil {
|
||||
return nil, errors.New("oracle: get quote: empty payload")
|
||||
return nil, merrors.Internal("oracle: get quote: empty payload")
|
||||
}
|
||||
return fromProtoQuote(resp.GetQuote()), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user