blob: ec2ff8792578cfaf138d1fadbfcfad92dc38cf42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import got from "got";
export default ({ host, port, wallet, username, password }) =>
new Proxy(
{},
{
get:
(target, prop) =>
(...params) =>
((method, ...params) => {
let url = `http://${host}:${port}/wallet/${wallet}`;
return got
.post(url, {
json: {
method,
params
},
headers: {
authorization: `Basic ${Buffer.from(
`${username}:${password}`
).toString("base64")}`
}
})
.json()
.then(({ result }) => result);
})(prop.toLowerCase(), ...params)
}
);
|