refactor: switch to hexToBytes
This commit is contained in:
parent
bb7807e3ae
commit
2c4c002973
10
src/index.ts
10
src/index.ts
|
@ -1,6 +1,6 @@
|
||||||
import { Client, factory } from "@lumeweb/libkernel/module";
|
import { Client, factory } from "@lumeweb/libkernel/module";
|
||||||
import type { Peer } from "@lumeweb/libpeerdiscovery";
|
import type { Peer } from "@lumeweb/libpeerdiscovery";
|
||||||
import { hexToBuf } from "@lumeweb/libweb";
|
import { hexToBytes } from "@lumeweb/libweb";
|
||||||
|
|
||||||
const MODULE = "zdiLW9MtAAMssP5vLBgd1FitouiVXzNUYZszFYG44uVKqCPDqUQox9aq1y";
|
const MODULE = "zdiLW9MtAAMssP5vLBgd1FitouiVXzNUYZszFYG44uVKqCPDqUQox9aq1y";
|
||||||
|
|
||||||
|
@ -29,13 +29,9 @@ export class PeerDiscoveryClient extends Client {
|
||||||
|
|
||||||
public async discover(pubkey: string | Uint8Array): Promise<Peer | boolean> {
|
public async discover(pubkey: string | Uint8Array): Promise<Peer | boolean> {
|
||||||
if (typeof pubkey === "string") {
|
if (typeof pubkey === "string") {
|
||||||
let buf = hexToBuf(pubkey);
|
pubkey = hexToBytes(pubkey);
|
||||||
if (buf[1]) {
|
|
||||||
throw new Error(buf[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
pubkey = buf[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.callModuleReturn("discover", { pubkey });
|
return await this.callModuleReturn("discover", { pubkey });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue