11import type { OnSettingsPageHandler } from '@metamask/snaps-sdk' ;
2- import {
3- assert ,
4- UserInputEventType ,
5- type OnUserInputHandler ,
6- } from '@metamask/snaps-sdk' ;
7- import {
8- Box ,
9- Container ,
10- Footer ,
11- Heading ,
12- Text ,
13- Button ,
14- } from '@metamask/snaps-sdk/jsx' ;
2+ import { Box , Heading , Text } from '@metamask/snaps-sdk/jsx' ;
153
164/**
175 * Handle incoming settings page requests from the MetaMask clients.
@@ -22,43 +10,10 @@ import {
2210export const onSettingsPage : OnSettingsPageHandler = async ( ) => {
2311 return {
2412 content : (
25- < Container >
26- < Box >
27- < Heading > Hello world!</ Heading >
28- < Text > Welcome to my Snap settings page!</ Text >
29- </ Box >
30- < Footer >
31- < Button name = "footer_button" > Footer button</ Button >
32- </ Footer >
33- </ Container >
13+ < Box >
14+ < Heading > Hello world!</ Heading >
15+ < Text > Welcome to my Snap settings page!</ Text >
16+ </ Box >
3417 ) ,
3518 } ;
3619} ;
37-
38- /**
39- * Handle incoming user events coming from the Snap interface.
40- *
41- * @param params - The event parameters.
42- * @param params.id - The Snap interface ID where the event was fired.
43- * @param params.event - The event object containing the event type, name and
44- * value.
45- * @see https://docs.metamask.io/snaps/reference/exports/#onuserinput
46- */
47- export const onUserInput : OnUserInputHandler = async ( { event, id } ) => {
48- // Since this Snap only has one event, we can assert the event type and name
49- // directly.
50- assert ( event . type === UserInputEventType . ButtonClickEvent ) ;
51- assert ( event . name === 'footer_button' ) ;
52-
53- await snap . request ( {
54- method : 'snap_updateInterface' ,
55- params : {
56- id,
57- ui : (
58- < Box >
59- < Text > Footer button was pressed</ Text >
60- </ Box >
61- ) ,
62- } ,
63- } ) ;
64- } ;
0 commit comments