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

Create SIP-22: Deep Links #134

Merged
merged 18 commits into from
Sep 24, 2024
60 changes: 60 additions & 0 deletions SIPS/sip-22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
sip: 22
title: MetaMask URL scheme
status: Draft
author: Christian Montoya (@Montoya), Hassan Malik(@hmalik88)
hmalik88 marked this conversation as resolved.
Show resolved Hide resolved
created: 2024-09-13
---

## Abstract

This SIP describes a URL scheme for extension navigation. The described URL will allow for navigation to Snaps entry points and elsewhere within the MetaMask extension. This scheme can potentially be used by Snap methods in the future to navigate the user to a location in-client and trigger the entry point.

## Motivation

While some Snap entry points are reactive, meaning they can be triggered by a method, others can only be triggered by a user navigating to the location where that entry point is displayed. In order for a Snap to programmatically navigate a user to that entry point, the Snap needs a way to identify that location. The location is identified by a URL scheme, and an in-client link pointing to this location is called a _deep link_.

## Specification

### 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)

### URL Scheme

[URL syntax](https://en.wikipedia.org/wiki/URL#Syntax) is defined with a scheme, authority, path, and with optional (query and fragment) portions. This SIP defines a new scheme: `metamask:`, the syntax is defined below:

`metamask://[authority]/[path]`

Where:

- `[authority]` refers to either `client` or `snap` (in the current case, `client` can mean either the extension or mobile version of MetaMask)
- `[path]` refers to the entire path which depending on the authority can be different
- For the `client` authority, the following paths are available:
- `/` - links to the client's home page
- For the `snap` authority, the path starts with the snap ID and has the following paths available to it:
- `/home` - leads to the snap's [home page](/SIPS/sip-15.md) (which is its settings page if it doesn't have a home page)

> [!NOTE]
> 1. In the future, fragments can potentially be used for navigation to specific portions of a page and params can be provided from a calling method for exports such as `onHome`.
> 2. This URL scheme assumes parity between `client` locations.

### Examples

The proposed URL for the Starknet Snap home page:

`metamask://snap/npm:@consensys/starknet-snap/home`

The URL for navigating to the extension's home page:
hmalik88 marked this conversation as resolved.
Show resolved Hide resolved

`metamask://client/`

### Using Deep Links

A Snap will be able to navigate to these links using the [SIP-7](https://github.com/MetaMask/SIPs/blob/main/SIPS/sip-7.md) `Link` component.

## Copyright

Copyright and related rights waived via [CC0](../LICENSE).
2 changes: 1 addition & 1 deletion tools/validate/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const parser = unified()
remarkLintNoInlinePadding,
remarkLintNoShortcutReferenceImage,
remarkLintNoShortcutReferenceLink,
remarkLintNoUndefinedReferences,
[remarkLintNoUndefinedReferences, { allow: [{ source: '^!' }] }],
remarkLintNoUnusedDefinitions,
],
}) // like remark-preset-lint-recommended but only for critical mistakes
Expand Down
Loading