-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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. |
Bitrise❌❌❌ Commit hash: 0f8068e Note
Tip
|
Bitrise✅✅✅ Commit hash: ed95ed3 Note
|
There was a problem hiding this 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
@@ -1237,6 +1238,14 @@ | |||
"info": "Info", | |||
"swap": "Swap", | |||
"bridge": "Bridge", | |||
"disabled_button": { |
There was a problem hiding this comment.
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?
2613b17
to
7a0a91a
Compare
Bitrise❌❌❌ Commit hash: f5d01a6 Note
Tip
|
app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.tsx
Outdated
Show resolved
Hide resolved
Bitrise❌❌❌ Commit hash: abda0b1 Note
Tip
|
Bitrise✅✅✅ Commit hash: 153c801 Note
|
There was a problem hiding this 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.
onPress={onBuy} | ||
iconStyle={styles.icon} | ||
containerStyle={styles.containerStyle} | ||
{...walletActionProps} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
you will need to run |
Bitrise✅✅✅ Commit hash: 21342d7 Note
|
# Conflicts: # app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.test.tsx # app/components/Views/AssetDetails/AssetDetailsActions/AssetDetailsActions.tsx
Quality Gate passedIssues Measures |
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. |
Bitrise✅✅✅ Commit hash: f714dd1 Note
|
const avatarStyle = useMemo( | ||
() => ({ | ||
...iconStyle, | ||
backgroundColor: disabled ? colors.primary.muted : colors.primary.default, |
There was a problem hiding this comment.
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
There was a problem hiding this 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
Do to difficulty rebasing this PR I am continuing the work over here. |
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.Related issues
Fixes: https://github.com/MetaMask/accounts-planning/issues/570
Manual testing steps
eth_signTransaction
from the account's methods)Screenshots/Recordings
Before
Wallet view
Asset details view
After
Wallet view
Asset details view
Pre-merge author checklist
Pre-merge reviewer checklist