aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rpc.js
blob: 72d1ee732ab49a3bf490423fc2b1fe4972426c4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)
    }
  );