@leofcoin/chain 1.0.5 → 1.0.8

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 (88) hide show
  1. package/.jsdoc.json +29 -0
  2. package/chain.js +25 -14
  3. package/dist/chain.browser.js +25 -1826
  4. package/dist/chain.browser.min.js +1 -1
  5. package/dist/chain.js +25 -14
  6. package/dist/node.browser.js +1058 -1083
  7. package/dist/node.browser.min.js +1 -1
  8. package/docs/@leofcoin/chain/1.0.7/chain.js.html +738 -0
  9. package/docs/@leofcoin/chain/1.0.7/contracts_factory.js.html +182 -0
  10. package/docs/@leofcoin/chain/1.0.7/contracts_nameService.js.html +231 -0
  11. package/docs/@leofcoin/chain/1.0.7/contracts_proxies_factoryProxy.js.html +135 -0
  12. package/docs/@leofcoin/chain/1.0.7/contracts_proxies_nameServiceProxy.js.html +135 -0
  13. package/docs/@leofcoin/chain/1.0.7/contracts_proxies_nativeTokenProxy.js.html +135 -0
  14. package/docs/@leofcoin/chain/1.0.7/contracts_proxies_validatorsProxy.js.html +135 -0
  15. package/docs/@leofcoin/chain/1.0.7/contracts_proxies_votingProxy.js.html +135 -0
  16. package/docs/@leofcoin/chain/1.0.7/contracts_validators.js.html +242 -0
  17. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Bold-webfont.eot +0 -0
  18. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Bold-webfont.svg +1830 -0
  19. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Bold-webfont.woff +0 -0
  20. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  21. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  22. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  23. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Italic-webfont.eot +0 -0
  24. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Italic-webfont.svg +1830 -0
  25. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Italic-webfont.woff +0 -0
  26. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Light-webfont.eot +0 -0
  27. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Light-webfont.svg +1831 -0
  28. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Light-webfont.woff +0 -0
  29. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  30. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  31. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  32. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Regular-webfont.eot +0 -0
  33. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Regular-webfont.svg +1831 -0
  34. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Regular-webfont.woff +0 -0
  35. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Semibold-webfont.eot +0 -0
  36. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Semibold-webfont.svg +1830 -0
  37. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Semibold-webfont.ttf +0 -0
  38. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-Semibold-webfont.woff +0 -0
  39. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
  40. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-SemiboldItalic-webfont.svg +1830 -0
  41. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  42. package/docs/@leofcoin/chain/1.0.7/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  43. package/docs/@leofcoin/chain/1.0.7/global.html +1153 -0
  44. package/docs/@leofcoin/chain/1.0.7/icons/home.svg +4 -0
  45. package/docs/@leofcoin/chain/1.0.7/icons/search.svg +4 -0
  46. package/docs/@leofcoin/chain/1.0.7/index.html +125 -0
  47. package/docs/@leofcoin/chain/1.0.7/machine.js.html +252 -0
  48. package/docs/@leofcoin/chain/1.0.7/scripts/linenumber.js +23 -0
  49. package/docs/@leofcoin/chain/1.0.7/scripts/pagelocation.js +89 -0
  50. package/docs/@leofcoin/chain/1.0.7/standards_roles.js.html +188 -0
  51. package/docs/@leofcoin/chain/1.0.7/standards_token.js.html +260 -0
  52. package/docs/@leofcoin/chain/1.0.7/styles/collapse.css +27 -0
  53. package/docs/@leofcoin/chain/1.0.7/styles/jsdoc-default.css +953 -0
  54. package/docs/@leofcoin/chain/1.0.7/styles/prettify-jsdoc.css +111 -0
  55. package/docs/@leofcoin/chain/1.0.7/styles/prettify-tomorrow.css +138 -0
  56. package/out/@leofcoin/chain/1.0.7/chain.js.html +645 -0
  57. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Bold-webfont.eot +0 -0
  58. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Bold-webfont.svg +1830 -0
  59. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Bold-webfont.woff +0 -0
  60. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  61. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  62. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  63. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Italic-webfont.eot +0 -0
  64. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Italic-webfont.svg +1830 -0
  65. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Italic-webfont.woff +0 -0
  66. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Light-webfont.eot +0 -0
  67. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Light-webfont.svg +1831 -0
  68. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Light-webfont.woff +0 -0
  69. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  70. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  71. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  72. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Regular-webfont.eot +0 -0
  73. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Regular-webfont.svg +1831 -0
  74. package/out/@leofcoin/chain/1.0.7/fonts/OpenSans-Regular-webfont.woff +0 -0
  75. package/out/@leofcoin/chain/1.0.7/global.html +477 -0
  76. package/out/@leofcoin/chain/1.0.7/index.html +69 -0
  77. package/out/@leofcoin/chain/1.0.7/machine.js.html +180 -0
  78. package/out/@leofcoin/chain/1.0.7/scripts/linenumber.js +25 -0
  79. package/out/@leofcoin/chain/1.0.7/scripts/prettify/Apache-License-2.0.txt +202 -0
  80. package/out/@leofcoin/chain/1.0.7/scripts/prettify/lang-css.js +2 -0
  81. package/out/@leofcoin/chain/1.0.7/scripts/prettify/prettify.js +28 -0
  82. package/out/@leofcoin/chain/1.0.7/styles/jsdoc-default.css +358 -0
  83. package/out/@leofcoin/chain/1.0.7/styles/prettify-jsdoc.css +111 -0
  84. package/out/@leofcoin/chain/1.0.7/styles/prettify-tomorrow.css +132 -0
  85. package/package.json +6 -3
  86. package/src/chain.js +24 -3
  87. package/src/machine.js +2 -3
  88. package/src/utils/utils.js +0 -9
