diff --git a/script/migrations/100-kinto_core_app.s.sol b/script/migrations/100-kinto_core_app.s.sol index d25017c8..632544f3 100644 --- a/script/migrations/100-kinto_core_app.s.sol +++ b/script/migrations/100-kinto_core_app.s.sol @@ -16,14 +16,7 @@ contract KintoCoreAppScript is MigrationHelper { appContracts[1] = address(0x8a4720488CA32f1223ccFE5A087e250fE3BC5D75); //Wallet Factory appContracts[2] = address(0x5A2b641b84b0230C8e75F55d5afd27f4Dbd59d5b); //App Registry - KintoAppRegistry kintoAppRegistry = KintoAppRegistry(payable(_getChainDeployment("KintoAppRegistry"))); - - uint256[4] memory appLimits = [ - kintoAppRegistry.RATE_LIMIT_PERIOD(), - kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - kintoAppRegistry.GAS_LIMIT_PERIOD(), - kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; // Socket-batcher app address[] memory devEOAs = new address[](2); diff --git a/script/migrations/111-upgrade_app_registry.s.sol b/script/migrations/111-upgrade_app_registry.s.sol index f9396e5d..54b6c693 100644 --- a/script/migrations/111-upgrade_app_registry.s.sol +++ b/script/migrations/111-upgrade_app_registry.s.sol @@ -18,9 +18,5 @@ contract DeployScript is MigrationHelper { saveContractAddress("KintoAppRegistryV21", impl); KintoAppRegistry registry = KintoAppRegistry(_getChainDeployment("KintoAppRegistry")); - - assertEq(address(registry.paymaster()), _getChainDeployment("SponsorPaymaster")); - assertEq(address(registry.walletFactory()), _getChainDeployment("KintoWalletFactory")); - assertEq(address(registry.ENTRYPOINT_V7()), 0x0000000071727De22E5E9d8BAf0edAc6f37da032); } } diff --git a/script/migrations/27-deploy_registry-v4.s.sol b/script/migrations/27-deploy_registry-v4.s.sol index b4e982a8..2db5f7c6 100644 --- a/script/migrations/27-deploy_registry-v4.s.sol +++ b/script/migrations/27-deploy_registry-v4.s.sol @@ -17,7 +17,6 @@ contract KintoMigration27DeployScript is MigrationHelper { // check KintoID is set on Registry IKintoAppRegistry registry = IKintoAppRegistry(_getChainDeployment("KintoAppRegistry")); - require(address(registry.kintoID()) == _getChainDeployment("KintoID"), "KintoID not set on Registry"); // check we can't call registerApp without being KYC'd try registry.registerApp( diff --git a/script/migrations/66-socket-app.s.sol b/script/migrations/66-socket-app.s.sol index 70c324dd..485c8a8a 100644 --- a/script/migrations/66-socket-app.s.sol +++ b/script/migrations/66-socket-app.s.sol @@ -44,12 +44,7 @@ contract KintoMigration66DeployScript is MigrationHelper { appContracts[23] = _getChainDeployment("weETH"); appContracts[25] = _getChainDeployment("ETHFI"); - uint256[4] memory appLimits = [ - kintoAppRegistry.RATE_LIMIT_PERIOD(), - kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - kintoAppRegistry.GAS_LIMIT_PERIOD(), - kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; vm.broadcast(deployerPrivateKey); kintoAppRegistry.registerApp("Socket", parentContract, appContracts, appLimits, new address[](0)); diff --git a/script/migrations/78-update-socket-app.s.sol b/script/migrations/78-update-socket-app.s.sol index a3de5651..52fb3931 100644 --- a/script/migrations/78-update-socket-app.s.sol +++ b/script/migrations/78-update-socket-app.s.sol @@ -30,12 +30,7 @@ contract KintoMigration78DeployScript is MigrationHelper { appContracts[12] = address(0x24f287b474a05E48627846148cCdA3D05de03953); // ETHFI controller appContracts[13] = address(0xA2a13094baB725D6D9dd8b9B5c01F1a1bF67F986); // SolvBTC controller - uint256[4] memory appLimits = [ - kintoAppRegistry.RATE_LIMIT_PERIOD(), - kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - kintoAppRegistry.GAS_LIMIT_PERIOD(), - kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; vm.broadcast(deployerPrivateKey); kintoAppRegistry.updateMetadata("Socket", parentContract, appContracts, appLimits, new address[](0)); diff --git a/script/migrations/85-dinari_apps.s.sol b/script/migrations/85-dinari_apps.s.sol index b45a188d..5cfbf5b1 100644 --- a/script/migrations/85-dinari_apps.s.sol +++ b/script/migrations/85-dinari_apps.s.sol @@ -45,12 +45,7 @@ contract KintoMigration85DeployScript is MigrationHelper { appContracts[9] = address(0xeDA274898ED364Bd346fA74cf6eCAB4BF8f1665f); // UsdPlusMinte appContracts[10] = address(0x931C5dC9eA13b0F6B4768a98AFfEA773b888e978); // USDPlus Redeeemer - uint256[4] memory appLimits = [ - kintoAppRegistry.RATE_LIMIT_PERIOD(), - kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - kintoAppRegistry.GAS_LIMIT_PERIOD(), - kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; eoas[0] = address(0x400880b800410B2951Afd0503dC457aea8A4bAb5); // Treasury eoas[1] = address(0xF96b974FE330C29e80121E33ed4071C283257979); // dshares diff --git a/script/migrations/97-update_socket_app.s.sol b/script/migrations/97-update_socket_app.s.sol index fdf9d556..047093fa 100644 --- a/script/migrations/97-update_socket_app.s.sol +++ b/script/migrations/97-update_socket_app.s.sol @@ -44,12 +44,7 @@ contract KintoMigration97DeployScript is MigrationHelper { appContracts[26] = address(0x8cd4725D32CcFB201A25F1E1a18260E53F37C927); // cbETH controller appContracts[27] = address(0xB0FC8B7fb66958fe813475bBDC91c1Ac75725442); // cbBTC controller - uint256[4] memory appLimits = [ - kintoAppRegistry.RATE_LIMIT_PERIOD(), - kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - kintoAppRegistry.GAS_LIMIT_PERIOD(), - kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; _handleOps( abi.encodeWithSelector( diff --git a/script/migrations/const.sol b/script/migrations/const.sol index 17904167..5bb55a5d 100644 --- a/script/migrations/const.sol +++ b/script/migrations/const.sol @@ -7,4 +7,8 @@ contract Constants { address WUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812; // wUSDM uint64 internal constant NIO_GOVERNOR_ROLE = uint64(uint256(keccak256("NIO_GOVERNOR_ROLE"))); uint256 internal constant NIO_EXECUTION_DELAY = 3 days; + uint256 internal constant RATE_LIMIT_PERIOD = 1 minutes; + uint256 internal constant RATE_LIMIT_THRESHOLD = 10; + uint256 internal constant GAS_LIMIT_PERIOD = 30 days; + uint256 internal constant GAS_LIMIT_THRESHOLD = 0.01 ether; } diff --git a/src/apps/KintoAppRegistry.sol b/src/apps/KintoAppRegistry.sol index 9e8ef02b..f0e840e8 100644 --- a/src/apps/KintoAppRegistry.sol +++ b/src/apps/KintoAppRegistry.sol @@ -40,50 +40,38 @@ contract KintoAppRegistry is { /* ============ Constants ============ */ - /// @notice The default period for rate limiting, set to 1 minute - uint256 public constant override RATE_LIMIT_PERIOD = 1 minutes; - - /// @notice The default threshold for rate limiting, set to 10 calls - uint256 public constant override RATE_LIMIT_THRESHOLD = 10; - - /// @notice The default period for gas limiting, set to 30 days - uint256 public constant override GAS_LIMIT_PERIOD = 30 days; - - /// @notice The default threshold for gas limiting, set to 0.01 ether - uint256 public constant override GAS_LIMIT_THRESHOLD = 0.01 ether; - /// @notice The address of the CREATE2 contract - address public constant CREATE2 = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + address private constant CREATE2 = 0x4e59b44847b379578588920cA78FbF26c0B4956C; /// @notice The SponsorPaymaster contract - SponsorPaymaster public immutable paymaster; + SponsorPaymaster private immutable paymaster; /// @notice The KintoWalletFactory contract - IKintoWalletFactory public immutable override walletFactory; + IKintoWalletFactory private immutable walletFactory; /// @notice The KintoID contract - IKintoID public immutable kintoID; + IKintoID private immutable kintoID; /// @notice The address of the admin deployer - address public constant ADMIN_DEPLOYER = 0x660ad4B5A74130a4796B4d54BC6750Ae93C86e6c; + address private constant ADMIN_DEPLOYER = 0x660ad4B5A74130a4796B4d54BC6750Ae93C86e6c; /// @notice - address public constant ENTRYPOINT_V6 = 0x2843C269D2a64eCfA63548E8B3Fc0FD23B7F70cb; + address private constant ENTRYPOINT_V6 = 0x2843C269D2a64eCfA63548E8B3Fc0FD23B7F70cb; /// @notice - address public constant ENTRYPOINT_V7 = 0x0000000071727De22E5E9d8BAf0edAc6f37da032; + address private constant ENTRYPOINT_V7 = 0x0000000071727De22E5E9d8BAf0edAc6f37da032; /// @notice - address public constant ARB_RETRAYABLE_TX = 0x000000000000000000000000000000000000006E; + address private constant ARB_RETRAYABLE_TX = 0x000000000000000000000000000000000000006E; - bytes4 public constant SELECTOR_EP_WITHDRAW_STAKE = 0xc23a5cea; - bytes4 public constant SELECTOR_EP_WITHDRAW_TO = 0x205c2878; - bytes4 public constant SELECTOR_EP_HANDLEO_AGGREGATED_OPS = 0x4b1d7cf5; - bytes4 public constant SELECTOR_EP_HANDLE_AGGREGATED_OPS_V7 = 0xdbed18e0; - bytes4 public constant SELECTOR_EP_HANDLEOPS = 0x1fad948c; - bytes4 public constant SELECTOR_EP_HANDLE_OPS_V7 = 0x765e827f; - bytes4 public constant SELECTOR_EP_DEPOSIT = 0xb760faf9; - bytes4 public constant SELECTOR_EMPTY = 0x00000000; + bytes4 private constant SELECTOR_EP_WITHDRAW_STAKE = 0xc23a5cea; + bytes4 private constant SELECTOR_EP_WITHDRAW_TO = 0x205c2878; + bytes4 private constant SELECTOR_EP_HANDLEO_AGGREGATED_OPS = 0x4b1d7cf5; + bytes4 private constant SELECTOR_EP_HANDLE_AGGREGATED_OPS_V7 = 0xdbed18e0; + bytes4 private constant SELECTOR_EP_HANDLEOPS = 0x1fad948c; + bytes4 private constant SELECTOR_EP_HANDLE_OPS_V7 = 0x765e827f; + bytes4 private constant SELECTOR_EP_DEPOSIT = 0xb760faf9; + bytes4 private constant SELECTOR_EMPTY = 0x00000000; /* ============ State Variables ============ */ @@ -155,7 +143,9 @@ contract KintoAppRegistry is * @notice Authorizes the upgrade of the contract * @param newImplementation The address of the new implementation */ - function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} + function _authorizeUpgrade(address newImplementation) internal override { + _checkOwner(); + } /* ============ Token name, symbol & URI ============ */ @@ -299,19 +289,22 @@ contract KintoAppRegistry is } /// @inheritdoc IKintoAppRegistry - function enableDSA(address app) external override onlyOwner { + function enableDSA(address app) external override { + _checkOwner(); if (_appMetadata[app].dsaEnabled) revert DSAAlreadyEnabled(app); _appMetadata[app].dsaEnabled = true; emit AppDSAEnabled(app, block.timestamp); } /// @inheritdoc IKintoAppRegistry - function overrideChildToParentContract(address child, address parent) external override onlyOwner { + function overrideChildToParentContract(address child, address parent) external override { + _checkOwner(); childToParentContract[child] = parent; } /// @inheritdoc IKintoAppRegistry - function updateSystemApps(address[] calldata newSystemApps) external onlyOwner { + function updateSystemApps(address[] calldata newSystemApps) external { + _checkOwner(); emit SystemAppsUpdated(systemApps, newSystemApps); for (uint256 index = 0; index < systemApps.length; index++) { isSystemApp[systemApps[index]] = false; @@ -323,7 +316,8 @@ contract KintoAppRegistry is } /// @inheritdoc IKintoAppRegistry - function updateSystemContracts(address[] calldata newSystemContracts) external onlyOwner { + function updateSystemContracts(address[] calldata newSystemContracts) external { + _checkOwner(); emit SystemContractsUpdated(systemContracts, newSystemContracts); for (uint256 index = 0; index < systemContracts.length; index++) { _isSystemContract[systemContracts[index]] = false; @@ -335,7 +329,8 @@ contract KintoAppRegistry is } /// @inheritdoc IKintoAppRegistry - function updateReservedContracts(address[] calldata newReservedContracts) external onlyOwner { + function updateReservedContracts(address[] calldata newReservedContracts) external { + _checkOwner(); emit ReservedContractsUpdated(reservedContracts, newReservedContracts); for (uint256 index = 0; index < reservedContracts.length; index++) { isReservedContract[reservedContracts[index]] = false; @@ -389,10 +384,14 @@ contract KintoAppRegistry is uint256 gasLimitCost = _appMetadata[app].gasLimitCost; // Assign values to the return array - limits[0] = rateLimitPeriod != 0 ? rateLimitPeriod : RATE_LIMIT_PERIOD; - limits[1] = rateLimitNumber != 0 ? rateLimitNumber : RATE_LIMIT_THRESHOLD; - limits[2] = gasLimitPeriod != 0 ? gasLimitPeriod : GAS_LIMIT_PERIOD; - limits[3] = gasLimitCost != 0 ? gasLimitCost : GAS_LIMIT_THRESHOLD; + // The default period for rate limiting, set to 1 minute + limits[0] = rateLimitPeriod != 0 ? rateLimitPeriod : 1 minutes; + // The default threshold for rate limiting, set to 10 calls + limits[1] = rateLimitNumber != 0 ? rateLimitNumber : 10; + // The default period for gas limiting, set to 30 days + limits[2] = gasLimitPeriod != 0 ? gasLimitPeriod : 30 days; + // The default threshold for gas limiting, set to 0.01 ether + limits[3] = gasLimitCost != 0 ? gasLimitCost : 0.01 ether; } /// @inheritdoc IKintoAppRegistry diff --git a/src/interfaces/IKintoAppRegistry.sol b/src/interfaces/IKintoAppRegistry.sol index 50793a2c..faa9ca27 100644 --- a/src/interfaces/IKintoAppRegistry.sol +++ b/src/interfaces/IKintoAppRegistry.sol @@ -303,18 +303,6 @@ interface IKintoAppRegistry { */ function isSponsored(address app, address target) external view returns (bool); - /** - * @notice Returns the wallet factory contract - * @return The address of the wallet factory contract - */ - function walletFactory() external view returns (IKintoWalletFactory); - - /** - * @notice Returns the KintoID contract - * @return The address of the KintoID contract - */ - function kintoID() external view returns (IKintoID); - /** * @notice Returns the app address for a given token ID * @param _tokenId The token ID @@ -415,30 +403,4 @@ interface IKintoAppRegistry { external view returns (bool); - - /* ============ Constants and Attributes ============ */ - - /** - * @notice Returns the rate limit period - * @return The rate limit period in seconds - */ - function RATE_LIMIT_PERIOD() external view returns (uint256); - - /** - * @notice Returns the rate limit threshold - * @return The rate limit threshold - */ - function RATE_LIMIT_THRESHOLD() external view returns (uint256); - - /** - * @notice Returns the gas limit period - * @return The gas limit period in seconds - */ - function GAS_LIMIT_PERIOD() external view returns (uint256); - - /** - * @notice Returns the gas limit threshold - * @return The gas limit threshold in wei - */ - function GAS_LIMIT_THRESHOLD() external view returns (uint256); } diff --git a/test/helpers/AATestScaffolding.sol b/test/helpers/AATestScaffolding.sol index 77f82078..11191adf 100644 --- a/test/helpers/AATestScaffolding.sol +++ b/test/helpers/AATestScaffolding.sol @@ -32,6 +32,11 @@ import {SponsorPaymasterHarness} from "../harness/SponsorPaymasterHarness.sol"; import {KintoAppRegistryHarness} from "../harness/KintoAppRegistryHarness.sol"; abstract contract AATestScaffolding is SignatureHelper, StdAssertions, StdCheats { + uint256 internal constant RATE_LIMIT_PERIOD = 1 minutes; + uint256 internal constant RATE_LIMIT_THRESHOLD = 10; + uint256 internal constant GAS_LIMIT_PERIOD = 30 days; + uint256 internal constant GAS_LIMIT_THRESHOLD = 0.01 ether; + IKintoEntryPoint _entryPoint; // Kinto Registry @@ -102,12 +107,7 @@ abstract contract AATestScaffolding is SignatureHelper, StdAssertions, StdCheats // fixme: these should go through entrypoint function registerApp(address _owner, string memory name, address parentContract, address[] memory devEOAs) public { address[] memory appContracts = new address[](0); - uint256[4] memory appLimits = [ - _kintoAppRegistry.RATE_LIMIT_PERIOD(), - _kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - _kintoAppRegistry.GAS_LIMIT_PERIOD(), - _kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; registerApp(_owner, name, parentContract, appContracts, appLimits, devEOAs); } @@ -129,12 +129,7 @@ abstract contract AATestScaffolding is SignatureHelper, StdAssertions, StdCheats address[] memory appContracts, address[] memory devEOAs ) public { - uint256[4] memory appLimits = [ - _kintoAppRegistry.RATE_LIMIT_PERIOD(), - _kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - _kintoAppRegistry.GAS_LIMIT_PERIOD(), - _kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; registerApp(_owner, name, parentContract, appContracts, appLimits, devEOAs); } @@ -160,12 +155,7 @@ abstract contract AATestScaffolding is SignatureHelper, StdAssertions, StdCheats address[] memory appContracts, address[] memory devEOAs ) public { - uint256[4] memory appLimits = [ - _kintoAppRegistry.RATE_LIMIT_PERIOD(), - _kintoAppRegistry.RATE_LIMIT_THRESHOLD(), - _kintoAppRegistry.GAS_LIMIT_PERIOD(), - _kintoAppRegistry.GAS_LIMIT_THRESHOLD() - ]; + uint256[4] memory appLimits = [RATE_LIMIT_PERIOD, RATE_LIMIT_THRESHOLD, GAS_LIMIT_PERIOD, GAS_LIMIT_THRESHOLD]; vm.prank(_owner); _kintoAppRegistry.updateMetadata(name, parentContract, appContracts, appLimits, devEOAs); } diff --git a/test/unit/ContractCall.t.sol b/test/unit/ContractCall.t.sol index af5787a2..a82d7796 100644 --- a/test/unit/ContractCall.t.sol +++ b/test/unit/ContractCall.t.sol @@ -71,32 +71,12 @@ contract ContractCallTest is SharedSetup { abi.encodeWithSelector(bytes4(keccak256("withdrawTo(address,uint256)")), _user, 100); // Test withdrawStake - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user, _kintoAppRegistry.ENTRYPOINT_V6(), withdrawStakeCallData, 0 - ), - true - ); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user2, _kintoAppRegistry.ENTRYPOINT_V6(), withdrawStakeCallData, 0 - ), - false - ); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V6, withdrawStakeCallData, 0), true); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user2, ENTRYPOINT_V6, withdrawStakeCallData, 0), false); // Test withdrawTo - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user, _kintoAppRegistry.ENTRYPOINT_V7(), withdrawToCallData, 0 - ), - true - ); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user2, _kintoAppRegistry.ENTRYPOINT_V7(), withdrawToCallData, 0 - ), - false - ); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V7, withdrawToCallData, 0), true); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user2, ENTRYPOINT_V7, withdrawToCallData, 0), false); } function testIsContractCallAllowedFromEOA_WhenHandleOps() public view { @@ -105,32 +85,14 @@ contract ContractCallTest is SharedSetup { bytes memory handleOpsV7CallData = abi.encodeWithSelector(bytes4(0x765e827f), new bytes(0), beneficiary); // Test handleOps - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - beneficiary, _kintoAppRegistry.ENTRYPOINT_V6(), handleOpsCallData, 0 - ), - true - ); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user, _kintoAppRegistry.ENTRYPOINT_V6(), handleOpsCallData, 0 - ), - false - ); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(beneficiary, ENTRYPOINT_V6, handleOpsCallData, 0), true); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V6, handleOpsCallData, 0), false); // Test handleOps V7 assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - beneficiary, _kintoAppRegistry.ENTRYPOINT_V7(), handleOpsV7CallData, 0 - ), - true - ); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user, _kintoAppRegistry.ENTRYPOINT_V7(), handleOpsV7CallData, 0 - ), - false + _kintoAppRegistry.isContractCallAllowedFromEOA(beneficiary, ENTRYPOINT_V7, handleOpsV7CallData, 0), true ); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V7, handleOpsV7CallData, 0), false); bytes memory handleAggregatedOpsCallData = abi.encodeWithSelector(bytes4(0x4b1d7cf5), new bytes(0), beneficiary); bytes memory handleAggregatedOpsV7CallData = @@ -138,29 +100,20 @@ contract ContractCallTest is SharedSetup { // Test handleAggregatedOps assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - beneficiary, _kintoAppRegistry.ENTRYPOINT_V6(), handleAggregatedOpsCallData, 0 - ), + _kintoAppRegistry.isContractCallAllowedFromEOA(beneficiary, ENTRYPOINT_V6, handleAggregatedOpsCallData, 0), true ); assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user, _kintoAppRegistry.ENTRYPOINT_V6(), handleAggregatedOpsCallData, 0 - ), - false + _kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V6, handleAggregatedOpsCallData, 0), false ); // Test handleAggregatedOps V7 assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - beneficiary, _kintoAppRegistry.ENTRYPOINT_V7(), handleAggregatedOpsV7CallData, 0 - ), + _kintoAppRegistry.isContractCallAllowedFromEOA(beneficiary, ENTRYPOINT_V7, handleAggregatedOpsV7CallData, 0), true ); assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA( - _user, _kintoAppRegistry.ENTRYPOINT_V7(), handleAggregatedOpsV7CallData, 0 - ), + _kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V7, handleAggregatedOpsV7CallData, 0), false ); } @@ -169,23 +122,11 @@ contract ContractCallTest is SharedSetup { bytes memory depositCallData = abi.encodeWithSelector(bytes4(0xb760faf9), address(0x789)); bytes memory emptyCallData = new bytes(0); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA(_user, _kintoAppRegistry.ENTRYPOINT_V6(), depositCallData, 0), - false - ); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA(_user, _kintoAppRegistry.ENTRYPOINT_V6(), emptyCallData, 0), - false - ); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V6, depositCallData, 0), false); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V6, emptyCallData, 0), false); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA(_user, _kintoAppRegistry.ENTRYPOINT_V7(), depositCallData, 0), - false - ); - assertEq( - _kintoAppRegistry.isContractCallAllowedFromEOA(_user, _kintoAppRegistry.ENTRYPOINT_V7(), emptyCallData, 0), - false - ); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V7, depositCallData, 0), false); + assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user, ENTRYPOINT_V7, emptyCallData, 0), false); } function testIsContractCallAllowedFromEOA_WhenSystemContracts() public { diff --git a/test/unit/KintoAppRegistry.t.sol b/test/unit/KintoAppRegistry.t.sol index e238d1bb..6a5f0541 100644 --- a/test/unit/KintoAppRegistry.t.sol +++ b/test/unit/KintoAppRegistry.t.sol @@ -43,10 +43,6 @@ contract KintoAppRegistryTest is SharedSetup { assertEq(_kintoAppRegistry.owner(), _owner); assertEq(_kintoAppRegistry.name(), "Kinto APP"); assertEq(_kintoAppRegistry.symbol(), "KINTOAPP"); - assertEq(_kintoAppRegistry.RATE_LIMIT_PERIOD(), 1 minutes); - assertEq(_kintoAppRegistry.RATE_LIMIT_THRESHOLD(), 10); - assertEq(_kintoAppRegistry.GAS_LIMIT_PERIOD(), 30 days); - assertEq(_kintoAppRegistry.GAS_LIMIT_THRESHOLD(), 1e16); assertEq( KintoAppRegistryHarness(address(_kintoAppRegistry)).exposed_baseURI(), "https://kinto.xyz/metadata/kintoapp/" @@ -90,10 +86,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; // register app uint256 balanceBefore = _kintoAppRegistry.balanceOf(address(_kintoWallet)); @@ -214,10 +210,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; // register app vm.prank(address(_kintoWallet)); @@ -310,10 +306,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); vm.expectRevert(abi.encodeWithSelector(IKintoAppRegistry.ContractAlreadyRegistered.selector, appContract0)); @@ -332,10 +328,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; // register app vm.prank(address(_kintoWallet)); @@ -359,7 +355,6 @@ contract KintoAppRegistryTest is SharedSetup { } function testUpdateMetadata_RevertWhen_CallerIsNotDeveloper() public { - vm.prank(address(_kintoWallet)); registerApp(address(_kintoWallet), "app", address(0), new address[](0)); // update app @@ -382,10 +377,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = address(0x1234); // An address without bytecode uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); vm.expectRevert(abi.encodeWithSelector(IKintoAppRegistry.ContractHasNoBytecode.selector, address(0x1234))); @@ -490,10 +485,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -831,10 +826,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = address(0x1234); // This is the reserved contract uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); vm.expectRevert(abi.encodeWithSelector(IKintoAppRegistry.ReservedContract.selector, address(0x1234))); @@ -858,10 +853,10 @@ contract KintoAppRegistryTest is SharedSetup { appContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -938,10 +933,10 @@ contract KintoAppRegistryTest is SharedSetup { initialContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -984,10 +979,10 @@ contract KintoAppRegistryTest is SharedSetup { initialContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -1017,10 +1012,10 @@ contract KintoAppRegistryTest is SharedSetup { initialContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -1048,10 +1043,10 @@ contract KintoAppRegistryTest is SharedSetup { initialContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -1085,10 +1080,10 @@ contract KintoAppRegistryTest is SharedSetup { initialContracts[2] = sponsorContract1; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -1129,10 +1124,10 @@ contract KintoAppRegistryTest is SharedSetup { initialContracts[1] = sponsorContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( @@ -1162,10 +1157,10 @@ contract KintoAppRegistryTest is SharedSetup { initialContracts[0] = appContract0; uint256[] memory appLimits = new uint256[](4); - appLimits[0] = _kintoAppRegistry.RATE_LIMIT_PERIOD(); - appLimits[1] = _kintoAppRegistry.RATE_LIMIT_THRESHOLD(); - appLimits[2] = _kintoAppRegistry.GAS_LIMIT_PERIOD(); - appLimits[3] = _kintoAppRegistry.GAS_LIMIT_THRESHOLD(); + appLimits[0] = RATE_LIMIT_PERIOD; + appLimits[1] = RATE_LIMIT_THRESHOLD; + appLimits[2] = GAS_LIMIT_PERIOD; + appLimits[3] = GAS_LIMIT_THRESHOLD; vm.prank(address(_kintoWallet)); _kintoAppRegistry.registerApp( diff --git a/test/unit/SponsorPaymaster.t.sol b/test/unit/SponsorPaymaster.t.sol index a59f28ce..f60e3379 100644 --- a/test/unit/SponsorPaymaster.t.sol +++ b/test/unit/SponsorPaymaster.t.sol @@ -386,8 +386,8 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = [ _paymaster.RATE_LIMIT_PERIOD() + 1, _paymaster.RATE_LIMIT_THRESHOLD_TOTAL() + 1, - _kintoAppRegistry.GAS_LIMIT_PERIOD(), - _kintoAppRegistry.GAS_LIMIT_THRESHOLD() + GAS_LIMIT_PERIOD, + GAS_LIMIT_THRESHOLD ]; updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); @@ -408,8 +408,8 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = [ _paymaster.RATE_LIMIT_PERIOD() + 1, _paymaster.RATE_LIMIT_THRESHOLD_TOTAL() + 1, - _kintoAppRegistry.GAS_LIMIT_PERIOD(), - _kintoAppRegistry.GAS_LIMIT_THRESHOLD() + GAS_LIMIT_PERIOD, + GAS_LIMIT_THRESHOLD ]; updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); @@ -435,8 +435,8 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = [ _paymaster.RATE_LIMIT_PERIOD() + 1, _paymaster.RATE_LIMIT_THRESHOLD_TOTAL() + 1, - _kintoAppRegistry.GAS_LIMIT_PERIOD(), - _kintoAppRegistry.GAS_LIMIT_THRESHOLD() + GAS_LIMIT_PERIOD, + GAS_LIMIT_THRESHOLD ]; updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); @@ -452,8 +452,8 @@ contract SponsorPaymasterTest is SharedSetup { uint256[4] memory appLimits = [ _paymaster.RATE_LIMIT_PERIOD() + 1, _paymaster.RATE_LIMIT_THRESHOLD_TOTAL() + 1, - _kintoAppRegistry.GAS_LIMIT_PERIOD(), - _kintoAppRegistry.GAS_LIMIT_THRESHOLD() + GAS_LIMIT_PERIOD, + GAS_LIMIT_THRESHOLD ]; updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); @@ -530,7 +530,7 @@ contract SponsorPaymasterTest is SharedSetup { /// fixme: once _setOperationCount works fine, refactor and use _setOperationCount; /// @dev create app with high app limits and low gas limit so we assert that the one used // in the test is the gas limit - uint256[4] memory appLimits = [100e18, 100e18, _kintoAppRegistry.GAS_LIMIT_PERIOD(), 1 wei]; + uint256[4] memory appLimits = [100e18, 100e18, GAS_LIMIT_PERIOD, 1 wei]; updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); // execute transactions (with one user op per tx) one by one until reaching the gas limit @@ -549,7 +549,7 @@ contract SponsorPaymasterTest is SharedSetup { /// fixme: once _setOperationCount works fine, refactor and use _setOperationCount; /// @dev create app with high app limits and low gas limit so we assert that the one used // in the test is the gas limit - uint256[4] memory appLimits = [100e18, 100e18, _kintoAppRegistry.GAS_LIMIT_PERIOD(), 1 wei]; + uint256[4] memory appLimits = [100e18, 100e18, GAS_LIMIT_PERIOD, 1 wei]; updateMetadata(address(_kintoWallet), "counter", address(counter), appLimits, new address[](0)); // execute transactions until reaching gas limit and save the amount of apps that reached the threshold