-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathISystemContract.sol
46 lines (40 loc) · 1.62 KB
/
ISystemContract.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {SystemContractHelper} from "../libraries/SystemContractHelper.sol";
import {BOOTLOADER_FORMAL_ADDRESS} from "../Constants.sol";
/// @dev Solidity does not allow exporting modifiers via libraries, so
/// the only way to do reuse modifiers is to have a base contract
/// @dev Never add storage variables into this contract as some
/// system contracts rely on this abstract contract as on interface!
abstract contract ISystemContract {
/// @notice Modifier that makes sure that the method
/// can only be called via a system call.
modifier onlySystemCall() {
require(
SystemContractHelper.isSystemCall() || SystemContractHelper.isSystemContract(msg.sender),
"This method require system call flag"
);
_;
}
/// @notice Modifier that makes sure that the method
/// can only be called from a system contract.
modifier onlyCallFromSystemContract() {
require(
SystemContractHelper.isSystemContract(msg.sender),
"This method require the caller to be system contract"
);
_;
}
/// @notice Modifier that makes sure that the method
/// can only be called from a special given address.
modifier onlyCallFrom(address caller) {
require(msg.sender == caller, "Inappropriate caller");
_;
}
/// @notice Modifier that makes sure that the method
/// can only be called from the bootloader.
modifier onlyCallFromBootloader() {
require(msg.sender == BOOTLOADER_FORMAL_ADDRESS, "Callable only by the bootloader");
_;
}
}