mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-19 00:29:03 +00:00
refactor(core): refactor send_request_chunk()
[no changelog]
This commit is contained in:
parent
efd4961f5e
commit
804bb2f549
@ -13,12 +13,7 @@ from .keychain import with_keychain_from_chain_id
|
||||
if TYPE_CHECKING:
|
||||
from typing import Iterable
|
||||
|
||||
from trezor.messages import (
|
||||
EthereumNetworkInfo,
|
||||
EthereumSignTx,
|
||||
EthereumTokenInfo,
|
||||
EthereumTxAck,
|
||||
)
|
||||
from trezor.messages import EthereumNetworkInfo, EthereumSignTx, EthereumTokenInfo
|
||||
|
||||
from apps.common.keychain import Keychain
|
||||
|
||||
@ -97,9 +92,9 @@ async def sign_tx(
|
||||
progress_obj.report(60)
|
||||
|
||||
while data_left > 0:
|
||||
resp = await send_request_chunk(data_left)
|
||||
data_left -= len(resp.data_chunk)
|
||||
sha.extend(resp.data_chunk)
|
||||
data = await send_request_chunk(data_left)
|
||||
data_left -= len(data)
|
||||
sha.extend(data)
|
||||
|
||||
# eip 155 replay protection
|
||||
rlp.write(sha, msg.chain_id)
|
||||
@ -246,14 +241,16 @@ def _get_total_length(msg: EthereumSignTx, data_total: int) -> int:
|
||||
return length
|
||||
|
||||
|
||||
async def send_request_chunk(data_left: int) -> EthereumTxAck:
|
||||
async def send_request_chunk(data_left: int) -> bytes:
|
||||
from trezor.messages import EthereumTxAck
|
||||
from trezor.wire.context import call
|
||||
|
||||
# TODO: layoutProgress ?
|
||||
req = EthereumTxRequest()
|
||||
req.data_length = min(data_left, 1024)
|
||||
return await call(req, EthereumTxAck)
|
||||
resp = await call(req, EthereumTxAck)
|
||||
assert resp.data_chunk is not None
|
||||
return resp.data_chunk
|
||||
|
||||
|
||||
def _sign_digest(
|
||||
|
@ -103,9 +103,9 @@ async def sign_tx_eip1559(
|
||||
sha.extend(data)
|
||||
|
||||
while data_left > 0:
|
||||
resp = await send_request_chunk(data_left)
|
||||
data_left -= len(resp.data_chunk)
|
||||
sha.extend(resp.data_chunk)
|
||||
data_chunk = await send_request_chunk(data_left)
|
||||
data_left -= len(data_chunk)
|
||||
sha.extend(data_chunk)
|
||||
|
||||
# write_access_list
|
||||
payload_length = sum(access_list_item_length(i) for i in msg.access_list)
|
||||
|
Loading…
Reference in New Issue
Block a user