@xelis/sdk 0.11.15 → 0.11.17

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 +97 -18
  49. package/dist/types/daemon/websocket.d.ts +5 -2
  50. package/package.json +1 -1
@@ -1,151 +1,131 @@
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 { Base64 } from 'js-base64';
17
2
  import { RPCMethod } from './types.js';
18
3
  import { HttpRPC } from '../rpc/http.js';
19
- var RPC = /** @class */ (function (_super) {
20
- __extends(RPC, _super);
21
- function RPC(endpoint, username, password) {
22
- var _this = _super.call(this, endpoint) || this;
23
- var authValue = Base64.encode("".concat(username, ":").concat(password));
24
- _this.headers.set("Authorization", "Basic ".concat(authValue));
25
- return _this;
26
- }
27
- RPC.prototype.getVersion = function () {
4
+ export class RPC extends HttpRPC {
5
+ constructor(endpoint, username, password) {
6
+ super(endpoint);
7
+ const authValue = Base64.encode(`${username}:${password}`);
8
+ this.headers.set("Authorization", `Basic ${authValue}`);
9
+ }
10
+ getVersion() {
28
11
  return this.request(RPCMethod.GetVersion);
29
- };
30
- RPC.prototype.getNetwork = function () {
12
+ }
13
+ getNetwork() {
31
14
  return this.request(RPCMethod.GetNetwork);
32
- };
33
- RPC.prototype.getNonce = function () {
15
+ }
16
+ getNonce() {
34
17
  return this.request(RPCMethod.GetNonce);
35
- };
36
- RPC.prototype.getTopoheight = function () {
18
+ }
19
+ getTopoheight() {
37
20
  return this.request(RPCMethod.GetTopoheight);
38
- };
39
- RPC.prototype.getAddress = function (params) {
40
- if (params === void 0) { params = {}; }
21
+ }
22
+ getAddress(params = {}) {
41
23
  return this.request(RPCMethod.GetAddress, params);
42
- };
43
- RPC.prototype.splitAddress = function (params) {
24
+ }
25
+ splitAddress(params) {
44
26
  return this.request(RPCMethod.SplitAddress, params);
45
- };
46
- RPC.prototype.rescan = function (params) {
27
+ }
28
+ rescan(params) {
47
29
  return this.request(RPCMethod.Rescan, params);
48
- };
49
- RPC.prototype.getBalance = function (asset) {
50
- return this.request(RPCMethod.GetBalance, { asset: asset });
51
- };
52
- RPC.prototype.hasBalance = function (asset) {
53
- return this.request(RPCMethod.HasBalance, { asset: asset });
54
- };
55
- RPC.prototype.getTrackedAssets = function () {
30
+ }
31
+ getBalance(asset) {
32
+ return this.request(RPCMethod.GetBalance, { asset });
33
+ }
34
+ hasBalance(asset) {
35
+ return this.request(RPCMethod.HasBalance, { asset });
36
+ }
37
+ getTrackedAssets() {
56
38
  return this.request(RPCMethod.GetTrackedAssets);
57
- };
58
- RPC.prototype.getAssetPrecision = function (params) {
39
+ }
40
+ getAssetPrecision(params) {
59
41
  return this.request(RPCMethod.GetAssetPrecision, params);
60
- };
61
- RPC.prototype.getAssets = function () {
42
+ }
43
+ getAssets() {
62
44
  return this.request(RPCMethod.GetAssets);
63
- };
64
- RPC.prototype.getAsset = function (params) {
45
+ }
46
+ getAsset(params) {
65
47
  return this.request(RPCMethod.GetAsset, params);
66
- };
67
- RPC.prototype.getTransaction = function (hash) {
68
- return this.request(RPCMethod.GetTransaction, { hash: hash });
69
- };
70
- RPC.prototype.searchTransaction = function (hash) {
71
- return this.request(RPCMethod.SearchTransaction, { hash: hash });
72
- };
73
- RPC.prototype.dumpTransaction = function (hash) {
74
- return this.request(RPCMethod.DumpTransaction, { hash: hash });
75
- };
76
- RPC.prototype.buildTransaction = function (params) {
48
+ }
49
+ getTransaction(hash) {
50
+ return this.request(RPCMethod.GetTransaction, { hash });
51
+ }
52
+ searchTransaction(hash) {
53
+ return this.request(RPCMethod.SearchTransaction, { hash });
54
+ }
55
+ dumpTransaction(hash) {
56
+ return this.request(RPCMethod.DumpTransaction, { hash });
57
+ }
58
+ buildTransaction(params) {
77
59
  return this.request(RPCMethod.BuildTransaction, params);
78
- };
79
- RPC.prototype.buildTransactionOffline = function (params) {
60
+ }
61
+ buildTransactionOffline(params) {
80
62
  return this.request(RPCMethod.BuildTransactionOffline, params);
81
- };
82
- RPC.prototype.buildUnsignedTransaction = function (params) {
63
+ }
64
+ buildUnsignedTransaction(params) {
83
65
  return this.request(RPCMethod.BuildUnsignedTransaction, params);
84
- };
85
- RPC.prototype.signUnsignedTransaction = function (params) {
66
+ }
67
+ signUnsignedTransaction(params) {
86
68
  return this.request(RPCMethod.SignUnsignedTransaction, params);
87
- };
88
- RPC.prototype.finalizeUnsignedTransaction = function (params) {
69
+ }
70
+ finalizeUnsignedTransaction(params) {
89
71
  return this.request(RPCMethod.FinalizeUnsignedTransaction, params);
90
- };
91
- RPC.prototype.clearTxCache = function () {
72
+ }
73
+ clearTxCache() {
92
74
  return this.request(RPCMethod.ClearTxCache);
93
- };
94
- RPC.prototype.listTransactions = function (params) {
75
+ }
76
+ listTransactions(params) {
95
77
  return this.request(RPCMethod.ListTransactions, params);
96
- };
97
- RPC.prototype.isOnline = function () {
78
+ }
79
+ isOnline() {
98
80
  return this.request(RPCMethod.IsOnline);
99
- };
100
- RPC.prototype.setOnlineMode = function (params) {
81
+ }
82
+ setOnlineMode(params) {
101
83
  return this.request(RPCMethod.SetOnlineMode, params);
102
- };
103
- RPC.prototype.setOfflineMode = function () {
84
+ }
85
+ setOfflineMode() {
104
86
  return this.request(RPCMethod.SetOfflineMode);
105
- };
106
- RPC.prototype.signData = function (data) {
87
+ }
88
+ signData(data) {
107
89
  return this.request(RPCMethod.SignData, data.toObject());
108
- };
109
- RPC.prototype.estimateFees = function (params) {
90
+ }
91
+ estimateFees(params) {
110
92
  return this.request(RPCMethod.EstimateFees, params);
111
- };
112
- RPC.prototype.estimateExtraDataSize = function (params) {
93
+ }
94
+ estimateExtraDataSize(params) {
113
95
  return this.request(RPCMethod.EstimateExtraDataSize, params);
114
- };
115
- RPC.prototype.networkInfo = function () {
96
+ }
97
+ networkInfo() {
116
98
  return this.request(RPCMethod.NetworkInfo);
117
- };
118
- RPC.prototype.decryptExtraData = function (params) {
99
+ }
100
+ decryptExtraData(params) {
119
101
  return this.request(RPCMethod.DecryptExtraData, params);
120
- };
121
- RPC.prototype.decryptCiphertext = function (params) {
102
+ }
103
+ decryptCiphertext(params) {
122
104
  return this.request(RPCMethod.DecryptCiphertext, params);
123
- };
124
- RPC.prototype.getMatchingKeys = function (params) {
105
+ }
106
+ getMatchingKeys(params) {
125
107
  return this.request(RPCMethod.GetMatchingKeys, params);
126
- };
127
- RPC.prototype.countMatchingEntries = function (params) {
108
+ }
109
+ countMatchingEntries(params) {
128
110
  return this.request(RPCMethod.CountMatchingEntries, params);
129
- };
130
- RPC.prototype.getValueFromKey = function (params) {
111
+ }
112
+ getValueFromKey(params) {
131
113
  return this.request(RPCMethod.GetValueFromKey, params);
132
- };
133
- RPC.prototype.store = function (params) {
114
+ }
115
+ store(params) {
134
116
  return this.request(RPCMethod.Store, params);
135
- };
136
- RPC.prototype["delete"] = function (params) {
117
+ }
118
+ delete(params) {
137
119
  return this.request(RPCMethod.Delete, params);
138
- };
139
- RPC.prototype.deleteTreeEntries = function (tree) {
140
- return this.request(RPCMethod.DeleteTreeEntries, { tree: tree });
141
- };
142
- RPC.prototype.hasKey = function (params) {
120
+ }
121
+ deleteTreeEntries(tree) {
122
+ return this.request(RPCMethod.DeleteTreeEntries, { tree });
123
+ }
124
+ hasKey(params) {
143
125
  return this.request(RPCMethod.HasKey, params);
144
- };
145
- RPC.prototype.queryDB = function (params) {
126
+ }
127
+ queryDB(params) {
146
128
  return this.request(RPCMethod.QueryDB, params);
147
- };
148
- return RPC;
149
- }(HttpRPC));
150
- export { RPC };
129
+ }
130
+ }
151
131
  export default RPC;
