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