diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0cca26d..93a12c3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -30,7 +30,7 @@ jobs: - uses: golangci/golangci-lint-action@v3.4.0 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c3932e..48365e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/api/handler/v1/erc20.go b/api/handler/v1/erc20.go index 8ebc3a8..0983a7b 100644 --- a/api/handler/v1/erc20.go +++ b/api/handler/v1/erc20.go @@ -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"` @@ -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") }