1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

protob: add check for message prefixes; fix binance message names

This commit is contained in:
Pavol Rusnak 2019-03-13 16:59:26 +01:00
parent d490121e15
commit 04bac52951
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 38 additions and 14 deletions

View File

@ -25,6 +25,7 @@ script:
- jsonlint defs/*/*.json - jsonlint defs/*/*.json
- python tools/cointool.py check - python tools/cointool.py check
- python tools/support.py check --ignore-missing - python tools/support.py check --ignore-missing
- cd protob && python check.py
- python protob/graph.py protob/*.proto - python protob/graph.py protob/*.proto
notifications: notifications:

23
protob/check.py Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
from glob import glob
import sys
error = False
for fn in sorted(glob("messages-*.proto")):
with open(fn, "rt") as f:
prefix = fn.split(".")[0][9:].capitalize()
if prefix in ["Bitcoin", "Bootloader", "Common", "Crypto", "Management"]:
continue
if prefix == "Nem":
prefix = "NEM"
for line in f:
line = line.strip().split(" ")
if line[0] not in ["enum", "message"]:
continue
if not line[1].startswith(prefix) and not line[1].startswith("Debug" + prefix):
print("ERROR:", fn, line[1])
error = True
if error:
sys.exit(1)

View File

@ -76,17 +76,17 @@ message BinanceTxRequest {
* @next Failure * @next Failure
*/ */
message BinanceTransferMsg { message BinanceTransferMsg {
repeated InputOutput inputs = 1; repeated BinanceInputOutput inputs = 1;
repeated InputOutput outputs = 2; repeated BinanceInputOutput outputs = 2;
message Coin { message BinanceInputOutput {
optional sint64 amount = 1; optional string address = 1;
optional string denom = 2; repeated BinanceCoin coins = 2;
} }
message InputOutput { message BinanceCoin {
optional string address = 1; optional sint64 amount = 1;
repeated Coin coins = 2; optional string denom = 2;
} }
} }
@ -98,28 +98,28 @@ message BinanceTransferMsg {
*/ */
message BinanceOrderMsg { message BinanceOrderMsg {
optional string id = 1; optional string id = 1;
optional OrderType ordertype = 2; optional BinanceOrderType ordertype = 2;
optional sint64 price = 3; optional sint64 price = 3;
optional sint64 quantity = 4; optional sint64 quantity = 4;
optional string sender = 5; optional string sender = 5;
optional OrderSide side = 6; optional BinanceOrderSide side = 6;
optional string symbol = 7; optional string symbol = 7;
optional TimeInForce timeinforce = 8; optional BinanceTimeInForce timeinforce = 8;
enum OrderType { enum BinanceOrderType {
OT_UNKNOWN = 0; OT_UNKNOWN = 0;
MARKET = 1; MARKET = 1;
LIMIT = 2; LIMIT = 2;
OT_RESERVED = 3; OT_RESERVED = 3;
} }
enum OrderSide { enum BinanceOrderSide {
SIDE_UNKNOWN = 0; SIDE_UNKNOWN = 0;
BUY = 1; BUY = 1;
SELL = 2; SELL = 2;
} }
enum TimeInForce { enum BinanceTimeInForce {
TIF_UNKNOWN = 0; TIF_UNKNOWN = 0;
GTE = 1; GTE = 1;
TIF_RESERVED = 2; TIF_RESERVED = 2;