feat(SIP-53): add singleton ability modifier#53
feat(SIP-53): add singleton ability modifier#53admin-aftermath wants to merge 1 commit intosui-foundation:mainfrom
singleton ability modifier#53Conversation
|
I am currently running into another use case where I would want to use singleton and wanted to document it here. I am working on an "ecosystem" of packages wherein I need to manage cross-package authorization. There is a core package and a series of packages that can be granted the ability to call permissioned functions from the core package. I currently have a system where packages are granted authority by an The issue with the above is that the external package just needs to pass in a witness type as proof. I have wrapped all permissioned functions so the witness type is created and passed in to the underlying core package function -- so, for the current contract version, there is deterministic security around (1) when the witness type is created and (2) how it is being used. The issue is that upon a package upgrade this determinism might not hold as you could just create a public constructor for the witness type. Ultimately what you would want, from a transparency / security standpoint, is proof that the "witness" (using quotes here since it will likely be a struct with This is a dumbed down version of what I have currently but gets the point across. Also, there are ways to get around this problem today, but |
|
Apologies for almost being a year late here (don't hesitate ping me on telegram if you need someone to look at something like this). When this first went up, we thought about it and thought maybe to revisit it once we added this With such a creation, you could define a wrapper around We hesitate on adding something like this to the
If we had a good common use case for something like this with these questions being easily answered, I think it could be valuable in |
|
A bit of a side note on abilities, something like
|
|
Here are my quick thoughts on these questions.
I'm sure I have a very specific view of this SIP and the benefits of singleton but imo singleton benefits the most when applied to objects, so an object variant would be required. I view singleton as a way to reduce the attack vectors across package boundaries: with singleton, you can assure that the state I expect to interact with is in fact the state I will interact with. For example,
Both of these scenarios involve reducing the possible number of objects of a given type down to the expected size of 1. I'm sure there are also benefits for types
Given the examples I've used above and in the SIP I don't see a practical reason to need this but still imo it would make sense to support. Regardless, a destroy function would need to be defined within the package that defines the inner type
Similar to the reasoning above, how you've defined the API in your first message is perfect. For creating and accessing by both reference / mutably you have feature parity as w/o the All in all I would be in favor of a |
|
One minor detail I dislike about the |
No description provided.