metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

feat: Migrate eth_accounts and permittedChains to CAIP-25 endowment

Open jiexi opened this issue 1 year ago • 24 comments

Description

This PR replaces the replaces the internal eth_accounts and endowment:permittedChains permission structure with a CAIP-25 endowment. It adds adapter logic to translate to and from the new internal CAIP-25 permissions. This change should be transparent to wallet users and to dapps except for one case, see below. This change is required in order to support CAIP-25 and CAIP-27 requests in a follow-up PR that enables the Multichain API.

Open in GitHub Codespaces

Related issues

Related: https://github.com/MetaMask/core/pull/4784

Manual testing steps

There should be no user or dapp facing difference in behavior except in wallet_revokePermissions, see below.

When calling wallet_revokePermissions and specifying either eth_accounts or endowment:permitted-chains, the entire CAIP-25 permission will be revoked. It will appear to the dapp as if both eth_accounts and endowment:permitted-chains were revoked.

await window.ethereum.request({
 "method": "wallet_revokePermissions",
 "params": [
  {
    eth_accounts: {}
  }
],
});

await window.ethereum.request({
 "method": "wallet_revokePermissions",
 "params": [
  {
    'endowment:permitted-chains': {}
  }
],
});

await window.ethereum.request({
 "method": "wallet_getPermissions",
 "params": [],
});

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.

jiexi avatar Oct 14 '24 19:10 jiexi

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

github-actions[bot] avatar Oct 14 '24 19:10 github-actions[bot]

👍 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↗︎

socket-security[bot] avatar Oct 14 '24 19:10 socket-security[bot]

@metamask-bot update-policies

jiexi avatar Oct 14 '24 20:10 jiexi

@metamaskbot update-policies

jiexi avatar Oct 15 '24 18:10 jiexi

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

metamaskbot avatar Oct 15 '24 18:10 metamaskbot

@metamaskbot update-policies

jiexi avatar Oct 15 '24 20:10 jiexi

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

metamaskbot avatar Oct 15 '24 20:10 metamaskbot

@SocketSecurity ignore npm/@metamask/[email protected]

i know that mcmire guy

jiexi avatar Oct 15 '24 21:10 jiexi

@SocketSecurity ignore npm/@metamask/[email protected]

i still know that mcmire fellow

jiexi avatar Oct 15 '24 21:10 jiexi

@SocketSecurity ignore npm/@metamask/[email protected]

the fetch isn't new, but even then it's fine because it fetches caller supplied url

jiexi avatar Oct 15 '24 21:10 jiexi

@metamaskbot update-policies

jiexi avatar Oct 15 '24 21:10 jiexi

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

metamaskbot avatar Oct 15 '24 21:10 metamaskbot

@metamaskbot update-policies

jiexi avatar Oct 16 '24 21:10 jiexi

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

metamaskbot avatar Oct 16 '24 21:10 metamaskbot

@metamaskbot update-policies

jiexi avatar Oct 17 '24 15:10 jiexi

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

metamaskbot avatar Oct 17 '24 16:10 metamaskbot

@metamaskbot update-policies

adonesky1 avatar Oct 17 '24 20:10 adonesky1

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

metamaskbot avatar Oct 17 '24 20:10 metamaskbot

@metamaskbot update-policies

jiexi avatar Oct 17 '24 21:10 jiexi

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

metamaskbot avatar Oct 17 '24 21:10 metamaskbot

@metamaskbot update-policies

adonesky1 avatar Oct 18 '24 14:10 adonesky1

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

metamaskbot avatar Oct 18 '24 14:10 metamaskbot

@metamaskbot update-policies

jiexi avatar Oct 21 '24 18:10 jiexi

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

metamaskbot avatar Oct 21 '24 18:10 metamaskbot

Builds ready [25bfb4f]
Page Load Metrics (1840 ± 119 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint35325891673465223
domContentLoaded15952318179318689
load160527091840248119
domInteractive16125572613
backgroundConnect8293436330
firstReactRender48206924823
getState5196334321
initialActions00000
loadScripts11391753134214771
setupStore11163353617
uiStartup176837082105406195
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -25.19 KiB (-0.50%)
  • ui: 593 Bytes (0.01%)
  • common: -120.86 KiB (-1.53%)

metamaskbot avatar Oct 21 '24 21:10 metamaskbot

@SocketSecurity ignore npm/@metamask/[email protected] @SocketSecurity ignore npm/@metamask/[email protected]

author is known. access is acceptable

jiexi avatar Oct 22 '24 23:10 jiexi

Builds ready [7f70c0b]
Page Load Metrics (2111 ± 140 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint167527462110296142
domContentLoaded166126752074282135
load167627662111291140
domInteractive21109532211
backgroundConnect992352512
firstReactRender472891055627
getState468282311
initialActions01000
loadScripts121020281522241116
setupStore1186342412
uiStartup185533732364369177
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -25.19 KiB (-0.57%)
  • ui: 593 Bytes (0.01%)
  • common: -120.86 KiB (-1.53%)

metamaskbot avatar Oct 22 '24 23:10 metamaskbot

@metamaskbot update-policies

jiexi avatar Oct 23 '24 17:10 jiexi