Skip to content

Commit

Permalink
[bot] - Update lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Nov 8, 2024
1 parent b0ede60 commit 95a30fb
Show file tree
Hide file tree
Showing 58 changed files with 140,669 additions and 21,313 deletions.
42 changes: 42 additions & 0 deletions generators/buildTokenList.jupiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"github.com/migratooor/tokenLists/generators/common/chains"
"github.com/migratooor/tokenLists/generators/common/helpers"
"github.com/migratooor/tokenLists/generators/common/models"
)

type TJupiterFMToken struct {
Address string `json:"address"`
Name string `json:"name"`
Symbol string `json:"symbol"`
LogoURI string `json:"logoURI"`
Decimals int `json:"decimals"`
}

var JupiterTokenEndpoint = `https://tokens.jup.ag/tokens?tags=verified`

func fetchJupiterTokenList() []models.TokenListToken {
tokenLists := []models.TokenListToken{}

tokenAddresses := []string{}
tokenIcons := map[string]string{}
fetchingURL := JupiterTokenEndpoint
list := helpers.FetchJSON[[]TJupiterFMToken](fetchingURL)

for _, token := range list {
tokenAddresses = append(tokenAddresses, token.Address)
tokenIcons[token.Address] = token.LogoURI
}
tokenLists = helpers.GetTokensFromAddressesWithIcons(chains.SOLANA.ID, tokenAddresses, tokenIcons)
return tokenLists
}

func buildJupiterTokenList() {
tokenList := helpers.LoadTokenListFromJsonFile(`jupiter.json`)
tokenList.Name = "Jupiter Verified Token List"
tokenList.LogoURI = "https://station.jup.ag/img/jupiter-logo.svg"

tokens := fetchJupiterTokenList()
helpers.SaveTokenListInJsonFile(tokenList, tokens, `jupiter.json`, helpers.SavingMethodStandard)
}
8 changes: 8 additions & 0 deletions generators/common/helpers/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func SaveChainListInJsonFile(
** If the list is empty, we skip
**************************************************************************/
if len(tokenList.NextTokensMap) == 0 {
logs.Error(`token list ` + tokenList.Name + ` is empty`)
return errors.New(`token list is empty`)
}

Expand All @@ -336,13 +337,17 @@ func SaveChainListInJsonFile(
if strings.EqualFold(`0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE`, token.Address) {
baseCoinCount++
}
if strings.EqualFold(`So11111111111111111111111111111111111111111`, token.Address) {
baseCoinCount++
}
}
for _, chainID := range chains.SUPPORTED_CHAIN_IDS {
chain := chains.CHAINS[chainID]
baseCoinCount += len(chain.ExtraTokens)
}

if len(tokenList.NextTokensMap) <= baseCoinCount {
logs.Error(`token list ` + tokenList.Name + ` is empty`)
return errors.New(`token list is empty`)
}

Expand Down Expand Up @@ -377,6 +382,7 @@ func SaveChainListInJsonFile(
** If there are no changes, we will just return.
**************************************************************************/
if !shouldBumpMajor && !shouldBumpMinor && !shouldBumpPatch {
logs.Error(`no changes detected for ` + tokenList.Name)
return errors.New(`no changes detected`)
}

Expand Down Expand Up @@ -423,7 +429,9 @@ func SaveChainListInJsonFile(
logs.Info(`ChainID ` + strconv.FormatUint(chainID, 10) + ` is not supported`)
continue
}
logs.Info(`Saving chain list for chainID ` + strconv.FormatUint(chainID, 10))
if chains.CHAINS[chainID].IsTestNet {
logs.Info(`ChainID ` + strconv.FormatUint(chainID, 10) + ` is a testnet`)
continue
}
chainIDStr := strconv.FormatUint(chainID, 10)
Expand Down
7 changes: 7 additions & 0 deletions generators/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ var GENERATORS = map[string]TGenerators{
GenerationMethod: GenerationStatic,
GeneratorType: GeneratorToken,
},
`jupiter`: {
Exec: buildJupiterTokenList,
Name: `Jupiter`,
Description: `A list of verified tokens available on Jupiter.`,
GenerationMethod: GenerationAPI,
GeneratorType: GeneratorToken,
},
`ledger`: {
Exec: buildLedgersTokenList,
Name: `Ledger`,
Expand Down
5 changes: 5 additions & 0 deletions generators/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/migratooor/tokenLists/generators/common/ethereum"
"github.com/migratooor/tokenLists/generators/common/helpers"
"github.com/migratooor/tokenLists/generators/common/logs"
)

Expand Down Expand Up @@ -34,6 +35,10 @@ func main() {
logs.Success(`Done!`)
}
}
} else if (len(os.Args) == 2) && (os.Args[1] == `chainlist`) {
tokenList := helpers.LoadTokenListFromJsonFile(`popular.json`)
helpers.SaveChainListInJsonFile(tokenList)
os.Exit(0)
} else {
for _, arg := range os.Args[1:] {
if _, ok := GENERATORS[arg]; ok {
Expand Down
Loading

0 comments on commit 95a30fb

Please sign in to comment.