diff --git a/Makefile b/Makefile index a371b14c22..5dcee7bc32 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,9 @@ test: ## run unit tests testpy: ## run selected unit tests from python-trezor cd tests ; ./run_tests_python_trezor.sh +pylint: ## run pylint on application sources + pylint --rcfile=pylint.rc -E $(shell find src -name *.py) + ## build commands: build: build_boardloader build_bootloader build_firmware build_unix build_cross ## build all diff --git a/mocks/micropython.py b/mocks/micropython.py index 436f58cb2b..0fac10569a 100644 --- a/mocks/micropython.py +++ b/mocks/micropython.py @@ -1,5 +1,5 @@ def const(c): - pass + return c def mem_info(verbose=None): pass diff --git a/mocks/ubinascii.py b/mocks/ubinascii.py index 79280af45d..7dd47dc54e 100644 --- a/mocks/ubinascii.py +++ b/mocks/ubinascii.py @@ -1,11 +1,14 @@ def hexlify(data, sep=None): - pass + return 0 def unhexlify(data): - pass + return 0 def a2b_base64(data): - pass + return 0 def b2a_base64(data): - pass + return 0 + +def crc32(data, crc=None): + return 0 diff --git a/mocks/uctypes.py b/mocks/uctypes.py new file mode 100644 index 0000000000..dac719a6d8 --- /dev/null +++ b/mocks/uctypes.py @@ -0,0 +1,37 @@ +ARRAY = 0 +NATIVE = 0 +LITTLE_ENDIAN = 0 +BIG_ENDIAN = 0 +VOID = 0 +UINT8 = 0 +INT8 = 0 +UINT16 = 0 +INT16 = 0 +UINT32 = 0 +INT32 = 0 +UINT64 = 0 +INT64 = 0 +BFUINT8 = 0 +BFINT8 = 0 +BFUINT16 = 0 +BFINT16 = 0 +BFUINT32 = 0 +BFINT32 = 0 +BF_POS = 0 +BF_LEN = 0 +FLOAT32 = 0 + +def struct(addr, descriptor, layout_type=NATIVE): + return 0 + +def sizeof(struct): + return 0 + +def addressof(obj): + return 0 + +def bytes_at(addr, size): + return 0 + +def bytearray_at(addr, size): + return 0 diff --git a/mocks/ustruct.py b/mocks/ustruct.py index aae1e50ff5..d98dff1796 100644 --- a/mocks/ustruct.py +++ b/mocks/ustruct.py @@ -1,14 +1,14 @@ def calcsize(fmt): - pass + return 0 def pack(fmt, *args): - pass + return 0 def pack_info(fmt, buffer, offset, *args): - pass + return 0 def unpack(fmt, data): - pass + return 0 def unpack_from(fmt, data, offset=0): - pass + return 0 diff --git a/mocks/utime.py b/mocks/utime.py index ad30d7cf78..66c2c48cfc 100644 --- a/mocks/utime.py +++ b/mocks/utime.py @@ -1,11 +1,11 @@ def localtime(secs=None): - pass + return 0 def ticks_ms(): - pass + return 0 def mktime(): - pass + return 0 def sleep(seconds): pass @@ -17,16 +17,19 @@ def sleep_us(us): pass def ticks_ms(): - pass + return 0 def ticks_us(): - pass + return 0 def ticks_cpu(): - pass + return 0 + +def ticks_add(ticks_in, delta_in): + return 0 def ticks_diff(old, new): - pass + return 0 def time(): - pass + return 0 diff --git a/pylint.rc b/pylint.rc new file mode 100644 index 0000000000..44ad8e37cb --- /dev/null +++ b/pylint.rc @@ -0,0 +1,2 @@ +[MASTER] +init-hook='sys.path.insert(0, "mocks")' diff --git a/src/apps/fido_u2f/__init__.py b/src/apps/fido_u2f/__init__.py index 4354203fa4..c3d5107d9d 100644 --- a/src/apps/fido_u2f/__init__.py +++ b/src/apps/fido_u2f/__init__.py @@ -1,3 +1,5 @@ +from micropython import const + import uctypes import ustruct import utime diff --git a/src/main.py b/src/main.py index 0bc5100e2e..a1537964f4 100644 --- a/src/main.py +++ b/src/main.py @@ -1,3 +1,5 @@ +from micropython import const + import trezor.main from trezor import msg from trezor import ui diff --git a/src/trezor/messages/Address.py b/src/trezor/messages/Address.py index fc361ab865..5ba296d0ab 100644 --- a/src/trezor/messages/Address.py +++ b/src/trezor/messages/Address.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class Address(p.MessageType): diff --git a/src/trezor/messages/ApplySettings.py b/src/trezor/messages/ApplySettings.py index 83a85e539d..9c47fff330 100644 --- a/src/trezor/messages/ApplySettings.py +++ b/src/trezor/messages/ApplySettings.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class ApplySettings(p.MessageType): diff --git a/src/trezor/messages/ButtonAck.py b/src/trezor/messages/ButtonAck.py index f09c192e54..0d13f1b1b7 100644 --- a/src/trezor/messages/ButtonAck.py +++ b/src/trezor/messages/ButtonAck.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class ButtonAck(p.MessageType): diff --git a/src/trezor/messages/ButtonRequest.py b/src/trezor/messages/ButtonRequest.py index 07a1ebc3e3..a53d781f8b 100644 --- a/src/trezor/messages/ButtonRequest.py +++ b/src/trezor/messages/ButtonRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class ButtonRequest(p.MessageType): diff --git a/src/trezor/messages/ButtonRequestType.py b/src/trezor/messages/ButtonRequestType.py index 779d4f63d6..f6b799d4c3 100644 --- a/src/trezor/messages/ButtonRequestType.py +++ b/src/trezor/messages/ButtonRequestType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + Other = const(1) FeeOverThreshold = const(2) ConfirmOutput = const(3) diff --git a/src/trezor/messages/Cancel.py b/src/trezor/messages/Cancel.py index bf2aa32e08..cb7bf9e166 100644 --- a/src/trezor/messages/Cancel.py +++ b/src/trezor/messages/Cancel.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class Cancel(p.MessageType): diff --git a/src/trezor/messages/ChangePin.py b/src/trezor/messages/ChangePin.py index fd6e37795d..4201251ae4 100644 --- a/src/trezor/messages/ChangePin.py +++ b/src/trezor/messages/ChangePin.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class ChangePin(p.MessageType): diff --git a/src/trezor/messages/CipherKeyValue.py b/src/trezor/messages/CipherKeyValue.py index 58fa5debb8..762cf65f54 100644 --- a/src/trezor/messages/CipherKeyValue.py +++ b/src/trezor/messages/CipherKeyValue.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class CipherKeyValue(p.MessageType): diff --git a/src/trezor/messages/CipheredKeyValue.py b/src/trezor/messages/CipheredKeyValue.py index b4dfeeb781..ec4edc43ba 100644 --- a/src/trezor/messages/CipheredKeyValue.py +++ b/src/trezor/messages/CipheredKeyValue.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class CipheredKeyValue(p.MessageType): diff --git a/src/trezor/messages/ClearSession.py b/src/trezor/messages/ClearSession.py index 84fa334589..338c75ffe5 100644 --- a/src/trezor/messages/ClearSession.py +++ b/src/trezor/messages/ClearSession.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class ClearSession(p.MessageType): diff --git a/src/trezor/messages/CoinType.py b/src/trezor/messages/CoinType.py index 079fe5ff8d..ce7b95979c 100644 --- a/src/trezor/messages/CoinType.py +++ b/src/trezor/messages/CoinType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class CoinType(p.MessageType): diff --git a/src/trezor/messages/DebugLinkDecision.py b/src/trezor/messages/DebugLinkDecision.py index e57d513a3e..6257cabd3d 100644 --- a/src/trezor/messages/DebugLinkDecision.py +++ b/src/trezor/messages/DebugLinkDecision.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkDecision(p.MessageType): diff --git a/src/trezor/messages/DebugLinkFlashErase.py b/src/trezor/messages/DebugLinkFlashErase.py index f66d051836..9a7409a8b1 100644 --- a/src/trezor/messages/DebugLinkFlashErase.py +++ b/src/trezor/messages/DebugLinkFlashErase.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkFlashErase(p.MessageType): diff --git a/src/trezor/messages/DebugLinkGetState.py b/src/trezor/messages/DebugLinkGetState.py index 007e3a8ccd..8acabc81a0 100644 --- a/src/trezor/messages/DebugLinkGetState.py +++ b/src/trezor/messages/DebugLinkGetState.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkGetState(p.MessageType): diff --git a/src/trezor/messages/DebugLinkLog.py b/src/trezor/messages/DebugLinkLog.py index 3740807088..35a3f25235 100644 --- a/src/trezor/messages/DebugLinkLog.py +++ b/src/trezor/messages/DebugLinkLog.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkLog(p.MessageType): diff --git a/src/trezor/messages/DebugLinkMemory.py b/src/trezor/messages/DebugLinkMemory.py index 1f6efabcf7..2757d2fb3a 100644 --- a/src/trezor/messages/DebugLinkMemory.py +++ b/src/trezor/messages/DebugLinkMemory.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkMemory(p.MessageType): diff --git a/src/trezor/messages/DebugLinkMemoryRead.py b/src/trezor/messages/DebugLinkMemoryRead.py index 39179a1b09..27805c9c79 100644 --- a/src/trezor/messages/DebugLinkMemoryRead.py +++ b/src/trezor/messages/DebugLinkMemoryRead.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkMemoryRead(p.MessageType): diff --git a/src/trezor/messages/DebugLinkMemoryWrite.py b/src/trezor/messages/DebugLinkMemoryWrite.py index c53de2a598..bb525fbffd 100644 --- a/src/trezor/messages/DebugLinkMemoryWrite.py +++ b/src/trezor/messages/DebugLinkMemoryWrite.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkMemoryWrite(p.MessageType): diff --git a/src/trezor/messages/DebugLinkState.py b/src/trezor/messages/DebugLinkState.py index 8adf128bf7..a2e265d452 100644 --- a/src/trezor/messages/DebugLinkState.py +++ b/src/trezor/messages/DebugLinkState.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .HDNodeType import HDNodeType diff --git a/src/trezor/messages/DebugLinkStop.py b/src/trezor/messages/DebugLinkStop.py index 92e37c82d8..e113cdf583 100644 --- a/src/trezor/messages/DebugLinkStop.py +++ b/src/trezor/messages/DebugLinkStop.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DebugLinkStop(p.MessageType): diff --git a/src/trezor/messages/DecryptMessage.py b/src/trezor/messages/DecryptMessage.py index 5ef7baf1c5..09e7c53ccc 100644 --- a/src/trezor/messages/DecryptMessage.py +++ b/src/trezor/messages/DecryptMessage.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DecryptMessage(p.MessageType): diff --git a/src/trezor/messages/DecryptedMessage.py b/src/trezor/messages/DecryptedMessage.py index cdc5823104..4217b3be70 100644 --- a/src/trezor/messages/DecryptedMessage.py +++ b/src/trezor/messages/DecryptedMessage.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class DecryptedMessage(p.MessageType): diff --git a/src/trezor/messages/ECDHSessionKey.py b/src/trezor/messages/ECDHSessionKey.py index 61af6e4986..a30cafe1b8 100644 --- a/src/trezor/messages/ECDHSessionKey.py +++ b/src/trezor/messages/ECDHSessionKey.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class ECDHSessionKey(p.MessageType): diff --git a/src/trezor/messages/EncryptMessage.py b/src/trezor/messages/EncryptMessage.py index 3d8ea3ced5..0b0a97e9d0 100644 --- a/src/trezor/messages/EncryptMessage.py +++ b/src/trezor/messages/EncryptMessage.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EncryptMessage(p.MessageType): diff --git a/src/trezor/messages/EncryptedMessage.py b/src/trezor/messages/EncryptedMessage.py index c26c51df71..79802d13cf 100644 --- a/src/trezor/messages/EncryptedMessage.py +++ b/src/trezor/messages/EncryptedMessage.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EncryptedMessage(p.MessageType): diff --git a/src/trezor/messages/Entropy.py b/src/trezor/messages/Entropy.py index b8cc4405c6..1f56df2396 100644 --- a/src/trezor/messages/Entropy.py +++ b/src/trezor/messages/Entropy.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class Entropy(p.MessageType): diff --git a/src/trezor/messages/EntropyAck.py b/src/trezor/messages/EntropyAck.py index 1183271f30..ccdb015133 100644 --- a/src/trezor/messages/EntropyAck.py +++ b/src/trezor/messages/EntropyAck.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EntropyAck(p.MessageType): diff --git a/src/trezor/messages/EntropyRequest.py b/src/trezor/messages/EntropyRequest.py index 3990dd7157..176f603224 100644 --- a/src/trezor/messages/EntropyRequest.py +++ b/src/trezor/messages/EntropyRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EntropyRequest(p.MessageType): diff --git a/src/trezor/messages/EstimateTxSize.py b/src/trezor/messages/EstimateTxSize.py index 6cb000d25e..4272bef9dd 100644 --- a/src/trezor/messages/EstimateTxSize.py +++ b/src/trezor/messages/EstimateTxSize.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EstimateTxSize(p.MessageType): diff --git a/src/trezor/messages/EthereumAddress.py b/src/trezor/messages/EthereumAddress.py index 7e8dc27bc3..c41a1c2b62 100644 --- a/src/trezor/messages/EthereumAddress.py +++ b/src/trezor/messages/EthereumAddress.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EthereumAddress(p.MessageType): diff --git a/src/trezor/messages/EthereumGetAddress.py b/src/trezor/messages/EthereumGetAddress.py index c6c0e669d2..fb454bed3e 100644 --- a/src/trezor/messages/EthereumGetAddress.py +++ b/src/trezor/messages/EthereumGetAddress.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EthereumGetAddress(p.MessageType): diff --git a/src/trezor/messages/EthereumSignTx.py b/src/trezor/messages/EthereumSignTx.py index 17d65ce45d..2703337d38 100644 --- a/src/trezor/messages/EthereumSignTx.py +++ b/src/trezor/messages/EthereumSignTx.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EthereumSignTx(p.MessageType): diff --git a/src/trezor/messages/EthereumTxAck.py b/src/trezor/messages/EthereumTxAck.py index 5c9683d35f..67705ef401 100644 --- a/src/trezor/messages/EthereumTxAck.py +++ b/src/trezor/messages/EthereumTxAck.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EthereumTxAck(p.MessageType): diff --git a/src/trezor/messages/EthereumTxRequest.py b/src/trezor/messages/EthereumTxRequest.py index 7e07a95dee..37d7008d7f 100644 --- a/src/trezor/messages/EthereumTxRequest.py +++ b/src/trezor/messages/EthereumTxRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class EthereumTxRequest(p.MessageType): diff --git a/src/trezor/messages/Failure.py b/src/trezor/messages/Failure.py index 97e8d2a1fa..19118310db 100644 --- a/src/trezor/messages/Failure.py +++ b/src/trezor/messages/Failure.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class Failure(p.MessageType): diff --git a/src/trezor/messages/FailureType.py b/src/trezor/messages/FailureType.py index d0eca25907..6955a9680f 100644 --- a/src/trezor/messages/FailureType.py +++ b/src/trezor/messages/FailureType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + UnexpectedMessage = const(1) ButtonExpected = const(2) SyntaxError = const(3) diff --git a/src/trezor/messages/Features.py b/src/trezor/messages/Features.py index 865166b05f..e86b471321 100644 --- a/src/trezor/messages/Features.py +++ b/src/trezor/messages/Features.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .CoinType import CoinType diff --git a/src/trezor/messages/FirmwareErase.py b/src/trezor/messages/FirmwareErase.py index 903bc7c464..a0c036e8d8 100644 --- a/src/trezor/messages/FirmwareErase.py +++ b/src/trezor/messages/FirmwareErase.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class FirmwareErase(p.MessageType): diff --git a/src/trezor/messages/FirmwareRequest.py b/src/trezor/messages/FirmwareRequest.py index 8a8c9a61fd..bb1f65d390 100644 --- a/src/trezor/messages/FirmwareRequest.py +++ b/src/trezor/messages/FirmwareRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class FirmwareRequest(p.MessageType): diff --git a/src/trezor/messages/FirmwareUpload.py b/src/trezor/messages/FirmwareUpload.py index aaa4f31e30..ae37d13a90 100644 --- a/src/trezor/messages/FirmwareUpload.py +++ b/src/trezor/messages/FirmwareUpload.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class FirmwareUpload(p.MessageType): diff --git a/src/trezor/messages/GetAddress.py b/src/trezor/messages/GetAddress.py index b94f0da592..82fcbd8721 100644 --- a/src/trezor/messages/GetAddress.py +++ b/src/trezor/messages/GetAddress.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .MultisigRedeemScriptType import MultisigRedeemScriptType diff --git a/src/trezor/messages/GetECDHSessionKey.py b/src/trezor/messages/GetECDHSessionKey.py index 650b667785..e3c8dab4e1 100644 --- a/src/trezor/messages/GetECDHSessionKey.py +++ b/src/trezor/messages/GetECDHSessionKey.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .IdentityType import IdentityType diff --git a/src/trezor/messages/GetEntropy.py b/src/trezor/messages/GetEntropy.py index aa5634f8fa..ff6f9ea1c6 100644 --- a/src/trezor/messages/GetEntropy.py +++ b/src/trezor/messages/GetEntropy.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class GetEntropy(p.MessageType): diff --git a/src/trezor/messages/GetFeatures.py b/src/trezor/messages/GetFeatures.py index d351cc6b17..2648583ef1 100644 --- a/src/trezor/messages/GetFeatures.py +++ b/src/trezor/messages/GetFeatures.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class GetFeatures(p.MessageType): diff --git a/src/trezor/messages/GetPublicKey.py b/src/trezor/messages/GetPublicKey.py index e37fa5c3a6..5904134fd4 100644 --- a/src/trezor/messages/GetPublicKey.py +++ b/src/trezor/messages/GetPublicKey.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class GetPublicKey(p.MessageType): diff --git a/src/trezor/messages/HDNodePathType.py b/src/trezor/messages/HDNodePathType.py index fb835c640d..1068b0c210 100644 --- a/src/trezor/messages/HDNodePathType.py +++ b/src/trezor/messages/HDNodePathType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .HDNodeType import HDNodeType diff --git a/src/trezor/messages/HDNodeType.py b/src/trezor/messages/HDNodeType.py index 89fe224ccb..7789098363 100644 --- a/src/trezor/messages/HDNodeType.py +++ b/src/trezor/messages/HDNodeType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class HDNodeType(p.MessageType): diff --git a/src/trezor/messages/IdentityType.py b/src/trezor/messages/IdentityType.py index b628c29aaa..0455a145dc 100644 --- a/src/trezor/messages/IdentityType.py +++ b/src/trezor/messages/IdentityType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class IdentityType(p.MessageType): diff --git a/src/trezor/messages/Initialize.py b/src/trezor/messages/Initialize.py index 808c03c44b..0c4cb1492d 100644 --- a/src/trezor/messages/Initialize.py +++ b/src/trezor/messages/Initialize.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class Initialize(p.MessageType): diff --git a/src/trezor/messages/InputScriptType.py b/src/trezor/messages/InputScriptType.py index 9e3907ecea..954b7aae27 100644 --- a/src/trezor/messages/InputScriptType.py +++ b/src/trezor/messages/InputScriptType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + SPENDADDRESS = const(0) SPENDMULTISIG = const(1) EXTERNAL = const(2) diff --git a/src/trezor/messages/LoadDevice.py b/src/trezor/messages/LoadDevice.py index 63bef4e914..2f272b9bad 100644 --- a/src/trezor/messages/LoadDevice.py +++ b/src/trezor/messages/LoadDevice.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .HDNodeType import HDNodeType diff --git a/src/trezor/messages/MessageSignature.py b/src/trezor/messages/MessageSignature.py index 7dcd376e6a..3c6c7f01bd 100644 --- a/src/trezor/messages/MessageSignature.py +++ b/src/trezor/messages/MessageSignature.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class MessageSignature(p.MessageType): diff --git a/src/trezor/messages/MessageType.py b/src/trezor/messages/MessageType.py index 927f5a0ef1..6870942695 100644 --- a/src/trezor/messages/MessageType.py +++ b/src/trezor/messages/MessageType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + Initialize = const(0) Ping = const(1) Success = const(2) diff --git a/src/trezor/messages/MultisigRedeemScriptType.py b/src/trezor/messages/MultisigRedeemScriptType.py index fe56d291c5..c06f0a6e6b 100644 --- a/src/trezor/messages/MultisigRedeemScriptType.py +++ b/src/trezor/messages/MultisigRedeemScriptType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .HDNodePathType import HDNodePathType diff --git a/src/trezor/messages/OutputScriptType.py b/src/trezor/messages/OutputScriptType.py index 4551a68af3..5b0f1d2839 100644 --- a/src/trezor/messages/OutputScriptType.py +++ b/src/trezor/messages/OutputScriptType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + PAYTOADDRESS = const(0) PAYTOSCRIPTHASH = const(1) PAYTOMULTISIG = const(2) diff --git a/src/trezor/messages/PassphraseAck.py b/src/trezor/messages/PassphraseAck.py index 759a21cca0..db33e825ba 100644 --- a/src/trezor/messages/PassphraseAck.py +++ b/src/trezor/messages/PassphraseAck.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class PassphraseAck(p.MessageType): diff --git a/src/trezor/messages/PassphraseRequest.py b/src/trezor/messages/PassphraseRequest.py index e973e24710..7d3976b773 100644 --- a/src/trezor/messages/PassphraseRequest.py +++ b/src/trezor/messages/PassphraseRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class PassphraseRequest(p.MessageType): diff --git a/src/trezor/messages/PinMatrixAck.py b/src/trezor/messages/PinMatrixAck.py index 8032777a78..db318827ea 100644 --- a/src/trezor/messages/PinMatrixAck.py +++ b/src/trezor/messages/PinMatrixAck.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class PinMatrixAck(p.MessageType): diff --git a/src/trezor/messages/PinMatrixRequest.py b/src/trezor/messages/PinMatrixRequest.py index 58f7b8031c..8a7399110f 100644 --- a/src/trezor/messages/PinMatrixRequest.py +++ b/src/trezor/messages/PinMatrixRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class PinMatrixRequest(p.MessageType): diff --git a/src/trezor/messages/PinMatrixRequestType.py b/src/trezor/messages/PinMatrixRequestType.py index 2fba5c9072..9380b49b00 100644 --- a/src/trezor/messages/PinMatrixRequestType.py +++ b/src/trezor/messages/PinMatrixRequestType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + Current = const(1) NewFirst = const(2) NewSecond = const(3) diff --git a/src/trezor/messages/Ping.py b/src/trezor/messages/Ping.py index 883723217a..6ee6be7e48 100644 --- a/src/trezor/messages/Ping.py +++ b/src/trezor/messages/Ping.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class Ping(p.MessageType): diff --git a/src/trezor/messages/PublicKey.py b/src/trezor/messages/PublicKey.py index 4b91d6cf95..98f81d4004 100644 --- a/src/trezor/messages/PublicKey.py +++ b/src/trezor/messages/PublicKey.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .HDNodeType import HDNodeType diff --git a/src/trezor/messages/RecoveryDevice.py b/src/trezor/messages/RecoveryDevice.py index f0d07d0525..7706ca762d 100644 --- a/src/trezor/messages/RecoveryDevice.py +++ b/src/trezor/messages/RecoveryDevice.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class RecoveryDevice(p.MessageType): diff --git a/src/trezor/messages/RecoveryDeviceType.py b/src/trezor/messages/RecoveryDeviceType.py index 0223a03ff2..0416a4d014 100644 --- a/src/trezor/messages/RecoveryDeviceType.py +++ b/src/trezor/messages/RecoveryDeviceType.py @@ -1,3 +1,5 @@ # Automatically generated by pb2py +from micropython import const + ScrambledWords = const(0) Matrix = const(1) diff --git a/src/trezor/messages/RequestType.py b/src/trezor/messages/RequestType.py index 3140f308fe..4ce14db44d 100644 --- a/src/trezor/messages/RequestType.py +++ b/src/trezor/messages/RequestType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + TXINPUT = const(0) TXOUTPUT = const(1) TXMETA = const(2) diff --git a/src/trezor/messages/ResetDevice.py b/src/trezor/messages/ResetDevice.py index fca19d50b0..81bce11caa 100644 --- a/src/trezor/messages/ResetDevice.py +++ b/src/trezor/messages/ResetDevice.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class ResetDevice(p.MessageType): diff --git a/src/trezor/messages/SetU2FCounter.py b/src/trezor/messages/SetU2FCounter.py index cb5e0392a8..d72a3ce44d 100644 --- a/src/trezor/messages/SetU2FCounter.py +++ b/src/trezor/messages/SetU2FCounter.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class SetU2FCounter(p.MessageType): diff --git a/src/trezor/messages/SignIdentity.py b/src/trezor/messages/SignIdentity.py index 55b01b95ae..63620c632f 100644 --- a/src/trezor/messages/SignIdentity.py +++ b/src/trezor/messages/SignIdentity.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .IdentityType import IdentityType diff --git a/src/trezor/messages/SignMessage.py b/src/trezor/messages/SignMessage.py index 17a1e86a3a..a11774b121 100644 --- a/src/trezor/messages/SignMessage.py +++ b/src/trezor/messages/SignMessage.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class SignMessage(p.MessageType): diff --git a/src/trezor/messages/SignTx.py b/src/trezor/messages/SignTx.py index 870865cc09..34cc42ac7b 100644 --- a/src/trezor/messages/SignTx.py +++ b/src/trezor/messages/SignTx.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class SignTx(p.MessageType): diff --git a/src/trezor/messages/SignedIdentity.py b/src/trezor/messages/SignedIdentity.py index 724024273f..f9735b57e7 100644 --- a/src/trezor/messages/SignedIdentity.py +++ b/src/trezor/messages/SignedIdentity.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class SignedIdentity(p.MessageType): diff --git a/src/trezor/messages/SimpleSignTx.py b/src/trezor/messages/SimpleSignTx.py index d56d5f8d7a..93704e5749 100644 --- a/src/trezor/messages/SimpleSignTx.py +++ b/src/trezor/messages/SimpleSignTx.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .TxInputType import TxInputType from .TxOutputType import TxOutputType diff --git a/src/trezor/messages/Storage.py b/src/trezor/messages/Storage.py index e934d7531d..dbf1da13df 100644 --- a/src/trezor/messages/Storage.py +++ b/src/trezor/messages/Storage.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .HDNodeType import HDNodeType diff --git a/src/trezor/messages/Success.py b/src/trezor/messages/Success.py index 5826b55d02..dc9f9c7e0c 100644 --- a/src/trezor/messages/Success.py +++ b/src/trezor/messages/Success.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class Success(p.MessageType): diff --git a/src/trezor/messages/TransactionType.py b/src/trezor/messages/TransactionType.py index f51f80bc02..efbda48df9 100644 --- a/src/trezor/messages/TransactionType.py +++ b/src/trezor/messages/TransactionType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .TxInputType import TxInputType from .TxOutputBinType import TxOutputBinType diff --git a/src/trezor/messages/TxAck.py b/src/trezor/messages/TxAck.py index 5e53e76454..fe720e132c 100644 --- a/src/trezor/messages/TxAck.py +++ b/src/trezor/messages/TxAck.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .TransactionType import TransactionType diff --git a/src/trezor/messages/TxInputType.py b/src/trezor/messages/TxInputType.py index 6611608bc5..c44008e27b 100644 --- a/src/trezor/messages/TxInputType.py +++ b/src/trezor/messages/TxInputType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .MultisigRedeemScriptType import MultisigRedeemScriptType diff --git a/src/trezor/messages/TxOutputBinType.py b/src/trezor/messages/TxOutputBinType.py index 4e47f71af6..ce6da03985 100644 --- a/src/trezor/messages/TxOutputBinType.py +++ b/src/trezor/messages/TxOutputBinType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class TxOutputBinType(p.MessageType): diff --git a/src/trezor/messages/TxOutputType.py b/src/trezor/messages/TxOutputType.py index 26f657bb80..3021501872 100644 --- a/src/trezor/messages/TxOutputType.py +++ b/src/trezor/messages/TxOutputType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .MultisigRedeemScriptType import MultisigRedeemScriptType diff --git a/src/trezor/messages/TxRequest.py b/src/trezor/messages/TxRequest.py index a93fd50016..469e9a1767 100644 --- a/src/trezor/messages/TxRequest.py +++ b/src/trezor/messages/TxRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p from .TxRequestDetailsType import TxRequestDetailsType from .TxRequestSerializedType import TxRequestSerializedType diff --git a/src/trezor/messages/TxRequestDetailsType.py b/src/trezor/messages/TxRequestDetailsType.py index 5917ae17b9..ee8f340f2a 100644 --- a/src/trezor/messages/TxRequestDetailsType.py +++ b/src/trezor/messages/TxRequestDetailsType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class TxRequestDetailsType(p.MessageType): diff --git a/src/trezor/messages/TxRequestSerializedType.py b/src/trezor/messages/TxRequestSerializedType.py index 3fb534511a..5cc7445e3d 100644 --- a/src/trezor/messages/TxRequestSerializedType.py +++ b/src/trezor/messages/TxRequestSerializedType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class TxRequestSerializedType(p.MessageType): diff --git a/src/trezor/messages/TxSize.py b/src/trezor/messages/TxSize.py index 5049fbde40..d092ff9ec1 100644 --- a/src/trezor/messages/TxSize.py +++ b/src/trezor/messages/TxSize.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class TxSize(p.MessageType): diff --git a/src/trezor/messages/VerifyMessage.py b/src/trezor/messages/VerifyMessage.py index da3689e127..08e5bcf62c 100644 --- a/src/trezor/messages/VerifyMessage.py +++ b/src/trezor/messages/VerifyMessage.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class VerifyMessage(p.MessageType): diff --git a/src/trezor/messages/WipeDevice.py b/src/trezor/messages/WipeDevice.py index c267caa4d4..71b4229094 100644 --- a/src/trezor/messages/WipeDevice.py +++ b/src/trezor/messages/WipeDevice.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class WipeDevice(p.MessageType): diff --git a/src/trezor/messages/WordAck.py b/src/trezor/messages/WordAck.py index 89271b7480..5f04f32600 100644 --- a/src/trezor/messages/WordAck.py +++ b/src/trezor/messages/WordAck.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class WordAck(p.MessageType): diff --git a/src/trezor/messages/WordRequest.py b/src/trezor/messages/WordRequest.py index 763bc88f0f..5077ff7b45 100644 --- a/src/trezor/messages/WordRequest.py +++ b/src/trezor/messages/WordRequest.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + import protobuf as p class WordRequest(p.MessageType): diff --git a/src/trezor/messages/WordRequestType.py b/src/trezor/messages/WordRequestType.py index e0baf37631..2c646605a9 100644 --- a/src/trezor/messages/WordRequestType.py +++ b/src/trezor/messages/WordRequestType.py @@ -1,4 +1,6 @@ # Automatically generated by pb2py +from micropython import const + Plain = const(0) Matrix9 = const(1) Matrix6 = const(2) diff --git a/src/trezor/messages/wire_types.py b/src/trezor/messages/wire_types.py index ad84d3111d..3d9bf0c092 100644 --- a/src/trezor/messages/wire_types.py +++ b/src/trezor/messages/wire_types.py @@ -1,3 +1,6 @@ +# Automatically generated by pb2py +from micropython import const + WordRequest = const(46) DebugLinkMemoryWrite = const(112) ButtonAck = const(27) diff --git a/src/trezor/ui/__init__.py b/src/trezor/ui/__init__.py index 10675faa1b..3d769d75ab 100644 --- a/src/trezor/ui/__init__.py +++ b/src/trezor/ui/__init__.py @@ -1,3 +1,5 @@ +from micropython import const + import sys import math import utime diff --git a/src/trezor/ui/pin.py b/src/trezor/ui/pin.py index 7c4f799595..967df753a0 100644 --- a/src/trezor/ui/pin.py +++ b/src/trezor/ui/pin.py @@ -2,7 +2,7 @@ from micropython import const from trezor import ui, res from trezor.crypto import random from trezor.ui import display -from treozr.ui.button import Button, BTN_CLICKED, CLEAR_BUTTON, CLEAR_BUTTON_ACTIVE +from trezor.ui.button import Button, BTN_CLICKED, CLEAR_BUTTON, CLEAR_BUTTON_ACTIVE def digit_area(i): diff --git a/tools/build_protobuf b/tools/build_protobuf index d76dca13bd..627b74fa61 100755 --- a/tools/build_protobuf +++ b/tools/build_protobuf @@ -5,6 +5,9 @@ echo > $CURDIR/pb2/__init__.py INDEX=../src/trezor/messages/wire_types.py rm -f $INDEX +echo '# Automatically generated by pb2py' >> $INDEX +echo 'from micropython import const' >> $INDEX +echo '' >> $INDEX for i in types messages storage ; do # Compile .proto files to python2 modules using google protobuf library