@@ -47,40 +47,24 @@ export function watchLogs({ url, address, fromBlock }: WatchLogsInput): WatchLog
4747
4848 ws = new WebSocket ( url ) ;
4949
50- ws . on ( "error" , ( error ) => {
50+ ws . addEventListener ( "error" , ( error ) => {
5151 const errorMessage = `ws${ wsId } error` ;
5252 debugError ( errorMessage , error ) ;
5353 subscriber . error ( errorMessage ) ;
5454 } ) ;
5555
56- ws . on ( "close" , ( ) => {
56+ ws . addEventListener ( "close" , ( ) => {
5757 const errorMessage = `ws${ wsId } close` ;
5858 debug ( errorMessage ) ;
5959 subscriber . error ( errorMessage ) ;
6060 } ) ;
6161
62- ws . on ( "open" , ( ) => {
62+ ws . addEventListener ( "open" , ( ) => {
6363 debug ( `ws${ wsId } open` ) ;
6464 } ) ;
6565
66- ws . on ( "ping" , ( ) => {
67- debug ( `ws${ wsId } ping` ) ;
68- } ) ;
69-
70- ws . on ( "pong" , ( ) => {
71- debug ( `ws${ wsId } pong` ) ;
72- } ) ;
73-
74- ws . on ( "unexpected-response" , ( message ) => {
75- debugError ( `ws${ wsId } unexpected-response` , message ) ;
76- } ) ;
77-
78- ws . on ( "upgrade" , ( ) => {
79- debug ( `ws${ wsId } upgrade` ) ;
80- } ) ;
81-
82- ws . on ( "message" , ( message ) => {
83- const data = JSON . parse ( message . toString ( ) ) ;
66+ ws . addEventListener ( "message" , ( message ) => {
67+ const data = JSON . parse ( message . data . toString ( ) ) ;
8468
8569 if ( "error" in data ) {
8670 const errorMessage = `ws${ wsId } json-rpc error` ;
0 commit comments