1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

src: rename wire_types to MessageType, drop copy in tools/build_protobuf

This commit is contained in:
Pavol Rusnak 2018-07-02 20:40:51 +02:00
parent 28e2970cfb
commit ac5e3f200a
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
17 changed files with 36 additions and 152 deletions

View File

@ -1,5 +1,5 @@
from trezor import ui, wire
from trezor.messages import ButtonRequestType, wire_types
from trezor.messages import ButtonRequestType, MessageType
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.ui.confirm import CONFIRMED, ConfirmDialog, HoldToConfirmDialog
@ -8,7 +8,7 @@ from trezor.ui.confirm import CONFIRMED, ConfirmDialog, HoldToConfirmDialog
async def confirm(ctx, content, code=None, *args, **kwargs):
if code is None:
code = ButtonRequestType.Other
await ctx.call(ButtonRequest(code=code), wire_types.ButtonAck)
await ctx.call(ButtonRequest(code=code), MessageType.ButtonAck)
dialog = ConfirmDialog(content, *args, **kwargs)
@ -19,7 +19,7 @@ async def confirm(ctx, content, code=None, *args, **kwargs):
async def hold_to_confirm(ctx, content, code=None, *args, **kwargs):
if code is None:
code = ButtonRequestType.Other
await ctx.call(ButtonRequest(code=code), wire_types.ButtonAck)
await ctx.call(ButtonRequest(code=code), MessageType.ButtonAck)
dialog = HoldToConfirmDialog(content, 'Hold to confirm', *args, **kwargs)

View File

@ -1,5 +1,5 @@
from trezor import ui, wire
from trezor.messages import ButtonRequestType, wire_types
from trezor.messages import ButtonRequestType, MessageType
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages import PassphraseSourceType
from trezor.messages.PassphraseRequest import PassphraseRequest
@ -20,9 +20,9 @@ async def request_passphrase_entry(ctx):
ack = await ctx.call(
ButtonRequest(code=ButtonRequestType.PassphraseType),
wire_types.ButtonAck,
wire_types.Cancel)
if ack.MESSAGE_WIRE_TYPE == wire_types.Cancel:
MessageType.ButtonAck,
MessageType.Cancel)
if ack.MESSAGE_WIRE_TYPE == MessageType.Cancel:
raise wire.ActionCancelled('Passphrase cancelled')
selector = EntrySelector(text)
@ -38,8 +38,8 @@ async def request_passphrase_ack(ctx, on_device):
text.render()
req = PassphraseRequest(on_device=on_device)
ack = await ctx.call(req, wire_types.PassphraseAck, wire_types.Cancel)
if ack.MESSAGE_WIRE_TYPE == wire_types.Cancel:
ack = await ctx.call(req, MessageType.PassphraseAck, MessageType.Cancel)
if ack.MESSAGE_WIRE_TYPE == MessageType.Cancel:
raise wire.ActionCancelled('Passphrase cancelled')
if on_device:
@ -55,7 +55,7 @@ async def request_passphrase_ack(ctx, on_device):
passphrase = ack.passphrase
req = PassphraseStateRequest(state=get_state(prev_state=ack.state, passphrase=passphrase))
ack = await ctx.call(req, wire_types.PassphraseStateAck, wire_types.Cancel)
ack = await ctx.call(req, MessageType.PassphraseStateAck, MessageType.Cancel)
return passphrase

View File

@ -4,7 +4,7 @@ if not __debug__:
if __debug__:
from trezor import loop
from trezor.messages import wire_types
from trezor.messages import MessageType
from trezor.messages.DebugLinkState import DebugLinkState
from trezor.ui import confirm, swipe
from trezor.wire import register, protobuf_workflow
@ -40,5 +40,5 @@ if __debug__:
# wipe storage when debug build is used
storage.wipe()
register(wire_types.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision)
register(wire_types.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState)
register(MessageType.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision)
register(MessageType.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState)

View File

@ -1,6 +1,6 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import EthereumGetAddress, EthereumSignTx
from trezor.messages.wire_types import EthereumSignMessage, EthereumVerifyMessage
from trezor.messages.MessageType import EthereumGetAddress, EthereumSignTx
from trezor.messages.MessageType import EthereumSignMessage, EthereumVerifyMessage
def dispatch_EthereumGetAddress(*args, **kwargs):

View File

