From 48ba506b0a27b4eca35abc1189d46335b20b8cf2 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Fri, 25 Jul 2025 11:08:05 +0200 Subject: [PATCH] refactor:format contracts --- contracts/libs/IexecLibOrders_v5.sol | 512 +++++++++++++------------ contracts/modules/DelegateBase.sol | 4 +- contracts/modules/DelegateBase.v8.sol | 2 +- contracts/registries/IRegistry.sol | 5 +- contracts/tools/TimelockController.sol | 96 ++++- package.json | 2 +- 6 files changed, 350 insertions(+), 271 deletions(-) diff --git a/contracts/libs/IexecLibOrders_v5.sol b/contracts/libs/IexecLibOrders_v5.sol index 13128da17..8fbc55c68 100644 --- a/contracts/libs/IexecLibOrders_v5.sol +++ b/contracts/libs/IexecLibOrders_v5.sol @@ -19,272 +19,286 @@ pragma solidity >=0.6.0; pragma experimental ABIEncoderV2; +library IexecLibOrders_v5 { + // bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); + // bytes32 public constant APPORDER_TYPEHASH = keccak256('AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); + // bytes32 public constant DATASETORDER_TYPEHASH = keccak256('DatasetOrder(address dataset,uint256 datasetprice,uint256 volume,bytes32 tag,address apprestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); + // bytes32 public constant WORKERPOOLORDER_TYPEHASH = keccak256('WorkerpoolOrder(address workerpool,uint256 workerpoolprice,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address apprestrict,address datasetrestrict,address requesterrestrict,bytes32 salt)'); + // bytes32 public constant REQUESTORDER_TYPEHASH = keccak256('RequestOrder(address app,uint256 appmaxprice,address dataset,uint256 datasetmaxprice,address workerpool,uint256 workerpoolmaxprice,address requester,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address beneficiary,address callback,string params,bytes32 salt)'); + // bytes32 public constant APPORDEROPERATION_TYPEHASH = keccak256('AppOrderOperation(AppOrder order,uint256 operation)AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); + // bytes32 public constant DATASETORDEROPERATION_TYPEHASH = keccak256('DatasetOrderOperation(DatasetOrder order,uint256 operation)DatasetOrder(address dataset,uint256 datasetprice,uint256 volume,bytes32 tag,address apprestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); + // bytes32 public constant WORKERPOOLORDEROPERATION_TYPEHASH = keccak256('WorkerpoolOrderOperation(WorkerpoolOrder order,uint256 operation)WorkerpoolOrder(address workerpool,uint256 workerpoolprice,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address apprestrict,address datasetrestrict,address requesterrestrict,bytes32 salt)'); + // bytes32 public constant REQUESTORDEROPERATION_TYPEHASH = keccak256('RequestOrderOperation(RequestOrder order,uint256 operation)RequestOrder(address app,uint256 appmaxprice,address dataset,uint256 datasetmaxprice,address workerpool,uint256 workerpoolmaxprice,address requester,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address beneficiary,address callback,string params,bytes32 salt)'); + bytes32 public constant EIP712DOMAIN_TYPEHASH = + 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; + bytes32 public constant APPORDER_TYPEHASH = + 0x60815a0eeec47dddf1615fe53b31d016c31444e01b9d796db365443a6445d008; + bytes32 public constant DATASETORDER_TYPEHASH = + 0x6cfc932a5a3d22c4359295b9f433edff52b60703fa47690a04a83e40933dd47c; + bytes32 public constant WORKERPOOLORDER_TYPEHASH = + 0xaa3429fb281b34691803133d3d978a75bb77c617ed6bc9aa162b9b30920022bb; + bytes32 public constant REQUESTORDER_TYPEHASH = + 0xf24e853034a3a450aba845a82914fbb564ad85accca6cf62be112a154520fae0; + bytes32 public constant APPORDEROPERATION_TYPEHASH = + 0x0638bb0702457e2b4b01be8a202579b8bf97e587fb4f2cc4d4aad01f21a06ee0; + bytes32 public constant DATASETORDEROPERATION_TYPEHASH = + 0x075eb6f7578ff4292c241bd2484cd5c1d5e6ecc2ddd3317e1d8176b5a45865ec; + bytes32 public constant WORKERPOOLORDEROPERATION_TYPEHASH = + 0x322d980b7d7a6a1f7c39ff0c5445da6ae1d8e0393ff0dd468c8be3e2c8644388; + bytes32 public constant REQUESTORDEROPERATION_TYPEHASH = + 0x0ded7b52c2d77595a40d242eca751df172b18e686326dbbed3f4748828af77c7; -library IexecLibOrders_v5 -{ - // bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); - // bytes32 public constant APPORDER_TYPEHASH = keccak256('AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); - // bytes32 public constant DATASETORDER_TYPEHASH = keccak256('DatasetOrder(address dataset,uint256 datasetprice,uint256 volume,bytes32 tag,address apprestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); - // bytes32 public constant WORKERPOOLORDER_TYPEHASH = keccak256('WorkerpoolOrder(address workerpool,uint256 workerpoolprice,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address apprestrict,address datasetrestrict,address requesterrestrict,bytes32 salt)'); - // bytes32 public constant REQUESTORDER_TYPEHASH = keccak256('RequestOrder(address app,uint256 appmaxprice,address dataset,uint256 datasetmaxprice,address workerpool,uint256 workerpoolmaxprice,address requester,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address beneficiary,address callback,string params,bytes32 salt)'); - // bytes32 public constant APPORDEROPERATION_TYPEHASH = keccak256('AppOrderOperation(AppOrder order,uint256 operation)AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); - // bytes32 public constant DATASETORDEROPERATION_TYPEHASH = keccak256('DatasetOrderOperation(DatasetOrder order,uint256 operation)DatasetOrder(address dataset,uint256 datasetprice,uint256 volume,bytes32 tag,address apprestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)'); - // bytes32 public constant WORKERPOOLORDEROPERATION_TYPEHASH = keccak256('WorkerpoolOrderOperation(WorkerpoolOrder order,uint256 operation)WorkerpoolOrder(address workerpool,uint256 workerpoolprice,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address apprestrict,address datasetrestrict,address requesterrestrict,bytes32 salt)'); - // bytes32 public constant REQUESTORDEROPERATION_TYPEHASH = keccak256('RequestOrderOperation(RequestOrder order,uint256 operation)RequestOrder(address app,uint256 appmaxprice,address dataset,uint256 datasetmaxprice,address workerpool,uint256 workerpoolmaxprice,address requester,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address beneficiary,address callback,string params,bytes32 salt)'); - bytes32 public constant EIP712DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; - bytes32 public constant APPORDER_TYPEHASH = 0x60815a0eeec47dddf1615fe53b31d016c31444e01b9d796db365443a6445d008; - bytes32 public constant DATASETORDER_TYPEHASH = 0x6cfc932a5a3d22c4359295b9f433edff52b60703fa47690a04a83e40933dd47c; - bytes32 public constant WORKERPOOLORDER_TYPEHASH = 0xaa3429fb281b34691803133d3d978a75bb77c617ed6bc9aa162b9b30920022bb; - bytes32 public constant REQUESTORDER_TYPEHASH = 0xf24e853034a3a450aba845a82914fbb564ad85accca6cf62be112a154520fae0; - bytes32 public constant APPORDEROPERATION_TYPEHASH = 0x0638bb0702457e2b4b01be8a202579b8bf97e587fb4f2cc4d4aad01f21a06ee0; - bytes32 public constant DATASETORDEROPERATION_TYPEHASH = 0x075eb6f7578ff4292c241bd2484cd5c1d5e6ecc2ddd3317e1d8176b5a45865ec; - bytes32 public constant WORKERPOOLORDEROPERATION_TYPEHASH = 0x322d980b7d7a6a1f7c39ff0c5445da6ae1d8e0393ff0dd468c8be3e2c8644388; - bytes32 public constant REQUESTORDEROPERATION_TYPEHASH = 0x0ded7b52c2d77595a40d242eca751df172b18e686326dbbed3f4748828af77c7; + enum OrderOperationEnum { + SIGN, + CLOSE + } - enum OrderOperationEnum - { - SIGN, - CLOSE - } + struct EIP712Domain { + string name; + string version; + uint256 chainId; + address verifyingContract; + } - struct EIP712Domain - { - string name; - string version; - uint256 chainId; - address verifyingContract; - } + struct AppOrder { + address app; + uint256 appprice; + uint256 volume; + bytes32 tag; + address datasetrestrict; + address workerpoolrestrict; + address requesterrestrict; + bytes32 salt; + bytes sign; + } - struct AppOrder - { - address app; - uint256 appprice; - uint256 volume; - bytes32 tag; - address datasetrestrict; - address workerpoolrestrict; - address requesterrestrict; - bytes32 salt; - bytes sign; - } + struct DatasetOrder { + address dataset; + uint256 datasetprice; + uint256 volume; + bytes32 tag; + address apprestrict; + address workerpoolrestrict; + address requesterrestrict; + bytes32 salt; + bytes sign; + } - struct DatasetOrder - { - address dataset; - uint256 datasetprice; - uint256 volume; - bytes32 tag; - address apprestrict; - address workerpoolrestrict; - address requesterrestrict; - bytes32 salt; - bytes sign; - } + struct WorkerpoolOrder { + address workerpool; + uint256 workerpoolprice; + uint256 volume; + bytes32 tag; + uint256 category; + uint256 trust; + address apprestrict; + address datasetrestrict; + address requesterrestrict; + bytes32 salt; + bytes sign; + } - struct WorkerpoolOrder - { - address workerpool; - uint256 workerpoolprice; - uint256 volume; - bytes32 tag; - uint256 category; - uint256 trust; - address apprestrict; - address datasetrestrict; - address requesterrestrict; - bytes32 salt; - bytes sign; - } + struct RequestOrder { + address app; + uint256 appmaxprice; + address dataset; + uint256 datasetmaxprice; + address workerpool; + uint256 workerpoolmaxprice; + address requester; + uint256 volume; + bytes32 tag; + uint256 category; + uint256 trust; + address beneficiary; + address callback; + string params; + bytes32 salt; + bytes sign; + } - struct RequestOrder - { - address app; - uint256 appmaxprice; - address dataset; - uint256 datasetmaxprice; - address workerpool; - uint256 workerpoolmaxprice; - address requester; - uint256 volume; - bytes32 tag; - uint256 category; - uint256 trust; - address beneficiary; - address callback; - string params; - bytes32 salt; - bytes sign; - } + struct AppOrderOperation { + AppOrder order; + OrderOperationEnum operation; + bytes sign; + } - struct AppOrderOperation - { - AppOrder order; - OrderOperationEnum operation; - bytes sign; - } + struct DatasetOrderOperation { + DatasetOrder order; + OrderOperationEnum operation; + bytes sign; + } - struct DatasetOrderOperation - { - DatasetOrder order; - OrderOperationEnum operation; - bytes sign; - } + struct WorkerpoolOrderOperation { + WorkerpoolOrder order; + OrderOperationEnum operation; + bytes sign; + } - struct WorkerpoolOrderOperation - { - WorkerpoolOrder order; - OrderOperationEnum operation; - bytes sign; - } + struct RequestOrderOperation { + RequestOrder order; + OrderOperationEnum operation; + bytes sign; + } - struct RequestOrderOperation - { - RequestOrder order; - OrderOperationEnum operation; - bytes sign; - } + function hash(EIP712Domain memory _domain) public pure returns (bytes32 domainhash) { + /** + * Readeable but expensive + */ + return + keccak256( + abi.encode( + EIP712DOMAIN_TYPEHASH, + keccak256(bytes(_domain.name)), + keccak256(bytes(_domain.version)), + _domain.chainId, + _domain.verifyingContract + ) + ); + } - function hash(EIP712Domain memory _domain) - public pure returns (bytes32 domainhash) - { - /** - * Readeable but expensive - */ - return keccak256(abi.encode( - EIP712DOMAIN_TYPEHASH - , keccak256(bytes(_domain.name)) - , keccak256(bytes(_domain.version)) - , _domain.chainId - , _domain.verifyingContract - )); - } + function hash(AppOrder memory _apporder) public pure returns (bytes32 apphash) { + /** + * Readeable but expensive + */ + return + keccak256( + abi.encode( + APPORDER_TYPEHASH, + _apporder.app, + _apporder.appprice, + _apporder.volume, + _apporder.tag, + _apporder.datasetrestrict, + _apporder.workerpoolrestrict, + _apporder.requesterrestrict, + _apporder.salt + ) + ); + } - function hash(AppOrder memory _apporder) - public pure returns (bytes32 apphash) - { - /** - * Readeable but expensive - */ - return keccak256(abi.encode( - APPORDER_TYPEHASH - , _apporder.app - , _apporder.appprice - , _apporder.volume - , _apporder.tag - , _apporder.datasetrestrict - , _apporder.workerpoolrestrict - , _apporder.requesterrestrict - , _apporder.salt - )); - } + function hash(DatasetOrder memory _datasetorder) public pure returns (bytes32 datasethash) { + /** + * Readeable but expensive + */ + return + keccak256( + abi.encode( + DATASETORDER_TYPEHASH, + _datasetorder.dataset, + _datasetorder.datasetprice, + _datasetorder.volume, + _datasetorder.tag, + _datasetorder.apprestrict, + _datasetorder.workerpoolrestrict, + _datasetorder.requesterrestrict, + _datasetorder.salt + ) + ); + } - function hash(DatasetOrder memory _datasetorder) - public pure returns (bytes32 datasethash) - { - /** - * Readeable but expensive - */ - return keccak256(abi.encode( - DATASETORDER_TYPEHASH - , _datasetorder.dataset - , _datasetorder.datasetprice - , _datasetorder.volume - , _datasetorder.tag - , _datasetorder.apprestrict - , _datasetorder.workerpoolrestrict - , _datasetorder.requesterrestrict - , _datasetorder.salt - )); - } + function hash( + WorkerpoolOrder memory _workerpoolorder + ) public pure returns (bytes32 workerpoolhash) { + /** + * Readeable but expensive + */ + return + keccak256( + abi.encode( + WORKERPOOLORDER_TYPEHASH, + _workerpoolorder.workerpool, + _workerpoolorder.workerpoolprice, + _workerpoolorder.volume, + _workerpoolorder.tag, + _workerpoolorder.category, + _workerpoolorder.trust, + _workerpoolorder.apprestrict, + _workerpoolorder.datasetrestrict, + _workerpoolorder.requesterrestrict, + _workerpoolorder.salt + ) + ); + } - function hash(WorkerpoolOrder memory _workerpoolorder) - public pure returns (bytes32 workerpoolhash) - { - /** - * Readeable but expensive - */ - return keccak256(abi.encode( - WORKERPOOLORDER_TYPEHASH - , _workerpoolorder.workerpool - , _workerpoolorder.workerpoolprice - , _workerpoolorder.volume - , _workerpoolorder.tag - , _workerpoolorder.category - , _workerpoolorder.trust - , _workerpoolorder.apprestrict - , _workerpoolorder.datasetrestrict - , _workerpoolorder.requesterrestrict - , _workerpoolorder.salt - )); - } + function hash(RequestOrder memory _requestorder) public pure returns (bytes32 requesthash) { + /** + * Readeable but expensive + */ + return + keccak256( + abi.encodePacked( + abi.encode( + REQUESTORDER_TYPEHASH, + _requestorder.app, + _requestorder.appmaxprice, + _requestorder.dataset, + _requestorder.datasetmaxprice, + _requestorder.workerpool, + _requestorder.workerpoolmaxprice + ), + abi.encode( + _requestorder.requester, + _requestorder.volume, + _requestorder.tag, + _requestorder.category, + _requestorder.trust, + _requestorder.beneficiary, + _requestorder.callback, + keccak256(bytes(_requestorder.params)), + _requestorder.salt + ) + ) + ); + } - function hash(RequestOrder memory _requestorder) - public pure returns (bytes32 requesthash) - { - /** - * Readeable but expensive - */ - return keccak256(abi.encodePacked( - abi.encode( - REQUESTORDER_TYPEHASH - , _requestorder.app - , _requestorder.appmaxprice - , _requestorder.dataset - , _requestorder.datasetmaxprice - , _requestorder.workerpool - , _requestorder.workerpoolmaxprice - ), - abi.encode( - _requestorder.requester - , _requestorder.volume - , _requestorder.tag - , _requestorder.category - , _requestorder.trust - , _requestorder.beneficiary - , _requestorder.callback - , keccak256(bytes(_requestorder.params)) - , _requestorder.salt - ) - )); - } + function hash(AppOrderOperation memory _apporderoperation) public pure returns (bytes32) { + return + keccak256( + abi.encode( + APPORDEROPERATION_TYPEHASH, + hash(_apporderoperation.order), + _apporderoperation.operation + ) + ); + } - function hash(AppOrderOperation memory _apporderoperation) - public pure returns (bytes32) - { - return keccak256(abi.encode( - APPORDEROPERATION_TYPEHASH - , hash(_apporderoperation.order) - , _apporderoperation.operation - )); - } + function hash( + DatasetOrderOperation memory _datasetorderoperation + ) public pure returns (bytes32) { + return + keccak256( + abi.encode( + DATASETORDEROPERATION_TYPEHASH, + hash(_datasetorderoperation.order), + _datasetorderoperation.operation + ) + ); + } - function hash(DatasetOrderOperation memory _datasetorderoperation) - public pure returns (bytes32) - { - return keccak256(abi.encode( - DATASETORDEROPERATION_TYPEHASH - , hash(_datasetorderoperation.order) - , _datasetorderoperation.operation - )); - } + function hash( + WorkerpoolOrderOperation memory _workerpoolorderoperation + ) public pure returns (bytes32) { + return + keccak256( + abi.encode( + WORKERPOOLORDEROPERATION_TYPEHASH, + hash(_workerpoolorderoperation.order), + _workerpoolorderoperation.operation + ) + ); + } - function hash(WorkerpoolOrderOperation memory _workerpoolorderoperation) - public pure returns (bytes32) - { - return keccak256(abi.encode( - WORKERPOOLORDEROPERATION_TYPEHASH - , hash(_workerpoolorderoperation.order) - , _workerpoolorderoperation.operation - )); - } - - function hash(RequestOrderOperation memory _requestorderoperation) - public pure returns (bytes32) - { - return keccak256(abi.encode( - REQUESTORDEROPERATION_TYPEHASH - , hash(_requestorderoperation.order) - , _requestorderoperation.operation - )); - } + function hash( + RequestOrderOperation memory _requestorderoperation + ) public pure returns (bytes32) { + return + keccak256( + abi.encode( + REQUESTORDEROPERATION_TYPEHASH, + hash(_requestorderoperation.order), + _requestorderoperation.operation + ) + ); + } } diff --git a/contracts/modules/DelegateBase.sol b/contracts/modules/DelegateBase.sol index a4783dd66..435b5d0ae 100644 --- a/contracts/modules/DelegateBase.sol +++ b/contracts/modules/DelegateBase.sol @@ -12,7 +12,6 @@ import "./interfaces/IOwnable.sol"; // TODO rename this contract to `FacetBase`. abstract contract DelegateBase is Store { - modifier onlyOwner() { require(_msgSender() == owner(), "Ownable: caller is not the owner"); _; @@ -22,8 +21,7 @@ abstract contract DelegateBase is Store { return IOwnable(address(this)).owner(); } - function _msgSender() internal view returns (address ) { + function _msgSender() internal view returns (address) { return msg.sender; } - } diff --git a/contracts/modules/DelegateBase.v8.sol b/contracts/modules/DelegateBase.v8.sol index 9f1422da8..e2f44e8d8 100644 --- a/contracts/modules/DelegateBase.v8.sol +++ b/contracts/modules/DelegateBase.v8.sol @@ -26,7 +26,7 @@ abstract contract DelegateBase is Store { return IERC5313(address(this)).owner(); } - function _msgSender() internal view returns (address ) { + function _msgSender() internal view returns (address) { return msg.sender; } } diff --git a/contracts/registries/IRegistry.sol b/contracts/registries/IRegistry.sol index 02c899d0a..0734d296e 100644 --- a/contracts/registries/IRegistry.sol +++ b/contracts/registries/IRegistry.sol @@ -20,7 +20,6 @@ pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol"; -interface IRegistry is IERC721Enumerable -{ - function isRegistered(address _entry) external view returns (bool); +interface IRegistry is IERC721Enumerable { + function isRegistered(address _entry) external view returns (bool); } diff --git a/contracts/tools/TimelockController.sol b/contracts/tools/TimelockController.sol index a0db6f44f..9615b641c 100644 --- a/contracts/tools/TimelockController.sol +++ b/contracts/tools/TimelockController.sol @@ -20,7 +20,6 @@ import "@openzeppelin/contracts/math/SafeMath.sol"; * a multisig or a DAO as the sole proposer. */ contract TimelockController is AccessControl { - bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256("TIMELOCK_ADMIN_ROLE"); bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE"); bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE"); @@ -32,12 +31,26 @@ contract TimelockController is AccessControl { /** * @dev Emitted when a call is scheduled as part of operation `id`. */ - event CallScheduled(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data, bytes32 predecessor, uint256 delay); + event CallScheduled( + bytes32 indexed id, + uint256 indexed index, + address target, + uint256 value, + bytes data, + bytes32 predecessor, + uint256 delay + ); /** * @dev Emitted when a call is performed as part of operation `id`. */ - event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data); + event CallExecuted( + bytes32 indexed id, + uint256 indexed index, + address target, + uint256 value, + bytes data + ); /** * @dev Emitted when operation `id` is cancelled. @@ -52,7 +65,12 @@ contract TimelockController is AccessControl { /** * @dev Initializes the contract with a given `minDelay`. */ - constructor(uint256 minDelay, address[] memory administrators, address[] memory proposers, address[] memory executors) public { + constructor( + uint256 minDelay, + address[] memory administrators, + address[] memory proposers, + address[] memory executors + ) public { _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE); _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE); @@ -83,7 +101,10 @@ contract TimelockController is AccessControl { * this role for everyone. */ modifier onlyRole(bytes32 role) { - require(hasRole(role, _msgSender()) || hasRole(role, address(0)), "TimelockController: sender requires permission"); + require( + hasRole(role, _msgSender()) || hasRole(role, address(0)), + "TimelockController: sender requires permission" + ); _; } @@ -133,7 +154,13 @@ contract TimelockController is AccessControl { * @dev Returns the identifier of an operation containing a single * transaction. */ - function hashOperation(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt) public pure returns (bytes32 hash) { + function hashOperation( + address target, + uint256 value, + bytes calldata data, + bytes32 predecessor, + bytes32 salt + ) public pure returns (bytes32 hash) { return keccak256(abi.encode(target, value, data, predecessor, salt)); } @@ -141,7 +168,13 @@ contract TimelockController is AccessControl { * @dev Returns the identifier of an operation containing a batch of * transactions. */ - function hashOperationBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt) public pure returns (bytes32 hash) { + function hashOperationBatch( + address[] calldata targets, + uint256[] calldata values, + bytes[] calldata datas, + bytes32 predecessor, + bytes32 salt + ) public pure returns (bytes32 hash) { return keccak256(abi.encode(targets, values, datas, predecessor, salt)); } @@ -154,7 +187,14 @@ contract TimelockController is AccessControl { * * - the caller must have the 'proposer' role. */ - function schedule(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRole(PROPOSER_ROLE) { + function schedule( + address target, + uint256 value, + bytes calldata data, + bytes32 predecessor, + bytes32 salt, + uint256 delay + ) public virtual onlyRole(PROPOSER_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _schedule(id, delay); emit CallScheduled(id, 0, target, value, data, predecessor, delay); @@ -169,7 +209,14 @@ contract TimelockController is AccessControl { * * - the caller must have the 'proposer' role. */ - function scheduleBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRole(PROPOSER_ROLE) { + function scheduleBatch( + address[] calldata targets, + uint256[] calldata values, + bytes[] calldata datas, + bytes32 predecessor, + bytes32 salt, + uint256 delay + ) public virtual onlyRole(PROPOSER_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == datas.length, "TimelockController: length mismatch"); @@ -213,7 +260,13 @@ contract TimelockController is AccessControl { * * - the caller must have the 'executor' role. */ - function execute(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt) public payable virtual onlyRole(EXECUTOR_ROLE) { + function execute( + address target, + uint256 value, + bytes calldata data, + bytes32 predecessor, + bytes32 salt + ) public payable virtual onlyRole(EXECUTOR_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _beforeCall(predecessor); _call(id, 0, target, value, data); @@ -229,7 +282,13 @@ contract TimelockController is AccessControl { * * - the caller must have the 'executor' role. */ - function executeBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt) public payable virtual onlyRole(EXECUTOR_ROLE) { + function executeBatch( + address[] calldata targets, + uint256[] calldata values, + bytes[] calldata datas, + bytes32 predecessor, + bytes32 salt + ) public payable virtual onlyRole(EXECUTOR_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == datas.length, "TimelockController: length mismatch"); @@ -245,7 +304,10 @@ contract TimelockController is AccessControl { * @dev Checks before execution of an operation's calls. */ function _beforeCall(bytes32 predecessor) private view { - require(predecessor == bytes32(0) || isOperationDone(predecessor), "TimelockController: missing dependency"); + require( + predecessor == bytes32(0) || isOperationDone(predecessor), + "TimelockController: missing dependency" + ); } /** @@ -261,9 +323,15 @@ contract TimelockController is AccessControl { * * Emits a {CallExecuted} event. */ - function _call(bytes32 id, uint256 index, address target, uint256 value, bytes calldata data) private { + function _call( + bytes32 id, + uint256 index, + address target, + uint256 value, + bytes calldata data + ) private { // solhint-disable-next-line avoid-low-level-calls - (bool success,) = target.call{value: value}(data); + (bool success, ) = target.call{value: value}(data); require(success, "TimelockController: underlying transaction reverted"); emit CallExecuted(id, index, target, value, data); diff --git a/package.json b/package.json index 90adfc528..19bdaa073 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test:native": "npm run clean && TEST__IS_NATIVE_CHAIN=true npx hardhat test test/byContract/IexecEscrow/IexecEscrowNative.test.ts", "coverage": "npx hardhat coverage", "verify": "npx hardhat verify", - "format": "npx prettier --write", + "format": "npx prettier --write ./contracts/**/*.sol", "uml": "npm run sol-to-uml && npm run puml-to-links && npm run storage-to-diagrams", "sol-to-uml": "npx zx scripts/tools/sol-to-uml.mjs", "puml-to-links": "npx zx scripts/tools/puml-to-links.mjs",