From cf53a7e223950550df58479817f12811bc1d5631 Mon Sep 17 00:00:00 2001 From: Owen Craston Date: Mon, 24 Apr 2023 16:18:06 -0700 Subject: [PATCH 01/17] Squashed commit of the following: commit 64fac616809e40a2699ed24f58536e7d6e59fc45 Author: Owen Craston Date: Tue Apr 11 14:57:18 2023 -0700 [Feature] execute snaps methods from Dapp on iOS (#6049) * Remove custom handlers and add PermissionMiddleware to SnapBridge RPC engine * exportMnemonic * Polyfill TextEncoder * slightly better UX * Add SnapMethodMiddleware to SnapBridge * fetch files based on manifest location * check source shasum --------- Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> commit b90e6a254373a3986cc90284eb2aa83fd60f45e1 Author: Owen Craston Date: Wed Apr 5 14:49:05 2023 -0700 add native module to xcodeproject (#6133) commit 4d365350278d5a77ac2e4a8ae52071e55b36529f Merge: 5ec6a865a 8aac1e027 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Mar 31 14:21:56 2023 -0300 Merge main commit 5ec6a865aad42c3607980bd100973092a9d9b9ca Author: Owen Craston Date: Mon Mar 27 18:15:16 2023 -0400 [Patch fix] Android build for snaps integration system (#6053) * swap for rn-fetch-blob * remove unused file commit 4ffc810ec0b8443f188420aacd04fc5b18a9ec21 Author: Owen Craston Date: Mon Mar 27 12:09:28 2023 -0400 Install snap from a Dapp (#6002) - extract icon from tar file - show request permissions for install snap and account access - move snap webview to the root of the app and make it invisible - create RPC method handlers to register snaps rpc methods commit e6eb204b204361abe19cfb87f17add8c880e5a1b Author: Owen Craston Date: Thu Mar 23 19:20:12 2023 -0400 [FEATURE] Create detectSnapLocation method to install a Snap From NPM iOS (#5926) * Install a Snap From NPM iOS - Create NPMLocation class - Create a custom fetch function for the npm logic as we have slightly different logic - create a swift native module to read a .tgz file and decompress it - read the decompressed folder data and pass it to snaps - swiftlint commit d7adb30984b1c4130cc9d5a0f60929d79688c47f Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Mar 19 10:59:25 2023 -0300 Fix SnapBridge network bug commit e03b85ee6dcc127f013625dca49e98bcc15d5d41 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Mar 19 10:58:46 2023 -0300 Integrate SubjectMetadataController commit 639b9bd4a59ed9148ad5e2dec9d2e20429c8ca8b Author: Owen Craston Date: Fri Mar 17 14:00:12 2023 -0700 [FEATURE] Create detectSnapLocation method to install a Local Snap (#5923) * Local snaps install with controller version 0.26.2 commit 437d572ff3e16d84c4b650fccbaafc6396b1d5ae Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Mar 16 01:40:36 2023 -0300 Add new allow action commit f6cf4bfd339d994f2b8cf362fd94ccda28babb39 Merge: c93bfa89b 49a63050a Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Mar 16 00:57:33 2023 -0300 Rebase commit c93bfa89b08272788bdf590de45e72ddc12204ea Merge: f83cbb276 0c4f95ad0 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Mar 15 08:49:21 2023 -0300 Rebase commit f83cbb27690612e6505c8f4b73fb7fd7cdc8951c Merge: 8acc20868 f46e93ec5 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Mar 13 23:41:52 2023 -0300 Rebase commit 8acc2086837b6528ef83a945c76c35f1a41fa89f Merge: 3b4b499a4 65ef08a77 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Mar 8 12:47:57 2023 -0300 Rebase commit 3b4b499a43354a6cb4c04fc1791a850b08bc189e Merge: 334768d12 cd02e018f Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Feb 23 12:53:10 2023 -0300 Merge main commit 334768d12f1334cf0ecca2c32fbf7f9c0bf1d342 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Feb 20 18:35:43 2023 -0300 Update patch commit 202f2cf04e12ea5f163dbb87872bc993baea6211 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Feb 20 18:34:38 2023 -0300 Update snaps-controller package commit 3adc23426158ef931edf8a4c74baef3d85494c7c Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Feb 20 18:33:01 2023 -0300 Update snaps-controller package commit 9c1c91bd05b024ac82c0f3cf7303397f2a81f475 Merge: 0d0152b30 027573270 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Feb 18 20:12:08 2023 -0300 Merge main commit 0d0152b30d883991a08ff5573183535a90971834 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Feb 15 15:37:01 2023 -0300 Remove unnecessary code commit 9800a4d1bd45b03e0daa1b5ccb079f7894ef56b1 Merge: 22e3562f9 b0b8d9f71 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Feb 15 10:07:49 2023 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into feat/snaps-system-integration commit 22e3562f99922f00c040aec058624a39239d2fb4 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Feb 14 13:14:06 2023 -0300 Fix styles commit dc68ac6dc87c1dda6408870ba431fb3a1c644702 Merge: 4bdde30ba 264a509ac Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Feb 14 12:35:50 2023 -0300 Merge main and solve conflicts commit 4bdde30ba5e60fb9a79e6a0e0406369eebb246bd Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Feb 3 13:32:10 2023 -0300 Fix permission bug commit 65f15a29c955566540c2e5975c3daa56d0b6cc2f Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Feb 3 13:14:33 2023 -0300 Fix imports commit 3cc578eb59b928663b78ea87859aeac92fcaaa15 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Feb 3 12:50:21 2023 -0300 Integrate PS commit 044bc01037fe62cf84aec1533669791b0717c0d2 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Feb 3 00:45:56 2023 -0300 Solve merge bugs commit 985c726233c87f00be775d6d080eae424dca884f Merge: e2ddafc2c 6e062b695 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Feb 3 00:37:28 2023 -0300 Merge main commit e2ddafc2c2308c22a5d3e4d07b4dc324896b8bef Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 16:13:52 2023 -0300 Update dependency commit 260d4d03d29496ec97e73fe58bc479efcb14ba7b Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 15:13:16 2023 -0300 Revert "Remove logs" This reverts commit 106523e5d566a805ebdc6d3de023f666f872ef44. commit 894fc4e7167c06c686e4408a641b410eb142d38d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 14:23:51 2023 -0300 Update structure commit 3d4e72c87bad41be7730cea7c339756462a623c3 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 14:23:37 2023 -0300 Update SnapController commit 376f2bf569ec6eeb5be2a9fe47e1cdcb6ec6da5a Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 14:23:17 2023 -0300 Update permissions commit f38942997b4cd7713f70ba3fdabc608ac89effbd Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 14:23:05 2023 -0300 Update styles commit 567f8a54a6ca31e35932d4dd021995a82b9ed88b Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 13:37:31 2023 -0300 Add error to alert commit 98583647ee588d5d298c36b57811cc33d37ebf39 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 12:05:10 2023 -0300 Clean up SnapElement code commit 106523e5d566a805ebdc6d3de023f666f872ef44 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 09:54:26 2023 -0300 Remove logs commit 85c7ea3f9d1856890b9b8cc3effce39028838dc5 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Jan 29 23:09:12 2023 -0300 Update UI commit c4d325282f9839ec49146e721ddc33e2aac971f5 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Jan 29 02:02:25 2023 -0300 Snaps developer UI commit 1506ca500ad9c60888ad085ea102bd8afae4d401 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 14:55:00 2023 -0300 Add snap UI (base) commit 46fb0f82c74aab84ddff7f24b3fff3ee4c4ad213 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 14:52:51 2023 -0300 Merge main commit 7abbc1bfddf193dfd2a79345dcac8570f2b3a0dd Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Jan 30 14:37:50 2023 -0300 Merge main commit 80e3b6ca9215e70ea3ea4a164ab24f50eead927c Merge: cb8a52b14 91e2ed880 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Jan 11 15:51:40 2023 -0300 Solve conflicts commit cb8a52b14a72521f120bcc1bf07482a9fe448c0e Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 28 18:50:01 2022 -0300 Clean fetchNPMPackage file commit 086b4f8dd1a4bcc6cb9602d4c0dafe4506616eac Merge: a27596c66 e94e0f048 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 28 18:04:02 2022 -0300 Solve conflicts commit a27596c6694f89f9ed90f006ee4280ca8acb69f7 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 21 14:45:17 2022 -0300 Include SnapController to engine init commit 2fcdc5a4e7ed5c65f713f1f3a4a0b08f374ae532 Merge: 950446cd5 c0122b143 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Dec 17 22:11:18 2022 -0300 Merge main commit 950446cd5def7f14f0e0dbb3472c352441539228 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 18:13:42 2022 -0300 Update logs and add test code commit 0ea4d634723d4487be62d9bedffbdc8010406da7 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 18:13:20 2022 -0300 Update patch commit 4f450b28de895586de9c3207d552c73284beee49 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 01:33:59 2022 -0300 Skip logic to destroy WebviewPostMessageStream commit 241fd9eefe8b66eeca8f312f1c6e1c0a98832498 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 01:33:32 2022 -0300 Add logic to destroy SnapDuplex stream commit 1da4e651cc0b41126f6b615f00e9bc3a521adc28 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 01:32:31 2022 -0300 Remove snapExecutionService method commit 2da9fc4685275318e41628b001142cdb687f9cc7 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 01:31:57 2022 -0300 Send valid method commit 2c98d4f88a969e0010e45e69466a9a24caf59b4d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 00:15:36 2022 -0300 Add styles to SnapsExecutionWebView for debugging commit d3f676a0ffc7b1dd56f3006a14c9cebcbc050671 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Dec 16 00:14:59 2022 -0300 Map current Snap Duplex streams commit 7340e207015bd927f39c71a3c530aae1f91a073c Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 15:42:31 2022 -0300 Update structure commit 0935e49b168f8343c5497bd0ad8f94fec217fb56 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 15:42:07 2022 -0300 Move Snaps WebView to different component commit 1689a4befd6ee832c3b5e022465a0eb047190f4a Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 12:02:08 2022 -0300 Remoce POC code commit aee140f650b76ae5e6906950bbb234743bbaa5f1 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:49:19 2022 -0300 Update utils directory commit 0a017ecd197fc1f885d6fada06f6c348e0060d0d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:44:39 2022 -0300 Move fetchNPMPackage to utils/snaps commit a60eb5c4706949d6359b20e3f7a26382148d6282 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:34:51 2022 -0300 Update paths commit 0e3e974c0d9c54fdde310f99a105cb08a037c9b2 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:34:28 2022 -0300 Upadte Snaps core index commit 3a60a88ef0655716b80e92dfb7f903011d22f0ad Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:33:55 2022 -0300 Delete SnapExecutionService commit 11b672cb7e1f43a662e5c84e53bd243821491dbd Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:33:32 2022 -0300 Move SnapBridge to core commit eb257dbd37e3b19de619b9bee5e98273f9042247 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:33:06 2022 -0300 Move WebviewPostMessageStream to core commit 15d33e330443f6df214d7247cbe3557884392e8d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:32:47 2022 -0300 Move WebviewExecutionService to core commit 87736ac0be71cf77246d8580cfdf7ffbfd7dad4b Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:32:29 2022 -0300 Move SnapWebviewPostMessageStream to core commit 05f100e2ce6232d023462d04bfd23438b22530f3 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:32:05 2022 -0300 Move SnapDuplex to core commit 6922dda62b4971dfc3f0df8cffbfd56edf5d3bf1 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:08:09 2022 -0300 Comment terminateSnap method commit 8a1854f2ca79dd210702d2df6adc6cb80f78a235 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 15 11:07:46 2022 -0300 Add action to get installed snaps commit 244743cd2fdd9bbfc1e3e9f5ebc7d3eb9283be3e Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 17:48:37 2022 -0300 Add log commit 2b1c876a4f592f8e75907d55640599350368f5ce Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:23:26 2022 -0300 Update patch commit 0781cd255894591fa5ee4ef65c97df0daf2688d5 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:20:49 2022 -0300 Update logs in SnapBridge commit bc957c3b0503d9c7de085ba305bd9af2b3dd28a1 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:20:11 2022 -0300 Delete log commit 45426b059cfed3bce8c54e2a4777fb8995522bfb Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:19:57 2022 -0300 Update logs in Engine commit ffc31d4144d40af6360f7727f8670fb1b83fdb09 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:19:42 2022 -0300 Update logs in WebviewPostMessageStream commit 6959c8c80c5b7279c61e22b2b808b8bcfa39ab6d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:19:17 2022 -0300 Update logs in WebviewExecutionService commit cd822dc5458cf246485b01a4ce566777fa9383a4 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:18:49 2022 -0300 Add logs to SnapWebviewPostMessageStream commit 9b94d2602c527e977f3794186032c9af52bca324 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:18:29 2022 -0300 Update test UI commit 209d6633ae0e1734da2998823146bcc57e4b6c31 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:17:11 2022 -0300 Update test UI commit a524fca3db9b5a70cad667815598b6c7c74eccf7 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 14:16:46 2022 -0300 Remove logs from SnapWebviewPostMessageStream commit 2255d2215a01f0a8cca87a9198e75ea220a10450 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 01:34:55 2022 -0300 Add mock methods commit 12ae8f08c7406157de24535609cb965104b2184d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 01:34:35 2022 -0300 Terminate snap after install commit 2c247d561b7fe4f916a2df94f4679a7c089a5edd Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:31:01 2022 -0300 Update SnapController patch commit e743773b1dcaa3dee7e0129e67e07a2a44ef4c9d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:19:27 2022 -0300 Remove test code commit de535e4820457a0aefcf7bfc0f381f40bc9365cb Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:19:11 2022 -0300 Update WebviewPostMessageStream commit d2f84ec27cbb7397b9231dacddcbc2b549b947cb Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:17:11 2022 -0300 Update WebviewExecutionService commit df937db2a75e3904b0b836876bde5fa06cc75da1 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:16:48 2022 -0300 Add SnapWebviewPostMessageStream commit e5c92b00af09389d08a7a3be40545ae6e132200b Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:16:35 2022 -0300 Update log commit 98553374e7def653993a93e4db3554bf2e240625 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:15:33 2022 -0300 Add SnapDuplex commit 8e101a9cb96f7b346672d2dfbc55295558f464e6 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Dec 14 00:14:10 2022 -0300 Update code to test snap commit 7e93e07498ffa2ca1a1284dc57ee8ef714d7a113 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Dec 13 11:39:31 2022 -0300 Working version commit 92dbeb0776f6250d66fc9cf0cca7f652ac7952dc Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Dec 13 00:10:29 2022 -0300 Update SnapController patch commit 0f8d29d659af437112fe20041ec1fc80ac5b917f Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Dec 13 00:10:11 2022 -0300 Add SnapBridge commit 440d6dfb02b63cd0802017d0b18371e8df5e24e9 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Dec 13 00:09:42 2022 -0300 Ideas to install a snap from NPM commit ffd740964c1948439e7a63ea91339edb3af64500 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Dec 13 00:08:05 2022 -0300 setup SnapProvider using SnapBridge commit ebde0c8301eef06a6e3cf7845b9d0a446802927b Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Dec 13 00:07:28 2022 -0300 Add method to install snap from localhost commit 177576a4b598578394271e422d95f08637cf6713 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Dec 12 19:15:48 2022 -0300 Fix _initEnvStream bug commit 143d838f9335b8c5af4f6c7c339fce640651d40a Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Dec 12 19:15:02 2022 -0300 Update logic to call SnapController commit 97d603ed6168f3ca466e5de2fa53b8f376da48ba Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 8 10:29:14 2022 -0300 Add @metamask/snap-controllers patch commit 73ac81ff67ab6a7ca5e079bb80ad6a1cc2ca5385 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 8 10:28:50 2022 -0300 Update logic commit ae2159ba30b1ca670dd1e1861d5ce03c47519523 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 8 10:28:15 2022 -0300 Add tar-stream module commit 3aaef895b8389be88edc5efd5d2a53ae29998706 Merge: f61362b80 e4d382085 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 8 01:32:03 2022 -0300 Merge main commit f61362b802076df9d2b584366070344a9d1096d6 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Dec 4 01:16:56 2022 -0300 Update commit 6201277db0a1ea94a05b1dcc0dc74472b759d936 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Dec 4 01:15:48 2022 -0300 Update mock id commit 624d1089e5e13ced1aef3faff5dc6f5fa877bf20 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Dec 4 01:15:20 2022 -0300 Add methods to fetch snap commit 8d7d83584614d1d054aabe6aa7f993e0d337234d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Dec 4 01:04:41 2022 -0300 Add pako module commit fdf6f257823124a62d6ba9bece8938ad46d26f07 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Dec 4 01:03:42 2022 -0300 Add config to resolve stream commit 1ed70668826203caf387e34a44cb300a6f59dbc4 Merge: 83f71fd86 09b2cbce7 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Dec 1 22:54:07 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit 83f71fd86cd7736a71191cca675ef72c70c4695a Merge: 07f62b5a2 e29a42370 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Nov 30 18:38:57 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit 07f62b5a2c907ea07c889e16c6412e19c117695e Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Nov 28 01:13:56 2022 -0300 Fix comments indentation commit 62efd1ccc0aa868528293f82f24cba1da8790493 Merge: fc2c74bd6 db811ad02 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sun Nov 27 20:30:18 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit fc2c74bd65c4ba87e05941b9498eb11a33930534 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 26 09:18:23 2022 -0300 Add commented code to mock snap install commit 0a56825ce6dab2652eac04c9b7866886c5280b19 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 26 09:17:31 2022 -0300 Fix interface name commit 4daa5475dbf1d4d14fb5f9895695c850a1ca7559 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 26 09:17:10 2022 -0300 Update UI commit 988b4c6b4b9564102738edc174bfd467435104f8 Author: Andre Pimenta Date: Thu Nov 24 16:43:51 2022 +0000 Update Engine.js commit 2c1eb44cae218ddfce12e0bbf0b006d251eebad5 Author: Andre Pimenta Date: Thu Nov 24 16:42:01 2022 +0000 Adding missing files commit 3f7a5b51ae9b05803fe33a327d3799eb01d63003 Merge: b9e3e823b 87c644a2d Author: Andre Pimenta Date: Thu Nov 24 16:26:19 2022 +0000 Merge branch 'snaps/exec-env' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit b9e3e823b52ee7ba8b1d01c719c88f15ce8cc7c5 Author: Andre Pimenta Date: Thu Nov 24 16:26:13 2022 +0000 WebviewPostMessageStream commit 87c644a2d60ef2d70d6c82a690fa395e31627b11 Merge: 9e8734cf4 1c0ebb47c Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Nov 23 23:27:28 2022 -0300 Solve conflicts commit 9e8734cf489747d47199d34def4a0e9a4c415d1e Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed Nov 23 15:22:21 2022 -0300 Update POC commit c4118733b6c61858478a223453799cf1d5f11160 Merge: 311ecff28 b79dad079 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Nov 22 20:56:27 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit 311ecff28face79ef3fdcdcde778a537eb372c7e Merge: ceeb00961 42f06f76a Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Tue Nov 22 17:06:02 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit ceeb00961d8140bc09434e7063a7628dd5732dec Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Nov 21 11:50:48 2022 -0300 Update code commit ca86eeb815bcb6e39bd8e2c646fdd3cdd97d33f2 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 19 22:48:16 2022 -0300 Add SnapController (commented) commit 828b132daaa89f50f3fe40b8dd71cc048d5cb263 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 19 22:47:41 2022 -0300 Add SnapExecutionService commit 71913dfdd4fec6bd44c925668da3b313b098c3f4 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 19 22:47:26 2022 -0300 Add snap utils methods commit e08f36f70e10977e6f89003c7b6efb849d3fb43f Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 19 22:46:59 2022 -0300 Add snap permissions commit 18345032d7be0cfa01f8883331146847204b4f9d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 19 22:46:47 2022 -0300 Add SNAP_BLOCKLIST commit 404529b15de67bdd864aa3e200d2dfd32aeb8682 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Sat Nov 19 22:45:59 2022 -0300 Update dependencies commit 27df777691e69a2e676a8f96e2b982359d6d072c Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Nov 18 18:35:54 2022 -0300 Update metro file to avoid loading issue commit 76dfc275c68b43e71482c35cba34b06fd23e8ddf Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Nov 18 11:03:22 2022 -0300 Update script commit 4aeed70f991037baa4f979e995d09b9dac953912 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Nov 18 11:03:05 2022 -0300 Add new file for communication commit 5c30f89aec3a2fd7e209a183a0ec4eefef534118 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Nov 18 11:02:42 2022 -0300 Remove code commit 831a33b107fed3f98e4e657b7944e843b03521d5 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri Nov 18 11:02:22 2022 -0300 Update @types/react commit ec1addb1c6b3a9bc05c70017544f75620a53c214 Merge: 0c3c9909f 239d0a3b1 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 23:44:42 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit 0c3c9909f56889a51b842c93d2e6d44a2deb1b36 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 20:42:03 2022 -0300 Update base html commit 958f0a3a1bf54ffd04cd9a162bcd98773920eedf Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 20:27:13 2022 -0300 Update example iframe commit 7905892f8b5ae88da0c8afb7b2c0bcbce9a599a4 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 20:26:56 2022 -0300 Add start snap command commit 0efa08d6e21ab7b9c466d0e7c03594bb8a5469bc Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 17:13:22 2022 -0300 Update bundle helloWorld_snap commit 9506d071f1b9be39ae71ba4a0c22e907c6f47cb3 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 17:09:03 2022 -0300 Update bundle helloWorld_snap commit 85569ec00dedaaefbc1ca31d89e7ec72888b9174 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 17:01:14 2022 -0300 Add helloWorld_snap bundle commit a1c2401c2f81634f4b001aa5ad55e0637bf450be Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 17:00:17 2022 -0300 Update eslint ignorePattern (revert later) commit 383395b8f7eeeb5d3f10938945ed3b51a3c7bbbe Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 14:41:59 2022 -0300 Remove eslint disable comment commit 8f0c085f4089b045bbc96f37d2f609fffcb6e18d Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 14:41:20 2022 -0300 Delete old file commit 54f6f408dd6af5436cf6b1036951ac51aeba2e27 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 14:41:03 2022 -0300 Create HTML files for testing commit f328854df86a2bf41fbab882916188c92e3bb257 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 14:40:36 2022 -0300 Move utils to new file commit 5818c8acdcd605a8a1f6b61f0f6d1c27e0cd5e49 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 14:40:25 2022 -0300 Update POC code with new solution commit a41ee3657fbccf3db73b735dd5b63b9a96e697d0 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 14:39:51 2022 -0300 Move mockss to new file commit ac8644729cfe2731be6d6a136676782d632d5d02 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 17 14:39:40 2022 -0300 Move constants to new file commit 25497aa339203524e52dddaa3b37738ca2988798 Merge: 247e73b68 0e50c07e6 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Nov 14 18:55:43 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit 247e73b68a3a9d6dc7cc9fab5e60f2a441c624b9 Merge: bd8cfcb00 4cd929b17 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon Nov 14 12:19:09 2022 -0300 Merge branch 'main' of https://github.com/MetaMask/metamask-mobile into snaps/exec-env commit bd8cfcb009a8fcc13d95080c22967c5c6b29f455 Author: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu Nov 10 22:40:28 2022 -0300 Add some poc code --- android/.project | 11 + .../org.eclipse.buildship.core.prefs | 11 + app/components/Nav/Main/MainNavigator.js | 11 + app/components/Nav/Main/RootRPCMethodsUI.js | 94 ++- app/components/Nav/Main/index.js | 4 + app/components/UI/DrawerView/index.js | 32 + .../InstallSnapApproval.tsx | 92 +++ .../UI/InstallSnapApproval/index.ts | 6 + .../UI/InstallSnapApproval/styles.ts | 79 ++ .../UI/InstallSnapApproval/types.ts | 9 + .../SnapsExecutionWebView.tsx | 56 ++ .../UI/SnapsExecutionWebView/index.ts | 4 + .../UI/SnapsExecutionWebView/styles.ts | 20 + .../Views/AccountConnect/AccountConnect.tsx | 2 +- .../AccountConnectMultiSelector.tsx | 2 +- .../AccountConnectMultiSelector.types.ts | 2 +- .../AccountConnectSingle.tsx | 2 +- .../AccountConnectSingle.types.ts | 2 +- .../AccountConnectSingleSelector.tsx | 2 +- .../AccountConnectSingleSelector.types.ts | 2 +- .../AccountPermissions/AccountPermissions.tsx | 2 +- .../Views/Snaps/SnapElement/SnapElement.tsx | 81 ++ .../Views/Snaps/SnapElement/index.ts | 4 + .../Views/Snaps/SnapElement/styles.ts | 36 + app/components/Views/Snaps/SnapsDev.tsx | 98 +++ app/components/Views/Snaps/index.ts | 4 + app/components/Views/Snaps/styles.ts | 42 + app/constants/navigation/Routes.ts | 3 + app/constants/permissions.ts | 13 +- app/core/BackgroundBridge/BackgroundBridge.js | 40 + app/core/Engine.ts | 210 ++++- app/core/EngineService/EngineService.ts | 8 + app/core/Permissions/constants.js | 7 - app/core/Permissions/constants.ts | 16 + app/core/Permissions/specifications.js | 14 +- app/core/RPCMethods/RPCMethodMiddleware.ts | 10 + app/core/Snaps/SnapBridge.ts | 269 +++++++ app/core/Snaps/SnapDuplex.ts | 66 ++ .../Snaps/SnapWebviewPostMessageStream.ts | 63 ++ app/core/Snaps/SnapsState.ts | 6 + app/core/Snaps/WebviewExecutionService.ts | 66 ++ app/core/Snaps/WebviewPostMessageStream.ts | 80 ++ app/core/Snaps/createSnapMethodMiddleware.ts | 47 ++ app/core/Snaps/index.ts | 28 + app/core/Snaps/location/fetch.ts | 48 ++ app/core/Snaps/location/http.ts | 111 +++ app/core/Snaps/location/index.ts | 2 + app/core/Snaps/location/local.ts | 56 ++ app/core/Snaps/location/location.ts | 55 ++ app/core/Snaps/location/npm.ts | 417 ++++++++++ app/core/Snaps/permissions/permissions.ts | 41 + app/util/snaps/checkSnapsBlockList.js | 34 + app/util/snaps/index.js | 4 + app/util/snaps/snap-blocklist.ts | 11 + .../Light-Swift-Untar.swift | 175 ++++ ios/MetaMask-Bridging-Header.h | 1 + ios/MetaMask.xcodeproj/project.pbxproj | 22 + ios/Podfile | 1 + ios/Podfile.lock | 6 +- ios/RNTar.m | 17 + ios/RNTar.swift | 74 ++ package.json | 12 +- .../@metamask+browser-passworder+4.0.2.patch | 103 +++ .../@metamask+keyring-controller+1.0.1.patch | 40 +- .../@metamask+snaps-controllers+0.26.2.patch | 40 + shim.js | 9 + .../Screens/EditGasFeeScreen.testids.js | 2 +- yarn.lock | 746 +++++++++++++++++- 68 files changed, 3624 insertions(+), 59 deletions(-) create mode 100644 app/components/UI/InstallSnapApproval/InstallSnapApproval.tsx create mode 100644 app/components/UI/InstallSnapApproval/index.ts create mode 100644 app/components/UI/InstallSnapApproval/styles.ts create mode 100644 app/components/UI/InstallSnapApproval/types.ts create mode 100644 app/components/UI/SnapsExecutionWebView/SnapsExecutionWebView.tsx create mode 100644 app/components/UI/SnapsExecutionWebView/index.ts create mode 100644 app/components/UI/SnapsExecutionWebView/styles.ts create mode 100644 app/components/Views/Snaps/SnapElement/SnapElement.tsx create mode 100644 app/components/Views/Snaps/SnapElement/index.ts create mode 100644 app/components/Views/Snaps/SnapElement/styles.ts create mode 100644 app/components/Views/Snaps/SnapsDev.tsx create mode 100644 app/components/Views/Snaps/index.ts create mode 100644 app/components/Views/Snaps/styles.ts delete mode 100644 app/core/Permissions/constants.js create mode 100644 app/core/Permissions/constants.ts create mode 100644 app/core/Snaps/SnapBridge.ts create mode 100644 app/core/Snaps/SnapDuplex.ts create mode 100644 app/core/Snaps/SnapWebviewPostMessageStream.ts create mode 100644 app/core/Snaps/SnapsState.ts create mode 100644 app/core/Snaps/WebviewExecutionService.ts create mode 100644 app/core/Snaps/WebviewPostMessageStream.ts create mode 100644 app/core/Snaps/createSnapMethodMiddleware.ts create mode 100644 app/core/Snaps/index.ts create mode 100644 app/core/Snaps/location/fetch.ts create mode 100644 app/core/Snaps/location/http.ts create mode 100644 app/core/Snaps/location/index.ts create mode 100644 app/core/Snaps/location/local.ts create mode 100644 app/core/Snaps/location/location.ts create mode 100644 app/core/Snaps/location/npm.ts create mode 100644 app/core/Snaps/permissions/permissions.ts create mode 100644 app/util/snaps/checkSnapsBlockList.js create mode 100644 app/util/snaps/index.js create mode 100644 app/util/snaps/snap-blocklist.ts create mode 100644 ios/Light-Swift-Untar-V2/Light-Swift-Untar.swift create mode 100644 ios/RNTar.m create mode 100644 ios/RNTar.swift create mode 100644 patches/@metamask+browser-passworder+4.0.2.patch create mode 100644 patches/@metamask+snaps-controllers+0.26.2.patch diff --git a/android/.project b/android/.project index 3cf8618bf4c..1efd2443546 100644 --- a/android/.project +++ b/android/.project @@ -14,4 +14,15 @@ org.eclipse.buildship.core.gradleprojectnature + + + 1684448150858 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs index e8895216fd3..e479558406c 100644 --- a/android/.settings/org.eclipse.buildship.core.prefs +++ b/android/.settings/org.eclipse.buildship.core.prefs @@ -1,2 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.project.dir= eclipse.preferences.version=1 +gradle.user.home= +java.home= +jvm.arguments= +offline.mode=false +override.workspace.settings=false +show.console.view=false +show.executions.view=false diff --git a/app/components/Nav/Main/MainNavigator.js b/app/components/Nav/Main/MainNavigator.js index a5f1488be7c..725077e6b7d 100644 --- a/app/components/Nav/Main/MainNavigator.js +++ b/app/components/Nav/Main/MainNavigator.js @@ -55,6 +55,7 @@ import CheckoutWebView from '../../UI/FiatOnRampAggregator/Views/Checkout'; import OnRampSettings from '../../UI/FiatOnRampAggregator/Views/Settings'; import OnrampAddActivationKey from '../../UI/FiatOnRampAggregator/Views/Settings/AddActivationKey'; import Regions from '../../UI/FiatOnRampAggregator/Views/Regions'; +import { SnapsDev } from '../../Views/Snaps'; import { colors as importedColors } from '../../../styles/common'; import OrderDetails from '../../UI/FiatOnRampAggregator/Views/OrderDetails'; import TabBar from '../../../component-library/components/Navigation/TabBar'; @@ -622,6 +623,16 @@ const SetPasswordFlow = () => ( ); +const SnapsDevUI = () => ( + + + +); + const MainNavigator = () => ( { /> ); + const onInstallSnapConfirm = () => { + acceptPendingApproval(hostToApprove.id, hostToApprove.requestData); + setShowPendingApproval(false); + }; + + const onInstallSnapReject = () => { + // eslint-disable-next-line no-console + console.log( + 'onInstallSnapReject', + hostToApprove.id, + hostToApprove.requestData, + ); + rejectPendingApproval(hostToApprove.id, hostToApprove.requestData); + setShowPendingApproval(false); + }; + + /** + * Render the modal that asks the user to approve/reject connections to a dapp using the MetaMask SDK. + */ + const renderInstallSnapApprovalModal = () => ( + + + + ); + // unapprovedTransaction effect useEffect(() => { Engine.context.TransactionController.hub.on( @@ -691,26 +733,39 @@ const RootRPCMethodsUI = (props) => { } switch (request.type) { + case ApprovalTypes.INSTALL_SNAP: + // eslint-disable-next-line no-console + console.log({ requestData, id: request.id }); + setHostToApprove({ requestData, id: request.id }); + showPendingApprovalModal({ + type: ApprovalTypes.INSTALL_SNAP, + origin: request.origin, + }); + break; + case ApprovalTypes.UPDATE_SNAP: + // eslint-disable-next-line no-console + console.log('Update Snap'); + break; case ApprovalTypes.REQUEST_PERMISSIONS: - if (requestData?.permissions?.eth_accounts) { - const { - metadata: { id }, - } = requestData; - - const totalAccounts = props.accountsLength; - - AnalyticsV2.trackEvent(MetaMetricsEvents.CONNECT_REQUEST_STARTED, { - number_of_accounts: totalAccounts, - source: 'PERMISSION SYSTEM', - }); - - props.navigation.navigate( - ...createAccountConnectNavDetails({ - hostInfo: requestData, - permissionRequestId: id, - }), - ); - } + // eslint-disable-next-line no-case-declarations + const { + metadata: { id }, + } = requestData; + + // eslint-disable-next-line no-case-declarations + const totalAccounts = props.accountsLength; + + AnalyticsV2.trackEvent(MetaMetricsEvents.CONNECT_REQUEST_STARTED, { + number_of_accounts: totalAccounts, + source: 'PERMISSION SYSTEM', + }); + + props.navigation.navigate( + ...createAccountConnectNavDetails({ + hostInfo: requestData, + permissionRequestId: id, + }), + ); break; case ApprovalTypes.CONNECT_ACCOUNTS: setHostToApprove({ data: requestData, id: request.id }); @@ -800,6 +855,7 @@ const RootRPCMethodsUI = (props) => { {renderWatchAssetModal()} {renderQRSigningModal()} {renderAccountsApprovalModal()} + {renderInstallSnapApprovalModal()} ); }; diff --git a/app/components/Nav/Main/index.js b/app/components/Nav/Main/index.js index 2839c2a276b..b5b3d9aef71 100644 --- a/app/components/Nav/Main/index.js +++ b/app/components/Nav/Main/index.js @@ -68,6 +68,7 @@ import { selectProviderConfig, selectProviderType, } from '../../../selectors/networkController'; +import { SnapsExecutionWebView } from '../../UI/SnapsExecutionWebView'; const Stack = createStackNavigator(); @@ -335,6 +336,9 @@ const Main = (props) => { ) : ( renderLoader() )} + + + diff --git a/app/components/UI/DrawerView/index.js b/app/components/UI/DrawerView/index.js index 0bee75a2491..a87d6fa7623 100644 --- a/app/components/UI/DrawerView/index.js +++ b/app/components/UI/DrawerView/index.js @@ -665,6 +665,23 @@ class DrawerView extends PureComponent { this.hideDrawer(); this.trackEvent(MetaMetricsEvents.WALLET_OPENED); }; + goToTransactionHistory = () => { + this.props.navigation.navigate('TransactionsHome'); + this.hideDrawer(); + this.trackEvent(MetaMetricsEvents.NAVIGATION_TAPS_TRANSACTION_HISTORY); + }; + + navigateToSnapsView = () => { + const { navigation } = this.props; + navigation.navigate(Routes.SNAPS.HOME); + this.hideDrawer(); + }; + + showSettings = async () => { + this.props.navigation.navigate('SettingsView'); + this.hideDrawer(); + this.trackEvent(MetaMetricsEvents.NAVIGATION_TAPS_SETTINGS); + }; onPressLock = async () => { const { passwordSet } = this.props; @@ -863,6 +880,21 @@ class DrawerView extends PureComponent { blockExplorerName = getBlockExplorerName(blockExplorer); } return [ + [ + { + name: strings('drawer.transaction_activity'), + icon: this.getFeatherIcon('list'), + selectedIcon: this.getSelectedFeatherIcon('list'), + action: this.goToTransactionHistory, + routeNames: ['TransactionsView'], + }, + { + name: 'Snaps', + icon: this.getFeatherIcon('box'), + selectedIcon: this.getSelectedFeatherIcon('box'), + action: this.navigateToSnapsView, + }, + ], [ { name: strings('drawer.share_address'), diff --git a/app/components/UI/InstallSnapApproval/InstallSnapApproval.tsx b/app/components/UI/InstallSnapApproval/InstallSnapApproval.tsx new file mode 100644 index 00000000000..42861186db6 --- /dev/null +++ b/app/components/UI/InstallSnapApproval/InstallSnapApproval.tsx @@ -0,0 +1,92 @@ +import React from 'react'; +import { Text, View } from 'react-native'; +import { useSelector } from 'react-redux'; +import { InstallSnapApprovalArgs } from './types'; +import createStyles from './styles'; +import { useAppThemeFromContext, mockTheme } from '../../../util/theme'; +import StyledButton from '../StyledButton'; +import { strings } from '../../../../locales/i18n'; +import { + ACCOUNT_APROVAL_MODAL_CONTAINER_ID, + CANCEL_BUTTON_ID, +} from '../../../constants/test-ids'; + +interface KeyItem { + key: string; +} + +const InstallSnapApproval = ({ + requestData, + onConfirm, + onCancel, +}: InstallSnapApprovalArgs) => { + const { colors } = useAppThemeFromContext() || mockTheme; + const styles = createStyles(colors); + + const selectedAddress = useSelector( + (state: any) => + state.engine.backgroundState.PreferencesController.selectedAddress, + ); + + const confirm = (): void => { + // eslint-disable-next-line no-console + console.log('confirm', onConfirm); + onConfirm(); + // Add track event + }; + + const cancel = (): void => { + // Add track event + onCancel(); + }; + const renderPermissions = () => { + // eslint-disable-next-line react/prop-types + const { permissions } = requestData.requestData; + const keys = Object.keys(permissions); + const keyItems: KeyItem[] = keys.map((key) => ({ key })); + + return ( + + Permission: + + {keyItems.map((item) => ( + + {item.key} + + ))} + + + ); + }; + return ( + + + {`account: ${selectedAddress}`} + + SNAP ID: {`${requestData.requestData.metadata.origin}`} + + {renderPermissions()} + + + {strings('accountApproval.cancel')} + + + Approve + + + + + ); +}; + +export default InstallSnapApproval; diff --git a/app/components/UI/InstallSnapApproval/index.ts b/app/components/UI/InstallSnapApproval/index.ts new file mode 100644 index 00000000000..043b61328a1 --- /dev/null +++ b/app/components/UI/InstallSnapApproval/index.ts @@ -0,0 +1,6 @@ +import InstallSnapApproval from './InstallSnapApproval'; +import { InstallSnapApprovalArgs } from './types'; + +export { InstallSnapApproval }; + +export type { InstallSnapApprovalArgs }; diff --git a/app/components/UI/InstallSnapApproval/styles.ts b/app/components/UI/InstallSnapApproval/styles.ts new file mode 100644 index 00000000000..13131124f64 --- /dev/null +++ b/app/components/UI/InstallSnapApproval/styles.ts @@ -0,0 +1,79 @@ +import { StyleSheet } from 'react-native'; +import { fontStyles } from '../../../styles/common'; +import Device from '../../../util/device'; + +const createStyles = (colors: any) => + StyleSheet.create({ + root: { + backgroundColor: colors.background.default, + paddingTop: 24, + borderTopLeftRadius: 20, + borderTopRightRadius: 20, + minHeight: 200, + paddingBottom: Device.isIphoneX() ? 20 : 0, + }, + accountCardWrapper: { + paddingHorizontal: 24, + }, + intro: { + ...fontStyles.bold, + textAlign: 'center', + color: colors.text.default, + fontSize: Device.isSmallDevice() ? 16 : 20, + marginBottom: 8, + marginTop: 16, + }, + warning: { + ...fontStyles.thin, + color: colors.text.default, + paddingHorizontal: 24, + marginBottom: 16, + fontSize: 14, + width: '100%', + textAlign: 'center', + }, + actionContainer: { + flex: 0, + flexDirection: 'row', + paddingVertical: 16, + paddingHorizontal: 24, + }, + button: { + flex: 1, + }, + cancel: { + marginRight: 8, + }, + confirm: { + marginLeft: 8, + }, + heading: { + fontSize: 16, + fontWeight: 'bold', + marginBottom: 10, + }, + listItem: { + marginBottom: 5, + }, + permissionContainer: { + marginBottom: 10, + }, + title: { + fontSize: 16, + fontWeight: 'bold', + marginBottom: 10, + }, + keysContainer: { + flexWrap: 'wrap', + }, + key: { + borderRadius: 10, + paddingHorizontal: 10, + paddingVertical: 5, + marginRight: 10, + marginBottom: 10, + fontSize: 16, + }, + }); + +export default createStyles; diff --git a/app/components/UI/InstallSnapApproval/types.ts b/app/components/UI/InstallSnapApproval/types.ts new file mode 100644 index 00000000000..5c5428ef789 --- /dev/null +++ b/app/components/UI/InstallSnapApproval/types.ts @@ -0,0 +1,9 @@ +interface InstallSnapApprovalArgs { + requestData: any; + onConfirm: () => void; + onCancel: () => void; + chainId?: string; +} + +// eslint-disable-next-line import/prefer-default-export +export type { InstallSnapApprovalArgs }; diff --git a/app/components/UI/SnapsExecutionWebView/SnapsExecutionWebView.tsx b/app/components/UI/SnapsExecutionWebView/SnapsExecutionWebView.tsx new file mode 100644 index 00000000000..c55d8aaa207 --- /dev/null +++ b/app/components/UI/SnapsExecutionWebView/SnapsExecutionWebView.tsx @@ -0,0 +1,56 @@ +import React, { useRef } from 'react'; +import { View, ScrollView } from 'react-native'; +import WebView from 'react-native-webview'; +import { snapsState, WebviewPostMessageStream } from '../../../core/Snaps'; +import { createStyles } from './styles'; + +let stream: any; + +const SnapsExecutionWebView = () => { + const styles = createStyles(); + + const webviewRef = useRef(); + + const setWebviewPostMessage = () => { + stream = new WebviewPostMessageStream({ + name: 'rnside', + target: 'webview', + targetOrigin: '*', + targetWindow: webviewRef.current, + }); + + // eslint-disable-next-line no-console + stream.on('data', (data: any) => + // eslint-disable-next-line no-console + console.log( + '[APP LOG] setWebviewPostMessage: Message from Webview ' + data, + ), + ); + + snapsState.stream = stream; + snapsState.webview = webviewRef.current; + }; + + const messageFromWebview = (data: any) => { + stream?._onMessage(data); + }; + + return ( + + + + + + ); +}; + +export default SnapsExecutionWebView; diff --git a/app/components/UI/SnapsExecutionWebView/index.ts b/app/components/UI/SnapsExecutionWebView/index.ts new file mode 100644 index 00000000000..5e8c0f374a9 --- /dev/null +++ b/app/components/UI/SnapsExecutionWebView/index.ts @@ -0,0 +1,4 @@ +import SnapsExecutionWebView from './SnapsExecutionWebView'; + +// eslint-disable-next-line import/prefer-default-export +export { SnapsExecutionWebView }; diff --git a/app/components/UI/SnapsExecutionWebView/styles.ts b/app/components/UI/SnapsExecutionWebView/styles.ts new file mode 100644 index 00000000000..659b2428b60 --- /dev/null +++ b/app/components/UI/SnapsExecutionWebView/styles.ts @@ -0,0 +1,20 @@ +/* eslint-disable react-native/no-color-literals */ +import { StyleSheet } from 'react-native'; + +// eslint-disable-next-line import/prefer-default-export +export const createStyles = () => + StyleSheet.create({ + webview: { + height: 0, + // marginBottom: 50, + // borderWidth: 1, + // borderStyle: 'dashed', + // borderColor: 'red', + }, + container: { + // flex: 1, + // borderWidth: 1, + // borderStyle: 'dashed', + // borderColor: 'green', + }, + }); diff --git a/app/components/Views/AccountConnect/AccountConnect.tsx b/app/components/Views/AccountConnect/AccountConnect.tsx index a027349b2bf..47a20278fe9 100644 --- a/app/components/Views/AccountConnect/AccountConnect.tsx +++ b/app/components/Views/AccountConnect/AccountConnect.tsx @@ -35,7 +35,7 @@ import { getUrlObj, prefixUrlWithProtocol } from '../../../util/browser'; import { strings } from '../../../../locales/i18n'; import { AvatarAccountType } from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount'; import { safeToChecksumAddress } from '../../../util/address'; -import USER_INTENT from '../../../constants/permissions'; +import { USER_INTENT } from '../../../constants/permissions'; // Internal dependencies. import { diff --git a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx index e9cb31f0070..d7def3fcb64 100644 --- a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx +++ b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx @@ -14,7 +14,7 @@ import Button, { ButtonWidthTypes, } from '../../../../component-library/components/Buttons/Button'; import AccountSelectorList from '../../../UI/AccountSelectorList'; -import USER_INTENT from '../../../../constants/permissions'; +import { USER_INTENT } from '../../../../constants/permissions'; import generateTestId from '../../../../../wdio/utils/generateTestId'; import { ACCOUNT_APPROVAL_SELECT_ALL_BUTTON } from '../../../../../wdio/screen-objects/testIDs/Components/AccountApprovalModal.testIds'; diff --git a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.types.ts b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.types.ts index 7a4420f58c8..e0db8a7c2c4 100644 --- a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.types.ts +++ b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.types.ts @@ -12,7 +12,7 @@ export enum AccountConnectMultiSelectorScreens { // External dependencies. import { UseAccounts } from '../../../hooks/useAccounts'; import { IconName } from '../../../../component-library/components/Icons/Icon'; -import USER_INTENT from '../../../../constants/permissions'; +import { USER_INTENT } from '../../../../constants/permissions'; /** * AccountConnectMultiSelector props. diff --git a/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.tsx b/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.tsx index 0a864dc50ff..7ff499d6732 100644 --- a/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.tsx +++ b/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.tsx @@ -29,7 +29,7 @@ import { AccountConnectScreens } from '../AccountConnect.types'; // Internal dependencies. import { AccountConnectSingleProps } from './AccountConnectSingle.types'; import styleSheet from './AccountConnectSingle.styles'; -import USER_INTENT from '../../../../constants/permissions'; +import { USER_INTENT } from '../../../../constants/permissions'; import { ACCOUNT_APROVAL_MODAL_CONTAINER_ID, diff --git a/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.types.ts b/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.types.ts index 702a2928bea..197398910ec 100644 --- a/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.types.ts +++ b/app/components/Views/AccountConnect/AccountConnectSingle/AccountConnectSingle.types.ts @@ -5,7 +5,7 @@ import { ImageSourcePropType } from 'react-native'; import { AccountConnectScreens } from '../AccountConnect.types'; import { Account } from '../../../hooks/useAccounts'; import { IconName } from '../../../../component-library/components/Icons/Icon'; -import USER_INTENT from '../../../../constants/permissions'; +import { USER_INTENT } from '../../../../constants/permissions'; /** * AccountConnectSingle props. diff --git a/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.tsx b/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.tsx index fdc06822918..152aef7761a 100644 --- a/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.tsx +++ b/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.tsx @@ -12,7 +12,7 @@ import { AccountConnectScreens } from '../AccountConnect.types'; // Internal dependencies. import { AccountConnectSingleSelectorProps } from './AccountConnectSingleSelector.types'; import styles from './AccountConnectSingleSelector.styles'; -import USER_INTENT from '../../../../constants/permissions'; +import { USER_INTENT } from '../../../../constants/permissions'; const AccountConnectSingleSelector = ({ accounts, diff --git a/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.types.ts b/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.types.ts index a07edeb7466..839bbf19eeb 100644 --- a/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.types.ts +++ b/app/components/Views/AccountConnect/AccountConnectSingleSelector/AccountConnectSingleSelector.types.ts @@ -1,6 +1,6 @@ // External dependencies. import { UseAccounts } from '../../../hooks/useAccounts'; -import USER_INTENT from '../../../../constants/permissions'; +import { USER_INTENT } from '../../../../constants/permissions'; import { AccountConnectScreens } from '../AccountConnect.types'; /** diff --git a/app/components/Views/AccountPermissions/AccountPermissions.tsx b/app/components/Views/AccountPermissions/AccountPermissions.tsx index b220895e4b3..761e0ca6567 100755 --- a/app/components/Views/AccountPermissions/AccountPermissions.tsx +++ b/app/components/Views/AccountPermissions/AccountPermissions.tsx @@ -45,7 +45,7 @@ import { } from './AccountPermissions.types'; import AccountPermissionsConnected from './AccountPermissionsConnected'; import AccountPermissionsRevoke from './AccountPermissionsRevoke'; -import USER_INTENT from '../../../constants/permissions'; +import { USER_INTENT } from '../../../constants/permissions'; const AccountPermissions = (props: AccountPermissionsProps) => { const navigation = useNavigation(); diff --git a/app/components/Views/Snaps/SnapElement/SnapElement.tsx b/app/components/Views/Snaps/SnapElement/SnapElement.tsx new file mode 100644 index 00000000000..9570a0c0fd9 --- /dev/null +++ b/app/components/Views/Snaps/SnapElement/SnapElement.tsx @@ -0,0 +1,81 @@ +import React, { useState } from 'react'; +import { View, TextInput } from 'react-native'; + +import Engine from '../../../../core/Engine'; +import { useTheme } from '../../../../util/theme'; +import Text from '../../../../component-library/components/Texts/Text'; +import Button, { + ButtonVariants, + ButtonSize, +} from '../../../../component-library/components/Buttons/Button'; + +import { createStyles } from './styles'; + +const SnapElement = (snap: any) => { + const { colors } = useTheme(); + const styles = createStyles(colors); + + const [input, setInput] = useState(''); + + const ping = async () => { + // eslint-disable-next-line no-console + console.log('ping'); + }; + + const terminate = async () => { + const { SnapController } = Engine.context as any; + await SnapController.terminateSnap(snap.snap.id); + }; + + const executeSnapMethod = async (): Promise => { + const { SnapController } = Engine.context as any; + const localSnap = snap.snap.id; + const origin = 'metamask-mobile'; + await SnapController.handleRequest({ + snapId: localSnap, + origin, + handler: 'onRpcRequest', + request: { + method: input.toLowerCase(), + }, + }); + }; + + return ( + + {`Snap: ${snap.snap.id}`} + {`Status: ${snap.snap.status}`} + +