1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00
trezor-firmware/tools/build_protobuf

110 lines
2.6 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -e
2019-05-16 11:28:20 +00:00
cd $(dirname $0)/..
PROTOB=common/protob
CORE_PROTOBUF_SOURCES="\
$PROTOB/messages.proto \
$PROTOB/messages-binance.proto \
2019-05-16 11:28:20 +00:00
$PROTOB/messages-bitcoin.proto \
$PROTOB/messages-cardano.proto \
$PROTOB/messages-common.proto \
$PROTOB/messages-crypto.proto \
$PROTOB/messages-debug.proto \
$PROTOB/messages-eos.proto \
$PROTOB/messages-ethereum.proto \
feat(core/ethereum): EIP-712 Based on original contribution by Max Kupriianov <xlab@hey.com> Implemented EIP-712 typed data signatures in Ethereum app. Add eth_abi into pyproject deps device test for EIP 712 fixed hex decoding for address fixup! fixed hex decoding for address code quality, more pythonic code, removing unused imports running black and isort on changed files trezorctl file input for EIP 712 data signing fixup! code quality, more pythonic code, removing unused imports fixup! fixup! code quality, more pythonic code, removing unused imports necessary changes after rebase to master unit tests for sign_typed_data.py new protobuf messages, working for nonarray types simplified and verified solution for our simple data support for simple arrays, without their confirmation reverting protobuf value messages to bytes, appropriate changes showing arrays in Trezor, code quality improvements data validation on Trezor, minor improvements using custom types for storing type data instead of dicts, addressing feedback from review moving helper functions to its own file, tests for decode_data additional overall tests support for arrays of structs adding support for metamask_v4_compat variable using HashWriter object to collect the final hash continously minor improvements in code quality validate_field_type function streaming values from client without saving them, missing UI prototype of streamed UI using confirm_properties accounting for bytes in data, more data types in integration tests rebase on master, using f-strings minor fixes and improvements from code review StructHasher class for the whole hashing process mypy and style changes asking users whether to show structs and arrays protobuf descriptions to fix make defs_check unifying comments, mypy fix unit tests for StructHasher class UI fixtures, skipping device tests for T1 addressing majority of code review comments about code quality and structure changing file structure - layouts, helpers, sign_typed_data decode_data renaming and docstring, renaming unit test file using tuples instead of lists in elifs layout improvements excluding core/src/apps/common/confirm.py file from the PR True/False returning layout with Show more button code review layout improvements forgotten br_type argument to should_show_more
2021-04-12 20:38:07 +00:00
$PROTOB/messages-ethereum-eip712.proto \
2019-05-16 11:28:20 +00:00
$PROTOB/messages-management.proto \
$PROTOB/messages-monero.proto \
$PROTOB/messages-nem.proto \
$PROTOB/messages-ripple.proto \
$PROTOB/messages-stellar.proto \
$PROTOB/messages-tezos.proto \
$PROTOB/messages-webauthn.proto \
2019-05-16 11:28:20 +00:00
"
PYTHON_PROTOBUF_SOURCES=$PROTOB/*.proto
CORE_MESSAGES_IGNORE="\
CosiCommit \
CosiCommitment \
CosiSign \
CosiSignature \
DebugLinkFlashErase \
DebugLinkLog \
DebugLinkMemory \
DebugLinkMemoryRead \
DebugLinkMemoryWrite \
DebugLinkStop \
NEMDecryptMessage \
NEMDecryptedMessage \
PinMatrixAck \
PinMatrixRequest \
PinMatrixRequestType \
WordAck \
WordRequest \
WordRequestType \
"
PYTHON_MESSAGES_IGNORE=""
2019-05-16 11:28:20 +00:00
RETURN=0
do_rebuild() {
local FILE_OR_DIR="$1"
2019-05-16 11:28:20 +00:00
shift
local OUTPUT="$1"
shift
local SOURCES="$1"
shift
2019-05-16 11:28:20 +00:00
if [ "$FILE_OR_DIR" == file ]; then
local param="--outfile"
else
local param="--python-outdir"
fi
# note $SOURCES is unquoted - we want wildcard expansion and multiple args
$PROTOB/pb2py "$@" $param="$OUTPUT" $SOURCES
2019-05-16 11:28:20 +00:00
}
do_check() {
# rebuild protobuf in tmpdir and check result against specified directory
local TMPDIR=$(mktemp -d proto-check.XXXXXX)
trap "rm -r $TMPDIR" RETURN
local FILE_OR_DIR="$1"
shift
local OUTPUT="$1"
2019-05-16 11:28:20 +00:00
shift
if [ "$FILE_OR_DIR" == file ]; then
local TMPDEST="$TMPDIR/testfile"
else
cp -rT "$OUTPUT" "$TMPDIR"
local TMPDEST="$TMPDIR"
fi
do_rebuild "$FILE_OR_DIR" "$TMPDEST" "$@"
if ! diff -ur --exclude __pycache__ "$OUTPUT" "$TMPDEST"; then
2019-05-16 11:28:20 +00:00
RETURN=1
fi
}
if [ "$1" == "--check" ]; then
func=do_check
else
func=do_rebuild
fi
$func dir core/src/trezor/enums "$CORE_PROTOBUF_SOURCES"
$func file core/src/trezor/enums/__init__.py "$CORE_PROTOBUF_SOURCES" --template=core/src/trezor/enums/_proto_init.mako
$func file core/src/trezor/messages.py "$CORE_PROTOBUF_SOURCES" --template=core/src/trezor/_proto_messages.mako
$func file python/src/trezorlib/messages.py "$PYTHON_PROTOBUF_SOURCES" \
--template=python/src/trezorlib/_proto_messages.mako \
--include-deprecated
2019-05-16 11:28:20 +00:00
exit $RETURN