You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]?
The text was updated successfully, but these errors were encountered:
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 withrenounce_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 includeensure_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]
?The text was updated successfully, but these errors were encountered: