aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rpc.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-06 16:48:13 -0800
committerAdam Soltys <[email protected]>2023-02-06 16:48:13 -0800
commit9c667055c6367e1b2e239686e72f52995679a47e (patch)
tree0b1d4aee51ec2d4e92d08a9d1404ba4e2ecd462a /lib/rpc.js
parent15294844dbc8e73b4d1e92008a7eebc6b86b9ec5 (diff)
parent6f5602d112b68adb7452abf3047f20c32e7725b6 (diff)
downloadcoinos-server-9c667055c6367e1b2e239686e72f52995679a47e.tar.gz
coinos-server-9c667055c6367e1b2e239686e72f52995679a47e.zip
Merge branch 'master' into test
Diffstat (limited to 'lib/rpc.js')
-rw-r--r--lib/rpc.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/rpc.js b/lib/rpc.js
index 9186f4cd..b8a2d0dd 100644
--- a/lib/rpc.js
+++ b/lib/rpc.js
@@ -1,4 +1,4 @@
-import wretch from "./wretch";
+import got from "got";
export default ({ host, port, wallet, username, password }) =>
new Proxy(
@@ -7,18 +7,20 @@ export default ({ host, port, wallet, username, password }) =>
get: (target, prop) => (...params) =>
((method, ...params) => {
let url = `http://${host}:${port}/wallet/${wallet}`;
- return wretch()
- .url(url)
- .auth(
- `Basic ${Buffer.from(`${username}:${password}`).toString(
- "base64"
- )}`
- )
- .post({
- method,
- params
+ return got
+ .post(url, {
+ json: {
+ method,
+ params
+ },
+ headers: {
+ authorization: `Basic ${Buffer.from(
+ `${username}:${password}`
+ ).toString("base64")}`
+ }
})
- .json(({ result }) => result);
+ .json()
+ .then(({ result }) => result);
})(prop.toLowerCase(), ...params)
}
);