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

fix(legacy/nem): remove checks for newly required protobuf attributes

[no changelog]
This commit is contained in:
matejcik 2022-01-06 14:48:42 +01:00 committed by matejcik
parent dfab3efb86
commit 454a7ce301
3 changed files with 14 additions and 59 deletions

View File

@ -59,8 +59,6 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
#define NEM_CHECK_PARAM_WHEN(b, s) \
CHECK_PARAM(!(b) || (reason = (s)) == NULL, reason)
CHECK_PARAM(msg->has_transaction, _("No common provided"));
// Ensure exactly one transaction is provided
unsigned int provided = msg->has_transfer + msg->has_provision_namespace +
msg->has_mosaic_creation + msg->has_supply_change +

View File

@ -39,21 +39,6 @@ const char *nem_validate_common(NEMTransactionCommon *common, bool inner) {
: _("Invalid NEM network");
}
if (!common->has_timestamp) {
return inner ? _("No timestamp provided in inner transaction")
: _("No timestamp provided");
}
if (!common->has_fee) {
return inner ? _("No fee provided in inner transaction")
: _("No fee provided");
}
if (!common->has_deadline) {
return inner ? _("No deadline provided in inner transaction")
: _("No deadline provided");
}
if (inner != common->has_signer) {
return inner ? _("No signer provided in inner transaction")
: _("Signer not allowed in outer transaction");
@ -68,9 +53,6 @@ const char *nem_validate_common(NEMTransactionCommon *common, bool inner) {
const char *nem_validate_transfer(const NEMTransfer *transfer,
uint8_t network) {
if (!transfer->has_recipient) return _("No recipient provided");
if (!transfer->has_amount) return _("No amount provided");
if (transfer->has_public_key &&
transfer->public_key.size != sizeof(ed25519_public_key)) {
return _("Invalid recipient public key");
@ -79,23 +61,11 @@ const char *nem_validate_transfer(const NEMTransfer *transfer,
if (!nem_validate_address(transfer->recipient, network))
return _("Invalid recipient address");
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMMosaic *mosaic = &transfer->mosaics[i];
if (!mosaic->has_namespace) return _("No mosaic namespace provided");
if (!mosaic->has_mosaic) return _("No mosaic name provided");
if (!mosaic->has_quantity) return _("No mosaic quantity provided");
}
return NULL;
}
const char *nem_validate_provision_namespace(
const NEMProvisionNamespace *provision_namespace, uint8_t network) {
if (!provision_namespace->has_namespace) return _("No namespace provided");
if (!provision_namespace->has_sink) return _("No rental sink provided");
if (!provision_namespace->has_fee) return _("No rental sink fee provided");
if (!nem_validate_address(provision_namespace->sink, network))
return _("Invalid rental sink address");
@ -104,11 +74,6 @@ const char *nem_validate_provision_namespace(
const char *nem_validate_mosaic_creation(
const NEMMosaicCreation *mosaic_creation, uint8_t network) {
if (!mosaic_creation->has_definition)
return _("No mosaic definition provided");
if (!mosaic_creation->has_sink) return _("No creation sink provided");
if (!mosaic_creation->has_fee) return _("No creation sink fee provided");
if (!nem_validate_address(mosaic_creation->sink, network))
return _("Invalid creation sink address");
@ -119,11 +84,6 @@ const char *nem_validate_mosaic_creation(
if (mosaic_creation->definition.networks_count)
return _("Networks not allowed in mosaic creation transactions");
if (!mosaic_creation->definition.has_namespace)
return _("No mosaic namespace provided");
if (!mosaic_creation->definition.has_mosaic)
return _("No mosaic name provided");
if (mosaic_creation->definition.has_levy) {
if (!mosaic_creation->definition.has_fee)
return _("No levy address provided");
@ -141,8 +101,6 @@ const char *nem_validate_mosaic_creation(
return _("No supply mutability provided");
if (!mosaic_creation->definition.has_transferable)
return _("No mosaic transferability provided");
if (!mosaic_creation->definition.has_description)
return _("No description provided");
if (mosaic_creation->definition.divisibility > NEM_MAX_DIVISIBILITY)
return _("Invalid divisibility provided");
@ -159,11 +117,7 @@ const char *nem_validate_mosaic_creation(
const char *nem_validate_supply_change(
const NEMMosaicSupplyChange *supply_change) {
if (!supply_change->has_namespace) return _("No namespace provided");
if (!supply_change->has_mosaic) return _("No mosaic provided");
if (!supply_change->has_type) return _("No type provided");
if (!supply_change->has_delta) return _("No delta provided");
(void)supply_change;
return NULL;
}
@ -177,9 +131,6 @@ const char *nem_validate_aggregate_modification(
const NEMCosignatoryModification *modification =
&aggregate_modification->modifications[i];
if (!modification->has_type) return _("No modification type provided");
if (!modification->has_public_key)
return _("No cosignatory public key provided");
if (modification->public_key.size != 32)
return _("Invalid cosignatory public key provided");
@ -194,9 +145,6 @@ const char *nem_validate_aggregate_modification(
const char *nem_validate_importance_transfer(
const NEMImportanceTransfer *importance_transfer) {
if (!importance_transfer->has_mode) return _("No mode provided");
if (!importance_transfer->has_public_key)
return _("No remote account provided");
if (importance_transfer->public_key.size != 32)
return _("Invalid remote account provided");

View File

@ -1,9 +1,12 @@
<%
ATTRIBUTES = (
("name", c_str),
("ticker", lambda s: c_str(" " + s) if s else "NULL"),
ATTRIBUTES_REQUIRED = (
("namespace", c_str),
("mosaic", c_str),
)
ATTRIBUTES_OPTIONAL = (
("name", c_str),
("ticker", lambda s: c_str(" " + s) if s else "NULL"),
("divisibility", int),
("levy", lambda s: "NEMMosaicLevy_" + s),
("fee", int),
@ -19,7 +22,13 @@ ATTRIBUTES = (
const NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT] = {
% for m in supported_on("trezor1", nem):
{
% for attr, func in ATTRIBUTES:
% for attr, func in ATTRIBUTES_REQUIRED:
% if attr in m:
.${attr} = ${func(m[attr])},
% endif
% endfor
.description = "",
% for attr, func in ATTRIBUTES_OPTIONAL:
% if attr in m:
.has_${attr} = true,
.${attr} = ${func(m[attr])},