Skip to content

Ownable #208

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

Open
brozorec opened this issue Apr 29, 2025 · 0 comments · May be fixed by #216
Open

Ownable #208

brozorec opened this issue Apr 29, 2025 · 0 comments · May be fixed by #216
Assignees
Labels
Small 1-2 days

Comments

@brozorec
Copy link
Collaborator

brozorec commented Apr 29, 2025

Implement a simple access control module that defines an "owner" account with exclusive permission to execute specific contract functions. This is useful for contracts where a single authority is responsible for sensitive operations (e.g., configuration, upgrades, or privileged actions).

The initial owner is set at deployment using an address provided by the deployer. Ownership can be transferred using a transfer_ownership function or renounced entirely with renounce_ownership.

Events:

  • ownership_transferred
  • ownership_renounced

To make it feel as a function modifier, the module will also include a procedural macro attribute #[only_owner], which can be applied to contract functions to restrict their execution to the current owner (if owner has renounced, function can be called anymore). The macro will expand to include ensure_is_owner() that checks the authorization of the owner for this invocation.

To further reduce boilerplate, do we include a derive macro that provides default implementations for the functions from this module? Can the defaults be included in #[default_impl]?

@brozorec brozorec added the Small 1-2 days label Apr 29, 2025
@brozorec brozorec added this to the Release v0.3.0 milestone Apr 29, 2025
@ozgunozerk ozgunozerk self-assigned this May 8, 2025
@ozgunozerk ozgunozerk linked a pull request May 10, 2025 that will close this issue
2 tasks
@ozgunozerk ozgunozerk linked a pull request May 10, 2025 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Small 1-2 days
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants