@xelis/sdk 0.11.14 → 0.11.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/address/bech32.js +47 -56
- package/dist/cjs/address/index.js +20 -21
- package/dist/cjs/config.js +26 -38
- package/dist/cjs/contract/contract.js +178 -0
- package/dist/cjs/contract/typed_contract.js +259 -0
- package/dist/cjs/contract/xvm_serializer.js +170 -0
- package/dist/cjs/daemon/rpc.js +157 -168
- package/dist/cjs/daemon/types.js +4 -1
- package/dist/cjs/daemon/websocket.js +170 -181
- package/dist/cjs/data/element.js +39 -41
- package/dist/cjs/data/value.js +106 -111
- package/dist/cjs/react/daemon.js +33 -43
- package/dist/cjs/rpc/http.js +75 -132
- package/dist/cjs/rpc/parse_json/parse_json.js +4 -4
- package/dist/cjs/rpc/types.js +1 -1
- package/dist/cjs/rpc/websocket.js +131 -201
- package/dist/cjs/wallet/rpc.js +98 -117
- package/dist/cjs/wallet/types.js +1 -1
- package/dist/cjs/wallet/websocket.js +105 -126
- package/dist/cjs/xswd/relayer/app.js +57 -36
- package/dist/cjs/xswd/relayer/index.js +25 -27
- package/dist/cjs/xswd/types.js +1 -1
- package/dist/cjs/xswd/websocket.js +15 -33
- package/dist/esm/address/bech32.js +46 -55
- package/dist/esm/address/index.js +16 -17
- package/dist/esm/config.js +25 -37
- package/dist/esm/contract/contract.js +172 -0
- package/dist/esm/contract/typed_contract.js +251 -0
- package/dist/esm/contract/xvm_serializer.js +163 -0
- package/dist/esm/daemon/rpc.js +153 -165
- package/dist/esm/daemon/types.js +3 -0
- package/dist/esm/daemon/websocket.js +166 -179
- package/dist/esm/data/element.js +37 -40
- package/dist/esm/data/value.js +104 -112
- package/dist/esm/react/daemon.js +30 -40
- package/dist/esm/rpc/http.js +73 -131
- package/dist/esm/rpc/parse_json/parse_json.js +1 -1
- package/dist/esm/rpc/websocket.js +126 -197
- package/dist/esm/wallet/rpc.js +93 -113
- package/dist/esm/wallet/websocket.js +101 -124
- package/dist/esm/xswd/relayer/app.js +54 -34
- package/dist/esm/xswd/relayer/index.js +22 -24
- package/dist/esm/xswd/websocket.js +10 -29
- package/dist/types/contract/contract.d.ts +80 -0
- package/dist/types/contract/typed_contract.d.ts +94 -0
- package/dist/types/contract/xvm_serializer.d.ts +69 -0
- package/dist/types/daemon/rpc.d.ts +5 -2
- package/dist/types/daemon/types.d.ts +99 -20
- package/dist/types/daemon/websocket.d.ts +5 -2
- package/dist/types/wallet/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/esm/wallet/rpc.js
CHANGED
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
12
|
+
}
|
|
13
|
+
getNetwork() {
|
|
31
14
|
return this.request(RPCMethod.GetNetwork);
|
|
32
|
-
}
|
|
33
|
-
|
|
15
|
+
}
|
|
16
|
+
getNonce() {
|
|
34
17
|
return this.request(RPCMethod.GetNonce);
|
|
35
|
-
}
|
|
36
|
-
|
|
18
|
+
}
|
|
19
|
+
getTopoheight() {
|
|
37
20
|
return this.request(RPCMethod.GetTopoheight);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (params === void 0) { params = {}; }
|
|
21
|
+
}
|
|
22
|
+
getAddress(params = {}) {
|
|
41
23
|
return this.request(RPCMethod.GetAddress, params);
|
|
42
|
-
}
|
|
43
|
-
|
|
24
|
+
}
|
|
25
|
+
splitAddress(params) {
|
|
44
26
|
return this.request(RPCMethod.SplitAddress, params);
|
|
45
|
-
}
|
|
46
|
-
|
|
27
|
+
}
|
|
28
|
+
rescan(params) {
|
|
47
29
|
return this.request(RPCMethod.Rescan, params);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return this.request(RPCMethod.GetBalance, { asset
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return this.request(RPCMethod.HasBalance, { asset
|
|
54
|
-
}
|
|
55
|
-
|
|
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
|
-
|
|
39
|
+
}
|
|
40
|
+
getAssetPrecision(params) {
|
|
59
41
|
return this.request(RPCMethod.GetAssetPrecision, params);
|
|
60
|
-
}
|
|
61
|
-
|
|
42
|
+
}
|
|
43
|
+
getAssets() {
|
|
62
44
|
return this.request(RPCMethod.GetAssets);
|
|
63
|
-
}
|
|
64
|
-
|
|
45
|
+
}
|
|
46
|
+
getAsset(params) {
|
|
65
47
|
return this.request(RPCMethod.GetAsset, params);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return this.request(RPCMethod.GetTransaction, { hash
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return this.request(RPCMethod.SearchTransaction, { hash
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return this.request(RPCMethod.DumpTransaction, { hash
|
|
75
|
-
}
|
|
76
|
-
|
|
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
|
-
|
|
60
|
+
}
|
|
61
|
+
buildTransactionOffline(params) {
|
|
80
62
|
return this.request(RPCMethod.BuildTransactionOffline, params);
|
|
81
|
-
}
|
|
82
|
-
|
|
63
|
+
}
|
|
64
|
+
buildUnsignedTransaction(params) {
|
|
83
65
|
return this.request(RPCMethod.BuildUnsignedTransaction, params);
|
|
84
|
-
}
|
|
85
|
-
|
|
66
|
+
}
|
|
67
|
+
signUnsignedTransaction(params) {
|
|
86
68
|
return this.request(RPCMethod.SignUnsignedTransaction, params);
|
|
87
|
-
}
|
|
88
|
-
|
|
69
|
+
}
|
|
70
|
+
finalizeUnsignedTransaction(params) {
|
|
89
71
|
return this.request(RPCMethod.FinalizeUnsignedTransaction, params);
|
|
90
|
-
}
|
|
91
|
-
|
|
72
|
+
}
|
|
73
|
+
clearTxCache() {
|
|
92
74
|
return this.request(RPCMethod.ClearTxCache);
|
|
93
|
-
}
|
|
94
|
-
|
|
75
|
+
}
|
|
76
|
+
listTransactions(params) {
|
|
95
77
|
return this.request(RPCMethod.ListTransactions, params);
|
|
96
|
-
}
|
|
97
|
-
|
|
78
|
+
}
|
|
79
|
+
isOnline() {
|
|
98
80
|
return this.request(RPCMethod.IsOnline);
|
|
99
|
-
}
|
|
100
|
-
|
|
81
|
+
}
|
|
82
|
+
setOnlineMode(params) {
|
|
101
83
|
return this.request(RPCMethod.SetOnlineMode, params);
|
|
102
|
-
}
|
|
103
|
-
|
|
84
|
+
}
|
|
85
|
+
setOfflineMode() {
|
|
104
86
|
return this.request(RPCMethod.SetOfflineMode);
|
|
105
|
-
}
|
|
106
|
-
|
|
87
|
+
}
|
|
88
|
+
signData(data) {
|
|
107
89
|
return this.request(RPCMethod.SignData, data.toObject());
|
|
108
|
-
}
|
|
109
|
-
|
|
90
|
+
}
|
|
91
|
+
estimateFees(params) {
|
|
110
92
|
return this.request(RPCMethod.EstimateFees, params);
|
|
111
|
-
}
|
|
112
|
-
|
|
93
|
+
}
|
|
94
|
+
estimateExtraDataSize(params) {
|
|
113
95
|
return this.request(RPCMethod.EstimateExtraDataSize, params);
|
|
114
|
-
}
|
|
115
|
-
|
|
96
|
+
}
|
|
97
|
+
networkInfo() {
|
|
116
98
|
return this.request(RPCMethod.NetworkInfo);
|
|
117
|
-
}
|
|
118
|
-
|
|
99
|
+
}
|
|
100
|
+
decryptExtraData(params) {
|
|
119
101
|
return this.request(RPCMethod.DecryptExtraData, params);
|
|
120
|
-
}
|
|
121
|
-
|
|
102
|
+
}
|
|
103
|
+
decryptCiphertext(params) {
|
|
122
104
|
return this.request(RPCMethod.DecryptCiphertext, params);
|
|
123
|
-
}
|
|
124
|
-
|
|
105
|
+
}
|
|
106
|
+
getMatchingKeys(params) {
|
|
125
107
|
return this.request(RPCMethod.GetMatchingKeys, params);
|
|
126
|
-
}
|
|
127
|
-
|
|
108
|
+
}
|
|
109
|
+
countMatchingEntries(params) {
|
|
128
110
|
return this.request(RPCMethod.CountMatchingEntries, params);
|
|
129
|
-
}
|
|
130
|
-
|
|
111
|
+
}
|
|
112
|
+
getValueFromKey(params) {
|
|
131
113
|
return this.request(RPCMethod.GetValueFromKey, params);
|
|
132
|
-
}
|
|
133
|
-
|
|
114
|
+
}
|
|
115
|
+
store(params) {
|
|
134
116
|
return this.request(RPCMethod.Store, params);
|
|
135
|
-
}
|
|
136
|
-
|
|
117
|
+
}
|
|
118
|
+
delete(params) {
|
|
137
119
|
return this.request(RPCMethod.Delete, params);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return this.request(RPCMethod.DeleteTreeEntries, { tree
|
|
141
|
-
}
|
|
142
|
-
|
|
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
|
-
|
|
126
|
+
}
|
|
127
|
+
queryDB(params) {
|
|
146
128
|
return this.request(RPCMethod.QueryDB, params);
|
|
147
|
-
}
|
|
148
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
8
|
+
dataCall(method, params) {
|
|
25
9
|
return this.ws.dataCall(this.prefix + method, params);
|
|
26
|
-
}
|
|
27
|
-
|
|
10
|
+
}
|
|
11
|
+
closeListener(event, listener) {
|
|
28
12
|
this.ws.closeListener(event, listener);
|
|
29
|
-
}
|
|
30
|
-
|
|
13
|
+
}
|
|
14
|
+
listen(event, listener) {
|
|
31
15
|
this.ws.listen(this.prefix + event, listener);
|
|
32
|
-
}
|
|
33
|
-
|
|
16
|
+
}
|
|
17
|
+
getVersion() {
|
|
34
18
|
return this.dataCall(RPCMethod.GetVersion);
|
|
35
|
-
}
|
|
36
|
-
|
|
19
|
+
}
|
|
20
|
+
getNetwork() {
|
|
37
21
|
return this.dataCall(RPCMethod.GetNetwork);
|
|
38
|
-
}
|
|
39
|
-
|
|
22
|
+
}
|
|
23
|
+
getNonce() {
|
|
40
24
|
return this.dataCall(RPCMethod.GetNonce);
|
|
41
|
-
}
|
|
42
|
-
|
|
25
|
+
}
|
|
26
|
+
getTopoheight() {
|
|
43
27
|
return this.dataCall(RPCMethod.GetTopoheight);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (params === void 0) { params = {}; }
|
|
28
|
+
}
|
|
29
|
+
getAddress(params = {}) {
|
|
47
30
|
return this.dataCall(RPCMethod.GetAddress, params);
|
|
48
|
-
}
|
|
49
|
-
|
|
31
|
+
}
|
|
32
|
+
splitAddress(params) {
|
|
50
33
|
return this.dataCall(RPCMethod.SplitAddress, params);
|
|
51
|
-
}
|
|
52
|
-
|
|
34
|
+
}
|
|
35
|
+
rescan(params) {
|
|
53
36
|
return this.dataCall(RPCMethod.Rescan, params);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return this.dataCall(RPCMethod.GetBalance, { asset
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return this.dataCall(RPCMethod.HasBalance, { asset
|
|
60
|
-
}
|
|
61
|
-
|
|
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
|
-
|
|
46
|
+
}
|
|
47
|
+
getAssetPrecision(params) {
|
|
65
48
|
return this.dataCall(RPCMethod.GetAssetPrecision, params);
|
|
66
|
-
}
|
|
67
|
-
|
|
49
|
+
}
|
|
50
|
+
getAssets() {
|
|
68
51
|
return this.dataCall(RPCMethod.GetAssets);
|
|
69
|
-
}
|
|
70
|
-
|
|
52
|
+
}
|
|
53
|
+
getAsset(params) {
|
|
71
54
|
return this.dataCall(RPCMethod.GetAsset, params);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return this.dataCall(RPCMethod.GetTransaction, { hash
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return this.dataCall(RPCMethod.SearchTransaction, { hash
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return this.dataCall(RPCMethod.DumpTransaction, { hash
|
|
81
|
-
}
|
|
82
|
-
|
|
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
|
-
|
|
67
|
+
}
|
|
68
|
+
buildTransactionOffline(params) {
|
|
86
69
|
return this.dataCall(RPCMethod.BuildTransactionOffline, params);
|
|
87
|
-
}
|
|
88
|
-
|
|
70
|
+
}
|
|
71
|
+
buildUnsignedTransaction(params) {
|
|
89
72
|
return this.dataCall(RPCMethod.BuildUnsignedTransaction, params);
|
|
90
|
-
}
|
|
91
|
-
|
|
73
|
+
}
|
|
74
|
+
signUnsignedTransaction(params) {
|
|
92
75
|
return this.dataCall(RPCMethod.SignUnsignedTransaction, params);
|
|
93
|
-
}
|
|
94
|
-
|
|
76
|
+
}
|
|
77
|
+
finalizeUnsignedTransaction(params) {
|
|
95
78
|
return this.dataCall(RPCMethod.FinalizeUnsignedTransaction, params);
|
|
96
|
-
}
|
|
97
|
-
|
|
79
|
+
}
|
|
80
|
+
clearTxCache() {
|
|
98
81
|
return this.dataCall(RPCMethod.ClearTxCache);
|
|
99
|
-
}
|
|
100
|
-
|
|
82
|
+
}
|
|
83
|
+
listTransactions(params) {
|
|
101
84
|
return this.dataCall(RPCMethod.GetTransaction, params);
|
|
102
|
-
}
|
|
103
|
-
|
|
85
|
+
}
|
|
86
|
+
isOnline() {
|
|
104
87
|
return this.dataCall(RPCMethod.IsOnline);
|
|
105
|
-
}
|
|
106
|
-
|
|
88
|
+
}
|
|
89
|
+
setOnlineMode(params) {
|
|
107
90
|
return this.dataCall(RPCMethod.SetOfflineMode, params);
|
|
108
|
-
}
|
|
109
|
-
|
|
91
|
+
}
|
|
92
|
+
setOfflineMode() {
|
|
110
93
|
return this.dataCall(RPCMethod.SetOfflineMode);
|
|
111
|
-
}
|
|
112
|
-
|
|
94
|
+
}
|
|
95
|
+
signData(data) {
|
|
113
96
|
return this.dataCall(RPCMethod.SignData, data.toObject());
|
|
114
|
-
}
|
|
115
|
-
|
|
97
|
+
}
|
|
98
|
+
estimateFees(params) {
|
|
116
99
|
return this.dataCall(RPCMethod.EstimateFees, params);
|
|
117
|
-
}
|
|
118
|
-
|
|
100
|
+
}
|
|
101
|
+
estimateExtraDataSize(params) {
|
|
119
102
|
return this.dataCall(RPCMethod.EstimateExtraDataSize, params);
|
|
120
|
-
}
|
|
121
|
-
|
|
103
|
+
}
|
|
104
|
+
networkInfo() {
|
|
122
105
|
return this.dataCall(RPCMethod.NetworkInfo);
|
|
123
|
-
}
|
|
124
|
-
|
|
106
|
+
}
|
|
107
|
+
decryptExtraData(params) {
|
|
125
108
|
return this.dataCall(RPCMethod.DecryptExtraData, params);
|
|
126
|
-
}
|
|
127
|
-
|
|
109
|
+
}
|
|
110
|
+
decryptCiphertext(params) {
|
|
128
111
|
return this.dataCall(RPCMethod.DecryptCiphertext, params);
|
|
129
|
-
}
|
|
130
|
-
|
|
112
|
+
}
|
|
113
|
+
getMatchingKeys(params) {
|
|
131
114
|
return this.dataCall(RPCMethod.GetMatchingKeys, params);
|
|
132
|
-
}
|
|
133
|
-
|
|
115
|
+
}
|
|
116
|
+
countMatchingEntries(params) {
|
|
134
117
|
return this.dataCall(RPCMethod.CountMatchingEntries, params);
|
|
135
|
-
}
|
|
136
|
-
|
|
118
|
+
}
|
|
119
|
+
getValueFromKey(params) {
|
|
137
120
|
return this.dataCall(RPCMethod.GetValueFromKey, params);
|
|
138
|
-
}
|
|
139
|
-
|
|
121
|
+
}
|
|
122
|
+
store(params) {
|
|
140
123
|
return this.dataCall(RPCMethod.Store, params);
|
|
141
|
-
}
|
|
142
|
-
|
|
124
|
+
}
|
|
125
|
+
delete(params) {
|
|
143
126
|
return this.dataCall(RPCMethod.Delete, params);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return this.dataCall(RPCMethod.DeleteTreeEntries, { tree
|
|
147
|
-
}
|
|
148
|
-
|
|
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
|
-
|
|
133
|
+
}
|
|
134
|
+
queryDB(params) {
|
|
152
135
|
return this.dataCall(RPCMethod.QueryDB, params);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
var _this = this;
|
|
2
|
+
export class App {
|
|
3
|
+
constructor(relayer) {
|
|
5
4
|
this.relayer = relayer;
|
|
6
|
-
this.element = document.createElement(
|
|
7
|
-
this.element.classList.add(
|
|
8
|
-
this.contentElement = document.createElement(
|
|
9
|
-
this.contentElement.classList.add(
|
|
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(
|
|
12
|
-
this.loadingElement.innerHTML =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
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 (
|
|
22
|
-
|
|
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
|
-
|
|
48
|
+
clear() {
|
|
29
49
|
this.loadingElement.remove();
|
|
30
50
|
this.errElement.remove();
|
|
31
51
|
this.qrCodeElement.remove();
|
|
32
|
-
}
|
|
33
|
-
|
|
52
|
+
}
|
|
53
|
+
setError(msg) {
|
|
34
54
|
this.clear();
|
|
35
|
-
this.errElement.innerHTML =
|
|
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
|
-
|
|
59
|
+
}
|
|
60
|
+
setLoading() {
|
|
39
61
|
this.clear();
|
|
40
62
|
this.contentElement.appendChild(this.loadingElement);
|
|
41
|
-
}
|
|
42
|
-
|
|
63
|
+
}
|
|
64
|
+
setQRCode(channelId) {
|
|
43
65
|
this.clear();
|
|
44
|
-
|
|
45
|
-
|
|
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:
|
|
54
|
-
light:
|
|
75
|
+
dark: `#fff`,
|
|
76
|
+
light: `#000` // background
|
|
55
77
|
}
|
|
56
78
|
});
|
|
57
79
|
this.contentElement.appendChild(this.qrCodeElement);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}());
|
|
61
|
-
export { App };
|
|
80
|
+
}
|
|
81
|
+
}
|