parent
4a39df2847
commit
f44ef58acb
@ -1,45 +0,0 @@
|
||||
{
|
||||
"erc20:eth:BAT": {
|
||||
"name": "Basic Attention Token"
|
||||
},
|
||||
"erc20:eth:LINK (Chainlink)": {
|
||||
"name": "Chainlink"
|
||||
},
|
||||
"erc20:eth:SOL": {
|
||||
"shortcut": "SOLA"
|
||||
},
|
||||
"eth:CLO": {
|
||||
"coinmarketcap_alias": "callisto-network"
|
||||
},
|
||||
"eth:ESN": {
|
||||
"coinmarketcap_alias": "ethersocial"
|
||||
},
|
||||
"nem:DIMTOK": {
|
||||
"coinmarketcap_alias": "dimcoin"
|
||||
},
|
||||
"eth:AUX": {
|
||||
"links": {
|
||||
"Github": "https://github.com/auxiliumglobal"
|
||||
},
|
||||
"wallet": {
|
||||
"MyEtherWallet": null
|
||||
}
|
||||
},
|
||||
"eth:EOS": {
|
||||
"hidden": true,
|
||||
"ignore_cmc_rank": true,
|
||||
"reason": "this exists as misc:EOS and the eth: entry is probably a mistake"
|
||||
},
|
||||
"eth:XDC": {
|
||||
"wallet": {
|
||||
"MyCrypto": null,
|
||||
"MyEtherWallet": null,
|
||||
"XDC Wallet": "https://wallet.xinfin.network"
|
||||
}
|
||||
},
|
||||
"misc:LSK": {
|
||||
"hidden": true,
|
||||
"ignore_cmc_rank": true,
|
||||
"reason": "delisted incompatible hardfork"
|
||||
}
|
||||
}
|
@ -1,38 +1,3 @@
|
||||
{
|
||||
"erc20:eth:BTL (Battle)": true,
|
||||
"erc20:eth:BTL (Bitlle)": true,
|
||||
"erc20:eth:LINK Platform": true,
|
||||
"erc20:eth:NXX": false,
|
||||
"erc20:eth:SNX:c011": false,
|
||||
"erc20:eth:TUSD": false,
|
||||
"erc20:eth:Hdp": true,
|
||||
"erc20:eth:Hdp.ф": true,
|
||||
"erc20:eth:HEX:2b59": false,
|
||||
"erc20:eth:JOB:dfbc": false,
|
||||
"misc:BNB": false,
|
||||
"eth:BNB": false,
|
||||
"eth:ONE:1666600000": false,
|
||||
"eth:ONE:1666600001": false,
|
||||
"eth:ONE:1666600002": false,
|
||||
"eth:ONE:1666600003": false,
|
||||
"eth:tGOR:5": false,
|
||||
"eth:tGOR:420": false,
|
||||
"eth:tCELO:44787": false,
|
||||
"eth:tCELO:62320": false,
|
||||
"eth:QKC:100000": false,
|
||||
"eth:QKC:100001": false,
|
||||
"eth:QKC:100002": false,
|
||||
"eth:QKC:100003": false,
|
||||
"eth:QKC:100004": false,
|
||||
"eth:QKC:100005": false,
|
||||
"eth:QKC:100006": false,
|
||||
"eth:QKC:100007": false,
|
||||
"eth:QKC:100008": false,
|
||||
"eth:xDAI:100": false,
|
||||
"eth:xDAI:200": false,
|
||||
"eth:CPAY:3000": false,
|
||||
"eth:CPAY:3001": false,
|
||||
"eth:CPAY:21337": false,
|
||||
"erc20:eth:USDT": false,
|
||||
"erc20:avax:USDT": false
|
||||
"misc:BNB": false
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 805ae42ecc53aa6493949b1e9c1da41e036c1845
|
@ -0,0 +1,62 @@
|
||||
[
|
||||
{
|
||||
"chain": "eth",
|
||||
"chain_id": 1,
|
||||
"coingecko_id": "ethereum",
|
||||
"is_testnet": false,
|
||||
"name": "Ethereum",
|
||||
"shortcut": "ETH",
|
||||
"slip44": 60
|
||||
},
|
||||
{
|
||||
"chain": "rop",
|
||||
"chain_id": 3,
|
||||
"is_testnet": true,
|
||||
"name": "Ropsten",
|
||||
"shortcut": "tROP",
|
||||
"slip44": 1
|
||||
},
|
||||
{
|
||||
"chain": "rin",
|
||||
"chain_id": 4,
|
||||
"is_testnet": true,
|
||||
"name": "Rinkeby",
|
||||
"shortcut": "tRIN",
|
||||
"slip44": 1
|
||||
},
|
||||
{
|
||||
"chain": "gor",
|
||||
"chain_id": 5,
|
||||
"is_testnet": true,
|
||||
"name": "Görli",
|
||||
"shortcut": "tGOR",
|
||||
"slip44": 1
|
||||
},
|
||||
{
|
||||
"chain": "bnb",
|
||||
"chain_id": 56,
|
||||
"coingecko_id": "binance-smart-chain",
|
||||
"is_testnet": false,
|
||||
"name": "Binance Smart Chain",
|
||||
"shortcut": "BNB",
|
||||
"slip44": 714
|
||||
},
|
||||
{
|
||||
"chain": "etc",
|
||||
"chain_id": 61,
|
||||
"coingecko_id": "ethereum-classic",
|
||||
"is_testnet": false,
|
||||
"name": "Ethereum Classic",
|
||||
"shortcut": "ETC",
|
||||
"slip44": 61
|
||||
},
|
||||
{
|
||||
"chain": "MATIC",
|
||||
"chain_id": 137,
|
||||
"coingecko_id": "polygon-pos",
|
||||
"is_testnet": false,
|
||||
"name": "Polygon",
|
||||
"shortcut": "MATIC",
|
||||
"slip44": 966
|
||||
}
|
||||
]
|
@ -0,0 +1 @@
|
||||
1669892465
|
@ -1 +0,0 @@
|
||||
Subproject commit 0eeaf9b9f13b5e6538da26d079e2b968dc8bb23f
|
@ -0,0 +1,189 @@
|
||||
{
|
||||
"1;eth": [
|
||||
{
|
||||
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
||||
"coingecko_id": "tether",
|
||||
"decimals": 6,
|
||||
"name": "Tether",
|
||||
"shortcut": "USDT"
|
||||
},
|
||||
{
|
||||
"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
||||
"coingecko_id": "usd-coin",
|
||||
"decimals": 6,
|
||||
"name": "USD Coin",
|
||||
"shortcut": "USDC"
|
||||
},
|
||||
{
|
||||
"address": "0x4fabb145d64652a948d72533023f6e7a623c7c53",
|
||||
"coingecko_id": "binance-usd",
|
||||
"decimals": 18,
|
||||
"name": "Binance USD",
|
||||
"shortcut": "BUSD"
|
||||
},
|
||||
{
|
||||
"address": "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce",
|
||||
"coingecko_id": "shiba-inu",
|
||||
"decimals": 18,
|
||||
"name": "Shiba Inu",
|
||||
"shortcut": "SHIB"
|
||||
},
|
||||
{
|
||||
"address": "0x6b175474e89094c44da98b954eedeac495271d0f",
|
||||
"coingecko_id": "dai",
|
||||
"decimals": 18,
|
||||
"name": "Dai",
|
||||
"shortcut": "DAI"
|
||||
},
|
||||
{
|
||||
"address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",
|
||||
"coingecko_id": "matic-network",
|
||||
"decimals": 18,
|
||||
"name": "Polygon",
|
||||
"shortcut": "MATIC"
|
||||
},
|
||||
{
|
||||
"address": "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
|
||||
"coingecko_id": "staked-ether",
|
||||
"decimals": 18,
|
||||
"name": "Lido Staked Ether",
|
||||
"shortcut": "STETH"
|
||||
},
|
||||
{
|
||||
"address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
|
||||
"coingecko_id": "uniswap",
|
||||
"decimals": 18,
|
||||
"name": "Uniswap",
|
||||
"shortcut": "UNI"
|
||||
},
|
||||
{
|
||||
"address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
||||
"coingecko_id": "wrapped-bitcoin",
|
||||
"decimals": 8,
|
||||
"name": "Wrapped Bitcoin",
|
||||
"shortcut": "WBTC"
|
||||
},
|
||||
{
|
||||
"address": "0x75231f58b43240c9718dd58b4967c5114342a86c",
|
||||
"coingecko_id": "okb",
|
||||
"decimals": 18,
|
||||
"name": "OKB",
|
||||
"shortcut": "OKB"
|
||||
},
|
||||
{
|
||||
"address": "0x2af5d2ad76741191d15dfe7bf6ac92d4bd912ca3",
|
||||
"coingecko_id": "leo-token",
|
||||
"decimals": 18,
|
||||
"name": "LEO Token",
|
||||
"shortcut": "LEO"
|
||||
},
|
||||
{
|
||||
"address": "0x514910771af9ca656af840dff83e8264ecf986ca",
|
||||
"coingecko_id": "chainlink",
|
||||
"decimals": 18,
|
||||
"name": "Chainlink",
|
||||
"shortcut": "LINK"
|
||||
},
|
||||
{
|
||||
"address": "0x50d1c9771902476076ecfc8b2a83ad6b9355a4c9",
|
||||
"coingecko_id": "ftx-token",
|
||||
"decimals": 18,
|
||||
"name": "FTX",
|
||||
"shortcut": "FTT"
|
||||
},
|
||||
{
|
||||
"address": "0xa0b73e1ff0b80914ab6fe0444e65848c4c34450b",
|
||||
"coingecko_id": "crypto-com-chain",
|
||||
"decimals": 8,
|
||||
"name": "Cronos",
|
||||
"shortcut": "CRO"
|
||||
},
|
||||
{
|
||||
"address": "0x4a220e6096b25eadb88358cb44068a3248254675",
|
||||
"coingecko_id": "quant-network",
|
||||
"decimals": 18,
|
||||
"name": "Quant",
|
||||
"shortcut": "QNT"
|
||||
},
|
||||
{
|
||||
"address": "0x4d224452801aced8b2f0aebe155379bb5d594381",
|
||||
"coingecko_id": "apecoin",
|
||||
"decimals": 18,
|
||||
"name": "ApeCoin",
|
||||
"shortcut": "APE"
|
||||
},
|
||||
{
|
||||
"address": "0xa2cd3d43c775978a96bdbf12d733d5a1ed94fb18",
|
||||
"coingecko_id": "chain-2",
|
||||
"decimals": 18,
|
||||
"name": "Chain",
|
||||
"shortcut": "XCN"
|
||||
},
|
||||
{
|
||||
"address": "0x853d955acef822db058eb8505911ed77f175b99e",
|
||||
"coingecko_id": "frax",
|
||||
"decimals": 18,
|
||||
"name": "Frax",
|
||||
"shortcut": "FRAX"
|
||||
},
|
||||
{
|
||||
"address": "0x3845badade8e6dff049820680d1f14bd3903a5d0",
|
||||
"coingecko_id": "the-sandbox",
|
||||
"decimals": 18,
|
||||
"name": "The Sandbox",
|
||||
"shortcut": "SAND"
|
||||
},
|
||||
{
|
||||
"address": "0x0f5d2fb29fb7d3cfee444a200298f468908cc942",
|
||||
"coingecko_id": "decentraland",
|
||||
"decimals": 18,
|
||||
"name": "Decentraland",
|
||||
"shortcut": "MANA"
|
||||
},
|
||||
{
|
||||
"address": "0xbb0e17ef65f82ab018d8edd776e8dd940327b28b",
|
||||
"coingecko_id": "axie-infinity",
|
||||
"decimals": 18,
|
||||
"name": "Axie Infinity",
|
||||
"shortcut": "AXS"
|
||||
},
|
||||
{
|
||||
"address": "0x3506424f91fd33084466f402d5d97f05f8e3b4af",
|
||||
"coingecko_id": "chiliz",
|
||||
"decimals": 18,
|
||||
"name": "Chiliz",
|
||||
"shortcut": "CHZ"
|
||||
},
|
||||
{
|
||||
"address": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
|
||||
"coingecko_id": "aave",
|
||||
"decimals": 18,
|
||||
"name": "Aave",
|
||||
"shortcut": "AAVE"
|
||||
},
|
||||
{
|
||||
"address": "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0",
|
||||
"decimals": 18,
|
||||
"name": "EOS",
|
||||
"shortcut": "EOS"
|
||||
}
|
||||
],
|
||||
"56;bnb": [
|
||||
{
|
||||
"address": "0x0eb3a705fc54725037cc9e008bdede697f62f335",
|
||||
"coingecko_id": "cosmos",
|
||||
"decimals": 18,
|
||||
"name": "Cosmos Hub",
|
||||
"shortcut": "ATOM"
|
||||
}
|
||||
],
|
||||
"137;MATIC": [
|
||||
{
|
||||
"address": "0x2c89bbc92bd86f8075d1decc58c7f4e0107f286b",
|
||||
"coingecko_id": "avalanche-2",
|
||||
"decimals": 18,
|
||||
"name": "Avalanche",
|
||||
"shortcut": "AVAX"
|
||||
}
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,331 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fetch information about coins and tokens supported by Trezor and update it in coins_details.json."""
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
import click
|
||||
|
||||
import coin_info
|
||||
import marketcap
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
OPTIONAL_KEYS = ("links", "notes", "wallet")
|
||||
ALLOWED_SUPPORT_STATUS = ("yes", "no")
|
||||
|
||||
WALLETS = coin_info.load_json("wallets.json")
|
||||
OVERRIDES = coin_info.load_json("coins_details.override.json")
|
||||
VERSIONS = coin_info.latest_releases()
|
||||
|
||||
# automatic wallet entries
|
||||
WALLET_SUITE = {"Trezor Suite": "https://suite.trezor.io"}
|
||||
WALLET_NEM = {"Nano Wallet": "https://nemplatform.com/wallets/#desktop"}
|
||||
WALLETS_ETH_3RDPARTY = {
|
||||
"MyEtherWallet": "https://www.myetherwallet.com",
|
||||
"MyCrypto": "https://mycrypto.com",
|
||||
}
|
||||
|
||||
|
||||
TREZOR_KNOWN_URLS = (
|
||||
"https://suite.trezor.io",
|
||||
"https://wallet.trezor.io",
|
||||
)
|
||||
|
||||
|
||||
def update_marketcaps(coins):
|
||||
for coin in coins.values():
|
||||
coin["marketcap_usd"] = marketcap.marketcap(coin) or 0
|
||||
|
||||
|
||||
def summary(coins, api_key):
|
||||
t1_coins = 0
|
||||
t2_coins = 0
|
||||
supported_marketcap = 0
|
||||
for coin in coins.values():
|
||||
if coin.get("hidden"):
|
||||
continue
|
||||
|
||||
t1_enabled = coin["t1_enabled"] == "yes"
|
||||
t2_enabled = coin["t2_enabled"] == "yes"
|
||||
if t1_enabled:
|
||||
t1_coins += 1
|
||||
if t2_enabled:
|
||||
t2_coins += 1
|
||||
if t1_enabled or t2_enabled:
|
||||
supported_marketcap += coin.get("marketcap_usd", 0)
|
||||
|
||||
total_marketcap = None
|
||||
try:
|
||||
ret = marketcap.call("global-metrics/quotes/latest", api_key)
|
||||
total_marketcap = int(ret["data"]["quote"]["USD"]["total_market_cap"])
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
marketcap_percent = 100 * supported_marketcap / total_marketcap
|
||||
return dict(
|
||||
updated_at=int(time.time()),
|
||||
updated_at_readable=time.asctime(),
|
||||
t1_coins=t1_coins,
|
||||
t2_coins=t2_coins,
|
||||
marketcap_usd=supported_marketcap,
|
||||
total_marketcap_usd=total_marketcap,
|
||||
marketcap_supported=f"{marketcap_percent:.02f} %",
|
||||
)
|
||||
|
||||
|
||||
def _is_supported(support, trezor_version):
|
||||
# True or version string means YES
|
||||
# False or None means NO
|
||||
return "yes" if support.get(trezor_version) else "no"
|
||||
|
||||
|
||||
def _suite_support(coin, support):
|
||||
"""Check the "suite" support property.
|
||||
If set, check that at least one of the backends run on trezor.io.
|
||||
If yes, assume we support the coin in our wallet.
|
||||
Otherwise it's probably working with a custom backend, which means don't
|
||||
link to our wallet.
|
||||
"""
|
||||
if not support.get("suite"):
|
||||
return False
|
||||
return any(".trezor.io" in url for url in coin["blockbook"])
|
||||
|
||||
|
||||
def dict_merge(orig, new):
|
||||
if isinstance(new, dict) and isinstance(orig, dict):
|
||||
for k, v in new.items():
|
||||
orig[k] = dict_merge(orig.get(k), v)
|
||||
return orig
|
||||
else:
|
||||
return new
|
||||
|
||||
|
||||
def update_simple(coins, support_info, type):
|
||||
res = {}
|
||||
for coin in coins:
|
||||
key = coin["key"]
|
||||
support = support_info[key]
|
||||
|
||||
details = dict(
|
||||
name=coin["name"],
|
||||
shortcut=coin["shortcut"],
|
||||
type=type,
|
||||
t1_enabled=_is_supported(support, "trezor1"),
|
||||
t2_enabled=_is_supported(support, "trezor2"),
|
||||
wallet={},
|
||||
)
|
||||
for k in OPTIONAL_KEYS:
|
||||
if k in coin:
|
||||
details[k] = coin[k]
|
||||
|
||||
details["wallet"].update(WALLETS.get(key, {}))
|
||||
|
||||
res[key] = details
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def update_bitcoin(coins, support_info):
|
||||
res = update_simple(coins, support_info, "coin")
|
||||
for coin in coins:
|
||||
key = coin["key"]
|
||||
support = support_info[key]
|
||||
details = dict(
|
||||
name=coin["coin_label"],
|
||||
links=dict(Homepage=coin["website"], Github=coin["github"]),
|
||||
wallet=WALLET_SUITE if _suite_support(coin, support) else {},
|
||||
)
|
||||
dict_merge(res[key], details)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def update_erc20(coins, networks, support_info):
|
||||
# TODO skip disabled networks?
|
||||
network_support = {n["chain"]: support_info.get(n["key"]) for n in networks}
|
||||
network_testnets = {n["chain"] for n in networks if "Testnet" in n["name"]}
|
||||
res = update_simple(coins, support_info, "erc20")
|
||||
for coin in coins:
|
||||
key = coin["key"]
|
||||
chain = coin["chain"]
|
||||
|
||||
hidden = False
|
||||
if chain in network_testnets:
|
||||
hidden = True
|
||||
if "deprecation" in coin:
|
||||
hidden = True
|
||||
|
||||
if network_support.get(chain, {}).get("suite"):
|
||||
wallets = WALLET_SUITE
|
||||
else:
|
||||
wallets = WALLETS_ETH_3RDPARTY
|
||||
|
||||
details = dict(
|
||||
network=chain,
|
||||
address=coin["address"],
|
||||
shortcut=coin["shortcut"],
|
||||
links={},
|
||||
wallet=wallets,
|
||||
)
|
||||
if hidden:
|
||||
details["hidden"] = True
|
||||
if coin.get("website"):
|
||||
details["links"]["Homepage"] = coin["website"]
|
||||
if coin.get("social", {}).get("github"):
|
||||
details["links"]["Github"] = coin["social"]["github"]
|
||||
|
||||
dict_merge(res[key], details)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def update_ethereum_networks(coins, support_info):
|
||||
res = update_simple(coins, support_info, "coin")
|
||||
for coin in coins:
|
||||
key = coin["key"]
|
||||
if support_info[key].get("suite"):
|
||||
wallets = WALLET_SUITE
|
||||
else:
|
||||
wallets = WALLETS_ETH_3RDPARTY
|
||||
details = dict(links=dict(Homepage=coin.get("url")), wallet=wallets)
|
||||
dict_merge(res[key], details)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def update_nem_mosaics(coins, support_info):
|
||||
res = update_simple(coins, support_info, "mosaic")
|
||||
for coin in coins:
|
||||
key = coin["key"]
|
||||
details = dict(wallet=WALLET_NEM)
|
||||
dict_merge(res[key], details)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def check_missing_data(coins):
|
||||
for k, coin in coins.items():
|
||||
hide = False
|
||||
|
||||
if "Homepage" not in coin.get("links", {}):
|
||||
level = logging.WARNING
|
||||
if k.startswith("erc20:"):
|
||||
level = logging.INFO
|
||||
LOG.log(level, f"{k}: Missing homepage")
|
||||
hide = True
|
||||
if coin["t1_enabled"] not in ALLOWED_SUPPORT_STATUS:
|
||||
LOG.error(f"{k}: Unknown t1_enabled: {coin['t1_enabled']}")
|
||||
hide = True
|
||||
if coin["t2_enabled"] not in ALLOWED_SUPPORT_STATUS:
|
||||
LOG.error(f"{k}: Unknown t2_enabled: {coin['t2_enabled']}")
|
||||
hide = True
|
||||
|
||||
# check wallets
|
||||
for wallet in coin["wallet"]:
|
||||
name = wallet.get("name")
|
||||
url = wallet.get("url")
|
||||
if not name or not url:
|
||||
LOG.warning(f"{k}: Bad wallet entry")
|
||||
hide = True
|
||||
continue
|
||||
if "trezor" in name.lower() and url not in TREZOR_KNOWN_URLS:
|
||||
LOG.warning(f"{k}: Strange URL for Trezor Wallet")
|
||||
|
||||
if coin["t1_enabled"] == "no" and coin["t2_enabled"] == "no":
|
||||
LOG.info(f"{k}: Coin not enabled on either device")
|
||||
hide = True
|
||||
|
||||
if len(coin.get("wallet", [])) == 0:
|
||||
LOG.debug(f"{k}: Missing wallet")
|
||||
|
||||
if "Testnet" in coin["name"] or "Regtest" in coin["name"]:
|
||||
LOG.debug(f"{k}: Hiding testnet")
|
||||
hide = True
|
||||
|
||||
if not hide and coin.get("hidden"):
|
||||
LOG.info(f"{k}: Details are OK, but coin is still hidden")
|
||||
|
||||
if hide:
|
||||
data = marketcap.get_coin(coin)
|
||||
if data and data["cmc_rank"] < 150 and not coin.get("ignore_cmc_rank"):
|
||||
LOG.warning(f"{k}: Hiding coin ranked {data['cmc_rank']} on CMC")
|
||||
coin["hidden"] = 1
|
||||
|
||||
# summary of hidden coins
|
||||
hidden_coins = [k for k, coin in coins.items() if coin.get("hidden")]
|
||||
for key in hidden_coins:
|
||||
del coins[key]
|
||||
|
||||
|
||||
def apply_overrides(coins):
|
||||
for key, override in OVERRIDES.items():
|
||||
if key not in coins:
|
||||
LOG.warning(f"override without coin: {key}")
|
||||
continue
|
||||
|
||||
dict_merge(coins[key], override)
|
||||
|
||||
|
||||
def finalize_wallets(coins):
|
||||
def sort_key(w):
|
||||
if "trezor.io" in w["url"]:
|
||||
return 0, w["name"]
|
||||
else:
|
||||
return 1, w["name"]
|
||||
|
||||
for coin in coins.values():
|
||||
wallets_list = [
|
||||
dict(name=name, url=url) for name, url in coin["wallet"].items() if url
|
||||
]
|
||||
wallets_list.sort(key=sort_key)
|
||||
coin["wallet"] = wallets_list
|
||||
|
||||
|
||||
@click.command()
|
||||
# fmt: off
|
||||
@click.option("-r", "--refresh", "refresh", flag_value=True, default=None, help="Force refresh market cap info")
|
||||
@click.option("-R", "--no-refresh", "refresh", flag_value=False, default=None, help="Force use cached market cap info")
|
||||
@click.option("-A", "--api-key", required=True, envvar="COINMARKETCAP_API_KEY", help="Coinmarketcap API key")
|
||||
@click.option("-v", "--verbose", is_flag=True, help="Display more info")
|
||||
# fmt: on
|
||||
def main(refresh, api_key, verbose):
|
||||
# setup logging
|
||||
log_level = logging.DEBUG if verbose else logging.WARNING
|
||||
root = logging.getLogger()
|
||||
root.setLevel(log_level)
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
handler.setLevel(log_level)
|
||||
root.addHandler(handler)
|
||||
|
||||
marketcap.init(api_key, refresh=refresh)
|
||||
|
||||
defs, _ = coin_info.coin_info_with_duplicates()
|
||||
support_info = coin_info.support_info(defs)
|
||||
|
||||
coins = {}
|
||||
coins.update(update_bitcoin(defs.bitcoin, support_info))
|
||||
coins.update(update_erc20(defs.erc20, defs.eth, support_info))
|
||||
coins.update(update_ethereum_networks(defs.eth, support_info))
|
||||
coins.update(update_nem_mosaics(defs.nem, support_info))
|
||||
coins.update(update_simple(defs.misc, support_info, "coin"))
|
||||
|
||||
apply_overrides(coins)
|
||||
finalize_wallets(coins)
|
||||
update_marketcaps(coins)
|
||||
|
||||
check_missing_data(coins)
|
||||
|
||||
info = summary(coins, api_key)
|
||||
details = dict(coins=coins, info=info)
|
||||
|
||||
print(json.dumps(info, sort_keys=True, indent=4))
|
||||
with open(os.path.join(coin_info.DEFS_DIR, "coins_details.json"), "w") as f:
|
||||
json.dump(details, f, sort_keys=True, indent=4)
|
||||
f.write("\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import click
|
||||
import requests
|
||||
|
||||
LIVE_URL = "https://trezor.io/static/json/coins_details.json"
|
||||
COINS_DETAILS = os.path.join(
|
||||
os.path.dirname(__file__), "..", "defs", "coins_details.json"
|
||||
)
|
||||
|
||||
|
||||
def diffize_file(coins_details, tmp):
|
||||
coins_list = list(coins_details["coins"].values())
|
||||
for coin in coins_list:
|
||||
coin.pop("marketcap_usd", None)
|
||||
links = coin.get("links", {})
|
||||
wallets = coin.get("wallet", {})
|
||||
for link in links:
|
||||
links[link] = links[link].rstrip("/")
|
||||
for wallet in wallets:
|
||||
wallet["url"] = wallet["url"].rstrip("/")
|
||||
|
||||
if not coin.get("wallet"):
|
||||
coin.pop("wallet", None)
|
||||
|
||||
coins_list.sort(key=lambda c: c["name"])
|
||||
|
||||
for coin in coins_list:
|
||||
name = coin["name"]
|
||||
for key in coin:
|
||||
print(name, "\t", key, ":", coin[key], file=tmp)
|
||||
tmp.flush()
|
||||
|
||||
|
||||
@click.command()
|
||||
def cli():
|
||||
"""Compare data from trezor.io/coins with current coins_details.json
|
||||
|
||||
Shows a nicely formatted diff between the live version and the trezor-common
|
||||
version. Useful for catching auto-generation problems, etc.
|
||||
"""
|
||||
live_json = requests.get(LIVE_URL).json()
|
||||
with open(COINS_DETAILS) as f:
|
||||
coins_details = json.load(f)
|
||||
|
||||
Tmp = tempfile.NamedTemporaryFile
|
||||
with Tmp("w") as tmpA, Tmp("w") as tmpB:
|
||||
diffize_file(live_json, tmpA)
|
||||
diffize_file(coins_details, tmpB)
|
||||
subprocess.call(["diff", "-u", "--color=auto", tmpA.name, tmpB.name])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
Loading…
Reference in new issue