harmony-one / sdk

Javascript SDK of Harmony protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event subscription doesn't respect the event topics.

kraikov opened this issue · comments

After calling a single function that emits a single event, all event subscriptions are emitting in the SDK.

For example: If I call a function newContract that emits a single event (NewContract) and I've subscribed for NewContract and
Withdraw events, both event handlers are invoked for the newContract call.

        this.contract.events
            .NewContract()
            .on('data', (event) => {
                console.log(event);
            })
            .on('error', console.error);

        this.contract.events
            .Withdraw()
            .on('data', (event) => {
                console.log(event);
            })
            .on('error', console.error);

This also breaks the SDK, because the decoder cannot decode the data. E.g. the decoder cannot decode the data for NewContract event when the Withdraw event data comes and vice versa.

image

@kraikov Interesting. This should have worked correctly, as decoding is based on the event format specified in the abi. Let me take a look. Thanks.

Okay. Would be nice if there is a way to subscribe to all events or by given topics. I don't know how events are handled internally, but this could save network bandwidth.