@@ -1,167 +1,144 @@
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 { WSRPC } from '../rpc/websocket.js';
17
2
  import { RPCMethod, RPCEvent } from './types.js';
18
- var WalletMethods = /** @class */ (function () {
19
- function WalletMethods(ws, prefix) {
20
- if (prefix === void 0) { prefix = ""; }
3
+ export class WalletMethods {
4
+ constructor(ws, prefix = "") {
21
5
  this.ws = ws;
22
6
  this.prefix = prefix;
23
7
  }
24
- WalletMethods.prototype.dataCall = function (method, params) {
8
+ dataCall(method, params) {
25
9
  return this.ws.dataCall(this.prefix + method, params);
26
- };
27
- WalletMethods.prototype.closeListener = function (event, listener) {
10
+ }
11
+ closeListener(event, listener) {
28
12
  this.ws.closeListener(event, listener);
29
- };
30
- WalletMethods.prototype.listen = function (event, listener) {
13
+ }
14
+ listen(event, listener) {
31
15
  this.ws.listen(this.prefix + event, listener);
32
- };
33
- WalletMethods.prototype.getVersion = function () {
16
+ }
17
+ getVersion() {
34
18
  return this.dataCall(RPCMethod.GetVersion);
35
- };
36
- WalletMethods.prototype.getNetwork = function () {
19
+ }
20
+ getNetwork() {
37
21
  return this.dataCall(RPCMethod.GetNetwork);
38
- };
39
- WalletMethods.prototype.getNonce = function () {
22
+ }
23
+ getNonce() {
40
24
  return this.dataCall(RPCMethod.GetNonce);
41
- };
42
- WalletMethods.prototype.getTopoheight = function () {
25
+ }
26
+ getTopoheight() {
43
27
  return this.dataCall(RPCMethod.GetTopoheight);
44
- };
45
- WalletMethods.prototype.getAddress = function (params) {
46
- if (params === void 0) { params = {}; }
28
+ }
29
+ getAddress(params = {}) {
47
30
  return this.dataCall(RPCMethod.GetAddress, params);
48
- };
49
- WalletMethods.prototype.splitAddress = function (params) {
31
+ }
32
+ splitAddress(params) {
50
33
  return this.dataCall(RPCMethod.SplitAddress, params);
51
- };
52
- WalletMethods.prototype.rescan = function (params) {
34
+ }
35
+ rescan(params) {
53
36
  return this.dataCall(RPCMethod.Rescan, params);
54
- };
55
- WalletMethods.prototype.getBalance = function (asset) {
56
- return this.dataCall(RPCMethod.GetBalance, { asset: asset });
57
- };
58
- WalletMethods.prototype.hasBalance = function (asset) {
59
- return this.dataCall(RPCMethod.HasBalance, { asset: asset });
60
- };
61
- WalletMethods.prototype.getTrackedAssets = function () {
37
+ }
38
+ getBalance(asset) {
39
+ return this.dataCall(RPCMethod.GetBalance, { asset });
40
+ }
41
+ hasBalance(asset) {
42
+ return this.dataCall(RPCMethod.HasBalance, { asset });
43
+ }
44
+ getTrackedAssets() {
62
45
  return this.dataCall(RPCMethod.GetTrackedAssets);
63
- };
64
- WalletMethods.prototype.getAssetPrecision = function (params) {
46
+ }
47
+ getAssetPrecision(params) {
65
48
  return this.dataCall(RPCMethod.GetAssetPrecision, params);
66
- };
67
- WalletMethods.prototype.getAssets = function () {
49
+ }
50
+ getAssets() {
68
51
  return this.dataCall(RPCMethod.GetAssets);
69
- };
70
- WalletMethods.prototype.getAsset = function (params) {
52
+ }
53
+ getAsset(params) {
71
54
  return this.dataCall(RPCMethod.GetAsset, params);
72
- };
73
- WalletMethods.prototype.getTransaction = function (hash) {
74
- return this.dataCall(RPCMethod.GetTransaction, { hash: hash });
75
- };
76
- WalletMethods.prototype.searchTransaction = function (hash) {
77
- return this.dataCall(RPCMethod.SearchTransaction, { hash: hash });
78
- };
79
- WalletMethods.prototype.dumpTransaction = function (hash) {
80
- return this.dataCall(RPCMethod.DumpTransaction, { hash: hash });
81
- };
82
- WalletMethods.prototype.buildTransaction = function (params) {
55
+ }
56
+ getTransaction(hash) {
57
+ return this.dataCall(RPCMethod.GetTransaction, { hash });
58
+ }
59
+ searchTransaction(hash) {
60
+ return this.dataCall(RPCMethod.SearchTransaction, { hash });
61
+ }
62
+ dumpTransaction(hash) {
63
+ return this.dataCall(RPCMethod.DumpTransaction, { hash });
64
+ }
65
+ buildTransaction(params) {
83
66
  return this.dataCall(RPCMethod.BuildTransaction, params);
84
- };
85
- WalletMethods.prototype.buildTransactionOffline = function (params) {
67
+ }
68
+ buildTransactionOffline(params) {
86
69
  return this.dataCall(RPCMethod.BuildTransactionOffline, params);
87
- };
88
- WalletMethods.prototype.buildUnsignedTransaction = function (params) {
70
+ }
71
+ buildUnsignedTransaction(params) {
89
72
  return this.dataCall(RPCMethod.BuildUnsignedTransaction, params);
90
- };
91
- WalletMethods.prototype.signUnsignedTransaction = function (params) {
73
+ }
74
+ signUnsignedTransaction(params) {
92
75
  return this.dataCall(RPCMethod.SignUnsignedTransaction, params);
93
- };
94
- WalletMethods.prototype.finalizeUnsignedTransaction = function (params) {
76
+ }
77
+ finalizeUnsignedTransaction(params) {
95
78
  return this.dataCall(RPCMethod.FinalizeUnsignedTransaction, params);
96
- };
97
- WalletMethods.prototype.clearTxCache = function () {
79
+ }
80
+ clearTxCache() {
98
81
  return this.dataCall(RPCMethod.ClearTxCache);
99
- };
100
- WalletMethods.prototype.listTransactions = function (params) {
82
+ }
83
+ listTransactions(params) {
101
84
  return this.dataCall(RPCMethod.GetTransaction, params);
102
- };
103
- WalletMethods.prototype.isOnline = function () {
85
+ }
86
+ isOnline() {
104
87
  return this.dataCall(RPCMethod.IsOnline);
105
- };
106
- WalletMethods.prototype.setOnlineMode = function (params) {
88
+ }
89
+ setOnlineMode(params) {
107
90
  return this.dataCall(RPCMethod.SetOfflineMode, params);
108
- };
109
- WalletMethods.prototype.setOfflineMode = function () {
91
+ }
92
+ setOfflineMode() {
110
93
  return this.dataCall(RPCMethod.SetOfflineMode);
111
- };
112
- WalletMethods.prototype.signData = function (data) {
94
+ }
95
+ signData(data) {
113
96
  return this.dataCall(RPCMethod.SignData, data.toObject());
114
- };
115
- WalletMethods.prototype.estimateFees = function (params) {
97
+ }
98
+ estimateFees(params) {
116
99
  return this.dataCall(RPCMethod.EstimateFees, params);
117
- };
118
- WalletMethods.prototype.estimateExtraDataSize = function (params) {
100
+ }
101
+ estimateExtraDataSize(params) {
119
102
  return this.dataCall(RPCMethod.EstimateExtraDataSize, params);
120
- };
121
- WalletMethods.prototype.networkInfo = function () {
103
+ }
104
+ networkInfo() {
122
105
  return this.dataCall(RPCMethod.NetworkInfo);
123
- };
124
- WalletMethods.prototype.decryptExtraData = function (params) {
106
+ }
107
+ decryptExtraData(params) {
125
108
  return this.dataCall(RPCMethod.DecryptExtraData, params);
126
- };
127
- WalletMethods.prototype.decryptCiphertext = function (params) {
109
+ }
110
+ decryptCiphertext(params) {
128
111
  return this.dataCall(RPCMethod.DecryptCiphertext, params);
129
- };
130
- WalletMethods.prototype.getMatchingKeys = function (params) {
112
+ }
113
+ getMatchingKeys(params) {
131
114
  return this.dataCall(RPCMethod.GetMatchingKeys, params);
132
- };
133
- WalletMethods.prototype.countMatchingEntries = function (params) {
115
+ }
116
+ countMatchingEntries(params) {
134
117
  return this.dataCall(RPCMethod.CountMatchingEntries, params);
135
- };
136
- WalletMethods.prototype.getValueFromKey = function (params) {
118
+ }
119
+ getValueFromKey(params) {
137
120
  return this.dataCall(RPCMethod.GetValueFromKey, params);
138
- };
139
- WalletMethods.prototype.store = function (params) {
121
+ }
122
+ store(params) {
140
123
  return this.dataCall(RPCMethod.Store, params);
141
- };
142
- WalletMethods.prototype["delete"] = function (params) {
124
+ }
125
+ delete(params) {
143
126
  return this.dataCall(RPCMethod.Delete, params);
144
- };
145
- WalletMethods.prototype.deleteTreeEntries = function (tree) {
146
- return this.dataCall(RPCMethod.DeleteTreeEntries, { tree: tree });
147
- };
148
- WalletMethods.prototype.hasKey = function (params) {
127
+ }
128
+ deleteTreeEntries(tree) {
129
+ return this.dataCall(RPCMethod.DeleteTreeEntries, { tree });
130
+ }
131
+ hasKey(params) {
149
132
  return this.dataCall(RPCMethod.HasKey, params);
150
- };
151
- WalletMethods.prototype.queryDB = function (params) {
133
+ }
134
+ queryDB(params) {
152
135
  return this.dataCall(RPCMethod.QueryDB, params);
153
- };
154
- return WalletMethods;
155
- }());
156
- export { WalletMethods };
157
- var WS = /** @class */ (function (_super) {
158
- __extends(WS, _super);
159
- function WS(endpoint, username, password) {
160
- var _this = _super.call(this, endpoint, { auth: "".concat(username, ":").concat(password) }) || this;
161
- _this.methods = new WalletMethods(_this);
162
- return _this;
163
- }
164
- return WS;
165
- }(WSRPC));
166
- export { WS };
136
+ }
137
+ }
138
+ export class WS extends WSRPC {
139
+ constructor(endpoint, username, password) {
140
+ super(endpoint, { auth: `${username}:${password}` });
141
+ this.methods = new WalletMethods(this);
142
+ }
143
+ }
167
144
  export default WS;
@@ -1,48 +1,70 @@
1
1
  import QRCode from 'qrcode';
2
- var App = /** @class */ (function () {
3
- function App(relayer) {
4
- var _this = this;
2
+ export class App {
3
+ constructor(relayer) {
5
4
  this.relayer = relayer;
6
- this.element = document.createElement("div");
7
- this.element.classList.add("xelis-xswd-relayer");
8
- this.contentElement = document.createElement("div");
9
- this.contentElement.classList.add("xelis-xswd-relayer-content");
5
+ this.element = document.createElement(`div`);
6
+ this.element.classList.add(`xelis-xswd-relayer`);
7
+ this.contentElement = document.createElement(`div`);
8
+ this.contentElement.classList.add(`xelis-xswd-relayer-content`);
10
9
  this.element.appendChild(this.contentElement);
11
- this.loadingElement = document.createElement("div");
12
- this.loadingElement.innerHTML = "\n <svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20.0001 12C20.0001 13.3811 19.6425 14.7386 18.9623 15.9405C18.282 17.1424 17.3022 18.1477 16.1182 18.8587C14.9341 19.5696 13.5862 19.9619 12.2056 19.9974C10.825 20.0328 9.45873 19.7103 8.23975 19.0612\" stroke=\"currentColor\" stroke-width=\"3.55556\" stroke-linecap=\"round\"/>\n </svg>\n ";
13
- this.loadingElement.classList.add("xelis-xswd-relayer-loading");
14
- this.errElement = document.createElement("div");
15
- this.errElement.classList.add("xelis-xswd-relayer-error");
16
- this.qrCodeElement = document.createElement("div");
17
- this.qrCodeElement.classList.add("xelis-xswd-relayer-qrcode");
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
- this.element.addEventListener("click", function (e) {
10
+ this.loadingElement = document.createElement(`div`);
11
+ this.loadingElement.innerHTML = `
12
+ <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
13
+ <path d="M20.0001 12C20.0001 13.3811 19.6425 14.7386 18.9623 15.9405C18.282 17.1424 17.3022 18.1477 16.1182 18.8587C14.9341 19.5696 13.5862 19.9619 12.2056 19.9974C10.825 20.0328 9.45873 19.7103 8.23975 19.0612" stroke="currentColor" stroke-width="3.55556" stroke-linecap="round"/>
14
+ </svg>
15
+ `;
16
+ this.loadingElement.classList.add(`xelis-xswd-relayer-loading`);
17
+ this.errElement = document.createElement(`div`);
18
+ this.errElement.classList.add(`xelis-xswd-relayer-error`);
19
+ this.qrCodeElement = document.createElement(`div`);
20
+ this.qrCodeElement.classList.add(`xelis-xswd-relayer-qrcode`);
21
+ this.qrCodeElement.innerHTML = `
22
+ <div class="xelis-xswd-relayer-scan-logo">
23
+ <svg fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
24
+ <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"/>
25
+ </svg>
26
+ </div>
27
+ <div class="xelis-xswd-relayer-logo-wrap">
28
+ <div class="xelis-xswd-relayer-logo">
29
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 778 743" fill="currentColor">
30
+ <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" />
31
+ <path d="M388.909 665.091L353.964 0L299.507 129.121L388.909 665.091Z" />
32
+ <path d="M424.056 0.202599L388.909 665.091L478.809 132.737L424.056 0.202599Z" />
33
+ </svg>
34
+ </div>
35
+ </div>
36
+ <div class="xelis-xswd-relayer-title">XSWD Relayer</div>
37
+ <canvas></canvas>
38
+ `;
39
+ this.element.addEventListener(`click`, (e) => {
20
40
  // close the app if clicking outside
21
- if (_this.element.isEqualNode(e.target)) {
22
- _this.relayer.close();
41
+ if (this.element.isEqualNode(e.target)) {
42
+ this.relayer.close();
23
43
  }
24
44
  });
25
45
  this.relayer.props.parent.appendChild(this.element);
26
46
  this.setLoading();
27
47
  }
28
- App.prototype.clear = function () {
48
+ clear() {
29
49
  this.loadingElement.remove();
30
50
  this.errElement.remove();
31
51
  this.qrCodeElement.remove();
32
- };
33
- App.prototype.setError = function (msg) {
52
+ }
53
+ setError(msg) {
34
54
  this.clear();
35
- this.errElement.innerHTML = "\n <div class=\"xelis-xswd-relayer-error-text\">error: ".concat(msg, "</div>\n ");
55
+ this.errElement.innerHTML = `
56
+ <div class="xelis-xswd-relayer-error-text">error: ${msg}</div>
57
+ `;
36
58
  this.contentElement.appendChild(this.errElement);
37
- };
38
- App.prototype.setLoading = function () {
59
+ }
60
+ setLoading() {
39
61
  this.clear();
40
62
  this.contentElement.appendChild(this.loadingElement);
41
- };
42
- App.prototype.setQRCode = function (channelId) {
63
+ }
64
+ setQRCode(channelId) {
43
65
  this.clear();
44
- var canvas = this.qrCodeElement.querySelector("canvas");
45
- var qrCodeData = JSON.stringify({
66
+ const canvas = this.qrCodeElement.querySelector(`canvas`);
67
+ const qrCodeData = JSON.stringify({
46
68
  inner: {},
47
69
  channel_id: channelId,
48
70
  relayer: this.relayer.props.url,
@@ -50,12 +72,10 @@ var App = /** @class */ (function () {
50
72
  });
51
73
  QRCode.toCanvas(canvas, qrCodeData, {
52
74
  color: {
53
- dark: "#fff",
54
- light: "#000" // background
75
+ dark: `#fff`,
76
+ light: `#000` // background
55
77
  }
56
78
  });
57
79
  this.contentElement.appendChild(this.qrCodeElement);
58
- };
59
- return App;
60
- }());
61
- export { App };
80
+ }
81
+ }