mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 17:42:02 +00:00
chore(core): delete unused code in src
[no changelog]
This commit is contained in:
parent
b08a6fe2c1
commit
428ac8d2ac
@ -212,14 +212,13 @@ class BasicApprover(Approver):
|
||||
async def add_payment_request(
|
||||
self, msg: TxAckPaymentRequest, keychain: Keychain
|
||||
) -> None:
|
||||
from trezor.ui.components.common.confirm import INFO
|
||||
|
||||
await super().add_payment_request(msg, keychain)
|
||||
if msg.amount is None:
|
||||
raise DataError("Missing payment request amount.")
|
||||
|
||||
result = await helpers.confirm_payment_request(msg, self.coin, self.amount_unit)
|
||||
self.show_payment_req_details = result is INFO
|
||||
# When user wants to see more info, the result will be False.
|
||||
self.show_payment_req_details = result is False
|
||||
|
||||
async def approve_orig_txids(
|
||||
self, tx_info: TxInfo, orig_txs: list[OriginalTxInfo]
|
||||
|
@ -14,10 +14,6 @@ if TYPE_CHECKING:
|
||||
Delegations = list[tuple[bytes, int]]
|
||||
GovernanceRegistrationPayload = dict[int, Delegations | bytes | int]
|
||||
SignedGovernanceRegistrationPayload = tuple[GovernanceRegistrationPayload, bytes]
|
||||
GovernanceRegistrationSignature = dict[int, bytes]
|
||||
GovernanceRegistration = dict[
|
||||
int, GovernanceRegistrationPayload | GovernanceRegistrationSignature
|
||||
]
|
||||
|
||||
from trezor import messages
|
||||
from trezor.wire import Context
|
||||
|
@ -31,7 +31,7 @@ class Credential:
|
||||
is_no_staking: bool = False
|
||||
is_mismatch: bool = False
|
||||
is_unusual_path: bool = False
|
||||
is_other_warning: bool = False
|
||||
is_other_warning: bool = False # TODO: this seems to be unused
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -220,10 +220,6 @@ def end_current_session() -> None:
|
||||
_active_session_idx = None
|
||||
|
||||
|
||||
def is_session_started() -> bool:
|
||||
return _active_session_idx is not None
|
||||
|
||||
|
||||
def set(key: int, value: bytes) -> None:
|
||||
if key & _SESSIONLESS_FLAG:
|
||||
_SESSIONLESS_CACHE.set(key ^ _SESSIONLESS_FLAG, value)
|
||||
|
@ -144,10 +144,6 @@ def set_passphrase_enabled(enable: bool) -> None:
|
||||
set_passphrase_always_on_device(False)
|
||||
|
||||
|
||||
def get_homescreen() -> bytes | None:
|
||||
return common.get(_NAMESPACE, _HOMESCREEN, public=True)
|
||||
|
||||
|
||||
def set_homescreen(homescreen: bytes) -> None:
|
||||
if len(homescreen) > HOMESCREEN_MAXSIZE:
|
||||
raise ValueError # homescreen too large
|
||||
|
@ -103,25 +103,6 @@ _SECRET_INDEX = const(255)
|
||||
_DIGEST_INDEX = const(254)
|
||||
"""The index of the share containing the digest of the shared secret."""
|
||||
|
||||
|
||||
# === Keyboard functions ===
|
||||
|
||||
KEYBOARD_FULL_MASK = const(0x1FF)
|
||||
"""All buttons are allowed. 9-bit bitmap all set to 1."""
|
||||
|
||||
|
||||
def word_completion_mask(prefix: str) -> int:
|
||||
if not prefix:
|
||||
return KEYBOARD_FULL_MASK
|
||||
return slip39.word_completion_mask(int(prefix))
|
||||
|
||||
|
||||
def button_sequence_to_word(prefix: str) -> str:
|
||||
if not prefix:
|
||||
return ""
|
||||
return slip39.button_sequence_to_word(int(prefix))
|
||||
|
||||
|
||||
# === External API ===
|
||||
|
||||
MAX_SHARE_COUNT = const(16)
|
||||
|
@ -223,10 +223,6 @@ class Syscall:
|
||||
pass
|
||||
|
||||
|
||||
SLEEP_FOREVER = Syscall()
|
||||
"""Tasks awaiting `SLEEP_FOREVER` will never be resumed."""
|
||||
|
||||
|
||||
class sleep(Syscall):
|
||||
"""Pause current task and resume it after given delay.
|
||||
|
||||
|
@ -136,16 +136,6 @@ def chunks(items: Chunkable, size: int) -> Iterator[Chunkable]:
|
||||
yield items[i : i + size]
|
||||
|
||||
|
||||
def chunks_intersperse(items: str, size: int, sep: str = "\n") -> Iterator[str]:
|
||||
first = True
|
||||
for i in range(0, len(items), size):
|
||||
if not first:
|
||||
yield sep
|
||||
else:
|
||||
first = False
|
||||
yield items[i : i + size]
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
class HashContext(Protocol):
|
||||
|
@ -11,6 +11,11 @@ from apps.base import handle_Initialize, handle_EndSession
|
||||
KEY = 0
|
||||
|
||||
|
||||
# Function moved from cache.py, as it was not used there
|
||||
def is_session_started() -> bool:
|
||||
return cache._active_session_idx is not None
|
||||
|
||||
|
||||
class TestStorageCache(unittest.TestCase):
|
||||
def setUp(self):
|
||||
cache.clear_all()
|
||||
@ -29,15 +34,15 @@ class TestStorageCache(unittest.TestCase):
|
||||
|
||||
def test_end_session(self):
|
||||
session_id = cache.start_session()
|
||||
self.assertTrue(cache.is_session_started())
|
||||
self.assertTrue(is_session_started())
|
||||
cache.set(KEY, b"A")
|
||||
cache.end_current_session()
|
||||
self.assertFalse(cache.is_session_started())
|
||||
self.assertFalse(is_session_started())
|
||||
self.assertRaises(cache.InvalidSessionError, cache.get, KEY)
|
||||
|
||||
# ending an ended session should be a no-op
|
||||
cache.end_current_session()
|
||||
self.assertFalse(cache.is_session_started())
|
||||
self.assertFalse(is_session_started())
|
||||
|
||||
session_id_a = cache.start_session(session_id)
|
||||
# original session no longer exists
|
||||
@ -217,10 +222,10 @@ class TestStorageCache(unittest.TestCase):
|
||||
def test_EndSession(self):
|
||||
self.assertRaises(cache.InvalidSessionError, cache.get, KEY)
|
||||
session_id = cache.start_session()
|
||||
self.assertTrue(cache.is_session_started())
|
||||
self.assertTrue(is_session_started())
|
||||
self.assertIsNone(cache.get(KEY))
|
||||
await_result(handle_EndSession(DUMMY_CONTEXT, EndSession()))
|
||||
self.assertFalse(cache.is_session_started())
|
||||
self.assertFalse(is_session_started())
|
||||
self.assertRaises(cache.InvalidSessionError, cache.get, KEY)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user