Open 0xfcks opened 2 years ago
Side Note: it looks like the tokenOfOwnerByIndex
works as expected when individual tokens are minted. For example, the test below passes (i.e. logs 3 different non-0 values*):
...
it('Mint Multiple Tokens Individually & Call Random TokenIdx For Each Token', async () => {
await contract.methods.mint(1).send({from: accounts[0], gas:1000000})
let tokenIdx = await contract.methods.tokenOfOwnerByIndex(accounts[0],0).call()
console.log(`Randomly Assigned Token Index: ${tokenIdx}`)
await contract.methods.mint(1).send({from: accounts[0], gas:1000000})
tokenIdx = await contract.methods.tokenOfOwnerByIndex(accounts[0],1).call()
console.log(`Randomly Assigned Token Index: ${tokenIdx}`)
await contract.methods.mint(1).send({from: accounts[0], gas:1000000})
tokenIdx = await contract.methods.tokenOfOwnerByIndex(accounts[0],2).call()
console.log(`Randomly Assigned Token Index: ${tokenIdx}`)
})
*I understand that the getRandomAvailableTokenId
can return 0 but its highly unlikely in tests cases (given large TokenSupply) and since the default value for non-existent token indexes by token owner is 0 I am choosing to use it in the test assertions
Hey! I love this 721 feature and its accompanied documentation! Thank you for all the work done in brining this to the Ethereum developer community.
I am wanting to use the
ERC721REnumerable
in an upcoming project but having issues in using thetokenOfOwnerByIndex
. Specifically, only the 0-index owner's token is showing a randomly generated index value.I'm checking to see if I am implementing the Enumerable contract correctly. Here is the basic contract structure Im using for tests:
And here is my mocha.js test:
The output for the last test is as follows:
Any suggestions/feedback would be greatly appreciated!