-
Notifications
You must be signed in to change notification settings - Fork 246
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
Rifeljm/#622 walletconnect bypass readonly commands #2055
base: main
Are you sure you want to change the base?
Conversation
d9f0824
to
7e8243e
Compare
<Typography variant="body2"> | ||
<Trans>Bypass confirmation for all read-only commands</Trans> | ||
</Typography> |
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.
Tweak wording and add an informative tooltip on hover.
TooltipIcon
needs to be imported from @chia-network/core
<Typography variant="body2"> | |
<Trans>Bypass confirmation for all read-only commands</Trans> | |
</Typography> | |
<Flex flexDirection="row" alignItems="center" gap={1}> | |
<Typography variant="body2"> | |
<Trans>Skip confirmation for all read-only commands</Trans> | |
</Typography> | |
<TooltipIcon> | |
<Trans> | |
By default, a prompt will be presented each time a WalletConnect command is invoked. Select this option if | |
you would like to skip the prompt for all read-only WalletConnect commands. | |
<p /> | |
Commands that create a transaction or otherwise modify your wallet will still require confirmation. | |
</Trans> | |
</TooltipIcon> | |
</Flex> | |
</Flex> |
|
The new
|
@@ -45,6 +46,9 @@ export default function SettingsIntegration() { | |||
useWalletConnectPairs(); | |||
|
|||
const pairs = get(); | |||
const { data: fingerprint } = useGetLoggedInFingerprintQuery(); | |||
|
|||
const [bypassReadonlyCommands, setBypassReadonlyCommands] = useLocalStorage<any>('bypass-readonly-commands', {}); |
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.
Is there a reason not to use the useWalletConnectPairs
or useWalletConnectPreferences
hooks? Creating a new localStorage item is going to make maintenance more complex. At the very least we should make the naming of these localStorage items consistent -- maybe walletConnectBypassReadonlyCommands
. But I would prefer using the existing hooks if possible.
@@ -334,6 +341,31 @@ export default function SettingsIntegration() { | |||
</Box> | |||
)} | |||
</Flex> | |||
<Box {...borderStyle}> | |||
<Typography variant="h6"> | |||
<Trans>Skip Confirmation For All Readonly Commands</Trans> |
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.
"Read-only"
for consistency
}} | ||
> | ||
<MenuItem value> | ||
<Trans>Always Skip</Trans> |
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.
What do you think about using "Always Allow" instead of "Always Skip"?
<Trans>Always Skip</Trans> | |
<Trans>Always Allow</Trans> |
let skipReadOnlyObject = {}; | ||
selectedFingerprints.forEach((f: number) => { | ||
skipReadOnlyObject = { ...skipReadOnlyObject, [f]: true }; | ||
}); | ||
setBypassReadonlyCommands({ ...bypassReadonlyCommands, [topic.toString()]: skipReadOnlyObject }); |
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.
It seems odd to create a nested data structure to hold a boolean. The data structure could be simplified to:
{
<topic_1>: [fingerprint_1, fingerprint_2],
<topic_2>: [fingerprint_3]
}
If the fingerprint is in the list, bypass confirmation is enabled. If it's not, then confirmation is required.
bypassConfirm, | ||
onChange: handleChangeParam, | ||
}); | ||
const isReadOnlyEnabled = bypassReadonlyCommands?.[pairedTopic]?.[fingerprint]; |
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.
Can we rename this to something like skipConfirmation
?
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.
Some edge cases and UX refinement to be ironed-out.
I'm seeing issues with the latest changes. Setting the checkbox to bypass readonly commands during pairing doesn't seem to take effect -- the walletConnectPreferences localStorage item isn't updated. |
'This PR has been flagged as stale due to no activity for over 60 |
No description provided.