Skip to content

fix: Disable Add to Batch button for safe apps [SW-363]#4623

Merged
usame-algan merged 3 commits intodevfrom
hide-add-to-batch
Dec 10, 2024
Merged

fix: Disable Add to Batch button for safe apps [SW-363]#4623
usame-algan merged 3 commits intodevfrom
hide-add-to-batch

Conversation

@usame-algan
Copy link
Copy Markdown
Contributor

@usame-algan usame-algan commented Dec 6, 2024

What it solves

Resolves SW-363

How this PR fixes it

  • Disables the BatchButton if there is an origin passed (it is a safe app or walletconnect)

How to test it

  1. Create a transaction through a safe app
  2. Choose Sign
  3. Observe Add to batch button is disabled
  4. Create a transaction through the native UI
  5. Observe there is an Add to batch button when signing and it is enabled

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@usame-algan usame-algan requested a review from katspaugh December 6, 2024 15:11
@notion-workspace
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 6, 2024

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Code review by ChatGPT

{isCreation && !isBatch && !isSafeAppTransaction && (
<BatchButton
onClick={onBatchClick}
disabled={submitDisabled || !isBatchable}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ensure the new isSafeAppTransaction variable is meaningful. Its usage is currently limited to a check condition in the render block. Consider consolidating this logic and removing it if it doesn't add clarity or functionality.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 6, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Code review by ChatGPT


expect(button).toBeInTheDocument()
})
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Consider refactoring the repeated render logic into a helper function to adhere to the DRY principle. This reduces redundancy and enhances maintainability.

  2. The usage of queryByText and getByText could lead to inconsistent behavior if the text content changes. Consider using a more robust method like test IDs for querying elements.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 6, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.7% (-0% 🔻)
14364/19490
🔴 Branches
51.05% (-0.01% 🔻)
3415/6689
🔴 Functions
56.43% (+0% 🔼)
2027/3592
🟡 Lines
75.27% (-0.01% 🔻)
13035/17318

Test suite run success

1664 tests passing in 226 suites.

Report generated by 🧪jest coverage report action from fe87c47

const submitDisabled =
!safeTx || !isSubmittable || disableSubmit || cannotPropose || (needsRiskConfirmation && !isRiskConfirmed)

const isSafeAppTransaction = !!origin
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think origin is also non-null in case of WalletConnect txs and probably swaps/staking/bridging as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we should hide it for those transactions as well to be on the safe side. At least for swaps the button is already disabled since it is a delegate call:
Screenshot 2024-12-09 at 10 29 49

@usame-algan usame-algan changed the title fix: Hide Add to Batch button for safe apps [SW-363] fix: Disable Add to Batch button for safe apps [SW-363] Dec 9, 2024
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Code review by ChatGPT

@@ -133,7 +135,7 @@ export const SignForm = ({
{isCreation && !isBatch && (
<BatchButton
onClick={onBatchClick}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The condition for rendering BatchButton has been modified, potentially affecting its visibility logic. Review if excluding !isSafeAppTransaction in the surrounding condition and adding it to the disabled prop aligns with the desired behavior.

@usame-algan
Copy link
Copy Markdown
Contributor Author

Slightly adjusted it so we always show the button but it is disabled to keep it consistent with previous behaviour.

@francovenica
Copy link
Copy Markdown
Contributor

LGTM

Checked that dapps don't have the add to batch button. Same for other types of tx like reject tx, swap, stake, bridge....
Made sure that the tx that must have the add to batch are still there: send funds, edit owner, edit policies, remove modules...

@usame-algan usame-algan merged commit 608d004 into dev Dec 10, 2024
@usame-algan usame-algan deleted the hide-add-to-batch branch December 10, 2024 08:25
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants