Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement try_get detector for mappings #62

Closed
matiascabello opened this issue Dec 19, 2023 · 0 comments · Fixed by #152
Closed

Implement try_get detector for mappings #62

matiascabello opened this issue Dec 19, 2023 · 0 comments · Fixed by #152

Comments

@matiascabello
Copy link
Collaborator

matiascabello commented Dec 19, 2023

Description

The method get or the following variants might cause the contract to panic on a Map:

  • get panics if the value corresponding to the key cannot be converted to type V.
  • get_unchecked panics if the map does not contain a value with the specified key or if the value corresponding to the key cannot be converted to type V
  • try_get_unchecked panics if the map does not contain a value with the specified key.

When using externally provided Maps as contract function arguments, there's no guarantee that entries will match the expected key (K) and value (V) types. To ensure type safety and avoid runtime errors, validate all entries before storage or when accessing them using try_ variant.

@matiascabello matiascabello added this to the Prototype milestone Dec 19, 2023
@jgcrosta jgcrosta assigned jgcrosta and unassigned faculerena Apr 18, 2024
@jgcrosta jgcrosta changed the title try_insert Implement try_get detector for mappings Apr 18, 2024
@matiascabello matiascabello removed this from the Prototype milestone Apr 19, 2024
@jgcrosta jgcrosta linked a pull request Apr 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants