weavedb-node-client 0.13.5 → 0.18.2
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 +25 -38
- 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")
|
|
@@ -97,16 +107,7 @@ class SDK extends Base {
|
|
|
97
107
|
if (!isNil(EthWallet)) this.setEthWallet(EthWallet)
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
|
|
101
|
-
let nocache = false
|
|
102
|
-
if (includes(func)(reads) && is(Boolean, last(query))) {
|
|
103
|
-
nocache = last(query)
|
|
104
|
-
query = init(query)
|
|
105
|
-
}
|
|
106
|
-
return { nocache, query }
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async _request(func, query, nocache, bundle, relay = false) {
|
|
110
|
+
async write(func, query, nocache, bundle, relay = false) {
|
|
110
111
|
if (!includes(func)(reads)) {
|
|
111
112
|
nocache = false
|
|
112
113
|
if (relay) {
|
|
@@ -115,7 +116,7 @@ class SDK extends Base {
|
|
|
115
116
|
}
|
|
116
117
|
const request = {
|
|
117
118
|
method: `${func}@${this.contractTxId}`,
|
|
118
|
-
query: JSON.stringify(query),
|
|
119
|
+
query: JSON.stringify(isNil(query) ? "" : query),
|
|
119
120
|
nocache,
|
|
120
121
|
}
|
|
121
122
|
const _query = () =>
|
|
@@ -134,37 +135,23 @@ class SDK extends Base {
|
|
|
134
135
|
})
|
|
135
136
|
})
|
|
136
137
|
let q = await _query()
|
|
137
|
-
if (isNil(q.err))
|
|
138
|
-
|
|
139
|
-
} else {
|
|
140
|
-
throw new Error(q.err)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async request(func, ...query) {
|
|
145
|
-
let nocache = false
|
|
146
|
-
;({ nocache, query } = this.parseQuery(func, query))
|
|
147
|
-
return await this._request(func, query, nocache)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async getNonce(addr) {
|
|
151
|
-
return this.request("getNonce", addr, true)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async getIds(tx) {
|
|
155
|
-
return this.request("getIds", tx)
|
|
138
|
+
if (!isNil(q.err)) throw new Error(q.err)
|
|
139
|
+
return q.result
|
|
156
140
|
}
|
|
157
141
|
|
|
158
|
-
async
|
|
159
|
-
|
|
160
|
-
|
|
142
|
+
async read(params, nocache) {
|
|
143
|
+
let query = dissoc("function")(params)
|
|
144
|
+
if (isEmpty(query)) {
|
|
145
|
+
query = null
|
|
146
|
+
} else if (!isNil(query.query)) {
|
|
147
|
+
query = query.query
|
|
148
|
+
}
|
|
161
149
|
|
|
162
|
-
|
|
163
|
-
return this.request("getAddressLink")
|
|
150
|
+
return await this.write(params.function, query, nocache)
|
|
164
151
|
}
|
|
165
152
|
|
|
166
|
-
async
|
|
167
|
-
return this.
|
|
153
|
+
async getNonce(addr) {
|
|
154
|
+
return this.readQuery("getNonce", addr, true)
|
|
168
155
|
}
|
|
169
156
|
}
|
|
170
157
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weavedb-node-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.2",
|
|
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.1"
|
|
15
15
|
}
|
|
16
16
|
}
|