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: Release Chain Permissions #27561

Merged
merged 105 commits into from
Oct 10, 2024
Merged

feat: Release Chain Permissions #27561

merged 105 commits into from
Oct 10, 2024

Conversation

NidhiKJha
Copy link
Member

@NidhiKJha NidhiKJha commented Oct 2, 2024

This PR is to remove feature flags and add e2e for Chain Permissions

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2713

Manual testing steps

  1. Run yarn start
  2. Everything should work

Screenshots/Recordings

Before

After

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.

@NidhiKJha NidhiKJha requested review from a team as code owners October 2, 2024 11:00
@darkwing darkwing changed the title feat: added e2e and removed feature flag feat: Release Amon Hen v2 Oct 2, 2024
Comment on lines 5753 to 5755
...(requestedPermissions[RestrictedMethods.eth_accounts] && {
[PermissionNames.permittedChains]: {},
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

do we anticipate a user trying to request permittedChains by itself? if so we probably need to populate an empty eth_accounts object here too? @adonesky1

Copy link
Contributor

Choose a reason for hiding this comment

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

do we anticipate a user trying to request permittedChains by itself? if so we probably need to populate an empty eth_accounts object here too? @adonesky1

🤔 I think whether or not we encourage it we should include an accounts permission as part of the request to avoid confusion/frustration

@jiexi
Copy link
Contributor

jiexi commented Oct 2, 2024

I see a few more references to CHAIN_PERMISSIONS left when I search in code

@NidhiKJha
Copy link
Member Author

NidhiKJha commented Oct 2, 2024

I see a few more references to CHAIN_PERMISSIONS left when I search in code

Those are for confirmation page Copy Changes. We are not removing feature flag from these files

<!--
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.
-->

## **Description**

<!--
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?
-->

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

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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 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).
- [ ] 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.
seaona and others added 3 commits October 9, 2024 14:51
<!--
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.
-->

## **Description**

<!--
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?
-->

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

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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 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).
- [ ] 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.
<!--
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.
-->

## **Description**

<!--
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?
-->

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

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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 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).
- [ ] 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.
@seaona
Copy link
Contributor

seaona commented Oct 9, 2024

QA Findings

Signed Transaction stuck after network switch

I've encountered a case where after switching networks using window.ethereum on a dapp and trying to send a transaction the tx status remains in Signed.

Screenshot from 2024-10-09 17-56-07

Then I cannot send transactions on other networks, as it says there's a tx pending.

Smart Transactions are disabled.

Repro:
I'm unsure if there's something in the wallet state that causes this, because just by doing these below, I encounter the issue:

  1. Setup ganache
  2. Connect to test dapp
  3. Trigger tx
  4. Confirm
  5. Tx remains signed
signed-tx-local.mp4

Invalid v value

This is a failure that sometimes appears in our e2e tests. I think this needs to be investigated further as might be a bug in the wallet side.

image

I'm trying to find repro steps (no luck so far), but I find it deterministically by running this spec in the mmi build:

Switch Ethereum Chain for two dapps queues switchEthereumChain request from second dapp after send tx request

I've seen this in other tests too, but the tests didn't fail as they were not checking if the tx was successful or not. If that's confirmed, we'd need to add a new step to capture this deterministically

…sendTransaction calls (#27734)

<!--
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.
-->

## **Description**

<!--
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?
-->

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

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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 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).
- [ ] 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.
Copy link

sonarcloud bot commented Oct 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
41.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@seaona
Copy link
Contributor

seaona commented Oct 9, 2024

ci e2e webpack: Chrome errors in webpack makes test fail

We see there are some empty errors that make test fails sometimes in webpack. After checking why those are empty we've seen that it's because those RPC errors don't have any value, but a description field. With the below change we can see how the error message is then displayed and we can see how those are expected RPC errors due to the server being down (in the test we shut down the 2 ganache servers)

#getErrorFromEvent(event) {
    // Extract the values from the array
    const values = event.args.map((a) => {
      console.log("Argument:", a); // Added 
      return a.value ? a.value : a.description; // changed
  });

Current ci:

image

With logs added:

Screenshot from 2024-10-09 20-46-46

Remaining part: we should fix the ignore-all to make that these errors are also ignored.

@metamaskbot
Copy link
Collaborator