@ -91,7 +91,7 @@ def get_total_length(msg: EthereumSignTx, data_total: int) -> int:
async def send_request_chunk(ctx, data_left: int):
from trezor.messages.wire_types import EthereumTxAck
from trezor.messages.MessageType import EthereumTxAck
# TODO: layoutProgress ?
req = EthereumTxRequest()
if data_left <= 1024:

View File

@ -1,6 +1,6 @@
from trezor import config, utils, wire
from trezor.wire import register, protobuf_workflow
from trezor.messages import wire_types
from trezor.messages import MessageType
from trezor.messages.Features import Features
from trezor.messages.Success import Success
@ -64,8 +64,8 @@ async def handle_Ping(ctx, msg):
def boot():
register(wire_types.Initialize, protobuf_workflow, handle_Initialize)
register(wire_types.GetFeatures, protobuf_workflow, handle_GetFeatures)
register(wire_types.Cancel, protobuf_workflow, handle_Cancel)
register(wire_types.ClearSession, protobuf_workflow, handle_ClearSession)
register(wire_types.Ping, protobuf_workflow, handle_Ping)
register(MessageType.Initialize, protobuf_workflow, handle_Initialize)
register(MessageType.GetFeatures, protobuf_workflow, handle_GetFeatures)
register(MessageType.Cancel, protobuf_workflow, handle_Cancel)
register(MessageType.ClearSession, protobuf_workflow, handle_ClearSession)
register(MessageType.Ping, protobuf_workflow, handle_Ping)

View File

@ -1,5 +1,5 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import \
from trezor.messages.MessageType import \
LiskGetAddress, LiskSignTx, LiskGetPublicKey, LiskSignMessage, LiskVerifyMessage

View File

@ -1,5 +1,5 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import \
from trezor.messages.MessageType import \
LoadDevice, ResetDevice, BackupDevice, WipeDevice, RecoveryDevice, ApplySettings, ApplyFlags, ChangePin, SetU2FCounter

View File

@ -1,5 +1,5 @@
from trezor import config, loop, ui, wire
from trezor.messages import wire_types
from trezor.messages import MessageType
from trezor.messages import ButtonRequestType
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages.Success import Success
@ -71,7 +71,7 @@ async def request_pin_confirm(ctx, *args, **kwargs):
async def request_pin_ack(ctx, *args, **kwargs):
try:
await ctx.call(ButtonRequest(code=ButtonRequestType.Other), wire_types.ButtonAck)
await ctx.call(ButtonRequest(code=ButtonRequestType.Other), MessageType.ButtonAck)
return await ctx.wait(request_pin(*args, **kwargs))
except PinCancelled:
raise wire.ActionCancelled('Cancelled')

View File

@ -3,7 +3,7 @@ from trezor.crypto import bip39
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages.ButtonRequestType import MnemonicWordCount, MnemonicInput
from trezor.messages.Success import Success
from trezor.messages.wire_types import ButtonAck
from trezor.messages.MessageType import ButtonAck
from trezor.pin import pin_to_int
from trezor.ui.mnemonic import MnemonicKeyboard
from trezor.ui.text import Text

View File

@ -1,7 +1,7 @@
from micropython import const
from trezor import config, ui, wire
from trezor.crypto import bip39, hashlib, random
from trezor.messages import ButtonRequestType, wire_types
from trezor.messages import ButtonRequestType, MessageType
from trezor.messages.ButtonRequest import ButtonRequest
from trezor.messages.EntropyRequest import EntropyRequest
from trezor.messages.Success import Success
@ -42,7 +42,7 @@ async def reset_device(ctx, msg):
await show_entropy(ctx, internal_ent)
# request external entropy and compute mnemonic
ent_ack = await ctx.call(EntropyRequest(), wire_types.EntropyAck)
ent_ack = await ctx.call(EntropyRequest(), MessageType.EntropyAck)
mnemonic = generate_mnemonic(msg.strength, internal_ent, ent_ack.entropy)
if not msg.skip_backup:
@ -143,7 +143,7 @@ async def show_entropy(ctx, entropy: bytes):
async def show_mnemonic(ctx, mnemonic: str):
await ctx.call(
ButtonRequest(code=ButtonRequestType.ResetDevice), wire_types.ButtonAck)
ButtonRequest(code=ButtonRequestType.ResetDevice), MessageType.ButtonAck)
first_page = const(0)
words_per_page = const(4)
words = list(enumerate(mnemonic.split()))

View File

@ -1,5 +1,5 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import NEMGetAddress, NEMSignTx
from trezor.messages.MessageType import NEMGetAddress, NEMSignTx
def dispatch_NemGetAddress(*args, **kwargs):

View File