@@ -0,0 +1,111 @@
1
+ /* JSDoc prettify.js theme */
2
+
3
+ /* plain text */
4
+ .pln {
5
+ color: #000000;
6
+ font-weight: normal;
7
+ font-style: normal;
8
+ }
9
+
10
+ /* string content */
11
+ .str {
12
+ color: #006400;
13
+ font-weight: normal;
14
+ font-style: normal;
15
+ }
16
+
17
+ /* a keyword */
18
+ .kwd {
19
+ color: #000000;
20
+ font-weight: bold;
21
+ font-style: normal;
22
+ }
23
+
24
+ /* a comment */
25
+ .com {
26
+ font-weight: normal;
27
+ font-style: italic;
28
+ }
29
+
30
+ /* a type name */
31
+ .typ {
32
+ color: #000000;
33
+ font-weight: normal;
34
+ font-style: normal;
35
+ }
36
+
37
+ /* a literal value */
38
+ .lit {
39
+ color: #006400;
40
+ font-weight: normal;
41
+ font-style: normal;
42
+ }
43
+
44
+ /* punctuation */
45
+ .pun {
46
+ color: #000000;
47
+ font-weight: bold;
48
+ font-style: normal;
49
+ }
50
+
51
+ /* lisp open bracket */
52
+ .opn {
53
+ color: #000000;
54
+ font-weight: bold;
55
+ font-style: normal;
56
+ }
57
+
58
+ /* lisp close bracket */
59
+ .clo {
60
+ color: #000000;
61
+ font-weight: bold;
62
+ font-style: normal;
63
+ }
64
+
65
+ /* a markup tag name */
66
+ .tag {
67
+ color: #006400;
68
+ font-weight: normal;
69
+ font-style: normal;
70
+ }
71
+
72
+ /* a markup attribute name */
73
+ .atn {
74
+ color: #006400;
75
+ font-weight: normal;
76
+ font-style: normal;
77
+ }
78
+
79
+ /* a markup attribute value */
80
+ .atv {
81
+ color: #006400;
82
+ font-weight: normal;
83
+ font-style: normal;
84
+ }
85
+
86
+ /* a declaration */
87
+ .dec {
88
+ color: #000000;
89
+ font-weight: bold;
90
+ font-style: normal;
91
+ }
92
+
93
+ /* a variable name */
94
+ .var {
95
+ color: #000000;
96
+ font-weight: normal;
97
+ font-style: normal;
98
+ }
99
+
100
+ /* a function name */
101
+ .fun {
102
+ color: #000000;
103
+ font-weight: bold;
104
+ font-style: normal;
105
+ }
106
+
107
+ /* Specify class=linenums on a pre to get line numbering */
108
+ ol.linenums {
109
+ margin-top: 0;
110
+ margin-bottom: 0;
111
+ }
@@ -0,0 +1,132 @@
1
+ /* Tomorrow Theme */
2
+ /* Original theme - https://github.com/chriskempson/tomorrow-theme */
3
+ /* Pretty printing styles. Used with prettify.js. */
4
+ /* SPAN elements with the classes below are added by prettyprint. */
5
+ /* plain text */
6
+ .pln {
7
+ color: #4d4d4c; }
8
+
9
+ @media screen {
10
+ /* string content */
11
+ .str {
12
+ color: #718c00; }
13
+
14
+ /* a keyword */
15
+ .kwd {
16
+ color: #8959a8; }
17
+
18
+ /* a comment */
19
+ .com {
20
+ color: #8e908c; }
21
+
22
+ /* a type name */
23
+ .typ {
24
+ color: #4271ae; }
25
+
26
+ /* a literal value */
27
+ .lit {
28
+ color: #f5871f; }
29
+
30
+ /* punctuation */
31
+ .pun {
32
+ color: #4d4d4c; }
33
+
34
+ /* lisp open bracket */
35
+ .opn {
36
+ color: #4d4d4c; }
37
+
38
+ /* lisp close bracket */
39
+ .clo {
40
+ color: #4d4d4c; }
41
+
42
+ /* a markup tag name */
43
+ .tag {
44
+ color: #c82829; }
45
+
46
+ /* a markup attribute name */
47
+ .atn {
48
+ color: #f5871f; }
49
+
50
+ /* a markup attribute value */
51
+ .atv {
52
+ color: #3e999f; }
53
+
54
+ /* a declaration */
55
+ .dec {
56
+ color: #f5871f; }
57
+
58
+ /* a variable name */
59
+ .var {
60
+ color: #c82829; }
61
+
62
+ /* a function name */
63
+ .fun {
64
+ color: #4271ae; } }
65
+ /* Use higher contrast and text-weight for printable form. */
66
+ @media print, projection {
67
+ .str {
68
+ color: #060; }
69
+
70
+ .kwd {
71
+ color: #006;
72
+ font-weight: bold; }
73
+
74
+ .com {
75
+ color: #600;
76
+ font-style: italic; }
77
+
78
+ .typ {
79
+ color: #404;
80
+ font-weight: bold; }
81
+
82
+ .lit {
83
+ color: #044; }
84
+
85
+ .pun, .opn, .clo {
86
+ color: #440; }
87
+
88
+ .tag {
89
+ color: #006;
90
+ font-weight: bold; }
91
+
92
+ .atn {
93
+ color: #404; }
94
+
95
+ .atv {
96
+ color: #060; } }
97
+ /* Style */
98
+ /*
99
+ pre.prettyprint {
100
+ background: white;
101
+ font-family: Consolas, Monaco, 'Andale Mono', monospace;
102
+ font-size: 12px;
103
+ line-height: 1.5;
104
+ border: 1px solid #ccc;
105
+ padding: 10px; }
106
+ */
107
+
108
+ /* Specify class=linenums on a pre to get line numbering */
109
+ ol.linenums {
110
+ margin-top: 0;
111
+ margin-bottom: 0; }
112
+
113
+ /* IE indents via margin-left */
114
+ li.L0,
115
+ li.L1,
116
+ li.L2,
117
+ li.L3,
118
+ li.L4,
119
+ li.L5,
120
+ li.L6,
121
+ li.L7,
122
+ li.L8,
123
+ li.L9 {
124
+ /* */ }
125
+
126
+ /* Alternate shading for lines */
127
+ li.L1,
128
+ li.L3,
129
+ li.L5,
130
+ li.L7,
131
+ li.L9 {
132
+ /* */ }
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\"><img alt=\"Creative Commons Licence\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc/4.0/88x31.png\" /></a><br />This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\">Creative Commons Attribution-NonCommercial 4.0 International License</a>.",
5
5
  "source": "./src/node.js",
6
6
  "main": "./dist/node.js",
7
7
  "scripts": {
8
8
  "c": "rollup -c",
9
9
  "w": "rollup -c -w",
10
- "build": "npm run c && webpack",
10
+ "build": "npm run c && webpack && npm run docs",
11
11
  "demo": "jsproject --serve ./ --port 5478 --open demo",
12
+ "docs": "sh node_modules/.bin/jsdoc --configure .jsdoc.json --verbose",
12
13
  "test": "echo \"Error: no test specified\" && exit 1"
13
14
  },
14
15
  "browserslist": "> 0.5%, last 2 versions, not dead",
@@ -21,6 +22,8 @@
21
22
  "@rollup/plugin-node-resolve": "^13.1.3",
22
23
  "@rollup/plugin-strip": "^2.1.0",
23
24
  "@vandeurenglenn/debug": "^1.0.0",
25
+ "jsdoc": "^3.6.10",
26
+ "jsdoc-template": "github:braintree/jsdoc-template",
24
27
  "rollup": "^2.70.1",
25
28
  "rollup-plugin-cleanup": "^3.2.1",
26
29
  "rollup-plugin-modify": "^3.0.0",
@@ -33,7 +36,7 @@
33
36
  "@ethersproject/bignumber": "^5.6.0",
34
37
  "@ethersproject/units": "^5.6.0",
35
38
  "@leofcoin/multi-wallet": "^2.1.1",
36
- "@leofcoin/peernet": "^0.11.25",
39
+ "@leofcoin/peernet": "^0.11.28",
37
40
  "@leofcoin/storage": "^2.3.0",
38
41
  "chalk": "^4.0.0",
39
42
  "datastore-level": "^8.0.0",
package/src/chain.js CHANGED
@@ -1,4 +1,4 @@
1
- import { BigNumber, formatUnits, parseUnits, info } from './utils/utils'
1
+ import { BigNumber, formatUnits, parseUnits } from './utils/utils'
2
2
  import Machine from './machine'
3
3
  import lib from './lib'
4
4
 
@@ -154,7 +154,7 @@ export default class Chain {
154
154
  console.log(this.#blocks);
155
155
  let blocksSynced = localIndex > 0 ? localIndex - index : index
156
156
  blocksSynced += 1
157
- info(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`)
157
+ debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`)
158
158
 
159
159
  const end = this.#blocks.length
160
160
  const start = (this.#blocks.length) - blocksSynced
@@ -268,7 +268,7 @@ export default class Chain {
268
268
  this.#lastBlock = {hash: blockMessage.hash, ...blockMessage.decoded}
269
269
  await blockStore.put(blockMessage.hash, blockMessage.encoded)
270
270
  await chainStore.put('lastBlock', new TextEncoder().encode(blockMessage.hash))
271
- info(`added block: ${blockMessage.hash}`)
271
+ debug(`added block: ${blockMessage.hash}`)
272
272
  let promises = []
273
273
  let contracts = []
274
274
  for (let transaction of blockMessage.decoded.transactions) {
@@ -467,6 +467,11 @@ export default class Chain {
467
467
  *
468
468
  * example: [hash]
469
469
  * createTransaction('0x0', 'createContract', [hash])
470
+ *
471
+ * @param {String} to - the contract address for the contract to interact with
472
+ * @param {String} method - the method/function to run
473
+ * @param {Array} params - array of paramters to apply to the contract method
474
+ * @param {Number} nonce - total transaction count [optional]
470
475
  */
471
476
  createTransaction(to, method, params, nonce) {
472
477
  return this.createTransactionFrom(peernet.id, to, method, params, nonce)
@@ -475,6 +480,12 @@ export default class Chain {
475
480
  * every tx done is trough contracts so no need for amount
476
481
  * data is undefined when nothing is returned
477
482
  * error is thrown on error so undefined data doesn't mean there is an error...
483
+ *
484
+ * @param {String} from - the sender address
485
+ * @param {String} to - the contract address for the contract to interact with
486
+ * @param {String} method - the method/function to run
487
+ * @param {Array} params - array of paramters to apply to the contract method
488
+ * @param {Number} nonce - total transaction count [optional]
478
489
  */
479
490
  async createTransactionFrom(from, to, method, params, nonce) {
480
491
  if (nonce === undefined) {
@@ -519,6 +530,7 @@ export default class Chain {
519
530
 
520
531
  /**
521
532
  *
533
+ * @param {String} contract - a contract string (see plugins/deployContract)
522
534
  */
523
535
  async deployContract(contract, params = []) {
524
536
  globalThis.msg = {sender: peernet.id, call: this.call}
@@ -588,6 +600,15 @@ export default class Chain {
588
600
  return this.#machine.deleteAll()
589
601
  }
590
602
 
603
+ /**
604
+ * lookup an address for a registered name using the builtin nameService
605
+ * @check nameService
606
+ *
607
+ * @param {String} - contractName
608
+ * @returns {String} - address
609
+ *
610
+ * @example chain.lookup('myCoolContractName') // qmqsfddfdgfg...
611
+ */
591
612
  lookup(name) {
592
613
  return this.call(lib.nameService, 'lookup', [name])
593
614
  }
package/src/machine.js CHANGED
@@ -2,7 +2,6 @@ import vm from 'vm'
2
2
  import ContractMessage from './messages/contract'
3
3
  import TransactionMessage from './messages/transaction'
4
4
  import lib from './lib'
5
- import { info, subinfo } from './utils/utils'
6
5
  // import State from './state'
7
6
 
8
7
  export default class Machine {
@@ -62,8 +61,8 @@ console.log(e);
62
61
  globalThis.msg = this.#createMessage(contractMessage.decoded.creator)
63
62
  // globalThis.msg = {sender: contractMessage.decoded.creator}
64
63
  this.#contracts[contractMessage.hash] = new Contract(...params)
65
- info(`loaded contract: ${contractMessage.hash}`);
66
- subinfo(`size: ${Math.round((contractMessage.encoded.length / 1024) * 100) / 100} kb`);
64
+ debug(`loaded contract: ${contractMessage.hash}`);
65
+ debug(`size: ${Math.round((contractMessage.encoded.length / 1024) * 100) / 100} kb`);
67
66
  } catch (e) {
68
67
  console.log(e);
69
68
  console.warn(`removing contract ${contractMessage.hash}`);
@@ -2,15 +2,6 @@
2
2
  // import { writeFile, readFile } from 'fs'
3
3
  export { BigNumber } from "@ethersproject/bignumber";
4
4
  export { formatUnits, parseUnits } from '@ethersproject/units'
5
- import chalk from 'chalk'
6
5
 
7
- const info = text => console.log(chalk.blueBright(text))
8
-
9
- const subinfo = text => console.log(chalk.magentaBright(text))
10
-
11
- export {
12
- info,
13
- subinfo
14
- }
15
6
  // export const write = promisify(writeFile)
16
7
  // export const read = promisify(readFile)