Add new EnumerableMap types (#4843)

Co-authored-by: ernestognw <ernestognw@gmail.com>
This commit is contained in:
Hadrien Croubois
2024-01-22 20:25:01 +01:00
committed by GitHub
parent e5c63635e3
commit a5c4cd8182
6 changed files with 417 additions and 52 deletions

View File

@ -36,6 +36,10 @@ import {EnumerableSet} from "./EnumerableSet.sol";
* - \`bytes32 -> bytes32\` (\`Bytes32ToBytes32Map\`) since v4.6.0
* - \`uint256 -> uint256\` (\`UintToUintMap\`) since v4.7.0
* - \`bytes32 -> uint256\` (\`Bytes32ToUintMap\`) since v4.7.0
* - \`uint256 -> bytes32\` (\`UintToBytes32Map\`) since v5.1.0
* - \`address -> address\` (\`AddressToAddressMap\`) since v5.1.0
* - \`address -> bytes32\` (\`AddressToBytes32Map\`) since v5.1.0
* - \`bytes32 -> address\` (\`Bytes32ToAddressMap\`) since v5.1.0
*
* [WARNING]
* ====

View File

@ -8,12 +8,10 @@ const formatType = (keyType, valueType) => ({
valueType,
});
const TYPES = [
['uint256', 'uint256'],
['uint256', 'address'],
['address', 'uint256'],
['bytes32', 'uint256'],
].map(args => formatType(...args));
const TYPES = ['uint256', 'address', 'bytes32']
.flatMap((key, _, array) => array.map(value => [key, value]))
.slice(0, -1) // remove bytes32 → byte32 (last one) that is already defined
.map(args => formatType(...args));
module.exports = {
TYPES,