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

Fix "id to index" bug #109

Merged
merged 10 commits into from
Jun 24, 2018
Merged

Conversation

lknix
Copy link
Contributor

@lknix lknix commented Jun 24, 2018

This fixes: #106

Otherwise we can mask the actual error.
- Don't set up tests to use default values (non-existing mapping value returns default value and can mask a problem)
- Change some arbitrary index values to less conflicting numbers (for clarity).
They are dependable data structures and should be always in sync.
@lknix lknix requested review from xpepermint and MoMannn June 24, 2018 15:17
We shrink tokens array with tokens.length-- which makes tokens[lastTokenIndex] = 0 redundant.
@xpepermint xpepermint merged commit 3825504 into nibbstack:master Jun 24, 2018
@@ -56,6 +56,7 @@ contract NFTokenEnumerable is
{
super._mint(_to, _tokenId);
tokens.push(_tokenId);
idToIndex[_tokenId] = tokens.length.sub(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

push function returns new array length, so I tend to do:

uint length = tokens.push(_tokenId);
idToIndex[_tokenId] = length - 1;

Don't know if that's more gas efficient tho.

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.

[bug, critical] idToIndex is never set
3 participants