Commit 7b5c8ec
committed
feat(snaps): Add support for custom network per Snap (#26389)
Like with websites, we want to support a custom network per Snap rather
than relying on the globally selected network. For Snaps, the permission
for the network to switch to is automatically granted.
[](https://codespaces.new/MetaMask/metamask-extension/pull/26389?quickstart=1)
1. Copy the build files for `@metamask/selected-network-controller` from
[this PR](MetaMask/core#4602).
2. Copy the build files for `@metamask/snaps-controllers` and
`@metamask/snaps-execution-environments` from [this
PR](MetaMask/snaps#2634).
3. Run `test-snaps` for the PR above (`yarn start` in
`packages/test-snaps`).
4. Install the Ethereum Provider Example Snap.
5. Switch the chain ID using the `test-snaps` button for the Ethereum
Provider example.
6. The Snap should now use the new network, without any permission
requests.
Step 1 and 2 are no longer necessary once these PRs are merged and
released.
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
<!-- [screenshots/recordings] -->
<!-- [screenshots/recordings] -->
- [ ] 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.
- [ ] 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.1 parent bb53fe9 commit 7b5c8ec
File tree
10 files changed
+707
-52
lines changed- app/scripts
- lib/rpc-method-middleware/handlers
- migrations
- test/e2e/snaps
10 files changed
+707
-52
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
201 | 229 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | 133 | | |
136 | 134 | | |
137 | 135 | | |
| |||
5894 | 5892 | | |
5895 | 5893 | | |
5896 | 5894 | | |
5897 | | - | |
5898 | | - | |
5899 | | - | |
5900 | | - | |
5901 | | - | |
5902 | | - | |
5903 | 5895 | | |
5904 | 5896 | | |
5905 | 5897 | | |
| |||
5951 | 5943 | | |
5952 | 5944 | | |
5953 | 5945 | | |
5954 | | - | |
| 5946 | + | |
5955 | 5947 | | |
5956 | 5948 | | |
5957 | 5949 | | |
5958 | | - | |
| 5950 | + | |
5959 | 5951 | | |
5960 | 5952 | | |
5961 | 5953 | | |
| |||
5969 | 5961 | | |
5970 | 5962 | | |
5971 | 5963 | | |
5972 | | - | |
5973 | | - | |
5974 | | - | |
5975 | | - | |
5976 | 5964 | | |
5977 | 5965 | | |
5978 | 5966 | | |
| |||
5996 | 5984 | | |
5997 | 5985 | | |
5998 | 5986 | | |
5999 | | - | |
| 5987 | + | |
6000 | 5988 | | |
6001 | 5989 | | |
6002 | 5990 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1293 | 1293 | | |
1294 | 1294 | | |
1295 | 1295 | | |
1296 | | - | |
| 1296 | + | |
1297 | 1297 | | |
1298 | 1298 | | |
1299 | 1299 | | |
| |||
1318 | 1318 | | |
1319 | 1319 | | |
1320 | 1320 | | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
1321 | 1324 | | |
1322 | 1325 | | |
1323 | 1326 | | |
| |||
1332 | 1335 | | |
1333 | 1336 | | |
1334 | 1337 | | |
1335 | | - | |
| 1338 | + | |
1336 | 1339 | | |
1337 | 1340 | | |
1338 | 1341 | | |
| |||
1365 | 1368 | | |
1366 | 1369 | | |
1367 | 1370 | | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
1368 | 1374 | | |
1369 | 1375 | | |
1370 | 1376 | | |
| |||
1432 | 1438 | | |
1433 | 1439 | | |
1434 | 1440 | | |
1435 | | - | |
| 1441 | + | |
1436 | 1442 | | |
1437 | 1443 | | |
1438 | 1444 | | |
1439 | | - | |
1440 | | - | |
1441 | | - | |
1442 | | - | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
1451 | | - | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
1456 | | - | |
1457 | | - | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
1458 | 1453 | | |
1459 | | - | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
1460 | 1463 | | |
1461 | 1464 | | |
1462 | 1465 | | |
| |||
1467 | 1470 | | |
1468 | 1471 | | |
1469 | 1472 | | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
1470 | 1479 | | |
1471 | 1480 | | |
1472 | 1481 | | |
| |||
1540 | 1549 | | |
1541 | 1550 | | |
1542 | 1551 | | |
1543 | | - | |
1544 | | - | |
1545 | | - | |
1546 | | - | |
1547 | | - | |
1548 | | - | |
1549 | | - | |
1550 | | - | |
1551 | | - | |
1552 | | - | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
1556 | 1552 | | |
1557 | 1553 | | |
1558 | 1554 | | |
| |||
0 commit comments