wao 0.25.1 → 0.25.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/hb.js +7 -3
- package/cjs/hyperbeam.js +134 -25
- package/esm/hb.js +9 -4
- package/esm/hyperbeam.js +47 -5
- package/package.json +1 -1
package/cjs/hb.js
CHANGED
|
@@ -44,8 +44,11 @@ var HB = /*#__PURE__*/function () {
|
|
|
44
44
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
45
45
|
_ref$url = _ref.url,
|
|
46
46
|
url = _ref$url === void 0 ? "http://localhost:10001" : _ref$url,
|
|
47
|
+
_ref$cu = _ref.cu,
|
|
48
|
+
cu = _ref$cu === void 0 ? "http://localhost:6363" : _ref$cu,
|
|
47
49
|
jwk = _ref.jwk;
|
|
48
50
|
_classCallCheck(this, HB);
|
|
51
|
+
this.cu = cu;
|
|
49
52
|
this.url = url;
|
|
50
53
|
this.dev = {};
|
|
51
54
|
this.dev.hyperbuddy = {
|
|
@@ -1360,16 +1363,17 @@ var HB = /*#__PURE__*/function () {
|
|
|
1360
1363
|
_ref15 = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {}, _ref15$tags = _ref15.tags, tags = _ref15$tags === void 0 ? {} : _ref15$tags, pid = _ref15.pid, action = _ref15.action, data = _ref15.data;
|
|
1361
1364
|
if (typeof action === "string") tags.Action = action;
|
|
1362
1365
|
json = {
|
|
1363
|
-
Tags: (0, _utils.buildTags)(tags)
|
|
1366
|
+
Tags: (0, _utils.buildTags)(_objectSpread({}, tags)),
|
|
1367
|
+
Owner: this.addr
|
|
1364
1368
|
};
|
|
1365
1369
|
if (data) json.Data = data;
|
|
1366
1370
|
_context34.next = 6;
|
|
1367
1371
|
return this.post({
|
|
1368
1372
|
path: "/~relay@1.0/call",
|
|
1369
1373
|
"relay-method": "POST",
|
|
1370
|
-
"relay-path": "/dry-run?process-id=".concat(pid),
|
|
1374
|
+
"relay-path": "".concat(this.cu, "/dry-run?process-id=").concat(pid),
|
|
1371
1375
|
"content-type": "application/json",
|
|
1372
|
-
body: JSON.stringify(json)
|
|
1376
|
+
"relay-body": JSON.stringify(json)
|
|
1373
1377
|
});
|
|
1374
1378
|
case 6:
|
|
1375
1379
|
res = _context34.sent;
|
package/cjs/hyperbeam.js
CHANGED
|
@@ -9,6 +9,9 @@ var _path = require("path");
|
|
|
9
9
|
var _ramda = require("ramda");
|
|
10
10
|
var _fs = require("fs");
|
|
11
11
|
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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); }
|
|
14
|
+
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); }); }; }
|
|
12
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
16
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
17
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -27,6 +30,8 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
27
30
|
port = _ref$port === void 0 ? 10001 : _ref$port,
|
|
28
31
|
_ref$cu = _ref.cu,
|
|
29
32
|
cu = _ref$cu === void 0 ? 6363 : _ref$cu,
|
|
33
|
+
_ref$as = _ref.as,
|
|
34
|
+
as = _ref$as === void 0 ? ["genesis_wasm"] : _ref$as,
|
|
30
35
|
bundler = _ref.bundler,
|
|
31
36
|
gateway = _ref.gateway,
|
|
32
37
|
wallet = _ref.wallet,
|
|
@@ -80,27 +85,129 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
80
85
|
this.cmake = cmake;
|
|
81
86
|
this.port = port;
|
|
82
87
|
this.bundler = bundler;
|
|
83
|
-
this.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
cwd: (0, _path.resolve)(process.cwd(), cwd)
|
|
89
|
-
});
|
|
90
|
-
this.hbeam.stdout.on("data", function (chunk) {
|
|
91
|
-
return console.log(chunk.toString());
|
|
92
|
-
});
|
|
93
|
-
this.hbeam.stderr.on("data", function (err) {
|
|
94
|
-
return console.error(err.toString());
|
|
95
|
-
});
|
|
96
|
-
this.hbeam.on("error", function (err) {
|
|
97
|
-
return console.error("failed to start process: ".concat(err));
|
|
98
|
-
});
|
|
99
|
-
this.hbeam.on("close", function (code) {
|
|
100
|
-
return console.log("child process exited with code ".concat(code));
|
|
101
|
-
});
|
|
88
|
+
this.as = as;
|
|
89
|
+
this.gateway = gateway;
|
|
90
|
+
this.wallet = wallet;
|
|
91
|
+
this.cwd = cwd;
|
|
92
|
+
this.run();
|
|
102
93
|
}
|
|
103
94
|
return _createClass(HyperBEAM, [{
|
|
95
|
+
key: "run",
|
|
96
|
+
value: function run() {
|
|
97
|
+
var _as = this.as.length === 0 ? [] : ["as", this.as.join(", ")];
|
|
98
|
+
this.hbeam = (0, _child_process.spawn)("rebar3", [].concat(_as, ["shell", "--eval", this.genEval({
|
|
99
|
+
gateway: this.gateway,
|
|
100
|
+
wallet: this.wallet
|
|
101
|
+
})]), {
|
|
102
|
+
env: _objectSpread(_objectSpread({}, process.env), this.genEnv()),
|
|
103
|
+
cwd: (0, _path.resolve)(process.cwd(), this.cwd)
|
|
104
|
+
});
|
|
105
|
+
this.hbeam.stdout.on("data", function (chunk) {
|
|
106
|
+
return console.log(chunk.toString());
|
|
107
|
+
});
|
|
108
|
+
this.hbeam.stderr.on("data", function (err) {
|
|
109
|
+
return console.error(err.toString());
|
|
110
|
+
});
|
|
111
|
+
this.hbeam.on("error", function (err) {
|
|
112
|
+
return console.error("failed to start process: ".concat(err));
|
|
113
|
+
});
|
|
114
|
+
this.hbeam.on("close", function (code) {
|
|
115
|
+
return console.log("child process exited with code ".concat(code));
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "ok",
|
|
120
|
+
value: function () {
|
|
121
|
+
var _ok = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
122
|
+
var address;
|
|
123
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
124
|
+
while (1) switch (_context.prev = _context.next) {
|
|
125
|
+
case 0:
|
|
126
|
+
_context.prev = 0;
|
|
127
|
+
_context.next = 3;
|
|
128
|
+
return fetch("http://localhost:".concat(this.port, "/~meta@1.0/info/address")).then(function (r) {
|
|
129
|
+
return r.text();
|
|
130
|
+
});
|
|
131
|
+
case 3:
|
|
132
|
+
address = _context.sent;
|
|
133
|
+
return _context.abrupt("return", address ? true : false);
|
|
134
|
+
case 7:
|
|
135
|
+
_context.prev = 7;
|
|
136
|
+
_context.t0 = _context["catch"](0);
|
|
137
|
+
return _context.abrupt("return", false);
|
|
138
|
+
case 10:
|
|
139
|
+
case "end":
|
|
140
|
+
return _context.stop();
|
|
141
|
+
}
|
|
142
|
+
}, _callee, this, [[0, 7]]);
|
|
143
|
+
}));
|
|
144
|
+
function ok() {
|
|
145
|
+
return _ok.apply(this, arguments);
|
|
146
|
+
}
|
|
147
|
+
return ok;
|
|
148
|
+
}()
|
|
149
|
+
}, {
|
|
150
|
+
key: "ready",
|
|
151
|
+
value: function () {
|
|
152
|
+
var _ready = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
153
|
+
var _this = this;
|
|
154
|
+
var timeout,
|
|
155
|
+
start,
|
|
156
|
+
_args3 = arguments;
|
|
157
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
158
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
159
|
+
case 0:
|
|
160
|
+
timeout = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : 30000;
|
|
161
|
+
start = Date.now();
|
|
162
|
+
return _context3.abrupt("return", new Promise(function (res) {
|
|
163
|
+
var to = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
164
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
165
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
166
|
+
case 0:
|
|
167
|
+
_context2.prev = 0;
|
|
168
|
+
if (!(Date.now() - start > 30000)) {
|
|
169
|
+
_context2.next = 6;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
clearInterval(to);
|
|
173
|
+
res(false);
|
|
174
|
+
_context2.next = 11;
|
|
175
|
+
break;
|
|
176
|
+
case 6:
|
|
177
|
+
_context2.next = 8;
|
|
178
|
+
return _this.ok();
|
|
179
|
+
case 8:
|
|
180
|
+
if (!_context2.sent) {
|
|
181
|
+
_context2.next = 11;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
clearInterval(to);
|
|
185
|
+
res(_this);
|
|
186
|
+
case 11:
|
|
187
|
+
_context2.next = 15;
|
|
188
|
+
break;
|
|
189
|
+
case 13:
|
|
190
|
+
_context2.prev = 13;
|
|
191
|
+
_context2.t0 = _context2["catch"](0);
|
|
192
|
+
case 15:
|
|
193
|
+
case "end":
|
|
194
|
+
return _context2.stop();
|
|
195
|
+
}
|
|
196
|
+
}, _callee2, null, [[0, 13]]);
|
|
197
|
+
})), 1000);
|
|
198
|
+
}));
|
|
199
|
+
case 3:
|
|
200
|
+
case "end":
|
|
201
|
+
return _context3.stop();
|
|
202
|
+
}
|
|
203
|
+
}, _callee3);
|
|
204
|
+
}));
|
|
205
|
+
function ready() {
|
|
206
|
+
return _ready.apply(this, arguments);
|
|
207
|
+
}
|
|
208
|
+
return ready;
|
|
209
|
+
}()
|
|
210
|
+
}, {
|
|
104
211
|
key: "genEnv",
|
|
105
212
|
value: function genEnv() {
|
|
106
213
|
var _env = {};
|
|
@@ -113,17 +220,19 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
113
220
|
}
|
|
114
221
|
}, {
|
|
115
222
|
key: "genEval",
|
|
116
|
-
value: function genEval(
|
|
117
|
-
var gateway =
|
|
118
|
-
|
|
119
|
-
wallet =
|
|
223
|
+
value: function genEval(_ref3) {
|
|
224
|
+
var gateway = _ref3.gateway,
|
|
225
|
+
_ref3$wallet = _ref3.wallet,
|
|
226
|
+
wallet = _ref3$wallet === void 0 ? ".wallet.json" : _ref3$wallet;
|
|
120
227
|
var _wallet = ", priv_key_location => <<\"".concat(wallet, "\">>");
|
|
121
228
|
var _gateway = gateway ? ", gateway => <<\"http://localhost:".concat(gateway, "\">>") : "";
|
|
122
229
|
|
|
123
230
|
// store option will be overwritten by hb.erl
|
|
124
231
|
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, "\">> }] }]") : "";
|
|
125
232
|
var _bundler = this.bundler ? ", bundler_httpsig => <<\"http://localhost:".concat(this.bundler, "\">>") : "";
|
|
126
|
-
|
|
233
|
+
/*
|
|
234
|
+
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 } } }]`
|
|
235
|
+
*/
|
|
127
236
|
var _p4_non_chargable = this.p4_lua ? ", p4_non_chargable_routes => [#{ <<\"template\">> => <<\"/*~node-process@1.0/*\">> }, #{ <<\"template\">> => <<\"/~wao@1.0/*\">> }, #{ <<\"template\">> => <<\"/~p4@1.0/balance\">> }, #{ <<\"template\">> => <<\"/~meta@1.0/*\">> }]" : !this.simplePay ? "" : ", p4_non_chargable_routes => [#{ <<\"template\">> => <<\"/~simple-pay@1.0/topup\">> }, #{ <<\"template\">> => <<\"/~p4@1.0/balance\">> }, #{ <<\"template\">> => <<\"/~meta@1.0/*\">> }, #{ <<\"template\">> => <<\"/~p4@1.0/balance\">> }, #{ <<\"template\">> => <<\"/~meta@1.0/*\">> }]";
|
|
128
237
|
var _operator = this.operator ? ", operator => <<\"".concat(this.operator, "\">>") : "";
|
|
129
238
|
var _spp = this.spp ? ", simple_pay_price => ".concat(this.spp) : "";
|
|
@@ -134,7 +243,7 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
134
243
|
return "<<\"".concat(addr, "\">>");
|
|
135
244
|
})(this.faff).join(", "), " ]");
|
|
136
245
|
var _on = this.p4_lua ? ", on => #{ <<\"request\">> => ".concat(processor, ", <<\"response\">> => ").concat(processor, " }") : this.simplePay ? ", 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\">> } }" : "";
|
|
137
|
-
var start = "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_faff).concat(_bundler).concat(
|
|
246
|
+
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(_node_processes, "}).");
|
|
138
247
|
return start;
|
|
139
248
|
}
|
|
140
249
|
}, {
|
package/esm/hb.js
CHANGED
|
@@ -11,7 +11,12 @@ const seed = num => {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
class HB {
|
|
14
|
-
constructor({
|
|
14
|
+
constructor({
|
|
15
|
+
url = "http://localhost:10001",
|
|
16
|
+
cu = "http://localhost:6363",
|
|
17
|
+
jwk,
|
|
18
|
+
} = {}) {
|
|
19
|
+
this.cu = cu
|
|
15
20
|
this.url = url
|
|
16
21
|
this.dev = {}
|
|
17
22
|
this.dev.hyperbuddy = {
|
|
@@ -393,14 +398,14 @@ class HB {
|
|
|
393
398
|
|
|
394
399
|
async dryrun({ tags = {}, pid, action, data } = {}) {
|
|
395
400
|
if (typeof action === "string") tags.Action = action
|
|
396
|
-
let json = { Tags: buildTags(tags) }
|
|
401
|
+
let json = { Tags: buildTags({ ...tags }), Owner: this.addr }
|
|
397
402
|
if (data) json.Data = data
|
|
398
403
|
const res = await this.post({
|
|
399
404
|
path: "/~relay@1.0/call",
|
|
400
405
|
"relay-method": "POST",
|
|
401
|
-
"relay-path":
|
|
406
|
+
"relay-path": `${this.cu}/dry-run?process-id=${pid}`,
|
|
402
407
|
"content-type": "application/json",
|
|
403
|
-
body: JSON.stringify(json),
|
|
408
|
+
"relay-body": JSON.stringify(json),
|
|
404
409
|
})
|
|
405
410
|
return JSON.parse(res.body)
|
|
406
411
|
}
|
package/esm/hyperbeam.js
CHANGED
|
@@ -7,6 +7,7 @@ export default class HyperBEAM {
|
|
|
7
7
|
constructor({
|
|
8
8
|
port = 10001,
|
|
9
9
|
cu = 6363,
|
|
10
|
+
as = ["genesis_wasm"],
|
|
10
11
|
bundler,
|
|
11
12
|
gateway,
|
|
12
13
|
wallet,
|
|
@@ -47,12 +48,25 @@ export default class HyperBEAM {
|
|
|
47
48
|
this.cmake = cmake
|
|
48
49
|
this.port = port
|
|
49
50
|
this.bundler = bundler
|
|
51
|
+
this.as = as
|
|
52
|
+
this.gateway = gateway
|
|
53
|
+
this.wallet = wallet
|
|
54
|
+
this.cwd = cwd
|
|
55
|
+
this.run()
|
|
56
|
+
}
|
|
57
|
+
run() {
|
|
58
|
+
const _as = this.as.length === 0 ? [] : ["as", this.as.join(", ")]
|
|
50
59
|
this.hbeam = spawn(
|
|
51
60
|
"rebar3",
|
|
52
|
-
[
|
|
61
|
+
[
|
|
62
|
+
..._as,
|
|
63
|
+
"shell",
|
|
64
|
+
"--eval",
|
|
65
|
+
this.genEval({ gateway: this.gateway, wallet: this.wallet }),
|
|
66
|
+
],
|
|
53
67
|
{
|
|
54
68
|
env: { ...process.env, ...this.genEnv() },
|
|
55
|
-
cwd: resolve(process.cwd(), cwd),
|
|
69
|
+
cwd: resolve(process.cwd(), this.cwd),
|
|
56
70
|
}
|
|
57
71
|
)
|
|
58
72
|
this.hbeam.stdout.on("data", chunk => console.log(chunk.toString()))
|
|
@@ -64,7 +78,34 @@ export default class HyperBEAM {
|
|
|
64
78
|
console.log(`child process exited with code ${code}`)
|
|
65
79
|
)
|
|
66
80
|
}
|
|
67
|
-
|
|
81
|
+
async ok() {
|
|
82
|
+
try {
|
|
83
|
+
const address = await fetch(
|
|
84
|
+
`http://localhost:${this.port}/~meta@1.0/info/address`
|
|
85
|
+
).then(r => r.text())
|
|
86
|
+
return address ? true : false
|
|
87
|
+
} catch (e) {
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async ready(timeout = 30000) {
|
|
92
|
+
const start = Date.now()
|
|
93
|
+
return new Promise(res => {
|
|
94
|
+
const to = setInterval(async () => {
|
|
95
|
+
try {
|
|
96
|
+
if (Date.now() - start > 30000) {
|
|
97
|
+
clearInterval(to)
|
|
98
|
+
res(false)
|
|
99
|
+
} else {
|
|
100
|
+
if (await this.ok()) {
|
|
101
|
+
clearInterval(to)
|
|
102
|
+
res(this)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {}
|
|
106
|
+
}, 1000)
|
|
107
|
+
})
|
|
108
|
+
}
|
|
68
109
|
genEnv() {
|
|
69
110
|
let _env = {}
|
|
70
111
|
if (this.c) {
|
|
@@ -88,8 +129,9 @@ export default class HyperBEAM {
|
|
|
88
129
|
const _bundler = this.bundler
|
|
89
130
|
? `, bundler_httpsig => <<"http://localhost:${this.bundler}">>`
|
|
90
131
|
: ""
|
|
132
|
+
/*
|
|
91
133
|
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 } } }]`
|
|
92
|
-
|
|
134
|
+
*/
|
|
93
135
|
const _p4_non_chargable = this.p4_lua
|
|
94
136
|
? `, p4_non_chargable_routes => [#{ <<"template">> => <<"/*~node-process@1.0/*">> }, #{ <<"template">> => <<"/~wao@1.0/*">> }, #{ <<"template">> => <<"/~p4@1.0/balance">> }, #{ <<"template">> => <<"/~meta@1.0/*">> }]`
|
|
95
137
|
: !this.simplePay
|
|
@@ -118,7 +160,7 @@ export default class HyperBEAM {
|
|
|
118
160
|
: !isNil(this.faff)
|
|
119
161
|
? `, 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">> } }`
|
|
120
162
|
: ""
|
|
121
|
-
const start = `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_faff}${_bundler}${
|
|
163
|
+
const start = `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_faff}${_bundler}${_on}${_p4_non_chargable}${_operator}${_spp}${_node_processes}}).`
|
|
122
164
|
return start
|
|
123
165
|
}
|
|
124
166
|
|