Skip to content

Commit

Permalink
fix small error
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala committed Jun 26, 2022
1 parent 61d8e05 commit 3fc8dec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/src/parser_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ parser_error_t _readCompactIndex(parser_context_t *c, pd_CompactIndex_t *v);
uint16_t _detectAddressType(const parser_context_t *c);

parser_error_t _toStringCompactInt(const compactInt_t *c, uint8_t decimalPlaces,
bool trimTrailingZeros,
char postfix[],
char prefix[],
char *outValue, uint16_t outValueLen,
Expand Down
12 changes: 9 additions & 3 deletions app/src/parser_impl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ const char *parser_getErrorDescription(parser_error_t err) {
return "Max nested calls reached";
case parser_tx_call_vec_too_large:
return "Call vector exceeds limit";
case parser_junction_limit:
return "Max junctions reached";
default:
return "Unrecognized error code";
}
Expand Down Expand Up @@ -189,6 +191,7 @@ parser_error_t _getValue(const compactInt_t *c, uint64_t *v) {

parser_error_t _toStringCompactInt(const compactInt_t *c,
uint8_t decimalPlaces,
bool trimTrailingZeros,
char postfix[],
char prefix[],
char *outValue, uint16_t outValueLen,
Expand Down Expand Up @@ -223,6 +226,10 @@ parser_error_t _toStringCompactInt(const compactInt_t *c,
return parser_unexpected_buffer_end;
}

if(trimTrailingZeros) {
number_inplace_trimming(bufferUI, 1);
}

pageString(outValue, outValueLen, bufferUI, pageIdx, pageCount);

return parser_ok;
Expand Down Expand Up @@ -293,17 +300,16 @@ parser_error_t _readCompactBalance(parser_context_t *c, pd_CompactBalance_t *v)
parser_error_t _toStringCompactIndex(const pd_CompactIndex_t *v,
char *outValue, uint16_t outValueLen,
uint8_t pageIdx, uint8_t *pageCount) {
return _toStringCompactInt(&v->index, 0, "", "", outValue, outValueLen, pageIdx, pageCount);
return _toStringCompactInt(&v->index, 0, false, "", "", outValue, outValueLen, pageIdx, pageCount);
}

parser_error_t _toStringCompactBalance(const pd_CompactBalance_t *v,
char *outValue, uint16_t outValueLen,
uint8_t pageIdx, uint8_t *pageCount) {
CHECK_ERROR(_toStringCompactInt(
&v->value,
COIN_AMOUNT_DECIMAL_PLACES, "", COIN_TICKER,
COIN_AMOUNT_DECIMAL_PLACES, true, "", COIN_TICKER,
outValue, outValueLen, pageIdx, pageCount))
number_inplace_trimming(outValue, 1);
return parser_ok;
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/substrate/substrate_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ parser_error_t _toStringCompactu32(
uint8_t pageIdx,
uint8_t* pageCount)
{
return _toStringCompactInt(v, 0, "", "", outValue, outValueLen, pageIdx, pageCount);
return _toStringCompactInt(v, 0, false, "", "", outValue, outValueLen, pageIdx, pageCount);
}

parser_error_t _toStringCompactu64(
Expand All @@ -315,7 +315,7 @@ parser_error_t _toStringCompactu64(
uint8_t pageIdx,
uint8_t* pageCount)
{
return _toStringCompactInt(v, 0, "", "", outValue, outValueLen, pageIdx, pageCount);
return _toStringCompactInt(v, 0, false, "", "", outValue, outValueLen, pageIdx, pageCount);
}

///////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion app/src/substrate/substrate_types_V1.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ parser_error_t _toStringCompactAccountIndex_V1(
uint8_t pageIdx,
uint8_t* pageCount)
{
return _toStringCompactInt(&v->value, 0, "", "", outValue, outValueLen, pageIdx, pageCount);
return _toStringCompactInt(&v->value, 0, false, "", "", outValue, outValueLen, pageIdx, pageCount);
}

parser_error_t _toStringDestroyWitness_V1(
Expand Down

0 comments on commit 3fc8dec

Please sign in to comment.