Skip to content

Commit

Permalink
Add internal function to authorise owner() of contract
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflau committed Jul 1, 2021
1 parent 66d04ec commit 4a4add7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions contracts/registry/ReverseRegistrar.sol
Expand Up @@ -42,7 +42,8 @@ contract ReverseRegistrar is Ownable, Controllable {
require(
addr == msg.sender ||
controllers[msg.sender] ||
ens.isApprovedForAll(addr, msg.sender),
ens.isApprovedForAll(addr, msg.sender) ||
ownsContract(addr),
"Caller is not a controller or authorised by address or the address itself"
);
_;
Expand Down Expand Up @@ -181,13 +182,8 @@ contract ReverseRegistrar is Ownable, Controllable {
}
}

/**
* @dev Transfers ownership of the reverse ENS record associated with the
* calling account.
* @param owner The address to set as the owner of the reverse record in ENS.
* @param resolver The address of the resolver to set; 0 to leave unchanged.
* @return The ENS node hash of the reverse record.
*/
/* Internal functions */

function _claimWithResolver(
address addr,
address owner,
Expand All @@ -206,4 +202,12 @@ contract ReverseRegistrar is Ownable, Controllable {

return node;
}

function ownsContract(address addr) internal view returns (bool) {
try Ownable(addr).owner() returns (address owner) {
return owner == msg.sender;
} catch {
return false;
}
}
}

0 comments on commit 4a4add7

Please sign in to comment.