mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-17 21:22:10 +00:00
refactor(core/ethereum): rename address.py to helpers.py
This commit is contained in:
parent
9a7e6c2900
commit
b1a3618c17
@ -6,7 +6,7 @@ from trezor.ui.layouts import show_address
|
||||
from apps.common import paths
|
||||
|
||||
from . import networks
|
||||
from .address import address_from_bytes
|
||||
from .helpers import address_from_bytes
|
||||
from .keychain import PATTERNS_ADDRESS, with_keychain_from_path
|
||||
|
||||
if False:
|
||||
|
@ -52,3 +52,4 @@ def bytes_from_address(address: str) -> bytes:
|
||||
return bytes()
|
||||
|
||||
raise wire.ProcessError("Ethereum: Invalid address length")
|
||||
|
@ -7,7 +7,7 @@ from trezor.utils import HashWriter
|
||||
from apps.common import paths
|
||||
from apps.common.signverify import decode_message
|
||||
|
||||
from . import address
|
||||
from .helpers import address_from_bytes
|
||||
from .keychain import PATTERNS_ADDRESS, with_keychain_from_path
|
||||
|
||||
if False:
|
||||
@ -42,6 +42,6 @@ async def sign_message(
|
||||
)
|
||||
|
||||
return EthereumMessageSignature(
|
||||
address=address.address_from_bytes(node.ethereum_pubkeyhash()),
|
||||
address=address_from_bytes(node.ethereum_pubkeyhash()),
|
||||
signature=signature[1:] + bytearray([signature[0]]),
|
||||
)
|
||||
|
@ -7,7 +7,8 @@ from trezor.utils import HashWriter
|
||||
|
||||
from apps.common import paths
|
||||
|
||||
from . import address, tokens
|
||||
from . import tokens
|
||||
from .helpers import bytes_from_address
|
||||
from .keychain import with_keychain_from_chain_id
|
||||
from .layout import (
|
||||
require_confirm_data,
|
||||
@ -96,7 +97,7 @@ async def handle_erc20(
|
||||
ctx: wire.Context, msg: EthereumSignTxAny
|
||||
) -> Tuple[tokens.TokenInfo | None, bytes, bytes, int]:
|
||||
token = None
|
||||
address_bytes = recipient = address.bytes_from_address(msg.to)
|
||||
address_bytes = recipient = bytes_from_address(msg.to)
|
||||
value = int.from_bytes(msg.value, "big")
|
||||
if (
|
||||
len(msg.to) in (40, 42)
|
||||
@ -125,7 +126,7 @@ def get_total_length(msg: EthereumSignTx, data_total: int) -> int:
|
||||
msg.nonce,
|
||||
msg.gas_price,
|
||||
msg.gas_limit,
|
||||
address.bytes_from_address(msg.to),
|
||||
bytes_from_address(msg.to),
|
||||
msg.value,
|
||||
msg.chain_id,
|
||||
0,
|
||||
|
@ -7,7 +7,7 @@ from trezor.utils import HashWriter
|
||||
|
||||
from apps.common import paths
|
||||
|
||||
from . import address
|
||||
from .helpers import bytes_from_address
|
||||
from .keychain import with_keychain_from_chain_id
|
||||
from .layout import (
|
||||
require_confirm_data,
|
||||
@ -27,7 +27,7 @@ TX_TYPE = 2
|
||||
|
||||
|
||||
def access_list_item_length(item: EthereumAccessList) -> int:
|
||||
address_length = rlp.length(address.bytes_from_address(item.address))
|
||||
address_length = rlp.length(bytes_from_address(item.address))
|
||||
keys_length = rlp.length(item.storage_keys)
|
||||
return (
|
||||
rlp.header_length(address_length + keys_length) + address_length + keys_length
|
||||
@ -43,7 +43,7 @@ def write_access_list(w: HashWriter, access_list: list[EthereumAccessList]) -> N
|
||||
payload_length = sum(access_list_item_length(i) for i in access_list)
|
||||
rlp.write_header(w, payload_length, rlp.LIST_HEADER_BYTE)
|
||||
for item in access_list:
|
||||
address_bytes = address.bytes_from_address(item.address)
|
||||
address_bytes = bytes_from_address(item.address)
|
||||
address_length = rlp.length(address_bytes)
|
||||
keys_length = rlp.length(item.storage_keys)
|
||||
rlp.write_header(w, address_length + keys_length, rlp.LIST_HEADER_BYTE)
|
||||
@ -125,7 +125,7 @@ def get_total_length(msg: EthereumSignTxEIP1559, data_total: int) -> int:
|
||||
fields: Tuple[rlp.RLPItem, ...] = (
|
||||
msg.nonce,
|
||||
msg.gas_limit,
|
||||
address.bytes_from_address(msg.to),
|
||||
bytes_from_address(msg.to),
|
||||
msg.value,
|
||||
msg.chain_id,
|
||||
msg.max_gas_fee,
|
||||
|
@ -6,7 +6,7 @@ from trezor.ui.layouts import confirm_signverify
|
||||
|
||||
from apps.common.signverify import decode_message
|
||||
|
||||
from .address import address_from_bytes, bytes_from_address
|
||||
from .helpers import address_from_bytes, bytes_from_address
|
||||
from .sign_message import message_digest
|
||||
|
||||
if False:
|
||||
|
@ -2,7 +2,7 @@ from common import *
|
||||
from apps.common.paths import HARDENED
|
||||
|
||||
if not utils.BITCOIN_ONLY:
|
||||
from apps.ethereum.address import address_from_bytes
|
||||
from apps.ethereum.helpers import address_from_bytes
|
||||
from apps.ethereum.networks import NetworkInfo
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user