wao 0.16.0 → 0.16.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/cjs/adaptor-base.js +1700 -0
- package/cjs/adaptor-web.js +42 -0
- package/cjs/adaptor.js +22 -1676
- package/cjs/index.js +0 -7
- package/cjs/test.js +7 -0
- package/cjs/web.js +7 -0
- package/esm/adaptor-base.js +514 -0
- package/esm/adaptor-web.js +11 -0
- package/esm/adaptor.js +4 -498
- package/esm/index.js +1 -2
- package/esm/test.js +2 -0
- package/esm/web.js +2 -1
- package/package.json +1 -5
package/esm/adaptor.js
CHANGED
|
@@ -1,504 +1,10 @@
|
|
|
1
|
-
import HB from "./hb.js"
|
|
2
|
-
import { DataItem } from "arbundles"
|
|
3
|
-
import {
|
|
4
|
-
toANS104Request,
|
|
5
|
-
parseSignatureInput,
|
|
6
|
-
tags,
|
|
7
|
-
toGraphObj,
|
|
8
|
-
} from "./utils.js"
|
|
9
1
|
import { connect } from "./aoconnect.js"
|
|
10
2
|
import { GQL, cu, su, mu } from "./test.js"
|
|
11
|
-
import
|
|
12
|
-
//import { httpbis, createVerifier } from "http-message-signatures"
|
|
13
|
-
//import { createPublicKey } from "node:crypto"
|
|
14
|
-
//const { verifyMessage } = httpbis
|
|
3
|
+
import Base from "./adaptor-base.js"
|
|
15
4
|
|
|
16
|
-
class Adaptor {
|
|
17
|
-
constructor(
|
|
18
|
-
|
|
19
|
-
let hb = null
|
|
20
|
-
if (hb_url) hb = new HB({ url: hb_url })
|
|
21
|
-
const {
|
|
22
|
-
ar: _ar,
|
|
23
|
-
message,
|
|
24
|
-
spawn,
|
|
25
|
-
dryrun,
|
|
26
|
-
result,
|
|
27
|
-
results,
|
|
28
|
-
mem,
|
|
29
|
-
monitor,
|
|
30
|
-
unmonitor,
|
|
31
|
-
recover,
|
|
32
|
-
} = connect(aoconnect, { log, cache: db, hb })
|
|
33
|
-
this.recover = recover
|
|
34
|
-
this.monitor = monitor
|
|
35
|
-
this.unmonitor = unmonitor
|
|
36
|
-
this.spawn = spawn
|
|
37
|
-
this._ar = _ar
|
|
38
|
-
this.message = message
|
|
39
|
-
this.dryrun = dryrun
|
|
40
|
-
this.result = result
|
|
41
|
-
this.results = results
|
|
42
|
-
this.mem = mem
|
|
43
|
-
this.gql = new GQL({ mem })
|
|
44
|
-
}
|
|
45
|
-
async get(req, res) {
|
|
46
|
-
res(await this[req.device](req))
|
|
47
|
-
}
|
|
48
|
-
async bd(req) {
|
|
49
|
-
return await this[`bd_${req.method.toLowerCase()}`](req)
|
|
50
|
-
}
|
|
51
|
-
async ar(req) {
|
|
52
|
-
return await this[`ar_${req.method.toLowerCase()}`](req)
|
|
53
|
-
}
|
|
54
|
-
async su(req) {
|
|
55
|
-
return await this[`su_${req.method.toLowerCase()}`](req)
|
|
56
|
-
}
|
|
57
|
-
async mu(req) {
|
|
58
|
-
return await this[`mu_${req.method.toLowerCase()}`](req)
|
|
59
|
-
}
|
|
60
|
-
async cu(req) {
|
|
61
|
-
return await this[`cu_${req.method.toLowerCase()}`](req)
|
|
62
|
-
}
|
|
63
|
-
async bd_get(req) {
|
|
64
|
-
switch (req.path) {
|
|
65
|
-
default:
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async bd_post(req) {
|
|
70
|
-
switch (req.path) {
|
|
71
|
-
case "/tx":
|
|
72
|
-
return await this.bd_post_tx(req)
|
|
73
|
-
default:
|
|
74
|
-
return await this.bad()
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async ar_get(req) {
|
|
79
|
-
switch (req.path) {
|
|
80
|
-
case "/":
|
|
81
|
-
return await this.ar_get_root(req)
|
|
82
|
-
case "/wallet/:id/balance":
|
|
83
|
-
return await this.ar_get_wallet_balance(req)
|
|
84
|
-
case "/mint/:id/:amount":
|
|
85
|
-
return await this.ar_get_mint(req)
|
|
86
|
-
case "/tx/:id/offset":
|
|
87
|
-
return await this.ar_get_tx_offset(req)
|
|
88
|
-
case "/tx_anchor":
|
|
89
|
-
return await this.ar_get_tx_anchor(req)
|
|
90
|
-
case "/mine":
|
|
91
|
-
return await this.ar_get_mine(req)
|
|
92
|
-
case "/:id":
|
|
93
|
-
return await this.ar_get_id(req)
|
|
94
|
-
case "/price/:id":
|
|
95
|
-
return await this.ar_get_price(req)
|
|
96
|
-
default:
|
|
97
|
-
return await this.bad()
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async ar_post(req) {
|
|
102
|
-
switch (req.path) {
|
|
103
|
-
case "/graphql":
|
|
104
|
-
return await this.ar_post_graphql(req)
|
|
105
|
-
case "/:id":
|
|
106
|
-
return await this.ar_post_id(req)
|
|
107
|
-
default:
|
|
108
|
-
return await this.bad()
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async su_get(req) {
|
|
113
|
-
switch (req.path) {
|
|
114
|
-
case "/":
|
|
115
|
-
return await this.su_get_root(req)
|
|
116
|
-
case "/timestamp":
|
|
117
|
-
return await this.su_get_timestamp(req)
|
|
118
|
-
case "/:pid":
|
|
119
|
-
return await this.su_get_pid(req)
|
|
120
|
-
default:
|
|
121
|
-
return await this.bad()
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async su_post(req) {
|
|
126
|
-
switch (req.path) {
|
|
127
|
-
default:
|
|
128
|
-
return await this.bad()
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async mu_get(req) {
|
|
133
|
-
switch (req.path) {
|
|
134
|
-
case "/":
|
|
135
|
-
return await this.mu_get_root(req)
|
|
136
|
-
case "/monitor:pid":
|
|
137
|
-
return await this.mu_get_monitor(req)
|
|
138
|
-
default:
|
|
139
|
-
return await this.bad()
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async mu_delete(req) {
|
|
144
|
-
switch (req.path) {
|
|
145
|
-
case "/monitor:pid":
|
|
146
|
-
return await this.mu_delete_monitor(req)
|
|
147
|
-
default:
|
|
148
|
-
return await this.bad()
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async mu_post(req) {
|
|
153
|
-
switch (req.path) {
|
|
154
|
-
case "/":
|
|
155
|
-
return await this.mu_post_root(req)
|
|
156
|
-
case "/monitor:pid":
|
|
157
|
-
return await this.mu_post_monitor(req)
|
|
158
|
-
default:
|
|
159
|
-
return await this.bad()
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async cu_get(req) {
|
|
164
|
-
switch (req.path) {
|
|
165
|
-
case "/":
|
|
166
|
-
return await this.cu_get_root(req)
|
|
167
|
-
case "/result/:mid":
|
|
168
|
-
return await this.cu_get_result(req)
|
|
169
|
-
case "/results/:pid":
|
|
170
|
-
return await this.cu_get_results(req)
|
|
171
|
-
case "/state/:pid":
|
|
172
|
-
return await this.cu_get_state(req)
|
|
173
|
-
default:
|
|
174
|
-
return await this.bad()
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
async cu_post(req) {
|
|
179
|
-
switch (req.path) {
|
|
180
|
-
case "/result/:mid": // not in the AO spec, but HyperBEAM queries it
|
|
181
|
-
return await this.cu_post_result(req)
|
|
182
|
-
case "/dry-run": // not in the AO spec
|
|
183
|
-
return await this.cu_post_dryrun(req)
|
|
184
|
-
default:
|
|
185
|
-
return await this.bad()
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
async bad({}) {
|
|
189
|
-
return { status: 400, error: "bad request" }
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async bd_post_tx({ query, params, body, headers, method }) {
|
|
193
|
-
// todo: items from HB has wrong sigs and ids
|
|
194
|
-
return { send: "Success" }
|
|
195
|
-
if (!Buffer.isBuffer(body)) {
|
|
196
|
-
console.log("BD: Invalid body | expected raw Buffer")
|
|
197
|
-
return { status: 400, send: "Invalid body: expected raw Buffer" }
|
|
198
|
-
}
|
|
199
|
-
const lines = body.toString("utf8").split(/\r?\n/)
|
|
200
|
-
const sigs = {}
|
|
201
|
-
let currentKey = null
|
|
202
|
-
|
|
203
|
-
for (let line of lines) {
|
|
204
|
-
const trimmed = line.trim()
|
|
205
|
-
if (/^--[a-zA-Z0-9_\-=]+/.test(trimmed)) {
|
|
206
|
-
currentKey = null
|
|
207
|
-
continue
|
|
208
|
-
}
|
|
209
|
-
const headerMatch = trimmed.match(/^([a-zA-Z0-9_-]+):\s*(.*)$/)
|
|
210
|
-
if (headerMatch && !headerMatch[2].includes(": ")) {
|
|
211
|
-
const key = headerMatch[1]
|
|
212
|
-
const value = headerMatch[2]
|
|
213
|
-
sigs[key] = value
|
|
214
|
-
currentKey = key
|
|
215
|
-
} else if (currentKey) sigs[currentKey] += "\n" + line
|
|
216
|
-
}
|
|
217
|
-
sigs.target = headers.process
|
|
218
|
-
sigs.slot = headers.slot
|
|
219
|
-
/*
|
|
220
|
-
const input = parseSignatureInput(headers["signature-input"])
|
|
221
|
-
const key = { kty: "RSA", n: input.keyid, e: "AQAB" }
|
|
222
|
-
const verifier = createVerifier(
|
|
223
|
-
createPublicKey({ key, format: "jwk" }),
|
|
224
|
-
"rsa-pss-sha512"
|
|
225
|
-
)*/
|
|
226
|
-
let id = null
|
|
227
|
-
try {
|
|
228
|
-
/*
|
|
229
|
-
const isValid = await verifyMessage(
|
|
230
|
-
{ keyLookup: params => ({ verify: verifier }) },
|
|
231
|
-
{
|
|
232
|
-
method: method,
|
|
233
|
-
headers: headers,
|
|
234
|
-
url: `http://ao.com${headers.path}`,
|
|
235
|
-
}
|
|
236
|
-
)*/
|
|
237
|
-
const item = toANS104Request(sigs).item
|
|
238
|
-
|
|
239
|
-
if (sigs.slot === "0" || sigs.type === "Process") {
|
|
240
|
-
for (let v of item.tags) if (v.name === "Type") v.value = "Process"
|
|
241
|
-
const res = await this.spawn({
|
|
242
|
-
http_msg: item,
|
|
243
|
-
module: sigs.module,
|
|
244
|
-
scheduler: sigs.scheduler,
|
|
245
|
-
})
|
|
246
|
-
} else if (sigs.type === "Message") {
|
|
247
|
-
for (let v of item.tags) if (v.name === "id") item.target = v.value
|
|
248
|
-
const res = await this.message({
|
|
249
|
-
slot: sigs.slot,
|
|
250
|
-
http_msg: item,
|
|
251
|
-
process: sigs.target,
|
|
252
|
-
})
|
|
253
|
-
}
|
|
254
|
-
} catch (e) {
|
|
255
|
-
console.log(e)
|
|
256
|
-
}
|
|
257
|
-
return { send: "Success" }
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
async cu_get_root({ query, params, body, headers, method }) {
|
|
261
|
-
return { json: { timestamp: Date.now(), address: cu.addr } }
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async cu_get_state({ query, params, body, headers, method }) {
|
|
265
|
-
const pid = params.pid
|
|
266
|
-
const memory = this.mem.env[pid]?.memory ?? null
|
|
267
|
-
if (!memory) {
|
|
268
|
-
return {
|
|
269
|
-
status: 404,
|
|
270
|
-
error: `TransactionNotFound: Process ${pid} was not found on gateway`,
|
|
271
|
-
}
|
|
272
|
-
} else return { send: Buffer.from(memory) }
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
async cu_post_dryrun({ query, params, body, headers, method }) {
|
|
276
|
-
const process = query["process-id"]
|
|
277
|
-
const { Id: id, Owner: owner, Tags: tags, Data: data } = body
|
|
278
|
-
const res2 = await this.dryrun({ id, owner, tags, data, process })
|
|
279
|
-
if (!res2) return { status: 400, error: true }
|
|
280
|
-
else {
|
|
281
|
-
delete res2.Memory
|
|
282
|
-
return { json: res2 }
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
async cu_post_results({ query, params, body, headers, method }) {
|
|
286
|
-
const pid = params.pid
|
|
287
|
-
const { from = null, to = null, sort = "ASC", limit = 25 } = query
|
|
288
|
-
let results = this.mem.env[pid]?.results ?? []
|
|
289
|
-
if (sort === "DESC") results = reverse(results)
|
|
290
|
-
let _res = []
|
|
291
|
-
let i = 1
|
|
292
|
-
let count = 0
|
|
293
|
-
let started = isNil(from)
|
|
294
|
-
for (let v of results) {
|
|
295
|
-
if (started) {
|
|
296
|
-
_res.push({ cursor: v, node: this.mem.msgs[v]?.res })
|
|
297
|
-
count++
|
|
298
|
-
if (!isNil(to) && v === to) break
|
|
299
|
-
if (limit <= count) break
|
|
300
|
-
} else if (from === v) started = true
|
|
301
|
-
|
|
302
|
-
i++
|
|
303
|
-
}
|
|
304
|
-
return { json: { edges: _res } }
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async cu_get_result({ query, params, body, headers, method }) {
|
|
308
|
-
let message = params.mid
|
|
309
|
-
const process = query["process-id"]
|
|
310
|
-
// check if recovery is ongoing and
|
|
311
|
-
if (isNil(this.mem.env[process])) {
|
|
312
|
-
const { success } = await this.recover(process)
|
|
313
|
-
if (!success) {
|
|
314
|
-
console.log("process not found:", query["process-id"])
|
|
315
|
-
return { status: 404, error: "not Found" }
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
const slot = message
|
|
319
|
-
if (!/^--[0-9a-zA-Z_-]{43,44}$/.test(message)) {
|
|
320
|
-
message = this.mem.env[process]?.results?.[slot]
|
|
321
|
-
}
|
|
322
|
-
if (isNil(message)) {
|
|
323
|
-
await this.recover(process)
|
|
324
|
-
message = this.mem.env[process]?.results?.[slot]
|
|
325
|
-
if (isNil(message)) return { status: 404, error: "not Found" }
|
|
326
|
-
}
|
|
327
|
-
const res2 = await this.result({ message, process })
|
|
328
|
-
if (isNil(message)) return { json: res2 }
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
async su_get_root({ query, params, body, headers, method }) {
|
|
332
|
-
return {
|
|
333
|
-
json: {
|
|
334
|
-
Unit: "Scheduler",
|
|
335
|
-
Timestamp: Date.now(),
|
|
336
|
-
Address: su.addr,
|
|
337
|
-
Processes: keys(this.mem.env),
|
|
338
|
-
},
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
async su_get_timestamp({ query, params, body, headers, method }) {
|
|
343
|
-
return { json: { timestamp: Date.now(), block_height: this.mem.height } }
|
|
344
|
-
}
|
|
345
|
-
async su_get_pid({ query, params, body, headers, method }) {
|
|
346
|
-
const pid = params.pid
|
|
347
|
-
const edges = map(async v => {
|
|
348
|
-
const tx = await this.mem.getTx(v)
|
|
349
|
-
const _tags = tags(v.tags)
|
|
350
|
-
const mid = _tags.Message
|
|
351
|
-
const mtx = await this.mem.getTx(mid)
|
|
352
|
-
return {
|
|
353
|
-
cursor: v,
|
|
354
|
-
node: {
|
|
355
|
-
message: {
|
|
356
|
-
id: mtx.id,
|
|
357
|
-
tags: mtx.tags,
|
|
358
|
-
owner: this.mem.addrmap[mtx.owner],
|
|
359
|
-
anchor: mtx.anchor ?? null,
|
|
360
|
-
target: pid,
|
|
361
|
-
signature: mtx.signature,
|
|
362
|
-
data: tx.data,
|
|
363
|
-
},
|
|
364
|
-
assignment: {
|
|
365
|
-
id: tx.id,
|
|
366
|
-
tags: tx.tags,
|
|
367
|
-
owner: this.mem.addrmap[tx.owner],
|
|
368
|
-
anchor: tx.anchor ?? null,
|
|
369
|
-
target: null,
|
|
370
|
-
signature: tx.signature,
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
}
|
|
374
|
-
})(reverse(this.mem.env[pid]?.results ?? [])) // need mod
|
|
375
|
-
return { json: { page_info: { has_next_page: false }, edges } }
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
async mu_get_root({ query, params, body, headers, method }) {
|
|
379
|
-
return { send: "ao messenger unit" }
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
async mu_post_root({ query, params, body, headers, method }) {
|
|
383
|
-
let valid = await DataItem.verify(body)
|
|
384
|
-
let type = null
|
|
385
|
-
let item = null
|
|
386
|
-
if (valid) item = new DataItem(body)
|
|
387
|
-
const _tags = tags(item.tags)
|
|
388
|
-
let err = null
|
|
389
|
-
if (_tags.Type === "Process") {
|
|
390
|
-
const res = await this.spawn({
|
|
391
|
-
item,
|
|
392
|
-
module: _tags.Module,
|
|
393
|
-
scheduler: _tags.Scheduler,
|
|
394
|
-
})
|
|
395
|
-
if (!res) err = "bad requrest"
|
|
396
|
-
} else if (_tags.Type === "Message") {
|
|
397
|
-
await this.message({ item, process: item.target })
|
|
398
|
-
} else err = true
|
|
399
|
-
|
|
400
|
-
if (err) return { status: 400, error: err }
|
|
401
|
-
else return { json: { id: item.id } }
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
async mu_post_monitor({ query, params, body, headers, method }) {
|
|
405
|
-
await this.monitor({ process: params.pid })
|
|
406
|
-
return { json: { id: params.pid, messag: "cron monitored!" } }
|
|
407
|
-
}
|
|
408
|
-
async mu_delete_monitor({ query, params, body, headers, method }) {
|
|
409
|
-
await this.unmonitor({ process: params.pid })
|
|
410
|
-
return { json: { id: params.pid, message: "cron deleted!" } }
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
async ar_get_root({ query, params, body, headers, method }) {
|
|
414
|
-
return {
|
|
415
|
-
json: {
|
|
416
|
-
version: 1,
|
|
417
|
-
timestamp: Date.now(),
|
|
418
|
-
height: this.mem.height,
|
|
419
|
-
network: "wao.LN.1",
|
|
420
|
-
current: this.mem.getAnchor(),
|
|
421
|
-
},
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
async ar_get_wallet_balance({ query, params, body, headers, method }) {
|
|
425
|
-
return { send: "0" }
|
|
426
|
-
}
|
|
427
|
-
async ar_get_mint({ query, params, body, headers, method }) {
|
|
428
|
-
return { json: { id: "0" } }
|
|
429
|
-
}
|
|
430
|
-
async ar_get_tx_offset({ query, params, body, headers, method }) {
|
|
431
|
-
return { status: 400, send: null }
|
|
432
|
-
}
|
|
433
|
-
async ar_get_tx_anchor({ query, params, body, headers, method }) {
|
|
434
|
-
return { send: this.mem.getAnchor() }
|
|
435
|
-
}
|
|
436
|
-
async ar_get_mine({ query, params, body, headers, method }) {
|
|
437
|
-
return { json: params }
|
|
438
|
-
}
|
|
439
|
-
async ar_get_id({ query, params, body, headers, method }) {
|
|
440
|
-
const _data = await this._ar.data(params.id)
|
|
441
|
-
if (!_data) return { status: 404, send: null }
|
|
442
|
-
else return { send: Buffer.from(_data, "base64") }
|
|
443
|
-
}
|
|
444
|
-
async ar_get_price({ query, params, body, headers, method }) {
|
|
445
|
-
return { send: "0" }
|
|
446
|
-
}
|
|
447
|
-
async ar_post_graphql({ query, params, body, headers, method }) {
|
|
448
|
-
try {
|
|
449
|
-
const { query, variables } = body
|
|
450
|
-
const { tar, args } = toGraphObj({ query, variables })
|
|
451
|
-
let res2 = null
|
|
452
|
-
if (tar === "transactions") {
|
|
453
|
-
res2 = await this.gql.txs({ ...args })
|
|
454
|
-
} else if (tar === "blocks") {
|
|
455
|
-
res2 = await this.gql.blocks({ ...args })
|
|
456
|
-
}
|
|
457
|
-
const edges = map(v => ({ node: v, cursor: v.cursor }), res2)
|
|
458
|
-
return {
|
|
459
|
-
json: {
|
|
460
|
-
data: { transactions: { pageInfo: { hasNextPage: true }, edges } },
|
|
461
|
-
},
|
|
462
|
-
}
|
|
463
|
-
} catch (e) {
|
|
464
|
-
console.log(e)
|
|
465
|
-
return { status: 400, error: "bad request" }
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
async ar_post_id({ query, params, body, headers, method }) {
|
|
469
|
-
// id = "tx" | "chunk"
|
|
470
|
-
if (body.chunk) {
|
|
471
|
-
if (this.data[body.data_root]) {
|
|
472
|
-
this.data[body.data_root].data += body.chunk
|
|
473
|
-
const buf = Buffer.from(body.chunk, "base64")
|
|
474
|
-
if (!this.data[body.data_root].chunks) {
|
|
475
|
-
this.data[body.data_root].chunks = buf
|
|
476
|
-
} else {
|
|
477
|
-
this.data[body.data_root].chunks = Buffer.concat([
|
|
478
|
-
this.data[body.data_root].chunks,
|
|
479
|
-
buf,
|
|
480
|
-
])
|
|
481
|
-
}
|
|
482
|
-
delete body.chunk
|
|
483
|
-
if (
|
|
484
|
-
this.data[body.data_root].data_size <=
|
|
485
|
-
this.data[body.data_root].chunks.length
|
|
486
|
-
) {
|
|
487
|
-
this.data[body.data_root].data =
|
|
488
|
-
this.data[body.data_root].chunks.toString("base64")
|
|
489
|
-
await this._ar.postTx(this.data[body.data_root])
|
|
490
|
-
delete this.data[body.data_root]
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
return { json: { id: body.id } }
|
|
494
|
-
} else {
|
|
495
|
-
if (body.data_root && body.data === "") {
|
|
496
|
-
this.data[body.data_root] = body
|
|
497
|
-
} else {
|
|
498
|
-
await this._ar.postTx(body)
|
|
499
|
-
}
|
|
500
|
-
return { json: { id: body.id } }
|
|
501
|
-
}
|
|
5
|
+
class Adaptor extends Base {
|
|
6
|
+
constructor(obj) {
|
|
7
|
+
super({ ...obj, GQL, cu, su, mu, connect })
|
|
502
8
|
}
|
|
503
9
|
}
|
|
504
10
|
export default Adaptor
|
package/esm/index.js
CHANGED
package/esm/test.js
CHANGED
|
@@ -9,6 +9,7 @@ import ArMem from "./armem.js"
|
|
|
9
9
|
import { dirname } from "./utils.js"
|
|
10
10
|
import { Testnet, Src, setup, ok, fail } from "./helpers.js"
|
|
11
11
|
import Server from "./server.js"
|
|
12
|
+
import Adaptor from "./adaptor.js"
|
|
12
13
|
|
|
13
14
|
const blueprint = async pkg => {
|
|
14
15
|
return readFileSync(resolve(await dirname(), `lua/${pkg}.lua`), "utf8")
|
|
@@ -16,6 +17,7 @@ const blueprint = async pkg => {
|
|
|
16
17
|
const scheduler = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
|
|
17
18
|
|
|
18
19
|
export {
|
|
20
|
+
Adaptor,
|
|
19
21
|
Testnet,
|
|
20
22
|
Server,
|
|
21
23
|
GQL,
|
package/esm/web.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { acc, mu, su, cu } from "./accounts-web.js"
|
|
2
2
|
import { connect } from "./aoconnect-web.js"
|
|
3
|
+
import Adaptor from "./adaptor-web.js"
|
|
3
4
|
import AO from "./wao.js"
|
|
4
5
|
import AR from "./war.js"
|
|
5
6
|
import GQL from "./tgql.js"
|
|
@@ -7,4 +8,4 @@ import ArMem from "./armem-web.js"
|
|
|
7
8
|
import { dirname } from "./utils.js"
|
|
8
9
|
const scheduler = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
|
|
9
10
|
|
|
10
|
-
export { GQL, ArMem, AO, AR, connect, acc, mu, su, cu, scheduler }
|
|
11
|
+
export { GQL, ArMem, AO, AR, connect, acc, mu, su, cu, scheduler, Adaptor }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wao",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"bin": {
|
|
5
5
|
"wao": "./cjs/cli.js",
|
|
6
6
|
"wao-esm": "./esm/cli.js"
|
|
@@ -20,10 +20,6 @@
|
|
|
20
20
|
"require": "./cjs/test.js",
|
|
21
21
|
"import": "./esm/test.js"
|
|
22
22
|
},
|
|
23
|
-
"./server": {
|
|
24
|
-
"require": "./cjs/server.js",
|
|
25
|
-
"import": "./esm/server.js"
|
|
26
|
-
},
|
|
27
23
|
"./web": {
|
|
28
24
|
"require": "./cjs/web.js",
|
|
29
25
|
"import": "./esm/web.js"
|