@xelis/sdk 0.11.14 → 0.11.16

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 (51) hide show
  1. package/dist/cjs/address/bech32.js +47 -56
  2. package/dist/cjs/address/index.js +20 -21
  3. package/dist/cjs/config.js +26 -38
  4. package/dist/cjs/contract/contract.js +178 -0
  5. package/dist/cjs/contract/typed_contract.js +259 -0
  6. package/dist/cjs/contract/xvm_serializer.js +170 -0
  7. package/dist/cjs/daemon/rpc.js +157 -168
  8. package/dist/cjs/daemon/types.js +4 -1
  9. package/dist/cjs/daemon/websocket.js +170 -181
  10. package/dist/cjs/data/element.js +39 -41
  11. package/dist/cjs/data/value.js +106 -111
  12. package/dist/cjs/react/daemon.js +33 -43
  13. package/dist/cjs/rpc/http.js +75 -132
  14. package/dist/cjs/rpc/parse_json/parse_json.js +4 -4
  15. package/dist/cjs/rpc/types.js +1 -1
  16. package/dist/cjs/rpc/websocket.js +131 -201
  17. package/dist/cjs/wallet/rpc.js +98 -117
  18. package/dist/cjs/wallet/types.js +1 -1
  19. package/dist/cjs/wallet/websocket.js +105 -126
  20. package/dist/cjs/xswd/relayer/app.js +57 -36
  21. package/dist/cjs/xswd/relayer/index.js +25 -27
  22. package/dist/cjs/xswd/types.js +1 -1
  23. package/dist/cjs/xswd/websocket.js +15 -33
  24. package/dist/esm/address/bech32.js +46 -55
  25. package/dist/esm/address/index.js +16 -17
  26. package/dist/esm/config.js +25 -37
  27. package/dist/esm/contract/contract.js +172 -0
  28. package/dist/esm/contract/typed_contract.js +251 -0
  29. package/dist/esm/contract/xvm_serializer.js +163 -0
  30. package/dist/esm/daemon/rpc.js +153 -165
  31. package/dist/esm/daemon/types.js +3 -0
  32. package/dist/esm/daemon/websocket.js +166 -179
  33. package/dist/esm/data/element.js +37 -40
  34. package/dist/esm/data/value.js +104 -112
  35. package/dist/esm/react/daemon.js +30 -40
  36. package/dist/esm/rpc/http.js +73 -131
  37. package/dist/esm/rpc/parse_json/parse_json.js +1 -1
  38. package/dist/esm/rpc/websocket.js +126 -197
  39. package/dist/esm/wallet/rpc.js +93 -113
  40. package/dist/esm/wallet/websocket.js +101 -124
  41. package/dist/esm/xswd/relayer/app.js +54 -34
  42. package/dist/esm/xswd/relayer/index.js +22 -24
  43. package/dist/esm/xswd/websocket.js +10 -29
  44. package/dist/types/contract/contract.d.ts +80 -0
  45. package/dist/types/contract/typed_contract.d.ts +94 -0
  46. package/dist/types/contract/xvm_serializer.d.ts +69 -0
  47. package/dist/types/daemon/rpc.d.ts +5 -2
  48. package/dist/types/daemon/types.d.ts +99 -20
  49. package/dist/types/daemon/websocket.d.ts +5 -2
  50. package/dist/types/wallet/types.d.ts +1 -1
  51. package/package.json +1 -1
