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

[#22036] fix: max fee issue when swapping from ETH #22048

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

Conversation

mohsen-ghafouri
Copy link
Contributor

@mohsen-ghafouri mohsen-ghafouri commented Feb 10, 2025

fixes #22036

Summary

The Max button fills the send field with all available ETH. This leaves no ETH to pay gas, leading to an error.

To fix this, we need to initially fetches the proposal using the maximum safe amount to determine the estimated gas fees and it display Max Button with corrected value.

As discussed:

Note

To display correct max balance for ETH we should have max fee, and fee comes with swap proposal. in initial state without amount we cannot have fee (As far as I tested, it give us error to get fee without asset amount, let me know if you have any other suggestion), so I just hide the max button till user enter some amount. we have to hide Max button when ever we are fetching gas fee to avoid display wrong amount.

Areas that may be impacted

  • Swap flow

Steps to test

  1. Select ETH for swap
  2. Enter some amount and Max button will appear
  3. Click on the Max button

Result

Simulator.Screen.Recording.-.iPhone.13.-.2025-02-20.at.23.06.58.mp4

status: ready

  1. The max value does not show the exact amount #22186

    • Fixed (checked by dev)
    • Verified (checked by QA)
  2. Validation incorrectly highlighted by red when ETH balance is insufficient for gas covering

    • Fixed (checked by dev)
    • Verified (checked by QA)
  3. unknown asset is shown in the "assets to receive" field when opening swap via long tap

    • Fixed (checked by dev)
    • Verified (checked by QA)
  4. Max value fills entire ETH balance, causing "not enough assets to pay gas fee" error

    • Fixed (checked by dev)
    • Verified (checked by QA)

@mohsen-ghafouri mohsen-ghafouri self-assigned this Feb 10, 2025
@mohsen-ghafouri mohsen-ghafouri requested review from briansztamfater, vkjr and shivekkhurana and removed request for briansztamfater February 10, 2025 17:13
@status-im-auto
Copy link
Member

status-im-auto commented Feb 10, 2025

Jenkins Builds

Click to see older builds (80)
Commit #️⃣ Finished (UTC) Duration Platform Result
59e339a #1 2025-02-10 17:17:11 ~3 min tests 📄log
✔️ 59e339a #1 2025-02-10 17:22:54 ~9 min android-e2e 🤖apk 📲
✔️ 59e339a #1 2025-02-10 17:23:29 ~9 min android 🤖apk 📲
✔️ 59e339a #1 2025-02-10 17:25:25 ~11 min ios 📱ipa 📲
✔️ 00dc6ca #2 2025-02-10 20:53:31 ~4 min tests 📄log
✔️ 00dc6ca #2 2025-02-10 20:57:33 ~9 min android-e2e 🤖apk 📲
✔️ 00dc6ca #2 2025-02-10 20:58:09 ~9 min android 🤖apk 📲
✔️ 00dc6ca #2 2025-02-10 20:59:22 ~10 min ios 📱ipa 📲
✔️ 7876825 #3 2025-02-19 19:06:50 ~4 min tests 📄log
✔️ 7876825 #3 2025-02-19 19:10:55 ~9 min android-e2e 🤖apk 📲
✔️ 7876825 #3 2025-02-19 19:11:30 ~9 min android 🤖apk 📲
✔️ 7876825 #3 2025-02-19 19:15:32 ~13 min ios 📱ipa 📲
✔️ eb5a3ac #6 2025-02-19 22:44:09 ~5 min tests 📄log
✔️ eb5a3ac #6 2025-02-19 22:48:05 ~9 min android-e2e 🤖apk 📲
✔️ eb5a3ac #6 2025-02-19 22:48:38 ~9 min android 🤖apk 📲
✔️ eb5a3ac #6 2025-02-19 22:51:37 ~12 min ios 📱ipa 📲
✔️ 7e25193 #7 2025-02-20 14:22:36 ~4 min tests 📄log
✔️ 7e25193 #7 2025-02-20 14:25:08 ~7 min android 🤖apk 📲
✔️ 7e25193 #7 2025-02-20 14:25:47 ~8 min android-e2e 🤖apk 📲
✔️ 7e25193 #7 2025-02-20 14:29:12 ~11 min ios 📱ipa 📲
✔️ 227c618 #8 2025-02-20 18:50:08 ~4 min tests 📄log
✔️ 227c618 #8 2025-02-20 18:53:41 ~7 min android-e2e 🤖apk 📲
✔️ 227c618 #8 2025-02-20 18:54:12 ~8 min android 🤖apk 📲
✔️ 227c618 #8 2025-02-20 18:56:32 ~10 min ios 📱ipa 📲
4f4b9a8 #9 2025-02-20 20:07:54 ~3 min tests 📄log
✔️ 4f4b9a8 #9 2025-02-20 20:13:22 ~8 min android-e2e 🤖apk 📲
✔️ 4f4b9a8 #9 2025-02-20 20:14:05 ~9 min android 🤖apk 📲
✔️ 4f4b9a8 #9 2025-02-20 20:17:25 ~12 min ios 📱ipa 📲
d2bea1b #10 2025-02-20 20:42:18 ~3 min tests 📄log
✔️ d2bea1b #10 2025-02-20 20:45:45 ~6 min android-e2e 🤖apk 📲
✔️ d2bea1b #10 2025-02-20 20:47:36 ~8 min android 🤖apk 📲
✔️ d2bea1b #10 2025-02-20 20:49:47 ~10 min ios 📱ipa 📲
159e225 #11 2025-02-20 20:56:40 ~3 min tests 📄log
✔️ 159e225 #11 2025-02-20 21:00:29 ~6 min android-e2e 🤖apk 📲
✔️ 159e225 #11 2025-02-20 21:01:43 ~8 min android 🤖apk 📲
✔️ 159e225 #11 2025-02-20 21:04:12 ~10 min ios 📱ipa 📲
✔️ 82891db #12 2025-02-20 21:16:54 ~5 min tests 📄log
✔️ 82891db #12 2025-02-20 21:20:48 ~9 min android-e2e 🤖apk 📲
✔️ 82891db #12 2025-02-20 21:21:21 ~9 min android 🤖apk 📲
✔️ 82891db #12 2025-02-20 21:22:23 ~10 min ios 📱ipa 📲
✔️ 8eae5a2 #15 2025-02-21 12:27:40 ~4 min tests 📄log
✔️ 8eae5a2 #15 2025-02-21 12:31:08 ~8 min android-e2e 🤖apk 📲
✔️ 8eae5a2 #15 2025-02-21 12:31:30 ~8 min android 🤖apk 📲
✔️ 8eae5a2 #15 2025-02-21 12:34:59 ~12 min ios 📱ipa 📲
✔️ 8664c48 #16 2025-02-24 05:45:52 ~5 min tests 📄log
✔️ 8664c48 #16 2025-02-24 05:49:38 ~8 min android-e2e 🤖apk 📲
✔️ 8664c48 #16 2025-02-24 05:50:23 ~9 min android 🤖apk 📲
✔️ 8664c48 #16 2025-02-24 05:52:22 ~11 min ios 📱ipa 📲
✔️ 89bf675 #17 2025-02-24 15:06:05 ~4 min tests 📄log
✔️ 89bf675 #17 2025-02-24 15:08:21 ~7 min android-e2e 🤖apk 📲
✔️ 89bf675 #17 2025-02-24 15:10:05 ~8 min android 🤖apk 📲
✔️ 89bf675 #17 2025-02-24 15:14:34 ~13 min ios 📱ipa 📲
✔️ 1665301 #18 2025-02-25 07:52:56 ~5 min tests 📄log
✔️ 1665301 #18 2025-02-25 07:56:50 ~9 min android-e2e 🤖apk 📲
✔️ 1665301 #18 2025-02-25 07:57:23 ~9 min android 🤖apk 📲
✔️ 1665301 #18 2025-02-25 07:59:19 ~11 min ios 📱ipa 📲
✔️ 5529929 #19 2025-02-25 14:23:03 ~5 min tests 📄log
✔️ 5529929 #19 2025-02-25 14:27:02 ~9 min android-e2e 🤖apk 📲
✔️ 5529929 #19 2025-02-25 14:27:29 ~9 min android 🤖apk 📲
✔️ 5529929 #19 2025-02-25 14:32:21 ~14 min ios 📱ipa 📲
✔️ cea972e #20 2025-02-25 16:57:39 ~4 min tests 📄log
✔️ cea972e #20 2025-02-25 17:01:51 ~9 min android-e2e 🤖apk 📲
✔️ cea972e #20 2025-02-25 17:02:25 ~9 min android 🤖apk 📲
✔️ cea972e #20 2025-02-25 17:03:34 ~10 min ios 📱ipa 📲
0197b7f #21 2025-02-25 17:10:44 ~3 min tests 📄log
✔️ 0197b7f #21 2025-02-25 17:15:08 ~8 min android-e2e 🤖apk 📲
✔️ 0197b7f #21 2025-02-25 17:15:44 ~8 min android 🤖apk 📲
✔️ 0197b7f #21 2025-02-25 17:18:20 ~11 min ios 📱ipa 📲
1e341b7 #22 2025-02-25 17:30:06 ~3 min tests 📄log
✔️ 1e341b7 #22 2025-02-25 17:33:56 ~6 min android-e2e 🤖apk 📲
✔️ 1e341b7 #22 2025-02-25 17:35:11 ~8 min android 🤖apk 📲
✔️ 1e341b7 #22 2025-02-25 17:37:37 ~10 min ios 📱ipa 📲
✔️ 047e3d3 #23 2025-02-25 17:53:23 ~4 min tests 📄log
✔️ 047e3d3 #23 2025-02-25 17:55:22 ~6 min android-e2e 🤖apk 📲
✔️ 047e3d3 #23 2025-02-25 17:56:59 ~8 min android 🤖apk 📲
✔️ 047e3d3 #23 2025-02-25 17:59:24 ~10 min ios 📱ipa 📲
✔️ 2122cd2 #24 2025-02-26 12:19:15 ~4 min tests 📄log
✔️ 2122cd2 #24 2025-02-26 12:21:36 ~7 min android 🤖apk 📲
✔️ 2122cd2 #24 2025-02-26 12:22:21 ~7 min android-e2e 🤖apk 📲
✔️ 2122cd2 #24 2025-02-26 12:26:02 ~11 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ e76d550 #25 2025-02-27 15:24:32 ~10 min tests 📄log
✔️ e76d550 #25 2025-02-27 15:25:25 ~11 min android-e2e 🤖apk 📲
✔️ e76d550 #25 2025-02-27 15:26:47 ~12 min ios 📱ipa 📲
✔️ e76d550 #25 2025-02-27 15:26:48 ~12 min android 🤖apk 📲
✔️ fd0c792 #26 2025-03-11 18:57:12 ~5 min tests 📄log
✔️ fd0c792 #26 2025-03-11 19:00:59 ~8 min android-e2e 🤖apk 📲
✔️ fd0c792 #26 2025-03-11 19:01:44 ~9 min android 🤖apk 📲
✔️ fd0c792 #26 2025-03-11 19:03:34 ~11 min ios 📱ipa 📲

@shivekkhurana shivekkhurana added the wallet-core Issues for mobile wallet team label Feb 11, 2025
Copy link
Contributor

@shivekkhurana shivekkhurana left a comment

Choose a reason for hiding this comment

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

Left a few notes.

@mohsen-ghafouri mohsen-ghafouri marked this pull request as draft February 17, 2025 22:20
@mohsen-ghafouri mohsen-ghafouri force-pushed the fix/max-fee-button branch 5 times, most recently from eb5a3ac to 7e25193 Compare February 20, 2025 14:17
@@ -309,3 +309,40 @@
(-> collectible
transforms/json->clj
transform-collectible))

