From c4c0a947a93c60ea2364b7de9b975d6dccc188cc Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 10 Jan 2024 02:54:20 -0500 Subject: [PATCH] fix: use addEventListener, on is not available in all environments --- src/methods/registry.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/methods/registry.ts b/src/methods/registry.ts index b874bef..e6238b4 100644 --- a/src/methods/registry.ts +++ b/src/methods/registry.ts @@ -74,7 +74,7 @@ export async function subscribeToEntry( const socket = new WS(wsUrl); - socket.on("open", () => { + socket.addEventListener("open", () => { const packer = new Packer(); packer.pack(2); packer.pack(publicKey); @@ -84,8 +84,8 @@ export async function subscribeToEntry( return { listen(cb: (entry: SignedRegistryEntry) => void) { - socket.on("message", (data) => { - cb(deserializeRegistryEntry(new Uint8Array(data as Buffer))); + socket.addEventListener("message", (data) => { + cb(deserializeRegistryEntry(new Uint8Array(data.data as Buffer))); }); }, end() {