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: CAIP Multichain (New) #27782

Draft
wants to merge 492 commits into
base: caip25-permission-migration
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
492 commits
Select commit Hold shift + click to select a range
baffa1c
Merge branch 'develop' into caip-multichain
jiexi Sep 30, 2024
d165506
Ignore sessionId. Remove hardcoded sessionId (#27510)
jiexi Sep 30, 2024
15f622a
Merge branch 'develop' into caip-multichain
jiexi Oct 1, 2024
b6ca49a
Merge branch 'develop' into caip-multichain
jiexi Oct 1, 2024
68db523
Do not assert unsupported required scopes (#27520)
jiexi Oct 2, 2024
4126dd3
Jl/caip multichain/fix connection flow for permitted chains (#27471)
jiexi Oct 3, 2024
1101102
Handle getCaveat missing permission throws properly (#27549)
jiexi Oct 3, 2024
a92853a
CAIP Multichain: deep clone flattened scopeObjects (#27404)
jiexi Oct 4, 2024
9ffa4b5
Merge branch 'develop' into caip-multichain
jiexi Oct 4, 2024
a392615
fix: bump api-specs on caip-multichain feature branch (#27585)
shanejonas Oct 7, 2024
a213b7e
Merge branch 'develop' into caip-multichain
jiexi Oct 7, 2024
91eef62
Merge branch 'develop' into caip-multichain
jiexi Oct 7, 2024
bd91fb0
Merge branch 'develop' into caip-multichain
jiexi Oct 7, 2024
8bcc777
Get session revoke session should not throw (#27677)
jiexi Oct 8, 2024
c6242ee
Merge branch 'develop' into caip-multichain
jiexi Oct 8, 2024
2852118
Merge branch 'develop' into caip-multichain
jiexi Oct 8, 2024
db8c573
Merge branch 'develop' into caip-multichain
jiexi Oct 9, 2024
2456465
fix: fix api spec multichain bump issues (#27669)
shanejonas Oct 9, 2024
48d19e2
Merge branch 'develop' into caip-multichain
jiexi Oct 9, 2024
a19cf08
fix: get wallet_getSession/revokeSession passing (#27741)
shanejonas Oct 9, 2024
6c3bc39
Multichain: Lint (#27745)
jiexi Oct 9, 2024
42a1c8b
Merge branch 'develop' into caip-multichain
jiexi Oct 10, 2024
c3b7e52
Merge branch 'develop' into caip-multichain
jiexi Oct 10, 2024
7221bb6
Move sign methods back into eip155:x (#27771)
jiexi Oct 10, 2024
947dcd7
Jl/caip multichain/fix wallet eip155 eth account assignment (#27769)
jiexi Oct 10, 2024
0f9ba64
Multichain: Fix Subscriptions (#27682)
jiexi Oct 10, 2024
14de6d2
Assign eth accounts to wallets (#27777)
jiexi Oct 10, 2024
50ec84a
initial pass
jiexi Oct 10, 2024
2e06555
Merge branch 'develop' into caip-multichain
jiexi Oct 11, 2024
f4e0bb2
Merge branch 'develop' into caip-multichain
jiexi Oct 11, 2024
200a1ba
Import attempt
jiexi Oct 11, 2024
4f8014e
Merge branch 'caip-multichain' into jl/caip-multichain-migrate-core
jiexi Oct 11, 2024
8f5c024
use barrel exported package
jiexi Oct 14, 2024
146f093
Merge branch 'develop' into caip-multichain
jiexi Oct 14, 2024
33a559f
Merge branch 'caip-multichain' into jl/caip-multichain-migrate-core
jiexi Oct 14, 2024
a4b2600
Update LavaMoat policies
metamaskbot Oct 14, 2024
26dc532
Merge branch 'develop' into caip-multichain
jiexi Oct 14, 2024
7ca1867
Merge branch 'caip-multichain' into jl/caip-multichain-migrate-core
jiexi Oct 14, 2024
e4e5793
working preview
jiexi Oct 14, 2024
28ba445
Merge branch 'develop' into caip-multichain
jiexi Oct 14, 2024
cd52a18
Merge branch 'caip-multichain' into jl/caip-multichain-migrate-core
jiexi Oct 14, 2024
cd1861d
Multichain: Fix snaps connection (#27803)
jiexi Oct 14, 2024
f66a26b
Merge branch 'develop' into caip-multichain
jiexi Oct 14, 2024
10fb361
upsert empty wallet:eip155 on add (#27845)
jiexi Oct 14, 2024
ccb56c5
Merge branch 'caip-multichain' into jl/caip-multichain-migrate-core
jiexi Oct 14, 2024
6adb2e4
Merge branch 'develop' into caip-multichain
jiexi Oct 14, 2024
bf0f1f8
Merge branch 'caip-multichain' into jl/caip-multichain-migrate-core
jiexi Oct 14, 2024
521b278
move processScopedProperties validateScopedPropertyEip3085 into creat…
jiexi Oct 14, 2024
884c830
lint
jiexi Oct 14, 2024
70ce992
Fix caipPermissionAdapterMiddleware import casing
jiexi Oct 14, 2024
df11376
Merge branch 'develop' into caip-multichain
jiexi Oct 14, 2024
aa5ed57
Merge branch 'caip-multichain' into jl/caip-multichain-migrate-core
jiexi Oct 14, 2024
aa03836
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 15, 2024
ed4c253
Update app/scripts/lib/rpc-method-middleware/handlers/wallet-createSe…
jiexi Oct 15, 2024
4e1df34
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
1be3e41
revert back to 597e8377
jiexi Oct 16, 2024
093e5a4
Fix createSession helper import
jiexi Oct 16, 2024
e0623f5
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
245c47e
Use most recent preview build
jiexi Oct 16, 2024
73dd95a
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
ea0aba4
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
542f8d5
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
ae5e1a5
Remove TODO about verifying switchChain permissioning flow
jiexi Oct 16, 2024
4db8a0d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
85c9fb0
Revert "Remove selectors intended for multichain API"
jiexi Oct 16, 2024
45b5269
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
bbc90fa
fix wallet_createSession for renamed core helpers
jiexi Oct 16, 2024
0a6faca
remove old js tests
jiexi Oct 16, 2024
a5907f5
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 16, 2024
1efe6e9
fix: add method middleware maker and use multichain handlers (#27882)
shanejonas Oct 16, 2024
6ff8102
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 17, 2024
aca50f8
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 17, 2024
f53b91e
fix: remove html-report-caip27 (#27940)
shanejonas Oct 17, 2024
33f3a0c
bring in preview build from new core pr
jiexi Oct 17, 2024
21701e7
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Oct 17, 2024
47a08e3
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 17, 2024
a0a54e2
Update LavaMoat policies
metamaskbot Oct 17, 2024
f3b68be
update wallet_createSession handler comment about listAccounts()
jiexi Oct 17, 2024
a75a9fa
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Oct 17, 2024
3cd8e7d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 17, 2024
db6c055
bring in new preview build for validator listAccount()
jiexi Oct 17, 2024
e5b7290
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 17, 2024
d3d76eb
fix yarn.lock
jiexi Oct 17, 2024
61becd8
use new preview build
jiexi Oct 21, 2024
7a68e3c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 21, 2024
52cad8e
lint
jiexi Oct 21, 2024
4cc9915
Update LavaMoat policies
metamaskbot Oct 21, 2024
5fae714
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Oct 21, 2024
83f737c
yarn dedupe
jiexi Oct 21, 2024
37f23fc
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 22, 2024
3132108
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 22, 2024
13f3907
Bring in updated core package for types
jiexi Oct 22, 2024
bcddb19
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 22, 2024
5b0db4d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 22, 2024
b2c52f2
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 22, 2024
049493e
Jl/caip mutlichain migrate core convert create session ts (#28020)
jiexi Oct 22, 2024
28bdb3c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 23, 2024
0b4c431
Filter wallet notifications by api type for connection
jiexi Oct 23, 2024
2d20ca8
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 23, 2024
d1d754e
Fix chainChanged still being sent for over Multichain
jiexi Oct 23, 2024
4945ab1
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 30, 2024
e4b4c6b
Update LavaMoat policies
metamaskbot Oct 30, 2024
7f9135f
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Oct 30, 2024
99e35c6
Send chainChanged events as before
jiexi Oct 31, 2024
3b4210d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 21, 2024
af9339c
use preview build 0d167a3d (multichain + permission refactor)
jiexi Nov 21, 2024
096d6f8
Update LavaMoat policies
metamaskbot Nov 21, 2024
2c3788a
use preview build c58e3946 (getInternalScopesObject))
jiexi Nov 21, 2024
927e0c6
Fix wallet_createSession
jiexi Nov 21, 2024
63695ef
fix mergeScopes usage
jiexi Nov 21, 2024
57630e6
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 21, 2024
a1d338a
use preview build 62975b62 (missing permission adapter middleware)
jiexi Nov 21, 2024
036110b
yarn dedupe
jiexi Nov 22, 2024
1bbc3c6
Fix wallet_createSession test
jiexi Nov 22, 2024
0a24b11
cleanup wallet_createSession test
jiexi Nov 22, 2024
73d1db7
Fix types
jiexi Nov 22, 2024
988891c
fix types
jiexi Nov 22, 2024
efa1804
lint
jiexi Nov 22, 2024
426f481
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 22, 2024
eae656b
use preview build 439ef9ba (filter out ignored 1193 methods)
jiexi Nov 22, 2024
06fcee2
use preview build 6732cd9a (loosen 1193 method enforcement)
jiexi Nov 22, 2024
f1dbda7
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 22, 2024
dc848dd
fix subscription not ending when removed from authorization
jiexi Nov 22, 2024
7b917ec
Update LavaMoat policies
metamaskbot Nov 22, 2024
e9f1038
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 25, 2024
f21c126
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 26, 2024
5b1bfc5
move sessionChanged notif constant to Multichain PR
jiexi Nov 26, 2024
b6d484a
use latest preview builds
adonesky1 Nov 26, 2024
d00ce1e
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 26, 2024
c85442b
use preview build 944be534 (multichain + caveat mutator fix)
jiexi Nov 26, 2024
c960727
cleanup caip-stream.test.ts
jiexi Nov 26, 2024
3c8d5af
Fix engine middleware cleanup for CAIP
jiexi Nov 26, 2024
fb53aba
add setupUntrustedCommunicationCaip spec. Cleanup setupUntrustedCommu…
jiexi Nov 26, 2024
90aca27
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 26, 2024
7e2afa9
update wallet_createSession handler comment about persisting sessionP…
jiexi Nov 26, 2024
5e9c995
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 27, 2024
23b918e
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Nov 27, 2024
34e89cc
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Dec 2, 2024
3ce6eff
yarn
jiexi Dec 2, 2024
1234247
Update LavaMoat policies
metamaskbot Dec 2, 2024
21b2181
Jl/caip multichain/cleanup middleware destroy (#28751)
jiexi Dec 2, 2024
88d618e
use preview build 9cfbf21f (latest multichain core after cleanup)
jiexi Dec 5, 2024
604c138
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 5, 2024
966721e
yarn dedupe
jiexi Dec 5, 2024
3fdcd36
Fix remove network in MMC
jiexi Dec 6, 2024
66db33e
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 6, 2024
2e492c2
fix wallet_createSession spec
jiexi Dec 6, 2024
2fa9ec3
Jl/caip multichain/filter unsupported methods notifications (#29001)
jiexi Dec 6, 2024
f79b22d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 9, 2024
66f98cd
Update LavaMoat policies
metamaskbot Dec 9, 2024
038e490
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 9, 2024
cd4011e
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 10, 2024
db816ce
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 11, 2024
e554460
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 11, 2024
bf32e15
restore app/scripts/controllers/permissions/selectors.test.js
jiexi Dec 11, 2024
9c33415
Implement Wallet Discovery For Multichain API #2970 (#29111)
ffmcgee725 Dec 13, 2024
c6ab79e
Jl/caip multichain/flask (#29003)
jiexi Dec 13, 2024
82aab64
dedupe
adonesky1 Dec 13, 2024
886ec3c
fix flask build
adonesky1 Dec 13, 2024
6573d05
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 16, 2024
73e026a
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Dec 16, 2024
e389bc2
dedupe
jiexi Dec 16, 2024
32c380d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 16, 2024
f4845a7
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 16, 2024
b75e6de
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 16, 2024
ce9e79b
chore: bump @metamask/providers
ffmcgee725 Dec 17, 2024
543c24d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 17, 2024
3d173a3
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Dec 17, 2024
953c127
fix connectAccount public address usage from upstream
jiexi Dec 17, 2024
d20da17
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 17, 2024
76ba552
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 17, 2024
09b84e6
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 17, 2024
8e5831e
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 18, 2024
f98f807
Update LavaMoat policies
metamaskbot Dec 18, 2024
3222176
dedupe
adonesky1 Dec 18, 2024
6662dd3
Update app/scripts/metamask-controller.js
jiexi Dec 19, 2024
0ede8b6
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 19, 2024
08178b5
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Dec 19, 2024
ca85516
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 19, 2024
069a8a7
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Dec 19, 2024
0048c4d
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 20, 2024
f478911
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 20, 2024
fc4a801
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 20, 2024
a44b9e7
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Dec 20, 2024
e757ab8
use updated preview
jiexi Jan 6, 2025
afc2629
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 6, 2025
43e2e3a
Fix wallet_createSession use getSupportedScopeObjects
jiexi Jan 6, 2025
babf3b8
Add back requestPermissionApprovalForOrigin to MMC. Use in requestApp…
jiexi Jan 6, 2025
9d8b687
Rename requestPermissionApprovalForOrigin to requestPermissionApprova…
jiexi Jan 6, 2025
432fcf8
yarn audit
jiexi Jan 6, 2025
add8328
Update LavaMoat policies
metamaskbot Jan 6, 2025
2071366
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 6, 2025
ffef7ae
First Multichain API e2e Test (#29209)
adonesky1 Jan 6, 2025
8a2203c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 7, 2025
7a13bcc
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 7, 2025
f4af744
Revert "Rename requestPermissionApprovalForOrigin to requestPermissio…
jiexi Jan 7, 2025
b991c19
Use requestPermissionApproval again
jiexi Jan 7, 2025
d3d5f9b
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 7, 2025
0b044e4
Jl/fix api specs multichain (#29487)
jiexi Jan 7, 2025
3f87444
Update app/scripts/metamask-controller.js
jiexi Jan 7, 2025
eee52ec
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 8, 2025
fb2c400
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 8, 2025
2e1be33
fix bad merge. lint
jiexi Jan 8, 2025
8b06c2c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 8, 2025
b1c0b07
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 8, 2025
75814f4
Jl/caip multichain/add api specs wallet create session (#29592)
jiexi Jan 8, 2025
9542e9c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 10, 2025
3f70fdc
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 10, 2025
af1cb6a
Update app/scripts/metamask-controller.js
jiexi Jan 10, 2025
7e5782b
add wallet_registerOnboarding to Multichain API (#29491)
jiexi Jan 10, 2025
6d861f1
jsdoc createUnsupportedMethodMiddleware
jiexi Jan 10, 2025
79dc228
Update LavaMoat policies
metamaskbot Jan 10, 2025
dbed7a1
Multichain API e2e test: calling `wallet_invokeMethod` on the same da…
ffmcgee725 Jan 10, 2025
c4b62c1
Multichain API E2E Test: wallet_notify (#29623)
ffmcgee725 Jan 10, 2025
3771ebc
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 10, 2025
7688c40
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 10, 2025
9faf0e6
remove unnecessary JSON.stringify in wallet_createSession
jiexi Jan 10, 2025
08ff03d
add missing import
jiexi Jan 10, 2025
c7f9adc
remove eip3085 handling from wallet_createSession
jiexi Jan 10, 2025
f7f5c28
remove unused hooks
jiexi Jan 10, 2025
9d7a8a4
jsdoc wallet_createSession handler
jiexi Jan 10, 2025
f2e64be
remove processScopedProperties
jiexi Jan 10, 2025
9f58f3f
lint
jiexi Jan 10, 2025
61f1182
use preview build 298fc547
jiexi Jan 10, 2025
bea54cf
move getCaveat in requestPermittedChainsPermissionIncremental to afte…
jiexi Jan 13, 2025
6aea438
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 13, 2025
ebee234
Multichain API E2E Test: wallet_revokeSession (#29639)
ffmcgee725 Jan 14, 2025
1817ba9
Multichain API E2E Test: wallet_createSession called with an existing…
ffmcgee725 Jan 14, 2025
2846b0d
remove extraneous hooks
adonesky1 Jan 14, 2025
19826fe
dedupe
adonesky1 Jan 14, 2025
7240c13
lint
adonesky1 Jan 14, 2025
10d4d9c
Update LavaMoat policies
metamaskbot Jan 14, 2025
492687c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 14, 2025
bb38fc4
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 14, 2025
0ba6f86
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 14, 2025
16c42b8
use preview build e05b7d3e
jiexi Jan 14, 2025
69a188b
Update LavaMoat policies
metamaskbot Jan 14, 2025
6633fb7
dedupe
adonesky1 Jan 14, 2025
113e643
update hookname: getCaveatForOrigin
adonesky1 Jan 14, 2025
106e7a6
Update LavaMoat policies
metamaskbot Jan 14, 2025
24fe195
wrap rpcErrors in flask build flags
adonesky1 Jan 14, 2025
65bd138
use preview build f3715655
jiexi Jan 14, 2025
baf0afc
fix getCaveatForOrigin
adonesky1 Jan 14, 2025
20204ec
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 14, 2025
9df1ef3
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 14, 2025
04d64da
use preview build 6244b7be
jiexi Jan 14, 2025
b89c40c
lint
jiexi Jan 14, 2025
8776db0
Multichain API E2E test: wallet_sessionChanged (#29706)
ffmcgee725 Jan 15, 2025
fe26dcf
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 15, 2025
724e178
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ workflows:
requires:
- prep-build-test
- get-changed-files-with-git-diff
- test-api-specs-multichain:
requires:
- prep-build-test-flask
- get-changed-files-with-git-diff
- test-e2e-chrome-multiple-providers:
requires:
- prep-build-test
Expand Down Expand Up @@ -1096,6 +1100,37 @@ jobs:
- store_test_results:
path: test/test-results/e2e

test-api-specs-multichain:
executor: node-browsers-medium-plus
steps:
- run: *shallow-git-clone-and-enable-vnc
- run: sudo corepack enable
- attach_workspace:
at: .
- run:
name: Move test build to dist
command: mv ./dist-test-flask ./dist
- run:
name: Move test zips to builds
command: mv ./builds-test-flask ./builds
- gh/install
- run:
name: test:api-specs-multichain
command: .circleci/scripts/test-run-e2e.sh yarn test:api-specs-multichain
no_output_timeout: 5m
- run:
name: Comment on PR
command: |
if [ -f html-report-multichain/index.html ]; then
gh pr comment "${CIRCLE_PR_NUMBER}" --body ":x: Multichain API Spec Test Failed. View the report [here](https://output.circle-artifacts.com/output/job/${CIRCLE_WORKFLOW_JOB_ID}/artifacts/${CIRCLE_NODE_INDEX}/html-report-multichain/index.html)."
else
echo "Multichain API Spec Report not found!"
fi
when: on_fail
- store_artifacts:
path: html-report-multichain
destination: html-report-multichain

test-api-specs:
executor: node-browsers-medium-plus
steps:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ lavamoat/**/policy-debug.json
# Attributions
licenseInfos.json

# Branding
/app/images/branding

# API Spec tests
html-report/
html-report-multichain/

/app/images/branding
/changed-files

# UI Integration tests
Expand Down
4 changes: 4 additions & 0 deletions app/build-types/flask/manifest/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
},
"default_title": "MetaMask Flask"
},
"externally_connectable": {
"matches": ["http://*/*", "https://*/*"],
"ids": ["*"]
},
"icons": {
"16": "images/icon-16.png",
"19": "images/icon-19.png",
Expand Down
6 changes: 0 additions & 6 deletions app/manifest/v2/_barad_dur.json

This file was deleted.

6 changes: 0 additions & 6 deletions app/manifest/v3/_barad_dur.json

This file was deleted.

13 changes: 11 additions & 2 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ function overrideContentSecurityPolicyHeader() {
// These are set after initialization
let connectRemote;
let connectExternalExtension;
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
let connectExternalCaip;
///: END:ONLY_INCLUDE_IF

browser.runtime.onConnect.addListener(async (...args) => {
// Queue up connection attempts here, waiting until after initialization
Expand All @@ -378,13 +380,18 @@ browser.runtime.onConnectExternal.addListener(async (...args) => {
// Queue up connection attempts here, waiting until after initialization
await isInitialized;
// This is set in `setupController`, which is called as part of initialization
const port = args[0];

if (port.sender.tab?.id && process.env.BARAD_DUR) {
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-mmi)
connectExternalExtension(...args);
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
const port = args[0];
if (port.sender.tab?.id) {
connectExternalCaip(...args);
} else {
connectExternalExtension(...args);
}
///: END:ONLY_INCLUDE_IF
});

function saveTimestamp() {
Expand Down Expand Up @@ -1017,6 +1024,7 @@ export function setupController(
});
};

///: BEGIN:ONLY_INCLUDE_IF(build-flask)
connectExternalCaip = async (remotePort) => {
if (metamaskBlockedPorts.includes(remotePort.name)) {
return;
Expand All @@ -1035,6 +1043,7 @@ export function setupController(
sender: remotePort.sender,
});
};
///: END:ONLY_INCLUDE_IF

if (overrides?.registerConnectListeners) {
overrides.registerConnectListeners(connectRemote, connectExternalExtension);
Expand Down
1 change: 1 addition & 0 deletions app/scripts/controllers/permissions/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum NOTIFICATION_NAMES {
accountsChanged = 'metamask_accountsChanged',
unlockStateChanged = 'metamask_unlockStateChanged',
chainChanged = 'metamask_chainChanged',
sessionChanged = 'wallet_sessionChanged',
}
113 changes: 113 additions & 0 deletions app/scripts/controllers/permissions/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ export const getPermittedAccountsByOrigin = createSelector(
},
);

/**
* Get the authorized CAIP-25 scopes for each subject, keyed by origin.
* The values of the returned map are immutable values from the
* PermissionController state.
*
* @returns {Map<string, Caip25Authorization>} The current origin:authorization map.
*/
export const getAuthorizedScopesByOrigin = createSelector(
getSubjects,
(subjects) => {
return Object.values(subjects).reduce(
(originToAuthorizationsMap, subject) => {
const caveats =
subject.permissions?.[Caip25EndowmentPermissionName]?.caveats || [];

const caveat = caveats.find(({ type }) => type === Caip25CaveatType);

if (caveat) {
originToAuthorizationsMap.set(subject.origin, caveat.value);
}
return originToAuthorizationsMap;
},
new Map(),
);
},
);

/**
* Get the permitted chains for each subject, keyed by origin.
* The values of the returned map are immutable values from the
Expand Down Expand Up @@ -112,3 +139,89 @@ export const diffMap = (currentMap, previousMap) => {
}
return changedMap;
};

/**
* Given the current and previous exposed CAIP-25 authorization for each PermissionController
* subject, returns a new map containing all authorizations that have changed.
* The values of each map must be immutable values directly from the
* PermissionController state, or an empty object instantiated in this
* function.
*
* @param {Map<string, Caip25Authorization>} newAuthorizationsMap - The new origin:authorization map.
* @param {Map<string, Caip25Authorization>} [previousAuthorizationsMap] - The previous origin:authorization map.
* @returns {Map<string, Caip25Authorization>} The origin:authorization map of changed authorizations.
*/
export const getChangedAuthorizations = (
newAuthorizationsMap,
previousAuthorizationsMap,
) => {
if (previousAuthorizationsMap === undefined) {
return newAuthorizationsMap;
}

const changedAuthorizations = new Map();
if (newAuthorizationsMap === previousAuthorizationsMap) {
return changedAuthorizations;
}

const newOrigins = new Set([...newAuthorizationsMap.keys()]);

for (const origin of previousAuthorizationsMap.keys()) {
const newAuthorizations = newAuthorizationsMap.get(origin) ?? {
requiredScopes: {},
optionalScopes: {},
};

// The values of these maps are references to immutable values, which is why
// a strict equality check is enough for diffing. The values are either from
// PermissionController state, or an empty object initialized in the previous
// call to this function. `newAuthorizationsMap` will never contain any empty
// objects.
if (previousAuthorizationsMap.get(origin) !== newAuthorizations) {
changedAuthorizations.set(origin, newAuthorizations);
}

newOrigins.delete(origin);
}

// By now, newOrigins is either empty or contains some number of previously
// unencountered origins, and all of their authorizations have "changed".
for (const origin of newOrigins.keys()) {
changedAuthorizations.set(origin, newAuthorizationsMap.get(origin));
}
return changedAuthorizations;
};

/**
*
* @param {Map<string, Caip25Authorization>} newAuthorizationsMap - The new origin:authorization map.
* @param {Map<string, Caip25Authorization>} [previousAuthorizationsMap] - The previous origin:authorization map.
* @returns {Map<string, Caip25Authorization>} The origin:authorization map of changed authorizations.
*/
export const getRemovedAuthorizations = (
newAuthorizationsMap,
previousAuthorizationsMap,
) => {
const removedAuthorizations = new Map();

// If there are no previous authorizations, there are no removed authorizations.
// OR If the new authorizations map is the same as the previous authorizations map,
// there are no removed authorizations
if (
previousAuthorizationsMap === undefined ||
newAuthorizationsMap === previousAuthorizationsMap
) {
return removedAuthorizations;
}

const previousOrigins = new Set([...previousAuthorizationsMap.keys()]);
for (const origin of newAuthorizationsMap.keys()) {
previousOrigins.delete(origin);
}

for (const origin of previousOrigins.keys()) {
removedAuthorizations.set(origin, previousAuthorizationsMap.get(origin));
}

return removedAuthorizations;
};
31 changes: 31 additions & 0 deletions app/scripts/controllers/permissions/selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
diffMap,
getPermittedAccountsByOrigin,
getPermittedChainsByOrigin,
getRemovedAuthorizations,
} from './selectors';

describe('PermissionController selectors', () => {
Expand Down Expand Up @@ -167,6 +168,36 @@ describe('PermissionController selectors', () => {
});
});

describe('getRemovedAuthorizations', () => {
it('returns an empty map if the new and previous values are the same', () => {
const newAuthorizations = new Map();
expect(
getRemovedAuthorizations(newAuthorizations, newAuthorizations),
).toStrictEqual(new Map());
});

it('returns a new map of the removed authorizations if the new and previous values differ', () => {
const mockAuthorization = {
requiredScopes: {
'eip155:1': {
accounts: [],
},
},
optionalScopes: {},
};
const previousAuthorizations = new Map([
['foo.bar', mockAuthorization],
['bar.baz', mockAuthorization],
]);

const newAuthorizations = new Map([['foo.bar', mockAuthorization]]);

expect(
getRemovedAuthorizations(newAuthorizations, previousAuthorizations),
).toStrictEqual(new Map([['bar.baz', mockAuthorization]]));
});
});

describe('getPermittedChainsByOrigin', () => {
it('memoizes and gets permitted chains by origin', () => {
const state1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ export const createEthAccountsMethodMiddleware = makeMethodMiddlewareMaker([
ethAccountsHandler,
]);

// The primary home of RPC method implementations for the MultiChain API.
export const createMultichainMethodMiddleware =
makeMethodMiddlewareMaker(localHandlers);

/**
* Creates a method middleware factory function given a set of method handlers.
*
* @param {Record<string, import('@metamask/permission-controller').PermittedHandlerExport>} handlers - The RPC method
* handler implementations.
* @returns The method middleware factory function.
*/
function makeMethodMiddlewareMaker(handlers) {
export function makeMethodMiddlewareMaker(handlers) {
const handlerMap = handlers.reduce((map, handler) => {
for (const methodName of handler.methodNames) {
map[methodName] = handler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import {
createEip1193MethodMiddleware,
createEthAccountsMethodMiddleware,
createMultichainMethodMiddleware,
} from '.';

const getHandler = () => ({
Expand Down Expand Up @@ -60,6 +61,7 @@ jest.mock('./handlers', () => ({
describe.each([
['createEip1193MethodMiddleware', createEip1193MethodMiddleware],
['createEthAccountsMethodMiddleware', createEthAccountsMethodMiddleware],
['createMultichainMethodMiddleware', createMultichainMethodMiddleware],
])('%s', (_name, createMiddleware) => {
const method1 = 'method1';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ describe('createUnsupportedMethodMiddleware', () => {
});
const getMockResponse = () => ({ jsonrpc: jsonrpc2, id: 'foo' });

it('forwards requests whose methods are not on the list of unsupported methods', () => {
const middleware = createUnsupportedMethodMiddleware();
it('forwards requests whose methods are not in the list of unsupported methods', () => {
const middleware = createUnsupportedMethodMiddleware([]);
const nextMock = jest.fn();
const endMock = jest.fn();

Expand All @@ -22,10 +22,12 @@ describe('createUnsupportedMethodMiddleware', () => {
});

// @ts-expect-error This function is missing from the Mocha type definitions
it.each([...UNSUPPORTED_RPC_METHODS.keys()])(
'ends requests for methods that are on the list of unsupported methods: %s',
it.each(UNSUPPORTED_RPC_METHODS)(
'ends requests for methods that are in the list of unsupported methods: %s',
(method: string) => {
const middleware = createUnsupportedMethodMiddleware();
const middleware = createUnsupportedMethodMiddleware(
UNSUPPORTED_RPC_METHODS,
);
const nextMock = jest.fn();
const endMock = jest.fn();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
import type { JsonRpcParams } from '@metamask/utils';
import { rpcErrors } from '@metamask/rpc-errors';
import { UNSUPPORTED_RPC_METHODS } from '../../../../shared/constants/network';

/**
* Creates a middleware that rejects explicitly unsupported RPC methods with the
* appropriate error.
*
* @param methods
Copy link
Member

Choose a reason for hiding this comment

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

Document please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done here 6d861f1

*/
export function createUnsupportedMethodMiddleware(): JsonRpcMiddleware<
JsonRpcParams,
null
> {
export function createUnsupportedMethodMiddleware(
methods: string[],
): JsonRpcMiddleware<JsonRpcParams, null> {
return async function unsupportedMethodMiddleware(req, _res, next, end) {
if ((UNSUPPORTED_RPC_METHODS as Set<string>).has(req.method)) {
if (methods.includes(req.method)) {
return end(rpcErrors.methodNotSupported());
}
return next();
Expand Down
Loading
Loading