|
cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
|
What each selectable asset IS — one row per pos_chain_t. More...
Go to the source code of this file.
Classes | |
| struct | pos_asset_t |
| One selectable asset. More... | |
| struct | pos_net_info_t |
| Names for one network, in both deployments. More... | |
Macros | |
| #define | POS_ASSET_COUNT (sizeof(POS_ASSETS) / sizeof(POS_ASSETS[0])) |
Enumerations | |
| enum | pos_net_t { POS_NET_ETH = 0 , POS_NET_POLY , POS_NET_TRON , POS_NET__COUNT } |
| A network, as the picker's first step offers it. More... | |
| enum | pos_coin_t { POS_COIN_NET = 0 , POS_COIN_USDC , POS_COIN_USDT } |
| Which mark an asset wears. A native coin wears its network's. More... | |
Functions | |
| static const pos_asset_t * | pos_asset_of (pos_chain_t chain) |
The row describing chain. | |
| static pos_net_t | pos_net_of (pos_chain_t chain) |
Which network chain is on. | |
| static bool | pos_chain_is_tron (pos_chain_t c) |
| true for the Tron selections; every other one is EVM. | |
| static bool | pos_chain_is_polygon (pos_chain_t c) |
| true for the Polygon selections. EVM like Ethereum, but its own endpoint, chain id and contracts. | |
| static bool | pos_chain_is_native_evm (pos_chain_t c) |
true for ETH and POL: no contract, the amount goes in value, 21000 gas, 18 decimals. Native TRX is not one — Tron signs on its own path. | |
| static const pos_net_info_t * | pos_net_info (pos_net_t net) |
Names for net, or Ethereum's for a value out of range. | |
Variables | |
| static const pos_asset_t | POS_ASSETS [] |
| static const pos_net_info_t | POS_NETS [POS_NET__COUNT] |
What each selectable asset IS — one row per pos_chain_t.
The nine selections used to be described by four parallel switches in ui.cpp (ticker, network name, address-row caption, icon pair) plus three hand-written picker tables, so adding one asset meant ten coordinated edits and a missed one shipped a row that rendered wrong or named the wrong contract. The facts are data, so they live in a table and the switches became lookups.
The family predicates (pos_chain_is_tron and friends) are derived from it, so which network an asset is on is said once. Deliberately NOT here:
The table is indexed by nothing: it is ordered for the picker — grouped by network, native coin first, exactly as the three tables it replaced were — and looked up by pos_asset_of. test_assets.cpp proves every enumerator appears exactly once, which is the check that makes a table trustworthy in place of ten remembered edit sites.
Definition in file assets.h.
| #define POS_ASSET_COUNT (sizeof(POS_ASSETS) / sizeof(POS_ASSETS[0])) |
Definition at line 127 of file assets.h.
Referenced by open_coin_picker(), and pos_asset_of().
| enum pos_coin_t |
| enum pos_net_t |
|
inlinestatic |
The row describing chain.
Never NULL for a value that came out of settings_get_chain(), which already rejects anything past POS_CHAIN__COUNT — but the fallback is the default asset rather than a NULL a caller has to remember to test, for the same reason settings_get_chain() falls back rather than failing: a terminal that renders the wrong ticker is recoverable, one that dereferences NULL on the amount screen is not.
Definition at line 145 of file assets.h.
References POS_ASSET_COUNT, and POS_ASSETS.
Referenced by active_token(), asset(), evm_balance_ok(), make_asset_badge(), pos_chain_is_native_evm(), pos_net_of(), token_load(), and tron_balance_ok().
|
inlinestatic |
true for ETH and POL: no contract, the amount goes in value, 21000 gas, 18 decimals. Native TRX is not one — Tron signs on its own path.
Definition at line 183 of file assets.h.
References pos_asset_t::native, pos_asset_t::net, pos_asset_of(), and POS_NET_TRON.
Referenced by amount_cents_max(), and chain_is_native_evm().
|
inlinestatic |
true for the Polygon selections. EVM like Ethereum, but its own endpoint, chain id and contracts.
Definition at line 174 of file assets.h.
References pos_net_of(), and POS_NET_POLY.
Referenced by chain_is_polygon(), token_decimals_ok(), and ui_refresh_addresses_for().
|
inlinestatic |
true for the Tron selections; every other one is EVM.
This decides which signing path runs, which payout is spent and which endpoint is called — pinned per enumerator in tests/units/test_chain.cpp.
Definition at line 165 of file assets.h.
References pos_net_of(), and POS_NET_TRON.
Referenced by build_settings(), chain_is_tron(), token_decimals_ok(), token_load(), and ui_refresh_addresses_for().
|
inlinestatic |
Names for net, or Ethereum's for a value out of range.
Definition at line 190 of file assets.h.
References POS_NET__COUNT, POS_NET_ETH, and POS_NETS.
Referenced by asset_network(), open_coin_picker(), open_network_picker(), and token_load().
|
inlinestatic |
Which network chain is on.
Definition at line 154 of file assets.h.
References pos_asset_t::net, and pos_asset_of().
Referenced by pos_chain_is_polygon(), and pos_chain_is_tron().
|
static |
Definition at line 102 of file assets.h.
Referenced by open_coin_picker(), and pos_asset_of().
|
static |
Definition at line 129 of file assets.h.
Referenced by pos_net_info().