From 4a134df1548ea40bb0630f6da7422c014b0223e9 Mon Sep 17 00:00:00 2001 From: Hassan Malik Date: Sat, 14 Dec 2024 13:10:16 -0500 Subject: [PATCH 01/16] update notification example snap and test-snaps --- .../notifications/src/{index.ts => index.tsx} | 23 +++++++++++++++++++ .../snaps/notifications/Notifications.tsx | 9 ++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) rename packages/examples/packages/notifications/src/{index.ts => index.tsx} (70%) diff --git a/packages/examples/packages/notifications/src/index.ts b/packages/examples/packages/notifications/src/index.tsx similarity index 70% rename from packages/examples/packages/notifications/src/index.ts rename to packages/examples/packages/notifications/src/index.tsx index 03cb37a4be..399b562a9a 100644 --- a/packages/examples/packages/notifications/src/index.ts +++ b/packages/examples/packages/notifications/src/index.tsx @@ -1,5 +1,6 @@ import { MethodNotFoundError, NotificationType } from '@metamask/snaps-sdk'; import type { OnRpcRequestHandler } from '@metamask/snaps-sdk'; +import { Box, Row, Address } from '@metamask/snaps-sdk/jsx'; /** * Handle incoming JSON-RPC requests from the dapp, sent through the @@ -39,6 +40,28 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => { }, }); + case 'inApp-expanded': + return await snap.request({ + method: 'snap_notify', + params: { + type: NotificationType.InApp, + message: 'Hello from MetaMask, click here for an expanded view!', + title: 'Hello World!', + content: ( + + +
+ + + ), + footerLink: { text: 'Go home', href: 'metamask://client/' }, + }, + }); + default: // eslint-disable-next-line @typescript-eslint/no-throw-literal throw new MethodNotFoundError({ method: request.method }); diff --git a/packages/test-snaps/src/features/snaps/notifications/Notifications.tsx b/packages/test-snaps/src/features/snaps/notifications/Notifications.tsx index 3fcd0a8938..4d3aa343b6 100644 --- a/packages/test-snaps/src/features/snaps/notifications/Notifications.tsx +++ b/packages/test-snaps/src/features/snaps/notifications/Notifications.tsx @@ -31,7 +31,6 @@ export const Notifications: FunctionComponent = () => { > +