@leofcoin/chain 1.0.12 → 1.0.13
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.
- package/dist/node.browser.js +1046 -1048
- package/dist/node.browser.min.js +1 -1
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/chain.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_factory.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_nameService.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_proxies_factoryProxy.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_proxies_nameServiceProxy.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_proxies_nativeTokenProxy.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_proxies_validatorsProxy.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_proxies_votingProxy.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/contracts_validators.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Bold-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-BoldItalic-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Italic-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Light-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-LightItalic-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Regular-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Semibold-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Semibold-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Semibold-webfont.ttf +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-Semibold-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/global.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/icons/home.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/icons/search.svg +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/index.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/machine.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/scripts/linenumber.js +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/scripts/pagelocation.js +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/standards_roles.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/standards_token.js.html +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/styles/collapse.css +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/styles/jsdoc-default.css +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/styles/prettify-jsdoc.css +0 -0
- package/docs/@leofcoin/chain/{1.0.10 → 1.0.12}/styles/prettify-tomorrow.css +0 -0
- package/package.json +2 -2
- package/rollup.config.js +0 -42
- package/_node.js +0 -1
- package/chain.js +0 -938
- package/docs/@leofcoin/chain/1.0.11/chain.js.html +0 -738
- package/docs/@leofcoin/chain/1.0.11/contracts_factory.js.html +0 -182
- package/docs/@leofcoin/chain/1.0.11/contracts_nameService.js.html +0 -231
- package/docs/@leofcoin/chain/1.0.11/contracts_proxies_factoryProxy.js.html +0 -135
- package/docs/@leofcoin/chain/1.0.11/contracts_proxies_nameServiceProxy.js.html +0 -135
- package/docs/@leofcoin/chain/1.0.11/contracts_proxies_nativeTokenProxy.js.html +0 -135
- package/docs/@leofcoin/chain/1.0.11/contracts_proxies_validatorsProxy.js.html +0 -135
- package/docs/@leofcoin/chain/1.0.11/contracts_proxies_votingProxy.js.html +0 -135
- package/docs/@leofcoin/chain/1.0.11/contracts_validators.js.html +0 -242
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Semibold-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Semibold-webfont.svg +0 -1830
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Semibold-webfont.ttf +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-Semibold-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1830
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- package/docs/@leofcoin/chain/1.0.11/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- package/docs/@leofcoin/chain/1.0.11/global.html +0 -1153
- package/docs/@leofcoin/chain/1.0.11/icons/home.svg +0 -4
- package/docs/@leofcoin/chain/1.0.11/icons/search.svg +0 -4
- package/docs/@leofcoin/chain/1.0.11/index.html +0 -125
- package/docs/@leofcoin/chain/1.0.11/machine.js.html +0 -252
- package/docs/@leofcoin/chain/1.0.11/scripts/linenumber.js +0 -23
- package/docs/@leofcoin/chain/1.0.11/scripts/pagelocation.js +0 -89
- package/docs/@leofcoin/chain/1.0.11/standards_roles.js.html +0 -188
- package/docs/@leofcoin/chain/1.0.11/standards_token.js.html +0 -260
- package/docs/@leofcoin/chain/1.0.11/styles/collapse.css +0 -27
- package/docs/@leofcoin/chain/1.0.11/styles/jsdoc-default.css +0 -953
- package/docs/@leofcoin/chain/1.0.11/styles/prettify-jsdoc.css +0 -111
- package/docs/@leofcoin/chain/1.0.11/styles/prettify-tomorrow.css +0 -138
- package/lib.js +0 -1
package/chain.js
DELETED
|
@@ -1,938 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var bignumber = require('@ethersproject/bignumber');
|
|
4
|
-
var units = require('@ethersproject/units');
|
|
5
|
-
require('vm');
|
|
6
|
-
var protons = require('protons');
|
|
7
|
-
var codecFormatInterface = require('@leofcoin/codec-format-interface');
|
|
8
|
-
require('@vandeurenglenn/base58');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var protons__default = /*#__PURE__*/_interopDefaultLegacy(protons);
|
|
13
|
-
|
|
14
|
-
var proto$4 = `
|
|
15
|
-
message ContractMessage {
|
|
16
|
-
required string creator = 1;
|
|
17
|
-
required bytes contract = 2;
|
|
18
|
-
repeated string constructorParameters = 3;
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
class ContractMessage$1 extends codecFormatInterface.FormatInterface {
|
|
23
|
-
get keys() {
|
|
24
|
-
return ['creator', 'contract', 'constructorParameters']
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
constructor(buffer) {
|
|
28
|
-
super(buffer, protons__default["default"](proto$4).ContractMessage, {name: 'contract-message'});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var proto$3 = `
|
|
33
|
-
|
|
34
|
-
message TransactionMessage {
|
|
35
|
-
required uint64 timestamp = 1;
|
|
36
|
-
required string from = 2;
|
|
37
|
-
required string to = 3;
|
|
38
|
-
required uint64 nonce = 4;
|
|
39
|
-
required string method = 5;
|
|
40
|
-
repeated string params = 6;
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
class TransactionMessage$1 extends codecFormatInterface.FormatInterface {
|
|
45
|
-
get keys() {
|
|
46
|
-
return ['timestamp', 'from', 'to', 'nonce', 'method', 'params']
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
constructor(buffer) {
|
|
50
|
-
const name = 'transaction-message';
|
|
51
|
-
super(buffer, protons__default["default"](proto$3).TransactionMessage, {name});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var proto$2 = `
|
|
56
|
-
message ValidatorMessage {
|
|
57
|
-
required string address = 1;
|
|
58
|
-
required string reward = 2;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
message Transaction {
|
|
62
|
-
required string hash = 1;
|
|
63
|
-
required uint64 timestamp = 2;
|
|
64
|
-
required string from = 3;
|
|
65
|
-
required string to = 4;
|
|
66
|
-
required uint64 nonce = 5;
|
|
67
|
-
required string method = 6;
|
|
68
|
-
repeated string params = 7;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
message BlockMessage {
|
|
72
|
-
required uint64 index = 1;
|
|
73
|
-
required string previousHash = 3;
|
|
74
|
-
required uint64 timestamp = 4;
|
|
75
|
-
required uint64 reward = 5;
|
|
76
|
-
required string fees = 6;
|
|
77
|
-
repeated Transaction transactions = 7;
|
|
78
|
-
repeated ValidatorMessage validators = 8;
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
class BlockMessage$1 extends codecFormatInterface.FormatInterface {
|
|
83
|
-
get keys() {
|
|
84
|
-
return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
constructor(buffer) {
|
|
88
|
-
const name = 'block-message';
|
|
89
|
-
super(buffer, protons__default["default"](proto$2).BlockMessage, {name});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
var proto$1 = `
|
|
94
|
-
|
|
95
|
-
message BWMessage {
|
|
96
|
-
required uint64 up = 1;
|
|
97
|
-
required uint64 down = 2;
|
|
98
|
-
}
|
|
99
|
-
`;
|
|
100
|
-
|
|
101
|
-
class BWMessage$1 extends codecFormatInterface.FormatInterface {
|
|
102
|
-
get keys() {
|
|
103
|
-
return ['up', 'down']
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
constructor(buffer) {
|
|
107
|
-
const name = 'bw-message';
|
|
108
|
-
super(buffer, protons__default["default"](proto$1).BWMessage, {name});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var proto = `
|
|
113
|
-
|
|
114
|
-
message BWRequestMessage {
|
|
115
|
-
}
|
|
116
|
-
`;
|
|
117
|
-
|
|
118
|
-
class BWRequestMessage$1 extends codecFormatInterface.FormatInterface {
|
|
119
|
-
get keys() {
|
|
120
|
-
return []
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
constructor(buffer) {
|
|
124
|
-
const name = 'bw-request-message';
|
|
125
|
-
super(buffer, protons__default["default"](proto).BWRequestMessage, {name});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var contractFactory$2 = "237,198,1,10,54,51,67,122,86,52,88,98,115,81,54,72,57,100,75,49,76,101,105,66,75,65,120,114,54,81,105,77,71,53,116,68,105,55,122,77,77,72,118,117,120,104,121,50,101,118,70,101,118,72,49,77,85,76,99,18,146,8,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,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,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,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,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,34,100,117,112,108,105,99,97,116,101,32,99,111,110,116,114,97,99,116,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,34,105,110,118,97,108,105,100,32,99,111,110,116,114,97,99,116,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,10";
|
|
130
|
-
var nativeToken$2 = "237,198,1,10,54,51,67,122,86,52,88,98,115,81,54,72,57,100,75,49,76,101,105,66,75,65,120,114,54,81,105,77,71,53,116,68,105,55,122,77,77,72,118,117,120,104,121,50,101,118,70,101,118,72,49,77,85,76,99,18,152,26,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,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,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,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,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,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,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,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,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,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,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,59,10";
|
|
131
|
-
var nameService$2 = "237,198,1,10,54,51,67,122,86,52,88,98,115,81,54,72,57,100,75,49,76,101,105,66,75,65,120,114,54,81,105,77,71,53,116,68,105,55,122,77,77,72,118,117,120,104,121,50,101,118,70,101,118,72,49,77,85,76,99,18,138,12,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,34,65,114,116,79,110,108,105,110,101,78,97,109,101,83,101,114,118,105,99,101,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,34,110,111,32,111,119,110,101,114,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,34,110,111,32,111,119,110,101,114,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,34,110,111,32,111,119,110,101,114,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,34,98,97,108,97,110,99,101,79,102,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,34,112,114,105,99,101,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,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,34,116,114,97,110,115,102,101,114,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,34,110,111,116,32,97,32,111,119,110,101,114,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,34,110,111,116,32,97,32,111,119,110,101,114,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,10,26,58,98,97,53,120,100,97,100,115,54,118,99,106,105,119,118,102,51,52,110,112,122,104,54,120,114,108,97,105,118,112,106,103,116,112,51,109,105,116,51,104,119,104,120,101,117,109,121,98,119,115,112,106,114,104,101,122,51,101,26,58,98,97,53,120,100,97,100,102,109,98,54,102,119,52,50,106,50,112,97,122,55,51,52,112,117,98,122,119,120,110,55,114,103,105,119,119,109,103,115,51,100,99,105,99,114,52,117,50,101,107,104,113,101,118,113,118,99,117,26,58,98,97,53,120,100,97,99,55,107,118,121,51,99,106,107,97,52,97,101,120,55,98,122,55,119,54,114,121,113,120,103,102,98,109,119,115,116,111,109,115,101,121,111,110,121,116,98,115,115,108,55,115,108,101,114,105,117,100,26,4,49,48,48,48";
|
|
132
|
-
var validators$2 = "237,198,1,10,54,51,67,122,86,52,88,98,115,81,54,72,57,100,75,49,76,101,105,66,75,65,120,114,54,81,105,77,71,53,116,68,105,55,122,77,77,72,118,117,120,104,121,50,101,118,70,101,118,72,49,77,85,76,99,18,215,16,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,34,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,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,34,110,111,116,32,97,110,32,111,119,110,101,114,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,34,110,111,116,32,97,110,32,111,119,110,101,114,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,34,97,108,114,101,97,100,121,32,97,32,118,97,108,105,100,97,116,111,114,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,34,98,97,108,97,110,99,101,79,102,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,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,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,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,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,34,98,97,108,97,110,99,101,79,102,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,10,26,58,98,97,53,120,100,97,100,102,109,98,54,102,119,52,50,106,50,112,97,122,55,51,52,112,117,98,122,119,120,110,55,114,103,105,119,119,109,103,115,51,100,99,105,99,114,52,117,50,101,107,104,113,101,118,113,118,99,117";
|
|
133
|
-
var bytecodes = {
|
|
134
|
-
contractFactory: contractFactory$2,
|
|
135
|
-
nativeToken: nativeToken$2,
|
|
136
|
-
nameService: nameService$2,
|
|
137
|
-
validators: validators$2
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
var contractFactory$1 = "ba5xdads6vcjiwvf34npzh6xrlaivpjgtp3mit3hwhxeumybwspjrhez3e";
|
|
141
|
-
var nativeToken$1 = "ba5xdadfmb6fw42j2paz734pubzwxn7rgiwwmgs3dcicr4u2ekhqevqvcu";
|
|
142
|
-
var nameService$1 = "ba5xdadsx73i3tkuk6q5bz4mm5zcgqipha3szmuixgit46albm2inuarp6";
|
|
143
|
-
var validators$1 = "ba5xdac7kvy3cjka4aex7bz7w6ryqxgfbmwstomseyonytbssl7sleriud";
|
|
144
|
-
var addresses = {
|
|
145
|
-
contractFactory: contractFactory$1,
|
|
146
|
-
nativeToken: nativeToken$1,
|
|
147
|
-
nameService: nameService$1,
|
|
148
|
-
validators: validators$1
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const { contractFactory, nativeToken, nameService, validators } = addresses;
|
|
152
|
-
|
|
153
|
-
const contractFactoryMessage = new Uint8Array(bytecodes.contractFactory.split(','));
|
|
154
|
-
const nativeTokenMessage = new Uint8Array(bytecodes.nativeToken.split(','));
|
|
155
|
-
|
|
156
|
-
const nameServiceMessage = new Uint8Array(bytecodes.nameService.split(','));
|
|
157
|
-
const validatorsMessage = new Uint8Array(bytecodes.validators.split(','));
|
|
158
|
-
|
|
159
|
-
const calculateFee = transaction => {
|
|
160
|
-
// excluded from fees
|
|
161
|
-
if (transaction.decoded.to === validators) return 0
|
|
162
|
-
// fee per gb
|
|
163
|
-
let fee = transaction.encoded.length;
|
|
164
|
-
fee = fee / 1024;
|
|
165
|
-
fee = fee / 1000000;
|
|
166
|
-
const parts = String(fee).split('.');
|
|
167
|
-
let decimals = 0;
|
|
168
|
-
if (parts[1]) {
|
|
169
|
-
const potentional = parts[1].split('e');
|
|
170
|
-
parts[1] = potentional[0];
|
|
171
|
-
decimals = Number(potentional[1].replace(/\-|\+/g, '')) + Number(potentional[0].length);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return Number.parseFloat(fee.toString()).toFixed(decimals)
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const calculateTransactionFee = transaction => {
|
|
178
|
-
transaction = new TransactionMessage$1(transaction);
|
|
179
|
-
return calculateFee(transaction)
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
var lib = {
|
|
183
|
-
nativeToken,
|
|
184
|
-
nameService,
|
|
185
|
-
contractFactory,
|
|
186
|
-
validators,
|
|
187
|
-
contractFactoryMessage,
|
|
188
|
-
nativeTokenMessage,
|
|
189
|
-
nameServiceMessage,
|
|
190
|
-
validatorsMessage,
|
|
191
|
-
TransactionMessage: TransactionMessage$1,
|
|
192
|
-
ContractMessage: ContractMessage$1,
|
|
193
|
-
BlockMessage: BlockMessage$1,
|
|
194
|
-
BWMessage: BWMessage$1,
|
|
195
|
-
BWRequestMessage: BWRequestMessage$1,
|
|
196
|
-
calculateFee,
|
|
197
|
-
calculateTransactionFee
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
// import State from './state'
|
|
201
|
-
|
|
202
|
-
class Machine {
|
|
203
|
-
#contracts = {}
|
|
204
|
-
#nonces = {}
|
|
205
|
-
constructor() {
|
|
206
|
-
return this.#init()
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
#createMessage(sender = peernet.id) {
|
|
210
|
-
return {
|
|
211
|
-
sender,
|
|
212
|
-
call: this.execute,
|
|
213
|
-
staticCall: this.get.bind(this)
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
async #init() {
|
|
218
|
-
// return
|
|
219
|
-
try {
|
|
220
|
-
let contracts = [
|
|
221
|
-
contractStore.get(lib.contractFactory),
|
|
222
|
-
contractStore.get(lib.nativeToken),
|
|
223
|
-
contractStore.get(lib.validators),
|
|
224
|
-
contractStore.get(lib.nameService)
|
|
225
|
-
];
|
|
226
|
-
|
|
227
|
-
contracts = await Promise.all(contracts);
|
|
228
|
-
for (const contract of contracts) {
|
|
229
|
-
const message = new ContractMessage$1(new Uint8Array(contract.buffer, contract.buffer.byteOffset, contract.buffer.byteLength));
|
|
230
|
-
await this.#runContract(message);
|
|
231
|
-
}
|
|
232
|
-
} catch (e) {
|
|
233
|
-
console.log(e);
|
|
234
|
-
}
|
|
235
|
-
// const transactions = await transactionStore.get()
|
|
236
|
-
// console.log({transactions});
|
|
237
|
-
// for (const key of Object.keys(transactions)) {
|
|
238
|
-
// const message = new TransactionMessage(transactions[key])
|
|
239
|
-
// console.log({message});
|
|
240
|
-
// const {from, to, method, params} = message.decoded
|
|
241
|
-
// globalThis.msg = this.#createMessage(from)
|
|
242
|
-
//
|
|
243
|
-
// console.log({from, to, method, params});
|
|
244
|
-
// await this.execute(to, method, params)
|
|
245
|
-
// }
|
|
246
|
-
return this
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
async #runContract(contractMessage) {
|
|
250
|
-
const params = contractMessage.decoded.constructorParameters;
|
|
251
|
-
try {
|
|
252
|
-
|
|
253
|
-
const func = new Function(new TextDecoder().decode(contractMessage.decoded.contract));
|
|
254
|
-
const Contract = func();
|
|
255
|
-
|
|
256
|
-
globalThis.msg = this.#createMessage(contractMessage.decoded.creator);
|
|
257
|
-
// globalThis.msg = {sender: contractMessage.decoded.creator}
|
|
258
|
-
this.#contracts[contractMessage.hash] = new Contract(...params);
|
|
259
|
-
debug(`loaded contract: ${contractMessage.hash}`);
|
|
260
|
-
debug(`size: ${Math.round((contractMessage.encoded.length / 1024) * 100) / 100} kb`);
|
|
261
|
-
} catch (e) {
|
|
262
|
-
console.log(e);
|
|
263
|
-
console.warn(`removing contract ${contractMessage.hash}`);
|
|
264
|
-
await contractStore.delete(contractMessage.hash, contractMessage.encoded);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* @params {ContractMessage} - contractMessage
|
|
270
|
-
*/
|
|
271
|
-
async addContract(contractMessage) {
|
|
272
|
-
if (!await contractStore.has(contractMessage.hash)) {
|
|
273
|
-
await contractStore.put(contractMessage.hash, contractMessage.encoded);
|
|
274
|
-
await this.#runContract(contractMessage);
|
|
275
|
-
return contractMessage.hash
|
|
276
|
-
}
|
|
277
|
-
throw new Error('duplicate contract')
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
async execute(contract, method, params) {
|
|
281
|
-
try {
|
|
282
|
-
let result;
|
|
283
|
-
// don't execute the method on a proxy
|
|
284
|
-
if (this.#contracts[contract].fallback) {
|
|
285
|
-
result = this.#contracts[contract].fallback(method, params);
|
|
286
|
-
} else {
|
|
287
|
-
result = await this.#contracts[contract][method](...params);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// this.#state.put(result)
|
|
291
|
-
return result
|
|
292
|
-
} catch (e) {
|
|
293
|
-
throw e
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
addJob(contract, method, params, from, nonce) {
|
|
298
|
-
if (!this.#nonces[from]) this.#nonces[from] = nonce;
|
|
299
|
-
if (nonce === this.#nonces[from] + 1) return this.#contracts[contract][method](...params)
|
|
300
|
-
// return setTimeout(() => {
|
|
301
|
-
// return this.addJob(contract, method, params, from, nonce)
|
|
302
|
-
// }, 50)
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
get(contract, method, params) {
|
|
306
|
-
let result;
|
|
307
|
-
if (params?.length > 0) {
|
|
308
|
-
result = this.#contracts[contract][method](...params);
|
|
309
|
-
} else {
|
|
310
|
-
result = this.#contracts[contract][method];
|
|
311
|
-
}
|
|
312
|
-
return result
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
async delete(hash) {
|
|
316
|
-
return contractStore.delete(hash)
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
async deleteAll() {
|
|
320
|
-
let hashes = await contractStore.get();
|
|
321
|
-
hashes = Object.keys(hashes).map(hash => this.delete(hash));
|
|
322
|
-
return Promise.all(hashes)
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
globalThis.BigNumber = bignumber.BigNumber;
|
|
327
|
-
|
|
328
|
-
const { ContractMessage, TransactionMessage, BlockMessage, BWMessage, BWRequestMessage } = lib;
|
|
329
|
-
// check if browser or local
|
|
330
|
-
class Chain {
|
|
331
|
-
#validators = []
|
|
332
|
-
#blocks = []
|
|
333
|
-
#machine
|
|
334
|
-
#runningEpoch = false
|
|
335
|
-
#lastBlock = {index: 0, previousHash: '0x0'}
|
|
336
|
-
|
|
337
|
-
constructor() {
|
|
338
|
-
return this.#init()
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
get lib() {
|
|
342
|
-
return lib
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
get lastBlock() {
|
|
346
|
-
return this.#lastBlock
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
get nativeToken() {
|
|
350
|
-
return lib.nativeToken
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
get validators() {
|
|
354
|
-
return [...this.#validators]
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
get blocks() {
|
|
358
|
-
return [...this.#blocks]
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
async hasTransactionToHandle() {
|
|
362
|
-
const size = await transactionPoolStore.size();
|
|
363
|
-
if (size > 0) return true
|
|
364
|
-
return false
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
async #runEpoch() {
|
|
368
|
-
const validators = await this.staticCall(lib.validators, 'validators');
|
|
369
|
-
if (!validators[peernet.id]?.active) return
|
|
370
|
-
|
|
371
|
-
this.#runningEpoch = true;
|
|
372
|
-
const start = new Date().getTime();
|
|
373
|
-
await this.#createBlock();
|
|
374
|
-
const end = new Date().getTime();
|
|
375
|
-
console.log((end - start) / 1000 + ' s');
|
|
376
|
-
if (await this.hasTransactionToHandle()) return this.#runEpoch()
|
|
377
|
-
this.#runningEpoch = false;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
async #setup() {
|
|
381
|
-
await contractStore.put(lib.contractFactory, lib.contractFactoryMessage);
|
|
382
|
-
await contractStore.put(lib.nativeToken, lib.nativeTokenMessage);
|
|
383
|
-
await contractStore.put(lib.validators, lib.validatorsMessage);
|
|
384
|
-
await contractStore.put(lib.nameService, lib.nameServiceMessage);
|
|
385
|
-
console.log('handle native contracts');
|
|
386
|
-
// handle native contracts
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
async #sync() {
|
|
390
|
-
let promises = [];
|
|
391
|
-
for (const peer of peernet.connections) {
|
|
392
|
-
if (peer.peerId !== this.id) {
|
|
393
|
-
let data = new peernet.protos['peernet-request']({request: 'lastBlock'});
|
|
394
|
-
|
|
395
|
-
const node = await peernet.prepareMessage(id, data.encoded);
|
|
396
|
-
promises.push(peer.request(node.encoded));
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
// if (this.)
|
|
400
|
-
|
|
401
|
-
promises = await Promise.allSettled(promises);
|
|
402
|
-
promises = promises.reduce((set, c) => {
|
|
403
|
-
console.log({c});
|
|
404
|
-
if (c.index > set.index) {
|
|
405
|
-
set.index = c.index;
|
|
406
|
-
set.hash = c.hash;
|
|
407
|
-
}
|
|
408
|
-
return set
|
|
409
|
-
}, {index: 0, hash: '0x0'});
|
|
410
|
-
// get lastblock
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
async #init() {
|
|
414
|
-
// this.node = await new Node()
|
|
415
|
-
this.participants = [];
|
|
416
|
-
const initialized = await contractStore.has(lib.contractFactory);
|
|
417
|
-
if (!initialized) await this.#setup();
|
|
418
|
-
|
|
419
|
-
this.#machine = await new Machine();
|
|
420
|
-
this.utils = { BigNumber: bignumber.BigNumber, formatUnits: units.formatUnits, parseUnits: units.parseUnits };
|
|
421
|
-
|
|
422
|
-
try {
|
|
423
|
-
let localBlock = await chainStore.get('lastBlock');
|
|
424
|
-
localBlock = await peernet.get(new TextDecoder().decode(localBlock));
|
|
425
|
-
localBlock = new BlockMessage(localBlock);
|
|
426
|
-
this.#lastBlock = {...localBlock.decoded, hash: localBlock.hash};
|
|
427
|
-
// console.log(this.lastBlock.decoded.transactions);
|
|
428
|
-
} catch (e) {
|
|
429
|
-
await this.#sync();
|
|
430
|
-
// this.#setup()
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
await peernet.addRequestHandler('bw-request-message', () => {
|
|
434
|
-
|
|
435
|
-
return new BWMessage(peernet.client.bw) || { up: 0, down: 0 }
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
await peernet.addRequestHandler('lastBlock', this.#lastBlockHandler.bind(this));
|
|
439
|
-
|
|
440
|
-
peernet.subscribe('add-block', this.#addBlock.bind(this));
|
|
441
|
-
|
|
442
|
-
peernet.subscribe('add-transaction', async transaction => {
|
|
443
|
-
try {
|
|
444
|
-
transaction = new TransactionMessage(transaction);
|
|
445
|
-
await transactionPoolStore.put(transaction.hash, transaction.encoded);
|
|
446
|
-
if (await this.hasTransactionToHandle() && !this.#runningEpoch) return this.#runEpoch()
|
|
447
|
-
} catch (e) {
|
|
448
|
-
throw Error('invalid transaction')
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
pubsub.subscribe('peer:connected', this.#peerConnected.bind(this));
|
|
453
|
-
|
|
454
|
-
// load local blocks
|
|
455
|
-
await this.resolveBlocks();
|
|
456
|
-
return this
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
async #peerConnected(peer) {
|
|
460
|
-
let node = new peernet.protos['peernet-request']({request: 'lastBlock'});
|
|
461
|
-
node = await peernet.prepareMessage(peer.id, node.encoded);
|
|
462
|
-
let response = await peer.request(node.encoded);
|
|
463
|
-
response = new Uint8Array(Object.values(response));
|
|
464
|
-
const proto = new globalThis.peernet.protos['peernet-message'](response);
|
|
465
|
-
response = new globalThis.peernet.protos['peernet-response'](proto.decoded.data);
|
|
466
|
-
let lastBlock = JSON.parse(new TextDecoder().decode(response.decoded.response));
|
|
467
|
-
|
|
468
|
-
if (!this.lastBlock || this.lastBlock.index < lastBlock.index) {
|
|
469
|
-
// TODO: check if valid
|
|
470
|
-
const localIndex = this.lastBlock ? this.lastBlock.index : 0;
|
|
471
|
-
const index = lastBlock.index;
|
|
472
|
-
await this.resolveBlock(lastBlock.hash);
|
|
473
|
-
this.#lastBlock = this.#blocks[this.#blocks.length - 1];
|
|
474
|
-
console.log({lastBlock: this.#lastBlock});
|
|
475
|
-
console.log(this.#blocks);
|
|
476
|
-
let blocksSynced = localIndex > 0 ? localIndex - index : index;
|
|
477
|
-
blocksSynced += 1;
|
|
478
|
-
debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
|
|
479
|
-
|
|
480
|
-
this.#blocks.length;
|
|
481
|
-
(this.#blocks.length) - blocksSynced;
|
|
482
|
-
await this.#loadBlocks(this.#blocks);
|
|
483
|
-
const message = new BlockMessage(this.lastBlock);
|
|
484
|
-
await blockStore.put(message.hash, message.encoded);
|
|
485
|
-
await chainStore.put('lastBlock', new TextEncoder().encode(this.lastBlock.hash));
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
async #lastBlockHandler() {
|
|
490
|
-
return new peernet.protos['peernet-response']({response: new TextEncoder().encode(JSON.stringify({ hash: this.lastBlock?.hash, index: this.lastBlock?.index }))})
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
async resolveBlock(hash) {
|
|
494
|
-
let block = await peernet.get(hash, 'block');
|
|
495
|
-
if (!await peernet.has(hash, 'block')) await peernet.put(hash, block, 'block');
|
|
496
|
-
block = await new BlockMessage(block);
|
|
497
|
-
const size = block.encoded.length || block.encoded.byteLength;
|
|
498
|
-
block = {...block.decoded, hash};
|
|
499
|
-
this.#blocks[block.index] = block;
|
|
500
|
-
console.log(`loaded block: ${hash} @${block.index} ${Math.round((size / 1024 / 1024) * 100) / 100} mb`);
|
|
501
|
-
if (block.index !== 0) {
|
|
502
|
-
return this.resolveBlock(block.previousHash)
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
async resolveBlocks() {
|
|
507
|
-
try {
|
|
508
|
-
|
|
509
|
-
const localBlock = await chainStore.get('lastBlock');
|
|
510
|
-
const hash = new TextDecoder().decode(localBlock);
|
|
511
|
-
if (hash !== '0x0')
|
|
512
|
-
await this.resolveBlock(new TextDecoder().decode(localBlock));
|
|
513
|
-
this.#lastBlock = this.#blocks[this.#blocks.length - 1];
|
|
514
|
-
await this.#loadBlocks(this.#blocks);
|
|
515
|
-
} catch (e) {
|
|
516
|
-
await chainStore.put('lastBlock', new TextEncoder().encode('0x0'));
|
|
517
|
-
return this.resolveBlocks()
|
|
518
|
-
// console.log(e);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
async #loadBlocks(blocks) {
|
|
523
|
-
for (const block of blocks) {
|
|
524
|
-
if (!block.loaded) {
|
|
525
|
-
for (const transaction of block.transactions) {
|
|
526
|
-
try {
|
|
527
|
-
await this.#machine.execute(transaction.to, transaction.method, transaction.params);
|
|
528
|
-
|
|
529
|
-
} catch (e) {
|
|
530
|
-
console.log(e);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
block.loaded = true;
|
|
534
|
-
// let message = await peernet.get(block.hash, 'block')
|
|
535
|
-
|
|
536
|
-
// const compressed = pako.deflate(message);
|
|
537
|
-
// const result = pako.inflate(compressed);
|
|
538
|
-
// console.log(result.length, compressed.length);
|
|
539
|
-
//
|
|
540
|
-
// console.log(result.length - compressed.length);
|
|
541
|
-
|
|
542
|
-
// message = new BlockMessage(message)
|
|
543
|
-
// for (const transaction of message.decoded.transactions) {
|
|
544
|
-
// try {
|
|
545
|
-
// await this.#machine.execute(transaction.to, transaction.method, transaction.params)
|
|
546
|
-
//
|
|
547
|
-
// } catch (e) {
|
|
548
|
-
// // console.log(e);
|
|
549
|
-
// }
|
|
550
|
-
// }
|
|
551
|
-
// block.loaded = true
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
async #executeTransaction({hash, from, to, method, params, nonce}) {
|
|
557
|
-
try {
|
|
558
|
-
let result = await this.#machine.execute(to, method, params, from, nonce);
|
|
559
|
-
// if (!result) result = this.#machine.state
|
|
560
|
-
pubsub.publish(`transaction.completed.${hash}`, {status: 'fulfilled', hash});
|
|
561
|
-
return result ? result : 'no state change'
|
|
562
|
-
} catch (e) {
|
|
563
|
-
pubsub.publish(`transaction.completed.${hash}`, {status: 'fail', hash, error: e});
|
|
564
|
-
throw e
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
async #addBlock(block) {
|
|
569
|
-
const blockMessage = new BlockMessage(block);
|
|
570
|
-
// if (!Buffer.isBuffer(block)) block = Buffer.from(block, 'hex')
|
|
571
|
-
// const transactionJob = async transaction => {
|
|
572
|
-
// try {
|
|
573
|
-
// transaction = await transactionPoolStore.get(transaction)
|
|
574
|
-
// } catch (e) {
|
|
575
|
-
// try {
|
|
576
|
-
// transaction = await peernet.get(transaction, 'transaction')
|
|
577
|
-
// } catch (e) {
|
|
578
|
-
// console.warn(`couldn't resolve ${transaction}`);
|
|
579
|
-
// }
|
|
580
|
-
// }
|
|
581
|
-
// transaction = new TransactionMessage(transaction)
|
|
582
|
-
// return transaction
|
|
583
|
-
// }
|
|
584
|
-
await Promise.all(blockMessage.decoded.transactions
|
|
585
|
-
.map(transaction => transactionPoolStore.delete(transaction.hash)));
|
|
586
|
-
|
|
587
|
-
// let transactions = blockMessage.decoded.transactions.map(tx => transactionJob(tx))
|
|
588
|
-
// transactions = await Promise.all(transactions)
|
|
589
|
-
this.#lastBlock = {hash: blockMessage.hash, ...blockMessage.decoded};
|
|
590
|
-
await blockStore.put(blockMessage.hash, blockMessage.encoded);
|
|
591
|
-
await chainStore.put('lastBlock', new TextEncoder().encode(blockMessage.hash));
|
|
592
|
-
debug(`added block: ${blockMessage.hash}`);
|
|
593
|
-
let promises = [];
|
|
594
|
-
let contracts = [];
|
|
595
|
-
for (let transaction of blockMessage.decoded.transactions) {
|
|
596
|
-
// await transactionStore.put(transaction.hash, transaction.encoded)
|
|
597
|
-
const index = contracts.indexOf(transaction.to);
|
|
598
|
-
if (index === -1) contracts.push(transaction.to);
|
|
599
|
-
promises.push(this.#executeTransaction(transaction));
|
|
600
|
-
}
|
|
601
|
-
try {
|
|
602
|
-
promises = await Promise.allSettled(promises);
|
|
603
|
-
|
|
604
|
-
// todo finish state
|
|
605
|
-
// for (const contract of contracts) {
|
|
606
|
-
// const state = await this.#machine.get(contract, 'state')
|
|
607
|
-
// // await stateStore.put(contract, state)
|
|
608
|
-
// console.log(state);
|
|
609
|
-
// }
|
|
610
|
-
pubsub.publish('block-processed', blockMessage.decoded);
|
|
611
|
-
} catch (e) {
|
|
612
|
-
console.log(e);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
async participate() {
|
|
620
|
-
// TODO: validate participant
|
|
621
|
-
// hold min amount of 50k ART for 7 days
|
|
622
|
-
// lock the 50k
|
|
623
|
-
// introduce peer-reputation
|
|
624
|
-
// peerReputation(peerId)
|
|
625
|
-
// {bandwith: {up, down}, uptime}
|
|
626
|
-
if (!await this.staticCall(lib.validators, 'has', [peernet.id])) await this.createTransactionFrom(peernet.id, lib.validators, 'addValidator', [peernet.id]);
|
|
627
|
-
if (await this.hasTransactionToHandle() && !this.#runningEpoch) return this.#runEpoch()
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
calculateFee(transaction) {
|
|
631
|
-
// excluded from fees
|
|
632
|
-
if (transaction.decoded.to === lib.validators) return 0
|
|
633
|
-
// fee per gb
|
|
634
|
-
return (transaction.encoded.length / 1024) / 1e-6
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
async #createBlock() {
|
|
638
|
-
let transactions = await transactionPoolStore.get();
|
|
639
|
-
|
|
640
|
-
if (Object.keys(transactions)?.length === 0 ) return
|
|
641
|
-
let block = {
|
|
642
|
-
transactions: [],
|
|
643
|
-
validators: [],
|
|
644
|
-
fees: 0
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
let _transactions = [];
|
|
648
|
-
|
|
649
|
-
// exclude failing tx
|
|
650
|
-
for (let transaction of Object.values(transactions)) {
|
|
651
|
-
transaction = new TransactionMessage(new Uint8Array(transaction, transaction.byteOffset, transaction.byteLength));
|
|
652
|
-
|
|
653
|
-
block.fees += Number(lib.calculateFee(transaction));
|
|
654
|
-
_transactions.push({...transaction.decoded, hash: transaction.hash });
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
transactions = _transactions.sort((a, b) => a.nonce - b.nonce);
|
|
658
|
-
_transactions = [];
|
|
659
|
-
for (let transaction of transactions) {
|
|
660
|
-
try {
|
|
661
|
-
await this.#executeTransaction(transaction);
|
|
662
|
-
_transactions.push(transaction);
|
|
663
|
-
} catch (e) {
|
|
664
|
-
transaction = new TransactionMessage(transaction);
|
|
665
|
-
block.fees -= Number(lib.calculateFee(transaction));
|
|
666
|
-
await transactionPoolStore.delete(transaction.hash);
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
transactions = _transactions;
|
|
671
|
-
// don't add empty block
|
|
672
|
-
if (transactions.length === 0) return
|
|
673
|
-
|
|
674
|
-
block.transactions = transactions;
|
|
675
|
-
const validators = await this.staticCall(lib.validators, 'validators');
|
|
676
|
-
console.log({validators});
|
|
677
|
-
// block.validators = Object.keys(block.validators).reduce((set, key) => {
|
|
678
|
-
// if (block.validators[key].active) {
|
|
679
|
-
// push({
|
|
680
|
-
// address: key
|
|
681
|
-
// })
|
|
682
|
-
// }
|
|
683
|
-
// }, [])
|
|
684
|
-
const peers = {};
|
|
685
|
-
for (const entry of peernet.peerEntries) {
|
|
686
|
-
peers[entry[0]] = entry[1];
|
|
687
|
-
}
|
|
688
|
-
for (const validator of Object.keys(validators)) {
|
|
689
|
-
if (validators[validator].active) {
|
|
690
|
-
const peer = peers[validator];
|
|
691
|
-
if (peer && peer.connected) {
|
|
692
|
-
let data = new BWRequestMessage();
|
|
693
|
-
const node = await peernet.prepareMessage(validator, data.encoded);
|
|
694
|
-
try {
|
|
695
|
-
const bw = await peer.request(node.encoded);
|
|
696
|
-
console.log(bw);
|
|
697
|
-
block.validators.push({
|
|
698
|
-
address: validator,
|
|
699
|
-
bw: bw.up + bw.down
|
|
700
|
-
});
|
|
701
|
-
} catch(e) {
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
} else if (peernet.id === validator) {
|
|
706
|
-
block.validators.push({
|
|
707
|
-
address: peernet.id,
|
|
708
|
-
bw: peernet.bw.up + peernet.bw.down
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
console.log(block.validators);
|
|
717
|
-
|
|
718
|
-
block.reward = 150;
|
|
719
|
-
block.validators = block.validators.map(validator => {
|
|
720
|
-
validator.reward = String(Number(block.fees) + block.reward / block.validators.length);
|
|
721
|
-
delete validator.bw;
|
|
722
|
-
return validator
|
|
723
|
-
});
|
|
724
|
-
// block.validators = lib.calculateValidatorReward(block.validators, block.fees)
|
|
725
|
-
|
|
726
|
-
block.index = this.lastBlock?.index;
|
|
727
|
-
if (block.index === undefined) block.index = 0;
|
|
728
|
-
else block.index += 1;
|
|
729
|
-
|
|
730
|
-
block.previousHash = this.lastBlock?.hash || '0x0';
|
|
731
|
-
block.timestamp = new Date().getTime();
|
|
732
|
-
|
|
733
|
-
const parts = String(block.fees).split('.');
|
|
734
|
-
let decimals = 0;
|
|
735
|
-
if (parts[1]) {
|
|
736
|
-
const potentional = parts[1].split('e');
|
|
737
|
-
if (potentional[0] !== parts[1]) {
|
|
738
|
-
parts[1] = potentional[0];
|
|
739
|
-
decimals = Number(potentional[1]?.replace(/\-|\+/g, '')) + Number(potentional[0].length);
|
|
740
|
-
} else {
|
|
741
|
-
decimals = parts[1].length;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
block.fees = Number.parseFloat(String(block.fees)).toFixed(decimals);
|
|
746
|
-
|
|
747
|
-
try {
|
|
748
|
-
let blockMessage = new BlockMessage(block);
|
|
749
|
-
this.#lastBlock = {...block, hash: blockMessage.hash};
|
|
750
|
-
peernet.publish('add-block', blockMessage.encoded);
|
|
751
|
-
this.#addBlock(blockMessage.encoded);
|
|
752
|
-
} catch (e) {
|
|
753
|
-
throw Error(`invalid block ${block}`)
|
|
754
|
-
}
|
|
755
|
-
// data = await this.#machine.execute(to, method, params)
|
|
756
|
-
// transactionStore.put(message.hash, message.encoded)
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
async getNonce(address) {
|
|
760
|
-
let transactions = await transactionPoolStore.get();
|
|
761
|
-
transactions = Object.keys(transactions).map(tx => new TransactionMessage(transactions[tx]));
|
|
762
|
-
transactions = transactions.filter(tx => tx.decoded.from === address);
|
|
763
|
-
transactions = transactions.map(tx => { return {...tx.decoded, hash: tx.hash} });
|
|
764
|
-
if (this.lastBlock && transactions.length === 0) {
|
|
765
|
-
let block = await peernet.get(this.lastBlock.hash);
|
|
766
|
-
block = new BlockMessage(block);
|
|
767
|
-
|
|
768
|
-
// for (let tx of block.decoded?.transactions) {
|
|
769
|
-
// tx = await peernet.get(tx, 'transaction')
|
|
770
|
-
// transactions.push(new TransactionMessage(tx))
|
|
771
|
-
// }
|
|
772
|
-
transactions = transactions.filter(tx => tx.from === address);
|
|
773
|
-
while (transactions.length === 0 && block.decoded.index !== 0) {
|
|
774
|
-
block = await blockStore.get(block.decoded.previousHash);
|
|
775
|
-
block = new BlockMessage(block);
|
|
776
|
-
transactions = block.decoded.transactions.filter(tx => tx.from === address);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
}
|
|
780
|
-
if (transactions.length === 0) return 0
|
|
781
|
-
|
|
782
|
-
transactions = transactions.sort((a, b) => a.timestamp - b.timestamp);
|
|
783
|
-
return transactions[transactions.length - 1].nonce
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
* whenever method = createContract params should hold the contract hash
|
|
788
|
-
*
|
|
789
|
-
* example: [hash]
|
|
790
|
-
* createTransaction('0x0', 'createContract', [hash])
|
|
791
|
-
*
|
|
792
|
-
* @param {String} to - the contract address for the contract to interact with
|
|
793
|
-
* @param {String} method - the method/function to run
|
|
794
|
-
* @param {Array} params - array of paramters to apply to the contract method
|
|
795
|
-
* @param {Number} nonce - total transaction count [optional]
|
|
796
|
-
*/
|
|
797
|
-
createTransaction(to, method, params, nonce) {
|
|
798
|
-
return this.createTransactionFrom(peernet.id, to, method, params, nonce)
|
|
799
|
-
}
|
|
800
|
-
/**
|
|
801
|
-
* every tx done is trough contracts so no need for amount
|
|
802
|
-
* data is undefined when nothing is returned
|
|
803
|
-
* error is thrown on error so undefined data doesn't mean there is an error...
|
|
804
|
-
*
|
|
805
|
-
* @param {String} from - the sender address
|
|
806
|
-
* @param {String} to - the contract address for the contract to interact with
|
|
807
|
-
* @param {String} method - the method/function to run
|
|
808
|
-
* @param {Array} params - array of paramters to apply to the contract method
|
|
809
|
-
* @param {Number} nonce - total transaction count [optional]
|
|
810
|
-
*/
|
|
811
|
-
async createTransactionFrom(from, to, method, params, nonce) {
|
|
812
|
-
if (nonce === undefined) {
|
|
813
|
-
nonce = await this.getNonce(from);
|
|
814
|
-
nonce += 1;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
let data;
|
|
818
|
-
let message = new TransactionMessage({timestamp: new Date().getTime(), from, to, nonce, method, params});
|
|
819
|
-
try {
|
|
820
|
-
// await transactionPoolStore.put(message.hash, new TextEncoder().encode(JSON.stringify({signature, message: message.encoded})))
|
|
821
|
-
await transactionPoolStore.put(message.hash, message.encoded);
|
|
822
|
-
peernet.publish('add-transaction', message.encoded);
|
|
823
|
-
} catch (e) {
|
|
824
|
-
throw e
|
|
825
|
-
}
|
|
826
|
-
const wait = () => new Promise((resolve, reject) => {
|
|
827
|
-
const completed = result => {
|
|
828
|
-
result.status === 'fulfilled' ? resolve(result.hash) : reject({hash: result.hash, error: result.error});
|
|
829
|
-
|
|
830
|
-
pubsub.unsubscribe(`transaction.completed.${message.hash}`, completed);
|
|
831
|
-
};
|
|
832
|
-
pubsub.subscribe(`transaction.completed.${message.hash}`, completed);
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
if (await this.hasTransactionToHandle() && !this.#runningEpoch) this.#runEpoch();
|
|
836
|
-
return {hash: message.hash, data, fee: lib.calculateFee(message), wait}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
async createContractMessage(creator, contract, constructorParameters = []) {
|
|
840
|
-
return new ContractMessage({
|
|
841
|
-
creator,
|
|
842
|
-
contract,
|
|
843
|
-
constructorParameters
|
|
844
|
-
})
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
async createContractAddress(creator, contract, constructorParameters = []) {
|
|
848
|
-
return this.createContractMessage(creator, contract, constructorParameters)
|
|
849
|
-
.hash
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
*
|
|
854
|
-
* @param {String} contract - a contract string (see plugins/deployContract)
|
|
855
|
-
*/
|
|
856
|
-
async deployContract(contract, params = []) {
|
|
857
|
-
globalThis.msg = {sender: peernet.id, call: this.call};
|
|
858
|
-
|
|
859
|
-
const hash = await this.createContractAddress(creator, contract, params);
|
|
860
|
-
|
|
861
|
-
try {
|
|
862
|
-
const tx = await this.createTransactionFrom(peernet.id, lib.contractFactory, 'deployContract', [hash, creator, contract, constructorParameters]);
|
|
863
|
-
} catch (e) {
|
|
864
|
-
throw e
|
|
865
|
-
}
|
|
866
|
-
return this.#machine.addContract(message)
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
#createMessage(sender = peernet.id) {
|
|
870
|
-
return {
|
|
871
|
-
sender: peernet.id,
|
|
872
|
-
call: this.call,
|
|
873
|
-
staticCall: this.staticCall,
|
|
874
|
-
delegate: this.delegate,
|
|
875
|
-
staticDelegate: this.staticDelegate
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
internalCall(sender, contract, method, params) {
|
|
880
|
-
globalThis.msg = this.#createMessage(sender);
|
|
881
|
-
|
|
882
|
-
return this.#machine.execute(contract, method, params)
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
call(contract, method, params) {
|
|
886
|
-
globalThis.msg = this.#createMessage();
|
|
887
|
-
|
|
888
|
-
return this.#machine.execute(contract, method, params)
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
staticCall(contract, method, params) {
|
|
892
|
-
globalThis.msg = this.#createMessage();
|
|
893
|
-
return this.#machine.get(contract, method, params)
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
delegate(contract, method, params) {
|
|
897
|
-
globalThis.msg = this.#createMessage();
|
|
898
|
-
|
|
899
|
-
return this.#machine.execute(contract, method, params)
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
staticDelegate(contract, method, params) {
|
|
903
|
-
globalThis.msg = this.#createMessage();
|
|
904
|
-
|
|
905
|
-
return this.#machine.get(contract, method, params)
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
mint(to, amount) {
|
|
909
|
-
return this.call(lib.nativeToken, 'mint', [to, amount])
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
transfer(from, to, amount) {
|
|
913
|
-
return this.call(lib.nativeToken, 'transfer', [from, to, amount])
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
get balances() {
|
|
917
|
-
return this.staticCall(lib.nativeToken, 'balances')
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
deleteAll() {
|
|
921
|
-
return this.#machine.deleteAll()
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
* lookup an address for a registered name using the builtin nameService
|
|
926
|
-
* @check nameService
|
|
927
|
-
*
|
|
928
|
-
* @param {String} - contractName
|
|
929
|
-
* @returns {String} - address
|
|
930
|
-
*
|
|
931
|
-
* @example chain.lookup('myCoolContractName') // qmqsfddfdgfg...
|
|
932
|
-
*/
|
|
933
|
-
lookup(name) {
|
|
934
|
-
return this.call(lib.nameService, 'lookup', [name])
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
module.exports = Chain;
|