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