mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
Mapping reflects latest changes in protobuf file
This commit is contained in:
parent
cc37fbaa5f
commit
b01c49715e
@ -1,4 +1,4 @@
|
|||||||
import bitkey_pb2 as proto
|
import trezor_pb2 as proto
|
||||||
|
|
||||||
map_type_to_class = {
|
map_type_to_class = {
|
||||||
0: proto.Initialize,
|
0: proto.Initialize,
|
||||||
@ -7,9 +7,6 @@ map_type_to_class = {
|
|||||||
3: proto.Failure,
|
3: proto.Failure,
|
||||||
4: proto.GetUUID,
|
4: proto.GetUUID,
|
||||||
5: proto.UUID,
|
5: proto.UUID,
|
||||||
6: proto.OtpRequest,
|
|
||||||
7: proto.OtpAck,
|
|
||||||
8: proto.OtpCancel,
|
|
||||||
9: proto.GetEntropy,
|
9: proto.GetEntropy,
|
||||||
10: proto.Entropy,
|
10: proto.Entropy,
|
||||||
11: proto.GetMasterPublicKey,
|
11: proto.GetMasterPublicKey,
|
||||||
@ -17,13 +14,13 @@ map_type_to_class = {
|
|||||||
13: proto.LoadDevice,
|
13: proto.LoadDevice,
|
||||||
14: proto.ResetDevice,
|
14: proto.ResetDevice,
|
||||||
15: proto.SignTx,
|
15: proto.SignTx,
|
||||||
# 16: proto.SignedTx,
|
# 16: proto.SignedTx,
|
||||||
17: proto.Features,
|
17: proto.Features,
|
||||||
18: proto.PinRequest,
|
18: proto.PinMatrixRequest,
|
||||||
19: proto.PinAck,
|
19: proto.PinMatrixAck,
|
||||||
20: proto.PinCancel,
|
20: proto.PinMatrixCancel,
|
||||||
21: proto.TxRequest,
|
21: proto.TxRequest,
|
||||||
#22: proto.OutputRequest,
|
# 22: proto.OutputRequest,
|
||||||
23: proto.TxInput,
|
23: proto.TxInput,
|
||||||
24: proto.TxOutput,
|
24: proto.TxOutput,
|
||||||
25: proto.SetMaxFeeKb,
|
25: proto.SetMaxFeeKb,
|
||||||
@ -35,30 +32,36 @@ map_type_to_class = {
|
|||||||
100: proto.DebugLinkDecision,
|
100: proto.DebugLinkDecision,
|
||||||
101: proto.DebugLinkGetState,
|
101: proto.DebugLinkGetState,
|
||||||
102: proto.DebugLinkState,
|
102: proto.DebugLinkState,
|
||||||
|
103: proto.DebugLinkStop,
|
||||||
}
|
}
|
||||||
|
|
||||||
map_class_to_type = {}
|
map_class_to_type = {}
|
||||||
|
|
||||||
|
|
||||||
def get_type(msg):
|
def get_type(msg):
|
||||||
return map_class_to_type[msg.__class__]
|
return map_class_to_type[msg.__class__]
|
||||||
|
|
||||||
|
|
||||||
def get_class(t):
|
def get_class(t):
|
||||||
return map_type_to_class[t]
|
return map_type_to_class[t]
|
||||||
|
|
||||||
|
|
||||||
def build_index():
|
def build_index():
|
||||||
for k, v in map_type_to_class.items():
|
for k, v in map_type_to_class.items():
|
||||||
map_class_to_type[v] = k
|
map_class_to_type[v] = k
|
||||||
|
|
||||||
|
|
||||||
def check_missing():
|
def check_missing():
|
||||||
from google.protobuf import reflection
|
from google.protobuf import reflection
|
||||||
|
|
||||||
types = [ proto.__dict__[item] for item in dir(proto)
|
types = [proto.__dict__[item] for item in dir(proto)
|
||||||
if issubclass(proto.__dict__[item].__class__, reflection.GeneratedProtocolMessageType) ]
|
if issubclass(proto.__dict__[item].__class__, reflection.GeneratedProtocolMessageType)]
|
||||||
|
|
||||||
missing = list(set(types) - set(map_type_to_class.values()))
|
missing = list(set(types) - set(map_type_to_class.values()))
|
||||||
|
|
||||||
if len(missing):
|
if len(missing):
|
||||||
raise Exception("Following protobuf messages are not defined in mapping: %s" % missing)
|
raise Exception("Following protobuf messages are not defined in mapping: %s" % missing)
|
||||||
|
|
||||||
|
|
||||||
check_missing()
|
check_missing()
|
||||||
build_index()
|
build_index()
|
||||||
|
Loading…
Reference in New Issue
Block a user