wao 0.4.0 → 0.4.2

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/tgql.js ADDED
@@ -0,0 +1,733 @@
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 _ramda = require("ramda");
9
+ 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; }
10
+ 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; }
11
+ 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; }
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); }); }; }
15
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
17
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
21
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
22
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
23
+ var subs = {
24
+ owner: ["address", "key"],
25
+ fee: ["winston", "ar"],
26
+ quantity: ["winston", "ar"],
27
+ data: ["size", "type"],
28
+ tags: ["name", "value"],
29
+ block: ["id", "timestamp", "height", "previous"],
30
+ parent: ["id"]
31
+ };
32
+ var field = function field(key) {
33
+ var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
34
+ if ((0, _ramda.includes)(key, ["id", "anchor", "signature", "recipient"])) {
35
+ return {
36
+ key: key
37
+ };
38
+ } else if (subs[key]) {
39
+ var _subs = [];
40
+ if (val === true) val = subs[key];else if ((0, _ramda.is)(Object, val) && !(0, _ramda.is)(Array, val)) {
41
+ var _val = [];
42
+ var isTrue = false;
43
+ var isFalse = false;
44
+ for (var k in val) if (val[k] === true) isTrue = true;else if (val[k] === false) isFalse = true;
45
+ if (!isTrue && isFalse) {
46
+ var _iterator = _createForOfIteratorHelper(subs[key]),
47
+ _step;
48
+ try {
49
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
50
+ var _k = _step.value;
51
+ if (val[_k] !== false) _val.push(_k);
52
+ }
53
+ } catch (err) {
54
+ _iterator.e(err);
55
+ } finally {
56
+ _iterator.f();
57
+ }
58
+ } else {
59
+ for (var _k2 in val) if (val[_k2] === true) _val.push(_k2);
60
+ }
61
+ val = _val;
62
+ } else if (!(0, _ramda.is)(Array, val)) val = subs[key];
63
+ var _iterator2 = _createForOfIteratorHelper(val),
64
+ _step2;
65
+ try {
66
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
67
+ var v2 = _step2.value;
68
+ if ((0, _ramda.is)(String, v2) && (0, _ramda.includes)(v2, subs[key])) _subs.push(v2);
69
+ }
70
+ } catch (err) {
71
+ _iterator2.e(err);
72
+ } finally {
73
+ _iterator2.f();
74
+ }
75
+ if (_subs.length === 0) return null;
76
+ return {
77
+ key: key,
78
+ subs: _subs
79
+ };
80
+ }
81
+ return null;
82
+ };
83
+ var field_blocks = function field_blocks(key) {
84
+ var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
85
+ if ((0, _ramda.includes)(key, ["id", "timestamp", "height", "previous"])) {
86
+ return {
87
+ key: key
88
+ };
89
+ }
90
+ return null;
91
+ };
92
+ var GQL = exports["default"] = /*#__PURE__*/function () {
93
+ function GQL(_ref) {
94
+ var mem = _ref.mem;
95
+ _classCallCheck(this, GQL);
96
+ this.mem = mem;
97
+ }
98
+ return _createClass(GQL, [{
99
+ key: "txs",
100
+ value: function () {
101
+ var _txs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
102
+ var _opt$first,
103
+ _this = this;
104
+ var opt,
105
+ block_max,
106
+ block_min,
107
+ _block,
108
+ first,
109
+ tags,
110
+ k,
111
+ _opt$tags,
112
+ recipients,
113
+ owners,
114
+ ids,
115
+ data,
116
+ blocks,
117
+ count,
118
+ after,
119
+ _iterator3,
120
+ _step3,
121
+ v,
122
+ block,
123
+ _txs2,
124
+ _iterator4,
125
+ _step4,
126
+ _tx$anchor,
127
+ _tx$signature,
128
+ v2,
129
+ tx,
130
+ tag_unmatch,
131
+ _iterator5,
132
+ _step5,
133
+ _v2,
134
+ ex,
135
+ _iterator8,
136
+ _step8,
137
+ _v3,
138
+ _tx,
139
+ _tx2,
140
+ fields,
141
+ _iterator6,
142
+ _step6,
143
+ _v,
144
+ fld,
145
+ _k3,
146
+ _fld,
147
+ _k4,
148
+ _fld2,
149
+ _i,
150
+ _fields,
151
+ f,
152
+ _tx$f$key,
153
+ _subs2,
154
+ _iterator7,
155
+ _step7,
156
+ _tx$f$key$f,
157
+ f2,
158
+ cursor,
159
+ next,
160
+ _args2 = arguments;
161
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
162
+ while (1) switch (_context2.prev = _context2.next) {
163
+ case 0:
164
+ opt = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
165
+ block_max = null;
166
+ block_min = null;
167
+ _block = {};
168
+ if ((0, _ramda.is)(Number, opt.block)) {
169
+ _block = {
170
+ min: opt.block,
171
+ max: opt.block
172
+ };
173
+ } else if ((0, _ramda.is)(Array, opt.block) && opt.block.length > 0) {
174
+ _block = {};
175
+ if (!(0, _ramda.isNil)(opt.block[0])) _block.min = opt.block[0];
176
+ if (!(0, _ramda.isNil)(opt.block[1])) _block.max = opt.block[1];
177
+ }
178
+ first = (_opt$first = opt.first) !== null && _opt$first !== void 0 ? _opt$first : 20;
179
+ tags = [];
180
+ for (k in (_opt$tags = opt.tags) !== null && _opt$tags !== void 0 ? _opt$tags : {}) {
181
+ if ((0, _ramda.is)(String, opt.tags[k])) {
182
+ tags.push({
183
+ name: k,
184
+ values: [opt.tags[k]]
185
+ });
186
+ } else if ((0, _ramda.is)(Array, opt.tags[k])) {
187
+ tags.push({
188
+ name: k,
189
+ values: opt.tags[k]
190
+ });
191
+ }
192
+ }
193
+ recipients = null;
194
+ if ((0, _ramda.is)(Array, opt.recipients)) recipients = opt.recipients;else if ((0, _ramda.is)(String, opt.recipient)) recipients = [opt.recipient];
195
+ owners = null;
196
+ if ((0, _ramda.is)(Array, opt.owners)) owners = opt.owners;else if ((0, _ramda.is)(String, opt.owner)) owners = [opt.owner];
197
+ ids = null;
198
+ if ((0, _ramda.is)(Array, opt.ids)) ids = opt.ids;else if ((0, _ramda.is)(String, opt.id)) ids = [opt.id];
199
+ data = [];
200
+ blocks = this.mem.blocks;
201
+ if (opt.asc !== true) blocks = (0, _ramda.reverse)(blocks);
202
+ count = 0;
203
+ after = false;
204
+ _iterator3 = _createForOfIteratorHelper(blocks);
205
+ _context2.prev = 20;
206
+ _iterator3.s();
207
+ case 22:
208
+ if ((_step3 = _iterator3.n()).done) {
209
+ _context2.next = 111;
210
+ break;
211
+ }
212
+ v = _step3.value;
213
+ block = (0, _ramda.clone)(this.mem.blockmap[v]);
214
+ if (!(!(0, _ramda.isNil)(_block.min) && block.height < _block.min)) {
215
+ _context2.next = 27;
216
+ break;
217
+ }
218
+ return _context2.abrupt("continue", 109);
219
+ case 27:
220
+ if (!(!(0, _ramda.isNil)(_block.max) && block.height > _block.max)) {
221
+ _context2.next = 29;
222
+ break;
223
+ }
224
+ return _context2.abrupt("continue", 109);
225
+ case 29:
226
+ _txs2 = block.txs;
227
+ if (opt.asc !== true) _txs2 = (0, _ramda.reverse)(_txs2);
228
+ _iterator4 = _createForOfIteratorHelper(_txs2);
229
+ _context2.prev = 32;
230
+ _iterator4.s();
231
+ case 34:
232
+ if ((_step4 = _iterator4.n()).done) {
233
+ _context2.next = 99;
234
+ break;
235
+ }
236
+ v2 = _step4.value;
237
+ if (!(!(0, _ramda.isNil)(opt.after) && opt.after === v2)) {
238
+ _context2.next = 39;
239
+ break;
240
+ }
241
+ after = true;
242
+ return _context2.abrupt("break", 99);
243
+ case 39:
244
+ if (!(!(0, _ramda.isNil)(opt.after) && count === 0 && !after)) {
245
+ _context2.next = 41;
246
+ break;
247
+ }
248
+ return _context2.abrupt("continue", 97);
249
+ case 41:
250
+ tx = this.mem.txs[v2];
251
+ if (!(!(0, _ramda.isNil)(ids) && ids.length > 0)) {
252
+ _context2.next = 45;
253
+ break;
254
+ }
255
+ if ((0, _ramda.includes)(tx.id, ids)) {
256
+ _context2.next = 45;
257
+ break;
258
+ }
259
+ return _context2.abrupt("continue", 97);
260
+ case 45:
261
+ if (!(!(0, _ramda.isNil)(owners) && owners.length > 0)) {
262
+ _context2.next = 48;
263
+ break;
264
+ }
265
+ if ((0, _ramda.includes)(tx.owner, owners)) {
266
+ _context2.next = 48;
267
+ break;
268
+ }
269
+ return _context2.abrupt("continue", 97);
270
+ case 48:
271
+ if (!(!(0, _ramda.isNil)(recipients) && recipients.length > 0)) {
272
+ _context2.next = 51;
273
+ break;
274
+ }
275
+ if ((0, _ramda.includes)(tx.recipient, recipients)) {
276
+ _context2.next = 51;
277
+ break;
278
+ }
279
+ return _context2.abrupt("continue", 97);
280
+ case 51:
281
+ tag_unmatch = false;
282
+ _iterator5 = _createForOfIteratorHelper(tags);
283
+ _context2.prev = 53;
284
+ _iterator5.s();
285
+ case 55:
286
+ if ((_step5 = _iterator5.n()).done) {
287
+ _context2.next = 81;
288
+ break;
289
+ }
290
+ _v2 = _step5.value;
291
+ ex = false;
292
+ _iterator8 = _createForOfIteratorHelper(tx.tags);
293
+ _context2.prev = 59;
294
+ _iterator8.s();
295
+ case 61:
296
+ if ((_step8 = _iterator8.n()).done) {
297
+ _context2.next = 68;
298
+ break;
299
+ }
300
+ _v3 = _step8.value;
301
+ if (!(_v3.name === _v2.name && (0, _ramda.includes)(_v3.value, _v2.values))) {
302
+ _context2.next = 66;
303
+ break;
304
+ }
305
+ ex = true;
306
+ return _context2.abrupt("break", 68);
307
+ case 66:
308
+ _context2.next = 61;
309
+ break;
310
+ case 68:
311
+ _context2.next = 73;
312
+ break;
313
+ case 70:
314
+ _context2.prev = 70;
315
+ _context2.t0 = _context2["catch"](59);
316
+ _iterator8.e(_context2.t0);
317
+ case 73:
318
+ _context2.prev = 73;
319
+ _iterator8.f();
320
+ return _context2.finish(73);
321
+ case 76:
322
+ if (ex) {
323
+ _context2.next = 79;
324
+ break;
325
+ }
326
+ tag_unmatch = true;
327
+ return _context2.abrupt("break", 81);
328
+ case 79:
329
+ _context2.next = 55;
330
+ break;
331
+ case 81:
332
+ _context2.next = 86;
333
+ break;
334
+ case 83:
335
+ _context2.prev = 83;
336
+ _context2.t1 = _context2["catch"](53);
337
+ _iterator5.e(_context2.t1);
338
+ case 86:
339
+ _context2.prev = 86;
340
+ _iterator5.f();
341
+ return _context2.finish(86);
342
+ case 89:
343
+ if (!tag_unmatch) {
344
+ _context2.next = 91;
345
+ break;
346
+ }
347
+ return _context2.abrupt("continue", 97);
348
+ case 91:
349
+ _tx = _objectSpread(_objectSpread({
350
+ cursor: tx.id
351
+ }, tx), {}, _defineProperty({
352
+ data: tx._data,
353
+ block: (0, _ramda.pick)(["id", "timestamp", "height", "previous"], block),
354
+ anchor: (_tx$anchor = tx.anchor) !== null && _tx$anchor !== void 0 ? _tx$anchor : "",
355
+ signature: (_tx$signature = tx.signature) !== null && _tx$signature !== void 0 ? _tx$signature : "",
356
+ owner: {
357
+ address: tx.owner,
358
+ key: this.mem.addrmap[tx.owner]
359
+ },
360
+ fee: {
361
+ ar: "0",
362
+ winston: "0"
363
+ },
364
+ quantity: {
365
+ ar: "0",
366
+ winston: "0"
367
+ }
368
+ }, "data", {
369
+ size: "0",
370
+ type: ""
371
+ }));
372
+ if (!(0, _ramda.isNil)(opt.fields)) {
373
+ _tx2 = {
374
+ cursor: tx.id
375
+ };
376
+ fields = [];
377
+ if ((0, _ramda.is)(Array, opt.fields) && opt.fields.length > 0) {
378
+ _iterator6 = _createForOfIteratorHelper(opt.fields);
379
+ try {
380
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
381
+ _v = _step6.value;
382
+ if ((0, _ramda.is)(String, _v)) {
383
+ fld = field(_v);
384
+ if (fld) fields.push(fld);
385
+ } else if ((0, _ramda.is)(Object, _v) && !(0, _ramda.is)(Array, _v)) {
386
+ for (_k3 in _v) {
387
+ _fld = field(_k3, _v[_k3]);
388
+ if (_fld) fields.push(_fld);
389
+ }
390
+ }
391
+ }
392
+ } catch (err) {
393
+ _iterator6.e(err);
394
+ } finally {
395
+ _iterator6.f();
396
+ }
397
+ } else if ((0, _ramda.is)(Object, opt.fields) && !(0, _ramda.is)(Array, opt.fields)) {
398
+ for (_k4 in opt.fields) {
399
+ _fld2 = field(_k4, opt.fields[_k4]);
400
+ if (_fld2) fields.push(_fld2);
401
+ }
402
+ }
403
+ for (_i = 0, _fields = fields; _i < _fields.length; _i++) {
404
+ f = _fields[_i];
405
+ if ((0, _ramda.isNil)(f.subs)) {
406
+ _tx2[f.key] = (_tx$f$key = _tx[f.key]) !== null && _tx$f$key !== void 0 ? _tx$f$key : "";
407
+ } else {
408
+ _subs2 = {};
409
+ _tx2[f.key] = {};
410
+ if ((0, _ramda.is)(Array, _tx[f.key])) {
411
+ _tx2[f.key] = (0, _ramda.map)((0, _ramda.pick)(f.subs))(_tx[f.key]);
412
+ } else {
413
+ _iterator7 = _createForOfIteratorHelper(f.subs);
414
+ try {
415
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
416
+ f2 = _step7.value;
417
+ _tx2[f.key][f2] = (_tx$f$key$f = _tx[f.key][f2]) !== null && _tx$f$key$f !== void 0 ? _tx$f$key$f : "";
418
+ }
419
+ } catch (err) {
420
+ _iterator7.e(err);
421
+ } finally {
422
+ _iterator7.f();
423
+ }
424
+ }
425
+ }
426
+ }
427
+ _tx = _tx2;
428
+ }
429
+ data.push(_tx);
430
+ count += 1;
431
+ if (!(count >= first)) {
432
+ _context2.next = 97;
433
+ break;
434
+ }
435
+ return _context2.abrupt("break", 99);
436
+ case 97:
437
+ _context2.next = 34;
438
+ break;
439
+ case 99:
440
+ _context2.next = 104;
441
+ break;
442
+ case 101:
443
+ _context2.prev = 101;
444
+ _context2.t2 = _context2["catch"](32);
445
+ _iterator4.e(_context2.t2);
446
+ case 104:
447
+ _context2.prev = 104;
448
+ _iterator4.f();
449
+ return _context2.finish(104);
450
+ case 107:
451
+ if (!(count >= first)) {
452
+ _context2.next = 109;
453
+ break;
454
+ }
455
+ return _context2.abrupt("break", 111);
456
+ case 109:
457
+ _context2.next = 22;
458
+ break;
459
+ case 111:
460
+ _context2.next = 116;
461
+ break;
462
+ case 113:
463
+ _context2.prev = 113;
464
+ _context2.t3 = _context2["catch"](20);
465
+ _iterator3.e(_context2.t3);
466
+ case 116:
467
+ _context2.prev = 116;
468
+ _iterator3.f();
469
+ return _context2.finish(116);
470
+ case 119:
471
+ if (!(opt.next === true)) {
472
+ _context2.next = 126;
473
+ break;
474
+ }
475
+ cursor = null;
476
+ if (data.length > 0) cursor = (0, _ramda.last)(data).cursor;
477
+ next = !cursor ? null : /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
478
+ var _opt;
479
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
480
+ while (1) switch (_context.prev = _context.next) {
481
+ case 0:
482
+ _opt = (0, _ramda.clone)(opt);
483
+ _opt.after = cursor;
484
+ _context.next = 4;
485
+ return _this.txs(_opt);
486
+ case 4:
487
+ return _context.abrupt("return", _context.sent);
488
+ case 5:
489
+ case "end":
490
+ return _context.stop();
491
+ }
492
+ }, _callee);
493
+ }));
494
+ return _context2.abrupt("return", {
495
+ data: data,
496
+ next: next
497
+ });
498
+ case 126:
499
+ return _context2.abrupt("return", data);
500
+ case 127:
501
+ case "end":
502
+ return _context2.stop();
503
+ }
504
+ }, _callee2, this, [[20, 113, 116, 119], [32, 101, 104, 107], [53, 83, 86, 89], [59, 70, 73, 76]]);
505
+ }));
506
+ function txs() {
507
+ return _txs.apply(this, arguments);
508
+ }
509
+ return txs;
510
+ }()
511
+ }, {
512
+ key: "blocks",
513
+ value: function () {
514
+ var _blocks = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
515
+ var _opt$first2,
516
+ _this2 = this;
517
+ var opt,
518
+ block_max,
519
+ block_min,
520
+ _block,
521
+ first,
522
+ ids,
523
+ data,
524
+ blocks,
525
+ count,
526
+ after,
527
+ _iterator9,
528
+ _step9,
529
+ v,
530
+ block,
531
+ block2,
532
+ fields,
533
+ _iterator10,
534
+ _step10,
535
+ _v4,
536
+ fld,
537
+ k,
538
+ _fld3,
539
+ _k5,
540
+ _fld4,
541
+ _i2,
542
+ _fields2,
543
+ f,
544
+ _block$f$key,
545
+ _subs3,
546
+ _iterator11,
547
+ _step11,
548
+ _block$f$key$f,
549
+ f2,
550
+ cursor,
551
+ next,
552
+ _args4 = arguments;
553
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
554
+ while (1) switch (_context4.prev = _context4.next) {
555
+ case 0:
556
+ opt = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
557
+ block_max = null;
558
+ block_min = null;
559
+ _block = {};
560
+ if ((0, _ramda.is)(Number, opt.block)) {
561
+ _block = {
562
+ min: opt.block,
563
+ max: opt.block
564
+ };
565
+ } else if ((0, _ramda.is)(Array, opt.block) && opt.block.length > 0) {
566
+ _block = {};
567
+ if (!(0, _ramda.isNil)(opt.block[0])) _block.min = opt.block[0];
568
+ if (!(0, _ramda.isNil)(opt.block[1])) _block.max = opt.block[1];
569
+ }
570
+ first = (_opt$first2 = opt.first) !== null && _opt$first2 !== void 0 ? _opt$first2 : 20;
571
+ ids = null;
572
+ if ((0, _ramda.is)(Array, opt.ids)) ids = opt.ids;else if ((0, _ramda.is)(String, opt.id)) ids = [opt.id];
573
+ data = [];
574
+ blocks = this.mem.blocks;
575
+ if (opt.asc !== true) blocks = (0, _ramda.reverse)(blocks);
576
+ count = 0;
577
+ after = false;
578
+ _iterator9 = _createForOfIteratorHelper(blocks);
579
+ _context4.prev = 14;
580
+ _iterator9.s();
581
+ case 16:
582
+ if ((_step9 = _iterator9.n()).done) {
583
+ _context4.next = 34;
584
+ break;
585
+ }
586
+ v = _step9.value;
587
+ block = (0, _ramda.clone)(_objectSpread(_objectSpread({}, this.mem.blockmap[v]), {}, {
588
+ cursor: v
589
+ }));
590
+ delete block.txs;
591
+ if (!(!(0, _ramda.isNil)(_block.min) && block.height < _block.min)) {
592
+ _context4.next = 22;
593
+ break;
594
+ }
595
+ return _context4.abrupt("continue", 32);
596
+ case 22:
597
+ if (!(!(0, _ramda.isNil)(_block.max) && block.height > _block.max)) {
598
+ _context4.next = 24;
599
+ break;
600
+ }
601
+ return _context4.abrupt("continue", 32);
602
+ case 24:
603
+ if (!(!(0, _ramda.isNil)(ids) && ids.length > 0)) {
604
+ _context4.next = 27;
605
+ break;
606
+ }
607
+ if ((0, _ramda.includes)(v.id, ids)) {
608
+ _context4.next = 27;
609
+ break;
610
+ }
611
+ return _context4.abrupt("continue", 32);
612
+ case 27:
613
+ if (!(0, _ramda.isNil)(opt.fields)) {
614
+ block2 = {
615
+ cursor: block.id
616
+ };
617
+ fields = [];
618
+ if ((0, _ramda.is)(Array, opt.fields) && opt.fields.length > 0) {
619
+ _iterator10 = _createForOfIteratorHelper(opt.fields);
620
+ try {
621
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
622
+ _v4 = _step10.value;
623
+ if ((0, _ramda.is)(String, _v4)) {
624
+ fld = field_blocks(_v4);
625
+ if (fld) fields.push(fld);
626
+ } else if ((0, _ramda.is)(Object, _v4) && !(0, _ramda.is)(Array, _v4)) {
627
+ for (k in _v4) {
628
+ _fld3 = field_blocks(k, _v4[k]);
629
+ if (_fld3) fields.push(_fld3);
630
+ }
631
+ }
632
+ }
633
+ } catch (err) {
634
+ _iterator10.e(err);
635
+ } finally {
636
+ _iterator10.f();
637
+ }
638
+ } else if ((0, _ramda.is)(Object, opt.fields) && !(0, _ramda.is)(Array, opt.fields)) {
639
+ for (_k5 in opt.fields) {
640
+ _fld4 = field_blocks(_k5, opt.fields[_k5]);
641
+ if (_fld4) fields.push(_fld4);
642
+ }
643
+ }
644
+ for (_i2 = 0, _fields2 = fields; _i2 < _fields2.length; _i2++) {
645
+ f = _fields2[_i2];
646
+ if ((0, _ramda.isNil)(f.subs)) {
647
+ block2[f.key] = (_block$f$key = block[f.key]) !== null && _block$f$key !== void 0 ? _block$f$key : "";
648
+ } else {
649
+ _subs3 = {};
650
+ block2[f.key] = {};
651
+ if ((0, _ramda.is)(Array, block[f.key])) {
652
+ block2[f.key] = (0, _ramda.map)((0, _ramda.pick)(f.subs))(block[f.key]);
653
+ } else {
654
+ _iterator11 = _createForOfIteratorHelper(f.subs);
655
+ try {
656
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
657
+ f2 = _step11.value;
658
+ block2[f.key][f2] = (_block$f$key$f = block[f.key][f2]) !== null && _block$f$key$f !== void 0 ? _block$f$key$f : "";
659
+ }
660
+ } catch (err) {
661
+ _iterator11.e(err);
662
+ } finally {
663
+ _iterator11.f();
664
+ }
665
+ }
666
+ }
667
+ }
668
+ block = block2;
669
+ }
670
+ data.push(block);
671
+ count += 1;
672
+ if (!(count >= first)) {
673
+ _context4.next = 32;
674
+ break;
675
+ }
676
+ return _context4.abrupt("break", 34);
677
+ case 32:
678
+ _context4.next = 16;
679
+ break;
680
+ case 34:
681
+ _context4.next = 39;
682
+ break;
683
+ case 36:
684
+ _context4.prev = 36;
685
+ _context4.t0 = _context4["catch"](14);
686
+ _iterator9.e(_context4.t0);
687
+ case 39:
688
+ _context4.prev = 39;
689
+ _iterator9.f();
690
+ return _context4.finish(39);
691
+ case 42:
692
+ if (!(opt.next === true)) {
693
+ _context4.next = 49;
694
+ break;
695
+ }
696
+ cursor = null;
697
+ if (data.length > 0) cursor = (0, _ramda.last)(data).cursor;
698
+ next = !cursor ? null : /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
699
+ var _opt;
700
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
701
+ while (1) switch (_context3.prev = _context3.next) {
702
+ case 0:
703
+ _opt = (0, _ramda.clone)(opt);
704
+ _opt.after = cursor;
705
+ _context3.next = 4;
706
+ return _this2.txs(_opt);
707
+ case 4:
708
+ return _context3.abrupt("return", _context3.sent);
709
+ case 5:
710
+ case "end":
711
+ return _context3.stop();
712
+ }
713
+ }, _callee3);
714
+ }));
715
+ return _context4.abrupt("return", {
716
+ data: data,
717
+ next: next
718
+ });
719
+ case 49:
720
+ return _context4.abrupt("return", data);
721
+ case 50:
722
+ case "end":
723
+ return _context4.stop();
724
+ }
725
+ }, _callee4, this, [[14, 36, 39, 42]]);
726
+ }));
727
+ function blocks() {
728
+ return _blocks.apply(this, arguments);
729
+ }
730
+ return blocks;
731
+ }()
732
+ }]);
733
+ }();