weavedb-node-client 0.13.4 → 0.18.0

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.
Files changed (2) hide show
  1. package/index.js +29 -26
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,4 +1,14 @@
1
- const { init, all, complement, isNil, is, last, includes } = require("ramda")
1
+ const {
2
+ dissoc,
3
+ isEmpty,
4
+ init,
5
+ all,
6
+ complement,
7
+ isNil,
8
+ is,
9
+ last,
10
+ includes,
11
+ } = require("ramda")
2
12
  const Base = require("weavedb-base")
3
13
  const PROTO_PATH = __dirname + "/weavedb.proto"
4
14
  const grpc = require("@grpc/grpc-js")
@@ -28,6 +38,7 @@ const reads = [
28
38
  "getEvolve",
29
39
  "getVersion",
30
40
  "getRelayerJob",
41
+ "listRelayerJobs",
31
42
  "listCollections",
32
43
  "getInfo",
33
44
  ,
@@ -105,7 +116,7 @@ class SDK extends Base {
105
116
  return { nocache, query }
106
117
  }
107
118
 
108
- async _request(func, query, nocache, bundle, relay = false) {
119
+ async write(func, query, nocache, bundle, relay = false) {
109
120
  if (!includes(func)(reads)) {
110
121
  nocache = false
111
122
  if (relay) {
@@ -114,7 +125,7 @@ class SDK extends Base {
114
125
  }
115
126
  const request = {
116
127
  method: `${func}@${this.contractTxId}`,
117
- query: JSON.stringify(query),
128
+ query: JSON.stringify(isNil(query) ? "" : query),
118
129
  nocache,
119
130
  }
120
131
  const _query = () =>
@@ -133,37 +144,29 @@ class SDK extends Base {
133
144
  })
134
145
  })
135
146
  let q = await _query()
136
- if (isNil(q.err)) {
137
- return q.result
138
- } else {
139
- throw new Error(q.err)
147
+ if (!isNil(q.err)) throw new Error(q.err)
148
+ return q.result
149
+ }
150
+
151
+ async read(params, nocache) {
152
+ let query = dissoc("function")(params)
153
+ if (isEmpty(query)) {
154
+ query = null
155
+ } else if (!isNil(query.query)) {
156
+ query = query.query
140
157
  }
158
+
159
+ return await this.write(params.function, query, nocache)
141
160
  }
142
161
 
143
- async request(func, ...query) {
162
+ async readQuery(func, ...query) {
144
163
  let nocache = false
145
164
  ;({ nocache, query } = this.parseQuery(func, query))
146
- return await this._request(func, query, nocache)
165
+ return await this.read({ function: func, query }, nocache)
147
166
  }
148
167
 
149
168
  async getNonce(addr) {
150
- return this.request("getNonce", addr, true)
151
- }
152
-
153
- async getIds(tx) {
154
- return this.request("getIds", tx)
155
- }
156
-
157
- async getAddressLink(address) {
158
- return this.request("getAddressLink", address)
159
- }
160
-
161
- async getVersion() {
162
- return this.request("getAddressLink")
163
- }
164
-
165
- async getEvolve() {
166
- return this.request("getEvolve")
169
+ return this.readQuery("getNonce", addr, true)
167
170
  }
168
171
  }
169
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weavedb-node-client",
3
- "version": "0.13.4",
3
+ "version": "0.18.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -11,6 +11,6 @@
11
11
  "@grpc/proto-loader": "^0.5.0",
12
12
  "arweave": "^1.12.2",
13
13
  "ramda": "^0.28.0",
14
- "weavedb-base": "^0.13.1"
14
+ "weavedb-base": "^0.18.0"
15
15
  }
16
16
  }