*Update api usage
This commit is contained in:
parent
bce2e9e4fc
commit
30f48f81ac
|
@ -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"
|
||||
|
|
15
src/index.ts
15
src/index.ts
|
@ -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;
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue