wao 0.23.0 → 0.23.1

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.
@@ -272,7 +272,7 @@ var Adaptor = /*#__PURE__*/function () {
272
272
  while (1) switch (_context9.prev = _context9.next) {
273
273
  case 0:
274
274
  _context9.t0 = req.path;
275
- _context9.next = _context9.t0 === "/" ? 3 : _context9.t0 === "/tx" ? 6 : _context9.t0 === "/wallet/:id/balance" ? 9 : _context9.t0 === "/mint/:id/:amount" ? 12 : _context9.t0 === "/tx/:id/offset" ? 15 : _context9.t0 === "/tx_anchor" ? 18 : _context9.t0 === "/mine" ? 21 : _context9.t0 === "/:id" ? 24 : _context9.t0 === "/price/:id" ? 27 : 30;
275
+ _context9.next = _context9.t0 === "/" ? 3 : _context9.t0 === "/wallet/:id/balance" ? 6 : _context9.t0 === "/mint/:id/:amount" ? 9 : _context9.t0 === "/tx/:id/offset" ? 12 : _context9.t0 === "/tx_anchor" ? 15 : _context9.t0 === "/mine" ? 18 : _context9.t0 === "/:id" ? 21 : _context9.t0 === "/price/:id" ? 24 : 27;
276
276
  break;
277
277
  case 3:
278
278
  _context9.next = 5;
@@ -281,50 +281,45 @@ var Adaptor = /*#__PURE__*/function () {
281
281
  return _context9.abrupt("return", _context9.sent);
282
282
  case 6:
283
283
  _context9.next = 8;
284
- return this.ar_get_tx(req);
284
+ return this.ar_get_wallet_balance(req);
285
285
  case 8:
286
286
  return _context9.abrupt("return", _context9.sent);
287
287
  case 9:
288
288
  _context9.next = 11;
289
- return this.ar_get_wallet_balance(req);
289
+ return this.ar_get_mint(req);
290
290
  case 11:
291
291
  return _context9.abrupt("return", _context9.sent);
292
292
  case 12:
293
293
  _context9.next = 14;
294
- return this.ar_get_mint(req);
294
+ return this.ar_get_tx_offset(req);
295
295
  case 14:
296
296
  return _context9.abrupt("return", _context9.sent);
297
297
  case 15:
298
298
  _context9.next = 17;
299
- return this.ar_get_tx_offset(req);
299
+ return this.ar_get_tx_anchor(req);
300
300
  case 17:
301
301
  return _context9.abrupt("return", _context9.sent);
302
302
  case 18:
303
303
  _context9.next = 20;
304
- return this.ar_get_tx_anchor(req);
304
+ return this.ar_get_mine(req);
305
305
  case 20:
306
306
  return _context9.abrupt("return", _context9.sent);
307
307
  case 21:
308
308
  _context9.next = 23;
309
- return this.ar_get_mine(req);
309
+ return this.ar_get_id(req);
310
310
  case 23:
311
311
  return _context9.abrupt("return", _context9.sent);
312
312
  case 24:
313
313
  _context9.next = 26;
314
- return this.ar_get_id(req);
314
+ return this.ar_get_price(req);
315
315
  case 26:
316
316
  return _context9.abrupt("return", _context9.sent);
317
317
  case 27:
318
318
  _context9.next = 29;
319
- return this.ar_get_price(req);
319
+ return this.bad();
320
320
  case 29:
321
321
  return _context9.abrupt("return", _context9.sent);
322
322
  case 30:
323
- _context9.next = 32;
324
- return this.bad();
325
- case 32:
326
- return _context9.abrupt("return", _context9.sent);
327
- case 33:
328
323
  case "end":
329
324
  return _context9.stop();
330
325
  }
@@ -1602,32 +1597,31 @@ var Adaptor = /*#__PURE__*/function () {
1602
1597
  query = _ref25.query, params = _ref25.params, body = _ref25.body, headers = _ref25.headers, method = _ref25.method;
1603
1598
  _context42.prev = 1;
1604
1599
  _query = body.query, variables = body.variables;
1605
- console.log(_query, variables);
1606
1600
  _toGraphObj = (0, _utils.toGraphObj)({
1607
1601
  query: _query,
1608
1602
  variables: variables
1609
1603
  }), tar = _toGraphObj.tar, args = _toGraphObj.args;
1610
1604
  res2 = null;
1611
1605
  if (!(tar === "transactions")) {
1612
- _context42.next = 12;
1606
+ _context42.next = 11;
1613
1607
  break;
1614
1608
  }
1615
- _context42.next = 9;
1609
+ _context42.next = 8;
1616
1610
  return this.gql.txs(_objectSpread({}, args));
1617
- case 9:
1611
+ case 8:
1618
1612
  res2 = _context42.sent;
1619
- _context42.next = 16;
1613
+ _context42.next = 15;
1620
1614
  break;
1621
- case 12:
1615
+ case 11:
1622
1616
  if (!(tar === "blocks")) {
1623
- _context42.next = 16;
1617
+ _context42.next = 15;
1624
1618
  break;
1625
1619
  }
1626
- _context42.next = 15;
1620
+ _context42.next = 14;
1627
1621
  return this.gql.blocks(_objectSpread({}, args));
1628
- case 15:
1622
+ case 14:
1629
1623
  res2 = _context42.sent;
1630
- case 16:
1624
+ case 15:
1631
1625
  edges = (0, _ramda.map)(function (v) {
1632
1626
  return {
1633
1627
  node: v,
@@ -1644,19 +1638,19 @@ var Adaptor = /*#__PURE__*/function () {
1644
1638
  })
1645
1639
  }
1646
1640
  });
1647
- case 20:
1648
- _context42.prev = 20;
1641
+ case 19:
1642
+ _context42.prev = 19;
1649
1643
  _context42.t0 = _context42["catch"](1);
1650
1644
  console.log(_context42.t0);
1651
1645
  return _context42.abrupt("return", {
1652
1646
  status: 400,
1653
1647
  error: "bad request"
1654
1648
  });
1655
- case 24:
1649
+ case 23:
1656
1650
  case "end":
1657
1651
  return _context42.stop();
1658
1652
  }
1659
- }, _callee42, this, [[1, 20]]);
1653
+ }, _callee42, this, [[1, 19]]);
1660
1654
  }));
