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

💥 Make owner Explicit in Constructor #217

Open
pcaversaccio opened this issue Mar 25, 2024 · 0 comments
Open

💥 Make owner Explicit in Constructor #217

pcaversaccio opened this issue Mar 25, 2024 · 0 comments
Assignees
Labels
feature 💥 New feature or request
Milestone

Comments

@pcaversaccio
Copy link
Owner

pcaversaccio commented Mar 25, 2024

Currently, the owner role is assigned to the msg.sender at construction time in ownable, ownable_2step, and access_control (here specifically the role DEFAULT_ADMIN_ROLE is assigned to msg.sender). If you deploy, for example, via a factory contract, this can become an issue as in this case you make the factory the owner. To improve the overall devex, we should make it possible to make the owner explicit.

As discussed here, we will use the yet-to-be-implemented Vyper @deploy decorator (vyperlang/vyper#3740) to implement this feature:

# access_control.vy

@deploy
def init_with_caller_as_default_admin():
    self._grant_role(DEFAULT_ADMIN_ROLE, msg.sender)


@deploy
def init_with_explicit_default_admin(default_admin: address):
    self._grant_role(DEFAULT_ADMIN_ROLE, default_admin)

...

And after that the user will be able to do:

from snekmate.auth import access_control as ac
initializes: ac

@deploy
def __init__():
    ac.init_with_caller_as_default_admin()

# OR

@deploy
def __init__(default_admin: address):
    ac.init_with_explicit_default_admin(default_admin)
@pcaversaccio pcaversaccio added the feature 💥 New feature or request label Mar 25, 2024
@pcaversaccio pcaversaccio self-assigned this Mar 25, 2024
@pcaversaccio pcaversaccio added this to the 0.1.0 milestone Mar 25, 2024
@pcaversaccio pcaversaccio modified the milestones: 0.1.0, 0.1.1 Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 💥 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant