Files
openzeppelin-contracts/scripts/generate/templates/EnumerableMap.opts.js
Hadrien Croubois a5c4cd8182 Add new EnumerableMap types (#4843)
Co-authored-by: ernestognw <ernestognw@gmail.com>
2024-01-22 19:25:01 +00:00

20 lines
528 B
JavaScript

const { capitalize } = require('../../helpers');
const mapType = str => (str == 'uint256' ? 'Uint' : capitalize(str));
const formatType = (keyType, valueType) => ({
name: `${mapType(keyType)}To${mapType(valueType)}Map`,
keyType,
valueType,
});
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,
formatType,
};