1661
1655
  function ar_post_graphql(_x42) {
1662
1656
  return _ar_post_graphql.apply(this, arguments);
package/cjs/hyperbeam.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
  var _child_process = require("child_process");
8
8
  var _path = require("path");
9
+ var _ramda = require("ramda");
9
10
  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); }
10
11
  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; }
11
12
  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; }
@@ -27,8 +28,17 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
27
28
  c = _ref.c,
28
29
  cmake = _ref.cmake,
29
30
  _ref$legacy = _ref.legacy,
30
- legacy = _ref$legacy === void 0 ? false : _ref$legacy;
31
+ legacy = _ref$legacy === void 0 ? false : _ref$legacy,
32
+ faff = _ref.faff,
33
+ _ref$simplePay = _ref.simplePay,
34
+ simplePay = _ref$simplePay === void 0 ? false : _ref$simplePay,
35
+ simplePayPrice = _ref.simplePayPrice,
36
+ operator = _ref.operator;
31
37
  _classCallCheck(this, HyperBEAM);
38
+ this.simplePay = simplePay;
39
+ this.spp = simplePayPrice;
40
+ this.operator = operator;
41
+ this.faff = faff;
32
42
  this.c = c;
33
43
  this.cmake = cmake;
34
44
  this.port = port;
@@ -78,8 +88,15 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
78
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\">> }] }]";
79
89
  var _bundler = ", bundler_httpsig => <<\"http://localhost:4001\">>";
