Skip to content

Commit

Permalink
summary upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Feb 23, 2024
1 parent 624362d commit aab09c4
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions generators/buildTokenList.summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"io/ioutil"
"sort"
"strconv"
"time"

"github.com/migratooor/tokenLists/generators/common/helpers"
Expand All @@ -20,8 +21,9 @@ type TMinTokenListData struct {
Keywords []string `json:"keywords"`
TokenCount int `json:"tokenCount"`
Metadata struct {
SupportedChains []int `json:"supportedChains"`
GenerationMethod string `json:"generationMethod"`
SupportedChains []int `json:"supportedChains"`
GenerationMethod string `json:"generationMethod"`
TokenCountPerChain map[string]int `json:"tokenCountPerChain"`
} `json:"metadata"`
Version struct {
Major int `json:"major"`
Expand Down Expand Up @@ -72,6 +74,14 @@ func buildSummary() {
}
listElement.Metadata.SupportedChains = listSupportedChains(tokenList.Tokens)
listElement.Metadata.GenerationMethod = string(data.GenerationMethod)
listElement.Metadata.TokenCountPerChain = make(map[string]int)
for _, token := range tokenList.Tokens {
chainStr := strconv.FormatUint(token.ChainID, 10)
if _, ok := listElement.Metadata.TokenCountPerChain[chainStr]; !ok {
listElement.Metadata.TokenCountPerChain[chainStr] = 0
}
listElement.Metadata.TokenCountPerChain[chainStr]++
}
tokenListSummary.Lists = append(tokenListSummary.Lists, listElement)
}

Expand All @@ -90,6 +100,14 @@ func buildSummary() {
}
listElement.Metadata.SupportedChains = listSupportedChains(tokenListooorList.Tokens)
listElement.Metadata.GenerationMethod = string(GenerationAPI)
listElement.Metadata.TokenCountPerChain = make(map[string]int)
for _, token := range tokenListooorList.Tokens {
chainStr := strconv.FormatUint(token.ChainID, 10)
if _, ok := listElement.Metadata.TokenCountPerChain[chainStr]; !ok {
listElement.Metadata.TokenCountPerChain[chainStr] = 0
}
listElement.Metadata.TokenCountPerChain[chainStr]++
}
tokenListSummary.Lists = append(tokenListSummary.Lists, listElement)
}

Expand Down

0 comments on commit aab09c4

Please sign in to comment.