File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: UNLICENSED
2-
32pragma solidity ^ 0.8.0 ;
43
54contract OnlyAuthorized {
6- address public owner = msg .sender ;
5+ address public owner;
6+ uint256 public n;
7+
8+ error OnlyOwner ();
9+ error ZeroAddress ();
10+
11+ constructor () {
12+ owner = msg .sender ;
13+ }
714
815 modifier onlyOwner () {
9- require (owner == msg .sender , " Only owner" );
16+ if ( msg .sender != owner) revert OnlyOwner ( );
1017 _;
1118 }
1219
13- function changeOwner (address _newOwner ) public onlyOwner {
14- owner = _newOwner;
20+ function changeOwner (address newOwner ) external onlyOwner {
21+ if (newOwner == address (0 )) revert ZeroAddress ();
22+ owner = newOwner;
1523 }
1624
17- uint256 public n;
18-
19- function setN (uint256 n_ ) public {
20- n = n_;
25+ function setN (uint256 newN ) external {
26+ n = newN;
2127 }
2228}
You can’t perform that action at this time.
0 commit comments