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

Documentation for Event Emitter with topicSets omits required padding for addresses in topics #1535

Closed
josh-richardson opened this issue May 1, 2021 · 3 comments
Labels
documentation Documentation related issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@josh-richardson
Copy link

josh-richardson commented May 1, 2021

The documentation for event emitters has an example whereby the following code is used:

topicSets = [
    utils.id("Transfer(address,address,uint256)"),
    null,
    [
        myAddress,
        myOtherAddress
    ]
]
provider.on(topicSets, (log, event) => {
    // Emitted any token is sent TO either address
})

Unfortunately, this causes an error which is addressed elsewhere in the documentation by the addition of the utils.hexZeroPad method. If this is indeed a mistake as I suspect, I'm happy to submit a PR to fix it.

Edit: I see when looking at the docs myOtherAddress is defined as AddressZero in events.wrm but as HashZero in provider.wrm, so it seems that everything would work as expected, however it might be clearer to end users if types were updated here to those which would more commonly be used in this situation (assuming users are more likely to pass a plain address as a string to this method rather than as a padded 32 byte hex string).

@josh-richardson josh-richardson added the documentation Documentation related issue. label May 1, 2021
@zemse
Copy link
Collaborator

zemse commented May 1, 2021

Yes, you are right hexZeroPad is to be used if you are passing addresses, as topics accept only bytes32 strings. I think this came up before in some previous issue but the example will be updated to make it clear.

@josh-richardson
Copy link
Author

Opened a PR: #1538

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Aug 9, 2021
@ricmoo
Copy link
Member

ricmoo commented Aug 9, 2021

Fixed and published.

Thanks! :)

@ricmoo ricmoo closed this as completed Aug 9, 2021
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation related issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

3 participants