metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

[Bug]: ERC20 swap attempt does not succeed on Ledger account when token spending approval is required

Open plasmacorral opened this issue 1 year ago • 1 comments

Describe the bug

Attempted to swap an ERC20 and the approval tx was presented to the Ledger device, and was approved on network. However, the actual swap transaction was never presented to the Ledger device. This was observed both with the default Ethereum app v1.10.3 setting of blind signing off, as well as when blind signing was enabled.

Initial attempt to swap Dai to Shib approval. Then I came back and attempted to swap Dai for Shib a second time relying on that earlier approval, and was successful after enabling blind signing on the Ledger Ethereum app. Then I observed this dangling approval when I attempted to swap GRT to USDC, and was left with just the approval and the actual swap was never presented to Ledger device.

Expected behavior

User attempting an ERC20 swap should have two approvals on the Ledger device. The first for the spending approval and the second for the actual swap.

Actual results: Approval is presented for signing, but swap itself is lost and never presented on Ledger

Screenshots/Recordings

Recording: https://recordit.co/Vg7MLtediW

Steps to reproduce

  1. Setup MMM with an existing SRP
  2. Add Ledger address to MMM
  3. Attempt mainnet swap of an ERC20 that requires a token spending approval
  4. Note that approval tx is sent to Ledger, but the swap itself never appears at the Ledger device or in the MMM activity for the token being swapped out

Error messages or log output

No response

Version

7.17.0

Build type

None

Device

Iphone Xs running iOS 17.3.1

Operating system

iOS

Additional context

This occurs regardless of whether blind signing is enabled or disabled in the Ledger Ethereum app (v1.10.3 tested)

Severity

No response

plasmacorral avatar Feb 22 '24 04:02 plasmacorral

related https://github.com/MetaMask/metamask-mobile/pull/8246

plasmacorral avatar Feb 22 '24 04:02 plasmacorral

ios specific issue

angelcheung22 avatar Feb 28 '24 09:02 angelcheung22

Waiting for Gustavo's response on the expected flow to determine if valid bug

angelcheung22 avatar Feb 28 '24 09:02 angelcheung22

In the observed scenario on the Polygon network, an approval transaction was successfully sent to the Ledger, but the actual swap transaction did not initially proceed. This was tested using an iPhone XS running iOS 17.3.1, and the LNX device running firmware version 2.2.3.

A detailed demonstration is provided in this video, where it was necessary to initiate the swap transaction a second time, following the successful approval. It's important to note that the video's resolution does not clearly showcase the LNX device's display, but it is crucial to highlight that the LNX screen displayed the transaction as Approval and indicated the amount in the ERC20 token (AAVE) being swapped. The transaction hash provided confirms that the displayed number, although difficult to read on the LNX device in the video, matches the 0.000194 custom spend limit entered into MMM, which is accurately represented as hex in the transaction data (...b07125162000).

plasmacorral avatar Feb 28 '24 14:02 plasmacorral

Observed today with a swap on Polygon, using Android 14 Pixel 5a with LNX fw 2.2.3 and eth app 1.10.3. Approval is sent to Ledger device, but the actual swap does not appear.

https://www.loom.com/share/131276669965400585bbd41f99861705?sid=20ff5692-d211-421d-a5ba-f8858cff9d79

plasmacorral avatar Feb 28 '24 17:02 plasmacorral

waiting for funds to retry the sceanrio.

angelcheung22 avatar Feb 29 '24 08:02 angelcheung22

Update on our latest findings:

  • Ledger flow is specific as it needs the confirmation modal to be displayed twice (once for approval, once for swap transaction)
  • We potentially need to modify the way the ledger confirmation modal is called and we need first to fully understand how this modal is triggered from the swap flow (we probably need some help from @gantunesr on this particular point)

Update from 29th of March This is some kind of UI only issue. We need to find a way for modal to be completely dismissed before opening it again (as it's routing driven, it's quite hard to manage)

Akaryatrh avatar Mar 26 '24 09:03 Akaryatrh

Quick update: a temporary fix has been proposed (please see link above), but:

  • we may try to integrate the recommended modal component to see if it helps resolving the issue
  • IMO we should not have a succession of modal displayed but just one modal that will sit on screen until both transactions are confirmed (not sure if it's feasible though)

Akaryatrh avatar Apr 09 '24 13:04 Akaryatrh