Skip to content

Commit

Permalink
Update OpenZeppelin version to the latest commit (~5.0.0), update Sol…
Browse files Browse the repository at this point in the history
…idity version to 0.8.20, update code and test for MetaTxModule, replace _beforeTokenTransfer by _update
  • Loading branch information
rya-sge committed Aug 9, 2023
1 parent 9f40618 commit 11307e4
Show file tree
Hide file tree
Showing 37 changed files with 749 additions and 6,512 deletions.
2 changes: 1 addition & 1 deletion contracts/CMTAT_PROXY.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "./modules/CMTAT_BASE.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/CMTAT_STANDALONE.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "./modules/CMTAT_BASE.sol";

Expand Down
11 changes: 6 additions & 5 deletions contracts/mocks/MinimalForwarderMock.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../openzeppelin-contracts-upgradeable/contracts/metatx/MinimalForwarderUpgradeable.sol";
import "../../openzeppelin-contracts-upgradeable/contracts/metatx/ERC2771ForwarderUpgradeable.sol";

contract MinimalForwarderMock is MinimalForwarderUpgradeable {
function initialize() public initializer {
__MinimalForwarder_init();
contract MinimalForwarderMock is ERC2771ForwarderUpgradeable {
function initialize(string memory name) public initializer {
__EIP712_init_unchained(name, "1");
__ERC2771Forwarder_init_unchained("");
}
}
2 changes: 1 addition & 1 deletion contracts/mocks/RuleEngine/CodeList.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

abstract contract CodeList {
// Used by RuleMock.sol
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/RuleEngine/RuleEngineMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "./interfaces/IRule.sol";
import "./interfaces/IRuleEngine.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/RuleEngine/RuleMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "./interfaces/IRule.sol";
import "./CodeList.sol";
Expand Down
13 changes: 8 additions & 5 deletions contracts/modules/CMTAT_BASE.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

// required OZ imports here
import "../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -176,17 +176,20 @@ abstract contract CMTAT_BASE is
* e.g. override(SnapshotModuleInternal, ERC20Upgradeable)
* - remove the keyword view
*/
function _beforeTokenTransfer(
function _update(
address from,
address to,
uint256 amount
) internal view override(ERC20Upgradeable) {
if(!ValidationModule.validateTransfer(from, to, amount)) revert Errors.InvalidTransfer(from, to, amount);
) internal override(ERC20Upgradeable) {
if(!ValidationModule.validateTransfer(from, to, amount)) {
revert Errors.InvalidTransfer(from, to, amount);
}
ERC20Upgradeable._update(from, to, amount);
// We call the SnapshotModule only if the transfer is valid
/*
SnapshotModule:
Add this call in case you add the SnapshotModule
SnapshotModuleInternal._beforeTokenTransfer(from, to, amount);
SnapshotModuleInternal._update(from, to, amount);
*/
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/internal/EnforcementModuleInternal.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
6 changes: 3 additions & 3 deletions contracts/modules/internal/SnapshotModuleInternal.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -255,12 +255,12 @@ abstract contract SnapshotModuleInternal is ERC20Upgradeable {
@dev Update balance and/or total supply snapshots before the values are modified. This is implemented
in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.
*/
function _beforeTokenTransfer(
function _update(
address from,
address to,
uint256 amount
) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
super._update(from, to, amount);

_setCurrentSnapshot();
if (from != address(0)) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/internal/ValidationModuleInternal.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/security/AuthorizationModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/security/OnlyDelegateCallModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../libraries/Errors.sol";

Expand Down
6 changes: 4 additions & 2 deletions contracts/modules/wrapper/mandatory/BaseModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

// required OZ imports here
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -103,7 +103,9 @@ abstract contract BaseModule is AuthorizationModule, OnlyDelegateCallModule {
@notice The call will be reverted if the new value of flag is the same as the current one
*/
function setFlag(uint256 flag_) public onlyRole(DEFAULT_ADMIN_ROLE) {
if(flag == flag_) revert Errors.SameValue();
if(flag == flag_) {
revert Errors.SameValue();
}
flag = flag_;
emit Flag(flag_);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/mandatory/BurnModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol";
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/mandatory/ERC20BaseModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

// required OZ imports here
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/mandatory/EnforcementModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol";
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/mandatory/MintModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol";
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/mandatory/PauseModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol";
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../../openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol";
import "../../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -64,7 +64,9 @@ abstract contract CreditEventsModule is
function setFlagDefault(
bool flagDefault_
) public onlyRole(DEBT_CREDIT_EVENT_ROLE) {
if(flagDefault_ == creditEvents.flagDefault) revert Errors.SameValue();
if(flagDefault_ == creditEvents.flagDefault) {
revert Errors.SameValue();
}
creditEvents.flagDefault = flagDefault_;
emit FlagDefault(flagDefault_);
}
Expand All @@ -75,7 +77,9 @@ abstract contract CreditEventsModule is
function setFlagRedeemed(
bool flagRedeemed_
) public onlyRole(DEBT_CREDIT_EVENT_ROLE) {
if(flagRedeemed_ == creditEvents.flagRedeemed) revert Errors.SameValue();
if(flagRedeemed_ == creditEvents.flagRedeemed) {
revert Errors.SameValue();
}
creditEvents.flagRedeemed = flagRedeemed_;
emit FlagRedeemed(flagRedeemed_);
}
Expand Down
10 changes: 7 additions & 3 deletions contracts/modules/wrapper/optional/DebtModule/DebtBaseModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../../openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol";
import "../../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -133,7 +133,9 @@ abstract contract DebtBaseModule is
@notice The call will be reverted if the new value of interestRate is the same as the current one
*/
function setInterestRate(uint256 interestRate_) public onlyRole(DEBT_ROLE) {
if(interestRate_ == debt.interestRate) revert Errors.SameValue();
if(interestRate_ == debt.interestRate) {
revert Errors.SameValue();
}
debt.interestRate = interestRate_;
emit InterestRate(interestRate_);
}
Expand All @@ -142,7 +144,9 @@ abstract contract DebtBaseModule is
@notice The call will be reverted if the new value of parValue is the same as the current one
*/
function setParValue(uint256 parValue_) public onlyRole(DEBT_ROLE) {
if(parValue_ == debt.parValue) revert Errors.SameValue();
if(parValue_ == debt.parValue) {
revert Errors.SameValue();
}
debt.parValue = parValue_;
emit ParValue(parValue_);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/optional/MetaTxModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/metatx/ERC2771ContextUpgradeable.sol";
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/optional/SnapshotModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "../../security/AuthorizationModule.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/optional/ValidationModule.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "../../security/AuthorizationModule.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/CMTATSnapshot/CMTATSnapshotProxyTest.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "./CMTAT_BASE_SnapshotTest.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

import "./CMTAT_BASE_SnapshotTest.sol";

Expand Down
6 changes: 3 additions & 3 deletions contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

// required OZ imports here
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -168,7 +168,7 @@ abstract contract CMTAT_BASE_SnapshotTest is
e.g. override(SnapshotModuleInternal, ERC20Upgradeable)
- remove the keyword view
*/
function _beforeTokenTransfer(
function _update(
address from,
address to,
uint256 amount
Expand All @@ -179,7 +179,7 @@ abstract contract CMTAT_BASE_SnapshotTest is
SnapshotModule:
Add this call in case you add the SnapshotModule
*/
SnapshotModuleInternal._beforeTokenTransfer(from, to, amount);
SnapshotModuleInternal._update(from, to, amount);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/killTest/BaseModuleTest.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

// required OZ imports here
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/killTest/CMTATKillTest.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.17;
pragma solidity ^0.8.20;

// required OZ imports here
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -183,7 +183,7 @@ contract CMTAT_KILL_TEST is
e.g. override(SnapshotModuleInternal, ERC20Upgradeable)
- remove the keyword view
*/
function _beforeTokenTransfer(
function _update(
address from,
address to,
uint256 amount
Expand All @@ -193,7 +193,7 @@ contract CMTAT_KILL_TEST is
/*
SnapshotModule:
Add this call in case you add the SnapshotModule
SnapshotModuleInternal._beforeTokenTransfer(from, to, amount);
SnapshotModuleInternal._update(from, to, amount);
*/
}

Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require("solidity-coverage")
require('solidity-docgen')
module.exports = {
solidity: {
version: '0.8.17',
version: '0.8.20',
settings: {
optimizer: {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion openzeppelin-contracts-upgradeable
Loading

0 comments on commit 11307e4

Please sign in to comment.