*Update api usage

This commit is contained in:
Derrick Hammer 2022-12-07 04:24:42 -05:00
parent bce2e9e4fc
commit 30f48f81ac
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 6 additions and 12 deletions

View File

@ -6,10 +6,11 @@
"build": "bash build.sh"
},
"devDependencies": {
"@lumeweb/relay": "https://github.com/LumeWeb/relay.git",
"@types/node": "^18.11.10",
"esbuild": "^0.15.5"
},
"dependencies": {
"@lumeweb/relay-types": "https://git.lumeweb.com/LumeWeb/relay-types.git",
"hs-client": "^0.0.11",
"hsd": "https://github.com/LumeWeb/hsd.git#spv-namestate",
"random-key": "^0.3.2"

View File

@ -1,9 +1,4 @@
import type {
Plugin,
PluginAPI,
RPCResponse,
RPCRequest,
} from "@lumeweb/relay";
import type { Plugin, PluginAPI } from "@lumeweb/relay-types";
// @ts-ignore
import rand from "random-key";
// @ts-ignore
@ -88,10 +83,10 @@ const plugin: Plugin = {
api.registerMethod("getnameresource", {
cacheable: true,
async handler(request: RPCRequest): Promise<RPCResponse> {
async handler(name: string): Promise<any> {
let resp;
try {
resp = await client.execute("getnameresource", request.data);
resp = await client.execute("getnameresource", name);
} catch (e: any) {
e = e as Error;
const eType = e.type.toLowerCase();
@ -107,9 +102,7 @@ const plugin: Plugin = {
throw e;
}
return {
data: resp,
};
return resp;
},
});
},