Skip to content

Commit

Permalink
kludge for keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Oct 10, 2023
1 parent 9e8e13a commit 2f06c5f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/api/rates_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ func (h *Handler) GetRates(ctx context.Context, params oas.GetRatesParams) (*oas
if len(tokens) == 0 {
return nil, toError(http.StatusBadRequest, fmt.Errorf("tokens is required param"))
}
human := false // temporary kludge for keeper
var convertedTokens []string
for _, token := range tokens {
if len(token) == 48 {
human = true
}
if accountID, err := ton.ParseAccountID(token); err == nil {
token = accountID.ToRaw()
} else {
Expand All @@ -70,6 +74,9 @@ func (h *Handler) GetRates(ctx context.Context, params oas.GetRatesParams) (*oas
return nil, toError(http.StatusBadRequest, fmt.Errorf("currencies is required param"))
}
for i := range currencies {
if len(currencies[i]) == 48 {
human = true
}
if len(currencies[i]) < 30 { //not jetton
currencies[i] = strings.ToUpper(currencies[i])
}
Expand Down Expand Up @@ -170,7 +177,16 @@ func (h *Handler) GetRates(ctx context.Context, params oas.GetRatesParams) (*oas
}
}
}

if human { // temporary kludge for keeper
temp := make(map[string]tokenRates, len(ratesRes))
for k, v := range ratesRes {
if len(k) > 48 {
k = ton.MustParseAccountID(k).ToHuman(true, false)
}
temp[k] = v
}
ratesRes = temp
}
bytesRatesRes, err := json.Marshal(ratesRes)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
Expand Down

0 comments on commit 2f06c5f

Please sign in to comment.