Skip to content

Commit

Permalink
Add UI for spend_plan
Browse files Browse the repository at this point in the history
  • Loading branch information
neithanmo committed Nov 28, 2024
1 parent 1c6407d commit c1f09f5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions app/src/plan/spend_plan.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "pb_decode.h"
#include "protobuf/penumbra/core/transaction/v1/transaction.pb.h"
#include "zxformat.h"
#include "known_assets.h"
#include "note.h"

parser_error_t decode_spend_plan(const bytes_t *data, spend_plan_t *output) {
penumbra_core_component_shielded_pool_v1_SpendPlan spend_plan =
Expand Down Expand Up @@ -59,3 +61,39 @@ parser_error_t decode_spend_plan(const bytes_t *data, spend_plan_t *output) {

return parser_ok;
}

parser_error_t spend_getNumItems(const parser_context_t *ctx, uint8_t *num_items) {
UNUSED(ctx);
// from spends we display only two items:
// - Spend 100 USDC
// - From Main Account
*num_items = 2;
return parser_ok;
}

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) {

parser_error_t err = parser_no_data;
if (spend == NULL || outKey == NULL || outVal == NULL || outKeyLen == 0 || outValLen == 0) {
return err;
}


switch ( displayIdx ) {
case 0:
snprintf(outKey, outKeyLen, "Spend");
return printValue(ctx, &spend->note.value, outVal, outValLen);
break;
case 1:
snprintf(outKey, outKeyLen, "From");
snprintf(outVal, outValLen, "Main Account");
break;
default:
return parser_no_data;
}
return parser_ok;

}

0 comments on commit c1f09f5

Please sign in to comment.