wao 0.25.3 → 0.25.4

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/esm/hb.js CHANGED
@@ -4,6 +4,8 @@ import { toAddr, buildTags } from "./utils.js"
4
4
  import { send as _send, createRequest } from "./signer.js"
5
5
  import { resolve } from "path"
6
6
  import { readFileSync } from "fs"
7
+ import hyper_aos from "./lua/hyper-aos.js"
8
+ import aos_wamr from "./lua/aos_wamr.js"
7
9
 
8
10
  const seed = num => {
9
11
  const array = new Uint8Array(num)
@@ -29,7 +31,6 @@ class HB {
29
31
  )
30
32
  },
31
33
  }
32
-
33
34
  this.dev.json = {
34
35
  commit: async args => {
35
36
  return await this.post({ path: "/~json@1.0/commit", ...args })
@@ -97,18 +98,14 @@ class HB {
97
98
  }
98
99
 
99
100
  async getImage() {
100
- const wasm = readFileSync(
101
- resolve(import.meta.dirname, "./lua/aos2-wamr.wasm")
102
- )
101
+ const wasm = Buffer.from(aos_wamr, "base64")
103
102
  const id = await this.cacheModule(wasm, "application/wasm")
104
103
  this.image ??= id
105
104
  return id
106
105
  }
107
106
 
108
107
  async getLua() {
109
- const lua = readFileSync(
110
- resolve(import.meta.dirname, "./lua/hyper-aos.lua")
111
- )
108
+ const lua = Buffer.from(hyper_aos, "base64")
112
109
  const id = await this.cacheModule(lua, "application/lua")
113
110
  this.lua ??= id
114
111
  return id
@@ -281,6 +278,7 @@ class HB {
281
278
  Type: "Process",
282
279
  image,
283
280
  "execution-device": "stack@1.0",
281
+ "push-device": "push@1.0",
284
282
  "device-stack": [
285
283
  "wasi@1.0",
286
284
  "json-iface@1.0",
@@ -315,6 +313,7 @@ class HB {
315
313
  Type: "Process",
316
314
  module: lua,
317
315
  "execution-device": "lua@5.3a",
316
+ "push-device": "push@1.0",
318
317
  "patch-from": "/results/outbox",
319
318
  })
320
319
  const pid = res.headers.process
@@ -385,24 +384,42 @@ class HB {
385
384
  Authority: this._info.address,
386
385
  "scheduler-location": this._info.address,
387
386
  "random-seed": seed(16),
388
- module: "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
387
+ module: module ?? "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
389
388
  device: "process@1.0",
390
389
  "scheduler-device": "scheduler@1.0",
391
390
  "execution-device": "stack@1.0",
391
+ "push-device": "push@1.0",
392
392
  "device-stack": ["genesis-wasm@1.0", "patch@1.0"],
393
393
  "patch-from": "/results/outbox",
394
394
  "stack-keys": ["init", "compute", "snapshot", "normalize"],
395
395
  })
396
396
  return await this.spawn(tags)
397
397
  }
398
-
398
+ async results({ process, limit, sort = "DESC", from, to } = {}) {
399
+ let params = ""
400
+ const addParam = (key, val) => {
401
+ params += params === "" ? "?" : "&"
402
+ params += `${key}=${val}`
403
+ }
404
+ if (limit) addParam("limit", limit)
405
+ if (sort) addParam("sort", sort)
406
+ if (from) addParam("from", from)
407
+ if (to) addParam("to", to)
408
+ const res = await this.post({
409
+ path: "/~relay@1.0/call",
410
+ method: "GET",
411
+ "relay-path": `${this.cu}/results/${process}${params}`,
412
+ "content-type": "application/json",
413
+ })
414
+ return JSON.parse(res.body)
415
+ }
399
416
  async dryrun({ tags = {}, pid, action, data } = {}) {
400
417
  if (typeof action === "string") tags.Action = action
401
418
  let json = { Tags: buildTags({ ...tags }), Owner: this.addr }
402
419
  if (data) json.Data = data
403
420
  const res = await this.post({
404
421
  path: "/~relay@1.0/call",
405
- "relay-method": "POST",
422
+ method: "POST",
406
423
  "relay-path": `${this.cu}/dry-run?process-id=${pid}`,
407
424
  "content-type": "application/json",
408
425
  "relay-body": JSON.stringify(json),
package/esm/hyperbeam.js CHANGED
@@ -15,14 +15,15 @@ export default class HyperBEAM {
15
15
  cwd = "./HyperBEAM",
16
16
  c,
17
17
  cmake,
18
- legacy = false,
19
18
  faff,
20
19
  simplePay = false,
21
20
  simplePayPrice,
22
21
  p4_lua,
23
22
  store_prefix,
24
23
  operator,
24
+ console = true,
25
25
  } = {}) {
26
+ this.console = console
26
27
  if (clearCache) {
27
28
  const dirname = resolve(process.cwd(), cwd)
28
29
  for (let v of readdirSync(dirname)) {
@@ -69,14 +70,16 @@ export default class HyperBEAM {
69
70
  cwd: resolve(process.cwd(), this.cwd),
70
71
  }
71
72
  )
72
- this.hbeam.stdout.on("data", chunk => console.log(chunk.toString()))
73
- this.hbeam.stderr.on("data", err => console.error(err.toString()))
74
- this.hbeam.on("error", err =>
75
- console.error(`failed to start process: ${err}`)
76
- )
77
- this.hbeam.on("close", code =>
78
- console.log(`child process exited with code ${code}`)
79
- )
73
+ if (this.console) {
74
+ this.hbeam.stdout.on("data", chunk => console.log(chunk.toString()))
75
+ this.hbeam.stderr.on("data", err => console.error(err.toString()))
76
+ this.hbeam.on("error", err =>
77
+ console.error(`failed to start process: ${err}`)
78
+ )
79
+ this.hbeam.on("close", code =>
80
+ console.log(`child process exited with code ${code}`)
81
+ )
82
+ }
80
83
  }
81
84
  async ok() {
82
85
  try {