mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
protob: add graph.py script, small fixes to proto files
This commit is contained in:
parent
25bc3b4570
commit
f7df570194
1
protob/.gitignore
vendored
1
protob/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
*.pb
|
*.pb
|
||||||
|
graph.gv*
|
||||||
|
55
protob/graph.py
Executable file
55
protob/graph.py
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from graphviz import Digraph
|
||||||
|
|
||||||
|
|
||||||
|
class Message(object):
|
||||||
|
def __init__(self, name, attrs):
|
||||||
|
self.name = name
|
||||||
|
self.attrs = attrs
|
||||||
|
|
||||||
|
|
||||||
|
def generate_messages(files):
|
||||||
|
attrs = []
|
||||||
|
msgs = []
|
||||||
|
for f in files:
|
||||||
|
for line in open(f, "rt").readlines():
|
||||||
|
line = line.rstrip()
|
||||||
|
if line.startswith(" * @"):
|
||||||
|
attrs.append(line[4:].split(" "))
|
||||||
|
elif line.startswith("message "):
|
||||||
|
name = line[8:-2]
|
||||||
|
msgs.append(Message(name, attrs))
|
||||||
|
attrs = []
|
||||||
|
return msgs
|
||||||
|
|
||||||
|
|
||||||
|
def generate_graph(msgs, fn):
|
||||||
|
dot = Digraph(format="png")
|
||||||
|
dot.attr(rankdir="LR")
|
||||||
|
for m in msgs:
|
||||||
|
typ = m.attrs[0][0]
|
||||||
|
if typ == "start":
|
||||||
|
dot.node(m.name, shape="box", color="blue")
|
||||||
|
elif typ == "end":
|
||||||
|
dot.node(m.name, shape="box", color="green3")
|
||||||
|
elif typ == "auxstart":
|
||||||
|
dot.node(m.name, shape="diamond", color="blue")
|
||||||
|
elif typ == "auxend":
|
||||||
|
dot.node(m.name, shape="diamond", color="green3")
|
||||||
|
elif typ == "next":
|
||||||
|
dot.node(m.name) # no attrs
|
||||||
|
elif typ in ["embed", "ignore"]:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise ValueError("wrong message type in message '%s'" % m.name)
|
||||||
|
for m in msgs:
|
||||||
|
for a in m.attrs:
|
||||||
|
if a[0] == "next":
|
||||||
|
dot.edge(m.name, a[1])
|
||||||
|
dot.render(fn)
|
||||||
|
|
||||||
|
|
||||||
|
msgs = generate_messages(sys.argv)
|
||||||
|
generate_graph(msgs, "graph.gv")
|
@ -58,6 +58,7 @@ message PublicKey {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Request: Ask device for address corresponding to address_n path
|
* Request: Ask device for address corresponding to address_n path
|
||||||
|
* @start
|
||||||
* @next Address
|
* @next Address
|
||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
|
@ -118,6 +118,15 @@ message CardanoTxRequest {
|
|||||||
optional bytes tx_body = 3; // serialised body of the signed transaction
|
optional bytes tx_body = 3; // serialised body of the signed transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Reported transaction data
|
||||||
|
* @next CardanoSignedTransaction
|
||||||
|
* @next CardanoTxRequest
|
||||||
|
*/
|
||||||
|
message CardanoTxAck {
|
||||||
|
optional bytes transaction = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response: Serialised signed cardano transaction
|
* Response: Serialised signed cardano transaction
|
||||||
* @end
|
* @end
|
||||||
@ -126,11 +135,3 @@ message CardanoSignedTransaction {
|
|||||||
optional bytes tx_hash = 1; // hash of the signed transaction
|
optional bytes tx_hash = 1; // hash of the signed transaction
|
||||||
optional bytes tx_body = 2; // serialised body of the signed transaction
|
optional bytes tx_body = 2; // serialised body of the signed transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Reported transaction data
|
|
||||||
* @next CardanoTxRequest
|
|
||||||
*/
|
|
||||||
message CardanoTxAck {
|
|
||||||
optional bytes transaction = 1;
|
|
||||||
}
|
|
||||||
|
@ -52,6 +52,7 @@ message DebugLinkStop {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Response: Device wants host to log event
|
* Response: Device wants host to log event
|
||||||
|
* @ignore
|
||||||
*/
|
*/
|
||||||
message DebugLinkLog {
|
message DebugLinkLog {
|
||||||
optional uint32 level = 1;
|
optional uint32 level = 1;
|
||||||
|
@ -123,6 +123,7 @@ message Ping {
|
|||||||
/**
|
/**
|
||||||
* Request: Abort last operation that required user interaction
|
* Request: Abort last operation that required user interaction
|
||||||
* @start
|
* @start
|
||||||
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message Cancel {
|
message Cancel {
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ message StellarPublicKey {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Request: ask device to sign Stellar transaction
|
* Request: ask device to sign Stellar transaction
|
||||||
|
* @start
|
||||||
* @next StellarTxOpRequest
|
* @next StellarTxOpRequest
|
||||||
*/
|
*/
|
||||||
message StellarSignTx {
|
message StellarSignTx {
|
||||||
|
Loading…
Reference in New Issue
Block a user