Skip to content

Custom types for commonly used structures #2396

@cicr99

Description

@cicr99

There are some places in the code where structures such as map[felt.Felt]map[felt.Felt]*felt.Felt to refer to StorageDiff or map[felt.Felt]*felt.Felt to refer to others like DeployedContracts, are used.
We could define instead a custom type like:

type StorageDiff map[felt.Felt]map[felt.Felt]*felt.Felt

Or consider creating types such as Address or ClassHash for felts, so DeployedContracts map would look like map[Address]ClassHash.

This will allow the code to be more readable and easier to work with (when creating new structures or passing them as arguments in functions). It would also make it safer as you restrict the specific type that must be used (not just any felt for example), and it even allows to create methods on top of these structures.

Check out these two comments for reference:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions