klaytn / caver-js

Official caver-js repository
GNU Lesser General Public License v3.0
114 stars 75 forks source link

Implicit library behavior for defining a web socket #27

Closed pixelplex closed 5 years ago

pixelplex commented 5 years ago

https://github.com/klaytn/caver-js/blob/master/packages/caver-core-method/src/index.js#L512 here, the library refers to the presence or absence of the .on method from the provider and thereby determines whether the provider is a web socket or not. But since the provider is an external class, we cannot guarantee that even the HTTP provider will not have this method, because everyone can override it.

For example, metamask adds this method so that even for an HTTP provider it is possible to provide subscriptions by wrapping interval requests into a subscription.

It seems to us that this behavior is not obvious and can lead to unexpected results.

kjhman21 commented 5 years ago

@pixelplex Thanks for filing this issue. We implemented a solution to solve this issue. Please take a look.

https://github.com/klaytn/caver-js/pull/28