Skip to content

Commit

Permalink
Revert "Add signature insights documentation (#1103)"
Browse files Browse the repository at this point in the history
This reverts commit 20ba995.
  • Loading branch information
ziad-saab committed Jan 25, 2024
1 parent 20ba995 commit faf4a82
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 238 deletions.
Binary file removed snaps/assets/signature-insights-permission.png
Binary file not shown.
Binary file removed snaps/assets/signature-insights-warning.png
Binary file not shown.
139 changes: 0 additions & 139 deletions snaps/how-to/provide-signature-insights.md

This file was deleted.

78 changes: 0 additions & 78 deletions snaps/reference/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,84 +208,6 @@ module.exports.onTransaction = async ({

<!--/tabs-->

## onSignature

:::flaskOnly
:::

To provide signature insights before a user signs a message, a Snap must export `onSignature`.
Whenever any of the message signature methods like `personal_sign` or `eth_signTypedData_v4`, MetaMask calls this method.
MetaMask passes the raw unsigned signature payload to the `onSignature` handler method.

:::note
For MetaMask to call the Snap's `onSignature` method, you must request the
[`endowment:signature-insight`](permissions.md#endowmentsignature-insight) permission.
:::

#### Parameters

An object containing:

- `signature` - The raw signature payload.
- `signatureOrigin` - The signature origin if
[`allowSignatureOrigin`](permissions.md#endowmentsignature-insight) is set to `true`.

#### Returns

- An optional `severity` property that, if present, must be set to `SeverityLevel.Critical`
- A `content` object displayed using [custom UI](../how-to/use-custom-ui.md) after the user presses the "Sign" button. At this time due to limitations of MetaMask's signature confirmation UI, the content will only be displayed if the `severity` property is present and set to `SeverityLevel.Critical`.

#### Example

<!--tabs-->

# TypeScript

```typescript
import { OnSignatureHandler, SeverityLevel } from '@metamask/snaps-types';
import { panel, heading, text } from '@metamask/snaps-ui';

export const onSignature: OnSignatureHandler = async ({
signature,
signatureOrigin,
}) => {
const insights = /* Get insights */;
return {
content: panel([
heading('My Signature Insights'),
text('Here are the insights:'),
...(insights.map((insight) => text(insight.value)))
]),
severity: SeverityLevel.Critical
};
};
```

# JavaScript

```js
import { SeverityLevel } from '@metamask/snaps-sdk';
import { panel, heading, text } from '@metamask/snaps-ui';

module.exports.onSignature = async ({
signature,
signatureOrigin,
}) => {
const insights = /* Get insights */;
return {
content: panel([
heading('My Signature Insights'),
text('Here are the insights:'),
...(insights.map((insight) => text(insight.value)))
]),
severity: SeverityLevel.Critical
};
};
```

<!--/tabs-->


## onCronjob

To run periodic actions for the user (cron jobs), a Snap must export `onCronjob`.
Expand Down
21 changes: 0 additions & 21 deletions snaps/reference/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,27 +230,6 @@ Specify this permission in the manifest file as follows:
},
```

### endowment:signature-insight

To provide signature insights, a Snap must request the `endowment:signature-insight` permission.
This permission grants a Snap read-only access to raw signature payloads, before they're accepted
for signing by the user, by exporting the [`onSignature`](../reference/exports.md#onsignature) method.

This permission requires an object with an `allowSignatureOrigin` property to signal if the Snap
should pass the `signatureOrigin` property as part of the `onSignature` parameters.
This property represents the signature initiator origin.
The default is `false`.

Specify this permission in the manifest file as follows:

```json
"initialPermissions": {
"endowment:signature-insight": {
"allowSignatureOrigin": true
}
},
```

### endowment:webassembly

To use WebAssembly, a Snap must request the `endowment:webassembly` permission.
Expand Down

0 comments on commit faf4a82

Please sign in to comment.