@leofcoin/chain 1.3.7 → 1.3.9

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.
@@ -10114,543 +10114,6 @@ exports.finished = __webpack_require__(186);
10114
10114
  exports.pipeline = __webpack_require__(619);
10115
10115
 
10116
10116
 
10117
- /***/ }),
10118
-
10119
- /***/ 470:
10120
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
10121
-
10122
- /* provided dependency */ var process = __webpack_require__(155);
10123
- // 'path' module extracted from Node.js v8.11.1 (only the posix part)
10124
- // transplited with Babel
10125
-
10126
- // Copyright Joyent, Inc. and other Node contributors.
10127
- //
10128
- // Permission is hereby granted, free of charge, to any person obtaining a
10129
- // copy of this software and associated documentation files (the
10130
- // "Software"), to deal in the Software without restriction, including
10131
- // without limitation the rights to use, copy, modify, merge, publish,
10132
- // distribute, sublicense, and/or sell copies of the Software, and to permit
10133
- // persons to whom the Software is furnished to do so, subject to the
10134
- // following conditions:
10135
- //
10136
- // The above copyright notice and this permission notice shall be included
10137
- // in all copies or substantial portions of the Software.
10138
- //
10139
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10140
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10141
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10142
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10143
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10144
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10145
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
10146
-
10147
-
10148
-
10149
- function assertPath(path) {
10150
- if (typeof path !== 'string') {
10151
- throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
10152
- }
10153
- }
10154
-
10155
- // Resolves . and .. elements in a path with directory names
10156
- function normalizeStringPosix(path, allowAboveRoot) {
10157
- var res = '';
10158
- var lastSegmentLength = 0;
10159
- var lastSlash = -1;
10160
- var dots = 0;
10161
- var code;
10162
- for (var i = 0; i <= path.length; ++i) {
10163
- if (i < path.length)
10164
- code = path.charCodeAt(i);
10165
- else if (code === 47 /*/*/)
10166
- break;
10167
- else
10168
- code = 47 /*/*/;
10169
- if (code === 47 /*/*/) {
10170
- if (lastSlash === i - 1 || dots === 1) {
10171
- // NOOP
10172
- } else if (lastSlash !== i - 1 && dots === 2) {
10173
- if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
10174
- if (res.length > 2) {
10175
- var lastSlashIndex = res.lastIndexOf('/');
10176
- if (lastSlashIndex !== res.length - 1) {
10177
- if (lastSlashIndex === -1) {
10178
- res = '';
10179
- lastSegmentLength = 0;
10180
- } else {
10181
- res = res.slice(0, lastSlashIndex);
10182
- lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
10183
- }
10184
- lastSlash = i;
10185
- dots = 0;
10186
- continue;
10187
- }
10188
- } else if (res.length === 2 || res.length === 1) {
10189
- res = '';
10190
- lastSegmentLength = 0;
10191
- lastSlash = i;
10192
- dots = 0;
10193
- continue;
10194
- }
10195
- }
10196
- if (allowAboveRoot) {
10197
- if (res.length > 0)
10198
- res += '/..';
10199
- else
10200
- res = '..';
10201
- lastSegmentLength = 2;
10202
- }
10203
- } else {
10204
- if (res.length > 0)
10205
- res += '/' + path.slice(lastSlash + 1, i);
10206
- else
10207
- res = path.slice(lastSlash + 1, i);
10208
- lastSegmentLength = i - lastSlash - 1;
10209
- }
10210
- lastSlash = i;
10211
- dots = 0;
10212
- } else if (code === 46 /*.*/ && dots !== -1) {
10213
- ++dots;
10214
- } else {
10215
- dots = -1;
10216
- }
10217
- }
10218
- return res;
10219
- }
10220
-
10221
- function _format(sep, pathObject) {
10222
- var dir = pathObject.dir || pathObject.root;
10223
- var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
10224
- if (!dir) {
10225
- return base;
10226
- }
10227
- if (dir === pathObject.root) {
10228
- return dir + base;
10229
- }
10230
- return dir + sep + base;
10231
- }
10232
-
10233
- var posix = {
10234
- // path.resolve([from ...], to)
10235
- resolve: function resolve() {
10236
- var resolvedPath = '';
10237
- var resolvedAbsolute = false;
10238
- var cwd;
10239
-
10240
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
10241
- var path;
10242
- if (i >= 0)
10243
- path = arguments[i];
10244
- else {
10245
- if (cwd === undefined)
10246
- cwd = process.cwd();
10247
- path = cwd;
10248
- }
10249
-
10250
- assertPath(path);
10251
-
10252
- // Skip empty entries
10253
- if (path.length === 0) {
10254
- continue;
10255
- }
10256
-
10257
- resolvedPath = path + '/' + resolvedPath;
10258
- resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
10259
- }
10260
-
10261
- // At this point the path should be resolved to a full absolute path, but
10262
- // handle relative paths to be safe (might happen when process.cwd() fails)
10263
-
10264
- // Normalize the path
10265
- resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
10266
-
10267
- if (resolvedAbsolute) {
10268
- if (resolvedPath.length > 0)
10269
- return '/' + resolvedPath;
10270
- else
10271
- return '/';
10272
- } else if (resolvedPath.length > 0) {
10273
- return resolvedPath;
10274
- } else {
10275
- return '.';
10276
- }
10277
- },
10278
-
10279
- normalize: function normalize(path) {
10280
- assertPath(path);
10281
-
10282
- if (path.length === 0) return '.';
10283
-
10284
- var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
10285
- var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
10286
-
10287
- // Normalize the path
10288
- path = normalizeStringPosix(path, !isAbsolute);
10289
-
10290
- if (path.length === 0 && !isAbsolute) path = '.';
10291
- if (path.length > 0 && trailingSeparator) path += '/';
10292
-
10293
- if (isAbsolute) return '/' + path;
10294
- return path;
10295
- },
10296
-
10297
- isAbsolute: function isAbsolute(path) {
10298
- assertPath(path);
10299
- return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
10300
- },
10301
-
10302
- join: function join() {
10303
- if (arguments.length === 0)
10304
- return '.';
10305
- var joined;
10306
- for (var i = 0; i < arguments.length; ++i) {
10307
- var arg = arguments[i];
10308
- assertPath(arg);
10309
- if (arg.length > 0) {
10310
- if (joined === undefined)
10311
- joined = arg;
10312
- else
10313
- joined += '/' + arg;
10314
- }
10315
- }
10316
- if (joined === undefined)
10317
- return '.';
10318
- return posix.normalize(joined);
10319
- },
10320
-
10321
- relative: function relative(from, to) {
10322
- assertPath(from);
10323
- assertPath(to);
10324
-
10325
- if (from === to) return '';
10326
-
10327
- from = posix.resolve(from);
10328
- to = posix.resolve(to);
10329
-
10330
- if (from === to) return '';
10331
-
10332
- // Trim any leading backslashes
10333
- var fromStart = 1;
10334
- for (; fromStart < from.length; ++fromStart) {
10335
- if (from.charCodeAt(fromStart) !== 47 /*/*/)
10336
- break;
10337
- }
10338
- var fromEnd = from.length;
10339
- var fromLen = fromEnd - fromStart;
10340
-
10341
- // Trim any leading backslashes
10342
- var toStart = 1;
10343
- for (; toStart < to.length; ++toStart) {
10344
- if (to.charCodeAt(toStart) !== 47 /*/*/)
10345
- break;
10346
- }
10347
- var toEnd = to.length;
10348
- var toLen = toEnd - toStart;
10349
-
10350
- // Compare paths to find the longest common path from root
10351
- var length = fromLen < toLen ? fromLen : toLen;
10352
- var lastCommonSep = -1;
10353
- var i = 0;
10354
- for (; i <= length; ++i) {
10355
- if (i === length) {
10356
- if (toLen > length) {
10357
- if (to.charCodeAt(toStart + i) === 47 /*/*/) {
10358
- // We get here if `from` is the exact base path for `to`.
10359
- // For example: from='/foo/bar'; to='/foo/bar/baz'
10360
- return to.slice(toStart + i + 1);
10361
- } else if (i === 0) {
10362
- // We get here if `from` is the root
10363
- // For example: from='/'; to='/foo'
10364
- return to.slice(toStart + i);
10365
- }
10366
- } else if (fromLen > length) {
10367
- if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
10368
- // We get here if `to` is the exact base path for `from`.
10369
- // For example: from='/foo/bar/baz'; to='/foo/bar'
10370
- lastCommonSep = i;
10371
- } else if (i === 0) {
10372
- // We get here if `to` is the root.
10373
- // For example: from='/foo'; to='/'
10374
- lastCommonSep = 0;
10375
- }
10376
- }
10377
- break;
10378
- }
10379
- var fromCode = from.charCodeAt(fromStart + i);
10380
- var toCode = to.charCodeAt(toStart + i);
10381
- if (fromCode !== toCode)
10382
- break;
10383
- else if (fromCode === 47 /*/*/)
10384
- lastCommonSep = i;
10385
- }
10386
-
10387
- var out = '';
10388
- // Generate the relative path based on the path difference between `to`
10389
- // and `from`
10390
- for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
10391
- if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
10392
- if (out.length === 0)
10393
- out += '..';
10394
- else
10395
- out += '/..';
10396
- }
10397
- }
10398
-
10399
- // Lastly, append the rest of the destination (`to`) path that comes after
10400
- // the common path parts
10401
- if (out.length > 0)
10402
- return out + to.slice(toStart + lastCommonSep);
10403
- else {
10404
- toStart += lastCommonSep;
10405
- if (to.charCodeAt(toStart) === 47 /*/*/)
10406
- ++toStart;
10407
- return to.slice(toStart);
10408
- }
10409
- },
10410
-
10411
- _makeLong: function _makeLong(path) {
10412
- return path;
10413
- },
10414
-
10415
- dirname: function dirname(path) {
10416
- assertPath(path);
10417
- if (path.length === 0) return '.';
10418
- var code = path.charCodeAt(0);
10419
- var hasRoot = code === 47 /*/*/;
10420
- var end = -1;
10421
- var matchedSlash = true;
10422
- for (var i = path.length - 1; i >= 1; --i) {
10423
- code = path.charCodeAt(i);
10424
- if (code === 47 /*/*/) {
10425
- if (!matchedSlash) {
10426
- end = i;
10427
- break;
10428
- }
10429
- } else {
10430
- // We saw the first non-path separator
10431
- matchedSlash = false;
10432
- }
10433
- }
10434
-
10435
- if (end === -1) return hasRoot ? '/' : '.';
10436
- if (hasRoot && end === 1) return '//';
10437
- return path.slice(0, end);
10438
- },
10439
-
10440
- basename: function basename(path, ext) {
10441
- if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
10442
- assertPath(path);
10443
-
10444
- var start = 0;
10445
- var end = -1;
10446
- var matchedSlash = true;
10447
- var i;
10448
-
10449
- if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
10450
- if (ext.length === path.length && ext === path) return '';
10451
- var extIdx = ext.length - 1;
10452
- var firstNonSlashEnd = -1;
10453
- for (i = path.length - 1; i >= 0; --i) {
10454
- var code = path.charCodeAt(i);
10455
- if (code === 47 /*/*/) {
10456
- // If we reached a path separator that was not part of a set of path
10457
- // separators at the end of the string, stop now
10458
- if (!matchedSlash) {
10459
- start = i + 1;
10460
- break;
10461
- }
10462
- } else {
10463
- if (firstNonSlashEnd === -1) {
10464
- // We saw the first non-path separator, remember this index in case
10465
- // we need it if the extension ends up not matching
10466
- matchedSlash = false;
10467
- firstNonSlashEnd = i + 1;
10468
- }
10469
- if (extIdx >= 0) {
10470
- // Try to match the explicit extension
10471
- if (code === ext.charCodeAt(extIdx)) {
10472
- if (--extIdx === -1) {
10473
- // We matched the extension, so mark this as the end of our path
10474
- // component
10475
- end = i;
10476
- }
10477
- } else {
10478
- // Extension does not match, so our result is the entire path
10479
- // component
10480
- extIdx = -1;
10481
- end = firstNonSlashEnd;
10482
- }
10483
- }
10484
- }
10485
- }
10486
-
10487
- if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
10488
- return path.slice(start, end);
10489
- } else {
10490
- for (i = path.length - 1; i >= 0; --i) {
10491
- if (path.charCodeAt(i) === 47 /*/*/) {
10492
- // If we reached a path separator that was not part of a set of path
10493
- // separators at the end of the string, stop now
10494
- if (!matchedSlash) {
10495
- start = i + 1;
10496
- break;
10497
- }
10498
- } else if (end === -1) {
10499
- // We saw the first non-path separator, mark this as the end of our
10500
- // path component
10501
- matchedSlash = false;
10502
- end = i + 1;
10503
- }
10504
- }
10505
-
10506
- if (end === -1) return '';
10507
- return path.slice(start, end);
10508
- }
10509
- },
10510
-
10511
- extname: function extname(path) {
10512
- assertPath(path);
10513
- var startDot = -1;
10514
- var startPart = 0;
10515
- var end = -1;
10516
- var matchedSlash = true;
10517
- // Track the state of characters (if any) we see before our first dot and
10518
- // after any path separator we find
10519
- var preDotState = 0;
10520
- for (var i = path.length - 1; i >= 0; --i) {
10521
- var code = path.charCodeAt(i);
10522
- if (code === 47 /*/*/) {
10523
- // If we reached a path separator that was not part of a set of path
10524
- // separators at the end of the string, stop now
10525
- if (!matchedSlash) {
10526
- startPart = i + 1;
10527
- break;
10528
- }
10529
- continue;
10530
- }
10531
- if (end === -1) {
10532
- // We saw the first non-path separator, mark this as the end of our
10533
- // extension
10534
- matchedSlash = false;
10535
- end = i + 1;
10536
- }
10537
- if (code === 46 /*.*/) {
10538
- // If this is our first dot, mark it as the start of our extension
10539
- if (startDot === -1)
10540
- startDot = i;
10541
- else if (preDotState !== 1)
10542
- preDotState = 1;
10543
- } else if (startDot !== -1) {
10544
- // We saw a non-dot and non-path separator before our dot, so we should
10545
- // have a good chance at having a non-empty extension
10546
- preDotState = -1;
10547
- }
10548
- }
10549
-
10550
- if (startDot === -1 || end === -1 ||
10551
- // We saw a non-dot character immediately before the dot
10552
- preDotState === 0 ||
10553
- // The (right-most) trimmed path component is exactly '..'
10554
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
10555
- return '';
10556
- }
10557
- return path.slice(startDot, end);
10558
- },
10559
-
10560
- format: function format(pathObject) {
10561
- if (pathObject === null || typeof pathObject !== 'object') {
10562
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
10563
- }
10564
- return _format('/', pathObject);
10565
- },
10566
-
10567
- parse: function parse(path) {
10568
- assertPath(path);
10569
-
10570
- var ret = { root: '', dir: '', base: '', ext: '', name: '' };
10571
- if (path.length === 0) return ret;
10572
- var code = path.charCodeAt(0);
10573
- var isAbsolute = code === 47 /*/*/;
10574
- var start;
10575
- if (isAbsolute) {
10576
- ret.root = '/';
10577
- start = 1;
10578
- } else {
10579
- start = 0;
10580
- }
10581
- var startDot = -1;
10582
- var startPart = 0;
10583
- var end = -1;
10584
- var matchedSlash = true;
10585
- var i = path.length - 1;
10586
-
10587
- // Track the state of characters (if any) we see before our first dot and
10588
- // after any path separator we find
10589
- var preDotState = 0;
10590
-
10591
- // Get non-dir info
10592
- for (; i >= start; --i) {
10593
- code = path.charCodeAt(i);
10594
- if (code === 47 /*/*/) {
10595
- // If we reached a path separator that was not part of a set of path
10596
- // separators at the end of the string, stop now
10597
- if (!matchedSlash) {
10598
- startPart = i + 1;
10599
- break;
10600
- }
10601
- continue;
10602
- }
10603
- if (end === -1) {
10604
- // We saw the first non-path separator, mark this as the end of our
10605
- // extension
10606
- matchedSlash = false;
10607
- end = i + 1;
10608
- }
10609
- if (code === 46 /*.*/) {
10610
- // If this is our first dot, mark it as the start of our extension
10611
- if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
10612
- } else if (startDot !== -1) {
10613
- // We saw a non-dot and non-path separator before our dot, so we should
10614
- // have a good chance at having a non-empty extension
10615
- preDotState = -1;
10616
- }
10617
- }
10618
-
10619
- if (startDot === -1 || end === -1 ||
10620
- // We saw a non-dot character immediately before the dot
10621
- preDotState === 0 ||
10622
- // The (right-most) trimmed path component is exactly '..'
10623
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
10624
- if (end !== -1) {
10625
- if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
10626
- }
10627
- } else {
10628
- if (startPart === 0 && isAbsolute) {
10629
- ret.name = path.slice(1, startDot);
10630
- ret.base = path.slice(1, end);
10631
- } else {
10632
- ret.name = path.slice(startPart, startDot);
10633
- ret.base = path.slice(startPart, end);
10634
- }
10635
- ret.ext = path.slice(startDot, end);
10636
- }
10637
-
10638
- if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
10639
-
10640
- return ret;
10641
- },
10642
-
10643
- sep: '/',
10644
- delimiter: ':',
10645
- win32: null,
10646
- posix: null
10647
- };
10648
-
10649
- posix.posix = posix;
10650
-
10651
- module.exports = posix;
10652
-
10653
-
10654
10117
  /***/ }),
