weavedb-node-client 0.13.5 → 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.
- package/index.js +28 -26
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
const {
|
|
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")
|
|
@@ -106,7 +116,7 @@ class SDK extends Base {
|
|
|
106
116
|
return { nocache, query }
|
|
107
117
|
}
|
|
108
118
|
|
|
109
|
-
async
|
|
119
|
+
async write(func, query, nocache, bundle, relay = false) {
|
|
110
120
|
if (!includes(func)(reads)) {
|
|
111
121
|
nocache = false
|
|
112
122
|
if (relay) {
|
|
@@ -115,7 +125,7 @@ class SDK extends Base {
|
|
|
115
125
|
}
|
|
116
126
|
const request = {
|
|
117
127
|
method: `${func}@${this.contractTxId}`,
|
|
118
|
-
query: JSON.stringify(query),
|
|
128
|
+
query: JSON.stringify(isNil(query) ? "" : query),
|
|
119
129
|
nocache,
|
|
120
130
|
}
|
|
121
131
|
const _query = () =>
|
|
@@ -134,37 +144,29 @@ class SDK extends Base {
|
|
|
134
144
|
})
|
|
135
145
|
})
|
|
136
146
|
let q = await _query()
|
|
137
|
-
if (isNil(q.err))
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
|
141
157
|
}
|
|
158
|
+
|
|
159
|
+
return await this.write(params.function, query, nocache)
|
|
142
160
|
}
|
|
143
161
|
|
|
144
|
-
async
|
|
162
|
+
async readQuery(func, ...query) {
|
|
145
163
|
let nocache = false
|
|
146
164
|
;({ nocache, query } = this.parseQuery(func, query))
|
|
147
|
-
return await this.
|
|
165
|
+
return await this.read({ function: func, query }, nocache)
|
|
148
166
|
}
|
|
149
167
|
|
|
150
168
|
async getNonce(addr) {
|
|
151
|
-
return this.
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async getIds(tx) {
|
|
155
|
-
return this.request("getIds", tx)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async getAddressLink(address) {
|
|
159
|
-
return this.request("getAddressLink", address)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async getVersion() {
|
|
163
|
-
return this.request("getAddressLink")
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async getEvolve() {
|
|
167
|
-
return this.request("getEvolve")
|
|
169
|
+
return this.readQuery("getNonce", addr, true)
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weavedb-node-client",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
14
|
+
"weavedb-base": "^0.18.0"
|
|
15
15
|
}
|
|
16
16
|
}
|