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

L04 Fix #137

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions contracts/src/access/ownable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ pub trait OwnableImpl: Storage<Data> + Internal {
}

#[modifiers(only_owner)]
fn transfer_ownership(&mut self, new_owner: AccountId) -> Result<(), OwnableError> {
fn transfer_ownership(&mut self, new_owner: Option<AccountId>) -> Result<(), OwnableError> {
let old_owner = self.data().owner.get_or_default();
self.data().owner.set(&Some(new_owner));
self._emit_ownership_transferred_event(old_owner, Some(new_owner));
if new_owner == None {
return Err(OwnableError::NewOwnerIsNotSet)
}
self.data().owner.set(&new_owner);
self._emit_ownership_transferred_event(old_owner, new_owner);
Ok(())
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/governance/timelock_controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ pub struct Data {
}

/// Modifier to make a function callable only by a certain role. In
/// addition to checking the sender's role, None account's role is also
/// considered. Granting a role to None account is equivalent to enabling
/// addition to checking the sender's role, if account is set to None, then role is also
/// considered. Granting a role to None is equivalent to enabling
/// this role for everyone.
#[modifier_definition]
pub fn only_role_or_open_role<T, F, R, E>(instance: &mut T, body: F, role: RoleType) -> Result<R, E>
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/traits/ownable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ pub trait Ownable {
///
/// Panics with `NewOwnerIsZero` error if new owner's address is zero.
#[ink(message)]
fn transfer_ownership(&mut self, new_owner: AccountId) -> Result<(), OwnableError>;
fn transfer_ownership(&mut self, new_owner: Option<AccountId>) -> Result<(), OwnableError>;
}
2 changes: 1 addition & 1 deletion lang/codegen/src/implementations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ pub(crate) fn impl_ownable(impl_args: &mut ImplArgs) {
}

#[ink(message)]
fn transfer_ownership(&mut self, new_owner: AccountId) -> Result<(), OwnableError> {
fn transfer_ownership(&mut self, new_owner: Option<AccountId>) -> Result<(), OwnableError> {
OwnableImpl::transfer_ownership(self, new_owner)
}
}
Expand Down