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

Jettons swap #17

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open

Jettons swap #17

wants to merge 17 commits into from

Conversation

fvalette-ledger
Copy link

@fvalette-ledger fvalette-ledger commented Feb 28, 2025

Checklist

  • App update process has been followed
  • Target branch is develop
  • Application version has been bumped

@fvalette-ledger fvalette-ledger added the enhancement New feature or request label Feb 28, 2025
Ease review and code comprehension.
Prerequisite to jetton wallet address check.
move code from transaction_hints.c to jetton.c and add helper function.
this will be requires for jetton swap address check.
and use the new jetton helper functions.
…ansfer.

For a Jetton transfer, transaction message is sent to owner jetton wallet address,
the recipient address is serialized in transaction hints.
Fix some type annotation non py39 compliant (this is the python version
packaged in build/test docker images.

Fix pathlib Path concatenation, do not use hardcoded path separator but
the `/` operator or Path initialization (w/ accepts *args as path fragment
to assemble).
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.72%. Comparing base (6c5ccc2) to head (445682d).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #17   +/-   ##
========================================
  Coverage    68.72%   68.72%           
========================================
  Files            8        8           
  Lines          243      243           
========================================
  Hits           167      167           
  Misses          76       76           
Flag Coverage Δ
unittests 68.72% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Some fixes are weird though, those are not compliant w/ configuration (...)
those changes are not related to the current feature.
those changes are not related to the current feature.
Disposable fix, this will be remove by Pull Request #16
This case shall not occurs as the transaction type is enforced and,
by construction, hints must be valid (also checked).
This is unlikely to got a null pointer here but static analyser
can't figure it out.
@fbeutin-ledger
Copy link

Remember to bump Makefile version

/* if ticker different from `TON`, address to check is a jetton wallet address */
if (strncmp(ticker, "TON", sizeof("TON")) != 0) {
if (!swap_get_jetton_wallet_address(ticker, hash)) {
return;

Choose a reason for hiding this comment

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

Hésite pas à rajouter plein de logs pour ce genre de cas de figure, si un jour on a un pb en prod ça sera bien plus simple à investiguer

return;
}

if (!swap_get_addr_hash_from_path(params, hash, HASH_LEN)) {
return;

Choose a reason for hiding this comment

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

log

}
#endif

if (!swap_check_address_consistency(params, hash)) {
return;

Choose a reason for hiding this comment

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

log

io_send_sw(SW_SWAP_FAILURE);
// unreachable
os_sched_exit(0);
} else {
PRINTF("Valid operation %d\n", G_context.tx_info.transaction.hints_type);
}

Choose a reason for hiding this comment

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

I'm not certain but I think we should be more strict in this check
If we are swapping jettons (currency is not TON) == we require a TRANSACTION_TRANSFER_JETTON
Otherwise we forbid it

Already defined in secure SDK.

if (params->address_parameters == NULL) {
PRINTF("derivation path expected\n");
return;
goto out;

Choose a reason for hiding this comment

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

might as well return false, more explicit and same behavior

if (get_public_key_helper(0, &cdata, &bip32_path_len, bip32_path, &pk_info) != 0) {
PRINTF("Failed to read public key\n");
return;
goto out;

Choose a reason for hiding this comment

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

same

Comment on lines +97 to +99
ret = true;
out:
return ret;

Choose a reason for hiding this comment

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

I can understand using gotos when there is a context to clean but I think having them here does not provide any benefit

Copy link
Author

Choose a reason for hiding this comment

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

The benefit is a cleaner stack frame and single exit point per function.

this already exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants