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

Add address-annotation permission SIP first draft #131

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
89 changes: 89 additions & 0 deletions SIPS/sip-x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
### Snap Improvement Proposal (SIP)

**Title:** Custom Permission for Address Annotation in MetaMask Snaps
danfinlay marked this conversation as resolved.
Show resolved Hide resolved

**SIP Number:** [To be assigned]
danfinlay marked this conversation as resolved.
Show resolved Hide resolved

**Author:** Dan Finlay <[email protected]>

#### Abstract

This SIP proposes a new custom permission for MetaMask Snaps. The permission will enable Snaps to provide additional UI annotations when an Ethereum address is presented within the MetaMask interface. The Snap will respond to events involving Ethereum addresses with a custom UI, enhancing user experience with contextual information or actions related to the address.
danfinlay marked this conversation as resolved.
Show resolved Hide resolved

#### Specification

1. **Permission Name:** `endowment:address-annotation`
danfinlay marked this conversation as resolved.
Show resolved Hide resolved

2. **Permission Description:**

- Allows a Snap to receive events containing Ethereum addresses.
- Snap can provide UI annotations or additional information for these addresses.
3. **Manifest Configuration:**

json

1. `"initialPermissions": {
"endowment:address-annotation": {}
}`

2. **Event Handling:**

- Implement an event listener in the Snap to handle incoming Ethereum addresses.
- The event will provide the Ethereum address as an argument.
3. **UI Annotation:**

- Utilize the `@metamask/snaps-ui` module to create custom UI components.
- Example components: `panel`, `heading`, `text`, `image`.
- The UI should be contextually relevant to the address provided.
4. **Use Cases:**

- Displaying additional information about an address, like its trustworthiness or associated metadata.
- Providing quick actions related to an address, such as adding it to a watchlist or checking its transaction history.

**Rich Example:**

    javascript

`import { panel, heading, text, image, divider } from '@metamask/snaps-ui';

function handleAddressEvent(address) {\
  // Example logic to generate insights based on the address\
  const addressInsight = getAddressInsight(address);

  // Custom UI components\
  const addressPanel = panel([\
    heading(`Details for ${address}`),\
    text(`Insight: ${addressInsight.description}`),\
    divider(),\
    image(addressInsight.imageUrl),\
    text(`Additional Info: ${addressInsight.additionalInfo}`)\
  ]);

  return addressPanel;\
}

function getAddressInsight(address) {\
  // Placeholder for logic to fetch or compute insights about the address\
  return {\
    description: "Trusted Address with High Volume Transactions",\
    imageUrl: "data:image/svg+xml;base64,...", // Base64 encoded SVG or data URI\
    additionalInfo: "This address is associated with a well-known NFT marketplace."\
  };\
}`

a new permission that does not affect existing permissions or Snap functionalities. It is fully backward compatible.


#### Rationale

This permission extends the functionality of MetaMask Snaps by allowing developers to create more interactive and informative experiences. Address-related context is crucial in blockchain interactions, and providing users with additional insights directly within MetaMask can enhance security and usability.

#### Backward Compatibility

This SIP introduces a new permission that does not affect existing permissions or Snap functionalities. It is fully backward compatible.

#### Security Considerations

- Security frame these annotations when they are displayed.
- May need to truncate excessive length messages.

Loading