Created
August 5, 2024 04:18
-
-
Save cuiweixie/253b7dab8006dc58fc87f27b73c6901c to your computer and use it in GitHub Desktop.
revert test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import { OwnerControlled } from "./set.sol"; | |
contract Nested { | |
constructor() { | |
} | |
// address 0x5FbDB2315678afecb367f032d93F642f64180aa3 | |
function callSet(address addr, uint256 value) public { | |
OwnerControlled oc = OwnerControlled(addr); | |
oc.setValue(value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
contract OwnerControlled { | |
address public owner; | |
uint256 private value; | |
event ValueChanged(uint256 newValue); | |
error Unknown(string str); | |
constructor() { | |
owner = msg.sender; | |
} | |
modifier onlyOwner() { | |
if(msg.sender != owner) { | |
revert Unknown("only Owner"); | |
} | |
_; | |
} | |
function setValue(uint256 _newValue) public onlyOwner { | |
value = _newValue; | |
emit ValueChanged(_newValue); | |
} | |
function getValue() public view returns (uint256) { | |
return value; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment