@xelis/sdk 0.9.11 → 0.10.1
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/address.js +55 -0
- package/dist/cjs/address/bech32.js +167 -0
- package/dist/cjs/config.js +4 -2
- package/dist/cjs/daemon/rpc.js +122 -71
- package/dist/cjs/daemon/types.js +44 -24
- package/dist/cjs/daemon/websocket.js +129 -105
- package/dist/cjs/data/element.js +84 -0
- package/dist/cjs/data/value.js +327 -0
- package/dist/cjs/{lib/rpc.js → rpc/http.js} +68 -18
- package/dist/cjs/rpc/parse_json/parse_json.js +15 -0
- package/dist/cjs/{lib → rpc}/websocket.js +119 -79
- package/dist/cjs/wallet/rpc.js +81 -70
- package/dist/cjs/wallet/types.js +44 -1
- package/dist/cjs/wallet/websocket.js +77 -14
- package/dist/cjs/xswd/websocket.js +3 -3
- package/dist/esm/address/address.js +53 -0
- package/dist/esm/address/bech32.js +161 -0
- package/dist/esm/config.js +3 -1
- package/dist/esm/daemon/rpc.js +122 -71
- package/dist/esm/daemon/types.js +44 -24
- package/dist/esm/daemon/websocket.js +130 -106
- package/dist/esm/data/element.js +81 -0
- package/dist/esm/data/value.js +324 -0
- package/dist/esm/{lib/rpc.js → rpc/http.js} +67 -17
- package/dist/esm/rpc/parse_json/parse_json.js +8 -0
- package/dist/esm/{lib → rpc}/websocket.js +118 -78
- package/dist/esm/wallet/rpc.js +81 -70
- package/dist/esm/wallet/types.js +43 -0
- package/dist/esm/wallet/websocket.js +77 -14
- package/dist/esm/xswd/websocket.js +3 -3
- package/dist/types/address/address.d.ts +12 -0
- package/dist/types/address/bech32.d.ts +6 -0
- package/dist/types/config.d.ts +2 -0
- package/dist/types/daemon/rpc.d.ts +68 -51
- package/dist/types/daemon/types.d.ts +216 -44
- package/dist/types/daemon/websocket.d.ts +77 -56
- package/dist/types/data/element.d.ts +20 -0
- package/dist/types/data/value.d.ts +50 -0
- package/dist/types/rpc/http.d.ts +9 -0
- package/dist/types/rpc/parse_json/parse_json.d.ts +1 -0
- package/dist/types/{lib → rpc}/websocket.d.ts +14 -10
- package/dist/types/wallet/rpc.d.ts +45 -26
- package/dist/types/wallet/types.d.ts +244 -21
- package/dist/types/wallet/websocket.d.ts +47 -22
- package/dist/types/xswd/websocket.d.ts +3 -3
- package/package.json +5 -4
- package/dist/cjs/lib/parse_data.js +0 -15
- package/dist/esm/lib/parse_data.js +0 -11
- package/dist/types/lib/parse_data.d.ts +0 -1
- package/dist/types/lib/rpc.d.ts +0 -7
- /package/dist/cjs/{lib → rpc}/types.js +0 -0
- /package/dist/esm/{lib → rpc}/types.js +0 -0
- /package/dist/types/{lib → rpc}/types.d.ts +0 -0
|
@@ -36,26 +36,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import WebSocket from 'isomorphic-ws';
|
|
38
38
|
import { to } from 'await-to-js';
|
|
39
|
-
import {
|
|
40
|
-
var
|
|
41
|
-
function
|
|
39
|
+
import { parseJSON } from './parse_json/parse_json.js';
|
|
40
|
+
var WSRPC = /** @class */ (function () {
|
|
41
|
+
function WSRPC(options) {
|
|
42
42
|
this.connectionTries = 0;
|
|
43
43
|
this.methodIdIncrement = 0;
|
|
44
44
|
this.endpoint = "";
|
|
45
45
|
this.timeout = 15000; // default to 15s
|
|
46
|
-
this.events =
|
|
46
|
+
this.events = new Map();
|
|
47
47
|
this.unsubscribeSuspense = 1000;
|
|
48
48
|
this.maxConnectionTries = 3;
|
|
49
49
|
this.reconnectOnConnectionLoss = true;
|
|
50
50
|
this.options = options;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
WSRPC.prototype.connect = function (endpoint) {
|
|
53
53
|
var _this = this;
|
|
54
54
|
// force disconnect if already connected
|
|
55
55
|
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
|
56
56
|
this.socket.close();
|
|
57
57
|
}
|
|
58
|
-
this.events =
|
|
58
|
+
this.events = new Map();
|
|
59
59
|
this.connectionTries = 0;
|
|
60
60
|
return new Promise(function (resolve, reject) {
|
|
61
61
|
_this.socket = new WebSocket(endpoint, _this.options);
|
|
@@ -77,7 +77,7 @@ var WS = /** @class */ (function () {
|
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
WSRPC.prototype.tryReconnect = function () {
|
|
81
81
|
var _this = this;
|
|
82
82
|
this.connectionTries++;
|
|
83
83
|
if (this.connectionTries > this.maxConnectionTries) {
|
|
@@ -91,26 +91,29 @@ var WS = /** @class */ (function () {
|
|
|
91
91
|
_this.tryReconnect();
|
|
92
92
|
});
|
|
93
93
|
};
|
|
94
|
-
|
|
94
|
+
WSRPC.prototype.close = function () {
|
|
95
95
|
if (!this.socket)
|
|
96
96
|
return;
|
|
97
97
|
this.socket.close();
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
WSRPC.prototype.clearEvent = function (event) {
|
|
100
100
|
var _this = this;
|
|
101
|
-
this.events
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
var eventData = this.events.get(event);
|
|
102
|
+
if (eventData) {
|
|
103
|
+
eventData.listeners.forEach(function (listener) {
|
|
104
|
+
_this.socket && _this.socket.removeEventListener("message", listener);
|
|
105
|
+
});
|
|
106
|
+
this.events["delete"](event);
|
|
107
|
+
}
|
|
105
108
|
};
|
|
106
|
-
|
|
109
|
+
WSRPC.prototype.closeAllListens = function (event) {
|
|
107
110
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
111
|
var _a, err, _;
|
|
109
112
|
return __generator(this, function (_b) {
|
|
110
113
|
switch (_b.label) {
|
|
111
114
|
case 0:
|
|
112
|
-
if (!this.events
|
|
113
|
-
return [4 /*yield*/, to(this.
|
|
115
|
+
if (!this.events.has(event)) return [3 /*break*/, 2];
|
|
116
|
+
return [4 /*yield*/, to(this.dataCall("unsubscribe", { notify: event }))];
|
|
114
117
|
case 1:
|
|
115
118
|
_a = _b.sent(), err = _a[0], _ = _a[1];
|
|
116
119
|
if (err)
|
|
@@ -122,59 +125,56 @@ var WS = /** @class */ (function () {
|
|
|
122
125
|
});
|
|
123
126
|
});
|
|
124
127
|
};
|
|
125
|
-
|
|
128
|
+
WSRPC.prototype.listenEvent = function (event, onData) {
|
|
126
129
|
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
-
var onMessage,
|
|
130
|
+
var onMessage, eventData, idRefObject, _a, err, _, closeListen;
|
|
128
131
|
var _this = this;
|
|
129
132
|
return __generator(this, function (_b) {
|
|
130
133
|
switch (_b.label) {
|
|
131
134
|
case 0:
|
|
132
135
|
onMessage = function (msgEvent) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (data.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
onData(msgEvent, data.result, undefined);
|
|
144
|
-
}
|
|
136
|
+
var eventData = _this.events.get(event);
|
|
137
|
+
if (eventData && typeof msgEvent.data === "string") {
|
|
138
|
+
try {
|
|
139
|
+
var data = parseJSON(msgEvent.data);
|
|
140
|
+
if (data.id === eventData.id) {
|
|
141
|
+
if (data.error) {
|
|
142
|
+
onData(msgEvent, undefined, new Error(data.error.message));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
onData(msgEvent, data.result, undefined);
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
}
|
|
149
|
+
catch (_a) {
|
|
150
|
+
// can't parse json -- do nothing
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (unsubscribeTimeoutId) {
|
|
154
|
+
eventData = this.events.get(event);
|
|
155
|
+
if (!eventData) return [3 /*break*/, 1];
|
|
156
|
+
if (eventData.unsubscribeTimeoutId) {
|
|
156
157
|
// clear timeout to unsubscribe
|
|
157
158
|
// because we got a new registered event and want to cancel the pending unsubscribe grace period
|
|
158
|
-
clearTimeout(unsubscribeTimeoutId);
|
|
159
|
+
clearTimeout(eventData.unsubscribeTimeoutId);
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
+
eventData.listeners.push(onMessage);
|
|
161
162
|
return [3 /*break*/, 3];
|
|
162
163
|
case 1:
|
|
163
|
-
|
|
164
|
-
this.
|
|
165
|
-
return [4 /*yield*/, to(this.call("subscribe", { notify: event }))];
|
|
164
|
+
idRefObject = {};
|
|
165
|
+
return [4 /*yield*/, to(this.dataCall("subscribe", { notify: event }, idRefObject))];
|
|
166
166
|
case 2:
|
|
167
|
-
_a = _b.sent(), err = _a[0],
|
|
167
|
+
_a = _b.sent(), err = _a[0], _ = _a[1];
|
|
168
168
|
if (err) {
|
|
169
169
|
this.clearEvent(event);
|
|
170
170
|
return [2 /*return*/, Promise.reject(err)];
|
|
171
171
|
}
|
|
172
|
-
this.events[
|
|
172
|
+
this.events.set(event, { listeners: [onMessage], id: idRefObject.id });
|
|
173
173
|
_b.label = 3;
|
|
174
174
|
case 3:
|
|
175
175
|
this.socket && this.socket.addEventListener("message", onMessage);
|
|
176
176
|
closeListen = function () {
|
|
177
|
-
var eventData = _this.events
|
|
177
|
+
var eventData = _this.events.get(event);
|
|
178
178
|
if (eventData) {
|
|
179
179
|
var listeners = eventData.listeners;
|
|
180
180
|
for (var i = 0; i < listeners.length; i++) {
|
|
@@ -187,17 +187,17 @@ var WS = /** @class */ (function () {
|
|
|
187
187
|
if (listeners.length === 0) {
|
|
188
188
|
if (_this.socket && _this.socket.readyState === WebSocket.OPEN) {
|
|
189
189
|
// we use a grace period to unsubscribe (mostly because of react useEffect and avoid unecessary subscribe)
|
|
190
|
-
|
|
190
|
+
eventData.unsubscribeTimeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
191
191
|
return __generator(this, function (_a) {
|
|
192
|
-
this.
|
|
193
|
-
|
|
192
|
+
this.dataCall("unsubscribe", { notify: event });
|
|
193
|
+
this.events["delete"](event);
|
|
194
194
|
return [2 /*return*/];
|
|
195
195
|
});
|
|
196
196
|
}); }, _this.unsubscribeSuspense);
|
|
197
197
|
}
|
|
198
198
|
else {
|
|
199
199
|
// socket is closed so we don't send unsubscribe and no grace period delete right away
|
|
200
|
-
|
|
200
|
+
_this.events["delete"](event);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
}
|
|
@@ -209,70 +209,110 @@ var WS = /** @class */ (function () {
|
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
211
|
};
|
|
212
|
-
|
|
212
|
+
WSRPC.prototype.batchCall = function (requests) {
|
|
213
|
+
var _this = this;
|
|
214
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
215
|
+
var id, data, _a, err, res, items;
|
|
216
|
+
return __generator(this, function (_b) {
|
|
217
|
+
switch (_b.label) {
|
|
218
|
+
case 0:
|
|
219
|
+
id = this.methodIdIncrement++;
|
|
220
|
+
requests.forEach(function (request) {
|
|
221
|
+
request.id = id;
|
|
222
|
+
request.jsonrpc = "2.0";
|
|
223
|
+
});
|
|
224
|
+
data = JSON.stringify(requests);
|
|
225
|
+
return [4 /*yield*/, to(this.rawCall(id, data))];
|
|
226
|
+
case 1:
|
|
227
|
+
_a = _b.sent(), err = _a[0], res = _a[1];
|
|
228
|
+
if (err)
|
|
229
|
+
return [2 /*return*/, reject(err)];
|
|
230
|
+
items = [];
|
|
231
|
+
res.forEach(function (v) {
|
|
232
|
+
if (v.error) {
|
|
233
|
+
items.push(new Error(v.error.message));
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
items.push(v.result);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
return [2 /*return*/, resolve(items)];
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}); });
|
|
243
|
+
};
|
|
244
|
+
WSRPC.prototype.rawCall = function (id, body) {
|
|
213
245
|
var _this = this;
|
|
214
246
|
return new Promise(function (resolve, reject) {
|
|
215
247
|
if (!_this.socket)
|
|
216
248
|
return reject(new Error("Socket is not initialized."));
|
|
217
249
|
if (_this.socket.readyState !== WebSocket.OPEN)
|
|
218
250
|
return reject(new Error("Can't send msg. Socket is not opened."));
|
|
219
|
-
var requestMethod = _this.createRequestMethod(method, params);
|
|
220
|
-
// for XSWD we want to send the application data without request method wrapping
|
|
221
|
-
if (overwriteData) {
|
|
222
|
-
requestMethod.id = null;
|
|
223
|
-
requestMethod.data = overwriteData;
|
|
224
|
-
}
|
|
225
251
|
var timeoutId = null;
|
|
226
252
|
var onMessage = function (msgEvent) {
|
|
227
253
|
if (typeof msgEvent.data === "string") {
|
|
228
|
-
var data =
|
|
229
|
-
|
|
254
|
+
var data = parseJSON(msgEvent.data);
|
|
255
|
+
console.log(data);
|
|
256
|
+
var valid = false;
|
|
257
|
+
if (Array.isArray(data) && data.length > 0 && data[0].id === id) {
|
|
258
|
+
//@ts-ignore
|
|
259
|
+
resolve(data);
|
|
260
|
+
valid = true;
|
|
261
|
+
}
|
|
262
|
+
else if (data.id === id) {
|
|
263
|
+
resolve(data);
|
|
264
|
+
valid = true;
|
|
265
|
+
}
|
|
266
|
+
else if (data.id === null && id === 0) {
|
|
267
|
+
// special case with xswd sending first call will return null id
|
|
268
|
+
resolve(data);
|
|
269
|
+
valid = true;
|
|
270
|
+
}
|
|
271
|
+
if (valid) {
|
|
230
272
|
clearTimeout(timeoutId);
|
|
231
273
|
_this.socket && _this.socket.removeEventListener("message", onMessage);
|
|
232
|
-
if (data.error)
|
|
233
|
-
return reject(new Error(data.error.message));
|
|
234
|
-
else
|
|
235
|
-
resolve(data);
|
|
236
274
|
}
|
|
237
275
|
}
|
|
238
276
|
};
|
|
239
|
-
|
|
240
|
-
_this.socket && _this.socket.addEventListener("message", onMessage); // we don't use { once: true } option because of timeout feature
|
|
277
|
+
_this.socket.addEventListener("message", onMessage);
|
|
241
278
|
if (_this.timeout > 0) {
|
|
242
279
|
timeoutId = setTimeout(function () {
|
|
243
280
|
_this.socket && _this.socket.removeEventListener("message", onMessage);
|
|
244
281
|
reject(new Error("timeout"));
|
|
245
282
|
}, _this.timeout);
|
|
246
283
|
}
|
|
247
|
-
if (_this.socket
|
|
248
|
-
_this.socket.send(
|
|
284
|
+
if (_this.socket.readyState === WebSocket.OPEN) {
|
|
285
|
+
_this.socket.send(body);
|
|
249
286
|
}
|
|
250
287
|
});
|
|
251
288
|
};
|
|
252
|
-
|
|
289
|
+
WSRPC.prototype.dataCall = function (method, params, idRefObj) {
|
|
253
290
|
var _this = this;
|
|
254
291
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
255
|
-
var _a, err, res;
|
|
292
|
+
var id, request, data, _a, err, res;
|
|
256
293
|
return __generator(this, function (_b) {
|
|
257
294
|
switch (_b.label) {
|
|
258
|
-
case 0:
|
|
295
|
+
case 0:
|
|
296
|
+
id = this.methodIdIncrement++;
|
|
297
|
+
if (idRefObj)
|
|
298
|
+
idRefObj.id = id;
|
|
299
|
+
request = { id: id, jsonrpc: "2.0", method: method };
|
|
300
|
+
if (params)
|
|
301
|
+
request.params = params;
|
|
302
|
+
data = JSON.stringify(request);
|
|
303
|
+
return [4 /*yield*/, to(this.rawCall(id, data))];
|
|
259
304
|
case 1:
|
|
260
305
|
_a = _b.sent(), err = _a[0], res = _a[1];
|
|
261
306
|
if (err)
|
|
262
307
|
return [2 /*return*/, reject(err)];
|
|
308
|
+
if (res.error) {
|
|
309
|
+
return [2 /*return*/, reject(res.error.message)];
|
|
310
|
+
}
|
|
263
311
|
return [2 /*return*/, resolve(res.result)];
|
|
264
312
|
}
|
|
265
313
|
});
|
|
266
314
|
}); });
|
|
267
315
|
};
|
|
268
|
-
|
|
269
|
-
var id = this.methodIdIncrement++;
|
|
270
|
-
var request = { id: id, jsonrpc: "2.0", method: method };
|
|
271
|
-
if (params)
|
|
272
|
-
request.params = params;
|
|
273
|
-
var data = JSON.stringify(request);
|
|
274
|
-
return { data: data, id: id };
|
|
275
|
-
};
|
|
276
|
-
return WS;
|
|
316
|
+
return WSRPC;
|
|
277
317
|
}());
|
|
278
|
-
export {
|
|
318
|
+
export { WSRPC };
|
package/dist/esm/wallet/rpc.js
CHANGED
|
@@ -13,122 +13,133 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
16
|
import { Base64 } from 'js-base64';
|
|
53
17
|
import { RPCMethod } from './types.js';
|
|
54
|
-
import {
|
|
18
|
+
import { HttpRPC } from '../rpc/http.js';
|
|
55
19
|
var RPC = /** @class */ (function (_super) {
|
|
56
20
|
__extends(RPC, _super);
|
|
57
21
|
function RPC(endpoint, username, password) {
|
|
58
22
|
var _this = _super.call(this, endpoint) || this;
|
|
59
23
|
var authValue = Base64.encode("".concat(username, ":").concat(password));
|
|
60
|
-
_this.
|
|
24
|
+
_this.headers.set("Authorization", "Basic ".concat(authValue));
|
|
61
25
|
return _this;
|
|
62
26
|
}
|
|
63
|
-
RPC.prototype.post = function (method, params) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var headers;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
headers = new Headers();
|
|
68
|
-
headers.set("Authorization", this.auth);
|
|
69
|
-
return [2 /*return*/, _super.prototype.post.call(this, method, params, headers)];
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
27
|
RPC.prototype.getVersion = function () {
|
|
74
|
-
return this.
|
|
28
|
+
return this.request(RPCMethod.GetVersion);
|
|
75
29
|
};
|
|
76
30
|
RPC.prototype.getNetwork = function () {
|
|
77
|
-
return this.
|
|
31
|
+
return this.request(RPCMethod.GetNetwork);
|
|
78
32
|
};
|
|
79
33
|
RPC.prototype.getNonce = function () {
|
|
80
|
-
return this.
|
|
34
|
+
return this.request(RPCMethod.GetNonce);
|
|
81
35
|
};
|
|
82
36
|
RPC.prototype.getTopoheight = function () {
|
|
83
|
-
return this.
|
|
37
|
+
return this.request(RPCMethod.GetTopoheight);
|
|
84
38
|
};
|
|
85
39
|
RPC.prototype.getAddress = function (params) {
|
|
86
40
|
if (params === void 0) { params = {}; }
|
|
87
|
-
return this.
|
|
41
|
+
return this.request(RPCMethod.GetAddress, params);
|
|
88
42
|
};
|
|
89
43
|
RPC.prototype.splitAddress = function (params) {
|
|
90
|
-
return this.
|
|
44
|
+
return this.request(RPCMethod.SplitAddress, params);
|
|
91
45
|
};
|
|
92
46
|
RPC.prototype.rescan = function (params) {
|
|
93
|
-
return this.
|
|
47
|
+
return this.request(RPCMethod.Rescan, params);
|
|
94
48
|
};
|
|
95
49
|
RPC.prototype.getBalance = function (asset) {
|
|
96
|
-
return this.
|
|
50
|
+
return this.request(RPCMethod.GetBalance, { asset: asset });
|
|
97
51
|
};
|
|
98
52
|
RPC.prototype.hasBalance = function (asset) {
|
|
99
|
-
return this.
|
|
53
|
+
return this.request(RPCMethod.HasBalance, { asset: asset });
|
|
100
54
|
};
|
|
101
55
|
RPC.prototype.getTrackedAssets = function () {
|
|
102
|
-
return this.
|
|
56
|
+
return this.request(RPCMethod.GetTrackedAssets);
|
|
103
57
|
};
|
|
104
58
|
RPC.prototype.getAssetPrecision = function (params) {
|
|
105
|
-
return this.
|
|
59
|
+
return this.request(RPCMethod.GetAssetPrecision, params);
|
|
60
|
+
};
|
|
61
|
+
RPC.prototype.getAssets = function () {
|
|
62
|
+
return this.request(RPCMethod.GetAssets);
|
|
63
|
+
};
|
|
64
|
+
RPC.prototype.getAsset = function (params) {
|
|
65
|
+
return this.request(RPCMethod.GetAsset, params);
|
|
106
66
|
};
|
|
107
67
|
RPC.prototype.getTransaction = function (hash) {
|
|
108
|
-
return this.
|
|
68
|
+
return this.request(RPCMethod.GetTransaction, { hash: hash });
|
|
109
69
|
};
|
|
110
70
|
RPC.prototype.buildTransaction = function (params) {
|
|
111
|
-
return this.
|
|
71
|
+
return this.request(RPCMethod.BuildTransaction, params);
|
|
72
|
+
};
|
|
73
|
+
RPC.prototype.buildTransactionOffline = function (params) {
|
|
74
|
+
return this.request(RPCMethod.BuildTransactionOffline, params);
|
|
75
|
+
};
|
|
76
|
+
RPC.prototype.buildUnsignedTransaction = function (params) {
|
|
77
|
+
return this.request(RPCMethod.BuildUnsignedTransaction, params);
|
|
78
|
+
};
|
|
79
|
+
RPC.prototype.signUnsignedTransaction = function (params) {
|
|
80
|
+
return this.request(RPCMethod.SignUnsignedTransaction, params);
|
|
81
|
+
};
|
|
82
|
+
RPC.prototype.finalizeUnsignedTransaction = function (params) {
|
|
83
|
+
return this.request(RPCMethod.FinalizeUnsignedTransaction, params);
|
|
84
|
+
};
|
|
85
|
+
RPC.prototype.clearTxCache = function () {
|
|
86
|
+
return this.request(RPCMethod.ClearTxCache);
|
|
112
87
|
};
|
|
113
88
|
RPC.prototype.listTransactions = function (params) {
|
|
114
|
-
return this.
|
|
89
|
+
return this.request(RPCMethod.ListTransactions, params);
|
|
115
90
|
};
|
|
116
91
|
RPC.prototype.isOnline = function () {
|
|
117
|
-
return this.
|
|
92
|
+
return this.request(RPCMethod.IsOnline);
|
|
93
|
+
};
|
|
94
|
+
RPC.prototype.setOnlineMode = function (params) {
|
|
95
|
+
return this.request(RPCMethod.SetOnlineMode, params);
|
|
96
|
+
};
|
|
97
|
+
RPC.prototype.setOfflineMode = function () {
|
|
98
|
+
return this.request(RPCMethod.SetOfflineMode);
|
|
118
99
|
};
|
|
119
100
|
RPC.prototype.signData = function (data) {
|
|
120
|
-
return this.
|
|
101
|
+
return this.request(RPCMethod.SignData, data.toObject());
|
|
121
102
|
};
|
|
122
103
|
RPC.prototype.estimateFees = function (params) {
|
|
123
|
-
return this.
|
|
104
|
+
return this.request(RPCMethod.EstimateFees, params);
|
|
124
105
|
};
|
|
125
|
-
RPC.prototype.
|
|
126
|
-
return this.
|
|
106
|
+
RPC.prototype.estimateExtraDataSize = function (params) {
|
|
107
|
+
return this.request(RPCMethod.EstimateExtraDataSize, params);
|
|
127
108
|
};
|
|
128
|
-
RPC.prototype.
|
|
129
|
-
return this.
|
|
109
|
+
RPC.prototype.networkInfo = function () {
|
|
110
|
+
return this.request(RPCMethod.NetworkInfo);
|
|
111
|
+
};
|
|
112
|
+
RPC.prototype.decryptExtraData = function (params) {
|
|
113
|
+
return this.request(RPCMethod.DecryptExtraData, params);
|
|
114
|
+
};
|
|
115
|
+
RPC.prototype.decryptCiphertext = function (params) {
|
|
116
|
+
return this.request(RPCMethod.DecryptCiphertext, params);
|
|
117
|
+
};
|
|
118
|
+
RPC.prototype.getMatchingKeys = function (params) {
|
|
119
|
+
return this.request(RPCMethod.GetMatchingKeys, params);
|
|
120
|
+
};
|
|
121
|
+
RPC.prototype.countMatchingEntries = function (params) {
|
|
122
|
+
return this.request(RPCMethod.CountMatchingEntries, params);
|
|
123
|
+
};
|
|
124
|
+
RPC.prototype.getValueFromKey = function (params) {
|
|
125
|
+
return this.request(RPCMethod.GetValueFromKey, params);
|
|
126
|
+
};
|
|
127
|
+
RPC.prototype.store = function (params) {
|
|
128
|
+
return this.request(RPCMethod.Store, params);
|
|
129
|
+
};
|
|
130
|
+
RPC.prototype["delete"] = function (params) {
|
|
131
|
+
return this.request(RPCMethod.Delete, params);
|
|
132
|
+
};
|
|
133
|
+
RPC.prototype.deleteTreeEntries = function (tree) {
|
|
134
|
+
return this.request(RPCMethod.DeleteTreeEntries, { tree: tree });
|
|
135
|
+
};
|
|
136
|
+
RPC.prototype.hasKey = function (params) {
|
|
137
|
+
return this.request(RPCMethod.HasKey, params);
|
|
138
|
+
};
|
|
139
|
+
RPC.prototype.queryDB = function (params) {
|
|
140
|
+
return this.request(RPCMethod.QueryDB, params);
|
|
130
141
|
};
|
|
131
142
|
return RPC;
|
|
132
|
-
}(
|
|
143
|
+
}(HttpRPC));
|
|
133
144
|
export { RPC };
|
|
134
145
|
export default RPC;
|
package/dist/esm/wallet/types.js
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
export var TxRole;
|
|
2
|
+
(function (TxRole) {
|
|
3
|
+
TxRole["Sender"] = "sender";
|
|
4
|
+
TxRole["Receiver"] = "receiver";
|
|
5
|
+
})(TxRole || (TxRole = {}));
|
|
6
|
+
export var ValueType;
|
|
7
|
+
(function (ValueType) {
|
|
8
|
+
ValueType[ValueType["Bool"] = 0] = "Bool";
|
|
9
|
+
ValueType[ValueType["String"] = 1] = "String";
|
|
10
|
+
ValueType[ValueType["U8"] = 2] = "U8";
|
|
11
|
+
ValueType[ValueType["U16"] = 3] = "U16";
|
|
12
|
+
ValueType[ValueType["U32"] = 4] = "U32";
|
|
13
|
+
ValueType[ValueType["U64"] = 5] = "U64";
|
|
14
|
+
ValueType[ValueType["U128"] = 6] = "U128";
|
|
15
|
+
ValueType[ValueType["Hash"] = 7] = "Hash";
|
|
16
|
+
ValueType[ValueType["Blob"] = 8] = "Blob";
|
|
17
|
+
})(ValueType || (ValueType = {}));
|
|
18
|
+
export var ElementType;
|
|
19
|
+
(function (ElementType) {
|
|
20
|
+
ElementType[ElementType["Value"] = 0] = "Value";
|
|
21
|
+
ElementType[ElementType["Array"] = 1] = "Array";
|
|
22
|
+
ElementType[ElementType["Fields"] = 2] = "Fields";
|
|
23
|
+
})(ElementType || (ElementType = {}));
|
|
1
24
|
export var RPCMethod;
|
|
2
25
|
(function (RPCMethod) {
|
|
3
26
|
RPCMethod["GetVersion"] = "get_version";
|
|
@@ -11,14 +34,33 @@ export var RPCMethod;
|
|
|
11
34
|
RPCMethod["HasBalance"] = "has_balance";
|
|
12
35
|
RPCMethod["GetTrackedAssets"] = "get_tracked_assets";
|
|
13
36
|
RPCMethod["GetAssetPrecision"] = "get_asset_precision";
|
|
37
|
+
RPCMethod["GetAssets"] = "get_assets";
|
|
38
|
+
RPCMethod["GetAsset"] = "get_asset";
|
|
14
39
|
RPCMethod["GetTransaction"] = "get_transaction";
|
|
15
40
|
RPCMethod["BuildTransaction"] = "build_transaction";
|
|
41
|
+
RPCMethod["BuildTransactionOffline"] = "build_transaction_offline";
|
|
42
|
+
RPCMethod["BuildUnsignedTransaction"] = "build_unsigned_transaction";
|
|
43
|
+
RPCMethod["SignUnsignedTransaction"] = "sign_unsigned_transaction";
|
|
44
|
+
RPCMethod["FinalizeUnsignedTransaction"] = "finalize_unsigned_transaction";
|
|
45
|
+
RPCMethod["ClearTxCache"] = "clear_tx_cache";
|
|
16
46
|
RPCMethod["ListTransactions"] = "list_transactions";
|
|
17
47
|
RPCMethod["IsOnline"] = "is_online";
|
|
18
48
|
RPCMethod["SetOnlineMode"] = "set_online_mode";
|
|
19
49
|
RPCMethod["SetOfflineMode"] = "set_offline_mode";
|
|
20
50
|
RPCMethod["SignData"] = "sign_data";
|
|
21
51
|
RPCMethod["EstimateFees"] = "estimate_fees";
|
|
52
|
+
RPCMethod["EstimateExtraDataSize"] = "estimate_extra_data_size";
|
|
53
|
+
RPCMethod["NetworkInfo"] = "network_info";
|
|
54
|
+
RPCMethod["DecryptExtraData"] = "decrypt_extra_data";
|
|
55
|
+
RPCMethod["DecryptCiphertext"] = "decrypt_ciphertext";
|
|
56
|
+
RPCMethod["GetMatchingKeys"] = "get_matching_keys";
|
|
57
|
+
RPCMethod["CountMatchingEntries"] = "count_matching_entries";
|
|
58
|
+
RPCMethod["GetValueFromKey"] = "get_value_from_key";
|
|
59
|
+
RPCMethod["Store"] = "store";
|
|
60
|
+
RPCMethod["Delete"] = "delete";
|
|
61
|
+
RPCMethod["DeleteTreeEntries"] = "delete_tree_entries";
|
|
62
|
+
RPCMethod["HasKey"] = "has_key";
|
|
63
|
+
RPCMethod["QueryDB"] = "query_db";
|
|
22
64
|
})(RPCMethod || (RPCMethod = {}));
|
|
23
65
|
export var RPCEvent;
|
|
24
66
|
(function (RPCEvent) {
|
|
@@ -27,6 +69,7 @@ export var RPCEvent;
|
|
|
27
69
|
RPCEvent["NewTransaction"] = "new_transaction";
|
|
28
70
|
RPCEvent["BalanceChanged"] = "balance_changed";
|
|
29
71
|
RPCEvent["Rescan"] = "rescan";
|
|
72
|
+
RPCEvent["HistorySynced"] = "history_synced";
|
|
30
73
|
RPCEvent["Online"] = "online";
|
|
31
74
|
RPCEvent["Offline"] = "offline";
|
|
32
75
|
})(RPCEvent || (RPCEvent = {}));
|