From df2dec014080c3d992f20bd285271ec1c661d7a6 Mon Sep 17 00:00:00 2001 From: Ryan Sauge Date: Mon, 4 Dec 2023 15:51:41 +0100 Subject: [PATCH] Add authorizationEngine --- contracts/CMTAT_STANDALONE.sol | 5 +- contracts/interfaces/IAuthorizationEngine.sol | 13 +++ contracts/libraries/Errors.sol | 2 + contracts/modules/CMTAT_BASE.sol | 9 +- .../modules/security/AuthorizationModule.sol | 78 +++++++++++---- contracts/modules/wrapper/core/BaseModule.sol | 2 +- .../CMTATSnapshotStandaloneTest.sol | 4 +- .../CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol | 9 +- .../AuthorizationModuleCommon.js | 94 ++----------------- test/common/BaseModuleCommon.js | 2 +- test/deployment/deployment.test.js | 13 ++- test/deploymentUtils.js | 31 +++--- test/proxy/general/Proxy.test.js | 3 +- test/proxy/general/UpgradeProxy.test.js | 4 +- test/proxy/modules/MetaTxModule.test.js | 6 +- .../ValidationModuleConstructor.test.js | 5 +- .../modules/ERC20SnapshotModule.test.js | 1 - test/standard/modules/MetaTxModule.test.js | 3 +- .../ValidationModule/ValidationModule.test.js | 1 + .../ValidationModuleConstructor.test.js | 5 +- 20 files changed, 128 insertions(+), 162 deletions(-) create mode 100644 contracts/interfaces/IAuthorizationEngine.sol diff --git a/contracts/CMTAT_STANDALONE.sol b/contracts/CMTAT_STANDALONE.sol index ad52c01a..5a35501d 100644 --- a/contracts/CMTAT_STANDALONE.sol +++ b/contracts/CMTAT_STANDALONE.sol @@ -9,6 +9,7 @@ contract CMTAT_STANDALONE is CMTAT_BASE { * @notice Contract version for standalone deployment * @param forwarderIrrevocable address of the forwarder, required for the gasless support * @param admin address of the admin of contract (Access Control) + * @param authorizationEngineIrrevocable * @param nameIrrevocable name of the token * @param symbolIrrevocable name of the symbol * @param decimalsIrrevocable number of decimals used to get its user representation, should be 0 to be compliant with the CMTAT specifications. @@ -22,7 +23,7 @@ contract CMTAT_STANDALONE is CMTAT_BASE { constructor( address forwarderIrrevocable, address admin, - uint48 initialDelay, + IAuthorizationEngine authorizationEngineIrrevocable, string memory nameIrrevocable, string memory symbolIrrevocable, uint8 decimalsIrrevocable, @@ -36,7 +37,7 @@ contract CMTAT_STANDALONE is CMTAT_BASE { // Warning : do not initialize the proxy initialize( admin, - initialDelay, + authorizationEngineIrrevocable, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, diff --git a/contracts/interfaces/IAuthorizationEngine.sol b/contracts/interfaces/IAuthorizationEngine.sol new file mode 100644 index 00000000..f49c9045 --- /dev/null +++ b/contracts/interfaces/IAuthorizationEngine.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MPL-2.0 + +pragma solidity ^0.8.0; + +interface IAuthorizationEngine { + /** + * @dev Returns true if the operation is a success, and false otherwise. + */ + function operateOnAuthorization( + bytes32 role, address account + ) external returns (bool isValid); + +} diff --git a/contracts/libraries/Errors.sol b/contracts/libraries/Errors.sol index cd7801a8..28840db9 100644 --- a/contracts/libraries/Errors.sol +++ b/contracts/libraries/Errors.sol @@ -58,6 +58,8 @@ library Errors { // AuthorizationModule error CMTAT_AuthorizationModule_AddressZeroNotAllowed(); + error CMTAT_AuthorizationModule_InvalidAuthorization(); + error CMTAT_AuthorizationModule_AuthorizationEngineAlreadySet(); // PauseModule error CMTAT_PauseModule_ContractIsDeactivated(); diff --git a/contracts/modules/CMTAT_BASE.sol b/contracts/modules/CMTAT_BASE.sol index 59da035a..801df619 100644 --- a/contracts/modules/CMTAT_BASE.sol +++ b/contracts/modules/CMTAT_BASE.sol @@ -56,7 +56,7 @@ abstract contract CMTAT_BASE is */ function initialize( address admin, - uint48 initialDelayToAcceptAdminRole, + IAuthorizationEngine authorizationEngineIrrevocable, string memory nameIrrevocable, string memory symbolIrrevocable, uint8 decimalsIrrevocable, @@ -68,7 +68,7 @@ abstract contract CMTAT_BASE is ) public initializer { __CMTAT_init( admin, - initialDelayToAcceptAdminRole, + authorizationEngineIrrevocable, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, @@ -85,7 +85,7 @@ abstract contract CMTAT_BASE is */ function __CMTAT_init( address admin, - uint48 initialDelayToAcceptAdminRole, + IAuthorizationEngine authorizationEngineIrrevocable, string memory nameIrrevocable, string memory symbolIrrevocable, uint8 decimalsIrrevocable, @@ -103,7 +103,6 @@ abstract contract CMTAT_BASE is __ERC165_init_unchained(); // AuthorizationModule inherits from AccessControlUpgradeable __AccessControl_init_unchained(); - __AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin); __Pausable_init_unchained(); /* Internal Modules */ @@ -119,7 +118,7 @@ abstract contract CMTAT_BASE is /* Wrapper */ // AuthorizationModule_init_unchained is called firstly due to inheritance - __AuthorizationModule_init_unchained(); + __AuthorizationModule_init_unchained(admin, authorizationEngineIrrevocable); __ERC20BurnModule_init_unchained(); __ERC20MintModule_init_unchained(); // EnforcementModule_init_unchained is called before ValidationModule_init_unchained due to inheritance diff --git a/contracts/modules/security/AuthorizationModule.sol b/contracts/modules/security/AuthorizationModule.sol index 2df2a049..9613c501 100644 --- a/contracts/modules/security/AuthorizationModule.sol +++ b/contracts/modules/security/AuthorizationModule.sol @@ -2,12 +2,17 @@ pragma solidity ^0.8.20; -import "../../../openzeppelin-contracts-upgradeable/contracts/access/extensions/AccessControlDefaultAdminRulesUpgradeable.sol"; +import "../../../openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol"; import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"; import "../../libraries/Errors.sol"; - -abstract contract AuthorizationModule is AccessControlDefaultAdminRulesUpgradeable { +import "../../interfaces/IAuthorizationEngine.sol"; +abstract contract AuthorizationModule is AccessControlUpgradeable { + IAuthorizationEngine private authorizationEngine; + /** + * @dev Emitted when a rule engine is set. + */ + event AuthorizationEngine(IAuthorizationEngine indexed newAuthorizationEngine); // BurnModule bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); // CreditEvents @@ -31,17 +36,67 @@ abstract contract AuthorizationModule is AccessControlDefaultAdminRulesUpgradeab * - The control of the zero address is done by AccessControlDefaultAdminRules * */ - function __AuthorizationModule_init_unchained( - ) internal view onlyInitializing { + function __AuthorizationModule_init_unchained(address admin, IAuthorizationEngine authorizationEngine_) + internal onlyInitializing { + if(admin == address(0)){ + revert Errors.CMTAT_AuthorizationModule_AddressZeroNotAllowed(); + } + _grantRole(DEFAULT_ADMIN_ROLE, admin); + if (address(authorizationEngine) != address (0)) { + authorizationEngine = authorizationEngine_; + } + + } + + /* + @notice set an authorizationEngine if not already set + @dev once an AuthorizationEngine is set, it is not possible to unset it + */ + function setAuthorizationEngine( + IAuthorizationEngine authorizationEngine_ + ) external onlyRole(DEFAULT_ADMIN_ROLE) { + if (address(authorizationEngine) != address (0)){ + revert Errors.CMTAT_AuthorizationModule_AuthorizationEngineAlreadySet(); + } + authorizationEngine = authorizationEngine_; + emit AuthorizationEngine(authorizationEngine_); + } + + function grantRole(bytes32 role, address account) public override onlyRole(getRoleAdmin(role)) { + if (address(authorizationEngine) != address (0)) { + bool result = authorizationEngine.operateOnAuthorization(role, account); + if(!result) { + // Operation rejected by the authorizationEngine + revert Errors.CMTAT_AuthorizationModule_InvalidAuthorization(); + } + } + return AccessControlUpgradeable.grantRole(role, account); + } + + + + + function revokeRole(bytes32 role, address account) public override onlyRole(getRoleAdmin(role)) { + if (address(authorizationEngine) != address (0)) { + bool result = authorizationEngine.operateOnAuthorization(role, account); + if(!result) { + // Operation rejected by the authorizationEngine + revert Errors.CMTAT_AuthorizationModule_InvalidAuthorization(); + } + } + return AccessControlUpgradeable.revokeRole(role, account); + } + + /* * @dev Returns `true` if `account` has been granted `role`. */ function hasRole( bytes32 role, address account - ) public view virtual override( IAccessControl, AccessControlUpgradeable) returns (bool) { + ) public view virtual override(AccessControlUpgradeable) returns (bool) { // The Default Admin has all roles if (AccessControlUpgradeable.hasRole(DEFAULT_ADMIN_ROLE, account)) { return true; @@ -49,16 +104,5 @@ abstract contract AuthorizationModule is AccessControlDefaultAdminRulesUpgradeab return AccessControlUpgradeable.hasRole(role, account); } - /** - @notice - Warning: this function should be called only in case of necessity (e.g private key leak) - Its goal is to transfer the adminship of the contract to a new admin, whithout delay. - The prefer way is to use the workflow of AccessControlDefaultAdminRulesUpgradeable - */ - function transferAdminshipDirectly(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { - // we revoke first the admin since we can only have one admin - _revokeRole(DEFAULT_ADMIN_ROLE, _msgSender()); - _grantRole(DEFAULT_ADMIN_ROLE, newAdmin); - } uint256[50] private __gap; } diff --git a/contracts/modules/wrapper/core/BaseModule.sol b/contracts/modules/wrapper/core/BaseModule.sol index 7fc46e74..23b26a76 100644 --- a/contracts/modules/wrapper/core/BaseModule.sol +++ b/contracts/modules/wrapper/core/BaseModule.sol @@ -12,7 +12,7 @@ abstract contract BaseModule is AuthorizationModule { @notice Get the current version of the smart contract */ - string public constant VERSION = "2.3.1"; + string public constant VERSION = "2.4.0"; /* Events */ event Term(string indexed newTermIndexed, string newTerm); event TokenId(string indexed newTokenIdIndexed, string newTokenId); diff --git a/contracts/test/CMTATSnapshot/CMTATSnapshotStandaloneTest.sol b/contracts/test/CMTATSnapshot/CMTATSnapshotStandaloneTest.sol index d372faac..7aaa4bcb 100644 --- a/contracts/test/CMTATSnapshot/CMTATSnapshotStandaloneTest.sol +++ b/contracts/test/CMTATSnapshot/CMTATSnapshotStandaloneTest.sol @@ -21,7 +21,7 @@ contract CMTATSnapshotStandaloneTest is CMTAT_BASE_SnapshotTest { constructor( address forwarderIrrevocable, address admin, - uint48 initialDelayToAcceptAdminRole, + IAuthorizationEngine authorizationEngineIrrevocable, string memory nameIrrevocable, string memory symbolIrrevocable, uint8 decimalsIrrevocable, @@ -35,7 +35,7 @@ contract CMTATSnapshotStandaloneTest is CMTAT_BASE_SnapshotTest { // Warning : do not initialize the proxy initialize( admin, - initialDelayToAcceptAdminRole, + authorizationEngineIrrevocable, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, diff --git a/contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol b/contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol index 2b051940..c8785f33 100644 --- a/contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol +++ b/contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol @@ -47,7 +47,7 @@ abstract contract CMTAT_BASE_SnapshotTest is */ function initialize( address admin, - uint48 initialDelayToAcceptAdminRole, + IAuthorizationEngine authorizationEngineIrrevocable, string memory nameIrrevocable, string memory symbolIrrevocable, uint8 decimalsIrrevocable, @@ -59,7 +59,7 @@ abstract contract CMTAT_BASE_SnapshotTest is ) public initializer { __CMTAT_init( admin, - initialDelayToAcceptAdminRole, + authorizationEngineIrrevocable, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, @@ -76,7 +76,7 @@ abstract contract CMTAT_BASE_SnapshotTest is */ function __CMTAT_init( address admin, - uint48 initialDelayToAcceptAdminRole, + IAuthorizationEngine authorizationEngineIrrevocable, string memory nameIrrevocable, string memory symbolIrrevocable, uint8 decimalsIrrevocable, @@ -109,8 +109,7 @@ abstract contract CMTAT_BASE_SnapshotTest is /* Wrapper */ // AuthorizationModule_init_unchained is called firstly due to inheritance - __AuthorizationModule_init_unchained(); - __AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin); + __AuthorizationModule_init_unchained(admin, authorizationEngineIrrevocable); __ERC20BurnModule_init_unchained(); __ERC20MintModule_init_unchained(); // EnforcementModule_init_unchained is called before ValidationModule_init_unchained due to inheritance diff --git a/test/common/AuthorizationModule/AuthorizationModuleCommon.js b/test/common/AuthorizationModule/AuthorizationModuleCommon.js index e8df45d8..4ea05578 100644 --- a/test/common/AuthorizationModule/AuthorizationModuleCommon.js +++ b/test/common/AuthorizationModule/AuthorizationModuleCommon.js @@ -1,11 +1,10 @@ -const { expectEvent, time } = require('@openzeppelin/test-helpers') +const { expectEvent } = require('@openzeppelin/test-helpers') const { expectRevertCustomError } = require('../../../openzeppelin-contracts-upgradeable/test/helpers/customError') -const { PAUSER_ROLE, DEFAULT_ADMIN_ROLE } = require('../../utils') +const { PAUSER_ROLE, DEFAULT_ADMIN_ROLE, ZERO_ADDRESS } = require('../../utils') const chai = require('chai') const should = chai.should() -const { DEFAULT_ADMIN_DELAY_WEB3 } = require('../../deploymentUtils') function AuthorizationModuleCommon (admin, address1, address2) { context('Authorization', function () { it('testAdminCanGrantRole', async function () { @@ -76,88 +75,15 @@ function AuthorizationModuleCommon (admin, address1, address2) { // Assert (await this.cmtat.hasRole(PAUSER_ROLE, address1)).should.equal(true) }) + }) - it('testCanAdminTransferAdminship', async function () { - // Arrange - Assert - (await this.cmtat.owner()).should.equal(admin) - // Act 1 - // Starts an admin transfer - await this.cmtat.beginDefaultAdminTransfer(address1, { from: admin }) - - // Wait for acceptance - const acceptSchedule = web3.utils - .toBN(await time.latest()) - .add(DEFAULT_ADMIN_DELAY_WEB3) - // We jump into the future - await time.increase(acceptSchedule.addn(1)) - - // Act 2 - this.logs = await this.cmtat.acceptDefaultAdminTransfer({ from: address1 }); - - // Assert - (await this.cmtat.owner()).should.equal(address1) - // Events - expectEvent(this.logs, 'RoleRevoked', { - role: DEFAULT_ADMIN_ROLE, - account: admin - }) - expectEvent(this.logs, 'RoleGranted', { - role: DEFAULT_ADMIN_ROLE, - account: address1 - }) - }) - - /* - Already tested by OpenZeppelin library - */ - it('testCannotNonAdminTransferAdminship', async function () { - // Arrange - Assert - (await this.cmtat.owner()).should.equal(admin) - // Act - // Starts an admin transfer - await expectRevertCustomError( - this.cmtat.beginDefaultAdminTransfer(address1, { from: address1 }), - 'AccessControlUnauthorizedAccount', - [address1, DEFAULT_ADMIN_ROLE] - ); - // Assert - (await this.cmtat.owner()).should.equal(admin) - }) - - it('testCanAdminTransferAdminshipDirectly', async function () { - // Arrange - Assert - (await this.cmtat.owner()).should.equal(admin) - - // Act - // Transfer the rights - await this.cmtat.transferAdminshipDirectly(address1, { from: admin }); - - // Assert - (await this.cmtat.owner()).should.equal(address1) - // Events - expectEvent(this.logs, 'RoleRevoked', { - role: DEFAULT_ADMIN_ROLE, - account: admin - }) - expectEvent(this.logs, 'RoleGranted', { - role: DEFAULT_ADMIN_ROLE, - account: address1 - }) - }) - - it('testCannotNonAdminTransferAdminshipDirectly', async function () { - // Arrange - Assert - (await this.cmtat.owner()).should.equal(admin) - // Transfer the rights - await expectRevertCustomError( - this.cmtat.transferAdminshipDirectly(address1, { from: address2 }), - 'AccessControlUnauthorizedAccount', - [address2, DEFAULT_ADMIN_ROLE] - ); - - // Assert - (await this.cmtat.owner()).should.equal(admin) - }) + it('testCannotNonAdminSetAuthorizationEngine', async function () { + // Act + await expectRevertCustomError( + this.cmtat.setAuthorizationEngine(ZERO_ADDRESS, { from: address1 }), + 'AccessControlUnauthorizedAccount', + [address1, DEFAULT_ADMIN_ROLE] + ) }) } module.exports = AuthorizationModuleCommon diff --git a/test/common/BaseModuleCommon.js b/test/common/BaseModuleCommon.js index 7979ef82..48d27daa 100644 --- a/test/common/BaseModuleCommon.js +++ b/test/common/BaseModuleCommon.js @@ -9,7 +9,7 @@ function BaseModuleCommon (owner, address1, address2, address3, proxyTest) { context('Token structure', function () { it('testHasTheDefinedVersion', async function () { // Act + Assert - (await this.cmtat.VERSION()).should.equal('2.3.1') + (await this.cmtat.VERSION()).should.equal('2.4.0') }) it('testHasTheDefinedTokenId', async function () { // Act + Assert diff --git a/test/deployment/deployment.test.js b/test/deployment/deployment.test.js index df953828..b63de452 100644 --- a/test/deployment/deployment.test.js +++ b/test/deployment/deployment.test.js @@ -9,7 +9,6 @@ const { } = require('../deploymentUtils') contract('CMTAT - Deployment', function ([_], deployer) { it('testCannotDeployProxyWithAdminSetToAddressZero', async function () { - const delayTime = BigInt(time.duration.days(3)) this.flag = 5 const DECIMAL = 0 // Act + Assert @@ -18,7 +17,7 @@ contract('CMTAT - Deployment', function ([_], deployer) { deployer, _, ZERO_ADDRESS, - delayTime, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DECIMAL, @@ -28,8 +27,8 @@ contract('CMTAT - Deployment', function ([_], deployer) { 'CMTAT_info', this.flag ), - 'AccessControlInvalidDefaultAdmin', - [ZERO_ADDRESS] + 'CMTAT_AuthorizationModule_AddressZeroNotAllowed', + [] ) }) it('testCannotDeployStandaloneWithAdminSetToAddressZero', async function () { @@ -41,7 +40,7 @@ contract('CMTAT - Deployment', function ([_], deployer) { deployer, _, ZERO_ADDRESS, - web3.utils.toBN(time.duration.days(3)), + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DECIMAL, @@ -51,8 +50,8 @@ contract('CMTAT - Deployment', function ([_], deployer) { 'CMTAT_info', this.flag ), - 'AccessControlInvalidDefaultAdmin', - [ZERO_ADDRESS] + 'CMTAT_AuthorizationModule_AddressZeroNotAllowed', + [] ) }) }) diff --git a/test/deploymentUtils.js b/test/deploymentUtils.js index 4eb5a2fc..e3f57b44 100644 --- a/test/deploymentUtils.js +++ b/test/deploymentUtils.js @@ -6,22 +6,15 @@ const CMTAT_STANDALONE_SNAPSHOT = artifacts.require( const CMTAT_PROXY = artifacts.require('CMTAT_PROXY') const CMTAT_PROXY_SNAPSHOT = artifacts.require('CMTATSnapshotProxyTest') const { deployProxy } = require('@openzeppelin/truffle-upgrades') -const { time } = require('@openzeppelin/test-helpers') const { ethers, upgrades } = require('hardhat') const DEPLOYMENT_FLAG = 5 const DEPLOYMENT_DECIMAL = 0 -const DEFAULT_ADMIN_DELAY = 1 -const DEFAULT_ADMIN_DELAY_WEB3 = web3.utils.toBN( - time.duration.days(DEFAULT_ADMIN_DELAY) -) -const DEFAULT_ADMIN_DELAY_HARDHAT = BigInt( - time.duration.days(DEFAULT_ADMIN_DELAY) -) + async function deployCMTATStandalone (_, admin, deployerAddress) { const cmtat = await CMTAT_STANDALONE.new( _, admin, - DEFAULT_ADMIN_DELAY_WEB3, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DEPLOYMENT_DECIMAL, @@ -39,7 +32,7 @@ async function deployCMTATStandaloneWithParameter ( deployerAddress, forwarderIrrevocable, admin, - defaultAdminDelay, + authorizationEngine, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, @@ -52,7 +45,7 @@ async function deployCMTATStandaloneWithParameter ( const cmtat = await CMTAT_STANDALONE.new( forwarderIrrevocable, admin, - defaultAdminDelay, + authorizationEngine, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, @@ -67,11 +60,10 @@ async function deployCMTATStandaloneWithParameter ( } async function deployCMTATStandaloneWithSnapshot (_, admin, deployerAddress) { - const DEFAULT_ADMIN_DELAY_WEB3_ = web3.utils.toBN(time.duration.days(3)) const cmtat = await CMTAT_STANDALONE_SNAPSHOT.new( _, admin, - DEFAULT_ADMIN_DELAY_WEB3_, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DEPLOYMENT_DECIMAL, @@ -94,7 +86,7 @@ async function deployCMTATProxy (_, admin, deployerAddress) { ETHERS_CMTAT_PROXY_FACTORY, [ admin, - DEFAULT_ADMIN_DELAY_HARDHAT, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DEPLOYMENT_DECIMAL, @@ -126,7 +118,7 @@ async function deployCMTATProxyWithSnapshot (_, admin, deployerAddress) { ETHERS_CMTAT_PROXY_FACTORY, [ admin, - DEFAULT_ADMIN_DELAY_HARDHAT, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DEPLOYMENT_DECIMAL, @@ -158,7 +150,7 @@ async function deployCMTATProxyWithKillTest (_, admin, deployerAddress) { ETHERS_CMTAT_PROXY_FACTORY, [ admin, - DEFAULT_ADMIN_DELAY_HARDHAT, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DEPLOYMENT_DECIMAL, @@ -185,7 +177,7 @@ async function deployCMTATProxyWithParameter ( deployerAddress, forwarderIrrevocable, admin, - defaultAdminDelay, + authorizationEngine, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, @@ -203,7 +195,7 @@ async function deployCMTATProxyWithParameter ( ETHERS_CMTAT_PROXY_FACTORY, [ admin, - defaultAdminDelay, + authorizationEngine, nameIrrevocable, symbolIrrevocable, decimalsIrrevocable, @@ -235,6 +227,5 @@ module.exports = { deployCMTATProxyWithParameter, deployCMTATStandaloneWithParameter, DEPLOYMENT_FLAG, - DEPLOYMENT_DECIMAL, - DEFAULT_ADMIN_DELAY_WEB3 + DEPLOYMENT_DECIMAL } diff --git a/test/proxy/general/Proxy.test.js b/test/proxy/general/Proxy.test.js index 8b15b413..7cd3d5fd 100644 --- a/test/proxy/general/Proxy.test.js +++ b/test/proxy/general/Proxy.test.js @@ -1,4 +1,3 @@ -const { time } = require('@openzeppelin/test-helpers') const { should } = require('chai').should() const { expectRevertCustomError @@ -32,7 +31,7 @@ contract( await expectRevertCustomError( this.implementationContract.initialize( attacker, - BigInt(time.duration.days(3)), + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DECIMAL, diff --git a/test/proxy/general/UpgradeProxy.test.js b/test/proxy/general/UpgradeProxy.test.js index 3e3b836a..73602d36 100644 --- a/test/proxy/general/UpgradeProxy.test.js +++ b/test/proxy/general/UpgradeProxy.test.js @@ -1,4 +1,4 @@ -const { BN, time } = require('@openzeppelin/test-helpers') +const { BN } = require('@openzeppelin/test-helpers') const { should } = require('chai').should() const { ZERO_ADDRESS } = require('../../utils') const { @@ -29,7 +29,7 @@ contract( ETHERS_CMTAT_PROXY_FACTORY, [ admin, - BigInt(time.duration.days(3)), + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DEPLOYMENT_DECIMAL, diff --git a/test/proxy/modules/MetaTxModule.test.js b/test/proxy/modules/MetaTxModule.test.js index bef29103..18fa343c 100644 --- a/test/proxy/modules/MetaTxModule.test.js +++ b/test/proxy/modules/MetaTxModule.test.js @@ -1,6 +1,3 @@ -const { time } = require('@openzeppelin/test-helpers') -const { deployProxy } = require('@openzeppelin/truffle-upgrades') -const CMTAT = artifacts.require('CMTAT_PROXY') const MinimalForwarderMock = artifacts.require('MinimalForwarderMock') const MetaTxModuleCommon = require('../../common/MetaTxModuleCommon') const { deployCMTATProxyWithParameter } = require('../../deploymentUtils') @@ -14,12 +11,11 @@ contract( const DECIMAL = 0 this.forwarder = await MinimalForwarderMock.new() await this.forwarder.initialize(ERC2771ForwarderDomain) - const delayTime = BigInt(time.duration.days(3)) this.cmtat = await deployCMTATProxyWithParameter( deployerAddress, this.forwarder.address, admin, - delayTime, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DECIMAL, diff --git a/test/proxy/modules/ValidationModule/ValidationModuleConstructor.test.js b/test/proxy/modules/ValidationModule/ValidationModuleConstructor.test.js index 0815c786..13f70a91 100644 --- a/test/proxy/modules/ValidationModule/ValidationModuleConstructor.test.js +++ b/test/proxy/modules/ValidationModule/ValidationModuleConstructor.test.js @@ -1,6 +1,6 @@ -const { time } = require('@openzeppelin/test-helpers') const ValidationModuleCommon = require('../../../common/ValidationModule/ValidationModuleCommon') const { deployCMTATProxyWithParameter } = require('../../../deploymentUtils') +const { ZERO_ADDRESS } = require('../../../utils') const RuleEngineMock = artifacts.require('RuleEngineMock') const ADDRESS1_INITIAL_BALANCE = 17 const ADDRESS2_INITIAL_BALANCE = 18 @@ -13,12 +13,11 @@ contract( this.flag = 5 const DECIMAL = 0 this.ruleEngineMock = await RuleEngineMock.new({ from: admin }) - const delayTime = BigInt(time.duration.days(3)) this.cmtat = await deployCMTATProxyWithParameter( deployerAddress, _, admin, - delayTime, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DECIMAL, diff --git a/test/standard/modules/ERC20SnapshotModule.test.js b/test/standard/modules/ERC20SnapshotModule.test.js index 47687cb5..5e01b210 100644 --- a/test/standard/modules/ERC20SnapshotModule.test.js +++ b/test/standard/modules/ERC20SnapshotModule.test.js @@ -1,4 +1,3 @@ -const CMTAT = artifacts.require('CMTATSnapshotStandaloneTest') const ERC20SnapshotModuleCommonRescheduling = require('../../common/ERC20SnapshotModuleCommon/ERC20SnapshotModuleCommonRescheduling') const ERC20SnapshotModuleCommonScheduling = require('../../common/ERC20SnapshotModuleCommon/ERC20SnapshotModuleCommonScheduling') const ERC20SnapshotModuleCommonUnschedule = require('../../common/ERC20SnapshotModuleCommon/ERC20SnapshotModuleCommonUnschedule') diff --git a/test/standard/modules/MetaTxModule.test.js b/test/standard/modules/MetaTxModule.test.js index c6c2ef83..602e5f90 100644 --- a/test/standard/modules/MetaTxModule.test.js +++ b/test/standard/modules/MetaTxModule.test.js @@ -1,4 +1,3 @@ -const { time } = require('@openzeppelin/test-helpers') const MinimalForwarderMock = artifacts.require('MinimalForwarderMock') const MetaTxModuleCommon = require('../../common/MetaTxModuleCommon') const { deployCMTATStandaloneWithParameter } = require('../../deploymentUtils') @@ -16,7 +15,7 @@ contract( deployerAddress, this.forwarder.address, admin, - web3.utils.toBN(time.duration.days(3)), + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DECIMAL, diff --git a/test/standard/modules/ValidationModule/ValidationModule.test.js b/test/standard/modules/ValidationModule/ValidationModule.test.js index 4a512e67..8cbe3229 100644 --- a/test/standard/modules/ValidationModule/ValidationModule.test.js +++ b/test/standard/modules/ValidationModule/ValidationModule.test.js @@ -1,5 +1,6 @@ const ValidationModuleCommon = require('../../../common/ValidationModule/ValidationModuleCommon') const { deployCMTATStandalone } = require('../../../deploymentUtils') +const { ZERO_ADDRESS } = require('../../../utils') const ADDRESS1_INITIAL_BALANCE = 31 const ADDRESS2_INITIAL_BALANCE = 32 const ADDRESS3_INITIAL_BALANCE = 33 diff --git a/test/standard/modules/ValidationModule/ValidationModuleConstructor.test.js b/test/standard/modules/ValidationModule/ValidationModuleConstructor.test.js index c68060df..dfe3da63 100644 --- a/test/standard/modules/ValidationModule/ValidationModuleConstructor.test.js +++ b/test/standard/modules/ValidationModule/ValidationModuleConstructor.test.js @@ -1,9 +1,9 @@ -const { time } = require('@openzeppelin/test-helpers') const ValidationModuleCommon = require('../../../common/ValidationModule/ValidationModuleCommon') const RuleEngineMock = artifacts.require('RuleEngineMock') const { deployCMTATStandaloneWithParameter } = require('../../../deploymentUtils') +const { ZERO_ADDRESS } = require('../../../utils') const ADDRESS1_INITIAL_BALANCE = 17 const ADDRESS2_INITIAL_BALANCE = 18 const ADDRESS3_INITIAL_BALANCE = 19 @@ -14,12 +14,11 @@ contract( this.flag = 5 const DECIMAL = 0 this.ruleEngineMock = await RuleEngineMock.new({ from: admin }) - const delayTime = BigInt(time.duration.days(3)) this.cmtat = await deployCMTATStandaloneWithParameter( deployerAddress, _, admin, - delayTime, + ZERO_ADDRESS, 'CMTA Token', 'CMTAT', DECIMAL,