Skip to content

chore: Cherry-pick resimulate into V12.5.1#28178

Merged
danjm merged 9 commits intoVersion-v12.5.1from
chore/pick-resimulate
Oct 31, 2024
Merged

chore: Cherry-pick resimulate into V12.5.1#28178
danjm merged 9 commits intoVersion-v12.5.1from
chore/pick-resimulate

Conversation

@OGPoyraz
Copy link
Copy Markdown
Member

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

This PR aims to add re-simulation logic which recently added at
MetaMask/core#4792

Patch note:
Transaction controller patch adds the re-simulate feature, branched
belove to keep track.

https://github.com/MetaMask/core/tree/patch/extension-transaction-controller-37-2-0

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28104?quickstart=1)

Fixes: MetaMask/MetaMask-planning#3380

TBD

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

<!-- [screenshots/recordings] -->

![1](https://github.com/user-attachments/assets/67fc06d4-2f01-4e95-b1da-e84f5145462e)

![2](https://github.com/user-attachments/assets/52153a4a-4c0d-44bd-990b-51f9b90eefb4)

- [X] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [X] I've completed the PR template to the best of my ability
- [X] I’ve included tests if applicable
- [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [X] 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 <metamaskbot@users.noreply.github.com>
@OGPoyraz OGPoyraz requested review from a team as code owners October 30, 2024 10:16
@github-actions github-actions bot added the team-confirmations Push issues to confirmations team label Oct 30, 2024
@OGPoyraz
Copy link
Copy Markdown
Member Author

@metamaskbot update-policies

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 30, 2024
@socket-security
Copy link
Copy Markdown

socket-security bot commented Oct 30, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@metamaskbot
Copy link
Copy Markdown
Collaborator

Policy update failed. You can review the logs or retry the policy update here

@OGPoyraz
Copy link
Copy Markdown
Member Author

@metamaskbot update-policies

@metamaskbot
Copy link
Copy Markdown
Collaborator

Policy update failed. You can review the logs or retry the policy update here

@OGPoyraz
Copy link
Copy Markdown
Member Author

@metamaskbot update-policies

@socket-security
Copy link
Copy Markdown

socket-security bot commented Oct 30, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/base-controller@7.0.2 None +1 1.06 MB metamaskbot
npm/@metamask/controller-utils@11.4.1 network 0 264 kB metamaskbot

🚮 Removed packages: npm/@metamask/base-controller@7.0.1, npm/@metamask/controller-utils@11.3.0

View full report↗︎

@metamaskbot
Copy link
Copy Markdown
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

OGPoyraz and others added 5 commits October 30, 2024 14:44
Upgrade the `TransactionController` to:

- Support Etherscan API keys when polling for incoming transactions.
- Populate `submitHistory` to aid with debug and persist even when
resetting the account.

Also adds the `ETHERSCAN_API_KEY` environment variable.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27611?quickstart=1)

1. Verify incoming transactions work on Mainnet and Sepolia with an API
key set.
2. Verify `submitHistory` is populated in state logs after creating
transactions and retrying, on both Infura and custom networks.

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] 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.
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [d213294]
Page Load Metrics (1808 ± 89 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15952297181318991
domContentLoaded15862162178216981
load15952301180818689
domInteractive13195555125

@@ -1849,6 +1849,10 @@ export default class MetamaskController extends EventEmitter {
getCurrentChainId({ metamask: this.networkController.state })
],
incomingTransactions: {
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.

Why is this change needed here, but it is not on the commit being cherry-picked?

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.

They were added in this PR: #27611

It was an earlier bump of the transaction controller. This cherry-pick includes both PRs

@@ -272,8 +272,10 @@ env:
- SECURITY_ALERTS_API_ENABLED: ''
# URL of security alerts API used to validate dApp requests
- SECURITY_ALERTS_API_URL: 'http://localhost:3000'
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.

Why is this change not in the commit being cherry-picked?

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.

signedCanceledTransactions: [],
txParams: this.#txParams,
transactionMeta: this.#transactionMeta,
// TODO: Replace `any` with type - version mismatch between smart-transactions-controller and transaction-controller breaking type safety
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.

Any idea what the type incompatibilities are here? The SmartTransactionsController is using types from v34.0.0 of the TransactionController, and I didn't see any breaking changes in the changelog that might explain this.

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.

Ah, looks like it was this: MetaMask/core#4714

The additional two types aren't expected by the SmartTransactionsController. It looks like the SmartTransactionsController doesn't have any matchers for this property, so it should not cause any problems there.

Comment on lines +316 to +317
// TODO: Replace `any` with type - version mismatch between smart-transactions-controller and transaction-controller breaking type safety
// eslint-disable-next-line @typescript-eslint/no-explicit-any
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.

Nit: @ts-expect-error is preferred because it will flag when the override is no longer needed

See https://github.com/MetaMask/contributor-docs/blob/main/docs/typescript.md#if-accompanied-by-a-todo-comment-ts-expect-error-is-acceptable-to-use-for-marking-errors-that-have-clear-plans-of-being-resolved for more details

Suggested change
// TODO: Replace `any` with type - version mismatch between smart-transactions-controller and transaction-controller breaking type safety
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// @ts-expect-error version mismatch between smart-transactions-controller and transaction-
// controller breaking type safety

},
{
return: `0x00000000000000000000000000000000${SENDER_ADDRESS_NO_0X_MOCK}`,
return: `0x000000000000000000000000${SENDER_ADDRESS_NO_0X_MOCK}`,
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.

Looks like this is from yet another separate transaction controller bump: #27954

// for more info)
state.version = global.platform.getVersion();
state.browser = window.navigator.userAgent;
state.completeTxList = await actions.getTransactions({
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.

Reasons not entirely clear to me, but this appears to be from #27611

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@danjm danjm merged commit 5dbbda3 into Version-v12.5.1 Oct 31, 2024
@danjm danjm deleted the chore/pick-resimulate branch October 31, 2024 02:46
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template team-confirmations Push issues to confirmations team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants