Add permission types package#48
Conversation
| /** | ||
| * A custom permission. | ||
| * @property data - is a record of the data that is associated with the permission, and the structure is defined by the ERCs. | ||
| */ | ||
| export type CustomPermission = BasePermission & { | ||
| type: 'custom'; | ||
| data: MetaMaskBasePermissionData & Record<string, unknown>; | ||
| }; |
There was a problem hiding this comment.
I think the problem of "custom" permission types is really a problem of "unknown" permission types.
In the Delegation Toolkit, there's a problem where the type hints become worthless if the accepted type is "native-token-stream" | "native-token-periodic" ... | string as the type system will always assign the broadest type, removing the relevant params types for that permission type. Maybe we can support only the known types for now?
In Extension there's a need for unknown permission types, where we want to present these to the user, and have the option to revoke them, even when we don't know how to render the parameters in a user friendly way. Maybe we can add the types for unknown permissions when we come to implement unknown permission type revocation and have a clearer understanding of what types are strictly needed?
If we do add these now, I think CustomPermission should be UnknownPermission or something and the type string (although that might introduce the narrowing problems described above).
There was a problem hiding this comment.
I took this from the extension code where we already introduced the custom type. We have a chance to now define and update this type to something else like UnknownPermission. I think the main question is: Do we want to allow general permissions or just the ones that we are currently officially supporting.
I think at some point we should open up to any permission. But that does not need to be with the first version. So I will comment this out for now with a TODO to come to it later.
📝 Description
Add @metamask/permission-types package that centralizes types for ethereum/ERCs#1098 in a single place. Now this types do not provide only the basic types described in 7715 but also add types for specific permissions used inside Metamask such as:
🚀 Why?
To have all types in a single place and not duplicated across different packages.
🧪 How to Test?
Describe how to test these changes:
List any breaking changes:
📋 Checklist
Check off completed items:
🔗 Related Issues
Link to related issues:
Closes #
Related to #
📚 Additional Notes
Any additional information, concerns, or context: