Skip to content

Commit

Permalink
Fixes convert call
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-script committed Dec 21, 2023
1 parent 551ea9d commit 899cd5d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
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")
}
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ services:
- ENVIRONMENT=staging
depends_on:
- dashboard-backend-redis
volumes:
- type: bind
source: ./
target: /go/src
ports:
- "8081:8081"
nginx:
container_name: nginx
build:
Expand Down
11 changes: 11 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM golang:1.21.1 as builder

WORKDIR /go/src/
<<<<<<< Updated upstream

COPY . .

Expand All @@ -19,3 +20,13 @@ COPY --from=builder /go/src/api/config/config.toml ./api/config/config.toml
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
EXPOSE 8081
CMD ["./server"]
=======

COPY . .

RUN go build ./cmd/server/
EXPOSE 8081

CMD ["go", "run", "/go/src/cmd/server/"]
# CMD ["go run ./go/src/cmd/server/"]
>>>>>>> Stashed changes

0 comments on commit 899cd5d

Please sign in to comment.