Monero
Classes | Functions | Variables
coin_info Namespace Reference

Classes

class  CoinsInfo
 

Functions

def load_json (path)
 
def check_type (val, types, nullable=False, empty=False, regex=None, choice=None)
 
def check_key (key, types, optional=False, kwargs)
 
def validate_btc (coin)
 
def _load_btc_coins ()
 
def _load_ethereum_networks ()
 
def _load_erc20_tokens ()
 
def _load_nem_mosaics ()
 
def _load_misc ()
 
def _load_fido_apps ()
 
def get_support_data ()
 
def latest_releases ()
 
def is_token (coin)
 
def support_info_single (support_data, coin)
 
def support_info (coins)
 
def _ensure_mandatory_values (coins)
 
def symbol_from_shortcut (shortcut)
 
def mark_duplicate_shortcuts (coins)
 
def deduplicate_erc20 (buckets, networks)
 
def deduplicate_keys (all_coins)
 
def _btc_sort_key (coin)
 
def collect_coin_info ()
 
def sort_coin_infos (all_coins)
 
def coin_info_with_duplicates ()
 
def coin_info ()
 
def fido_info ()
 
def search (coins, keyword)
 

Variables

 requests = None
 
 log = logging.getLogger(__name__)
 
 DEFS_DIR
 
list BTC_CHECKS
 
string RELEASES_URL = "https://beta-wallet.trezor.io/data/firmware/{}/releases.json"
 
tuple MISSING_SUPPORT_MEANS_NO = ("connect", "webwallet")
 
tuple VERSIONED_SUPPORT_INFO = ("trezor1", "trezor2")
 

Function Documentation

◆ _btc_sort_key()

def coin_info._btc_sort_key (   coin)
private

◆ _ensure_mandatory_values()

def coin_info._ensure_mandatory_values (   coins)
private
Checks that every coin has the mandatory fields: name, shortcut, key

◆ _load_btc_coins()

def coin_info._load_btc_coins ( )
private
Load btc-like coins from `bitcoin/*.json`

◆ _load_erc20_tokens()

def coin_info._load_erc20_tokens ( )
private
Load ERC20 tokens from `ethereum/tokens` submodule.

◆ _load_ethereum_networks()

def coin_info._load_ethereum_networks ( )
private
Load ethereum networks from `ethereum/networks.json`

◆ _load_fido_apps()

def coin_info._load_fido_apps ( )
private
Load FIDO apps from `fido/*.json`

◆ _load_misc()

def coin_info._load_misc ( )
private
Loads miscellaneous networks from `misc/misc.json`

◆ _load_nem_mosaics()

def coin_info._load_nem_mosaics ( )
private
Loads NEM mosaics from `nem/nem_mosaics.json`

◆ check_key()

def coin_info.check_key (   key,
  types,
  optional = False,
  kwargs 
)

◆ check_type()

def coin_info.check_type (   val,
  types,
  nullable = False,
  empty = False,
  regex = None,
  choice = None 
)

◆ coin_info()

def coin_info.coin_info ( )
Collects coin info, fills out support info and returns the result.

Does not auto-delete duplicates. This should now be based on support info.

◆ coin_info_with_duplicates()

def coin_info.coin_info_with_duplicates ( )
Collects coin info, detects duplicates but does not remove them.

Returns the CoinsInfo object and duplicate buckets.

◆ collect_coin_info()

def coin_info.collect_coin_info ( )
Returns all definition as dict organized by coin type.
`coins` for btc-like coins,
`eth` for ethereum networks,
`erc20` for ERC20 tokens,
`nem` for NEM mosaics,
`misc` for other networks.

◆ deduplicate_erc20()

def coin_info.deduplicate_erc20 (   buckets,
  networks 
)
Apply further processing to ERC20 duplicate buckets.

This function works on results of `mark_duplicate_shortcuts`.

Buckets that contain at least one non-token are ignored - symbol collisions
with non-tokens always apply.

Otherwise the following rules are applied:

