Эх сурвалжийг харах

Use immutable variables where possible (#2528)

Co-authored-by: rotciv <victorfage@gmail.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Francisco Giordano 4 жил өмнө
parent
commit
7d20d0e2d2

+ 1 - 1
contracts/payment/PullPayment.sol

@@ -23,7 +23,7 @@ import "./escrow/Escrow.sol";
  * payments with {payments}, and retrieve them with {withdrawPayments}.
  * payments with {payments}, and retrieve them with {withdrawPayments}.
  */
  */
 abstract contract PullPayment {
 abstract contract PullPayment {
-    Escrow private _escrow;
+    Escrow immutable private _escrow;
 
 
     constructor () {
     constructor () {
         _escrow = new Escrow();
         _escrow = new Escrow();

+ 1 - 1
contracts/payment/escrow/RefundEscrow.sol

@@ -23,7 +23,7 @@ contract RefundEscrow is ConditionalEscrow {
     event RefundsEnabled();
     event RefundsEnabled();
 
 
     State private _state;
     State private _state;
-    address payable private _beneficiary;
+    address payable immutable private _beneficiary;
 
 
     /**
     /**
      * @dev Constructor.
      * @dev Constructor.

+ 1 - 1
contracts/token/ERC20/ERC20Capped.sol

@@ -8,7 +8,7 @@ import "./ERC20.sol";
  * @dev Extension of {ERC20} that adds a cap to the supply of tokens.
  * @dev Extension of {ERC20} that adds a cap to the supply of tokens.
  */
  */
 abstract contract ERC20Capped is ERC20 {
 abstract contract ERC20Capped is ERC20 {
-    uint256 private _cap;
+    uint256 immutable private _cap;
 
 
     /**
     /**
      * @dev Sets the value of the `cap`. This value is immutable, it can only be
      * @dev Sets the value of the `cap`. This value is immutable, it can only be

+ 3 - 3
contracts/token/ERC20/TokenTimelock.sol

@@ -15,13 +15,13 @@ contract TokenTimelock {
     using SafeERC20 for IERC20;
     using SafeERC20 for IERC20;
 
 
     // ERC20 basic token contract being held
     // ERC20 basic token contract being held
-    IERC20 private _token;
+    IERC20 immutable private _token;
 
 
     // beneficiary of tokens after they are released
     // beneficiary of tokens after they are released
-    address private _beneficiary;
+    address immutable private _beneficiary;
 
 
     // timestamp when token release is enabled
     // timestamp when token release is enabled
-    uint256 private _releaseTime;
+    uint256 immutable private _releaseTime;
 
 
     constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) {
     constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) {
         // solhint-disable-next-line not-rely-on-time
         // solhint-disable-next-line not-rely-on-time