From 7d20d0e2d21919c75d54bb856bd8441d0811d734 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Fri, 19 Feb 2021 11:11:54 -0300 Subject: [PATCH] Use immutable variables where possible (#2528) Co-authored-by: rotciv Co-authored-by: Hadrien Croubois --- contracts/payment/PullPayment.sol | 2 +- contracts/payment/escrow/RefundEscrow.sol | 2 +- contracts/token/ERC20/ERC20Capped.sol | 2 +- contracts/token/ERC20/TokenTimelock.sol | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/payment/PullPayment.sol b/contracts/payment/PullPayment.sol index 05617f66d01..cc68f2ac319 100644 --- a/contracts/payment/PullPayment.sol +++ b/contracts/payment/PullPayment.sol @@ -23,7 +23,7 @@ import "./escrow/Escrow.sol"; * payments with {payments}, and retrieve them with {withdrawPayments}. */ abstract contract PullPayment { - Escrow private _escrow; + Escrow immutable private _escrow; constructor () { _escrow = new Escrow(); diff --git a/contracts/payment/escrow/RefundEscrow.sol b/contracts/payment/escrow/RefundEscrow.sol index e57f2f23ed0..1a0875c1435 100644 --- a/contracts/payment/escrow/RefundEscrow.sol +++ b/contracts/payment/escrow/RefundEscrow.sol @@ -23,7 +23,7 @@ contract RefundEscrow is ConditionalEscrow { event RefundsEnabled(); State private _state; - address payable private _beneficiary; + address payable immutable private _beneficiary; /** * @dev Constructor. diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index bef65cf5e1e..5e048dff7a1 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/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. */ 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 diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 102f45a82b3..5568c353c57 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -15,13 +15,13 @@ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held - IERC20 private _token; + IERC20 immutable private _token; // beneficiary of tokens after they are released - address private _beneficiary; + address immutable private _beneficiary; // timestamp when token release is enabled - uint256 private _releaseTime; + uint256 immutable private _releaseTime; constructor (IERC20 token_, address beneficiary_, uint256 releaseTime_) { // solhint-disable-next-line not-rely-on-time