10655
10118
 
10656
10119
  /***/ 155:
@@ -13250,8 +12713,6 @@ function joinSignature(signature) {
13250
12713
  ]));
13251
12714
  }
13252
12715
  //# sourceMappingURL=index.js.map
13253
- // EXTERNAL MODULE: ./node_modules/path-browserify/index.js
13254
- var path_browserify = __webpack_require__(470);
13255
12716
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/easy-worker/src/worker.js
13256
12717
  /* provided dependency */ var process = __webpack_require__(155);
13257
12718
  class EasyWorker {
@@ -13339,7 +12800,6 @@ class EasyWorker {
13339
12800
 
13340
12801
 
13341
12802
 
13342
-
13343
12803
  var proto$1 = `
13344
12804
  message ContractMessage {
13345
12805
  required string creator = 1;
@@ -13732,21 +13192,20 @@ const get = (contract, method, params) => {
13732
13192
  return result
13733
13193
  };
13734
13194
 
13735
- const runContract = async (contractMessage) => {
13736
- const params = contractMessage.decoded.constructorParameters;
13195
+ const runContract = async ({decoded, hash, encoded}) => {
13196
+ const params = decoded.constructorParameters;
13737
13197
  try {
13738
13198
 
13739
- const func = new Function(contractMessage.decoded.contract);
13199
+ const func = new Function(decoded.contract);
13740
13200
  const Contract = func();
13741
13201
 
13742
- globalThis.msg = createMessage(contractMessage.decoded.creator);
13743
- // globalThis.msg = {sender: contractMessage.decoded.creator}
13744
- contracts[await contractMessage.hash] = await new Contract(...params);
13202
+ globalThis.msg = createMessage(decoded.creator);
13203
+ contracts[hash] = await new Contract(...params);
13745
13204
  worker.postMessage({
13746
13205
  type: 'debug',
13747
13206
  messages: [
13748
- `loaded contract: ${await contractMessage.hash}`,
13749
- `size: ${formatBytes(contractMessage.encoded.length)}`
13207
+ `loaded contract: ${hash}`,
13208
+ `size: ${formatBytes(encoded.length)}`
13750
13209
  ]
13751
13210
  });
13752
13211
  } catch (e) {
@@ -13810,7 +13269,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
13810
13269
 
13811
13270
  contracts = await Promise.all(contracts.map(async contract => {
13812
13271
  contract = await new ContractMessage(new Uint8Array(contract.split(',')));
13813
- await runContract(contract);
13272
+ await runContract({decoded: contract.decoded, encoded: contract.encoded, hash: await contract.hash});
13814
13273
  return contract
13815
13274
  }));
13816
13275
 
@@ -13869,6 +13328,22 @@ const tasks = async (e) => {
13869
13328
  });
13870
13329
  }
13871
13330
  }
13331
+ if (e.type === 'run') {
13332
+ try {
13333
+ const value = await runContract(e.input);
13334
+ worker.postMessage({
13335
+ type: 'response',
13336
+ id,
13337
+ value
13338
+ });
13339
+ } catch (e) {
13340
+ worker.postMessage({
13341
+ type: 'fetchError',
13342
+ message: e.message,
13343
+ id
13344
+ });
13345
+ }
13346
+ }
13872
13347
  if (e.type === 'get') {
13873
13348
  try {
13874
13349
  const value = await get(e.input.contract, e.input.method, e.input.params);