You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever a new value of a unique type is created, we need to dynamically check to ensure that it has not been created before. To do this, we should:
Implement hashing of every kind of base type (could be done by generating helper functions or just generating the hashing code inline). We should use abi.encodePacked for this (see this). Note that this will be very costly for maps and arrays; that is fine, because we want to ensure that uniqueness is properly handled, even at the cost of performance. We should consider adding a warning for this in the future (see Warn on expensive unique types #23).
Add a mapping (bytes32 => bool) as a field of the contract for every unique type T.
Whenever a new value of T is created: hash it, check if it's in the map, and throw an error if so, otherwise, add it to the map.
Whenever a new value of a
uniquetype is created, we need to dynamically check to ensure that it has not been created before. To do this, we should:abi.encodePackedfor this (see this). Note that this will be very costly for maps and arrays; that is fine, because we want to ensure that uniqueness is properly handled, even at the cost of performance. We should consider adding a warning for this in the future (see Warn on expensiveuniquetypes #23).mapping (bytes32 => bool)as a field of the contract for everyuniquetypeT.Tis created: hash it, check if it's in the map, and throw an error if so, otherwise, add it to the map.