@leofcoin/chain 1.1.9 → 1.1.11

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.
Files changed (67) hide show
  1. package/demo/865.browser.js +10 -0
  2. package/demo/865.machine-worker.js +10 -0
  3. package/demo/chain.browser.js +51312 -6162
  4. package/demo/chain.js +1209 -0
  5. package/demo/generate-account.browser.js +50 -0
  6. package/demo/index.html +8 -1
  7. package/demo/machine-worker.js +17624 -0
  8. package/demo/messages.browser.js +328 -0
  9. package/demo/{911.browser.js → multi-wallet.browser.js} +1 -11010
  10. package/demo/node.browser.js +2458 -3954
  11. package/demo/node.js +1 -0
  12. package/demo/peernet-swarm.browser.js +832 -0
  13. package/demo/storage.browser.js +3724 -0
  14. package/demo/workers/865.js +10 -0
  15. package/demo/workers/block-worker.js +13200 -0
  16. package/demo/workers/machine-worker.js +2912 -1526
  17. package/demo/workers/pool-worker.js +8504 -0
  18. package/demo/{main.browser.js → workers/transaction-worker.js} +1456 -1123
  19. package/demo/workers/workers/865.js +10 -0
  20. package/demo/workers/workers/block-worker.js +13200 -0
  21. package/demo/workers/workers/machine-worker.js +13904 -0
  22. package/demo/workers/workers/pool-worker.js +8504 -0
  23. package/demo/workers/workers/transaction-worker.js +8496 -0
  24. package/dist/865.browser.js +10 -0
  25. package/dist/browser/workers/865.js +10 -0
  26. package/dist/browser/workers/block-worker.js +13200 -0
  27. package/dist/browser/workers/machine-worker.js +13930 -0
  28. package/dist/browser/workers/pool-worker.js +8504 -0
  29. package/{demo/427.browser.js → dist/browser/workers/transaction-worker.js} +1533 -1129
  30. package/dist/chain.browser.js +59742 -0
  31. package/dist/chain.js +207 -187
  32. package/dist/generate-account.browser.js +50 -0
  33. package/dist/messages.browser.js +328 -0
  34. package/dist/module/chain.js +206 -187
  35. package/dist/module/node.js +203 -1
  36. package/dist/module/workers/block-worker.js +93 -0
  37. package/dist/module/workers/machine-worker.js +67 -331
  38. package/dist/module/workers/pool-worker.js +55 -0
  39. package/dist/module/workers/transaction-worker.js +47 -0
  40. package/{demo/peernet-worker.browser.js → dist/multi-wallet.browser.js} +2 -11317
  41. package/dist/node.browser.js +9839 -0
  42. package/dist/node.js +209 -1
  43. package/dist/pako.browser.js +6731 -0
  44. package/dist/peernet-swarm.browser.js +832 -0
  45. package/dist/storage.browser.js +3724 -0
  46. package/dist/workers/block-worker.js +1 -1
  47. package/dist/workers/machine-worker.js +1 -1
  48. package/dist/workers/pool-worker.js +1 -1
  49. package/dist/workers/transaction-worker.js +1 -1
  50. package/dist/wrtc.browser.js +28 -0
  51. package/package.json +9 -4
  52. package/rollup.config.js +41 -11
  53. package/src/chain.js +46 -16
  54. package/src/machine.js +25 -28
  55. package/test/chain.js +1 -1
  56. package/webpack.config.js +17 -4
  57. package/demo/151.browser.js +0 -271
  58. package/demo/205.browser.js +0 -215
  59. package/demo/560.browser.js +0 -3
  60. package/src/workers/block-worker.js +0 -70
  61. package/src/workers/machine-worker.js +0 -174
  62. package/src/workers/pool-worker.js +0 -37
  63. package/src/workers/transaction-worker.js +0 -26
  64. package/workers/block-worker.js +0 -1
  65. package/workers/machine-worker.js +0 -1
  66. package/workers/pool-worker.js +0 -1
  67. package/workers/transaction-worker.js +0 -1