@ -1,5 +1,5 @@
from trezor.wire import register, protobuf_workflow
from trezor.messages.wire_types import \
from trezor.messages.MessageType import \
GetPublicKey, GetAddress, \
GetEntropy, \
SignTx, \

View File

@ -1,5 +1,5 @@
from trezor import ui, wire
from trezor.messages.wire_types import TxAck
from trezor.messages.MessageType import TxAck
from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXFINISHED
from apps.common import seed

View File

@ -1,4 +1,4 @@
from trezor.messages import wire_types
from trezor.messages import MessageType
if __debug__:
from trezor import log
@ -28,5 +28,5 @@ def get_type(wire_type):
# build reverse table of wire types
for msg_name in dir(wire_types):
type_to_name[getattr(wire_types, msg_name)] = msg_name
for msg_name in dir(MessageType):
type_to_name[getattr(MessageType, msg_name)] = msg_name

View File

@ -1,114 +0,0 @@
# Automatically generated by pb2py
# fmt: off
Initialize = 0
Ping = 1
Success = 2
Failure = 3
ChangePin = 4
WipeDevice = 5
FirmwareErase = 6
FirmwareUpload = 7
FirmwareRequest = 8
GetEntropy = 9
Entropy = 10
GetPublicKey = 11
PublicKey = 12
LoadDevice = 13
ResetDevice = 14
SignTx = 15
SimpleSignTx = 16
Features = 17
PinMatrixRequest = 18
PinMatrixAck = 19
Cancel = 20
TxRequest = 21
TxAck = 22
CipherKeyValue = 23
ClearSession = 24
ApplySettings = 25
ButtonRequest = 26
ButtonAck = 27
ApplyFlags = 28
GetAddress = 29
Address = 30
SelfTest = 32
BackupDevice = 34
EntropyRequest = 35
EntropyAck = 36
SignMessage = 38
VerifyMessage = 39
MessageSignature = 40
PassphraseRequest = 41
PassphraseAck = 42
PassphraseStateRequest = 77
PassphraseStateAck = 78
EstimateTxSize = 43
TxSize = 44
RecoveryDevice = 45
WordRequest = 46
WordAck = 47
CipheredKeyValue = 48
EncryptMessage = 49
EncryptedMessage = 50
DecryptMessage = 51
DecryptedMessage = 52
SignIdentity = 53
SignedIdentity = 54
GetFeatures = 55
EthereumGetAddress = 56
EthereumAddress = 57
EthereumSignTx = 58
EthereumTxRequest = 59
EthereumTxAck = 60
GetECDHSessionKey = 61
ECDHSessionKey = 62
SetU2FCounter = 63
EthereumSignMessage = 64
EthereumVerifyMessage = 65
EthereumMessageSignature = 66
NEMGetAddress = 67
NEMAddress = 68
NEMSignTx = 69
NEMSignedTx = 70
CosiCommit = 71
CosiCommitment = 72
CosiSign = 73
CosiSignature = 74
NEMDecryptMessage = 75
NEMDecryptedMessage = 76
DebugLinkDecision = 100
DebugLinkGetState = 101
DebugLinkState = 102
DebugLinkStop = 103
DebugLinkLog = 104
DebugLinkMemoryRead = 110
DebugLinkMemory = 111
DebugLinkMemoryWrite = 112
DebugLinkFlashErase = 113
LiskGetAddress = 114
LiskAddress = 115
LiskSignTx = 116
LiskSignedTx = 117
LiskSignMessage = 118
LiskMessageSignature = 119
LiskVerifyMessage = 120
LiskGetPublicKey = 121
LiskPublicKey = 122
StellarGetPublicKey = 200
StellarPublicKey = 201
StellarSignTx = 202
StellarTxOpRequest = 203
StellarGetAddress = 207
StellarAddress = 208
StellarCreateAccountOp = 210
StellarPaymentOp = 211
StellarPathPaymentOp = 212
StellarManageOfferOp = 213
StellarCreatePassiveOfferOp = 214
StellarSetOptionsOp = 215
StellarChangeTrustOp = 216
StellarAllowTrustOp = 217
StellarAccountMergeOp = 218
StellarManageDataOp = 220
StellarBumpSequenceOp = 221
StellarSignedTx = 230

View File

@ -5,5 +5,3 @@ set -e
--no-init-py \
-o ../src/trezor/messages \
../vendor/trezor-common/protob/{types,messages}.proto
cp ../src/trezor/messages/MessageType.py ../src/trezor/messages/wire_types.py