Skip to content

Commit

Permalink
fix spend plan print
Browse files Browse the repository at this point in the history
  • Loading branch information
abenso committed Dec 11, 2024
1 parent 89f13cc commit 96c2eeb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 8 additions & 0 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "output.h"
#include "tx_metadata.h"
#include "memo.h"
#include "spend.h"

static uint8_t action_idx = 0;

Expand Down Expand Up @@ -86,6 +87,9 @@ parser_error_t parser_getNumItems(const parser_context_t *ctx, uint8_t *num_item
case penumbra_core_transaction_v1_ActionPlan_output_tag:
CHECK_ERROR(output_getNumItems(ctx, &action_num_items));
break;
case penumbra_core_transaction_v1_ActionPlan_spend_tag:
CHECK_ERROR(spend_getNumItems(ctx, &action_num_items));
break;
default:
return parser_unexpected_error;
}
Expand Down Expand Up @@ -152,6 +156,10 @@ parser_error_t parser_getItem(const parser_context_t *ctx, uint8_t displayIdx, c
CHECK_ERROR(output_getItem(ctx, &ctx->tx_obj->actions_plan[action_idx].action.output, 0, outKey, outKeyLen,
outVal, outValLen, pageIdx, pageCount))
break;
case penumbra_core_transaction_v1_ActionPlan_spend_tag:
CHECK_ERROR(spend_getItem(ctx, &ctx->tx_obj->actions_plan[action_idx].action.spend, 0, outKey, outKeyLen,
outVal, outValLen, pageIdx, pageCount))
break;
default:
return parser_unexpected_error;
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/plan/spend.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ parser_error_t decode_spend_plan(const bytes_t *data, spend_plan_t *output) {
return parser_spend_plan_error;
}

output->note.value.amount.lo = spend_plan.note.value.amount.lo;
output->note.value.amount.hi = spend_plan.note.value.amount.hi;
output->note.value.has_amount = spend_plan.note.value.has_amount;
if (output->note.value.has_amount) {
output->note.value.amount.lo = spend_plan.note.value.amount.lo;
output->note.value.amount.hi = spend_plan.note.value.amount.hi;
}
output->note.value.has_asset_id = spend_plan.note.value.has_asset_id;
output->position = spend_plan.position;

return parser_ok;
Expand Down
6 changes: 4 additions & 2 deletions app/src/plan/spend.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ parser_error_t spend_printValue(const parser_context_t *ctx, const spend_plan_t

parser_error_t spend_getNumItems(const parser_context_t *ctx, uint8_t *num_items);

parser_error_t spend_getItem(const parser_context_t *ctx, const spend_plan_t *spend, const address_index_t *addr_index, uint8_t displayIdx, char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen, uint8_t pageIdx, uint8_t *pageCount);
parser_error_t spend_getItem(const parser_context_t *ctx, const spend_plan_t *spend,
uint8_t displayIdx, char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen, uint8_t pageIdx,
uint8_t *pageCount);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 96c2eeb

Please sign in to comment.