refactor: switch to hexToBytes

This commit is contained in:
Derrick Hammer 2023-09-09 07:49:55 -04:00
parent bb7807e3ae
commit 2c4c002973
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 7 deletions

View File

@ -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<Peer | boolean> {
if (typeof pubkey === "string") {
let buf = hexToBuf(pubkey);
if (buf[1]) {
throw new Error(buf[1]);
pubkey = hexToBytes(pubkey);
}
pubkey = buf[0];
}
return await this.callModuleReturn("discover", { pubkey });
}
}