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

feat: disable wallet buttons for accounts that cannot sign transactions #11330

Closed
wants to merge 31 commits into from

Conversation

k-g-j
Copy link
Contributor

@k-g-j k-g-j commented Sep 19, 2024

Description

This PR disables certain buttons in the WalletActions component when the selected account cannot sign transactions. This change improves the user experience by preventing attempts to perform actions that require transaction signing when the account cannot do so.

  1. The reason for the change is to prevent users from attempting actions that their current account cannot perform.
  2. The improvement is that Buy, Sell, Send, Swap, and Bridge buttons are now disabled when the selected account cannot sign transactions, providing clear visual feedback to the user about available actions.

Related issues

Fixes: https://github.com/MetaMask/accounts-planning/issues/570

Manual testing steps

  1. Go to the SSK and create an account
  2. Update the account using this JSON, replacing the address and ID fields with the new account information (this update step removes eth_signTransaction from the account's methods)
{
    "id": "your new account ID",
    "address": "you new account address",
    "options": {},
    "methods": [
        "personal_sign",
        "eth_sign",
        "eth_signTypedData_v1",
        "eth_signTypedData_v3",
        "eth_signTypedData_v4"
    ],
    "type": "eip155:eoa"
}
  1. Switch to the account that cannot sign transactions if not already there
  2. Verify that the Buy, Sell, Send, Swap, and Bridge buttons are visually disabled with a message and not clickable
  3. Click on the asset details view
  4. Verify that the Buy, Sell, Send, Swap, and Bridge buttons are visually disabled and not clickable
  5. Switch back to an account that can sign transactions
  6. Verify that the buttons are now enabled and functional in wallet view and asset details view

Screenshots/Recordings

Before

Wallet view

Asset details view
simulator_screenshot_5FB98682-1B94-440A-9E12-BDE6D8B2B1C3

After

Wallet view
Simulator Screenshot - iPhone 15 Pro - 2024-10-24 at 15 43 57

Asset details view
Simulator Screenshot - iPhone 15 Pro - 2024-10-24 at 15 44 06

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@k-g-j k-g-j changed the base branch from main to feat/display-snap-accounts-list September 19, 2024 20:56
@k-g-j k-g-j added area-UI needs-qa Any New Features that needs a full manual QA prior to being added to a release. team-accounts labels Sep 19, 2024
@k-g-j k-g-j changed the base branch from feat/display-snap-accounts-list to main September 23, 2024 15:09
@k-g-j k-g-j marked this pull request as ready for review September 23, 2024 16:34
@k-g-j k-g-j requested a review from a team as a code owner September 23, 2024 16:34
@k-g-j k-g-j added the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 23, 2024
Copy link
Contributor

github-actions bot commented Sep 23, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 0f8068e
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/5ef1ab5f-a183-4616-bbb1-1086411a722d

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@k-g-j k-g-j added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Sep 23, 2024
Copy link
Contributor

github-actions bot commented Sep 23, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: ed95ed3
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/3efa2677-f1bb-4979-8a75-c2aaa4555cfe

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

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

looks good overall, left some minor comments

app/components/UI/WalletAction/WalletAction.types.ts Outdated Show resolved Hide resolved
app/components/UI/WalletAction/WalletAction.types.ts Outdated Show resolved Hide resolved
app/components/Views/WalletActions/WalletActions.test.tsx Outdated Show resolved Hide resolved
@k-g-j k-g-j removed the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 24, 2024
@@ -1237,6 +1238,14 @@
"info": "Info",
"swap": "Swap",
"bridge": "Bridge",
"disabled_button": {
Copy link
Contributor

Choose a reason for hiding this comment

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

@AlexJupiter @eriknson what do you think of this copy?

@k-g-j k-g-j force-pushed the feat/disable-signing-buttons branch from 2613b17 to 7a0a91a Compare September 24, 2024 22:13
@k-g-j k-g-j added the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 26, 2024
Copy link
Contributor

github-actions bot commented Sep 26, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: f5d01a6
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/4b8e980b-bc7a-4554-b6b7-b155a1c30f8d

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@k-g-j k-g-j removed the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 27, 2024
owencraston
owencraston previously approved these changes Sep 27, 2024
@k-g-j k-g-j added the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 27, 2024
Copy link
Contributor

github-actions bot commented Sep 27, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: abda0b1
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/56bd3f1b-5482-4883-a2e9-cfe49cb8cc4f

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@k-g-j k-g-j removed the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 30, 2024
Copy link
Contributor

github-actions bot commented Oct 24, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 153c801
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c590af70-6880-4c18-9f3a-f22061ae6ba2

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@k-g-j k-g-j removed the Run Smoke E2E Triggers smoke e2e on Bitrise label Oct 24, 2024
Copy link
Contributor

@owencraston owencraston left a comment

Choose a reason for hiding this comment

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

Looking very good and very nice 😁 ! The code looks good I just had a few comments/questions about all the memoization of props.

app/components/UI/WalletAction/WalletAction.tsx Outdated Show resolved Hide resolved
onPress={onBuy}
iconStyle={styles.icon}
containerStyle={styles.containerStyle}
{...walletActionProps}
Copy link
Contributor

Choose a reason for hiding this comment

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

I THINK the spread operator here defeats the purpose of the memoization since spreading the object will create a new reference anyway. See this stackoverflow thread. I am not certain about this so please correct me if I am wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

the same goes for the rest of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I THINK you are right

I updated the code in this commit 37077bf so we're not creating new object references unnecessarily, which was defeating the purpose of memoization. It also makes the code more explicit about which props are being passed to each WalletAction component.

actionID={WalletActionsModalSelectorsIDs.BUY_BUTTON}
iconStyle={styles.icon}
{...walletActionBaseProps}
Copy link
Contributor

Choose a reason for hiding this comment

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

same question about spreading the memoized props.

Copy link
Contributor Author

@k-g-j k-g-j Oct 24, 2024

Choose a reason for hiding this comment

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

Same logic as your above comment and my point about creating new object references unnecessarily
addressed here 5685ae6

@owencraston
Copy link
Contributor

you will need to run yarn jest -u pp/components/UI/AssetOverview/AssetOverview.test.tsx to update the snapshot and get your unit tests passing.

@k-g-j k-g-j added the Run Smoke E2E Triggers smoke e2e on Bitrise label Oct 24, 2024
Copy link
Contributor

github-actions bot commented Oct 24, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 21342d7
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/749fe63d-1cb3-43e0-bc1f-9d2a9ebceb56

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

# Conflicts:
#	app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.test.tsx
#	app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.tsx
Copy link

@k-g-j k-g-j enabled auto-merge October 25, 2024 19:39
@plasmacorral plasmacorral removed the Run Smoke E2E Triggers smoke e2e on Bitrise label Oct 29, 2024
@plasmacorral
Copy link
Contributor

Tested on Pixel 5a with Android 14 with commit f714dd1d56a1b22e79b6b53cc8a5668294a22eca. Buttons were enabled in the wallet view bottom bar and asset view when signing was enabled on the snap account, and disabled when signing permission was removed. Re-enabling signing restored the buttons. Checked on Eth mainnet, Sepolia, Base, and Arbitrum. No impact on button display or function for HD, imported, QR, and Ledger accounts.

@plasmacorral plasmacorral added Run Smoke E2E Triggers smoke e2e on Bitrise QA in Progress QA has started on the feature. and removed needs-qa Any New Features that needs a full manual QA prior to being added to a release. labels Oct 29, 2024
@MetaMask MetaMask deleted a comment from github-actions bot Oct 29, 2024
@plasmacorral plasmacorral added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Oct 29, 2024
Copy link
Contributor

github-actions bot commented Oct 29, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: f714dd1
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/b9492f57-5c3f-430e-9c1a-799a0ee86c53

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

const avatarStyle = useMemo(
() => ({
...iconStyle,
backgroundColor: disabled ? colors.primary.muted : colors.primary.default,
Copy link
Contributor

Choose a reason for hiding this comment

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

this disabled change is not needed since the opacity would take care of color change

Copy link
Contributor

@brianacnguyen brianacnguyen left a comment

Choose a reason for hiding this comment

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

1 small request regarding avatar disabled

@owencraston
Copy link
Contributor

Do to difficulty rebasing this PR I am continuing the work over here.

@owencraston owencraston closed this Nov 5, 2024
auto-merge was automatically disabled November 5, 2024 01:54

Pull request was closed

@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-UI needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) QA in Progress QA has started on the feature. Run Smoke E2E Triggers smoke e2e on Bitrise team-accounts
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants