Skip to content

Commit

Permalink
fix: fix the jump problem in format_operation_source
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Aug 26, 2021
1 parent acdd872 commit 985506e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/stellar_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,35 @@ static void format_confirm_transaction_details(tx_context_t *txCtx) {
format_memo(txCtx);
}

static void format_next_operation(tx_context_t *txCtx) {
formatter_stack[formatter_index] = NULL;
set_state_data(true);
}

static void format_operation_source(tx_context_t *txCtx) {
if (txCtx->opDetails.sourceAccountPresent) {
strcpy(detailCaption, "Op Source");
print_public_key(txCtx->opDetails.sourceAccount, detailValue, 0, 0);
push_to_formatter_stack(&format_confirm_transaction_details);
} else {
if (txCtx->opIdx == txCtx->opCount) {
// last operation: show transaction details
if (txCtx->opIdx == txCtx->opCount) {
// last operation
if (txCtx->opDetails.sourceAccountPresent) {
// If there is a source account, wait for the user to
// enter the next step after displaying the source account
strcpy(detailCaption, "Op Source");
print_public_key(txCtx->opDetails.sourceAccount, detailValue, 0, 0);
push_to_formatter_stack(&format_confirm_transaction_details);
} else {
// Otherwise, go to the next step and display the transaction information.
format_confirm_transaction_details(txCtx);
}
} else {
// more operations
if (txCtx->opDetails.sourceAccountPresent) {
// If there is a source account, wait for the user to
// enter the next step after displaying the source account
strcpy(detailCaption, "Op Source");
print_public_key(txCtx->opDetails.sourceAccount, detailValue, 0, 0);
push_to_formatter_stack(&format_next_operation);
} else {
// more operations: show next operation
formatter_stack[formatter_index] = NULL;
set_state_data(true);
// Otherwise, show the next operation.
format_next_operation(txCtx);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/src/test_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static const char *testcases[] = {
"../testcases/txInflation.raw",
"../testcases/txBumpSequence.raw",
"../testcases/txManageBuyOffer.raw",
"../testcases/txMultiOpWithSource.raw",
NULL,
};

Expand Down
Binary file added tests/testcases/txMultiOpWithSource.raw
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/testcases/txMultiOpWithSource.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Operation 1 of 2;
Merge Account; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I
Destination; GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD
Op Source; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I
Operation 2 of 2;
Allow Trust; JPY
Account ID; GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD
Op Source; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I
Memo Text; multi-op-with-source
Fee; 0.00002 XLM
Network; Test
Tx Source; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I

0 comments on commit 985506e

Please sign in to comment.