Skip to content

Commit

Permalink
fix(eventindexer): fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
k-kaddal committed Jun 13, 2024
1 parent c35146e commit 2207f45
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/eventindexer/indexer/fetch_nft_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ func resolveMetadataURL(tokenURI string) (string, error) {
if strings.HasPrefix(tokenURI, "ipfs://") {
ipfsHash := strings.TrimPrefix(tokenURI, "ipfs://")
resolvedURL := fmt.Sprintf("https://ipfs.io/ipfs/%s", ipfsHash)

if isValidURL(resolvedURL) {
return resolvedURL, nil
}

return "", eventindexer.ErrInvalidURL
}

Expand All @@ -106,6 +108,7 @@ func isValidURL(rawURL string) bool {
client := &http.Client{
Timeout: 20 * time.Second,
}

resp, err := client.Head(rawURL)
if err != nil || resp.StatusCode != http.StatusOK {
return false
Expand Down
1 change: 1 addition & 0 deletions packages/eventindexer/nft_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (a *Attributes) Scan(value interface{}) error {

func (a *Attribute) UnmarshalJSON(data []byte) error {
type Alias Attribute

aux := &struct {
Value interface{} `json:"value"`
*Alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ func (srv *Server) GetNFTBalancesByAddressAndChainID(c echo.Context) error {

balances, ok := page.Items.(*[]eventindexer.NFTBalance)
if !ok {
return webutils.LogAndRenderErrors(c, http.StatusInternalServerError, echo.NewHTTPError(http.StatusInternalServerError, "Failed to cast paginated items"))
return webutils.LogAndRenderErrors(
c,
http.StatusInternalServerError,
echo.NewHTTPError(http.StatusInternalServerError, "Failed to cast paginated items"))
}

var balancesWithMetadata []NFTBalanceWithMetadata

for _, balance := range *balances {
metadata, err := srv.nftMetadataRepo.GetNFTMetadata(
c.Request().Context(),
Expand Down

0 comments on commit 2207f45

Please sign in to comment.