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: Snaps new architecture mobile integration #8700

Merged
merged 40 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
447fe53
bump: snaps rpc & utils, adds sdk
Jonathansoufer Feb 15, 2024
89c1cb2
chore: refactor methods usages due bumped packages
Jonathansoufer Feb 15, 2024
ed4ba93
chore: bump snaps-controller package
Jonathansoufer Feb 15, 2024
dd2ebe0
chore: changing methods imports
Jonathansoufer Feb 15, 2024
6e53131
chore: bump post-message-stream package + patching
Jonathansoufer Feb 16, 2024
689874e
chore: bump @metamask/base-controller
Jonathansoufer Feb 16, 2024
54d950c
chore: resolve conflicts
Jonathansoufer Feb 16, 2024
2d16f56
bump: snaps rpc & utils, adds sdk
Jonathansoufer Feb 15, 2024
50f9ac6
chore: refactor methods usages due bumped packages
Jonathansoufer Feb 15, 2024
ae042ae
chore: bump snaps-controller package
Jonathansoufer Feb 15, 2024
e972553
chore: changing methods imports
Jonathansoufer Feb 15, 2024
1792a18
chore: bump post-message-stream package + patching
Jonathansoufer Feb 16, 2024
4276131
chore: bump @metamask/base-controller
Jonathansoufer Feb 16, 2024
9f2260b
yarn dedupe
owencraston Feb 16, 2024
00ab85f
fix specifications.test.js
owencraston Feb 16, 2024
c99d0ed
Merge branch 'main' into feat/bump-mobile-snaps-packages
Jonathansoufer Feb 17, 2024
920d70d
chore: resolve conflicts
Jonathansoufer Feb 19, 2024
60121f5
chore: resolve conflicts on yarn.lock
Jonathansoufer Feb 19, 2024
55ada1b
chore: fix test match with snaps codefence
Jonathansoufer Feb 19, 2024
939e1f3
chore: adds unencryptedSnapStates state
Jonathansoufer Feb 19, 2024
f34423d
chore: fix lint problems on Engine mod
Jonathansoufer Feb 19, 2024
e1e234b
Merge branch 'main' into feat/bump-mobile-snaps-packages
Jonathansoufer Feb 20, 2024
cccda48
fix: endownments imports
Jonathansoufer Feb 20, 2024
d912f25
Merge branch 'feat/bump-mobile-snaps-packages' of github.com:MetaMask…
Jonathansoufer Feb 20, 2024
81e2d18
chore: handle type mismatching due base-controller type change
Jonathansoufer Feb 20, 2024
e23697d
Merge branch 'main' into feat/bump-mobile-snaps-packages
Jonathansoufer Feb 20, 2024
d3a1dc7
chore: adds explicity on getRestricted type due issue core/issues/3648
Jonathansoufer Feb 20, 2024
2faa3ce
Merge branch 'feat/bump-mobile-snaps-packages' of github.com:MetaMask…
Jonathansoufer Feb 20, 2024
2ca518b
chore: replicates 8369 PR from branched 8607 PR
Jonathansoufer Feb 21, 2024
54234d2
chore: adds addSubjectMetadata action
Jonathansoufer Feb 22, 2024
b9566be
update permission controller to enable addSubjectMetaData controller
owencraston Feb 23, 2024
ad48683
chore: fix addSubjectMetadata name requir
Jonathansoufer Feb 23, 2024
f97a9f2
Merge branch 'main' into feat/snaps-integration-refactor
Jonathansoufer Feb 23, 2024
6d0f220
chore: fix lint issue
Jonathansoufer Feb 23, 2024
df5f6d9
chore: fix depcheck unused devDependencies
Jonathansoufer Feb 23, 2024
63b5887
Merge branch 'main' into feat/snaps-integration-refactor
Jonathansoufer Feb 23, 2024
7915e68
Merge branch 'feat/snaps-integration-refactor' of github.com:MetaMask…
Jonathansoufer Feb 23, 2024
63835a9
Merge branch 'main' into feat/snaps-integration-refactor
Jonathansoufer Feb 26, 2024
ee67ff1
chore: fix merge conflicts
Jonathansoufer Feb 27, 2024
0aa92f5
chore: fix dedup
Jonathansoufer Feb 27, 2024
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
2 changes: 1 addition & 1 deletion app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import {
stopIncomingTransactionPolling,
} from '../../../util/transaction-controller';
///: BEGIN:ONLY_INCLUDE_IF(snaps)
import { SnapsExecutionWebView } from '../../UI/SnapsExecutionWebView';
import { SnapsExecutionWebView } from '../../../lib/snaps';
///: END:ONLY_INCLUDE_IF

const Stack = createStackNavigator();
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions app/components/UI/SnapsExecutionWebView/index.ts

This file was deleted.

