-
Notifications
You must be signed in to change notification settings - Fork 17
Propose SIP-34 onActivityItem handler / hook #179
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,90 @@ | ||||||
| --- | ||||||
| sip: 34 | ||||||
| title: Activity Item Insights | ||||||
| status: Draft | ||||||
| author: Kylan Hurt (@smilingkylan, kylan.hurt@gmail.com) | ||||||
| created: 2025-10-26 | ||||||
| --- | ||||||
|
|
||||||
| ## Abstract | ||||||
|
|
||||||
| The purpose of this SIP is to propose the addition of an lifecycle hook, similar to the `onTransaction` and `onSignature` hooks that triggers when the user clicks on a history item (typically a transaction), passing with it parameters related to the transaction. I am giving this hook the name `onActivityItem`. | ||||||
|
|
||||||
| ## Motivation | ||||||
|
|
||||||
| Some web functionality works best when triggered after a financial transaction has occurred. In Web2 some examples may be satisfaction surveys after an online order, an email encouraging users to sign up for a newsletter, or consider purchasing another product related to the one they just bought. | ||||||
|
|
||||||
| While Web3 may not support communication services like email or text message natively, we can include information and call-to-actions at the point where the user is within the context of the product they just bought: when viewing the completed (or failed) transaction itself. The equivalent in MetaMask is Activity (history) tab of the home screen. | ||||||
|
|
||||||
| If a user wants to learn more about a past transaction or the smart contract / dapp they interacted with then we can present those sorts of insights to them at the point when they are viewing a previous transaction. | ||||||
|
|
||||||
| ## Specification | ||||||
|
|
||||||
| One of the perks of this proposal is that we can more or less mimic the `onTransaction` and `onSignature` handlers. The main two differences will be the following: | ||||||
|
|
||||||
| 1. Different entry-point (I will leave this part to you) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by this?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By "entry point" I just meant the area in the code / UI where the |
||||||
| 2. The parameters passed to the `onActivityItem` function should also include information about confirmations for the activity item / transaction | ||||||
|
|
||||||
| ``` | ||||||
| import type { OnActivityItemHandler } from "@metamask/snaps-sdk"; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a definition for this type? |
||||||
| import { Box, Heading, Text } from "@metamask/snaps-sdk/jsx"; | ||||||
|
|
||||||
| export const onActivityItem: OnActivityItemHandler = async ({ | ||||||
| // should this be `activityItem` instead or is `Activity` only ever transactions? | ||||||
| // `transaction` param should also include details about tx / block confirmations | ||||||
|
Comment on lines
+33
to
+34
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should figure this out before merging. 😅 |
||||||
| transaction, | ||||||
| chainId, | ||||||
| transactionOrigin, | ||||||
| }) => { | ||||||
| const insights = /* Get insights */; | ||||||
| return { | ||||||
| content: ( | ||||||
| <Box> | ||||||
| <Heading>My Activity Item Insights</Heading> | ||||||
| <Text>Here are the insights:</Text> | ||||||
| {insights.map((insight) => ( | ||||||
| <Text>{insight.value}</Text> | ||||||
| ))} | ||||||
| </Box> | ||||||
| ), | ||||||
| }; | ||||||
| }; | ||||||
| ``` | ||||||
|
|
||||||
| ### 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) | ||||||
smilingkylan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ### Snap Manifest | ||||||
|
|
||||||
| This SIP introduces a new permission named `endowment:activity-item-insight`. This permission grants a Snap the ability to read details about an activity item (tx) and optionally the origin from which that transaction oriented. The MM Snaps team is welcome to include or exclude any properties they see fit to best enable Snaps developers. | ||||||
|
|
||||||
| This permission is specified as follows in `snap.manifest.json` files: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "initialPermissions": { | ||||||
| "endowment:activity-item-insight": { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can drop the
Suggested change
|
||||||
| "allowActivityItemOrigin": true | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ### Security Considerations | ||||||
|
|
||||||
| The security concerns are very similar to the `onTransaction` handler except that it will typically be a past transaction rather one that is about to be signed. | ||||||
|
|
||||||
| ### User Experience Considerations | ||||||
|
|
||||||
| None | ||||||
|
|
||||||
smilingkylan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| ## Backwards Compatibility | ||||||
|
|
||||||
| This SIP introduces a new method and does not modify any existing functionality. Therefore, there are no backwards compatibility concerns. | ||||||
|
|
||||||
| ## Copyright | ||||||
|
|
||||||
| Copyright and related rights waived via [CC0](../LICENSE). | ||||||
Uh oh!
There was an error while loading. Please reload this page.