-
-
Notifications
You must be signed in to change notification settings - Fork 201
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
fix: TransactionController afterSign hook should be allowed to modify the transaction #4343
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
matthewwalsh0
approved these changes
May 31, 2024
This was referenced May 31, 2024
Merged
mcmire
pushed a commit
that referenced
this pull request
May 31, 2024
… the transaction (#4343) > [!NOTE] > This change is intended to be cherry-picked into MetaMask/extension v11.17.0 via an upgrade to the @metamask/transaction-controller package. ## Explanation **Issue:** A recent update to the transaction-controller has made the TransactionMeta object passed to the `afterSign` hook frozen. This change prevents adding new properties, leading to the error: “Cannot add property custodyId, object is not extensible.” This bug is breaking all transactions for MMI as the original txMeta cannot store required properties like custodyId. **Fix:** We deep clone the transaction meta before passing it to the hook. A deep clone is used because transactionMeta is recursively frozen by immer. This fix was intended to minimize the change for the cherry-pick going into v11.17.0. A longer term solution might involve using immer more throughout the TransactionController.ts file to make it clearer when a transactionMeta is being mutated and how. **Testing:** This fix was applied to and verified with the MMI extension. <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? For example: * Fixes #12345 * Related to #67890 --> ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> ### `@metamask/transaction-controller` - **FIXED**: afterSign hook is now able to modify the transaction ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate
zone-live
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Jun 5, 2024
> [!NOTE] > This PR is intended to be cherry-picked into RC 11.17.0 after being merged into develop ## **Description** Upgrade transaction-controller to get this fix: MetaMask/core#4343 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/24947?quickstart=1) ## **Related issues** Fixes: A recent update to the transaction-controller has made the TransactionMeta object passed to the afterSign hook frozen. This change prevents adding new properties, leading to the error: “Cannot add property custodyId, object is not extensible.” This bug is breaking all transactions for MMI as the original txMeta cannot store required properties like custodyId. Blocked by #24861 Blocked by #24913 ## **Manual testing steps** I followed these steps to test the fix: 1. yarn && yarn start:mmi 2. create a new wallet 3. visit https://saturn-custody-ui.dev.metamask-institutional.io/ and add two custodial addresses 4. send 0ETH from one custodial address to the other You should see a popup with an Approve button. Before this fix, the transaction would appear in the activity tab with an error. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. --------- Co-authored-by: MetaMask Bot <[email protected]> Co-authored-by: Antonio Regadas <[email protected]>
zone-live
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Jun 6, 2024
> [!NOTE] > This PR is intended to be cherry-picked into RC 11.17.0 after being merged into develop Upgrade transaction-controller to get this fix: MetaMask/core#4343 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/24947?quickstart=1) Fixes: A recent update to the transaction-controller has made the TransactionMeta object passed to the afterSign hook frozen. This change prevents adding new properties, leading to the error: “Cannot add property custodyId, object is not extensible.” This bug is breaking all transactions for MMI as the original txMeta cannot store required properties like custodyId. Blocked by #24861 Blocked by #24913 I followed these steps to test the fix: 1. yarn && yarn start:mmi 2. create a new wallet 3. visit https://saturn-custody-ui.dev.metamask-institutional.io/ and add two custodial addresses 4. send 0ETH from one custodial address to the other You should see a popup with an Approve button. Before this fix, the transaction would appear in the activity tab with an error. <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> <!-- [screenshots/recordings] --> <!-- [screenshots/recordings] --> - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] 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. --------- Co-authored-by: MetaMask Bot <[email protected]> Co-authored-by: Antonio Regadas <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note
This change is intended to be cherry-picked into MetaMask/extension v11.17.0 via an upgrade to the @metamask/transaction-controller package.
Explanation
Issue:
A recent update to the transaction-controller has made the TransactionMeta object passed to the
afterSign
hook frozen. This change prevents adding new properties, leading to the error: “Cannot add property custodyId, object is not extensible.” This bug is breaking all transactions for MMI as the original txMeta cannot store required properties like custodyId.Fix:
We deep clone the transaction meta before passing it to the hook. A deep clone is used because transactionMeta is recursively frozen by immer. This fix was intended to minimize the change for the cherry-pick going into v11.17.0. A longer term solution might involve using immer more throughout the TransactionController.ts file to make it clearer when a transactionMeta is being mutated and how.
Testing:
This fix was applied to and verified with the MMI extension.
References
Changelog
@metamask/transaction-controller
Checklist