Skip to content

Commit 336036e

Browse files
authored
Fixes convert call (#98)
1 parent 551ea9d commit 336036e

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- uses: golangci/golangci-lint-action@v3.4.0
3131
with:
3232
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
33-
version: 1.54.2
33+
version: v1.54.2
3434
args: --timeout 10m
3535
github-token: ${{ secrets.github_token }}
3636
# Check only if there are differences in the source code

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
## Unreleased
3838

39+
- (fix) [fse-900] Fix failing convertCoin and convertERC20 endpoints
40+
3941
## 1.3.7 - 2023-12-13
4042

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

4345
## 1.3.6 - 2023-12-13
4446

45-
- (chore) [fse-897] Fix linter version
47+
- (chore) [fse-897] Fix linter version
4648

4749
## 1.3.5 - 2023-12-12
4850

api/handler/v1/erc20.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ type TokensByNameIBC struct {
272272
}
273273

274274
type TokensByNameConfig struct {
275+
CoinDenom string `json:"coinDenom"`
275276
CosmosDenom string `json:"cosmosDenom"`
276277
Ibc TokensByNameIBC `json:"ibc"`
277278
ERC20Address string `json:"erc20Address"`
@@ -291,13 +292,20 @@ func ERC20TokensByNameInternal(name string) (string, error) {
291292
if err != nil {
292293
return "", err
293294
}
294-
295+
// Caches all tokens on redis the first time this is called
295296
for _, v := range val {
296-
if strings.Contains(v.URL, name) {
297-
res := buildValuesResponse(v.Content)
298-
db.RedisSetERC20TokensByName(name, res)
299-
return res, nil
297+
res := buildValuesResponse(v.Content)
298+
var tokensByName TokensByName
299+
err = json.Unmarshal([]byte(res), &tokensByName)
300+
if err != nil {
301+
continue
300302
}
303+
db.RedisSetERC20TokensByName(tokensByName.Values.CoinDenom, res)
304+
}
305+
306+
if val, err := db.RedisGetERC20TokensByName(name); err == nil {
307+
return val, nil
301308
}
309+
302310
return "", fmt.Errorf("invalid token, please try again")
303311
}

0 commit comments

Comments
 (0)