Skip to content

Commit 4a134df

Browse files
committed
update notification example snap and test-snaps
1 parent b0036f5 commit 4a134df

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

packages/examples/packages/notifications/src/index.ts packages/examples/packages/notifications/src/index.tsx

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MethodNotFoundError, NotificationType } from '@metamask/snaps-sdk';
22
import type { OnRpcRequestHandler } from '@metamask/snaps-sdk';
3+
import { Box, Row, Address } from '@metamask/snaps-sdk/jsx';
34

45
/**
56
* Handle incoming JSON-RPC requests from the dapp, sent through the
@@ -39,6 +40,28 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
3940
},
4041
});
4142

43+
case 'inApp-expanded':
44+
return await snap.request({
45+
method: 'snap_notify',
46+
params: {
47+
type: NotificationType.InApp,
48+
message: 'Hello from MetaMask, click here for an expanded view!',
49+
title: 'Hello World!',
50+
content: (
51+
<Box>
52+
<Row
53+
label="From"
54+
variant="warning"
55+
tooltip="This address has been deemed dangerous."
56+
>
57+
<Address address="0x1234567890123456789012345678901234567890" />
58+
</Row>
59+
</Box>
60+
),
61+
footerLink: { text: 'Go home', href: 'metamask://client/' },
62+
},
63+
});
64+
4265
default:
4366
// eslint-disable-next-line @typescript-eslint/no-throw-literal
4467
throw new MethodNotFoundError({ method: request.method });

packages/test-snaps/src/features/snaps/notifications/Notifications.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,20 @@ export const Notifications: FunctionComponent = () => {
3131
>
3232
<ButtonGroup>
3333
<Button
34-
variant="primary"
3534
id="sendInAppNotification"
3635
disabled={isLoading}
3736
onClick={handleClick('inApp')}
3837
>
3938
Send In-App Notification
4039
</Button>
4140
<Button
42-
variant="secondary"
41+
id="sendExpandedViewNotification"
42+
disabled={isLoading}
43+
onClick={handleClick('inApp-extended')}
44+
>
45+
Send In-App Notification With Expanded View
46+
</Button>
47+
<Button
4348
id="sendNativeNotification"
4449
disabled={isLoading}
4550
onClick={handleClick('native')}

0 commit comments

Comments
 (0)