MCPcopy
hub / github.com/trustwallet/assets / validateTokenList

Function validateTokenList

internal/processor/validators.go:280–313  ·  view source on GitHub ↗
(path1, path2 string, chain1 coin.Coin)

Source from the content-addressed store, hash-verified

278}
279
280func validateTokenList(path1, path2 string, chain1 coin.Coin) error {
281 var tokenList1 tokenlist.Model
282 err := file.ReadJSONFile(path1, &tokenList1)
283 if err != nil {
284 return err
285 }
286
287 if file.Exists(path2) {
288 var tokenList2 tokenlist.Model
289 err = file.ReadJSONFile(path2, &tokenList2)
290 if err != nil {
291 return err
292 }
293
294 tokensMap := make(map[string]bool)
295 for _, token := range tokenList2.Tokens {
296 tokensMap[token.Asset] = true
297 }
298
299 for _, token := range tokenList1.Tokens {
300 if _, exists := tokensMap[token.Asset]; exists {
301 return fmt.Errorf("duplicate asset: %s from %s, already exist in %s",
302 token.Asset, path1, path2)
303 }
304 }
305 }
306
307 err = tokenlist.ValidateTokenList(tokenList1, chain1, path1)
308 if err != nil {
309 return err
310 }
311
312 return nil
313}
314
315func (s *Service) ValidateInfoFolder(f *file.AssetFile) error {
316 dirFiles, err := file.ReadDir(f.Path())

Callers 2

ValidateTokenListFileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…