package/webpack.config.js CHANGED
@@ -31,6 +31,9 @@ module.exports = [{
31
31
  fallback: {
32
32
  'vm': require.resolve("vm-browserify"),
33
33
  "path": require.resolve("path-browserify"),
34
+ "stream": require.resolve("stream-browserify"),
35
+ "crypto": require.resolve("crypto-browserify"),
36
+ "os": require.resolve("os-browserify/browser"),
34
37
  "child_process": false,
35
38
  "fs": false,
36
39
  "util": false,
@@ -41,6 +44,7 @@ module.exports = [{
41
44
  library: {
42
45
  type: 'module'
43
46
  },
47
+ publicPath: '',
44
48
  filename: '[name].browser.js',
45
49
  chunkFilename: '[name].browser.js',
46
50
  path: path.resolve(__dirname, 'dist'),
@@ -50,7 +54,12 @@ module.exports = [{
50
54
  }
51
55
  }, {
52
56
  mode: 'production',
53
- entry: './dist/module/workers/machine-worker.js',
57
+ entry: {
58
+ 'machine-worker': './dist/module/workers/machine-worker.js',
59
+ 'block-worker': './dist/module/workers/block-worker.js',
60
+ 'transaction-worker': './dist/module/workers/transaction-worker.js',
61
+ 'pool-worker': './dist/module/workers/pool-worker.js'
62
+ },
54
63
  plugins: [
55
64
  // Work around for Buffer is undefined:
56
65
  // https://github.com/webpack/changelog-v5/issues/10
@@ -75,10 +84,13 @@ module.exports = [{
75
84
  // extensions: [ '.ts', '.js' ],
76
85
  fallback: {
77
86
  'vm': require.resolve("vm-browserify"),
78
- // "stream": require.resolve("stream-browserify"),
87
+ 'path': require.resolve("path-browserify"),
88
+ "stream": require.resolve("stream-browserify"),
89
+ "os": require.resolve("os-browserify/browser"),
79
90
  // "buffer": require.resolve("buffer"),
80
91
  "fs": false,
81
92
  "util": false,
93
+ "child_process": false,
82
94
  // "assert": require.resolve("assert/"),
83
95
  }
84
96
  },
@@ -86,8 +98,9 @@ module.exports = [{
86
98
  library: {
87
99
  type: 'module'
88
100
  },
89
- filename: 'machine-worker.js',
90
- path: path.resolve(__dirname, 'dist'),
101
+ publicPath: '',
102
+ filename: '[name].js',
103
+ path: path.resolve(__dirname, 'dist/browser/workers'),
91
104
  },
92
105
  experiments: {
93
106
  outputModule: true
@@ -1,271 +0,0 @@
1
- /******/ var __webpack_modules__ = ({
2
-
3
- /***/ 5602:
4
- /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
5
-
6
- /* harmony import */ var _leofcoin_peernet__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7911);
7
- /* harmony import */ var _leofcoin_peernet__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_leofcoin_peernet__WEBPACK_IMPORTED_MODULE_0__);
8
- /* harmony import */ var _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3427);
9
- class ContractMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_1__.FormatInterface{get keys(){return["creator","contract","constructorParameters"]}get messageName(){return"ContractMessage"}constructor(e){super(e,"\nmessage ContractMessage {\n required string creator = 1;\n required bytes contract = 2;\n repeated string constructorParameters = 3;\n}\n",{name:"contract-message"})}}class TransactionMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_1__.FormatInterface{get keys(){return["timestamp","from","to","nonce","method","params","signature"]}get messageName(){return"TransactionMessage"}constructor(e){super(e,"\n\nmessage TransactionMessage {\n required uint64 timestamp = 1;\n required string from = 2;\n required string to = 3;\n required uint64 nonce = 4;\n required string method = 5;\n repeated string params = 6;\n required string signature = 7;\n}\n",{name:"transaction-message"})}}class BlockMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_1__.FormatInterface{get keys(){return["index","previousHash","timestamp","reward","fees","transactions","validators"]}get messageName(){return"BlockMessage"}constructor(e){super(e,"\nmessage ValidatorMessage {\n required string address = 1;\n required string reward = 2;\n}\n\nmessage Transaction {\n required string hash = 1;\n required uint64 timestamp = 2;\n required string from = 3;\n required string to = 4;\n required uint64 nonce = 5;\n required string method = 6;\n repeated string params = 7;\n}\n\nmessage BlockMessage {\n required uint64 index = 1;\n required string previousHash = 3;\n required uint64 timestamp = 4;\n required uint64 reward = 5;\n required string fees = 6;\n repeated Transaction transactions = 7;\n repeated ValidatorMessage validators = 8;\n}\n",{name:"block-message"})}}class BWMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_1__.FormatInterface{get keys(){return["up","down"]}get messageName(){return"BWMessage"}constructor(e){super(e,"\n\nmessage BWMessage {\n required uint64 up = 1;\n required uint64 down = 2;\n}\n",{name:"bw-message"})}}class BWRequestMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_1__.FormatInterface{get keys(){return[]}get messageName(){return"BWRequestMessage"}constructor(e){super(e,"\n\nmessage BWRequestMessage {\n}\n",{name:"bw-request-message"})}}(async()=>{const s={network:"leofcoin",root:".leofcoin",networkName:"leofcoin:mandarine",networkVersion:"v0.1.0"};globalThis.Peernet?await new globalThis.Peernet(s):await new (_leofcoin_peernet__WEBPACK_IMPORTED_MODULE_0___default())(s),await(async()=>{await peernet.addProto("contract-message",ContractMessage),await peernet.addProto("transaction-message",TransactionMessage),await peernet.addProto("block-message",BlockMessage),await peernet.addProto("bw-message",BWMessage),await peernet.addProto("bw-request-message",BWRequestMessage),await peernet.addCodec("contract-message",{codec:parseInt("636d",16),hashAlg:"keccak-256"}),await peernet.addCodec("transaction-message",{codec:parseInt("746d",16),hashAlg:"keccak-256"}),await peernet.addCodec("block-message",{codec:parseInt("626d",16),hashAlg:"keccak-256"}),await peernet.addCodec("bw-message",{codec:parseInt("62776d",16),hashAlg:"keccak-256"}),await peernet.addCodec("bw-request-message",{codec:parseInt("6277726d",16),hashAlg:"keccak-256"}),await peernet.addStore("contract","art",".leofcoin",!1),await peernet.addStore("accounts","art",".leofcoin",!1),await peernet.addStore("transactionPool","art",".leofcoin",!1)})(),onmessage=function(e){console.log(e),postMessage("world")},postMessage("world")})();
10
-
11
-
12
- /***/ }),
13
-
14
- /***/ 2361:
15
- /***/ (function() {
16
-
17
- /* (ignored) */
18
-
19
- /***/ }),
20
-
21
- /***/ 4616:
22
- /***/ (function() {
23
-
24
- /* (ignored) */
25
-
26
- /***/ })
27
-
28
- /******/ });
29
- /************************************************************************/
30
- /******/ // The module cache
31
- /******/ var __webpack_module_cache__ = {};
32
- /******/
33
- /******/ // The require function
34
- /******/ function __webpack_require__(moduleId) {
35
- /******/ // Check if module is in cache
36
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
37
- /******/ if (cachedModule !== undefined) {
38
- /******/ return cachedModule.exports;
39
- /******/ }
40
- /******/ // Create a new module (and put it into the cache)
41
- /******/ var module = __webpack_module_cache__[moduleId] = {
42
- /******/ // no module.id needed
43
- /******/ // no module.loaded needed
44
- /******/ exports: {}
45
- /******/ };
46
- /******/
47
- /******/ // Execute the module function
48
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
49
- /******/
50
- /******/ // Return the exports of the module
51
- /******/ return module.exports;
52
- /******/ }
53
- /******/
54
- /******/ // expose the modules object (__webpack_modules__)
55
- /******/ __webpack_require__.m = __webpack_modules__;
56
- /******/
57
- /******/ // the startup function
58
- /******/ __webpack_require__.x = function() {
59
- /******/ // Load entry module and return exports
60
- /******/ // This entry module depends on other loaded chunks and execution need to be delayed
61
- /******/ var __webpack_exports__ = __webpack_require__.O(undefined, [911], function() { return __webpack_require__(5602); })
62
- /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
63
- /******/ return __webpack_exports__;
64
- /******/ };
65
- /******/
66
- /************************************************************************/
67
- /******/ /* webpack/runtime/chunk loaded */
68
- /******/ !function() {
69
- /******/ var deferred = [];
70
- /******/ __webpack_require__.O = function(result, chunkIds, fn, priority) {
71
- /******/ if(chunkIds) {
72
- /******/ priority = priority || 0;
73
- /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
74
- /******/ deferred[i] = [chunkIds, fn, priority];
75
- /******/ return;
76
- /******/ }
77
- /******/ var notFulfilled = Infinity;
78
- /******/ for (var i = 0; i < deferred.length; i++) {
79
- /******/ var chunkIds = deferred[i][0];
80
- /******/ var fn = deferred[i][1];
81
- /******/ var priority = deferred[i][2];
82
- /******/ var fulfilled = true;
83
- /******/ for (var j = 0; j < chunkIds.length; j++) {
84
- /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {
85
- /******/ chunkIds.splice(j--, 1);
86
- /******/ } else {
87
- /******/ fulfilled = false;
88
- /******/ if(priority < notFulfilled) notFulfilled = priority;
89
- /******/ }
90
- /******/ }
91
- /******/ if(fulfilled) {
92
- /******/ deferred.splice(i--, 1)
93
- /******/ var r = fn();
94
- /******/ if (r !== undefined) result = r;
95
- /******/ }
96
- /******/ }
97
- /******/ return result;
98
- /******/ };
99
- /******/ }();
100
- /******/
101
- /******/ /* webpack/runtime/compat get default export */
102
- /******/ !function() {
103
- /******/ // getDefaultExport function for compatibility with non-harmony modules
104
- /******/ __webpack_require__.n = function(module) {
105
- /******/ var getter = module && module.__esModule ?
106
- /******/ function() { return module['default']; } :
107
- /******/ function() { return module; };
108
- /******/ __webpack_require__.d(getter, { a: getter });
109
- /******/ return getter;
110
- /******/ };
111
- /******/ }();
112
- /******/
113
- /******/ /* webpack/runtime/create fake namespace object */
114
- /******/ !function() {
115
- /******/ var getProto = Object.getPrototypeOf ? function(obj) { return Object.getPrototypeOf(obj); } : function(obj) { return obj.__proto__; };
116
- /******/ var leafPrototypes;
117
- /******/ // create a fake namespace object
118
- /******/ // mode & 1: value is a module id, require it
119
- /******/ // mode & 2: merge all properties of value into the ns
120
- /******/ // mode & 4: return value when already ns object
121
- /******/ // mode & 16: return value when it's Promise-like
122
- /******/ // mode & 8|1: behave like require
123
- /******/ __webpack_require__.t = function(value, mode) {
124
- /******/ if(mode & 1) value = this(value);
125
- /******/ if(mode & 8) return value;
126
- /******/ if(typeof value === 'object' && value) {
127
- /******/ if((mode & 4) && value.__esModule) return value;
128
- /******/ if((mode & 16) && typeof value.then === 'function') return value;
129
- /******/ }
130
- /******/ var ns = Object.create(null);
131
- /******/ __webpack_require__.r(ns);
132
- /******/ var def = {};
133
- /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
134
- /******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {
135
- /******/ Object.getOwnPropertyNames(current).forEach(function(key) { def[key] = function() { return value[key]; }; });
136
- /******/ }
137
- /******/ def['default'] = function() { return value; };
138
- /******/ __webpack_require__.d(ns, def);
139
- /******/ return ns;
140
- /******/ };
141
- /******/ }();
142
- /******/
143
- /******/ /* webpack/runtime/define property getters */
144
- /******/ !function() {
145
- /******/ // define getter functions for harmony exports
146
- /******/ __webpack_require__.d = function(exports, definition) {
147
- /******/ for(var key in definition) {
148
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
149
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
150
- /******/ }
151
- /******/ }
152
- /******/ };
153
- /******/ }();
154
- /******/
155
- /******/ /* webpack/runtime/ensure chunk */
156
- /******/ !function() {
157
- /******/ __webpack_require__.f = {};
158
- /******/ // This file contains only the entry chunk.
159
- /******/ // The chunk loading function for additional chunks
160
- /******/ __webpack_require__.e = function(chunkId) {
161
- /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
162
- /******/ __webpack_require__.f[key](chunkId, promises);
163
- /******/ return promises;
164
- /******/ }, []));
165
- /******/ };
166
- /******/ }();
167
- /******/
168
- /******/ /* webpack/runtime/get javascript chunk filename */
169
- /******/ !function() {
170
- /******/ // This function allow to reference async chunks and sibling chunks for the entrypoint
171
- /******/ __webpack_require__.u = function(chunkId) {
172
- /******/ // return url for filenames based on template
173
- /******/ return "" + ({"228":"wrtc","682":"pako"}[chunkId] || chunkId) + ".browser.js";
174
- /******/ };
175
- /******/ }();
176
- /******/
177
- /******/ /* webpack/runtime/global */
178
- /******/ !function() {
179
- /******/ __webpack_require__.g = (function() {
180
- /******/ if (typeof globalThis === 'object') return globalThis;
181
- /******/ try {
182
- /******/ return this || new Function('return this')();
183
- /******/ } catch (e) {
184
- /******/ if (typeof window === 'object') return window;
185
- /******/ }
186
- /******/ })();
187
- /******/ }();
188
- /******/
189
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
190
- /******/ !function() {
191
- /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
192
- /******/ }();
193
- /******/
194
- /******/ /* webpack/runtime/make namespace object */
195
- /******/ !function() {
196
- /******/ // define __esModule on exports
197
- /******/ __webpack_require__.r = function(exports) {
198
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
199
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
200
- /******/ }
201
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
202
- /******/ };
203
- /******/ }();
204
- /******/
205
- /******/ /* webpack/runtime/publicPath */
206
- /******/ !function() {
207
- /******/ var scriptUrl;
208
- /******/ if (typeof import.meta.url === "string") scriptUrl = import.meta.url
209
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
210
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
211
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
212
- /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
213
- /******/ __webpack_require__.p = scriptUrl;
214
- /******/ }();
215
- /******/
216
- /******/ /* webpack/runtime/importScripts chunk loading */
217
- /******/ !function() {
218
- /******/ // no baseURI
219
- /******/
220
- /******/ // object to store loaded chunks
221
- /******/ // "1" means "already loaded"
222
- /******/ var installedChunks = {
223
- /******/ 151: 1
224
- /******/ };
225
- /******/
226
- /******/ // importScripts chunk loading
227
- /******/ var installChunk = function(data) {
228
- /******/ var chunkIds = data[0];
229
- /******/ var moreModules = data[1];
230
- /******/ var runtime = data[2];
231
- /******/ for(var moduleId in moreModules) {
232
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
233
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
234
- /******/ }
235
- /******/ }
236
- /******/ if(runtime) runtime(__webpack_require__);
237
- /******/ while(chunkIds.length)
238
- /******/ installedChunks[chunkIds.pop()] = 1;
239
- /******/ parentChunkLoadingFunction(data);
240
- /******/ };
241
- /******/ __webpack_require__.f.i = function(chunkId, promises) {
242
- /******/ // "1" is the signal for "already loaded"
243
- /******/ if(!installedChunks[chunkId]) {
244
- /******/ if(true) { // all chunks have JS
245
- /******/ importScripts(__webpack_require__.p + __webpack_require__.u(chunkId));
246
- /******/ }
247
- /******/ }
248
- /******/ };
249
- /******/
250
- /******/ var chunkLoadingGlobal = self["webpackChunk_leofcoin_chain"] = self["webpackChunk_leofcoin_chain"] || [];
251
- /******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
252
- /******/ chunkLoadingGlobal.push = installChunk;
253
- /******/
254
- /******/ // no HMR
255
- /******/
256
- /******/ // no HMR manifest
257
- /******/ }();
258
- /******/
259
- /******/ /* webpack/runtime/startup chunk dependencies */
260
- /******/ !function() {
261
- /******/ var next = __webpack_require__.x;
262
- /******/ __webpack_require__.x = function() {
263
- /******/ return __webpack_require__.e(911).then(next);
264
- /******/ };
265
- /******/ }();
266
- /******/
267
- /************************************************************************/
268
- /******/
269
- /******/ // run startup
270
- /******/ var __webpack_exports__ = __webpack_require__.x();
271
- /******/
@@ -1,215 +0,0 @@
1
- /******/ var __webpack_modules__ = ({
2
-
3
- /***/ 560:
4
- /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
5
-
6
- /* harmony import */ var _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3427);
7
- class ContractMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_0__.FormatInterface{get keys(){return["creator","contract","constructorParameters"]}get messageName(){return"ContractMessage"}constructor(e){super(e,"\nmessage ContractMessage {\n required string creator = 1;\n required bytes contract = 2;\n repeated string constructorParameters = 3;\n}\n",{name:"contract-message"})}}class TransactionMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_0__.FormatInterface{get keys(){return["timestamp","from","to","nonce","method","params","signature"]}get messageName(){return"TransactionMessage"}constructor(e){super(e,"\n\nmessage TransactionMessage {\n required uint64 timestamp = 1;\n required string from = 2;\n required string to = 3;\n required uint64 nonce = 4;\n required string method = 5;\n repeated string params = 6;\n required string signature = 7;\n}\n",{name:"transaction-message"})}}class BlockMessage extends _leofcoin_codec_format_interface__WEBPACK_IMPORTED_MODULE_0__.FormatInterface{get keys(){return["index","previousHash","timestamp","reward","fees","transactions","validators"]}get messageName(){return"BlockMessage"}constructor(e){super(e,"\nmessage ValidatorMessage {\n required string address = 1;\n required string reward = 2;\n}\n\nmessage Transaction {\n required string hash = 1;\n required uint64 timestamp = 2;\n required string from = 3;\n required string to = 4;\n required uint64 nonce = 5;\n required string method = 6;\n repeated string params = 7;\n}\n\nmessage BlockMessage {\n required uint64 index = 1;\n required string previousHash = 3;\n required uint64 timestamp = 4;\n required uint64 reward = 5;\n required string fees = 6;\n repeated Transaction transactions = 7;\n repeated ValidatorMessage validators = 8;\n}\n",{name:"block-message"})}}const t={},a=(e=globalThis.peerid)=>({sender:e,call:(void 0).execute,staticCall:(void 0).get.bind(void 0)}),r=async e=>{const r=e.decoded.constructorParameters;try{const s=new Function(e.decoded.contract)();globalThis.msg=a(e.decoded.creator),t[await e.hash]=await new s(...r),debug(`loaded contract: ${await e.hash}`),debug(`size: ${formatBytes(e.encoded.length)}`)}catch(t){console.log(t),console.warn(`removing contract ${await e.hash}`),await contractStore.delete(await e.hash,e.encoded)}},s=async(e,a,r)=>{try{let s;return s=t[e].fallback?await t[e].fallback(a,r):await t[e][a](...r),s}catch(e){throw e}};onmessage=function(e){console.log(e.data),"init"===e.data.type&&(async({contracts:e,blocks:t,peerid:n})=>{globalThis.peerid=n;try{for(const t of e){const e=await new ContractMessage(t);await r(e)}}catch(e){console.log(e)}(t=(t=await Promise.all(t.map((e=>new BlockMessage(e))))).sort(((e,t)=>e.decoded.timestamp-t.decoded.timestamp))).forEach((async e=>{const t=e.encoded.length||e.encoded.byteLength;console.log(`loaded block: ${await e.hash} @${e.decoded.index} ${formatBytes(t)}`)}));const o=t.reduce(((e,t)=>[...e,...t.decoded.transactions]),[]);for(const e of o){const t=await new TransactionMessage(e),{from:r,to:n,method:o,params:i}=t.decoded;globalThis.msg=a(r),await s(n,o,i)}})(e.data.params),postMessage("world")},postMessage("world");
8
-
9
-
10
- /***/ }),
11
-
12
- /***/ 2361:
13
- /***/ (function() {
14
-
15
- /* (ignored) */
16
-
17
- /***/ }),
18
-
19
- /***/ 4616:
20
- /***/ (function() {
21
-
22
- /* (ignored) */
23
-
24
- /***/ })
25
-
26
- /******/ });
27
- /************************************************************************/
28
- /******/ // The module cache
29
- /******/ var __webpack_module_cache__ = {};
30
- /******/
31
- /******/ // The require function
32
- /******/ function __webpack_require__(moduleId) {
33
- /******/ // Check if module is in cache
34
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
35
- /******/ if (cachedModule !== undefined) {
36
- /******/ return cachedModule.exports;
37
- /******/ }
38
- /******/ // Create a new module (and put it into the cache)
39
- /******/ var module = __webpack_module_cache__[moduleId] = {
40
- /******/ // no module.id needed
41
- /******/ // no module.loaded needed
42
- /******/ exports: {}
43
- /******/ };
44
- /******/
45
- /******/ // Execute the module function
46
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
47
- /******/
48
- /******/ // Return the exports of the module
49
- /******/ return module.exports;
50
- /******/ }
51
- /******/
52
- /******/ // expose the modules object (__webpack_modules__)
53
- /******/ __webpack_require__.m = __webpack_modules__;
54
- /******/
55
- /******/ // the startup function
56
- /******/ __webpack_require__.x = function() {
57
- /******/ // Load entry module and return exports
58
- /******/ // This entry module depends on other loaded chunks and execution need to be delayed
59
- /******/ var __webpack_exports__ = __webpack_require__.O(undefined, [427], function() { return __webpack_require__(560); })
60
- /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
61
- /******/ return __webpack_exports__;
62
- /******/ };
63
- /******/
64
- /************************************************************************/
65
- /******/ /* webpack/runtime/chunk loaded */
66
- /******/ !function() {
67
- /******/ var deferred = [];
68
- /******/ __webpack_require__.O = function(result, chunkIds, fn, priority) {
69
- /******/ if(chunkIds) {
70
- /******/ priority = priority || 0;
71
- /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
72
- /******/ deferred[i] = [chunkIds, fn, priority];
73
- /******/ return;
74
- /******/ }
75
- /******/ var notFulfilled = Infinity;
76
- /******/ for (var i = 0; i < deferred.length; i++) {
77
- /******/ var chunkIds = deferred[i][0];
78
- /******/ var fn = deferred[i][1];
79
- /******/ var priority = deferred[i][2];
80
- /******/ var fulfilled = true;
81
- /******/ for (var j = 0; j < chunkIds.length; j++) {
82
- /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {
83
- /******/ chunkIds.splice(j--, 1);
84
- /******/ } else {
85
- /******/ fulfilled = false;
86
- /******/ if(priority < notFulfilled) notFulfilled = priority;
87
- /******/ }
88
- /******/ }
89
- /******/ if(fulfilled) {
90
- /******/ deferred.splice(i--, 1)
91
- /******/ var r = fn();
92
- /******/ if (r !== undefined) result = r;
93
- /******/ }
94
- /******/ }
95
- /******/ return result;
96
- /******/ };
97
- /******/ }();
98
- /******/
99
- /******/ /* webpack/runtime/ensure chunk */
100
- /******/ !function() {
101
- /******/ __webpack_require__.f = {};
102
- /******/ // This file contains only the entry chunk.
103
- /******/ // The chunk loading function for additional chunks
104
- /******/ __webpack_require__.e = function(chunkId) {
105
- /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
106
- /******/ __webpack_require__.f[key](chunkId, promises);
107
- /******/ return promises;
108
- /******/ }, []));
109
- /******/ };
110
- /******/ }();
111
- /******/
112
- /******/ /* webpack/runtime/get javascript chunk filename */
113
- /******/ !function() {
114
- /******/ // This function allow to reference async chunks and sibling chunks for the entrypoint
115
- /******/ __webpack_require__.u = function(chunkId) {
116
- /******/ // return url for filenames based on template
117
- /******/ return "" + chunkId + ".browser.js";
118
- /******/ };
119
- /******/ }();
120
- /******/
121
- /******/ /* webpack/runtime/global */
122
- /******/ !function() {
123
- /******/ __webpack_require__.g = (function() {
124
- /******/ if (typeof globalThis === 'object') return globalThis;
125
- /******/ try {
126
- /******/ return this || new Function('return this')();
127
- /******/ } catch (e) {
128
- /******/ if (typeof window === 'object') return window;
129
- /******/ }
130
- /******/ })();
131
- /******/ }();
132
- /******/
133
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
134
- /******/ !function() {
135
- /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
136
- /******/ }();
137
- /******/
138
- /******/ /* webpack/runtime/make namespace object */
139
- /******/ !function() {
140
- /******/ // define __esModule on exports
141
- /******/ __webpack_require__.r = function(exports) {
142
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
143
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
144
- /******/ }
145
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
146
- /******/ };
147
- /******/ }();
148
- /******/
149
- /******/ /* webpack/runtime/publicPath */
150
- /******/ !function() {
151
- /******/ var scriptUrl;
152
- /******/ if (typeof import.meta.url === "string") scriptUrl = import.meta.url
153
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
154
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
155
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
156
- /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
157
- /******/ __webpack_require__.p = scriptUrl;
158
- /******/ }();
159
- /******/
160
- /******/ /* webpack/runtime/importScripts chunk loading */
161
- /******/ !function() {
162
- /******/ // no baseURI
163
- /******/
164
- /******/ // object to store loaded chunks
165
- /******/ // "1" means "already loaded"
166
- /******/ var installedChunks = {
167
- /******/ 205: 1
168
- /******/ };
169
- /******/
170
- /******/ // importScripts chunk loading
171
- /******/ var installChunk = function(data) {
172
- /******/ var chunkIds = data[0];
173
- /******/ var moreModules = data[1];
174
- /******/ var runtime = data[2];
175
- /******/ for(var moduleId in moreModules) {
176
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
177
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
178
- /******/ }
179
- /******/ }
180
- /******/ if(runtime) runtime(__webpack_require__);
181
- /******/ while(chunkIds.length)
182
- /******/ installedChunks[chunkIds.pop()] = 1;
183
- /******/ parentChunkLoadingFunction(data);
184
- /******/ };
185
- /******/ __webpack_require__.f.i = function(chunkId, promises) {
186
- /******/ // "1" is the signal for "already loaded"
187
- /******/ if(!installedChunks[chunkId]) {
188
- /******/ if(true) { // all chunks have JS
189
- /******/ importScripts(__webpack_require__.p + __webpack_require__.u(chunkId));
190
- /******/ }
191
- /******/ }
192
- /******/ };
193
- /******/
194
- /******/ var chunkLoadingGlobal = self["webpackChunk_leofcoin_chain"] = self["webpackChunk_leofcoin_chain"] || [];
195
- /******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
196
- /******/ chunkLoadingGlobal.push = installChunk;
197
- /******/
198
- /******/ // no HMR
199
- /******/
200
- /******/ // no HMR manifest
201
- /******/ }();
202
- /******/
203
- /******/ /* webpack/runtime/startup chunk dependencies */
204
- /******/ !function() {
205
- /******/ var next = __webpack_require__.x;
206
- /******/ __webpack_require__.x = function() {
207
- /******/ return __webpack_require__.e(427).then(next);
208
- /******/ };
209
- /******/ }();
210
- /******/
211
- /************************************************************************/
212
- /******/
213
- /******/ // run startup
214
- /******/ var __webpack_exports__ = __webpack_require__.x();
215
- /******/
@@ -1,3 +0,0 @@
1
- var __webpack_exports__ = {};
2
- onmessage=function(o){console.log(o.data),postMessage("world")},postMessage("world");
3
-
@@ -1,70 +0,0 @@
1
- import { BlockMessage, ContractMessage, TransactionMessage } from '../../../messages/src/messages'
2
- import { formatBytes, BigNumber } from '../../../utils/src/utils'
3
- import bytecodes from '../../../lib/src/bytecodes.json'
4
- import { fork } from 'child_process'
5
- import { join } from 'path'
6
-
7
- const contractFactoryMessage = bytecodes.contractFactory
8
- const nativeTokenMessage = bytecodes.nativeToken
9
- const nameServiceMessage = bytecodes.nameService
10
- const validatorsMessage = bytecodes.validators
11
-
12
- globalThis.BigNumber = BigNumber
13
-
14
- globalThis.peernet = globalThis.peernet || {}
15
- globalThis.contracts = {}
16
-
17
- const run = async (blocks) => {
18
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)))
19
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp)
20
-
21
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
22
- // if (globalThis.process) {
23
- const worker = fork(join(__dirname, './transaction-worker.js'), {serialization: 'advanced'})
24
- // worker.once('message', async transactions => {
25
- const size = block.encoded.length || block.encoded.byteLength
26
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
27
- resolve(block)
28
- // })
29
- })))
30
- // worker.send(block.decoded.transactions)
31
- // } else {
32
- // const worker = new Worker('./workers/transaction-worker.js')
33
- // worker.onmessage = async message => {
34
- // const transactions = message.data
35
- // block.decoded.transactions = transactions
36
- // const size = block.encoded.length || block.encoded.byteLength
37
- // console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
38
- // resolve(block)
39
- // }
40
- // worker.postMessage(block.decoded.transactions)
41
- // }
42
- // })))
43
- return blocks
44
- }
45
-
46
- const tasks = async blocks => {
47
- globalThis.peernet.codecs = {
48
- 'contract-message': {
49
- codec: parseInt('63636d', 16),
50
- hashAlg: 'keccak-256'
51
- },
52
- 'transaction-message': {
53
- codec: parseInt('746d', 16),
54
- hashAlg: 'keccak-256'
55
- },
56
- 'block-message': {
57
- codec: parseInt('626d', 16),
58
- hashAlg: 'keccak-256'
59
- }
60
- }
61
-
62
- blocks = await run(blocks)
63
- globalThis.process ? process.send(blocks) : postMessage(blocks)
64
- }
65
-
66
- if (globalThis.process) {
67
- process.on('message', tasks)
68
- } else {
69
- onmessage = message => tasks(message.data)
70
- }