From 2c4c00297339b0c8e2b9621b5c8dedf3cc92fed6 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 9 Sep 2023 07:49:55 -0400 Subject: [PATCH] refactor: switch to hexToBytes --- src/index.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9f5af1e..dce7532 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { Client, factory } from "@lumeweb/libkernel/module"; import type { Peer } from "@lumeweb/libpeerdiscovery"; -import { hexToBuf } from "@lumeweb/libweb"; +import { hexToBytes } from "@lumeweb/libweb"; const MODULE = "zdiLW9MtAAMssP5vLBgd1FitouiVXzNUYZszFYG44uVKqCPDqUQox9aq1y"; @@ -29,13 +29,9 @@ export class PeerDiscoveryClient extends Client { public async discover(pubkey: string | Uint8Array): Promise { if (typeof pubkey === "string") { - let buf = hexToBuf(pubkey); - if (buf[1]) { - throw new Error(buf[1]); - } - - pubkey = buf[0]; + pubkey = hexToBytes(pubkey); } + return await this.callModuleReturn("discover", { pubkey }); } }