Skip to content

Commit

Permalink
Fixes convert call (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-script committed Dec 21, 2023
1 parent 551ea9d commit 336036e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: golangci/[email protected]
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: 1.54.2
version: v1.54.2
args: --timeout 10m
github-token: ${{ secrets.github_token }}
# Check only if there are differences in the source code
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

- (fix) [fse-900] Fix failing convertCoin and convertERC20 endpoints

## 1.3.7 - 2023-12-13

- (chore) [fse-897] Update github actions

## 1.3.6 - 2023-12-13

- (chore) [fse-897] Fix linter version
- (chore) [fse-897] Fix linter version

## 1.3.5 - 2023-12-12

Expand Down
18 changes: 13 additions & 5 deletions api/handler/v1/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ type TokensByNameIBC struct {
}

type TokensByNameConfig struct {
CoinDenom string `json:"coinDenom"`
CosmosDenom string `json:"cosmosDenom"`
Ibc TokensByNameIBC `json:"ibc"`
ERC20Address string `json:"erc20Address"`
Expand All @@ -291,13 +292,20 @@ func ERC20TokensByNameInternal(name string) (string, error) {
if err != nil {
return "", err
}

// Caches all tokens on redis the first time this is called
for _, v := range val {
if strings.Contains(v.URL, name) {
res := buildValuesResponse(v.Content)
db.RedisSetERC20TokensByName(name, res)
return res, nil
res := buildValuesResponse(v.Content)
var tokensByName TokensByName
err = json.Unmarshal([]byte(res), &tokensByName)
if err != nil {
continue
}
db.RedisSetERC20TokensByName(tokensByName.Values.CoinDenom, res)
}

if val, err := db.RedisGetERC20TokensByName(name); err == nil {
return val, nil
}

return "", fmt.Errorf("invalid token, please try again")
}

0 comments on commit 336036e

Please sign in to comment.