Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the jump problem in format_operation_source #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should jump to display transaction information after the last operation display is completed.

} 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