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

Block confirming dangerous actions #271

Merged
merged 3 commits into from
Jun 24, 2022
Merged

Block confirming dangerous actions #271

merged 3 commits into from
Jun 24, 2022

Conversation

lukaw3d
Copy link
Member

@lukaw3d lukaw3d commented Jun 15, 2022

Related to #243

Disables Confirm button in #236 for the following warnings:

  • confirmTransferringToValidator
  • confirmDepositingToParatimeToForeignAccount (except in Emerald paratime)
  • confirmWithdrawingFromParatimeToForeignAccount
  • confirmDepositingToParatimeToLedgerAccount

Related to oasisprotocol/wallet@699336f

Copy link
Contributor

@pro-wh pro-wh left a comment

Choose a reason for hiding this comment

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

didn't understand what I read, but it looks pretty unthreatening of an implementation.

other than the implementation, we discussed in some brief meetings that the team wants to move the extension in this direction. so it is on behalf of our whole team that I formally enter this change as approved.

currentClassName = cx("click-cursor",{
"common-button": true,
[propsClass]: true,
currentClassName = cx("common-button", propsClass, {
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this part do? I don't know react.

getting rid of click-cursor? two-arg cx to three-arg cx? what is cx?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://www.npmjs.com/package/classnames

classNames('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux'
classNames(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'

In case of our disabled button:

  • original

    cx("click-cursor", {
      "common-button": true, 
      ["account-common-btn account-common-btn-danger"]: true, 
      "click-cursor": false, 
      "click-cursor-disable": true,
    })
    // => "click-cursor common-button account-common-btn account-common-btn-danger click-cursor-disable"
  • removed needless unconditional click-cursor. CSS context

    .click-cursor { cursor: pointer; }
    .click-cursor-disable { cursor: not-allowed; }
    cx({
      "common-button": true, 
      ["account-common-btn account-common-btn-danger"]: true, 
      "click-cursor": false, 
      "click-cursor-disable": true,
    })
    // => "common-button account-common-btn account-common-btn-danger click-cursor-disable"
  • used unconditional classes like a normal person (and typescript didn't like newly-typed propsClass: string | undefined as an object key)

    cx("common-button", "account-common-btn account-common-btn-danger", {
      "click-cursor": false, 
      "click-cursor-disable": true,
    })
    // => "common-button account-common-btn account-common-btn-danger click-cursor-disable"

Copy link
Contributor

Choose a reason for hiding this comment

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

ok yeah that old one was really weird. probably written without an understanding of cx.

"confirmWantToContinue": "Are you sure you want to continue?",
"confirmTransferringToValidator": "This is a validator wallet address. Transfers to this address do not stake your funds with the validator.",
"confirmDepositingToParatimeToForeignAccount": "Destination account is not in your wallet! We recommend you always deposit into your own ParaTime account, then transfer from there.",
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we get rid of it? this PR adds no new references to this. were there broken references before this?

Copy link
Member Author

Choose a reason for hiding this comment

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

#239 (comment)
had broken reference after we removed this warning from emerald. I didn't notice it was still used for cipher

Comment on lines -45 to +46
"confirmTransferringToValidator": "This is a validator wallet address. Transfers to this address do not stake your funds with the validator.",
"confirmWantToContinue": "Are you sure you want to continue?",
"confirmTransferringToValidator": "This is a validator wallet address. Transfers to this address do not stake your funds with the validator.",
Copy link
Contributor

Choose a reason for hiding this comment

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

ℹ️ moved unchanged

Copy link
Member Author

Choose a reason for hiding this comment

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

All four warnings are now neatly together in the translation :D

@pro-wh
Copy link
Contributor

pro-wh commented Jun 23, 2022

users who must still do these non-recommended transactions using this software: for the time being, un-disable the button in the dev tools. in the longer term, migrate to using the CLI for these "I know what I'm doing" actions

@@ -869,6 +869,7 @@ class SendPage extends React.Component {
/>
<Button
content={getLanguage('confirm')}
disabled
Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, removing this in devtools doesn't fix click

Copy link
Contributor

@pro-wh pro-wh Jun 23, 2022

Choose a reason for hiding this comment

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

how does disabled work in the Button component?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh it goes into <button disabled={disabled}>

Copy link
Member Author

Choose a reason for hiding this comment

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

Button just forwards it to button, then react does a lot of magic that I don't know.
Either react doesn't attach the listener when it creates a disabled button, or it ignores events based on internal props without looking at changed html.

But this is probably involved https://github.com/facebook/react/blob/9abe745/packages/react-dom/src/events/getListener.js#L40

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

Successfully merging this pull request may close these issues.

2 participants