1. If _all tokens_ in the bucket have shortcuts with distinct suffixes, e.g.,
`CAT (BitClave)` and `CAT (Blockcat)`, the bucket is cleared - all are considered
non-duplicate.

(If even one token in the bucket _does not_ have a distinct suffix, e.g.,
`MIT` and `MIT (Mychatcoin)`, this rule does not apply and ALL tokens in the bucket
are still considered duplicate.)

2. If there is only one "main" token in the bucket, the bucket is cleared.
That means that all other tokens must either be on testnets, or they must be marked
as deprecated, with a deprecation pointing to the "main" token.

◆ deduplicate_keys()

def coin_info.deduplicate_keys (   all_coins)

◆ fido_info()

def coin_info.fido_info ( )
Returns info about known FIDO/U2F apps.

◆ get_support_data()

def coin_info.get_support_data ( )
Get raw support data from `support.json`.

◆ is_token()

def coin_info.is_token (   coin)

◆ latest_releases()

def coin_info.latest_releases ( )
Get latest released firmware versions for Trezor 1 and 2

◆ load_json()

def coin_info.load_json (   path)
Convenience function to load a JSON file from DEFS_DIR.

◆ mark_duplicate_shortcuts()

def coin_info.mark_duplicate_shortcuts (   coins)
Finds coins with identical symbols and sets their `duplicate` field.

"Symbol" here means the first part of `shortcut` (separated by space),
so, e.g., "BTL (Battle)" and "BTL (Bitlle)" have the same symbol "BTL".

The result of this function is a dictionary of _buckets_, each of which is
indexed by the duplicated symbol, or `_override`. The `_override` bucket will
contain all coins that are set to `true` in `duplicity_overrides.json`.

Each coin in every bucket will have its "duplicate" property set to True, unless
it's explicitly marked as `false` in `duplicity_overrides.json`.

◆ search()

def coin_info.search (   coins,
  keyword 
)

◆ sort_coin_infos()

def coin_info.sort_coin_infos (   all_coins)

◆ support_info()

def coin_info.support_info (   coins)
Generate Trezor support information.

Takes a collection of coins and generates a support-info entry for each.
The support-info is a dict with keys based on `support.json` keys.
These are usually: "trezor1", "trezor2", "connect" and "webwallet".

The `coins` argument can be a `CoinsInfo` object, a list or a dict of
coin items.

Support information is taken from `support.json`.

◆ support_info_single()

def coin_info.support_info_single (   support_data,
  coin 
)
Extract a support dict from `support.json` data.

Returns a dict of support values for each "device", i.e., `support.json`
top-level key.

The support value for each device is determined in order of priority:
* if the coin is a duplicate ERC20 token, all support values are `None`
* if the coin has an entry in `unsupported`, its support is `None`
* if the coin has an entry in `supported` its support is that entry
  (usually a version string, or `True` for connect/webwallet)
* otherwise support is presumed "soon"

◆ symbol_from_shortcut()

def coin_info.symbol_from_shortcut (   shortcut)

◆ validate_btc()

def coin_info.validate_btc (   coin)

Variable Documentation

◆ BTC_CHECKS

list coin_info.BTC_CHECKS

◆ DEFS_DIR

coin_info.DEFS_DIR
Initial value:
1 = os.path.abspath(
2  os.environ.get("DEFS_DIR") or os.path.join(os.path.dirname(__file__), "..", "defs")
3 )

◆ log

coin_info.log = logging.getLogger(__name__)

◆ MISSING_SUPPORT_MEANS_NO

tuple coin_info.MISSING_SUPPORT_MEANS_NO = ("connect", "webwallet")

◆ RELEASES_URL

string coin_info.RELEASES_URL = "https://beta-wallet.trezor.io/data/firmware/{}/releases.json"

◆ requests

coin_info.requests = None

◆ VERSIONED_SUPPORT_INFO

tuple coin_info.VERSIONED_SUPPORT_INFO = ("trezor1", "trezor2")