mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +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
|
||||
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
|
||||
* @start
|
||||
* @next Address
|
||||
* @next Failure
|
||||
*/
|
||||
@ -94,7 +95,7 @@ message SignMessage {
|
||||
* Response: Signed message
|
||||
* @end
|
||||
*/
|
||||
message MessageSignature {
|
||||
message MessageSignature {
|
||||
optional string address = 1; // address used to sign the message
|
||||
optional bytes signature = 2; // signature of the message
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ message CardanoAddress {
|
||||
* @next CardanoPublicKey
|
||||
* @next Failure
|
||||
*/
|
||||
message CardanoGetPublicKey {
|
||||
message CardanoGetPublicKey {
|
||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ message CardanoMessageSignature {
|
||||
* @next Success
|
||||
* @next Failure
|
||||
*/
|
||||
message CardanoVerifyMessage {
|
||||
message CardanoVerifyMessage {
|
||||
optional bytes public_key = 1; // Public key which was used to sign message
|
||||
optional bytes signature = 2; // signature to verify
|
||||
optional bytes message = 3; // message to verify
|
||||
@ -118,6 +118,15 @@ message CardanoTxRequest {
|
||||
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
|
||||
* @end
|
||||
@ -126,11 +135,3 @@ message CardanoSignedTransaction {
|
||||
optional bytes tx_hash = 1; // hash 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;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ syntax = "proto2";
|
||||
* Response: Success of the previous request
|
||||
* @end
|
||||
*/
|
||||
message Success {
|
||||
message Success {
|
||||
optional string message = 1; // human readable description of action or request-specific payload
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ message PinMatrixAck {
|
||||
* @auxstart
|
||||
* @next PassphraseAck
|
||||
*/
|
||||
message PassphraseRequest {
|
||||
message PassphraseRequest {
|
||||
optional bool on_device = 1; // passphrase is being entered on the device
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ message PassphraseStateRequest {
|
||||
* Request: Send passphrase state back
|
||||
* @auxend
|
||||
*/
|
||||
message PassphraseStateAck {
|
||||
message PassphraseStateAck {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,6 +52,7 @@ message DebugLinkStop {
|
||||
|
||||
/**
|
||||
* Response: Device wants host to log event
|
||||
* @ignore
|
||||
*/
|
||||
message DebugLinkLog {
|
||||
optional uint32 level = 1;
|
||||
|
@ -92,7 +92,7 @@ message EthereumMessageSignature {
|
||||
* @next Success
|
||||
* @next Failure
|
||||
*/
|
||||
message EthereumVerifyMessage {
|
||||
message EthereumVerifyMessage {
|
||||
optional bytes address = 1; // address to verify
|
||||
optional bytes signature = 2; // signature to verify
|
||||
optional bytes message = 3; // message to verify
|
||||
|
@ -10,7 +10,7 @@ option java_outer_classname = "TrezorMessageLisk";
|
||||
* @next LiskAddress
|
||||
* @next Failure
|
||||
*/
|
||||
message LiskGetAddress {
|
||||
message LiskGetAddress {
|
||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||
optional bool show_display = 2; // Optionally show on display before sending the result
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ message Ping {
|
||||
/**
|
||||
* Request: Abort last operation that required user interaction
|
||||
* @start
|
||||
* @next Failure
|
||||
*/
|
||||
message Cancel {
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ message StellarAddress {
|
||||
* @start
|
||||
* @next StellarPublicKey
|
||||
*/
|
||||
message StellarGetPublicKey {
|
||||
message StellarGetPublicKey {
|
||||
repeated uint32 address_n = 1; // BIP-32 path. For compatibility with other wallets, must be m/44'/148'/index'
|
||||
optional bool show_display = 2; // optionally show on display before sending the result
|
||||
}
|
||||
@ -52,6 +52,7 @@ message StellarPublicKey {
|
||||
|
||||
/**
|
||||
* Request: ask device to sign Stellar transaction
|
||||
* @start
|
||||
* @next StellarTxOpRequest
|
||||
*/
|
||||
message StellarSignTx {
|
||||
|
@ -28,7 +28,7 @@ message TezosAddress {
|
||||
* @start
|
||||
* @next TezosPublicKey
|
||||
*/
|
||||
message TezosGetPublicKey {
|
||||
message TezosGetPublicKey {
|
||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||
optional bool show_display = 2; // Optionally show on display before sending the result
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user