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: token approvals from nested transactions in simulation details #30511

Open
wants to merge 19 commits into
base: feat/atomic-batch-transactions
Choose a base branch
from

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Feb 21, 2025

Description

Decode approvals from nested transaction data and include them in the simulation details.

Specifically:

  • Add BatchSimulationDetails component to display simulation details including approvals.
  • Add useBatchApproveBalanceChanges hook to generate balance changes for approvals.
  • Add optional staticRows property to SimulationDetails to display additional static data.
  • Add parseApprovalTransactionData function to shared utils to centralise approval data parsing.
  • Add buildXTransactionData helper functions to avoid hardcoding transaction data strings.
  • Add isApproval, isAllApproval, and isUnlimitedApproval to BalanceChange type.
  • Extend AmountPill to support approval styles and handle unlimited and all.
  • Extend BalanceChangeRow to include edit icon if onEdit provided in balance change.
  • Extend EditSpendingCapModal to support optional data and to properties.

Note that edit approval will not submit as it is pending an additional ticket to connect to a new method from the TransactionController.

Open in GitHub Codespaces

Related issues

Fixes #4283

Manual testing steps

Screenshots/Recordings

Before

After

Confirmation Edit Modal Storybook

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.

@matthewwalsh0 matthewwalsh0 added the team-confirmations Push issues to confirmations team label Feb 21, 2025
@matthewwalsh0 matthewwalsh0 added the DO-NOT-MERGE Pull requests that should not be merged label Feb 21, 2025
@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review February 21, 2025 23:40
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner February 21, 2025 23:40
const { args, name } = transactionDescription ?? {};

if (
!['approve', 'increaseAllowance', 'setApprovalForAll'].includes(name ?? '')
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can compare token method names by leveraging the TransactionTypes like we do in determineTransactionType, instead of hardcoding the strings?

Copy link
Member Author

@matthewwalsh0 matthewwalsh0 Feb 24, 2025

Choose a reason for hiding this comment

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

We technically could, but it's coincidence that the types match the names as some of the transaction types for example don't align with any contract methods.

Though I'm not opposed to using a central enum, assuming one exists or we add one.

@@ -48,7 +67,25 @@ export const BalanceChangeRow: React.FC<{
style={{ minWidth: 0 }}
>
<Box display={Display.Flex} flexDirection={FlexDirection.Row} gap={1}>
<AmountPill asset={asset} amount={amount} />
{onEdit && (
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a great addition, and directly addresses a pain point recently reported internally. 🔥 See https://consensys.slack.com/archives/C03ETQA9EPK/p1739549199067819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO-NOT-MERGE Pull requests that should not be merged team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants