Skip to content

Commit

Permalink
feat: add blast
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Mar 6, 2024
1 parent 18e4cf4 commit da96b22
Show file tree
Hide file tree
Showing 24 changed files with 7,838 additions and 137 deletions.
29 changes: 19 additions & 10 deletions generators/buildTokenList.routescan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,39 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/migratooor/tokenLists/generators/common/chains"
"github.com/migratooor/tokenLists/generators/common/helpers"
"github.com/migratooor/tokenLists/generators/common/logs"
"github.com/migratooor/tokenLists/generators/common/models"
)

var ROUTESCAN_URI = map[uint64]string{
81457: `https://cdn.routescan.io/api/evm/all/erc20`,
}

func handleRouteScanTokenList(chainID uint64, tokenAddresses []common.Address) []models.TokenListToken {
func handleRouteScanTokenList(chainID uint64, tokenAddresses []common.Address, logos map[common.Address]string) []models.TokenListToken {
tokenList := helpers.GetTokensFromAddresses(chainID, tokenAddresses)
tokenList = append(tokenList, chains.CHAINS[chainID].Coin)

for i, token := range tokenList {
if logo, ok := logos[common.HexToAddress(token.Address)]; ok {
if logo != `` {
tokenList[i].LogoURI = logo
}
}
}

return tokenList
}

func fetchRouteScanTokenList(chainID uint64) []models.TokenListToken {
type TRoutescanAPIResponse struct {
Items []struct {
Address string `json:"address"`
Details struct {
Detail struct {
Icon string `json:"icon"`
Type string `json:"type"`
Blacklist bool `json:"blacklist"`
}
Transfers struct {
last24h uint64 `json:"last24h"`
Last24h uint64 `json:"last24h"`
}
Holders uint64 `json:"holders"`
} `json:"items"`
Expand All @@ -37,24 +45,26 @@ func fetchRouteScanTokenList(chainID uint64) []models.TokenListToken {
explorerBaseURI := ROUTESCAN_URI[chainID]
nextPageURI := `?count=false&includedChainIds=81457&limit=1000&sort=marketCap%2Cdesc`
tokens := []common.Address{}
logos := map[common.Address]string{}
response := helpers.FetchJSON[TRoutescanAPIResponse](explorerBaseURI + nextPageURI)
for _, token := range response.Items {
if token.Details.Type == `ERC-721` || token.Details.Type == `ERC-1155` {
if token.Detail.Type == `ERC-721` || token.Detail.Type == `ERC-1155` {
continue
}
if token.Details.Blacklist {
if token.Detail.Blacklist {
continue
}
if token.Holders == 0 {
continue
}
if token.Transfers.last24h == 0 {
if token.Transfers.Last24h == 0 {
continue
}
tokens = append(tokens, common.HexToAddress(token.Address))
logos[common.HexToAddress(token.Address)] = token.Detail.Icon
}

return handleRouteScanTokenList(chainID, tokens)
return handleRouteScanTokenList(chainID, tokens, logos)
}

func buildRouteScanTokenList() {
Expand All @@ -67,6 +77,5 @@ func buildRouteScanTokenList() {
for chainID := range ROUTESCAN_URI {
tokens = append(tokens, fetchRouteScanTokenList(chainID)...)
}
logs.Pretty(tokens)
// helpers.SaveTokenListInJsonFile(tokenList, tokens, `routescan.json`, helpers.SavingMethodStandard)
helpers.SaveTokenListInJsonFile(tokenList, tokens, `routescan.json`, helpers.SavingMethodStandard)
}
Loading

0 comments on commit da96b22

Please sign in to comment.