80
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/*\">> }]";
92
+ var _operator = this.operator ? ", operator => <<\"".concat(this.operator, "\">>") : "";
93
+ var _spp = this.spp ? ", simple_pay_price => ".concat(this.spp) : "";
81
94
  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, " }).");
95
+ var _faff = (0, _ramda.isNil)(this.faff) ? "" : ", faff_allow_list => [ ".concat((0, _ramda.map)(function (addr) {
96
+ return "<<\"".concat(addr, "\">>");
97
+ })(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\">> } }" : ", 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, " }).");
83
100
  }
84
101
  }, {
85
102
  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: ["/", "/tx", "/wallet/:id/balance", "/mint/:id/:amount", "/tx/:id/offset", "/tx_anchor", "/mine", "/:id", "/price/:id"],
91
+ get: ["/", "/wallet/:id/balance", "/mint/:id/:amount", "/tx/:id/offset", "/tx_anchor", "/mine", "/:id", "/price/:id"],
92
92
  post: ["/graphql", "/:id"]
93
93
  });
94
94
  }
@@ -90,8 +90,6 @@ 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)
95
93
  case "/wallet/:id/balance":
96
94
  return await this.ar_get_wallet_balance(req)
97
95
  case "/mint/:id/:amount":
@@ -471,7 +469,6 @@ class Adaptor {
471
469
  async ar_post_graphql({ query, params, body, headers, method }) {
472
470
  try {
473
471
  const { query, variables } = body
474
- console.log(query, variables)
475
472
  const { tar, args } = toGraphObj({ query, variables })
476
473
  let res2 = null
477
474
  if (tar === "transactions") {
package/esm/hyperbeam.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { spawn } from "child_process"
2
2
  import { resolve } from "path"
3
+ import { isNil, map } from "ramda"
3
4
 
4
5
  export default class HyperBEAM {
5
6
  constructor({
@@ -10,7 +11,15 @@ export default class HyperBEAM {
10
11
  c,
11
12
  cmake,
12
13
  legacy = false,
14
+ faff,
15
+ simplePay = false,
16
+ simplePayPrice,
17
+ operator,
13
18
  } = {}) {
19
+ this.simplePay = simplePay
20
+ this.spp = simplePayPrice
21
+ this.operator = operator
22
+ this.faff = faff
14
23
  this.c = c
15
24
  this.cmake = cmake
16
25
  this.port = port
@@ -49,10 +58,24 @@ export default class HyperBEAM {
49
58
  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
59
  const _bundler = `, bundler_httpsig => <<"http://localhost:4001">>`
51
60
  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 } } }]`
61
+ const _p4_non_chargeable = !this.simplePay
62
+ ? ""
63
+ : `, p4_non_chargable_routes => [#{ <<"template">> => <<"/~simple-pay@1.0/topup">> }, #{ <<"template">> => <<"/~p4@1.0/balance">> }, #{ <<"template">> => <<"/~meta@1.0/*">> }]`
64
+ const _operator = this.operator
65
+ ? `, operator => <<"${this.operator}">>`
66
+ : ""
67
+ const _spp = this.spp ? `, simple_pay_price => ${this.spp}` : ""
68
+
52
69
  const _port = `port => ${this.port}`
70
+ const _faff = isNil(this.faff)
71
+ ? ""
72
+ : `, faff_allow_list => [ ${map(addr => `<<"${addr}">>`)(this.faff).join(", ")} ]`
73
+ const _on = this.simplePay
74
+ ? `, 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">> } }`
75
+ : `, 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">> } }`
53
76
  return !legacy
54
- ? `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store} }).`
55
- : `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store}${_bundler}${_routes} }).`
77
+ ? `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store}${_on} }).`
78
+ : `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store}${_faff}${_bundler}${_routes}${_on}${_p4_non_chargeable}${_operator}${_spp} }).`
56
79
  }
57
80
 
58
81
  kill() {
package/esm/server.js CHANGED
@@ -47,7 +47,6 @@ class Server {
47
47
  this.launch("AR", app, {
48
48
  get: [
49
49
  "/",
50
- "/tx",
51
50
  "/wallet/:id/balance",
52
51
  "/mint/:id/:amount",
53
52
  "/tx/:id/offset",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"