31 changes: 20 additions & 11 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ import {
SnapControllerEvents,
SnapControllerActions,
PersistedSnapControllerState,
WebViewExecutionService,
} from '@metamask/snaps-controllers';
import { Snap } from '@metamask/snaps-utils';
import { NotificationArgs } from '@metamask/snaps-rpc-methods/dist/types/restricted/notify';
import { getSnapsWebViewPromise } from '../lib/snaps';
import {
buildSnapEndowmentSpecifications,
buildSnapRestrictedMethodSpecifications,
Expand Down Expand Up @@ -149,7 +151,6 @@ import AnalyticsV2 from '../util/analyticsV2';
///: BEGIN:ONLY_INCLUDE_IF(snaps)
import {
SnapBridge,
WebviewExecutionService,
ExcludedSnapEndowments,
ExcludedSnapPermissions,
detectSnapLocation,
Expand Down Expand Up @@ -332,7 +333,7 @@ class Engine {
/**
* Object that runs and manages the execution of Snaps
*/
snapExecutionService: WebviewExecutionService;
snapExecutionService: WebViewExecutionService;
///: END:ONLY_INCLUDE_IF

/**
Expand All @@ -353,6 +354,8 @@ class Engine {
never
>({
name: 'ApprovalController',
allowedEvents: [],
allowedActions: [],
}),
showApprovalRequest: () => undefined,
typesExcludedFromRateLimiting: [
Expand Down Expand Up @@ -384,7 +387,8 @@ class Engine {
messenger: this.controllerMessenger.getRestricted<
'NetworkController',
never,
// @ts-expect-error TODO: Resolve/patch mismatch between base-controller versions. Before: never, never. Now: string, string, which expects 3rd and 4th args to be informed for restrictedControllerMessengers
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // TODO: fix this type mismatch after the base-controller version is updated
'NetworkController:networkDidChange'
>({
name: 'NetworkController',
Expand All @@ -397,7 +401,8 @@ class Engine {
// noop
},
};
// @ts-expect-error TODO: Resolve/patch mismatch between base-controller versions. Before: never, never. Now: string, string, which expects 3rd and 4th args to be informed for restrictedControllerMessengers
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const networkController = new NetworkController(networkControllerOpts);

networkController.initializeProvider();
Expand Down Expand Up @@ -634,6 +639,11 @@ class Engine {
),
getMnemonic: getPrimaryKeyringMnemonic.bind(this),
getUnlockPromise: getAppState.bind(this),
addSubjectMetadata: (params: any) =>
Jonathansoufer marked this conversation as resolved.
Show resolved Hide resolved
this.controllerMessenger.call<'SubjectMetadataController:addSubjectMetadata'>(
'SubjectMetadataController:addSubjectMetadata',
params,
),
getSnap: this.controllerMessenger.call.bind(
this.controllerMessenger,
'SnapController:get',
Expand Down Expand Up @@ -801,11 +811,12 @@ class Engine {
'0x025b65308f0f0fb8bc7f7ff87bfc296e0330eee5d3c1d1ee4a048b2fd6a86fa0a6',
});

this.snapExecutionService = new WebviewExecutionService({
this.snapExecutionService = new WebViewExecutionService({
messenger: this.controllerMessenger.getRestricted({
name: 'ExecutionService',
}),
setupSnapProvider: setupSnapProvider.bind(this),
getWebView: () => getSnapsWebViewPromise,
});

const snapControllerMessenger = this.controllerMessenger.getRestricted({
Expand All @@ -831,6 +842,7 @@ class Engine {
`${approvalController.name}:updateRequestState`,
`${permissionController.name}:grantPermissions`,
`${subjectMetadataController.name}:getSubjectMetadata`,
`${subjectMetadataController.name}:addSubjectMetadata`,
`${phishingController.name}:maybeUpdateState`,
`${phishingController.name}:testOrigin`,
`${snapsRegistry.name}:get`,
Expand Down Expand Up @@ -872,15 +884,12 @@ class Engine {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(snap: Snap, svgIcon: any = null) => {
const {
manifest: { proposedName },
version,
} = snap;
const parts = snap.id.split(/[:/]/);
subjectMetadataController.addSubjectMetadata({
Jonathansoufer marked this conversation as resolved.
Show resolved Hide resolved
subjectType: SubjectType.Snap,
name: proposedName,
name: parts[parts.length - 1] || snap.id,
Jonathansoufer marked this conversation as resolved.
Show resolved Hide resolved
origin: snap.id,
version,
version: snap.version,
svgIcon,
});
},
Expand Down
73 changes: 0 additions & 73 deletions app/core/Snaps/SnapDuplex.ts

This file was deleted.

55 changes: 0 additions & 55 deletions app/core/Snaps/SnapWebviewPostMessageStream.ts

This file was deleted.

8 changes: 0 additions & 8 deletions app/core/Snaps/SnapsState.ts

This file was deleted.

51 changes: 0 additions & 51 deletions app/core/Snaps/WebviewExecutionService.ts

This file was deleted.

Loading
Loading