diff --git a/foundry.toml b/foundry.toml index f5477b4..b2ab783 100644 --- a/foundry.toml +++ b/foundry.toml @@ -10,7 +10,7 @@ out = "out" script = "script" solc = "0.8.26" - src = "contracts" + src = "src" test = "test" cache_path = "cache_forge" libs = ["node_modules", "lib"] @@ -18,13 +18,13 @@ [fmt] - bracket_spacing = true - int_types = "long" - line_length = 120 - multiline_func_header = "all" - number_underscore = "thousands" - quote_style = "double" - tab_width = 4 - wrap_comments = true +bracket_spacing = true +int_types = "long" +line_length = 120 +multiline_func_header = "all" +number_underscore = "thousands" +quote_style = "double" +tab_width = 4 +wrap_comments = true # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/src/AssociatedArrayLib.sol b/src/AssociatedArrayLib.sol index 851cc42..9119789 100644 --- a/src/AssociatedArrayLib.sol +++ b/src/AssociatedArrayLib.sol @@ -19,6 +19,7 @@ library AssociatedArrayLib { } function _get(Array storage s, address account, uint256 index) private view returns (bytes32 value) { + if (index >= _length(s, account)) revert AssociatedArray_OutOfBounds(index); assembly { mstore(0x00, account) mstore(0x20, s.slot) diff --git a/src/EnumerableMap.sol b/src/EnumerableMap.sol index 8e53cc1..b2cce53 100644 --- a/src/EnumerableMap.sol +++ b/src/EnumerableMap.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; -import {EnumerableSet} from "./EnumerableSet.sol"; +import { EnumerableSet } from "./EnumerableSet.sol"; /** * Fork of OZ's EnumerableSet that makes all storage access ERC-4337 compliant via associated storage @@ -73,7 +73,12 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(Bytes32ToBytes32Map storage map, address account, bytes32 key, bytes32 value) + function set( + Bytes32ToBytes32Map storage map, + address account, + bytes32 key, + bytes32 value + ) internal returns (bool) { @@ -115,7 +120,11 @@ library EnumerableMap { * * - `index` must be strictly less than {length}. */ - function at(Bytes32ToBytes32Map storage map, address account, uint256 index) + function at( + Bytes32ToBytes32Map storage map, + address account, + uint256 index + ) internal view returns (bytes32, bytes32) @@ -128,7 +137,11 @@ library EnumerableMap { * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ - function tryGet(Bytes32ToBytes32Map storage map, address account, bytes32 key) + function tryGet( + Bytes32ToBytes32Map storage map, + address account, + bytes32 key + ) internal view returns (bool, bytes32) @@ -311,7 +324,11 @@ library EnumerableMap { * * - `index` must be strictly less than {length}. */ - function at(UintToAddressMap storage map, address account, uint256 index) + function at( + UintToAddressMap storage map, + address account, + uint256 index + ) internal view returns (uint256, address) @@ -409,7 +426,11 @@ library EnumerableMap { * * - `index` must be strictly less than {length}. */ - function at(AddressToUintMap storage map, address account, uint256 index) + function at( + AddressToUintMap storage map, + address account, + uint256 index + ) internal view returns (address, uint256) @@ -507,7 +528,11 @@ library EnumerableMap { * * - `index` must be strictly less than {length}. */ - function at(Bytes32ToUintMap storage map, address account, uint256 index) + function at( + Bytes32ToUintMap storage map, + address account, + uint256 index + ) internal view returns (bytes32, uint256)