wao 0.5.6 → 0.6.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/ao.js +145 -50
- package/cjs/aoconnect.js +127 -114
- package/cjs/ar.js +14 -6
- package/cjs/armem.js +2 -1
- package/cjs/gql.js +27 -15
- package/cjs/helpers.js +217 -82
- package/cjs/lua/process.wasm +0 -0
- package/cjs/run.js +3 -1
- package/cjs/server.js +80 -153
- package/cjs/tao.js +13 -11
- package/cjs/tar.js +347 -206
- package/cjs/test.js +6 -0
- package/cjs/tgql.js +23 -8
- package/cjs/utils.js +141 -1
- package/cjs/weavedrive.js +86 -60
- package/esm/ao.js +30 -1
- package/esm/aoconnect.js +24 -15
- package/esm/ar.js +9 -3
- package/esm/armem.js +1 -0
- package/esm/gql.js +15 -6
- package/esm/helpers.js +50 -2
- package/esm/lua/process.wasm +0 -0
- package/esm/run.js +1 -1
- package/esm/server.js +30 -187
- package/esm/tao.js +7 -5
- package/esm/tar.js +125 -85
- package/esm/test.js +2 -1
- package/esm/tgql.js +12 -4
- package/esm/utils.js +227 -0
- package/esm/weavedrive.js +31 -25
- package/package.json +1 -1
package/cjs/tar.js
CHANGED
|
@@ -8,6 +8,7 @@ exports["default"] = void 0;
|
|
|
8
8
|
var _ar = _interopRequireDefault(require("./ar.js"));
|
|
9
9
|
var _utils = require("./utils.js");
|
|
10
10
|
var WarpArBundles = _interopRequireWildcard(require("warp-arbundles"));
|
|
11
|
+
var _arbundles = require("arbundles");
|
|
11
12
|
var _base64url = _interopRequireDefault(require("base64url"));
|
|
12
13
|
var _armem = _interopRequireDefault(require("./armem.js"));
|
|
13
14
|
var _tgql = _interopRequireDefault(require("./tgql.js"));
|
|
@@ -48,6 +49,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
48
49
|
_this = _callSuper(this, AR, [_objectSpread(_objectSpread({}, opt), {}, {
|
|
49
50
|
in_memory: true
|
|
50
51
|
})]);
|
|
52
|
+
_this.log = opt.log === true;
|
|
51
53
|
_this.in_memory = true;
|
|
52
54
|
_this.mem = (_opt$mem = opt.mem) !== null && _opt$mem !== void 0 ? _opt$mem : new _armem["default"]();
|
|
53
55
|
_this.gql = new _tgql["default"]({
|
|
@@ -58,62 +60,85 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
58
60
|
}
|
|
59
61
|
_inherits(AR, _MAR);
|
|
60
62
|
return _createClass(AR, [{
|
|
61
|
-
key: "
|
|
63
|
+
key: "owner",
|
|
62
64
|
value: function () {
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
+
var _owner = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(di) {
|
|
66
|
+
var raw_owner, hashBuffer;
|
|
65
67
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
66
68
|
while (1) switch (_context.prev = _context.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
raw_owner = di.rawOwner;
|
|
71
|
+
_context.t0 = Buffer;
|
|
72
|
+
_context.next = 4;
|
|
73
|
+
return crypto.subtle.digest("SHA-256", raw_owner);
|
|
74
|
+
case 4:
|
|
75
|
+
_context.t1 = _context.sent;
|
|
76
|
+
hashBuffer = _context.t0.from.call(_context.t0, _context.t1);
|
|
77
|
+
return _context.abrupt("return", _base64url["default"].encode(hashBuffer));
|
|
78
|
+
case 7:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context.stop();
|
|
81
|
+
}
|
|
82
|
+
}, _callee);
|
|
83
|
+
}));
|
|
84
|
+
function owner(_x) {
|
|
85
|
+
return _owner.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
return owner;
|
|
88
|
+
}()
|
|
89
|
+
}, {
|
|
90
|
+
key: "dataitem",
|
|
91
|
+
value: function () {
|
|
92
|
+
var _dataitem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
93
|
+
var _ref$target, target, _ref$data, data, _ref$tags, tags, signer, item, di, _tags, _item, owner;
|
|
94
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
95
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
67
96
|
case 0:
|
|
68
97
|
_ref$target = _ref.target, target = _ref$target === void 0 ? "" : _ref$target, _ref$data = _ref.data, data = _ref$data === void 0 ? "1984" : _ref$data, _ref$tags = _ref.tags, tags = _ref$tags === void 0 ? {} : _ref$tags, signer = _ref.signer, item = _ref.item;
|
|
69
98
|
di = item;
|
|
70
99
|
if (di) {
|
|
71
|
-
|
|
100
|
+
_context2.next = 10;
|
|
72
101
|
break;
|
|
73
102
|
}
|
|
74
103
|
_tags = (0, _utils.buildTags)(tags);
|
|
75
|
-
|
|
104
|
+
_context2.next = 6;
|
|
76
105
|
return signer({
|
|
77
106
|
data: data,
|
|
78
107
|
tags: _tags,
|
|
79
108
|
target: target
|
|
80
109
|
});
|
|
81
110
|
case 6:
|
|
82
|
-
_item =
|
|
111
|
+
_item = _context2.sent;
|
|
83
112
|
di = new DataItem(_item.raw);
|
|
84
|
-
|
|
113
|
+
_context2.next = 11;
|
|
85
114
|
break;
|
|
86
115
|
case 10:
|
|
87
116
|
tags = (0, _utils.tags)(di.tags);
|
|
88
117
|
case 11:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
_context.t1 = _context.sent;
|
|
95
|
-
hashBuffer = _context.t0.from.call(_context.t0, _context.t1);
|
|
96
|
-
owner = _base64url["default"].encode(hashBuffer);
|
|
97
|
-
_context.next = 20;
|
|
118
|
+
_context2.next = 13;
|
|
119
|
+
return this.owner(di);
|
|
120
|
+
case 13:
|
|
121
|
+
owner = _context2.sent;
|
|
122
|
+
_context2.next = 16;
|
|
98
123
|
return di.id;
|
|
99
|
-
case
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return
|
|
105
|
-
id:
|
|
106
|
-
owner:
|
|
107
|
-
item:
|
|
108
|
-
tags:
|
|
124
|
+
case 16:
|
|
125
|
+
_context2.t0 = _context2.sent;
|
|
126
|
+
_context2.t1 = owner;
|
|
127
|
+
_context2.t2 = di;
|
|
128
|
+
_context2.t3 = tags;
|
|
129
|
+
return _context2.abrupt("return", {
|
|
130
|
+
id: _context2.t0,
|
|
131
|
+
owner: _context2.t1,
|
|
132
|
+
item: _context2.t2,
|
|
133
|
+
tags: _context2.t3
|
|
109
134
|
});
|
|
110
|
-
case
|
|
135
|
+
case 21:
|
|
111
136
|
case "end":
|
|
112
|
-
return
|
|
137
|
+
return _context2.stop();
|
|
113
138
|
}
|
|
114
|
-
},
|
|
139
|
+
}, _callee2, this);
|
|
115
140
|
}));
|
|
116
|
-
function dataitem(
|
|
141
|
+
function dataitem(_x2) {
|
|
117
142
|
return _dataitem.apply(this, arguments);
|
|
118
143
|
}
|
|
119
144
|
return dataitem;
|
|
@@ -121,18 +146,35 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
121
146
|
}, {
|
|
122
147
|
key: "post",
|
|
123
148
|
value: function () {
|
|
124
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
125
|
-
var _ref2$data, data, _ref2$tags, tags, jwk, tx, _tags, _iterator, _step, v
|
|
126
|
-
return _regeneratorRuntime().wrap(function
|
|
127
|
-
while (1) switch (
|
|
149
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
150
|
+
var _ref2$data, data, _ref2$tags, tags, jwk, err, _yield$this$checkWall, tx, _tags, _iterator, _step, v;
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
152
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
128
153
|
case 0:
|
|
129
154
|
_ref2$data = _ref2.data, data = _ref2$data === void 0 ? "1984" : _ref2$data, _ref2$tags = _ref2.tags, tags = _ref2$tags === void 0 ? {} : _ref2$tags, jwk = _ref2.jwk;
|
|
130
|
-
|
|
155
|
+
err = null;
|
|
156
|
+
_context3.next = 4;
|
|
157
|
+
return this.checkWallet({
|
|
158
|
+
jwk: jwk
|
|
159
|
+
});
|
|
160
|
+
case 4:
|
|
161
|
+
_yield$this$checkWall = _context3.sent;
|
|
162
|
+
err = _yield$this$checkWall.err;
|
|
163
|
+
jwk = _yield$this$checkWall.jwk;
|
|
164
|
+
if (!err) {
|
|
165
|
+
_context3.next = 9;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
return _context3.abrupt("return", {
|
|
169
|
+
err: err
|
|
170
|
+
});
|
|
171
|
+
case 9:
|
|
172
|
+
_context3.next = 11;
|
|
131
173
|
return this.arweave.createTransaction({
|
|
132
174
|
data: data
|
|
133
175
|
});
|
|
134
|
-
case
|
|
135
|
-
tx =
|
|
176
|
+
case 11:
|
|
177
|
+
tx = _context3.sent;
|
|
136
178
|
_tags = (0, _utils.buildTags)(null, tags);
|
|
137
179
|
_iterator = _createForOfIteratorHelper(_tags);
|
|
138
180
|
try {
|
|
@@ -145,71 +187,78 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
145
187
|
} finally {
|
|
146
188
|
_iterator.f();
|
|
147
189
|
}
|
|
148
|
-
|
|
149
|
-
return this.
|
|
150
|
-
case
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
address: owner,
|
|
154
|
-
key: jwk.n
|
|
155
|
-
};
|
|
156
|
-
_context2.next = 13;
|
|
157
|
-
return this.postTx(tx, jwk, {
|
|
158
|
-
recipient: "",
|
|
159
|
-
tags: _tags,
|
|
160
|
-
data: data,
|
|
161
|
-
owner: owner
|
|
162
|
-
});
|
|
163
|
-
case 13:
|
|
164
|
-
return _context2.abrupt("return", _context2.sent);
|
|
165
|
-
case 14:
|
|
190
|
+
_context3.next = 17;
|
|
191
|
+
return this.postTx(tx, jwk);
|
|
192
|
+
case 17:
|
|
193
|
+
return _context3.abrupt("return", _context3.sent);
|
|
194
|
+
case 18:
|
|
166
195
|
case "end":
|
|
167
|
-
return
|
|
196
|
+
return _context3.stop();
|
|
168
197
|
}
|
|
169
|
-
},
|
|
198
|
+
}, _callee3, this);
|
|
170
199
|
}));
|
|
171
|
-
function post(
|
|
200
|
+
function post(_x3) {
|
|
172
201
|
return _post.apply(this, arguments);
|
|
173
202
|
}
|
|
174
203
|
return post;
|
|
175
204
|
}()
|
|
176
205
|
}, {
|
|
177
|
-
key: "
|
|
206
|
+
key: "postItems",
|
|
178
207
|
value: function () {
|
|
179
|
-
var
|
|
180
|
-
var
|
|
181
|
-
return _regeneratorRuntime().wrap(function
|
|
182
|
-
while (1) switch (
|
|
208
|
+
var _postItems = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(items, jwk) {
|
|
209
|
+
var err, _yield$this$checkWall2, _items, _iterator2, _step2, di, data_size, data_type, _iterator3, _step3, _t, owner, data, _item, bundle, tx;
|
|
210
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
211
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
183
212
|
case 0:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
213
|
+
err = null;
|
|
214
|
+
_context4.next = 3;
|
|
215
|
+
return this.checkWallet({
|
|
216
|
+
jwk: jwk
|
|
217
|
+
});
|
|
218
|
+
case 3:
|
|
219
|
+
_yield$this$checkWall2 = _context4.sent;
|
|
220
|
+
err = _yield$this$checkWall2.err;
|
|
221
|
+
jwk = _yield$this$checkWall2.jwk;
|
|
222
|
+
if (!err) {
|
|
223
|
+
_context4.next = 8;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
return _context4.abrupt("return", {
|
|
227
|
+
err: err
|
|
228
|
+
});
|
|
229
|
+
case 8:
|
|
230
|
+
if (!(0, _ramda.is)(Array, items)) items = [items];
|
|
231
|
+
_items = [];
|
|
232
|
+
_iterator2 = _createForOfIteratorHelper(items);
|
|
233
|
+
_context4.prev = 11;
|
|
234
|
+
_iterator2.s();
|
|
235
|
+
case 13:
|
|
236
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
237
|
+
_context4.next = 47;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
di = _step2.value;
|
|
241
|
+
_context4.next = 17;
|
|
242
|
+
return di.id;
|
|
243
|
+
case 17:
|
|
244
|
+
di._id = _context4.sent;
|
|
192
245
|
data_size = Buffer.byteLength(di.rawData).toString();
|
|
193
246
|
data_type = "";
|
|
194
|
-
|
|
247
|
+
_iterator3 = _createForOfIteratorHelper(di.tags);
|
|
195
248
|
try {
|
|
196
|
-
for (
|
|
197
|
-
_t =
|
|
249
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
250
|
+
_t = _step3.value;
|
|
198
251
|
if (_t.name === "Content-Type") data_type = _t.value;
|
|
199
252
|
}
|
|
200
253
|
} catch (err) {
|
|
201
|
-
|
|
254
|
+
_iterator3.e(err);
|
|
202
255
|
} finally {
|
|
203
|
-
|
|
256
|
+
_iterator3.f();
|
|
204
257
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
case 13:
|
|
210
|
-
_context3.t1 = _context3.sent;
|
|
211
|
-
hashBuffer = _context3.t0.from.call(_context3.t0, _context3.t1);
|
|
212
|
-
owner = _base64url["default"].encode(hashBuffer);
|
|
258
|
+
_context4.next = 24;
|
|
259
|
+
return this.owner(di);
|
|
260
|
+
case 24:
|
|
261
|
+
owner = _context4.sent;
|
|
213
262
|
this.mem.addrmap[owner] = {
|
|
214
263
|
key: di.owner,
|
|
215
264
|
address: owner
|
|
@@ -218,178 +267,250 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
218
267
|
try {
|
|
219
268
|
data = _base64url["default"].decode(di.data);
|
|
220
269
|
} catch (e) {}
|
|
221
|
-
|
|
270
|
+
_context4.t0 = {
|
|
222
271
|
size: data_size,
|
|
223
272
|
type: data_type
|
|
224
273
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
274
|
+
_context4.t1 = di.anchor;
|
|
275
|
+
_context4.t2 = di.signature;
|
|
276
|
+
_context4.t3 = di.target;
|
|
277
|
+
_context4.next = 34;
|
|
229
278
|
return di.id;
|
|
230
|
-
case
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
279
|
+
case 34:
|
|
280
|
+
_context4.t4 = _context4.sent;
|
|
281
|
+
_context4.t5 = di;
|
|
282
|
+
_context4.t6 = owner;
|
|
283
|
+
_context4.t7 = di.tags;
|
|
284
|
+
_context4.t8 = data;
|
|
236
285
|
_item = {
|
|
237
|
-
_data:
|
|
238
|
-
anchor:
|
|
239
|
-
signature:
|
|
240
|
-
recipient:
|
|
241
|
-
id:
|
|
242
|
-
item:
|
|
243
|
-
owner:
|
|
244
|
-
tags:
|
|
245
|
-
data:
|
|
286
|
+
_data: _context4.t0,
|
|
287
|
+
anchor: _context4.t1,
|
|
288
|
+
signature: _context4.t2,
|
|
289
|
+
recipient: _context4.t3,
|
|
290
|
+
id: _context4.t4,
|
|
291
|
+
item: _context4.t5,
|
|
292
|
+
owner: _context4.t6,
|
|
293
|
+
tags: _context4.t7,
|
|
294
|
+
data: _context4.t8
|
|
246
295
|
};
|
|
247
|
-
|
|
296
|
+
_context4.next = 42;
|
|
248
297
|
return di.id;
|
|
249
|
-
case
|
|
250
|
-
|
|
251
|
-
this.mem.txs[
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
case
|
|
298
|
+
case 42:
|
|
299
|
+
_context4.t9 = _context4.sent;
|
|
300
|
+
this.mem.txs[_context4.t9] = _item;
|
|
301
|
+
_items.push(_item);
|
|
302
|
+
case 45:
|
|
303
|
+
_context4.next = 13;
|
|
304
|
+
break;
|
|
305
|
+
case 47:
|
|
306
|
+
_context4.next = 52;
|
|
307
|
+
break;
|
|
308
|
+
case 49:
|
|
309
|
+
_context4.prev = 49;
|
|
310
|
+
_context4.t10 = _context4["catch"](11);
|
|
311
|
+
_iterator2.e(_context4.t10);
|
|
312
|
+
case 52:
|
|
313
|
+
_context4.prev = 52;
|
|
314
|
+
_iterator2.f();
|
|
315
|
+
return _context4.finish(52);
|
|
316
|
+
case 55:
|
|
317
|
+
_context4.next = 57;
|
|
318
|
+
return (0, _arbundles.bundleAndSignData)(items, new _arbundles.ArweaveSigner(jwk));
|
|
319
|
+
case 57:
|
|
320
|
+
bundle = _context4.sent;
|
|
321
|
+
_context4.next = 60;
|
|
322
|
+
return this.mem.arweave.createTransaction({
|
|
323
|
+
data: bundle.binary
|
|
324
|
+
}, jwk);
|
|
325
|
+
case 60:
|
|
326
|
+
tx = _context4.sent;
|
|
327
|
+
tx.addTag("Bundle-Format", "binary");
|
|
328
|
+
tx.addTag("Bundle-Version", "2.0.0");
|
|
329
|
+
_context4.next = 65;
|
|
330
|
+
return this.postTx(tx, jwk, _items);
|
|
331
|
+
case 65:
|
|
332
|
+
return _context4.abrupt("return", _context4.sent);
|
|
333
|
+
case 66:
|
|
257
334
|
case "end":
|
|
258
|
-
return
|
|
335
|
+
return _context4.stop();
|
|
259
336
|
}
|
|
260
|
-
},
|
|
337
|
+
}, _callee4, this, [[11, 49, 52, 55]]);
|
|
261
338
|
}));
|
|
262
|
-
function
|
|
263
|
-
return
|
|
339
|
+
function postItems(_x4, _x5) {
|
|
340
|
+
return _postItems.apply(this, arguments);
|
|
264
341
|
}
|
|
265
|
-
return
|
|
342
|
+
return postItems;
|
|
266
343
|
}()
|
|
267
344
|
}, {
|
|
268
345
|
key: "postTx",
|
|
269
346
|
value: function () {
|
|
270
|
-
var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
347
|
+
var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tx, jwk) {
|
|
271
348
|
var _last;
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
|
|
349
|
+
var items,
|
|
350
|
+
err,
|
|
351
|
+
_yield$this$checkWall3,
|
|
352
|
+
res,
|
|
353
|
+
block,
|
|
354
|
+
msg,
|
|
355
|
+
_iterator4,
|
|
356
|
+
_step4,
|
|
357
|
+
item,
|
|
358
|
+
_tags2,
|
|
359
|
+
data_type,
|
|
360
|
+
_iterator5,
|
|
361
|
+
_step5,
|
|
362
|
+
v,
|
|
363
|
+
_tags,
|
|
364
|
+
_iterator6,
|
|
365
|
+
_step6,
|
|
366
|
+
_v,
|
|
367
|
+
owner,
|
|
368
|
+
_args5 = arguments;
|
|
369
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
370
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
275
371
|
case 0:
|
|
276
|
-
|
|
372
|
+
items = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : [];
|
|
373
|
+
err = null;
|
|
374
|
+
_context5.next = 4;
|
|
375
|
+
return this.checkWallet({
|
|
376
|
+
jwk: jwk
|
|
377
|
+
});
|
|
378
|
+
case 4:
|
|
379
|
+
_yield$this$checkWall3 = _context5.sent;
|
|
380
|
+
err = _yield$this$checkWall3.err;
|
|
381
|
+
jwk = _yield$this$checkWall3.jwk;
|
|
382
|
+
if (!err) {
|
|
383
|
+
_context5.next = 9;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
return _context5.abrupt("return", {
|
|
387
|
+
err: err
|
|
388
|
+
});
|
|
389
|
+
case 9:
|
|
390
|
+
res = null;
|
|
277
391
|
if (tx.id) {
|
|
278
|
-
|
|
392
|
+
_context5.next = 13;
|
|
279
393
|
break;
|
|
280
394
|
}
|
|
281
|
-
|
|
395
|
+
_context5.next = 13;
|
|
282
396
|
return this.mem.arweave.transactions.sign(tx, jwk);
|
|
283
|
-
case
|
|
397
|
+
case 13:
|
|
284
398
|
this.mem.height += 1;
|
|
285
399
|
block = {
|
|
286
400
|
id: tx.id,
|
|
287
401
|
timestamp: Date.now(),
|
|
288
402
|
height: this.mem.height,
|
|
289
|
-
previous: (_last = (0, _ramda.last)(this.mem.blocks)) !== null && _last !== void 0 ? _last : ""
|
|
403
|
+
previous: (_last = (0, _ramda.last)(this.mem.blocks)) !== null && _last !== void 0 ? _last : "",
|
|
404
|
+
txs: []
|
|
290
405
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
if (!item.id) {
|
|
296
|
-
item.id = tx.id;
|
|
297
|
-
this.mem.txs[tx.id] = item;
|
|
298
|
-
this.mem.txs[tx.id].parent = null;
|
|
299
|
-
this.mem.txs[tx.id].signature = tx.signature;
|
|
300
|
-
this.mem.txs[tx.id].anchor = tx.last_tx;
|
|
301
|
-
data_type = "";
|
|
302
|
-
_iterator3 = _createForOfIteratorHelper(tx.tags);
|
|
406
|
+
msg = null;
|
|
407
|
+
if (items) {
|
|
408
|
+
_iterator4 = _createForOfIteratorHelper(items);
|
|
303
409
|
try {
|
|
304
|
-
for (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
410
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
411
|
+
item = _step4.value;
|
|
412
|
+
this.mem.txs[item.id] = item;
|
|
413
|
+
this.mem.txs[item.id].parent = {
|
|
414
|
+
id: tx.id
|
|
415
|
+
};
|
|
416
|
+
this.mem.txs[item.id].bundledIn = {
|
|
417
|
+
id: tx.id
|
|
418
|
+
};
|
|
419
|
+
this.mem.txs[item.id].anchor = "";
|
|
420
|
+
_tags2 = (0, _utils.tags)(item.tags);
|
|
421
|
+
if ((0, _ramda.includes)(_tags2.Type, ["Message", "Process", "Module", "Scheduler-Location", "Attestation", "Available"])) {
|
|
422
|
+
msg = {
|
|
423
|
+
id: item.id,
|
|
424
|
+
type: _tags2.Type
|
|
425
|
+
};
|
|
426
|
+
if (msg.type === "Process") msg.pid = item.recipient;
|
|
427
|
+
}
|
|
428
|
+
data_type = "";
|
|
429
|
+
_iterator5 = _createForOfIteratorHelper(item.item.tags);
|
|
430
|
+
try {
|
|
431
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
432
|
+
v = _step5.value;
|
|
433
|
+
if (v.name === "Content-Type") data_type = v.value;
|
|
434
|
+
}
|
|
435
|
+
//this.mem.txs[tx.id]._data = { size: tx.data_size, type: data_type }
|
|
436
|
+
} catch (err) {
|
|
437
|
+
_iterator5.e(err);
|
|
438
|
+
} finally {
|
|
439
|
+
_iterator5.f();
|
|
314
440
|
}
|
|
441
|
+
block.txs.push(item.id);
|
|
442
|
+
this.mem.txs[item.id].block = block.id;
|
|
315
443
|
}
|
|
316
444
|
} catch (err) {
|
|
317
|
-
|
|
445
|
+
_iterator4.e(err);
|
|
318
446
|
} finally {
|
|
319
|
-
|
|
447
|
+
_iterator4.f();
|
|
320
448
|
}
|
|
321
|
-
this.mem.txs[tx.id]._data = {
|
|
322
|
-
size: tx.data_size,
|
|
323
|
-
type: data_type
|
|
324
|
-
};
|
|
325
|
-
} else {
|
|
326
|
-
this.mem.txs[item.id].parent = {
|
|
327
|
-
id: block.id
|
|
328
|
-
};
|
|
329
449
|
}
|
|
330
|
-
block.txs = [item.id];
|
|
331
|
-
this.mem.txs[item.id].block = block.id;
|
|
332
|
-
_context4.next = 22;
|
|
333
|
-
break;
|
|
334
|
-
case 12:
|
|
335
450
|
_tags = [];
|
|
336
|
-
|
|
451
|
+
_iterator6 = _createForOfIteratorHelper(tx.tags);
|
|
337
452
|
try {
|
|
338
|
-
for (
|
|
339
|
-
_v =
|
|
453
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
454
|
+
_v = _step6.value;
|
|
340
455
|
_tags.push({
|
|
341
456
|
name: _base64url["default"].decode(_v.name),
|
|
342
457
|
value: _base64url["default"].decode(_v.value)
|
|
343
458
|
});
|
|
344
459
|
}
|
|
345
460
|
} catch (err) {
|
|
346
|
-
|
|
461
|
+
_iterator6.e(err);
|
|
347
462
|
} finally {
|
|
348
|
-
|
|
463
|
+
_iterator6.f();
|
|
349
464
|
}
|
|
350
465
|
tx.tags = _tags;
|
|
351
|
-
|
|
466
|
+
_context5.next = 23;
|
|
352
467
|
return this.arweave.wallets.jwkToAddress({
|
|
353
468
|
n: tx.owner
|
|
354
469
|
});
|
|
355
|
-
case
|
|
356
|
-
tx.owner =
|
|
470
|
+
case 23:
|
|
471
|
+
tx.owner = _context5.sent;
|
|
357
472
|
this.mem.txs[tx.id] = tx;
|
|
358
|
-
block.txs
|
|
473
|
+
block.txs.push(tx.id);
|
|
359
474
|
this.mem.txs[tx.id].block = block.id;
|
|
360
|
-
case 22:
|
|
361
475
|
this.mem.blocks.push(block.id);
|
|
362
476
|
this.mem.blockmap[block.id] = block;
|
|
363
477
|
if (!jwk) {
|
|
364
|
-
|
|
478
|
+
_context5.next = 34;
|
|
365
479
|
break;
|
|
366
480
|
}
|
|
367
|
-
|
|
481
|
+
_context5.next = 32;
|
|
368
482
|
return this.arweave.wallets.jwkToAddress(jwk);
|
|
369
|
-
case
|
|
370
|
-
owner =
|
|
483
|
+
case 32:
|
|
484
|
+
owner = _context5.sent;
|
|
371
485
|
this.mem.addrmap[owner] = {
|
|
372
486
|
address: owner,
|
|
373
487
|
key: jwk.n
|
|
374
488
|
};
|
|
375
|
-
case
|
|
489
|
+
case 34:
|
|
376
490
|
res = {
|
|
377
491
|
id: tx.id,
|
|
378
492
|
status: 200,
|
|
379
493
|
statusText: "200"
|
|
380
494
|
};
|
|
381
|
-
|
|
495
|
+
if (this.log) {
|
|
496
|
+
if (msg) {
|
|
497
|
+
console.log("New ".concat(msg.type, ":\t").concat(msg.id).concat(msg.pid ? " > ".concat(msg.pid) : ""));
|
|
498
|
+
} else {
|
|
499
|
+
console.log("New Post:\t".concat(tx.id));
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return _context5.abrupt("return", {
|
|
382
503
|
res: res,
|
|
383
504
|
err: err,
|
|
384
505
|
id: tx.id
|
|
385
506
|
});
|
|
386
|
-
case
|
|
507
|
+
case 37:
|
|
387
508
|
case "end":
|
|
388
|
-
return
|
|
509
|
+
return _context5.stop();
|
|
389
510
|
}
|
|
390
|
-
},
|
|
511
|
+
}, _callee5, this);
|
|
391
512
|
}));
|
|
392
|
-
function postTx(
|
|
513
|
+
function postTx(_x6, _x7) {
|
|
393
514
|
return _postTx.apply(this, arguments);
|
|
394
515
|
}
|
|
395
516
|
return postTx;
|
|
@@ -397,16 +518,16 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
397
518
|
}, {
|
|
398
519
|
key: "tx",
|
|
399
520
|
value: function () {
|
|
400
|
-
var _tx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
401
|
-
return _regeneratorRuntime().wrap(function
|
|
402
|
-
while (1) switch (
|
|
521
|
+
var _tx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
522
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
523
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
403
524
|
case 0:
|
|
404
|
-
return
|
|
525
|
+
return _context6.abrupt("return", this.mem.txs[id]);
|
|
405
526
|
case 1:
|
|
406
527
|
case "end":
|
|
407
|
-
return
|
|
528
|
+
return _context6.stop();
|
|
408
529
|
}
|
|
409
|
-
},
|
|
530
|
+
}, _callee6, this);
|
|
410
531
|
}));
|
|
411
532
|
function tx(_x8) {
|
|
412
533
|
return _tx.apply(this, arguments);
|
|
@@ -416,27 +537,47 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
416
537
|
}, {
|
|
417
538
|
key: "data",
|
|
418
539
|
value: function () {
|
|
419
|
-
var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
420
|
-
var
|
|
421
|
-
var tx, _data;
|
|
422
|
-
return _regeneratorRuntime().wrap(function
|
|
423
|
-
while (1) switch (
|
|
540
|
+
var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id, _string) {
|
|
541
|
+
var _tx$data;
|
|
542
|
+
var decode, string, tx, _data, isBuf, isStr;
|
|
543
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
544
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
424
545
|
case 0:
|
|
546
|
+
decode = true;
|
|
547
|
+
string = _string;
|
|
548
|
+
if ((0, _ramda.is)(Object, _string)) {
|
|
549
|
+
if (!(0, _ramda.isNil)(_string.decode)) decode = _string.decode;
|
|
550
|
+
if (!(0, _ramda.isNil)(_string.string)) string = _string.string;
|
|
551
|
+
}
|
|
425
552
|
tx = this.mem.txs[id];
|
|
426
|
-
_data = (
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
_data = _base64url["default"].decode(_data);
|
|
553
|
+
_data = (_tx$data = tx === null || tx === void 0 ? void 0 : tx.data) !== null && _tx$data !== void 0 ? _tx$data : null;
|
|
554
|
+
isBuf = (0, _ramda.is)(Uint8Array, _data) || (0, _ramda.is)(ArrayBuffer, _data);
|
|
555
|
+
isStr = (0, _ramda.is)(String, _data);
|
|
556
|
+
if (!(decode === false)) {
|
|
557
|
+
_context7.next = 12;
|
|
558
|
+
break;
|
|
433
559
|
}
|
|
434
|
-
|
|
435
|
-
|
|
560
|
+
if (isStr) _data = new TextEncoder().encode(_data);
|
|
561
|
+
return _context7.abrupt("return", _base64url["default"].encode(_data));
|
|
562
|
+
case 12:
|
|
563
|
+
if (!(isBuf && string)) {
|
|
564
|
+
_context7.next = 16;
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
return _context7.abrupt("return", Buffer.from(_data).toString());
|
|
568
|
+
case 16:
|
|
569
|
+
if (!(isStr && string !== true)) {
|
|
570
|
+
_context7.next = 18;
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
return _context7.abrupt("return", new TextEncoder().encode(_data));
|
|
574
|
+
case 18:
|
|
575
|
+
return _context7.abrupt("return", _data);
|
|
576
|
+
case 19:
|
|
436
577
|
case "end":
|
|
437
|
-
return
|
|
578
|
+
return _context7.stop();
|
|
438
579
|
}
|
|
439
|
-
},
|
|
580
|
+
}, _callee7, this);
|
|
440
581
|
}));
|
|
441
582
|
function data(_x9, _x10) {
|
|
442
583
|
return _data2.apply(this, arguments);
|