@dappworks/kit 0.4.175 → 0.4.177
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/StorageState-qzikHBY8.d.ts +66 -0
- package/dist/aiem.d.mts +4 -4
- package/dist/aiem.mjs +3 -1228
- package/dist/aiem.mjs.map +1 -1
- package/dist/chunk-2EXDWOHY.mjs +58 -0
- package/dist/chunk-3DOB34HY.mjs +292 -0
- package/dist/chunk-3DOB34HY.mjs.map +1 -0
- package/dist/{chunk-3O7QI47S.mjs → chunk-3HD22664.mjs} +2 -2
- package/dist/chunk-5JMONDHE.mjs +436 -0
- package/dist/chunk-5JMONDHE.mjs.map +1 -0
- package/dist/chunk-L6XS2K2K.mjs +76 -0
- package/dist/chunk-L6XS2K2K.mjs.map +1 -0
- package/dist/{chunk-AIZ7XDNV.mjs → chunk-TQNAAA4I.mjs} +22 -21
- package/dist/chunk-TQNAAA4I.mjs.map +1 -0
- package/dist/{chunk-GKK6EXKY.mjs → chunk-XSLAZWOE.mjs} +4 -4
- package/dist/dev.d.mts +3 -3
- package/dist/dev.mjs +2 -2
- package/dist/experimental.d.mts +3 -3
- package/dist/experimental.mjs +1 -1
- package/dist/form.d.mts +15 -15
- package/dist/form.mjs +2 -2
- package/dist/form.mjs.map +1 -1
- package/dist/index.d.mts +6 -67
- package/dist/index.mjs +3 -291
- package/dist/index.mjs.map +1 -1
- package/dist/inspector.d.mts +2 -2
- package/dist/inspector.mjs +1 -1
- package/dist/jsontable.d.mts +8 -8
- package/dist/jsontable.mjs +4 -4
- package/dist/metrics.d.mts +15 -15
- package/dist/metrics.mjs +4 -4
- package/dist/plugins.d.mts +11 -11
- package/dist/plugins.mjs +21 -83
- package/dist/plugins.mjs.map +1 -1
- package/dist/ui.d.mts +7 -7
- package/dist/ui.mjs +3 -3
- package/dist/utils.mjs +1 -1
- package/dist/wallet.d.mts +152 -0
- package/dist/wallet.mjs +3631 -0
- package/dist/wallet.mjs.map +1 -0
- package/package.json +13 -3
- package/dist/chunk-AIZ7XDNV.mjs.map +0 -1
- package/dist/chunk-R4SQKVDQ.mjs +0 -35
- /package/dist/{chunk-R4SQKVDQ.mjs.map → chunk-2EXDWOHY.mjs.map} +0 -0
- /package/dist/{chunk-3O7QI47S.mjs.map → chunk-3HD22664.mjs.map} +0 -0
- /package/dist/{chunk-GKK6EXKY.mjs.map → chunk-XSLAZWOE.mjs.map} +0 -0
package/dist/wallet.mjs
ADDED
|
@@ -0,0 +1,3631 @@
|
|
|
1
|
+
import { AIem } from './chunk-5JMONDHE.mjs';
|
|
2
|
+
import './chunk-7MDKCI65.mjs';
|
|
3
|
+
import { StorageState, ObjectPool, PromiseHook, BigNumberState } from './chunk-3DOB34HY.mjs';
|
|
4
|
+
import './chunk-OISBIKAQ.mjs';
|
|
5
|
+
import { DialogStore } from './chunk-L6XS2K2K.mjs';
|
|
6
|
+
import { ToastPlugin } from './chunk-IMOLRP7I.mjs';
|
|
7
|
+
import './chunk-K73JTEJQ.mjs';
|
|
8
|
+
import { RootStore } from './chunk-XSGTWROT.mjs';
|
|
9
|
+
import { helper } from './chunk-UPGWJHSO.mjs';
|
|
10
|
+
import './chunk-ONVPCAMQ.mjs';
|
|
11
|
+
import './chunk-K7LFG5BA.mjs';
|
|
12
|
+
import { __commonJS, __spreadValues, __spreadProps, __toESM } from './chunk-2EXDWOHY.mjs';
|
|
13
|
+
import { RainbowKitProvider, darkTheme, lightTheme, getDefaultConfig, useConnectModal } from '@rainbow-me/rainbowkit';
|
|
14
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
15
|
+
import React2, { useEffect } from 'react';
|
|
16
|
+
import { observer } from 'mobx-react-lite';
|
|
17
|
+
import { WagmiProvider, useWalletClient, useAccount, useSwitchChain, useConnect } from 'wagmi';
|
|
18
|
+
import BigNumber from 'bignumber.js';
|
|
19
|
+
import EventEmitter from 'events';
|
|
20
|
+
import { encodeFunctionData, hashMessage, hashTypedData } from 'viem';
|
|
21
|
+
import { iopayWallet, metaMaskWallet, walletConnectWallet, okxWallet, binanceWallet } from '@rainbow-me/rainbowkit/wallets';
|
|
22
|
+
import { iotex } from 'viem/chains';
|
|
23
|
+
|
|
24
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/utils.js
|
|
25
|
+
var require_utils = __commonJS({
|
|
26
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/utils.js"(exports) {
|
|
27
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
28
|
+
function adopt(value) {
|
|
29
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
30
|
+
resolve(value);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
34
|
+
function fulfilled(value) {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function rejected(value) {
|
|
42
|
+
try {
|
|
43
|
+
step(generator["throw"](value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function step(result) {
|
|
49
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
50
|
+
}
|
|
51
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.getData = exports.fetchData = exports.stringifyQuery = exports.insertParams = void 0;
|
|
56
|
+
var isErrorResponse = (data) => {
|
|
57
|
+
const isObject = typeof data === "object" && data !== null;
|
|
58
|
+
return isObject && "code" in data && "message" in data;
|
|
59
|
+
};
|
|
60
|
+
function replaceParam(str, key, value) {
|
|
61
|
+
return str.replace(new RegExp(`\\{${key}\\}`, "g"), value);
|
|
62
|
+
}
|
|
63
|
+
function insertParams(template, params) {
|
|
64
|
+
return params ? Object.keys(params).reduce((result, key) => {
|
|
65
|
+
return replaceParam(result, key, String(params[key]));
|
|
66
|
+
}, template) : template;
|
|
67
|
+
}
|
|
68
|
+
exports.insertParams = insertParams;
|
|
69
|
+
function stringifyQuery(query) {
|
|
70
|
+
if (!query) {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
const searchParams = new URLSearchParams();
|
|
74
|
+
Object.keys(query).forEach((key) => {
|
|
75
|
+
if (query[key] != null) {
|
|
76
|
+
searchParams.append(key, String(query[key]));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const searchString = searchParams.toString();
|
|
80
|
+
return searchString ? `?${searchString}` : "";
|
|
81
|
+
}
|
|
82
|
+
exports.stringifyQuery = stringifyQuery;
|
|
83
|
+
function parseResponse(resp) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
let json;
|
|
86
|
+
try {
|
|
87
|
+
json = yield resp.json();
|
|
88
|
+
} catch (_a) {
|
|
89
|
+
json = {};
|
|
90
|
+
}
|
|
91
|
+
if (!resp.ok) {
|
|
92
|
+
const errTxt = isErrorResponse(json) ? `CGW error - ${json.code}: ${json.message}` : `CGW error - status ${resp.statusText}`;
|
|
93
|
+
throw new Error(errTxt);
|
|
94
|
+
}
|
|
95
|
+
return json;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function fetchData(url, method, body, headers, credentials) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const requestHeaders = Object.assign({ "Content-Type": "application/json" }, headers);
|
|
101
|
+
const options = {
|
|
102
|
+
method: method !== null && method !== void 0 ? method : "POST",
|
|
103
|
+
headers: requestHeaders
|
|
104
|
+
};
|
|
105
|
+
if (credentials) {
|
|
106
|
+
options["credentials"] = credentials;
|
|
107
|
+
}
|
|
108
|
+
if (body != null) {
|
|
109
|
+
options.body = typeof body === "string" ? body : JSON.stringify(body);
|
|
110
|
+
}
|
|
111
|
+
const resp = yield fetch(url, options);
|
|
112
|
+
return parseResponse(resp);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
exports.fetchData = fetchData;
|
|
116
|
+
function getData(url, headers, credentials) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const options = {
|
|
119
|
+
method: "GET"
|
|
120
|
+
};
|
|
121
|
+
if (headers) {
|
|
122
|
+
options["headers"] = Object.assign(Object.assign({}, headers), { "Content-Type": "application/json" });
|
|
123
|
+
}
|
|
124
|
+
if (credentials) {
|
|
125
|
+
options["credentials"] = credentials;
|
|
126
|
+
}
|
|
127
|
+
const resp = yield fetch(url, options);
|
|
128
|
+
return parseResponse(resp);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
exports.getData = getData;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/endpoint.js
|
|
136
|
+
var require_endpoint = __commonJS({
|
|
137
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/endpoint.js"(exports) {
|
|
138
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
139
|
+
exports.getEndpoint = exports.deleteEndpoint = exports.putEndpoint = exports.postEndpoint = void 0;
|
|
140
|
+
var utils_1 = require_utils();
|
|
141
|
+
function makeUrl(baseUrl, path, pathParams, query) {
|
|
142
|
+
const pathname = (0, utils_1.insertParams)(path, pathParams);
|
|
143
|
+
const search = (0, utils_1.stringifyQuery)(query);
|
|
144
|
+
return `${baseUrl}${pathname}${search}`;
|
|
145
|
+
}
|
|
146
|
+
function postEndpoint(baseUrl, path, params) {
|
|
147
|
+
const url = makeUrl(baseUrl, path, params === null || params === void 0 ? void 0 : params.path, params === null || params === void 0 ? void 0 : params.query);
|
|
148
|
+
return (0, utils_1.fetchData)(url, "POST", params === null || params === void 0 ? void 0 : params.body, params === null || params === void 0 ? void 0 : params.headers, params === null || params === void 0 ? void 0 : params.credentials);
|
|
149
|
+
}
|
|
150
|
+
exports.postEndpoint = postEndpoint;
|
|
151
|
+
function putEndpoint(baseUrl, path, params) {
|
|
152
|
+
const url = makeUrl(baseUrl, path, params === null || params === void 0 ? void 0 : params.path, params === null || params === void 0 ? void 0 : params.query);
|
|
153
|
+
return (0, utils_1.fetchData)(url, "PUT", params === null || params === void 0 ? void 0 : params.body, params === null || params === void 0 ? void 0 : params.headers, params === null || params === void 0 ? void 0 : params.credentials);
|
|
154
|
+
}
|
|
155
|
+
exports.putEndpoint = putEndpoint;
|
|
156
|
+
function deleteEndpoint(baseUrl, path, params) {
|
|
157
|
+
const url = makeUrl(baseUrl, path, params === null || params === void 0 ? void 0 : params.path, params === null || params === void 0 ? void 0 : params.query);
|
|
158
|
+
return (0, utils_1.fetchData)(url, "DELETE", params === null || params === void 0 ? void 0 : params.body, params === null || params === void 0 ? void 0 : params.headers, params === null || params === void 0 ? void 0 : params.credentials);
|
|
159
|
+
}
|
|
160
|
+
exports.deleteEndpoint = deleteEndpoint;
|
|
161
|
+
function getEndpoint(baseUrl, path, params, rawUrl) {
|
|
162
|
+
if (rawUrl) {
|
|
163
|
+
return (0, utils_1.getData)(rawUrl, void 0, params === null || params === void 0 ? void 0 : params.credentials);
|
|
164
|
+
}
|
|
165
|
+
const url = makeUrl(baseUrl, path, params === null || params === void 0 ? void 0 : params.path, params === null || params === void 0 ? void 0 : params.query);
|
|
166
|
+
return (0, utils_1.getData)(url, params === null || params === void 0 ? void 0 : params.headers, params === null || params === void 0 ? void 0 : params.credentials);
|
|
167
|
+
}
|
|
168
|
+
exports.getEndpoint = getEndpoint;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/config.js
|
|
173
|
+
var require_config = __commonJS({
|
|
174
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/config.js"(exports) {
|
|
175
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
176
|
+
exports.DEFAULT_BASE_URL = void 0;
|
|
177
|
+
exports.DEFAULT_BASE_URL = "https://safe-client.safe.global";
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/safe-info.js
|
|
182
|
+
var require_safe_info = __commonJS({
|
|
183
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/safe-info.js"(exports) {
|
|
184
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
185
|
+
exports.ImplementationVersionState = void 0;
|
|
186
|
+
(function(ImplementationVersionState2) {
|
|
187
|
+
ImplementationVersionState2["UP_TO_DATE"] = "UP_TO_DATE";
|
|
188
|
+
ImplementationVersionState2["OUTDATED"] = "OUTDATED";
|
|
189
|
+
ImplementationVersionState2["UNKNOWN"] = "UNKNOWN";
|
|
190
|
+
})(exports.ImplementationVersionState || (exports.ImplementationVersionState = {}));
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/safe-apps.js
|
|
195
|
+
var require_safe_apps = __commonJS({
|
|
196
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/safe-apps.js"(exports) {
|
|
197
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
198
|
+
exports.SafeAppSocialPlatforms = exports.SafeAppFeatures = exports.SafeAppAccessPolicyTypes = void 0;
|
|
199
|
+
(function(SafeAppAccessPolicyTypes2) {
|
|
200
|
+
SafeAppAccessPolicyTypes2["NoRestrictions"] = "NO_RESTRICTIONS";
|
|
201
|
+
SafeAppAccessPolicyTypes2["DomainAllowlist"] = "DOMAIN_ALLOWLIST";
|
|
202
|
+
})(exports.SafeAppAccessPolicyTypes || (exports.SafeAppAccessPolicyTypes = {}));
|
|
203
|
+
(function(SafeAppFeatures2) {
|
|
204
|
+
SafeAppFeatures2["BATCHED_TRANSACTIONS"] = "BATCHED_TRANSACTIONS";
|
|
205
|
+
})(exports.SafeAppFeatures || (exports.SafeAppFeatures = {}));
|
|
206
|
+
(function(SafeAppSocialPlatforms2) {
|
|
207
|
+
SafeAppSocialPlatforms2["TWITTER"] = "TWITTER";
|
|
208
|
+
SafeAppSocialPlatforms2["GITHUB"] = "GITHUB";
|
|
209
|
+
SafeAppSocialPlatforms2["DISCORD"] = "DISCORD";
|
|
210
|
+
})(exports.SafeAppSocialPlatforms || (exports.SafeAppSocialPlatforms = {}));
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/transactions.js
|
|
215
|
+
var require_transactions = __commonJS({
|
|
216
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/transactions.js"(exports) {
|
|
217
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
218
|
+
exports.LabelValue = exports.StartTimeValue = exports.DurationType = exports.DetailedExecutionInfoType = exports.TransactionListItemType = exports.ConflictType = exports.TransactionInfoType = exports.SettingsInfoType = exports.TransactionTokenType = exports.TransferDirection = exports.TransactionStatus = exports.Operation = void 0;
|
|
219
|
+
(function(Operation3) {
|
|
220
|
+
Operation3[Operation3["CALL"] = 0] = "CALL";
|
|
221
|
+
Operation3[Operation3["DELEGATE"] = 1] = "DELEGATE";
|
|
222
|
+
})(exports.Operation || (exports.Operation = {}));
|
|
223
|
+
(function(TransactionStatus3) {
|
|
224
|
+
TransactionStatus3["AWAITING_CONFIRMATIONS"] = "AWAITING_CONFIRMATIONS";
|
|
225
|
+
TransactionStatus3["AWAITING_EXECUTION"] = "AWAITING_EXECUTION";
|
|
226
|
+
TransactionStatus3["CANCELLED"] = "CANCELLED";
|
|
227
|
+
TransactionStatus3["FAILED"] = "FAILED";
|
|
228
|
+
TransactionStatus3["SUCCESS"] = "SUCCESS";
|
|
229
|
+
})(exports.TransactionStatus || (exports.TransactionStatus = {}));
|
|
230
|
+
(function(TransferDirection3) {
|
|
231
|
+
TransferDirection3["INCOMING"] = "INCOMING";
|
|
232
|
+
TransferDirection3["OUTGOING"] = "OUTGOING";
|
|
233
|
+
TransferDirection3["UNKNOWN"] = "UNKNOWN";
|
|
234
|
+
})(exports.TransferDirection || (exports.TransferDirection = {}));
|
|
235
|
+
(function(TransactionTokenType2) {
|
|
236
|
+
TransactionTokenType2["ERC20"] = "ERC20";
|
|
237
|
+
TransactionTokenType2["ERC721"] = "ERC721";
|
|
238
|
+
TransactionTokenType2["NATIVE_COIN"] = "NATIVE_COIN";
|
|
239
|
+
})(exports.TransactionTokenType || (exports.TransactionTokenType = {}));
|
|
240
|
+
(function(SettingsInfoType2) {
|
|
241
|
+
SettingsInfoType2["SET_FALLBACK_HANDLER"] = "SET_FALLBACK_HANDLER";
|
|
242
|
+
SettingsInfoType2["ADD_OWNER"] = "ADD_OWNER";
|
|
243
|
+
SettingsInfoType2["REMOVE_OWNER"] = "REMOVE_OWNER";
|
|
244
|
+
SettingsInfoType2["SWAP_OWNER"] = "SWAP_OWNER";
|
|
245
|
+
SettingsInfoType2["CHANGE_THRESHOLD"] = "CHANGE_THRESHOLD";
|
|
246
|
+
SettingsInfoType2["CHANGE_IMPLEMENTATION"] = "CHANGE_IMPLEMENTATION";
|
|
247
|
+
SettingsInfoType2["ENABLE_MODULE"] = "ENABLE_MODULE";
|
|
248
|
+
SettingsInfoType2["DISABLE_MODULE"] = "DISABLE_MODULE";
|
|
249
|
+
SettingsInfoType2["SET_GUARD"] = "SET_GUARD";
|
|
250
|
+
SettingsInfoType2["DELETE_GUARD"] = "DELETE_GUARD";
|
|
251
|
+
})(exports.SettingsInfoType || (exports.SettingsInfoType = {}));
|
|
252
|
+
(function(TransactionInfoType2) {
|
|
253
|
+
TransactionInfoType2["TRANSFER"] = "Transfer";
|
|
254
|
+
TransactionInfoType2["SETTINGS_CHANGE"] = "SettingsChange";
|
|
255
|
+
TransactionInfoType2["CUSTOM"] = "Custom";
|
|
256
|
+
TransactionInfoType2["CREATION"] = "Creation";
|
|
257
|
+
TransactionInfoType2["SWAP_ORDER"] = "SwapOrder";
|
|
258
|
+
TransactionInfoType2["TWAP_ORDER"] = "TwapOrder";
|
|
259
|
+
TransactionInfoType2["SWAP_TRANSFER"] = "SwapTransfer";
|
|
260
|
+
})(exports.TransactionInfoType || (exports.TransactionInfoType = {}));
|
|
261
|
+
(function(ConflictType2) {
|
|
262
|
+
ConflictType2["NONE"] = "None";
|
|
263
|
+
ConflictType2["HAS_NEXT"] = "HasNext";
|
|
264
|
+
ConflictType2["END"] = "End";
|
|
265
|
+
})(exports.ConflictType || (exports.ConflictType = {}));
|
|
266
|
+
(function(TransactionListItemType2) {
|
|
267
|
+
TransactionListItemType2["TRANSACTION"] = "TRANSACTION";
|
|
268
|
+
TransactionListItemType2["LABEL"] = "LABEL";
|
|
269
|
+
TransactionListItemType2["CONFLICT_HEADER"] = "CONFLICT_HEADER";
|
|
270
|
+
TransactionListItemType2["DATE_LABEL"] = "DATE_LABEL";
|
|
271
|
+
})(exports.TransactionListItemType || (exports.TransactionListItemType = {}));
|
|
272
|
+
(function(DetailedExecutionInfoType2) {
|
|
273
|
+
DetailedExecutionInfoType2["MULTISIG"] = "MULTISIG";
|
|
274
|
+
DetailedExecutionInfoType2["MODULE"] = "MODULE";
|
|
275
|
+
})(exports.DetailedExecutionInfoType || (exports.DetailedExecutionInfoType = {}));
|
|
276
|
+
(function(DurationType2) {
|
|
277
|
+
DurationType2["AUTO"] = "AUTO";
|
|
278
|
+
DurationType2["LIMIT_DURATION"] = "LIMIT_DURATION";
|
|
279
|
+
})(exports.DurationType || (exports.DurationType = {}));
|
|
280
|
+
(function(StartTimeValue2) {
|
|
281
|
+
StartTimeValue2["AT_MINING_TIME"] = "AT_MINING_TIME";
|
|
282
|
+
StartTimeValue2["AT_EPOCH"] = "AT_EPOCH";
|
|
283
|
+
})(exports.StartTimeValue || (exports.StartTimeValue = {}));
|
|
284
|
+
(function(LabelValue2) {
|
|
285
|
+
LabelValue2["Queued"] = "Queued";
|
|
286
|
+
LabelValue2["Next"] = "Next";
|
|
287
|
+
})(exports.LabelValue || (exports.LabelValue = {}));
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/chains.js
|
|
292
|
+
var require_chains = __commonJS({
|
|
293
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/chains.js"(exports) {
|
|
294
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
295
|
+
exports.FEATURES = exports.GAS_PRICE_TYPE = exports.RPC_AUTHENTICATION = void 0;
|
|
296
|
+
(function(RPC_AUTHENTICATION2) {
|
|
297
|
+
RPC_AUTHENTICATION2["API_KEY_PATH"] = "API_KEY_PATH";
|
|
298
|
+
RPC_AUTHENTICATION2["NO_AUTHENTICATION"] = "NO_AUTHENTICATION";
|
|
299
|
+
RPC_AUTHENTICATION2["UNKNOWN"] = "UNKNOWN";
|
|
300
|
+
})(exports.RPC_AUTHENTICATION || (exports.RPC_AUTHENTICATION = {}));
|
|
301
|
+
(function(GAS_PRICE_TYPE2) {
|
|
302
|
+
GAS_PRICE_TYPE2["ORACLE"] = "ORACLE";
|
|
303
|
+
GAS_PRICE_TYPE2["FIXED"] = "FIXED";
|
|
304
|
+
GAS_PRICE_TYPE2["FIXED_1559"] = "FIXED1559";
|
|
305
|
+
GAS_PRICE_TYPE2["UNKNOWN"] = "UNKNOWN";
|
|
306
|
+
})(exports.GAS_PRICE_TYPE || (exports.GAS_PRICE_TYPE = {}));
|
|
307
|
+
(function(FEATURES2) {
|
|
308
|
+
FEATURES2["ERC721"] = "ERC721";
|
|
309
|
+
FEATURES2["SAFE_APPS"] = "SAFE_APPS";
|
|
310
|
+
FEATURES2["CONTRACT_INTERACTION"] = "CONTRACT_INTERACTION";
|
|
311
|
+
FEATURES2["DOMAIN_LOOKUP"] = "DOMAIN_LOOKUP";
|
|
312
|
+
FEATURES2["SPENDING_LIMIT"] = "SPENDING_LIMIT";
|
|
313
|
+
FEATURES2["EIP1559"] = "EIP1559";
|
|
314
|
+
FEATURES2["SAFE_TX_GAS_OPTIONAL"] = "SAFE_TX_GAS_OPTIONAL";
|
|
315
|
+
FEATURES2["TX_SIMULATION"] = "TX_SIMULATION";
|
|
316
|
+
FEATURES2["EIP1271"] = "EIP1271";
|
|
317
|
+
})(exports.FEATURES || (exports.FEATURES = {}));
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/common.js
|
|
322
|
+
var require_common = __commonJS({
|
|
323
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/common.js"(exports) {
|
|
324
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
325
|
+
exports.TokenType = void 0;
|
|
326
|
+
(function(TokenType3) {
|
|
327
|
+
TokenType3["ERC20"] = "ERC20";
|
|
328
|
+
TokenType3["ERC721"] = "ERC721";
|
|
329
|
+
TokenType3["NATIVE_TOKEN"] = "NATIVE_TOKEN";
|
|
330
|
+
})(exports.TokenType || (exports.TokenType = {}));
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/master-copies.js
|
|
335
|
+
var require_master_copies = __commonJS({
|
|
336
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/master-copies.js"(exports) {
|
|
337
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/decoded-data.js
|
|
342
|
+
var require_decoded_data = __commonJS({
|
|
343
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/decoded-data.js"(exports) {
|
|
344
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
345
|
+
exports.ConfirmationViewTypes = void 0;
|
|
346
|
+
(function(ConfirmationViewTypes2) {
|
|
347
|
+
ConfirmationViewTypes2["COW_SWAP_ORDER"] = "COW_SWAP_ORDER";
|
|
348
|
+
ConfirmationViewTypes2["COW_SWAP_TWAP_ORDER"] = "COW_SWAP_TWAP_ORDER";
|
|
349
|
+
})(exports.ConfirmationViewTypes || (exports.ConfirmationViewTypes = {}));
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/safe-messages.js
|
|
354
|
+
var require_safe_messages = __commonJS({
|
|
355
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/safe-messages.js"(exports) {
|
|
356
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
357
|
+
exports.SafeMessageStatus = exports.SafeMessageListItemType = void 0;
|
|
358
|
+
(function(SafeMessageListItemType2) {
|
|
359
|
+
SafeMessageListItemType2["DATE_LABEL"] = "DATE_LABEL";
|
|
360
|
+
SafeMessageListItemType2["MESSAGE"] = "MESSAGE";
|
|
361
|
+
})(exports.SafeMessageListItemType || (exports.SafeMessageListItemType = {}));
|
|
362
|
+
(function(SafeMessageStatus2) {
|
|
363
|
+
SafeMessageStatus2["NEEDS_CONFIRMATION"] = "NEEDS_CONFIRMATION";
|
|
364
|
+
SafeMessageStatus2["CONFIRMED"] = "CONFIRMED";
|
|
365
|
+
})(exports.SafeMessageStatus || (exports.SafeMessageStatus = {}));
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/notifications.js
|
|
370
|
+
var require_notifications = __commonJS({
|
|
371
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/notifications.js"(exports) {
|
|
372
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
373
|
+
exports.DeviceType = void 0;
|
|
374
|
+
(function(DeviceType2) {
|
|
375
|
+
DeviceType2["ANDROID"] = "ANDROID";
|
|
376
|
+
DeviceType2["IOS"] = "IOS";
|
|
377
|
+
DeviceType2["WEB"] = "WEB";
|
|
378
|
+
})(exports.DeviceType || (exports.DeviceType = {}));
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/relay.js
|
|
383
|
+
var require_relay = __commonJS({
|
|
384
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/types/relay.js"(exports) {
|
|
385
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/index.js
|
|
390
|
+
var require_dist = __commonJS({
|
|
391
|
+
"../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/index.js"(exports) {
|
|
392
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
393
|
+
if (k2 === void 0)
|
|
394
|
+
k2 = k;
|
|
395
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
396
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
397
|
+
desc = { enumerable: true, get: function() {
|
|
398
|
+
return m[k];
|
|
399
|
+
} };
|
|
400
|
+
}
|
|
401
|
+
Object.defineProperty(o, k2, desc);
|
|
402
|
+
} : function(o, m, k, k2) {
|
|
403
|
+
if (k2 === void 0)
|
|
404
|
+
k2 = k;
|
|
405
|
+
o[k2] = m[k];
|
|
406
|
+
});
|
|
407
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
408
|
+
for (var p in m)
|
|
409
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
410
|
+
__createBinding(exports2, m, p);
|
|
411
|
+
};
|
|
412
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
413
|
+
exports.deleteAccount = exports.getAccount = exports.createAccount = exports.verifyAuth = exports.getAuthNonce = exports.getContract = exports.getSafeOverviews = exports.unsubscribeAll = exports.unsubscribeSingle = exports.registerRecoveryModule = exports.deleteRegisteredEmail = exports.getRegisteredEmail = exports.verifyEmail = exports.resendEmailVerificationCode = exports.changeEmail = exports.registerEmail = exports.unregisterDevice = exports.unregisterSafe = exports.registerDevice = exports.getDelegates = exports.confirmSafeMessage = exports.proposeSafeMessage = exports.getSafeMessage = exports.getSafeMessages = exports.getDecodedData = exports.getMasterCopies = exports.getSafeApps = exports.getChainConfig = exports.getChainsConfig = exports.getConfirmationView = exports.proposeTransaction = exports.getNonces = exports.postSafeGasEstimation = exports.deleteTransaction = exports.getTransactionDetails = exports.getTransactionQueue = exports.getTransactionHistory = exports.getCollectiblesPage = exports.getCollectibles = exports.getAllOwnedSafes = exports.getOwnedSafes = exports.getFiatCurrencies = exports.getBalances = exports.getMultisigTransactions = exports.getModuleTransactions = exports.getIncomingTransfers = exports.getSafeInfo = exports.getRelayCount = exports.relayTransaction = exports.setBaseUrl = void 0;
|
|
414
|
+
exports.putAccountDataSettings = exports.getAccountDataSettings = exports.getAccountDataTypes = void 0;
|
|
415
|
+
var endpoint_1 = require_endpoint();
|
|
416
|
+
var config_1 = require_config();
|
|
417
|
+
__exportStar(require_safe_info(), exports);
|
|
418
|
+
__exportStar(require_safe_apps(), exports);
|
|
419
|
+
__exportStar(require_transactions(), exports);
|
|
420
|
+
__exportStar(require_chains(), exports);
|
|
421
|
+
__exportStar(require_common(), exports);
|
|
422
|
+
__exportStar(require_master_copies(), exports);
|
|
423
|
+
__exportStar(require_decoded_data(), exports);
|
|
424
|
+
__exportStar(require_safe_messages(), exports);
|
|
425
|
+
__exportStar(require_notifications(), exports);
|
|
426
|
+
__exportStar(require_relay(), exports);
|
|
427
|
+
var baseUrl = config_1.DEFAULT_BASE_URL;
|
|
428
|
+
var setBaseUrl = (url) => {
|
|
429
|
+
baseUrl = url;
|
|
430
|
+
};
|
|
431
|
+
exports.setBaseUrl = setBaseUrl;
|
|
432
|
+
function relayTransaction(chainId, body) {
|
|
433
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/relay", { path: { chainId }, body });
|
|
434
|
+
}
|
|
435
|
+
exports.relayTransaction = relayTransaction;
|
|
436
|
+
function getRelayCount(chainId, address) {
|
|
437
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/relay/{address}", { path: { chainId, address } });
|
|
438
|
+
}
|
|
439
|
+
exports.getRelayCount = getRelayCount;
|
|
440
|
+
function getSafeInfo(chainId, address) {
|
|
441
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{address}", { path: { chainId, address } });
|
|
442
|
+
}
|
|
443
|
+
exports.getSafeInfo = getSafeInfo;
|
|
444
|
+
function getIncomingTransfers(chainId, address, query, pageUrl) {
|
|
445
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{address}/incoming-transfers/", {
|
|
446
|
+
path: { chainId, address },
|
|
447
|
+
query
|
|
448
|
+
}, pageUrl);
|
|
449
|
+
}
|
|
450
|
+
exports.getIncomingTransfers = getIncomingTransfers;
|
|
451
|
+
function getModuleTransactions(chainId, address, query, pageUrl) {
|
|
452
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{address}/module-transactions/", {
|
|
453
|
+
path: { chainId, address },
|
|
454
|
+
query
|
|
455
|
+
}, pageUrl);
|
|
456
|
+
}
|
|
457
|
+
exports.getModuleTransactions = getModuleTransactions;
|
|
458
|
+
function getMultisigTransactions(chainId, address, query, pageUrl) {
|
|
459
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{address}/multisig-transactions/", {
|
|
460
|
+
path: { chainId, address },
|
|
461
|
+
query
|
|
462
|
+
}, pageUrl);
|
|
463
|
+
}
|
|
464
|
+
exports.getMultisigTransactions = getMultisigTransactions;
|
|
465
|
+
function getBalances(chainId, address, currency = "usd", query = {}) {
|
|
466
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{address}/balances/{currency}", {
|
|
467
|
+
path: { chainId, address, currency },
|
|
468
|
+
query
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
exports.getBalances = getBalances;
|
|
472
|
+
function getFiatCurrencies() {
|
|
473
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/balances/supported-fiat-codes");
|
|
474
|
+
}
|
|
475
|
+
exports.getFiatCurrencies = getFiatCurrencies;
|
|
476
|
+
function getOwnedSafes(chainId, address) {
|
|
477
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/owners/{address}/safes", { path: { chainId, address } });
|
|
478
|
+
}
|
|
479
|
+
exports.getOwnedSafes = getOwnedSafes;
|
|
480
|
+
function getAllOwnedSafes(address) {
|
|
481
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/owners/{address}/safes", { path: { address } });
|
|
482
|
+
}
|
|
483
|
+
exports.getAllOwnedSafes = getAllOwnedSafes;
|
|
484
|
+
function getCollectibles(chainId, address, query = {}) {
|
|
485
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{address}/collectibles", {
|
|
486
|
+
path: { chainId, address },
|
|
487
|
+
query
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
exports.getCollectibles = getCollectibles;
|
|
491
|
+
function getCollectiblesPage(chainId, address, query = {}, pageUrl) {
|
|
492
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v2/chains/{chainId}/safes/{address}/collectibles", { path: { chainId, address }, query }, pageUrl);
|
|
493
|
+
}
|
|
494
|
+
exports.getCollectiblesPage = getCollectiblesPage;
|
|
495
|
+
function getTransactionHistory(chainId, address, query = {}, pageUrl) {
|
|
496
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/transactions/history", { path: { chainId, safe_address: address }, query }, pageUrl);
|
|
497
|
+
}
|
|
498
|
+
exports.getTransactionHistory = getTransactionHistory;
|
|
499
|
+
function getTransactionQueue(chainId, address, query = {}, pageUrl) {
|
|
500
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/transactions/queued", { path: { chainId, safe_address: address }, query }, pageUrl);
|
|
501
|
+
}
|
|
502
|
+
exports.getTransactionQueue = getTransactionQueue;
|
|
503
|
+
function getTransactionDetails(chainId, transactionId) {
|
|
504
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/transactions/{transactionId}", {
|
|
505
|
+
path: { chainId, transactionId }
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
exports.getTransactionDetails = getTransactionDetails;
|
|
509
|
+
function deleteTransaction(chainId, safeTxHash, signature) {
|
|
510
|
+
return (0, endpoint_1.deleteEndpoint)(baseUrl, "/v1/chains/{chainId}/transactions/{safeTxHash}", {
|
|
511
|
+
path: { chainId, safeTxHash },
|
|
512
|
+
body: { signature }
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
exports.deleteTransaction = deleteTransaction;
|
|
516
|
+
function postSafeGasEstimation(chainId, address, body) {
|
|
517
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations", {
|
|
518
|
+
path: { chainId, safe_address: address },
|
|
519
|
+
body
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
exports.postSafeGasEstimation = postSafeGasEstimation;
|
|
523
|
+
function getNonces(chainId, address) {
|
|
524
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/nonces", {
|
|
525
|
+
path: { chainId, safe_address: address }
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
exports.getNonces = getNonces;
|
|
529
|
+
function proposeTransaction(chainId, address, body) {
|
|
530
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/transactions/{safe_address}/propose", {
|
|
531
|
+
path: { chainId, safe_address: address },
|
|
532
|
+
body
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
exports.proposeTransaction = proposeTransaction;
|
|
536
|
+
function getConfirmationView(chainId, safeAddress, encodedData, to) {
|
|
537
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation", {
|
|
538
|
+
path: { chainId, safe_address: safeAddress },
|
|
539
|
+
body: { data: encodedData, to }
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
exports.getConfirmationView = getConfirmationView;
|
|
543
|
+
function getChainsConfig(query) {
|
|
544
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains", {
|
|
545
|
+
query
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
exports.getChainsConfig = getChainsConfig;
|
|
549
|
+
function getChainConfig(chainId) {
|
|
550
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}", {
|
|
551
|
+
path: { chainId }
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
exports.getChainConfig = getChainConfig;
|
|
555
|
+
function getSafeApps(chainId, query = {}) {
|
|
556
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safe-apps", {
|
|
557
|
+
path: { chainId },
|
|
558
|
+
query
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
exports.getSafeApps = getSafeApps;
|
|
562
|
+
function getMasterCopies(chainId) {
|
|
563
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/about/master-copies", {
|
|
564
|
+
path: { chainId }
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
exports.getMasterCopies = getMasterCopies;
|
|
568
|
+
function getDecodedData(chainId, encodedData, to) {
|
|
569
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/data-decoder", {
|
|
570
|
+
path: { chainId },
|
|
571
|
+
body: { data: encodedData, to }
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
exports.getDecodedData = getDecodedData;
|
|
575
|
+
function getSafeMessages(chainId, address, pageUrl) {
|
|
576
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/messages", { path: { chainId, safe_address: address }, query: {} }, pageUrl);
|
|
577
|
+
}
|
|
578
|
+
exports.getSafeMessages = getSafeMessages;
|
|
579
|
+
function getSafeMessage(chainId, messageHash) {
|
|
580
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/messages/{message_hash}", {
|
|
581
|
+
path: { chainId, message_hash: messageHash }
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
exports.getSafeMessage = getSafeMessage;
|
|
585
|
+
function proposeSafeMessage(chainId, address, body) {
|
|
586
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/messages", {
|
|
587
|
+
path: { chainId, safe_address: address },
|
|
588
|
+
body
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
exports.proposeSafeMessage = proposeSafeMessage;
|
|
592
|
+
function confirmSafeMessage(chainId, messageHash, body) {
|
|
593
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/messages/{message_hash}/signatures", {
|
|
594
|
+
path: { chainId, message_hash: messageHash },
|
|
595
|
+
body
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
exports.confirmSafeMessage = confirmSafeMessage;
|
|
599
|
+
function getDelegates(chainId, query = {}) {
|
|
600
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v2/chains/{chainId}/delegates", {
|
|
601
|
+
path: { chainId },
|
|
602
|
+
query
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
exports.getDelegates = getDelegates;
|
|
606
|
+
function registerDevice(body) {
|
|
607
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/register/notifications", {
|
|
608
|
+
body
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
exports.registerDevice = registerDevice;
|
|
612
|
+
function unregisterSafe(chainId, address, uuid) {
|
|
613
|
+
return (0, endpoint_1.deleteEndpoint)(baseUrl, "/v1/chains/{chainId}/notifications/devices/{uuid}/safes/{safe_address}", {
|
|
614
|
+
path: { chainId, safe_address: address, uuid }
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
exports.unregisterSafe = unregisterSafe;
|
|
618
|
+
function unregisterDevice(chainId, uuid) {
|
|
619
|
+
return (0, endpoint_1.deleteEndpoint)(baseUrl, "/v1/chains/{chainId}/notifications/devices/{uuid}", {
|
|
620
|
+
path: { chainId, uuid }
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
exports.unregisterDevice = unregisterDevice;
|
|
624
|
+
function registerEmail(chainId, safeAddress, body, headers) {
|
|
625
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/emails", {
|
|
626
|
+
path: { chainId, safe_address: safeAddress },
|
|
627
|
+
body,
|
|
628
|
+
headers
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
exports.registerEmail = registerEmail;
|
|
632
|
+
function changeEmail(chainId, safeAddress, signerAddress, body, headers) {
|
|
633
|
+
return (0, endpoint_1.putEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}", {
|
|
634
|
+
path: { chainId, safe_address: safeAddress, signer: signerAddress },
|
|
635
|
+
body,
|
|
636
|
+
headers
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
exports.changeEmail = changeEmail;
|
|
640
|
+
function resendEmailVerificationCode(chainId, safeAddress, signerAddress) {
|
|
641
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify-resend", {
|
|
642
|
+
path: { chainId, safe_address: safeAddress, signer: signerAddress },
|
|
643
|
+
body: ""
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
exports.resendEmailVerificationCode = resendEmailVerificationCode;
|
|
647
|
+
function verifyEmail(chainId, safeAddress, signerAddress, body) {
|
|
648
|
+
return (0, endpoint_1.putEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify", {
|
|
649
|
+
path: { chainId, safe_address: safeAddress, signer: signerAddress },
|
|
650
|
+
body
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
exports.verifyEmail = verifyEmail;
|
|
654
|
+
function getRegisteredEmail(chainId, safeAddress, signerAddress, headers) {
|
|
655
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}", {
|
|
656
|
+
path: { chainId, safe_address: safeAddress, signer: signerAddress },
|
|
657
|
+
headers
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
exports.getRegisteredEmail = getRegisteredEmail;
|
|
661
|
+
function deleteRegisteredEmail(chainId, safeAddress, signerAddress, headers) {
|
|
662
|
+
return (0, endpoint_1.deleteEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}", {
|
|
663
|
+
path: { chainId, safe_address: safeAddress, signer: signerAddress },
|
|
664
|
+
headers
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
exports.deleteRegisteredEmail = deleteRegisteredEmail;
|
|
668
|
+
function registerRecoveryModule(chainId, safeAddress, body) {
|
|
669
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/chains/{chainId}/safes/{safe_address}/recovery", {
|
|
670
|
+
path: { chainId, safe_address: safeAddress },
|
|
671
|
+
body
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
exports.registerRecoveryModule = registerRecoveryModule;
|
|
675
|
+
function unsubscribeSingle(query) {
|
|
676
|
+
return (0, endpoint_1.deleteEndpoint)(baseUrl, "/v1/subscriptions", { query });
|
|
677
|
+
}
|
|
678
|
+
exports.unsubscribeSingle = unsubscribeSingle;
|
|
679
|
+
function unsubscribeAll(query) {
|
|
680
|
+
return (0, endpoint_1.deleteEndpoint)(baseUrl, "/v1/subscriptions/all", { query });
|
|
681
|
+
}
|
|
682
|
+
exports.unsubscribeAll = unsubscribeAll;
|
|
683
|
+
function getSafeOverviews(safes, query) {
|
|
684
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/safes", {
|
|
685
|
+
query: Object.assign(Object.assign({}, query), { safes: safes.join(",") })
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
exports.getSafeOverviews = getSafeOverviews;
|
|
689
|
+
function getContract(chainId, contractAddress) {
|
|
690
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/chains/{chainId}/contracts/{contractAddress}", {
|
|
691
|
+
path: {
|
|
692
|
+
chainId,
|
|
693
|
+
contractAddress
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
exports.getContract = getContract;
|
|
698
|
+
function getAuthNonce() {
|
|
699
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/auth/nonce", { credentials: "include" });
|
|
700
|
+
}
|
|
701
|
+
exports.getAuthNonce = getAuthNonce;
|
|
702
|
+
function verifyAuth(body) {
|
|
703
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/auth/verify", {
|
|
704
|
+
body,
|
|
705
|
+
credentials: "include"
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
exports.verifyAuth = verifyAuth;
|
|
709
|
+
function createAccount(body) {
|
|
710
|
+
return (0, endpoint_1.postEndpoint)(baseUrl, "/v1/accounts", {
|
|
711
|
+
body,
|
|
712
|
+
credentials: "include"
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
exports.createAccount = createAccount;
|
|
716
|
+
function getAccount(address) {
|
|
717
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/accounts/{address}", {
|
|
718
|
+
path: { address },
|
|
719
|
+
credentials: "include"
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
exports.getAccount = getAccount;
|
|
723
|
+
function deleteAccount(address) {
|
|
724
|
+
return (0, endpoint_1.deleteEndpoint)(baseUrl, "/v1/accounts/{address}", {
|
|
725
|
+
path: { address },
|
|
726
|
+
credentials: "include"
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
exports.deleteAccount = deleteAccount;
|
|
730
|
+
function getAccountDataTypes() {
|
|
731
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/accounts/data-types");
|
|
732
|
+
}
|
|
733
|
+
exports.getAccountDataTypes = getAccountDataTypes;
|
|
734
|
+
function getAccountDataSettings(address) {
|
|
735
|
+
return (0, endpoint_1.getEndpoint)(baseUrl, "/v1/accounts/{address}/data-settings", {
|
|
736
|
+
path: { address },
|
|
737
|
+
credentials: "include"
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
exports.getAccountDataSettings = getAccountDataSettings;
|
|
741
|
+
function putAccountDataSettings(address, body) {
|
|
742
|
+
return (0, endpoint_1.putEndpoint)(baseUrl, "/v1/accounts/{address}/data-settings", {
|
|
743
|
+
path: { address },
|
|
744
|
+
body,
|
|
745
|
+
credentials: "include"
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
exports.putAccountDataSettings = putAccountDataSettings;
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
var matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
752
|
+
var stringToIcon = (value, validate, allowSimpleName, provider = "") => {
|
|
753
|
+
const colonSeparated = value.split(":");
|
|
754
|
+
if (value.slice(0, 1) === "@") {
|
|
755
|
+
if (colonSeparated.length < 2 || colonSeparated.length > 3) {
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
758
|
+
provider = colonSeparated.shift().slice(1);
|
|
759
|
+
}
|
|
760
|
+
if (colonSeparated.length > 3 || !colonSeparated.length) {
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
if (colonSeparated.length > 1) {
|
|
764
|
+
const name2 = colonSeparated.pop();
|
|
765
|
+
const prefix = colonSeparated.pop();
|
|
766
|
+
const result = {
|
|
767
|
+
// Allow provider without '@': "provider:prefix:name"
|
|
768
|
+
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
|
|
769
|
+
prefix,
|
|
770
|
+
name: name2
|
|
771
|
+
};
|
|
772
|
+
return validate && !validateIconName(result) ? null : result;
|
|
773
|
+
}
|
|
774
|
+
const name = colonSeparated[0];
|
|
775
|
+
const dashSeparated = name.split("-");
|
|
776
|
+
if (dashSeparated.length > 1) {
|
|
777
|
+
const result = {
|
|
778
|
+
provider,
|
|
779
|
+
prefix: dashSeparated.shift(),
|
|
780
|
+
name: dashSeparated.join("-")
|
|
781
|
+
};
|
|
782
|
+
return validate && !validateIconName(result) ? null : result;
|
|
783
|
+
}
|
|
784
|
+
if (allowSimpleName && provider === "") {
|
|
785
|
+
const result = {
|
|
786
|
+
provider,
|
|
787
|
+
prefix: "",
|
|
788
|
+
name
|
|
789
|
+
};
|
|
790
|
+
return validate && !validateIconName(result, allowSimpleName) ? null : result;
|
|
791
|
+
}
|
|
792
|
+
return null;
|
|
793
|
+
};
|
|
794
|
+
var validateIconName = (icon, allowSimpleName) => {
|
|
795
|
+
if (!icon) {
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
|
|
799
|
+
};
|
|
800
|
+
var defaultIconDimensions = Object.freeze(
|
|
801
|
+
{
|
|
802
|
+
left: 0,
|
|
803
|
+
top: 0,
|
|
804
|
+
width: 16,
|
|
805
|
+
height: 16
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
var defaultIconTransformations = Object.freeze({
|
|
809
|
+
rotate: 0,
|
|
810
|
+
vFlip: false,
|
|
811
|
+
hFlip: false
|
|
812
|
+
});
|
|
813
|
+
var defaultIconProps = Object.freeze(__spreadValues(__spreadValues({}, defaultIconDimensions), defaultIconTransformations));
|
|
814
|
+
var defaultExtendedIconProps = Object.freeze(__spreadProps(__spreadValues({}, defaultIconProps), {
|
|
815
|
+
body: "",
|
|
816
|
+
hidden: false
|
|
817
|
+
}));
|
|
818
|
+
function mergeIconTransformations(obj1, obj2) {
|
|
819
|
+
const result = {};
|
|
820
|
+
if (!obj1.hFlip !== !obj2.hFlip) {
|
|
821
|
+
result.hFlip = true;
|
|
822
|
+
}
|
|
823
|
+
if (!obj1.vFlip !== !obj2.vFlip) {
|
|
824
|
+
result.vFlip = true;
|
|
825
|
+
}
|
|
826
|
+
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
827
|
+
if (rotate) {
|
|
828
|
+
result.rotate = rotate;
|
|
829
|
+
}
|
|
830
|
+
return result;
|
|
831
|
+
}
|
|
832
|
+
function mergeIconData(parent, child) {
|
|
833
|
+
const result = mergeIconTransformations(parent, child);
|
|
834
|
+
for (const key in defaultExtendedIconProps) {
|
|
835
|
+
if (key in defaultIconTransformations) {
|
|
836
|
+
if (key in parent && !(key in result)) {
|
|
837
|
+
result[key] = defaultIconTransformations[key];
|
|
838
|
+
}
|
|
839
|
+
} else if (key in child) {
|
|
840
|
+
result[key] = child[key];
|
|
841
|
+
} else if (key in parent) {
|
|
842
|
+
result[key] = parent[key];
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return result;
|
|
846
|
+
}
|
|
847
|
+
function getIconsTree(data, names) {
|
|
848
|
+
const icons = data.icons;
|
|
849
|
+
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
850
|
+
const resolved = /* @__PURE__ */ Object.create(null);
|
|
851
|
+
function resolve(name) {
|
|
852
|
+
if (icons[name]) {
|
|
853
|
+
return resolved[name] = [];
|
|
854
|
+
}
|
|
855
|
+
if (!(name in resolved)) {
|
|
856
|
+
resolved[name] = null;
|
|
857
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
858
|
+
const value = parent && resolve(parent);
|
|
859
|
+
if (value) {
|
|
860
|
+
resolved[name] = [parent].concat(value);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return resolved[name];
|
|
864
|
+
}
|
|
865
|
+
(Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
|
|
866
|
+
return resolved;
|
|
867
|
+
}
|
|
868
|
+
function internalGetIconData(data, name, tree) {
|
|
869
|
+
const icons = data.icons;
|
|
870
|
+
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
871
|
+
let currentProps = {};
|
|
872
|
+
function parse(name2) {
|
|
873
|
+
currentProps = mergeIconData(
|
|
874
|
+
icons[name2] || aliases[name2],
|
|
875
|
+
currentProps
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
parse(name);
|
|
879
|
+
tree.forEach(parse);
|
|
880
|
+
return mergeIconData(data, currentProps);
|
|
881
|
+
}
|
|
882
|
+
function parseIconSet(data, callback) {
|
|
883
|
+
const names = [];
|
|
884
|
+
if (typeof data !== "object" || typeof data.icons !== "object") {
|
|
885
|
+
return names;
|
|
886
|
+
}
|
|
887
|
+
if (data.not_found instanceof Array) {
|
|
888
|
+
data.not_found.forEach((name) => {
|
|
889
|
+
callback(name, null);
|
|
890
|
+
names.push(name);
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
const tree = getIconsTree(data);
|
|
894
|
+
for (const name in tree) {
|
|
895
|
+
const item = tree[name];
|
|
896
|
+
if (item) {
|
|
897
|
+
callback(name, internalGetIconData(data, name, item));
|
|
898
|
+
names.push(name);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
return names;
|
|
902
|
+
}
|
|
903
|
+
var optionalPropertyDefaults = __spreadValues({
|
|
904
|
+
provider: "",
|
|
905
|
+
aliases: {},
|
|
906
|
+
not_found: {}
|
|
907
|
+
}, defaultIconDimensions);
|
|
908
|
+
function checkOptionalProps(item, defaults) {
|
|
909
|
+
for (const prop in defaults) {
|
|
910
|
+
if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return true;
|
|
915
|
+
}
|
|
916
|
+
function quicklyValidateIconSet(obj) {
|
|
917
|
+
if (typeof obj !== "object" || obj === null) {
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
const data = obj;
|
|
921
|
+
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
const icons = data.icons;
|
|
928
|
+
for (const name in icons) {
|
|
929
|
+
const icon = icons[name];
|
|
930
|
+
if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
|
|
931
|
+
icon,
|
|
932
|
+
defaultExtendedIconProps
|
|
933
|
+
)) {
|
|
934
|
+
return null;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
|
|
938
|
+
for (const name in aliases) {
|
|
939
|
+
const icon = aliases[name];
|
|
940
|
+
const parent = icon.parent;
|
|
941
|
+
if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
|
|
942
|
+
icon,
|
|
943
|
+
defaultExtendedIconProps
|
|
944
|
+
)) {
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
return data;
|
|
949
|
+
}
|
|
950
|
+
var dataStorage = /* @__PURE__ */ Object.create(null);
|
|
951
|
+
function newStorage(provider, prefix) {
|
|
952
|
+
return {
|
|
953
|
+
provider,
|
|
954
|
+
prefix,
|
|
955
|
+
icons: /* @__PURE__ */ Object.create(null),
|
|
956
|
+
missing: /* @__PURE__ */ new Set()
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
function getStorage(provider, prefix) {
|
|
960
|
+
const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
|
|
961
|
+
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
962
|
+
}
|
|
963
|
+
function addIconSet(storage2, data) {
|
|
964
|
+
if (!quicklyValidateIconSet(data)) {
|
|
965
|
+
return [];
|
|
966
|
+
}
|
|
967
|
+
return parseIconSet(data, (name, icon) => {
|
|
968
|
+
if (icon) {
|
|
969
|
+
storage2.icons[name] = icon;
|
|
970
|
+
} else {
|
|
971
|
+
storage2.missing.add(name);
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
function addIconToStorage(storage2, name, icon) {
|
|
976
|
+
try {
|
|
977
|
+
if (typeof icon.body === "string") {
|
|
978
|
+
storage2.icons[name] = __spreadValues({}, icon);
|
|
979
|
+
return true;
|
|
980
|
+
}
|
|
981
|
+
} catch (err) {
|
|
982
|
+
}
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
var simpleNames = false;
|
|
986
|
+
function allowSimpleNames(allow) {
|
|
987
|
+
if (typeof allow === "boolean") {
|
|
988
|
+
simpleNames = allow;
|
|
989
|
+
}
|
|
990
|
+
return simpleNames;
|
|
991
|
+
}
|
|
992
|
+
function getIconData(name) {
|
|
993
|
+
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
|
|
994
|
+
if (icon) {
|
|
995
|
+
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
996
|
+
const iconName = icon.name;
|
|
997
|
+
return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
function addIcon(name, data) {
|
|
1001
|
+
const icon = stringToIcon(name, true, simpleNames);
|
|
1002
|
+
if (!icon) {
|
|
1003
|
+
return false;
|
|
1004
|
+
}
|
|
1005
|
+
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
1006
|
+
return addIconToStorage(storage2, icon.name, data);
|
|
1007
|
+
}
|
|
1008
|
+
function addCollection(data, provider) {
|
|
1009
|
+
if (typeof data !== "object") {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
if (typeof provider !== "string") {
|
|
1013
|
+
provider = data.provider || "";
|
|
1014
|
+
}
|
|
1015
|
+
if (simpleNames && !provider && !data.prefix) {
|
|
1016
|
+
let added = false;
|
|
1017
|
+
if (quicklyValidateIconSet(data)) {
|
|
1018
|
+
data.prefix = "";
|
|
1019
|
+
parseIconSet(data, (name, icon) => {
|
|
1020
|
+
if (icon && addIcon(name, icon)) {
|
|
1021
|
+
added = true;
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
return added;
|
|
1026
|
+
}
|
|
1027
|
+
const prefix = data.prefix;
|
|
1028
|
+
if (!validateIconName({
|
|
1029
|
+
provider,
|
|
1030
|
+
prefix,
|
|
1031
|
+
name: "a"
|
|
1032
|
+
})) {
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
const storage2 = getStorage(provider, prefix);
|
|
1036
|
+
return !!addIconSet(storage2, data);
|
|
1037
|
+
}
|
|
1038
|
+
var defaultIconSizeCustomisations = Object.freeze({
|
|
1039
|
+
width: null,
|
|
1040
|
+
height: null
|
|
1041
|
+
});
|
|
1042
|
+
var defaultIconCustomisations = Object.freeze(__spreadValues(__spreadValues({}, defaultIconSizeCustomisations), defaultIconTransformations));
|
|
1043
|
+
var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
1044
|
+
var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
1045
|
+
function calculateSize(size, ratio, precision) {
|
|
1046
|
+
if (ratio === 1) {
|
|
1047
|
+
return size;
|
|
1048
|
+
}
|
|
1049
|
+
precision = precision || 100;
|
|
1050
|
+
if (typeof size === "number") {
|
|
1051
|
+
return Math.ceil(size * ratio * precision) / precision;
|
|
1052
|
+
}
|
|
1053
|
+
if (typeof size !== "string") {
|
|
1054
|
+
return size;
|
|
1055
|
+
}
|
|
1056
|
+
const oldParts = size.split(unitsSplit);
|
|
1057
|
+
if (oldParts === null || !oldParts.length) {
|
|
1058
|
+
return size;
|
|
1059
|
+
}
|
|
1060
|
+
const newParts = [];
|
|
1061
|
+
let code = oldParts.shift();
|
|
1062
|
+
let isNumber = unitsTest.test(code);
|
|
1063
|
+
while (true) {
|
|
1064
|
+
if (isNumber) {
|
|
1065
|
+
const num = parseFloat(code);
|
|
1066
|
+
if (isNaN(num)) {
|
|
1067
|
+
newParts.push(code);
|
|
1068
|
+
} else {
|
|
1069
|
+
newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
1070
|
+
}
|
|
1071
|
+
} else {
|
|
1072
|
+
newParts.push(code);
|
|
1073
|
+
}
|
|
1074
|
+
code = oldParts.shift();
|
|
1075
|
+
if (code === void 0) {
|
|
1076
|
+
return newParts.join("");
|
|
1077
|
+
}
|
|
1078
|
+
isNumber = !isNumber;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
var isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
1082
|
+
function iconToSVG(icon, customisations) {
|
|
1083
|
+
const fullIcon = __spreadValues(__spreadValues({}, defaultIconProps), icon);
|
|
1084
|
+
const fullCustomisations = __spreadValues(__spreadValues({}, defaultIconCustomisations), customisations);
|
|
1085
|
+
const box = {
|
|
1086
|
+
left: fullIcon.left,
|
|
1087
|
+
top: fullIcon.top,
|
|
1088
|
+
width: fullIcon.width,
|
|
1089
|
+
height: fullIcon.height
|
|
1090
|
+
};
|
|
1091
|
+
let body = fullIcon.body;
|
|
1092
|
+
[fullIcon, fullCustomisations].forEach((props) => {
|
|
1093
|
+
const transformations = [];
|
|
1094
|
+
const hFlip = props.hFlip;
|
|
1095
|
+
const vFlip = props.vFlip;
|
|
1096
|
+
let rotation = props.rotate;
|
|
1097
|
+
if (hFlip) {
|
|
1098
|
+
if (vFlip) {
|
|
1099
|
+
rotation += 2;
|
|
1100
|
+
} else {
|
|
1101
|
+
transformations.push(
|
|
1102
|
+
"translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
|
|
1103
|
+
);
|
|
1104
|
+
transformations.push("scale(-1 1)");
|
|
1105
|
+
box.top = box.left = 0;
|
|
1106
|
+
}
|
|
1107
|
+
} else if (vFlip) {
|
|
1108
|
+
transformations.push(
|
|
1109
|
+
"translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
|
|
1110
|
+
);
|
|
1111
|
+
transformations.push("scale(1 -1)");
|
|
1112
|
+
box.top = box.left = 0;
|
|
1113
|
+
}
|
|
1114
|
+
let tempValue;
|
|
1115
|
+
if (rotation < 0) {
|
|
1116
|
+
rotation -= Math.floor(rotation / 4) * 4;
|
|
1117
|
+
}
|
|
1118
|
+
rotation = rotation % 4;
|
|
1119
|
+
switch (rotation) {
|
|
1120
|
+
case 1:
|
|
1121
|
+
tempValue = box.height / 2 + box.top;
|
|
1122
|
+
transformations.unshift(
|
|
1123
|
+
"rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
|
|
1124
|
+
);
|
|
1125
|
+
break;
|
|
1126
|
+
case 2:
|
|
1127
|
+
transformations.unshift(
|
|
1128
|
+
"rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
|
|
1129
|
+
);
|
|
1130
|
+
break;
|
|
1131
|
+
case 3:
|
|
1132
|
+
tempValue = box.width / 2 + box.left;
|
|
1133
|
+
transformations.unshift(
|
|
1134
|
+
"rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
|
|
1135
|
+
);
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
if (rotation % 2 === 1) {
|
|
1139
|
+
if (box.left !== box.top) {
|
|
1140
|
+
tempValue = box.left;
|
|
1141
|
+
box.left = box.top;
|
|
1142
|
+
box.top = tempValue;
|
|
1143
|
+
}
|
|
1144
|
+
if (box.width !== box.height) {
|
|
1145
|
+
tempValue = box.width;
|
|
1146
|
+
box.width = box.height;
|
|
1147
|
+
box.height = tempValue;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (transformations.length) {
|
|
1151
|
+
body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
const customisationsWidth = fullCustomisations.width;
|
|
1155
|
+
const customisationsHeight = fullCustomisations.height;
|
|
1156
|
+
const boxWidth = box.width;
|
|
1157
|
+
const boxHeight = box.height;
|
|
1158
|
+
let width;
|
|
1159
|
+
let height;
|
|
1160
|
+
if (customisationsWidth === null) {
|
|
1161
|
+
height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
1162
|
+
width = calculateSize(height, boxWidth / boxHeight);
|
|
1163
|
+
} else {
|
|
1164
|
+
width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
|
|
1165
|
+
height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
1166
|
+
}
|
|
1167
|
+
const attributes = {};
|
|
1168
|
+
const setAttr = (prop, value) => {
|
|
1169
|
+
if (!isUnsetKeyword(value)) {
|
|
1170
|
+
attributes[prop] = value.toString();
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
setAttr("width", width);
|
|
1174
|
+
setAttr("height", height);
|
|
1175
|
+
attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
|
|
1176
|
+
return {
|
|
1177
|
+
attributes,
|
|
1178
|
+
body
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
var regex = /\sid="(\S+)"/g;
|
|
1182
|
+
var randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
|
|
1183
|
+
var counter = 0;
|
|
1184
|
+
function replaceIDs(body, prefix = randomPrefix) {
|
|
1185
|
+
const ids = [];
|
|
1186
|
+
let match;
|
|
1187
|
+
while (match = regex.exec(body)) {
|
|
1188
|
+
ids.push(match[1]);
|
|
1189
|
+
}
|
|
1190
|
+
if (!ids.length) {
|
|
1191
|
+
return body;
|
|
1192
|
+
}
|
|
1193
|
+
const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
|
|
1194
|
+
ids.forEach((id) => {
|
|
1195
|
+
const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
|
|
1196
|
+
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1197
|
+
body = body.replace(
|
|
1198
|
+
// Allowed characters before id: [#;"]
|
|
1199
|
+
// Allowed characters after id: [)"], .[a-z]
|
|
1200
|
+
new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
|
|
1201
|
+
"$1" + newID + suffix + "$3"
|
|
1202
|
+
);
|
|
1203
|
+
});
|
|
1204
|
+
body = body.replace(new RegExp(suffix, "g"), "");
|
|
1205
|
+
return body;
|
|
1206
|
+
}
|
|
1207
|
+
var storage = /* @__PURE__ */ Object.create(null);
|
|
1208
|
+
function setAPIModule(provider, item) {
|
|
1209
|
+
storage[provider] = item;
|
|
1210
|
+
}
|
|
1211
|
+
function getAPIModule(provider) {
|
|
1212
|
+
return storage[provider] || storage[""];
|
|
1213
|
+
}
|
|
1214
|
+
function createAPIConfig(source) {
|
|
1215
|
+
let resources;
|
|
1216
|
+
if (typeof source.resources === "string") {
|
|
1217
|
+
resources = [source.resources];
|
|
1218
|
+
} else {
|
|
1219
|
+
resources = source.resources;
|
|
1220
|
+
if (!(resources instanceof Array) || !resources.length) {
|
|
1221
|
+
return null;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
const result = {
|
|
1225
|
+
// API hosts
|
|
1226
|
+
resources,
|
|
1227
|
+
// Root path
|
|
1228
|
+
path: source.path || "/",
|
|
1229
|
+
// URL length limit
|
|
1230
|
+
maxURL: source.maxURL || 500,
|
|
1231
|
+
// Timeout before next host is used.
|
|
1232
|
+
rotate: source.rotate || 750,
|
|
1233
|
+
// Timeout before failing query.
|
|
1234
|
+
timeout: source.timeout || 5e3,
|
|
1235
|
+
// Randomise default API end point.
|
|
1236
|
+
random: source.random === true,
|
|
1237
|
+
// Start index
|
|
1238
|
+
index: source.index || 0,
|
|
1239
|
+
// Receive data after time out (used if time out kicks in first, then API module sends data anyway).
|
|
1240
|
+
dataAfterTimeout: source.dataAfterTimeout !== false
|
|
1241
|
+
};
|
|
1242
|
+
return result;
|
|
1243
|
+
}
|
|
1244
|
+
var configStorage = /* @__PURE__ */ Object.create(null);
|
|
1245
|
+
var fallBackAPISources = [
|
|
1246
|
+
"https://api.simplesvg.com",
|
|
1247
|
+
"https://api.unisvg.com"
|
|
1248
|
+
];
|
|
1249
|
+
var fallBackAPI = [];
|
|
1250
|
+
while (fallBackAPISources.length > 0) {
|
|
1251
|
+
if (fallBackAPISources.length === 1) {
|
|
1252
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
1253
|
+
} else {
|
|
1254
|
+
if (Math.random() > 0.5) {
|
|
1255
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
1256
|
+
} else {
|
|
1257
|
+
fallBackAPI.push(fallBackAPISources.pop());
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
configStorage[""] = createAPIConfig({
|
|
1262
|
+
resources: ["https://api.iconify.design"].concat(fallBackAPI)
|
|
1263
|
+
});
|
|
1264
|
+
function addAPIProvider(provider, customConfig) {
|
|
1265
|
+
const config = createAPIConfig(customConfig);
|
|
1266
|
+
if (config === null) {
|
|
1267
|
+
return false;
|
|
1268
|
+
}
|
|
1269
|
+
configStorage[provider] = config;
|
|
1270
|
+
return true;
|
|
1271
|
+
}
|
|
1272
|
+
function getAPIConfig(provider) {
|
|
1273
|
+
return configStorage[provider];
|
|
1274
|
+
}
|
|
1275
|
+
var detectFetch = () => {
|
|
1276
|
+
let callback;
|
|
1277
|
+
try {
|
|
1278
|
+
callback = fetch;
|
|
1279
|
+
if (typeof callback === "function") {
|
|
1280
|
+
return callback;
|
|
1281
|
+
}
|
|
1282
|
+
} catch (err) {
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
var fetchModule = detectFetch();
|
|
1286
|
+
function calculateMaxLength(provider, prefix) {
|
|
1287
|
+
const config = getAPIConfig(provider);
|
|
1288
|
+
if (!config) {
|
|
1289
|
+
return 0;
|
|
1290
|
+
}
|
|
1291
|
+
let result;
|
|
1292
|
+
if (!config.maxURL) {
|
|
1293
|
+
result = 0;
|
|
1294
|
+
} else {
|
|
1295
|
+
let maxHostLength = 0;
|
|
1296
|
+
config.resources.forEach((item) => {
|
|
1297
|
+
const host = item;
|
|
1298
|
+
maxHostLength = Math.max(maxHostLength, host.length);
|
|
1299
|
+
});
|
|
1300
|
+
const url = prefix + ".json?icons=";
|
|
1301
|
+
result = config.maxURL - maxHostLength - config.path.length - url.length;
|
|
1302
|
+
}
|
|
1303
|
+
return result;
|
|
1304
|
+
}
|
|
1305
|
+
function shouldAbort(status) {
|
|
1306
|
+
return status === 404;
|
|
1307
|
+
}
|
|
1308
|
+
var prepare = (provider, prefix, icons) => {
|
|
1309
|
+
const results = [];
|
|
1310
|
+
const maxLength = calculateMaxLength(provider, prefix);
|
|
1311
|
+
const type = "icons";
|
|
1312
|
+
let item = {
|
|
1313
|
+
type,
|
|
1314
|
+
provider,
|
|
1315
|
+
prefix,
|
|
1316
|
+
icons: []
|
|
1317
|
+
};
|
|
1318
|
+
let length = 0;
|
|
1319
|
+
icons.forEach((name, index) => {
|
|
1320
|
+
length += name.length + 1;
|
|
1321
|
+
if (length >= maxLength && index > 0) {
|
|
1322
|
+
results.push(item);
|
|
1323
|
+
item = {
|
|
1324
|
+
type,
|
|
1325
|
+
provider,
|
|
1326
|
+
prefix,
|
|
1327
|
+
icons: []
|
|
1328
|
+
};
|
|
1329
|
+
length = name.length;
|
|
1330
|
+
}
|
|
1331
|
+
item.icons.push(name);
|
|
1332
|
+
});
|
|
1333
|
+
results.push(item);
|
|
1334
|
+
return results;
|
|
1335
|
+
};
|
|
1336
|
+
function getPath(provider) {
|
|
1337
|
+
if (typeof provider === "string") {
|
|
1338
|
+
const config = getAPIConfig(provider);
|
|
1339
|
+
if (config) {
|
|
1340
|
+
return config.path;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
return "/";
|
|
1344
|
+
}
|
|
1345
|
+
var send = (host, params, callback) => {
|
|
1346
|
+
if (!fetchModule) {
|
|
1347
|
+
callback("abort", 424);
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
let path = getPath(params.provider);
|
|
1351
|
+
switch (params.type) {
|
|
1352
|
+
case "icons": {
|
|
1353
|
+
const prefix = params.prefix;
|
|
1354
|
+
const icons = params.icons;
|
|
1355
|
+
const iconsList = icons.join(",");
|
|
1356
|
+
const urlParams = new URLSearchParams({
|
|
1357
|
+
icons: iconsList
|
|
1358
|
+
});
|
|
1359
|
+
path += prefix + ".json?" + urlParams.toString();
|
|
1360
|
+
break;
|
|
1361
|
+
}
|
|
1362
|
+
case "custom": {
|
|
1363
|
+
const uri = params.uri;
|
|
1364
|
+
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
default:
|
|
1368
|
+
callback("abort", 400);
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
let defaultError = 503;
|
|
1372
|
+
fetchModule(host + path).then((response) => {
|
|
1373
|
+
const status = response.status;
|
|
1374
|
+
if (status !== 200) {
|
|
1375
|
+
setTimeout(() => {
|
|
1376
|
+
callback(shouldAbort(status) ? "abort" : "next", status);
|
|
1377
|
+
});
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
defaultError = 501;
|
|
1381
|
+
return response.json();
|
|
1382
|
+
}).then((data) => {
|
|
1383
|
+
if (typeof data !== "object" || data === null) {
|
|
1384
|
+
setTimeout(() => {
|
|
1385
|
+
if (data === 404) {
|
|
1386
|
+
callback("abort", data);
|
|
1387
|
+
} else {
|
|
1388
|
+
callback("next", defaultError);
|
|
1389
|
+
}
|
|
1390
|
+
});
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
setTimeout(() => {
|
|
1394
|
+
callback("success", data);
|
|
1395
|
+
});
|
|
1396
|
+
}).catch(() => {
|
|
1397
|
+
callback("next", defaultError);
|
|
1398
|
+
});
|
|
1399
|
+
};
|
|
1400
|
+
var fetchAPIModule = {
|
|
1401
|
+
prepare,
|
|
1402
|
+
send
|
|
1403
|
+
};
|
|
1404
|
+
function sortIcons(icons) {
|
|
1405
|
+
const result = {
|
|
1406
|
+
loaded: [],
|
|
1407
|
+
missing: [],
|
|
1408
|
+
pending: []
|
|
1409
|
+
};
|
|
1410
|
+
const storage2 = /* @__PURE__ */ Object.create(null);
|
|
1411
|
+
icons.sort((a, b) => {
|
|
1412
|
+
if (a.provider !== b.provider) {
|
|
1413
|
+
return a.provider.localeCompare(b.provider);
|
|
1414
|
+
}
|
|
1415
|
+
if (a.prefix !== b.prefix) {
|
|
1416
|
+
return a.prefix.localeCompare(b.prefix);
|
|
1417
|
+
}
|
|
1418
|
+
return a.name.localeCompare(b.name);
|
|
1419
|
+
});
|
|
1420
|
+
let lastIcon = {
|
|
1421
|
+
provider: "",
|
|
1422
|
+
prefix: "",
|
|
1423
|
+
name: ""
|
|
1424
|
+
};
|
|
1425
|
+
icons.forEach((icon) => {
|
|
1426
|
+
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
lastIcon = icon;
|
|
1430
|
+
const provider = icon.provider;
|
|
1431
|
+
const prefix = icon.prefix;
|
|
1432
|
+
const name = icon.name;
|
|
1433
|
+
const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
|
|
1434
|
+
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
1435
|
+
let list;
|
|
1436
|
+
if (name in localStorage.icons) {
|
|
1437
|
+
list = result.loaded;
|
|
1438
|
+
} else if (prefix === "" || localStorage.missing.has(name)) {
|
|
1439
|
+
list = result.missing;
|
|
1440
|
+
} else {
|
|
1441
|
+
list = result.pending;
|
|
1442
|
+
}
|
|
1443
|
+
const item = {
|
|
1444
|
+
provider,
|
|
1445
|
+
prefix,
|
|
1446
|
+
name
|
|
1447
|
+
};
|
|
1448
|
+
list.push(item);
|
|
1449
|
+
});
|
|
1450
|
+
return result;
|
|
1451
|
+
}
|
|
1452
|
+
function removeCallback(storages, id) {
|
|
1453
|
+
storages.forEach((storage2) => {
|
|
1454
|
+
const items = storage2.loaderCallbacks;
|
|
1455
|
+
if (items) {
|
|
1456
|
+
storage2.loaderCallbacks = items.filter((row) => row.id !== id);
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
function updateCallbacks(storage2) {
|
|
1461
|
+
if (!storage2.pendingCallbacksFlag) {
|
|
1462
|
+
storage2.pendingCallbacksFlag = true;
|
|
1463
|
+
setTimeout(() => {
|
|
1464
|
+
storage2.pendingCallbacksFlag = false;
|
|
1465
|
+
const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
|
|
1466
|
+
if (!items.length) {
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
let hasPending = false;
|
|
1470
|
+
const provider = storage2.provider;
|
|
1471
|
+
const prefix = storage2.prefix;
|
|
1472
|
+
items.forEach((item) => {
|
|
1473
|
+
const icons = item.icons;
|
|
1474
|
+
const oldLength = icons.pending.length;
|
|
1475
|
+
icons.pending = icons.pending.filter((icon) => {
|
|
1476
|
+
if (icon.prefix !== prefix) {
|
|
1477
|
+
return true;
|
|
1478
|
+
}
|
|
1479
|
+
const name = icon.name;
|
|
1480
|
+
if (storage2.icons[name]) {
|
|
1481
|
+
icons.loaded.push({
|
|
1482
|
+
provider,
|
|
1483
|
+
prefix,
|
|
1484
|
+
name
|
|
1485
|
+
});
|
|
1486
|
+
} else if (storage2.missing.has(name)) {
|
|
1487
|
+
icons.missing.push({
|
|
1488
|
+
provider,
|
|
1489
|
+
prefix,
|
|
1490
|
+
name
|
|
1491
|
+
});
|
|
1492
|
+
} else {
|
|
1493
|
+
hasPending = true;
|
|
1494
|
+
return true;
|
|
1495
|
+
}
|
|
1496
|
+
return false;
|
|
1497
|
+
});
|
|
1498
|
+
if (icons.pending.length !== oldLength) {
|
|
1499
|
+
if (!hasPending) {
|
|
1500
|
+
removeCallback([storage2], item.id);
|
|
1501
|
+
}
|
|
1502
|
+
item.callback(
|
|
1503
|
+
icons.loaded.slice(0),
|
|
1504
|
+
icons.missing.slice(0),
|
|
1505
|
+
icons.pending.slice(0),
|
|
1506
|
+
item.abort
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
var idCounter = 0;
|
|
1514
|
+
function storeCallback(callback, icons, pendingSources) {
|
|
1515
|
+
const id = idCounter++;
|
|
1516
|
+
const abort = removeCallback.bind(null, pendingSources, id);
|
|
1517
|
+
if (!icons.pending.length) {
|
|
1518
|
+
return abort;
|
|
1519
|
+
}
|
|
1520
|
+
const item = {
|
|
1521
|
+
id,
|
|
1522
|
+
icons,
|
|
1523
|
+
callback,
|
|
1524
|
+
abort
|
|
1525
|
+
};
|
|
1526
|
+
pendingSources.forEach((storage2) => {
|
|
1527
|
+
(storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
|
|
1528
|
+
});
|
|
1529
|
+
return abort;
|
|
1530
|
+
}
|
|
1531
|
+
function listToIcons(list, validate = true, simpleNames2 = false) {
|
|
1532
|
+
const result = [];
|
|
1533
|
+
list.forEach((item) => {
|
|
1534
|
+
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
|
|
1535
|
+
if (icon) {
|
|
1536
|
+
result.push(icon);
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
return result;
|
|
1540
|
+
}
|
|
1541
|
+
var defaultConfig = {
|
|
1542
|
+
resources: [],
|
|
1543
|
+
index: 0,
|
|
1544
|
+
timeout: 2e3,
|
|
1545
|
+
rotate: 750,
|
|
1546
|
+
random: false,
|
|
1547
|
+
dataAfterTimeout: false
|
|
1548
|
+
};
|
|
1549
|
+
function sendQuery(config, payload, query, done) {
|
|
1550
|
+
const resourcesCount = config.resources.length;
|
|
1551
|
+
const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
|
|
1552
|
+
let resources;
|
|
1553
|
+
if (config.random) {
|
|
1554
|
+
let list = config.resources.slice(0);
|
|
1555
|
+
resources = [];
|
|
1556
|
+
while (list.length > 1) {
|
|
1557
|
+
const nextIndex = Math.floor(Math.random() * list.length);
|
|
1558
|
+
resources.push(list[nextIndex]);
|
|
1559
|
+
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
|
|
1560
|
+
}
|
|
1561
|
+
resources = resources.concat(list);
|
|
1562
|
+
} else {
|
|
1563
|
+
resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
1564
|
+
}
|
|
1565
|
+
const startTime = Date.now();
|
|
1566
|
+
let status = "pending";
|
|
1567
|
+
let queriesSent = 0;
|
|
1568
|
+
let lastError;
|
|
1569
|
+
let timer = null;
|
|
1570
|
+
let queue = [];
|
|
1571
|
+
let doneCallbacks = [];
|
|
1572
|
+
if (typeof done === "function") {
|
|
1573
|
+
doneCallbacks.push(done);
|
|
1574
|
+
}
|
|
1575
|
+
function resetTimer() {
|
|
1576
|
+
if (timer) {
|
|
1577
|
+
clearTimeout(timer);
|
|
1578
|
+
timer = null;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
function abort() {
|
|
1582
|
+
if (status === "pending") {
|
|
1583
|
+
status = "aborted";
|
|
1584
|
+
}
|
|
1585
|
+
resetTimer();
|
|
1586
|
+
queue.forEach((item) => {
|
|
1587
|
+
if (item.status === "pending") {
|
|
1588
|
+
item.status = "aborted";
|
|
1589
|
+
}
|
|
1590
|
+
});
|
|
1591
|
+
queue = [];
|
|
1592
|
+
}
|
|
1593
|
+
function subscribe(callback, overwrite) {
|
|
1594
|
+
if (overwrite) {
|
|
1595
|
+
doneCallbacks = [];
|
|
1596
|
+
}
|
|
1597
|
+
if (typeof callback === "function") {
|
|
1598
|
+
doneCallbacks.push(callback);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
function getQueryStatus() {
|
|
1602
|
+
return {
|
|
1603
|
+
startTime,
|
|
1604
|
+
payload,
|
|
1605
|
+
status,
|
|
1606
|
+
queriesSent,
|
|
1607
|
+
queriesPending: queue.length,
|
|
1608
|
+
subscribe,
|
|
1609
|
+
abort
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
function failQuery() {
|
|
1613
|
+
status = "failed";
|
|
1614
|
+
doneCallbacks.forEach((callback) => {
|
|
1615
|
+
callback(void 0, lastError);
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
function clearQueue() {
|
|
1619
|
+
queue.forEach((item) => {
|
|
1620
|
+
if (item.status === "pending") {
|
|
1621
|
+
item.status = "aborted";
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
queue = [];
|
|
1625
|
+
}
|
|
1626
|
+
function moduleResponse(item, response, data) {
|
|
1627
|
+
const isError = response !== "success";
|
|
1628
|
+
queue = queue.filter((queued) => queued !== item);
|
|
1629
|
+
switch (status) {
|
|
1630
|
+
case "pending":
|
|
1631
|
+
break;
|
|
1632
|
+
case "failed":
|
|
1633
|
+
if (isError || !config.dataAfterTimeout) {
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
break;
|
|
1637
|
+
default:
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
if (response === "abort") {
|
|
1641
|
+
lastError = data;
|
|
1642
|
+
failQuery();
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
if (isError) {
|
|
1646
|
+
lastError = data;
|
|
1647
|
+
if (!queue.length) {
|
|
1648
|
+
if (!resources.length) {
|
|
1649
|
+
failQuery();
|
|
1650
|
+
} else {
|
|
1651
|
+
execNext();
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
resetTimer();
|
|
1657
|
+
clearQueue();
|
|
1658
|
+
if (!config.random) {
|
|
1659
|
+
const index = config.resources.indexOf(item.resource);
|
|
1660
|
+
if (index !== -1 && index !== config.index) {
|
|
1661
|
+
config.index = index;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
status = "completed";
|
|
1665
|
+
doneCallbacks.forEach((callback) => {
|
|
1666
|
+
callback(data);
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
function execNext() {
|
|
1670
|
+
if (status !== "pending") {
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
resetTimer();
|
|
1674
|
+
const resource = resources.shift();
|
|
1675
|
+
if (resource === void 0) {
|
|
1676
|
+
if (queue.length) {
|
|
1677
|
+
timer = setTimeout(() => {
|
|
1678
|
+
resetTimer();
|
|
1679
|
+
if (status === "pending") {
|
|
1680
|
+
clearQueue();
|
|
1681
|
+
failQuery();
|
|
1682
|
+
}
|
|
1683
|
+
}, config.timeout);
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
failQuery();
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
const item = {
|
|
1690
|
+
status: "pending",
|
|
1691
|
+
resource,
|
|
1692
|
+
callback: (status2, data) => {
|
|
1693
|
+
moduleResponse(item, status2, data);
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
queue.push(item);
|
|
1697
|
+
queriesSent++;
|
|
1698
|
+
timer = setTimeout(execNext, config.rotate);
|
|
1699
|
+
query(resource, payload, item.callback);
|
|
1700
|
+
}
|
|
1701
|
+
setTimeout(execNext);
|
|
1702
|
+
return getQueryStatus;
|
|
1703
|
+
}
|
|
1704
|
+
function initRedundancy(cfg) {
|
|
1705
|
+
const config = __spreadValues(__spreadValues({}, defaultConfig), cfg);
|
|
1706
|
+
let queries = [];
|
|
1707
|
+
function cleanup() {
|
|
1708
|
+
queries = queries.filter((item) => item().status === "pending");
|
|
1709
|
+
}
|
|
1710
|
+
function query(payload, queryCallback, doneCallback) {
|
|
1711
|
+
const query2 = sendQuery(
|
|
1712
|
+
config,
|
|
1713
|
+
payload,
|
|
1714
|
+
queryCallback,
|
|
1715
|
+
(data, error) => {
|
|
1716
|
+
cleanup();
|
|
1717
|
+
if (doneCallback) {
|
|
1718
|
+
doneCallback(data, error);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
);
|
|
1722
|
+
queries.push(query2);
|
|
1723
|
+
return query2;
|
|
1724
|
+
}
|
|
1725
|
+
function find(callback) {
|
|
1726
|
+
return queries.find((value) => {
|
|
1727
|
+
return callback(value);
|
|
1728
|
+
}) || null;
|
|
1729
|
+
}
|
|
1730
|
+
const instance = {
|
|
1731
|
+
query,
|
|
1732
|
+
find,
|
|
1733
|
+
setIndex: (index) => {
|
|
1734
|
+
config.index = index;
|
|
1735
|
+
},
|
|
1736
|
+
getIndex: () => config.index,
|
|
1737
|
+
cleanup
|
|
1738
|
+
};
|
|
1739
|
+
return instance;
|
|
1740
|
+
}
|
|
1741
|
+
function emptyCallback$1() {
|
|
1742
|
+
}
|
|
1743
|
+
var redundancyCache = /* @__PURE__ */ Object.create(null);
|
|
1744
|
+
function getRedundancyCache(provider) {
|
|
1745
|
+
if (!redundancyCache[provider]) {
|
|
1746
|
+
const config = getAPIConfig(provider);
|
|
1747
|
+
if (!config) {
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
const redundancy = initRedundancy(config);
|
|
1751
|
+
const cachedReundancy = {
|
|
1752
|
+
config,
|
|
1753
|
+
redundancy
|
|
1754
|
+
};
|
|
1755
|
+
redundancyCache[provider] = cachedReundancy;
|
|
1756
|
+
}
|
|
1757
|
+
return redundancyCache[provider];
|
|
1758
|
+
}
|
|
1759
|
+
function sendAPIQuery(target, query, callback) {
|
|
1760
|
+
let redundancy;
|
|
1761
|
+
let send2;
|
|
1762
|
+
if (typeof target === "string") {
|
|
1763
|
+
const api = getAPIModule(target);
|
|
1764
|
+
if (!api) {
|
|
1765
|
+
callback(void 0, 424);
|
|
1766
|
+
return emptyCallback$1;
|
|
1767
|
+
}
|
|
1768
|
+
send2 = api.send;
|
|
1769
|
+
const cached = getRedundancyCache(target);
|
|
1770
|
+
if (cached) {
|
|
1771
|
+
redundancy = cached.redundancy;
|
|
1772
|
+
}
|
|
1773
|
+
} else {
|
|
1774
|
+
const config = createAPIConfig(target);
|
|
1775
|
+
if (config) {
|
|
1776
|
+
redundancy = initRedundancy(config);
|
|
1777
|
+
const moduleKey = target.resources ? target.resources[0] : "";
|
|
1778
|
+
const api = getAPIModule(moduleKey);
|
|
1779
|
+
if (api) {
|
|
1780
|
+
send2 = api.send;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
if (!redundancy || !send2) {
|
|
1785
|
+
callback(void 0, 424);
|
|
1786
|
+
return emptyCallback$1;
|
|
1787
|
+
}
|
|
1788
|
+
return redundancy.query(query, send2, callback)().abort;
|
|
1789
|
+
}
|
|
1790
|
+
var browserCacheVersion = "iconify2";
|
|
1791
|
+
var browserCachePrefix = "iconify";
|
|
1792
|
+
var browserCacheCountKey = browserCachePrefix + "-count";
|
|
1793
|
+
var browserCacheVersionKey = browserCachePrefix + "-version";
|
|
1794
|
+
var browserStorageHour = 36e5;
|
|
1795
|
+
var browserStorageCacheExpiration = 168;
|
|
1796
|
+
function getStoredItem(func, key) {
|
|
1797
|
+
try {
|
|
1798
|
+
return func.getItem(key);
|
|
1799
|
+
} catch (err) {
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
function setStoredItem(func, key, value) {
|
|
1803
|
+
try {
|
|
1804
|
+
func.setItem(key, value);
|
|
1805
|
+
return true;
|
|
1806
|
+
} catch (err) {
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
function removeStoredItem(func, key) {
|
|
1810
|
+
try {
|
|
1811
|
+
func.removeItem(key);
|
|
1812
|
+
} catch (err) {
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
function setBrowserStorageItemsCount(storage2, value) {
|
|
1816
|
+
return setStoredItem(storage2, browserCacheCountKey, value.toString());
|
|
1817
|
+
}
|
|
1818
|
+
function getBrowserStorageItemsCount(storage2) {
|
|
1819
|
+
return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
|
|
1820
|
+
}
|
|
1821
|
+
var browserStorageConfig = {
|
|
1822
|
+
local: true,
|
|
1823
|
+
session: true
|
|
1824
|
+
};
|
|
1825
|
+
var browserStorageEmptyItems = {
|
|
1826
|
+
local: /* @__PURE__ */ new Set(),
|
|
1827
|
+
session: /* @__PURE__ */ new Set()
|
|
1828
|
+
};
|
|
1829
|
+
var browserStorageStatus = false;
|
|
1830
|
+
function setBrowserStorageStatus(status) {
|
|
1831
|
+
browserStorageStatus = status;
|
|
1832
|
+
}
|
|
1833
|
+
var _window = typeof window === "undefined" ? {} : window;
|
|
1834
|
+
function getBrowserStorage(key) {
|
|
1835
|
+
const attr = key + "Storage";
|
|
1836
|
+
try {
|
|
1837
|
+
if (_window && _window[attr] && typeof _window[attr].length === "number") {
|
|
1838
|
+
return _window[attr];
|
|
1839
|
+
}
|
|
1840
|
+
} catch (err) {
|
|
1841
|
+
}
|
|
1842
|
+
browserStorageConfig[key] = false;
|
|
1843
|
+
}
|
|
1844
|
+
function iterateBrowserStorage(key, callback) {
|
|
1845
|
+
const func = getBrowserStorage(key);
|
|
1846
|
+
if (!func) {
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
const version = getStoredItem(func, browserCacheVersionKey);
|
|
1850
|
+
if (version !== browserCacheVersion) {
|
|
1851
|
+
if (version) {
|
|
1852
|
+
const total2 = getBrowserStorageItemsCount(func);
|
|
1853
|
+
for (let i = 0; i < total2; i++) {
|
|
1854
|
+
removeStoredItem(func, browserCachePrefix + i.toString());
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
|
|
1858
|
+
setBrowserStorageItemsCount(func, 0);
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
|
|
1862
|
+
const parseItem = (index) => {
|
|
1863
|
+
const name = browserCachePrefix + index.toString();
|
|
1864
|
+
const item = getStoredItem(func, name);
|
|
1865
|
+
if (typeof item !== "string") {
|
|
1866
|
+
return;
|
|
1867
|
+
}
|
|
1868
|
+
try {
|
|
1869
|
+
const data = JSON.parse(item);
|
|
1870
|
+
if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && // Valid item: run callback
|
|
1871
|
+
callback(data, index)) {
|
|
1872
|
+
return true;
|
|
1873
|
+
}
|
|
1874
|
+
} catch (err) {
|
|
1875
|
+
}
|
|
1876
|
+
removeStoredItem(func, name);
|
|
1877
|
+
};
|
|
1878
|
+
let total = getBrowserStorageItemsCount(func);
|
|
1879
|
+
for (let i = total - 1; i >= 0; i--) {
|
|
1880
|
+
if (!parseItem(i)) {
|
|
1881
|
+
if (i === total - 1) {
|
|
1882
|
+
total--;
|
|
1883
|
+
setBrowserStorageItemsCount(func, total);
|
|
1884
|
+
} else {
|
|
1885
|
+
browserStorageEmptyItems[key].add(i);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
function initBrowserStorage() {
|
|
1891
|
+
if (browserStorageStatus) {
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
setBrowserStorageStatus(true);
|
|
1895
|
+
for (const key in browserStorageConfig) {
|
|
1896
|
+
iterateBrowserStorage(key, (item) => {
|
|
1897
|
+
const iconSet = item.data;
|
|
1898
|
+
const provider = item.provider;
|
|
1899
|
+
const prefix = iconSet.prefix;
|
|
1900
|
+
const storage2 = getStorage(
|
|
1901
|
+
provider,
|
|
1902
|
+
prefix
|
|
1903
|
+
);
|
|
1904
|
+
if (!addIconSet(storage2, iconSet).length) {
|
|
1905
|
+
return false;
|
|
1906
|
+
}
|
|
1907
|
+
const lastModified = iconSet.lastModified || -1;
|
|
1908
|
+
storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
|
|
1909
|
+
return true;
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
function updateLastModified(storage2, lastModified) {
|
|
1914
|
+
const lastValue = storage2.lastModifiedCached;
|
|
1915
|
+
if (
|
|
1916
|
+
// Matches or newer
|
|
1917
|
+
lastValue && lastValue >= lastModified
|
|
1918
|
+
) {
|
|
1919
|
+
return lastValue === lastModified;
|
|
1920
|
+
}
|
|
1921
|
+
storage2.lastModifiedCached = lastModified;
|
|
1922
|
+
if (lastValue) {
|
|
1923
|
+
for (const key in browserStorageConfig) {
|
|
1924
|
+
iterateBrowserStorage(key, (item) => {
|
|
1925
|
+
const iconSet = item.data;
|
|
1926
|
+
return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
return true;
|
|
1931
|
+
}
|
|
1932
|
+
function storeInBrowserStorage(storage2, data) {
|
|
1933
|
+
if (!browserStorageStatus) {
|
|
1934
|
+
initBrowserStorage();
|
|
1935
|
+
}
|
|
1936
|
+
function store(key) {
|
|
1937
|
+
let func;
|
|
1938
|
+
if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
const set = browserStorageEmptyItems[key];
|
|
1942
|
+
let index;
|
|
1943
|
+
if (set.size) {
|
|
1944
|
+
set.delete(index = Array.from(set).shift());
|
|
1945
|
+
} else {
|
|
1946
|
+
index = getBrowserStorageItemsCount(func);
|
|
1947
|
+
if (!setBrowserStorageItemsCount(func, index + 1)) {
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
const item = {
|
|
1952
|
+
cached: Math.floor(Date.now() / browserStorageHour),
|
|
1953
|
+
provider: storage2.provider,
|
|
1954
|
+
data
|
|
1955
|
+
};
|
|
1956
|
+
return setStoredItem(
|
|
1957
|
+
func,
|
|
1958
|
+
browserCachePrefix + index.toString(),
|
|
1959
|
+
JSON.stringify(item)
|
|
1960
|
+
);
|
|
1961
|
+
}
|
|
1962
|
+
if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
if (!Object.keys(data.icons).length) {
|
|
1966
|
+
return;
|
|
1967
|
+
}
|
|
1968
|
+
if (data.not_found) {
|
|
1969
|
+
data = Object.assign({}, data);
|
|
1970
|
+
delete data.not_found;
|
|
1971
|
+
}
|
|
1972
|
+
if (!store("local")) {
|
|
1973
|
+
store("session");
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
function emptyCallback() {
|
|
1977
|
+
}
|
|
1978
|
+
function loadedNewIcons(storage2) {
|
|
1979
|
+
if (!storage2.iconsLoaderFlag) {
|
|
1980
|
+
storage2.iconsLoaderFlag = true;
|
|
1981
|
+
setTimeout(() => {
|
|
1982
|
+
storage2.iconsLoaderFlag = false;
|
|
1983
|
+
updateCallbacks(storage2);
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
function loadNewIcons(storage2, icons) {
|
|
1988
|
+
if (!storage2.iconsToLoad) {
|
|
1989
|
+
storage2.iconsToLoad = icons;
|
|
1990
|
+
} else {
|
|
1991
|
+
storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
|
|
1992
|
+
}
|
|
1993
|
+
if (!storage2.iconsQueueFlag) {
|
|
1994
|
+
storage2.iconsQueueFlag = true;
|
|
1995
|
+
setTimeout(() => {
|
|
1996
|
+
storage2.iconsQueueFlag = false;
|
|
1997
|
+
const { provider, prefix } = storage2;
|
|
1998
|
+
const icons2 = storage2.iconsToLoad;
|
|
1999
|
+
delete storage2.iconsToLoad;
|
|
2000
|
+
let api;
|
|
2001
|
+
if (!icons2 || !(api = getAPIModule(provider))) {
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
const params = api.prepare(provider, prefix, icons2);
|
|
2005
|
+
params.forEach((item) => {
|
|
2006
|
+
sendAPIQuery(provider, item, (data) => {
|
|
2007
|
+
if (typeof data !== "object") {
|
|
2008
|
+
item.icons.forEach((name) => {
|
|
2009
|
+
storage2.missing.add(name);
|
|
2010
|
+
});
|
|
2011
|
+
} else {
|
|
2012
|
+
try {
|
|
2013
|
+
const parsed = addIconSet(
|
|
2014
|
+
storage2,
|
|
2015
|
+
data
|
|
2016
|
+
);
|
|
2017
|
+
if (!parsed.length) {
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
const pending = storage2.pendingIcons;
|
|
2021
|
+
if (pending) {
|
|
2022
|
+
parsed.forEach((name) => {
|
|
2023
|
+
pending.delete(name);
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
storeInBrowserStorage(storage2, data);
|
|
2027
|
+
} catch (err) {
|
|
2028
|
+
console.error(err);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
loadedNewIcons(storage2);
|
|
2032
|
+
});
|
|
2033
|
+
});
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
var loadIcons = (icons, callback) => {
|
|
2038
|
+
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
|
|
2039
|
+
const sortedIcons = sortIcons(cleanedIcons);
|
|
2040
|
+
if (!sortedIcons.pending.length) {
|
|
2041
|
+
let callCallback = true;
|
|
2042
|
+
if (callback) {
|
|
2043
|
+
setTimeout(() => {
|
|
2044
|
+
if (callCallback) {
|
|
2045
|
+
callback(
|
|
2046
|
+
sortedIcons.loaded,
|
|
2047
|
+
sortedIcons.missing,
|
|
2048
|
+
sortedIcons.pending,
|
|
2049
|
+
emptyCallback
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
return () => {
|
|
2055
|
+
callCallback = false;
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
const newIcons = /* @__PURE__ */ Object.create(null);
|
|
2059
|
+
const sources = [];
|
|
2060
|
+
let lastProvider, lastPrefix;
|
|
2061
|
+
sortedIcons.pending.forEach((icon) => {
|
|
2062
|
+
const { provider, prefix } = icon;
|
|
2063
|
+
if (prefix === lastPrefix && provider === lastProvider) {
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
lastProvider = provider;
|
|
2067
|
+
lastPrefix = prefix;
|
|
2068
|
+
sources.push(getStorage(provider, prefix));
|
|
2069
|
+
const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
|
|
2070
|
+
if (!providerNewIcons[prefix]) {
|
|
2071
|
+
providerNewIcons[prefix] = [];
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
sortedIcons.pending.forEach((icon) => {
|
|
2075
|
+
const { provider, prefix, name } = icon;
|
|
2076
|
+
const storage2 = getStorage(provider, prefix);
|
|
2077
|
+
const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
|
|
2078
|
+
if (!pendingQueue.has(name)) {
|
|
2079
|
+
pendingQueue.add(name);
|
|
2080
|
+
newIcons[provider][prefix].push(name);
|
|
2081
|
+
}
|
|
2082
|
+
});
|
|
2083
|
+
sources.forEach((storage2) => {
|
|
2084
|
+
const { provider, prefix } = storage2;
|
|
2085
|
+
if (newIcons[provider][prefix].length) {
|
|
2086
|
+
loadNewIcons(storage2, newIcons[provider][prefix]);
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
|
|
2090
|
+
};
|
|
2091
|
+
function mergeCustomisations(defaults, item) {
|
|
2092
|
+
const result = __spreadValues({}, defaults);
|
|
2093
|
+
for (const key in item) {
|
|
2094
|
+
const value = item[key];
|
|
2095
|
+
const valueType = typeof value;
|
|
2096
|
+
if (key in defaultIconSizeCustomisations) {
|
|
2097
|
+
if (value === null || value && (valueType === "string" || valueType === "number")) {
|
|
2098
|
+
result[key] = value;
|
|
2099
|
+
}
|
|
2100
|
+
} else if (valueType === typeof result[key]) {
|
|
2101
|
+
result[key] = key === "rotate" ? value % 4 : value;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
return result;
|
|
2105
|
+
}
|
|
2106
|
+
var separator = /[\s,]+/;
|
|
2107
|
+
function flipFromString(custom, flip) {
|
|
2108
|
+
flip.split(separator).forEach((str) => {
|
|
2109
|
+
const value = str.trim();
|
|
2110
|
+
switch (value) {
|
|
2111
|
+
case "horizontal":
|
|
2112
|
+
custom.hFlip = true;
|
|
2113
|
+
break;
|
|
2114
|
+
case "vertical":
|
|
2115
|
+
custom.vFlip = true;
|
|
2116
|
+
break;
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
function rotateFromString(value, defaultValue = 0) {
|
|
2121
|
+
const units = value.replace(/^-?[0-9.]*/, "");
|
|
2122
|
+
function cleanup(value2) {
|
|
2123
|
+
while (value2 < 0) {
|
|
2124
|
+
value2 += 4;
|
|
2125
|
+
}
|
|
2126
|
+
return value2 % 4;
|
|
2127
|
+
}
|
|
2128
|
+
if (units === "") {
|
|
2129
|
+
const num = parseInt(value);
|
|
2130
|
+
return isNaN(num) ? 0 : cleanup(num);
|
|
2131
|
+
} else if (units !== value) {
|
|
2132
|
+
let split = 0;
|
|
2133
|
+
switch (units) {
|
|
2134
|
+
case "%":
|
|
2135
|
+
split = 25;
|
|
2136
|
+
break;
|
|
2137
|
+
case "deg":
|
|
2138
|
+
split = 90;
|
|
2139
|
+
}
|
|
2140
|
+
if (split) {
|
|
2141
|
+
let num = parseFloat(value.slice(0, value.length - units.length));
|
|
2142
|
+
if (isNaN(num)) {
|
|
2143
|
+
return 0;
|
|
2144
|
+
}
|
|
2145
|
+
num = num / split;
|
|
2146
|
+
return num % 1 === 0 ? cleanup(num) : 0;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
return defaultValue;
|
|
2150
|
+
}
|
|
2151
|
+
function iconToHTML(body, attributes) {
|
|
2152
|
+
let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
2153
|
+
for (const attr in attributes) {
|
|
2154
|
+
renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
|
|
2155
|
+
}
|
|
2156
|
+
return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
|
|
2157
|
+
}
|
|
2158
|
+
function encodeSVGforURL(svg) {
|
|
2159
|
+
return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
|
|
2160
|
+
}
|
|
2161
|
+
function svgToData(svg) {
|
|
2162
|
+
return "data:image/svg+xml," + encodeSVGforURL(svg);
|
|
2163
|
+
}
|
|
2164
|
+
function svgToURL(svg) {
|
|
2165
|
+
return 'url("' + svgToData(svg) + '")';
|
|
2166
|
+
}
|
|
2167
|
+
var policy;
|
|
2168
|
+
function createPolicy() {
|
|
2169
|
+
try {
|
|
2170
|
+
policy = window.trustedTypes.createPolicy("iconify", {
|
|
2171
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
2172
|
+
createHTML: (s) => s
|
|
2173
|
+
});
|
|
2174
|
+
} catch (err) {
|
|
2175
|
+
policy = null;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
function cleanUpInnerHTML(html) {
|
|
2179
|
+
if (policy === void 0) {
|
|
2180
|
+
createPolicy();
|
|
2181
|
+
}
|
|
2182
|
+
return policy ? policy.createHTML(html) : html;
|
|
2183
|
+
}
|
|
2184
|
+
var defaultExtendedIconCustomisations = __spreadProps(__spreadValues({}, defaultIconCustomisations), {
|
|
2185
|
+
inline: false
|
|
2186
|
+
});
|
|
2187
|
+
var svgDefaults = {
|
|
2188
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
2189
|
+
"xmlnsXlink": "http://www.w3.org/1999/xlink",
|
|
2190
|
+
"aria-hidden": true,
|
|
2191
|
+
"role": "img"
|
|
2192
|
+
};
|
|
2193
|
+
var commonProps = {
|
|
2194
|
+
display: "inline-block"
|
|
2195
|
+
};
|
|
2196
|
+
var monotoneProps = {
|
|
2197
|
+
backgroundColor: "currentColor"
|
|
2198
|
+
};
|
|
2199
|
+
var coloredProps = {
|
|
2200
|
+
backgroundColor: "transparent"
|
|
2201
|
+
};
|
|
2202
|
+
var propsToAdd = {
|
|
2203
|
+
Image: "var(--svg)",
|
|
2204
|
+
Repeat: "no-repeat",
|
|
2205
|
+
Size: "100% 100%"
|
|
2206
|
+
};
|
|
2207
|
+
var propsToAddTo = {
|
|
2208
|
+
WebkitMask: monotoneProps,
|
|
2209
|
+
mask: monotoneProps,
|
|
2210
|
+
background: coloredProps
|
|
2211
|
+
};
|
|
2212
|
+
for (const prefix in propsToAddTo) {
|
|
2213
|
+
const list = propsToAddTo[prefix];
|
|
2214
|
+
for (const prop in propsToAdd) {
|
|
2215
|
+
list[prefix + prop] = propsToAdd[prop];
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
var inlineDefaults = __spreadProps(__spreadValues({}, defaultExtendedIconCustomisations), {
|
|
2219
|
+
inline: true
|
|
2220
|
+
});
|
|
2221
|
+
function fixSize(value) {
|
|
2222
|
+
return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
|
|
2223
|
+
}
|
|
2224
|
+
var render = (icon, props, inline, ref) => {
|
|
2225
|
+
const defaultProps = inline ? inlineDefaults : defaultExtendedIconCustomisations;
|
|
2226
|
+
const customisations = mergeCustomisations(defaultProps, props);
|
|
2227
|
+
const mode = props.mode || "svg";
|
|
2228
|
+
const style = {};
|
|
2229
|
+
const customStyle = props.style || {};
|
|
2230
|
+
const componentProps = __spreadProps(__spreadValues({}, mode === "svg" ? svgDefaults : {}), {
|
|
2231
|
+
ref
|
|
2232
|
+
});
|
|
2233
|
+
for (let key in props) {
|
|
2234
|
+
const value = props[key];
|
|
2235
|
+
if (value === void 0) {
|
|
2236
|
+
continue;
|
|
2237
|
+
}
|
|
2238
|
+
switch (key) {
|
|
2239
|
+
case "icon":
|
|
2240
|
+
case "style":
|
|
2241
|
+
case "children":
|
|
2242
|
+
case "onLoad":
|
|
2243
|
+
case "mode":
|
|
2244
|
+
case "_ref":
|
|
2245
|
+
case "_inline":
|
|
2246
|
+
break;
|
|
2247
|
+
case "inline":
|
|
2248
|
+
case "hFlip":
|
|
2249
|
+
case "vFlip":
|
|
2250
|
+
customisations[key] = value === true || value === "true" || value === 1;
|
|
2251
|
+
break;
|
|
2252
|
+
case "flip":
|
|
2253
|
+
if (typeof value === "string") {
|
|
2254
|
+
flipFromString(customisations, value);
|
|
2255
|
+
}
|
|
2256
|
+
break;
|
|
2257
|
+
case "color":
|
|
2258
|
+
style.color = value;
|
|
2259
|
+
break;
|
|
2260
|
+
case "rotate":
|
|
2261
|
+
if (typeof value === "string") {
|
|
2262
|
+
customisations[key] = rotateFromString(value);
|
|
2263
|
+
} else if (typeof value === "number") {
|
|
2264
|
+
customisations[key] = value;
|
|
2265
|
+
}
|
|
2266
|
+
break;
|
|
2267
|
+
case "ariaHidden":
|
|
2268
|
+
case "aria-hidden":
|
|
2269
|
+
if (value !== true && value !== "true") {
|
|
2270
|
+
delete componentProps["aria-hidden"];
|
|
2271
|
+
}
|
|
2272
|
+
break;
|
|
2273
|
+
default:
|
|
2274
|
+
if (defaultProps[key] === void 0) {
|
|
2275
|
+
componentProps[key] = value;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
const item = iconToSVG(icon, customisations);
|
|
2280
|
+
const renderAttribs = item.attributes;
|
|
2281
|
+
if (customisations.inline) {
|
|
2282
|
+
style.verticalAlign = "-0.125em";
|
|
2283
|
+
}
|
|
2284
|
+
if (mode === "svg") {
|
|
2285
|
+
componentProps.style = __spreadValues(__spreadValues({}, style), customStyle);
|
|
2286
|
+
Object.assign(componentProps, renderAttribs);
|
|
2287
|
+
let localCounter = 0;
|
|
2288
|
+
let id = props.id;
|
|
2289
|
+
if (typeof id === "string") {
|
|
2290
|
+
id = id.replace(/-/g, "_");
|
|
2291
|
+
}
|
|
2292
|
+
componentProps.dangerouslySetInnerHTML = {
|
|
2293
|
+
__html: cleanUpInnerHTML(replaceIDs(item.body, id ? () => id + "ID" + localCounter++ : "iconifyReact"))
|
|
2294
|
+
};
|
|
2295
|
+
return React2.createElement("svg", componentProps);
|
|
2296
|
+
}
|
|
2297
|
+
const { body, width, height } = icon;
|
|
2298
|
+
const useMask = mode === "mask" || (mode === "bg" ? false : body.indexOf("currentColor") !== -1);
|
|
2299
|
+
const html = iconToHTML(body, __spreadProps(__spreadValues({}, renderAttribs), {
|
|
2300
|
+
width: width + "",
|
|
2301
|
+
height: height + ""
|
|
2302
|
+
}));
|
|
2303
|
+
componentProps.style = __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, style), {
|
|
2304
|
+
"--svg": svgToURL(html),
|
|
2305
|
+
"width": fixSize(renderAttribs.width),
|
|
2306
|
+
"height": fixSize(renderAttribs.height)
|
|
2307
|
+
}), commonProps), useMask ? monotoneProps : coloredProps), customStyle);
|
|
2308
|
+
return React2.createElement("span", componentProps);
|
|
2309
|
+
};
|
|
2310
|
+
allowSimpleNames(true);
|
|
2311
|
+
setAPIModule("", fetchAPIModule);
|
|
2312
|
+
if (typeof document !== "undefined" && typeof window !== "undefined") {
|
|
2313
|
+
initBrowserStorage();
|
|
2314
|
+
const _window2 = window;
|
|
2315
|
+
if (_window2.IconifyPreload !== void 0) {
|
|
2316
|
+
const preload = _window2.IconifyPreload;
|
|
2317
|
+
const err = "Invalid IconifyPreload syntax.";
|
|
2318
|
+
if (typeof preload === "object" && preload !== null) {
|
|
2319
|
+
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
|
2320
|
+
try {
|
|
2321
|
+
if (
|
|
2322
|
+
// Check if item is an object and not null/array
|
|
2323
|
+
typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
|
|
2324
|
+
typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
|
|
2325
|
+
!addCollection(item)
|
|
2326
|
+
) {
|
|
2327
|
+
console.error(err);
|
|
2328
|
+
}
|
|
2329
|
+
} catch (e) {
|
|
2330
|
+
console.error(err);
|
|
2331
|
+
}
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
if (_window2.IconifyProviders !== void 0) {
|
|
2336
|
+
const providers = _window2.IconifyProviders;
|
|
2337
|
+
if (typeof providers === "object" && providers !== null) {
|
|
2338
|
+
for (let key in providers) {
|
|
2339
|
+
const err = "IconifyProviders[" + key + "] is invalid.";
|
|
2340
|
+
try {
|
|
2341
|
+
const value = providers[key];
|
|
2342
|
+
if (typeof value !== "object" || !value || value.resources === void 0) {
|
|
2343
|
+
continue;
|
|
2344
|
+
}
|
|
2345
|
+
if (!addAPIProvider(key, value)) {
|
|
2346
|
+
console.error(err);
|
|
2347
|
+
}
|
|
2348
|
+
} catch (e) {
|
|
2349
|
+
console.error(err);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
var IconComponent = class extends React2.Component {
|
|
2356
|
+
constructor(props) {
|
|
2357
|
+
super(props);
|
|
2358
|
+
this.state = {
|
|
2359
|
+
// Render placeholder before component is mounted
|
|
2360
|
+
icon: null
|
|
2361
|
+
};
|
|
2362
|
+
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Abort loading icon
|
|
2365
|
+
*/
|
|
2366
|
+
_abortLoading() {
|
|
2367
|
+
if (this._loading) {
|
|
2368
|
+
this._loading.abort();
|
|
2369
|
+
this._loading = null;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
/**
|
|
2373
|
+
* Update state
|
|
2374
|
+
*/
|
|
2375
|
+
_setData(icon) {
|
|
2376
|
+
if (this.state.icon !== icon) {
|
|
2377
|
+
this.setState({
|
|
2378
|
+
icon
|
|
2379
|
+
});
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Check if icon should be loaded
|
|
2384
|
+
*/
|
|
2385
|
+
_checkIcon(changed) {
|
|
2386
|
+
const state = this.state;
|
|
2387
|
+
const icon = this.props.icon;
|
|
2388
|
+
if (typeof icon === "object" && icon !== null && typeof icon.body === "string") {
|
|
2389
|
+
this._icon = "";
|
|
2390
|
+
this._abortLoading();
|
|
2391
|
+
if (changed || state.icon === null) {
|
|
2392
|
+
this._setData({
|
|
2393
|
+
data: icon
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
return;
|
|
2397
|
+
}
|
|
2398
|
+
let iconName;
|
|
2399
|
+
if (typeof icon !== "string" || (iconName = stringToIcon(icon, false, true)) === null) {
|
|
2400
|
+
this._abortLoading();
|
|
2401
|
+
this._setData(null);
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
const data = getIconData(iconName);
|
|
2405
|
+
if (!data) {
|
|
2406
|
+
if (!this._loading || this._loading.name !== icon) {
|
|
2407
|
+
this._abortLoading();
|
|
2408
|
+
this._icon = "";
|
|
2409
|
+
this._setData(null);
|
|
2410
|
+
if (data !== null) {
|
|
2411
|
+
this._loading = {
|
|
2412
|
+
name: icon,
|
|
2413
|
+
abort: loadIcons([iconName], this._checkIcon.bind(this, false))
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
if (this._icon !== icon || state.icon === null) {
|
|
2420
|
+
this._abortLoading();
|
|
2421
|
+
this._icon = icon;
|
|
2422
|
+
const classes = ["iconify"];
|
|
2423
|
+
if (iconName.prefix !== "") {
|
|
2424
|
+
classes.push("iconify--" + iconName.prefix);
|
|
2425
|
+
}
|
|
2426
|
+
if (iconName.provider !== "") {
|
|
2427
|
+
classes.push("iconify--" + iconName.provider);
|
|
2428
|
+
}
|
|
2429
|
+
this._setData({
|
|
2430
|
+
data,
|
|
2431
|
+
classes
|
|
2432
|
+
});
|
|
2433
|
+
if (this.props.onLoad) {
|
|
2434
|
+
this.props.onLoad(icon);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Component mounted
|
|
2440
|
+
*/
|
|
2441
|
+
componentDidMount() {
|
|
2442
|
+
this._checkIcon(false);
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Component updated
|
|
2446
|
+
*/
|
|
2447
|
+
componentDidUpdate(oldProps) {
|
|
2448
|
+
if (oldProps.icon !== this.props.icon) {
|
|
2449
|
+
this._checkIcon(true);
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
/**
|
|
2453
|
+
* Abort loading
|
|
2454
|
+
*/
|
|
2455
|
+
componentWillUnmount() {
|
|
2456
|
+
this._abortLoading();
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Render
|
|
2460
|
+
*/
|
|
2461
|
+
render() {
|
|
2462
|
+
const props = this.props;
|
|
2463
|
+
const icon = this.state.icon;
|
|
2464
|
+
if (icon === null) {
|
|
2465
|
+
return props.children ? props.children : React2.createElement("span", {});
|
|
2466
|
+
}
|
|
2467
|
+
let newProps = props;
|
|
2468
|
+
if (icon.classes) {
|
|
2469
|
+
newProps = __spreadProps(__spreadValues({}, props), {
|
|
2470
|
+
className: (typeof props.className === "string" ? props.className + " " : "") + icon.classes.join(" ")
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
return render(__spreadValues(__spreadValues({}, defaultIconProps), icon.data), newProps, props._inline, props._ref);
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
var Icon = React2.forwardRef(function Icon2(props, ref) {
|
|
2477
|
+
const newProps = __spreadProps(__spreadValues({}, props), {
|
|
2478
|
+
_ref: ref,
|
|
2479
|
+
_inline: false
|
|
2480
|
+
});
|
|
2481
|
+
return React2.createElement(IconComponent, newProps);
|
|
2482
|
+
});
|
|
2483
|
+
React2.forwardRef(function InlineIcon2(props, ref) {
|
|
2484
|
+
const newProps = __spreadProps(__spreadValues({}, props), {
|
|
2485
|
+
_ref: ref,
|
|
2486
|
+
_inline: true
|
|
2487
|
+
});
|
|
2488
|
+
return React2.createElement(IconComponent, newProps);
|
|
2489
|
+
});
|
|
2490
|
+
|
|
2491
|
+
// module/Wallet/walletPluginStore.tsx
|
|
2492
|
+
var defaultRPCList = [
|
|
2493
|
+
{ name: "https://babel-api.fastblocks.io", latency: 0, height: 0, custom: false },
|
|
2494
|
+
{ name: "https://babel-api.mainnet.iotex.one", latency: 0, height: 0 },
|
|
2495
|
+
{ name: "https://babel-api.mainnet.iotex.io", latency: 0, height: 0 },
|
|
2496
|
+
{ name: "https://iotex-network.rpc.thirdweb.com", latency: 0, height: 0 },
|
|
2497
|
+
{ name: "https://iotexrpc.com", latency: 0, height: 0 },
|
|
2498
|
+
{ name: "https://iotex.api.onfinality.io/public", latency: 0, height: 0 },
|
|
2499
|
+
{ name: "https://rpc.ankr.com/iotex", latency: 0, height: 0 }
|
|
2500
|
+
];
|
|
2501
|
+
var WalletRpcStore = class {
|
|
2502
|
+
constructor() {
|
|
2503
|
+
this.sid = "WalletPluginStore";
|
|
2504
|
+
this.autoObservable = true;
|
|
2505
|
+
this.curRpc = new StorageState({ default: "https://babel-api.mainnet.iotex.one", key: "curRPC-v2", value: "https://babel-api.mainnet.iotex.one" });
|
|
2506
|
+
this.isAutoSelectRpc = new StorageState({ key: "isAutoSelectRpc", default: true });
|
|
2507
|
+
this.customRpc = "";
|
|
2508
|
+
this.rpcList = new StorageState({ key: "customRpcList-v2", default: defaultRPCList, value: [] });
|
|
2509
|
+
this.showCustomRpc = false;
|
|
2510
|
+
}
|
|
2511
|
+
get currentRpc() {
|
|
2512
|
+
var _a, _b;
|
|
2513
|
+
console.log((_a = this.rpcList.value) == null ? void 0 : _a.find((i) => i.name == this.curRpc));
|
|
2514
|
+
return ((_b = this.rpcList.value) == null ? void 0 : _b.find((i) => i.name == this.curRpc.value)) || null;
|
|
2515
|
+
}
|
|
2516
|
+
addCustomRpc() {
|
|
2517
|
+
const item = { name: this.customRpc, latency: 0, height: 0, custom: true };
|
|
2518
|
+
if (defaultRPCList.find((i) => i.name === item.name)) {
|
|
2519
|
+
return RootStore.Get(ToastPlugin).error("Rpc already exists");
|
|
2520
|
+
}
|
|
2521
|
+
if (this.rpcList.value) {
|
|
2522
|
+
this.rpcList.save([...this.rpcList.value, item]);
|
|
2523
|
+
this.refresh();
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
this.rpcList.save([...defaultRPCList, item]);
|
|
2527
|
+
this.refresh();
|
|
2528
|
+
}
|
|
2529
|
+
async addToMetamask(url) {
|
|
2530
|
+
var _a;
|
|
2531
|
+
try {
|
|
2532
|
+
await ((_a = window.ethereum) == null ? void 0 : _a.request({
|
|
2533
|
+
method: "wallet_addEthereumChain",
|
|
2534
|
+
params: [{
|
|
2535
|
+
chainId: `0x${4689 .toString(16)}`,
|
|
2536
|
+
chainName: "IoTeX Mainnet",
|
|
2537
|
+
nativeCurrency: {
|
|
2538
|
+
name: "IoTeX",
|
|
2539
|
+
symbol: "IOTX",
|
|
2540
|
+
decimals: 18
|
|
2541
|
+
},
|
|
2542
|
+
rpcUrls: [url],
|
|
2543
|
+
blockExplorerUrls: ["https://iotexscan.io"]
|
|
2544
|
+
}]
|
|
2545
|
+
}));
|
|
2546
|
+
RootStore.Get(ToastPlugin).success("Network added");
|
|
2547
|
+
console.log("Network added");
|
|
2548
|
+
} catch (error) {
|
|
2549
|
+
console.error("Failed to add network", error);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
refresh() {
|
|
2553
|
+
this.showCustomRpc = false;
|
|
2554
|
+
this.customRpc = "";
|
|
2555
|
+
setTimeout(() => {
|
|
2556
|
+
this.testRpc();
|
|
2557
|
+
}, 500);
|
|
2558
|
+
}
|
|
2559
|
+
latencyColor(latency) {
|
|
2560
|
+
if (latency < 0) {
|
|
2561
|
+
return "text-red-500";
|
|
2562
|
+
}
|
|
2563
|
+
if (latency < 1) {
|
|
2564
|
+
return "text-green-500";
|
|
2565
|
+
}
|
|
2566
|
+
if (latency < 2) {
|
|
2567
|
+
return "text-yellow-500";
|
|
2568
|
+
}
|
|
2569
|
+
return "text-red-500";
|
|
2570
|
+
}
|
|
2571
|
+
async testRpcFunction(url) {
|
|
2572
|
+
const start = performance.now();
|
|
2573
|
+
try {
|
|
2574
|
+
const response = await fetch(url, {
|
|
2575
|
+
method: "POST",
|
|
2576
|
+
headers: {
|
|
2577
|
+
"Content-Type": "application/json"
|
|
2578
|
+
},
|
|
2579
|
+
body: JSON.stringify({
|
|
2580
|
+
jsonrpc: "2.0",
|
|
2581
|
+
method: "eth_getBlockByNumber",
|
|
2582
|
+
params: ["latest", false],
|
|
2583
|
+
id: 1
|
|
2584
|
+
})
|
|
2585
|
+
});
|
|
2586
|
+
if (!response.ok) {
|
|
2587
|
+
throw new Error(`Error from server: ${response.status}`);
|
|
2588
|
+
}
|
|
2589
|
+
const res = await response.json();
|
|
2590
|
+
console.log(res);
|
|
2591
|
+
const end = performance.now();
|
|
2592
|
+
return { url, lentency: Number(helper.number.numberFormat((end - start) / 1e3, "0.000", { fallback: "-1" })), height: parseInt(res.result.number, 16) };
|
|
2593
|
+
} catch (error) {
|
|
2594
|
+
console.error("RPC Latency Test Failed:", error);
|
|
2595
|
+
return { url, lentency: -1, height: -1 };
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
testRpc() {
|
|
2599
|
+
var _a;
|
|
2600
|
+
(_a = this.rpcList) == null ? void 0 : _a.value.forEach((i) => {
|
|
2601
|
+
this.testRpcFunction(i.name).then((res) => {
|
|
2602
|
+
i.latency = res.lentency;
|
|
2603
|
+
i.height = res.height;
|
|
2604
|
+
});
|
|
2605
|
+
});
|
|
2606
|
+
this.rpcList.save(this.rpcList.value);
|
|
2607
|
+
}
|
|
2608
|
+
removeRpc(name) {
|
|
2609
|
+
this.rpcList.save(this.rpcList.value.filter((i) => i.name !== name));
|
|
2610
|
+
}
|
|
2611
|
+
scoreIcon(score) {
|
|
2612
|
+
if (score < 0) {
|
|
2613
|
+
return /* @__PURE__ */ React.createElement(Icon, { icon: "codicon:error", width: "18", height: "18", style: { color: "#FF0000" } });
|
|
2614
|
+
}
|
|
2615
|
+
if (score < 1) {
|
|
2616
|
+
return /* @__PURE__ */ React.createElement(Icon, { icon: "icon-park-solid:check-one", width: "18", height: "18", style: { color: "#289726" } });
|
|
2617
|
+
}
|
|
2618
|
+
if (score < 2) {
|
|
2619
|
+
return /* @__PURE__ */ React.createElement(Icon, { icon: "bxs:error", width: "18", height: "18", style: { color: "#FFA500" } });
|
|
2620
|
+
}
|
|
2621
|
+
return /* @__PURE__ */ React.createElement(Icon, { icon: "codicon:error", width: "18", height: "18", style: { color: "#FF0000" } });
|
|
2622
|
+
}
|
|
2623
|
+
get wallet() {
|
|
2624
|
+
return RootStore.Get(WalletStore);
|
|
2625
|
+
}
|
|
2626
|
+
// debounceAutoSelectRpc = pDebounce(this.autoSelectRpc, 3000)
|
|
2627
|
+
async autoSelectRpc() {
|
|
2628
|
+
console.log("autoSelectRpc");
|
|
2629
|
+
for (let i = 0; i < this.rpcList.value.length; i++) {
|
|
2630
|
+
const item = this.rpcList.value[i];
|
|
2631
|
+
const res = await this.testRpcFunction(item.name);
|
|
2632
|
+
if (res.lentency != -1 || res.height > 0) {
|
|
2633
|
+
this.curRpc.save(item.name);
|
|
2634
|
+
break;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
};
|
|
2639
|
+
var WalletHistoryStore = class {
|
|
2640
|
+
constructor() {
|
|
2641
|
+
this.sid = "WalletHistoryStore";
|
|
2642
|
+
this.isRender = false;
|
|
2643
|
+
this.autoObservable = true;
|
|
2644
|
+
this.history = new StorageState({ value: [], key: "history" });
|
|
2645
|
+
}
|
|
2646
|
+
set(params) {
|
|
2647
|
+
Object.assign(this, params);
|
|
2648
|
+
}
|
|
2649
|
+
get historyList() {
|
|
2650
|
+
console.log(this.isRender, "this.isRender");
|
|
2651
|
+
if (this.isRender) {
|
|
2652
|
+
return this.history.value;
|
|
2653
|
+
}
|
|
2654
|
+
return [];
|
|
2655
|
+
}
|
|
2656
|
+
recordHistory(item) {
|
|
2657
|
+
let value = this.history.load();
|
|
2658
|
+
if (!value) {
|
|
2659
|
+
value = [item];
|
|
2660
|
+
} else {
|
|
2661
|
+
value = [...value, item];
|
|
2662
|
+
}
|
|
2663
|
+
this.history.setValue(value);
|
|
2664
|
+
}
|
|
2665
|
+
updateHistoryStatusByTx(tx, status) {
|
|
2666
|
+
let value = this.history.load();
|
|
2667
|
+
if (!value) {
|
|
2668
|
+
return;
|
|
2669
|
+
}
|
|
2670
|
+
value = value.map((i) => {
|
|
2671
|
+
if (i.tx == tx) {
|
|
2672
|
+
i.status = status;
|
|
2673
|
+
return i;
|
|
2674
|
+
}
|
|
2675
|
+
if (!tx) {
|
|
2676
|
+
i.status = status;
|
|
2677
|
+
}
|
|
2678
|
+
return i;
|
|
2679
|
+
});
|
|
2680
|
+
this.history.setValue(value);
|
|
2681
|
+
}
|
|
2682
|
+
clearHistory() {
|
|
2683
|
+
this.history.setValue(null);
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
|
|
2687
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/version.js
|
|
2688
|
+
var getSDKVersion = () => "9.1.0";
|
|
2689
|
+
|
|
2690
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/communication/utils.js
|
|
2691
|
+
var dec2hex = (dec) => dec.toString(16).padStart(2, "0");
|
|
2692
|
+
var generateId = (len) => {
|
|
2693
|
+
const arr = new Uint8Array((len) / 2);
|
|
2694
|
+
window.crypto.getRandomValues(arr);
|
|
2695
|
+
return Array.from(arr, dec2hex).join("");
|
|
2696
|
+
};
|
|
2697
|
+
var generateRequestId = () => {
|
|
2698
|
+
if (typeof window !== "undefined") {
|
|
2699
|
+
return generateId(10);
|
|
2700
|
+
}
|
|
2701
|
+
return (/* @__PURE__ */ new Date()).getTime().toString(36);
|
|
2702
|
+
};
|
|
2703
|
+
|
|
2704
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/communication/messageFormatter.js
|
|
2705
|
+
var MessageFormatter = class {
|
|
2706
|
+
};
|
|
2707
|
+
MessageFormatter.makeRequest = (method, params) => {
|
|
2708
|
+
const id = generateRequestId();
|
|
2709
|
+
return {
|
|
2710
|
+
id,
|
|
2711
|
+
method,
|
|
2712
|
+
params,
|
|
2713
|
+
env: {
|
|
2714
|
+
sdkVersion: getSDKVersion()
|
|
2715
|
+
}
|
|
2716
|
+
};
|
|
2717
|
+
};
|
|
2718
|
+
MessageFormatter.makeResponse = (id, data, version) => ({
|
|
2719
|
+
id,
|
|
2720
|
+
success: true,
|
|
2721
|
+
version,
|
|
2722
|
+
data
|
|
2723
|
+
});
|
|
2724
|
+
MessageFormatter.makeErrorResponse = (id, error, version) => ({
|
|
2725
|
+
id,
|
|
2726
|
+
success: false,
|
|
2727
|
+
error,
|
|
2728
|
+
version
|
|
2729
|
+
});
|
|
2730
|
+
|
|
2731
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/communication/methods.js
|
|
2732
|
+
var Methods;
|
|
2733
|
+
(function(Methods2) {
|
|
2734
|
+
Methods2["sendTransactions"] = "sendTransactions";
|
|
2735
|
+
Methods2["rpcCall"] = "rpcCall";
|
|
2736
|
+
Methods2["getChainInfo"] = "getChainInfo";
|
|
2737
|
+
Methods2["getSafeInfo"] = "getSafeInfo";
|
|
2738
|
+
Methods2["getTxBySafeTxHash"] = "getTxBySafeTxHash";
|
|
2739
|
+
Methods2["getSafeBalances"] = "getSafeBalances";
|
|
2740
|
+
Methods2["signMessage"] = "signMessage";
|
|
2741
|
+
Methods2["signTypedMessage"] = "signTypedMessage";
|
|
2742
|
+
Methods2["getEnvironmentInfo"] = "getEnvironmentInfo";
|
|
2743
|
+
Methods2["getOffChainSignature"] = "getOffChainSignature";
|
|
2744
|
+
Methods2["requestAddressBook"] = "requestAddressBook";
|
|
2745
|
+
Methods2["wallet_getPermissions"] = "wallet_getPermissions";
|
|
2746
|
+
Methods2["wallet_requestPermissions"] = "wallet_requestPermissions";
|
|
2747
|
+
})(Methods || (Methods = {}));
|
|
2748
|
+
var RestrictedMethods;
|
|
2749
|
+
(function(RestrictedMethods2) {
|
|
2750
|
+
RestrictedMethods2["requestAddressBook"] = "requestAddressBook";
|
|
2751
|
+
})(RestrictedMethods || (RestrictedMethods = {}));
|
|
2752
|
+
|
|
2753
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/communication/index.js
|
|
2754
|
+
var PostMessageCommunicator = class {
|
|
2755
|
+
constructor(allowedOrigins = null, debugMode = false) {
|
|
2756
|
+
this.allowedOrigins = null;
|
|
2757
|
+
this.callbacks = /* @__PURE__ */ new Map();
|
|
2758
|
+
this.debugMode = false;
|
|
2759
|
+
this.isServer = typeof window === "undefined";
|
|
2760
|
+
this.isValidMessage = ({ origin, data, source }) => {
|
|
2761
|
+
const emptyOrMalformed = !data;
|
|
2762
|
+
const sentFromParentEl = !this.isServer && source === window.parent;
|
|
2763
|
+
const majorVersionNumber = typeof data.version !== "undefined" && parseInt(data.version.split(".")[0]);
|
|
2764
|
+
const allowedSDKVersion = typeof majorVersionNumber === "number" && majorVersionNumber >= 1;
|
|
2765
|
+
let validOrigin = true;
|
|
2766
|
+
if (Array.isArray(this.allowedOrigins)) {
|
|
2767
|
+
validOrigin = this.allowedOrigins.find((regExp) => regExp.test(origin)) !== void 0;
|
|
2768
|
+
}
|
|
2769
|
+
return !emptyOrMalformed && sentFromParentEl && allowedSDKVersion && validOrigin;
|
|
2770
|
+
};
|
|
2771
|
+
this.logIncomingMessage = (msg) => {
|
|
2772
|
+
console.info(`Safe Apps SDK v1: A message was received from origin ${msg.origin}. `, msg.data);
|
|
2773
|
+
};
|
|
2774
|
+
this.onParentMessage = (msg) => {
|
|
2775
|
+
if (this.isValidMessage(msg)) {
|
|
2776
|
+
this.debugMode && this.logIncomingMessage(msg);
|
|
2777
|
+
this.handleIncomingMessage(msg.data);
|
|
2778
|
+
}
|
|
2779
|
+
};
|
|
2780
|
+
this.handleIncomingMessage = (payload) => {
|
|
2781
|
+
const { id } = payload;
|
|
2782
|
+
const cb = this.callbacks.get(id);
|
|
2783
|
+
if (cb) {
|
|
2784
|
+
cb(payload);
|
|
2785
|
+
this.callbacks.delete(id);
|
|
2786
|
+
}
|
|
2787
|
+
};
|
|
2788
|
+
this.send = (method, params) => {
|
|
2789
|
+
const request = MessageFormatter.makeRequest(method, params);
|
|
2790
|
+
if (this.isServer) {
|
|
2791
|
+
throw new Error("Window doesn't exist");
|
|
2792
|
+
}
|
|
2793
|
+
window.parent.postMessage(request, "*");
|
|
2794
|
+
return new Promise((resolve, reject) => {
|
|
2795
|
+
this.callbacks.set(request.id, (response) => {
|
|
2796
|
+
if (!response.success) {
|
|
2797
|
+
reject(new Error(response.error));
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
resolve(response);
|
|
2801
|
+
});
|
|
2802
|
+
});
|
|
2803
|
+
};
|
|
2804
|
+
this.allowedOrigins = allowedOrigins;
|
|
2805
|
+
this.debugMode = debugMode;
|
|
2806
|
+
if (!this.isServer) {
|
|
2807
|
+
window.addEventListener("message", this.onParentMessage);
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
};
|
|
2811
|
+
var communication_default = PostMessageCommunicator;
|
|
2812
|
+
|
|
2813
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/types/sdk.js
|
|
2814
|
+
var isObjectEIP712TypedData = (obj) => {
|
|
2815
|
+
return typeof obj === "object" && obj != null && "domain" in obj && "types" in obj && "message" in obj;
|
|
2816
|
+
};
|
|
2817
|
+
|
|
2818
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/types/gateway.js
|
|
2819
|
+
var import_safe_gateway_typescript_sdk = __toESM(require_dist(), 1);
|
|
2820
|
+
|
|
2821
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/txs/index.js
|
|
2822
|
+
var TXs = class {
|
|
2823
|
+
constructor(communicator) {
|
|
2824
|
+
this.communicator = communicator;
|
|
2825
|
+
}
|
|
2826
|
+
async getBySafeTxHash(safeTxHash) {
|
|
2827
|
+
if (!safeTxHash) {
|
|
2828
|
+
throw new Error("Invalid safeTxHash");
|
|
2829
|
+
}
|
|
2830
|
+
const response = await this.communicator.send(Methods.getTxBySafeTxHash, { safeTxHash });
|
|
2831
|
+
return response.data;
|
|
2832
|
+
}
|
|
2833
|
+
async signMessage(message) {
|
|
2834
|
+
const messagePayload = {
|
|
2835
|
+
message
|
|
2836
|
+
};
|
|
2837
|
+
const response = await this.communicator.send(Methods.signMessage, messagePayload);
|
|
2838
|
+
return response.data;
|
|
2839
|
+
}
|
|
2840
|
+
async signTypedMessage(typedData) {
|
|
2841
|
+
if (!isObjectEIP712TypedData(typedData)) {
|
|
2842
|
+
throw new Error("Invalid typed data");
|
|
2843
|
+
}
|
|
2844
|
+
const response = await this.communicator.send(Methods.signTypedMessage, { typedData });
|
|
2845
|
+
return response.data;
|
|
2846
|
+
}
|
|
2847
|
+
async send({ txs, params }) {
|
|
2848
|
+
if (!txs || !txs.length) {
|
|
2849
|
+
throw new Error("No transactions were passed");
|
|
2850
|
+
}
|
|
2851
|
+
const messagePayload = {
|
|
2852
|
+
txs,
|
|
2853
|
+
params
|
|
2854
|
+
};
|
|
2855
|
+
const response = await this.communicator.send(Methods.sendTransactions, messagePayload);
|
|
2856
|
+
return response.data;
|
|
2857
|
+
}
|
|
2858
|
+
};
|
|
2859
|
+
|
|
2860
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/eth/constants.js
|
|
2861
|
+
var RPC_CALLS = {
|
|
2862
|
+
eth_call: "eth_call",
|
|
2863
|
+
eth_gasPrice: "eth_gasPrice",
|
|
2864
|
+
eth_getLogs: "eth_getLogs",
|
|
2865
|
+
eth_getBalance: "eth_getBalance",
|
|
2866
|
+
eth_getCode: "eth_getCode",
|
|
2867
|
+
eth_getBlockByHash: "eth_getBlockByHash",
|
|
2868
|
+
eth_getBlockByNumber: "eth_getBlockByNumber",
|
|
2869
|
+
eth_getStorageAt: "eth_getStorageAt",
|
|
2870
|
+
eth_getTransactionByHash: "eth_getTransactionByHash",
|
|
2871
|
+
eth_getTransactionReceipt: "eth_getTransactionReceipt",
|
|
2872
|
+
eth_getTransactionCount: "eth_getTransactionCount",
|
|
2873
|
+
eth_estimateGas: "eth_estimateGas",
|
|
2874
|
+
safe_setSettings: "safe_setSettings"
|
|
2875
|
+
};
|
|
2876
|
+
|
|
2877
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/eth/index.js
|
|
2878
|
+
var inputFormatters = {
|
|
2879
|
+
defaultBlockParam: (arg = "latest") => arg,
|
|
2880
|
+
returnFullTxObjectParam: (arg = false) => arg,
|
|
2881
|
+
blockNumberToHex: (arg) => Number.isInteger(arg) ? `0x${arg.toString(16)}` : arg
|
|
2882
|
+
};
|
|
2883
|
+
var Eth = class {
|
|
2884
|
+
constructor(communicator) {
|
|
2885
|
+
this.communicator = communicator;
|
|
2886
|
+
this.call = this.buildRequest({
|
|
2887
|
+
call: RPC_CALLS.eth_call,
|
|
2888
|
+
formatters: [null, inputFormatters.defaultBlockParam]
|
|
2889
|
+
});
|
|
2890
|
+
this.getBalance = this.buildRequest({
|
|
2891
|
+
call: RPC_CALLS.eth_getBalance,
|
|
2892
|
+
formatters: [null, inputFormatters.defaultBlockParam]
|
|
2893
|
+
});
|
|
2894
|
+
this.getCode = this.buildRequest({
|
|
2895
|
+
call: RPC_CALLS.eth_getCode,
|
|
2896
|
+
formatters: [null, inputFormatters.defaultBlockParam]
|
|
2897
|
+
});
|
|
2898
|
+
this.getStorageAt = this.buildRequest({
|
|
2899
|
+
call: RPC_CALLS.eth_getStorageAt,
|
|
2900
|
+
formatters: [null, inputFormatters.blockNumberToHex, inputFormatters.defaultBlockParam]
|
|
2901
|
+
});
|
|
2902
|
+
this.getPastLogs = this.buildRequest({
|
|
2903
|
+
call: RPC_CALLS.eth_getLogs
|
|
2904
|
+
});
|
|
2905
|
+
this.getBlockByHash = this.buildRequest({
|
|
2906
|
+
call: RPC_CALLS.eth_getBlockByHash,
|
|
2907
|
+
formatters: [null, inputFormatters.returnFullTxObjectParam]
|
|
2908
|
+
});
|
|
2909
|
+
this.getBlockByNumber = this.buildRequest({
|
|
2910
|
+
call: RPC_CALLS.eth_getBlockByNumber,
|
|
2911
|
+
formatters: [inputFormatters.blockNumberToHex, inputFormatters.returnFullTxObjectParam]
|
|
2912
|
+
});
|
|
2913
|
+
this.getTransactionByHash = this.buildRequest({
|
|
2914
|
+
call: RPC_CALLS.eth_getTransactionByHash
|
|
2915
|
+
});
|
|
2916
|
+
this.getTransactionReceipt = this.buildRequest({
|
|
2917
|
+
call: RPC_CALLS.eth_getTransactionReceipt
|
|
2918
|
+
});
|
|
2919
|
+
this.getTransactionCount = this.buildRequest({
|
|
2920
|
+
call: RPC_CALLS.eth_getTransactionCount,
|
|
2921
|
+
formatters: [null, inputFormatters.defaultBlockParam]
|
|
2922
|
+
});
|
|
2923
|
+
this.getGasPrice = this.buildRequest({
|
|
2924
|
+
call: RPC_CALLS.eth_gasPrice
|
|
2925
|
+
});
|
|
2926
|
+
this.getEstimateGas = (transaction) => this.buildRequest({
|
|
2927
|
+
call: RPC_CALLS.eth_estimateGas
|
|
2928
|
+
})([transaction]);
|
|
2929
|
+
this.setSafeSettings = this.buildRequest({
|
|
2930
|
+
call: RPC_CALLS.safe_setSettings
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2933
|
+
buildRequest(args) {
|
|
2934
|
+
const { call, formatters } = args;
|
|
2935
|
+
return async (params) => {
|
|
2936
|
+
if (formatters && Array.isArray(params)) {
|
|
2937
|
+
formatters.forEach((formatter, i) => {
|
|
2938
|
+
if (formatter) {
|
|
2939
|
+
params[i] = formatter(params[i]);
|
|
2940
|
+
}
|
|
2941
|
+
});
|
|
2942
|
+
}
|
|
2943
|
+
const payload = {
|
|
2944
|
+
call,
|
|
2945
|
+
params: params || []
|
|
2946
|
+
};
|
|
2947
|
+
const response = await this.communicator.send(Methods.rpcCall, payload);
|
|
2948
|
+
return response.data;
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
|
|
2953
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/safe/signatures.js
|
|
2954
|
+
var MAGIC_VALUE = "0x1626ba7e";
|
|
2955
|
+
var MAGIC_VALUE_BYTES = "0x20c13b0b";
|
|
2956
|
+
|
|
2957
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/types/permissions.js
|
|
2958
|
+
var PERMISSIONS_REQUEST_REJECTED = 4001;
|
|
2959
|
+
var PermissionsError = class _PermissionsError extends Error {
|
|
2960
|
+
constructor(message, code, data) {
|
|
2961
|
+
super(message);
|
|
2962
|
+
this.code = code;
|
|
2963
|
+
this.data = data;
|
|
2964
|
+
Object.setPrototypeOf(this, _PermissionsError.prototype);
|
|
2965
|
+
}
|
|
2966
|
+
};
|
|
2967
|
+
|
|
2968
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/wallet/index.js
|
|
2969
|
+
var Wallet = class {
|
|
2970
|
+
constructor(communicator) {
|
|
2971
|
+
this.communicator = communicator;
|
|
2972
|
+
}
|
|
2973
|
+
async getPermissions() {
|
|
2974
|
+
const response = await this.communicator.send(Methods.wallet_getPermissions, void 0);
|
|
2975
|
+
return response.data;
|
|
2976
|
+
}
|
|
2977
|
+
async requestPermissions(permissions) {
|
|
2978
|
+
if (!this.isPermissionRequestValid(permissions)) {
|
|
2979
|
+
throw new PermissionsError("Permissions request is invalid", PERMISSIONS_REQUEST_REJECTED);
|
|
2980
|
+
}
|
|
2981
|
+
try {
|
|
2982
|
+
const response = await this.communicator.send(Methods.wallet_requestPermissions, permissions);
|
|
2983
|
+
return response.data;
|
|
2984
|
+
} catch (e) {
|
|
2985
|
+
throw new PermissionsError("Permissions rejected", PERMISSIONS_REQUEST_REJECTED);
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
isPermissionRequestValid(permissions) {
|
|
2989
|
+
return permissions.every((pr) => {
|
|
2990
|
+
if (typeof pr === "object") {
|
|
2991
|
+
return Object.keys(pr).every((method) => {
|
|
2992
|
+
if (Object.values(RestrictedMethods).includes(method)) {
|
|
2993
|
+
return true;
|
|
2994
|
+
}
|
|
2995
|
+
return false;
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
return false;
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
};
|
|
3002
|
+
|
|
3003
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/decorators/requirePermissions.js
|
|
3004
|
+
var hasPermission = (required, permissions) => permissions.some((permission) => permission.parentCapability === required);
|
|
3005
|
+
var requirePermission = () => (_, propertyKey, descriptor) => {
|
|
3006
|
+
const originalMethod = descriptor.value;
|
|
3007
|
+
descriptor.value = async function() {
|
|
3008
|
+
const wallet = new Wallet(this.communicator);
|
|
3009
|
+
let currentPermissions = await wallet.getPermissions();
|
|
3010
|
+
if (!hasPermission(propertyKey, currentPermissions)) {
|
|
3011
|
+
currentPermissions = await wallet.requestPermissions([{ [propertyKey]: {} }]);
|
|
3012
|
+
}
|
|
3013
|
+
if (!hasPermission(propertyKey, currentPermissions)) {
|
|
3014
|
+
throw new PermissionsError("Permissions rejected", PERMISSIONS_REQUEST_REJECTED);
|
|
3015
|
+
}
|
|
3016
|
+
return originalMethod.apply(this);
|
|
3017
|
+
};
|
|
3018
|
+
return descriptor;
|
|
3019
|
+
};
|
|
3020
|
+
var requirePermissions_default = requirePermission;
|
|
3021
|
+
|
|
3022
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/safe/index.js
|
|
3023
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
3024
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3025
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3026
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3027
|
+
else
|
|
3028
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3029
|
+
if (d = decorators[i])
|
|
3030
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3031
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3032
|
+
};
|
|
3033
|
+
var Safe = class {
|
|
3034
|
+
constructor(communicator) {
|
|
3035
|
+
this.communicator = communicator;
|
|
3036
|
+
}
|
|
3037
|
+
async getChainInfo() {
|
|
3038
|
+
const response = await this.communicator.send(Methods.getChainInfo, void 0);
|
|
3039
|
+
return response.data;
|
|
3040
|
+
}
|
|
3041
|
+
async getInfo() {
|
|
3042
|
+
const response = await this.communicator.send(Methods.getSafeInfo, void 0);
|
|
3043
|
+
return response.data;
|
|
3044
|
+
}
|
|
3045
|
+
// There is a possibility that this method will change because we may add pagination to the endpoint
|
|
3046
|
+
async experimental_getBalances({ currency = "usd" } = {}) {
|
|
3047
|
+
const response = await this.communicator.send(Methods.getSafeBalances, {
|
|
3048
|
+
currency
|
|
3049
|
+
});
|
|
3050
|
+
return response.data;
|
|
3051
|
+
}
|
|
3052
|
+
async check1271Signature(messageHash, signature = "0x") {
|
|
3053
|
+
const safeInfo = await this.getInfo();
|
|
3054
|
+
const encodedIsValidSignatureCall = encodeFunctionData({
|
|
3055
|
+
abi: [
|
|
3056
|
+
{
|
|
3057
|
+
constant: false,
|
|
3058
|
+
inputs: [
|
|
3059
|
+
{
|
|
3060
|
+
name: "_dataHash",
|
|
3061
|
+
type: "bytes32"
|
|
3062
|
+
},
|
|
3063
|
+
{
|
|
3064
|
+
name: "_signature",
|
|
3065
|
+
type: "bytes"
|
|
3066
|
+
}
|
|
3067
|
+
],
|
|
3068
|
+
name: "isValidSignature",
|
|
3069
|
+
outputs: [
|
|
3070
|
+
{
|
|
3071
|
+
name: "",
|
|
3072
|
+
type: "bytes4"
|
|
3073
|
+
}
|
|
3074
|
+
],
|
|
3075
|
+
payable: false,
|
|
3076
|
+
stateMutability: "nonpayable",
|
|
3077
|
+
type: "function"
|
|
3078
|
+
}
|
|
3079
|
+
],
|
|
3080
|
+
functionName: "isValidSignature",
|
|
3081
|
+
args: [messageHash, signature]
|
|
3082
|
+
});
|
|
3083
|
+
const payload = {
|
|
3084
|
+
call: RPC_CALLS.eth_call,
|
|
3085
|
+
params: [
|
|
3086
|
+
{
|
|
3087
|
+
to: safeInfo.safeAddress,
|
|
3088
|
+
data: encodedIsValidSignatureCall
|
|
3089
|
+
},
|
|
3090
|
+
"latest"
|
|
3091
|
+
]
|
|
3092
|
+
};
|
|
3093
|
+
try {
|
|
3094
|
+
const response = await this.communicator.send(Methods.rpcCall, payload);
|
|
3095
|
+
return response.data.slice(0, 10).toLowerCase() === MAGIC_VALUE;
|
|
3096
|
+
} catch (err) {
|
|
3097
|
+
return false;
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
async check1271SignatureBytes(messageHash, signature = "0x") {
|
|
3101
|
+
const safeInfo = await this.getInfo();
|
|
3102
|
+
const encodedIsValidSignatureCall = encodeFunctionData({
|
|
3103
|
+
abi: [
|
|
3104
|
+
{
|
|
3105
|
+
constant: false,
|
|
3106
|
+
inputs: [
|
|
3107
|
+
{
|
|
3108
|
+
name: "_data",
|
|
3109
|
+
type: "bytes"
|
|
3110
|
+
},
|
|
3111
|
+
{
|
|
3112
|
+
name: "_signature",
|
|
3113
|
+
type: "bytes"
|
|
3114
|
+
}
|
|
3115
|
+
],
|
|
3116
|
+
name: "isValidSignature",
|
|
3117
|
+
outputs: [
|
|
3118
|
+
{
|
|
3119
|
+
name: "",
|
|
3120
|
+
type: "bytes4"
|
|
3121
|
+
}
|
|
3122
|
+
],
|
|
3123
|
+
payable: false,
|
|
3124
|
+
stateMutability: "nonpayable",
|
|
3125
|
+
type: "function"
|
|
3126
|
+
}
|
|
3127
|
+
],
|
|
3128
|
+
functionName: "isValidSignature",
|
|
3129
|
+
args: [messageHash, signature]
|
|
3130
|
+
});
|
|
3131
|
+
const payload = {
|
|
3132
|
+
call: RPC_CALLS.eth_call,
|
|
3133
|
+
params: [
|
|
3134
|
+
{
|
|
3135
|
+
to: safeInfo.safeAddress,
|
|
3136
|
+
data: encodedIsValidSignatureCall
|
|
3137
|
+
},
|
|
3138
|
+
"latest"
|
|
3139
|
+
]
|
|
3140
|
+
};
|
|
3141
|
+
try {
|
|
3142
|
+
const response = await this.communicator.send(Methods.rpcCall, payload);
|
|
3143
|
+
return response.data.slice(0, 10).toLowerCase() === MAGIC_VALUE_BYTES;
|
|
3144
|
+
} catch (err) {
|
|
3145
|
+
return false;
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
calculateMessageHash(message) {
|
|
3149
|
+
return hashMessage(message);
|
|
3150
|
+
}
|
|
3151
|
+
calculateTypedMessageHash(typedMessage) {
|
|
3152
|
+
const chainId = typeof typedMessage.domain.chainId === "object" ? typedMessage.domain.chainId.toNumber() : Number(typedMessage.domain.chainId);
|
|
3153
|
+
let primaryType = typedMessage.primaryType;
|
|
3154
|
+
if (!primaryType) {
|
|
3155
|
+
const fields = Object.values(typedMessage.types);
|
|
3156
|
+
const primaryTypes = Object.keys(typedMessage.types).filter((typeName) => fields.every((dataTypes) => dataTypes.every(({ type }) => type.replace("[", "").replace("]", "") !== typeName)));
|
|
3157
|
+
if (primaryTypes.length === 0 || primaryTypes.length > 1)
|
|
3158
|
+
throw new Error("Please specify primaryType");
|
|
3159
|
+
primaryType = primaryTypes[0];
|
|
3160
|
+
}
|
|
3161
|
+
return hashTypedData({
|
|
3162
|
+
message: typedMessage.message,
|
|
3163
|
+
domain: __spreadProps(__spreadValues({}, typedMessage.domain), {
|
|
3164
|
+
chainId,
|
|
3165
|
+
verifyingContract: typedMessage.domain.verifyingContract,
|
|
3166
|
+
salt: typedMessage.domain.salt
|
|
3167
|
+
}),
|
|
3168
|
+
types: typedMessage.types,
|
|
3169
|
+
primaryType
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
async getOffChainSignature(messageHash) {
|
|
3173
|
+
const response = await this.communicator.send(Methods.getOffChainSignature, messageHash);
|
|
3174
|
+
return response.data;
|
|
3175
|
+
}
|
|
3176
|
+
async isMessageSigned(message, signature = "0x") {
|
|
3177
|
+
let check;
|
|
3178
|
+
if (typeof message === "string") {
|
|
3179
|
+
check = async () => {
|
|
3180
|
+
const messageHash = this.calculateMessageHash(message);
|
|
3181
|
+
const messageHashSigned = await this.isMessageHashSigned(messageHash, signature);
|
|
3182
|
+
return messageHashSigned;
|
|
3183
|
+
};
|
|
3184
|
+
}
|
|
3185
|
+
if (isObjectEIP712TypedData(message)) {
|
|
3186
|
+
check = async () => {
|
|
3187
|
+
const messageHash = this.calculateTypedMessageHash(message);
|
|
3188
|
+
const messageHashSigned = await this.isMessageHashSigned(messageHash, signature);
|
|
3189
|
+
return messageHashSigned;
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
if (check) {
|
|
3193
|
+
const isValid = await check();
|
|
3194
|
+
return isValid;
|
|
3195
|
+
}
|
|
3196
|
+
throw new Error("Invalid message type");
|
|
3197
|
+
}
|
|
3198
|
+
async isMessageHashSigned(messageHash, signature = "0x") {
|
|
3199
|
+
const checks = [this.check1271Signature.bind(this), this.check1271SignatureBytes.bind(this)];
|
|
3200
|
+
for (const check of checks) {
|
|
3201
|
+
const isValid = await check(messageHash, signature);
|
|
3202
|
+
if (isValid) {
|
|
3203
|
+
return true;
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
return false;
|
|
3207
|
+
}
|
|
3208
|
+
async getEnvironmentInfo() {
|
|
3209
|
+
const response = await this.communicator.send(Methods.getEnvironmentInfo, void 0);
|
|
3210
|
+
return response.data;
|
|
3211
|
+
}
|
|
3212
|
+
async requestAddressBook() {
|
|
3213
|
+
const response = await this.communicator.send(Methods.requestAddressBook, void 0);
|
|
3214
|
+
return response.data;
|
|
3215
|
+
}
|
|
3216
|
+
};
|
|
3217
|
+
__decorate([
|
|
3218
|
+
requirePermissions_default()
|
|
3219
|
+
], Safe.prototype, "requestAddressBook", null);
|
|
3220
|
+
|
|
3221
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/sdk.js
|
|
3222
|
+
var SafeAppsSDK = class {
|
|
3223
|
+
constructor(opts = {}) {
|
|
3224
|
+
const { allowedDomains = null, debug = false } = opts;
|
|
3225
|
+
this.communicator = new communication_default(allowedDomains, debug);
|
|
3226
|
+
this.eth = new Eth(this.communicator);
|
|
3227
|
+
this.txs = new TXs(this.communicator);
|
|
3228
|
+
this.safe = new Safe(this.communicator);
|
|
3229
|
+
this.wallet = new Wallet(this.communicator);
|
|
3230
|
+
}
|
|
3231
|
+
};
|
|
3232
|
+
var sdk_default = SafeAppsSDK;
|
|
3233
|
+
|
|
3234
|
+
// ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js
|
|
3235
|
+
var esm_default = sdk_default;
|
|
3236
|
+
var SuccessTxDialog = observer((props) => {
|
|
3237
|
+
return /* @__PURE__ */ React2.createElement("div", { className: "flex-col gap-4 py-10" }, /* @__PURE__ */ React2.createElement("div", { className: "w-full flex items-center justify-center" }, /* @__PURE__ */ React2.createElement(Icon, { icon: "icon-park-solid:check-one", width: "48", height: "48", className: "text-green-500" })), /* @__PURE__ */ React2.createElement("div", { className: "text-2xl font-[900] text-center mt-4" }, props.msg), /* @__PURE__ */ React2.createElement(
|
|
3238
|
+
"div",
|
|
3239
|
+
{
|
|
3240
|
+
className: "flex items-center justify-center text-green-500 text-sm mt-6 gap-2 cursor-pointer hover:text-green-600 transition",
|
|
3241
|
+
onClick: (e) => window.open(`https://iotexscan.io/tx/${props.hash}`, "_blank")
|
|
3242
|
+
},
|
|
3243
|
+
"View on IoTeXScan ",
|
|
3244
|
+
/* @__PURE__ */ React2.createElement(Icon, { icon: "material-symbols:chip-extraction-rounded", width: "18", height: "18" })
|
|
3245
|
+
));
|
|
3246
|
+
});
|
|
3247
|
+
var ShowSuccessTxDialog = ({ msg, hash }) => {
|
|
3248
|
+
RootStore.Get(DialogStore).setData({
|
|
3249
|
+
title: "",
|
|
3250
|
+
content: /* @__PURE__ */ React2.createElement(SuccessTxDialog, { msg, hash }),
|
|
3251
|
+
isOpen: true
|
|
3252
|
+
});
|
|
3253
|
+
};
|
|
3254
|
+
var WalletConfigStore = class {
|
|
3255
|
+
constructor() {
|
|
3256
|
+
this.sid = "WalletConfigStore";
|
|
3257
|
+
this.autoObservable = true;
|
|
3258
|
+
this.appName = "Dappkit";
|
|
3259
|
+
this.projectId = "b69e844f38265667350efd78e3e1a5fb";
|
|
3260
|
+
// @ts-ignore
|
|
3261
|
+
this.supportedChains = [iotex];
|
|
3262
|
+
this.defaultChainId = 4689;
|
|
3263
|
+
}
|
|
3264
|
+
set(params) {
|
|
3265
|
+
Object.assign(this, params);
|
|
3266
|
+
}
|
|
3267
|
+
get rainbowKitConfig() {
|
|
3268
|
+
var _a, _b;
|
|
3269
|
+
console.log(`rainbowKitConfig-${(_a = this.supportedChains) == null ? void 0 : _a.map((i) => i.id).join("-")}`);
|
|
3270
|
+
return ObjectPool.get(`rainbowKitConfig-${(_b = this.supportedChains) == null ? void 0 : _b.map((i) => i.id).join("-")}`, () => {
|
|
3271
|
+
return getDefaultConfig({
|
|
3272
|
+
appName: this.appName,
|
|
3273
|
+
projectId: this.projectId,
|
|
3274
|
+
//@ts-ignore
|
|
3275
|
+
chains: this.supportedChains,
|
|
3276
|
+
wallets: [
|
|
3277
|
+
{
|
|
3278
|
+
groupName: "Recommended",
|
|
3279
|
+
wallets: [iopayWallet, metaMaskWallet]
|
|
3280
|
+
},
|
|
3281
|
+
{
|
|
3282
|
+
groupName: "Others",
|
|
3283
|
+
wallets: [metaMaskWallet, walletConnectWallet, iopayWallet, okxWallet, binanceWallet]
|
|
3284
|
+
}
|
|
3285
|
+
]
|
|
3286
|
+
});
|
|
3287
|
+
});
|
|
3288
|
+
}
|
|
3289
|
+
};
|
|
3290
|
+
|
|
3291
|
+
// module/Wallet/index.tsx
|
|
3292
|
+
var WalletStore = class _WalletStore {
|
|
3293
|
+
constructor(args) {
|
|
3294
|
+
this.sid = "wallet";
|
|
3295
|
+
this.autoObservable = true;
|
|
3296
|
+
this.account = "0x...";
|
|
3297
|
+
this.isSuccessDialogOpen = false;
|
|
3298
|
+
this.isInSafeApp = false;
|
|
3299
|
+
this.isConnect = false;
|
|
3300
|
+
this.event = new EventEmitter();
|
|
3301
|
+
this.updateTicker = 0;
|
|
3302
|
+
this.balance = PromiseHook.wrap({
|
|
3303
|
+
func: async () => {
|
|
3304
|
+
var _a;
|
|
3305
|
+
if (!this.publicClient || !this.account)
|
|
3306
|
+
return new BigNumberState({ value: new BigNumber(0) });
|
|
3307
|
+
const balance = await this.publicClient.getBalance({
|
|
3308
|
+
address: this.account
|
|
3309
|
+
});
|
|
3310
|
+
if (balance) {
|
|
3311
|
+
return new BigNumberState({ value: new BigNumber((_a = balance == null ? void 0 : balance.toString()) != null ? _a : "0") });
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
});
|
|
3315
|
+
Object.assign(this, args);
|
|
3316
|
+
}
|
|
3317
|
+
get supportedChains() {
|
|
3318
|
+
return RootStore.Get(WalletConfigStore).supportedChains;
|
|
3319
|
+
}
|
|
3320
|
+
get reconnectOnMount() {
|
|
3321
|
+
if (!this.isConnect && this.updateTicker == 0) {
|
|
3322
|
+
return true;
|
|
3323
|
+
}
|
|
3324
|
+
if (!this.isConnect && this.updateTicker != 0) {
|
|
3325
|
+
return false;
|
|
3326
|
+
}
|
|
3327
|
+
if (this.isConnect) {
|
|
3328
|
+
return true;
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
use() {
|
|
3332
|
+
console.log("use wallet");
|
|
3333
|
+
const { data: walletClient, isSuccess } = useWalletClient();
|
|
3334
|
+
const { chain, address, isConnected } = useAccount();
|
|
3335
|
+
const { switchChain } = useSwitchChain();
|
|
3336
|
+
const { openConnectModal } = useConnectModal();
|
|
3337
|
+
const { connect } = useConnect();
|
|
3338
|
+
this.set({
|
|
3339
|
+
//@ts-ignore
|
|
3340
|
+
connect,
|
|
3341
|
+
// @ts-ignore
|
|
3342
|
+
walletClient,
|
|
3343
|
+
openConnectModal,
|
|
3344
|
+
switchChain
|
|
3345
|
+
});
|
|
3346
|
+
useEffect(() => {
|
|
3347
|
+
RootStore.Get(WalletHistoryStore).set({ isRender: true });
|
|
3348
|
+
this.set({
|
|
3349
|
+
isConnect: isConnected,
|
|
3350
|
+
account: address,
|
|
3351
|
+
chain
|
|
3352
|
+
});
|
|
3353
|
+
if (this.account) {
|
|
3354
|
+
this.updateTicker++;
|
|
3355
|
+
this.event.emit("walletAccount:ready");
|
|
3356
|
+
}
|
|
3357
|
+
}, [address, isConnected, chain]);
|
|
3358
|
+
}
|
|
3359
|
+
//always return or return default chain
|
|
3360
|
+
get publicClient() {
|
|
3361
|
+
if (this.chain && this.supportedChains.some((i) => i.id === this.chain.id)) {
|
|
3362
|
+
if (this.chain.id == 4689) {
|
|
3363
|
+
return AIem.PubClient("4689", { rpcUrls: { default: { http: [RootStore.Get(WalletRpcStore).curRpc.value] } }, multicall: true });
|
|
3364
|
+
}
|
|
3365
|
+
return AIem.PubClient(this.chain.id.toString());
|
|
3366
|
+
} else {
|
|
3367
|
+
return AIem.PubClient("4689");
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
set(args) {
|
|
3371
|
+
Object.assign(this, args);
|
|
3372
|
+
}
|
|
3373
|
+
toJSON() {
|
|
3374
|
+
const { account } = this;
|
|
3375
|
+
return { account };
|
|
3376
|
+
}
|
|
3377
|
+
async prepare(chainId) {
|
|
3378
|
+
const promise = new Promise(async (res, rej) => {
|
|
3379
|
+
var _a, _b;
|
|
3380
|
+
if (!window)
|
|
3381
|
+
return;
|
|
3382
|
+
if (this.account) {
|
|
3383
|
+
if (Number((_a = this.chain) == null ? void 0 : _a.id) == Number(chainId)) {
|
|
3384
|
+
res();
|
|
3385
|
+
return;
|
|
3386
|
+
}
|
|
3387
|
+
(_b = this.switchChain) == null ? void 0 : _b.call(this, { chainId: chainId != null ? chainId : 4689 });
|
|
3388
|
+
const interval = setInterval(() => {
|
|
3389
|
+
var _a2;
|
|
3390
|
+
if (this.switchChain) {
|
|
3391
|
+
if (((_a2 = this.chain) == null ? void 0 : _a2.id) == chainId) {
|
|
3392
|
+
clearInterval(interval);
|
|
3393
|
+
res();
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
}, 1e3);
|
|
3397
|
+
} else {
|
|
3398
|
+
try {
|
|
3399
|
+
this.openConnectModal();
|
|
3400
|
+
const interval = setInterval(() => {
|
|
3401
|
+
if (this.account) {
|
|
3402
|
+
clearInterval(interval);
|
|
3403
|
+
res();
|
|
3404
|
+
}
|
|
3405
|
+
}, 1e3);
|
|
3406
|
+
} catch (error) {
|
|
3407
|
+
rej(error);
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
});
|
|
3411
|
+
await promise;
|
|
3412
|
+
return this;
|
|
3413
|
+
}
|
|
3414
|
+
async waitForTransactionReceipt({ hash }) {
|
|
3415
|
+
if (this.isInSafeApp) {
|
|
3416
|
+
console.log("isInSafeApp", this.isInSafeApp);
|
|
3417
|
+
const sdk = new esm_default();
|
|
3418
|
+
while (true) {
|
|
3419
|
+
const queued = await sdk.txs.getBySafeTxHash(hash);
|
|
3420
|
+
if (queued.txStatus === import_safe_gateway_typescript_sdk.TransactionStatus.AWAITING_CONFIRMATIONS || queued.txStatus === import_safe_gateway_typescript_sdk.TransactionStatus.AWAITING_EXECUTION || queued.txStatus === import_safe_gateway_typescript_sdk.TransactionStatus.CANCELLED) {
|
|
3421
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
3422
|
+
} else {
|
|
3423
|
+
return this.publicClient.waitForTransactionReceipt({ hash: queued.txHash });
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
} else {
|
|
3427
|
+
return this.publicClient.waitForTransactionReceipt({ hash });
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
static async SendTx(...args) {
|
|
3431
|
+
return RootStore.Get(_WalletStore).sendTx(...args);
|
|
3432
|
+
}
|
|
3433
|
+
static async SendRawTx(...args) {
|
|
3434
|
+
return RootStore.Get(_WalletStore).sendRawTx(...args);
|
|
3435
|
+
}
|
|
3436
|
+
async sendTx({
|
|
3437
|
+
chainId,
|
|
3438
|
+
tx,
|
|
3439
|
+
autoAlert = true,
|
|
3440
|
+
loadingText,
|
|
3441
|
+
successText,
|
|
3442
|
+
onError,
|
|
3443
|
+
historyItem,
|
|
3444
|
+
showSuccessDialog = false
|
|
3445
|
+
}) {
|
|
3446
|
+
var _a, _b, _c;
|
|
3447
|
+
const toast = RootStore.Get(ToastPlugin);
|
|
3448
|
+
let hash;
|
|
3449
|
+
const historyStore = RootStore.Get(WalletHistoryStore);
|
|
3450
|
+
try {
|
|
3451
|
+
if (loadingText)
|
|
3452
|
+
toast.loading(loadingText);
|
|
3453
|
+
if (!chainId)
|
|
3454
|
+
throw new Error("chainId, address, data is required");
|
|
3455
|
+
await RootStore.Get(_WalletStore).prepare(Number(chainId));
|
|
3456
|
+
hash = await tx();
|
|
3457
|
+
if (historyItem) {
|
|
3458
|
+
historyStore.recordHistory(__spreadProps(__spreadValues({}, historyItem), { tx: hash, timestamp: Date.now(), status: "loading", chainId: Number(chainId) }));
|
|
3459
|
+
}
|
|
3460
|
+
const receipt = await this.waitForTransactionReceipt({ hash });
|
|
3461
|
+
if (receipt.status == "success") {
|
|
3462
|
+
toast.dismiss();
|
|
3463
|
+
toast.success("The transaction was successful");
|
|
3464
|
+
if (historyItem) {
|
|
3465
|
+
if (showSuccessDialog) {
|
|
3466
|
+
ShowSuccessTxDialog({ msg: historyItem.msg, hash });
|
|
3467
|
+
}
|
|
3468
|
+
historyStore.updateHistoryStatusByTx(hash, "success");
|
|
3469
|
+
}
|
|
3470
|
+
} else {
|
|
3471
|
+
toast.dismiss();
|
|
3472
|
+
toast.error("The transaction failed");
|
|
3473
|
+
historyStore.updateHistoryStatusByTx(hash, "fail");
|
|
3474
|
+
}
|
|
3475
|
+
if (successText)
|
|
3476
|
+
toast.success(successText);
|
|
3477
|
+
this.updateTicker++;
|
|
3478
|
+
return receipt;
|
|
3479
|
+
} catch (error) {
|
|
3480
|
+
console.log(error);
|
|
3481
|
+
toast.dismiss();
|
|
3482
|
+
if (autoAlert) {
|
|
3483
|
+
const msg = /reason="[A-Za-z0-9_ :"]*/g.exec(error == null ? void 0 : error.message);
|
|
3484
|
+
console.log("sendTx", error == null ? void 0 : error.message);
|
|
3485
|
+
if (((_a = error == null ? void 0 : error.message) == null ? void 0 : _a.includes("user rejected transaction")) || String(error).toLowerCase().includes("user rejected") || String(error).toLowerCase().includes("user denied")) {
|
|
3486
|
+
toast.error("user rejected transaction");
|
|
3487
|
+
onError == null ? void 0 : onError(error);
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
if (((_b = error == null ? void 0 : error.message) == null ? void 0 : _b.includes("The Transaction may not be processed on a block yet")) || ((_c = error == null ? void 0 : error.message) == null ? void 0 : _c.includes("could not be found"))) {
|
|
3491
|
+
if (historyItem) {
|
|
3492
|
+
historyStore.updateHistoryStatusByTx(hash, "success");
|
|
3493
|
+
}
|
|
3494
|
+
toast.success("The transaction was successful");
|
|
3495
|
+
return;
|
|
3496
|
+
}
|
|
3497
|
+
if (msg) {
|
|
3498
|
+
toast.error(msg);
|
|
3499
|
+
onError == null ? void 0 : onError(msg);
|
|
3500
|
+
} else {
|
|
3501
|
+
if (error == null ? void 0 : error.message.includes("viem")) {
|
|
3502
|
+
const messageArr = error == null ? void 0 : error.message.split("\n");
|
|
3503
|
+
console.log("messageArr---", messageArr);
|
|
3504
|
+
if (messageArr.length > 0) {
|
|
3505
|
+
toast.error(messageArr[0]);
|
|
3506
|
+
onError == null ? void 0 : onError(messageArr[0]);
|
|
3507
|
+
}
|
|
3508
|
+
} else {
|
|
3509
|
+
toast.error(String((error == null ? void 0 : error.message) || error));
|
|
3510
|
+
onError == null ? void 0 : onError(String((error == null ? void 0 : error.message) || error));
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
} else {
|
|
3514
|
+
throw error;
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
async sendRawTx({
|
|
3519
|
+
chainId,
|
|
3520
|
+
address,
|
|
3521
|
+
data,
|
|
3522
|
+
value = "0",
|
|
3523
|
+
autoAlert = true,
|
|
3524
|
+
onSended,
|
|
3525
|
+
onSuccess,
|
|
3526
|
+
onError,
|
|
3527
|
+
historyItem,
|
|
3528
|
+
loadingText,
|
|
3529
|
+
showSuccessDialog = false
|
|
3530
|
+
}) {
|
|
3531
|
+
var _a, _b, _c;
|
|
3532
|
+
chainId = Number(chainId);
|
|
3533
|
+
const toast = RootStore.Get(ToastPlugin);
|
|
3534
|
+
try {
|
|
3535
|
+
if (!chainId || !address)
|
|
3536
|
+
throw new Error("chainId, address, is required");
|
|
3537
|
+
await RootStore.Get(_WalletStore).prepare(chainId);
|
|
3538
|
+
if (loadingText)
|
|
3539
|
+
toast.loading(loadingText);
|
|
3540
|
+
const historyStore = RootStore.Get(WalletHistoryStore);
|
|
3541
|
+
const hash = await this.walletClient.sendTransaction({
|
|
3542
|
+
account: this.account,
|
|
3543
|
+
to: address,
|
|
3544
|
+
data,
|
|
3545
|
+
value: value ? BigInt(value) : void 0
|
|
3546
|
+
});
|
|
3547
|
+
let receipt = await this.waitForTransactionReceipt({ hash });
|
|
3548
|
+
console.log(receipt);
|
|
3549
|
+
if (historyItem) {
|
|
3550
|
+
historyStore.recordHistory(__spreadProps(__spreadValues({}, historyItem), { tx: receipt.transactionHash, timestamp: Date.now(), status: "loading", chainId: Number(chainId) }));
|
|
3551
|
+
}
|
|
3552
|
+
onSended ? onSended({ res: receipt }) : null;
|
|
3553
|
+
if (receipt.status == "success") {
|
|
3554
|
+
if (historyItem) {
|
|
3555
|
+
if (showSuccessDialog) {
|
|
3556
|
+
ShowSuccessTxDialog({ msg: historyItem.msg, hash });
|
|
3557
|
+
}
|
|
3558
|
+
historyStore.updateHistoryStatusByTx(receipt.transactionHash, "success");
|
|
3559
|
+
}
|
|
3560
|
+
onSuccess && onSuccess({ res: receipt });
|
|
3561
|
+
toast.dismiss();
|
|
3562
|
+
toast.success("The transaction was successful");
|
|
3563
|
+
} else {
|
|
3564
|
+
if (historyItem) {
|
|
3565
|
+
historyStore.updateHistoryStatusByTx(receipt.transactionHash, "fail");
|
|
3566
|
+
}
|
|
3567
|
+
onError && onError({ res: receipt });
|
|
3568
|
+
toast.dismiss();
|
|
3569
|
+
toast.error("The transaction failed");
|
|
3570
|
+
}
|
|
3571
|
+
return receipt;
|
|
3572
|
+
} catch (error) {
|
|
3573
|
+
toast.dismiss();
|
|
3574
|
+
console.log(error.message);
|
|
3575
|
+
const msg = /reason="[A-Za-z0-9_ :"]*/g.exec(error == null ? void 0 : error.message);
|
|
3576
|
+
if (((_a = error == null ? void 0 : error.message) == null ? void 0 : _a.includes("user rejected transaction")) || ((_b = error == null ? void 0 : error.message) == null ? void 0 : _b.includes("cancel")) || String(error).toLowerCase().includes("user rejected") || String(error).toLowerCase().includes("user denied")) {
|
|
3577
|
+
autoAlert && toast.error("user rejected transaction");
|
|
3578
|
+
return;
|
|
3579
|
+
}
|
|
3580
|
+
if ((_c = error == null ? void 0 : error.message) == null ? void 0 : _c.includes("Price slippage check")) {
|
|
3581
|
+
autoAlert && toast.error("The latest pool price has changed, please try to increase the slippage tolerance or reload the page.");
|
|
3582
|
+
return;
|
|
3583
|
+
}
|
|
3584
|
+
if (error == null ? void 0 : error.message.includes("viem")) {
|
|
3585
|
+
const messageArr = error == null ? void 0 : error.message.split("\n");
|
|
3586
|
+
console.log("messageArr---", messageArr);
|
|
3587
|
+
if (messageArr.length > 0) {
|
|
3588
|
+
toast.error(messageArr[0]);
|
|
3589
|
+
onError == null ? void 0 : onError(messageArr[0]);
|
|
3590
|
+
return;
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
if (msg) {
|
|
3594
|
+
autoAlert && toast.error(msg);
|
|
3595
|
+
} else {
|
|
3596
|
+
autoAlert && toast.error(String(error.message));
|
|
3597
|
+
}
|
|
3598
|
+
if (!autoAlert) {
|
|
3599
|
+
throw error;
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
};
|
|
3604
|
+
|
|
3605
|
+
// module/Wallet/provider.tsx
|
|
3606
|
+
var queryClient = new QueryClient();
|
|
3607
|
+
var WalletProvider = observer(({
|
|
3608
|
+
children,
|
|
3609
|
+
theme,
|
|
3610
|
+
appName
|
|
3611
|
+
}) => {
|
|
3612
|
+
const walletConfig = RootStore.Get(WalletConfigStore);
|
|
3613
|
+
useEffect(() => {
|
|
3614
|
+
if (appName) {
|
|
3615
|
+
walletConfig.appName = appName;
|
|
3616
|
+
}
|
|
3617
|
+
}, [appName]);
|
|
3618
|
+
return (
|
|
3619
|
+
//@ts-ignore
|
|
3620
|
+
/* @__PURE__ */ React2.createElement(WagmiProvider, { config: walletConfig.rainbowKitConfig, reconnectOnMount: true }, /* @__PURE__ */ React2.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React2.createElement(RainbowKitProvider, { locale: "en", theme: theme == "dark" ? darkTheme() : lightTheme() }, children, /* @__PURE__ */ React2.createElement(WalletConnect, null))))
|
|
3621
|
+
);
|
|
3622
|
+
});
|
|
3623
|
+
var WalletConnect = () => {
|
|
3624
|
+
const wallet = RootStore.Get(WalletStore);
|
|
3625
|
+
wallet.use();
|
|
3626
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null);
|
|
3627
|
+
};
|
|
3628
|
+
|
|
3629
|
+
export { WalletConfigStore, WalletHistoryStore, WalletProvider, WalletRpcStore, WalletStore };
|
|
3630
|
+
//# sourceMappingURL=out.js.map
|
|
3631
|
+
//# sourceMappingURL=wallet.mjs.map
|