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 e236c2b commit 6522672
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/stellar_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,36 @@ static void format_confirm_transaction_details(tx_context_t *txCtx) {
format_memo(txCtx);
}

static void format_next_operation(tx_context_t *txCtx) {
(void) 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_muxed_account(&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_muxed_account(&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_muxed_account(&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 @@ -43,6 +43,7 @@ static const char *testcases[] = {
"../testcases/txBumpSequence.raw",
"../testcases/txManageBuyOffer.raw",
"../testcases/txPathPaymentStrictSend.raw",
"../testcases/txMultiOpWithSource.raw",
"../testcases/txCreateClaimableBalancePredicateAnd.raw",
"../testcases/txCreateClaimableBalancePredicateBeforeAbs.raw",
"../testcases/txCreateClaimableBalancePredicateBeforeRel.raw",
Expand Down
Binary file added tests/testcases/txMultiOpWithSource.raw
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/testcases/txMultiOpWithSource.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Operation 1 of 2;
Operation Type; Account Merge
Merge Account; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I
Destination; GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD
Op Source; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I
Operation 2 of 2;
Operation Type; Allow Trust
Trustor; GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD
Asset Code; JPY
Authorize Flag; AUTHORIZED_FLAG
Op Source; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I
Memo Text; multi-op-with-source
Fee; 0.00002 XLM
Network; Test
Tx Source; GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I

0 comments on commit 6522672

Please sign in to comment.