From ac96452f13fa84b21e75bfe54d545a958316198d Mon Sep 17 00:00:00 2001 From: Filipp Makarov Date: Tue, 24 Sep 2024 12:35:05 +0300 Subject: [PATCH] lint --- contracts/base/ModuleManager.sol | 3 +- contracts/modules/validators/K1Validator.sol | 41 +- contracts/utils/AssociatedArrayLib.sol | 276 ------------- contracts/utils/EnumerableSet4337.sol | 371 ------------------ .../concrete/modules/TestK1Validator.t.sol | 1 + 5 files changed, 21 insertions(+), 671 deletions(-) delete mode 100644 contracts/utils/AssociatedArrayLib.sol delete mode 100644 contracts/utils/EnumerableSet4337.sol diff --git a/contracts/base/ModuleManager.sol b/contracts/base/ModuleManager.sol index 3f8d62f6..835bb0fc 100644 --- a/contracts/base/ModuleManager.sol +++ b/contracts/base/ModuleManager.sol @@ -21,9 +21,8 @@ import { IValidator } from "../interfaces/modules/IValidator.sol"; import { CallType, CALLTYPE_SINGLE, CALLTYPE_STATIC } from "../lib/ModeLib.sol"; import { LocalCallDataParserLib } from "../lib/local/LocalCallDataParserLib.sol"; import { IModuleManagerEventsAndErrors } from "../interfaces/base/IModuleManagerEventsAndErrors.sol"; -import { MODULE_TYPE_VALIDATOR, MODULE_TYPE_EXECUTOR, MODULE_TYPE_FALLBACK, MODULE_TYPE_HOOK, MODULE_TYPE_MULTI, MODULE_ENABLE_MODE_TYPE_HASH, ERC1271_MAGICVALUE, SUPPORTS_NESTED_TYPED_DATA_SIGN } from "contracts/types/Constants.sol"; +import { MODULE_TYPE_VALIDATOR, MODULE_TYPE_EXECUTOR, MODULE_TYPE_FALLBACK, MODULE_TYPE_HOOK, MODULE_TYPE_MULTI, MODULE_ENABLE_MODE_TYPE_HASH, ERC1271_MAGICVALUE } from "contracts/types/Constants.sol"; import { RegistryAdapter } from "./RegistryAdapter.sol"; -import { IERC7739 } from "../interfaces/IERC7739.sol"; import { EIP712 } from "solady/src/utils/EIP712.sol"; import { ExcessivelySafeCall } from "excessively-safe-call/src/ExcessivelySafeCall.sol"; import { SentinelListLib } from "sentinellist/src/SentinelList.sol"; diff --git a/contracts/modules/validators/K1Validator.sol b/contracts/modules/validators/K1Validator.sol index 1c0ba53c..c5168ecb 100644 --- a/contracts/modules/validators/K1Validator.sol +++ b/contracts/modules/validators/K1Validator.sol @@ -1,10 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.23; +pragma solidity ^0.8.27; import { ERC7739Validator } from "../../base/ERC7739Validator.sol"; import { IValidator } from "../../interfaces/modules/IValidator.sol"; import { EnumerableSet } from "enumerableset4337/EnumerableSet4337.sol"; -import { ERC1271_MAGICVALUE, ERC1271_INVALID } from "../../../contracts/types/Constants.sol"; import { MODULE_TYPE_VALIDATOR, VALIDATION_SUCCESS, VALIDATION_FAILED } from "../../../contracts/types/Constants.sol"; import { SignatureCheckerLib } from "solady/src/utils/SignatureCheckerLib.sol"; import { PackedUserOperation } from "account-abstraction/contracts/interfaces/PackedUserOperation.sol"; @@ -34,7 +33,7 @@ contract K1Validator is IValidator, ERC7739Validator { /// @notice Mapping of smart account addresses to their respective owner addresses mapping(address => address) public smartAccountOwners; - EnumerableSet.AddressSet private safeSenders; + EnumerableSet.AddressSet private _safeSenders; /// @notice Error to indicate that no owner was provided during installation error NoOwnerProvided(); @@ -74,12 +73,18 @@ contract K1Validator is IValidator, ERC7739Validator { /** * De-initialize the module with the given data - * - * @param data The data to de-initialize the module with */ - function onUninstall(bytes calldata data) external override { + function onUninstall(bytes calldata) external override { delete smartAccountOwners[msg.sender]; - safeSenders.removeAll(msg.sender); + _safeSenders.removeAll(msg.sender); + } + + /// @notice Transfers ownership of the validator to a new owner + /// @param newOwner The address of the new owner + function transferOwnership(address newOwner) external { + require(newOwner != address(0), ZeroAddressNotAllowed()); + require(!_isContract(newOwner), NewOwnerIsContract()); + smartAccountOwners[msg.sender] = newOwner; } /** @@ -92,14 +97,6 @@ contract K1Validator is IValidator, ERC7739Validator { return _isInitialized(smartAccount); } - /// @notice Transfers ownership of the validator to a new owner - /// @param newOwner The address of the new owner - function transferOwnership(address newOwner) external { - require(newOwner != address(0), ZeroAddressNotAllowed()); - require(!_isContract(newOwner), NewOwnerIsContract()); - smartAccountOwners[msg.sender] = newOwner; - } - /*////////////////////////////////////////////////////////////////////////// MODULE LOGIC //////////////////////////////////////////////////////////////////////////*/ @@ -162,14 +159,14 @@ contract K1Validator is IValidator, ERC7739Validator { return _validateSignatureForOwner(owner, hash, sig); } - /// @notice Adds a safe sender to the safeSenders list for the smart account + /// @notice Adds a safe sender to the _safeSenders list for the smart account function addSafeSender(address sender) external { - safeSenders.add(msg.sender, sender); + _safeSenders.add(msg.sender, sender); } - /// @notice Removes a safe sender from the safeSenders list for the smart account + /// @notice Removes a safe sender from the _safeSenders list for the smart account function removeSafeSender(address sender) external { - safeSenders.remove(msg.sender, sender); + _safeSenders.remove(msg.sender, sender); } /*////////////////////////////////////////////////////////////////////////// @@ -201,7 +198,7 @@ contract K1Validator is IValidator, ERC7739Validator { return ( sender == 0x000000000000D9ECebf3C23529de49815Dac1c4c || // MulticallerWithSigner sender == msg.sender || // Smart Account. Assume smart account never sends non safe eip-712 struct - safeSenders.contains(msg.sender, sender) // check if sender is in safeSenders for the Smart Account + _safeSenders.contains(msg.sender, sender) // check if sender is in _safeSenders for the Smart Account ); } @@ -247,10 +244,10 @@ contract K1Validator is IValidator, ERC7739Validator { return size > 0; } - // @notice Fills the safeSenders list from the given data + // @notice Fills the _safeSenders list from the given data function _fillSafeSenders(bytes calldata data) private { for (uint256 i; i < data.length / 20; i++) { - safeSenders.add(msg.sender, address(bytes20(data[20*i:20*(i+1)]))); + _safeSenders.add(msg.sender, address(bytes20(data[20*i:20*(i+1)]))); } } diff --git a/contracts/utils/AssociatedArrayLib.sol b/contracts/utils/AssociatedArrayLib.sol deleted file mode 100644 index 20d928d3..00000000 --- a/contracts/utils/AssociatedArrayLib.sol +++ /dev/null @@ -1,276 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -library AssociatedArrayLib { - using AssociatedArrayLib for *; - - error AssociatedArray_OutOfBounds(uint256 index); - - struct Array { - uint256 _spacer; - } - - function _slot(Array storage s, address account) private pure returns (bytes32 __slot) { - assembly { - mstore(0x00, account) - mstore(0x20, s.slot) - __slot := keccak256(0x00, 0x40) - } - } - - function _length(Array storage s, address account) private view returns (uint256 __length) { - bytes32 slot = _slot(s, account); - assembly { - __length := sload(slot) - } - } - - function _get(Array storage s, address account, uint256 index) private view returns (bytes32 value) { - return _get(_slot(s, account), index); - } - - function _get(bytes32 slot, uint256 index) private view returns (bytes32 value) { - assembly { - //if (index >= _length(s, account)) revert AssociatedArray_OutOfBounds(index); - if iszero(lt(index, sload(slot))) { - mstore(0, 0x8277484f) // `AssociatedArray_OutOfBounds(uint256)` - mstore(0x20, index) - revert(0x1c, 0x24) - } - value := sload(add(slot, mul(0x20, add(index, 1)))) - } - } - - function _getAll(Array storage s, address account) private view returns (bytes32[] memory values) { - bytes32 slot = _slot(s, account); - uint256 __length; - assembly { - __length := sload(slot) - } - values = new bytes32[](__length); - for (uint256 i; i < __length; i++) { - values[i] = _get(slot, i); - } - } - - // inefficient. complexity = O(n) - // use with caution - // in case of large arrays, consider using EnumerableSet4337 instead - function _contains(Array storage s, address account, bytes32 value) private view returns (bool) { - bytes32 slot = _slot(s, account); - uint256 __length; - assembly { - __length := sload(slot) - } - for (uint256 i; i < __length; i++) { - if (_get(slot, i) == value) { - return true; - } - } - return false; - } - - function _set(Array storage s, address account, uint256 index, bytes32 value) private { - _set(_slot(s, account), index, value); - } - - function _set(bytes32 slot, uint256 index, bytes32 value) private { - assembly { - //if (index >= _length(s, account)) revert AssociatedArray_OutOfBounds(index); - if iszero(lt(index, sload(slot))) { - mstore(0, 0x8277484f) // `AssociatedArray_OutOfBounds(uint256)` - mstore(0x20, index) - revert(0x1c, 0x24) - } - sstore(add(slot, mul(0x20, add(index, 1))), value) - } - } - - function _push(Array storage s, address account, bytes32 value) private { - bytes32 slot = _slot(s, account); - assembly { - // load length (stored @ slot), add 1 to it => index. - // mul index by 0x20 and add it to orig slot to get the next free slot - let index := add(sload(slot), 1) - sstore(add(slot, mul(0x20, index)), value) - sstore(slot, index) //increment length by 1 - } - } - - function _pop(Array storage s, address account) private { - bytes32 slot = _slot(s, account); - uint256 __length; - assembly { - __length := sload(slot) - } - if (__length == 0) return; - _set(slot, __length - 1, 0); - assembly { - sstore(slot, sub(__length, 1)) - } - } - - function _remove(Array storage s, address account, uint256 index) private { - bytes32 slot = _slot(s, account); - uint256 __length; - assembly { - __length := sload(slot) - if iszero(lt(index, __length)) { - mstore(0, 0x8277484f) // `AssociatedArray_OutOfBounds(uint256)` - mstore(0x20, index) - revert(0x1c, 0x24) - } - } - _set(slot, index, _get(s, account, __length - 1)); - - assembly { - // clear the last slot - // this is the 'unchecked' version of _set(slot, __length - 1, 0) - // as we use length-1 as index, so the check is excessive. - // also removes extra -1 and +1 operations - sstore(add(slot, mul(0x20, __length)), 0) - // store new length - sstore(slot, sub(__length, 1)) - } - } - - struct Bytes32Array { - Array _inner; - } - - function length(Bytes32Array storage s, address account) internal view returns (uint256) { - return _length(s._inner, account); - } - - function get(Bytes32Array storage s, address account, uint256 index) internal view returns (bytes32) { - return _get(s._inner, account, index); - } - - function getAll(Bytes32Array storage s, address account) internal view returns (bytes32[] memory) { - return _getAll(s._inner, account); - } - - function contains(Bytes32Array storage s, address account, bytes32 value) internal view returns (bool) { - return _contains(s._inner, account, value); - } - - function add(Bytes32Array storage s, address account, bytes32 value) internal { - if (!_contains(s._inner, account, value)) { - _push(s._inner, account, value); - } - } - - function set(Bytes32Array storage s, address account, uint256 index, bytes32 value) internal { - _set(s._inner, account, index, value); - } - - function push(Bytes32Array storage s, address account, bytes32 value) internal { - _push(s._inner, account, value); - } - - function pop(Bytes32Array storage s, address account) internal { - _pop(s._inner, account); - } - - function remove(Bytes32Array storage s, address account, uint256 index) internal { - _remove(s._inner, account, index); - } - - struct AddressArray { - Array _inner; - } - - function length(AddressArray storage s, address account) internal view returns (uint256) { - return _length(s._inner, account); - } - - function get(AddressArray storage s, address account, uint256 index) internal view returns (address) { - return address(uint160(uint256(_get(s._inner, account, index)))); - } - - function getAll(AddressArray storage s, address account) internal view returns (address[] memory) { - bytes32[] memory bytes32Array = _getAll(s._inner, account); - address[] memory addressArray; - - /// @solidity memory-safe-assembly - assembly { - addressArray := bytes32Array - } - return addressArray; - } - - function contains(AddressArray storage s, address account, address value) internal view returns (bool) { - return _contains(s._inner, account, bytes32(uint256(uint160(value)))); - } - - function add(AddressArray storage s, address account, address value) internal { - if (!_contains(s._inner, account, bytes32(uint256(uint160(value))))) { - _push(s._inner, account, bytes32(uint256(uint160(value)))); - } - } - - function set(AddressArray storage s, address account, uint256 index, address value) internal { - _set(s._inner, account, index, bytes32(uint256(uint160(value)))); - } - - function push(AddressArray storage s, address account, address value) internal { - _push(s._inner, account, bytes32(uint256(uint160(value)))); - } - - function pop(AddressArray storage s, address account) internal { - _pop(s._inner, account); - } - - function remove(AddressArray storage s, address account, uint256 index) internal { - _remove(s._inner, account, index); - } - - struct UintArray { - Array _inner; - } - - function length(UintArray storage s, address account) internal view returns (uint256) { - return _length(s._inner, account); - } - - function get(UintArray storage s, address account, uint256 index) internal view returns (uint256) { - return uint256(_get(s._inner, account, index)); - } - - function getAll(UintArray storage s, address account) internal view returns (uint256[] memory) { - bytes32[] memory bytes32Array = _getAll(s._inner, account); - uint256[] memory uintArray; - - /// @solidity memory-safe-assembly - assembly { - uintArray := bytes32Array - } - return uintArray; - } - - function contains(UintArray storage s, address account, uint256 value) internal view returns (bool) { - return _contains(s._inner, account, bytes32(value)); - } - - function add(UintArray storage s, address account, uint256 value) internal { - if (!_contains(s._inner, account, bytes32(value))) { - _push(s._inner, account, bytes32(value)); - } - } - - function set(UintArray storage s, address account, uint256 index, uint256 value) internal { - _set(s._inner, account, index, bytes32(value)); - } - - function push(UintArray storage s, address account, uint256 value) internal { - _push(s._inner, account, bytes32(value)); - } - - function pop(UintArray storage s, address account) internal { - _pop(s._inner, account); - } - - function remove(UintArray storage s, address account, uint256 index) internal { - _remove(s._inner, account, index); - } -} diff --git a/contracts/utils/EnumerableSet4337.sol b/contracts/utils/EnumerableSet4337.sol deleted file mode 100644 index ad62b37f..00000000 --- a/contracts/utils/EnumerableSet4337.sol +++ /dev/null @@ -1,371 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.20; - -import "./AssociatedArrayLib.sol"; - -/** - * Fork of OZ's EnumerableSet that makes all storage access ERC-4337 compliant via associated storage - * @author zeroknots.eth (rhinestone) - */ -library EnumerableSet { - using AssociatedArrayLib for AssociatedArrayLib.Bytes32Array; - // To implement this library for multiple types with as little code - // repetition as possible, we write it in terms of a generic Set type with - // bytes32 values. - // The Set implementation uses private functions, and user-facing - // implementations (such as AddressSet) are just wrappers around the - // underlying Set. - // This means that we can only create new EnumerableSets for types that fit - // in bytes32. - - struct Set { - // Storage of set values - AssociatedArrayLib.Bytes32Array _values; - // Position is the index of the value in the `values` array plus 1. - // Position 0 is used to mean a value is not in the set. - mapping(bytes32 value => mapping(address account => uint256)) _positions; - } - - /** - * @dev Add a value to a set. O(1). - * - * Returns true if the value was added to the set, that is if it was not - * already present. - */ - function _add(Set storage set, address account, bytes32 value) private returns (bool) { - if (!_contains(set, account, value)) { - set._values.push(account, value); - // The value is stored at length-1, but we add 1 to all indexes - // and use 0 as a sentinel value - set._positions[value][account] = set._values.length(account); - return true; - } else { - return false; - } - } - - /** - * @dev Removes a value from a set. O(1). - * - * Returns true if the value was removed from the set, that is if it was - * present. - */ - function _remove(Set storage set, address account, bytes32 value) private returns (bool) { - // We cache the value's position to prevent multiple reads from the same storage slot - uint256 position = set._positions[value][account]; - - if (position != 0) { - // Equivalent to contains(set, value) - // To delete an element from the _values array in O(1), we swap the element to delete with the last one in - // the array, and then remove the last element (sometimes called as 'swap and pop'). - // This modifies the order of the array, as noted in {at}. - - uint256 valueIndex = position - 1; - uint256 lastIndex = set._values.length(account) - 1; - - if (valueIndex != lastIndex) { - bytes32 lastValue = set._values.get(account, lastIndex); - - // Move the lastValue to the index where the value to delete is - set._values.set(account, valueIndex, lastValue); - // Update the tracked position of the lastValue (that was just moved) - set._positions[lastValue][account] = position; - } - - // Delete the slot where the moved value was stored - set._values.pop(account); - - // Delete the tracked position for the deleted slot - delete set._positions[value][account]; - - return true; - } else { - return false; - } - } - - function _removeAll(Set storage set, address account) internal { - // get length of the array - uint256 len = _length(set, account); - for (uint256 i = 1; i <= len; i++) { - // get last value - bytes32 value = _at(set, account, len - i); - _remove(set, account, value); - } - } - - /** - * @dev Returns true if the value is in the set. O(1). - */ - function _contains(Set storage set, address account, bytes32 value) private view returns (bool) { - return set._positions[value][account] != 0; - } - - /** - * @dev Returns the number of values on the set. O(1). - */ - function _length(Set storage set, address account) private view returns (uint256) { - return set._values.length(account); - } - - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ - function _at(Set storage set, address account, uint256 index) private view returns (bytes32) { - return set._values.get(account, index); - } - - /** - * @dev Return the entire set in an array - * - * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed - * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that - * this function has an unbounded cost, and using it as part of a state-changing function may render the function - * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. - */ - function _values(Set storage set, address account) private view returns (bytes32[] memory) { - return set._values.getAll(account); - } - - // Bytes32Set - - struct Bytes32Set { - Set _inner; - } - - /** - * @dev Add a value to a set. O(1). - * - * Returns true if the value was added to the set, that is if it was not - * already present. - */ - function add(Bytes32Set storage set, address account, bytes32 value) internal returns (bool) { - return _add(set._inner, account, value); - } - - /** - * @dev Removes a value from a set. O(1). - * - * Returns true if the value was removed from the set, that is if it was - * present. - */ - function remove(Bytes32Set storage set, address account, bytes32 value) internal returns (bool) { - return _remove(set._inner, account, value); - } - - function removeAll(Bytes32Set storage set, address account) internal { - return _removeAll(set._inner, account); - } - - /** - * @dev Returns true if the value is in the set. O(1). - */ - function contains(Bytes32Set storage set, address account, bytes32 value) internal view returns (bool) { - return _contains(set._inner, account, value); - } - - /** - * @dev Returns the number of values in the set. O(1). - */ - function length(Bytes32Set storage set, address account) internal view returns (uint256) { - return _length(set._inner, account); - } - - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ - function at(Bytes32Set storage set, address account, uint256 index) internal view returns (bytes32) { - return _at(set._inner, account, index); - } - - /** - * @dev Return the entire set in an array - * - * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed - * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that - * this function has an unbounded cost, and using it as part of a state-changing function may render the function - * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. - */ - function values(Bytes32Set storage set, address account) internal view returns (bytes32[] memory) { - bytes32[] memory store = _values(set._inner, account); - bytes32[] memory result; - - /// @solidity memory-safe-assembly - assembly { - result := store - } - - return result; - } - - // AddressSet - - struct AddressSet { - Set _inner; - } - - /** - * @dev Add a value to a set. O(1). - * - * Returns true if the value was added to the set, that is if it was not - * already present. - */ - function add(AddressSet storage set, address account, address value) internal returns (bool) { - return _add(set._inner, account, bytes32(uint256(uint160(value)))); - } - - /** - * @dev Removes a value from a set. O(1). - * - * Returns true if the value was removed from the set, that is if it was - * present. - */ - function remove(AddressSet storage set, address account, address value) internal returns (bool) { - return _remove(set._inner, account, bytes32(uint256(uint160(value)))); - } - - function removeAll(AddressSet storage set, address account) internal { - return _removeAll(set._inner, account); - } - - /** - * @dev Returns true if the value is in the set. O(1). - */ - function contains(AddressSet storage set, address account, address value) internal view returns (bool) { - return _contains(set._inner, account, bytes32(uint256(uint160(value)))); - } - - /** - * @dev Returns the number of values in the set. O(1). - */ - function length(AddressSet storage set, address account) internal view returns (uint256) { - return _length(set._inner, account); - } - - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ - function at(AddressSet storage set, address account, uint256 index) internal view returns (address) { - return address(uint160(uint256(_at(set._inner, account, index)))); - } - - /** - * @dev Return the entire set in an array - * - * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed - * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that - * this function has an unbounded cost, and using it as part of a state-changing function may render the function - * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. - */ - function values(AddressSet storage set, address account) internal view returns (address[] memory) { - bytes32[] memory store = _values(set._inner, account); - address[] memory result; - - /// @solidity memory-safe-assembly - assembly { - result := store - } - - return result; - } - - // UintSet - - struct UintSet { - Set _inner; - } - - /** - * @dev Add a value to a set. O(1). - * - * Returns true if the value was added to the set, that is if it was not - * already present. - */ - function add(UintSet storage set, address account, uint256 value) internal returns (bool) { - return _add(set._inner, account, bytes32(value)); - } - - /** - * @dev Removes a value from a set. O(1). - * - * Returns true if the value was removed from the set, that is if it was - * present. - */ - function remove(UintSet storage set, address account, uint256 value) internal returns (bool) { - return _remove(set._inner, account, bytes32(value)); - } - - function removeAll(UintSet storage set, address account) internal { - return _removeAll(set._inner, account); - } - - /** - * @dev Returns true if the value is in the set. O(1). - */ - function contains(UintSet storage set, address account, uint256 value) internal view returns (bool) { - return _contains(set._inner, account, bytes32(value)); - } - - /** - * @dev Returns the number of values in the set. O(1). - */ - function length(UintSet storage set, address account) internal view returns (uint256) { - return _length(set._inner, account); - } - - /** - * @dev Returns the value stored at position `index` in the set. O(1). - * - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ - function at(UintSet storage set, address account, uint256 index) internal view returns (uint256) { - return uint256(_at(set._inner, account, index)); - } - - /** - * @dev Return the entire set in an array - * - * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed - * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that - * this function has an unbounded cost, and using it as part of a state-changing function may render the function - * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. - */ - function values(UintSet storage set, address account) internal view returns (uint256[] memory) { - bytes32[] memory store = _values(set._inner, account); - uint256[] memory result; - - /// @solidity memory-safe-assembly - assembly { - result := store - } - - return result; - } -} diff --git a/test/foundry/unit/concrete/modules/TestK1Validator.t.sol b/test/foundry/unit/concrete/modules/TestK1Validator.t.sol index 70bbc992..6cdf5883 100644 --- a/test/foundry/unit/concrete/modules/TestK1Validator.t.sol +++ b/test/foundry/unit/concrete/modules/TestK1Validator.t.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import "../../../utils/Imports.sol"; import "../../../utils/NexusTest_Base.t.sol"; +import { ERC1271_MAGICVALUE, ERC1271_INVALID } from "contracts/types/Constants.sol"; /// @title TestK1Validator /// @notice Unit tests for the K1Validator contract