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

Add has to Path and Map #322

Merged
merged 2 commits into from
Jul 12, 2021
Merged

Add has to Path and Map #322

merged 2 commits into from
Jul 12, 2021

Conversation

ethanfrey
Copy link
Member

Closes #261

@ethanfrey ethanfrey requested a review from maurolacy July 12, 2021 16:50
Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

let key = TOKENS.key(&token_id);
if deps.storage.get(&key).is_none() {
key.save(deps.storage, &"".to_owned())?;
if !TOKENS.has(deps.storage, &token_id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When writing tests I found out the (untested) case would actually panic.
If you attempt to write b"" to the db.

(Which we added to avoid getting confusing results from the cosmos sdk storage layer). So I fixed that with real data as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the original code had that flaw too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I guess you mean, as a key, not as a value.

@ethanfrey ethanfrey merged commit eaec2a1 into main Jul 12, 2021
@ethanfrey ethanfrey deleted the map-existence-check branch July 12, 2021 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add existence helpers to cw-storage-plus
2 participants