Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snaps Pages #113

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions SIPS/sip-15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
sip: 15
title: Snaps Home Page
status: Draft
discussions-to: https://github.com/MetaMask/SIPs/discussions/115
author: Frederik Bolding (@frederikbolding)
created: 2023-10-26
---

## Abstract

This SIP proposes a new API that allows snaps to surface a static UI to display data that may be useful to users of the snap. This proposal outlines some of the details around this feature.

## Motivation

Snaps currently tend to leverage separate websites for showing details relating to the status of the snap. For example, snaps that manage new blockchain accounts for users have to rely almost exclusively on these to show balances on new kinds of networks. This proposal aims to start improving on this by giving snaps a surface directly in the client where they can render custom UI.

This new surface differs from the existing custom UI surfaces as it isn't reactionary, instead of being triggered by an RPC call or a transaction being confirmed the user can choose to view the home page screen at any time.
Montoya marked this conversation as resolved.
Show resolved Hide resolved

## Specification

> Formal specifications are written in Typescript.

### Language

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" written in uppercase in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt)

### Snap Manifest

This SIP specifies a permission named `endowment:home-page`.
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved
The permission signals to the platform that the snap wants to use the home page functionality. This MAY change routing in the client or change how the snap is displayed to the user.
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved

This permission is specified as follows in `snap.manifest.json` files:

```json
{
"initialPermissions": {
"endowment:home-page": {}
}
}
```

### Snap Implementation

When a user navigates to the snap home page, the `onHome` handler will be invoked. This handler MUST be used to generate the static UI content for the home page.
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved

Any snap that wishes to expose a home page MUST implement the following API:

```typescript
import { panel, text } from "@metamask/snap-ui";
import { OnHomeHandler } from "@metamask/snap-types";

export const onHome: OnHomeHandler = async () => {
const content = panel([text('Hello world!')])
return { content };
};
```

The `onHome` handler takes no arguments and MUST return a value that matches the following interface:

```typescript
import { Component } from "@metamask/snap-ui";
interface OnHomeResponse {
content: Component;
}
```


## Copyright

Copyright and related rights waived via [CC0](../LICENSE).