mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 20:38:10 +00:00
src/apps/ethereum: use wire.Error
This commit is contained in:
parent
db696b23fd
commit
0f2ed0f07c
@ -1,6 +1,6 @@
|
||||
from trezor import wire
|
||||
from trezor.messages.EthereumSignTx import EthereumSignTx
|
||||
from trezor.messages.EthereumTxRequest import EthereumTxRequest
|
||||
from trezor.messages import FailureType
|
||||
from trezor.utils import HashWriter
|
||||
from trezor.crypto import rlp
|
||||
from apps.ethereum import tokens
|
||||
@ -124,21 +124,21 @@ def node_derive(root, address_n: list):
|
||||
|
||||
def check(msg: EthereumSignTx):
|
||||
if msg.chain_id < 0 or msg.chain_id > MAX_CHAIN_ID:
|
||||
raise ValueError(FailureType.DataError, 'Chain id out of bounds')
|
||||
raise wire.DataError('Chain id out of bounds')
|
||||
|
||||
if msg.data_length > 0:
|
||||
if not msg.data_initial_chunk:
|
||||
raise ValueError(FailureType.DataError, 'Data length provided, but no initial chunk')
|
||||
raise wire.DataError('Data length provided, but no initial chunk')
|
||||
# Our encoding only supports transactions up to 2^24 bytes. To
|
||||
# prevent exceeding the limit we use a stricter limit on data length.
|
||||
if msg.data_length > 16000000:
|
||||
raise ValueError(FailureType.DataError, 'Data length exceeds limit')
|
||||
raise wire.DataError('Data length exceeds limit')
|
||||
if len(msg.data_initial_chunk) > msg.data_length:
|
||||
raise ValueError(FailureType.DataError, 'Invalid size of initial chunk')
|
||||
raise wire.DataError('Invalid size of initial chunk')
|
||||
|
||||
# safety checks
|
||||
if not check_gas(msg) or not check_to(msg):
|
||||
raise ValueError(FailureType.DataError, 'Safety check failed')
|
||||
raise wire.DataError('Safety check failed')
|
||||
|
||||
|
||||
def check_gas(msg: EthereumSignTx) -> bool:
|
||||
|
Loading…
Reference in New Issue
Block a user