@xelis/sdk 0.10.12 → 0.11.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/daemon/websocket.js +6 -60
- package/dist/cjs/react/daemon.js +15 -73
- package/dist/cjs/rpc/websocket.js +96 -199
- package/dist/cjs/wallet/websocket.js +6 -24
- package/dist/cjs/xswd/relayer/app.js +8 -3
- package/dist/cjs/xswd/relayer/index.css +136 -10
- package/dist/cjs/xswd/websocket.js +3 -3
- package/dist/esm/daemon/websocket.js +6 -60
- package/dist/esm/react/daemon.js +15 -73
- package/dist/esm/rpc/websocket.js +95 -198
- package/dist/esm/wallet/websocket.js +6 -24
- package/dist/esm/xswd/relayer/app.js +8 -3
- package/dist/esm/xswd/relayer/index.css +136 -10
- package/dist/esm/xswd/websocket.js +3 -3
- package/dist/types/daemon/websocket.d.ts +25 -21
- package/dist/types/react/daemon.d.ts +2 -2
- package/dist/types/rpc/websocket.d.ts +14 -22
- package/dist/types/wallet/websocket.d.ts +14 -10
- package/dist/types/xswd/websocket.d.ts +1 -1
- package/package.json +1 -1
|
@@ -34,254 +34,119 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
import to from "await-to-js";
|
|
38
|
+
import { parseJSON } from "./parse_json/parse_json.js";
|
|
37
39
|
import WebSocket from 'isomorphic-ws';
|
|
38
|
-
import { to } from 'await-to-js';
|
|
39
|
-
import { parseJSON } from './parse_json/parse_json.js';
|
|
40
40
|
var WSRPC = /** @class */ (function () {
|
|
41
|
-
function WSRPC(options) {
|
|
42
|
-
this.connectionTries = 0;
|
|
43
|
-
this.methodIdIncrement = 0;
|
|
44
|
-
this.endpoint = "";
|
|
45
|
-
this.timeout = 15000; // default to 15s
|
|
46
|
-
this.events = new Map();
|
|
47
|
-
this.unsubscribeSuspense = 1000;
|
|
48
|
-
this.maxConnectionTries = 3;
|
|
49
|
-
this.reconnectOnConnectionLoss = true;
|
|
50
|
-
this.options = options;
|
|
51
|
-
}
|
|
52
|
-
WSRPC.prototype.connect = function (endpoint) {
|
|
41
|
+
function WSRPC(endpoint, options) {
|
|
53
42
|
var _this = this;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
43
|
+
this.socket = new WebSocket(endpoint, options);
|
|
44
|
+
this.methodIdIncrement = 0;
|
|
45
|
+
this.callTimeout = 3000;
|
|
58
46
|
this.events = new Map();
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
_this.socket = new WebSocket(endpoint, _this.options);
|
|
62
|
-
_this.endpoint = endpoint;
|
|
63
|
-
_this.socket.addEventListener("open", function (event) {
|
|
64
|
-
resolve(event);
|
|
65
|
-
});
|
|
66
|
-
_this.socket.addEventListener("close", function (event) {
|
|
67
|
-
if (_this.reconnectOnConnectionLoss && !event.wasClean) {
|
|
68
|
-
_this.tryReconnect();
|
|
69
|
-
reject(new Error("Unhandled close. Reconnecting..."));
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
reject(event);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
_this.socket.addEventListener("error", function (err) {
|
|
76
|
-
reject(err);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
WSRPC.prototype.tryReconnect = function () {
|
|
81
|
-
var _this = this;
|
|
82
|
-
this.connectionTries++;
|
|
83
|
-
if (this.connectionTries > this.maxConnectionTries) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
this.socket = new WebSocket(this.endpoint, this.options);
|
|
87
|
-
this.socket.addEventListener("open", function () {
|
|
88
|
-
_this.connectionTries = 0;
|
|
47
|
+
this.socket.addEventListener("close", function () {
|
|
48
|
+
_this.events = new Map();
|
|
89
49
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
WSRPC.prototype.close = function () {
|
|
95
|
-
if (!this.socket)
|
|
96
|
-
return;
|
|
97
|
-
this.socket.close();
|
|
98
|
-
};
|
|
99
|
-
WSRPC.prototype.clearEvent = function (event) {
|
|
100
|
-
var _this = this;
|
|
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
|
-
}
|
|
108
|
-
};
|
|
109
|
-
WSRPC.prototype.closeAllListens = function (event) {
|
|
50
|
+
}
|
|
51
|
+
WSRPC.prototype.closeListener = function (event, listener) {
|
|
110
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
-
var
|
|
112
|
-
return __generator(this, function (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.
|
|
122
|
-
|
|
123
|
-
|
|
53
|
+
var eventData;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
eventData = this.events.get(event);
|
|
56
|
+
if (eventData) {
|
|
57
|
+
if (eventData.listeners.length > 1) {
|
|
58
|
+
eventData.listeners = eventData.listeners.filter(function (l) { return l !== listener; });
|
|
59
|
+
this.events.set(event, eventData);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.events["delete"](event);
|
|
63
|
+
this.socket.removeEventListener("message", eventData.onMessage);
|
|
64
|
+
this.dataCall("unsubscribe", { notify: event });
|
|
65
|
+
}
|
|
124
66
|
}
|
|
67
|
+
return [2 /*return*/];
|
|
125
68
|
});
|
|
126
69
|
});
|
|
127
70
|
};
|
|
128
|
-
WSRPC.prototype.
|
|
71
|
+
WSRPC.prototype.listen = function (event, listener) {
|
|
129
72
|
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
-
var
|
|
73
|
+
var eventData, idRefObject_1, onMessage;
|
|
131
74
|
var _this = this;
|
|
132
|
-
return __generator(this, function (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
eventData = this.events.get(event);
|
|
77
|
+
if (eventData) {
|
|
78
|
+
eventData.listeners.push(listener);
|
|
79
|
+
this.events.set(event, eventData);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
idRefObject_1 = {};
|
|
83
|
+
this.dataCall("subscribe", { notify: event }, idRefObject_1);
|
|
84
|
+
onMessage = function (msgEvent) {
|
|
85
|
+
var eventData = _this.events.get(event);
|
|
86
|
+
if (eventData && typeof msgEvent.data === "string") {
|
|
87
|
+
try {
|
|
88
|
+
var data_1 = parseJSON(msgEvent.data);
|
|
89
|
+
if (data_1.id === idRefObject_1.id) {
|
|
90
|
+
eventData.listeners.forEach(function (listener) {
|
|
91
|
+
if (data_1.error) {
|
|
92
|
+
listener(undefined, new Error(data_1.error.message));
|
|
143
93
|
}
|
|
144
94
|
else {
|
|
145
|
-
|
|
95
|
+
listener(data_1.result, undefined);
|
|
146
96
|
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (_a) {
|
|
150
|
-
// can't parse json -- do nothing
|
|
97
|
+
});
|
|
151
98
|
}
|
|
152
99
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (!eventData) return [3 /*break*/, 1];
|
|
156
|
-
if (eventData.unsubscribeTimeoutId) {
|
|
157
|
-
// clear timeout to unsubscribe
|
|
158
|
-
// because we got a new registered event and want to cancel the pending unsubscribe grace period
|
|
159
|
-
clearTimeout(eventData.unsubscribeTimeoutId);
|
|
160
|
-
}
|
|
161
|
-
eventData.listeners.push(onMessage);
|
|
162
|
-
return [3 /*break*/, 3];
|
|
163
|
-
case 1:
|
|
164
|
-
// important if multiple listenEvent are called without await at least we store listener before getting id
|
|
165
|
-
// avoid trying to subscribe the same event multiple times
|
|
166
|
-
this.events.set(event, { listeners: [onMessage] });
|
|
167
|
-
idRefObject = {};
|
|
168
|
-
return [4 /*yield*/, to(this.dataCall("subscribe", { notify: event }, idRefObject))];
|
|
169
|
-
case 2:
|
|
170
|
-
_a = _b.sent(), err = _a[0], _ = _a[1];
|
|
171
|
-
if (err) {
|
|
172
|
-
this.clearEvent(event);
|
|
173
|
-
return [2 /*return*/, Promise.reject(err)];
|
|
174
|
-
}
|
|
175
|
-
eventData_1 = this.events.get(event);
|
|
176
|
-
if (eventData_1)
|
|
177
|
-
eventData_1.id = idRefObject.id;
|
|
178
|
-
_b.label = 3;
|
|
179
|
-
case 3:
|
|
180
|
-
this.socket && this.socket.addEventListener("message", onMessage);
|
|
181
|
-
closeListen = function () {
|
|
182
|
-
var eventData = _this.events.get(event);
|
|
183
|
-
if (eventData) {
|
|
184
|
-
var listeners = eventData.listeners;
|
|
185
|
-
for (var i = 0; i < listeners.length; i++) {
|
|
186
|
-
if (listeners[i] === onMessage) {
|
|
187
|
-
listeners.splice(i, 1);
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
// no more listener so we unsubscribe from daemon websocket if socket still open
|
|
192
|
-
if (listeners.length === 0) {
|
|
193
|
-
// we use a grace period to unsubscribe (mostly because of react useEffect and avoid unecessary subscribe)
|
|
194
|
-
eventData.unsubscribeTimeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
195
|
-
return __generator(this, function (_a) {
|
|
196
|
-
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
|
197
|
-
this.dataCall("unsubscribe", { notify: event });
|
|
198
|
-
}
|
|
199
|
-
this.events["delete"](event);
|
|
200
|
-
return [2 /*return*/];
|
|
201
|
-
});
|
|
202
|
-
}); }, _this.unsubscribeSuspense);
|
|
203
|
-
}
|
|
100
|
+
catch (_a) {
|
|
101
|
+
// can't parse json -- do nothing
|
|
204
102
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
this.socket.addEventListener("message", onMessage);
|
|
106
|
+
this.events.set(event, { onMessage: onMessage, listeners: [listener] });
|
|
209
107
|
}
|
|
108
|
+
return [2 /*return*/];
|
|
210
109
|
});
|
|
211
110
|
});
|
|
212
111
|
};
|
|
213
|
-
WSRPC.prototype.batchCall = function (requests) {
|
|
214
|
-
var _this = this;
|
|
215
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
216
|
-
var id, data, _a, err, res, items;
|
|
217
|
-
return __generator(this, function (_b) {
|
|
218
|
-
switch (_b.label) {
|
|
219
|
-
case 0:
|
|
220
|
-
id = this.methodIdIncrement++;
|
|
221
|
-
requests.forEach(function (request) {
|
|
222
|
-
request.id = id;
|
|
223
|
-
request.jsonrpc = "2.0";
|
|
224
|
-
});
|
|
225
|
-
data = JSON.stringify(requests);
|
|
226
|
-
return [4 /*yield*/, to(this.rawCall(id, data))];
|
|
227
|
-
case 1:
|
|
228
|
-
_a = _b.sent(), err = _a[0], res = _a[1];
|
|
229
|
-
if (err)
|
|
230
|
-
return [2 /*return*/, reject(err)];
|
|
231
|
-
items = [];
|
|
232
|
-
res.forEach(function (v) {
|
|
233
|
-
if (v.error) {
|
|
234
|
-
items.push(new Error(v.error.message));
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
items.push(v.result);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
return [2 /*return*/, resolve(items)];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}); });
|
|
244
|
-
};
|
|
245
112
|
WSRPC.prototype.rawCall = function (id, body) {
|
|
246
113
|
var _this = this;
|
|
247
114
|
return new Promise(function (resolve, reject) {
|
|
248
|
-
if (!_this.socket)
|
|
249
|
-
return reject(new Error("Socket is not initialized."));
|
|
250
115
|
if (_this.socket.readyState !== WebSocket.OPEN)
|
|
251
116
|
return reject(new Error("Can't send msg. Socket is not opened."));
|
|
252
117
|
var timeoutId = null;
|
|
253
118
|
var onMessage = function (msgEvent) {
|
|
254
119
|
if (typeof msgEvent.data === "string") {
|
|
255
|
-
var
|
|
120
|
+
var data_2 = parseJSON(msgEvent.data);
|
|
256
121
|
var evaluate_data = function () {
|
|
257
122
|
clearTimeout(timeoutId);
|
|
258
|
-
_this.socket
|
|
259
|
-
if (
|
|
260
|
-
reject(new Error(
|
|
123
|
+
_this.socket.removeEventListener("message", onMessage);
|
|
124
|
+
if (data_2.error && data_2.error.message) {
|
|
125
|
+
reject(new Error(data_2.error.message));
|
|
261
126
|
return;
|
|
262
127
|
}
|
|
263
|
-
return resolve(
|
|
128
|
+
return resolve(data_2);
|
|
264
129
|
};
|
|
265
130
|
// this is for batch call we match the id with first item id
|
|
266
|
-
if (Array.isArray(
|
|
131
|
+
if (Array.isArray(data_2) && data_2.length > 0 && data_2[0].id === id) {
|
|
267
132
|
return evaluate_data();
|
|
268
133
|
}
|
|
269
134
|
// the msg id is matching so we can evaluate the data
|
|
270
|
-
if (
|
|
135
|
+
if (data_2.id === id) {
|
|
271
136
|
return evaluate_data();
|
|
272
137
|
}
|
|
273
138
|
// special XSWD case - sending first call will return null id
|
|
274
|
-
if (
|
|
139
|
+
if (data_2.id === null && id === 0) {
|
|
275
140
|
return evaluate_data();
|
|
276
141
|
}
|
|
277
142
|
}
|
|
278
143
|
};
|
|
279
144
|
_this.socket.addEventListener("message", onMessage);
|
|
280
|
-
if (_this.
|
|
145
|
+
if (_this.callTimeout > 0) {
|
|
281
146
|
timeoutId = setTimeout(function () {
|
|
282
147
|
_this.socket && _this.socket.removeEventListener("message", onMessage);
|
|
283
148
|
reject(new Error("timeout"));
|
|
284
|
-
}, _this.
|
|
149
|
+
}, _this.callTimeout);
|
|
285
150
|
}
|
|
286
151
|
if (_this.socket.readyState === WebSocket.OPEN) {
|
|
287
152
|
_this.socket.send(body);
|
|
@@ -315,6 +180,38 @@ var WSRPC = /** @class */ (function () {
|
|
|
315
180
|
});
|
|
316
181
|
}); });
|
|
317
182
|
};
|
|
183
|
+
WSRPC.prototype.batchCall = function (requests) {
|
|
184
|
+
var _this = this;
|
|
185
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
186
|
+
var id, data, _a, err, res, items;
|
|
187
|
+
return __generator(this, function (_b) {
|
|
188
|
+
switch (_b.label) {
|
|
189
|
+
case 0:
|
|
190
|
+
id = this.methodIdIncrement++;
|
|
191
|
+
requests.forEach(function (request) {
|
|
192
|
+
request.id = id;
|
|
193
|
+
request.jsonrpc = "2.0";
|
|
194
|
+
});
|
|
195
|
+
data = JSON.stringify(requests);
|
|
196
|
+
return [4 /*yield*/, to(this.rawCall(id, data))];
|
|
197
|
+
case 1:
|
|
198
|
+
_a = _b.sent(), err = _a[0], res = _a[1];
|
|
199
|
+
if (err)
|
|
200
|
+
return [2 /*return*/, reject(err)];
|
|
201
|
+
items = [];
|
|
202
|
+
res.forEach(function (v) {
|
|
203
|
+
if (v.error) {
|
|
204
|
+
items.push(new Error(v.error.message));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
items.push(v.result);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return [2 /*return*/, resolve(items)];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}); });
|
|
214
|
+
};
|
|
318
215
|
return WSRPC;
|
|
319
216
|
}());
|
|
320
217
|
export { WSRPC };
|
|
@@ -24,29 +24,11 @@ var WalletMethods = /** @class */ (function () {
|
|
|
24
24
|
WalletMethods.prototype.dataCall = function (method, params) {
|
|
25
25
|
return this.ws.dataCall(this.prefix + method, params);
|
|
26
26
|
};
|
|
27
|
-
WalletMethods.prototype.
|
|
28
|
-
|
|
27
|
+
WalletMethods.prototype.closeListener = function (event, listener) {
|
|
28
|
+
this.ws.closeListener(event, listener);
|
|
29
29
|
};
|
|
30
|
-
WalletMethods.prototype.
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
WalletMethods.prototype.onNewTransaction = function (onData) {
|
|
34
|
-
return this.ws.listenEvent(this.prefix + RPCEvent.NewTransaction, onData);
|
|
35
|
-
};
|
|
36
|
-
WalletMethods.prototype.onBalanceChanged = function (onData) {
|
|
37
|
-
return this.ws.listenEvent(this.prefix + RPCEvent.BalanceChanged, onData);
|
|
38
|
-
};
|
|
39
|
-
WalletMethods.prototype.onRescan = function (onData) {
|
|
40
|
-
return this.ws.listenEvent(this.prefix + RPCEvent.Rescan, onData);
|
|
41
|
-
};
|
|
42
|
-
WalletMethods.prototype.onHistorySynced = function (onData) {
|
|
43
|
-
return this.ws.listenEvent(this.prefix + RPCEvent.HistorySynced, onData);
|
|
44
|
-
};
|
|
45
|
-
WalletMethods.prototype.onOnline = function (onData) {
|
|
46
|
-
return this.ws.listenEvent(this.prefix + RPCEvent.Online, onData);
|
|
47
|
-
};
|
|
48
|
-
WalletMethods.prototype.onOffline = function (onData) {
|
|
49
|
-
return this.ws.listenEvent(this.prefix + RPCEvent.Offline, onData);
|
|
30
|
+
WalletMethods.prototype.listen = function (event, listener) {
|
|
31
|
+
this.ws.listen(this.prefix + event, listener);
|
|
50
32
|
};
|
|
51
33
|
WalletMethods.prototype.getVersion = function () {
|
|
52
34
|
return this.dataCall(RPCMethod.GetVersion);
|
|
@@ -174,8 +156,8 @@ var WalletMethods = /** @class */ (function () {
|
|
|
174
156
|
export { WalletMethods };
|
|
175
157
|
var WS = /** @class */ (function (_super) {
|
|
176
158
|
__extends(WS, _super);
|
|
177
|
-
function WS(username, password) {
|
|
178
|
-
var _this = _super.call(this, { auth: "".concat(username, ":").concat(password) }) || this;
|
|
159
|
+
function WS(endpoint, username, password) {
|
|
160
|
+
var _this = _super.call(this, endpoint, { auth: "".concat(username, ":").concat(password) }) || this;
|
|
179
161
|
_this.methods = new WalletMethods(_this);
|
|
180
162
|
return _this;
|
|
181
163
|
}
|
|
@@ -15,7 +15,7 @@ var App = /** @class */ (function () {
|
|
|
15
15
|
this.errElement.classList.add("xelis-xswd-relayer-error");
|
|
16
16
|
this.qrCodeElement = document.createElement("div");
|
|
17
17
|
this.qrCodeElement.classList.add("xelis-xswd-relayer-qrcode");
|
|
18
|
-
this.qrCodeElement.innerHTML = "\n <div>XSWD Relayer</div>\n <canvas></canvas>\n ";
|
|
18
|
+
this.qrCodeElement.innerHTML = "\n <div class=\"xelis-xswd-relayer-scan-logo\">\n <svg fill=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M4,4h6v6H4V4M20,4v6H14V4h6M14,15h2V13H14V11h2v2h2V11h2v2H18v2h2v3H18v2H16V18H13v2H11V16h3V15m2,0v3h2V15H16M4,20V14h6v6H4M6,6V8H8V6H6M16,6V8h2V6H16M6,16v2H8V16H6M4,11H6v2H4V11m5,0h4v4H11V13H9V11m2-5h2v4H11V6M2,2V6H0V2A2,2,0,0,1,2,0H6V2H2M22,0a2,2,0,0,1,2,2V6H22V2H18V0h4M2,18v4H6v2H2a2,2,0,0,1-2-2V18H2m20,4V18h2v4a2,2,0,0,1-2,2H18V22Z\"/>\n </svg>\n </div>\n <div class=\"xelis-xswd-relayer-logo-wrap\">\n <div class=\"xelis-xswd-relayer-logo\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 778 743\" fill=\"currentColor\">\n <path fillRule=\"evenodd\" clipRule=\"evenodd\" d=\"M388.909 742.872L777.817 353.964L424.056 0.202599L478.809 132.737L700.036 353.964L388.909 665.091L77.7817 353.964L299.507 129.121L353.964 0L0 353.964L388.909 742.872Z\" />\n <path d=\"M388.909 665.091L353.964 0L299.507 129.121L388.909 665.091Z\" />\n <path d=\"M424.056 0.202599L388.909 665.091L478.809 132.737L424.056 0.202599Z\" />\n </svg>\n </div>\n </div>\n <div class=\"xelis-xswd-relayer-title\">XSWD Relayer</div>\n <canvas></canvas>\n ";
|
|
19
19
|
this.element.addEventListener("click", function (e) {
|
|
20
20
|
// close the app if clicking outside
|
|
21
21
|
if (_this.element.isEqualNode(e.target)) {
|
|
@@ -32,7 +32,7 @@ var App = /** @class */ (function () {
|
|
|
32
32
|
};
|
|
33
33
|
App.prototype.setError = function (msg) {
|
|
34
34
|
this.clear();
|
|
35
|
-
this.errElement.innerHTML = "error: ".concat(msg);
|
|
35
|
+
this.errElement.innerHTML = "\n <div class=\"xelis-xswd-relayer-error-text\">error: ".concat(msg, "</div>\n ");
|
|
36
36
|
this.contentElement.appendChild(this.errElement);
|
|
37
37
|
};
|
|
38
38
|
App.prototype.setLoading = function () {
|
|
@@ -48,7 +48,12 @@ var App = /** @class */ (function () {
|
|
|
48
48
|
relayer: this.relayer.props.url,
|
|
49
49
|
encryption_mode: this.relayer.props.encryption_mode
|
|
50
50
|
});
|
|
51
|
-
QRCode.toCanvas(canvas, qrCodeData
|
|
51
|
+
QRCode.toCanvas(canvas, qrCodeData, {
|
|
52
|
+
color: {
|
|
53
|
+
dark: "#fff",
|
|
54
|
+
light: "#000" // background
|
|
55
|
+
}
|
|
56
|
+
});
|
|
52
57
|
this.contentElement.appendChild(this.qrCodeElement);
|
|
53
58
|
};
|
|
54
59
|
return App;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
.xelis-xswd-relayer {
|
|
2
|
+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
2
3
|
position: fixed;
|
|
3
4
|
top: 0;
|
|
4
5
|
left: 0;
|
|
5
6
|
bottom: 0;
|
|
6
7
|
right: 0;
|
|
7
|
-
background-color: rgba(0, 0, 0, 0.
|
|
8
|
-
backdrop-filter: blur(
|
|
8
|
+
background-color: rgba(0, 0, 0, 0.8);
|
|
9
|
+
backdrop-filter: blur(30px);
|
|
10
|
+
opacity: 0;
|
|
11
|
+
animation: xelis-xswd-relayer-appear .25s forwards;
|
|
12
|
+
user-select: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@keyframes xelis-xswd-relayer-appear {
|
|
16
|
+
100% {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
}
|
|
9
19
|
}
|
|
10
20
|
|
|
11
21
|
.xelis-xswd-relayer-content {
|
|
@@ -13,16 +23,51 @@
|
|
|
13
23
|
top: 50%;
|
|
14
24
|
left: 50%;
|
|
15
25
|
translate: -50% -50%;
|
|
16
|
-
background-color: aquamarine;
|
|
17
|
-
filter: drop-shadow(0px 0px 25px black);
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
.xelis-xswd-relayer-error {
|
|
28
|
+
.xelis-xswd-relayer-error {
|
|
29
|
+
background-color: #02ffcf;
|
|
30
|
+
padding: 15px;
|
|
31
|
+
border-radius: 10px;
|
|
32
|
+
animation: xelis-xswd-relayer-error-appear .5s forwards;
|
|
33
|
+
opacity: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@keyframes xelis-xswd-relayer-error-appear {
|
|
37
|
+
25% {
|
|
38
|
+
translate: -4px 0;
|
|
39
|
+
rotate: -3deg;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
50% {
|
|
43
|
+
translate: 4px 0;
|
|
44
|
+
rotate: 3deg;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
75% {
|
|
48
|
+
translate: -4px 0;
|
|
49
|
+
rotate: -3deg;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
100% {
|
|
53
|
+
opacity: 1;
|
|
54
|
+
translate: 0 0;
|
|
55
|
+
rotate: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
.xelis-xswd-relayer-error-text {
|
|
61
|
+
background-color: rgba(31, 31, 31, 1);
|
|
62
|
+
border-radius: 5px;
|
|
63
|
+
padding: 5px 10px;
|
|
64
|
+
color: rgb(255, 63, 63);
|
|
65
|
+
}
|
|
21
66
|
|
|
22
67
|
.xelis-xswd-relayer-loading {
|
|
23
|
-
width:
|
|
24
|
-
height:
|
|
25
|
-
color:
|
|
68
|
+
width: 75px;
|
|
69
|
+
height: 75px;
|
|
70
|
+
color: #02ffcf;
|
|
26
71
|
animation: xelis-xswd-relayer-loading-animation .75s infinite;
|
|
27
72
|
}
|
|
28
73
|
|
|
@@ -32,6 +77,87 @@
|
|
|
32
77
|
}
|
|
33
78
|
}
|
|
34
79
|
|
|
35
|
-
.xelis-xswd-relayer-qrcode {
|
|
80
|
+
.xelis-xswd-relayer-qrcode {
|
|
81
|
+
background-color: rgba(2, 255, 207, 1);
|
|
82
|
+
padding: 30px 30px 50px 30px;
|
|
83
|
+
border-radius: 15px;
|
|
84
|
+
animation: xelis-xswd-relayer-qrcode-appear .25s forwards, xelis-xswd-relayer-qrcode-animation 2s infinite alternate;
|
|
85
|
+
translate: 0 -100%;
|
|
86
|
+
opacity: 0;
|
|
87
|
+
position: relative;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@keyframes xelis-xswd-relayer-qrcode-appear {
|
|
91
|
+
100% {
|
|
92
|
+
translate: 0 0;
|
|
93
|
+
opacity: 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@keyframes xelis-xswd-relayer-qrcode-animation {
|
|
98
|
+
0% {
|
|
99
|
+
background-color: rgba(2, 255, 207, 0.3);
|
|
100
|
+
filter: drop-shadow(0px 0px 100px rgba(2, 255, 209, 0.1));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
100% {
|
|
104
|
+
background-color: rgba(2, 255, 207, 1);
|
|
105
|
+
filter: drop-shadow(0px 0px 200px rgba(2, 255, 209, 0.1));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.xelis-xswd-relayer-scan-logo {
|
|
110
|
+
position: absolute;
|
|
111
|
+
bottom: -30px;
|
|
112
|
+
left: 50%;
|
|
113
|
+
translate: -50% 0;
|
|
114
|
+
width: 25px;
|
|
115
|
+
height: 25px;
|
|
116
|
+
color: white;
|
|
117
|
+
background-color: black;
|
|
118
|
+
padding: 20px;
|
|
119
|
+
border-radius: 100%;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.xelis-xswd-relayer-logo-wrap {
|
|
123
|
+
position: absolute;
|
|
124
|
+
width: 100%;
|
|
125
|
+
height: 100%;
|
|
126
|
+
overflow: hidden;
|
|
127
|
+
top: 0;
|
|
128
|
+
left: 0;
|
|
129
|
+
border-radius: 15px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.xelis-xswd-relayer-logo {
|
|
133
|
+
position: absolute;
|
|
134
|
+
width: 100%;
|
|
135
|
+
height: 100%;
|
|
136
|
+
top: 25%;
|
|
137
|
+
left: 5%;
|
|
138
|
+
scale: 1.8;
|
|
139
|
+
z-index: -1;
|
|
140
|
+
animation: xelis-xswd-relayer-logo-animation 2s infinite alternate;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@keyframes xelis-xswd-relayer-logo-animation {
|
|
144
|
+
0% {
|
|
145
|
+
color: rgba(0, 206, 168, 0);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
100% {
|
|
149
|
+
color: rgba(0, 206, 168, 0.8);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
.xelis-xswd-relayer-title {
|
|
155
|
+
font-size: 25px;
|
|
156
|
+
font-weight: bold;
|
|
157
|
+
margin-bottom: 10px;
|
|
158
|
+
color: black;
|
|
159
|
+
}
|
|
36
160
|
|
|
37
|
-
.xelis-xswd-relayer-qrcode canvas {
|
|
161
|
+
.xelis-xswd-relayer-qrcode canvas {
|
|
162
|
+
border-radius: 10px;
|
|
163
|
+
}
|
|
@@ -18,9 +18,9 @@ import { DaemonMethods } from '../daemon/websocket.js';
|
|
|
18
18
|
import { WalletMethods } from '../wallet/websocket.js';
|
|
19
19
|
var WS = /** @class */ (function (_super) {
|
|
20
20
|
__extends(WS, _super);
|
|
21
|
-
function WS() {
|
|
22
|
-
var _this = _super.call(this) || this;
|
|
23
|
-
_this.
|
|
21
|
+
function WS(endpoint) {
|
|
22
|
+
var _this = _super.call(this, endpoint) || this;
|
|
23
|
+
_this.callTimeout = 0; // xswd needs user input for confirmation - timeout should not be used
|
|
24
24
|
_this.daemon = new DaemonMethods(_this, "node.");
|
|
25
25
|
_this.wallet = new WalletMethods(_this, "wallet.");
|
|
26
26
|
return _this;
|