File tree 2 files changed +30
-2
lines changed
examples/packages/notifications/src
test-snaps/src/features/snaps/notifications
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { MethodNotFoundError , NotificationType } from '@metamask/snaps-sdk' ;
2
2
import type { OnRpcRequestHandler } from '@metamask/snaps-sdk' ;
3
+ import { Box , Row , Address } from '@metamask/snaps-sdk/jsx' ;
3
4
4
5
/**
5
6
* Handle incoming JSON-RPC requests from the dapp, sent through the
@@ -39,6 +40,28 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
39
40
} ,
40
41
} ) ;
41
42
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
+
42
65
default :
43
66
// eslint-disable-next-line @typescript-eslint/no-throw-literal
44
67
throw new MethodNotFoundError ( { method : request . method } ) ;
Original file line number Diff line number Diff line change @@ -31,15 +31,20 @@ export const Notifications: FunctionComponent = () => {
31
31
>
32
32
< ButtonGroup >
33
33
< Button
34
- variant = "primary"
35
34
id = "sendInAppNotification"
36
35
disabled = { isLoading }
37
36
onClick = { handleClick ( 'inApp' ) }
38
37
>
39
38
Send In-App Notification
40
39
</ Button >
41
40
< 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
43
48
id = "sendNativeNotification"
44
49
disabled = { isLoading }
45
50
onClick = { handleClick ( 'native' ) }
You can’t perform that action at this time.
0 commit comments