Update docs
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {AccessManaged} from "../access/manager/AccessManaged.sol";
|
||||
import {StorageSlot} from "../utils/StorageSlot.sol";
|
||||
|
||||
abstract contract AccessManagedTarget is AccessManaged {
|
||||
event CalledRestricted(address caller);
|
||||
@ -17,6 +18,16 @@ abstract contract AccessManagedTarget is AccessManaged {
|
||||
emit CalledUnrestricted(msg.sender);
|
||||
}
|
||||
|
||||
function setIsConsumingScheduledOp(bool isConsuming, bytes32 slot) external {
|
||||
// Memory layout is 0x....<_consumingSchedule (boolean)><authority (address)>
|
||||
bytes32 mask = bytes32(uint256(1 << 160));
|
||||
if (isConsuming) {
|
||||
StorageSlot.getBytes32Slot(slot).value |= mask;
|
||||
} else {
|
||||
StorageSlot.getBytes32Slot(slot).value &= ~mask;
|
||||
}
|
||||
}
|
||||
|
||||
fallback() external {
|
||||
emit CalledFallback(msg.sender);
|
||||
}
|
||||
|
||||
69
contracts/mocks/AuthorityMock.sol
Normal file
69
contracts/mocks/AuthorityMock.sol
Normal file
@ -0,0 +1,69 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IAccessManaged} from "../access/manager/IAccessManaged.sol";
|
||||
import {IAuthority} from "../access/manager/IAuthority.sol";
|
||||
|
||||
contract NotAuthorityMock is IAuthority {
|
||||
function canCall(address /* caller */, address /* target */, bytes4 /* selector */) external pure returns (bool) {
|
||||
revert("AuthorityNoDelayMock: not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
contract AuthorityNoDelayMock is IAuthority {
|
||||
bool _immediate;
|
||||
|
||||
function canCall(
|
||||
address /* caller */,
|
||||
address /* target */,
|
||||
bytes4 /* selector */
|
||||
) external view returns (bool immediate) {
|
||||
return _immediate;
|
||||
}
|
||||
|
||||
function _setImmediate(bool immediate) external {
|
||||
_immediate = immediate;
|
||||
}
|
||||
}
|
||||
|
||||
contract AuthorityDelayMock {
|
||||
bool _immediate;
|
||||
uint32 _delay;
|
||||
|
||||
function canCall(
|
||||
address /* caller */,
|
||||
address /* target */,
|
||||
bytes4 /* selector */
|
||||
) external view returns (bool immediate, uint32 delay) {
|
||||
return (_immediate, _delay);
|
||||
}
|
||||
|
||||
function _setImmediate(bool immediate) external {
|
||||
_immediate = immediate;
|
||||
}
|
||||
|
||||
function _setDelay(uint32 delay) external {
|
||||
_delay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
contract AuthorityNoResponse {
|
||||
function canCall(address /* caller */, address /* target */, bytes4 /* selector */) external view {}
|
||||
}
|
||||
|
||||
contract AuthoritiyObserveIsConsuming {
|
||||
event ConsumeScheduledOpCalled(address caller, bytes data, bytes4 isConsuming);
|
||||
|
||||
function canCall(
|
||||
address /* caller */,
|
||||
address /* target */,
|
||||
bytes4 /* selector */
|
||||
) external pure returns (bool immediate, uint32 delay) {
|
||||
return (false, 1);
|
||||
}
|
||||
|
||||
function consumeScheduledOp(address caller, bytes memory data) public {
|
||||
emit ConsumeScheduledOpCalled(caller, data, IAccessManaged(msg.sender).isConsumingScheduledOp());
|
||||
}
|
||||
}
|
||||
22
contracts/mocks/docs/ERC20WithAutoMinerReward.sol
Normal file
22
contracts/mocks/docs/ERC20WithAutoMinerReward.sol
Normal file
@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {ERC20} from "../../token/ERC20/ERC20.sol";
|
||||
|
||||
contract ERC20WithAutoMinerReward is ERC20 {
|
||||
constructor() ERC20("Reward", "RWD") {
|
||||
_mintMinerReward();
|
||||
}
|
||||
|
||||
function _mintMinerReward() internal {
|
||||
_mint(block.coinbase, 1000);
|
||||
}
|
||||
|
||||
function _update(address from, address to, uint256 value) internal virtual override {
|
||||
if (!(from == address(0) && to == block.coinbase)) {
|
||||
_mintMinerReward();
|
||||
}
|
||||
super._update(from, to, value);
|
||||
}
|
||||
}
|
||||
17
contracts/mocks/docs/MyContractOwnable.sol
Normal file
17
contracts/mocks/docs/MyContractOwnable.sol
Normal file
@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Ownable} from "../../access/Ownable.sol";
|
||||
|
||||
contract MyContract is Ownable {
|
||||
constructor(address initialOwner) Ownable(initialOwner) {}
|
||||
|
||||
function normalThing() public {
|
||||
// anyone can call this normalThing()
|
||||
}
|
||||
|
||||
function specialThing() public onlyOwner {
|
||||
// only the owner can call specialThing()!
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user