@leofcoin/chain 1.4.83 → 1.4.86

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 (29) hide show
  1. package/exports/browser/chain.js +75 -54
  2. package/exports/browser/client-c8558012-c8558012.js +10727 -0
  3. package/exports/browser/{index-6311966e-b5f647d8.js → index-ed6cbdf7-cced6308.js} +2 -2
  4. package/exports/browser/{index-c3f4012c.js → index-fd1bc5f0.js} +202 -212
  5. package/exports/browser/{messages-54aa3cad-5309745b.js → messages-35d069e1-0b6352ff.js} +2 -2
  6. package/exports/browser/{node-browser-3cbee72b.js → node-browser-e89e6592.js} +509 -600
  7. package/exports/browser/node-browser.js +2 -2
  8. package/exports/browser/workers/block-worker.js +201 -211
  9. package/exports/browser/workers/machine-worker.js +214 -215
  10. package/exports/chain.js +51 -36
  11. package/exports/{typings → types}/machine.d.ts +8 -7
  12. package/exports/{typings → types}/node-browser.d.ts +1 -1
  13. package/exports/{typings → types}/node.d.ts +3 -3
  14. package/exports/workers/block-worker.js +6035 -0
  15. package/exports/workers/machine-worker.js +6298 -0
  16. package/package.json +18 -10
  17. package/exports/browser/client-6072af1a-6072af1a.js +0 -41092
  18. /package/exports/{typings → types}/config/config.d.ts +0 -0
  19. /package/exports/{typings → types}/config/main.d.ts +0 -0
  20. /package/exports/{typings → types}/config/protocol.d.ts +0 -0
  21. /package/exports/{typings → types}/contract.d.ts +0 -0
  22. /package/exports/{typings → types}/fee/config.d.ts +0 -0
  23. /package/exports/{typings → types}/jobs/jobber.d.ts +0 -0
  24. /package/exports/{typings → types}/machine-state.d.ts +0 -0
  25. /package/exports/{typings → types}/protocol.d.ts +0 -0
  26. /package/exports/{typings → types}/sync-controller.d.ts +0 -0
  27. /package/exports/{typings → types}/transaction.d.ts +0 -0
  28. /package/exports/{typings → types}/typer.d.ts +0 -0
  29. /package/exports/{typings → types}/types.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { B as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, a as arrayify, b as isBytes, C as ContractMessage, T as TransactionMessage, R as RawTransactionMessage, g as getDefaultExportFromCjs, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-c3f4012c.js';
1
+ import { B as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, a as arrayify, b as isBytes, C as ContractMessage, T as TransactionMessage, t as toBase58, R as RawTransactionMessage, g as getDefaultExportFromCjs, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-fd1bc5f0.js';
2
2
 
3
3
  const logger$1 = new Logger(version$1);
4
4
  const _constructorGuard = {};
@@ -400,21 +400,27 @@ const formatBytes = (bytes, decimals = 2) => {
400
400
  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${byteFormats[i]}`
401
401
  };
402
402
 
403
- var contractFactory$2 = "IHNY2GQHKD3V4U2EF6P4TIHJNRQNDJ3N3AVXV6YGD6F2T3CNLMXWFU2LAC5";
404
- var nativeToken$2 = "IHNY2GQHXGQL4URICKLN5SE5ULIPF2QSFWU3DP4GZFOA5DBX4MMVDKJ2I3M";
405
- var nameService$2 = "IHNY2GQHZF3V4WIARWW7R2V4BDWWETJEN5QFITSTVIBWJFBZSD4ZBOSDNS4";
406
- var validators$2 = "IHNY2GQHJNPTBQQVFOPOCU6YG6SZMBEGXL5G2O6MTSK4PU7PGU7C7SG4PPY";
407
- var addresses = {
408
- contractFactory: contractFactory$2,
409
- nativeToken: nativeToken$2,
410
- nameService: nameService$2,
411
- validators: validators$2
403
+ var contractFactory$1 = "IHNY2GQHKD3V4U2EF6P4TIHJNRQNDJ3N3AVXV6YGD6F2T3CNLMXWFU2LAC5";
404
+ var nativeToken$1 = "IHNY2GQHXGQL4URICKLN5SE5ULIPF2QSFWU3DP4GZFOA5DBX4MMVDKJ2I3M";
405
+ var nameService$1 = "IHNY2GQHZF3V4WIARWW7R2V4BDWWETJEN5QFITSTVIBWJFBZSD4ZBOSDNS4";
406
+ var validators$1 = "IHNY2GQHJNPTBQQVFOPOCU6YG6SZMBEGXL5G2O6MTSK4PU7PGU7C7SG4PPY";
407
+ var addresses$1 = {
408
+ contractFactory: contractFactory$1,
409
+ nativeToken: nativeToken$1,
410
+ nameService: nameService$1,
411
+ validators: validators$1
412
412
  };
413
413
 
414
- const contractFactory$1 = addresses.contractFactory;
415
- const nameService$1 = addresses.nameService;
416
- const nativeToken$1 = addresses.nativeToken;
417
- const validators$1 = addresses.validators;
414
+ const contractFactory$2 = addresses$1.contractFactory;
415
+ const nameService$2 = addresses$1.nameService;
416
+ const nativeToken$2 = addresses$1.nativeToken;
417
+ const validators$2 = addresses$1.validators;
418
+ var addresses = {
419
+ contractFactory: contractFactory$2,
420
+ nameService: nameService$2,
421
+ nativeToken: nativeToken$2,
422
+ validators: validators$2
423
+ };
418
424
 
419
425
  var contractFactory = "237,198,141,3,53,89,84,113,122,107,70,97,116,87,49,76,109,71,88,104,102,72,105,99,106,51,120,84,105,114,81,120,89,113,75,101,122,102,70,116,101,114,51,49,80,113,49,82,78,82,97,54,85,87,89,89,87,115,173,5,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,82,101,103,105,115,116,101,114,101,100,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,34,104,97,115,82,111,108,101,34,44,91,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,93,41,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,2,91,93";
420
426
  var nativeToken = "237,198,141,3,53,89,84,113,122,107,70,97,116,87,49,76,109,71,88,104,102,72,105,99,106,51,120,84,105,114,81,120,89,113,75,101,122,102,70,116,101,114,51,49,80,113,49,82,78,82,97,54,85,87,89,89,87,115,163,26,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,34,79,87,78,69,82,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,82,111,108,101,115,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,77,73,78,84,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,102,114,111,109,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,66,85,82,78,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,34,48,120,48,48,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,34,48,120,48,48,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,34,48,120,48,48,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,84,111,107,101,110,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,34,65,114,116,79,110,108,105,110,101,34,44,34,65,82,84,34,44,49,56,44,115,116,97,116,101,41,125,125,114,101,116,117,114,110,32,65,114,116,79,110,108,105,110,101,59,2,91,93";
@@ -440,7 +446,7 @@ const createContractMessage = async (creator, contract, constructorParameters =
440
446
  };
441
447
  const calculateFee = async (transaction, format = false) => {
442
448
  // excluded from fees
443
- if (transaction.to === validators$1)
449
+ if (transaction.to === validators$2)
444
450
  return 0;
445
451
  transaction = await new TransactionMessage(transaction);
446
452
  let fee = parseUnits(String(transaction.encoded.length));
@@ -460,7 +466,7 @@ const createTransactionHash = async (transaction) => {
460
466
  return (await transaction.peernetHash).digest;
461
467
  };
462
468
  const signTransaction = async (transaction, wallet) => {
463
- const signature = await wallet.sign(await createTransactionHash(transaction));
469
+ const signature = toBase58(await wallet.sign(await createTransactionHash(transaction)));
464
470
  const signedTransaction = { ...transaction, signature };
465
471
  return signedTransaction;
466
472
  };
@@ -1352,7 +1358,7 @@ class Transaction extends Protocol {
1352
1358
  * @returns {TransactionMessage}
1353
1359
  */
1354
1360
  async promiseTransactions(transactions) {
1355
- transactions = await Promise.all(transactions.map(tx => new TransactionMessage(tx)));
1361
+ transactions = await Promise.all(transactions.map(tx => new TransactionMessage(tx.encoded || tx)));
1356
1362
  return transactions;
1357
1363
  }
1358
1364
  /**
@@ -1452,7 +1458,7 @@ class Transaction extends Protocol {
1452
1458
  }
1453
1459
  async sendTransaction(message) {
1454
1460
  if (!this.isTransactionMessage(message))
1455
- message = new TransactionMessage(message);
1461
+ message = await new TransactionMessage(message);
1456
1462
  if (!message.decoded.signature)
1457
1463
  throw new Error(`transaction not signed`);
1458
1464
  if (message.decoded.nonce === undefined)
@@ -1628,13 +1634,16 @@ class EasyWorker {
1628
1634
 
1629
1635
  // import State from './state'
1630
1636
  class Machine {
1637
+ worker;
1631
1638
  #contracts = {};
1632
1639
  #nonces = {};
1633
1640
  lastBlock = { index: 0, hash: '0x0', previousHash: '0x0' };
1634
1641
  constructor(blocks) {
1642
+ // @ts-ignore
1635
1643
  return this.#init(blocks);
1636
1644
  }
1637
- #createMessage(sender = peernet.selectedAccount) {
1645
+ // @ts-ignore
1646
+ #createMessage(sender = globalThis.peernet.selectedAccount) {
1638
1647
  return {
1639
1648
  sender,
1640
1649
  call: this.execute,
@@ -1645,6 +1654,7 @@ class Machine {
1645
1654
  switch (data.type) {
1646
1655
  case 'contractError': {
1647
1656
  console.warn(`removing contract ${await data.hash()}`);
1657
+ // @ts-ignore
1648
1658
  await contractStore.delete(await data.hash());
1649
1659
  break;
1650
1660
  }
@@ -1659,7 +1669,7 @@ class Machine {
1659
1669
  }
1660
1670
  case 'debug': {
1661
1671
  for (const message of data.messages)
1662
- debug(message);
1672
+ globalThis.debug(message);
1663
1673
  break;
1664
1674
  }
1665
1675
  case 'machine-ready': {
@@ -1680,20 +1690,32 @@ class Machine {
1680
1690
  resolve(this);
1681
1691
  };
1682
1692
  pubsub.subscribe('machine.ready', machineReady);
1683
- this.worker = await new EasyWorker('./exports/browser/workers/machine-worker.js', { serialization: 'advanced', type: 'module' });
1693
+ let pre;
1694
+ try {
1695
+ const importee = await import('url');
1696
+ const url = importee.default;
1697
+ if (url)
1698
+ pre = url.fileURLToPath(new URL('.', import.meta.url));
1699
+ }
1700
+ catch {
1701
+ // browser env
1702
+ pre = './';
1703
+ }
1704
+ this.worker = await new EasyWorker(pre + 'workers/machine-worker.js', { serialization: 'advanced', type: 'module' });
1684
1705
  this.worker.onmessage(this.#onmessage.bind(this));
1685
1706
  // const blocks = await blockStore.values()
1686
1707
  const contracts = await Promise.all([
1687
- contractStore.get(contractFactory$1),
1688
- contractStore.get(nativeToken$1),
1689
- contractStore.get(validators$1),
1690
- contractStore.get(nameService$1)
1708
+ globalThis.contractStore.get(contractFactory$2),
1709
+ globalThis.contractStore.get(nativeToken$2),
1710
+ globalThis.contractStore.get(validators$2),
1711
+ globalThis.contractStore.get(nameService$2)
1691
1712
  ]);
1692
1713
  const message = {
1693
1714
  type: 'init',
1694
1715
  input: {
1695
1716
  contracts,
1696
1717
  blocks,
1718
+ // @ts-ignore
1697
1719
  peerid: peernet.peerId
1698
1720
  }
1699
1721
  };
@@ -1703,6 +1725,7 @@ class Machine {
1703
1725
  async #runContract(contractMessage) {
1704
1726
  const hash = await contractMessage.hash();
1705
1727
  return new Promise((resolve, reject) => {
1728
+ // @ts-ignore
1706
1729
  const id = randombytes(20).toString('hex');
1707
1730
  const onmessage = message => {
1708
1731
  pubsub.unsubscribe(id, onmessage);
@@ -1732,17 +1755,17 @@ class Machine {
1732
1755
  */
1733
1756
  async execute(contract, method, parameters) {
1734
1757
  try {
1735
- if (contract === contractFactory$1 && method === 'registerContract') {
1758
+ if (contract === contractFactory$2 && method === 'registerContract') {
1736
1759
  if (await this.has(parameters[0]))
1737
1760
  throw new Error(`duplicate contract @${parameters[0]}`);
1738
1761
  let message;
1739
- if (!await contractStore.has(parameters[0])) {
1762
+ if (!await globalThis.contractStore.has(parameters[0])) {
1740
1763
  message = await peernet.get(parameters[0], 'contract');
1741
1764
  message = await new ContractMessage(message);
1742
- await contractStore.put(await message.hash(), message.encoded);
1765
+ await globalThis.contractStore.put(await message.hash(), message.encoded);
1743
1766
  }
1744
1767
  if (!message) {
1745
- message = await contractStore.get(parameters[0]);
1768
+ message = await globalThis.contractStore.get(parameters[0]);
1746
1769
  message = await new ContractMessage(message);
1747
1770
  }
1748
1771
  if (!await this.has(await message.hash()))
@@ -1753,6 +1776,7 @@ class Machine {
1753
1776
  throw new Error(`contract deployment failed for ${parameters[0]}\n${error.message}`);
1754
1777
  }
1755
1778
  return new Promise((resolve, reject) => {
1779
+ // @ts-ignore
1756
1780
  const id = randombytes(20).toString('hex');
1757
1781
  const onmessage = message => {
1758
1782
  pubsub.unsubscribe(id, onmessage);
@@ -1794,6 +1818,7 @@ class Machine {
1794
1818
  }
1795
1819
  async has(address) {
1796
1820
  return new Promise((resolve, reject) => {
1821
+ // @ts-ignore
1797
1822
  const id = randombytes(20).toString('hex');
1798
1823
  const onmessage = message => {
1799
1824
  pubsub.unsubscribe(id, onmessage);
@@ -1813,14 +1838,14 @@ class Machine {
1813
1838
  });
1814
1839
  }
1815
1840
  async delete(hash) {
1816
- return contractStore.delete(hash);
1841
+ return globalThis.contractStore.delete(hash);
1817
1842
  }
1818
1843
  /**
1819
1844
  *
1820
1845
  * @returns Promise
1821
1846
  */
1822
1847
  async deleteAll() {
1823
- let hashes = await contractStore.get();
1848
+ let hashes = await globalThis.contractStore.get();
1824
1849
  hashes = Object.keys(hashes).map(hash => this.delete(hash));
1825
1850
  return Promise.all(hashes);
1826
1851
  }
@@ -1995,7 +2020,7 @@ class State extends Contract {
1995
2020
  if (block !== undefined) {
1996
2021
  block = await new BlockMessage(block);
1997
2022
  const { index } = block.decoded;
1998
- if (this.#blocks[index] && this.#blocks[index].hash !== block.hash)
2023
+ if (this.#blocks[index - 1] && this.#blocks[index - 1].hash !== block.hash)
1999
2024
  throw `invalid block ${hash} @${index}`;
2000
2025
  if (!await globalThis.peernet.has(hash, 'block'))
2001
2026
  await globalThis.peernet.put(hash, block.encoded, 'block');
@@ -2004,9 +2029,9 @@ class State extends Contract {
2004
2029
  }
2005
2030
  async #resolveBlock(hash) {
2006
2031
  let index = this.#blockHashMap.get(hash);
2007
- if (this.#blocks[index]) {
2008
- if (this.#blocks[index].previousHash !== '0x0') {
2009
- return this.resolveBlock(this.#blocks[index].previousHash);
2032
+ if (this.#blocks[index - 1]) {
2033
+ if (this.#blocks[index - 1].previousHash !== '0x0') {
2034
+ return this.resolveBlock(this.#blocks[index - 1].previousHash);
2010
2035
  }
2011
2036
  else {
2012
2037
  return;
@@ -2017,11 +2042,11 @@ class State extends Contract {
2017
2042
  index = block.decoded.index;
2018
2043
  const size = block.encoded.length > 0 ? block.encoded.length : block.encoded.byteLength;
2019
2044
  this.#totalSize += size;
2020
- this.#blocks[index] = { hash, ...block.decoded };
2045
+ this.#blocks[index - 1] = { hash, ...block.decoded };
2021
2046
  this.#blockHashMap.set(hash, index);
2022
2047
  globalThis.debug(`resolved block: ${hash} @${index} ${formatBytes(size)}`);
2023
2048
  globalThis.pubsub.publish('block-resolved', { hash, index });
2024
- this.#lastResolved = this.#blocks[index];
2049
+ this.#lastResolved = this.#blocks[index - 1];
2025
2050
  this.#lastResolvedTime = Date.now();
2026
2051
  }
2027
2052
  catch (error) {
@@ -2131,12 +2156,12 @@ class State extends Contract {
2131
2156
  if (!this.#lastBlock || Number(this.#lastBlock.index) < Number(lastBlock.index)) {
2132
2157
  // TODO: check if valid
2133
2158
  const localIndex = this.#lastBlock ? this.lastBlock.index : 0;
2134
- const index = lastBlock.index;
2159
+ const index = lastBlock.index - 1;
2135
2160
  await this.resolveBlock(lastBlock.hash);
2136
2161
  console.log('ok');
2137
2162
  let blocksSynced = localIndex > 0 ? (localIndex > index ? localIndex - index : index - localIndex) : index;
2138
2163
  globalThis.debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
2139
- const start = (this.#blocks.length - blocksSynced) - 1;
2164
+ const start = (this.#blocks.length - blocksSynced);
2140
2165
  if (this.#machine)
2141
2166
  await this.#loadBlocks(this.blocks.slice(start));
2142
2167
  await this.updateState(new BlockMessage(this.#blocks[this.#blocks.length - 1]));
@@ -2203,7 +2228,7 @@ class State extends Contract {
2203
2228
  await globalThis.transactionPoolStore.delete(transaction.hash);
2204
2229
  try {
2205
2230
  await this.#machine.execute(transaction.to, transaction.method, transaction.params);
2206
- if (transaction.to === nativeToken$1) {
2231
+ if (transaction.to === nativeToken$2) {
2207
2232
  this.#nativeCalls += 1;
2208
2233
  if (transaction.method === 'burn')
2209
2234
  this.#nativeBurns += 1;
@@ -2221,7 +2246,7 @@ class State extends Contract {
2221
2246
  return false;
2222
2247
  }
2223
2248
  }
2224
- this.#blocks[block.index].loaded = true;
2249
+ this.#blocks[block.index - 1].loaded = true;
2225
2250
  globalThis.debug(`loaded block: ${block.hash} @${block.index}`);
2226
2251
  globalThis.pubsub.publish('block-loaded', { ...block });
2227
2252
  }
@@ -2276,7 +2301,7 @@ class Chain extends State {
2276
2301
  #state;
2277
2302
  #slotTime = 10000;
2278
2303
  id;
2279
- utils;
2304
+ utils = {};
2280
2305
  /** {Address[]} */
2281
2306
  #validators = [];
2282
2307
  /** {Boolean} */
@@ -2286,6 +2311,7 @@ class Chain extends State {
2286
2311
  #jail = [];
2287
2312
  constructor() {
2288
2313
  super();
2314
+ // @ts-ignore
2289
2315
  return this.#init();
2290
2316
  }
2291
2317
  get nativeToken() {
@@ -2313,7 +2339,6 @@ class Chain extends State {
2313
2339
  }
2314
2340
  catch (error) {
2315
2341
  console.error(error);
2316
- console.log('ttttt');
2317
2342
  }
2318
2343
  const end = Date.now();
2319
2344
  console.log(((end - start) / 1000) + ' s');
@@ -2337,7 +2362,6 @@ class Chain extends State {
2337
2362
  message: nameServiceMessage
2338
2363
  }];
2339
2364
  await Promise.all(contracts.map(async ({ address, message }) => {
2340
- // console.log({message});
2341
2365
  message = await new ContractMessage(Uint8Array.from(message.split(',').map(string => Number(string))));
2342
2366
  await globalThis.contractStore.put(address, message.encoded);
2343
2367
  }));
@@ -2407,7 +2431,7 @@ class Chain extends State {
2407
2431
  this.#jail.push(validatorInfo.address);
2408
2432
  }
2409
2433
  #addTransaction(message) {
2410
- console.log(message);
2434
+ console.log({ message });
2411
2435
  }
2412
2436
  async #prepareRequest(request) {
2413
2437
  let node = await new globalThis.peernet.protos['peernet-request']({ request });
@@ -2425,13 +2449,11 @@ class Chain extends State {
2425
2449
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
2426
2450
  let transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
2427
2451
  const transactions = await globalThis.transactionPoolStore.keys();
2428
- console.log({ transactionsInPool });
2429
2452
  const transactionsToGet = [];
2430
2453
  for (const key of transactionsInPool) {
2431
2454
  if (!transactions.includes(key) && !ignorelist.includes(key))
2432
2455
  transactionsToGet.push(transactionPoolStore.put(key, (await peernet.get(key, 'transaction'))));
2433
2456
  }
2434
- console.log(await transactionPoolStore.keys());
2435
2457
  await Promise.all(transactionsToGet);
2436
2458
  if (Object.keys(lastBlock).length > 0) {
2437
2459
  if (!this.lastBlock || !this.blocks[this.blocks.length - 1]?.loaded || lastBlock && lastBlock.index > this.lastBlock?.index || !this.loaded && !this.resolving) {
@@ -2506,7 +2528,6 @@ class Chain extends State {
2506
2528
  console.log(error.hash);
2507
2529
  console.log('errrrr');
2508
2530
  await transactionPoolStore.delete(error.hash);
2509
- console.log({ e: error });
2510
2531
  }
2511
2532
  }
2512
2533
  async participate(address) {
@@ -2557,7 +2578,6 @@ class Chain extends State {
2557
2578
  // exclude failing tx
2558
2579
  transactions = await this.promiseTransactions(transactions);
2559
2580
  transactions = transactions.sort((a, b) => a.nonce - b.nonce);
2560
- console.log({ transactions });
2561
2581
  for (let transaction of transactions) {
2562
2582
  const hash = await transaction.hash();
2563
2583
  const doubleTransactions = [];
@@ -2576,7 +2596,6 @@ class Chain extends State {
2576
2596
  // if (timestamp + this.#slotTime > Date.now()) {
2577
2597
  try {
2578
2598
  const result = await this.#executeTransaction({ ...transaction.decoded, hash });
2579
- console.log({ result });
2580
2599
  block.transactions.push(transaction);
2581
2600
  block.fees = block.fees.add(await calculateFee(transaction.decoded));
2582
2601
  await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
@@ -2648,6 +2667,7 @@ class Chain extends State {
2648
2667
  // block.reward = block.reward.toString()
2649
2668
  // block.fees = block.fees.toString()
2650
2669
  try {
2670
+ console.log(block.transactions);
2651
2671
  block.transactions = await Promise.all(block.transactions
2652
2672
  .map(async (transaction) => {
2653
2673
  await globalThis.transactionPoolStore.delete(await transaction.hash());
@@ -2670,7 +2690,7 @@ class Chain extends State {
2670
2690
  // transactionStore.put(message.hash, message.encoded)
2671
2691
  }
2672
2692
  async #sendTransaction(transaction) {
2673
- transaction = await new TransactionMessage(transaction.encoded);
2693
+ transaction = await new TransactionMessage(transaction.encoded || transaction);
2674
2694
  const hash = await transaction.hash();
2675
2695
  try {
2676
2696
  const has = await globalThis.transactionPoolStore.has(hash);
@@ -2693,9 +2713,10 @@ class Chain extends State {
2693
2713
  * error is thrown on error so undefined data doesn't mean there is an error...
2694
2714
  **/
2695
2715
  async sendTransaction(transaction) {
2696
- const event = await super.sendTransaction(transaction);
2697
- this.#sendTransaction(await new TransactionMessage(event.message.encoded));
2698
- globalThis.peernet.publish('send-transaction', event.message.encoded);
2716
+ const transactionMessage = await new TransactionMessage({ ...transaction });
2717
+ const event = await super.sendTransaction(transactionMessage);
2718
+ this.#sendTransaction(transactionMessage.encoded);
2719
+ globalThis.peernet.publish('send-transaction', transactionMessage.encoded);
2699
2720
  return event;
2700
2721
  }
2701
2722
  async addContract(transaction, contractMessage) {