refactor(core): do not preallocate known addresses
What changed, and why it matters
This commit is a code cleanup in Trezor's Ethereum app. It replaces a pre-built lookup table of known smart-contract addresses with a generated template and a helper function that searches the same data on demand. The visible behavior—such as which contract names are shown on the device screen—does not appear to change. There is no indication this fixes or introduces a security vulnerability.
No security action required. Treat as a normal maintainability refactor; verify generated output matches the template if reviewing build reproducibility.
Security signals we found
No change to address/chain-id matching logic
No new untrusted input parsing
No memory-unsafe operations introduced
Refactor motivated by flash-size savings, not a vulnerability fix
Evidence from the diff
The change refactors core/src/apps/ethereum/sc_constants.py so that the KNOWN_ADDRESSES dictionary is no longer preallocated at import time. Instead, a Mako template (sc_constants.py.mako) generates a generator-based _known_address_iterator() and a lookup_known_address(chain_id, address) helper. Callers in clear_signing.py and clear_signing_definitions.py now use the helper. WETH deployments are also de-duplicated by sharing weth_deployments() between the known-address list and the WETH display-format context. The data set (addresses, chain IDs, and labels) is preserved, and the lookup semantics remain equivalent. No security-relevant logic change is visible in the diff.
Changed components
core/src/apps/ethereum/sc_constants.pycore/src/apps/ethereum/sc_constants.py.makocore/src/apps/ethereum/clear_signing.pycore/src/apps/ethereum/clear_signing_definitions.pyInspect captured patch +226 / −145
diff --git a/core/src/apps/ethereum/clear_signing.py b/core/src/apps/ethereum/clear_signing.py
index 3aa1a58b..25b11dd8 100644
--- a/core/src/apps/ethereum/clear_signing.py
+++ b/core/src/apps/ethereum/clear_signing.py
@@ -1096,7 +1096,7 @@ async def _handle_approve(
fee_items: Iterable[StrPropertyType],
) -> None:
from .layout import require_confirm_approve
- from .sc_constants import KNOWN_ADDRESSES
+ from .sc_constants import lookup_known_address
from .yielding_vaults import UNKNOWN_VAULT, lookup_vault
# approve() is not payable; surface any native ETH sent along with it.
@@ -1127,7 +1127,7 @@ async def _handle_approve(
assert isinstance(arg1_raw_value, int)
- recipient_str = KNOWN_ADDRESSES.get((msg.chain_id, arg0_raw_value))
+ recipient_str = lookup_known_address(msg.chain_id, arg0_raw_value)
if recipient_str is None:
vault = lookup_vault(defs.network, arg0_raw_value)
if vault is not UNKNOWN_VAULT:
@@ -1237,7 +1237,7 @@ async def _handle_generic_ui(
from . import tokens
from .helpers import bytes_from_address
from .layout import require_confirm_clear_signing
- from .sc_constants import KNOWN_ADDRESSES
+ from .sc_constants import lookup_known_address
# Surface the native ETH value in the summary when non-zero - unless the
# display format already renders it as an `AmountFormatter` field (e.g. a
@@ -1274,8 +1274,8 @@ async def _handle_generic_ui(
)
properties_to_confirm.append(token_address_property)
- recipient_str = KNOWN_ADDRESSES.get(
- (msg.chain_id, bytes_from_address(msg.to)), msg.to
+ recipient_str = (
+ lookup_known_address(msg.chain_id, bytes_from_address(msg.to)) or msg.to
)
await require_confirm_clear_signing(
diff --git a/core/src/apps/ethereum/clear_signing_definitions.py b/core/src/apps/ethereum/clear_signing_definitions.py
index 26d42665..b09ae49d 100644
--- a/core/src/apps/ethereum/clear_signing_definitions.py
+++ b/core/src/apps/ethereum/clear_signing_definitions.py
@@ -760,40 +760,10 @@ def all_display_formats() -> Generator[DisplayFormat, None, None]:
# currency formatter: deposit() wraps the transaction value into WETH and
# withdraw(wad) unwraps the same amount of WETH back to the native currency.
# https://github.com/trezor/trezor-firmware/issues/7252
- WETH_DEPLOYMENTS = [
- # https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- (
- 1,
- b"\xc0\x2a\xaa\x39\xb2\x23\xfe\x8d\x0a\x0e\x5c\x4f\x27\xea\xd9\x08\x3c\x75\x6c\xc2",
- ),
- # https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000006
- (
- 10,
- b"\x42\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06",
- ),
- # https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
- (
- 42161,
- b"\x82\xaf\x49\x44\x7d\x8a\x07\xe3\xbd\x95\xbd\x0d\x56\xf3\x52\x41\x52\x3f\xba\xb1",
- ),
- # https://basescan.org/address/0x4200000000000000000000000000000000000006
- (
- 8453,
- b"\x42\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06",
- ),
- # https://sepolia.etherscan.io/address/0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9
- (
- 11155111,
- b"\x7b\x79\x99\x5e\x5f\x79\x3a\x07\xbc\x00\xc2\x14\x12\xe5\x0e\xca\xe0\x98\xe7\xf9",
- ),
- # https://holesky.etherscan.io/address/0x94373a4919B3240D86eA41593D5eBa789FEF3848
- (
- 17000,
- b"\x94\x37\x3a\x49\x19\xb3\x24\x0d\x86\xea\x41\x59\x3d\x5e\xba\x78\x9f\xef\x38\x48",
- ),
- ]
+ # The deployments list is generated from `sc_constants.py.mako`.
+ from .sc_constants import weth_deployments
- WETH_CONTEXT = BindingContext(WETH_DEPLOYMENTS)
+ WETH_CONTEXT = BindingContext(tuple(weth_deployments()))
yield DisplayFormat(
binding_context=WETH_CONTEXT,
diff --git a/core/src/apps/ethereum/sc_constants.py b/core/src/apps/ethereum/sc_constants.py
index f885b995..9aa49766 100644
--- a/core/src/apps/ethereum/sc_constants.py
+++ b/core/src/apps/ethereum/sc_constants.py
@@ -1,109 +1,73 @@
-from ubinascii import unhexlify
+# generated from sc_constants.py.mako
+# (by running `make templates` in `core`)
+# do not edit manually!
+# fmt: off
-KNOWN_ADDRESSES = {
- # https://github.com/LedgerHQ/clear-signing-erc7730-registry/blob/master/registry/1inch/calldata-AggregationRouterV6.json#L9
- (
- 1,
- unhexlify("111111125421cA6dc452d289314280a0f8842A65"),
- ): "1inch Aggregation Router V6",
- # https://github.com/LedgerHQ/clear-signing-erc7730-registry/blob/master/registry/lifi/calldata-LIFIDiamond.json
- (1, unhexlify("1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE")): "LiFI Diamond",
- # https://github.com/LedgerHQ/clear-signing-erc7730-registry/blob/master/registry/uniswap/calldata-UniswapV3Router02.json#L6
- (1, unhexlify("68b3465833fb72A70ecDF485E0e4C7bD8665Fc45")): "Uniswap V3 Router",
- # https://etherscan.io/address/0xe592427a0aece92de3edee1f18e0157c05861564
- (1, unhexlify("e592427a0aece92de3edee1f18e0157c05861564")): "Uniswap V3 Router",
- # Lido
- # https://etherscan.io/address/0x889edc2edab5f40e902b864ad4d7ade8e412f9b1
- (1, unhexlify("889edc2edab5f40e902b864ad4d7ade8e412f9b1")): "Lido",
- # https://etherscan.io/address/0xae7ab96520de3a18e5e111b5eaab095312d7fe84
- (1, unhexlify("ae7ab96520de3a18e5e111b5eaab095312d7fe84")): "Lido",
- # https://etherscan.io/address/0xa88f0329c2c4ce51ba3fc619bbf44efe7120dd0d
- (1, unhexlify("a88f0329c2c4ce51ba3fc619bbf44efe7120dd0d")): "Lido",
- # https://etherscan.io/address/0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0
- (1, unhexlify("7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0")): "Lido",
- # Morpho
- # https://etherscan.io/address/0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb
- (1, unhexlify("bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb")): "Morpho",
- # https://basescan.org/address/0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb
- (8453, unhexlify("bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb")): "Morpho",
- # https://etherscan.io/address/0x6566194141eefa99af43bb5aa71460ca2dc90245
- (1, unhexlify("6566194141eefa99af43bb5aa71460ca2dc90245")): "Morpho",
- # https://basescan.org/address/0x6bfd8137e702540e7a42b74178a4a49ba43920c4
- (8453, unhexlify("6bfd8137e702540e7a42b74178a4a49ba43920c4")): "Morpho",
- # Kiln
- # https://etherscan.io/address/0x576834cb068e677db4aff6ca245c7bde16c3867e
- (1, unhexlify("576834cb068e677db4aff6ca245c7bde16c3867e")): "Kiln",
- # https://etherscan.io/address/0x004c226fff73aa94b78a4df1a0e861797ba16819
- (1, unhexlify("004c226fff73aa94b78a4df1a0e861797ba16819")): "Kiln",
- # Missing account tag on ethscan. But contract deployer is tagged as Kiln.
- # Fresh high value transactions.
- # https://etherscan.io/address/0x8659eeff31cfcff580d37af8e7af250f8998aa83
- (1, unhexlify("8659eeff31cfcff580d37af8e7af250f8998aa83")): "Kiln",
- # Ethena
- # https://etherscan.io/address/0x9d39a5de30e57443bff2a8307a4256c8797a3497
- (1, unhexlify("9d39a5de30e57443bff2a8307a4256c8797a3497")): "Ethena",
- # StarkGate
- # https://etherscan.io/address/0xce5485cfb26914c5dce00b9baf0580364dafc7a4
- (1, unhexlify("ce5485cfb26914c5dce00b9baf0580364dafc7a4")): "StarkGate",
- # WalletConnect
- # https://optimistic.etherscan.io/address/0x521b4c065bbdbe3e20b3727340730936912dfa46
- (10, unhexlify("521b4c065bbdbe3e20b3727340730936912dfa46")): "WalletConnect",
- # https://optimistic.etherscan.io/address/0xef4461891dfb3ac8572ccf7c794664a8dd927945
- (10, unhexlify("ef4461891dfb3ac8572ccf7c794664a8dd927945")): "WalletConnect",
- # https://etherscan.io/address/0xef4461891dfb3ac8572ccf7c794664a8dd927945
- (1, unhexlify("ef4461891dfb3ac8572ccf7c794664a8dd927945")): "WalletConnect",
- # https://basescan.org/address/0xef4461891dfb3ac8572ccf7c794664a8dd927945
- (8453, unhexlify("ef4461891dfb3ac8572ccf7c794664a8dd927945")): "WalletConnect",
- # Core Stake
- # https://scan.coredao.org/address/0x0000000000000000000000000000000000001011
- (1116, unhexlify("0000000000000000000000000000000000001011")): "Core Stake",
- # https://scan.coredao.org/address/0x0000000000000000000000000000000000001010
- (1116, unhexlify("0000000000000000000000000000000000001010")): "Core Stake",
- # WETH (Wrapped Ether) - canonical contracts, see clear_signing_definitions.py
- # https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- (1, unhexlify("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")): "WETH",
- # https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000006
- (10, unhexlify("4200000000000000000000000000000000000006")): "WETH",
- # https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
- (42161, unhexlify("82aF49447D8a07e3bd95BD0d56f35241523fBab1")): "WETH",
- # https://basescan.org/address/0x4200000000000000000000000000000000000006
- (8453, unhexlify("4200000000000000000000000000000000000006")): "WETH",
- # https://sepolia.etherscan.io/address/0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9
- (11155111, unhexlify("7b79995e5f793A07Bc00c21412e50Ecae098E7f9")): "WETH",
- # https://holesky.etherscan.io/address/0x94373a4919B3240D86eA41593D5eBa789FEF3848
- (17000, unhexlify("94373a4919B3240D86eA41593D5eBa789FEF3848")): "WETH",
- # yield.xyz
- # https://etherscan.io/address/0xb929b89153fc2eed442e81e5a1add4e2fa39028f
- (1, unhexlify("b929b89153fc2eed442e81e5a1add4e2fa39028f")): "yield.xyz",
- # https://etherscan.io/address/0x56d783ca8e0b998c57a428bf1c26a8baca50524e
- (1, unhexlify("56d783ca8e0b998c57a428bf1c26a8baca50524e")): "yield.xyz",
- # https://etherscan.io/address/0x857679d69fe50e7b722f94acd2629d80c355163d
- (1, unhexlify("857679d69fe50e7b722f94acd2629d80c355163d")): "yield.xyz",
- # https://etherscan.io/address/0xf30cf4ed712d3734161fdaab5b1dbb49fd2d0e5c
- (1, unhexlify("f30cf4ed712d3734161fdaab5b1dbb49fd2d0e5c")): "yield.xyz",
- # https://etherscan.io/address/0x5a10de50160126a5f936506bd342c541ac44e943
- (1, unhexlify("5a10de50160126a5f936506bd342c541ac44e943")): "yield.xyz",
- # https://etherscan.io/address/0x35b1ca0f398905cf752e6fe122b51c88022fca32
- (1, unhexlify("35b1ca0f398905cf752e6fe122b51c88022fca32")): "yield.xyz",
- # https://etherscan.io/address/0xd9e6987d77bf2c6d0647b8181fd68a259f838c36
- (1, unhexlify("d9e6987d77bf2c6d0647b8181fd68a259f838c36")): "yield.xyz",
- # https://etherscan.io/address/0xd14a87025109013b0a2354a775cb335f926af65a
- (1, unhexlify("d14a87025109013b0a2354a775cb335f926af65a")): "yield.xyz",
- # https://etherscan.io/address/0xa6e768fef2d1af36c0cfdb276422e7881a83e951
- (1, unhexlify("a6e768fef2d1af36c0cfdb276422e7881a83e951")): "yield.xyz",
- # https://etherscan.io/address/0x467585aaea860f9d8b3b43bb994e4da8a93788a7
- (1, unhexlify("467585aaea860f9d8b3b43bb994e4da8a93788a7")): "yield.xyz",
- # https://etherscan.io/address/0x06998af8f39ff8630d1fb515d22781da4dc2ca71
- (1, unhexlify("06998af8f39ff8630d1fb515d22781da4dc2ca71")): "yield.xyz",
- # https://etherscan.io/address/0x875e901465a639f2e71fcfc10f426ed32f5a909a
- (1, unhexlify("875e901465a639f2e71fcfc10f426ed32f5a909a")): "yield.xyz",
- # https://etherscan.io/address/0x2905b3387c9550ea57fa3ee7d4b7e5abf3acd3d2
- (1, unhexlify("2905b3387c9550ea57fa3ee7d4b7e5abf3acd3d2")): "yield.xyz",
- # https://etherscan.io/address/0x15c2b3adca66e26b6f230b4023f52a285b7f9995
- (1, unhexlify("15c2b3adca66e26b6f230b4023f52a285b7f9995")): "yield.xyz",
-}
+from typing import Iterator
-if __debug__:
- KNOWN_ADDRESSES[(1, unhexlify("dddddddddddddddddddddddddddddddddddddddd"))] = (
- "Trezor Test. DO NOT USE"
- )
+
+def lookup_known_address(chain_id: int, address: bytes) -> str | None:
+ """Return a human-readable name of a well-known smart contract,
+ or `None` if the address is not known.
+ """
+ for known_chain_id, known_address, name in _known_address_iterator():
+ if chain_id == known_chain_id and address == known_address:
+ return name
+ return None
+
+
+def _known_address_iterator() -> Iterator[tuple[int, bytes, str]]:
+ # NOTE: implementing the `_known_address_iterator` as a generator instead of an if-tree of `return` statements saves flash size (Same trick as in `apps.ethereum.tokens`.)
+
+ yield (1, b"\x11\x11\x11\x12\x54\x21\xca\x6d\xc4\x52\xd2\x89\x31\x42\x80\xa0\xf8\x84\x2a\x65", "1inch Aggregation Router V6")
+ yield (1, b"\x12\x31\xde\xb6\xf5\x74\x9e\xf6\xce\x69\x43\xa2\x75\xa1\xd3\xe7\x48\x6f\x4e\xae", "LiFI Diamond")
+ yield (1, b"\x68\xb3\x46\x58\x33\xfb\x72\xa7\x0e\xcd\xf4\x85\xe0\xe4\xc7\xbd\x86\x65\xfc\x45", "Uniswap V3 Router")
+ yield (1, b"\xe5\x92\x42\x7a\x0a\xec\xe9\x2d\xe3\xed\xee\x1f\x18\xe0\x15\x7c\x05\x86\x15\x64", "Uniswap V3 Router")
+ yield (1, b"\x88\x9e\xdc\x2e\xda\xb5\xf4\x0e\x90\x2b\x86\x4a\xd4\xd7\xad\xe8\xe4\x12\xf9\xb1", "Lido")
+ yield (1, b"\xae\x7a\xb9\x65\x20\xde\x3a\x18\xe5\xe1\x11\xb5\xea\xab\x09\x53\x12\xd7\xfe\x84", "Lido")
+ yield (1, b"\xa8\x8f\x03\x29\xc2\xc4\xce\x51\xba\x3f\xc6\x19\xbb\xf4\x4e\xfe\x71\x20\xdd\x0d", "Lido")
+ yield (1, b"\x7f\x39\xc5\x81\xf5\x95\xb5\x3c\x5c\xb1\x9b\xd0\xb3\xf8\xda\x6c\x93\x5e\x2c\xa0", "Lido")
+ yield (1, b"\xbb\xbb\xbb\xbb\xbb\x9c\xc5\xe9\x0e\x3b\x3a\xf6\x4b\xda\xf6\x2c\x37\xee\xff\xcb", "Morpho")
+ yield (8453, b"\xbb\xbb\xbb\xbb\xbb\x9c\xc5\xe9\x0e\x3b\x3a\xf6\x4b\xda\xf6\x2c\x37\xee\xff\xcb", "Morpho")
+ yield (1, b"\x65\x66\x19\x41\x41\xee\xfa\x99\xaf\x43\xbb\x5a\xa7\x14\x60\xca\x2d\xc9\x02\x45", "Morpho")
+ yield (8453, b"\x6b\xfd\x81\x37\xe7\x02\x54\x0e\x7a\x42\xb7\x41\x78\xa4\xa4\x9b\xa4\x39\x20\xc4", "Morpho")
+ yield (1, b"\x57\x68\x34\xcb\x06\x8e\x67\x7d\xb4\xaf\xf6\xca\x24\x5c\x7b\xde\x16\xc3\x86\x7e", "Kiln")
+ yield (1, b"\x00\x4c\x22\x6f\xff\x73\xaa\x94\xb7\x8a\x4d\xf1\xa0\xe8\x61\x79\x7b\xa1\x68\x19", "Kiln")
+ yield (1, b"\x86\x59\xee\xff\x31\xcf\xcf\xf5\x80\xd3\x7a\xf8\xe7\xaf\x25\x0f\x89\x98\xaa\x83", "Kiln")
+ yield (1, b"\x9d\x39\xa5\xde\x30\xe5\x74\x43\xbf\xf2\xa8\x30\x7a\x42\x56\xc8\x79\x7a\x34\x97", "Ethena")
+ yield (1, b"\xce\x54\x85\xcf\xb2\x69\x14\xc5\xdc\xe0\x0b\x9b\xaf\x05\x80\x36\x4d\xaf\xc7\xa4", "StarkGate")
+ yield (10, b"\x52\x1b\x4c\x06\x5b\xbd\xbe\x3e\x20\xb3\x72\x73\x40\x73\x09\x36\x91\x2d\xfa\x46", "WalletConnect")
+ yield (10, b"\xef\x44\x61\x89\x1d\xfb\x3a\xc8\x57\x2c\xcf\x7c\x79\x46\x64\xa8\xdd\x92\x79\x45", "WalletConnect")
+ yield (1, b"\xef\x44\x61\x89\x1d\xfb\x3a\xc8\x57\x2c\xcf\x7c\x79\x46\x64\xa8\xdd\x92\x79\x45", "WalletConnect")
+ yield (8453, b"\xef\x44\x61\x89\x1d\xfb\x3a\xc8\x57\x2c\xcf\x7c\x79\x46\x64\xa8\xdd\x92\x79\x45", "WalletConnect")
+ yield (1116, b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x11", "Core Stake")
+ yield (1116, b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10", "Core Stake")
+ yield (1, b"\xb9\x29\xb8\x91\x53\xfc\x2e\xed\x44\x2e\x81\xe5\xa1\xad\xd4\xe2\xfa\x39\x02\x8f", "yield.xyz")
+ yield (1, b"\x56\xd7\x83\xca\x8e\x0b\x99\x8c\x57\xa4\x28\xbf\x1c\x26\xa8\xba\xca\x50\x52\x4e", "yield.xyz")
+ yield (1, b"\x85\x76\x79\xd6\x9f\xe5\x0e\x7b\x72\x2f\x94\xac\xd2\x62\x9d\x80\xc3\x55\x16\x3d", "yield.xyz")
+ yield (1, b"\xf3\x0c\xf4\xed\x71\x2d\x37\x34\x16\x1f\xda\xab\x5b\x1d\xbb\x49\xfd\x2d\x0e\x5c", "yield.xyz")
+ yield (1, b"\x5a\x10\xde\x50\x16\x01\x26\xa5\xf9\x36\x50\x6b\xd3\x42\xc5\x41\xac\x44\xe9\x43", "yield.xyz")
+ yield (1, b"\x35\xb1\xca\x0f\x39\x89\x05\xcf\x75\x2e\x6f\xe1\x22\xb5\x1c\x88\x02\x2f\xca\x32", "yield.xyz")
+ yield (1, b"\xd9\xe6\x98\x7d\x77\xbf\x2c\x6d\x06\x47\xb8\x18\x1f\xd6\x8a\x25\x9f\x83\x8c\x36", "yield.xyz")
+ yield (1, b"\xd1\x4a\x87\x02\x51\x09\x01\x3b\x0a\x23\x54\xa7\x75\xcb\x33\x5f\x92\x6a\xf6\x5a", "yield.xyz")
+ yield (1, b"\xa6\xe7\x68\xfe\xf2\xd1\xaf\x36\xc0\xcf\xdb\x27\x64\x22\xe7\x88\x1a\x83\xe9\x51", "yield.xyz")
+ yield (1, b"\x46\x75\x85\xaa\xea\x86\x0f\x9d\x8b\x3b\x43\xbb\x99\x4e\x4d\xa8\xa9\x37\x88\xa7", "yield.xyz")
+ yield (1, b"\x06\x99\x8a\xf8\xf3\x9f\xf8\x63\x0d\x1f\xb5\x15\xd2\x27\x81\xda\x4d\xc2\xca\x71", "yield.xyz")
+ yield (1, b"\x87\x5e\x90\x14\x65\xa6\x39\xf2\xe7\x1f\xcf\xc1\x0f\x42\x6e\xd3\x2f\x5a\x90\x9a", "yield.xyz")
+ yield (1, b"\x29\x05\xb3\x38\x7c\x95\x50\xea\x57\xfa\x3e\xe7\xd4\xb7\xe5\xab\xf3\xac\xd3\xd2", "yield.xyz")
+ yield (1, b"\x15\xc2\xb3\xad\xca\x66\xe2\x6b\x6f\x23\x0b\x40\x23\xf5\x2a\x28\x5b\x7f\x99\x95", "yield.xyz")
+ for chain_id, addr in weth_deployments():
+ yield (chain_id, addr, "WETH")
+
+ if __debug__:
+ yield (1, b"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", "Trezor Test. DO NOT USE")
+
+
+def weth_deployments() -> Iterator[tuple[int, bytes]]:
+ """Canonical WETH (Wrapped Ether) contract deployments: (chain_id, address)."""
+ yield (1, b"\xc0\x2a\xaa\x39\xb2\x23\xfe\x8d\x0a\x0e\x5c\x4f\x27\xea\xd9\x08\x3c\x75\x6c\xc2")
+ yield (10, b"\x42\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06")
+ yield (42161, b"\x82\xaf\x49\x44\x7d\x8a\x07\xe3\xbd\x95\xbd\x0d\x56\xf3\x52\x41\x52\x3f\xba\xb1")
+ yield (8453, b"\x42\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06")
+ yield (11155111, b"\x7b\x79\x99\x5e\x5f\x79\x3a\x07\xbc\x00\xc2\x14\x12\xe5\x0e\xca\xe0\x98\xe7\xf9")
+ yield (17000, b"\x94\x37\x3a\x49\x19\xb3\x24\x0d\x86\xea\x41\x59\x3d\x5e\xba\x78\x9f\xef\x38\x48")
diff --git a/core/src/apps/ethereum/sc_constants.py.mako b/core/src/apps/ethereum/sc_constants.py.mako
new file mode 100644
index 00000000..281423fe
--- /dev/null
+++ b/core/src/apps/ethereum/sc_constants.py.mako
@@ -0,0 +1,147 @@
+# generated from ${THIS_FILE.name}
+# (by running `make templates` in `core`)
+# do not edit manually!
+# fmt: off
+
+from typing import Iterator
+<%
+from binascii import unhexlify
+
+def fmt_addr(addr_hex: str) -> str:
+ data = "".join(f'\\x{b:02x}' for b in unhexlify(addr_hex))
+ return f'b"{data}"'
+
+
+KNOWN_ADDRESSES = [
+ # https://github.com/LedgerHQ/clear-signing-erc7730-registry/blob/master/registry/1inch/calldata-AggregationRouterV6.json#L9
+ (1, "111111125421cA6dc452d289314280a0f8842A65", "1inch Aggregation Router V6"),
+ # https://github.com/LedgerHQ/clear-signing-erc7730-registry/blob/master/registry/lifi/calldata-LIFIDiamond.json
+ (1, "1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE", "LiFI Diamond"),
+ # https://github.com/LedgerHQ/clear-signing-erc7730-registry/blob/master/registry/uniswap/calldata-UniswapV3Router02.json#L6
+ (1, "68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", "Uniswap V3 Router"),
+ # https://etherscan.io/address/0xe592427a0aece92de3edee1f18e0157c05861564
+ (1, "e592427a0aece92de3edee1f18e0157c05861564", "Uniswap V3 Router"),
+ # Lido
+ # https://etherscan.io/address/0x889edc2edab5f40e902b864ad4d7ade8e412f9b1
+ (1, "889edc2edab5f40e902b864ad4d7ade8e412f9b1", "Lido"),
+ # https://etherscan.io/address/0xae7ab96520de3a18e5e111b5eaab095312d7fe84
+ (1, "ae7ab96520de3a18e5e111b5eaab095312d7fe84", "Lido"),
+ # https://etherscan.io/address/0xa88f0329c2c4ce51ba3fc619bbf44efe7120dd0d
+ (1, "a88f0329c2c4ce51ba3fc619bbf44efe7120dd0d", "Lido"),
+ # https://etherscan.io/address/0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0
+ (1, "7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0", "Lido"),
+ # Morpho
+ # https://etherscan.io/address/0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb
+ (1, "bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb", "Morpho"),
+ # https://basescan.org/address/0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb
+ (8453, "bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb", "Morpho"),
+ # https://etherscan.io/address/0x6566194141eefa99af43bb5aa71460ca2dc90245
+ (1, "6566194141eefa99af43bb5aa71460ca2dc90245", "Morpho"),
+ # https://basescan.org/address/0x6bfd8137e702540e7a42b74178a4a49ba43920c4
+ (8453, "6bfd8137e702540e7a42b74178a4a49ba43920c4", "Morpho"),
+ # Kiln
+ # https://etherscan.io/address/0x576834cb068e677db4aff6ca245c7bde16c3867e
+ (1, "576834cb068e677db4aff6ca245c7bde16c3867e", "Kiln"),
+ # https://etherscan.io/address/0x004c226fff73aa94b78a4df1a0e861797ba16819
+ (1, "004c226fff73aa94b78a4df1a0e861797ba16819", "Kiln"),
+ # Missing account tag on ethscan. But contract deployer is tagged as Kiln.
+ # Fresh high value transactions.
+ # https://etherscan.io/address/0x8659eeff31cfcff580d37af8e7af250f8998aa83
+ (1, "8659eeff31cfcff580d37af8e7af250f8998aa83", "Kiln"),
+ # Ethena
+ # https://etherscan.io/address/0x9d39a5de30e57443bff2a8307a4256c8797a3497
+ (1, "9d39a5de30e57443bff2a8307a4256c8797a3497", "Ethena"),
+ # StarkGate
+ # https://etherscan.io/address/0xce5485cfb26914c5dce00b9baf0580364dafc7a4
+ (1, "ce5485cfb26914c5dce00b9baf0580364dafc7a4", "StarkGate"),
+ # WalletConnect
+ # https://optimistic.etherscan.io/address/0x521b4c065bbdbe3e20b3727340730936912dfa46
+ (10, "521b4c065bbdbe3e20b3727340730936912dfa46", "WalletConnect"),
+ # https://optimistic.etherscan.io/address/0xef4461891dfb3ac8572ccf7c794664a8dd927945
+ (10, "ef4461891dfb3ac8572ccf7c794664a8dd927945", "WalletConnect"),
+ # https://etherscan.io/address/0xef4461891dfb3ac8572ccf7c794664a8dd927945
+ (1, "ef4461891dfb3ac8572ccf7c794664a8dd927945", "WalletConnect"),
+ # https://basescan.org/address/0xef4461891dfb3ac8572ccf7c794664a8dd927945
+ (8453, "ef4461891dfb3ac8572ccf7c794664a8dd927945", "WalletConnect"),
+ # Core Stake
+ # https://scan.coredao.org/address/0x0000000000000000000000000000000000001011
+ (1116, "0000000000000000000000000000000000001011", "Core Stake"),
+ # https://scan.coredao.org/address/0x0000000000000000000000000000000000001010
+ (1116, "0000000000000000000000000000000000001010", "Core Stake"),
+ # yield.xyz
+ # https://etherscan.io/address/0xb929b89153fc2eed442e81e5a1add4e2fa39028f
+ (1, "b929b89153fc2eed442e81e5a1add4e2fa39028f", "yield.xyz"),
+ # https://etherscan.io/address/0x56d783ca8e0b998c57a428bf1c26a8baca50524e
+ (1, "56d783ca8e0b998c57a428bf1c26a8baca50524e", "yield.xyz"),
+ # https://etherscan.io/address/0x857679d69fe50e7b722f94acd2629d80c355163d
+ (1, "857679d69fe50e7b722f94acd2629d80c355163d", "yield.xyz"),
+ # https://etherscan.io/address/0xf30cf4ed712d3734161fdaab5b1dbb49fd2d0e5c
+ (1, "f30cf4ed712d3734161fdaab5b1dbb49fd2d0e5c", "yield.xyz"),
+ # https://etherscan.io/address/0x5a10de50160126a5f936506bd342c541ac44e943
+ (1, "5a10de50160126a5f936506bd342c541ac44e943", "yield.xyz"),
+ # https://etherscan.io/address/0x35b1ca0f398905cf752e6fe122b51c88022fca32
+ (1, "35b1ca0f398905cf752e6fe122b51c88022fca32", "yield.xyz"),
+ # https://etherscan.io/address/0xd9e6987d77bf2c6d0647b8181fd68a259f838c36
+ (1, "d9e6987d77bf2c6d0647b8181fd68a259f838c36", "yield.xyz"),
+ # https://etherscan.io/address/0xd14a87025109013b0a2354a775cb335f926af65a
+ (1, "d14a87025109013b0a2354a775cb335f926af65a", "yield.xyz"),
+ # https://etherscan.io/address/0xa6e768fef2d1af36c0cfdb276422e7881a83e951
+ (1, "a6e768fef2d1af36c0cfdb276422e7881a83e951", "yield.xyz"),
+ # https://etherscan.io/address/0x467585aaea860f9d8b3b43bb994e4da8a93788a7
+ (1, "467585aaea860f9d8b3b43bb994e4da8a93788a7", "yield.xyz"),
+ # https://etherscan.io/address/0x06998af8f39ff8630d1fb515d22781da4dc2ca71
+ (1, "06998af8f39ff8630d1fb515d22781da4dc2ca71", "yield.xyz"),
+ # https://etherscan.io/address/0x875e901465a639f2e71fcfc10f426ed32f5a909a
+ (1, "875e901465a639f2e71fcfc10f426ed32f5a909a", "yield.xyz"),
+ # https://etherscan.io/address/0x2905b3387c9550ea57fa3ee7d4b7e5abf3acd3d2
+ (1, "2905b3387c9550ea57fa3ee7d4b7e5abf3acd3d2", "yield.xyz"),
+ # https://etherscan.io/address/0x15c2b3adca66e26b6f230b4023f52a285b7f9995
+ (1, "15c2b3adca66e26b6f230b4023f52a285b7f9995", "yield.xyz"),
+]
+
+# Canonical WETH (Wrapped Ether) contracts holding the chain's native currency.
+WETH_DEPLOYMENTS = [
+ # https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
+ (1, "C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
+ # https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000006
+ (10, "4200000000000000000000000000000000000006"),
+ # https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
+ (42161, "82aF49447D8a07e3bd95BD0d56f35241523fBab1"),
+ # https://basescan.org/address/0x4200000000000000000000000000000000000006
+ (8453, "4200000000000000000000000000000000000006"),
+ # https://sepolia.etherscan.io/address/0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9
+ (11155111, "7b79995e5f793A07Bc00c21412e50Ecae098E7f9"),
+ # https://holesky.etherscan.io/address/0x94373a4919B3240D86eA41593D5eBa789FEF3848
+ (17000, "94373a4919B3240D86eA41593D5eBa789FEF3848"),
+]
+
+%>
+
+def lookup_known_address(chain_id: int, address: bytes) -> str | None:
+ """Return a human-readable name of a well-known smart contract,
+ or `None` if the address is not known.
+ """
+ for known_chain_id, known_address, name in _known_address_iterator():
+ if chain_id == known_chain_id and address == known_address:
+ return name
+ return None
+
+
+def _known_address_iterator() -> Iterator[tuple[int, bytes, str]]:
+ # NOTE: implementing the `_known_address_iterator` as a generator instead of an if-tree of `return` statements saves flash size (Same trick as in `apps.ethereum.tokens`.)
+
+% for chain_id, addr, name in KNOWN_ADDRESSES:
+ yield (${chain_id}, ${fmt_addr(addr)}, "${name}")
+% endfor
+ for chain_id, addr in weth_deployments():
+ yield (chain_id, addr, "WETH")
+
+ if __debug__:
+ yield (1, ${fmt_addr("dddddddddddddddddddddddddddddddddddddddd")}, "Trezor Test. DO NOT USE")
+
+
+def weth_deployments() -> Iterator[tuple[int, bytes]]:
+ """Canonical WETH (Wrapped Ether) contract deployments: (chain_id, address)."""
+% for chain_id, addr in WETH_DEPLOYMENTS:
+ yield (${chain_id}, ${fmt_addr(addr)})
+% endfor
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.