From 9473aad794f36a5ce41909f64a9acf4e082466ad Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 8 Sep 2024 22:13:49 -0700 Subject: package rpc --- lib/rpc.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'lib/rpc.ts') diff --git a/lib/rpc.ts b/lib/rpc.ts index 909ec96f..2019b8ad 100644 --- a/lib/rpc.ts +++ b/lib/rpc.ts @@ -1,19 +1,2 @@ -import got from "got"; -import { fail } from "$lib/utils"; -import { err } from "$lib/logging"; - -export default ({ host, port, wallet, username, password }): any => { - let url = `http://${host}:${port}/wallet/${wallet}`; - let token = btoa(`${username}:${password}`); - let headers = { authorization: `Basic ${token}` }; - let p = (json) => got.post(url, { json, headers }).json(); - - let get = - (_, prop: any) => - (...params) => - p({ method: prop.toLowerCase(), params }) - .then((res: any) => res.result) - .catch((e) => (err(e.message), fail(`Failed to call ${prop}`))); - - return new Proxy({}, { get }); -}; +import rpc from "@coinos/rpc"; +export default rpc; -- cgit v1.2.3