Builds ready [535b710]
Page Load Metrics (1946 ± 161 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint160528121936322154
domContentLoaded156325971878263127
load160128531946335161
domInteractive148039168
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -297 Bytes (-0.01%)
  • ui: -3.13 KiB (-0.04%)
  • common: -200 Bytes (-0.00%)

@NidhiKJha
Copy link
Member Author

ci e2e webpack: Chrome errors in webpack makes test fail

@seaona interesting catch. Following our slack conversation if the flakiness would be there, I will file a follow up PR and address it there. Thanks ❤️

@EtherWizard33 EtherWizard33 self-requested a review October 9, 2024 19:18
Copy link

@EtherWizard33 EtherWizard33 left a comment

Choose a reason for hiding this comment

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

Hey Nidhi, looks like one of the checks in not passing

2024-10-09 13 17 12

text: 'Switching networks will cancel all pending confirmations',
tag: 'span',
});
// await driver.findElement({
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably remove this correct?

Copy link
Contributor

@vinnyhoward vinnyhoward left a comment

Choose a reason for hiding this comment

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

LGTM!✅

await driver.clickElement({
text: 'Confirm',
tag: 'button',
});

await driver.waitForSelector({ text: 'OK' });
Copy link
Member

@FrederikBolding FrederikBolding Oct 10, 2024

Choose a reason for hiding this comment

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

I believe these waitForSelector calls were added to try and combat flakiness, I don't think we should be removing them. This applies to multiple places and files in this PR.

cc @bowensanders

Copy link
Member Author

Choose a reason for hiding this comment

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

This is replaced with await driver.clickElementAndWaitForWindowToClose. We can keep it but here we have have added an extra condition that the windown close when this button is clicked. In other instances of file, we wanted to make sure that the window is closed once we click the button.

@@ -140,12 +127,6 @@ describe('Test Snap TxInsights-v2', function () {
tag: 'button',
text: 'Activity',
});

// wait for transaction confirmation
await driver.waitForSelector({
Copy link
Member

Choose a reason for hiding this comment

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

How come this is removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this one I can add back. Can I do it in a follow up PR?

@@ -18,10 +17,6 @@ import { CaveatTypes } from '../../../../shared/constants/permissions';
* @returns {JSX.Element} A permission description node.
*/
function getDescriptionNode(permission, index, accounts) {
const permissionValue = permission?.permissionValue?.caveats?.find(
Copy link
Member

Choose a reason for hiding this comment

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

This seems to revert 4fa502b - is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because caveats doesn't exist in permissionValue object

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, any idea why this value changed since that fix then? 🤔

@@ -49,7 +49,7 @@ export const PermissionCellStatus = ({

const renderAccountsGroup = () => (
<>
{process.env.CHAIN_PERMISSIONS ? (
{networks.length > 0 ? (
Copy link
Member

@FrederikBolding FrederikBolding Oct 10, 2024

Choose a reason for hiding this comment

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

This confuses me, are we stopping rendering accounts? If so, can we remove the code for it?

Or are we keeping it for Snaps for now? If so, this is still confusing 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

We are just keeping it for Snaps. networks is defined only in case of permittedChains.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like it is in use for non-Snap connections too. I think this deserves a refactor outside of this PR. It feels confusing to nest the networks display logic inside the account group logic.

Screenshot 2024-10-10 at 11 49 17

Copy link
Member Author

@NidhiKJha NidhiKJha Oct 10, 2024

Choose a reason for hiding this comment

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

For initial connection screen, we need to show the current active account and all the enabled networks to be there , this screen should not show up for Snaps. This is connections screen, it doesn't use permission cell anyway

Copy link
Member

@FrederikBolding FrederikBolding left a comment

Choose a reason for hiding this comment

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

Looks like we have double padding on switchEthereumChain. Unclear if this is caused by this PR
Screenshot 2024-10-10 at 12 11 30

Copy link
Member

@FrederikBolding FrederikBolding left a comment

Choose a reason for hiding this comment

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

Not blocking, but I have left some comments that should probably be addressed in a follow up.

@NidhiKJha NidhiKJha added this pull request to the merge queue Oct 10, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 10, 2024
@NidhiKJha NidhiKJha added this pull request to the merge queue Oct 10, 2024
Merged via the queue into develop with commit 11b9bd4 Oct 10, 2024
77 of 78 checks passed
@NidhiKJha NidhiKJha deleted the multichain-e2e-tests-v2 branch October 10, 2024 11:33
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2024
@metamaskbot metamaskbot added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Oct 10, 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 release-12.7.0 Issue or pull request that will be included in release 12.7.0 team-wallet-ux
Projects
None yet
Development

Successfully merging this pull request may close these issues.