Commit 85dfb2fc authored by Alain Mebsout's avatar Alain Mebsout

Merge branch 'collect_call_reveal' into 'master'

Support for collect calls with embedded revelations

See merge request !13
parents 5cce2ed8 04ba2875
......@@ -18,8 +18,8 @@
# Version
APPVERSION_M=0
APPVERSION_N=5
APPVERSION_P=0
APPVERSION_D=20190925
APPVERSION_P=1
APPVERSION_D=20191014
# Enable PRINTF (with specific runtime on Ledger)
DEBUG = 0
......@@ -160,6 +160,7 @@ distrib:
push: distrib
scp ${ARCHIVE}.tar.gz dune.network:/home/www.dune.network/www/files/ledger-app-dune/${TARGET_SHORT}/
ssh dune.network "cd /home/www.dune.network/www/files/ledger-app-dune/${TARGET_SHORT}/; ln -sf ${ARCHIVE}.tar.gz latest.tar.gz"
##############
# Compiler #
......
......@@ -441,7 +441,8 @@ bool prompt_transaction
}
case OPERATION_TAG_TRANSACTION:
case OPERATION_TAG_COLLECT_CALL:
case OPERATION_TAG_COLLECT_CALL_V0:
case OPERATION_TAG_COLLECT_CALL_V1:
{
static const uint32_t TYPE_INDEX = 0;
static const uint32_t AMOUNT_INDEX = 1;
......@@ -471,8 +472,12 @@ bool prompt_transaction
register_ui_callback(AMOUNT_INDEX,
microtez_to_string_indirect, &ops->operation.amount);
if ( ops->operation.tag == OPERATION_TAG_COLLECT_CALL ) {
REGISTER_STATIC_UI_VALUE(TYPE_INDEX, "Collect Call");
if ( ops->operation.flags & TRANSACTION_FLAG_COLLECT_CALL ) {
if ( ops->operation.flags & TRANSACTION_FLAG_HAS_EMBED_REVEAL ) {
REGISTER_STATIC_UI_VALUE(TYPE_INDEX, "Collect Call (with revelation)");
} else {
REGISTER_STATIC_UI_VALUE(TYPE_INDEX, "Collect Call");
}
} else if ( ops->operation.flags & TRANSACTION_FLAG_HAS_PARAM ) {
REGISTER_STATIC_UI_VALUE(TYPE_INDEX, "Contract Call");
} else {
......
......@@ -223,7 +223,8 @@ static inline bool is_operation_allowed (enum operation_tag tag) {
case OPERATION_TAG_ORIGINATION:
case OPERATION_TAG_TRANSACTION:
#ifdef DUNE_APP
case OPERATION_TAG_COLLECT_CALL:
case OPERATION_TAG_COLLECT_CALL_V0:
case OPERATION_TAG_COLLECT_CALL_V1:
case OPERATION_TAG_DUNE_MANAGER:
#endif
return ! IS_BAKING_MODE();
......
......@@ -375,15 +375,42 @@ void parse_operations_throws_parse_error
}
break;
case OPERATION_TAG_TRANSACTION:
case OPERATION_TAG_COLLECT_CALL:
case OPERATION_TAG_COLLECT_CALL_V0:
case OPERATION_TAG_COLLECT_CALL_V1:
{
out->operation.amount = PARSE_Z(data, &ix, length);
const struct contract *destination = NEXT_TYPE(struct contract);
parse_contract(&out->operation.destination, destination);
if ( tag == OPERATION_TAG_COLLECT_CALL ) {
if ( tag == OPERATION_TAG_COLLECT_CALL_V0 ) {
out->operation.flags |= TRANSACTION_FLAG_COLLECT_CALL;
PARSE_Z(data, &ix, length); // collect call gas
} else if ( tag == OPERATION_TAG_COLLECT_CALL_V1 ) {
if (NEXT_BYTE(data, &ix, length)) {
// is collect call
out->operation.flags |= TRANSACTION_FLAG_COLLECT_CALL;
PARSE_Z(data, &ix, length); // collect call gas
if (NEXT_BYTE(data, &ix, length)) {
// has embedded revelation
out->operation.flags |= TRANSACTION_FLAG_HAS_EMBED_REVEAL;
// Ensure public key matches signing key.
raw_tezos_header_signature_type_t const *const sig_type =
NEXT_TYPE(raw_tezos_header_signature_type_t);
if (parse_raw_tezos_header_signature_type(sig_type) != out->signing.signature_type) {
PARSE_ERROR();
}
size_t klen = out->public_key.W_len;
advance_ix(&ix, length, klen);
if (memcmp(out->public_key.W, data + ix - klen, klen) != 0) {
PARSE_ERROR();
}
}
}
}
if (NEXT_BYTE(data, &ix, length)) {
......@@ -392,6 +419,16 @@ void parse_operations_throws_parse_error
IGNORE_NEXT_SIZED_FIELD(); // ignore parameters
// TODO: Support params
}
/* There can be extensions in v1 */
if ( tag == OPERATION_TAG_COLLECT_CALL_V1 ) {
/* Extensions */
if (NEXT_BYTE(data, &ix, length)) {
/* Should be none */
PARSE_ERROR();
}
}
}
break;
......
......@@ -274,8 +274,9 @@ enum operation_tag {
OPERATION_TAG_TRANSACTION = 8,
OPERATION_TAG_ORIGINATION = 9,
OPERATION_TAG_DELEGATION = 10,
OPERATION_TAG_COLLECT_CALL = 200,
OPERATION_TAG_COLLECT_CALL_V0 = 200,
OPERATION_TAG_DUNE_MANAGER = 201,
OPERATION_TAG_COLLECT_CALL_V1 = 202,
};
enum dune_operation_tag {
......@@ -292,6 +293,7 @@ enum dune_operation_tag {
#define TRANSACTION_FLAG_COLLECT_CALL 0b001
#define TRANSACTION_FLAG_HAS_PARAM 0b100
#define TRANSACTION_FLAG_HAS_EMBED_REVEAL 0b010
#define DUNE_MANAGE_ACCOUNTS_FLAG 0b01
#define DUNE_ACTIVATE_FLAG_HAS_PROTO 0b010
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment