-
Notifications
You must be signed in to change notification settings - Fork 5k
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: Migrate eth_accounts and permittedChains to CAIP-25 endowment #27847
base: main
Are you sure you want to change the base?
Conversation
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. |
New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@json-schema-spec/[email protected], npm/@json-schema-tools/[email protected] |
👍 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. |
@metamask-bot update-policies |
.yarn/patches/@json-schema-tools-reference-resolver-npm-1.2.6-4e1497c16d.patch
Show resolved
Hide resolved
@metamaskbot update-policies |
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
app/scripts/lib/rpc-method-middleware/handlers/ethereum-chain-utils.js
Outdated
Show resolved
Hide resolved
app/scripts/lib/rpc-method-middleware/handlers/wallet-requestPermissions.ts
Outdated
Show resolved
Hide resolved
app/scripts/lib/rpc-method-middleware/handlers/wallet-revokePermissions.ts
Outdated
Show resolved
Hide resolved
@metamaskbot update-policies |
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
@SocketSecurity ignore npm/@metamask/[email protected] i know that mcmire guy |
@SocketSecurity ignore npm/@metamask/[email protected] i still know that mcmire fellow |
@SocketSecurity ignore npm/@metamask/[email protected] the fetch isn't new, but even then it's fine because it fetches caller supplied url |
@metamaskbot update-policies |
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
@metamaskbot update-policies |
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
app/scripts/lib/rpc-method-middleware/handlers/wallet-revokePermissions.ts
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
@metamaskbot update-policies |
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
Builds ready [29d2381]
Page Load Metrics (1566 ± 46 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
# Conflicts: # app/scripts/migrations/137.test.ts # app/scripts/migrations/137.ts # package.json
…o caip25-permission-migration
Co-authored-by: Mark Stacey <[email protected]>
Co-authored-by: Mark Stacey <[email protected]>
Co-authored-by: Mark Stacey <[email protected]>
…o caip25-permission-migration
Builds ready [2f0a4e5]
Page Load Metrics (1637 ± 74 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
@@ -60,7 +60,7 @@ export const EditAccountsModal: React.FC<EditAccountsModalProps> = ({ | |||
|
|||
useEffect(() => { | |||
setSelectedAccountAddresses(defaultSelectedAccountAddresses); | |||
}, [defaultSelectedAccountAddresses]); | |||
}, [JSON.stringify(defaultSelectedAccountAddresses)]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being stringified? Both here and in edit-networks-modal
, I see the same change made in both places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change can be moved into main. It's because this component can sometimes rerender while you're using it and your checkboxes get overwritten with the default selected again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think this can be made separately against main
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The changes here and in switch-custom-network
can probably be reverted (I think they were needed for the previous version of withPermissionControllerConnectedToTestDapp
)
.sort(); | ||
|
||
assert.deepStrictEqual(grantedPermissionNames, [ | ||
'endowment:permitted-chains', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recording something we discussed on a call: We should verify whether the order has changed here
'0xbee150bdc171c7d4190891e78234f791a3ac7b24', | ||
'0xa5c5293e124d04e2f85e8553851001fd2f192647', | ||
'0xb9504634e5788208933b51ae7440b478bfadf865', | ||
'eip155:1337:0xbee150bdc171c7d4190891e78234f791a3ac7b24', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These prefixes don't need to be here, they're added by the migration
@@ -1257,16 +1252,16 @@ class FixtureBuilder { | |||
}, | |||
], | |||
date: 1708029792962, | |||
id: 'oKXoF_MNlffiR2u1Y3mDE', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe we can revert these re-order changes to minimize the diff
@@ -657,6 +643,11 @@ class FixtureBuilder { | |||
lastSelected: 1665507800000, | |||
name: 'Account 2', | |||
}, | |||
[ERC_4337_ACCOUNT]: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why this was added
await new TestDapp(driver).openTestDappPage(); | ||
|
||
await driver.findClickableElement({ text: 'Connect', tag: 'button' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I see that the changes here are different than the prior file, despite the changes being similar in nature. The previous file uses connectAccount
on the test dapp instance rather than running these connect steps one by one. Worth considering which approach we prefer, if they are indeed equivalent.
…o caip25-permission-migration
Description
This PR replaces the replaces the internal
eth_accounts
andendowment: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 foronetwo cases, 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.Related issues
Related: MetaMask/core#4784
Manual testing steps
There should be no user or dapp facing difference in behavior except:
wallet_revokePermissions
and specifying eithereth_accounts
orendowment:permitted-chains
, the entire CAIP-25 permission will be revoked. It will appear to the dapp as if botheth_accounts
andendowment:permitted-chains
were revoked.wallet_getPermissions
for a permitted dapp when the wallet is locked,eth_accounts
should be returned in addition toendowment:permitted-chains
. Currently there is a regression onmain
where onlyendowment:permitted-chains
gets returned when the wallet is locked.Locked Wallet Behavior with dapp connected
Other than the two noted items below, this behavior matches that in
main
eth_accounts
returns []wallet_getPermissions
returns permissions incl eth_accountswallet_revokePermissions
works as usual and revokes eth_accounts and revoke permitted-chains togethermain
where eth_accounts and permitted-chains aren't revoked as a pair if either is revokedeth_requestAccounts
prompts for unlock, after unlock returns accounts if any are permitted, otherwise shows connection promptwallet_requestPermissions
prompts for unlockaccountsChanged
empty array on lock. no event after revokePermissions which makes sense since the dapp was told empty array on lock and now it's actually empty array so no changes have occurred as far as the dapp should be concerned.wallet_addEthereum
orwallet_switchEthereumChain
flows without account permissions, these permissions will be removed with this migration. We think this ok because:Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist