@leofcoin/chain 1.0.24 → 1.0.26

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 (132) hide show
  1. package/demo/151.browser.js +271 -0
  2. package/demo/205.browser.js +215 -0
  3. package/demo/427.browser.js +8092 -0
  4. package/demo/560.browser.js +3 -0
  5. package/demo/911.browser.js +11024 -0
  6. package/{dist → demo}/chain.browser.js +6765 -24164
  7. package/demo/index.html +4 -4
  8. package/demo/main.browser.js +8163 -0
  9. package/{dist → demo}/node.browser.js +3157 -2582
  10. package/{dist → demo}/pako.browser.js +0 -0
  11. package/demo/peernet-worker.browser.js +11330 -0
  12. package/demo/workers/machine-worker.js +12544 -0
  13. package/{dist → demo}/wrtc.browser.js +0 -0
  14. package/dist/chain.js +235 -143
  15. package/dist/module/chain.js +1189 -0
  16. package/dist/module/node.js +1 -0
  17. package/dist/module/workers/machine-worker.js +491 -0
  18. package/dist/node.js +1 -1
  19. package/package.json +11 -19
  20. package/rollup.config.js +87 -3
  21. package/src/chain.js +94 -61
  22. package/src/config/config.js +11 -16
  23. package/src/machine.js +96 -57
  24. package/src/node.js +2 -1
  25. package/src/workers/block-worker.js +71 -0
  26. package/src/workers/machine-worker.js +160 -0
  27. package/src/workers/pool-worker.js +37 -0
  28. package/src/workers/transaction-worker.js +26 -0
  29. package/test/chain.js +14 -14
  30. package/test/create-genesis.js +13 -5
  31. package/webpack.config.js +49 -6
  32. package/workers/block-worker.js +1 -0
  33. package/workers/machine-worker.js +1 -0
  34. package/workers/pool-worker.js +1 -0
  35. package/workers/transaction-worker.js +1 -0
  36. package/dist/protons.browser.js +0 -11429
  37. package/docs/@leofcoin/chain/1.0.22/chain.js.html +0 -891
  38. package/docs/@leofcoin/chain/1.0.22/contracts_factory.js.html +0 -182
  39. package/docs/@leofcoin/chain/1.0.22/contracts_nameService.js.html +0 -231
  40. package/docs/@leofcoin/chain/1.0.22/contracts_proxies_factoryProxy.js.html +0 -135
  41. package/docs/@leofcoin/chain/1.0.22/contracts_proxies_nameServiceProxy.js.html +0 -135
  42. package/docs/@leofcoin/chain/1.0.22/contracts_proxies_nativeTokenProxy.js.html +0 -135
  43. package/docs/@leofcoin/chain/1.0.22/contracts_proxies_validatorsProxy.js.html +0 -135
  44. package/docs/@leofcoin/chain/1.0.22/contracts_proxies_votingProxy.js.html +0 -135
  45. package/docs/@leofcoin/chain/1.0.22/contracts_validators.js.html +0 -242
  46. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Bold-webfont.eot +0 -0
  47. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Bold-webfont.svg +0 -1830
  48. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Bold-webfont.woff +0 -0
  49. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  50. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  51. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  52. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Italic-webfont.eot +0 -0
  53. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Italic-webfont.svg +0 -1830
  54. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Italic-webfont.woff +0 -0
  55. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Light-webfont.eot +0 -0
  56. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Light-webfont.svg +0 -1831
  57. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Light-webfont.woff +0 -0
  58. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  59. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  60. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  61. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Regular-webfont.eot +0 -0
  62. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Regular-webfont.svg +0 -1831
  63. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Regular-webfont.woff +0 -0
  64. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Semibold-webfont.eot +0 -0
  65. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Semibold-webfont.svg +0 -1830
  66. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Semibold-webfont.ttf +0 -0
  67. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-Semibold-webfont.woff +0 -0
  68. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
  69. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1830
  70. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  71. package/docs/@leofcoin/chain/1.0.22/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  72. package/docs/@leofcoin/chain/1.0.22/global.html +0 -1805
  73. package/docs/@leofcoin/chain/1.0.22/icons/home.svg +0 -4
  74. package/docs/@leofcoin/chain/1.0.22/icons/search.svg +0 -4
  75. package/docs/@leofcoin/chain/1.0.22/index.html +0 -125
  76. package/docs/@leofcoin/chain/1.0.22/machine.js.html +0 -255
  77. package/docs/@leofcoin/chain/1.0.22/scripts/linenumber.js +0 -23
  78. package/docs/@leofcoin/chain/1.0.22/scripts/pagelocation.js +0 -89
  79. package/docs/@leofcoin/chain/1.0.22/standards_roles.js.html +0 -188
  80. package/docs/@leofcoin/chain/1.0.22/standards_token.js.html +0 -260
  81. package/docs/@leofcoin/chain/1.0.22/styles/collapse.css +0 -27
  82. package/docs/@leofcoin/chain/1.0.22/styles/jsdoc-default.css +0 -953
  83. package/docs/@leofcoin/chain/1.0.22/styles/prettify-jsdoc.css +0 -111
  84. package/docs/@leofcoin/chain/1.0.22/styles/prettify-tomorrow.css +0 -138
  85. package/docs/@leofcoin/chain/1.0.24/chain.js.html +0 -891
  86. package/docs/@leofcoin/chain/1.0.24/contracts_factory.js.html +0 -182
  87. package/docs/@leofcoin/chain/1.0.24/contracts_nameService.js.html +0 -231
  88. package/docs/@leofcoin/chain/1.0.24/contracts_proxies_factoryProxy.js.html +0 -135
  89. package/docs/@leofcoin/chain/1.0.24/contracts_proxies_nameServiceProxy.js.html +0 -135
  90. package/docs/@leofcoin/chain/1.0.24/contracts_proxies_nativeTokenProxy.js.html +0 -135
  91. package/docs/@leofcoin/chain/1.0.24/contracts_proxies_validatorsProxy.js.html +0 -135
  92. package/docs/@leofcoin/chain/1.0.24/contracts_proxies_votingProxy.js.html +0 -135
  93. package/docs/@leofcoin/chain/1.0.24/contracts_validators.js.html +0 -242
  94. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Bold-webfont.eot +0 -0
  95. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Bold-webfont.svg +0 -1830
  96. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Bold-webfont.woff +0 -0
  97. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  98. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  99. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  100. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Italic-webfont.eot +0 -0
  101. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Italic-webfont.svg +0 -1830
  102. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Italic-webfont.woff +0 -0
  103. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Light-webfont.eot +0 -0
  104. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Light-webfont.svg +0 -1831
  105. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Light-webfont.woff +0 -0
  106. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  107. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  108. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  109. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Regular-webfont.eot +0 -0
  110. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Regular-webfont.svg +0 -1831
  111. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Regular-webfont.woff +0 -0
  112. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Semibold-webfont.eot +0 -0
  113. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Semibold-webfont.svg +0 -1830
  114. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Semibold-webfont.ttf +0 -0
  115. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-Semibold-webfont.woff +0 -0
  116. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
  117. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1830
  118. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  119. package/docs/@leofcoin/chain/1.0.24/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  120. package/docs/@leofcoin/chain/1.0.24/global.html +0 -1805
  121. package/docs/@leofcoin/chain/1.0.24/icons/home.svg +0 -4
  122. package/docs/@leofcoin/chain/1.0.24/icons/search.svg +0 -4
  123. package/docs/@leofcoin/chain/1.0.24/index.html +0 -125
  124. package/docs/@leofcoin/chain/1.0.24/machine.js.html +0 -255
  125. package/docs/@leofcoin/chain/1.0.24/scripts/linenumber.js +0 -23
  126. package/docs/@leofcoin/chain/1.0.24/scripts/pagelocation.js +0 -89
  127. package/docs/@leofcoin/chain/1.0.24/standards_roles.js.html +0 -188
  128. package/docs/@leofcoin/chain/1.0.24/standards_token.js.html +0 -260
  129. package/docs/@leofcoin/chain/1.0.24/styles/collapse.css +0 -27
  130. package/docs/@leofcoin/chain/1.0.24/styles/jsdoc-default.css +0 -953
  131. package/docs/@leofcoin/chain/1.0.24/styles/prettify-jsdoc.css +0 -111
  132. package/docs/@leofcoin/chain/1.0.24/styles/prettify-tomorrow.css +0 -138