(defn- bridge-amount-greater-than-bonder-fees?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just moved them from send.event to data-store file so i can used in swap as well.

@@ -583,3 +584,82 @@
[:dispatch
[:navigate-to-within-stack
[:screen/wallet.swap-select-asset-to-pay :screen/wallet.swap-select-account]]]])})))

(rf/reg-event-fx :wallet/get-swap-proposal-fee
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a simplified version of :wallet/start-get-swap-proposal, designed to fetch only the relevant fee fields early using a synchronous RPC call.

@mohsen-ghafouri mohsen-ghafouri force-pushed the fix/max-fee-button branch 4 times, most recently from 159e225 to 82891db Compare February 20, 2025 21:11
@mohsen-ghafouri mohsen-ghafouri marked this pull request as ready for review February 20, 2025 21:21
@mohsen-ghafouri mohsen-ghafouri requested a review from vkjr February 20, 2025 21:21
@mohsen-ghafouri
Copy link
Contributor Author

@VolodLytvynenko as i checked issue 3, the design related to that flow is https://www.figma.com/design/AD2JSKg0I8dZcylyiGa62O/Swap-for-Mobile?node-id=76-132707&t=6IkldMKUJdS0jXw5-4, so we should red highlight when user try to enter an amount above available amount (total balance - fee)

@mohsen-ghafouri
Copy link
Contributor Author

I applied changes about Max Button label (it shows exact amount now), also i couldn't reproduce the issue 3, can be related to when USDC is not available temporary. I couldn't find any clue how it happens. from everywhere that i tested, it shows USDC for ETH.

Please let me know if any other issue remain for this PR. thanks @VolodLytvynenko

Simulator.Screen.Recording.-.iPhone.13.-.2025-02-25.at.17.19.03.mp4

@VolodLytvynenko
Copy link
Contributor

@VolodLytvynenko as i checked issue 3, the design related to that flow is https://www.figma.com/design/AD2JSKg0I8dZcylyiGa62O/Swap-for-Mobile?node-id=76-132707&t=6IkldMKUJdS0jXw5-4, so we should red highlight when user try to enter an amount above available amount (total balance - fee)

@mohsen-ghafouri the screen you share related to another case.

  1. If the entered value is higher than the user's balance (e.g., the user has 1 USDT but enters 2 USDT), the field should be highlighted in red (as shown in your screenshot).

  2. However, there is a different case is when the user has 1 USDT but no ETH to cover the fee. A completely different UI validation is designed for this scenario. You can find the design here.

but, this is a low-priority issue and can be considered as a follow-up.

@VolodLytvynenko
Copy link
Contributor

@mohsen-ghafouri one more issue is found. Take a look please #22191

@mohsen-ghafouri
Copy link
Contributor Author

@VolodLytvynenko as i checked issue 3, the design related to that flow is https://www.figma.com/design/AD2JSKg0I8dZcylyiGa62O/Swap-for-Mobile?node-id=76-132707&t=6IkldMKUJdS0jXw5-4, so we should red highlight when user try to enter an amount above available amount (total balance - fee)

@mohsen-ghafouri the screen you share related to another case.

  1. If the entered value is higher than the user's balance (e.g., the user has 1 USDT but enters 2 USDT), the field should be highlighted in red (as shown in your screenshot).
  2. However, there is a different case is when the user has 1 USDT but no ETH to cover the fee. A completely different UI validation is designed for this scenario. You can find the design here.

but, this is a low-priority issue and can be considered as a follow-up.

I believe this was implemented before the new flow. For other assets, we don’t know the fee upfront, so the fee error only shows after the user fills in the amount and receives a quote. But for ETH, since we have the fee available, we can consider it as the user types the amount—if it exceeds the available balance minus the fee, we display a red highlight to indicate that they should reduce the amount.

CC @shivekkhurana @xAlisher

@mohsen-ghafouri
Copy link
Contributor Author

@VolodLytvynenko issue #22191 and Issue #22188 resolved. could you please check again.

@mohsen-ghafouri mohsen-ghafouri force-pushed the fix/max-fee-button branch 2 times, most recently from 1e341b7 to 047e3d3 Compare February 25, 2025 17:48
@status-im-auto
Copy link
Member

71% of end-end tests have passed

Total executed tests: 14
Failed tests: 4
Expected to fail tests: 0
Passed tests: 10
IDs of failed tests: 727230,741839,702843,727229 

Failed tests (4)

Click to expand
  • Rerun failed tests

  • Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843

    Device 1: Find `EmojisNumber` by `xpath`: `//*[starts-with(@text,'Message AFTER edit 2 (Edited)')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']/../..//*[@content-desc='emoji-reaction-2']/android.widget.TextView[2]`
    Device 1: Element EmojisNumber text is equal to 1

    critical/chats/test_public_chat_browsing.py:388: in test_community_message_edit
        self.errors.verify_no_errors()
    base_test_case.py:179: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Device 2: Message is not edited
    



    Device sessions

    Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230

    # STEP: Getting ETH amount in the wallet of the receiver before transaction
    Device 2: Find Button by xpath: //android.view.ViewGroup[contains(@content-desc,'Account 1')]

    critical/wallet/test_wallet_testnet.py:173: in test_wallet_send_asset_from_drawer
        eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx()
    critical/wallet/test_wallet_testnet.py:45: in _get_balances_before_tx
        self.wallet_2.get_account_element().click()
    ../views/base_element.py:89: in click
        element = self.find_element()
    ../views/base_element.py:78: in find_element
        raise NoSuchElementException(
     Device 2: Button by xpath: `//android.view.ViewGroup[contains(@content-desc,'Account 1')]` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    2. test_wallet_send_eth, id: 727229

    Device 1: Tap on found: Button
    Device 2: Find Button by accessibility id: network-dropdown

    critical/wallet/test_wallet_testnet.py:156: in test_wallet_send_eth
        self._check_balances_after_tx(amount_to_send, None, None, eth_amount_sender, eth_amount_receiver)
    critical/wallet/test_wallet_testnet.py:94: in _check_balances_after_tx
        self.wallet_2.set_network_in_wallet(network_name=self.network)
    ../views/wallet_view.py:184: in set_network_in_wallet
        self.network_drop_down.click()
    ../views/base_element.py:89: in click
        element = self.find_element()
    ../views/base_element.py:78: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `network-dropdown` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Class TestWalletCollectibles:

    1. test_wallet_collectibles_balance, id: 741839

    # STEP: Check BVL collectible info and image
    # STEP: Check Glitch Punks collectible info and image

    critical/wallet/test_collectibles.py:94: in test_wallet_collectibles_balance
        self.errors.verify_no_errors()
    base_test_case.py:179: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Device 1: Collectible 'BVL' is not displayed
    E    Device 1: Collectible 'Glitch Punks' is not displayed
    



    Passed tests (10)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    2. test_wallet_swap_flow_mainnet, id: 741555
    3. test_wallet_balance_mainnet, id: 740490
    4. test_wallet_bridge_flow_mainnet, id: 741612
    5. test_wallet_send_flow_mainnet, id: 741554

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_profile_switch, id: 703133
    Device sessions

    2. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    Class TestWalletCollectibles:

    1. test_wallet_send_collectible, id: 741840
    2. test_wallet_collectible_send_from_expanded_info_view, id: 741841

    @@ -29,6 +29,15 @@
    :account account
    :test-networks-enabled? test-networks-enabled?
    :token-symbol (get-in data [:asset-to-pay :symbol])}))
    received-asset (if-not (nil? asset-to-receive)
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    currently default assets for new account are "ETH", "DAI" and "SNT", I added this part to fallback to "SNT" if there is no "USDC" in user's account, we can remove this part after we implement #22160

    @status-im-auto
    Copy link
    Member

    79% of end-end tests have passed

    Total executed tests: 14
    Failed tests: 3
    Expected to fail tests: 0
    Passed tests: 11
    
    IDs of failed tests: 741839,702745,702843 
    

    Failed tests (3)

    Click to expand
  • Rerun failed tests

  • Class TestWalletCollectibles:

    1. test_wallet_collectibles_balance, id: 741839

    # STEP: Check BVL collectible info and image
    # STEP: Check Glitch Punks collectible info and image

    critical/wallet/test_collectibles.py:94: in test_wallet_collectibles_balance
        self.errors.verify_no_errors()
    base_test_case.py:179: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Device 1: Collectible 'BVL' is not displayed
    E    Device 1: Collectible 'Glitch Punks' is not displayed
    



    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745

    Device 1: Looking for chat: 'shVmyBJKutC98njmwaNc'
    Device 1: Click until ChatMessageInput by accessibility id: chat-message-input will be presented

    critical/chats/test_1_1_public_chats.py:291: in test_1_1_chat_non_latin_messages_stack_update_profile_photo
        self.home_1.get_chat(self.username_2).click()
    ../views/home_view.py:61: in click
        self.click_until_presence_of_element(desired_element=desired_element)
    ../views/base_element.py:109: in click_until_presence_of_element
        raise NoSuchElementException("%s element not found" % desired_element.name)
     ChatMessageInput element not found; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843

    Device 1: Wait for text element EmojisNumber to be equal to 1
    Device 1: Find EmojisNumber by xpath: //*[starts-with(@text,'Message AFTER edit 2 (Edited)')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']/../..//*[@content-desc='emoji-reaction-2']/android.widget.TextView[2]

    critical/chats/test_public_chat_browsing.py:388: in test_community_message_edit
        self.errors.verify_no_errors()
    base_test_case.py:179: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Device 1: Message reaction is not shown for the sender
    



    Device sessions

    Passed tests (11)

    Click to expand

    Class TestWalletCollectibles:

    1. test_wallet_collectible_send_from_expanded_info_view, id: 741841
    2. test_wallet_send_collectible, id: 741840

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_profile_switch, id: 703133
    Device sessions

    2. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230
    2. test_wallet_send_eth, id: 727229

    Class TestWalletOneDevice:

    1. test_wallet_swap_flow_mainnet, id: 741555
    2. test_wallet_add_remove_regular_account, id: 727231
    3. test_wallet_bridge_flow_mainnet, id: 741612
    4. test_wallet_balance_mainnet, id: 740490
    5. test_wallet_send_flow_mainnet, id: 741554

    @mohsen-ghafouri
    Copy link
    Contributor Author

    Hey @vkjr @briansztamfater @clauxx @smohamedjavid @alwx, I would like to have more eyes on this PR if you have time please.

    Comment on lines +92 to +97
    (defn button-loader
    [theme]
    {:width 100
    :height 22
    :border-radius 6
    :background-color (loader-color theme)})
    Copy link
    Member

    Choose a reason for hiding this comment

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

    i noticed in the last video that the pay input size changes slightly when the balance button is loaded. Could be due to the height of the loader.

    from-locked-amount {}
    send-type constants/send-type-swap
    request-uuid (str (random-uuid))
    params [(cond->
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    This is quite a duplication of functionality with :wallet/start-get-swap-proposal and it also duplicates all the "not-so-good-patterns". For example, to-address and from-address are useless variables that can be substituted with wallet-address. disabled-to-chain-ids and disabled-from-chain-ids are identical, and so on.

    Instead of duplicating it we can create a separate function that will prepare parameters for get-suggested-routes. Something like params-for-swap-routes-request That function can get db as an argument and encapsulate all the commonalities between :wallet/get-swap-proposal-fee and :wallet/start-get-swap-proposal. All the differences can go in additional args. Also as a bonus it will hide the list of status-go parameters from event.
    Wdyt?

    Copy link
    Member

    Choose a reason for hiding this comment

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

    +1 on this. There's too much duplication with the router events.

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Sure let me see if i can transfer some logic to utils or in specific sub,

    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    I believe a function in the same file that has common logic between :wallet/start-get-swap-proposal and yours :wallet/get-swap-proposal-fee would be sufficient

    @VolodLytvynenko
    Copy link
    Contributor

    Hi @mohsen-ghafouri . Could you please resolve any conflicts and rebase the current PR? Thanx!

    @mohsen-ghafouri
    Copy link
    Contributor Author

    Hey @VolodLytvynenko, sure. it requires some adjustment regarding latest feedback, will let you know once it's being ready

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    Status: CONTRIBUTOR
    Development

    Successfully merging this pull request may close these issues.

    👛 Max fee calculation bug while swapping from ETH
    7 participants