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: Add Multichain API to Flask #27782

Open
wants to merge 953 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
953 commits
Select commit Hold shift + click to select a range
20b2245
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 7, 2025
d6dfd27
use isSnapId in background-api
jiexi Jan 7, 2025
d2a2d44
jsdoc handlers
jiexi Jan 7, 2025
cd0e2d1
Merge branch 'main' into caip25-permission-migration
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
1ef2033
replace parseInt with hexToBigInt
jiexi Jan 8, 2025
b9e61e0
Merge branch 'main' into caip25-permission-migration
jiexi Jan 8, 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
52e6ea2
Merge branch 'main' into caip25-permission-migration
jiexi Jan 8, 2025
8b06c2c
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 8, 2025
132e784
Merge branch 'main' into caip25-permission-migration
jiexi Jan 8, 2025
b1c0b07
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 8, 2025
097ef14
Fix wallet_requestPermissions approval ordering
jiexi Jan 8, 2025
75814f4
Jl/caip multichain/add api specs wallet create session (#29592)
jiexi Jan 8, 2025
43a5aad
Merge branch 'main' into caip25-permission-migration
jiexi Jan 9, 2025
9a42c67
Merge branch 'main' into caip25-permission-migration
jiexi Jan 9, 2025
368fccb
Jl/caip25 permission migration/fix wallet request permissions delay g…
jiexi Jan 9, 2025
60b4a0b
move cannot derive ethAccounts comment to ethAccounts var assignment
jiexi Jan 9, 2025
553f83e
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 9, 2025
094abb3
Update app/scripts/lib/rpc-method-middleware/handlers/wallet-revokePe…
jiexi Jan 9, 2025
51dc9d3
add ignoreLock options object to getPermittedAccounts
jiexi Jan 9, 2025
9f2422e
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 9, 2025
8a3bc99
remove isMultichainOrigin checks in add/switchEthereumChain and revok…
jiexi Jan 9, 2025
30b1773
Convert request-accounts.ts back to js
jiexi Jan 9, 2025
85782c5
Merge branch 'main' into caip25-permission-migration
jiexi Jan 10, 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
49e9ac4
fix migration to skip malformed permission subjects (#29634)
adonesky1 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
73ca76f
grant wallet:eip155 for dapps as well
jiexi Jan 10, 2025
5b027f8
annoying persistent local lint
jiexi Jan 10, 2025
c1cbb26
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 10, 2025
c4b62c1
Multichain API E2E Test: wallet_notify (#29623)
ffmcgee725 Jan 10, 2025
70b9f05
Merge branch 'main' into caip25-permission-migration
jiexi 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
b27d53b
Update app/scripts/lib/rpc-method-middleware/handlers/wallet-requestP…
jiexi Jan 13, 2025
bea54cf
move getCaveat in requestPermittedChainsPermissionIncremental to afte…
jiexi Jan 13, 2025
2e078a8
Merge branch 'main' into caip25-permission-migration
jiexi Jan 13, 2025
50748b6
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 13, 2025
6aea438
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 13, 2025
ec4f301
move getCaveat in requestPermittedChainsPermissionIncremental to afte…
jiexi Jan 13, 2025
df60de4
Update ui/pages/permissions-connect/connect-page/connect-page.tsx
jiexi Jan 13, 2025
11faff5
Update ui/components/multichain/pages/review-permissions-page/site-ce…
jiexi Jan 13, 2025
abc0343
remove delays from sign.flow.ts
jiexi Jan 13, 2025
8d99f45
lint
jiexi Jan 13, 2025
422f379
Merge branch 'main' into caip25-permission-migration
jiexi Jan 13, 2025
e932140
lint
jiexi Jan 13, 2025
b1d52ad
Merge branch 'main' into caip25-permission-migration
jiexi Jan 13, 2025
cec2311
Merge branch 'main' into caip25-permission-migration
jiexi Jan 13, 2025
ebee234
Multichain API E2E Test: wallet_revokeSession (#29639)
ffmcgee725 Jan 14, 2025
0c0adf8
address partially mutation state bugs (#29682)
adonesky1 Jan 14, 2025
1817ba9
Multichain API E2E Test: wallet_createSession called with an existing…
ffmcgee725 Jan 14, 2025
6ebcb5f
Jl/restore legacy fixtures (#29674)
jiexi Jan 14, 2025
2846b0d
remove extraneous hooks
adonesky1 Jan 14, 2025
19826fe
dedupe
adonesky1 Jan 14, 2025
7240c13
lint
adonesky1 Jan 14, 2025
f166986
Merge branch 'main' into caip25-permission-migration
jiexi Jan 14, 2025
fe7469e
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi 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
4b52240
Merge branch 'main' into caip25-permission-migration
jiexi 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
62621a1
Merge branch 'main' into caip25-permission-migration
adonesky1 Jan 15, 2025
113ba76
lint
adonesky1 Jan 15, 2025
29d2381
lint
adonesky1 Jan 15, 2025
ec919bd
Docs: Update Developer Docs link in README (#29733)
Montoya Jan 15, 2025
236b2d4
Merge branch 'main' into caip25-permission-migration
jiexi Jan 15, 2025
9d73bd9
jsdoc captureKeyringTypesWithMissingIdentities
jiexi Jan 15, 2025
89ed1b3
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 15, 2025
eb67f19
jsdoc sortAccountsByLastSelected
jiexi Jan 15, 2025
c86e052
Merge branch 'main' into caip25-permission-migration
jiexi Jan 15, 2025
ea4294a
Update app/scripts/migrations/138.ts
adonesky1 Jan 15, 2025
fdeb41e
Update app/scripts/migrations/138.ts
adonesky1 Jan 15, 2025
28094b5
Update app/scripts/migrations/138.ts
adonesky1 Jan 15, 2025
ab87b63
add comment/link for BUILT_IN_NETWORKS
adonesky1 Jan 15, 2025
9cdf8b7
address feedback / cleanup migration
adonesky1 Jan 15, 2025
43a0749
bail out of migration when encountering any data malformation
adonesky1 Jan 15, 2025
134f730
make malformation checks against networkConfigurations more strict
adonesky1 Jan 15, 2025
27b7353
Merge branch 'main' into caip25-permission-migration
jiexi Jan 15, 2025
8bdde06
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi 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
b2581f4
lint
jiexi Jan 15, 2025
6a6b1bf
Trigger
jiexi Jan 15, 2025
b213d94
add isNonEmptyArrayOfStrings to migration
jiexi Jan 15, 2025
2f0a4e5
Merge branch 'main' into caip25-permission-migration
jiexi Jan 15, 2025
0de03cc
Update test/e2e/tests/request-queuing/ui.spec.js
jiexi Jan 15, 2025
9233f06
Revert ui/ducks/bridge/selectors.ts
jiexi Jan 15, 2025
dcdee7f
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 15, 2025
5357693
Merge branch 'main' into caip25-permission-migration
jiexi Jan 16, 2025
651a40c
cleanup fixtures
jiexi Jan 16, 2025
b032101
clean fixtures deprecated-networks.spec.js and switch-custom-network.…
jiexi Jan 16, 2025
4c700fd
remove ERC_4337_ACCOUNT from withPreferencesControllerAdditionalAccou…
jiexi Jan 16, 2025
0f6c9f9
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
adonesky1 Jan 16, 2025
79678cd
update yarn.lock post rebase
adonesky1 Jan 16, 2025
6865dc5
Update LavaMoat policies
metamaskbot Jan 16, 2025
0412864
dedupe
adonesky1 Jan 16, 2025
792306f
fix wallet locked behavior
adonesky1 Jan 16, 2025
dea12c0
Update LavaMoat policies
metamaskbot Jan 16, 2025
ba9efbb
revert unecessary change to fixtures
jiexi Jan 16, 2025
7797d67
Merge branch 'main' into caip25-permission-migration
jiexi Jan 16, 2025
608ac95
revert unecessary change to fixtures 2
jiexi Jan 16, 2025
03624be
restore styling changes fixture
jiexi Jan 16, 2025
bd1e230
undo fixture changes that aren't needed
jiexi Jan 16, 2025
76f77b0
Merge branch 'main' into caip25-permission-migration
jiexi Jan 16, 2025
962c343
lint
jiexi Jan 16, 2025
3d0cfdd
lint
jiexi Jan 16, 2025
aba2d8a
Merge branch 'main' into caip25-permission-migration
jiexi Jan 17, 2025
1fb0f29
Update ui/components/multichain/edit-accounts-modal/edit-accounts-mod…
adonesky1 Jan 17, 2025
1bf080d
Multichain API E2E Test: handling when MetaMask is password locked (#…
ffmcgee725 Jan 17, 2025
5f96f94
Fix wallet_revokePermission spec
jiexi Jan 17, 2025
4762e5c
Merge branch 'main' into caip25-permission-migration
jiexi Jan 17, 2025
18440d6
Merge remote-tracking branch 'origin/caip25-permission-migration' int…
jiexi Jan 17, 2025
15fa319
Merge branch 'main' into caip25-permission-migration
jiexi Jan 17, 2025
c1b4b29
Merge branch 'caip25-permission-migration' into jl/caip-multichain-mi…
jiexi Jan 17, 2025
540899a
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 17, 2025
ad7169d
Update LavaMoat policies
metamaskbot Jan 17, 2025
d52827e
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 21, 2025
9b74e4c
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 21, 2025
a15a668
use preview build 2ba45577
jiexi Jan 21, 2025
a91d9b4
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 21, 2025
f85ad62
Update LavaMoat policies
metamaskbot Jan 21, 2025
6e0dbeb
remove caipPermissionAdapterMiddleware
jiexi Jan 21, 2025
721c85b
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 22, 2025
58be906
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 23, 2025
66d0308
yarn dedupe
jiexi Jan 23, 2025
d4410f2
Update LavaMoat policies
metamaskbot Jan 23, 2025
b8ae6c3
lint?
jiexi Jan 23, 2025
7f32e4d
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 23, 2025
0c2a696
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 23, 2025
a69d816
remove unneeded hooks
jiexi Jan 23, 2025
cfe4339
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 23, 2025
67dae48
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 24, 2025
d65cabf
fix remove network
jiexi Jan 24, 2025
fc286d9
lint
jiexi Jan 24, 2025
ea676b4
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 24, 2025
1ff78c6
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 28, 2025
51ad9d9
yarn
jiexi Jan 28, 2025
7199240
Restore wallet locked behavior
jiexi Jan 28, 2025
96c77a2
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 28, 2025
ef209cd
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 28, 2025
0c27eb1
move missing caveat check
jiexi Jan 29, 2025
6bcd229
lint
jiexi Jan 29, 2025
464e972
remove connect.spec
jiexi Jan 29, 2025
2d08956
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 29, 2025
5bd7d64
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 29, 2025
16f9f38
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 30, 2025
d5ab747
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 30, 2025
acdac1f
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 30, 2025
970ad3b
lint
jiexi Jan 30, 2025
94c8dd9
WIP: adapt to new CAIP-25 approval UI
jiexi Jan 30, 2025
08c32f0
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 30, 2025
ec9ddca
update approval UI to modify only evm portion of returned CAIP-25 per…
jiexi Jan 30, 2025
e0c548e
update wallet_createSession to pass in a validated CAIP-25 permission…
jiexi Jan 30, 2025
95e1275
lint
jiexi Jan 30, 2025
c18440b
Fix connect page supported request chain id check
jiexi Jan 30, 2025
ffbf346
WIP: fix snaps request accounts
jiexi Jan 30, 2025
a265050
Fix snaps account grant
jiexi Jan 30, 2025
9b6cf67
lint
jiexi Jan 30, 2025
16c0b5d
lint
jiexi Jan 31, 2025
80c0fd8
Update app/scripts/lib/rpc-method-middleware/handlers/wallet-createSe…
jiexi Jan 31, 2025
4feca47
delete password-locked spec
jiexi Jan 31, 2025
c40afc6
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 31, 2025
c5cfbde
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 31, 2025
cf15677
remove console.log
jiexi Jan 31, 2025
22e6e6b
loosen wallet_revokeSession fixture assert
jiexi Jan 31, 2025
6d511af
remove secp256k1 v5 force resolution
adonesky1 Jan 31, 2025
a139124
yarn.lock reset
adonesky1 Jan 31, 2025
7cce39d
Update LavaMoat policies
metamaskbot Jan 31, 2025
6867030
lint
adonesky1 Jan 31, 2025
3e7c8ae
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Jan 31, 2025
66a4c65
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Jan 31, 2025
6311273
Update app/scripts/lib/rpc-method-middleware/handlers/request-account…
adonesky1 Feb 3, 2025
b07aac2
remove comment
adonesky1 Feb 3, 2025
ccb8644
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 3, 2025
164d189
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Feb 3, 2025
22957ef
Update LavaMoat policies
FrederikBolding Feb 4, 2025
3613394
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 5, 2025
f054b45
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Feb 5, 2025
97a5097
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 5, 2025
e22b7bc
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 5, 2025
f665043
yarn dedupe
jiexi Feb 5, 2025
ecdb0b8
Update app/scripts/metamask-controller.js
jiexi Feb 5, 2025
e1d3631
DRY multichain eth subscription add and removal
jiexi Feb 5, 2025
fd30905
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Feb 5, 2025
f90be7c
update getRemovedAuthorizations to include removed scopes as well as …
jiexi Feb 5, 2025
8a5f2cf
switch to createDeepEqualSelector
jiexi Feb 6, 2025
551b56c
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 6, 2025
75db2f7
add default value to createUnsupportedMethodMiddleware
jiexi Feb 6, 2025
1e20517
Bump api-specs to 0.10.14
jiexi Feb 6, 2025
84cc007
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 6, 2025
d5445f1
yarn dedupe
jiexi Feb 6, 2025
eed6a10
Lint
jiexi Feb 6, 2025
1d43a4a
codefence UNSUPPORTED_RPC_METHODS in MMC
jiexi Feb 6, 2025
03a40aa
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 6, 2025
5152d05
bump @metamask/api-specs to 0.10.15
jiexi Feb 7, 2025
7103714
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 7, 2025
57c5874
Fix sessionChanged not firing
jiexi Feb 7, 2025
c960844
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 7, 2025
701820c
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 8, 2025
68f4c35
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 12, 2025
f4b58b4
Add permission differs
jiexi Feb 12, 2025
de7ebf7
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 12, 2025
259e36a
Make createUnsupportedMethodMiddleware accept a Set again
jiexi Feb 12, 2025
1230a38
Add back BARAD_DUR flag. Replaces Multichain API flask code fences. S…
jiexi Feb 12, 2025
e381705
rename BARAD_DUR to MULTICHAIN_API
jiexi Feb 12, 2025
a219b31
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 12, 2025
1cf91a7
Fix flipped connectExternalCaip condition
jiexi Feb 12, 2025
1b8d61b
Fix MMC test
jiexi Feb 12, 2025
4446500
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 13, 2025
b2be74f
fix bad merge
jiexi Feb 13, 2025
986adf9
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 13, 2025
9b81f88
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 13, 2025
9ae93dc
Merge remote-tracking branch 'origin/jl/caip-multichain-migrate-core'…
jiexi Feb 13, 2025
db2d7b3
WIP update e2e tests
jiexi Feb 13, 2025
454ffdc
Finish update e2e tests -ish
jiexi Feb 13, 2025
7f6ad99
Merge branch 'main' into jl/caip-multichain-migrate-core
jiexi Feb 13, 2025
2a454ef
Fix ganacheOptions renamed to localNodeOptions
jiexi Feb 13, 2025
d9c024c
Merge branch 'main', remote-tracking branch 'origin' into jl/caip-mul…
adonesky1 Feb 14, 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 @@ -159,6 +159,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 @@ -695,6 +699,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
1 change: 1 addition & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ignores:
- '@metamask/forwarder'
- '@metamask/phishing-warning' # statically hosted as part of some e2e tests
- '@metamask/test-dapp'
- '@metamask/test-dapp-multichain'
- '@metamask/design-tokens' # Only imported in index.css
- '@tsconfig/node22' # required dynamically by TS, used in tsconfig.json
- '@sentry/cli' # invoked as `sentry-cli`
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,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 @@ -374,7 +374,9 @@ function overrideContentSecurityPolicyHeader() {
// These are set after initialization
let connectRemote;
let connectExternalExtension;
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
jiexi marked this conversation as resolved.
Show resolved Hide resolved
let connectExternalCaip;
///: END:ONLY_INCLUDE_IF

browser.runtime.onConnect.addListener(async (...args) => {
// Queue up connection attempts here, waiting until after initialization
Expand All @@ -387,13 +389,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 @@ -1011,6 +1018,7 @@ export function setupController(
});
};

///: BEGIN:ONLY_INCLUDE_IF(build-flask)
connectExternalCaip = async (remotePort) => {
if (metamaskBlockedPorts.includes(remotePort.name)) {
return;
Expand All @@ -1029,6 +1037,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
Gudahtt marked this conversation as resolved.
Show resolved Hide resolved
* PermissionController state.
*
* @returns {Map<string, Caip25Authorization>} The current origin:authorization map.
*/
export const getAuthorizedScopesByOrigin = createSelector(
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved
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 = (
Gudahtt marked this conversation as resolved.
Show resolved Hide resolved
Gudahtt marked this conversation as resolved.
Show resolved Hide resolved
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
Loading
Loading