wao 0.36.1 → 0.36.3
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/bundler.js +219 -0
- package/cjs/hb.js +49 -37
- package/cjs/hyperbeam.js +8 -3
- package/esm/bundler.js +117 -0
- package/esm/hb.js +35 -26
- package/esm/hyperbeam.js +14 -4
- package/package.json +3 -2
package/cjs/bundler.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _express = _interopRequireDefault(require("express"));
|
|
9
|
+
var _turboSdk = require("@ardrive/turbo-sdk");
|
|
10
|
+
var _arbundles = require("@dha-team/arbundles");
|
|
11
|
+
var _cors = _interopRequireDefault(require("cors"));
|
|
12
|
+
var _bodyParser = _interopRequireDefault(require("body-parser"));
|
|
13
|
+
var _hbsig = require("hbsig");
|
|
14
|
+
var _ramda = require("ramda");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
17
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
18
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
19
|
+
var timestamp = 0;
|
|
20
|
+
var height = 0;
|
|
21
|
+
var last_checked = 0;
|
|
22
|
+
var nonce = 0;
|
|
23
|
+
var toMsg = function toMsg(req) {
|
|
24
|
+
var msg = req.headers;
|
|
25
|
+
if (req.body) msg.body = req.body.toString("binary");
|
|
26
|
+
return msg;
|
|
27
|
+
};
|
|
28
|
+
var bundler = function bundler() {
|
|
29
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
30
|
+
_ref$port = _ref.port,
|
|
31
|
+
port = _ref$port === void 0 ? 4001 : _ref$port,
|
|
32
|
+
jwk = _ref.jwk,
|
|
33
|
+
_ref$timeout = _ref.timeout,
|
|
34
|
+
timeout = _ref$timeout === void 0 ? 1000 * 60 : _ref$timeout;
|
|
35
|
+
var app = (0, _express["default"])();
|
|
36
|
+
app.use((0, _cors["default"])());
|
|
37
|
+
app.use(_bodyParser["default"].raw({
|
|
38
|
+
type: "*/*",
|
|
39
|
+
limit: "100mb"
|
|
40
|
+
}));
|
|
41
|
+
app.post("/tx", /*#__PURE__*/function () {
|
|
42
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, res) {
|
|
43
|
+
var out, k, _out$body$commitments, _out$body, _out$body2, msg, signer, tags, type, _i, _Object$values, tagObj, opt, di, _res, dis, _out$blockHeight, _out$blockTimestamp, json, atags, _tags, _k, _signer, di2, res2;
|
|
44
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
45
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
if (Buffer.isBuffer(req.body)) {
|
|
48
|
+
_context2.next = 3;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
console.log("BD: Invalid body | expected raw Buffer");
|
|
52
|
+
return _context2.abrupt("return", res.status(400).send("Invalid body: expected raw Buffer"));
|
|
53
|
+
case 3:
|
|
54
|
+
res.status(200).send("success");
|
|
55
|
+
_context2.prev = 4;
|
|
56
|
+
out = (0, _hbsig.structured_to)((0, _hbsig.httpsig_from)(toMsg(req)));
|
|
57
|
+
_context2.t0 = _regeneratorRuntime().keys((_out$body$commitments = (_out$body = out.body) === null || _out$body === void 0 ? void 0 : _out$body.commitments) !== null && _out$body$commitments !== void 0 ? _out$body$commitments : {});
|
|
58
|
+
case 7:
|
|
59
|
+
if ((_context2.t1 = _context2.t0()).done) {
|
|
60
|
+
_context2.next = 57;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
k = _context2.t1.value;
|
|
64
|
+
msg = (_out$body2 = out.body) === null || _out$body2 === void 0 ? void 0 : _out$body2.commitments[k];
|
|
65
|
+
signer = {
|
|
66
|
+
signatureType: 1,
|
|
67
|
+
signatureLength: 512,
|
|
68
|
+
ownerLength: 512,
|
|
69
|
+
publicKey: msg.owner,
|
|
70
|
+
sign: function () {
|
|
71
|
+
var _sign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
72
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
73
|
+
while (1) switch (_context.prev = _context.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
case "end":
|
|
76
|
+
return _context.stop();
|
|
77
|
+
}
|
|
78
|
+
}, _callee);
|
|
79
|
+
}));
|
|
80
|
+
function sign() {
|
|
81
|
+
return _sign.apply(this, arguments);
|
|
82
|
+
}
|
|
83
|
+
return sign;
|
|
84
|
+
}()
|
|
85
|
+
};
|
|
86
|
+
tags = [];
|
|
87
|
+
type = null;
|
|
88
|
+
if (msg["original-tags"]) {
|
|
89
|
+
for (_i = 0, _Object$values = Object.values(msg["original-tags"]); _i < _Object$values.length; _i++) {
|
|
90
|
+
tagObj = _Object$values[_i];
|
|
91
|
+
tags.push({
|
|
92
|
+
name: tagObj.name,
|
|
93
|
+
value: tagObj.value
|
|
94
|
+
});
|
|
95
|
+
if (tagObj.name === "Type") {
|
|
96
|
+
type = tagObj.value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
opt = {
|
|
101
|
+
tags: tags
|
|
102
|
+
};
|
|
103
|
+
if (type !== "Process") opt.target = out.process;
|
|
104
|
+
_context2.next = 18;
|
|
105
|
+
return (0, _arbundles.createData)(out.data || "", signer, opt);
|
|
106
|
+
case 18:
|
|
107
|
+
di = _context2.sent;
|
|
108
|
+
_context2.next = 21;
|
|
109
|
+
return di.setSignature(msg.signature);
|
|
110
|
+
case 21:
|
|
111
|
+
_context2.next = 23;
|
|
112
|
+
return fetch("https://up.arweave.net:443/tx", {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: {
|
|
115
|
+
"Content-Type": "application/octet-stream"
|
|
116
|
+
},
|
|
117
|
+
body: di.binary
|
|
118
|
+
});
|
|
119
|
+
case 23:
|
|
120
|
+
_res = _context2.sent;
|
|
121
|
+
console.log(_res === null || _res === void 0 ? void 0 : _res.status, di.tags);
|
|
122
|
+
dis = [di];
|
|
123
|
+
if (!(type === "Message")) {
|
|
124
|
+
_context2.next = 55;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (out["block-timestamp"]) {
|
|
128
|
+
_context2.next = 41;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
_context2.prev = 28;
|
|
132
|
+
if (!(Date.now() - last_checked > timeout)) {
|
|
133
|
+
_context2.next = 36;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
_context2.next = 32;
|
|
137
|
+
return fetch("https://arweave.net/block/current").then(function (r) {
|
|
138
|
+
return r.json();
|
|
139
|
+
});
|
|
140
|
+
case 32:
|
|
141
|
+
json = _context2.sent;
|
|
142
|
+
height = json.height;
|
|
143
|
+
timestamp = json.timestamp;
|
|
144
|
+
last_checked = Date.now();
|
|
145
|
+
case 36:
|
|
146
|
+
_context2.next = 41;
|
|
147
|
+
break;
|
|
148
|
+
case 38:
|
|
149
|
+
_context2.prev = 38;
|
|
150
|
+
_context2.t2 = _context2["catch"](28);
|
|
151
|
+
console.log(_context2.t2);
|
|
152
|
+
case 41:
|
|
153
|
+
atags = {
|
|
154
|
+
Process: out.process,
|
|
155
|
+
Epoch: out.epoch,
|
|
156
|
+
Nonce: Number(++nonce).toString(),
|
|
157
|
+
"Hash-Chain": out["hash-chain"],
|
|
158
|
+
"Block-Height": Number((_out$blockHeight = out["block-height"]) !== null && _out$blockHeight !== void 0 ? _out$blockHeight : height).toString(),
|
|
159
|
+
Tmestamp: Number((_out$blockTimestamp = out["block-timestamp"]) !== null && _out$blockTimestamp !== void 0 ? _out$blockTimestamp : timestamp).toString(),
|
|
160
|
+
"Data-Protocol": "ao",
|
|
161
|
+
Slot: Number(out.slot).toString(),
|
|
162
|
+
Variant: "ao.WDB.1",
|
|
163
|
+
Type: "Assignment",
|
|
164
|
+
Message: di.id
|
|
165
|
+
};
|
|
166
|
+
_tags = [];
|
|
167
|
+
if (msg["original-tags"]) {
|
|
168
|
+
for (_k in atags) _tags.push({
|
|
169
|
+
name: _k,
|
|
170
|
+
value: atags[_k]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
_signer = new _turboSdk.ArweaveSigner(jwk);
|
|
174
|
+
_context2.next = 47;
|
|
175
|
+
return (0, _arbundles.createData)("", _signer, {
|
|
176
|
+
tags: _tags
|
|
177
|
+
});
|
|
178
|
+
case 47:
|
|
179
|
+
di2 = _context2.sent;
|
|
180
|
+
_context2.next = 50;
|
|
181
|
+
return di2.sign(_signer);
|
|
182
|
+
case 50:
|
|
183
|
+
dis.push(di2);
|
|
184
|
+
_context2.next = 53;
|
|
185
|
+
return fetch("https://up.arweave.net:443/tx", {
|
|
186
|
+
method: "POST",
|
|
187
|
+
headers: {
|
|
188
|
+
"Content-Type": "application/octet-stream"
|
|
189
|
+
},
|
|
190
|
+
body: di2.binary
|
|
191
|
+
});
|
|
192
|
+
case 53:
|
|
193
|
+
res2 = _context2.sent;
|
|
194
|
+
console.log(res2 === null || res2 === void 0 ? void 0 : res2.status, di2.tags);
|
|
195
|
+
case 55:
|
|
196
|
+
_context2.next = 7;
|
|
197
|
+
break;
|
|
198
|
+
case 57:
|
|
199
|
+
_context2.next = 62;
|
|
200
|
+
break;
|
|
201
|
+
case 59:
|
|
202
|
+
_context2.prev = 59;
|
|
203
|
+
_context2.t3 = _context2["catch"](4);
|
|
204
|
+
console.log(_context2.t3);
|
|
205
|
+
case 62:
|
|
206
|
+
case "end":
|
|
207
|
+
return _context2.stop();
|
|
208
|
+
}
|
|
209
|
+
}, _callee2, null, [[4, 59], [28, 38]]);
|
|
210
|
+
}));
|
|
211
|
+
return function (_x, _x2) {
|
|
212
|
+
return _ref2.apply(this, arguments);
|
|
213
|
+
};
|
|
214
|
+
}());
|
|
215
|
+
return app.listen(port, function () {
|
|
216
|
+
return console.log("BD on port ".concat(port));
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
var _default = exports["default"] = bundler;
|
package/cjs/hb.js
CHANGED
|
@@ -492,7 +492,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
492
492
|
data: data,
|
|
493
493
|
pid: this.cache,
|
|
494
494
|
tags: {
|
|
495
|
-
"
|
|
495
|
+
"Content-Type": type
|
|
496
496
|
}
|
|
497
497
|
});
|
|
498
498
|
case 9:
|
|
@@ -600,7 +600,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
600
600
|
case 0:
|
|
601
601
|
_ref7 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, pid = _ref7.pid, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data;
|
|
602
602
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
603
|
-
|
|
603
|
+
Type: "Message",
|
|
604
604
|
target: pid
|
|
605
605
|
});
|
|
606
606
|
if (data) _tags.data = data;
|
|
@@ -677,23 +677,23 @@ var HB = /*#__PURE__*/function () {
|
|
|
677
677
|
key: "post104",
|
|
678
678
|
value: function () {
|
|
679
679
|
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref9) {
|
|
680
|
-
var _ref9$path, path, _ref9$tags, tags, _ref9$data, data, _tags, signer, di, res
|
|
680
|
+
var _ref9$path, path, _ref9$tags, tags, _ref9$data, data, target, _tags, signer, di, res;
|
|
681
681
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
682
682
|
while (1) switch (_context19.prev = _context19.next) {
|
|
683
683
|
case 0:
|
|
684
|
-
_ref9$path = _ref9.path, path = _ref9$path === void 0 ? "/~process@1.0/schedule" : _ref9$path, _ref9$tags = _ref9.tags, tags = _ref9$tags === void 0 ? {} : _ref9$tags, _ref9$data = _ref9.data, data = _ref9$data === void 0 ? "1984" : _ref9$data;
|
|
684
|
+
_ref9$path = _ref9.path, path = _ref9$path === void 0 ? "/~process@1.0/schedule" : _ref9$path, _ref9$tags = _ref9.tags, tags = _ref9$tags === void 0 ? {} : _ref9$tags, _ref9$data = _ref9.data, data = _ref9$data === void 0 ? "1984" : _ref9$data, target = _ref9.target;
|
|
685
685
|
_tags = (0, _utils.buildTags)((0, _ramda.mergeLeft)(tags, {
|
|
686
686
|
signingFormat: "ANS-104"
|
|
687
687
|
}));
|
|
688
688
|
signer = new _sdk.ArweaveSigner(this.jwk);
|
|
689
|
-
console.log(_tags);
|
|
690
689
|
di = (0, _arbundles.createData)(data, signer, {
|
|
691
|
-
tags: _tags
|
|
690
|
+
tags: _tags,
|
|
691
|
+
target: target
|
|
692
692
|
});
|
|
693
|
-
_context19.next =
|
|
693
|
+
_context19.next = 6;
|
|
694
694
|
return di.sign(signer);
|
|
695
|
-
case
|
|
696
|
-
_context19.next =
|
|
695
|
+
case 6:
|
|
696
|
+
_context19.next = 8;
|
|
697
697
|
return fetch("".concat(this.url).concat(path), {
|
|
698
698
|
method: "POST",
|
|
699
699
|
headers: {
|
|
@@ -702,19 +702,18 @@ var HB = /*#__PURE__*/function () {
|
|
|
702
702
|
},
|
|
703
703
|
body: di.binary
|
|
704
704
|
});
|
|
705
|
-
case
|
|
705
|
+
case 8:
|
|
706
706
|
res = _context19.sent;
|
|
707
707
|
_context19.t0 = _hbsig.structured_to;
|
|
708
708
|
_context19.t1 = _hbsig.httpsig_from;
|
|
709
|
-
_context19.next =
|
|
709
|
+
_context19.next = 13;
|
|
710
710
|
return toMsg(res);
|
|
711
|
-
case
|
|
711
|
+
case 13:
|
|
712
712
|
_context19.t2 = _context19.sent;
|
|
713
713
|
_context19.t3 = (0, _context19.t1)(_context19.t2);
|
|
714
|
-
|
|
715
|
-
res.out = _headers;
|
|
714
|
+
res.out = (0, _context19.t0)(_context19.t3);
|
|
716
715
|
return _context19.abrupt("return", res);
|
|
717
|
-
case
|
|
716
|
+
case 17:
|
|
718
717
|
case "end":
|
|
719
718
|
return _context19.stop();
|
|
720
719
|
}
|
|
@@ -750,10 +749,11 @@ var HB = /*#__PURE__*/function () {
|
|
|
750
749
|
break;
|
|
751
750
|
}
|
|
752
751
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
753
|
-
|
|
752
|
+
Type: "Message"
|
|
754
753
|
});
|
|
755
754
|
_context20.next = 6;
|
|
756
755
|
return this.post104({
|
|
756
|
+
target: pid,
|
|
757
757
|
path: "/".concat(pid, "/schedule"),
|
|
758
758
|
tags: _tags,
|
|
759
759
|
data: data !== null && data !== void 0 ? data : "1984"
|
|
@@ -764,7 +764,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
764
764
|
break;
|
|
765
765
|
case 9:
|
|
766
766
|
_tags2 = (0, _ramda.mergeLeft)(tags, {
|
|
767
|
-
|
|
767
|
+
Type: "Message",
|
|
768
768
|
target: pid
|
|
769
769
|
});
|
|
770
770
|
if (data) _tags2.data = data;
|
|
@@ -857,9 +857,9 @@ var HB = /*#__PURE__*/function () {
|
|
|
857
857
|
case 10:
|
|
858
858
|
_context22.t2 = _context22.t1;
|
|
859
859
|
tags = {
|
|
860
|
-
"
|
|
861
|
-
|
|
862
|
-
|
|
860
|
+
"Data-Protocol": "ao",
|
|
861
|
+
Variant: "ao.N.1",
|
|
862
|
+
Authority: _context22.t0,
|
|
863
863
|
module: _context22.t2,
|
|
864
864
|
"execution-device": "lua@5.3a",
|
|
865
865
|
"push-device": "push@1.0",
|
|
@@ -920,19 +920,31 @@ var HB = /*#__PURE__*/function () {
|
|
|
920
920
|
key: "slot",
|
|
921
921
|
value: function () {
|
|
922
922
|
var _slot = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref13) {
|
|
923
|
-
var pid, _ref13$path, path;
|
|
923
|
+
var pid, _ref13$path, path, res;
|
|
924
924
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
925
925
|
while (1) switch (_context24.prev = _context24.next) {
|
|
926
926
|
case 0:
|
|
927
927
|
pid = _ref13.pid, _ref13$path = _ref13.path, path = _ref13$path === void 0 ? "" : _ref13$path;
|
|
928
928
|
if (path && !/^\//.test(path)) path = "/" + path;
|
|
929
|
-
|
|
929
|
+
if (!(this.format === "ans104")) {
|
|
930
|
+
_context24.next = 9;
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
_context24.next = 5;
|
|
934
|
+
return this.get({
|
|
935
|
+
path: "/".concat(pid, "/slot").concat(path)
|
|
936
|
+
});
|
|
937
|
+
case 5:
|
|
938
|
+
res = _context24.sent;
|
|
939
|
+
return _context24.abrupt("return", res.out);
|
|
940
|
+
case 9:
|
|
941
|
+
_context24.next = 11;
|
|
930
942
|
return this.getJSON({
|
|
931
943
|
path: "/".concat(pid, "/slot").concat(path)
|
|
932
944
|
});
|
|
933
|
-
case
|
|
945
|
+
case 11:
|
|
934
946
|
return _context24.abrupt("return", _context24.sent);
|
|
935
|
-
case
|
|
947
|
+
case 12:
|
|
936
948
|
case "end":
|
|
937
949
|
return _context24.stop();
|
|
938
950
|
}
|
|
@@ -1027,10 +1039,10 @@ var HB = /*#__PURE__*/function () {
|
|
|
1027
1039
|
tags: (0, _ramda.mergeLeft)(tags, {
|
|
1028
1040
|
"codec-device": "ans104@1.0",
|
|
1029
1041
|
"random-seed": (0, _utils.seed)(16),
|
|
1030
|
-
|
|
1042
|
+
Type: "Process",
|
|
1031
1043
|
"execution-device": "test-device@1.0",
|
|
1032
1044
|
device: "process@1.0",
|
|
1033
|
-
|
|
1045
|
+
Scheduler: this.operator
|
|
1034
1046
|
})
|
|
1035
1047
|
});
|
|
1036
1048
|
case 7:
|
|
@@ -1042,10 +1054,10 @@ var HB = /*#__PURE__*/function () {
|
|
|
1042
1054
|
_context27.next = 13;
|
|
1043
1055
|
return this.commit((0, _ramda.mergeLeft)(tags, {
|
|
1044
1056
|
"random-seed": (0, _utils.seed)(16),
|
|
1045
|
-
|
|
1057
|
+
Type: "Process",
|
|
1046
1058
|
"execution-device": "test-device@1.0",
|
|
1047
1059
|
device: "process@1.0",
|
|
1048
|
-
|
|
1060
|
+
Scheduler: this.operator
|
|
1049
1061
|
}), {
|
|
1050
1062
|
path: false
|
|
1051
1063
|
});
|
|
@@ -1055,7 +1067,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1055
1067
|
_context27.t3 = {
|
|
1056
1068
|
path: "/~process@1.0/schedule",
|
|
1057
1069
|
body: _context27.t1,
|
|
1058
|
-
|
|
1070
|
+
Scheduler: _context27.t2
|
|
1059
1071
|
};
|
|
1060
1072
|
_context27.next = 18;
|
|
1061
1073
|
return _context27.t0.post.call(_context27.t0, _context27.t3);
|
|
@@ -1096,9 +1108,9 @@ var HB = /*#__PURE__*/function () {
|
|
|
1096
1108
|
return this.setInfo();
|
|
1097
1109
|
case 3:
|
|
1098
1110
|
t = (0, _ramda.mergeLeft)(tags, {
|
|
1099
|
-
"
|
|
1100
|
-
|
|
1101
|
-
|
|
1111
|
+
"Data-Protocol": "ao",
|
|
1112
|
+
Variant: "ao.TN.1",
|
|
1113
|
+
Authority: this.operator,
|
|
1102
1114
|
module: module !== null && module !== void 0 ? module : "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
|
|
1103
1115
|
device: "process@1.0",
|
|
1104
1116
|
"execution-device": "stack@1.0",
|
|
@@ -1188,7 +1200,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1188
1200
|
path: "/~relay@1.0/call",
|
|
1189
1201
|
method: "GET",
|
|
1190
1202
|
"relay-path": "".concat(this.cu, "/results/").concat(process).concat(params),
|
|
1191
|
-
"
|
|
1203
|
+
"Content-Type": "application/json"
|
|
1192
1204
|
});
|
|
1193
1205
|
case 9:
|
|
1194
1206
|
res = _context30.sent;
|
|
@@ -1232,7 +1244,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1232
1244
|
path: "/~relay@1.0/call",
|
|
1233
1245
|
method: "POST",
|
|
1234
1246
|
"relay-path": "".concat(this.cu, "/dry-run?process-id=").concat(pid),
|
|
1235
|
-
"
|
|
1247
|
+
"Content-Type": "application/json",
|
|
1236
1248
|
"relay-body": JSON.stringify(json)
|
|
1237
1249
|
});
|
|
1238
1250
|
case 6:
|
|
@@ -1603,9 +1615,9 @@ var HB = /*#__PURE__*/function () {
|
|
|
1603
1615
|
image = _context39.t0;
|
|
1604
1616
|
case 14:
|
|
1605
1617
|
tags = {
|
|
1606
|
-
"
|
|
1607
|
-
|
|
1608
|
-
|
|
1618
|
+
"Data-Protocol": "ao",
|
|
1619
|
+
Variant: "ao.N.1",
|
|
1620
|
+
Authority: this.operator,
|
|
1609
1621
|
image: image,
|
|
1610
1622
|
"execution-device": "stack@1.0",
|
|
1611
1623
|
"push-device": "push@1.0",
|
package/cjs/hyperbeam.js
CHANGED
|
@@ -52,6 +52,8 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
52
52
|
_ref$simple_pay = _ref.simple_pay,
|
|
53
53
|
simple_pay = _ref$simple_pay === void 0 ? false : _ref$simple_pay,
|
|
54
54
|
simple_pay_price = _ref.simple_pay_price,
|
|
55
|
+
bundler_ans104 = _ref.bundler_ans104,
|
|
56
|
+
bundler_httpsig = _ref.bundler_httpsig,
|
|
55
57
|
p4_non_chargable_routes = _ref.p4_non_chargable_routes,
|
|
56
58
|
p4_lua = _ref.p4_lua,
|
|
57
59
|
store_prefix = _ref.store_prefix,
|
|
@@ -106,7 +108,9 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
106
108
|
this.cmake = cmake;
|
|
107
109
|
this.port = port;
|
|
108
110
|
this.url = "http://localhost:".concat(this.port);
|
|
109
|
-
this.bundler = bundler;
|
|
111
|
+
if (bundler) this.bundler = "http://localhost::".concat(bundler);
|
|
112
|
+
this.bundler_ans104 = bundler_ans104;
|
|
113
|
+
if (bundler_httpsig) this.bundler = bundler_httpsig;
|
|
110
114
|
this.as = as;
|
|
111
115
|
this.gateway = gateway;
|
|
112
116
|
if (Array.isArray(this.faff)) {
|
|
@@ -378,7 +382,8 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
378
382
|
|
|
379
383
|
// store option will be overwritten by hb.erl
|
|
380
384
|
var _store = this.store_prefix ? ", store => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"".concat(this.store_prefix, "\">> }, #{ <<\"store-module\">> => hb_store_gateway, <<\"subindex\">> => [#{ <<\"name\">> => <<\"Data-Protocol\">>, <<\"value\">> => <<\"ao\">> }], <<\"store\">> => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"").concat(this.store_prefix, "\">> }] }, #{ <<\"store-module\">> => hb_store_gateway, <<\"store\">> => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"").concat(this.store_prefix, "\">> }] }]") : "";
|
|
381
|
-
var _bundler = this.bundler ? ", bundler_httpsig => <<\"
|
|
385
|
+
var _bundler = this.bundler ? ", bundler_httpsig => <<\"".concat(this.bundler, "\">>") : "";
|
|
386
|
+
var _bundler_ans104 = this.bundler_ans104 === false ? ", bundler_ans104 => false" : this.bundler_ans104 ? ", bundler_ans104 => <<\"http://localhost:".concat(this.bundler_ans104, "\">>") : "";
|
|
382
387
|
/*
|
|
383
388
|
const _routes = `, routes => [#{ <<"template">> => <<"/result/.*">>, <<"node">> => #{ <<"prefix">> => <<"http://localhost:${this.cu}">> } }, #{ <<\"template\">> => <<\"/dry-run\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:${this.cu}\">> } }, #{ <<"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 } } }]`
|
|
384
389
|
*/
|
|
@@ -394,7 +399,7 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
394
399
|
return "<<\"".concat(addr, "\">>");
|
|
395
400
|
})(this.faff).join(", "), " ]");
|
|
396
401
|
var _on = this.p4_lua ? ", on => #{ <<\"request\">> => ".concat(processor, ", <<\"response\">> => ").concat(processor, " }") : this.simple_pay ? ", on => #{ <<\"request\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"simple-pay@1.0\">>, <<\"ledger-device\">> => <<\"simple-pay@1.0\">> }, <<\"response\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"simple-pay@1.0\">>, <<\"ledger-device\">> => <<\"simple-pay@1.0\">> } }" : !(0, _ramda.isNil)(this.faff) ? ", on => #{ <<\"request\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"faff@1.0\">>, <<\"ledger-device\">> => <<\"faff@1.0\">> }, <<\"response\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"faff@1.0\">>, <<\"ledger-device\">> => <<\"faff@1.0\">> } }" : "";
|
|
397
|
-
var start = "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_faff).concat(_bundler).concat(_on).concat(_p4_non_chargable).concat(_operator).concat(_spp).concat(_devices).concat(_node_processes, "}).");
|
|
402
|
+
var start = "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_faff).concat(_bundler).concat(_bundler_ans104).concat(_on).concat(_p4_non_chargable).concat(_operator).concat(_spp).concat(_devices).concat(_node_processes, "}).");
|
|
398
403
|
return start;
|
|
399
404
|
}
|
|
400
405
|
}, {
|
package/esm/bundler.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import express from "express"
|
|
2
|
+
import { ArweaveSigner, TurboFactory } from "@ardrive/turbo-sdk"
|
|
3
|
+
import { createData } from "@dha-team/arbundles"
|
|
4
|
+
import cors from "cors"
|
|
5
|
+
import bodyParser from "body-parser"
|
|
6
|
+
import { httpsig_from, structured_to } from "hbsig"
|
|
7
|
+
import { keys, omit } from "ramda"
|
|
8
|
+
|
|
9
|
+
let timestamp = 0
|
|
10
|
+
let height = 0
|
|
11
|
+
let last_checked = 0
|
|
12
|
+
let nonce = 0
|
|
13
|
+
|
|
14
|
+
const toMsg = req => {
|
|
15
|
+
let msg = req.headers
|
|
16
|
+
if (req.body) msg.body = req.body.toString("binary")
|
|
17
|
+
return msg
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const bundler = ({ port = 4001, jwk, timeout = 1000 * 60 } = {}) => {
|
|
21
|
+
const app = express()
|
|
22
|
+
app.use(cors())
|
|
23
|
+
app.use(bodyParser.raw({ type: "*/*", limit: "100mb" }))
|
|
24
|
+
app.post("/tx", async (req, res) => {
|
|
25
|
+
if (!Buffer.isBuffer(req.body)) {
|
|
26
|
+
console.log("BD: Invalid body | expected raw Buffer")
|
|
27
|
+
return res.status(400).send("Invalid body: expected raw Buffer")
|
|
28
|
+
}
|
|
29
|
+
res.status(200).send("success")
|
|
30
|
+
try {
|
|
31
|
+
const out = structured_to(httpsig_from(toMsg(req)))
|
|
32
|
+
for (const k in out.body?.commitments ?? {}) {
|
|
33
|
+
const msg = out.body?.commitments[k]
|
|
34
|
+
const signer = {
|
|
35
|
+
signatureType: 1,
|
|
36
|
+
signatureLength: 512,
|
|
37
|
+
ownerLength: 512,
|
|
38
|
+
publicKey: msg.owner,
|
|
39
|
+
sign: async () => {},
|
|
40
|
+
}
|
|
41
|
+
const tags = []
|
|
42
|
+
let type = null
|
|
43
|
+
if (msg["original-tags"]) {
|
|
44
|
+
for (const tagObj of Object.values(msg["original-tags"])) {
|
|
45
|
+
tags.push({ name: tagObj.name, value: tagObj.value })
|
|
46
|
+
if (tagObj.name === "Type") {
|
|
47
|
+
type = tagObj.value
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let opt = { tags }
|
|
52
|
+
if (type !== "Process") opt.target = out.process
|
|
53
|
+
const di = await createData(out.data || "", signer, opt)
|
|
54
|
+
await di.setSignature(msg.signature)
|
|
55
|
+
const res = await fetch("https://up.arweave.net:443/tx", {
|
|
56
|
+
method: "POST",
|
|
57
|
+
headers: {
|
|
58
|
+
"Content-Type": "application/octet-stream",
|
|
59
|
+
},
|
|
60
|
+
body: di.binary,
|
|
61
|
+
})
|
|
62
|
+
console.log(res?.status, di.tags)
|
|
63
|
+
const dis = [di]
|
|
64
|
+
if (type === "Message") {
|
|
65
|
+
if (!out["block-timestamp"]) {
|
|
66
|
+
try {
|
|
67
|
+
if (Date.now() - last_checked > timeout) {
|
|
68
|
+
const json = await fetch(
|
|
69
|
+
"https://arweave.net/block/current"
|
|
70
|
+
).then(r => r.json())
|
|
71
|
+
height = json.height
|
|
72
|
+
timestamp = json.timestamp
|
|
73
|
+
last_checked = Date.now()
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.log(e)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const atags = {
|
|
80
|
+
Process: out.process,
|
|
81
|
+
Epoch: out.epoch,
|
|
82
|
+
Nonce: Number(++nonce).toString(),
|
|
83
|
+
"Hash-Chain": out["hash-chain"],
|
|
84
|
+
"Block-Height": Number(out["block-height"] ?? height).toString(),
|
|
85
|
+
Tmestamp: Number(out["block-timestamp"] ?? timestamp).toString(),
|
|
86
|
+
"Data-Protocol": "ao",
|
|
87
|
+
Slot: Number(out.slot).toString(),
|
|
88
|
+
Variant: "ao.WDB.1",
|
|
89
|
+
Type: "Assignment",
|
|
90
|
+
Message: di.id,
|
|
91
|
+
}
|
|
92
|
+
const tags = []
|
|
93
|
+
if (msg["original-tags"]) {
|
|
94
|
+
for (const k in atags) tags.push({ name: k, value: atags[k] })
|
|
95
|
+
}
|
|
96
|
+
const signer = new ArweaveSigner(jwk)
|
|
97
|
+
const di2 = await createData("", signer, { tags })
|
|
98
|
+
await di2.sign(signer)
|
|
99
|
+
dis.push(di2)
|
|
100
|
+
const res2 = await fetch("https://up.arweave.net:443/tx", {
|
|
101
|
+
method: "POST",
|
|
102
|
+
headers: {
|
|
103
|
+
"Content-Type": "application/octet-stream",
|
|
104
|
+
},
|
|
105
|
+
body: di2.binary,
|
|
106
|
+
})
|
|
107
|
+
console.log(res2?.status, di2.tags)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} catch (e) {
|
|
111
|
+
console.log(e)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
return app.listen(port, () => console.log(`BD on port ${port}`))
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default bundler
|
package/esm/hb.js
CHANGED
|
@@ -127,7 +127,7 @@ class HB {
|
|
|
127
127
|
const { slot } = await this.scheduleFlat({
|
|
128
128
|
data,
|
|
129
129
|
pid: this.cache,
|
|
130
|
-
tags: { "
|
|
130
|
+
tags: { "Content-Type": type },
|
|
131
131
|
})
|
|
132
132
|
const msgs = await this.messages({ pid: this.cache, from: slot, limit: 1 })
|
|
133
133
|
return msgs.edges[0].node.message.Id
|
|
@@ -146,7 +146,7 @@ class HB {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
async scheduleFlat({ pid, tags = {}, data } = {}) {
|
|
149
|
-
let _tags = mergeLeft(tags, {
|
|
149
|
+
let _tags = mergeLeft(tags, { Type: "Message", target: pid })
|
|
150
150
|
if (data) _tags.data = data
|
|
151
151
|
let res = await this.post({ path: "/~process@1.0/schedule", body: _tags })
|
|
152
152
|
return { slot: res.out.slot, res, pid }
|
|
@@ -160,11 +160,15 @@ class HB {
|
|
|
160
160
|
})
|
|
161
161
|
return { slot: res.out.slot, res, pid }
|
|
162
162
|
}
|
|
163
|
-
async post104({
|
|
163
|
+
async post104({
|
|
164
|
+
path = "/~process@1.0/schedule",
|
|
165
|
+
tags = {},
|
|
166
|
+
data = "1984",
|
|
167
|
+
target,
|
|
168
|
+
}) {
|
|
164
169
|
const _tags = buildTags(mergeLeft(tags, { signingFormat: "ANS-104" }))
|
|
165
170
|
const signer = new ArweaveSigner(this.jwk)
|
|
166
|
-
|
|
167
|
-
const di = createData(data, signer, { tags: _tags })
|
|
171
|
+
const di = createData(data, signer, { tags: _tags, target })
|
|
168
172
|
await di.sign(signer)
|
|
169
173
|
let res = await fetch(`${this.url}${path}`, {
|
|
170
174
|
method: "POST",
|
|
@@ -174,22 +178,22 @@ class HB {
|
|
|
174
178
|
},
|
|
175
179
|
body: di.binary,
|
|
176
180
|
})
|
|
177
|
-
|
|
178
|
-
res.out = _headers
|
|
181
|
+
res.out = structured_to(httpsig_from(await toMsg(res)))
|
|
179
182
|
return res
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
async schedule({ pid, tags = {}, data } = {}) {
|
|
183
186
|
let res = null
|
|
184
187
|
if (this.format === "ans104") {
|
|
185
|
-
let _tags = mergeLeft(tags, {
|
|
188
|
+
let _tags = mergeLeft(tags, { Type: "Message" })
|
|
186
189
|
res = await this.post104({
|
|
190
|
+
target: pid,
|
|
187
191
|
path: `/${pid}/schedule`,
|
|
188
192
|
tags: _tags,
|
|
189
193
|
data: data ?? "1984",
|
|
190
194
|
})
|
|
191
195
|
} else {
|
|
192
|
-
let _tags = mergeLeft(tags, {
|
|
196
|
+
let _tags = mergeLeft(tags, { Type: "Message", target: pid })
|
|
193
197
|
if (data) _tags.data = data
|
|
194
198
|
let body = await this.commit(_tags, { path: false })
|
|
195
199
|
let signed = await this.sign({ path: `/${pid}/schedule`, body })
|
|
@@ -206,9 +210,9 @@ class HB {
|
|
|
206
210
|
async spawnLua(lua) {
|
|
207
211
|
await this.setInfo()
|
|
208
212
|
const tags = {
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
"Data-Protocol": "ao",
|
|
214
|
+
Variant: "ao.N.1",
|
|
215
|
+
Authority: this.operator,
|
|
212
216
|
module: this.lua ?? (await this.getLua()),
|
|
213
217
|
"execution-device": "lua@5.3a",
|
|
214
218
|
"push-device": "push@1.0",
|
|
@@ -229,7 +233,12 @@ class HB {
|
|
|
229
233
|
|
|
230
234
|
async slot({ pid, path = "" }) {
|
|
231
235
|
if (path && !/^\//.test(path)) path = "/" + path
|
|
232
|
-
|
|
236
|
+
if (this.format === "ans104") {
|
|
237
|
+
const res = await this.get({ path: `/${pid}/slot${path}` })
|
|
238
|
+
return res.out
|
|
239
|
+
} else {
|
|
240
|
+
return await this.getJSON({ path: `/${pid}/slot${path}` })
|
|
241
|
+
}
|
|
233
242
|
}
|
|
234
243
|
|
|
235
244
|
async messages({ pid, from, to } = {}) {
|
|
@@ -256,10 +265,10 @@ class HB {
|
|
|
256
265
|
tags: mergeLeft(tags, {
|
|
257
266
|
"codec-device": "ans104@1.0",
|
|
258
267
|
"random-seed": seed(16),
|
|
259
|
-
|
|
268
|
+
Type: "Process",
|
|
260
269
|
"execution-device": "test-device@1.0",
|
|
261
270
|
device: "process@1.0",
|
|
262
|
-
|
|
271
|
+
Scheduler: this.operator,
|
|
263
272
|
}),
|
|
264
273
|
})
|
|
265
274
|
} else {
|
|
@@ -268,14 +277,14 @@ class HB {
|
|
|
268
277
|
body: await this.commit(
|
|
269
278
|
mergeLeft(tags, {
|
|
270
279
|
"random-seed": seed(16),
|
|
271
|
-
|
|
280
|
+
Type: "Process",
|
|
272
281
|
"execution-device": "test-device@1.0",
|
|
273
282
|
device: "process@1.0",
|
|
274
|
-
|
|
283
|
+
Scheduler: this.operator,
|
|
275
284
|
}),
|
|
276
285
|
{ path: false }
|
|
277
286
|
),
|
|
278
|
-
|
|
287
|
+
Scheduler: this.operator,
|
|
279
288
|
})
|
|
280
289
|
}
|
|
281
290
|
return { res, pid: res.out.process }
|
|
@@ -284,9 +293,9 @@ class HB {
|
|
|
284
293
|
async spawnLegacy({ module, tags = {}, data } = {}) {
|
|
285
294
|
await this.setInfo()
|
|
286
295
|
let t = mergeLeft(tags, {
|
|
287
|
-
"
|
|
288
|
-
|
|
289
|
-
|
|
296
|
+
"Data-Protocol": "ao",
|
|
297
|
+
Variant: "ao.TN.1",
|
|
298
|
+
Authority: this.operator,
|
|
290
299
|
module: module ?? "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
|
|
291
300
|
device: "process@1.0",
|
|
292
301
|
"execution-device": "stack@1.0",
|
|
@@ -316,7 +325,7 @@ class HB {
|
|
|
316
325
|
path: "/~relay@1.0/call",
|
|
317
326
|
method: "GET",
|
|
318
327
|
"relay-path": `${this.cu}/results/${process}${params}`,
|
|
319
|
-
"
|
|
328
|
+
"Content-Type": "application/json",
|
|
320
329
|
})
|
|
321
330
|
return JSON.parse(res.body)
|
|
322
331
|
}
|
|
@@ -329,7 +338,7 @@ class HB {
|
|
|
329
338
|
path: "/~relay@1.0/call",
|
|
330
339
|
method: "POST",
|
|
331
340
|
"relay-path": `${this.cu}/dry-run?process-id=${pid}`,
|
|
332
|
-
"
|
|
341
|
+
"Content-Type": "application/json",
|
|
333
342
|
"relay-body": JSON.stringify(json),
|
|
334
343
|
})
|
|
335
344
|
return JSON.parse(res.body)
|
|
@@ -399,9 +408,9 @@ class HB {
|
|
|
399
408
|
await this.setInfo()
|
|
400
409
|
image ??= this.image ?? (await this.getImage())
|
|
401
410
|
const tags = {
|
|
402
|
-
"
|
|
403
|
-
|
|
404
|
-
|
|
411
|
+
"Data-Protocol": "ao",
|
|
412
|
+
Variant: "ao.N.1",
|
|
413
|
+
Authority: this.operator,
|
|
405
414
|
image,
|
|
406
415
|
"execution-device": "stack@1.0",
|
|
407
416
|
"push-device": "push@1.0",
|
package/esm/hyperbeam.js
CHANGED
|
@@ -24,6 +24,8 @@ export default class HyperBEAM {
|
|
|
24
24
|
faff,
|
|
25
25
|
simple_pay = false,
|
|
26
26
|
simple_pay_price,
|
|
27
|
+
bundler_ans104,
|
|
28
|
+
bundler_httpsig,
|
|
27
29
|
p4_non_chargable_routes,
|
|
28
30
|
p4_lua,
|
|
29
31
|
store_prefix,
|
|
@@ -66,7 +68,9 @@ export default class HyperBEAM {
|
|
|
66
68
|
this.cmake = cmake
|
|
67
69
|
this.port = port
|
|
68
70
|
this.url = `http://localhost:${this.port}`
|
|
69
|
-
this.bundler = bundler
|
|
71
|
+
if (bundler) this.bundler = `http://localhost::${bundler}`
|
|
72
|
+
this.bundler_ans104 = bundler_ans104
|
|
73
|
+
if (bundler_httpsig) this.bundler = bundler_httpsig
|
|
70
74
|
this.as = as
|
|
71
75
|
this.gateway = gateway
|
|
72
76
|
if (Array.isArray(this.faff)) {
|
|
@@ -221,9 +225,15 @@ export default class HyperBEAM {
|
|
|
221
225
|
const _store = this.store_prefix
|
|
222
226
|
? `, store => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"${this.store_prefix}">> }, #{ <<"store-module">> => hb_store_gateway, <<"subindex">> => [#{ <<"name">> => <<"Data-Protocol">>, <<"value">> => <<"ao">> }], <<"store">> => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"${this.store_prefix}">> }] }, #{ <<"store-module">> => hb_store_gateway, <<"store">> => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"${this.store_prefix}">> }] }]`
|
|
223
227
|
: ""
|
|
224
|
-
|
|
225
|
-
? `, bundler_httpsig => <<"
|
|
228
|
+
let _bundler = this.bundler
|
|
229
|
+
? `, bundler_httpsig => <<"${this.bundler}">>`
|
|
226
230
|
: ""
|
|
231
|
+
let _bundler_ans104 =
|
|
232
|
+
this.bundler_ans104 === false
|
|
233
|
+
? ", bundler_ans104 => false"
|
|
234
|
+
: this.bundler_ans104
|
|
235
|
+
? `, bundler_ans104 => <<"http://localhost:${this.bundler_ans104}">>`
|
|
236
|
+
: ""
|
|
227
237
|
/*
|
|
228
238
|
const _routes = `, routes => [#{ <<"template">> => <<"/result/.*">>, <<"node">> => #{ <<"prefix">> => <<"http://localhost:${this.cu}">> } }, #{ <<\"template\">> => <<\"/dry-run\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:${this.cu}\">> } }, #{ <<"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 } } }]`
|
|
229
239
|
*/
|
|
@@ -260,7 +270,7 @@ export default class HyperBEAM {
|
|
|
260
270
|
: !isNil(this.faff)
|
|
261
271
|
? `, on => #{ <<"request">> => #{ <<"device">> => <<"p4@1.0">>, <<"pricing-device">> => <<"faff@1.0">>, <<"ledger-device">> => <<"faff@1.0">> }, <<"response">> => #{ <<"device">> => <<"p4@1.0">>, <<"pricing-device">> => <<"faff@1.0">>, <<"ledger-device">> => <<"faff@1.0">> } }`
|
|
262
272
|
: ""
|
|
263
|
-
const start = `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_faff}${_bundler}${_on}${_p4_non_chargable}${_operator}${_spp}${_devices}${_node_processes}}).`
|
|
273
|
+
const start = `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_faff}${_bundler}${_bundler_ans104}${_on}${_p4_non_chargable}${_operator}${_spp}${_devices}${_node_processes}}).`
|
|
264
274
|
return start
|
|
265
275
|
}
|
|
266
276
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wao",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.3",
|
|
4
4
|
"bin": {
|
|
5
5
|
"wao": "./cjs/cli.js",
|
|
6
6
|
"wao-esm": "./esm/cli.js"
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@ar.io/sdk": "^3.20.0",
|
|
35
|
+
"@ardrive/turbo-sdk": "^1.31.1",
|
|
35
36
|
"@bokuweb/zstd-wasm": "^0.0.22",
|
|
36
37
|
"@dha-team/arbundles": "^1.0.4",
|
|
37
38
|
"@permaweb/ao-loader": "^0.0.44",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"express": "^5.1.0",
|
|
50
51
|
"fast-sha256": "^1.3.0",
|
|
51
52
|
"graphql": "^16.10.0",
|
|
52
|
-
"hbsig": "^0.1.
|
|
53
|
+
"hbsig": "^0.1.5",
|
|
53
54
|
"http-message-signatures": "^1.0.4",
|
|
54
55
|
"lmdb": "^3.2.2",
|
|
55
56
|
"localforage": "^1.10.0",
|