aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rpc.js
diff options
context:
space:
mode:
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)
}
);