rainbow-me / rainbow

🌈‒ the Ethereum wallet that lives in your pocket
https://rainbow.me
GNU General Public License v3.0
3.96k stars 628 forks source link

Claim as X #6193

Open benisgold opened 1 month ago

benisgold commented 1 month ago

Fixes APP-1787

I'm sorry about the commits

Context

Two types of claimables:

Transaction: Are claimed on-chain Sponsored: Claims still occur on-chain, but can only be initiated via an off-chain request. Rainbow doesn't always receive a tx confirmation from these claims.

This feature lets users swap/bridge their claimable to other tokens/networks. We sandwich (rap) together the claim + approval/swap/bridge transactions by using our internal raps module, which manages the nonce of each tx to ensure that the user does not execute any other txs while still executing the claim rap. For this reason, the feature is only compatible with transaction-type claimables, since we require the nonce from the claim tx to confidently execute the following transactions. If you see dropdown menus to select tokens/networks to swap to on the claim panel, you are looking at a transaction-type claimable.

High Level Claim Flow

  1. Check that claimStatus = "notReady"
  2. If swap/bridge is necessary, get quote and calculate display values for token amount + native currency value that user will receive.
  3. Estimate gas (for both claim tx + swap/bridge tx if necessary) + build claim tx payload. This step also includes checking user balance to see if they can afford the gas fee + formatting the gas fee for display on the UI.
  4. If gas can be afforded, set claimStatus = "ready". Now the claim button is enabled.

Details on Token/Network Selection

The claimable asset and network should be selected by default. The tokens that appear in the dropdown menu are the claimable asset, ETH, WBTC, DAI, and the native asset of the currently selected network. All networks are available on the dropdown menu. However, not all tokens/networks are compatible. For example, if the selected token is Degen and the user tries to also select ApeChain as the network that wouldn't be possible. To mitigate this, once an item from the first dropdown is selected (whether it is token/network), the options of the 2nd, unused dropdown are automatically constrained by the 1st selection. Each dropdown has a "reset" option that will reset both dropdowns back to the default so they can see all the options again.

Screen recordings / screenshots

Working on it...

What to test

Go to 0xtester.eth and play around with the test claimables there. Also if you have real claimables you can test with that would be amazing. These changes affect sponsored-type claimables too so testing those also would be great too.

linear[bot] commented 2 days ago

APP-1787 Claim as X

brunobar79 commented 1 day ago

Launch in simulator or device for 59a6a3518d1d1eb0e65e5d01e8fc16e1b19f38eb