diff options
Diffstat (limited to 'lib/rpc.js')
| -rw-r--r-- | lib/rpc.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/rpc.js b/lib/rpc.js new file mode 100644 index 00000000..72d1ee73 --- /dev/null +++ b/lib/rpc.js @@ -0,0 +1,18 @@ +export default ({ host, port, wallet, user, password }) => + new Proxy( + {}, + { + get: (target, prop) => (...params) => + ((method, ...params) => + wretch() + .url(`http://${host}:${port}/wallet/${wallet}`) + .auth( + `Basic ${Buffer.from(`${user}:${password}`).toString("base64")}` + ) + .post({ + method, + params + }) + .json(({ result }) => result))(prop.toLowerCase(), ...params) + } + ); |
