mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-09 06:50:58 +00:00
style: skip formatting in special cases
This commit is contained in:
parent
93d1b0751b
commit
6751d84236
@ -45,8 +45,9 @@ class CoinInfo:
|
|||||||
self.sign_hash_double = True
|
self.sign_hash_double = True
|
||||||
|
|
||||||
|
|
||||||
# the following list is generated using tools/codegen/gen_coins.py
|
# generated using tools/codegen/gen_coins.py
|
||||||
# do not edit manually!
|
# do not edit manually!
|
||||||
|
# fmt: off
|
||||||
COINS = [
|
COINS = [
|
||||||
CoinInfo(
|
CoinInfo(
|
||||||
coin_name='Bitcoin',
|
coin_name='Bitcoin',
|
||||||
|
@ -8,6 +8,7 @@ HOMESCREEN_MAXSIZE = 16384
|
|||||||
|
|
||||||
_STORAGE_VERSION = b'\x01'
|
_STORAGE_VERSION = b'\x01'
|
||||||
|
|
||||||
|
# fmt: off
|
||||||
_APP = const(0x01) # app namespace
|
_APP = const(0x01) # app namespace
|
||||||
_DEVICE_ID = const(0x00) # bytes
|
_DEVICE_ID = const(0x00) # bytes
|
||||||
_VERSION = const(0x01) # int
|
_VERSION = const(0x01) # int
|
||||||
@ -22,6 +23,7 @@ _U2F_COUNTER = const(0x09) # int
|
|||||||
_PASSPHRASE_SOURCE = const(0x0A) # int
|
_PASSPHRASE_SOURCE = const(0x0A) # int
|
||||||
_UNFINISHED_BACKUP = const(0x0B) # bool (0x01 or empty)
|
_UNFINISHED_BACKUP = const(0x0B) # bool (0x01 or empty)
|
||||||
_AUTOLOCK_DELAY_MS = const(0x0C) # int
|
_AUTOLOCK_DELAY_MS = const(0x0C) # int
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
def _new_device_id() -> str:
|
def _new_device_id() -> str:
|
||||||
|
@ -1,3 +1,25 @@
|
|||||||
|
def shortcut_by_chain_id(chain_id, tx_type=None):
|
||||||
|
if tx_type in [1, 6] and chain_id in [1, 3]:
|
||||||
|
return 'WAN'
|
||||||
|
else:
|
||||||
|
n = by_chain_id(chain_id)
|
||||||
|
return n.shortcut if n is not None else 'UNKN'
|
||||||
|
|
||||||
|
|
||||||
|
def by_chain_id(chain_id):
|
||||||
|
for n in NETWORKS:
|
||||||
|
if n.chain_id == chain_id:
|
||||||
|
return n
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def by_slip44(slip44):
|
||||||
|
for n in NETWORKS:
|
||||||
|
if n.slip44 == slip44:
|
||||||
|
return n
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class NetworkInfo:
|
class NetworkInfo:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -15,8 +37,9 @@ class NetworkInfo:
|
|||||||
self.rskip60 = rskip60
|
self.rskip60 = rskip60
|
||||||
|
|
||||||
|
|
||||||
# the following list is generated using tools/codegen/gen_eth_networks.py
|
# generated using tools/codegen/gen_eth_networks.py
|
||||||
# do not edit manually!
|
# do not edit manually!
|
||||||
|
# fmt: off
|
||||||
NETWORKS = [
|
NETWORKS = [
|
||||||
NetworkInfo(
|
NetworkInfo(
|
||||||
chain_id=1,
|
chain_id=1,
|
||||||
@ -124,25 +147,3 @@ NETWORKS = [
|
|||||||
rskip60=False,
|
rskip60=False,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def shortcut_by_chain_id(chain_id, tx_type=None):
|
|
||||||
if tx_type in [1, 6] and chain_id in [1, 3]:
|
|
||||||
return 'WAN'
|
|
||||||
else:
|
|
||||||
n = by_chain_id(chain_id)
|
|
||||||
return n.shortcut if n is not None else 'UNKN'
|
|
||||||
|
|
||||||
|
|
||||||
def by_chain_id(chain_id):
|
|
||||||
for n in NETWORKS:
|
|
||||||
if n.chain_id == chain_id:
|
|
||||||
return n
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def by_slip44(slip44):
|
|
||||||
for n in NETWORKS:
|
|
||||||
if n.slip44 == slip44:
|
|
||||||
return n
|
|
||||||
return None
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# isort:skip_file
|
||||||
|
|
||||||
# unlock the device
|
# unlock the device
|
||||||
import boot # noqa: F401
|
import boot # noqa: F401
|
||||||
|
|
||||||
|
@ -1,35 +1,31 @@
|
|||||||
from micropython import const
|
|
||||||
|
|
||||||
import math
|
import math
|
||||||
import utime
|
import utime
|
||||||
|
from micropython import const
|
||||||
from trezorui import Display
|
from trezorui import Display
|
||||||
|
|
||||||
from trezor import io
|
from trezor import io, loop, res, workflow
|
||||||
from trezor import loop
|
|
||||||
from trezor import res
|
|
||||||
from trezor import workflow
|
|
||||||
from trezor.utils import model
|
from trezor.utils import model
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
|
|
||||||
# in debug mode, display an indicator in top right corner
|
# in debug mode, display an indicator in top right corner
|
||||||
if __debug__:
|
if __debug__:
|
||||||
|
|
||||||
def debug_display_refresh():
|
def debug_display_refresh():
|
||||||
display.bar(Display.WIDTH - 8, 0, 8, 8, 0xF800)
|
display.bar(Display.WIDTH - 8, 0, 8, 8, 0xF800)
|
||||||
display.refresh()
|
display.refresh()
|
||||||
|
|
||||||
loop.after_step_hook = debug_display_refresh
|
loop.after_step_hook = debug_display_refresh
|
||||||
|
|
||||||
# in both debug and production, emulator needs to draw the screen explicitly
|
# in both debug and production, emulator needs to draw the screen explicitly
|
||||||
elif model() == 'EMU':
|
elif model() == "EMU":
|
||||||
loop.after_step_hook = display.refresh
|
loop.after_step_hook = display.refresh
|
||||||
|
|
||||||
# import constants from modtrezorui
|
# re-export constants from modtrezorui
|
||||||
|
|
||||||
SIZE = Display.FONT_SIZE
|
|
||||||
NORMAL = Display.FONT_NORMAL
|
NORMAL = Display.FONT_NORMAL
|
||||||
BOLD = Display.FONT_BOLD
|
BOLD = Display.FONT_BOLD
|
||||||
MONO = Display.FONT_MONO
|
MONO = Display.FONT_MONO
|
||||||
|
SIZE = Display.FONT_SIZE
|
||||||
WIDTH = Display.WIDTH
|
WIDTH = Display.WIDTH
|
||||||
HEIGHT = Display.HEIGHT
|
HEIGHT = Display.HEIGHT
|
||||||
|
|
||||||
@ -46,10 +42,12 @@ def blend(ca: int, cb: int, t: float) -> int:
|
|||||||
return rgb(
|
return rgb(
|
||||||
lerpi((ca >> 8) & 0xF8, (cb >> 8) & 0xF8, t),
|
lerpi((ca >> 8) & 0xF8, (cb >> 8) & 0xF8, t),
|
||||||
lerpi((ca >> 3) & 0xFC, (cb >> 3) & 0xFC, t),
|
lerpi((ca >> 3) & 0xFC, (cb >> 3) & 0xFC, t),
|
||||||
lerpi((ca << 3) & 0xF8, (cb << 3) & 0xF8, t))
|
lerpi((ca << 3) & 0xF8, (cb << 3) & 0xF8, t),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
from trezor.ui.style import *
|
# import style definitions
|
||||||
|
from trezor.ui.style import * # isort:skip
|
||||||
|
|
||||||
|
|
||||||
def contains(area: tuple, pos: tuple) -> bool:
|
def contains(area: tuple, pos: tuple) -> bool:
|
||||||
@ -77,7 +75,7 @@ def pulse(delay: int):
|
|||||||
yield 0.5 + 0.5 * math.sin(utime.ticks_us() / delay)
|
yield 0.5 + 0.5 * math.sin(utime.ticks_us() / delay)
|
||||||
|
|
||||||
|
|
||||||
async def alert(count: int=3):
|
async def alert(count: int = 3):
|
||||||
short_sleep = loop.sleep(20000)
|
short_sleep = loop.sleep(20000)
|
||||||
long_sleep = loop.sleep(80000)
|
long_sleep = loop.sleep(80000)
|
||||||
current = display.backlight()
|
current = display.backlight()
|
||||||
@ -104,7 +102,7 @@ async def click() -> tuple:
|
|||||||
return pos
|
return pos
|
||||||
|
|
||||||
|
|
||||||
async def backlight_slide(val: int, delay: int=35000, step: int=20):
|
async def backlight_slide(val: int, delay: int = 35000, step: int = 20):
|
||||||
sleep = loop.sleep(delay)
|
sleep = loop.sleep(delay)
|
||||||
current = display.backlight()
|
current = display.backlight()
|
||||||
for i in range(current, val, -step if current > val else step):
|
for i in range(current, val, -step if current > val else step):
|
||||||
@ -129,11 +127,9 @@ def layout(f):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
def header(title: str,
|
def header(
|
||||||
icon: bytes=ICON_DEFAULT,
|
title: str, icon: bytes = ICON_DEFAULT, fg: int = FG, bg: int = BG, ifg: int = GREEN
|
||||||
fg: int=FG,
|
):
|
||||||
bg: int=BG,
|
|
||||||
ifg: int=GREEN):
|
|
||||||
if icon is not None:
|
if icon is not None:
|
||||||
display.icon(14, 15, res.load(icon), ifg, bg)
|
display.icon(14, 15, res.load(icon), ifg, bg)
|
||||||
display.text(44, 35, title, BOLD, fg, bg)
|
display.text(44, 35, title, BOLD, fg, bg)
|
||||||
@ -143,16 +139,18 @@ VIEWX = const(6)
|
|||||||
VIEWY = const(9)
|
VIEWY = const(9)
|
||||||
|
|
||||||
|
|
||||||
def grid(i: int,
|
def grid(
|
||||||
n_x: int=3,
|
i: int,
|
||||||
n_y: int=5,
|
n_x: int = 3,
|
||||||
start_x: int=VIEWX,
|
n_y: int = 5,
|
||||||
start_y: int=VIEWY,
|
start_x: int = VIEWX,
|
||||||
end_x: int=(WIDTH - VIEWX),
|
start_y: int = VIEWY,
|
||||||
end_y: int=(HEIGHT - VIEWY),
|
end_x: int = (WIDTH - VIEWX),
|
||||||
cells_x: int=1,
|
end_y: int = (HEIGHT - VIEWY),
|
||||||
cells_y: int=1,
|
cells_x: int = 1,
|
||||||
spacing: int=0):
|
cells_y: int = 1,
|
||||||
|
spacing: int = 0,
|
||||||
|
):
|
||||||
w = (end_x - start_x) // n_x
|
w = (end_x - start_x) // n_x
|
||||||
h = (end_y - start_y) // n_y
|
h = (end_y - start_y) // n_y
|
||||||
x = (i % n_x) * w
|
x = (i % n_x) * w
|
||||||
|
@ -2,6 +2,8 @@ from trezor import io
|
|||||||
|
|
||||||
from apps.common.storage import get_device_id
|
from apps.common.storage import get_device_id
|
||||||
|
|
||||||
|
# fmt: off
|
||||||
|
|
||||||
# interface used for trezor wire protocol
|
# interface used for trezor wire protocol
|
||||||
iface_wire = io.WebUSB(
|
iface_wire = io.WebUSB(
|
||||||
iface_num=0,
|
iface_num=0,
|
||||||
|
Loading…
Reference in New Issue
Block a user