Skip to content

Add uniqueness checking #21

@ReedOei

Description

@ReedOei

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:

  1. 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).
  2. Add a mapping (bytes32 => bool) as a field of the contract for every unique type T.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions