weavedb-node-client 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { all, complement,
|
|
1
|
+
const { all, complement, isNil } = require("ramda")
|
|
2
2
|
const Base = require("weavedb-base")
|
|
3
3
|
const PROTO_PATH = __dirname + "/weavedb.proto"
|
|
4
4
|
const grpc = require("@grpc/grpc-js")
|
|
@@ -11,10 +11,22 @@ const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
|
|
|
11
11
|
oneofs: true,
|
|
12
12
|
})
|
|
13
13
|
const weavedb_proto = grpc.loadPackageDefinition(packageDefinition).weavedb
|
|
14
|
+
let Arweave = require("arweave")
|
|
14
15
|
|
|
15
16
|
class SDK extends Base {
|
|
16
|
-
constructor({
|
|
17
|
+
constructor({
|
|
18
|
+
rpc,
|
|
19
|
+
contractTxId,
|
|
20
|
+
wallet,
|
|
21
|
+
name,
|
|
22
|
+
version,
|
|
23
|
+
EthWallet,
|
|
24
|
+
web3,
|
|
25
|
+
arweave,
|
|
26
|
+
}) {
|
|
17
27
|
super()
|
|
28
|
+
this.contractTxId = contractTxId
|
|
29
|
+
this.arweave = Arweave.init(arweave)
|
|
18
30
|
this.client = new weavedb_proto.DB(rpc, grpc.credentials.createInsecure())
|
|
19
31
|
if (typeof window === "object") {
|
|
20
32
|
require("@metamask/legacy-web3")
|
|
@@ -32,7 +44,7 @@ class SDK extends Base {
|
|
|
32
44
|
|
|
33
45
|
async _request(func, query) {
|
|
34
46
|
const request = {
|
|
35
|
-
method: func
|
|
47
|
+
method: `${func}@${this.contractTxId}`,
|
|
36
48
|
query: JSON.stringify(query),
|
|
37
49
|
}
|
|
38
50
|
const _query = () =>
|
|
@@ -51,7 +63,11 @@ class SDK extends Base {
|
|
|
51
63
|
})
|
|
52
64
|
})
|
|
53
65
|
let q = await _query()
|
|
54
|
-
|
|
66
|
+
if (isNil(q.err)) {
|
|
67
|
+
return q.result
|
|
68
|
+
} else {
|
|
69
|
+
throw new Error(q.err)
|
|
70
|
+
}
|
|
55
71
|
}
|
|
56
72
|
|
|
57
73
|
async request(func, ...query) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weavedb-node-client",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
"@grpc/grpc-js": "^1.1.0",
|
|
11
11
|
"@grpc/proto-loader": "^0.5.0",
|
|
12
12
|
"ramda": "^0.28.0",
|
|
13
|
-
"weavedb-base": "^0.
|
|
13
|
+
"weavedb-base": "^0.7.3"
|
|
14
14
|
}
|
|
15
15
|
}
|