wao 0.22.4 → 0.23.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/cjs/adaptor-base.js +28 -22
- package/cjs/hb.js +398 -214
- package/cjs/hyperbeam.js +5 -1
- package/cjs/server.js +1 -1
- package/esm/adaptor-base.js +3 -0
- package/esm/hb.js +65 -8
- package/esm/hyperbeam.js +6 -2
- package/esm/server.js +1 -0
- package/package.json +1 -1
package/cjs/hyperbeam.js
CHANGED
|
@@ -75,7 +75,11 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
75
75
|
legacy = _ref2$legacy === void 0 ? false : _ref2$legacy;
|
|
76
76
|
var _wallet = ", priv_key_location => <<\"".concat(wallet, "\">>");
|
|
77
77
|
var _gateway = gateway ? ", gateway => <<\"http://localhost:".concat(gateway, "\">>") : "";
|
|
78
|
-
|
|
78
|
+
var _store = ", store => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"cache-mainnet\">> }, #{ <<\"store-module\">> => hb_store_gateway, <<\"subindex\">> => [#{ <<\"name\">> => <<\"Data-Protocol\">>, <<\"value\">> => <<\"ao\">> }], <<\"store\">> => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"cache-mainnet\">> }] }, #{ <<\"store-module\">> => hb_store_gateway, <<\"store\">> => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"cache-mainnet\">> }] }]";
|
|
79
|
+
var _bundler = ", bundler_httpsig => <<\"http://localhost:4001\">>";
|
|
80
|
+
var _routes = ", routes => [#{ <<\"template\">> => <<\"/result/.*\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:6363\">> } }, #{ <<\"template\">> => <<\"/graphql\">>, <<\"nodes\">> => [#{ <<\"prefix\">> => <<\"http://localhost:".concat(gateway, "\">>, <<\"opts\">> => #{ http_client => httpc, protocol => http2 } }, #{ <<\"prefix\">> => <<\"http://localhost:").concat(gateway, "\">>, <<\"opts\">> => #{ http_client => gun, protocol => http2 } }] }, #{ <<\"template\">> => <<\"/raw\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:").concat(gateway, "\">>, <<\"opts\">> => #{ http_client => gun, protocol => http2 } } }]");
|
|
81
|
+
var _port = "port => ".concat(this.port);
|
|
82
|
+
return !legacy ? "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_store, " }).") : "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_store).concat(_bundler).concat(_routes, " }).");
|
|
79
83
|
}
|
|
80
84
|
}, {
|
|
81
85
|
key: "kill",
|
package/cjs/server.js
CHANGED
|
@@ -88,7 +88,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
88
88
|
limit: "100mb"
|
|
89
89
|
}));
|
|
90
90
|
this.launch("AR", app, {
|
|
91
|
-
get: ["/", "/wallet/:id/balance", "/mint/:id/:amount", "/tx/:id/offset", "/tx_anchor", "/mine", "/:id", "/price/:id"],
|
|
91
|
+
get: ["/", "/tx", "/wallet/:id/balance", "/mint/:id/:amount", "/tx/:id/offset", "/tx_anchor", "/mine", "/:id", "/price/:id"],
|
|
92
92
|
post: ["/graphql", "/:id"]
|
|
93
93
|
});
|
|
94
94
|
}
|
package/esm/adaptor-base.js
CHANGED
|
@@ -90,6 +90,8 @@ class Adaptor {
|
|
|
90
90
|
switch (req.path) {
|
|
91
91
|
case "/":
|
|
92
92
|
return await this.ar_get_root(req)
|
|
93
|
+
case "/tx":
|
|
94
|
+
return await this.ar_get_tx(req)
|
|
93
95
|
case "/wallet/:id/balance":
|
|
94
96
|
return await this.ar_get_wallet_balance(req)
|
|
95
97
|
case "/mint/:id/:amount":
|
|
@@ -469,6 +471,7 @@ class Adaptor {
|
|
|
469
471
|
async ar_post_graphql({ query, params, body, headers, method }) {
|
|
470
472
|
try {
|
|
471
473
|
const { query, variables } = body
|
|
474
|
+
console.log(query, variables)
|
|
472
475
|
const { tar, args } = toGraphObj({ query, variables })
|
|
473
476
|
let res2 = null
|
|
474
477
|
if (tar === "transactions") {
|
package/esm/hb.js
CHANGED
|
@@ -83,10 +83,21 @@ class HB {
|
|
|
83
83
|
async getImage() {
|
|
84
84
|
const result = await this.send({
|
|
85
85
|
path: "/~wao@1.0/cache_wasm_image",
|
|
86
|
-
method: "POST",
|
|
87
86
|
filename: "test/aos-2-pure-xs.wasm",
|
|
88
87
|
})
|
|
89
|
-
|
|
88
|
+
const image = result.headers.get("image")
|
|
89
|
+
this.image ??= image
|
|
90
|
+
return image
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async getLua() {
|
|
94
|
+
const result = await this.send({
|
|
95
|
+
path: "/~wao@1.0/cache_lua_module",
|
|
96
|
+
filename: "test/hyper-aos.lua",
|
|
97
|
+
})
|
|
98
|
+
const lua = result.headers.get("id").split("/").pop()
|
|
99
|
+
this.lua ??= lua
|
|
100
|
+
return lua
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
async messageAOS({ pid, action = "Eval", tags = {}, data }) {
|
|
@@ -106,7 +117,7 @@ class HB {
|
|
|
106
117
|
return { slot, outbox: await this.computeAOS({ pid, slot }) }
|
|
107
118
|
}
|
|
108
119
|
|
|
109
|
-
path(dev = "
|
|
120
|
+
path(dev = "message", path, json = true, params = {}, pid = "", tail = "") {
|
|
110
121
|
if (!/@/.test(dev)) dev += "@1.0"
|
|
111
122
|
let _params = ""
|
|
112
123
|
if (!isEmpty(params)) {
|
|
@@ -116,15 +127,28 @@ class HB {
|
|
|
116
127
|
i++
|
|
117
128
|
}
|
|
118
129
|
}
|
|
119
|
-
return `${this.url}
|
|
130
|
+
return `${this.url}/${pid}~${dev}${path ? `/${path}` : ""}${tail}${json ? "/~json@1.0/serialize" : ""}${_params}`
|
|
120
131
|
}
|
|
121
132
|
|
|
122
|
-
async text(dev, path) {
|
|
123
|
-
|
|
133
|
+
async text(dev, path, params = {}, tail) {
|
|
134
|
+
let pid = ""
|
|
135
|
+
if (/^[a-zA-Z0-9_-]{43}$/.test(dev)) {
|
|
136
|
+
pid = dev
|
|
137
|
+
dev = "process"
|
|
138
|
+
}
|
|
139
|
+
return await this.fetch(
|
|
140
|
+
this.path(dev, path, false, params, pid, tail),
|
|
141
|
+
false
|
|
142
|
+
)
|
|
124
143
|
}
|
|
125
144
|
|
|
126
|
-
async json(dev, path) {
|
|
127
|
-
|
|
145
|
+
async json(dev, path, params = {}, tail) {
|
|
146
|
+
let pid = ""
|
|
147
|
+
if (/^[a-zA-Z0-9_-]{43}$/.test(dev)) {
|
|
148
|
+
pid = dev
|
|
149
|
+
dev = "process"
|
|
150
|
+
}
|
|
151
|
+
return await this.fetch(this.path(dev, path, true, params, pid, tail))
|
|
128
152
|
}
|
|
129
153
|
|
|
130
154
|
async fetch(url, json = true) {
|
|
@@ -137,6 +161,12 @@ class HB {
|
|
|
137
161
|
).then(r => r.json())
|
|
138
162
|
}
|
|
139
163
|
|
|
164
|
+
async computeLua({ pid, slot }) {
|
|
165
|
+
return await fetch(
|
|
166
|
+
`${this.url}/${pid}/compute/results/~json@1.0/serialize?slot=${slot}`
|
|
167
|
+
).then(r => r.json())
|
|
168
|
+
}
|
|
169
|
+
|
|
140
170
|
async compute({ pid, slot }) {
|
|
141
171
|
return await fetch(
|
|
142
172
|
`${this.url}/${pid}/compute/~json@1.0/serialize?slot=${slot}`
|
|
@@ -181,6 +211,9 @@ class HB {
|
|
|
181
211
|
if (action) tags.Action = action
|
|
182
212
|
return await this.schedule({ pid, tags, data, scheduler })
|
|
183
213
|
}
|
|
214
|
+
async scheduleLua(...args) {
|
|
215
|
+
return await this.scheduleLegacy(...args)
|
|
216
|
+
}
|
|
184
217
|
async schedule({ pid, tags = {}, data, scheduler } = {}) {
|
|
185
218
|
pid ??= this.pid
|
|
186
219
|
scheduler ??= this.scheduler
|
|
@@ -229,6 +262,30 @@ class HB {
|
|
|
229
262
|
return { pid, res }
|
|
230
263
|
}
|
|
231
264
|
|
|
265
|
+
async spawnLua(lua = "8DvyaxF8xpHMgPdmpMnhcb1mjY-M8qr2kGxnCpGMb60") {
|
|
266
|
+
const addr = await this.dev.meta.info({ key: "address" })
|
|
267
|
+
this.scheduler ??= addr
|
|
268
|
+
lua ??= this.lua ?? (await this.getLua())
|
|
269
|
+
const res = await this.send({
|
|
270
|
+
device: "process@1.0",
|
|
271
|
+
path: "/schedule",
|
|
272
|
+
scheduler: this.scheduler,
|
|
273
|
+
"Data-Protocol": "ao",
|
|
274
|
+
Variant: "ao.N.1",
|
|
275
|
+
"scheduler-location": this.scheduler,
|
|
276
|
+
Authority: this.scheduler,
|
|
277
|
+
"random-seed": seed(16),
|
|
278
|
+
Type: "Process",
|
|
279
|
+
module: lua,
|
|
280
|
+
"scheduler-device": "scheduler@1.0",
|
|
281
|
+
"execution-device": "lua@5.3a",
|
|
282
|
+
"patch-from": "/results/outbox",
|
|
283
|
+
})
|
|
284
|
+
const pid = res.headers.get("process")
|
|
285
|
+
this.pid ??= pid
|
|
286
|
+
return { pid, res }
|
|
287
|
+
}
|
|
288
|
+
|
|
232
289
|
parseMetrics(txt) {
|
|
233
290
|
const parts = txt.split(/\r?\n/)
|
|
234
291
|
let index = 0
|
package/esm/hyperbeam.js
CHANGED
|
@@ -46,9 +46,13 @@ export default class HyperBEAM {
|
|
|
46
46
|
const _gateway = gateway
|
|
47
47
|
? `, gateway => <<"http://localhost:${gateway}">>`
|
|
48
48
|
: ""
|
|
49
|
+
const _store = `, store => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"cache-mainnet">> }, #{ <<"store-module">> => hb_store_gateway, <<"subindex">> => [#{ <<"name">> => <<"Data-Protocol">>, <<"value">> => <<"ao">> }], <<"store">> => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"cache-mainnet">> }] }, #{ <<"store-module">> => hb_store_gateway, <<"store">> => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"cache-mainnet">> }] }]`
|
|
50
|
+
const _bundler = `, bundler_httpsig => <<"http://localhost:4001">>`
|
|
51
|
+
const _routes = `, routes => [#{ <<"template">> => <<"/result/.*">>, <<"node">> => #{ <<"prefix">> => <<"http://localhost:6363">> } }, #{ <<"template">> => <<"/graphql">>, <<"nodes">> => [#{ <<"prefix">> => <<"http://localhost:${gateway}">>, <<"opts">> => #{ http_client => httpc, protocol => http2 } }, #{ <<"prefix">> => <<"http://localhost:${gateway}">>, <<"opts">> => #{ http_client => gun, protocol => http2 } }] }, #{ <<"template">> => <<"/raw">>, <<"node">> => #{ <<"prefix">> => <<"http://localhost:${gateway}">>, <<"opts">> => #{ http_client => gun, protocol => http2 } } }]`
|
|
52
|
+
const _port = `port => ${this.port}`
|
|
49
53
|
return !legacy
|
|
50
|
-
? `hb:start_mainnet(#{
|
|
51
|
-
: `hb:start_mainnet(#{
|
|
54
|
+
? `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store} }).`
|
|
55
|
+
: `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store}${_bundler}${_routes} }).`
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
kill() {
|
package/esm/server.js
CHANGED