@@ -0,0 +1 @@
1
+ import e from"@leofcoin/peernet";import{FormatInterface as a}from"@leofcoin/codec-format-interface";class ContractMessage extends a{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 a{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 a{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 a{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 a{get keys(){return[]}get messageName(){return"BWRequestMessage"}constructor(e){super(e,"\n\nmessage BWRequestMessage {\n}\n",{name:"bw-request-message"})}}class Node{constructor(){return this._init()}async _init(a={network:"leofcoin",root:".leofcoin",networkName:"leofcoin:mandarine",networkVersion:"v0.1.0"}){return globalThis.Peernet?await new globalThis.Peernet(a):await new e(a),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("63636d",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)})(),this}}export{Node as default};
@@ -0,0 +1,491 @@
1
+ import { FormatInterface } from '@leofcoin/codec-format-interface';
2
+ import _BN from 'bn.js';
3
+ import { isBytes, hexlify, isHexString } from '@ethersproject/bytes';
4
+ import { Logger } from '@ethersproject/logger';
5
+ import '@ethersproject/bignumber';
6
+ import { fork } from 'child_process';
7
+
8
+ var proto = `
9
+ message ContractMessage {
10
+ required string creator = 1;
11
+ required bytes contract = 2;
12
+ repeated string constructorParameters = 3;
13
+ }
14
+ `;
15
+
16
+ class ContractMessage extends FormatInterface {
17
+ get keys() {
18
+ return ['creator', 'contract', 'constructorParameters']
19
+ }
20
+
21
+ get messageName() {
22
+ return 'ContractMessage'
23
+ }
24
+
25
+ constructor(buffer) {
26
+ super(buffer, proto, {name: 'contract-message'});
27
+ }
28
+ }
29
+
30
+ const version$1 = "bignumber/5.6.2";
31
+
32
+ var BN = _BN.BN;
33
+ const logger = new Logger(version$1);
34
+ const _constructorGuard = {};
35
+ const MAX_SAFE = 0x1fffffffffffff;
36
+ // Only warn about passing 10 into radix once
37
+ let _warnedToStringRadix = false;
38
+ class BigNumber {
39
+ constructor(constructorGuard, hex) {
40
+ if (constructorGuard !== _constructorGuard) {
41
+ logger.throwError("cannot call constructor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, {
42
+ operation: "new (BigNumber)"
43
+ });
44
+ }
45
+ this._hex = hex;
46
+ this._isBigNumber = true;
47
+ Object.freeze(this);
48
+ }
49
+ fromTwos(value) {
50
+ return toBigNumber(toBN(this).fromTwos(value));
51
+ }
52
+ toTwos(value) {
53
+ return toBigNumber(toBN(this).toTwos(value));
54
+ }
55
+ abs() {
56
+ if (this._hex[0] === "-") {
57
+ return BigNumber.from(this._hex.substring(1));
58
+ }
59
+ return this;
60
+ }
61
+ add(other) {
62
+ return toBigNumber(toBN(this).add(toBN(other)));
63
+ }
64
+ sub(other) {
65
+ return toBigNumber(toBN(this).sub(toBN(other)));
66
+ }
67
+ div(other) {
68
+ const o = BigNumber.from(other);
69
+ if (o.isZero()) {
70
+ throwFault("division-by-zero", "div");
71
+ }
72
+ return toBigNumber(toBN(this).div(toBN(other)));
73
+ }
74
+ mul(other) {
75
+ return toBigNumber(toBN(this).mul(toBN(other)));
76
+ }
77
+ mod(other) {
78
+ const value = toBN(other);
79
+ if (value.isNeg()) {
80
+ throwFault("division-by-zero", "mod");
81
+ }
82
+ return toBigNumber(toBN(this).umod(value));
83
+ }
84
+ pow(other) {
85
+ const value = toBN(other);
86
+ if (value.isNeg()) {
87
+ throwFault("negative-power", "pow");
88
+ }
89
+ return toBigNumber(toBN(this).pow(value));
90
+ }
91
+ and(other) {
92
+ const value = toBN(other);
93
+ if (this.isNegative() || value.isNeg()) {
94
+ throwFault("unbound-bitwise-result", "and");
95
+ }
96
+ return toBigNumber(toBN(this).and(value));
97
+ }
98
+ or(other) {
99
+ const value = toBN(other);
100
+ if (this.isNegative() || value.isNeg()) {
101
+ throwFault("unbound-bitwise-result", "or");
102
+ }
103
+ return toBigNumber(toBN(this).or(value));
104
+ }
105
+ xor(other) {
106
+ const value = toBN(other);
107
+ if (this.isNegative() || value.isNeg()) {
108
+ throwFault("unbound-bitwise-result", "xor");
109
+ }
110
+ return toBigNumber(toBN(this).xor(value));
111
+ }
112
+ mask(value) {
113
+ if (this.isNegative() || value < 0) {
114
+ throwFault("negative-width", "mask");
115
+ }
116
+ return toBigNumber(toBN(this).maskn(value));
117
+ }
118
+ shl(value) {
119
+ if (this.isNegative() || value < 0) {
120
+ throwFault("negative-width", "shl");
121
+ }
122
+ return toBigNumber(toBN(this).shln(value));
123
+ }
124
+ shr(value) {
125
+ if (this.isNegative() || value < 0) {
126
+ throwFault("negative-width", "shr");
127
+ }
128
+ return toBigNumber(toBN(this).shrn(value));
129
+ }
130
+ eq(other) {
131
+ return toBN(this).eq(toBN(other));
132
+ }
133
+ lt(other) {
134
+ return toBN(this).lt(toBN(other));
135
+ }
136
+ lte(other) {
137
+ return toBN(this).lte(toBN(other));
138
+ }
139
+ gt(other) {
140
+ return toBN(this).gt(toBN(other));
141
+ }
142
+ gte(other) {
143
+ return toBN(this).gte(toBN(other));
144
+ }
145
+ isNegative() {
146
+ return (this._hex[0] === "-");
147
+ }
148
+ isZero() {
149
+ return toBN(this).isZero();
150
+ }
151
+ toNumber() {
152
+ try {
153
+ return toBN(this).toNumber();
154
+ }
155
+ catch (error) {
156
+ throwFault("overflow", "toNumber", this.toString());
157
+ }
158
+ return null;
159
+ }
160
+ toBigInt() {
161
+ try {
162
+ return BigInt(this.toString());
163
+ }
164
+ catch (e) { }
165
+ return logger.throwError("this platform does not support BigInt", Logger.errors.UNSUPPORTED_OPERATION, {
166
+ value: this.toString()
167
+ });
168
+ }
169
+ toString() {
170
+ // Lots of people expect this, which we do not support, so check (See: #889)
171
+ if (arguments.length > 0) {
172
+ if (arguments[0] === 10) {
173
+ if (!_warnedToStringRadix) {
174
+ _warnedToStringRadix = true;
175
+ logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed");
176
+ }
177
+ }
178
+ else if (arguments[0] === 16) {
179
+ logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", Logger.errors.UNEXPECTED_ARGUMENT, {});
180
+ }
181
+ else {
182
+ logger.throwError("BigNumber.toString does not accept parameters", Logger.errors.UNEXPECTED_ARGUMENT, {});
183
+ }
184
+ }
185
+ return toBN(this).toString(10);
186
+ }
187
+ toHexString() {
188
+ return this._hex;
189
+ }
190
+ toJSON(key) {
191
+ return { type: "BigNumber", hex: this.toHexString() };
192
+ }
193
+ static from(value) {
194
+ if (value instanceof BigNumber) {
195
+ return value;
196
+ }
197
+ if (typeof (value) === "string") {
198
+ if (value.match(/^-?0x[0-9a-f]+$/i)) {
199
+ return new BigNumber(_constructorGuard, toHex(value));
200
+ }
201
+ if (value.match(/^-?[0-9]+$/)) {
202
+ return new BigNumber(_constructorGuard, toHex(new BN(value)));
203
+ }
204
+ return logger.throwArgumentError("invalid BigNumber string", "value", value);
205
+ }
206
+ if (typeof (value) === "number") {
207
+ if (value % 1) {
208
+ throwFault("underflow", "BigNumber.from", value);
209
+ }
210
+ if (value >= MAX_SAFE || value <= -MAX_SAFE) {
211
+ throwFault("overflow", "BigNumber.from", value);
212
+ }
213
+ return BigNumber.from(String(value));
214
+ }
215
+ const anyValue = value;
216
+ if (typeof (anyValue) === "bigint") {
217
+ return BigNumber.from(anyValue.toString());
218
+ }
219
+ if (isBytes(anyValue)) {
220
+ return BigNumber.from(hexlify(anyValue));
221
+ }
222
+ if (anyValue) {
223
+ // Hexable interface (takes priority)
224
+ if (anyValue.toHexString) {
225
+ const hex = anyValue.toHexString();
226
+ if (typeof (hex) === "string") {
227
+ return BigNumber.from(hex);
228
+ }
229
+ }
230
+ else {
231
+ // For now, handle legacy JSON-ified values (goes away in v6)
232
+ let hex = anyValue._hex;
233
+ // New-form JSON
234
+ if (hex == null && anyValue.type === "BigNumber") {
235
+ hex = anyValue.hex;
236
+ }
237
+ if (typeof (hex) === "string") {
238
+ if (isHexString(hex) || (hex[0] === "-" && isHexString(hex.substring(1)))) {
239
+ return BigNumber.from(hex);
240
+ }
241
+ }
242
+ }
243
+ }
244
+ return logger.throwArgumentError("invalid BigNumber value", "value", value);
245
+ }
246
+ static isBigNumber(value) {
247
+ return !!(value && value._isBigNumber);
248
+ }
249
+ }
250
+ // Normalize the hex string
251
+ function toHex(value) {
252
+ // For BN, call on the hex string
253
+ if (typeof (value) !== "string") {
254
+ return toHex(value.toString(16));
255
+ }
256
+ // If negative, prepend the negative sign to the normalized positive value
257
+ if (value[0] === "-") {
258
+ // Strip off the negative sign
259
+ value = value.substring(1);
260
+ // Cannot have multiple negative signs (e.g. "--0x04")
261
+ if (value[0] === "-") {
262
+ logger.throwArgumentError("invalid hex", "value", value);
263
+ }
264
+ // Call toHex on the positive component
265
+ value = toHex(value);
266
+ // Do not allow "-0x00"
267
+ if (value === "0x00") {
268
+ return value;
269
+ }
270
+ // Negate the value
271
+ return "-" + value;
272
+ }
273
+ // Add a "0x" prefix if missing
274
+ if (value.substring(0, 2) !== "0x") {
275
+ value = "0x" + value;
276
+ }
277
+ // Normalize zero
278
+ if (value === "0x") {
279
+ return "0x00";
280
+ }
281
+ // Make the string even length
282
+ if (value.length % 2) {
283
+ value = "0x0" + value.substring(2);
284
+ }
285
+ // Trim to smallest even-length string
286
+ while (value.length > 4 && value.substring(0, 4) === "0x00") {
287
+ value = "0x" + value.substring(4);
288
+ }
289
+ return value;
290
+ }
291
+ function toBigNumber(value) {
292
+ return BigNumber.from(toHex(value));
293
+ }
294
+ function toBN(value) {
295
+ const hex = BigNumber.from(value).toHexString();
296
+ if (hex[0] === "-") {
297
+ return (new BN("-" + hex.substring(3), 16));
298
+ }
299
+ return new BN(hex.substring(2), 16);
300
+ }
301
+ function throwFault(fault, operation, value) {
302
+ const params = { fault: fault, operation: operation };
303
+ if (value != null) {
304
+ params.value = value;
305
+ }
306
+ return logger.throwError(fault, Logger.errors.NUMERIC_FAULT, params);
307
+ }
308
+
309
+ const version = "units/5.6.1";
310
+
311
+ new Logger(version);
312
+
313
+ const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
314
+
315
+ const formatBytes = (bytes, decimals = 2) => {
316
+ if (bytes === 0) return '0 Bytes';
317
+ if (decimals < 0) decimals = 0;
318
+
319
+ const k = 1024;
320
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
321
+
322
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${byteFormats[i]}`
323
+ };
324
+
325
+ var contractFactory = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,53,69,121,74,118,54,84,86,69,97,88,71,116,114,101,69,70,84,70,83,69,74,109,97,75,66,100,118,83,113,116,88,112,88,87,52,114,55,98,119,87,66,119,56,119,83,89,86,106,71,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,92,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,92,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,118,97,108,105,100,40,104,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,61,91,93,41,123,99,111,110,115,116,32,109,101,115,115,97,103,101,61,110,101,119,32,67,111,110,116,114,97,99,116,77,101,115,115,97,103,101,40,123,99,114,101,97,116,111,114,58,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,58,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,58,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,125,41,59,114,101,116,117,114,110,32,66,111,111,108,101,97,110,40,109,101,115,115,97,103,101,46,104,97,115,104,61,61,61,104,97,115,104,41,125,97,115,121,110,99,32,100,101,112,108,111,121,67,111,110,116,114,97,99,116,40,99,111,110,116,114,97,99,116,72,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,61,91,93,41,123,105,102,40,99,111,110,116,114,97,99,116,46,99,114,101,97,116,111,114,33,61,61,109,115,103,46,115,101,110,100,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,111,110,108,121,32,97,32,99,111,110,116,114,97,99,116,32,99,114,101,97,116,111,114,32,99,97,110,32,100,101,112,108,111,121,32,97,32,99,111,110,116,114,97,99,116,92,34,41,59,105,102,40,97,119,97,105,116,32,99,111,110,116,114,97,99,116,83,116,111,114,101,46,104,97,115,40,104,97,115,104,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,100,117,112,108,105,99,97,116,101,32,99,111,110,116,114,97,99,116,92,34,41,59,105,102,40,33,116,104,105,115,46,105,115,86,97,108,105,100,40,99,111,110,116,114,97,99,116,72,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,105,110,118,97,108,105,100,32,99,111,110,116,114,97,99,116,92,34,41,59,97,119,97,105,116,32,99,111,110,116,114,97,99,116,83,116,111,114,101,46,112,117,116,40,104,97,115,104,44,101,110,99,111,100,101,100,41,44,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,104,97,115,104,41,125,125,59,92,110,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125";
326
+ var nativeToken = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,53,69,121,74,118,54,84,86,69,97,88,71,116,114,101,69,70,84,70,83,69,74,109,97,75,66,100,118,83,113,116,88,112,88,87,52,114,55,98,119,87,66,119,56,119,83,89,86,106,71,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,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,69,114,114,111,114,40,92,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,92,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,92,34,79,87,78,69,82,92,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,45,49,33,61,61,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,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,92,34,79,87,78,69,82,92,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,92,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,92,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,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,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,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,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,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,92,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,92,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,92,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,92,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,92,34,77,73,78,84,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,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,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,92,34,66,85,82,78,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,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,116,111,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,92,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,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,92,34,48,120,48,48,92,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,92,34,48,120,48,48,92,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,92,34,48,120,48,48,92,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,103,108,111,98,97,108,84,104,105,115,46,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,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,92,34,65,114,116,79,110,108,105,110,101,92,34,44,92,34,65,82,84,92,34,44,49,56,44,115,116,97,116,101,41,125,125,59,92,110,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125";
327
+ var nameService = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,53,69,121,74,118,54,84,86,69,97,88,71,116,114,101,69,70,84,70,83,69,74,109,97,75,66,100,118,83,113,116,88,112,88,87,52,114,55,98,119,87,66,119,56,119,83,89,86,106,71,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,78,97,109,101,83,101,114,118,105,99,101,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,78,97,109,101,83,101,114,118,105,99,101,92,34,59,35,111,119,110,101,114,59,35,112,114,105,99,101,61,48,59,35,114,101,103,105,115,116,114,121,61,123,125,59,35,99,117,114,114,101,110,99,121,59,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,114,101,103,105,115,116,114,121,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,101,103,105,115,116,114,121,125,125,103,101,116,32,115,116,97,116,101,40,41,123,125,99,111,110,115,116,114,117,99,116,111,114,40,102,97,99,116,111,114,121,65,100,100,114,101,115,115,44,99,117,114,114,101,110,99,121,44,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,44,112,114,105,99,101,44,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,111,119,110,101,114,61,115,116,97,116,101,46,111,119,110,101,114,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,61,115,116,97,116,101,46,114,101,103,105,115,116,114,121,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,112,114,105,99,101,61,115,116,97,116,101,46,112,114,105,99,101,41,58,40,116,104,105,115,46,35,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,102,97,99,116,111,114,121,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,84,111,107,101,110,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,99,117,114,114,101,110,99,121,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,41,125,99,104,97,110,103,101,79,119,110,101,114,40,111,119,110,101,114,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,111,119,110,101,114,61,111,119,110,101,114,125,99,104,97,110,103,101,80,114,105,99,101,40,112,114,105,99,101,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,97,115,121,110,99,32,112,117,114,99,104,97,115,101,78,97,109,101,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,60,116,104,105,115,46,35,112,114,105,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,112,114,105,99,101,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,34,41,59,116,114,121,123,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,116,114,97,110,115,102,101,114,92,34,44,91,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,111,119,110,101,114,44,116,104,105,115,46,35,112,114,105,99,101,93,41,125,99,97,116,99,104,40,101,41,123,116,104,114,111,119,32,101,125,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,97,100,100,114,101,115,115,125,125,108,111,111,107,117,112,40,110,97,109,101,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,125,116,114,97,110,115,102,101,114,79,119,110,101,114,115,104,105,112,40,110,97,109,101,44,116,111,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,111,119,110,101,114,61,116,111,125,99,104,97,110,103,101,65,100,100,114,101,115,115,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,97,100,100,114,101,115,115,61,97,100,100,114,101,115,115,125,125,59,92,110,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,104,112,120,106,108,105,98,50,110,97,110,110,55,113,53,111,118,97,113,115,53,117,111,55,100,117,102,97,99,51,114,52,121,111,109,102,51,54,112,116,52,100,53,121,103,54,97,116,116,54,101,119,34,44,34,105,104,110,121,50,103,113,104,114,120,52,52,110,105,105,102,116,105,53,122,97,119,102,113,99,108,102,107,108,102,55,101,119,115,102,54,122,51,114,101,109,50,102,109,98,120,115,116,54,109,120,121,121,122,97,104,108,109,54,34,44,34,105,104,110,121,50,103,113,103,121,53,106,112,107,101,118,119,102,111,108,117,119,101,50,98,50,121,55,118,105,113,116,99,102,114,119,103,97,98,105,112,122,51,109,107,98,55,116,119,110,104,106,115,113,104,100,99,50,119,116,34,44,34,49,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,34,93,125";
328
+ var validators = "237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,53,69,121,74,118,54,84,86,69,97,88,71,116,114,101,69,70,84,70,83,69,74,109,97,75,66,100,118,83,113,116,88,112,88,87,52,114,55,98,119,87,66,119,56,119,83,89,86,106,71,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,86,97,108,105,100,97,116,111,114,115,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,92,34,59,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,48,59,35,118,97,108,105,100,97,116,111,114,115,61,123,125,59,35,111,119,110,101,114,59,35,99,117,114,114,101,110,99,121,59,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,59,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,111,119,110,101,114,58,116,104,105,115,46,35,111,119,110,101,114,44,109,105,110,105,109,117,109,66,97,108,97,110,99,101,58,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,99,117,114,114,101,110,99,121,58,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,118,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,99,111,110,115,116,114,117,99,116,111,114,40,116,111,107,101,110,65,100,100,114,101,115,115,44,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,111,119,110,101,114,61,115,116,97,116,101,46,111,119,110,101,114,44,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,115,116,97,116,101,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,118,97,108,105,100,97,116,111,114,115,41,58,40,116,104,105,115,46,35,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,53,101,52,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,116,111,107,101,110,65,100,100,114,101,115,115,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,109,115,103,46,115,101,110,100,101,114,93,61,123,102,105,114,115,116,83,101,101,110,58,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,44,97,99,116,105,118,101,58,33,48,125,41,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,111,119,110,101,114,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,111,119,110,101,114,125,103,101,116,32,99,117,114,114,101,110,99,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,117,114,114,101,110,99,121,125,103,101,116,32,118,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,103,101,116,32,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,125,103,101,116,32,109,105,110,105,109,117,109,66,97,108,97,110,99,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,99,104,97,110,103,101,79,119,110,101,114,40,111,119,110,101,114,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,110,32,111,119,110,101,114,92,34,41,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,110,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,104,97,115,40,118,97,108,105,100,97,116,111,114,41,123,114,101,116,117,114,110,32,66,111,111,108,101,97,110,40,118,111,105,100,32,48,33,61,61,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,41,125,97,115,121,110,99,32,97,100,100,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,108,114,101,97,100,121,32,97,32,118,97,108,105,100,97,116,111,114,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,61,123,102,105,114,115,116,83,101,101,110,58,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,44,97,99,116,105,118,101,58,33,48,125,125,114,101,109,111,118,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,45,61,49,44,100,101,108,101,116,101,32,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,125,97,115,121,110,99,32,117,112,100,97,116,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,44,97,99,116,105,118,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,38,38,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,38,38,40,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,33,49,41,44,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,97,99,116,105,118,101,125,125,59,92,110,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,104,114,120,52,52,110,105,105,102,116,105,53,122,97,119,102,113,99,108,102,107,108,102,55,101,119,115,102,54,122,51,114,101,109,50,102,109,98,120,115,116,54,109,120,121,121,122,97,104,108,109,54,34,93,125";
329
+ var bytecodes = {
330
+ contractFactory: contractFactory,
331
+ nativeToken: nativeToken,
332
+ nameService: nameService,
333
+ validators: validators
334
+ };
335
+
336
+ const contractFactoryMessage = bytecodes.contractFactory;
337
+ const nativeTokenMessage = bytecodes.nativeToken;
338
+ const nameServiceMessage = bytecodes.nameService;
339
+ const validatorsMessage = bytecodes.validators;
340
+
341
+ globalThis.BigNumber = BigNumber;
342
+
343
+ globalThis.peernet = globalThis.peernet || {};
344
+ globalThis.contracts = {};
345
+
346
+ const get = (contract, method, params) => {
347
+ let result;
348
+ if (params?.length > 0) {
349
+ result = contracts[contract][method](...params);
350
+ } else {
351
+ result = contracts[contract][method];
352
+ }
353
+ return result
354
+ };
355
+
356
+ const runContract = async (contractMessage) => {
357
+ const params = contractMessage.decoded.constructorParameters;
358
+ try {
359
+
360
+ const func = new Function(contractMessage.decoded.contract);
361
+ const Contract = func();
362
+
363
+ globalThis.msg = createMessage(contractMessage.decoded.creator);
364
+ // globalThis.msg = {sender: contractMessage.decoded.creator}
365
+ contracts[await contractMessage.hash] = await new Contract(...params);
366
+ process.send({
367
+ type: 'debug',
368
+ messages: [
369
+ `loaded contract: ${await contractMessage.hash}`,
370
+ `size: ${formatBytes(contractMessage.encoded.length)}`
371
+ ]
372
+ });
373
+ } catch (e) {
374
+ console.log(e);
375
+ process.send({
376
+ type: 'contractError',
377
+ hash: await contractMessage.hash
378
+ });
379
+ }
380
+ };
381
+
382
+ const execute = async (contract, method, params) => {
383
+ try {
384
+ let result;
385
+ // don't execute the method on a proxy
386
+ if (contracts[contract].fallback) {
387
+ result = await contracts[contract].fallback(method, params);
388
+ } else {
389
+ result = await contracts[contract][method](...params);
390
+ }
391
+
392
+ // state.put(result)
393
+ return result
394
+ } catch (e) {
395
+ throw e
396
+ }
397
+ };
398
+
399
+
400
+ const createMessage = (sender = globalThis.peerid) => {
401
+ return {
402
+ sender,
403
+ call: execute,
404
+ staticCall: get
405
+ }
406
+ };
407
+
408
+ const _init = async ({ contracts, blocks, peerid })=> {
409
+ globalThis.peerid = peerid;
410
+ contracts = [
411
+ contractFactoryMessage,
412
+ nativeTokenMessage,
413
+ nameServiceMessage,
414
+ validatorsMessage
415
+ ];
416
+
417
+ contracts = await Promise.all(contracts.map(async contract => {
418
+ contract = await new ContractMessage(new Uint8Array(contract.split(',')));
419
+ await runContract(contract);
420
+ return contract
421
+ }));
422
+
423
+ const worker = fork('./workers/block-worker.js', {serialization: 'advanced'});
424
+ // worker.on('message')
425
+ worker.once('message', async (blocks) => {
426
+ for (const block of blocks) {
427
+ await Promise.all(block.decoded.transactions.map(async message => {
428
+ const {from, to, method, params} = message.decoded;
429
+ globalThis.msg = createMessage(from);
430
+
431
+ await execute(to, method, params);
432
+ }));
433
+ }
434
+ process.send({type: 'machine-ready'});
435
+ worker.kill();
436
+
437
+
438
+
439
+ });
440
+ worker.send(blocks);
441
+ };
442
+
443
+ const tasks = async (e) => {
444
+ globalThis.peernet.codecs = {
445
+ 'contract-message': {
446
+ codec: parseInt('63636d', 16),
447
+ hashAlg: 'keccak-256'
448
+ },
449
+ 'transaction-message': {
450
+ codec: parseInt('746d', 16),
451
+ hashAlg: 'keccak-256'
452
+ },
453
+ 'block-message': {
454
+ codec: parseInt('626d', 16),
455
+ hashAlg: 'keccak-256'
456
+ }
457
+ };
458
+ if (e.type === 'init') await _init(e.input);
459
+ if (e.type === 'get') {
460
+ const value = await get(e.input.contract, e.input.method, e.input.params);
461
+ process.send({
462
+ type: 'response',
463
+ id: e.id,
464
+ value
465
+ });
466
+ }
467
+ if (e.type === 'execute') {
468
+ try {
469
+ const value = await execute(e.input.contract, e.input.method, e.input.params);
470
+ process.send({
471
+ type: 'response',
472
+ id: e.id,
473
+ value
474
+ });
475
+ } catch(e) {
476
+ process.send({
477
+ type: 'executionError',
478
+ message: e,
479
+ id: e.id
480
+
481
+ });
482
+ }
483
+ }
484
+ };
485
+
486
+
487
+ if (globalThis.process) {
488
+ process.on('message', tasks);
489
+ } else {
490
+ onmessage = message => tasks(message.data);
491
+ }
package/dist/node.js CHANGED
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("@leofcoin/peernet"));module.exports=class Node{constructor(){return this._init()}async _init(e={network:"leofcoin",root:".leofcoin",networkName:"leofcoin:mandarine",networkVersion:"v0.1.0"}){return globalThis.Peernet?await new globalThis.Peernet(e):await new t.default(e),this}};
1
+ "use strict";var e=require("@leofcoin/peernet"),a=require("@leofcoin/codec-format-interface");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=r(e);class ContractMessage extends a.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 a.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 a.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 a.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 a.FormatInterface{get keys(){return[]}get messageName(){return"BWRequestMessage"}constructor(e){super(e,"\n\nmessage BWRequestMessage {\n}\n",{name:"bw-request-message"})}}module.exports=class Node{constructor(){return this._init()}async _init(e={network:"leofcoin",root:".leofcoin",networkName:"leofcoin:mandarine",networkVersion:"v0.1.0"}){return globalThis.Peernet?await new globalThis.Peernet(e):await new t.default(e),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("63636d",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)})(),this}};
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
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
- "source": "./src/node.js",
6
5
  "main": "./dist/node.js",
7
6
  "module": "./dist/chain.esm",
8
7
  "scripts": {
9
8
  "c": "rollup -c",
10
9
  "w": "rollup -c -w",
11
- "build": "npm run c && webpack",
12
- "demo": "jsproject --serve ./ --port 5478 --open demo",
13
- "docs": "sh node_modules/.bin/jsdoc --configure .jsdoc.json --verbose",
10
+ "build": "npm run c && webpack && cp ./dist/*browser.js ./demo && cp ./dist/machine-worker.js ./demo/workers/machine-worker.js",
11
+ "demo": "jsproject --serve ./demo --port 5478 --open demo",
14
12
  "test": "echo \"Error: no test specified\" && exit 1"
15
13
  },
16
14
  "browserslist": "> 0.5%, last 2 versions, not dead",
@@ -18,16 +16,11 @@
18
16
  "author": "",
19
17
  "license": "MIT",
20
18
  "devDependencies": {
21
- "@rollup/plugin-commonjs": "^21.0.2",
22
19
  "@rollup/plugin-json": "^4.1.0",
23
- "@rollup/plugin-node-resolve": "^13.1.3",
24
20
  "@rollup/plugin-strip": "^2.1.0",
25
21
  "@vandeurenglenn/debug": "^1.0.0",
26
- "jsdoc": "^3.6.10",
27
- "jsdoc-template": "github:braintree/jsdoc-template",
28
22
  "rollup": "^2.70.1",
29
23
  "rollup-plugin-cleanup": "^3.2.1",
30
- "rollup-plugin-modify": "^3.0.0",
31
24
  "rollup-plugin-terser": "^7.0.2",
32
25
  "tape": "^5.5.2",
33
26
  "vm-browserify": "^1.1.2",
@@ -37,19 +30,18 @@
37
30
  "@ethersproject/bignumber": "^5.6.0",
38
31
  "@ethersproject/units": "^5.6.0",
39
32
  "@leofcoin/addresses": "^1.0.0-beta.1",
33
+ "@leofcoin/codec-format-interface": "^1.4.0",
40
34
  "@leofcoin/lib": "^1.0.11",
41
- "@leofcoin/messages": "^1.1.1",
35
+ "@leofcoin/messages": "^1.2.0",
42
36
  "@leofcoin/multi-wallet": "^2.1.1",
43
- "@leofcoin/peernet": "^0.12.3",
44
- "@leofcoin/storage": "^2.3.0",
37
+ "@leofcoin/peernet": "^0.14.0",
38
+ "@leofcoin/storage": "^3.0.6",
45
39
  "@leofcoin/utils": "^1.0.2",
46
40
  "@vandeurenglenn/base32": "^1.1.0",
41
+ "@vandeurenglenn/easy-worker": "^1.0.0",
42
+ "@vandeurenglenn/queue": "^1.0.0",
47
43
  "chalk": "^4.0.0",
48
- "datastore-level": "^8.0.0",
49
- "pako": "^2.0.4"
50
- },
51
- "directories": {
52
- "example": "examples",
53
- "test": "test"
44
+ "pako": "^2.0.4",
45
+ "webpack": "^5.74.0"
54
46
  }
55
47
  }