@@ -4,13 +4,20 @@ pragma solidity ^0.8.0;
4
4
5
5
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol " ;
6
6
7
+ import { IWhitelist } from "../../libraries/common/IWhitelist.sol " ;
8
+
7
9
import { IL2GasPriceOracle } from "./IL2GasPriceOracle.sol " ;
8
10
9
11
contract L2GasPriceOracle is OwnableUpgradeable , IL2GasPriceOracle {
10
12
/**********
11
13
* Events *
12
14
**********/
13
15
16
+ /// @notice Emitted when owner updates whitelist contract.
17
+ /// @param _oldWhitelist The address of old whitelist contract.
18
+ /// @param _newWhitelist The address of new whitelist contract.
19
+ event UpdateWhitelist (address _oldWhitelist , address _newWhitelist );
20
+
14
21
/// @notice Emitted when current fee overhead is updated.
15
22
/// @param overhead The current fee overhead updated.
16
23
event OverheadUpdated (uint256 overhead );
@@ -51,6 +58,9 @@ contract L2GasPriceOracle is OwnableUpgradeable, IL2GasPriceOracle {
51
58
/// @notice The latest known l2 base fee.
52
59
uint256 public l2BaseFee;
53
60
61
+ /// @notice The address of whitelist contract.
62
+ IWhitelist public whitelist;
63
+
54
64
/***************
55
65
* Constructor *
56
66
***************/
@@ -105,6 +115,20 @@ contract L2GasPriceOracle is OwnableUpgradeable, IL2GasPriceOracle {
105
115
}
106
116
}
107
117
118
+ /****************************
119
+ * Public Mutated Functions *
120
+ ****************************/
121
+
122
+ /// @notice Allows the owner to modify the l2 base fee.
123
+ /// @param _l2BaseFee The new l2 base fee.
124
+ function setL2BaseFee (uint256 _l2BaseFee ) external {
125
+ require (whitelist.isSenderAllowed (msg .sender ), "Not whitelisted sender " );
126
+
127
+ l2BaseFee = _l2BaseFee;
128
+
129
+ emit L2BaseFeeUpdated (_l2BaseFee);
130
+ }
131
+
108
132
/************************
109
133
* Restricted Functions *
110
134
************************/
@@ -127,11 +151,13 @@ contract L2GasPriceOracle is OwnableUpgradeable, IL2GasPriceOracle {
127
151
emit ScalarUpdated (_scalar);
128
152
}
129
153
130
- /// Allows the owner to modify the l2 base fee.
131
- /// @param _l2BaseFee The new l2 base fee.
132
- function setL2BaseFee (uint256 _l2BaseFee ) external onlyOwner {
133
- l2BaseFee = _l2BaseFee;
154
+ /// @notice Update whitelist contract.
155
+ /// @dev This function can only called by contract owner.
156
+ /// @param _newWhitelist The address of new whitelist contract.
157
+ function updateWhitelist (address _newWhitelist ) external onlyOwner {
158
+ address _oldWhitelist = address (whitelist);
134
159
135
- emit L2BaseFeeUpdated (_l2BaseFee);
160
+ whitelist = IWhitelist (_newWhitelist);
161
+ emit UpdateWhitelist (_oldWhitelist, _newWhitelist);
136
162
}
137
163
}
0 commit comments