Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added extensions/fiats/AED/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/ARS/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/AUD/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/BDT/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/BOB/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/BRL/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/CAD/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/CHF/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/CLP/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/CNY/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/COP/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/CRC/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/CZK/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/DKK/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/DOP/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/EUR/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/GBP/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/GHS/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/GTQ/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/HKD/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/HRK/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/HUF/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/IDR/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/ILS/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/INR/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/fiats/ISK/logo.png
Binary file added extensions/fiats/JPY/logo.png
Binary file added extensions/fiats/KES/logo.png
Binary file added extensions/fiats/KRW/logo.png
Binary file added extensions/fiats/MXN/logo.png
Binary file added extensions/fiats/MYR/logo.png
Binary file added extensions/fiats/NGN/logo.png
Binary file added extensions/fiats/NZD/logo.png
Binary file added extensions/fiats/PEN/logo.png
Binary file added extensions/fiats/PHP/logo.png
Binary file added extensions/fiats/PKR/logo.png
Binary file added extensions/fiats/PLN/logo.png
Binary file added extensions/fiats/RON/logo.png
Binary file added extensions/fiats/RUB/logo.png
Binary file added extensions/fiats/RWF/logo.png
Binary file added extensions/fiats/SAR/logo.png
Binary file added extensions/fiats/SEK/logo.png
Binary file added extensions/fiats/SGD/logo.png
Binary file added extensions/fiats/THB/logo.png
Binary file added extensions/fiats/TRY/logo.png
Binary file added extensions/fiats/TWD/logo.png
Binary file added extensions/fiats/TZS/logo.png
Binary file added extensions/fiats/UGX/logo.png
Binary file added extensions/fiats/USD/logo.png
Binary file added extensions/fiats/XAF/logo.png
Binary file added extensions/fiats/XOF/logo.png
Binary file added extensions/fiats/ZAR/logo.png
60 changes: 30 additions & 30 deletions fiat.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
[
{"symbol": "ARS", "name": "Argentine Peso", "decimals": 2},
{"symbol": "AUD", "name": "Australian Dollar", "decimals": 2},
{"symbol": "BRL", "name": "Brazilian Real", "decimals": 2},
{"symbol": "CAD", "name": "Canadian Dollar", "decimals": 2},
{"symbol": "CHF", "name": "Swiss Franc", "decimals": 2},
{"symbol": "CLP", "name": "Chilean Peso", "decimals": 0},
{"symbol": "CNY", "name": "Chinese Yuan", "decimals": 2},
{"symbol": "CZK", "name": "Czech Koruna", "decimals": 2},
{"symbol": "DKK", "name": "Danish Krone", "decimals": 2},
{"symbol": "EUR", "name": "Euro", "decimals": 2},
{"symbol": "GBP", "name": "British Pound", "decimals": 2},
{"symbol": "GHS", "name": "Ghanaian Cedi", "decimals": 2},
{"symbol": "HKD", "name": "Hong Kong Dollar", "decimals": 2},
{"symbol": "HRK", "name": "Croatian Kuna", "decimals": 2},
{"symbol": "HUF", "name": "Hungarian Forint", "decimals": 2},
{"symbol": "INR", "name": "Indian Rupee", "decimals": 2},
{"symbol": "ISK", "name": "Icelandic Króna", "decimals": 0},
{"symbol": "JPY", "name": "Japanese Yen", "decimals": 0},
{"symbol": "KRW", "name": "South Korean Won", "decimals": 0},
{"symbol": "NGN", "name": "Nigerian Naira", "decimals": 2},
{"symbol": "NZD", "name": "New Zealand Dollar", "decimals": 2},
{"symbol": "PLN", "name": "Polish złoty", "decimals": 2},
{"symbol": "RON", "name": "Romanian Leu", "decimals": 2},
{"symbol": "RUB", "name": "Russian Ruble", "decimals": 2},
{"symbol": "SEK", "name": "Swedish Krona", "decimals": 2},
{"symbol": "SGD", "name": "Singapore Dollar", "decimals": 2},
{"symbol": "THB", "name": "Thai Baht", "decimals": 2},
{"symbol": "TRY", "name": "Turkish Lira", "decimals": 2},
{"symbol": "TWD", "name": "New Taiwan Dollar", "decimals": 2},
{"symbol": "USD", "name": "US Dollar", "decimals": 2}
{"symbol": "ARS", "name": "Argentine Peso", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/ARS/logo.png"},
{"symbol": "AUD", "name": "Australian Dollar", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/AUD/logo.png"},
{"symbol": "BRL", "name": "Brazilian Real", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/BRL/logo.png"},
{"symbol": "CAD", "name": "Canadian Dollar", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/CAD/logo.png"},
{"symbol": "CHF", "name": "Swiss Franc", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/CHF/logo.png"},
{"symbol": "CLP", "name": "Chilean Peso", "decimals": 0, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/CLP/logo.png"},
{"symbol": "CNY", "name": "Chinese Yuan", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/CNY/logo.png"},
{"symbol": "CZK", "name": "Czech Koruna", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/CZK/logo.png"},
{"symbol": "DKK", "name": "Danish Krone", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/DKK/logo.png"},
{"symbol": "EUR", "name": "Euro", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/EUR/logo.png"},
{"symbol": "GBP", "name": "British Pound", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/GBP/logo.png"},
{"symbol": "GHS", "name": "Ghanaian Cedi", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/GHS/logo.png"},
{"symbol": "HKD", "name": "Hong Kong Dollar", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/HKD/logo.png"},
{"symbol": "HRK", "name": "Croatian Kuna", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/HRK/logo.png"},
{"symbol": "HUF", "name": "Hungarian Forint", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/HUF/logo.png"},
{"symbol": "INR", "name": "Indian Rupee", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/INR/logo.png"},
{"symbol": "ISK", "name": "Icelandic Króna", "decimals": 0, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/ISK/logo.png"},
{"symbol": "JPY", "name": "Japanese Yen", "decimals": 0, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/JPY/logo.png"},
{"symbol": "KRW", "name": "South Korean Won", "decimals": 0, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/KRW/logo.png"},
{"symbol": "NGN", "name": "Nigerian Naira", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/NGN/logo.png"},
{"symbol": "NZD", "name": "New Zealand Dollar", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/NZD/logo.png"},
{"symbol": "PLN", "name": "Polish złoty", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/PLN/logo.png"},
{"symbol": "RON", "name": "Romanian Leu", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/RON/logo.png"},
{"symbol": "RUB", "name": "Russian Ruble", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/RUB/logo.png"},
{"symbol": "SEK", "name": "Swedish Krona", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/SEK/logo.png"},
{"symbol": "SGD", "name": "Singapore Dollar", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/SGD/logo.png"},
{"symbol": "THB", "name": "Thai Baht", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/THB/logo.png"},
{"symbol": "TRY", "name": "Turkish Lira", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/TRY/logo.png"},
{"symbol": "TWD", "name": "New Taiwan Dollar", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/TWD/logo.png"},
{"symbol": "USD", "name": "US Dollar", "decimals": 2, "logo": "https://raw.githubusercontent.com/blockchain/coin-definitions/master/extensions/fiats/USD/logo.png"}
]
5 changes: 4 additions & 1 deletion scripts/build-lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def fetch_tokens(chain):


def fetch_prices():
coins = fetch_coins()
# Use published coins.json rather than rescanning Trust Wallet assets.
# Auto-bump does not rebuild coins.json, and assets often introduce L1
# symbol collisions (e.g. multiple chains using ETH) that would abort CI.
coins = list(map(Coin.from_dict, read_json(FINAL_BLOCKCHAINS_LIST)))

prices = {
"timestamp": datetime.now().isoformat(),
Expand Down
65 changes: 63 additions & 2 deletions scripts/check-lists.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import hashlib
import itertools
import operator
import os
from dataclasses import dataclass
from functools import reduce
from typing import List

from common_classes import Coin, Token
from statics import EXT_PRICES
from statics import BC_REPO_ROOT, EXT_PRICES
from utils import read_json

EXT_FIATS = "extensions/fiats/"


class CheckResult:
def __init__(self, ref, msg):
Expand Down Expand Up @@ -131,6 +135,24 @@ class Group:
parentSymbol: str
childSymbols: List[str]


@dataclass
class Fiat:
symbol: str
name: str
decimals: int
logo: str

def __str__(self):
return f"[FIAT {self.symbol}]"

def logo_path(self):
return os.path.join(EXT_FIATS, self.symbol, "logo.png")

def expected_logo_url(self):
return BC_REPO_ROOT + self.logo_path()


def find_duplicates(items, key):
groups = itertools.groupby(sorted(items, key=key), key)
groups = [(symbol, list(items)) for symbol, items in groups]
Expand All @@ -142,6 +164,40 @@ def check_logo(coin):
yield Warning(coin, "No logo")


def check_fiats(fiats: List[Fiat]):
duplicates = find_duplicates(fiats, lambda f: f.symbol.upper())
for symbol, items in duplicates:
yield Error(symbol, f"Duplicate fiat symbol: {items}")

content_hashes = {}
for fiat in fiats:
if fiat.symbol.upper() != fiat.symbol:
yield Error(fiat, "Contains mix of lower and upper case letters")

if not isinstance(fiat.decimals, int) or fiat.decimals < 0:
yield Error(fiat, f"Invalid decimals: {fiat.decimals}")

if not fiat.name:
yield Error(fiat, "Missing name")

expected_logo = fiat.expected_logo_url()
if fiat.logo != expected_logo:
yield Error(fiat, f"Invalid logo URL, expected {expected_logo}")

logo_path = fiat.logo_path()
if not os.path.exists(logo_path):
yield Error(fiat, f"Logo file not found: {logo_path}")
continue

with open(logo_path, "rb") as logo_file:
digest = hashlib.sha256(logo_file.read()).hexdigest()

if digest in content_hashes:
yield Error(fiat, f"Duplicate logo content (same as {content_hashes[digest]})")
else:
content_hashes[digest] = fiat.symbol


def check_groups(
groups: List[Group],
custody_currencies: list[CustodyCurrency],
Expand Down Expand Up @@ -283,6 +339,7 @@ def main():
other_tokens = [token for chain_tokens in chains.values() for token in chain_tokens]

custody_currencies = list(map(lambda x: CustodyCurrency(**x), read_json("custody.json")))
fiats = list(map(lambda x: Fiat(**x), read_json("fiat.json")))

combined = sorted(itertools.chain(coins, eth_erc20_tokens, other_tokens), key=lambda x: x.symbol)
duplicates = find_duplicates(combined, lambda t: t.symbol.upper())
Expand All @@ -294,10 +351,14 @@ def main():
print(f"{len(eth_erc20_tokens)} ETH tokens")
for (k, v) in chains.items():
print(f"{len(v)} {k} tokens")
print(f"{len(fiats)} fiats")
print(f"Total: {len(combined)}")

prices = read_json(EXT_PRICES)['prices']
issues = list(check_currencies(custody_currencies, coins, eth_erc20_tokens, chains, prices, groups))
issues = list(itertools.chain(
check_currencies(custody_currencies, coins, eth_erc20_tokens, chains, prices, groups),
check_fiats(fiats),
))

print("")
print(reduce(operator.add, map(lambda i: "\n- " + str(i), issues)))
Expand Down
Loading