len(AdvancedCollectible) is always 0, tokenId does not increment
jtf512 opened this issue · 4 comments
I thought I made a mistake modifying it to 0.8, but even with a fresh pull of the example code this is still the case. It happens in the video too @ 1:24:10
Same problem here. It also then always prints the token_id = 0 breed in the print function in create_collectible.py
breed = get_breed(advanced_collectible.tokenIdToBreed(token_id))
print("Dog breed of tokenId {} is {}".format(token_id, breed))
I have feeling that this funtion does not properly work
token_id = advanced_collectible.requestIdToTokenId(requestId)
However
sender = advanced_collectible.requestIdToSender(requestId)
gives me the right sender address (=my address).
Can you send the full command you're running, the error you're getting, and the script you're running.
@Tomberino @PatrickAlphaC I am running into this issue as well, and I think this again has to do with the delayed response from the Chainlink nodes. When you call createCollectible
that function updates the requestIdToSender
mapping (which is why you are seeing this mapping work), but not the requestIdToTokenId
mapping. That mapping is only updated after the fulfillRandomness
callback is called by the Chainlink node.
So my question is, is there a way within brownie to wait or listen for an event? I suspect that you'd want to wait or listen for the Transfer
event that is emitted from the _safeMint
function so that you know the token has actually been minted before checking the requestIdToTokenId
mapping. I believe this type of functionality should be implemented between line 16 and 17 in create_collectible.py
I am happy to try and fix this and make a pull request if you could point me in the right direction! I can't seem to find an example of how to do this in brownie.
Yes, it's on my todo list to add a listen
update to the examples here, I just haven't got around to it yet.
You can either:
- Listen
- wait longer
To solve