-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { logError } from '@metamask/snaps-utils'; | ||
import type { FunctionComponent } from 'react'; | ||
import { Button } from 'react-bootstrap'; | ||
|
||
import { useInvokeMutation } from '../../../api'; | ||
import { Result, Snap } from '../../../components'; | ||
import { getSnapId } from '../../../utils'; | ||
import { JSX_SNAP_ID, JSX_SNAP_PORT, JSX_VERSION } from './constants'; | ||
|
||
export const Jsx: FunctionComponent = () => { | ||
const [invokeSnap, { isLoading, data, error }] = useInvokeMutation(); | ||
|
||
const handleSubmit = () => { | ||
invokeSnap({ | ||
snapId: getSnapId(JSX_SNAP_ID, JSX_SNAP_PORT), | ||
method: 'display', | ||
}).catch(logError); | ||
}; | ||
|
||
return ( | ||
<Snap | ||
name="JSX Snap" | ||
snapId={JSX_SNAP_ID} | ||
port={JSX_SNAP_PORT} | ||
version={JSX_VERSION} | ||
testId="jsx" | ||
> | ||
<Button | ||
variant="primary" | ||
id="displayJsx" | ||
className="mb-3" | ||
disabled={isLoading} | ||
onClick={handleSubmit} | ||
> | ||
Show JSX dialog | ||
</Button> | ||
<Result> | ||
<span id="rpcResult"> | ||
{JSON.stringify(data, null, 2)} | ||
{JSON.stringify(error, null, 2)} | ||
</span> | ||
</Result> | ||
</Snap> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import packageJson from '@metamask/jsx-example-snap/package.json'; | ||
|
||
export const JSX_SNAP_ID = 'npm:@metamask/jsx-example-snap'; | ||
export const JSX_SNAP_PORT = 8029; | ||
export const JSX_VERSION = packageJson.version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Jsx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters