blooo-io / LedgerHQ-app-plugin-apwine

Apache License 2.0
0 stars 2 forks source link

Donjon code review #19

Open adrienlacombe opened 1 year ago

adrienlacombe commented 1 year ago
adrienlacombe commented 1 year ago
adrienlacombe commented 1 year ago
adrienlacombe commented 1 year ago
GuilaneDen commented 1 year ago

Hi @adrienlacombe-ledger , thank you for the review.

I have a question about the handle_zapintopt function, the last parameter which is _input[1] is not a parameter that we are displaying. Therefore we don't want to parse it and skip it.

However, when I don't want to parse a certain parameter I put context->next_param = NONE or skip it with context->skip++; but it seems that neither of the two options is accepted by the donjon. Do you know how to skip a parameter at the end of the input data?

adrienlacombe commented 1 year ago

hi @GuilaneDen

When there is no need to parse more parameters we can use context->next_param = NONE or when we don’t want to parse certain parameters we can use context->skip = Y (to skip the next Y parameters). In the case of handle_zapintopt the length parameter of the array _inputs should be read and make sure that is a valid number. The correct way do code this function is to read the length of this array and make sure that is larger than 0 (at least). Then parse _inputs[0] and skip the remaining _inputs[1:] (python syntax to be clearer). Also set context->next_param = NONE since no more parameters are expected after skipping the remaining _inputs.

adrienlacombe commented 1 year ago
adrienlacombe commented 1 year ago
adrienlacombe commented 1 year ago
if (context->array_len != 0) {
  handle_amount_received(msg, context);
} else {
  msg->result = ETH_PLUGIN_RESULT_ERROR;
  break;
}
adrienlacombe commented 1 year ago
adrienlacombe commented 1 year ago