diff options
| author | Adam Soltys <[email protected]> | 2022-09-02 14:47:08 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-02 14:47:14 -0700 |
| commit | 3161dd7ee95b6c7d70f8341298dd4fab84cda8b0 (patch) | |
| tree | 16cd6c55d5dc481331b1e8b640d179f193e7ea13 /lib/rpc.js | |
| parent | 7a8d64833de8873afb92982b3f5bfff59b30c542 (diff) | |
| download | coinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.tar.gz coinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.zip | |
es6 migration
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) + } + ); |
