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

protob: fix small issues with protob, run graph.py in travis

This commit is contained in:
Pavol Rusnak 2018-10-18 14:08:22 +02:00
parent 50b9ecaf46
commit 9744e89378
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 39 additions and 28 deletions

View File

@ -12,7 +12,7 @@ python:
- "3.6" - "3.6"
install: install:
- pip install demjson - pip install demjson graphviz
- pip install -r tools/requirements.txt - pip install -r tools/requirements.txt
script: script:
@ -20,6 +20,7 @@ script:
- jsonlint defs/*/*.json - jsonlint defs/*/*.json
- python tools/cointool.py check - python tools/cointool.py check
- python tools/support.py check --ignore-tokens --ignore-missing - python tools/support.py check --ignore-tokens --ignore-missing
- python protob/graph.py protob/*.proto
notifications: notifications:
webhooks: webhooks:

View File

@ -1,11 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import sys
from os.path import basename
from graphviz import Digraph from graphviz import Digraph
class Message(object): class Message(object):
def __init__(self, name, attrs): def __init__(self, fname, name, attrs):
self.fname = basename(fname)
self.name = name self.name = name
if len(attrs) == 0: if len(attrs) == 0:
raise ValueError("message '%s' has no attributes" % name) raise ValueError("message '%s' has no attributes" % name)
@ -16,18 +18,20 @@ class Message(object):
elif t == "next": elif t == "next":
self.typ = "normal" self.typ = "normal"
attrs = attrs attrs = attrs
elif t == "wrap":
self.typ = "normal"
attrs = attrs
else: else:
raise ValueError("wrong message type in message '%s'" % name) raise ValueError("wrong message type in message '%s'" % name)
self.next = [] self.next = []
self.wrap = []
for a in attrs: for a in attrs:
if a[0] == "next": if a[0] == "next":
self.next.append(a[1]) self.next.append(a[1])
elif a[0] == "wrap":
self.wrap.append(a[1]) def __repr__(self):
return '%s(type=%s, fname="%s", next=%s)' % (
self.name,
self.typ,
self.fname,
self.next,
)
def generate_messages(files): def generate_messages(files):
@ -40,13 +44,13 @@ def generate_messages(files):
attrs.append(line[4:].split(" ")) attrs.append(line[4:].split(" "))
elif line.startswith("message "): elif line.startswith("message "):
name = line[8:-2] name = line[8:-2]
msgs[name] = Message(name, attrs) msgs[name] = Message(f, name, attrs)
attrs = [] attrs = []
return msgs return msgs
def generate_graph(msgs, fn): def generate_graph(msgs, fn):
dot = Digraph(format="png") dot = Digraph()
dot.attr(rankdir="LR") dot.attr(rankdir="LR")
for m in msgs.values(): for m in msgs.values():
if m.typ == "start": if m.typ == "start":
@ -63,10 +67,15 @@ def generate_graph(msgs, fn):
for m in msgs.values(): for m in msgs.values():
for n in m.next: for n in m.next:
dot.edge(m.name, n) dot.edge(m.name, n)
for n in m.wrap:
dot.edge(m.name, n)
dot.render(fn) dot.render(fn)
msgs = generate_messages(sys.argv) def main():
generate_graph(msgs, "graph.gv") proto_files = sys.argv
msgs = generate_messages(proto_files)
generate_graph(msgs, "proto.gv")
if __name__ == "__main__":
main()

View File

@ -54,6 +54,7 @@ message MoneroTransactionDestinationEntry {
/** /**
* Range sig parameters / data. * Range sig parameters / data.
* @embed
*/ */
message MoneroTransactionRsigData { message MoneroTransactionRsigData {
optional uint32 rsig_type = 1; // range signature (aka proof) type optional uint32 rsig_type = 1; // range signature (aka proof) type

View File

@ -63,7 +63,7 @@ message OntologyAddress {
/** /**
* Request: Ask device to sign Ontology transfer * Request: Ask device to sign Ontology transfer
* @start * @start
* @next OntologySignedTransfer * @next OntologySignedTransfer
*/ */
message OntologySignTransfer { message OntologySignTransfer {
@ -99,7 +99,7 @@ message OntologySignedTransfer {
/** /**
* Request: Ask device to sign Ontology ONG withdrawal * Request: Ask device to sign Ontology ONG withdrawal
* @start * @start
* @next OntologySignedWithdrawOng * @next OntologySignedWithdrawOng
*/ */
message OntologySignWithdrawOng { message OntologySignWithdrawOng {
@ -127,7 +127,7 @@ message OntologySignedWithdrawOng {
/** /**
* Request: Ask device to sign Ontology ONT ID registration * Request: Ask device to sign Ontology ONT ID registration
* @start * @start
* @next OntologySignedOntIdRegister * @next OntologySignedOntIdRegister
*/ */
message OntologySignOntIdRegister { message OntologySignOntIdRegister {
@ -154,7 +154,7 @@ message OntologySignedOntIdRegister {
/** /**
* Request: Ask device to sign Ontology ONT ID attributes adding * Request: Ask device to sign Ontology ONT ID attributes adding
* @start * @start
* @next OntologySignedOntIdAddAttributes * @next OntologySignedOntIdAddAttributes
*/ */
message OntologySignOntIdAddAttributes { message OntologySignOntIdAddAttributes {

View File

@ -6,7 +6,7 @@ option java_outer_classname = "TrezorMessageTron";
/** /**
* Request: Ask device for Tron address corresponding to address_n path * Request: Ask device for Tron address corresponding to address_n path
* @next PassphraseRequest * @start
* @next TronAddress * @next TronAddress
* @next Failure * @next Failure
*/ */
@ -17,7 +17,7 @@ message TronGetAddress {
/** /**
* Response: Contains Tron address derived from device private seed * Response: Contains Tron address derived from device private seed
* @prev TronGetAddress * @end
*/ */
message TronAddress { message TronAddress {
optional string address = 1; // Tron address (base58) optional string address = 1; // Tron address (base58)
@ -25,12 +25,13 @@ message TronAddress {
/** /**
* Request: Ask device to sign Tron transaction * Request: Ask device to sign Tron transaction
* @start
* @next TronSignedTx * @next TronSignedTx
*/ */
message TronSignTx { message TronSignTx {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
// Common part of transaction // Common part of transaction
optional bytes ref_block_bytes = 2; // Reference block number optional bytes ref_block_bytes = 2; // Reference block number
optional bytes ref_block_hash = 3; // Reference block hash optional bytes ref_block_hash = 3; // Reference block hash
optional uint64 expiration = 4; // Transaction expiration optional uint64 expiration = 4; // Transaction expiration
optional string data = 5; // Extra transaction info optional string data = 5; // Extra transaction info
@ -90,13 +91,13 @@ message TronSignTx {
optional string description = 10; // Asset description optional string description = 10; // Asset description
optional string url = 11; // Asset URL optional string url = 11; // Asset URL
} }
// Participate in an asset // Participate in an asset
message TronParticipateAssetIssueContract { message TronParticipateAssetIssueContract {
optional bytes to_address = 1; // Asset issuer address - decoded base 58 optional bytes to_address = 1; // Asset issuer address - decoded base 58
optional string asset_name = 2; // The name of target asset optional string asset_name = 2; // The name of target asset
optional uint64 amount = 3; // TRX amount in sun optional uint64 amount = 3; // TRX amount in sun
} }
// Freeze TRX balance // Freeze TRX balance
message TronFreezeBalanceContract { message TronFreezeBalanceContract {
optional uint64 frozen_balance = 1; // Amount to freeze optional uint64 frozen_balance = 1; // Amount to freeze
optional uint64 frozen_duration = 2; // Freeze minimal duration in days optional uint64 frozen_duration = 2; // Freeze minimal duration in days
@ -118,7 +119,7 @@ message TronSignTx {
// Network proposal contract // Network proposal contract
message TronProposalCreateContract { message TronProposalCreateContract {
message TronProposalParameters { message TronProposalParameters {
optional uint64 key = 1; // Paramter key optional uint64 key = 1; // Parameter key
optional uint64 value = 2; // Parameter value optional uint64 value = 2; // Parameter value
} }
repeated TronProposalParameters parameters = 1; // Parameter to be changed repeated TronProposalParameters parameters = 1; // Parameter to be changed
@ -132,7 +133,6 @@ message TronSignTx {
message TronProposalDeleteContract { message TronProposalDeleteContract {
optional uint64 proposal_id = 1; // Proposal ID optional uint64 proposal_id = 1; // Proposal ID
} }
optional TronTransferContract transfer_contract = 1; optional TronTransferContract transfer_contract = 1;
optional TronTransferAssetContract transfer_asset_contract = 2; optional TronTransferAssetContract transfer_asset_contract = 2;
optional TronVoteWitnessContract vote_witness_contract = 4; optional TronVoteWitnessContract vote_witness_contract = 4;
@ -153,9 +153,9 @@ message TronSignTx {
} }
/** /**
* Response: Contains Tron transaction signature * Response: Contains Tron transaction signature
* @prev TronSignTx * @end
*/ */
message TronSignedTx { message TronSignedTx {
optional bytes signature = 1; // Transaction signature optional bytes signature = 1; // Transaction signature
optional bytes serialized_tx = 2; // Serialized transaction optional bytes serialized_tx = 2; // Serialized transaction