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

getter added for an array of tokens held by an owner #1522

Merged
merged 34 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f2e5ed1
signing prefix added
Aniket-Engg Mar 10, 2018
ebdae17
Merge branch 'master' into master
Aniket-Engg Mar 13, 2018
2bf341c
Minor improvement
Aniket-Engg Mar 13, 2018
27c614a
Merge branch 'master' of https://github.com/Aniket-Engg/zeppelin-soli…
Aniket-Engg Mar 13, 2018
bc7ea7a
Tests changed
Aniket-Engg Mar 13, 2018
5a72021
Successfully tested
Aniket-Engg Mar 13, 2018
de0d2d4
Minor improvements
Aniket-Engg Mar 13, 2018
7f32e5c
Minor improvements
Aniket-Engg Mar 13, 2018
c3fb8a8
minor changes
Aniket-Engg Oct 1, 2018
68de840
Revert "Dangling commas are now required. (#1359)"
Aniket-Engg Oct 1, 2018
92b725f
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 1, 2018
1fe2cdf
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 1, 2018
75bc310
updates
Aniket-Engg Oct 1, 2018
9d9a5a0
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 3, 2018
10b1898
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 4, 2018
3858a0c
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 4, 2018
9484daa
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 5, 2018
5139019
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 8, 2018
3097a48
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 9, 2018
a46e176
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 10, 2018
fc9d1a7
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 11, 2018
23df893
fixes #1404
Aniket-Engg Oct 11, 2018
d8dd5ec
approve failing test
Aniket-Engg Oct 11, 2018
ae96caa
suggested changes done
Aniket-Engg Oct 16, 2018
e2fb20a
ISafeERC20 removed
Aniket-Engg Oct 16, 2018
52c7870
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 16, 2018
998dfd7
Merge branch 'fix/#1404' of https://github.com/Aniket-Engg/zeppelin-s…
Aniket-Engg Oct 16, 2018
c8963b1
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Oct 17, 2018
7ffe179
conflicts
Aniket-Engg Oct 22, 2018
5f88845
conflict fixes
Aniket-Engg Oct 22, 2018
6b40c91
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Nov 2, 2018
7f9725e
Merge remote-tracking branch 'upstream/master'
Aniket-Engg Nov 28, 2018
ac8c493
fixes #1512
Aniket-Engg Nov 28, 2018
94fa635
Update test/token/ERC721/ERC721Full.test.js
frangio Dec 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions contracts/mocks/ERC721FullMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import "../token/ERC721/ERC721Burnable.sol";

/**
* @title ERC721FullMock
* This mock just provides a public mint and burn functions for testing purposes,
* and a public setter for metadata URI
* This mock just provides public functions for setting metadata URI, getting all tokens of an owner,
* checking token existence, removal of a token from an address
*/
contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, ERC721Burnable {
constructor (string name, string symbol) public ERC721Mintable() ERC721Full(name, symbol) {}
Expand All @@ -17,6 +17,10 @@ contract ERC721FullMock is ERC721Full, ERC721Mintable, ERC721MetadataMintable, E
return _exists(tokenId);
}

function tokensOfOwner(address owner) public view returns (uint256[] memory) {
return _tokensOfOwner(owner);
}

function setTokenURI(uint256 tokenId, string uri) public {
_setTokenURI(tokenId, uri);
}
Expand Down
9 changes: 9 additions & 0 deletions contracts/token/ERC721/ERC721Enumerable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,13 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
_allTokensIndex[tokenId] = 0;
_allTokensIndex[lastToken] = tokenIndex;
}

/**
* @dev Gets the list of token IDs of the requested owner
* @param owner address owning the tokens
* @return uint256[] List of token IDs owned by the requested address
*/
function _tokensOfOwner(address owner) internal view returns (uint256[] storage) {
return _ownedTokens[owner];
}
}
9 changes: 9 additions & 0 deletions test/token/ERC721/ERC721Full.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ contract('ERC721Full', function ([
});
});

describe('tokensOfOwner', function () {
it('returns total tokens of owner', async function () {
const tokenIds = await this.token.tokensOfOwner(owner);
Aniket-Engg marked this conversation as resolved.
Show resolved Hide resolved
tokenIds.length.should.equal(2);
tokenIds[0].should.be.bignumber.equal(firstTokenId);
tokenIds[1].should.be.bignumber.equal(secondTokenId);
});
});

describe('totalSupply', function () {
it('returns total token supply', async function () {
(await this.token.totalSupply()).should.be.bignumber.equal(2);
Expand Down