@@ -1,253 +1,242 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.WS = exports.DaemonMethods = void 0;
19
- var types_1 = require("./types");
20
- var websocket_1 = require("../rpc/websocket");
21
- var DaemonMethods = /** @class */ (function () {
22
- function DaemonMethods(ws, prefix) {
23
- if (prefix === void 0) { prefix = ""; }
4
+ const types_1 = require("./types");
5
+ const websocket_1 = require("../rpc/websocket");
6
+ class DaemonMethods {
7
+ constructor(ws, prefix = "") {
24
8
  this.ws = ws;
25
9
  this.prefix = prefix;
26
10
  }
27
- DaemonMethods.prototype.dataCall = function (method, params) {
11
+ dataCall(method, params) {
28
12
  return this.ws.dataCall(this.prefix + method, params);
29
- };
30
- DaemonMethods.prototype.closeListener = function (event, listener) {
13
+ }
14
+ closeListener(event, listener) {
31
15
  this.ws.closeListener(event, listener);
32
- };
33
- DaemonMethods.prototype.listen = function (event, listener) {
16
+ }
17
+ listen(event, listener) {
34
18
  this.ws.listen(this.prefix + event, listener);
35
- };
36
- DaemonMethods.prototype.getVersion = function () {
19
+ }
20
+ getVersion() {
37
21
  return this.dataCall(types_1.RPCMethod.GetVersion);
38
- };
39
- DaemonMethods.prototype.getHeight = function () {
22
+ }
23
+ getHeight() {
40
24
  return this.dataCall(types_1.RPCMethod.GetHeight);
41
- };
42
- DaemonMethods.prototype.getTopoheight = function () {
25
+ }
26
+ getTopoheight() {
43
27
  return this.dataCall(types_1.RPCMethod.GetTopoheight);
44
- };
45
- DaemonMethods.prototype.getPrunedTopoheight = function () {
28
+ }
29
+ getPrunedTopoheight() {
46
30
  return this.dataCall(types_1.RPCMethod.GetPrunedTopoheight);
47
- };
48
- DaemonMethods.prototype.getInfo = function () {
31
+ }
32
+ getInfo() {
49
33
  return this.dataCall(types_1.RPCMethod.GetInfo);
50
- };
51
- DaemonMethods.prototype.getDifficulty = function () {
34
+ }
35
+ getDifficulty() {
52
36
  return this.dataCall(types_1.RPCMethod.GetDifficulty);
53
- };
54
- DaemonMethods.prototype.getTips = function () {
37
+ }
38
+ getTips() {
55
39
  return this.dataCall(types_1.RPCMethod.GetTips);
56
- };
57
- DaemonMethods.prototype.getDevFeeThresholds = function () {
40
+ }
41
+ getDevFeeThresholds() {
58
42
  return this.dataCall(types_1.RPCMethod.GetDevFeeThresholds);
59
- };
60
- DaemonMethods.prototype.getSizeOnDisk = function () {
43
+ }
44
+ getSizeOnDisk() {
61
45
  return this.dataCall(types_1.RPCMethod.GetSizeOnDisk);
62
- };
63
- DaemonMethods.prototype.getStableHeight = function () {
46
+ }
47
+ getStableHeight() {
64
48
  return this.dataCall(types_1.RPCMethod.GetStableHeight);
65
- };
66
- DaemonMethods.prototype.getStableTopoheight = function () {
49
+ }
50
+ getStableTopoheight() {
67
51
  return this.dataCall(types_1.RPCMethod.GetStableTopoheight);
68
- };
69
- DaemonMethods.prototype.getHardForks = function () {
52
+ }
53
+ getHardForks() {
70
54
  return this.dataCall(types_1.RPCMethod.GetHardForks);
71
- };
72
- DaemonMethods.prototype.getBlockAtTopoheight = function (params) {
55
+ }
56
+ getBlockAtTopoheight(params) {
73
57
  return this.dataCall(types_1.RPCMethod.GetBlockAtTopoheight, params);
74
- };
75
- DaemonMethods.prototype.getBlocksAtHeight = function (params) {
58
+ }
59
+ getBlocksAtHeight(params) {
76
60
  return this.dataCall(types_1.RPCMethod.GetBlocksAtHeight, params);
77
- };
78
- DaemonMethods.prototype.getBlockByHash = function (params) {
61
+ }
62
+ getBlockByHash(params) {
79
63
  return this.dataCall(types_1.RPCMethod.GetBlockByHash, params);
80
- };
81
- DaemonMethods.prototype.getTopBlock = function (params) {
64
+ }
65
+ getTopBlock(params) {
82
66
  return this.dataCall(types_1.RPCMethod.GetTopBlock, params);
83
- };
84
- DaemonMethods.prototype.getBalance = function (params) {
67
+ }
68
+ getBalance(params) {
85
69
  return this.dataCall(types_1.RPCMethod.GetBalance, params);
86
- };
87
- DaemonMethods.prototype.getStableBalance = function (params) {
70
+ }
71
+ getStableBalance(params) {
88
72
  return this.dataCall(types_1.RPCMethod.GetStableBalance, params);
89
- };
90
- DaemonMethods.prototype.hasBalance = function (params) {
73
+ }
74
+ hasBalance(params) {
91
75
  return this.dataCall(types_1.RPCMethod.HasBalance, params);
92
- };
93
- DaemonMethods.prototype.getBalanceAtTopoheight = function (params) {
76
+ }
77
+ getBalanceAtTopoheight(params) {
94
78
  return this.dataCall(types_1.RPCMethod.GetBalanceAtTopoheight, params);
95
- };
96
- DaemonMethods.prototype.getNonce = function (params) {
79
+ }
80
+ getNonce(params) {
97
81
  return this.dataCall(types_1.RPCMethod.GetNonce, params);
98
- };
99
- DaemonMethods.prototype.hasNonce = function (params) {
82
+ }
83
+ hasNonce(params) {
100
84
  return this.dataCall(types_1.RPCMethod.HasNonce, params);
101
- };
102
- DaemonMethods.prototype.getNonceAtTopoheight = function (params) {
85
+ }
86
+ getNonceAtTopoheight(params) {
103
87
  return this.dataCall(types_1.RPCMethod.GetNonceAtTopoheight, params);
104
- };
105
- DaemonMethods.prototype.getAsset = function (params) {
88
+ }
89
+ getAsset(params) {
106
90
  return this.dataCall(types_1.RPCMethod.GetAsset, params);
107
- };
108
- DaemonMethods.prototype.getAssets = function (params) {
91
+ }
92
+ getAssets(params) {
109
93
  return this.dataCall(types_1.RPCMethod.GetAssets, params);
110
- };
111
- DaemonMethods.prototype.countAssets = function () {
94
+ }
95
+ countAssets() {
112
96
  return this.dataCall(types_1.RPCMethod.CountAssets);
113
- };
114
- DaemonMethods.prototype.countTransactions = function () {
97
+ }
98
+ countTransactions() {
115
99
  return this.dataCall(types_1.RPCMethod.CountTransactions);
116
- };
117
- DaemonMethods.prototype.countAccounts = function () {
100
+ }
101
+ countAccounts() {
118
102
  return this.dataCall(types_1.RPCMethod.CountAccounts);
119
- };
120
- DaemonMethods.prototype.countContracts = function () {
103
+ }
104
+ countContracts() {
121
105
  return this.dataCall(types_1.RPCMethod.CountContracts);
122
- };
123
- DaemonMethods.prototype.submitTransaction = function (hexData) {
106
+ }
107
+ submitTransaction(hexData) {
124
108
  return this.dataCall(types_1.RPCMethod.SubmitTransaction, { data: hexData });
125
- };
126
- DaemonMethods.prototype.getTransactionExecutor = function (hash) {
127
- return this.dataCall(types_1.RPCMethod.GetTransactionExecutor, { hash: hash });
128
- };
129
- DaemonMethods.prototype.getTransaction = function (hash) {
130
- return this.dataCall(types_1.RPCMethod.GetTransaction, { hash: hash });
131
- };
132
- DaemonMethods.prototype.getTransactions = function (txHashes) {
109
+ }
110
+ getTransactionExecutor(hash) {
111
+ return this.dataCall(types_1.RPCMethod.GetTransactionExecutor, { hash });
112
+ }
113
+ getTransaction(hash) {
114
+ return this.dataCall(types_1.RPCMethod.GetTransaction, { hash });
115
+ }
116
+ getTransactions(txHashes) {
133
117
  return this.dataCall(types_1.RPCMethod.GetTransactions, { tx_hashes: txHashes });
134
- };
135
- DaemonMethods.prototype.isTxExecutedInBlock = function (params) {
118
+ }
119
+ isTxExecutedInBlock(params) {
136
120
  return this.dataCall(types_1.RPCMethod.IsTxExecutedInBlock, params);
137
- };
138
- DaemonMethods.prototype.p2pStatus = function () {
121
+ }
122
+ p2pStatus() {
139
123
  return this.dataCall(types_1.RPCMethod.P2PStatus);
140
- };
141
- DaemonMethods.prototype.getPeers = function () {
124
+ }
125
+ getPeers() {
142
126
  return this.dataCall(types_1.RPCMethod.GetPeers);
143
- };
144
- DaemonMethods.prototype.getMemPool = function (params) {
127
+ }
128
+ getMemPool(params) {
145
129
  return this.dataCall(types_1.RPCMethod.GetMempool, params);
146
- };
147
- DaemonMethods.prototype.getMempoolSummary = function (params) {
130
+ }
131
+ getMempoolSummary(params) {
148
132
  return this.dataCall(types_1.RPCMethod.GetMempoolSummary, params);
149
- };
150
- DaemonMethods.prototype.getMempoolCache = function (address) {
151
- return this.dataCall(types_1.RPCMethod.GetMempoolCache, { address: address });
152
- };
153
- DaemonMethods.prototype.getEstimatedFeeRates = function () {
133
+ }
134
+ getMempoolCache(address) {
135
+ return this.dataCall(types_1.RPCMethod.GetMempoolCache, { address });
136
+ }
137
+ getEstimatedFeeRates() {
154
138
  return this.dataCall(types_1.RPCMethod.GetEstimatedFeeRates);
155
- };
156
- DaemonMethods.prototype.getDAGOrder = function (params) {
139
+ }
140
+ getDAGOrder(params) {
157
141
  return this.dataCall(types_1.RPCMethod.GetDAGOrder, params);
158
- };
159
- DaemonMethods.prototype.getBlocksRangeByTopoheight = function (params) {
142
+ }
143
+ getBlocksRangeByTopoheight(params) {
160
144
  return this.dataCall(types_1.RPCMethod.GetBlocksRangeByTopoheight, params);
161
- };
162
- DaemonMethods.prototype.getBlocksRangeByHeight = function (params) {
145
+ }
146
+ getBlocksRangeByHeight(params) {
163
147
  return this.dataCall(types_1.RPCMethod.GetBlocksRangeByHeight, params);
164
- };
165
- DaemonMethods.prototype.getAccountHistory = function (params) {
148
+ }
149
+ getAccountHistory(params) {
166
150
  return this.dataCall(types_1.RPCMethod.GetAccountHistory, params);
167
- };
168
- DaemonMethods.prototype.getAccountAssets = function (address) {
169
- return this.dataCall(types_1.RPCMethod.GetAccountAssets, { address: address });
170
- };
171
- DaemonMethods.prototype.getAccounts = function (params) {
151
+ }
152
+ getAccountAssets(address) {
153
+ return this.dataCall(types_1.RPCMethod.GetAccountAssets, { address });
154
+ }
155
+ getAccounts(params) {
172
156
  return this.dataCall(types_1.RPCMethod.GetAccounts, params);
173
- };
174
- DaemonMethods.prototype.isAccountRegistered = function (params) {
157
+ }
158
+ isAccountRegistered(params) {
175
159
  return this.dataCall(types_1.RPCMethod.IsAccountRegistered, params);
176
- };
177
- DaemonMethods.prototype.getAccountRegistrationTopoheight = function (address) {
178
- return this.dataCall(types_1.RPCMethod.GetAccountRegistrationTopoheight, { address: address });
179
- };
180
- DaemonMethods.prototype.validateAddress = function (params) {
160
+ }
161
+ getAccountRegistrationTopoheight(address) {
162
+ return this.dataCall(types_1.RPCMethod.GetAccountRegistrationTopoheight, { address });
163
+ }
164
+ validateAddress(params) {
181
165
  return this.dataCall(types_1.RPCMethod.ValidateAddress, params);
182
- };
183
- DaemonMethods.prototype.splitAddress = function (params) {
166
+ }
167
+ splitAddress(params) {
184
168
  return this.dataCall(types_1.RPCMethod.SplitAddress, params);
185
- };
186
- DaemonMethods.prototype.extractKeyFromAddress = function (params) {
169
+ }
170
+ extractKeyFromAddress(params) {
187
171
  return this.dataCall(types_1.RPCMethod.ExtractKeyFromAddress, params);
188
- };
189
- DaemonMethods.prototype.makeIntegratedAddress = function (params) {
172
+ }
173
+ makeIntegratedAddress(params) {
190
174
  return this.dataCall(types_1.RPCMethod.MakeIntegratedAddress, params);
191
- };
192
- DaemonMethods.prototype.decryptExtraData = function (params) {
175
+ }
176
+ decryptExtraData(params) {
193
177
  return this.dataCall(types_1.RPCMethod.DecryptExtraData, params);
194
- };
195
- DaemonMethods.prototype.getMultisigAtTopoheight = function (params) {
178
+ }
179
+ getMultisigAtTopoheight(params) {
196
180
  return this.dataCall(types_1.RPCMethod.GetMultisigAtTopoheight, params);
197
- };
198
- DaemonMethods.prototype.getMultisig = function (params) {
181
+ }
182
+ getMultisig(params) {
199
183
  return this.dataCall(types_1.RPCMethod.GetMultisig, params);
200
- };
201
- DaemonMethods.prototype.hasMultisig = function (params) {
184
+ }
185
+ hasMultisig(params) {
202
186
  return this.dataCall(types_1.RPCMethod.HasMultisig, params);
203
- };
204
- DaemonMethods.prototype.hasMultisigAtTopoheight = function (params) {
187
+ }
188
+ hasMultisigAtTopoheight(params) {
205
189
  return this.dataCall(types_1.RPCMethod.HasMultisigAtTopoheight, params);
206
- };
207
- DaemonMethods.prototype.getContractOutputs = function (params) {
190
+ }
191
+ getContractLogs(params) {
192
+ return this.dataCall(types_1.RPCMethod.GetContractLogs, params);
193
+ }
194
+ getContractScheduledExecutionsAtTopoheight(params) {
195
+ return this.dataCall(types_1.RPCMethod.GetContractScheduledExecutionsAtTopoheight, params);
196
+ }
197
+ getContractRegisteredExecutionsAtTopoheight(params) {
198
+ return this.dataCall(types_1.RPCMethod.GetContractRegisteredExecutionsAtTopoheight, params);
199
+ }
200
+ getContractOutputs(params) {
208
201
  return this.dataCall(types_1.RPCMethod.GetContractOutputs, params);
209
- };
210
- DaemonMethods.prototype.getContractModule = function (params) {
202
+ }
203
+ getContractModule(params) {
211
204
  return this.dataCall(types_1.RPCMethod.GetContractModule, params);
212
- };
213
- DaemonMethods.prototype.getContractData = function (params) {
205
+ }
206
+ getContractData(params) {
214
207
  return this.dataCall(types_1.RPCMethod.GetContractData, params);
215
- };
216
- DaemonMethods.prototype.getContractDataAtTopoheight = function (params) {
208
+ }
209
+ getContractDataAtTopoheight(params) {
217
210
  return this.dataCall(types_1.RPCMethod.GetContractDataAtTopoheight, params);
218
- };
219
- DaemonMethods.prototype.getContractBalance = function (params) {
211
+ }
212
+ getContractBalance(params) {
220
213
  return this.dataCall(types_1.RPCMethod.GetContractBalance, params);
221
- };
222
- DaemonMethods.prototype.getContractBalanceAtTopoheight = function (params) {
214
+ }
215
+ getContractBalanceAtTopoheight(params) {
223
216
  return this.dataCall(types_1.RPCMethod.GetContractBalanceAtTopoheight, params);
224
- };
225
- DaemonMethods.prototype.getContractAssets = function (params) {
217
+ }
218
+ getContractAssets(params) {
226
219
  return this.dataCall(types_1.RPCMethod.GetContractAssets, params);
227
- };
228
- DaemonMethods.prototype.getP2PBlockPropagation = function (params) {
220
+ }
221
+ getP2PBlockPropagation(params) {
229
222
  return this.dataCall(types_1.RPCMethod.GetP2PBlockPropagation, params);
230
- };
231
- DaemonMethods.prototype.getBlockTemplate = function (address) {
232
- return this.dataCall(types_1.RPCMethod.GetBlockTemplate, { address: address });
233
- };
234
- DaemonMethods.prototype.getMinerWork = function (params) {
223
+ }
224
+ getBlockTemplate(address) {
225
+ return this.dataCall(types_1.RPCMethod.GetBlockTemplate, { address });
226
+ }
227
+ getMinerWork(params) {
235
228
  return this.dataCall(types_1.RPCMethod.GetMinerWork, params);
236
- };
237
- DaemonMethods.prototype.submitBlock = function (params) {
229
+ }
230
+ submitBlock(params) {
238
231
  return this.dataCall(types_1.RPCMethod.SubmitBlock, params);
239
- };
240
- return DaemonMethods;
241
- }());
232
+ }
233
+ }
242
234
  exports.DaemonMethods = DaemonMethods;
243
- var WS = /** @class */ (function (_super) {
244
- __extends(WS, _super);
245
- function WS(endpoint) {
246
- var _this = _super.call(this, endpoint) || this;
247
- _this.methods = new DaemonMethods(_this);
248
- return _this;
249
- }
250
- return WS;
251
- }(websocket_1.WSRPC));
235
+ class WS extends websocket_1.WSRPC {
236
+ constructor(endpoint) {
237
+ super(endpoint);
238
+ this.methods = new DaemonMethods(this);
239
+ }
240
+ }
252
241
  exports.WS = WS;
253
- exports["default"] = WS;
242
+ exports.default = WS;
@@ -1,39 +1,38 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Element = exports.ElementType = void 0;
4
- var value_1 = require("./value");
4
+ const value_1 = require("./value");
5
5
  var ElementType;
6
6
  (function (ElementType) {
7
7
  ElementType[ElementType["Value"] = 0] = "Value";
8
8
  ElementType[ElementType["Array"] = 1] = "Array";
9
9
  ElementType[ElementType["Fields"] = 2] = "Fields";
10
10
  })(ElementType = exports.ElementType || (exports.ElementType = {}));
11
- var Element = /** @class */ (function () {
12
- function Element() {
13
- }
14
- Element.v = function (data) {
15
- var element = new Element();
16
- element.value = value_1.Value["new"](data);
11
+ class Element {
12
+ constructor() { }
13
+ static v(data) {
14
+ let element = new Element();
15
+ element.value = value_1.Value.new(data);
17
16
  return element;
18
- };
19
- Element.value = function (value) {
20
- var element = new Element();
17
+ }
18
+ static value(value) {
19
+ let element = new Element();
21
20
  element.value = value;
22
21
  return element;
23
- };
24
- Element.array = function (arr) {
25
- var element = new Element();
22
+ }
23
+ static array(arr) {
24
+ let element = new Element();
26
25
  element.array = arr;
27
26
  return element;
28
- };
29
- Element.fields = function (fields) {
30
- var element = new Element();
27
+ }
28
+ static fields(fields) {
29
+ let element = new Element();
31
30
  element.fields = fields;
32
31
  return element;
33
- };
34
- Element.prototype.validate = function () {
35
- var count = 0;
36
- var eType = 0;
32
+ }
33
+ validate() {
34
+ let count = 0;
35
+ let eType = 0;
37
36
  if (this.value) {
38
37
  count++;
39
38
  eType = ElementType.Value;
@@ -50,35 +49,34 @@ var Element = /** @class */ (function () {
50
49
  throw "only one field (Value, Array, or Fields) must be set";
51
50
  }
52
51
  return eType;
53
- };
54
- Element.fromBytes = function (data) {
55
- var reader = new value_1.ValueReader(data);
52
+ }
53
+ static fromBytes(data) {
54
+ let reader = new value_1.ValueReader(data);
56
55
  return reader.read();
57
- };
58
- Element.prototype.toBytes = function () {
59
- var writer = new value_1.ValueWriter();
56
+ }
57
+ toBytes() {
58
+ let writer = new value_1.ValueWriter();
60
59
  writer.write(this);
61
60
  return new Uint8Array(writer.data);
62
- };
63
- Element.prototype.toObject = function () {
64
- var vType = this.validate();
61
+ }
62
+ toObject() {
63
+ let vType = this.validate();
65
64
  switch (vType) {
66
65
  case ElementType.Value:
67
66
  return this.value.data;
68
67
  case ElementType.Array:
69
- var arr_1 = [];
70
- this.array.forEach(function (item) {
71
- arr_1.push(item.toObject());
68
+ let arr = [];
69
+ this.array.forEach((item) => {
70
+ arr.push(item.toObject());
72
71
  });
73
- return arr_1;
72
+ return arr;
74
73
  case ElementType.Fields:
75
- var obj_1 = {};
76
- this.fields.forEach(function (item, key) {
77
- obj_1[key.data] = item.toObject();
74
+ let obj = {};
75
+ this.fields.forEach((item, key) => {
76
+ obj[key.data] = item.toObject();
78
77
  });
79
- return obj_1;
78
+ return obj;
80
79
  }
81
- };
82
- return Element;
83
- }());
80
+ }
81
+ }
84
82
  exports.Element = Element;