@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,253 +1,242 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
11
|
+
dataCall(method, params) {
|
|
28
12
|
return this.ws.dataCall(this.prefix + method, params);
|
|
29
|
-
}
|
|
30
|
-
|
|
13
|
+
}
|
|
14
|
+
closeListener(event, listener) {
|
|
31
15
|
this.ws.closeListener(event, listener);
|
|
32
|
-
}
|
|
33
|
-
|
|
16
|
+
}
|
|
17
|
+
listen(event, listener) {
|
|
34
18
|
this.ws.listen(this.prefix + event, listener);
|
|
35
|
-
}
|
|
36
|
-
|
|
19
|
+
}
|
|
20
|
+
getVersion() {
|
|
37
21
|
return this.dataCall(types_1.RPCMethod.GetVersion);
|
|
38
|
-
}
|
|
39
|
-
|
|
22
|
+
}
|
|
23
|
+
getHeight() {
|
|
40
24
|
return this.dataCall(types_1.RPCMethod.GetHeight);
|
|
41
|
-
}
|
|
42
|
-
|
|
25
|
+
}
|
|
26
|
+
getTopoheight() {
|
|
43
27
|
return this.dataCall(types_1.RPCMethod.GetTopoheight);
|
|
44
|
-
}
|
|
45
|
-
|
|
28
|
+
}
|
|
29
|
+
getPrunedTopoheight() {
|
|
46
30
|
return this.dataCall(types_1.RPCMethod.GetPrunedTopoheight);
|
|
47
|
-
}
|
|
48
|
-
|
|
31
|
+
}
|
|
32
|
+
getInfo() {
|
|
49
33
|
return this.dataCall(types_1.RPCMethod.GetInfo);
|
|
50
|
-
}
|
|
51
|
-
|
|
34
|
+
}
|
|
35
|
+
getDifficulty() {
|
|
52
36
|
return this.dataCall(types_1.RPCMethod.GetDifficulty);
|
|
53
|
-
}
|
|
54
|
-
|
|
37
|
+
}
|
|
38
|
+
getTips() {
|
|
55
39
|
return this.dataCall(types_1.RPCMethod.GetTips);
|
|
56
|
-
}
|
|
57
|
-
|
|
40
|
+
}
|
|
41
|
+
getDevFeeThresholds() {
|
|
58
42
|
return this.dataCall(types_1.RPCMethod.GetDevFeeThresholds);
|
|
59
|
-
}
|
|
60
|
-
|
|
43
|
+
}
|
|
44
|
+
getSizeOnDisk() {
|
|
61
45
|
return this.dataCall(types_1.RPCMethod.GetSizeOnDisk);
|
|
62
|
-
}
|
|
63
|
-
|
|
46
|
+
}
|
|
47
|
+
getStableHeight() {
|
|
64
48
|
return this.dataCall(types_1.RPCMethod.GetStableHeight);
|
|
65
|
-
}
|
|
66
|
-
|
|
49
|
+
}
|
|
50
|
+
getStableTopoheight() {
|
|
67
51
|
return this.dataCall(types_1.RPCMethod.GetStableTopoheight);
|
|
68
|
-
}
|
|
69
|
-
|
|
52
|
+
}
|
|
53
|
+
getHardForks() {
|
|
70
54
|
return this.dataCall(types_1.RPCMethod.GetHardForks);
|
|
71
|
-
}
|
|
72
|
-
|
|
55
|
+
}
|
|
56
|
+
getBlockAtTopoheight(params) {
|
|
73
57
|
return this.dataCall(types_1.RPCMethod.GetBlockAtTopoheight, params);
|
|
74
|
-
}
|
|
75
|
-
|
|
58
|
+
}
|
|
59
|
+
getBlocksAtHeight(params) {
|
|
76
60
|
return this.dataCall(types_1.RPCMethod.GetBlocksAtHeight, params);
|
|
77
|
-
}
|
|
78
|
-
|
|
61
|
+
}
|
|
62
|
+
getBlockByHash(params) {
|
|
79
63
|
return this.dataCall(types_1.RPCMethod.GetBlockByHash, params);
|
|
80
|
-
}
|
|
81
|
-
|
|
64
|
+
}
|
|
65
|
+
getTopBlock(params) {
|
|
82
66
|
return this.dataCall(types_1.RPCMethod.GetTopBlock, params);
|
|
83
|
-
}
|
|
84
|
-
|
|
67
|
+
}
|
|
68
|
+
getBalance(params) {
|
|
85
69
|
return this.dataCall(types_1.RPCMethod.GetBalance, params);
|
|
86
|
-
}
|
|
87
|
-
|
|
70
|
+
}
|
|
71
|
+
getStableBalance(params) {
|
|
88
72
|
return this.dataCall(types_1.RPCMethod.GetStableBalance, params);
|
|
89
|
-
}
|
|
90
|
-
|
|
73
|
+
}
|
|
74
|
+
hasBalance(params) {
|
|
91
75
|
return this.dataCall(types_1.RPCMethod.HasBalance, params);
|
|
92
|
-
}
|
|
93
|
-
|
|
76
|
+
}
|
|
77
|
+
getBalanceAtTopoheight(params) {
|
|
94
78
|
return this.dataCall(types_1.RPCMethod.GetBalanceAtTopoheight, params);
|
|
95
|
-
}
|
|
96
|
-
|
|
79
|
+
}
|
|
80
|
+
getNonce(params) {
|
|
97
81
|
return this.dataCall(types_1.RPCMethod.GetNonce, params);
|
|
98
|
-
}
|
|
99
|
-
|
|
82
|
+
}
|
|
83
|
+
hasNonce(params) {
|
|
100
84
|
return this.dataCall(types_1.RPCMethod.HasNonce, params);
|
|
101
|
-
}
|
|
102
|
-
|
|
85
|
+
}
|
|
86
|
+
getNonceAtTopoheight(params) {
|
|
103
87
|
return this.dataCall(types_1.RPCMethod.GetNonceAtTopoheight, params);
|
|
104
|
-
}
|
|
105
|
-
|
|
88
|
+
}
|
|
89
|
+
getAsset(params) {
|
|
106
90
|
return this.dataCall(types_1.RPCMethod.GetAsset, params);
|
|
107
|
-
}
|
|
108
|
-
|
|
91
|
+
}
|
|
92
|
+
getAssets(params) {
|
|
109
93
|
return this.dataCall(types_1.RPCMethod.GetAssets, params);
|
|
110
|
-
}
|
|
111
|
-
|
|
94
|
+
}
|
|
95
|
+
countAssets() {
|
|
112
96
|
return this.dataCall(types_1.RPCMethod.CountAssets);
|
|
113
|
-
}
|
|
114
|
-
|
|
97
|
+
}
|
|
98
|
+
countTransactions() {
|
|
115
99
|
return this.dataCall(types_1.RPCMethod.CountTransactions);
|
|
116
|
-
}
|
|
117
|
-
|
|
100
|
+
}
|
|
101
|
+
countAccounts() {
|
|
118
102
|
return this.dataCall(types_1.RPCMethod.CountAccounts);
|
|
119
|
-
}
|
|
120
|
-
|
|
103
|
+
}
|
|
104
|
+
countContracts() {
|
|
121
105
|
return this.dataCall(types_1.RPCMethod.CountContracts);
|
|
122
|
-
}
|
|
123
|
-
|
|
106
|
+
}
|
|
107
|
+
submitTransaction(hexData) {
|
|
124
108
|
return this.dataCall(types_1.RPCMethod.SubmitTransaction, { data: hexData });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return this.dataCall(types_1.RPCMethod.GetTransactionExecutor, { hash
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return this.dataCall(types_1.RPCMethod.GetTransaction, { hash
|
|
131
|
-
}
|
|
132
|
-
|
|
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
|
-
|
|
118
|
+
}
|
|
119
|
+
isTxExecutedInBlock(params) {
|
|
136
120
|
return this.dataCall(types_1.RPCMethod.IsTxExecutedInBlock, params);
|
|
137
|
-
}
|
|
138
|
-
|
|
121
|
+
}
|
|
122
|
+
p2pStatus() {
|
|
139
123
|
return this.dataCall(types_1.RPCMethod.P2PStatus);
|
|
140
|
-
}
|
|
141
|
-
|
|
124
|
+
}
|
|
125
|
+
getPeers() {
|
|
142
126
|
return this.dataCall(types_1.RPCMethod.GetPeers);
|
|
143
|
-
}
|
|
144
|
-
|
|
127
|
+
}
|
|
128
|
+
getMemPool(params) {
|
|
145
129
|
return this.dataCall(types_1.RPCMethod.GetMempool, params);
|
|
146
|
-
}
|
|
147
|
-
|
|
130
|
+
}
|
|
131
|
+
getMempoolSummary(params) {
|
|
148
132
|
return this.dataCall(types_1.RPCMethod.GetMempoolSummary, params);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return this.dataCall(types_1.RPCMethod.GetMempoolCache, { address
|
|
152
|
-
}
|
|
153
|
-
|
|
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
|
-
|
|
139
|
+
}
|
|
140
|
+
getDAGOrder(params) {
|
|
157
141
|
return this.dataCall(types_1.RPCMethod.GetDAGOrder, params);
|
|
158
|
-
}
|
|
159
|
-
|
|
142
|
+
}
|
|
143
|
+
getBlocksRangeByTopoheight(params) {
|
|
160
144
|
return this.dataCall(types_1.RPCMethod.GetBlocksRangeByTopoheight, params);
|
|
161
|
-
}
|
|
162
|
-
|
|
145
|
+
}
|
|
146
|
+
getBlocksRangeByHeight(params) {
|
|
163
147
|
return this.dataCall(types_1.RPCMethod.GetBlocksRangeByHeight, params);
|
|
164
|
-
}
|
|
165
|
-
|
|
148
|
+
}
|
|
149
|
+
getAccountHistory(params) {
|
|
166
150
|
return this.dataCall(types_1.RPCMethod.GetAccountHistory, params);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return this.dataCall(types_1.RPCMethod.GetAccountAssets, { address
|
|
170
|
-
}
|
|
171
|
-
|
|
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
|
-
|
|
157
|
+
}
|
|
158
|
+
isAccountRegistered(params) {
|
|
175
159
|
return this.dataCall(types_1.RPCMethod.IsAccountRegistered, params);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return this.dataCall(types_1.RPCMethod.GetAccountRegistrationTopoheight, { address
|
|
179
|
-
}
|
|
180
|
-
|
|
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
|
-
|
|
166
|
+
}
|
|
167
|
+
splitAddress(params) {
|
|
184
168
|
return this.dataCall(types_1.RPCMethod.SplitAddress, params);
|
|
185
|
-
}
|
|
186
|
-
|
|
169
|
+
}
|
|
170
|
+
extractKeyFromAddress(params) {
|
|
187
171
|
return this.dataCall(types_1.RPCMethod.ExtractKeyFromAddress, params);
|
|
188
|
-
}
|
|
189
|
-
|
|
172
|
+
}
|
|
173
|
+
makeIntegratedAddress(params) {
|
|
190
174
|
return this.dataCall(types_1.RPCMethod.MakeIntegratedAddress, params);
|
|
191
|
-
}
|
|
192
|
-
|
|
175
|
+
}
|
|
176
|
+
decryptExtraData(params) {
|
|
193
177
|
return this.dataCall(types_1.RPCMethod.DecryptExtraData, params);
|
|
194
|
-
}
|
|
195
|
-
|
|
178
|
+
}
|
|
179
|
+
getMultisigAtTopoheight(params) {
|
|
196
180
|
return this.dataCall(types_1.RPCMethod.GetMultisigAtTopoheight, params);
|
|
197
|
-
}
|
|
198
|
-
|
|
181
|
+
}
|
|
182
|
+
getMultisig(params) {
|
|
199
183
|
return this.dataCall(types_1.RPCMethod.GetMultisig, params);
|
|
200
|
-
}
|
|
201
|
-
|
|
184
|
+
}
|
|
185
|
+
hasMultisig(params) {
|
|
202
186
|
return this.dataCall(types_1.RPCMethod.HasMultisig, params);
|
|
203
|
-
}
|
|
204
|
-
|
|
187
|
+
}
|
|
188
|
+
hasMultisigAtTopoheight(params) {
|
|
205
189
|
return this.dataCall(types_1.RPCMethod.HasMultisigAtTopoheight, params);
|
|
206
|
-
}
|
|
207
|
-
|
|
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
|
-
|
|
202
|
+
}
|
|
203
|
+
getContractModule(params) {
|
|
211
204
|
return this.dataCall(types_1.RPCMethod.GetContractModule, params);
|
|
212
|
-
}
|
|
213
|
-
|
|
205
|
+
}
|
|
206
|
+
getContractData(params) {
|
|
214
207
|
return this.dataCall(types_1.RPCMethod.GetContractData, params);
|
|
215
|
-
}
|
|
216
|
-
|
|
208
|
+
}
|
|
209
|
+
getContractDataAtTopoheight(params) {
|
|
217
210
|
return this.dataCall(types_1.RPCMethod.GetContractDataAtTopoheight, params);
|
|
218
|
-
}
|
|
219
|
-
|
|
211
|
+
}
|
|
212
|
+
getContractBalance(params) {
|
|
220
213
|
return this.dataCall(types_1.RPCMethod.GetContractBalance, params);
|
|
221
|
-
}
|
|
222
|
-
|
|
214
|
+
}
|
|
215
|
+
getContractBalanceAtTopoheight(params) {
|
|
223
216
|
return this.dataCall(types_1.RPCMethod.GetContractBalanceAtTopoheight, params);
|
|
224
|
-
}
|
|
225
|
-
|
|
217
|
+
}
|
|
218
|
+
getContractAssets(params) {
|
|
226
219
|
return this.dataCall(types_1.RPCMethod.GetContractAssets, params);
|
|
227
|
-
}
|
|
228
|
-
|
|
220
|
+
}
|
|
221
|
+
getP2PBlockPropagation(params) {
|
|
229
222
|
return this.dataCall(types_1.RPCMethod.GetP2PBlockPropagation, params);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return this.dataCall(types_1.RPCMethod.GetBlockTemplate, { address
|
|
233
|
-
}
|
|
234
|
-
|
|
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
|
-
|
|
229
|
+
}
|
|
230
|
+
submitBlock(params) {
|
|
238
231
|
return this.dataCall(types_1.RPCMethod.SubmitBlock, params);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
}());
|
|
232
|
+
}
|
|
233
|
+
}
|
|
242
234
|
exports.DaemonMethods = DaemonMethods;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
|
242
|
+
exports.default = WS;
|
package/dist/cjs/data/element.js
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Element = exports.ElementType = void 0;
|
|
4
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
20
|
-
|
|
17
|
+
}
|
|
18
|
+
static value(value) {
|
|
19
|
+
let element = new Element();
|
|
21
20
|
element.value = value;
|
|
22
21
|
return element;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
}
|
|
23
|
+
static array(arr) {
|
|
24
|
+
let element = new Element();
|
|
26
25
|
element.array = arr;
|
|
27
26
|
return element;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
}
|
|
28
|
+
static fields(fields) {
|
|
29
|
+
let element = new Element();
|
|
31
30
|
element.fields = fields;
|
|
32
31
|
return element;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
55
|
-
|
|
52
|
+
}
|
|
53
|
+
static fromBytes(data) {
|
|
54
|
+
let reader = new value_1.ValueReader(data);
|
|
56
55
|
return reader.read();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
}
|
|
57
|
+
toBytes() {
|
|
58
|
+
let writer = new value_1.ValueWriter();
|
|
60
59
|
writer.write(this);
|
|
61
60
|
return new Uint8Array(writer.data);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
70
|
-
this.array.forEach(
|
|
71
|
-
|
|
68
|
+
let arr = [];
|
|
69
|
+
this.array.forEach((item) => {
|
|
70
|
+
arr.push(item.toObject());
|
|
72
71
|
});
|
|
73
|
-
return
|
|
72
|
+
return arr;
|
|
74
73
|
case ElementType.Fields:
|
|
75
|
-
|
|
76
|
-
this.fields.forEach(
|
|
77
|
-
|
|
74
|
+
let obj = {};
|
|
75
|
+
this.fields.forEach((item, key) => {
|
|
76
|
+
obj[key.data] = item.toObject();
|
|
78
77
|
});
|
|
79
|
-
return
|
|
78
|
+
return obj;
|
|
80
79
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
84
82
|
exports.Element = Element;
|