wao 0.23.5 → 0.24.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/hyperbeam.js CHANGED
@@ -7,6 +7,7 @@ exports["default"] = void 0;
7
7
  var _child_process = require("child_process");
8
8
  var _path = require("path");
9
9
  var _ramda = require("ramda");
10
+ var _fs = require("fs");
10
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); }
11
12
  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; }
12
13
  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; }
@@ -21,10 +22,13 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
21
22
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
22
23
  _ref$port = _ref.port,
23
24
  port = _ref$port === void 0 ? 10001 : _ref$port,
25
+ _ref$cu = _ref.cu,
26
+ cu = _ref$cu === void 0 ? 6363 : _ref$cu,
27
+ bundler = _ref.bundler,
24
28
  gateway = _ref.gateway,
25
29
  wallet = _ref.wallet,
26
30
  _ref$cwd = _ref.cwd,
27
- cwd = _ref$cwd === void 0 ? "../HyperBEAM" : _ref$cwd,
31
+ cwd = _ref$cwd === void 0 ? "./HyperBEAM" : _ref$cwd,
28
32
  c = _ref.c,
29
33
  cmake = _ref.cmake,
30
34
  _ref$legacy = _ref.legacy,
@@ -33,8 +37,13 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
33
37
  _ref$simplePay = _ref.simplePay,
34
38
  simplePay = _ref$simplePay === void 0 ? false : _ref$simplePay,
35
39
  simplePayPrice = _ref.simplePayPrice,
40
+ p4_lua = _ref.p4_lua,
41
+ store_prefix = _ref.store_prefix,
36
42
  operator = _ref.operator;
37
43
  _classCallCheck(this, HyperBEAM);
44
+ this.cu = cu;
45
+ this.store_prefix = store_prefix !== null && store_prefix !== void 0 ? store_prefix : "cache-mainnet-" + Math.floor(Math.random() * 10000000);
46
+ this.p4_lua = p4_lua;
38
47
  this.simplePay = simplePay;
39
48
  this.spp = simplePayPrice;
40
49
  this.operator = operator;
@@ -42,13 +51,13 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
42
51
  this.c = c;
43
52
  this.cmake = cmake;
44
53
  this.port = port;
54
+ this.bundler = bundler;
45
55
  this.hbeam = (0, _child_process.spawn)("rebar3", ["shell", "--eval", this.genEval({
46
56
  gateway: gateway,
47
- wallet: wallet,
48
- legacy: legacy
57
+ wallet: wallet
49
58
  })], {
50
59
  env: _objectSpread(_objectSpread({}, process.env), this.genEnv()),
51
- cwd: (0, _path.resolve)(import.meta.dirname, cwd)
60
+ cwd: (0, _path.resolve)(process.cwd(), cwd)
52
61
  });
53
62
  this.hbeam.stdout.on("data", function (chunk) {
54
63
  return console.log(chunk.toString());
@@ -80,23 +89,24 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
80
89
  value: function genEval(_ref2) {
81
90
  var gateway = _ref2.gateway,
82
91
  _ref2$wallet = _ref2.wallet,
83
- wallet = _ref2$wallet === void 0 ? ".wallet.json" : _ref2$wallet,
84
- _ref2$legacy = _ref2.legacy,
85
- legacy = _ref2$legacy === void 0 ? false : _ref2$legacy;
92
+ wallet = _ref2$wallet === void 0 ? ".wallet.json" : _ref2$wallet;
86
93
  var _wallet = ", priv_key_location => <<\"".concat(wallet, "\">>");
87
94
  var _gateway = gateway ? ", gateway => <<\"http://localhost:".concat(gateway, "\">>") : "";
88
- 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\">> }] }]";
89
- var _bundler = ", bundler_httpsig => <<\"http://localhost:4001\">>";
90
- 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 } } }]");
91
- var _p4_non_chargeable = !this.simplePay ? "" : ", p4_non_chargable_routes => [#{ <<\"template\">> => <<\"/~simple-pay@1.0/topup\">> }, #{ <<\"template\">> => <<\"/~p4@1.0/balance\">> }, #{ <<\"template\">> => <<\"/~meta@1.0/*\">> }]";
95
+ 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, "\">> }] }]") : "";
96
+ var _bundler = this.bundler ? ", bundler_httpsig => <<\"http://localhost:".concat(this.bundler, "\">>") : "";
97
+ var _routes = ", routes => [#{ <<\"template\">> => <<\"/result/.*\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:".concat(this.cu, "\">> } }, #{ <<\"template\">> => <<\"/dry-run\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:").concat(this.cu, "\">> } }, #{ <<\"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 } } }]");
98
+ 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/*\">> }]";
92
99
  var _operator = this.operator ? ", operator => <<\"".concat(this.operator, "\">>") : "";
93
100
  var _spp = this.spp ? ", simple_pay_price => ".concat(this.spp) : "";
101
+ var _node_processes = this.p4_lua ? ", node_processes => #{ <<\"ledger\">> => #{ <<\"device\">> => <<\"process@1.0\">>, <<\"execution-device\">> => <<\"lua@5.3a\">>, <<\"scheduler-device\">> => <<\"scheduler@1.0\">>, <<\"module\">> => <<\"".concat(this.p4_lua.processor, "\">>, <<\"operator\">> => <<\"").concat(this.operator, "\">> } }") : "";
102
+ var processor = this.p4_lua ? "#{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"simple-pay@1.0\">>, <<\"ledger-device\">> => <<\"lua@5.3a\">>, <<\"module\">> => <<\"".concat(this.p4_lua.client, "\">>, <<\"ledger-path\">> => <<\"/ledger~node-process@1.0\">> }") : "";
94
103
  var _port = "port => ".concat(this.port);
95
104
  var _faff = (0, _ramda.isNil)(this.faff) ? "" : ", faff_allow_list => [ ".concat((0, _ramda.map)(function (addr) {
96
105
  return "<<\"".concat(addr, "\">>");
97
106
  })(this.faff).join(", "), " ]");
98
- var _on = 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\">> } }" : "";
99
- return !legacy ? "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_store).concat(_on, " }).") : "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_store).concat(_faff).concat(_bundler).concat(_routes).concat(_on).concat(_p4_non_chargeable).concat(_operator).concat(_spp, " }).");
107
+ 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\">> } }" : "";
108
+ var start = "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_store).concat(_faff).concat(_bundler).concat(_routes).concat(_on).concat(_p4_non_chargable).concat(_operator).concat(_spp).concat(_node_processes, " }).");
109
+ return start;
100
110
  }
101
111
  }, {
102
112
  key: "kill",
Binary file
Binary file