@xrpl-wallet-kit/browser 0.1.10 → 0.1.12
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/xrpl-wallet-kit.iife.js +946 -992
- package/dist/xrpl-wallet-kit.iife.min.js +48 -48
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @xrpl-wallet-kit/browser v0.1.
|
|
1
|
+
/*! @xrpl-wallet-kit/browser v0.1.12 | MIT | https://github.com/XRPDomains/xrpl-wallet-kit */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __typeError = (msg) => {
|
|
4
4
|
throw TypeError(msg);
|
|
@@ -1848,23 +1848,23 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
1848
1848
|
global2.Buffer = bufferExports.Buffer;
|
|
1849
1849
|
}
|
|
1850
1850
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
})(
|
|
1851
|
+
var WalletKitErrorCode = /* @__PURE__ */ ((WalletKitErrorCode2) => {
|
|
1852
|
+
WalletKitErrorCode2["WALLET_NOT_FOUND"] = "WALLET_NOT_FOUND";
|
|
1853
|
+
WalletKitErrorCode2["WALLET_NOT_INSTALLED"] = "WALLET_NOT_INSTALLED";
|
|
1854
|
+
WalletKitErrorCode2["WALLET_NOT_AVAILABLE"] = "WALLET_NOT_AVAILABLE";
|
|
1855
|
+
WalletKitErrorCode2["CONNECTION_FAILED"] = "CONNECTION_FAILED";
|
|
1856
|
+
WalletKitErrorCode2["CONNECTION_REJECTED"] = "CONNECTION_REJECTED";
|
|
1857
|
+
WalletKitErrorCode2["SIGN_FAILED"] = "SIGN_FAILED";
|
|
1858
|
+
WalletKitErrorCode2["SIGN_REJECTED"] = "SIGN_REJECTED";
|
|
1859
|
+
WalletKitErrorCode2["REQUEST_TIMEOUT"] = "REQUEST_TIMEOUT";
|
|
1860
|
+
WalletKitErrorCode2["UNSUPPORTED_METHOD"] = "UNSUPPORTED_METHOD";
|
|
1861
|
+
WalletKitErrorCode2["INVALID_ADAPTER"] = "INVALID_ADAPTER";
|
|
1862
|
+
WalletKitErrorCode2["NETWORK_MISMATCH"] = "NETWORK_MISMATCH";
|
|
1863
|
+
WalletKitErrorCode2["NOT_CONNECTED"] = "NOT_CONNECTED";
|
|
1864
|
+
WalletKitErrorCode2["ALREADY_CONNECTED"] = "ALREADY_CONNECTED";
|
|
1865
|
+
WalletKitErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
1866
|
+
return WalletKitErrorCode2;
|
|
1867
|
+
})(WalletKitErrorCode || {});
|
|
1868
1868
|
class WalletKitError extends Error {
|
|
1869
1869
|
constructor(code, message, options = {}) {
|
|
1870
1870
|
super(message);
|
|
@@ -1878,10 +1878,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
1878
1878
|
return error instanceof WalletKitError;
|
|
1879
1879
|
}
|
|
1880
1880
|
function getErrorMessage(error) {
|
|
1881
|
-
if (error instanceof Error)
|
|
1882
|
-
|
|
1883
|
-
if (typeof error === "string")
|
|
1884
|
-
return error;
|
|
1881
|
+
if (error instanceof Error) return error.message;
|
|
1882
|
+
if (typeof error === "string") return error;
|
|
1885
1883
|
try {
|
|
1886
1884
|
return JSON.stringify(error);
|
|
1887
1885
|
} catch {
|
|
@@ -1889,23 +1887,73 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
1889
1887
|
}
|
|
1890
1888
|
}
|
|
1891
1889
|
const createWalletError = {
|
|
1892
|
-
walletNotFound: (adapterId) => new WalletKitError(
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1890
|
+
walletNotFound: (adapterId) => new WalletKitError(
|
|
1891
|
+
"WALLET_NOT_FOUND",
|
|
1892
|
+
`Wallet adapter is not registered: ${adapterId}`,
|
|
1893
|
+
{ details: { adapterId } }
|
|
1894
|
+
),
|
|
1895
|
+
walletNotInstalled: (walletName, cause) => new WalletKitError(
|
|
1896
|
+
"WALLET_NOT_INSTALLED",
|
|
1897
|
+
`${walletName} is not installed`,
|
|
1898
|
+
{ cause, details: { walletName } }
|
|
1899
|
+
),
|
|
1900
|
+
walletNotAvailable: (walletName, cause) => new WalletKitError(
|
|
1901
|
+
"WALLET_NOT_AVAILABLE",
|
|
1902
|
+
`${walletName} provider is not available`,
|
|
1903
|
+
{ cause, details: { walletName } }
|
|
1904
|
+
),
|
|
1905
|
+
connectionFailed: (walletName, cause) => new WalletKitError(
|
|
1906
|
+
"CONNECTION_FAILED",
|
|
1907
|
+
`Failed to connect ${walletName}: ${getErrorMessage(cause)}`,
|
|
1908
|
+
{ cause, details: { walletName } }
|
|
1909
|
+
),
|
|
1910
|
+
connectionRejected: (walletName, cause) => new WalletKitError(
|
|
1911
|
+
"CONNECTION_REJECTED",
|
|
1912
|
+
`${walletName} connection was rejected`,
|
|
1913
|
+
{ cause, details: { walletName } }
|
|
1914
|
+
),
|
|
1915
|
+
signFailed: (cause) => new WalletKitError(
|
|
1916
|
+
"SIGN_FAILED",
|
|
1917
|
+
`Failed to sign request: ${getErrorMessage(cause)}`,
|
|
1918
|
+
{ cause }
|
|
1919
|
+
),
|
|
1920
|
+
signRejected: (cause) => new WalletKitError(
|
|
1921
|
+
"SIGN_REJECTED",
|
|
1922
|
+
"Signing request was rejected",
|
|
1923
|
+
{ cause }
|
|
1924
|
+
),
|
|
1925
|
+
requestTimeout: (message, cause) => new WalletKitError(
|
|
1926
|
+
"REQUEST_TIMEOUT",
|
|
1927
|
+
message,
|
|
1928
|
+
{ cause }
|
|
1929
|
+
),
|
|
1930
|
+
unsupportedMethod: (method, walletName) => new WalletKitError(
|
|
1931
|
+
"UNSUPPORTED_METHOD",
|
|
1932
|
+
walletName ? `${method} is not supported by ${walletName}` : `${method} is not supported`,
|
|
1933
|
+
{ details: { method, walletName } }
|
|
1934
|
+
),
|
|
1935
|
+
invalidAdapter: (adapterId, issues) => new WalletKitError(
|
|
1936
|
+
"INVALID_ADAPTER",
|
|
1937
|
+
`Wallet adapter is invalid: ${adapterId}`,
|
|
1938
|
+
{ details: { adapterId, issues } }
|
|
1939
|
+
),
|
|
1940
|
+
notConnected: () => new WalletKitError(
|
|
1941
|
+
"NOT_CONNECTED",
|
|
1942
|
+
"No wallet is connected"
|
|
1943
|
+
),
|
|
1944
|
+
alreadyConnected: (walletName) => new WalletKitError(
|
|
1945
|
+
"ALREADY_CONNECTED",
|
|
1946
|
+
`Already connected to ${walletName}`,
|
|
1947
|
+
{ details: { walletName } }
|
|
1948
|
+
),
|
|
1949
|
+
unknown: (cause) => new WalletKitError(
|
|
1950
|
+
"UNKNOWN_ERROR",
|
|
1951
|
+
getErrorMessage(cause),
|
|
1952
|
+
{ cause }
|
|
1953
|
+
)
|
|
1905
1954
|
};
|
|
1906
1955
|
function normalizeWalletError(error) {
|
|
1907
|
-
if (isWalletKitError(error))
|
|
1908
|
-
return error;
|
|
1956
|
+
if (isWalletKitError(error)) return error;
|
|
1909
1957
|
const message = getErrorMessage(error).toLowerCase();
|
|
1910
1958
|
if (/reject|denied|cancelled|canceled|closed/i.test(message)) {
|
|
1911
1959
|
return createWalletError.signRejected(error);
|
|
@@ -1938,7 +1986,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
1938
1986
|
const walletAdapter = adapter;
|
|
1939
1987
|
const adapterId = ((_a2 = walletAdapter.metadata) == null ? void 0 : _a2.id) || "unknown";
|
|
1940
1988
|
if (walletAdapter.adapterApiVersion && !walletAdapter.adapterApiVersion.startsWith("1.")) {
|
|
1941
|
-
addIssue(
|
|
1989
|
+
addIssue(
|
|
1990
|
+
issues,
|
|
1991
|
+
"warning",
|
|
1992
|
+
"adapterApiVersion",
|
|
1993
|
+
`Adapter ${adapterId} declares API ${walletAdapter.adapterApiVersion}; this core expects ${WALLET_ADAPTER_API_VERSION}.`
|
|
1994
|
+
);
|
|
1942
1995
|
}
|
|
1943
1996
|
if (!walletAdapter.metadata || typeof walletAdapter.metadata !== "object") {
|
|
1944
1997
|
addIssue(issues, "error", "metadata", "metadata is required.");
|
|
@@ -2000,7 +2053,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2000
2053
|
const result = validateWalletAdapter(adapter);
|
|
2001
2054
|
if (!result.valid) {
|
|
2002
2055
|
const walletAdapter = adapter && typeof adapter === "object" ? adapter : void 0;
|
|
2003
|
-
throw createWalletError.invalidAdapter(
|
|
2056
|
+
throw createWalletError.invalidAdapter(
|
|
2057
|
+
((_a2 = walletAdapter == null ? void 0 : walletAdapter.metadata) == null ? void 0 : _a2.id) || "unknown",
|
|
2058
|
+
result.issues.map((issue2) => `${issue2.field}: ${issue2.message}`)
|
|
2059
|
+
);
|
|
2004
2060
|
}
|
|
2005
2061
|
}
|
|
2006
2062
|
class BaseWalletAdapter {
|
|
@@ -2029,17 +2085,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2029
2085
|
}
|
|
2030
2086
|
async waitForAvailability(timeoutMs = 2500, pollMs = 100) {
|
|
2031
2087
|
const isAvailable = this.isAvailable;
|
|
2032
|
-
if (!isAvailable)
|
|
2033
|
-
return true;
|
|
2088
|
+
if (!isAvailable) return true;
|
|
2034
2089
|
const startedAt = Date.now();
|
|
2035
2090
|
do {
|
|
2036
2091
|
try {
|
|
2037
|
-
if (await isAvailable.call(this))
|
|
2038
|
-
return true;
|
|
2092
|
+
if (await isAvailable.call(this)) return true;
|
|
2039
2093
|
} catch {
|
|
2040
2094
|
}
|
|
2041
|
-
if (timeoutMs <= 0)
|
|
2042
|
-
return false;
|
|
2095
|
+
if (timeoutMs <= 0) return false;
|
|
2043
2096
|
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
2044
2097
|
} while (Date.now() - startedAt < timeoutMs);
|
|
2045
2098
|
return false;
|
|
@@ -2102,8 +2155,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2102
2155
|
this.write("error", message, args);
|
|
2103
2156
|
}
|
|
2104
2157
|
write(level, message, args) {
|
|
2105
|
-
if (this.level === "silent" || levels[level] < levels[this.level])
|
|
2106
|
-
return;
|
|
2158
|
+
if (this.level === "silent" || levels[level] < levels[this.level]) return;
|
|
2107
2159
|
const target = console[level];
|
|
2108
2160
|
target(`${this.prefix} ${message}`, ...args);
|
|
2109
2161
|
}
|
|
@@ -2165,8 +2217,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2165
2217
|
}
|
|
2166
2218
|
resolve(id2 = "mainnet") {
|
|
2167
2219
|
const network = this.networks.get(id2);
|
|
2168
|
-
if (!network)
|
|
2169
|
-
throw new Error(`XRPL network is not registered: ${id2}`);
|
|
2220
|
+
if (!network) throw new Error(`XRPL network is not registered: ${id2}`);
|
|
2170
2221
|
return network;
|
|
2171
2222
|
}
|
|
2172
2223
|
list() {
|
|
@@ -2180,39 +2231,29 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2180
2231
|
return registry.register(network);
|
|
2181
2232
|
}
|
|
2182
2233
|
function resolveNetwork(networks, id2 = "mainnet") {
|
|
2183
|
-
if (networks instanceof NetworkRegistry)
|
|
2184
|
-
return networks.resolve(id2);
|
|
2234
|
+
if (networks instanceof NetworkRegistry) return networks.resolve(id2);
|
|
2185
2235
|
return createNetworkRegistry(networks).resolve(id2);
|
|
2186
2236
|
}
|
|
2187
2237
|
function getNativeAsset(network) {
|
|
2188
2238
|
return (network == null ? void 0 : network.nativeAsset) ?? "XRP";
|
|
2189
2239
|
}
|
|
2190
2240
|
function getHttpRpcUrl(networkOrUrl) {
|
|
2191
|
-
if (!networkOrUrl)
|
|
2192
|
-
return void 0;
|
|
2241
|
+
if (!networkOrUrl) return void 0;
|
|
2193
2242
|
const rpcUrl = typeof networkOrUrl === "string" ? networkOrUrl : networkOrUrl.httpRpcUrl ?? networkOrUrl.rpcUrl;
|
|
2194
|
-
if (rpcUrl.startsWith("wss://"))
|
|
2195
|
-
|
|
2196
|
-
if (rpcUrl.startsWith("ws://"))
|
|
2197
|
-
return `http://${rpcUrl.slice(5)}`;
|
|
2243
|
+
if (rpcUrl.startsWith("wss://")) return `https://${rpcUrl.slice(6)}`;
|
|
2244
|
+
if (rpcUrl.startsWith("ws://")) return `http://${rpcUrl.slice(5)}`;
|
|
2198
2245
|
return rpcUrl;
|
|
2199
2246
|
}
|
|
2200
2247
|
function getExplorerAccountUrl(network, address) {
|
|
2201
|
-
if (!network)
|
|
2202
|
-
|
|
2203
|
-
if (network.
|
|
2204
|
-
|
|
2205
|
-
if (network.networkType === "
|
|
2206
|
-
return `https://testnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2207
|
-
if (network.networkType === "DEVNET")
|
|
2208
|
-
return `https://devnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2209
|
-
if (network.networkType === "MAINNET")
|
|
2210
|
-
return `https://livenet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2248
|
+
if (!network) return void 0;
|
|
2249
|
+
if (network.explorerAccountUrl) return network.explorerAccountUrl.replace("{address}", encodeURIComponent(address));
|
|
2250
|
+
if (network.networkType === "TESTNET") return `https://testnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2251
|
+
if (network.networkType === "DEVNET") return `https://devnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2252
|
+
if (network.networkType === "MAINNET") return `https://livenet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2211
2253
|
return void 0;
|
|
2212
2254
|
}
|
|
2213
2255
|
function getExplorerTxUrl(network, hash2) {
|
|
2214
|
-
if (!(network == null ? void 0 : network.explorerTxUrl))
|
|
2215
|
-
return void 0;
|
|
2256
|
+
if (!(network == null ? void 0 : network.explorerTxUrl)) return void 0;
|
|
2216
2257
|
const encodedHash = encodeURIComponent(hash2);
|
|
2217
2258
|
return network.explorerTxUrl.includes("{hash}") ? network.explorerTxUrl.replace("{hash}", encodedHash) : `${network.explorerTxUrl.replace(/\/$/, "")}/${encodedHash}`;
|
|
2218
2259
|
}
|
|
@@ -2220,16 +2261,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2220
2261
|
return (network == null ? void 0 : network.networkType) === "MAINNET" && (network.family ?? "xrpl") === "xrpl" && getNativeAsset(network) === "XRP";
|
|
2221
2262
|
}
|
|
2222
2263
|
function pickPath(source, paths) {
|
|
2223
|
-
if (!source || typeof source !== "object")
|
|
2224
|
-
return void 0;
|
|
2264
|
+
if (!source || typeof source !== "object") return void 0;
|
|
2225
2265
|
for (const path of paths) {
|
|
2226
2266
|
const value = path.split(".").reduce((current, key) => {
|
|
2227
|
-
if (!current || typeof current !== "object")
|
|
2228
|
-
return void 0;
|
|
2267
|
+
if (!current || typeof current !== "object") return void 0;
|
|
2229
2268
|
return current[key];
|
|
2230
2269
|
}, source);
|
|
2231
|
-
if (value !== void 0 && value !== null && value !== "")
|
|
2232
|
-
return value;
|
|
2270
|
+
if (value !== void 0 && value !== null && value !== "") return value;
|
|
2233
2271
|
}
|
|
2234
2272
|
return void 0;
|
|
2235
2273
|
}
|
|
@@ -2328,12 +2366,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2328
2366
|
return {
|
|
2329
2367
|
getItem: (key) => typeof localStorage === "undefined" ? null : localStorage.getItem(prefix + key),
|
|
2330
2368
|
setItem: (key, value) => {
|
|
2331
|
-
if (typeof localStorage !== "undefined")
|
|
2332
|
-
localStorage.setItem(prefix + key, value);
|
|
2369
|
+
if (typeof localStorage !== "undefined") localStorage.setItem(prefix + key, value);
|
|
2333
2370
|
},
|
|
2334
2371
|
removeItem: (key) => {
|
|
2335
|
-
if (typeof localStorage !== "undefined")
|
|
2336
|
-
localStorage.removeItem(prefix + key);
|
|
2372
|
+
if (typeof localStorage !== "undefined") localStorage.removeItem(prefix + key);
|
|
2337
2373
|
}
|
|
2338
2374
|
};
|
|
2339
2375
|
}
|
|
@@ -2357,8 +2393,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2357
2393
|
}
|
|
2358
2394
|
return transaction2;
|
|
2359
2395
|
});
|
|
2360
|
-
if (changed)
|
|
2361
|
-
await this.writeList(this.key(networkId, accountAddress), normalized);
|
|
2396
|
+
if (changed) await this.writeList(this.key(networkId, accountAddress), normalized);
|
|
2362
2397
|
return normalized;
|
|
2363
2398
|
}
|
|
2364
2399
|
async add(accountAddress, networkId, transaction2) {
|
|
@@ -2387,8 +2422,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2387
2422
|
async readList(key) {
|
|
2388
2423
|
try {
|
|
2389
2424
|
const raw = await this.storage.getItem(key);
|
|
2390
|
-
if (!raw)
|
|
2391
|
-
return [];
|
|
2425
|
+
if (!raw) return [];
|
|
2392
2426
|
const parsed = JSON.parse(raw);
|
|
2393
2427
|
return Array.isArray(parsed) ? parsed.filter(this.isStoredTransaction) : [];
|
|
2394
2428
|
} catch {
|
|
@@ -2400,15 +2434,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2400
2434
|
}
|
|
2401
2435
|
async addIndex(accountAddress, networkId) {
|
|
2402
2436
|
const current = await this.readIndex(accountAddress);
|
|
2403
|
-
if (current.includes(networkId))
|
|
2404
|
-
return;
|
|
2437
|
+
if (current.includes(networkId)) return;
|
|
2405
2438
|
await this.storage.setItem(this.indexKey(accountAddress), JSON.stringify([...current, networkId]));
|
|
2406
2439
|
}
|
|
2407
2440
|
async readIndex(accountAddress) {
|
|
2408
2441
|
try {
|
|
2409
2442
|
const raw = await this.storage.getItem(this.indexKey(accountAddress));
|
|
2410
|
-
if (!raw)
|
|
2411
|
-
return [];
|
|
2443
|
+
if (!raw) return [];
|
|
2412
2444
|
const parsed = JSON.parse(raw);
|
|
2413
2445
|
return Array.isArray(parsed) ? parsed.filter((value) => typeof value === "string") : [];
|
|
2414
2446
|
} catch {
|
|
@@ -2416,8 +2448,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2416
2448
|
}
|
|
2417
2449
|
}
|
|
2418
2450
|
isStoredTransaction(value) {
|
|
2419
|
-
if (!value || typeof value !== "object")
|
|
2420
|
-
return false;
|
|
2451
|
+
if (!value || typeof value !== "object") return false;
|
|
2421
2452
|
const transaction2 = value;
|
|
2422
2453
|
return typeof transaction2.hash === "string" && typeof transaction2.status === "string" && typeof transaction2.submittedAt === "number";
|
|
2423
2454
|
}
|
|
@@ -2472,8 +2503,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2472
2503
|
}
|
|
2473
2504
|
async getWalletAvailability() {
|
|
2474
2505
|
const entries = await Promise.all([...this.adapters.values()].map(async (adapter) => {
|
|
2475
|
-
if (!adapter.isAvailable)
|
|
2476
|
-
return [adapter.metadata.id, false];
|
|
2506
|
+
if (!adapter.isAvailable) return [adapter.metadata.id, false];
|
|
2477
2507
|
try {
|
|
2478
2508
|
return [adapter.metadata.id, Boolean(await adapter.isAvailable())];
|
|
2479
2509
|
} catch (error) {
|
|
@@ -2485,8 +2515,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2485
2515
|
}
|
|
2486
2516
|
async getAvailableWallets() {
|
|
2487
2517
|
const results2 = await Promise.all([...this.adapters.values()].map(async (adapter) => {
|
|
2488
|
-
if (!adapter.isAvailable)
|
|
2489
|
-
return null;
|
|
2518
|
+
if (!adapter.isAvailable) return null;
|
|
2490
2519
|
try {
|
|
2491
2520
|
return await adapter.isAvailable() ? adapter : null;
|
|
2492
2521
|
} catch (error) {
|
|
@@ -2518,10 +2547,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2518
2547
|
return this.networkRegistry.resolve(id2);
|
|
2519
2548
|
}
|
|
2520
2549
|
async autoReconnect() {
|
|
2521
|
-
if (!this.config.autoReconnect)
|
|
2522
|
-
|
|
2523
|
-
if (this.autoReconnectPromise)
|
|
2524
|
-
return this.autoReconnectPromise;
|
|
2550
|
+
if (!this.config.autoReconnect) return null;
|
|
2551
|
+
if (this.autoReconnectPromise) return this.autoReconnectPromise;
|
|
2525
2552
|
this.autoReconnectPromise = this.runAutoReconnect().finally(() => {
|
|
2526
2553
|
this.autoReconnectPromise = void 0;
|
|
2527
2554
|
});
|
|
@@ -2529,8 +2556,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2529
2556
|
}
|
|
2530
2557
|
async runAutoReconnect() {
|
|
2531
2558
|
const serialized = await this.storage.getItem(SESSION_KEY);
|
|
2532
|
-
if (!serialized)
|
|
2533
|
-
return this.recoverPendingReturnSession();
|
|
2559
|
+
if (!serialized) return this.recoverPendingReturnSession();
|
|
2534
2560
|
const session = this.parseStoredSession(serialized);
|
|
2535
2561
|
if (!session) {
|
|
2536
2562
|
await this.storage.removeItem(SESSION_KEY);
|
|
@@ -2597,15 +2623,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2597
2623
|
const recoverableAdapters = [];
|
|
2598
2624
|
for (const adapter of adaptersWithRecovery) {
|
|
2599
2625
|
try {
|
|
2600
|
-
if (adapter.canRecoverSession && !await adapter.canRecoverSession({ network, walletId: adapter.metadata.id }))
|
|
2601
|
-
continue;
|
|
2626
|
+
if (adapter.canRecoverSession && !await adapter.canRecoverSession({ network, walletId: adapter.metadata.id })) continue;
|
|
2602
2627
|
recoverableAdapters.push(adapter);
|
|
2603
2628
|
} catch (error) {
|
|
2604
2629
|
this.logger.warn(`Session recovery availability check failed for ${adapter.metadata.id}`, error);
|
|
2605
2630
|
}
|
|
2606
2631
|
}
|
|
2607
|
-
if (!recoverableAdapters.length)
|
|
2608
|
-
return null;
|
|
2632
|
+
if (!recoverableAdapters.length) return null;
|
|
2609
2633
|
const announcedAdapters = /* @__PURE__ */ new Set();
|
|
2610
2634
|
const recoveryRetryDelaysMs = this.config.recoveryRetryDelaysMs ?? RECOVER_SESSION_RETRY_DELAYS_MS;
|
|
2611
2635
|
const recoveryDeadline = Date.now() + DEFAULT_PENDING_RETURN_RECOVERY_TIMEOUT_MS;
|
|
@@ -2616,8 +2640,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2616
2640
|
timedOut = true;
|
|
2617
2641
|
break;
|
|
2618
2642
|
}
|
|
2619
|
-
if (delayMs > 0)
|
|
2620
|
-
await this.delay(Math.min(delayMs, remainingBeforeDelay));
|
|
2643
|
+
if (delayMs > 0) await this.delay(Math.min(delayMs, remainingBeforeDelay));
|
|
2621
2644
|
for (const adapter of recoverableAdapters) {
|
|
2622
2645
|
const remaining = recoveryDeadline - Date.now();
|
|
2623
2646
|
if (remaining <= 0) {
|
|
@@ -2636,8 +2659,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2636
2659
|
break;
|
|
2637
2660
|
}
|
|
2638
2661
|
const recovered = recovery.value;
|
|
2639
|
-
if (!(recovered == null ? void 0 : recovered.session))
|
|
2640
|
-
continue;
|
|
2662
|
+
if (!(recovered == null ? void 0 : recovered.session)) continue;
|
|
2641
2663
|
const enrichedSession = await this.enrichSession(this.withWalletMetadata(recovered.session, adapter));
|
|
2642
2664
|
this.setSession(enrichedSession);
|
|
2643
2665
|
await this.saveSession(enrichedSession);
|
|
@@ -2649,8 +2671,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2649
2671
|
this.logger.warn(`Session recovery failed for ${adapter.metadata.id}`, error);
|
|
2650
2672
|
}
|
|
2651
2673
|
}
|
|
2652
|
-
if (timedOut)
|
|
2653
|
-
break;
|
|
2674
|
+
if (timedOut) break;
|
|
2654
2675
|
}
|
|
2655
2676
|
recoverableAdapters.forEach((adapter) => {
|
|
2656
2677
|
var _a3;
|
|
@@ -2709,8 +2730,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2709
2730
|
async cancelPendingConnection(exceptAdapterId) {
|
|
2710
2731
|
var _a2, _b, _c;
|
|
2711
2732
|
const pendingAdapterId = this.pendingAdapterId;
|
|
2712
|
-
if (!pendingAdapterId || pendingAdapterId === exceptAdapterId)
|
|
2713
|
-
return;
|
|
2733
|
+
if (!pendingAdapterId || pendingAdapterId === exceptAdapterId) return;
|
|
2714
2734
|
(_a2 = this.pendingAbortController) == null ? void 0 : _a2.abort();
|
|
2715
2735
|
this.pendingAbortController = void 0;
|
|
2716
2736
|
this.pendingAdapterId = null;
|
|
@@ -2755,7 +2775,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2755
2775
|
const adapter = this.requireActiveAdapter("signMessage");
|
|
2756
2776
|
try {
|
|
2757
2777
|
this.emit("signing", { adapterId: adapter.metadata.id, kind: "message" });
|
|
2758
|
-
const result = this.normalizeSignMessageResult(
|
|
2778
|
+
const result = this.normalizeSignMessageResult(
|
|
2779
|
+
adapter.metadata.id,
|
|
2780
|
+
await adapter.signMessage({ ...request, account: request.account ?? this.getAccount() ?? void 0 })
|
|
2781
|
+
);
|
|
2759
2782
|
this.emit("signed", { adapterId: adapter.metadata.id, kind: "message", result });
|
|
2760
2783
|
return result;
|
|
2761
2784
|
} catch (error) {
|
|
@@ -2766,8 +2789,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2766
2789
|
}
|
|
2767
2790
|
async authenticate(request) {
|
|
2768
2791
|
const account = request.account ?? this.getAccount();
|
|
2769
|
-
if (!account)
|
|
2770
|
-
throw createWalletError.notConnected();
|
|
2792
|
+
if (!account) throw createWalletError.notConnected();
|
|
2771
2793
|
const issuedAt = /* @__PURE__ */ new Date();
|
|
2772
2794
|
const expiresAt = new Date(issuedAt.getTime() + (request.expiresIn ?? DEFAULT_AUTHENTICATE_EXPIRES_IN_SECONDS) * 1e3);
|
|
2773
2795
|
const message = [
|
|
@@ -2794,11 +2816,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2794
2816
|
}
|
|
2795
2817
|
normalizeSignMessageResult(adapterId, result) {
|
|
2796
2818
|
const normalized = (() => {
|
|
2797
|
-
if (result.signatureKind === "signature" || result.signatureKind === "signedTx")
|
|
2798
|
-
return result;
|
|
2819
|
+
if (result.signatureKind === "signature" || result.signatureKind === "signedTx") return result;
|
|
2799
2820
|
const legacy2 = result;
|
|
2800
2821
|
const inferredKind = legacy2.txBlob ? "signedTx" : "signature";
|
|
2801
|
-
this.logger.warn(
|
|
2822
|
+
this.logger.warn(
|
|
2823
|
+
`Adapter "${adapterId}" returned SignMessageResult without signatureKind. Inferred "${inferredKind}" for backward compatibility; update the adapter before using auth verification.`
|
|
2824
|
+
);
|
|
2802
2825
|
return { ...legacy2, signatureKind: inferredKind };
|
|
2803
2826
|
})();
|
|
2804
2827
|
if (normalized.signatureKind === "signature" && !this.hasProofValue(normalized.signature)) {
|
|
@@ -2871,8 +2894,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2871
2894
|
}
|
|
2872
2895
|
async signTransaction(request) {
|
|
2873
2896
|
const adapter = this.getAdapter();
|
|
2874
|
-
if (!adapter)
|
|
2875
|
-
throw createWalletError.notConnected();
|
|
2897
|
+
if (!adapter) throw createWalletError.notConnected();
|
|
2876
2898
|
if (typeof adapter.signTransaction !== "function" && typeof adapter.signAndSubmit !== "function") {
|
|
2877
2899
|
throw createWalletError.unsupportedMethod("signTransaction", adapter.metadata.name);
|
|
2878
2900
|
}
|
|
@@ -2951,11 +2973,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2951
2973
|
}
|
|
2952
2974
|
async resolveActivationStatus(account) {
|
|
2953
2975
|
var _a2, _b, _c, _d, _e2;
|
|
2954
|
-
if (((_a2 = this.config.accountStatus) == null ? void 0 : _a2.enabled) === false || account.activationStatus)
|
|
2955
|
-
return account;
|
|
2976
|
+
if (((_a2 = this.config.accountStatus) == null ? void 0 : _a2.enabled) === false || account.activationStatus) return account;
|
|
2956
2977
|
const rpcUrl = ((_b = account.network) == null ? void 0 : _b.httpRpcUrl) ? getHttpRpcUrl(account.network) : void 0;
|
|
2957
|
-
if (!rpcUrl || typeof fetch !== "function")
|
|
2958
|
-
return account;
|
|
2978
|
+
if (!rpcUrl || typeof fetch !== "function") return account;
|
|
2959
2979
|
let timer;
|
|
2960
2980
|
try {
|
|
2961
2981
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
@@ -2971,34 +2991,26 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2971
2991
|
}),
|
|
2972
2992
|
signal: controller == null ? void 0 : controller.signal
|
|
2973
2993
|
});
|
|
2974
|
-
if (timer)
|
|
2975
|
-
clearTimeout(timer);
|
|
2994
|
+
if (timer) clearTimeout(timer);
|
|
2976
2995
|
const body = await response.json();
|
|
2977
|
-
if ((_d = body.result) == null ? void 0 : _d.account_data)
|
|
2978
|
-
|
|
2979
|
-
if (((_e2 = body.result) == null ? void 0 : _e2.error) === "actNotFound")
|
|
2980
|
-
return { ...account, activationStatus: "unfunded" };
|
|
2996
|
+
if ((_d = body.result) == null ? void 0 : _d.account_data) return { ...account, activationStatus: "active" };
|
|
2997
|
+
if (((_e2 = body.result) == null ? void 0 : _e2.error) === "actNotFound") return { ...account, activationStatus: "unfunded" };
|
|
2981
2998
|
return { ...account, activationStatus: "unknown" };
|
|
2982
2999
|
} catch (error) {
|
|
2983
3000
|
this.logger.debug("Account activation status lookup failed", error);
|
|
2984
3001
|
return { ...account, activationStatus: "unknown" };
|
|
2985
3002
|
} finally {
|
|
2986
|
-
if (timer)
|
|
2987
|
-
clearTimeout(timer);
|
|
3003
|
+
if (timer) clearTimeout(timer);
|
|
2988
3004
|
}
|
|
2989
3005
|
}
|
|
2990
3006
|
confirmTransaction(transaction2) {
|
|
2991
3007
|
var _a2, _b;
|
|
2992
|
-
if (((_a2 = this.config.transactionConfirmation) == null ? void 0 : _a2.enabled) === false)
|
|
2993
|
-
|
|
2994
|
-
if (this.pendingConfirmations.has(transaction2.hash))
|
|
2995
|
-
return;
|
|
3008
|
+
if (((_a2 = this.config.transactionConfirmation) == null ? void 0 : _a2.enabled) === false) return;
|
|
3009
|
+
if (this.pendingConfirmations.has(transaction2.hash)) return;
|
|
2996
3010
|
const rpcUrl = ((_b = transaction2.account) == null ? void 0 : _b.network) ? getHttpRpcUrl(transaction2.account.network) : void 0;
|
|
2997
|
-
if (!rpcUrl || typeof fetch !== "function")
|
|
2998
|
-
return;
|
|
3011
|
+
if (!rpcUrl || typeof fetch !== "function") return;
|
|
2999
3012
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
3000
|
-
if (controller)
|
|
3001
|
-
this.pendingConfirmations.set(transaction2.hash, controller);
|
|
3013
|
+
if (controller) this.pendingConfirmations.set(transaction2.hash, controller);
|
|
3002
3014
|
void this.runTransactionConfirmation(transaction2, rpcUrl, controller).finally(() => {
|
|
3003
3015
|
this.pendingConfirmations.delete(transaction2.hash);
|
|
3004
3016
|
});
|
|
@@ -3008,16 +3020,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3008
3020
|
const attempts = Math.max(1, ((_a2 = this.config.transactionConfirmation) == null ? void 0 : _a2.attempts) ?? DEFAULT_TX_CONFIRMATION_ATTEMPTS);
|
|
3009
3021
|
const intervalMs = Math.max(0, ((_b = this.config.transactionConfirmation) == null ? void 0 : _b.intervalMs) ?? DEFAULT_TX_CONFIRMATION_INTERVAL_MS);
|
|
3010
3022
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
3011
|
-
if (controller == null ? void 0 : controller.signal.aborted)
|
|
3012
|
-
|
|
3013
|
-
if (
|
|
3014
|
-
await this.delay(intervalMs);
|
|
3015
|
-
if (controller == null ? void 0 : controller.signal.aborted)
|
|
3016
|
-
return;
|
|
3023
|
+
if (controller == null ? void 0 : controller.signal.aborted) return;
|
|
3024
|
+
if (attempt > 0 && intervalMs > 0) await this.delay(intervalMs);
|
|
3025
|
+
if (controller == null ? void 0 : controller.signal.aborted) return;
|
|
3017
3026
|
try {
|
|
3018
3027
|
const result = await this.lookupTransaction(transaction2.hash, rpcUrl, controller == null ? void 0 : controller.signal);
|
|
3019
|
-
if (!result || !result.validated)
|
|
3020
|
-
continue;
|
|
3028
|
+
if (!result || !result.validated) continue;
|
|
3021
3029
|
if (result.transactionResult === "tesSUCCESS") {
|
|
3022
3030
|
this.addTransaction({
|
|
3023
3031
|
...transaction2,
|
|
@@ -3027,8 +3035,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3027
3035
|
});
|
|
3028
3036
|
return;
|
|
3029
3037
|
}
|
|
3030
|
-
if (!result.transactionResult)
|
|
3031
|
-
continue;
|
|
3038
|
+
if (!result.transactionResult) continue;
|
|
3032
3039
|
this.addTransaction({
|
|
3033
3040
|
...transaction2,
|
|
3034
3041
|
status: "failed",
|
|
@@ -3038,8 +3045,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3038
3045
|
});
|
|
3039
3046
|
return;
|
|
3040
3047
|
} catch (error) {
|
|
3041
|
-
if (controller == null ? void 0 : controller.signal.aborted)
|
|
3042
|
-
return;
|
|
3048
|
+
if (controller == null ? void 0 : controller.signal.aborted) return;
|
|
3043
3049
|
this.logger.debug(`Transaction confirmation lookup failed for ${transaction2.hash}`, error);
|
|
3044
3050
|
}
|
|
3045
3051
|
}
|
|
@@ -3051,8 +3057,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3051
3057
|
params: [{ transaction: hash2, binary: false }]
|
|
3052
3058
|
}, signal, ((_a2 = this.config.transactionConfirmation) == null ? void 0 : _a2.timeoutMs) ?? DEFAULT_TX_CONFIRMATION_TIMEOUT_MS);
|
|
3053
3059
|
const result = response.result;
|
|
3054
|
-
if (!result || result.error === "txnNotFound")
|
|
3055
|
-
return null;
|
|
3060
|
+
if (!result || result.error === "txnNotFound") return null;
|
|
3056
3061
|
const validated = result.validated === true;
|
|
3057
3062
|
const meta = result.meta ?? result.metaData ?? result.metadata;
|
|
3058
3063
|
const transactionResult = pickPath({ meta, result }, [
|
|
@@ -3070,25 +3075,20 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3070
3075
|
};
|
|
3071
3076
|
}
|
|
3072
3077
|
async loadPersistedTransactions(session) {
|
|
3073
|
-
if (!this.transactionStore)
|
|
3074
|
-
return;
|
|
3078
|
+
if (!this.transactionStore) return;
|
|
3075
3079
|
const address = session.account.address;
|
|
3076
|
-
if (!address)
|
|
3077
|
-
return;
|
|
3080
|
+
if (!address) return;
|
|
3078
3081
|
const transactions2 = await this.transactionStore.get(address, this.transactionNetworkId(session.account));
|
|
3079
3082
|
this.transactions.clear();
|
|
3080
3083
|
transactions2.forEach((transaction2) => this.transactions.set(transaction2.hash, transaction2));
|
|
3081
3084
|
transactions2.forEach((transaction2) => {
|
|
3082
|
-
if (transaction2.status === "submitted")
|
|
3083
|
-
this.confirmTransaction(transaction2);
|
|
3085
|
+
if (transaction2.status === "submitted") this.confirmTransaction(transaction2);
|
|
3084
3086
|
});
|
|
3085
3087
|
}
|
|
3086
3088
|
async persistTransaction(transaction2) {
|
|
3087
|
-
if (!this.transactionStore)
|
|
3088
|
-
return;
|
|
3089
|
+
if (!this.transactionStore) return;
|
|
3089
3090
|
const account = transaction2.account ?? this.getAccount() ?? void 0;
|
|
3090
|
-
if (!(account == null ? void 0 : account.address))
|
|
3091
|
-
return;
|
|
3091
|
+
if (!(account == null ? void 0 : account.address)) return;
|
|
3092
3092
|
await this.transactionStore.add(account.address, this.transactionNetworkId(account), {
|
|
3093
3093
|
...transaction2,
|
|
3094
3094
|
account
|
|
@@ -3119,8 +3119,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3119
3119
|
});
|
|
3120
3120
|
return await response.json();
|
|
3121
3121
|
} finally {
|
|
3122
|
-
if (timer)
|
|
3123
|
-
clearTimeout(timer);
|
|
3122
|
+
if (timer) clearTimeout(timer);
|
|
3124
3123
|
}
|
|
3125
3124
|
}
|
|
3126
3125
|
cancelTransactionConfirmations() {
|
|
@@ -3129,16 +3128,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3129
3128
|
}
|
|
3130
3129
|
requireAdapter(adapterId) {
|
|
3131
3130
|
const adapter = this.adapters.get(adapterId);
|
|
3132
|
-
if (!adapter)
|
|
3133
|
-
throw createWalletError.walletNotFound(adapterId);
|
|
3131
|
+
if (!adapter) throw createWalletError.walletNotFound(adapterId);
|
|
3134
3132
|
return adapter;
|
|
3135
3133
|
}
|
|
3136
3134
|
requireActiveAdapter(method) {
|
|
3137
3135
|
const adapter = this.getAdapter();
|
|
3138
|
-
if (!adapter)
|
|
3139
|
-
|
|
3140
|
-
if (typeof adapter[method] !== "function")
|
|
3141
|
-
throw createWalletError.unsupportedMethod(String(method), adapter.metadata.name);
|
|
3136
|
+
if (!adapter) throw createWalletError.notConnected();
|
|
3137
|
+
if (typeof adapter[method] !== "function") throw createWalletError.unsupportedMethod(String(method), adapter.metadata.name);
|
|
3142
3138
|
return adapter;
|
|
3143
3139
|
}
|
|
3144
3140
|
async saveSession(session) {
|
|
@@ -3153,8 +3149,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3153
3149
|
try {
|
|
3154
3150
|
const parsed = JSON.parse(serialized);
|
|
3155
3151
|
if ("version" in parsed && "session" in parsed) {
|
|
3156
|
-
if (parsed.version !== WALLET_STORAGE_VERSION)
|
|
3157
|
-
return null;
|
|
3152
|
+
if (parsed.version !== WALLET_STORAGE_VERSION) return null;
|
|
3158
3153
|
return this.isValidStoredSession(parsed.session) ? parsed.session : null;
|
|
3159
3154
|
}
|
|
3160
3155
|
if (this.isValidStoredSession(parsed)) {
|
|
@@ -3167,14 +3162,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3167
3162
|
}
|
|
3168
3163
|
}
|
|
3169
3164
|
isValidStoredSession(value) {
|
|
3170
|
-
if (!value || typeof value !== "object")
|
|
3171
|
-
return false;
|
|
3165
|
+
if (!value || typeof value !== "object") return false;
|
|
3172
3166
|
const session = value;
|
|
3173
3167
|
return typeof session.adapterId === "string" && typeof session.connectedAt === "number" && Boolean(session.account) && typeof session.account === "object" && typeof session.account.address === "string";
|
|
3174
3168
|
}
|
|
3175
3169
|
async withTimeout(promise, timeoutMs) {
|
|
3176
|
-
if (!promise)
|
|
3177
|
-
return { timedOut: false };
|
|
3170
|
+
if (!promise) return { timedOut: false };
|
|
3178
3171
|
let timer;
|
|
3179
3172
|
const timeout = new Promise((resolve) => {
|
|
3180
3173
|
timer = setTimeout(() => resolve({ timedOut: true }), timeoutMs);
|
|
@@ -3185,13 +3178,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3185
3178
|
timeout
|
|
3186
3179
|
]);
|
|
3187
3180
|
} finally {
|
|
3188
|
-
if (timer)
|
|
3189
|
-
clearTimeout(timer);
|
|
3181
|
+
if (timer) clearTimeout(timer);
|
|
3190
3182
|
}
|
|
3191
3183
|
}
|
|
3192
3184
|
normalizeConnectionError(adapter, error) {
|
|
3193
|
-
if (isWalletKitError(error))
|
|
3194
|
-
return error;
|
|
3185
|
+
if (isWalletKitError(error)) return error;
|
|
3195
3186
|
const message = error instanceof Error ? error.message : String(error);
|
|
3196
3187
|
if (/reject|denied|cancelled|canceled|closed/i.test(message)) {
|
|
3197
3188
|
return createWalletError.connectionRejected(adapter.metadata.name, error);
|
|
@@ -4446,18 +4437,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4446
4437
|
const signInAndWait = this.requireMethod("signInAndWait");
|
|
4447
4438
|
const result = await this.withAbort(signInAndWait(this.randomHex()), options.signal);
|
|
4448
4439
|
const address = this.pickString(result, ["response.data.address", "response.address", "address"]);
|
|
4449
|
-
if (!address)
|
|
4450
|
-
throw new Error("Crossmark did not return an XRPL address");
|
|
4440
|
+
if (!address) throw new Error("Crossmark did not return an XRPL address");
|
|
4451
4441
|
const publicKey = this.pickString(result, ["response.data.publicKey", "response.data.public_key", "response.publicKey", "publicKey"]);
|
|
4452
4442
|
return { account: { address, publicKey, network: options.network, networkType: (_a2 = options.network) == null ? void 0 : _a2.networkType }, raw: result };
|
|
4453
4443
|
}
|
|
4454
4444
|
async restoreSession(session) {
|
|
4455
|
-
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500))
|
|
4456
|
-
return null;
|
|
4445
|
+
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500)) return null;
|
|
4457
4446
|
const provider = this.getProvider(false);
|
|
4458
4447
|
const address = this.resolvePassiveAddress(provider);
|
|
4459
|
-
if (!address || address !== session.account.address)
|
|
4460
|
-
return null;
|
|
4448
|
+
if (!address || address !== session.account.address) return null;
|
|
4461
4449
|
return {
|
|
4462
4450
|
account: { ...session.account, address },
|
|
4463
4451
|
session: { ...session, account: { ...session.account, address } },
|
|
@@ -4479,8 +4467,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4479
4467
|
"signature",
|
|
4480
4468
|
"signedMessage"
|
|
4481
4469
|
]);
|
|
4482
|
-
if (typeof signature !== "string" || !signature)
|
|
4483
|
-
throw createWalletError.signRejected(result);
|
|
4470
|
+
if (typeof signature !== "string" || !signature) throw createWalletError.signRejected(result);
|
|
4484
4471
|
const publicKey = this.pickString(result, [
|
|
4485
4472
|
"response.data.publicKey",
|
|
4486
4473
|
"response.data.public_key",
|
|
@@ -4505,8 +4492,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4505
4492
|
}
|
|
4506
4493
|
getProvider(required = true) {
|
|
4507
4494
|
const provider = this.options.provider ?? CrossmarkSdk;
|
|
4508
|
-
if (!provider && required)
|
|
4509
|
-
throw new Error("Please install Crossmark Extension");
|
|
4495
|
+
if (!provider && required) throw new Error("Please install Crossmark Extension");
|
|
4510
4496
|
return provider;
|
|
4511
4497
|
}
|
|
4512
4498
|
hasInjectedProvider() {
|
|
@@ -4516,16 +4502,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4516
4502
|
var _a2;
|
|
4517
4503
|
const provider = this.getProvider();
|
|
4518
4504
|
const handler = (_a2 = provider == null ? void 0 : provider.methods) == null ? void 0 : _a2[method];
|
|
4519
|
-
if (typeof handler !== "function")
|
|
4520
|
-
throw new Error(`Crossmark provider is missing ${String(method)}()`);
|
|
4505
|
+
if (typeof handler !== "function") throw new Error(`Crossmark provider is missing ${String(method)}()`);
|
|
4521
4506
|
return handler;
|
|
4522
4507
|
}
|
|
4523
4508
|
resolvePassiveAddress(provider) {
|
|
4524
4509
|
var _a2, _b, _c;
|
|
4525
4510
|
try {
|
|
4526
4511
|
const address = (_b = (_a2 = provider == null ? void 0 : provider.sync) == null ? void 0 : _a2.getAddress) == null ? void 0 : _b.call(_a2);
|
|
4527
|
-
if (address)
|
|
4528
|
-
return address;
|
|
4512
|
+
if (address) return address;
|
|
4529
4513
|
} catch {
|
|
4530
4514
|
}
|
|
4531
4515
|
return (_c = provider == null ? void 0 : provider.session) == null ? void 0 : _c.address;
|
|
@@ -4544,8 +4528,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4544
4528
|
if ((_a2 = globalThis.crypto) == null ? void 0 : _a2.getRandomValues) {
|
|
4545
4529
|
globalThis.crypto.getRandomValues(bytes2);
|
|
4546
4530
|
} else {
|
|
4547
|
-
for (let index2 = 0; index2 < bytes2.length; index2 += 1)
|
|
4548
|
-
bytes2[index2] = Math.floor(Math.random() * 256);
|
|
4531
|
+
for (let index2 = 0; index2 < bytes2.length; index2 += 1) bytes2[index2] = Math.floor(Math.random() * 256);
|
|
4549
4532
|
}
|
|
4550
4533
|
return [...bytes2].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
4551
4534
|
}
|
|
@@ -4554,34 +4537,32 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4554
4537
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
4555
4538
|
}
|
|
4556
4539
|
withAbort(promise, signal) {
|
|
4557
|
-
if (!signal)
|
|
4558
|
-
|
|
4559
|
-
if (signal.aborted)
|
|
4560
|
-
return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4540
|
+
if (!signal) return promise;
|
|
4541
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4561
4542
|
return new Promise((resolve, reject) => {
|
|
4562
4543
|
let settled = false;
|
|
4563
4544
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
4564
4545
|
const abort = () => {
|
|
4565
|
-
if (settled)
|
|
4566
|
-
return;
|
|
4546
|
+
if (settled) return;
|
|
4567
4547
|
settled = true;
|
|
4568
4548
|
cleanup();
|
|
4569
4549
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4570
4550
|
};
|
|
4571
4551
|
signal.addEventListener("abort", abort, { once: true });
|
|
4572
|
-
promise.then(
|
|
4573
|
-
|
|
4574
|
-
return;
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
return;
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4552
|
+
promise.then(
|
|
4553
|
+
(value) => {
|
|
4554
|
+
if (settled) return;
|
|
4555
|
+
settled = true;
|
|
4556
|
+
cleanup();
|
|
4557
|
+
resolve(value);
|
|
4558
|
+
},
|
|
4559
|
+
(error) => {
|
|
4560
|
+
if (settled) return;
|
|
4561
|
+
settled = true;
|
|
4562
|
+
cleanup();
|
|
4563
|
+
reject(error);
|
|
4564
|
+
}
|
|
4565
|
+
);
|
|
4585
4566
|
});
|
|
4586
4567
|
}
|
|
4587
4568
|
}
|
|
@@ -4612,21 +4593,17 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4612
4593
|
const provider = this.provider();
|
|
4613
4594
|
const state2 = await this.withAbort(this.initialize(provider), options.signal);
|
|
4614
4595
|
const connected = await this.withAbort(this.resolveConnected(provider, state2), options.signal);
|
|
4615
|
-
if (!connected)
|
|
4616
|
-
throw new Error("DropFi connection was rejected");
|
|
4596
|
+
if (!connected) throw new Error("DropFi connection was rejected");
|
|
4617
4597
|
const address = await this.withAbort(this.resolveAddress(provider, connected, state2), options.signal);
|
|
4618
|
-
if (!address)
|
|
4619
|
-
throw new Error("DropFi did not return an XRPL address");
|
|
4598
|
+
if (!address) throw new Error("DropFi did not return an XRPL address");
|
|
4620
4599
|
const publicKey = await this.withAbort(this.resolvePublicKey(provider, connected, state2), options.signal);
|
|
4621
4600
|
this.activeAddress = address;
|
|
4622
4601
|
return { account: { address, publicKey, network: options.network, networkType: (_a2 = options.network) == null ? void 0 : _a2.networkType }, raw: { connected, address, publicKey } };
|
|
4623
4602
|
}
|
|
4624
4603
|
async restoreSession(session) {
|
|
4625
|
-
if (!this.hasInjectedProvider() && !await this.waitForAvailability(2500))
|
|
4626
|
-
return null;
|
|
4604
|
+
if (!this.hasInjectedProvider() && !await this.waitForAvailability(2500)) return null;
|
|
4627
4605
|
const provider = this.provider(false);
|
|
4628
|
-
if (!provider)
|
|
4629
|
-
return null;
|
|
4606
|
+
if (!provider) return null;
|
|
4630
4607
|
const state2 = await this.initialize(provider);
|
|
4631
4608
|
let connected;
|
|
4632
4609
|
if (typeof provider.isConnected === "function") {
|
|
@@ -4637,8 +4614,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4637
4614
|
}
|
|
4638
4615
|
}
|
|
4639
4616
|
const address = await this.resolvePassiveAddress(provider, state2);
|
|
4640
|
-
if (!address || address !== session.account.address)
|
|
4641
|
-
return null;
|
|
4617
|
+
if (!address || address !== session.account.address) return null;
|
|
4642
4618
|
const publicKey = await this.resolvePublicKey(provider, void 0, state2);
|
|
4643
4619
|
this.activeAddress = address;
|
|
4644
4620
|
return {
|
|
@@ -4663,8 +4639,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4663
4639
|
}
|
|
4664
4640
|
async signMessage(request) {
|
|
4665
4641
|
const provider = this.provider();
|
|
4666
|
-
if (!provider.signMessage)
|
|
4667
|
-
throw new Error("DropFi provider is missing signMessage()");
|
|
4642
|
+
if (!provider.signMessage) throw new Error("DropFi provider is missing signMessage()");
|
|
4668
4643
|
const result = await provider.signMessage(request.message);
|
|
4669
4644
|
const signature = this.pickString(result, [
|
|
4670
4645
|
"signature",
|
|
@@ -4672,8 +4647,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4672
4647
|
"response.signature",
|
|
4673
4648
|
"response.data.signature"
|
|
4674
4649
|
]);
|
|
4675
|
-
if (typeof signature !== "string" || !signature)
|
|
4676
|
-
throw createWalletError.signRejected(signature);
|
|
4650
|
+
if (typeof signature !== "string" || !signature) throw createWalletError.signRejected(signature);
|
|
4677
4651
|
const publicKey = this.pickString(result, [
|
|
4678
4652
|
"publicKey",
|
|
4679
4653
|
"public_key",
|
|
@@ -4684,8 +4658,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4684
4658
|
"response.data.publicKey",
|
|
4685
4659
|
"response.data.public_key"
|
|
4686
4660
|
]);
|
|
4687
|
-
if (typeof publicKey !== "string" || !publicKey)
|
|
4688
|
-
throw createWalletError.signRejected(result);
|
|
4661
|
+
if (typeof publicKey !== "string" || !publicKey) throw createWalletError.signRejected(result);
|
|
4689
4662
|
return {
|
|
4690
4663
|
signatureKind: "signature",
|
|
4691
4664
|
proof: signature,
|
|
@@ -4696,8 +4669,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4696
4669
|
}
|
|
4697
4670
|
async signAndSubmit(request) {
|
|
4698
4671
|
const provider = this.provider();
|
|
4699
|
-
if (!provider.sendTransaction)
|
|
4700
|
-
throw new Error("DropFi provider is missing sendTransaction()");
|
|
4672
|
+
if (!provider.sendTransaction) throw new Error("DropFi provider is missing sendTransaction()");
|
|
4701
4673
|
return normalizeTxResult(await provider.sendTransaction(request.txJson));
|
|
4702
4674
|
}
|
|
4703
4675
|
async withTimeout(promise, timeoutMs) {
|
|
@@ -4708,63 +4680,59 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4708
4680
|
try {
|
|
4709
4681
|
return await Promise.race([promise, timeout]);
|
|
4710
4682
|
} finally {
|
|
4711
|
-
if (timer)
|
|
4712
|
-
clearTimeout(timer);
|
|
4683
|
+
if (timer) clearTimeout(timer);
|
|
4713
4684
|
}
|
|
4714
4685
|
}
|
|
4715
4686
|
withAbort(promise, signal) {
|
|
4716
|
-
if (!signal)
|
|
4717
|
-
|
|
4718
|
-
if (signal.aborted)
|
|
4719
|
-
return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4687
|
+
if (!signal) return promise;
|
|
4688
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4720
4689
|
return new Promise((resolve, reject) => {
|
|
4721
4690
|
let settled = false;
|
|
4722
4691
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
4723
4692
|
const abort = () => {
|
|
4724
|
-
if (settled)
|
|
4725
|
-
return;
|
|
4693
|
+
if (settled) return;
|
|
4726
4694
|
settled = true;
|
|
4727
4695
|
cleanup();
|
|
4728
4696
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4729
4697
|
};
|
|
4730
4698
|
signal.addEventListener("abort", abort, { once: true });
|
|
4731
|
-
promise.then(
|
|
4732
|
-
|
|
4733
|
-
return;
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
return;
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4699
|
+
promise.then(
|
|
4700
|
+
(value) => {
|
|
4701
|
+
if (settled) return;
|
|
4702
|
+
settled = true;
|
|
4703
|
+
cleanup();
|
|
4704
|
+
resolve(value);
|
|
4705
|
+
},
|
|
4706
|
+
(error) => {
|
|
4707
|
+
if (settled) return;
|
|
4708
|
+
settled = true;
|
|
4709
|
+
cleanup();
|
|
4710
|
+
reject(error);
|
|
4711
|
+
}
|
|
4712
|
+
);
|
|
4744
4713
|
});
|
|
4745
4714
|
}
|
|
4746
4715
|
provider(required = true) {
|
|
4747
4716
|
const host = globalThis;
|
|
4748
4717
|
const provider = this.options.provider ?? host.__xwk_dropfi ?? host.dropfi ?? this.resolveLegacyXrplProvider(host.xrpl);
|
|
4749
|
-
if (!provider && required)
|
|
4750
|
-
throw new Error("Please install DropFi Wallet");
|
|
4718
|
+
if (!provider && required) throw new Error("Please install DropFi Wallet");
|
|
4751
4719
|
return provider;
|
|
4752
4720
|
}
|
|
4753
4721
|
hasInjectedProvider() {
|
|
4754
4722
|
return Object.prototype.hasOwnProperty.call(this.options, "provider");
|
|
4755
4723
|
}
|
|
4756
4724
|
resolveLegacyXrplProvider(provider) {
|
|
4757
|
-
if (!provider)
|
|
4758
|
-
return void 0;
|
|
4725
|
+
if (!provider) return void 0;
|
|
4759
4726
|
return this.isDropFiProvider(provider) ? provider : void 0;
|
|
4760
4727
|
}
|
|
4761
4728
|
isDropFiProvider(provider) {
|
|
4762
4729
|
var _a2, _b;
|
|
4763
|
-
return Boolean(
|
|
4730
|
+
return Boolean(
|
|
4731
|
+
provider.isDropFi || provider.connect || provider.getAddress || provider.getAccounts || provider.selectedAddress || ((_a2 = provider.connectedAccounts) == null ? void 0 : _a2.length) || ((_b = provider.accounts) == null ? void 0 : _b.length) || provider.initialize || provider.isConnected || provider.sendTransaction
|
|
4732
|
+
);
|
|
4764
4733
|
}
|
|
4765
4734
|
async initialize(provider) {
|
|
4766
|
-
if (!provider.initialize)
|
|
4767
|
-
return null;
|
|
4735
|
+
if (!provider.initialize) return null;
|
|
4768
4736
|
try {
|
|
4769
4737
|
return await provider.initialize();
|
|
4770
4738
|
} catch {
|
|
@@ -4773,30 +4741,23 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4773
4741
|
}
|
|
4774
4742
|
async resolveAddress(provider, connected, state2) {
|
|
4775
4743
|
var _a2, _b, _c, _d, _e2, _f, _g;
|
|
4776
|
-
if (typeof connected === "string")
|
|
4777
|
-
return connected;
|
|
4744
|
+
if (typeof connected === "string") return connected;
|
|
4778
4745
|
if (connected && typeof connected === "object") {
|
|
4779
4746
|
const result = connected;
|
|
4780
|
-
if (result.address)
|
|
4781
|
-
|
|
4782
|
-
if (result.
|
|
4783
|
-
|
|
4784
|
-
if ((_a2 = result.connectedAccounts) == null ? void 0 : _a2[0])
|
|
4785
|
-
return result.connectedAccounts[0];
|
|
4786
|
-
if ((_b = result.accounts) == null ? void 0 : _b[0])
|
|
4787
|
-
return result.accounts[0];
|
|
4747
|
+
if (result.address) return result.address;
|
|
4748
|
+
if (result.selectedAddress) return result.selectedAddress;
|
|
4749
|
+
if ((_a2 = result.connectedAccounts) == null ? void 0 : _a2[0]) return result.connectedAccounts[0];
|
|
4750
|
+
if ((_b = result.accounts) == null ? void 0 : _b[0]) return result.accounts[0];
|
|
4788
4751
|
}
|
|
4789
4752
|
if (typeof provider.getAddress === "function") {
|
|
4790
4753
|
const address = await provider.getAddress();
|
|
4791
4754
|
const normalized = this.normalizeAddressResult(address);
|
|
4792
|
-
if (normalized)
|
|
4793
|
-
return normalized;
|
|
4755
|
+
if (normalized) return normalized;
|
|
4794
4756
|
}
|
|
4795
4757
|
if (typeof provider.getAccounts === "function") {
|
|
4796
4758
|
const accounts = await provider.getAccounts();
|
|
4797
4759
|
const first = Array.isArray(accounts) ? accounts[0] : (_c = accounts.accounts) == null ? void 0 : _c[0];
|
|
4798
|
-
if (first)
|
|
4799
|
-
return first;
|
|
4760
|
+
if (first) return first;
|
|
4800
4761
|
}
|
|
4801
4762
|
return provider.selectedAddress ?? ((_d = provider.connectedAccounts) == null ? void 0 : _d[0]) ?? ((_e2 = provider.accounts) == null ? void 0 : _e2[0]) ?? (state2 == null ? void 0 : state2.selectedAddress) ?? ((_f = state2 == null ? void 0 : state2.connectedAccounts) == null ? void 0 : _f[0]) ?? ((_g = state2 == null ? void 0 : state2.accounts) == null ? void 0 : _g[0]);
|
|
4802
4763
|
}
|
|
@@ -4806,8 +4767,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4806
4767
|
try {
|
|
4807
4768
|
const address = await provider.getAddress();
|
|
4808
4769
|
const normalized = this.normalizeAddressResult(address);
|
|
4809
|
-
if (normalized)
|
|
4810
|
-
return normalized;
|
|
4770
|
+
if (normalized) return normalized;
|
|
4811
4771
|
} catch {
|
|
4812
4772
|
}
|
|
4813
4773
|
}
|
|
@@ -4815,46 +4775,34 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4815
4775
|
try {
|
|
4816
4776
|
const accounts = await provider.getAccounts();
|
|
4817
4777
|
const first = Array.isArray(accounts) ? accounts[0] : (_a2 = accounts.accounts) == null ? void 0 : _a2[0];
|
|
4818
|
-
if (first)
|
|
4819
|
-
return first;
|
|
4778
|
+
if (first) return first;
|
|
4820
4779
|
} catch {
|
|
4821
4780
|
}
|
|
4822
4781
|
}
|
|
4823
4782
|
return provider.selectedAddress ?? ((_b = provider.connectedAccounts) == null ? void 0 : _b[0]) ?? ((_c = provider.accounts) == null ? void 0 : _c[0]) ?? (state2 == null ? void 0 : state2.selectedAddress) ?? ((_d = state2 == null ? void 0 : state2.connectedAccounts) == null ? void 0 : _d[0]) ?? ((_e2 = state2 == null ? void 0 : state2.accounts) == null ? void 0 : _e2[0]);
|
|
4824
4783
|
}
|
|
4825
4784
|
async resolveConnected(provider, state2) {
|
|
4826
|
-
if (typeof provider.isConnected === "function" && await provider.isConnected())
|
|
4827
|
-
return true;
|
|
4785
|
+
if (typeof provider.isConnected === "function" && await provider.isConnected()) return true;
|
|
4828
4786
|
const existingAddress = await this.resolveAddress(provider, true, state2);
|
|
4829
|
-
if (existingAddress)
|
|
4830
|
-
|
|
4831
|
-
if (typeof provider.connect === "function")
|
|
4832
|
-
return provider.connect();
|
|
4787
|
+
if (existingAddress) return true;
|
|
4788
|
+
if (typeof provider.connect === "function") return provider.connect();
|
|
4833
4789
|
return false;
|
|
4834
4790
|
}
|
|
4835
4791
|
normalizeAddressResult(value) {
|
|
4836
4792
|
var _a2;
|
|
4837
|
-
if (typeof value === "string")
|
|
4838
|
-
|
|
4839
|
-
if (!value || typeof value !== "object")
|
|
4840
|
-
return void 0;
|
|
4793
|
+
if (typeof value === "string") return value;
|
|
4794
|
+
if (!value || typeof value !== "object") return void 0;
|
|
4841
4795
|
return value.address ?? value.selectedAddress ?? ((_a2 = value.result) == null ? void 0 : _a2.address);
|
|
4842
4796
|
}
|
|
4843
4797
|
async resolvePublicKey(provider, connected, state2) {
|
|
4844
|
-
if (connected && typeof connected === "object" && typeof connected.publicKey === "string" && connected.publicKey)
|
|
4845
|
-
|
|
4846
|
-
if (typeof
|
|
4847
|
-
|
|
4848
|
-
if (typeof provider.publicKey === "string" && provider.publicKey)
|
|
4849
|
-
return provider.publicKey;
|
|
4850
|
-
if (typeof provider.getPublicKey !== "function")
|
|
4851
|
-
return void 0;
|
|
4798
|
+
if (connected && typeof connected === "object" && typeof connected.publicKey === "string" && connected.publicKey) return connected.publicKey;
|
|
4799
|
+
if (typeof (state2 == null ? void 0 : state2.publicKey) === "string" && state2.publicKey) return state2.publicKey;
|
|
4800
|
+
if (typeof provider.publicKey === "string" && provider.publicKey) return provider.publicKey;
|
|
4801
|
+
if (typeof provider.getPublicKey !== "function") return void 0;
|
|
4852
4802
|
try {
|
|
4853
4803
|
const result = await provider.getPublicKey();
|
|
4854
|
-
if (typeof result === "string" && result)
|
|
4855
|
-
|
|
4856
|
-
if (!result || typeof result !== "object")
|
|
4857
|
-
return void 0;
|
|
4804
|
+
if (typeof result === "string" && result) return result;
|
|
4805
|
+
if (!result || typeof result !== "object") return void 0;
|
|
4858
4806
|
return this.pickString(result, ["publicKey", "public_key", "result.publicKey", "result.public_key"]);
|
|
4859
4807
|
} catch {
|
|
4860
4808
|
return void 0;
|
|
@@ -8947,31 +8895,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
8947
8895
|
}
|
|
8948
8896
|
async isAvailable() {
|
|
8949
8897
|
const provider = this.getProvider(false);
|
|
8950
|
-
if (!(provider == null ? void 0 : provider.isInstalled))
|
|
8951
|
-
return false;
|
|
8898
|
+
if (!(provider == null ? void 0 : provider.isInstalled)) return false;
|
|
8952
8899
|
const result = await provider.isInstalled();
|
|
8953
8900
|
return this.isInstalledResult(result);
|
|
8954
8901
|
}
|
|
8955
8902
|
async connect(options) {
|
|
8956
8903
|
var _a2, _b, _c;
|
|
8957
8904
|
const provider = this.getProvider();
|
|
8958
|
-
if (!provider.isInstalled || !this.isInstalledResult(await provider.isInstalled()))
|
|
8959
|
-
|
|
8960
|
-
if (!provider.getAddress)
|
|
8961
|
-
throw new Error("GemWallet provider is missing getAddress()");
|
|
8905
|
+
if (!provider.isInstalled || !this.isInstalledResult(await provider.isInstalled())) throw new Error("Please install GemWallet Extension");
|
|
8906
|
+
if (!provider.getAddress) throw new Error("GemWallet provider is missing getAddress()");
|
|
8962
8907
|
const [address, publicKey, network] = await this.withAbort(Promise.all([provider.getAddress(), this.getPublicKey(provider), (_a2 = provider.getNetwork) == null ? void 0 : _a2.call(provider)]), options.signal);
|
|
8963
8908
|
const accountAddress = (_b = address.result) == null ? void 0 : _b.address;
|
|
8964
|
-
if (!accountAddress)
|
|
8965
|
-
throw new Error("GemWallet did not return an XRPL address");
|
|
8909
|
+
if (!accountAddress) throw new Error("GemWallet did not return an XRPL address");
|
|
8966
8910
|
return { account: { address: accountAddress, publicKey: publicKey == null ? void 0 : publicKey.publicKey, network: options.network, networkType: this.networkName((_c = network == null ? void 0 : network.result) == null ? void 0 : _c.network) }, raw: { address, publicKey: publicKey == null ? void 0 : publicKey.raw, network } };
|
|
8967
8911
|
}
|
|
8968
8912
|
async restoreSession(session) {
|
|
8969
|
-
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500))
|
|
8970
|
-
return null;
|
|
8913
|
+
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500)) return null;
|
|
8971
8914
|
const provider = this.getProvider();
|
|
8972
8915
|
const address = await this.getCurrentAddress(provider);
|
|
8973
|
-
if (!address || address.accountAddress !== session.account.address)
|
|
8974
|
-
return null;
|
|
8916
|
+
if (!address || address.accountAddress !== session.account.address) return null;
|
|
8975
8917
|
return {
|
|
8976
8918
|
account: { ...session.account, address: address.accountAddress },
|
|
8977
8919
|
session: { ...session, account: { ...session.account, address: address.accountAddress } },
|
|
@@ -8981,15 +8923,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
8981
8923
|
async signMessage(request) {
|
|
8982
8924
|
var _a2, _b, _c;
|
|
8983
8925
|
const provider = this.getProvider();
|
|
8984
|
-
if (!provider.signMessage)
|
|
8985
|
-
throw new Error("GemWallet provider is missing signMessage()");
|
|
8926
|
+
if (!provider.signMessage) throw new Error("GemWallet provider is missing signMessage()");
|
|
8986
8927
|
const [result, resolvedPublicKey] = await Promise.all([
|
|
8987
8928
|
provider.signMessage(request.message),
|
|
8988
8929
|
((_a2 = request.account) == null ? void 0 : _a2.publicKey) ? Promise.resolve(void 0) : this.getPublicKey(provider)
|
|
8989
8930
|
]);
|
|
8990
8931
|
const signature = (_b = result == null ? void 0 : result.result) == null ? void 0 : _b.signedMessage;
|
|
8991
|
-
if (typeof signature !== "string" || !signature)
|
|
8992
|
-
throw createWalletError.signRejected(result);
|
|
8932
|
+
if (typeof signature !== "string" || !signature) throw createWalletError.signRejected(result);
|
|
8993
8933
|
return {
|
|
8994
8934
|
signatureKind: "signature",
|
|
8995
8935
|
proof: signature,
|
|
@@ -9008,23 +8948,16 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9008
8948
|
resolveMethodHint(request) {
|
|
9009
8949
|
if (request.methodHint && request.methodHint !== "generic") {
|
|
9010
8950
|
const hint = String(request.methodHint);
|
|
9011
|
-
if (["trustset", "trustSet", "setTrustline", "trustline", "trustLine"].includes(hint))
|
|
9012
|
-
return "setTrustline";
|
|
8951
|
+
if (["trustset", "trustSet", "setTrustline", "trustline", "trustLine"].includes(hint)) return "setTrustline";
|
|
9013
8952
|
return request.methodHint;
|
|
9014
8953
|
}
|
|
9015
8954
|
const transactionType = request.txJson.TransactionType;
|
|
9016
|
-
if (transactionType === "Payment")
|
|
9017
|
-
|
|
9018
|
-
if (transactionType === "
|
|
9019
|
-
|
|
9020
|
-
if (transactionType === "
|
|
9021
|
-
|
|
9022
|
-
if (transactionType === "NFTokenCancelOffer")
|
|
9023
|
-
return "cancelNFTOffer";
|
|
9024
|
-
if (transactionType === "NFTokenBurn")
|
|
9025
|
-
return "burnNFT";
|
|
9026
|
-
if (transactionType === "TrustSet")
|
|
9027
|
-
return "setTrustline";
|
|
8955
|
+
if (transactionType === "Payment") return "payment";
|
|
8956
|
+
if (transactionType === "NFTokenCreateOffer") return "createNFTOffer";
|
|
8957
|
+
if (transactionType === "NFTokenAcceptOffer") return "acceptNFTOffer";
|
|
8958
|
+
if (transactionType === "NFTokenCancelOffer") return "cancelNFTOffer";
|
|
8959
|
+
if (transactionType === "NFTokenBurn") return "burnNFT";
|
|
8960
|
+
if (transactionType === "TrustSet") return "setTrustline";
|
|
9028
8961
|
return request.methodHint ?? "generic";
|
|
9029
8962
|
}
|
|
9030
8963
|
toGemWalletPaymentPayload(txJson) {
|
|
@@ -9032,12 +8965,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9032
8965
|
amount: txJson.Amount,
|
|
9033
8966
|
destination: txJson.Destination
|
|
9034
8967
|
};
|
|
9035
|
-
if (txJson.DestinationTag !== void 0)
|
|
9036
|
-
|
|
9037
|
-
if (txJson.
|
|
9038
|
-
payload.invoiceID = txJson.InvoiceID;
|
|
9039
|
-
if (txJson.Memos !== void 0)
|
|
9040
|
-
payload.memos = this.toGemWalletMemos(txJson.Memos);
|
|
8968
|
+
if (txJson.DestinationTag !== void 0) payload.destinationTag = txJson.DestinationTag;
|
|
8969
|
+
if (txJson.InvoiceID !== void 0) payload.invoiceID = txJson.InvoiceID;
|
|
8970
|
+
if (txJson.Memos !== void 0) payload.memos = this.toGemWalletMemos(txJson.Memos);
|
|
9041
8971
|
return Object.fromEntries(Object.entries(payload).filter(([, value]) => value !== void 0));
|
|
9042
8972
|
}
|
|
9043
8973
|
toGemWalletBurnNFTPayload(txJson) {
|
|
@@ -9068,8 +8998,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9068
8998
|
return Object.fromEntries(Object.entries(payload).filter(([, value]) => value !== void 0));
|
|
9069
8999
|
}
|
|
9070
9000
|
toGemWalletMemos(memos) {
|
|
9071
|
-
if (!Array.isArray(memos))
|
|
9072
|
-
return memos;
|
|
9001
|
+
if (!Array.isArray(memos)) return memos;
|
|
9073
9002
|
return memos.map((item) => {
|
|
9074
9003
|
const memo = this.getRecord(this.getRecord(item).Memo);
|
|
9075
9004
|
return {
|
|
@@ -9086,8 +9015,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9086
9015
|
}
|
|
9087
9016
|
getProvider(required = true) {
|
|
9088
9017
|
const provider = this.options.provider ?? GemWalletApi;
|
|
9089
|
-
if (!provider && required)
|
|
9090
|
-
throw new Error("GemWallet provider is not available");
|
|
9018
|
+
if (!provider && required) throw new Error("GemWallet provider is not available");
|
|
9091
9019
|
return provider;
|
|
9092
9020
|
}
|
|
9093
9021
|
hasInjectedProvider() {
|
|
@@ -9095,8 +9023,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9095
9023
|
}
|
|
9096
9024
|
async getCurrentAddress(provider) {
|
|
9097
9025
|
var _a2;
|
|
9098
|
-
if (!provider.getAddress)
|
|
9099
|
-
return void 0;
|
|
9026
|
+
if (!provider.getAddress) return void 0;
|
|
9100
9027
|
try {
|
|
9101
9028
|
const raw = await provider.getAddress();
|
|
9102
9029
|
const accountAddress = (_a2 = raw.result) == null ? void 0 : _a2.address;
|
|
@@ -9106,14 +9033,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9106
9033
|
}
|
|
9107
9034
|
}
|
|
9108
9035
|
async getPublicKey(provider) {
|
|
9109
|
-
if (!provider.getPublicKey)
|
|
9110
|
-
return void 0;
|
|
9036
|
+
if (!provider.getPublicKey) return void 0;
|
|
9111
9037
|
try {
|
|
9112
9038
|
const raw = await provider.getPublicKey();
|
|
9113
9039
|
const payload = raw && typeof raw === "object" && "result" in raw ? raw.result : raw;
|
|
9114
9040
|
const record = payload && typeof payload === "object" ? payload : void 0;
|
|
9115
|
-
if (!record)
|
|
9116
|
-
return { raw };
|
|
9041
|
+
if (!record) return { raw };
|
|
9117
9042
|
const publicKey = typeof record.publicKey === "string" && record.publicKey ? record.publicKey : void 0;
|
|
9118
9043
|
const address = typeof record.address === "string" && record.address ? record.address : void 0;
|
|
9119
9044
|
return publicKey || address ? { publicKey, address, raw } : { raw };
|
|
@@ -9126,61 +9051,57 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9126
9051
|
}
|
|
9127
9052
|
booleanResult(result, key) {
|
|
9128
9053
|
var _a2;
|
|
9129
|
-
if (typeof result === "boolean")
|
|
9130
|
-
|
|
9131
|
-
if (typeof (result == null ? void 0 : result.result) === "boolean")
|
|
9132
|
-
return result.result;
|
|
9054
|
+
if (typeof result === "boolean") return result;
|
|
9055
|
+
if (typeof (result == null ? void 0 : result.result) === "boolean") return result.result;
|
|
9133
9056
|
return Boolean((_a2 = result == null ? void 0 : result.result) == null ? void 0 : _a2[key]);
|
|
9134
9057
|
}
|
|
9135
9058
|
networkName(network) {
|
|
9136
9059
|
return typeof network === "string" ? network : network == null ? void 0 : network.name;
|
|
9137
9060
|
}
|
|
9138
9061
|
withAbort(promise, signal) {
|
|
9139
|
-
if (!signal)
|
|
9140
|
-
|
|
9141
|
-
if (signal.aborted)
|
|
9142
|
-
return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
9062
|
+
if (!signal) return promise;
|
|
9063
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
9143
9064
|
return new Promise((resolve, reject) => {
|
|
9144
9065
|
let settled = false;
|
|
9145
9066
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
9146
9067
|
const abort = () => {
|
|
9147
|
-
if (settled)
|
|
9148
|
-
return;
|
|
9068
|
+
if (settled) return;
|
|
9149
9069
|
settled = true;
|
|
9150
9070
|
cleanup();
|
|
9151
9071
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
9152
9072
|
};
|
|
9153
9073
|
signal.addEventListener("abort", abort, { once: true });
|
|
9154
|
-
promise.then(
|
|
9155
|
-
|
|
9156
|
-
return;
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
return;
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9074
|
+
promise.then(
|
|
9075
|
+
(value) => {
|
|
9076
|
+
if (settled) return;
|
|
9077
|
+
settled = true;
|
|
9078
|
+
cleanup();
|
|
9079
|
+
resolve(value);
|
|
9080
|
+
},
|
|
9081
|
+
(error) => {
|
|
9082
|
+
if (settled) return;
|
|
9083
|
+
settled = true;
|
|
9084
|
+
cleanup();
|
|
9085
|
+
reject(error);
|
|
9086
|
+
}
|
|
9087
|
+
);
|
|
9167
9088
|
});
|
|
9168
9089
|
}
|
|
9169
9090
|
}
|
|
9170
9091
|
function createGemWalletAdapter(options) {
|
|
9171
9092
|
return new GemWalletAdapter(options);
|
|
9172
9093
|
}
|
|
9173
|
-
const LEDGER_ICON = "data:image/svg+xml;base64,
|
|
9094
|
+
const LEDGER_ICON = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzAwMCIgZD0iTTAgMGgyOHYyOEgweiIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjY1IDQuNEg0LjRWOWgxLjFWNS41bDYuMTUtLjA0VjQuNFptLjA1IDUuOTV2Ny4yNWg0LjZ2LTEuMWgtMy41bC0uMDQtNi4xNUgxMS43Wk00LjQgMjMuNmg3LjI1di0xLjA2TDUuNSAyMi41VjE5SDQuNHY0LjZaTTE2LjM1IDQuNGg3LjI1VjloLTEuMVY1LjVsLTYuMTUtLjA0VjQuNFptNy4yNSAxOS4yaC03LjI1di0xLjA2bDYuMTUtLjA0VjE5aDEuMXY0LjZaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=";
|
|
9174
9095
|
const DEFAULT_TIMEOUT = 6e4;
|
|
9175
9096
|
const DEFAULT_ACCOUNT_INDEX = 0;
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
})(
|
|
9097
|
+
var LedgerDeviceState = /* @__PURE__ */ ((LedgerDeviceState2) => {
|
|
9098
|
+
LedgerDeviceState2["NOT_CONNECTED"] = "NOT_CONNECTED";
|
|
9099
|
+
LedgerDeviceState2["LOCKED"] = "LOCKED";
|
|
9100
|
+
LedgerDeviceState2["APP_NOT_OPEN"] = "APP_NOT_OPEN";
|
|
9101
|
+
LedgerDeviceState2["READY"] = "READY";
|
|
9102
|
+
LedgerDeviceState2["UNKNOWN"] = "UNKNOWN";
|
|
9103
|
+
return LedgerDeviceState2;
|
|
9104
|
+
})(LedgerDeviceState || {});
|
|
9184
9105
|
class LedgerAdapter extends BaseWalletAdapter {
|
|
9185
9106
|
constructor(options = {}) {
|
|
9186
9107
|
super();
|
|
@@ -9245,8 +9166,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9245
9166
|
this.network = void 0;
|
|
9246
9167
|
}
|
|
9247
9168
|
async signAndSubmit(request) {
|
|
9248
|
-
if (!this.session)
|
|
9249
|
-
throw createWalletError.notConnected();
|
|
9169
|
+
if (!this.session) throw createWalletError.notConnected();
|
|
9250
9170
|
try {
|
|
9251
9171
|
const result = await this.session.signTransaction(request.txJson, request.submit ?? true);
|
|
9252
9172
|
return {
|
|
@@ -9263,8 +9183,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9263
9183
|
}
|
|
9264
9184
|
}
|
|
9265
9185
|
async signTransaction(request) {
|
|
9266
|
-
if (!this.session)
|
|
9267
|
-
throw createWalletError.notConnected();
|
|
9186
|
+
if (!this.session) throw createWalletError.notConnected();
|
|
9268
9187
|
try {
|
|
9269
9188
|
const result = await this.session.signTransaction(request.txJson, false);
|
|
9270
9189
|
return {
|
|
@@ -9287,7 +9206,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9287
9206
|
const accounts = [];
|
|
9288
9207
|
for (let index2 = startIndex; index2 < startIndex + count; index2 += 1) {
|
|
9289
9208
|
const path = getDerivationPath(index2);
|
|
9290
|
-
const account = await this.withTimeout(
|
|
9209
|
+
const account = await this.withTimeout(
|
|
9210
|
+
this.xrp.getAddress(path, false, false),
|
|
9211
|
+
"Ledger account lookup timeout. Please check your Ledger device."
|
|
9212
|
+
);
|
|
9291
9213
|
accounts.push({
|
|
9292
9214
|
address: account.address,
|
|
9293
9215
|
publicKey: account.publicKey,
|
|
@@ -9299,8 +9221,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9299
9221
|
} catch (error) {
|
|
9300
9222
|
throw this.mapConnectionError(error);
|
|
9301
9223
|
} finally {
|
|
9302
|
-
if (cleanupAfter)
|
|
9303
|
-
await this.cleanup();
|
|
9224
|
+
if (cleanupAfter) await this.cleanup();
|
|
9304
9225
|
}
|
|
9305
9226
|
}
|
|
9306
9227
|
async connectDefaultLedger() {
|
|
@@ -9311,9 +9232,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9311
9232
|
this.transport = await this.createTransport();
|
|
9312
9233
|
const Xrp2 = await loadLedgerXrpApp();
|
|
9313
9234
|
this.xrp = new Xrp2(this.transport);
|
|
9314
|
-
const account = await this.withTimeout(
|
|
9315
|
-
|
|
9316
|
-
|
|
9235
|
+
const account = await this.withTimeout(
|
|
9236
|
+
this.xrp.getAddress(this.derivationPath, false, false),
|
|
9237
|
+
"Ledger connection timeout. Please check your Ledger device."
|
|
9238
|
+
);
|
|
9239
|
+
if (!account.address) throw new Error("Ledger did not return an XRPL address");
|
|
9317
9240
|
return {
|
|
9318
9241
|
address: account.address,
|
|
9319
9242
|
publicKey: account.publicKey,
|
|
@@ -9322,10 +9245,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9322
9245
|
};
|
|
9323
9246
|
}
|
|
9324
9247
|
async signWithDefaultLedger(tx, submit2 = true) {
|
|
9325
|
-
if (!this.xrp || !this.session)
|
|
9326
|
-
|
|
9327
|
-
if (!this.network)
|
|
9328
|
-
throw createWalletError.connectionFailed(this.metadata.name, new Error("XRPL network is required for Ledger signing"));
|
|
9248
|
+
if (!this.xrp || !this.session) throw createWalletError.notConnected();
|
|
9249
|
+
if (!this.network) throw createWalletError.connectionFailed(this.metadata.name, new Error("XRPL network is required for Ledger signing"));
|
|
9329
9250
|
const { Client, encode: encode2 } = await Promise.resolve().then(() => index$4);
|
|
9330
9251
|
const client2 = new Client(this.network.rpcUrl);
|
|
9331
9252
|
await client2.connect();
|
|
@@ -9341,9 +9262,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9341
9262
|
const publicKey = this.session.publicKey ?? (await this.xrp.getAddress(this.derivationPath, false, false)).publicKey;
|
|
9342
9263
|
txForSigning.SigningPubKey = publicKey.toUpperCase();
|
|
9343
9264
|
const signingBlob = encode2(txForSigning).toUpperCase();
|
|
9344
|
-
const signature = await this.withTimeout(
|
|
9345
|
-
|
|
9346
|
-
|
|
9265
|
+
const signature = await this.withTimeout(
|
|
9266
|
+
this.xrp.signTransaction(this.derivationPath, signingBlob),
|
|
9267
|
+
"Ledger signing timeout. Please confirm the transaction on your Ledger device."
|
|
9268
|
+
);
|
|
9269
|
+
if (!signature) throw new Error("Ledger did not return a transaction signature");
|
|
9347
9270
|
const signedTx = {
|
|
9348
9271
|
...txForSigning,
|
|
9349
9272
|
TxnSignature: signature.toUpperCase()
|
|
@@ -9372,60 +9295,49 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9372
9295
|
}
|
|
9373
9296
|
async createTransport() {
|
|
9374
9297
|
const support = getLedgerBrowserSupport();
|
|
9375
|
-
if (!support.supported)
|
|
9376
|
-
throw createWalletError.walletNotAvailable("Ledger", new Error(support.message));
|
|
9298
|
+
if (!support.supported) throw createWalletError.walletNotAvailable("Ledger", new Error(support.message));
|
|
9377
9299
|
if (this.options.preferWebHID !== false && support.webHID) {
|
|
9378
9300
|
try {
|
|
9379
9301
|
return await createWebHIDTransport();
|
|
9380
9302
|
} catch (error) {
|
|
9381
|
-
if (!support.webUSB)
|
|
9382
|
-
throw error;
|
|
9303
|
+
if (!support.webUSB) throw error;
|
|
9383
9304
|
}
|
|
9384
9305
|
}
|
|
9385
9306
|
if (support.webUSB) {
|
|
9386
9307
|
try {
|
|
9387
9308
|
return await createWebUSBTransport();
|
|
9388
9309
|
} catch (error) {
|
|
9389
|
-
if (!support.webHID || this.options.preferWebHID !== false)
|
|
9390
|
-
throw error;
|
|
9310
|
+
if (!support.webHID || this.options.preferWebHID !== false) throw error;
|
|
9391
9311
|
}
|
|
9392
9312
|
}
|
|
9393
|
-
if (support.webHID)
|
|
9394
|
-
return createWebHIDTransport();
|
|
9313
|
+
if (support.webHID) return createWebHIDTransport();
|
|
9395
9314
|
throw createWalletError.walletNotAvailable("Ledger", new Error("No compatible Ledger transport is available"));
|
|
9396
9315
|
}
|
|
9397
9316
|
async cleanup() {
|
|
9398
9317
|
const transport = this.transport;
|
|
9399
9318
|
this.transport = void 0;
|
|
9400
9319
|
this.xrp = void 0;
|
|
9401
|
-
if (!transport)
|
|
9402
|
-
return;
|
|
9320
|
+
if (!transport) return;
|
|
9403
9321
|
try {
|
|
9404
9322
|
await transport.close();
|
|
9405
9323
|
} catch {
|
|
9406
9324
|
}
|
|
9407
9325
|
}
|
|
9408
9326
|
mapConnectionError(error) {
|
|
9409
|
-
if (isWalletKitErrorLike(error))
|
|
9410
|
-
return error;
|
|
9327
|
+
if (isWalletKitErrorLike(error)) return error;
|
|
9411
9328
|
const parsed = parseLedgerError(error);
|
|
9412
|
-
if (parsed.timeout)
|
|
9413
|
-
|
|
9414
|
-
if (parsed.
|
|
9415
|
-
return createWalletError.connectionRejected(this.metadata.name, error);
|
|
9416
|
-
if (parsed.state === exports.LedgerDeviceState.NOT_CONNECTED) {
|
|
9329
|
+
if (parsed.timeout) return createWalletError.requestTimeout(parsed.message, error);
|
|
9330
|
+
if (parsed.rejected) return createWalletError.connectionRejected(this.metadata.name, error);
|
|
9331
|
+
if (parsed.state === "NOT_CONNECTED") {
|
|
9417
9332
|
return createWalletError.walletNotAvailable(this.metadata.name, new Error(parsed.message));
|
|
9418
9333
|
}
|
|
9419
9334
|
return createWalletError.connectionFailed(this.metadata.name, new Error(parsed.message));
|
|
9420
9335
|
}
|
|
9421
9336
|
mapSigningError(error) {
|
|
9422
|
-
if (isWalletKitErrorLike(error))
|
|
9423
|
-
return error;
|
|
9337
|
+
if (isWalletKitErrorLike(error)) return error;
|
|
9424
9338
|
const parsed = parseLedgerError(error);
|
|
9425
|
-
if (parsed.timeout)
|
|
9426
|
-
|
|
9427
|
-
if (parsed.rejected)
|
|
9428
|
-
return createWalletError.signRejected(error);
|
|
9339
|
+
if (parsed.timeout) return createWalletError.requestTimeout(parsed.message, error);
|
|
9340
|
+
if (parsed.rejected) return createWalletError.signRejected(error);
|
|
9429
9341
|
return createWalletError.signFailed(new Error(parsed.message));
|
|
9430
9342
|
}
|
|
9431
9343
|
async withTimeout(promise, message) {
|
|
@@ -9439,8 +9351,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9439
9351
|
})
|
|
9440
9352
|
]);
|
|
9441
9353
|
} finally {
|
|
9442
|
-
if (timer)
|
|
9443
|
-
clearTimeout(timer);
|
|
9354
|
+
if (timer) clearTimeout(timer);
|
|
9444
9355
|
}
|
|
9445
9356
|
}
|
|
9446
9357
|
}
|
|
@@ -9477,27 +9388,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9477
9388
|
const statusCode = getLedgerStatusCode(error);
|
|
9478
9389
|
const lower = message.toLowerCase();
|
|
9479
9390
|
if (statusCode === 27013 || /reject|denied|cancelled|canceled|closed|access denied/.test(lower)) {
|
|
9480
|
-
return { state:
|
|
9391
|
+
return { state: "READY", message: message || "Ledger request was rejected", rejected: true, timeout: false };
|
|
9481
9392
|
}
|
|
9482
9393
|
if (/timeout|timed out/.test(lower)) {
|
|
9483
|
-
return { state:
|
|
9394
|
+
return { state: "UNKNOWN", message: message || "Ledger request timed out", rejected: false, timeout: true };
|
|
9484
9395
|
}
|
|
9485
9396
|
if (statusCode === 26628 || /locked|pin/.test(lower)) {
|
|
9486
|
-
return { state:
|
|
9397
|
+
return { state: "LOCKED", message: "Ledger is locked. Please unlock your Ledger device.", rejected: false, timeout: false };
|
|
9487
9398
|
}
|
|
9488
9399
|
if ([28160, 25873, 25871].includes(statusCode ?? 0) || /app.*open|xrp.*app|cla_not_supported/.test(lower)) {
|
|
9489
|
-
return { state:
|
|
9400
|
+
return { state: "APP_NOT_OPEN", message: "Please open the XRP app on your Ledger device.", rejected: false, timeout: false };
|
|
9490
9401
|
}
|
|
9491
9402
|
if (/no device|not found|disconnected|cannot open device|transport/i.test(message)) {
|
|
9492
|
-
return { state:
|
|
9403
|
+
return { state: "NOT_CONNECTED", message: "Ledger device not found. Please connect and unlock your Ledger device.", rejected: false, timeout: false };
|
|
9493
9404
|
}
|
|
9494
|
-
return { state:
|
|
9405
|
+
return { state: "UNKNOWN", message: message || "Unknown Ledger error", rejected: false, timeout: false };
|
|
9495
9406
|
}
|
|
9496
9407
|
function getLedgerErrorMessage(error) {
|
|
9497
|
-
if (error instanceof Error)
|
|
9498
|
-
|
|
9499
|
-
if (typeof error === "string")
|
|
9500
|
-
return error;
|
|
9408
|
+
if (error instanceof Error) return error.message;
|
|
9409
|
+
if (typeof error === "string") return error;
|
|
9501
9410
|
try {
|
|
9502
9411
|
return JSON.stringify(error);
|
|
9503
9412
|
} catch {
|
|
@@ -9505,8 +9414,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9505
9414
|
}
|
|
9506
9415
|
}
|
|
9507
9416
|
function getLedgerStatusCode(error) {
|
|
9508
|
-
if (!error || typeof error !== "object")
|
|
9509
|
-
return void 0;
|
|
9417
|
+
if (!error || typeof error !== "object") return void 0;
|
|
9510
9418
|
const value = error.statusCode ?? error.status;
|
|
9511
9419
|
return typeof value === "number" ? value : void 0;
|
|
9512
9420
|
}
|
|
@@ -9604,12 +9512,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9604
9512
|
icon: BIFROST_ICON
|
|
9605
9513
|
}
|
|
9606
9514
|
];
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
})(
|
|
9515
|
+
var XRPLWalletConnectMethod = /* @__PURE__ */ ((XRPLWalletConnectMethod2) => {
|
|
9516
|
+
XRPLWalletConnectMethod2["SIGN_TRANSACTION"] = "xrpl_signTransaction";
|
|
9517
|
+
XRPLWalletConnectMethod2["SIGN_TRANSACTION_FOR"] = "xrpl_signTransactionFor";
|
|
9518
|
+
XRPLWalletConnectMethod2["SIGN_MESSAGE"] = "xrpl_signMessage";
|
|
9519
|
+
return XRPLWalletConnectMethod2;
|
|
9520
|
+
})(XRPLWalletConnectMethod || {});
|
|
9613
9521
|
const WALLETCONNECT_ICON = WALLETCONNECT_ICON$1;
|
|
9614
9522
|
const XRPL_NAMESPACE = "xrpl";
|
|
9615
9523
|
const USER_DISCONNECTED = { code: 6e3, message: "User disconnected" };
|
|
@@ -9619,8 +9527,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9619
9527
|
const WALLETCONNECT_REQUEST_TIMEOUT_CODE = "WALLETCONNECT_REQUEST_TIMEOUT";
|
|
9620
9528
|
function isMobile$1() {
|
|
9621
9529
|
var _a2;
|
|
9622
|
-
if (typeof navigator === "undefined")
|
|
9623
|
-
return false;
|
|
9530
|
+
if (typeof navigator === "undefined") return false;
|
|
9624
9531
|
const userAgent = navigator.userAgent;
|
|
9625
9532
|
const platform = navigator.platform;
|
|
9626
9533
|
const maxTouchPoints = navigator.maxTouchPoints ?? 0;
|
|
@@ -9668,8 +9575,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9668
9575
|
}
|
|
9669
9576
|
async preInitialize(network) {
|
|
9670
9577
|
var _a2, _b, _c, _d;
|
|
9671
|
-
if (this.pendingConnection)
|
|
9672
|
-
return;
|
|
9578
|
+
if (this.pendingConnection) return;
|
|
9673
9579
|
try {
|
|
9674
9580
|
const client2 = await this.getClient();
|
|
9675
9581
|
const resolvedNetwork = this.requireNetwork(network);
|
|
@@ -9741,10 +9647,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9741
9647
|
const client2 = await this.getClient();
|
|
9742
9648
|
const topic = typeof ((_a2 = session.metadata) == null ? void 0 : _a2.topic) === "string" ? session.metadata.topic : void 0;
|
|
9743
9649
|
const restoredSession = this.findStoredWalletConnectSession(client2, topic, network, session.account.address);
|
|
9744
|
-
if (!restoredSession)
|
|
9745
|
-
|
|
9746
|
-
if (restoredSession.expiry && restoredSession.expiry * 1e3 <= Date.now())
|
|
9747
|
-
return null;
|
|
9650
|
+
if (!restoredSession) return null;
|
|
9651
|
+
if (restoredSession.expiry && restoredSession.expiry * 1e3 <= Date.now()) return null;
|
|
9748
9652
|
this.session = restoredSession;
|
|
9749
9653
|
this.activeNetwork = network;
|
|
9750
9654
|
this.setupEventListeners();
|
|
@@ -9763,8 +9667,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9763
9667
|
}
|
|
9764
9668
|
async recoverSession(options) {
|
|
9765
9669
|
const network = this.requireNetwork(options.network);
|
|
9766
|
-
if (!await this.canRecoverSession())
|
|
9767
|
-
return null;
|
|
9670
|
+
if (!await this.canRecoverSession()) return null;
|
|
9768
9671
|
const client2 = await this.getClient();
|
|
9769
9672
|
const recoveredSession = this.findLatestStoredWalletConnectSession(client2, network);
|
|
9770
9673
|
this.debug("recover_session_check", "modal", {
|
|
@@ -9772,8 +9675,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9772
9675
|
recovered: Boolean(recoveredSession),
|
|
9773
9676
|
network: network.id
|
|
9774
9677
|
});
|
|
9775
|
-
if (!recoveredSession)
|
|
9776
|
-
return null;
|
|
9678
|
+
if (!recoveredSession) return null;
|
|
9777
9679
|
this.clearPendingRecoveryMarker();
|
|
9778
9680
|
this.session = recoveredSession;
|
|
9779
9681
|
this.activeNetwork = network;
|
|
@@ -9796,8 +9698,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9796
9698
|
return this.shouldRecoverWithoutStoredSession() && await this.hasPendingRecoveryMarker();
|
|
9797
9699
|
}
|
|
9798
9700
|
async disconnect() {
|
|
9799
|
-
if (!this.client || !this.session)
|
|
9800
|
-
return;
|
|
9701
|
+
if (!this.client || !this.session) return;
|
|
9801
9702
|
try {
|
|
9802
9703
|
await this.client.disconnect({
|
|
9803
9704
|
topic: this.session.topic,
|
|
@@ -9843,8 +9744,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9843
9744
|
getSignMessageRequestPreview(request) {
|
|
9844
9745
|
var _a2, _b;
|
|
9845
9746
|
const network = this.requireNetwork(this.activeNetwork);
|
|
9846
|
-
const method = this.sessionSupportsMethod(
|
|
9847
|
-
|
|
9747
|
+
const method = this.sessionSupportsMethod(
|
|
9748
|
+
"xrpl_signMessage"
|
|
9749
|
+
/* SIGN_MESSAGE */
|
|
9750
|
+
) ? "xrpl_signMessage" : "xrpl_signTransaction";
|
|
9751
|
+
const params = method === "xrpl_signMessage" ? {
|
|
9848
9752
|
message: request.message,
|
|
9849
9753
|
account: (_a2 = request.account) == null ? void 0 : _a2.address
|
|
9850
9754
|
} : {
|
|
@@ -9865,46 +9769,37 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9865
9769
|
return ((_b = (_a2 = this.options).deeplink) == null ? void 0 : _b.call(_a2, uri)) ?? uri;
|
|
9866
9770
|
}
|
|
9867
9771
|
findStoredWalletConnectSession(client2, topic, network, address) {
|
|
9868
|
-
if (!this.hasSessionStore(client2))
|
|
9869
|
-
return void 0;
|
|
9772
|
+
if (!this.hasSessionStore(client2)) return void 0;
|
|
9870
9773
|
if (topic) {
|
|
9871
9774
|
try {
|
|
9872
9775
|
const stored = client2.session.get(topic);
|
|
9873
|
-
if (this.sessionMatchesWalletProfile(stored) && this.sessionHasNetworkAccount(stored, network, address))
|
|
9874
|
-
return stored;
|
|
9776
|
+
if (this.sessionMatchesWalletProfile(stored) && this.sessionHasNetworkAccount(stored, network, address)) return stored;
|
|
9875
9777
|
} catch {
|
|
9876
9778
|
}
|
|
9877
9779
|
}
|
|
9878
9780
|
const sessions = client2.session.getAll();
|
|
9879
9781
|
return sessions.find((storedSession) => {
|
|
9880
9782
|
var _a2;
|
|
9881
|
-
if (!this.sessionMatchesWalletProfile(storedSession))
|
|
9882
|
-
return false;
|
|
9783
|
+
if (!this.sessionMatchesWalletProfile(storedSession)) return false;
|
|
9883
9784
|
const accounts = ((_a2 = storedSession.namespaces[XRPL_NAMESPACE]) == null ? void 0 : _a2.accounts) ?? [];
|
|
9884
9785
|
const chainId = this.requireWalletConnectChainId(network);
|
|
9885
9786
|
return accounts.some((account) => account === `${chainId}:${address}` || account.endsWith(`:${address}`));
|
|
9886
9787
|
});
|
|
9887
9788
|
}
|
|
9888
9789
|
findLatestStoredWalletConnectSession(client2, network) {
|
|
9889
|
-
if (!this.hasSessionStore(client2))
|
|
9890
|
-
return void 0;
|
|
9790
|
+
if (!this.hasSessionStore(client2)) return void 0;
|
|
9891
9791
|
const sessions = client2.session.getAll().filter((storedSession) => {
|
|
9892
|
-
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now())
|
|
9893
|
-
|
|
9894
|
-
if (!this.sessionMatchesWalletProfile(storedSession))
|
|
9895
|
-
return false;
|
|
9792
|
+
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now()) return false;
|
|
9793
|
+
if (!this.sessionMatchesWalletProfile(storedSession)) return false;
|
|
9896
9794
|
return this.sessionHasNetworkAccount(storedSession, network);
|
|
9897
9795
|
}).sort((a2, b2) => (b2.expiry ?? 0) - (a2.expiry ?? 0));
|
|
9898
9796
|
return sessions[0];
|
|
9899
9797
|
}
|
|
9900
9798
|
findLatestStoredWalletConnectSessionForAddress(client2, network, address) {
|
|
9901
|
-
if (!this.hasSessionStore(client2))
|
|
9902
|
-
return void 0;
|
|
9799
|
+
if (!this.hasSessionStore(client2)) return void 0;
|
|
9903
9800
|
const sessions = client2.session.getAll().filter((storedSession) => {
|
|
9904
|
-
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now())
|
|
9905
|
-
|
|
9906
|
-
if (!this.sessionMatchesWalletProfile(storedSession))
|
|
9907
|
-
return false;
|
|
9801
|
+
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now()) return false;
|
|
9802
|
+
if (!this.sessionMatchesWalletProfile(storedSession)) return false;
|
|
9908
9803
|
return this.sessionHasNetworkAccount(storedSession, network, address);
|
|
9909
9804
|
}).sort((a2, b2) => (b2.expiry ?? 0) - (a2.expiry ?? 0));
|
|
9910
9805
|
return sessions[0];
|
|
@@ -9913,8 +9808,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9913
9808
|
return this.metadata.type === "walletconnect";
|
|
9914
9809
|
}
|
|
9915
9810
|
async getClient() {
|
|
9916
|
-
if (this.client)
|
|
9917
|
-
return this.client;
|
|
9811
|
+
if (this.client) return this.client;
|
|
9918
9812
|
if (!this.initializationPromise) {
|
|
9919
9813
|
this.initializationPromise = Promise.resolve().then(() => index$2).then(({ default: SignClient }) => SignClient.init({
|
|
9920
9814
|
projectId: this.options.projectId,
|
|
@@ -9925,8 +9819,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9925
9819
|
return this.client;
|
|
9926
9820
|
}
|
|
9927
9821
|
async initializeModal() {
|
|
9928
|
-
if (this.modal)
|
|
9929
|
-
return this.modal;
|
|
9822
|
+
if (this.modal) return this.modal;
|
|
9930
9823
|
const { WalletConnectModal: WalletConnectModal2 } = await Promise.resolve().then(() => index$1);
|
|
9931
9824
|
this.modal = new WalletConnectModal2({
|
|
9932
9825
|
projectId: this.options.projectId,
|
|
@@ -9955,8 +9848,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9955
9848
|
}
|
|
9956
9849
|
this.pendingConnection = void 0;
|
|
9957
9850
|
this.throwIfAborted(signal);
|
|
9958
|
-
if (!connection2.uri)
|
|
9959
|
-
throw new Error("WalletConnect did not return a connection URI");
|
|
9851
|
+
if (!connection2.uri) throw new Error("WalletConnect did not return a connection URI");
|
|
9960
9852
|
let didOpen = false;
|
|
9961
9853
|
let rejectModalClose;
|
|
9962
9854
|
const modalClosed = new Promise((_2, reject) => {
|
|
@@ -10004,8 +9896,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10004
9896
|
optionalNamespaces: this.createOptionalNamespaces(network)
|
|
10005
9897
|
});
|
|
10006
9898
|
this.throwIfAborted(signal);
|
|
10007
|
-
if (!result.uri)
|
|
10008
|
-
throw new Error("WalletConnect did not return a connection URI");
|
|
9899
|
+
if (!result.uri) throw new Error("WalletConnect did not return a connection URI");
|
|
10009
9900
|
connection2 = { uri: result.uri, approval: result.approval, existingTopics };
|
|
10010
9901
|
}
|
|
10011
9902
|
this.throwIfAborted(signal);
|
|
@@ -10031,10 +9922,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10031
9922
|
let timeoutTimer;
|
|
10032
9923
|
let checkCount = 0;
|
|
10033
9924
|
const cleanup = () => {
|
|
10034
|
-
if (timer)
|
|
10035
|
-
|
|
10036
|
-
if (timeoutTimer)
|
|
10037
|
-
clearTimeout(timeoutTimer);
|
|
9925
|
+
if (timer) clearInterval(timer);
|
|
9926
|
+
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
10038
9927
|
if (typeof window !== "undefined") {
|
|
10039
9928
|
window.removeEventListener("focus", check);
|
|
10040
9929
|
window.removeEventListener("pageshow", check);
|
|
@@ -10042,8 +9931,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10042
9931
|
}
|
|
10043
9932
|
};
|
|
10044
9933
|
const settle = (callback) => {
|
|
10045
|
-
if (settled)
|
|
10046
|
-
return;
|
|
9934
|
+
if (settled) return;
|
|
10047
9935
|
settled = true;
|
|
10048
9936
|
cleanup();
|
|
10049
9937
|
callback();
|
|
@@ -10090,12 +9978,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10090
9978
|
});
|
|
10091
9979
|
check();
|
|
10092
9980
|
if (!settled) {
|
|
10093
|
-
if (!options.rejectOnApprovalError)
|
|
10094
|
-
return;
|
|
9981
|
+
if (!options.rejectOnApprovalError) return;
|
|
10095
9982
|
setTimeout(() => {
|
|
10096
9983
|
check();
|
|
10097
|
-
if (!settled)
|
|
10098
|
-
settle(() => reject(error));
|
|
9984
|
+
if (!settled) settle(() => reject(error));
|
|
10099
9985
|
}, 1500);
|
|
10100
9986
|
}
|
|
10101
9987
|
});
|
|
@@ -10123,10 +10009,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10123
10009
|
}
|
|
10124
10010
|
findNewWalletConnectSession(client2, network, existingTopics) {
|
|
10125
10011
|
return client2.session.getAll().find((storedSession) => {
|
|
10126
|
-
if (existingTopics.has(storedSession.topic))
|
|
10127
|
-
|
|
10128
|
-
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now())
|
|
10129
|
-
return false;
|
|
10012
|
+
if (existingTopics.has(storedSession.topic)) return false;
|
|
10013
|
+
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now()) return false;
|
|
10130
10014
|
return this.sessionHasNetworkAccount(storedSession, network);
|
|
10131
10015
|
});
|
|
10132
10016
|
}
|
|
@@ -10140,8 +10024,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10140
10024
|
});
|
|
10141
10025
|
}
|
|
10142
10026
|
throwIfAborted(signal) {
|
|
10143
|
-
if (signal == null ? void 0 : signal.aborted)
|
|
10144
|
-
throw new Error("WalletConnect connection was cancelled");
|
|
10027
|
+
if (signal == null ? void 0 : signal.aborted) throw new Error("WalletConnect connection was cancelled");
|
|
10145
10028
|
}
|
|
10146
10029
|
combineSignals(first, second) {
|
|
10147
10030
|
const controller = new AbortController();
|
|
@@ -10159,20 +10042,16 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10159
10042
|
const accounts = ((_a2 = session.namespaces[XRPL_NAMESPACE]) == null ? void 0 : _a2.accounts) ?? [];
|
|
10160
10043
|
const chainId = this.requireWalletConnectChainId(network);
|
|
10161
10044
|
return accounts.some((account) => {
|
|
10162
|
-
if (!account.startsWith(`${chainId}:`))
|
|
10163
|
-
return false;
|
|
10045
|
+
if (!account.startsWith(`${chainId}:`)) return false;
|
|
10164
10046
|
return !address || account === `${chainId}:${address}` || account.endsWith(`:${address}`);
|
|
10165
10047
|
});
|
|
10166
10048
|
}
|
|
10167
10049
|
sessionMatchesWalletProfile(session) {
|
|
10168
|
-
if (this.metadata.id === "walletconnect")
|
|
10169
|
-
return true;
|
|
10050
|
+
if (this.metadata.id === "walletconnect") return true;
|
|
10170
10051
|
const peerName = this.normalizeWalletName(this.getSessionPeerName(session));
|
|
10171
|
-
if (!peerName)
|
|
10172
|
-
return true;
|
|
10052
|
+
if (!peerName) return true;
|
|
10173
10053
|
const expectedName = this.normalizeWalletName(this.options.name ?? this.metadata.name);
|
|
10174
|
-
if (!expectedName)
|
|
10175
|
-
return true;
|
|
10054
|
+
if (!expectedName) return true;
|
|
10176
10055
|
return peerName === expectedName || peerName.includes(expectedName) || expectedName.includes(peerName);
|
|
10177
10056
|
}
|
|
10178
10057
|
getSessionPeerName(session) {
|
|
@@ -10192,9 +10071,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10192
10071
|
[XRPL_NAMESPACE]: {
|
|
10193
10072
|
chains: [chainId],
|
|
10194
10073
|
methods: [
|
|
10195
|
-
|
|
10074
|
+
"xrpl_signTransaction",
|
|
10196
10075
|
// moved from requiredNamespaces
|
|
10197
|
-
|
|
10076
|
+
"xrpl_signTransactionFor"
|
|
10077
|
+
/* SIGN_TRANSACTION_FOR */
|
|
10198
10078
|
],
|
|
10199
10079
|
events: []
|
|
10200
10080
|
}
|
|
@@ -10202,13 +10082,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10202
10082
|
}
|
|
10203
10083
|
async signMessageWithWalletConnectMethod(network, request) {
|
|
10204
10084
|
var _a2, _b, _c;
|
|
10205
|
-
if (!this.client || !this.session)
|
|
10206
|
-
throw new Error("WalletConnect session not found");
|
|
10085
|
+
if (!this.client || !this.session) throw new Error("WalletConnect session not found");
|
|
10207
10086
|
return this.withRequestTimeout(this.client.request({
|
|
10208
10087
|
chainId: this.requireWalletConnectChainId(network),
|
|
10209
10088
|
topic: this.session.topic,
|
|
10210
10089
|
request: {
|
|
10211
|
-
method:
|
|
10090
|
+
method: "xrpl_signMessage",
|
|
10212
10091
|
params: {
|
|
10213
10092
|
message: request.message,
|
|
10214
10093
|
account: (_a2 = request.account) == null ? void 0 : _a2.address,
|
|
@@ -10216,7 +10095,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10216
10095
|
from: (_c = request.account) == null ? void 0 : _c.address
|
|
10217
10096
|
}
|
|
10218
10097
|
}
|
|
10219
|
-
}),
|
|
10098
|
+
}), "xrpl_signMessage", this.getSignOnlyRequestTimeoutMs());
|
|
10220
10099
|
}
|
|
10221
10100
|
signatureResponsePaths() {
|
|
10222
10101
|
return [
|
|
@@ -10283,8 +10162,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10283
10162
|
}
|
|
10284
10163
|
async resolveTxBlobProof(result) {
|
|
10285
10164
|
const direct = this.pickString(result, this.txBlobResponsePaths());
|
|
10286
|
-
if (direct)
|
|
10287
|
-
return direct;
|
|
10165
|
+
if (direct) return direct;
|
|
10288
10166
|
const txJson = pickPath(result, [
|
|
10289
10167
|
"tx_json",
|
|
10290
10168
|
"txJson",
|
|
@@ -10302,10 +10180,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10302
10180
|
"response.data.resp.txJson",
|
|
10303
10181
|
"response.data.resp.transaction"
|
|
10304
10182
|
]);
|
|
10305
|
-
if (!txJson || typeof txJson !== "object")
|
|
10306
|
-
|
|
10307
|
-
if (!this.looksSignedTxJson(txJson))
|
|
10308
|
-
return void 0;
|
|
10183
|
+
if (!txJson || typeof txJson !== "object") return void 0;
|
|
10184
|
+
if (!this.looksSignedTxJson(txJson)) return void 0;
|
|
10309
10185
|
try {
|
|
10310
10186
|
const { encode: encode2 } = await Promise.resolve().then(() => index$4);
|
|
10311
10187
|
return encode2(txJson);
|
|
@@ -10318,8 +10194,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10318
10194
|
}
|
|
10319
10195
|
}
|
|
10320
10196
|
looksSignedTxJson(value) {
|
|
10321
|
-
if (!value || typeof value !== "object")
|
|
10322
|
-
return false;
|
|
10197
|
+
if (!value || typeof value !== "object") return false;
|
|
10323
10198
|
const tx = value;
|
|
10324
10199
|
return typeof tx.TransactionType === "string" && typeof tx.Account === "string" && typeof tx.SigningPubKey === "string" && typeof tx.TxnSignature === "string";
|
|
10325
10200
|
}
|
|
@@ -10343,37 +10218,34 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10343
10218
|
if (Array.isArray(value)) {
|
|
10344
10219
|
return value.map((item) => this.sanitizeWalletConnectPayload(item)).filter((item) => item !== void 0);
|
|
10345
10220
|
}
|
|
10346
|
-
if (!value || typeof value !== "object")
|
|
10347
|
-
return value;
|
|
10221
|
+
if (!value || typeof value !== "object") return value;
|
|
10348
10222
|
const output = {};
|
|
10349
10223
|
for (const [key, item] of Object.entries(value)) {
|
|
10350
|
-
if (item === void 0 || item === null)
|
|
10351
|
-
continue;
|
|
10224
|
+
if (item === void 0 || item === null) continue;
|
|
10352
10225
|
const sanitized = this.sanitizeWalletConnectPayload(item);
|
|
10353
|
-
if (sanitized !== void 0)
|
|
10354
|
-
output[key] = sanitized;
|
|
10226
|
+
if (sanitized !== void 0) output[key] = sanitized;
|
|
10355
10227
|
}
|
|
10356
10228
|
return output;
|
|
10357
10229
|
}
|
|
10358
10230
|
async requestSignTransaction(network, txJson, submit2) {
|
|
10359
|
-
if (!this.client || !this.session)
|
|
10360
|
-
throw new Error("WalletConnect session not found");
|
|
10231
|
+
if (!this.client || !this.session) throw new Error("WalletConnect session not found");
|
|
10361
10232
|
const params = { tx_json: txJson };
|
|
10362
|
-
if (!submit2)
|
|
10363
|
-
params.submit = false;
|
|
10233
|
+
if (!submit2) params.submit = false;
|
|
10364
10234
|
return this.withRequestTimeout(this.client.request({
|
|
10365
10235
|
chainId: this.requireWalletConnectChainId(network),
|
|
10366
10236
|
topic: this.session.topic,
|
|
10367
10237
|
request: {
|
|
10368
|
-
method:
|
|
10238
|
+
method: "xrpl_signTransaction",
|
|
10369
10239
|
params
|
|
10370
10240
|
}
|
|
10371
|
-
}),
|
|
10241
|
+
}), "xrpl_signTransaction", this.getTransactionRequestTimeoutMs(submit2));
|
|
10372
10242
|
}
|
|
10373
10243
|
async requestSignOnlyTransaction(network, txJson) {
|
|
10374
|
-
if (!this.client || !this.session)
|
|
10375
|
-
|
|
10376
|
-
|
|
10244
|
+
if (!this.client || !this.session) throw new Error("WalletConnect session not found");
|
|
10245
|
+
const method = this.sessionSupportsMethod(
|
|
10246
|
+
"xrpl_signTransactionFor"
|
|
10247
|
+
/* SIGN_TRANSACTION_FOR */
|
|
10248
|
+
) ? "xrpl_signTransactionFor" : "xrpl_signTransaction";
|
|
10377
10249
|
return this.withRequestTimeout(this.client.request({
|
|
10378
10250
|
chainId: this.requireWalletConnectChainId(network),
|
|
10379
10251
|
topic: this.session.topic,
|
|
@@ -10396,8 +10268,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10396
10268
|
return /missing or invalid.*request\(\).*method|method.*not.*supported|unsupported.*method/i.test(message);
|
|
10397
10269
|
}
|
|
10398
10270
|
requireSession() {
|
|
10399
|
-
if (!this.session)
|
|
10400
|
-
throw new Error("WalletConnect session not found");
|
|
10271
|
+
if (!this.session) throw new Error("WalletConnect session not found");
|
|
10401
10272
|
return this.session;
|
|
10402
10273
|
}
|
|
10403
10274
|
getSignOnlyRequestTimeoutMs() {
|
|
@@ -10424,7 +10295,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10424
10295
|
wallet: this.metadata.id,
|
|
10425
10296
|
timeoutMs
|
|
10426
10297
|
});
|
|
10427
|
-
const timeoutDetail = method ===
|
|
10298
|
+
const timeoutDetail = method === "xrpl_signTransaction" ? "The wallet may have submitted the transaction but did not return a response to the dApp." : "The wallet did not return a response to the dApp.";
|
|
10428
10299
|
const error = new Error(`WalletConnect request timed out after ${timeoutMs}ms: ${method}. ${timeoutDetail}`);
|
|
10429
10300
|
error.code = WALLETCONNECT_REQUEST_TIMEOUT_CODE;
|
|
10430
10301
|
reject(error);
|
|
@@ -10445,8 +10316,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10445
10316
|
}
|
|
10446
10317
|
throw error;
|
|
10447
10318
|
} finally {
|
|
10448
|
-
if (timer)
|
|
10449
|
-
clearTimeout(timer);
|
|
10319
|
+
if (timer) clearTimeout(timer);
|
|
10450
10320
|
}
|
|
10451
10321
|
}
|
|
10452
10322
|
async handleStaleWalletConnectRequest(method, error) {
|
|
@@ -10479,12 +10349,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10479
10349
|
async clearWalletConnectPairings() {
|
|
10480
10350
|
var _a2, _b;
|
|
10481
10351
|
const pairing = (_b = (_a2 = this.client) == null ? void 0 : _a2.core) == null ? void 0 : _b.pairing;
|
|
10482
|
-
if (!(pairing == null ? void 0 : pairing.getPairings) || !pairing.disconnect)
|
|
10483
|
-
return;
|
|
10352
|
+
if (!(pairing == null ? void 0 : pairing.getPairings) || !pairing.disconnect) return;
|
|
10484
10353
|
const pairings = pairing.getPairings();
|
|
10485
10354
|
for (const item of pairings) {
|
|
10486
|
-
if (!item.topic)
|
|
10487
|
-
continue;
|
|
10355
|
+
if (!item.topic) continue;
|
|
10488
10356
|
try {
|
|
10489
10357
|
await pairing.disconnect({ topic: item.topic });
|
|
10490
10358
|
} catch {
|
|
@@ -10492,38 +10360,32 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10492
10360
|
}
|
|
10493
10361
|
}
|
|
10494
10362
|
shouldUseModal() {
|
|
10495
|
-
if (!this.options.useModal || this.options.modalMode === "never")
|
|
10496
|
-
return false;
|
|
10363
|
+
if (!this.options.useModal || this.options.modalMode === "never") return false;
|
|
10497
10364
|
const mode2 = this.options.modalMode ?? "mobile-only";
|
|
10498
10365
|
return mode2 === "always" || mode2 === "mobile-only" && isMobile$1();
|
|
10499
10366
|
}
|
|
10500
10367
|
extractAddress(session, network) {
|
|
10501
10368
|
var _a2, _b;
|
|
10502
10369
|
const account = (_b = (_a2 = session.namespaces.xrpl) == null ? void 0 : _a2.accounts) == null ? void 0 : _b[0];
|
|
10503
|
-
if (!account)
|
|
10504
|
-
throw new Error("WalletConnect XRPL account not found in session");
|
|
10370
|
+
if (!account) throw new Error("WalletConnect XRPL account not found in session");
|
|
10505
10371
|
const parts = account.split(":");
|
|
10506
10372
|
const chainId = this.requireWalletConnectChainId(network);
|
|
10507
10373
|
return parts[2] ?? account.replace(`${chainId}:`, "");
|
|
10508
10374
|
}
|
|
10509
10375
|
setupEventListeners() {
|
|
10510
|
-
if (!this.client)
|
|
10511
|
-
return;
|
|
10376
|
+
if (!this.client) return;
|
|
10512
10377
|
void this.runCleanup();
|
|
10513
10378
|
const onSessionDelete = (event) => {
|
|
10514
10379
|
var _a2;
|
|
10515
|
-
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic))
|
|
10516
|
-
this.cleanup();
|
|
10380
|
+
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic)) this.cleanup();
|
|
10517
10381
|
};
|
|
10518
10382
|
const onSessionExpire = (event) => {
|
|
10519
10383
|
var _a2;
|
|
10520
|
-
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic))
|
|
10521
|
-
this.cleanup();
|
|
10384
|
+
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic)) this.cleanup();
|
|
10522
10385
|
};
|
|
10523
10386
|
const onSessionUpdate = (event) => {
|
|
10524
10387
|
var _a2, _b;
|
|
10525
|
-
if (!this.client || !(event == null ? void 0 : event.topic) || event.topic !== ((_a2 = this.session) == null ? void 0 : _a2.topic))
|
|
10526
|
-
return;
|
|
10388
|
+
if (!this.client || !(event == null ? void 0 : event.topic) || event.topic !== ((_a2 = this.session) == null ? void 0 : _a2.topic)) return;
|
|
10527
10389
|
try {
|
|
10528
10390
|
this.session = this.client.session.get(event.topic);
|
|
10529
10391
|
this.debug("session_update", "custom", { topic: event.topic });
|
|
@@ -10559,8 +10421,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10559
10421
|
if (currentTopic) {
|
|
10560
10422
|
try {
|
|
10561
10423
|
const stored = client2.session.get(currentTopic);
|
|
10562
|
-
if (this.sessionHasNetworkAccount(stored, network, address))
|
|
10563
|
-
refreshed = stored;
|
|
10424
|
+
if (this.sessionHasNetworkAccount(stored, network, address)) refreshed = stored;
|
|
10564
10425
|
} catch {
|
|
10565
10426
|
refreshed = void 0;
|
|
10566
10427
|
}
|
|
@@ -10585,7 +10446,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10585
10446
|
pairingTopic: refreshed.pairingTopic
|
|
10586
10447
|
});
|
|
10587
10448
|
this.session = refreshed;
|
|
10588
|
-
await this.handleStaleWalletConnectRequest(
|
|
10449
|
+
await this.handleStaleWalletConnectRequest("xrpl_signTransaction", new Error("WalletConnect session pairing not found"));
|
|
10589
10450
|
}
|
|
10590
10451
|
if (refreshed.topic !== ((_b = this.session) == null ? void 0 : _b.topic)) {
|
|
10591
10452
|
this.debug("request_session_refreshed", "custom", {
|
|
@@ -10604,11 +10465,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10604
10465
|
isSessionPairingStale(session) {
|
|
10605
10466
|
var _a2, _b;
|
|
10606
10467
|
const pairingTopic = session.pairingTopic;
|
|
10607
|
-
if (!pairingTopic)
|
|
10608
|
-
return false;
|
|
10468
|
+
if (!pairingTopic) return false;
|
|
10609
10469
|
const pairing = (_b = (_a2 = this.client) == null ? void 0 : _a2.core) == null ? void 0 : _b.pairing;
|
|
10610
|
-
if (!(pairing == null ? void 0 : pairing.getPairings))
|
|
10611
|
-
return false;
|
|
10470
|
+
if (!(pairing == null ? void 0 : pairing.getPairings)) return false;
|
|
10612
10471
|
try {
|
|
10613
10472
|
return !pairing.getPairings().some((item) => item.topic === pairingTopic);
|
|
10614
10473
|
} catch {
|
|
@@ -10633,8 +10492,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10633
10492
|
return `xwk.walletconnect.pending.${this.options.projectId}.${this.metadata.id}`;
|
|
10634
10493
|
}
|
|
10635
10494
|
async setPendingRecoveryMarker() {
|
|
10636
|
-
if (!this.shouldRecoverWithoutStoredSession())
|
|
10637
|
-
return;
|
|
10495
|
+
if (!this.shouldRecoverWithoutStoredSession()) return;
|
|
10638
10496
|
try {
|
|
10639
10497
|
await this.recoveryStorage.setItem(this.getPendingRecoveryKey(), String(Date.now()));
|
|
10640
10498
|
} catch {
|
|
@@ -10643,8 +10501,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10643
10501
|
async hasPendingRecoveryMarker() {
|
|
10644
10502
|
try {
|
|
10645
10503
|
const value = await this.recoveryStorage.getItem(this.getPendingRecoveryKey());
|
|
10646
|
-
if (!value)
|
|
10647
|
-
return false;
|
|
10504
|
+
if (!value) return false;
|
|
10648
10505
|
const timestamp = Number(value);
|
|
10649
10506
|
if (!Number.isFinite(timestamp) || Date.now() - timestamp > PENDING_RECOVERY_TTL_MS) {
|
|
10650
10507
|
this.clearPendingRecoveryMarker();
|
|
@@ -10662,8 +10519,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10662
10519
|
}
|
|
10663
10520
|
}
|
|
10664
10521
|
requireNetwork(network) {
|
|
10665
|
-
if (!network)
|
|
10666
|
-
throw new Error("XRPL network is required for WalletConnect");
|
|
10522
|
+
if (!network) throw new Error("XRPL network is required for WalletConnect");
|
|
10667
10523
|
return network;
|
|
10668
10524
|
}
|
|
10669
10525
|
requireWalletConnectChainId(network) {
|
|
@@ -10673,8 +10529,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10673
10529
|
return network.walletConnectChainId;
|
|
10674
10530
|
}
|
|
10675
10531
|
removeWalletConnectModalElements() {
|
|
10676
|
-
if (typeof document === "undefined")
|
|
10677
|
-
return;
|
|
10532
|
+
if (typeof document === "undefined") return;
|
|
10678
10533
|
window.setTimeout(() => {
|
|
10679
10534
|
document.querySelectorAll("wcm-modal").forEach((element) => element.remove());
|
|
10680
10535
|
}, 0);
|
|
@@ -15686,8 +15541,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15686
15541
|
await this.setPendingRecoveryMarker();
|
|
15687
15542
|
try {
|
|
15688
15543
|
const result = await this.withAbort(this.authorize(), options.signal);
|
|
15689
|
-
if (result instanceof Error)
|
|
15690
|
-
throw result;
|
|
15544
|
+
if (result instanceof Error) throw result;
|
|
15691
15545
|
const connectResult = await this.createConnectResultFromAuth(result, options);
|
|
15692
15546
|
this.clearPendingRecoveryMarker();
|
|
15693
15547
|
return connectResult;
|
|
@@ -15703,8 +15557,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15703
15557
|
this.auth = this.sdk;
|
|
15704
15558
|
}
|
|
15705
15559
|
const state2 = await this.checkXamanState({ network: session.account.network });
|
|
15706
|
-
if (!((_a2 = state2 == null ? void 0 : state2.account) == null ? void 0 : _a2.address) || state2.account.address !== session.account.address)
|
|
15707
|
-
return null;
|
|
15560
|
+
if (!((_a2 = state2 == null ? void 0 : state2.account) == null ? void 0 : _a2.address) || state2.account.address !== session.account.address) return null;
|
|
15708
15561
|
const account = ((_b = state2 == null ? void 0 : state2.account) == null ? void 0 : _b.address) ? { ...session.account, ...state2.account } : session.account;
|
|
15709
15562
|
return { account, session: { ...session, account }, raw: (state2 == null ? void 0 : state2.raw) ?? null };
|
|
15710
15563
|
}
|
|
@@ -15712,8 +15565,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15712
15565
|
return this.hasPendingRecoveryMarker();
|
|
15713
15566
|
}
|
|
15714
15567
|
async recoverSession(options) {
|
|
15715
|
-
if (!await this.hasPendingRecoveryMarker())
|
|
15716
|
-
return null;
|
|
15568
|
+
if (!await this.hasPendingRecoveryMarker()) return null;
|
|
15717
15569
|
try {
|
|
15718
15570
|
const result = await this.withAbort(this.authorize(), options.signal);
|
|
15719
15571
|
if (!result || result instanceof Error) {
|
|
@@ -15734,7 +15586,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15734
15586
|
async disconnect() {
|
|
15735
15587
|
var _a2;
|
|
15736
15588
|
try {
|
|
15737
|
-
const logoutTargets = [this.sdk, this.auth].filter(
|
|
15589
|
+
const logoutTargets = [this.sdk, this.auth].filter(
|
|
15590
|
+
(target, index2, targets) => Boolean(target) && targets.indexOf(target) === index2
|
|
15591
|
+
);
|
|
15738
15592
|
for (const target of logoutTargets) {
|
|
15739
15593
|
await ((_a2 = target.logout) == null ? void 0 : _a2.call(target));
|
|
15740
15594
|
}
|
|
@@ -15756,8 +15610,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15756
15610
|
options: { submit: false }
|
|
15757
15611
|
};
|
|
15758
15612
|
const result = await this.createAndResolvePayload(payload);
|
|
15759
|
-
if (!((_a2 = result == null ? void 0 : result.meta) == null ? void 0 : _a2.signed))
|
|
15760
|
-
throw createWalletError.signRejected(result);
|
|
15613
|
+
if (!((_a2 = result == null ? void 0 : result.meta) == null ? void 0 : _a2.signed)) throw createWalletError.signRejected(result);
|
|
15761
15614
|
return {
|
|
15762
15615
|
signatureKind: "signedTx",
|
|
15763
15616
|
proof: ((_b = result.response) == null ? void 0 : _b.hex) ?? void 0,
|
|
@@ -15780,13 +15633,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15780
15633
|
}
|
|
15781
15634
|
async checkXamanState(options = {}) {
|
|
15782
15635
|
var _a2, _b, _c, _d;
|
|
15783
|
-
if (!this.sdk)
|
|
15784
|
-
return null;
|
|
15636
|
+
if (!this.sdk) return null;
|
|
15785
15637
|
await this.waitForSdkReady(this.sdk);
|
|
15786
15638
|
const openid = await this.resolveSdkValue((_a2 = this.sdk.environment) == null ? void 0 : _a2.openid);
|
|
15787
15639
|
const accountAddress = await this.resolveSdkValue((_b = this.sdk.user) == null ? void 0 : _b.account) ?? ((_c = this.sdk.state) == null ? void 0 : _c.account) ?? (openid == null ? void 0 : openid.account) ?? (openid == null ? void 0 : openid.sub);
|
|
15788
|
-
if (!accountAddress)
|
|
15789
|
-
return null;
|
|
15640
|
+
if (!accountAddress) return null;
|
|
15790
15641
|
return {
|
|
15791
15642
|
account: {
|
|
15792
15643
|
address: accountAddress,
|
|
@@ -15800,28 +15651,24 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15800
15651
|
};
|
|
15801
15652
|
}
|
|
15802
15653
|
requireSdk() {
|
|
15803
|
-
if (!this.sdk)
|
|
15804
|
-
throw new Error("Xaman SDK is not available. Connect Xaman first.");
|
|
15654
|
+
if (!this.sdk) throw new Error("Xaman SDK is not available. Connect Xaman first.");
|
|
15805
15655
|
return this.sdk;
|
|
15806
15656
|
}
|
|
15807
15657
|
async authorize() {
|
|
15808
15658
|
if (!this.auth) {
|
|
15809
|
-
if (!this.options.apiKey)
|
|
15810
|
-
throw new Error("Xaman apiKey is required when auth is not injected");
|
|
15659
|
+
if (!this.options.apiKey) throw new Error("Xaman apiKey is required when auth is not injected");
|
|
15811
15660
|
this.sdk = new distExports.Xumm(this.options.apiKey);
|
|
15812
15661
|
this.auth = this.sdk;
|
|
15813
15662
|
}
|
|
15814
15663
|
const result = await this.auth.authorize();
|
|
15815
|
-
if (!result)
|
|
15816
|
-
throw new Error("Xaman authorization was cancelled");
|
|
15664
|
+
if (!result) throw new Error("Xaman authorization was cancelled");
|
|
15817
15665
|
return result;
|
|
15818
15666
|
}
|
|
15819
15667
|
async createConnectResultFromAuth(result, options) {
|
|
15820
15668
|
var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l;
|
|
15821
15669
|
this.sdk = result.sdk ?? this.sdk;
|
|
15822
15670
|
const accountAddress = ((_a2 = result.me) == null ? void 0 : _a2.sub) ?? ((_b = result.me) == null ? void 0 : _b.account) ?? await this.resolveSdkValue((_d = (_c = this.sdk) == null ? void 0 : _c.user) == null ? void 0 : _d.account) ?? ((_f = (_e2 = this.sdk) == null ? void 0 : _e2.state) == null ? void 0 : _f.account);
|
|
15823
|
-
if (!accountAddress)
|
|
15824
|
-
throw new Error("Xaman did not return an XRPL account");
|
|
15671
|
+
if (!accountAddress) throw new Error("Xaman did not return an XRPL account");
|
|
15825
15672
|
const networkType = ((_g = result.me) == null ? void 0 : _g.networkType) ?? await this.resolveSdkValue((_i = (_h = this.sdk) == null ? void 0 : _h.user) == null ? void 0 : _i.networkType);
|
|
15826
15673
|
const account = { address: accountAddress, network: options.network, networkType };
|
|
15827
15674
|
return {
|
|
@@ -15860,8 +15707,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15860
15707
|
emitPayloadQr(created) {
|
|
15861
15708
|
var _a2, _b, _c, _d, _e2, _f, _g, _h;
|
|
15862
15709
|
const uri = ((_a2 = created.next) == null ? void 0 : _a2.always) ?? ((_b = created.refs) == null ? void 0 : _b.qr_png);
|
|
15863
|
-
if (!uri)
|
|
15864
|
-
return;
|
|
15710
|
+
if (!uri) return;
|
|
15865
15711
|
(_h = (_g = this.options).onQr) == null ? void 0 : _h.call(_g, {
|
|
15866
15712
|
adapterId: this.metadata.id,
|
|
15867
15713
|
uri,
|
|
@@ -15879,8 +15725,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15879
15725
|
(_b = sdk.environment) == null ? void 0 : _b.retrieved,
|
|
15880
15726
|
(_c = sdk.environment) == null ? void 0 : _c.success
|
|
15881
15727
|
].filter((signal) => Boolean(signal));
|
|
15882
|
-
if (!readySignals.length)
|
|
15883
|
-
return;
|
|
15728
|
+
if (!readySignals.length) return;
|
|
15884
15729
|
await Promise.race([
|
|
15885
15730
|
Promise.race(readySignals).then(() => void 0),
|
|
15886
15731
|
new Promise((resolve) => setTimeout(resolve, XAMAN_RESTORE_READY_TIMEOUT_MS))
|
|
@@ -15888,42 +15733,39 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15888
15733
|
}
|
|
15889
15734
|
clearPkceStorage() {
|
|
15890
15735
|
var _a2;
|
|
15891
|
-
if (typeof window === "undefined")
|
|
15892
|
-
return;
|
|
15736
|
+
if (typeof window === "undefined") return;
|
|
15893
15737
|
try {
|
|
15894
15738
|
(_a2 = window.localStorage) == null ? void 0 : _a2.removeItem("XummPkceJwt");
|
|
15895
15739
|
} catch {
|
|
15896
15740
|
}
|
|
15897
15741
|
}
|
|
15898
15742
|
withAbort(promise, signal) {
|
|
15899
|
-
if (!signal)
|
|
15900
|
-
|
|
15901
|
-
if (signal.aborted)
|
|
15902
|
-
return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
15743
|
+
if (!signal) return promise;
|
|
15744
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
15903
15745
|
return new Promise((resolve, reject) => {
|
|
15904
15746
|
let settled = false;
|
|
15905
15747
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
15906
15748
|
const abort = () => {
|
|
15907
|
-
if (settled)
|
|
15908
|
-
return;
|
|
15749
|
+
if (settled) return;
|
|
15909
15750
|
settled = true;
|
|
15910
15751
|
cleanup();
|
|
15911
15752
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
15912
15753
|
};
|
|
15913
15754
|
signal.addEventListener("abort", abort, { once: true });
|
|
15914
|
-
promise.then(
|
|
15915
|
-
|
|
15916
|
-
return;
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
|
|
15922
|
-
return;
|
|
15923
|
-
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15755
|
+
promise.then(
|
|
15756
|
+
(value) => {
|
|
15757
|
+
if (settled) return;
|
|
15758
|
+
settled = true;
|
|
15759
|
+
cleanup();
|
|
15760
|
+
resolve(value);
|
|
15761
|
+
},
|
|
15762
|
+
(error) => {
|
|
15763
|
+
if (settled) return;
|
|
15764
|
+
settled = true;
|
|
15765
|
+
cleanup();
|
|
15766
|
+
reject(error);
|
|
15767
|
+
}
|
|
15768
|
+
);
|
|
15927
15769
|
});
|
|
15928
15770
|
}
|
|
15929
15771
|
getPendingRecoveryKey() {
|
|
@@ -15938,8 +15780,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15938
15780
|
async hasPendingRecoveryMarker() {
|
|
15939
15781
|
try {
|
|
15940
15782
|
const value = await this.recoveryStorage.getItem(this.getPendingRecoveryKey());
|
|
15941
|
-
if (!value)
|
|
15942
|
-
return false;
|
|
15783
|
+
if (!value) return false;
|
|
15943
15784
|
const timestamp = Number(value);
|
|
15944
15785
|
if (!Number.isFinite(timestamp) || Date.now() - timestamp > XAMAN_PENDING_RECOVERY_TTL_MS) {
|
|
15945
15786
|
this.clearPendingRecoveryMarker();
|
|
@@ -15962,6 +15803,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15962
15803
|
}
|
|
15963
15804
|
const METAMASK_ICON = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIGlkPSJMYXllcl8xIiB4PSIwIiB5PSIwIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzMTguNiAzMTguNiI+CiAgPHN0eWxlPgogICAgLnN0MSwuc3Q2e2ZpbGw6I2U0NzYxYjtzdHJva2U6I2U0NzYxYjtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmR9LnN0NntmaWxsOiNmNjg1MWI7c3Ryb2tlOiNmNjg1MWJ9CiAgPC9zdHlsZT4KICA8cGF0aCBmaWxsPSIjZTI3NjFiIiBzdHJva2U9IiNlMjc2MWIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTI3NC4xIDM1LjUtOTkuNSA3My45TDE5MyA2NS44eiIvPgogIDxwYXRoIGQ9Im00NC40IDM1LjUgOTguNyA3NC42LTE3LjUtNDQuM3ptMTkzLjkgMTcxLjMtMjYuNSA0MC42IDU2LjcgMTUuNiAxNi4zLTU1LjN6bS0yMDQuNC45TDUwLjEgMjYzbDU2LjctMTUuNi0yNi41LTQwLjZ6IiBjbGFzcz0ic3QxIi8+CiAgPHBhdGggZD0ibTEwMy42IDEzOC4yLTE1LjggMjMuOSA1Ni4zIDIuNS0yLTYwLjV6bTExMS4zIDAtMzktMzQuOC0xLjMgNjEuMiA1Ni4yLTIuNXpNMTA2LjggMjQ3LjRsMzMuOC0xNi41LTI5LjItMjIuOHptNzEuMS0xNi41IDMzLjkgMTYuNS00LjctMzkuM3oiIGNsYXNzPSJzdDEiLz4KICA8cGF0aCBmaWxsPSIjZDdjMWIzIiBzdHJva2U9IiNkN2MxYjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTIxMS44IDI0Ny40LTMzLjktMTYuNSAyLjcgMjIuMS0uMyA5LjN6bS0xMDUgMCAzMS41IDE0LjktLjItOS4zIDIuNS0yMi4xeiIvPgogIDxwYXRoIGZpbGw9IiMyMzM0NDciIHN0cm9rZT0iIzIzMzQ0NyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJtMTM4LjggMTkzLjUtMjguMi04LjMgMTkuOS05LjF6bTQwLjkgMCA4LjMtMTcuNCAyMCA5LjF6Ii8+CiAgPHBhdGggZmlsbD0iI2NkNjExNiIgc3Ryb2tlPSIjY2Q2MTE2IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGQ9Im0xMDYuOCAyNDcuNCA0LjgtNDAuNi0zMS4zLjl6TTIwNyAyMDYuOGw0LjggNDAuNiAyNi41LTM5Ljd6bTIzLjgtNDQuNy01Ni4yIDIuNSA1LjIgMjguOSA4LjMtMTcuNCAyMCA5LjF6bS0xMjAuMiAyMy4xIDIwLTkuMSA4LjIgMTcuNCA1LjMtMjguOS01Ni4zLTIuNXoiLz4KICA8cGF0aCBmaWxsPSIjZTQ3NTFmIiBzdHJva2U9IiNlNDc1MWYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTg3LjggMTYyLjEgMjMuNiA0Ni0uOC0yMi45em0xMjAuMyAyMy4xLTEgMjIuOSAyMy43LTQ2em0tNjQtMjAuNi01LjMgMjguOSA2LjYgMzQuMSAxLjUtNDQuOXptMzAuNSAwLTIuNyAxOCAxLjIgNDUgNi43LTM0LjF6Ii8+CiAgPHBhdGggZD0ibTE3OS44IDE5My41LTYuNyAzNC4xIDQuOCAzLjMgMjkuMi0yMi44IDEtMjIuOXptLTY5LjItOC4zLjggMjIuOSAyOS4yIDIyLjggNC44LTMuMy02LjYtMzQuMXoiIGNsYXNzPSJzdDYiLz4KICA8cGF0aCBmaWxsPSIjYzBhZDllIiBzdHJva2U9IiNjMGFkOWUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTE4MC4zIDI2Mi4zLjMtOS4zLTIuNS0yLjJoLTM3LjdsLTIuMyAyLjIuMiA5LjMtMzEuNS0xNC45IDExIDkgMjIuMyAxNS41aDM4LjNsMjIuNC0xNS41IDExLTl6Ii8+CiAgPHBhdGggZmlsbD0iIzE2MTYxNiIgc3Ryb2tlPSIjMTYxNjE2IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGQ9Im0xNzcuOSAyMzAuOS00LjgtMy4zaC0yNy43bC00LjggMy4zLTIuNSAyMi4xIDIuMy0yLjJoMzcuN2wyLjUgMi4yeiIvPgogIDxwYXRoIGZpbGw9IiM3NjNkMTYiIHN0cm9rZT0iIzc2M2QxNiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJtMjc4LjMgMTE0LjIgOC41LTQwLjgtMTIuNy0zNy45LTk2LjIgNzEuNCAzNyAzMS4zIDUyLjMgMTUuMyAxMS42LTEzLjUtNS0zLjYgOC03LjMtNi4yLTQuOCA4LTYuMXpNMzEuOCA3My40bDguNSA0MC44LTUuNCA0IDggNi4xLTYuMSA0LjggOCA3LjMtNSAzLjYgMTEuNSAxMy41IDUyLjMtMTUuMyAzNy0zMS4zLTk2LjItNzEuNHoiLz4KICA8cGF0aCBkPSJtMjY3LjIgMTUzLjUtNTIuMy0xNS4zIDE1LjkgMjMuOS0yMy43IDQ2IDMxLjItLjRoNDYuNXptLTE2My42LTE1LjMtNTIuMyAxNS4zLTE3LjQgNTQuMmg0Ni40bDMxLjEuNC0yMy42LTQ2em03MSAyNi40IDMuMy01Ny43IDE1LjItNDEuMWgtNjcuNWwxNSA0MS4xIDMuNSA1Ny43IDEuMiAxOC4yLjEgNDQuOGgyNy43bC4yLTQ0Ljh6IiBjbGFzcz0ic3Q2Ii8+Cjwvc3ZnPg==";
|
|
15964
15805
|
const XRPLSNAP_ICON = METAMASK_ICON;
|
|
15806
|
+
const NETWORK_TO_SNAP_CHAIN_ID = {
|
|
15807
|
+
mainnet: 0,
|
|
15808
|
+
testnet: 1,
|
|
15809
|
+
devnet: 2
|
|
15810
|
+
};
|
|
15811
|
+
const discoveredMetaMaskProviders = /* @__PURE__ */ new Set();
|
|
15812
|
+
let eip6963DiscoveryStarted = false;
|
|
15965
15813
|
class XrplSnapAdapter extends BaseWalletAdapter {
|
|
15966
15814
|
constructor(options = {}) {
|
|
15967
15815
|
super();
|
|
@@ -15976,33 +15824,63 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15976
15824
|
icon: options.icon ?? METAMASK_ICON
|
|
15977
15825
|
};
|
|
15978
15826
|
}
|
|
15979
|
-
isAvailable() {
|
|
15980
|
-
return Boolean(this.
|
|
15827
|
+
async isAvailable() {
|
|
15828
|
+
return Boolean(await this.ethereumCandidate(false));
|
|
15981
15829
|
}
|
|
15982
15830
|
async connect(options) {
|
|
15983
15831
|
var _a2;
|
|
15984
|
-
const ethereum = this.
|
|
15985
|
-
|
|
15832
|
+
const ethereum = await this.ethereumCandidate().catch((error) => {
|
|
15833
|
+
throw createWalletError.walletNotAvailable("MetaMask Snaps", error);
|
|
15834
|
+
});
|
|
15835
|
+
await this.withAbort(
|
|
15836
|
+
ethereum.request({ method: "wallet_requestSnaps", params: { [this.snapId]: {} } }).catch((error) => {
|
|
15837
|
+
if (this.isSnapsUnsupportedError(error)) {
|
|
15838
|
+
throw createWalletError.walletNotAvailable("MetaMask Snaps", error);
|
|
15839
|
+
}
|
|
15840
|
+
throw error;
|
|
15841
|
+
}),
|
|
15842
|
+
options.signal
|
|
15843
|
+
);
|
|
15844
|
+
this.activeAddress = void 0;
|
|
15845
|
+
this.activeProvider = ethereum;
|
|
15846
|
+
await this.selectSnapNetwork(options);
|
|
15986
15847
|
const snap = await this.withAbort(ethereum.request({ method: "wallet_invokeSnap", params: { snapId: this.snapId, request: { method: "xrpl_getAccount" } } }), options.signal);
|
|
15987
15848
|
const address = snap.account;
|
|
15988
|
-
|
|
15989
|
-
|
|
15849
|
+
const publicKey = snap.publicKey;
|
|
15850
|
+
if (!address) throw new Error("XRPL Snap did not return an XRPL address");
|
|
15990
15851
|
this.activeAddress = address;
|
|
15991
|
-
|
|
15852
|
+
this.activeProvider = ethereum;
|
|
15853
|
+
return { account: { address, publicKey, network: options.network, networkType: (_a2 = options.network) == null ? void 0 : _a2.networkType }, raw: snap };
|
|
15992
15854
|
}
|
|
15993
15855
|
async restoreSession(session) {
|
|
15994
|
-
|
|
15995
|
-
|
|
15856
|
+
const ethereum = await this.ethereum(false);
|
|
15857
|
+
if (!ethereum || !await this.providerSupportsSnaps(ethereum)) return null;
|
|
15996
15858
|
this.activeAddress = session.account.address;
|
|
15859
|
+
this.activeProvider = ethereum;
|
|
15997
15860
|
return { account: session.account, session, raw: null };
|
|
15998
15861
|
}
|
|
15999
15862
|
async signMessage(request) {
|
|
15863
|
+
var _a2;
|
|
16000
15864
|
const txJson = this.createSignMessagePaymentTx(request);
|
|
16001
|
-
const methods2 = this.options.signMessageMethods ?? ["xrpl_sign", "xrpl_signTransaction", "npm:xrpl-snap"];
|
|
15865
|
+
const methods2 = this.options.signMessageMethods ?? ["xrpl_signMessage", "xrpl_sign", "xrpl_signTransaction", "npm:xrpl-snap"];
|
|
16002
15866
|
const errors2 = [];
|
|
16003
15867
|
for (const method of methods2) {
|
|
16004
15868
|
try {
|
|
16005
|
-
const
|
|
15869
|
+
const params = method === "xrpl_signMessage" ? { message: request.message } : txJson;
|
|
15870
|
+
const result = await this.invokeSnap(method, params);
|
|
15871
|
+
const signature = this.pickString(result, [
|
|
15872
|
+
"signature",
|
|
15873
|
+
"signedMessage",
|
|
15874
|
+
"result.signature",
|
|
15875
|
+
"result.signedMessage",
|
|
15876
|
+
"response.signature",
|
|
15877
|
+
"response.signedMessage",
|
|
15878
|
+
"response.data.signature",
|
|
15879
|
+
"response.data.signedMessage"
|
|
15880
|
+
]);
|
|
15881
|
+
if (method === "xrpl_signMessage" && signature) {
|
|
15882
|
+
return { signatureKind: "signature", proof: signature, signature, publicKey: (_a2 = request.account) == null ? void 0 : _a2.publicKey, raw: result };
|
|
15883
|
+
}
|
|
16006
15884
|
const txBlob = this.pickString(result, [
|
|
16007
15885
|
"tx_blob",
|
|
16008
15886
|
"txBlob",
|
|
@@ -16029,6 +15907,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16029
15907
|
"result.signature",
|
|
16030
15908
|
"result.signedMessage"
|
|
16031
15909
|
]);
|
|
15910
|
+
if (!txBlob) throw new Error(`XRPL Snap ${method} did not return a signature or signed transaction`);
|
|
16032
15911
|
return { signatureKind: "signedTx", proof: txBlob, txBlob, raw: result };
|
|
16033
15912
|
} catch (error) {
|
|
16034
15913
|
errors2.push({ method, error: this.formatError(error) });
|
|
@@ -16037,14 +15916,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16037
15916
|
throw this.toSnapSignError(errors2, "XRPL Snap could not sign the message.");
|
|
16038
15917
|
}
|
|
16039
15918
|
getSignMessageRequestPreview(request) {
|
|
16040
|
-
var _a2;
|
|
15919
|
+
var _a2, _b, _c;
|
|
16041
15920
|
return {
|
|
16042
15921
|
method: "wallet_invokeSnap",
|
|
16043
15922
|
params: {
|
|
16044
15923
|
snapId: this.snapId,
|
|
16045
15924
|
request: {
|
|
16046
|
-
method: ((_a2 = this.options.signMessageMethods) == null ? void 0 : _a2[0]) ?? "
|
|
16047
|
-
params: this.createSignMessagePaymentTx(request)
|
|
15925
|
+
method: ((_a2 = this.options.signMessageMethods) == null ? void 0 : _a2[0]) ?? "xrpl_signMessage",
|
|
15926
|
+
params: ((_b = this.options.signMessageMethods) == null ? void 0 : _b[0]) === "xrpl_sign" || ((_c = this.options.signMessageMethods) == null ? void 0 : _c[0]) === "xrpl_signTransaction" ? this.createSignMessagePaymentTx(request) : { message: request.message }
|
|
16048
15927
|
}
|
|
16049
15928
|
}
|
|
16050
15929
|
};
|
|
@@ -16052,13 +15931,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16052
15931
|
async signAndSubmit(request) {
|
|
16053
15932
|
try {
|
|
16054
15933
|
const result = await this.invokeSnap("xrpl_signAndSubmit", request.txJson);
|
|
15934
|
+
this.assertSuccessfulSubmit(result);
|
|
16055
15935
|
return normalizeTxResult(result);
|
|
16056
15936
|
} catch (error) {
|
|
16057
15937
|
throw this.toSnapSignError(error, "XRPL Snap could not submit this transaction.");
|
|
16058
15938
|
}
|
|
16059
15939
|
}
|
|
16060
|
-
invokeSnap(method, params) {
|
|
16061
|
-
|
|
15940
|
+
async invokeSnap(method, params) {
|
|
15941
|
+
const ethereum = await this.ethereum();
|
|
15942
|
+
return ethereum.request({
|
|
16062
15943
|
method: "wallet_invokeSnap",
|
|
16063
15944
|
params: { snapId: this.snapId, request: { method, params } }
|
|
16064
15945
|
});
|
|
@@ -16066,8 +15947,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16066
15947
|
createSignMessagePaymentTx(request) {
|
|
16067
15948
|
var _a2;
|
|
16068
15949
|
const account = ((_a2 = request.account) == null ? void 0 : _a2.address) ?? this.activeAddress;
|
|
16069
|
-
if (!account)
|
|
16070
|
-
throw new Error("XRPL Snap account is not connected");
|
|
15950
|
+
if (!account) throw new Error("XRPL Snap account is not connected");
|
|
16071
15951
|
return {
|
|
16072
15952
|
TransactionType: "Payment",
|
|
16073
15953
|
Account: account,
|
|
@@ -16077,83 +15957,210 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16077
15957
|
Memos: [{ Memo: { MemoData: utf8ToHex(request.message) } }]
|
|
16078
15958
|
};
|
|
16079
15959
|
}
|
|
15960
|
+
async selectSnapNetwork(options) {
|
|
15961
|
+
var _a2;
|
|
15962
|
+
const networkId = (_a2 = options.network) == null ? void 0 : _a2.id;
|
|
15963
|
+
if (!networkId) return;
|
|
15964
|
+
const chainId = NETWORK_TO_SNAP_CHAIN_ID[networkId];
|
|
15965
|
+
if (chainId === void 0) return;
|
|
15966
|
+
try {
|
|
15967
|
+
const active = await this.invokeSnap("xrpl_getActiveNetwork", void 0);
|
|
15968
|
+
if ((active == null ? void 0 : active.chainId) !== chainId) await this.invokeSnap("xrpl_changeNetwork", { chainId });
|
|
15969
|
+
const applied = await this.invokeSnap("xrpl_getActiveNetwork", void 0);
|
|
15970
|
+
if ((applied == null ? void 0 : applied.chainId) !== chainId) {
|
|
15971
|
+
throw new Error(`XRPL Snap network mismatch: expected chain ${chainId}, got ${String(applied == null ? void 0 : applied.chainId)}`);
|
|
15972
|
+
}
|
|
15973
|
+
} catch (error) {
|
|
15974
|
+
if (/unknown method|method not found|not supported|unsupported/i.test(this.getErrorMessage(error))) return;
|
|
15975
|
+
throw error;
|
|
15976
|
+
}
|
|
15977
|
+
}
|
|
15978
|
+
assertSuccessfulSubmit(result) {
|
|
15979
|
+
const engineResult = this.pickString(result, [
|
|
15980
|
+
"engine_result",
|
|
15981
|
+
"result.engine_result",
|
|
15982
|
+
"response.engine_result",
|
|
15983
|
+
"response.data.engine_result",
|
|
15984
|
+
"response.data.result.engine_result"
|
|
15985
|
+
]);
|
|
15986
|
+
if (!engineResult) return;
|
|
15987
|
+
if (engineResult === "tesSUCCESS" || engineResult === "terQUEUED") return;
|
|
15988
|
+
const message = this.pickString(result, [
|
|
15989
|
+
"engine_result_message",
|
|
15990
|
+
"result.engine_result_message",
|
|
15991
|
+
"response.engine_result_message",
|
|
15992
|
+
"response.data.engine_result_message",
|
|
15993
|
+
"response.data.result.engine_result_message"
|
|
15994
|
+
]);
|
|
15995
|
+
throw new Error(message ? `XRPL Snap submission failed: ${message}` : `XRPL Snap submission failed: ${engineResult}`);
|
|
15996
|
+
}
|
|
16080
15997
|
pickString(value, paths) {
|
|
16081
15998
|
for (const path of paths) {
|
|
16082
15999
|
const found = path.split(".").reduce((current, key) => {
|
|
16083
|
-
if (current && typeof current === "object" && key in current)
|
|
16084
|
-
return current[key];
|
|
16000
|
+
if (current && typeof current === "object" && key in current) return current[key];
|
|
16085
16001
|
return void 0;
|
|
16086
16002
|
}, value);
|
|
16087
|
-
if (typeof found === "string")
|
|
16088
|
-
return found;
|
|
16003
|
+
if (typeof found === "string") return found;
|
|
16089
16004
|
}
|
|
16090
16005
|
return void 0;
|
|
16091
16006
|
}
|
|
16092
16007
|
formatError(error) {
|
|
16093
|
-
if (error instanceof Error)
|
|
16094
|
-
return { name: error.name, message: error.message };
|
|
16008
|
+
if (error instanceof Error) return { name: error.name, message: error.message };
|
|
16095
16009
|
return error;
|
|
16096
16010
|
}
|
|
16097
16011
|
toSnapSignError(cause, fallback) {
|
|
16098
16012
|
const message = this.getErrorMessage(cause);
|
|
16099
|
-
if (/reject|denied|cancelled|canceled|closed/i.test(message))
|
|
16100
|
-
|
|
16101
|
-
if (/
|
|
16102
|
-
|
|
16103
|
-
if (/not installed|not available|provider/i.test(message))
|
|
16104
|
-
return createWalletError.walletNotAvailable("XRPL Snap", cause);
|
|
16105
|
-
if (/unsupported|not supported|unknown method|method not found/i.test(message))
|
|
16106
|
-
return createWalletError.unsupportedMethod("XRPL Snap request", "MetaMask");
|
|
16013
|
+
if (/reject|denied|cancelled|canceled|closed/i.test(message)) return createWalletError.signRejected(cause);
|
|
16014
|
+
if (/timeout|timed out/i.test(message)) return createWalletError.requestTimeout("XRPL Snap request timed out. Please try again.", cause);
|
|
16015
|
+
if (/not installed|not available|provider/i.test(message)) return createWalletError.walletNotAvailable("XRPL Snap", cause);
|
|
16016
|
+
if (/unsupported|not supported|unknown method|method not found/i.test(message)) return createWalletError.unsupportedMethod("XRPL Snap request", "MetaMask");
|
|
16107
16017
|
const safeError = new Error(fallback);
|
|
16108
16018
|
safeError.cause = cause;
|
|
16109
16019
|
return createWalletError.signFailed(safeError);
|
|
16110
16020
|
}
|
|
16111
16021
|
getErrorMessage(error) {
|
|
16112
|
-
if (error instanceof Error)
|
|
16113
|
-
|
|
16114
|
-
if (typeof error === "string")
|
|
16115
|
-
return error;
|
|
16022
|
+
if (error instanceof Error) return error.message;
|
|
16023
|
+
if (typeof error === "string") return error;
|
|
16116
16024
|
try {
|
|
16117
16025
|
return JSON.stringify(error);
|
|
16118
16026
|
} catch {
|
|
16119
16027
|
return String(error);
|
|
16120
16028
|
}
|
|
16121
16029
|
}
|
|
16122
|
-
ethereum(required = true) {
|
|
16123
|
-
const
|
|
16124
|
-
|
|
16125
|
-
|
|
16030
|
+
async ethereum(required = true) {
|
|
16031
|
+
const injected = globalThis.ethereum;
|
|
16032
|
+
this.startEip6963Discovery();
|
|
16033
|
+
const configured = this.options.ethereum;
|
|
16034
|
+
if (configured) return await this.pickSnapProvider(configured, true) ?? this.pickStrongMetaMaskProvider(configured);
|
|
16035
|
+
const ethereum = this.activeProvider ?? await this.pickSnapProvider(injected, false) ?? await this.discoverMetaMaskProvider() ?? [...discoveredMetaMaskProviders][0] ?? this.pickStrongMetaMaskProvider(injected);
|
|
16036
|
+
if (!ethereum && required) throw new Error("No MetaMask provider installed");
|
|
16037
|
+
if (ethereum) this.activeProvider = ethereum;
|
|
16038
|
+
return ethereum;
|
|
16039
|
+
}
|
|
16040
|
+
async ethereumCandidate(required = true) {
|
|
16041
|
+
const injected = globalThis.ethereum;
|
|
16042
|
+
this.startEip6963Discovery();
|
|
16043
|
+
const configured = this.options.ethereum;
|
|
16044
|
+
const ethereum = await this.pickSnapProvider(configured, true) ?? this.pickStrongMetaMaskProvider(configured) ?? this.activeProvider ?? await this.pickSnapProvider(injected, false) ?? this.pickStrongMetaMaskProvider(injected) ?? await this.discoverMetaMaskProvider() ?? [...discoveredMetaMaskProviders][0];
|
|
16045
|
+
if (!ethereum && required) throw new Error("No MetaMask provider installed");
|
|
16126
16046
|
return ethereum;
|
|
16127
16047
|
}
|
|
16048
|
+
pickStrongMetaMaskProvider(injected) {
|
|
16049
|
+
if (!injected) return void 0;
|
|
16050
|
+
const providers = Array.isArray(injected.providers) ? injected.providers : [];
|
|
16051
|
+
return providers.find((provider) => this.hasMetaMaskProviderApi(provider)) ?? (this.hasMetaMaskProviderApi(injected) ? injected : void 0);
|
|
16052
|
+
}
|
|
16053
|
+
async pickSnapProvider(injected, allowRootProvider = false) {
|
|
16054
|
+
const preferred = this.pickStrongMetaMaskProvider(injected);
|
|
16055
|
+
if (preferred && await this.providerSupportsSnaps(preferred)) return preferred;
|
|
16056
|
+
for (const provider of (injected == null ? void 0 : injected.providers) ?? []) {
|
|
16057
|
+
if (provider === preferred) continue;
|
|
16058
|
+
if (await this.providerSupportsSnaps(provider)) return provider;
|
|
16059
|
+
}
|
|
16060
|
+
if (allowRootProvider && injected && injected !== preferred && await this.providerSupportsSnaps(injected)) return injected;
|
|
16061
|
+
return void 0;
|
|
16062
|
+
}
|
|
16063
|
+
startEip6963Discovery() {
|
|
16064
|
+
if (eip6963DiscoveryStarted) return;
|
|
16065
|
+
const scope = globalThis;
|
|
16066
|
+
if (!scope.addEventListener || !scope.dispatchEvent) return;
|
|
16067
|
+
eip6963DiscoveryStarted = true;
|
|
16068
|
+
scope.addEventListener("eip6963:announceProvider", (event) => {
|
|
16069
|
+
const provider = this.pickMetaMaskProviderFromAnnounce(event);
|
|
16070
|
+
if (provider) discoveredMetaMaskProviders.add(provider);
|
|
16071
|
+
});
|
|
16072
|
+
try {
|
|
16073
|
+
scope.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
16074
|
+
} catch {
|
|
16075
|
+
}
|
|
16076
|
+
}
|
|
16077
|
+
discoverMetaMaskProvider() {
|
|
16078
|
+
const cached = [...discoveredMetaMaskProviders][0];
|
|
16079
|
+
if (cached) return Promise.resolve(cached);
|
|
16080
|
+
const scope = globalThis;
|
|
16081
|
+
if (!scope.addEventListener || !scope.removeEventListener || !scope.dispatchEvent) return Promise.resolve(void 0);
|
|
16082
|
+
const addEventListener = scope.addEventListener.bind(scope);
|
|
16083
|
+
const removeEventListener = scope.removeEventListener.bind(scope);
|
|
16084
|
+
const dispatchEvent = scope.dispatchEvent.bind(scope);
|
|
16085
|
+
return new Promise((resolve) => {
|
|
16086
|
+
let timer;
|
|
16087
|
+
let settled = false;
|
|
16088
|
+
const finish = (provider) => {
|
|
16089
|
+
if (settled) return;
|
|
16090
|
+
settled = true;
|
|
16091
|
+
if (timer) clearTimeout(timer);
|
|
16092
|
+
removeEventListener("eip6963:announceProvider", onAnnounce);
|
|
16093
|
+
resolve(provider);
|
|
16094
|
+
};
|
|
16095
|
+
const onAnnounce = (event) => {
|
|
16096
|
+
const provider = this.pickMetaMaskProviderFromAnnounce(event);
|
|
16097
|
+
if (provider) {
|
|
16098
|
+
discoveredMetaMaskProviders.add(provider);
|
|
16099
|
+
finish(provider);
|
|
16100
|
+
}
|
|
16101
|
+
};
|
|
16102
|
+
addEventListener("eip6963:announceProvider", onAnnounce);
|
|
16103
|
+
try {
|
|
16104
|
+
dispatchEvent(new Event("eip6963:requestProvider"));
|
|
16105
|
+
} catch {
|
|
16106
|
+
finish(void 0);
|
|
16107
|
+
return;
|
|
16108
|
+
}
|
|
16109
|
+
timer = setTimeout(() => finish([...discoveredMetaMaskProviders][0]), this.options.providerDiscoveryTimeoutMs ?? 1e3);
|
|
16110
|
+
});
|
|
16111
|
+
}
|
|
16112
|
+
pickMetaMaskProviderFromAnnounce(event) {
|
|
16113
|
+
var _a2, _b, _c, _d;
|
|
16114
|
+
const detail = event.detail;
|
|
16115
|
+
const provider = detail == null ? void 0 : detail.provider;
|
|
16116
|
+
const rdns = ((_b = (_a2 = detail == null ? void 0 : detail.info) == null ? void 0 : _a2.rdns) == null ? void 0 : _b.toLowerCase()) ?? "";
|
|
16117
|
+
const name = ((_d = (_c = detail == null ? void 0 : detail.info) == null ? void 0 : _c.name) == null ? void 0 : _d.toLowerCase()) ?? "";
|
|
16118
|
+
if (provider && (rdns.includes("metamask") || name.includes("metamask") || this.hasMetaMaskProviderApi(provider))) return provider;
|
|
16119
|
+
return void 0;
|
|
16120
|
+
}
|
|
16121
|
+
async providerSupportsSnaps(ethereum) {
|
|
16122
|
+
try {
|
|
16123
|
+
await ethereum.request({ method: "wallet_getSnaps" });
|
|
16124
|
+
return true;
|
|
16125
|
+
} catch (error) {
|
|
16126
|
+
if (this.isSnapsUnsupportedError(error)) return false;
|
|
16127
|
+
return false;
|
|
16128
|
+
}
|
|
16129
|
+
}
|
|
16130
|
+
hasMetaMaskProviderApi(provider) {
|
|
16131
|
+
return Boolean(provider && provider._metamask);
|
|
16132
|
+
}
|
|
16133
|
+
isSnapsUnsupportedError(error) {
|
|
16134
|
+
const message = this.getErrorMessage(error);
|
|
16135
|
+
return /-32601|wallet_requestSnaps|wallet_getSnaps|does not exist|not available|unsupported|method not found|unknown method/i.test(message);
|
|
16136
|
+
}
|
|
16128
16137
|
withAbort(promise, signal) {
|
|
16129
|
-
if (!signal)
|
|
16130
|
-
|
|
16131
|
-
if (signal.aborted)
|
|
16132
|
-
return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
16138
|
+
if (!signal) return promise;
|
|
16139
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
16133
16140
|
return new Promise((resolve, reject) => {
|
|
16134
16141
|
let settled = false;
|
|
16135
16142
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
16136
16143
|
const abort = () => {
|
|
16137
|
-
if (settled)
|
|
16138
|
-
return;
|
|
16144
|
+
if (settled) return;
|
|
16139
16145
|
settled = true;
|
|
16140
16146
|
cleanup();
|
|
16141
16147
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
16142
16148
|
};
|
|
16143
16149
|
signal.addEventListener("abort", abort, { once: true });
|
|
16144
|
-
promise.then(
|
|
16145
|
-
|
|
16146
|
-
return;
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
return;
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16150
|
+
promise.then(
|
|
16151
|
+
(value) => {
|
|
16152
|
+
if (settled) return;
|
|
16153
|
+
settled = true;
|
|
16154
|
+
cleanup();
|
|
16155
|
+
resolve(value);
|
|
16156
|
+
},
|
|
16157
|
+
(error) => {
|
|
16158
|
+
if (settled) return;
|
|
16159
|
+
settled = true;
|
|
16160
|
+
cleanup();
|
|
16161
|
+
reject(error);
|
|
16162
|
+
}
|
|
16163
|
+
);
|
|
16157
16164
|
});
|
|
16158
16165
|
}
|
|
16159
16166
|
}
|
|
@@ -16164,7 +16171,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16164
16171
|
const lightTheme = {
|
|
16165
16172
|
accent: "#0078ae",
|
|
16166
16173
|
accentText: "#ffffff",
|
|
16167
|
-
background: "#
|
|
16174
|
+
background: "#fbfcff",
|
|
16168
16175
|
foreground: "#111827",
|
|
16169
16176
|
error: "#b45309",
|
|
16170
16177
|
success: "#059669",
|
|
@@ -16172,15 +16179,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16172
16179
|
border: "rgba(17,24,39,.08)",
|
|
16173
16180
|
overlay: "rgba(15,23,42,.46)",
|
|
16174
16181
|
overlayBlur: 0,
|
|
16175
|
-
surface: "#
|
|
16176
|
-
surfaceHover: "
|
|
16182
|
+
surface: "#f3f7fb",
|
|
16183
|
+
surfaceHover: "#edf3f8",
|
|
16177
16184
|
fallbackIconBackground: "rgba(15,23,42,.06)",
|
|
16178
16185
|
fallbackIconColor: "#111827",
|
|
16179
16186
|
shadow: "0 8px 40px rgba(15,23,42,.12), 0 0 0 1px rgba(15,23,42,.04)",
|
|
16180
16187
|
radius: "14px",
|
|
16181
16188
|
walletRadius: "10px",
|
|
16182
16189
|
spinnerTrail: "rgba(0,0,0,.08)",
|
|
16183
|
-
headerBackground: "#
|
|
16190
|
+
headerBackground: "#fbfcff",
|
|
16184
16191
|
fontFamily: defaultFontFamily
|
|
16185
16192
|
};
|
|
16186
16193
|
const darkTheme = {
|
|
@@ -16214,9 +16221,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16214
16221
|
};
|
|
16215
16222
|
const minimalTheme = {
|
|
16216
16223
|
...lightTheme,
|
|
16217
|
-
background: "#
|
|
16218
|
-
headerBackground: "#
|
|
16219
|
-
surface: "#
|
|
16224
|
+
background: "#fbfcff",
|
|
16225
|
+
headerBackground: "#fbfcff",
|
|
16226
|
+
surface: "#fbfcff",
|
|
16220
16227
|
border: "#d7dee8",
|
|
16221
16228
|
radius: "8px",
|
|
16222
16229
|
walletRadius: "8px",
|
|
@@ -16338,9 +16345,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16338
16345
|
crisp: (overrides = {}) => ({ ...crispTheme, ...overrides }),
|
|
16339
16346
|
soft: (overrides = {}) => ({ ...softTheme, ...overrides })
|
|
16340
16347
|
};
|
|
16341
|
-
const
|
|
16348
|
+
const enUSMessages = {
|
|
16342
16349
|
connectWallet: "Connect Wallet",
|
|
16343
|
-
footerText: "XRPL Wallet Kit",
|
|
16344
16350
|
connect: "Connect",
|
|
16345
16351
|
connected: "Connected",
|
|
16346
16352
|
connectedAccount: "Connected account",
|
|
@@ -16367,9 +16373,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16367
16373
|
openWallet: "Open Wallet",
|
|
16368
16374
|
qrUriCopied: "QR URI copied.",
|
|
16369
16375
|
installed: "Installed",
|
|
16376
|
+
recommended: "Recommended",
|
|
16377
|
+
mobileWallet: "Mobile wallet",
|
|
16378
|
+
extensionWallet: "Extension",
|
|
16379
|
+
walletConnectWallet: "WalletConnect",
|
|
16380
|
+
xrplSnapWallet: "XRPL Snap",
|
|
16381
|
+
hardwareWallet: "Hardware",
|
|
16382
|
+
embeddedWallet: "Embedded wallet",
|
|
16370
16383
|
copyAddress: "Copy address",
|
|
16384
|
+
addressQr: "Address QR",
|
|
16385
|
+
showAddressQr: "Show address QR code",
|
|
16371
16386
|
copying: "Copying...",
|
|
16372
16387
|
viewExplorer: "View explorer",
|
|
16388
|
+
recentTransactions: "Recent transactions",
|
|
16389
|
+
noRecentTransactions: "No recent transactions",
|
|
16390
|
+
transactionSubmitted: "Submitted",
|
|
16391
|
+
transactionConfirmed: "Confirmed",
|
|
16392
|
+
transactionFailed: "Failed",
|
|
16393
|
+
transactionUnknown: "Unknown",
|
|
16394
|
+
view: "View",
|
|
16373
16395
|
disconnect: "Disconnect",
|
|
16374
16396
|
disconnecting: "Disconnecting...",
|
|
16375
16397
|
notActivated: "Not activated",
|
|
@@ -16382,8 +16404,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16382
16404
|
moreWallets: (count) => `+${count} more wallets`,
|
|
16383
16405
|
accountNotActivated: (asset) => `Account not activated. Send ${asset} to activate.`
|
|
16384
16406
|
};
|
|
16385
|
-
const
|
|
16386
|
-
...
|
|
16407
|
+
const viVNMessages = {
|
|
16408
|
+
...enUSMessages,
|
|
16387
16409
|
connectWallet: "Kết nối ví",
|
|
16388
16410
|
connect: "Kết nối",
|
|
16389
16411
|
connected: "Đã kết nối",
|
|
@@ -16411,9 +16433,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16411
16433
|
openWallet: "Mở ví",
|
|
16412
16434
|
qrUriCopied: "Đã sao chép QR URI.",
|
|
16413
16435
|
installed: "Đã cài",
|
|
16436
|
+
recommended: "Đề xuất",
|
|
16437
|
+
mobileWallet: "Ví di động",
|
|
16438
|
+
extensionWallet: "Extension",
|
|
16439
|
+
walletConnectWallet: "WalletConnect",
|
|
16440
|
+
xrplSnapWallet: "XRPL Snap",
|
|
16441
|
+
hardwareWallet: "Ví phần cứng",
|
|
16442
|
+
embeddedWallet: "Ví nhúng",
|
|
16414
16443
|
copyAddress: "Sao chép địa chỉ",
|
|
16444
|
+
addressQr: "Mã QR địa chỉ",
|
|
16445
|
+
showAddressQr: "Hiển thị mã QR địa chỉ",
|
|
16415
16446
|
copying: "Đang sao chép...",
|
|
16416
16447
|
viewExplorer: "Xem explorer",
|
|
16448
|
+
recentTransactions: "Giao dịch gần đây",
|
|
16449
|
+
noRecentTransactions: "Chưa có giao dịch gần đây",
|
|
16450
|
+
transactionSubmitted: "Đã gửi",
|
|
16451
|
+
transactionConfirmed: "Đã xác nhận",
|
|
16452
|
+
transactionFailed: "Thất bại",
|
|
16453
|
+
transactionUnknown: "Chưa rõ",
|
|
16454
|
+
view: "Xem",
|
|
16417
16455
|
disconnect: "Ngắt kết nối",
|
|
16418
16456
|
disconnecting: "Đang ngắt kết nối...",
|
|
16419
16457
|
notActivated: "Chưa kích hoạt",
|
|
@@ -16431,28 +16469,41 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16431
16469
|
vi: "vi-VN",
|
|
16432
16470
|
ja: "ja-JP",
|
|
16433
16471
|
ko: "ko-KR",
|
|
16472
|
+
// default to Simplified; use "zh-TW" for Traditional
|
|
16434
16473
|
zh: "zh-CN"
|
|
16435
16474
|
};
|
|
16436
16475
|
const builtInMessages = {
|
|
16437
|
-
"en-US":
|
|
16438
|
-
"vi-VN":
|
|
16439
|
-
"ja-JP": enMessages,
|
|
16440
|
-
"ko-KR": enMessages,
|
|
16441
|
-
"zh-CN": enMessages,
|
|
16442
|
-
"zh-TW": enMessages
|
|
16476
|
+
"en-US": enUSMessages,
|
|
16477
|
+
"vi-VN": viVNMessages
|
|
16443
16478
|
};
|
|
16444
|
-
function resolveWalletUiMessages(locale = "en", overrides = {}) {
|
|
16479
|
+
function resolveWalletUiMessages(locale = "en-US", overrides = {}) {
|
|
16445
16480
|
const normalizedLocale = normalizeWalletUiLocale(locale);
|
|
16481
|
+
const definedOverrides = Object.fromEntries(
|
|
16482
|
+
Object.entries(overrides).filter(([, value]) => value !== void 0)
|
|
16483
|
+
);
|
|
16446
16484
|
return {
|
|
16447
|
-
...builtInMessages[normalizedLocale] ??
|
|
16448
|
-
...
|
|
16485
|
+
...builtInMessages[normalizedLocale] ?? enUSMessages,
|
|
16486
|
+
...definedOverrides
|
|
16449
16487
|
};
|
|
16450
16488
|
}
|
|
16451
16489
|
function normalizeWalletUiLocale(locale = "en-US") {
|
|
16452
16490
|
return localeAliases[locale] ?? locale;
|
|
16453
16491
|
}
|
|
16454
16492
|
function resolveWalletUiOptions(overrides = {}) {
|
|
16455
|
-
const {
|
|
16493
|
+
const {
|
|
16494
|
+
mode: mode2,
|
|
16495
|
+
customTheme,
|
|
16496
|
+
modal,
|
|
16497
|
+
walletList,
|
|
16498
|
+
walletConnect,
|
|
16499
|
+
connectButton: _connectButton,
|
|
16500
|
+
accountPanel: _accountPanel,
|
|
16501
|
+
identity: _identity,
|
|
16502
|
+
themeName,
|
|
16503
|
+
language,
|
|
16504
|
+
messages,
|
|
16505
|
+
transactionPreview
|
|
16506
|
+
} = overrides;
|
|
16456
16507
|
const resolvedMessages = resolveWalletUiMessages(language, messages);
|
|
16457
16508
|
const walletConnectUiMode = (walletConnect == null ? void 0 : walletConnect.mode) ?? overrides.walletConnectUiMode ?? "default";
|
|
16458
16509
|
const wallets = (walletList == null ? void 0 : walletList.wallets) === "all" ? void 0 : walletList == null ? void 0 : walletList.wallets;
|
|
@@ -19809,11 +19860,9 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19809
19860
|
let savedHtmlOverscrollBehavior = "";
|
|
19810
19861
|
let savedScrollY = 0;
|
|
19811
19862
|
function lockPageScroll() {
|
|
19812
|
-
if (typeof window === "undefined" || typeof document === "undefined")
|
|
19813
|
-
return;
|
|
19863
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
19814
19864
|
pageScrollLockCount += 1;
|
|
19815
|
-
if (pageScrollLockCount > 1)
|
|
19816
|
-
return;
|
|
19865
|
+
if (pageScrollLockCount > 1) return;
|
|
19817
19866
|
savedBodyOverflow = document.body.style.overflow;
|
|
19818
19867
|
savedBodyPaddingRight = document.body.style.paddingRight;
|
|
19819
19868
|
savedBodyPosition = document.body.style.position;
|
|
@@ -19826,16 +19875,13 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19826
19875
|
document.body.style.position = "fixed";
|
|
19827
19876
|
document.body.style.top = `-${savedScrollY}px`;
|
|
19828
19877
|
document.body.style.width = "100%";
|
|
19829
|
-
if (scrollbarWidth > 0)
|
|
19830
|
-
document.body.style.paddingRight = `${scrollbarWidth}px`;
|
|
19878
|
+
if (scrollbarWidth > 0) document.body.style.paddingRight = `${scrollbarWidth}px`;
|
|
19831
19879
|
document.documentElement.style.overscrollBehavior = "contain";
|
|
19832
19880
|
}
|
|
19833
19881
|
function unlockPageScroll() {
|
|
19834
|
-
if (typeof window === "undefined" || typeof document === "undefined" || pageScrollLockCount === 0)
|
|
19835
|
-
return;
|
|
19882
|
+
if (typeof window === "undefined" || typeof document === "undefined" || pageScrollLockCount === 0) return;
|
|
19836
19883
|
pageScrollLockCount -= 1;
|
|
19837
|
-
if (pageScrollLockCount > 0)
|
|
19838
|
-
return;
|
|
19884
|
+
if (pageScrollLockCount > 0) return;
|
|
19839
19885
|
document.body.style.overflow = savedBodyOverflow;
|
|
19840
19886
|
document.body.style.paddingRight = savedBodyPaddingRight;
|
|
19841
19887
|
document.body.style.position = savedBodyPosition;
|
|
@@ -19846,8 +19892,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19846
19892
|
savedScrollY = 0;
|
|
19847
19893
|
}
|
|
19848
19894
|
function ensureWalletStyle(id2, styles2) {
|
|
19849
|
-
if (typeof document === "undefined")
|
|
19850
|
-
return;
|
|
19895
|
+
if (typeof document === "undefined") return;
|
|
19851
19896
|
const selector = `style[data-xwk-style="${id2}"]`;
|
|
19852
19897
|
let element = document.head.querySelector(selector);
|
|
19853
19898
|
if (!element) {
|
|
@@ -19857,8 +19902,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19857
19902
|
} else if (element.nextSibling) {
|
|
19858
19903
|
document.head.appendChild(element);
|
|
19859
19904
|
}
|
|
19860
|
-
if (element.textContent !== styles2)
|
|
19861
|
-
element.textContent = styles2;
|
|
19905
|
+
if (element.textContent !== styles2) element.textContent = styles2;
|
|
19862
19906
|
}
|
|
19863
19907
|
const QR_SIZE = 304;
|
|
19864
19908
|
const QR_DARK = "#111827";
|
|
@@ -20481,30 +20525,30 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20481
20525
|
}
|
|
20482
20526
|
isRejectedError(error, message) {
|
|
20483
20527
|
if (isWalletKitError(error)) {
|
|
20484
|
-
return error.code ===
|
|
20528
|
+
return error.code === WalletKitErrorCode.CONNECTION_REJECTED || error.code === WalletKitErrorCode.SIGN_REJECTED;
|
|
20485
20529
|
}
|
|
20486
20530
|
return /reject|denied|cancelled|canceled|closed|user rejected|proposal expired|expired/i.test(message);
|
|
20487
20531
|
}
|
|
20488
20532
|
isTimeoutError(error, message) {
|
|
20489
|
-
if (isWalletKitError(error) && error.code ===
|
|
20533
|
+
if (isWalletKitError(error) && error.code === WalletKitErrorCode.REQUEST_TIMEOUT)
|
|
20490
20534
|
return true;
|
|
20491
20535
|
return /timeout|timed out/i.test(message);
|
|
20492
20536
|
}
|
|
20493
20537
|
getFriendlyErrorMessage(error) {
|
|
20494
20538
|
if (isWalletKitError(error)) {
|
|
20495
20539
|
switch (error.code) {
|
|
20496
|
-
case
|
|
20540
|
+
case WalletKitErrorCode.CONNECTION_REJECTED:
|
|
20497
20541
|
return "Connection was rejected in the wallet.";
|
|
20498
|
-
case
|
|
20542
|
+
case WalletKitErrorCode.SIGN_REJECTED:
|
|
20499
20543
|
return "Request was rejected in the wallet.";
|
|
20500
|
-
case
|
|
20544
|
+
case WalletKitErrorCode.REQUEST_TIMEOUT:
|
|
20501
20545
|
return "Wallet request timed out. Please try again.";
|
|
20502
|
-
case
|
|
20503
|
-
case
|
|
20546
|
+
case WalletKitErrorCode.WALLET_NOT_INSTALLED:
|
|
20547
|
+
case WalletKitErrorCode.WALLET_NOT_AVAILABLE:
|
|
20504
20548
|
return "Wallet is not available in this browser.";
|
|
20505
|
-
case
|
|
20549
|
+
case WalletKitErrorCode.UNSUPPORTED_METHOD:
|
|
20506
20550
|
return "This wallet does not support the requested action.";
|
|
20507
|
-
case
|
|
20551
|
+
case WalletKitErrorCode.NETWORK_MISMATCH:
|
|
20508
20552
|
return "Wallet network does not match this dApp.";
|
|
20509
20553
|
default:
|
|
20510
20554
|
return this.formatDisplayErrorMessage(error.message);
|
|
@@ -20698,7 +20742,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20698
20742
|
const spinnerSecondary = theme.spinnerTrail;
|
|
20699
20743
|
const qrLoadingColor = theme.muted;
|
|
20700
20744
|
const overlayBlur = theme.overlayBlur > 0 ? `blur(${theme.overlayBlur}px)` : "none";
|
|
20701
|
-
const styles2 = `.xwk-overlay{position:fixed;inset:0;background:${theme.overlay};-webkit-backdrop-filter:${overlayBlur};backdrop-filter:${overlayBlur};display:grid;overscroll-behavior:contain;place-items:center;z-index:2147483647;font-family:${theme.fontFamily};font-size:${bodyFontSize};opacity:0;padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));transition:opacity .2s ease-out}.xwk-overlay[data-xwk-state="open"]{opacity:1}.xwk-overlay[data-xwk-state="closing"]{opacity:0;transition-duration:.18s;transition-timing-function:cubic-bezier(.4,0,1,1)}.xwk-modal{box-sizing:border-box;display:block;width:min(${width},100%);max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));background:${theme.background};border:1px solid ${theme.border};border-radius:${theme.radius};box-shadow:${theme.shadow};color:${theme.foreground};opacity:0;overflow:hidden;transform:translateY(8px) scale(.97);transform-origin:center bottom;transition:opacity .24s cubic-bezier(.22,1,.36,1),transform .24s cubic-bezier(.22,1,.36,1)}.xwk-overlay[data-xwk-state="open"] .xwk-modal{opacity:1;transform:translateY(0) scale(1)}.xwk-overlay[data-xwk-state="closing"] .xwk-modal{opacity:0;transform:translateY(6px) scale(.985);transition-duration:.18s;transition-timing-function:cubic-bezier(.4,0,1,1)}.xwk-header{display:grid;grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;column-gap:8px;padding:8px 18px;background:${theme.headerBackground};border-bottom:1px solid ${theme.border}}.xwk-title{font-size:${titleFontSize};font-weight:500;text-align:center;color:${theme.foreground};min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-close,.xwk-back{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent;border:0;border-radius:999px;box-shadow:none;box-sizing:border-box;color:${theme.muted};cursor:pointer;display:inline-flex;font:inherit;height:44px;justify-content:center;margin:0;min-height:0;outline:none;overflow:hidden;padding:0;touch-action:manipulation;transform:none;width:44px}.xwk-back{justify-self:start}.xwk-close{font-size:26px;font-weight:500;justify-self:end;line-height:1}.xwk-close:hover,.xwk-back:hover{background:${theme.surfaceHover};box-shadow:none;color:${theme.foreground};transform:none}.xwk-close:focus-visible,.xwk-back:focus-visible,.xwk-wallet:focus-visible,.xwk-action:focus-visible,.xwk-qr-theme-action:focus-visible{outline:2px solid ${theme.accent};outline-offset:2px;text-decoration:none}.xwk-body{-webkit-overflow-scrolling:touch;box-sizing:border-box;max-height:min(620px,calc(100dvh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));overscroll-behavior:contain;overflow:auto;padding:12px 22px 18px}.xwk-list,.xwk-connect,.xwk-qr{display:none}.xwk-overlay[data-xwk-view="list"] .xwk-list{display:block}.xwk-overlay[data-xwk-view="connect"] .xwk-connect{display:block}.xwk-overlay[data-xwk-view="qr"] .xwk-qr{display:block}.xwk-network-row{align-items:center;display:flex;justify-content:flex-end;margin:-2px 0 8px;min-height:22px}.xwk-network-badge{align-items:center;background:${this.resolveThemeMode() === "dark" ? "rgba(245,158,11,.12)" : "#fef3c7"};border:1px solid ${this.resolveThemeMode() === "dark" ? "rgba(245,158,11,.20)" : "#fde68a"};border-radius:999px;color:${this.resolveThemeMode() === "dark" ? "#fbbf24" : "#92400e"};display:inline-flex;font-size:10px;font-weight:560;letter-spacing:0;line-height:1;padding:5px 9px;text-transform:none}.xwk-network-dot{border-radius:999px;display:inline-block;height:6px;margin-right:5px;width:6px}.xwk-grid{display:grid;grid-template-columns:${gridColumns};gap:7px}.xwk-wallet{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.surface};border:0;border-radius:${theme.walletRadius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:flex;flex-direction:${walletDirection};font:inherit;gap:12px;justify-content:${layout === "list" ? "flex-start" : "center"};line-height:1.2;margin:0;min-height:${walletMinHeight};min-width:0;outline:none;overflow:hidden;padding:${layout === "list" ? "12px 12px" : "12px 10px"};text-align:${textAlign};touch-action:manipulation;transform:none;transition:background-color .16s ease;width:100%}.xwk-wallet:hover{background:${theme.surfaceHover};box-shadow:none;transform:none}.xwk-wallet:active{background:${theme.surfaceHover};transform:none}.xwk-wallet img:not(.xwk-mini-icon),.xwk-icon-fallback{border-radius:${theme.walletRadius};flex:0 0 auto;height:${iconSize};object-fit:contain;overflow:hidden;width:${iconSize}}.xwk-icon-fallback{align-items:center;background:${theme.accent};color:${theme.accentText};display:inline-flex;font-weight:700;justify-content:center}.xwk-wallet-group{margin-top:0;min-height:${walletMinHeight}}.xwk-wallet-group .xwk-wallet-info{align-items:center;display:${layout === "list" ? "flex" : "grid"};gap:${layout === "list" ? "10px" : "2px"}}.xwk-wallet-group .xwk-name{flex:1 1 auto}.xwk-wallet-group .xwk-group{display:${layout === "list" ? "none" : groupDisplay}}.xwk-group-placeholder{visibility:hidden}.xwk-wallet-info{display:grid;gap:2px;min-width:0;width:100%}.xwk-name{color:${walletNameColor};display:block;font-size:${layout === "list" ? nameFontSize : gridNameFontSize};font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-group{color:${theme.muted};display:${groupDisplay};font-size:${groupFontSize};font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-group-icons{align-items:center;display:${layout === "list" ? "inline-flex" : "none"};flex:0 0 auto;gap:4px;justify-content:flex-end;margin-left:auto;min-width:0}.xwk-mini-icon,.xwk-mini-fallback,.xwk-mini-more{align-items:center;border:1px solid ${miniIconBorder};border-radius:10px;box-sizing:border-box;display:inline-flex;flex:0 0 auto;height:32px;justify-content:center;object-fit:cover;overflow:hidden;width:32px}.xwk-mini-fallback,.xwk-mini-more{background:${theme.background};color:${theme.muted};font-size:12px;font-weight:600}.xwk-mini-more{border-radius:999px;width:auto;min-width:32px;padding:0 8px}.xwk-wallet-badges{align-items:center;display:inline-flex;flex:0 0 auto;gap:6px;justify-content:flex-end;margin-left:auto;min-width:0}.xwk-wallet-badge{align-items:center;background:${badgeBackground};border:1px solid ${badgeBorder};border-radius:999px;color:${badgeColor};display:inline-flex;flex:0 0 auto;font-size:11px;font-weight:500;gap:6px;line-height:1;min-height:24px;padding:0 10px;visibility:hidden}.xwk-wallet-badge:before{background:${badgeDot};border-radius:999px;content:"";height:6px;width:6px}.xwk-wallet-badge.xwk-installed,.xwk-wallet-badge.xwk-recommended{visibility:visible}.xwk-wallet-badge.xwk-recommended{background:${recommendedBadgeBackground};border-color:${recommendedBadgeBorder};color:${theme.accent}}.xwk-wallet-badge.xwk-recommended:before{background:currentColor}.xwk-status{color:${theme.accent};font-size:12px;margin-top:8px;min-height:0;max-width:100%;overflow-wrap:anywhere}.xwk-status.xwk-error,.xwk-error-text{color:${theme.error}}.xwk-status.xwk-error{background:${theme.surface};border:1px solid ${theme.border};border-radius:10px;box-sizing:border-box;line-height:1.35;padding:9px 10px}.xwk-hidden{display:none}.xwk-back.xwk-hidden{display:inline-flex;pointer-events:none;visibility:hidden}.xwk-connect{text-align:center;padding:30px 0 16px}.xwk-spinner{display:grid;margin:0 auto 16px;place-items:center;position:relative;width:104px;height:104px}.xwk-spinner:before{animation:xwk-spin 1s linear infinite;border:3px solid transparent;border-top-color:${spinnerPrimary};border-right-color:${spinnerSecondary};border-radius:50%;content:"";height:96px;position:absolute;width:96px}.xwk-connect-icon img,.xwk-connect-icon .xwk-icon-fallback{border-radius:${theme.walletRadius};height:66px;object-fit:contain;overflow:hidden;width:66px}.xwk-connect-name{display:block;font-size:${nameFontSize};font-weight:600;margin-top:4px}.xwk-connect-status{color:${theme.muted};font-size:${bodyFontSize};font-weight:400;line-height:1.45;margin:14px auto 0;max-width:420px}.xwk-qr{text-align:center}.xwk-qr-title{color:${theme.foreground};font-size:${titleFontSize};font-weight:500;margin:0 0 14px}.xwk-qr-card{background:${theme.surface};border:1px solid ${theme.border};border-radius:14px;box-sizing:border-box;display:flex;flex-direction:column;justify-content:space-between;margin:0 auto 10px;min-height:386px;padding:12px;width:min(332px,100%)}.xwk-qr-code-wrap{position:relative;flex:0 0 auto;margin:0 auto 10px;width:100%}.xwk-qr-code{aspect-ratio:1/1;background:transparent;border:0;border-radius:10px;box-sizing:border-box;color:${theme.muted};display:grid;min-height:0;padding:0;place-items:center;width:100%}.xwk-qr-code-light{background:#fff;padding:8px}.xwk-qr-theme-action{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.background};border:1px solid ${actionBorder};border-radius:999px;box-shadow:none;box-sizing:border-box;color:${theme.muted};cursor:pointer;display:inline-flex;height:34px;justify-content:center;margin:0;min-height:0;opacity:0;outline:none;padding:0;pointer-events:none;position:absolute;right:8px;top:8px;touch-action:manipulation;transform:none;transition:opacity .14s ease,background-color .16s ease,border-color .16s ease,color .16s ease;width:34px}.xwk-qr-code-wrap:hover .xwk-qr-theme-action,.xwk-qr-code-wrap:focus-within .xwk-qr-theme-action,.xwk-qr-theme-action:focus-visible{opacity:1;pointer-events:auto}.xwk-qr-theme-action:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;color:${theme.foreground};transform:none}.xwk-qr-theme-action svg{height:17px;width:17px}.xwk-qr-code canvas,.xwk-qr-code img,.xwk-qr-code svg{aspect-ratio:1/1;display:block;height:auto;max-width:100%;width:100%}.xwk-qr-loading{align-items:center;color:${qrLoadingColor};display:inline-flex;font-size:13px;gap:8px}.xwk-qr-message{align-items:center;color:${theme.muted};display:grid;font-size:${bodyFontSize};gap:7px;line-height:1.35;max-width:260px;text-align:center}.xwk-qr-message strong{color:${theme.foreground};font-size:${nameFontSize};font-weight:600}.xwk-qr-message span{display:block;max-width:100%;overflow-wrap:anywhere}.xwk-qr-loading-spinner{animation:xwk-spin 1s linear infinite;border:2px solid ${spinnerSecondary};border-top-color:${spinnerPrimary};border-radius:999px;display:inline-block;height:18px;width:18px}.xwk-qr-help{color:${theme.muted};font-size:${bodyFontSize};font-weight:400;line-height:1.35;margin:10px auto 0;max-width:420px;min-height:22px;white-space:nowrap}.xwk-qr-fallback{color:${theme.muted};font-size:11px;line-height:1.5;overflow-wrap:anywhere}.xwk-actions{display:grid;gap:10px;grid-template-columns:1fr 1fr;margin-top:14px}.xwk-qr-card-actions{display:grid;flex:0 0 auto;gap:10px;grid-template-columns:1fr;min-height:46px}.xwk-qr-card-actions-dual{grid-template-columns:repeat(auto-fit,minmax(0,1fr))}.xwk-qr-card-actions-placeholder{visibility:hidden}.xwk-action{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:inline-flex;font:inherit;font-size:${bodyFontSize};font-weight:560;gap:8px;justify-content:center;line-height:1.2;margin:0;min-height:46px;min-width:0;outline:none;overflow:hidden;padding:0 12px;text-decoration:none;touch-action:manipulation;transform:none;transition:background-color .16s ease,border-color .16s ease;white-space:nowrap;width:100%}.xwk-copy-inside{background:${theme.surface};border-color:${actionBorder};color:${theme.foreground};font-size:${bodyFontSize};width:100%}.xwk-action:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;text-decoration:none;transform:none}.xwk-action:active{background:${theme.surfaceHover};box-shadow:none;opacity:1;text-decoration:none;transform:none}.xwk-copy-inside:hover{background:${theme.surfaceHover};box-shadow:none;text-decoration:none}.xwk-action-primary{background:${theme.surface};border-color:${actionBorder};color:${theme.foreground}}.xwk-action-primary:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;color:${theme.foreground};text-decoration:none}.xwk-action svg{flex:0 0 auto;opacity:.58}.xwk-copied-icon{color:${theme.success};opacity:1!important}.xwk-action:disabled{cursor:default;opacity:.76}.xwk-retrying .xwk-refresh-icon{animation:xwk-spin .7s linear infinite}.xwk-footer{border-top:0;color:${theme.muted};font-size:11px;font-weight:400;padding:12px 16px 14px;text-align:center}@keyframes xwk-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.xwk-overlay,.xwk-modal,.xwk-wallet,.xwk-action,.xwk-close,.xwk-back,.xwk-qr-theme-action{transition-duration:1ms!important;animation-duration:1ms!important}.xwk-spinner:before,.xwk-qr-loading-spinner{animation:none}}@media(max-width:640px){.xwk-overlay{padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left));place-items:end center}.xwk-modal{border-bottom-left-radius:0;border-bottom-right-radius:0;max-height:calc(100dvh - 24px - env(safe-area-inset-top));transform:translateY(100%);width:100%}.xwk-overlay[data-xwk-state="open"] .xwk-modal{transform:translateY(0);transition-duration:.32s;transition-timing-function:cubic-bezier(.32,.72,0,1)}.xwk-overlay[data-xwk-state="closing"] .xwk-modal{transform:translateY(100%);transition-duration:.24s;transition-timing-function:cubic-bezier(.4,0,1,1)}.xwk-header{grid-template-columns:44px minmax(0,1fr) 44px;column-gap:8px;padding:10px 16px}.xwk-body{max-height:calc(100dvh - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:14px 16px 16px}.xwk-grid{grid-template-columns:${layout === "icon" ? "repeat(3,minmax(0,1fr))" : "1fr"}}.xwk-wallet-badges{gap:4px}.xwk-wallet-badge{font-size:10px;min-height:22px;padding:0 8px}.xwk-actions{grid-template-columns:1fr}.xwk-qr-card{min-height:358px;padding:12px;width:min(304px,100%)}.xwk-qr-code-wrap{width:100%}.xwk-action{font-size:clamp(12px,3.55vw,${bodyFontSize});gap:6px;padding:0 10px}.xwk-action svg{height:17px;width:17px;flex:0 0 auto}.xwk-qr-card-actions-dual{grid-template-columns:1fr}.xwk-qr-help{font-size:clamp(12px,3.45vw,${bodyFontSize});min-height:38px;white-space:normal}}@media(max-width:360px){.xwk-qr-card{min-height:354px;width:min(284px,100%)}}@media(max-height:560px){.xwk-body{max-height:calc(100dvh - 96px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:10px 16px}.xwk-connect{padding:18px 0 10px}.xwk-spinner{height:82px;margin-bottom:12px;width:82px}.xwk-spinner:before{height:76px;width:76px}.xwk-connect-icon img,.xwk-connect-icon .xwk-icon-fallback{border-radius:${theme.walletRadius};height:54px;width:54px}.xwk-qr-card{min-height:320px;width:min(260px,100%)}.xwk-qr-title{margin-bottom:10px}.xwk-qr-help{margin-top:8px}.xwk-footer{padding:8px 16px 10px}}`;
|
|
20745
|
+
const styles2 = `.xwk-overlay{position:fixed;inset:0;background:${theme.overlay};-webkit-backdrop-filter:${overlayBlur};backdrop-filter:${overlayBlur};display:grid;overscroll-behavior:contain;place-items:center;z-index:var(--xwk-layer-modal,2147483000);font-family:${theme.fontFamily};font-size:${bodyFontSize};opacity:0;padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));transition:opacity .2s ease-out}.xwk-overlay[data-xwk-state="open"]{opacity:1}.xwk-overlay[data-xwk-state="closing"]{opacity:0;transition-duration:.18s;transition-timing-function:cubic-bezier(.4,0,1,1)}.xwk-modal{box-sizing:border-box;display:block;width:min(${width},100%);max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));background:${theme.background};border:1px solid ${theme.border};border-radius:${theme.radius};box-shadow:${theme.shadow};color:${theme.foreground};opacity:0;overflow:hidden;transform:translateY(8px) scale(.97);transform-origin:center bottom;transition:opacity .24s cubic-bezier(.22,1,.36,1),transform .24s cubic-bezier(.22,1,.36,1)}.xwk-overlay[data-xwk-state="open"] .xwk-modal{opacity:1;transform:translateY(0) scale(1)}.xwk-overlay[data-xwk-state="closing"] .xwk-modal{opacity:0;transform:translateY(6px) scale(.985);transition-duration:.18s;transition-timing-function:cubic-bezier(.4,0,1,1)}.xwk-header{display:grid;grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;column-gap:8px;padding:8px 18px;background:${theme.headerBackground};border-bottom:1px solid ${theme.border}}.xwk-title{font-size:${titleFontSize};font-weight:600;letter-spacing:0;text-align:center;color:${theme.foreground};min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-close,.xwk-back{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent;border:0;border-radius:999px;box-shadow:none;box-sizing:border-box;color:${theme.muted};cursor:pointer;display:inline-flex;font:inherit;height:44px;justify-content:center;margin:0;min-height:0;outline:none;overflow:hidden;padding:0;touch-action:manipulation;transform:none;width:44px}.xwk-back{justify-self:start}.xwk-close{font-size:26px;font-weight:500;justify-self:end;line-height:1}.xwk-close:hover,.xwk-back:hover{background:${theme.surfaceHover};box-shadow:none;color:${theme.foreground};transform:none}.xwk-close:focus-visible,.xwk-back:focus-visible,.xwk-wallet:focus-visible,.xwk-action:focus-visible,.xwk-qr-theme-action:focus-visible{outline:2px solid ${theme.accent};outline-offset:2px;text-decoration:none}.xwk-body{-webkit-overflow-scrolling:touch;box-sizing:border-box;max-height:min(620px,calc(100dvh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));overscroll-behavior:contain;overflow:auto;padding:12px 22px 18px}.xwk-list,.xwk-connect,.xwk-qr{display:none}.xwk-overlay[data-xwk-view="list"] .xwk-list{display:block}.xwk-overlay[data-xwk-view="connect"] .xwk-connect{display:block}.xwk-overlay[data-xwk-view="qr"] .xwk-qr{display:block}.xwk-network-row{align-items:center;display:flex;justify-content:flex-end;margin:-2px 0 8px;min-height:22px}.xwk-network-badge{align-items:center;background:${this.resolveThemeMode() === "dark" ? "rgba(245,158,11,.12)" : "#fef3c7"};border:1px solid ${this.resolveThemeMode() === "dark" ? "rgba(245,158,11,.20)" : "#fde68a"};border-radius:999px;color:${this.resolveThemeMode() === "dark" ? "#fbbf24" : "#92400e"};display:inline-flex;font-size:10px;font-weight:560;letter-spacing:0;line-height:1;padding:5px 9px;text-transform:none}.xwk-network-dot{border-radius:999px;display:inline-block;height:6px;margin-right:5px;width:6px}.xwk-grid{display:grid;grid-template-columns:${gridColumns};gap:7px}.xwk-wallet{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.surface};border:0;border-radius:${theme.walletRadius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:flex;flex-direction:${walletDirection};font:inherit;gap:12px;justify-content:${layout === "list" ? "flex-start" : "center"};line-height:1.2;margin:0;min-height:${walletMinHeight};min-width:0;outline:none;overflow:hidden;padding:${layout === "list" ? "12px 12px" : "12px 10px"};text-align:${textAlign};touch-action:manipulation;transform:none;transition:background-color .16s ease;width:100%}.xwk-wallet:hover{background:${theme.surfaceHover};box-shadow:none;transform:none}.xwk-wallet:active{background:${theme.surfaceHover};transform:none}.xwk-wallet img:not(.xwk-mini-icon),.xwk-icon-fallback{border-radius:${theme.walletRadius};flex:0 0 auto;height:${iconSize};object-fit:contain;overflow:hidden;width:${iconSize}}.xwk-icon-fallback{align-items:center;background:${theme.accent};color:${theme.accentText};display:inline-flex;font-weight:700;justify-content:center}.xwk-wallet-group{margin-top:0;min-height:${walletMinHeight}}.xwk-wallet-group .xwk-wallet-info{align-items:center;display:${layout === "list" ? "flex" : "grid"};gap:${layout === "list" ? "10px" : "2px"}}.xwk-wallet-group .xwk-name{flex:1 1 auto}.xwk-wallet-group .xwk-group{display:${layout === "list" ? "none" : groupDisplay}}.xwk-group-placeholder{visibility:hidden}.xwk-wallet-info{display:grid;gap:2px;min-width:0;width:100%}.xwk-name{color:${walletNameColor};display:block;font-size:${layout === "list" ? nameFontSize : gridNameFontSize};font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-group{color:${theme.muted};display:${groupDisplay};font-size:${groupFontSize};font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-group-icons{align-items:center;display:${layout === "list" ? "inline-flex" : "none"};flex:0 0 auto;gap:4px;justify-content:flex-end;margin-left:auto;min-width:0}.xwk-mini-icon,.xwk-mini-fallback,.xwk-mini-more{align-items:center;border:1px solid ${miniIconBorder};border-radius:10px;box-sizing:border-box;display:inline-flex;flex:0 0 auto;height:32px;justify-content:center;object-fit:cover;overflow:hidden;width:32px}.xwk-mini-fallback,.xwk-mini-more{background:${theme.background};color:${theme.muted};font-size:12px;font-weight:600}.xwk-mini-more{border-radius:999px;width:auto;min-width:32px;padding:0 8px}.xwk-wallet-badges{align-items:center;display:inline-flex;flex:0 0 auto;gap:6px;justify-content:flex-end;margin-left:auto;min-width:0}.xwk-wallet-badge{align-items:center;background:${badgeBackground};border:1px solid ${badgeBorder};border-radius:999px;color:${badgeColor};display:inline-flex;flex:0 0 auto;font-size:11px;font-weight:500;gap:6px;line-height:1;min-height:24px;padding:0 10px;visibility:hidden}.xwk-wallet-badge:before{background:${badgeDot};border-radius:999px;content:"";height:6px;width:6px}.xwk-wallet-badge.xwk-installed,.xwk-wallet-badge.xwk-recommended{visibility:visible}.xwk-wallet-badge.xwk-recommended{background:${recommendedBadgeBackground};border-color:${recommendedBadgeBorder};color:${theme.accent}}.xwk-wallet-badge.xwk-recommended:before{background:currentColor}.xwk-status{color:${theme.accent};font-size:12px;margin-top:8px;min-height:0;max-width:100%;overflow-wrap:anywhere}.xwk-status.xwk-error,.xwk-error-text{color:${theme.error}}.xwk-status.xwk-error{background:${theme.surface};border:1px solid ${theme.border};border-radius:10px;box-sizing:border-box;line-height:1.35;padding:9px 10px}.xwk-hidden{display:none}.xwk-back.xwk-hidden{display:inline-flex;pointer-events:none;visibility:hidden}.xwk-connect{text-align:center;padding:30px 0 16px}.xwk-spinner{display:grid;margin:0 auto 16px;place-items:center;position:relative;width:104px;height:104px}.xwk-spinner:before{animation:xwk-spin 1s linear infinite;border:3px solid transparent;border-top-color:${spinnerPrimary};border-right-color:${spinnerSecondary};border-radius:50%;content:"";height:96px;position:absolute;width:96px}.xwk-connect-icon img,.xwk-connect-icon .xwk-icon-fallback{border-radius:${theme.walletRadius};height:66px;object-fit:contain;overflow:hidden;width:66px}.xwk-connect-name{display:block;font-size:${nameFontSize};font-weight:600;margin-top:4px}.xwk-connect-status{color:${theme.muted};font-size:${bodyFontSize};font-weight:400;line-height:1.45;margin:14px auto 0;max-width:420px}.xwk-qr{text-align:center}.xwk-qr-title{color:${theme.foreground};font-size:${titleFontSize};font-weight:500;margin:0 0 14px}.xwk-qr-card{background:${theme.surface};border:1px solid ${theme.border};border-radius:14px;box-sizing:border-box;display:flex;flex-direction:column;justify-content:space-between;margin:0 auto 10px;min-height:386px;padding:12px;width:min(332px,100%)}.xwk-qr-code-wrap{position:relative;flex:0 0 auto;margin:0 auto 10px;width:100%}.xwk-qr-code{aspect-ratio:1/1;background:transparent;border:0;border-radius:10px;box-sizing:border-box;color:${theme.muted};display:grid;min-height:0;padding:0;place-items:center;width:100%}.xwk-qr-code-light{background:${QR_LIGHT};padding:8px}.xwk-qr-theme-action{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.background};border:1px solid ${actionBorder};border-radius:999px;box-shadow:none;box-sizing:border-box;color:${theme.muted};cursor:pointer;display:inline-flex;height:34px;justify-content:center;margin:0;min-height:0;opacity:0;outline:none;padding:0;pointer-events:none;position:absolute;right:8px;top:8px;touch-action:manipulation;transform:none;transition:opacity .14s ease,background-color .16s ease,border-color .16s ease,color .16s ease;width:34px}.xwk-qr-code-wrap:hover .xwk-qr-theme-action,.xwk-qr-code-wrap:focus-within .xwk-qr-theme-action,.xwk-qr-theme-action:focus-visible{opacity:1;pointer-events:auto}.xwk-qr-theme-action:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;color:${theme.foreground};transform:none}.xwk-qr-theme-action svg{height:17px;width:17px}.xwk-qr-code canvas,.xwk-qr-code img,.xwk-qr-code svg{aspect-ratio:1/1;display:block;height:auto;max-width:100%;width:100%}.xwk-qr-loading{align-items:center;color:${qrLoadingColor};display:inline-flex;font-size:13px;gap:8px}.xwk-qr-message{align-items:center;color:${theme.muted};display:grid;font-size:${bodyFontSize};gap:7px;line-height:1.35;max-width:260px;text-align:center}.xwk-qr-message strong{color:${theme.foreground};font-size:${nameFontSize};font-weight:600}.xwk-qr-message span{display:block;max-width:100%;overflow-wrap:anywhere}.xwk-qr-loading-spinner{animation:xwk-spin 1s linear infinite;border:2px solid ${spinnerSecondary};border-top-color:${spinnerPrimary};border-radius:999px;display:inline-block;height:18px;width:18px}.xwk-qr-help{color:${theme.muted};font-size:${bodyFontSize};font-weight:400;line-height:1.35;margin:10px auto 0;max-width:420px;min-height:22px;white-space:nowrap}.xwk-qr-fallback{color:${theme.muted};font-size:11px;line-height:1.5;overflow-wrap:anywhere}.xwk-actions{display:grid;gap:10px;grid-template-columns:1fr 1fr;margin-top:14px}.xwk-qr-card-actions{display:grid;flex:0 0 auto;gap:10px;grid-template-columns:1fr;min-height:46px}.xwk-qr-card-actions-dual{grid-template-columns:repeat(auto-fit,minmax(0,1fr))}.xwk-qr-card-actions-placeholder{visibility:hidden}.xwk-action{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:inline-flex;font:inherit;font-size:${bodyFontSize};font-weight:560;gap:8px;justify-content:center;line-height:1.2;margin:0;min-height:46px;min-width:0;outline:none;overflow:hidden;padding:0 12px;text-decoration:none;touch-action:manipulation;transform:none;transition:background-color .16s ease,border-color .16s ease;white-space:nowrap;width:100%}.xwk-copy-inside{background:${theme.surface};border-color:${actionBorder};color:${theme.foreground};font-size:${bodyFontSize};width:100%}.xwk-action:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;text-decoration:none;transform:none}.xwk-action:active{background:${theme.surfaceHover};box-shadow:none;opacity:1;text-decoration:none;transform:none}.xwk-copy-inside:hover{background:${theme.surfaceHover};box-shadow:none;text-decoration:none}.xwk-action-primary{background:${theme.surface};border-color:${actionBorder};color:${theme.foreground}}.xwk-action-primary:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;color:${theme.foreground};text-decoration:none}.xwk-action svg{flex:0 0 auto;opacity:.58}.xwk-copied-icon{--xwk-success-icon-foreground:${theme.background};color:${theme.success};opacity:1!important}.xwk-action:disabled{cursor:default;opacity:.76}.xwk-retrying .xwk-refresh-icon{animation:xwk-spin .7s linear infinite}.xwk-footer{border-top:0;color:${theme.muted};font-size:11px;font-weight:400;padding:12px 16px 14px;text-align:center}@keyframes xwk-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.xwk-overlay,.xwk-modal,.xwk-wallet,.xwk-action,.xwk-close,.xwk-back,.xwk-qr-theme-action{transition-duration:1ms!important;animation-duration:1ms!important}.xwk-spinner:before,.xwk-qr-loading-spinner{animation:none}}@media(max-width:640px){.xwk-overlay{padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left));place-items:end center}.xwk-modal{border-bottom-left-radius:0;border-bottom-right-radius:0;max-height:calc(100dvh - 24px - env(safe-area-inset-top));transform:translateY(100%);width:100%}.xwk-overlay[data-xwk-state="open"] .xwk-modal{transform:translateY(0);transition-duration:.32s;transition-timing-function:cubic-bezier(.32,.72,0,1)}.xwk-overlay[data-xwk-state="closing"] .xwk-modal{transform:translateY(100%);transition-duration:.24s;transition-timing-function:cubic-bezier(.4,0,1,1)}.xwk-header{grid-template-columns:44px minmax(0,1fr) 44px;column-gap:8px;padding:10px 16px}.xwk-body{max-height:calc(100dvh - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:14px 16px 16px}.xwk-grid{grid-template-columns:${layout === "icon" ? "repeat(3,minmax(0,1fr))" : "1fr"}}.xwk-wallet-badges{gap:4px}.xwk-wallet-badge{font-size:10px;min-height:22px;padding:0 8px}.xwk-actions{grid-template-columns:1fr}.xwk-qr-card{min-height:358px;padding:12px;width:min(304px,100%)}.xwk-qr-code-wrap{width:100%}.xwk-action{font-size:clamp(12px,3.55vw,${bodyFontSize});gap:6px;padding:0 10px}.xwk-action svg{height:17px;width:17px;flex:0 0 auto}.xwk-qr-card-actions-dual{grid-template-columns:1fr}.xwk-qr-help{font-size:clamp(12px,3.45vw,${bodyFontSize});min-height:38px;white-space:normal}}@media(max-width:360px){.xwk-qr-card{min-height:354px;width:min(284px,100%)}}@media(max-height:560px){.xwk-body{max-height:calc(100dvh - 96px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:10px 16px}.xwk-connect{padding:18px 0 10px}.xwk-spinner{height:82px;margin-bottom:12px;width:82px}.xwk-spinner:before{height:76px;width:76px}.xwk-connect-icon img,.xwk-connect-icon .xwk-icon-fallback{border-radius:${theme.walletRadius};height:54px;width:54px}.xwk-qr-card{min-height:320px;width:min(260px,100%)}.xwk-qr-title{margin-bottom:10px}.xwk-qr-help{margin-top:8px}.xwk-footer{padding:8px 16px 10px}}`;
|
|
20702
20746
|
this.cachedStyleKey = styleKey;
|
|
20703
20747
|
this.cachedStyle = styles2;
|
|
20704
20748
|
return styles2;
|
|
@@ -20709,8 +20753,8 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20709
20753
|
}
|
|
20710
20754
|
renderMobileSheetOverrides(theme) {
|
|
20711
20755
|
const inlineOverrides = `.xwk-inline{background:transparent!important;display:block!important;inset:auto!important;opacity:1!important;overflow:visible!important;padding:0!important;place-items:initial!important;position:relative!important;z-index:auto!important}.xwk-inline .xwk-modal{border:1px solid ${theme.border}!important;border-radius:${theme.radius}!important;box-shadow:none!important;max-height:none!important;max-width:none!important;opacity:1!important;transform:none!important;transition:none!important;width:100%!important}.xwk-inline .xwk-body{max-height:none!important}.xwk-inline .xwk-header-spacer{display:block;height:44px;width:44px}.xwk-inline[data-xwk-state="closing"] .xwk-modal{opacity:1!important;transform:none!important}`;
|
|
20712
|
-
const skeletonOverrides = `.xwk-skeleton{animation:xwk-qr-skeleton-pulse 1.4s ease-in-out infinite;background:linear-gradient(90deg,${theme.surface} 25%,${theme.surfaceHover} 50%,${theme.surface} 75%);background-size:200% 100%;display:inline-block}.xwk-skeleton-circle{border-radius:999px}.xwk-skeleton-line{height:14px;border-radius:4px}.xwk-skeleton-pill{border-radius:999px}.xwk-skeleton-card,.xwk-skeleton-button{border-radius:${theme.walletRadius}}.xwk-skeleton-row{align-items:center;display:flex;gap:12px;width:100%}.xwk-qr-loading-skeleton{display:grid;height:100%;place-items:stretch;width:100%}.xwk-qr-skeleton{border-radius:10px;box-sizing:border-box;display:block;height:100%;overflow:hidden;position:relative;width:100%}.xwk-qr-skeleton:before{background
|
|
20713
|
-
return `${skeletonOverrides}.xwk-modal:focus{outline:none}.xwk-sr-only{border:0!important;clip:rect(0 0 0 0)!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;white-space:nowrap!important;width:1px!important}.xwk-error-text,.xwk-connect-status.xwk-error-text,.xwk-qr-loading.xwk-error-text{color:${theme.error}!important}.xwk-close,.xwk-back{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;appearance:none;background:transparent!important;border:0!important;box-shadow:none!important;margin:0;outline:none!important}.xwk-close:focus-visible,.xwk-back:focus-visible{outline:2px solid ${theme.accent}!important;outline-offset:0}@media(max-width:640px){.xwk-overlay{padding:max(12px,env(safe-area-inset-top)) 0 0!important;place-items:end center!important}.xwk-modal{align-self:end!important;border-bottom:0!important;border-bottom-left-radius:0!important;border-bottom-right-radius:0!important;border-left:0!important;border-right:0!important;border-top-left-radius:${theme.radius}!important;border-top-right-radius:${theme.radius}!important;height:auto!important;max-height:calc(100dvh - env(safe-area-inset-top))!important;max-width:none!important;width:
|
|
20756
|
+
const skeletonOverrides = `.xwk-skeleton{animation:xwk-qr-skeleton-pulse 1.4s ease-in-out infinite;background:linear-gradient(90deg,${theme.surface} 25%,${theme.surfaceHover} 50%,${theme.surface} 75%);background-size:200% 100%;display:inline-block}.xwk-skeleton-circle{border-radius:999px}.xwk-skeleton-line{height:14px;border-radius:4px}.xwk-skeleton-pill{border-radius:999px}.xwk-skeleton-card,.xwk-skeleton-button{border-radius:${theme.walletRadius}}.xwk-skeleton-row{align-items:center;display:flex;gap:12px;width:100%}.xwk-qr-loading-skeleton{display:grid;height:100%;place-items:stretch;width:100%}.xwk-qr-skeleton{background:${theme.surface};border-radius:10px;box-sizing:border-box;display:block;height:100%;overflow:hidden;position:relative;width:100%}.xwk-qr-skeleton:before{background:linear-gradient(90deg,${theme.surface} 0%,${theme.surfaceHover} 48%,${theme.surface} 100%);content:"";inset:0;opacity:.72;position:absolute}.xwk-qr-skeleton:after{animation:xwk-qr-shimmer 1.35s ease-in-out infinite;background:linear-gradient(90deg,transparent 0%,${theme.surfaceHover} 42%,${theme.background} 50%,${theme.surfaceHover} 58%,transparent 100%);content:"";inset:0;opacity:.58;position:absolute;transform:translateX(-115%);will-change:transform}.xwk-wallet-badge-loading{color:transparent;min-width:72px;visibility:visible}.xwk-wallet-badge-loading:before{display:none}@keyframes xwk-qr-skeleton-pulse{0%{background-position:200% 0}100%{background-position:-200% 0}}@keyframes xwk-qr-shimmer{0%{transform:translateX(-115%)}100%{transform:translateX(115%)}}@media(prefers-reduced-motion:reduce){.xwk-skeleton,.xwk-qr-skeleton,.xwk-qr-skeleton:after{animation:none!important}.xwk-skeleton,.xwk-qr-skeleton{background:${theme.surfaceHover}!important}.xwk-qr-skeleton:after{display:none!important}}`;
|
|
20757
|
+
return `${skeletonOverrides}.xwk-modal:focus{outline:none}.xwk-sr-only{border:0!important;clip:rect(0 0 0 0)!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;white-space:nowrap!important;width:1px!important}.xwk-error-text,.xwk-connect-status.xwk-error-text,.xwk-qr-loading.xwk-error-text{color:${theme.error}!important}.xwk-close,.xwk-back{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;appearance:none;background:transparent!important;border:0!important;box-shadow:none!important;margin:0;outline:none!important}.xwk-close:focus-visible,.xwk-back:focus-visible{outline:2px solid ${theme.accent}!important;outline-offset:0}@media(max-width:640px){.xwk-overlay{padding:max(12px,env(safe-area-inset-top)) 0 0!important;place-items:end center!important}.xwk-modal{align-self:end!important;border-bottom:0!important;border-bottom-left-radius:0!important;border-bottom-right-radius:0!important;border-left:0!important;border-right:0!important;border-top-left-radius:${theme.radius}!important;border-top-right-radius:${theme.radius}!important;height:auto!important;max-height:calc(100dvh - env(safe-area-inset-top))!important;max-width:none!important;width:100%!important}.xwk-header{border-top-left-radius:${theme.radius};border-top-right-radius:${theme.radius}}.xwk-body{padding-bottom:max(6px,calc(6px + env(safe-area-inset-bottom)))!important}.xwk-overlay[data-xwk-view="list"] .xwk-body{padding-bottom:max(2px,calc(2px + env(safe-area-inset-bottom)))!important}.xwk-network-row{margin:-4px 0 8px!important}.xwk-overlay[data-xwk-view="list"] .xwk-footer{padding-top:6px!important}}${inlineOverrides}`;
|
|
20714
20758
|
}
|
|
20715
20759
|
renderWalletList(layout) {
|
|
20716
20760
|
const groups = this.getGroups();
|
|
@@ -20812,7 +20856,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20812
20856
|
return `<svg width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="2"/><path d="M12 2v2.2M12 19.8V22M4.9 4.9l1.6 1.6M17.5 17.5l1.6 1.6M2 12h2.2M19.8 12H22M4.9 19.1l1.6-1.6M17.5 6.5l1.6-1.6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`;
|
|
20813
20857
|
}
|
|
20814
20858
|
checkIcon() {
|
|
20815
|
-
return `<svg class="xwk-copied-icon" width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="currentColor"/><path d="m7.8 12.4 2.7 2.7 5.9-6.2" stroke="
|
|
20859
|
+
return `<svg class="xwk-copied-icon" width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="currentColor"/><path d="m7.8 12.4 2.7 2.7 5.9-6.2" stroke="var(--xwk-success-icon-foreground,currentColor)" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
20816
20860
|
}
|
|
20817
20861
|
messages() {
|
|
20818
20862
|
return resolveWalletUiMessages(this.options.language, this.options.messages);
|
|
@@ -20871,7 +20915,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20871
20915
|
color: qrColor
|
|
20872
20916
|
},
|
|
20873
20917
|
backgroundOptions: {
|
|
20874
|
-
color: this.qrLightMode ?
|
|
20918
|
+
color: this.qrLightMode ? QR_LIGHT : "transparent"
|
|
20875
20919
|
}
|
|
20876
20920
|
});
|
|
20877
20921
|
qrCode.append(container);
|
|
@@ -20883,7 +20927,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20883
20927
|
width: QR_SIZE,
|
|
20884
20928
|
color: {
|
|
20885
20929
|
dark: QR_DARK,
|
|
20886
|
-
light:
|
|
20930
|
+
light: QR_LIGHT
|
|
20887
20931
|
}
|
|
20888
20932
|
});
|
|
20889
20933
|
const image = document.createElement("img");
|
|
@@ -20938,12 +20982,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20938
20982
|
function createXrpBalanceResolver() {
|
|
20939
20983
|
return async ({ address, network }) => {
|
|
20940
20984
|
var _a2, _b, _c;
|
|
20941
|
-
if (!(network == null ? void 0 : network.rpcUrl))
|
|
20942
|
-
return null;
|
|
20985
|
+
if (!(network == null ? void 0 : network.rpcUrl)) return null;
|
|
20943
20986
|
const symbol = getNativeAsset(network);
|
|
20944
20987
|
const endpoint = getHttpRpcUrl(network);
|
|
20945
|
-
if (!endpoint)
|
|
20946
|
-
return null;
|
|
20988
|
+
if (!endpoint) return null;
|
|
20947
20989
|
const accountInfo = await rpc(endpoint, {
|
|
20948
20990
|
method: "account_info",
|
|
20949
20991
|
params: [{ account: address, ledger_index: "validated" }]
|
|
@@ -20967,8 +21009,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20967
21009
|
}
|
|
20968
21010
|
const accountData = (_b = accountInfo.result) == null ? void 0 : _b.account_data;
|
|
20969
21011
|
const balanceDrops = parseDrops(accountData == null ? void 0 : accountData.Balance);
|
|
20970
|
-
if (balanceDrops == null || ((_c = accountInfo.result) == null ? void 0 : _c.error))
|
|
20971
|
-
return null;
|
|
21012
|
+
if (balanceDrops == null || ((_c = accountInfo.result) == null ? void 0 : _c.error)) return null;
|
|
20972
21013
|
const ownerCount = (accountData == null ? void 0 : accountData.OwnerCount) ?? 0;
|
|
20973
21014
|
const reserveInfo = await resolveReserve(endpoint).catch(() => ({
|
|
20974
21015
|
baseDrops: FALLBACK_RESERVE_BASE_DROPS,
|
|
@@ -21003,8 +21044,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21003
21044
|
headers: { "content-type": "application/json" },
|
|
21004
21045
|
body: JSON.stringify(payload)
|
|
21005
21046
|
});
|
|
21006
|
-
if (!response.ok)
|
|
21007
|
-
throw new Error(`Wallet RPC request failed: ${response.status}`);
|
|
21047
|
+
if (!response.ok) throw new Error(`Wallet RPC request failed: ${response.status}`);
|
|
21008
21048
|
return response.json();
|
|
21009
21049
|
}
|
|
21010
21050
|
async function resolveReserve(endpoint) {
|
|
@@ -21016,26 +21056,22 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21016
21056
|
return { baseDrops, incDrops };
|
|
21017
21057
|
}
|
|
21018
21058
|
function parseDrops(value) {
|
|
21019
|
-
if (value == null)
|
|
21020
|
-
return null;
|
|
21059
|
+
if (value == null) return null;
|
|
21021
21060
|
const parsed = typeof value === "number" ? value : Number(value);
|
|
21022
21061
|
return Number.isFinite(parsed) ? parsed : null;
|
|
21023
21062
|
}
|
|
21024
21063
|
function parseReserveDrops(drops, xrp, fallback) {
|
|
21025
21064
|
const parsedDrops = parseDrops(drops);
|
|
21026
|
-
if (parsedDrops != null)
|
|
21027
|
-
return parsedDrops;
|
|
21065
|
+
if (parsedDrops != null) return parsedDrops;
|
|
21028
21066
|
const parsedXrp = parseDrops(xrp);
|
|
21029
|
-
if (parsedXrp != null)
|
|
21030
|
-
return Math.round(parsedXrp * 1e6);
|
|
21067
|
+
if (parsedXrp != null) return Math.round(parsedXrp * 1e6);
|
|
21031
21068
|
return fallback;
|
|
21032
21069
|
}
|
|
21033
21070
|
function formatDrops(drops) {
|
|
21034
21071
|
return formatXrpBalance(drops / 1e6);
|
|
21035
21072
|
}
|
|
21036
21073
|
function formatXrpBalance(value) {
|
|
21037
|
-
if (!Number.isFinite(value))
|
|
21038
|
-
return "0";
|
|
21074
|
+
if (!Number.isFinite(value)) return "0";
|
|
21039
21075
|
const precision = value >= 100 ? 2 : value >= 1 ? 4 : 6;
|
|
21040
21076
|
return value.toLocaleString("en-US", {
|
|
21041
21077
|
maximumFractionDigits: precision,
|
|
@@ -21167,16 +21203,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21167
21203
|
this.render();
|
|
21168
21204
|
}));
|
|
21169
21205
|
this.offEvents.push(options.modal.onClose(() => {
|
|
21170
|
-
if (this.options.manager.getSession())
|
|
21171
|
-
return;
|
|
21206
|
+
if (this.options.manager.getSession()) return;
|
|
21172
21207
|
this.connecting = false;
|
|
21173
21208
|
this.render();
|
|
21174
21209
|
}));
|
|
21175
21210
|
}
|
|
21176
21211
|
mount(target = document.body) {
|
|
21177
21212
|
const nextTarget = this.resolveTarget(target);
|
|
21178
|
-
if (!nextTarget)
|
|
21179
|
-
throw new Error("Wallet button target was not found");
|
|
21213
|
+
if (!nextTarget) throw new Error("Wallet button target was not found");
|
|
21180
21214
|
this.target = nextTarget;
|
|
21181
21215
|
nextTarget.innerHTML = "";
|
|
21182
21216
|
nextTarget.appendChild(this.createRoot());
|
|
@@ -21212,18 +21246,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21212
21246
|
this.identityResolvingKey = void 0;
|
|
21213
21247
|
this.clearBalanceRefreshTimers();
|
|
21214
21248
|
this.clearBalanceDebounce();
|
|
21215
|
-
if (this.copyResetTimer)
|
|
21216
|
-
|
|
21217
|
-
if (this.identitySettleTimer)
|
|
21218
|
-
window.clearTimeout(this.identitySettleTimer);
|
|
21249
|
+
if (this.copyResetTimer) window.clearTimeout(this.copyResetTimer);
|
|
21250
|
+
if (this.identitySettleTimer) window.clearTimeout(this.identitySettleTimer);
|
|
21219
21251
|
this.offEvents.splice(0).forEach((off) => off());
|
|
21220
|
-
if (this.target)
|
|
21221
|
-
this.target.innerHTML = "";
|
|
21252
|
+
if (this.target) this.target.innerHTML = "";
|
|
21222
21253
|
this.target = void 0;
|
|
21223
21254
|
}
|
|
21224
21255
|
render() {
|
|
21225
|
-
if (!this.target)
|
|
21226
|
-
return;
|
|
21256
|
+
if (!this.target) return;
|
|
21227
21257
|
this.target.innerHTML = "";
|
|
21228
21258
|
try {
|
|
21229
21259
|
this.target.appendChild(this.createRoot());
|
|
@@ -21276,8 +21306,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21276
21306
|
this.options.modal.open();
|
|
21277
21307
|
return;
|
|
21278
21308
|
}
|
|
21279
|
-
if (!this.options.accountPanel)
|
|
21280
|
-
return;
|
|
21309
|
+
if (!this.options.accountPanel) return;
|
|
21281
21310
|
this.panelOpen = !this.panelOpen;
|
|
21282
21311
|
this.render();
|
|
21283
21312
|
}
|
|
@@ -21289,20 +21318,16 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21289
21318
|
}
|
|
21290
21319
|
handleDocumentPointerDown(event) {
|
|
21291
21320
|
var _a2;
|
|
21292
|
-
if (!this.panelOpen || !this.target)
|
|
21293
|
-
|
|
21294
|
-
if (event.target instanceof Node && this.
|
|
21295
|
-
return;
|
|
21296
|
-
if (event.target instanceof Node && ((_a2 = this.accountPanelPortal) == null ? void 0 : _a2.contains(event.target)))
|
|
21297
|
-
return;
|
|
21321
|
+
if (!this.panelOpen || !this.target) return;
|
|
21322
|
+
if (event.target instanceof Node && this.target.contains(event.target)) return;
|
|
21323
|
+
if (event.target instanceof Node && ((_a2 = this.accountPanelPortal) == null ? void 0 : _a2.contains(event.target))) return;
|
|
21298
21324
|
this.panelOpen = false;
|
|
21299
21325
|
this.addressQrOpen = false;
|
|
21300
21326
|
this.historyOpen = false;
|
|
21301
21327
|
this.render();
|
|
21302
21328
|
}
|
|
21303
21329
|
handleDocumentKeyDown(event) {
|
|
21304
|
-
if (!this.panelOpen)
|
|
21305
|
-
return;
|
|
21330
|
+
if (!this.panelOpen) return;
|
|
21306
21331
|
if (event.key === "Escape") {
|
|
21307
21332
|
this.panelOpen = false;
|
|
21308
21333
|
this.addressQrOpen = false;
|
|
@@ -21310,8 +21335,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21310
21335
|
this.render();
|
|
21311
21336
|
return;
|
|
21312
21337
|
}
|
|
21313
|
-
if (event.key !== "Tab" || this.options.accountPanelMode !== "modal")
|
|
21314
|
-
return;
|
|
21338
|
+
if (event.key !== "Tab" || this.options.accountPanelMode !== "modal") return;
|
|
21315
21339
|
const focusable = this.getAccountPanelFocusableElements();
|
|
21316
21340
|
if (!focusable.length) {
|
|
21317
21341
|
event.preventDefault();
|
|
@@ -21333,8 +21357,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21333
21357
|
syncPanelListeners() {
|
|
21334
21358
|
this.removePanelListeners();
|
|
21335
21359
|
this.syncPanelScrollLock(this.panelOpen && this.options.accountPanelMode === "modal");
|
|
21336
|
-
if (!this.panelOpen)
|
|
21337
|
-
return;
|
|
21360
|
+
if (!this.panelOpen) return;
|
|
21338
21361
|
document.addEventListener("pointerdown", this.onDocumentPointerDown);
|
|
21339
21362
|
document.addEventListener("keydown", this.onDocumentKeyDown);
|
|
21340
21363
|
if (this.options.accountPanelMode === "modal") {
|
|
@@ -21355,8 +21378,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21355
21378
|
portal.dataset.xwkEntering = entering ? "true" : "false";
|
|
21356
21379
|
this.ensureStyles();
|
|
21357
21380
|
portal.innerHTML = this.renderPanel();
|
|
21358
|
-
if (entering)
|
|
21359
|
-
document.body.appendChild(portal);
|
|
21381
|
+
if (entering) document.body.appendChild(portal);
|
|
21360
21382
|
this.accountPanelPortal = portal;
|
|
21361
21383
|
this.bindPanelActions(portal);
|
|
21362
21384
|
this.renderAddressQrIfNeeded(portal);
|
|
@@ -21374,8 +21396,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21374
21396
|
this.closeSubView();
|
|
21375
21397
|
});
|
|
21376
21398
|
(_c = root.querySelector("[data-xwk-account-overlay]")) == null ? void 0 : _c.addEventListener("click", (event) => {
|
|
21377
|
-
if (event.target === event.currentTarget)
|
|
21378
|
-
this.closePanel();
|
|
21399
|
+
if (event.target === event.currentTarget) this.closePanel();
|
|
21379
21400
|
});
|
|
21380
21401
|
(_d = root.querySelector("[data-xwk-copy-address]")) == null ? void 0 : _d.addEventListener("click", (event) => {
|
|
21381
21402
|
event.stopPropagation();
|
|
@@ -21392,16 +21413,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21392
21413
|
(_g = root.querySelector("[data-xwk-disconnect]")) == null ? void 0 : _g.addEventListener("click", () => void this.disconnect());
|
|
21393
21414
|
}
|
|
21394
21415
|
openAddressQr() {
|
|
21395
|
-
if (!this.options.manager.getSession())
|
|
21396
|
-
return;
|
|
21416
|
+
if (!this.options.manager.getSession()) return;
|
|
21397
21417
|
this.panelOpen = true;
|
|
21398
21418
|
this.addressQrOpen = true;
|
|
21399
21419
|
this.historyOpen = false;
|
|
21400
21420
|
this.render();
|
|
21401
21421
|
}
|
|
21402
21422
|
openTransactionHistory() {
|
|
21403
|
-
if (!this.options.manager.getSession())
|
|
21404
|
-
return;
|
|
21423
|
+
if (!this.options.manager.getSession()) return;
|
|
21405
21424
|
this.panelOpen = true;
|
|
21406
21425
|
this.addressQrOpen = false;
|
|
21407
21426
|
this.historyOpen = true;
|
|
@@ -21418,8 +21437,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21418
21437
|
document.removeEventListener("keydown", this.onDocumentKeyDown);
|
|
21419
21438
|
}
|
|
21420
21439
|
syncPanelScrollLock(shouldLock) {
|
|
21421
|
-
if (shouldLock === this.panelScrollLocked)
|
|
21422
|
-
return;
|
|
21440
|
+
if (shouldLock === this.panelScrollLocked) return;
|
|
21423
21441
|
this.panelScrollLocked = shouldLock;
|
|
21424
21442
|
if (shouldLock) {
|
|
21425
21443
|
lockPageScroll();
|
|
@@ -21428,8 +21446,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21428
21446
|
}
|
|
21429
21447
|
}
|
|
21430
21448
|
async disconnect() {
|
|
21431
|
-
if (this.accountAction)
|
|
21432
|
-
return;
|
|
21449
|
+
if (this.accountAction) return;
|
|
21433
21450
|
this.accountAction = "disconnect";
|
|
21434
21451
|
this.render();
|
|
21435
21452
|
try {
|
|
@@ -21441,17 +21458,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21441
21458
|
}
|
|
21442
21459
|
}
|
|
21443
21460
|
async copyAddress() {
|
|
21444
|
-
if (this.copyInProgress || this.accountAction)
|
|
21445
|
-
return;
|
|
21461
|
+
if (this.copyInProgress || this.accountAction) return;
|
|
21446
21462
|
const address = this.getSessionAddress(this.options.manager.getSession());
|
|
21447
|
-
if (!address)
|
|
21448
|
-
return;
|
|
21463
|
+
if (!address) return;
|
|
21449
21464
|
this.copyInProgress = true;
|
|
21450
21465
|
try {
|
|
21451
21466
|
await this.copyText(address);
|
|
21452
21467
|
this.copied = true;
|
|
21453
|
-
if (this.copyResetTimer)
|
|
21454
|
-
window.clearTimeout(this.copyResetTimer);
|
|
21468
|
+
if (this.copyResetTimer) window.clearTimeout(this.copyResetTimer);
|
|
21455
21469
|
this.copyResetTimer = window.setTimeout(() => {
|
|
21456
21470
|
this.copied = false;
|
|
21457
21471
|
this.render();
|
|
@@ -21500,13 +21514,11 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21500
21514
|
}
|
|
21501
21515
|
const requestId = ++this.identityRequest;
|
|
21502
21516
|
const cacheKey = this.identityCacheKey(session);
|
|
21503
|
-
if (options.force)
|
|
21504
|
-
this.identityCache.delete(cacheKey);
|
|
21517
|
+
if (options.force) this.identityCache.delete(cacheKey);
|
|
21505
21518
|
this.identityResolvingKey = cacheKey;
|
|
21506
21519
|
try {
|
|
21507
21520
|
const result = await this.options.identityResolver(address, session, { force: options.force });
|
|
21508
|
-
if (requestId !== this.identityRequest)
|
|
21509
|
-
return;
|
|
21521
|
+
if (requestId !== this.identityRequest) return;
|
|
21510
21522
|
const identity2 = typeof result === "string" ? { name: result } : result ?? null;
|
|
21511
21523
|
this.identityName = (identity2 == null ? void 0 : identity2.name) ?? null;
|
|
21512
21524
|
this.identityAvatar = (identity2 == null ? void 0 : identity2.avatar) ?? null;
|
|
@@ -21544,14 +21556,12 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21544
21556
|
this.identityAvatar = (cached == null ? void 0 : cached.avatar) ?? null;
|
|
21545
21557
|
this.clearIdentitySettleTimer();
|
|
21546
21558
|
this.render();
|
|
21547
|
-
if (this.identityResolvingKey !== cacheKey)
|
|
21548
|
-
void this.resolveIdentity(session);
|
|
21559
|
+
if (this.identityResolvingKey !== cacheKey) void this.resolveIdentity(session);
|
|
21549
21560
|
return;
|
|
21550
21561
|
}
|
|
21551
21562
|
this.identityName = null;
|
|
21552
21563
|
this.identityAvatar = null;
|
|
21553
|
-
if (this.identityResolvingKey !== cacheKey)
|
|
21554
|
-
void this.resolveIdentity(session);
|
|
21564
|
+
if (this.identityResolvingKey !== cacheKey) void this.resolveIdentity(session);
|
|
21555
21565
|
this.clearIdentitySettleTimer();
|
|
21556
21566
|
this.identitySettleTimer = window.setTimeout(() => {
|
|
21557
21567
|
this.identitySettleTimer = void 0;
|
|
@@ -21559,8 +21569,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21559
21569
|
}, 260);
|
|
21560
21570
|
}
|
|
21561
21571
|
clearIdentitySettleTimer() {
|
|
21562
|
-
if (!this.identitySettleTimer)
|
|
21563
|
-
return;
|
|
21572
|
+
if (!this.identitySettleTimer) return;
|
|
21564
21573
|
window.clearTimeout(this.identitySettleTimer);
|
|
21565
21574
|
this.identitySettleTimer = void 0;
|
|
21566
21575
|
}
|
|
@@ -21574,8 +21583,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21574
21583
|
this.balance = null;
|
|
21575
21584
|
this.balanceLoading = false;
|
|
21576
21585
|
this.activationStatus = "unknown";
|
|
21577
|
-
if (session)
|
|
21578
|
-
delete session.balance;
|
|
21586
|
+
if (session) delete session.balance;
|
|
21579
21587
|
(_b = (_a2 = this.options).onBalanceChange) == null ? void 0 : _b.call(_a2, null, session);
|
|
21580
21588
|
this.render();
|
|
21581
21589
|
return;
|
|
@@ -21599,8 +21607,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21599
21607
|
network: session.account.network,
|
|
21600
21608
|
session
|
|
21601
21609
|
});
|
|
21602
|
-
if (requestId !== this.balanceRequest)
|
|
21603
|
-
return;
|
|
21610
|
+
if (requestId !== this.balanceRequest) return;
|
|
21604
21611
|
this.balance = this.normalizeBalance(result);
|
|
21605
21612
|
this.activationStatus = ((_e2 = this.balance) == null ? void 0 : _e2.activationStatus) ?? (this.balance ? "active" : "unknown");
|
|
21606
21613
|
session.account.activationStatus = this.activationStatus;
|
|
@@ -21622,8 +21629,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21622
21629
|
this.render();
|
|
21623
21630
|
}
|
|
21624
21631
|
} finally {
|
|
21625
|
-
if (requestId === this.balanceRequest)
|
|
21626
|
-
this.balanceLoading = false;
|
|
21632
|
+
if (requestId === this.balanceRequest) this.balanceLoading = false;
|
|
21627
21633
|
}
|
|
21628
21634
|
}
|
|
21629
21635
|
renderButton() {
|
|
@@ -21645,8 +21651,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21645
21651
|
renderPanel() {
|
|
21646
21652
|
const messages = this.messages();
|
|
21647
21653
|
const session = this.options.manager.getSession();
|
|
21648
|
-
if (!session)
|
|
21649
|
-
return "";
|
|
21654
|
+
if (!session) return "";
|
|
21650
21655
|
const content = this.addressQrOpen ? this.renderAddressQrPanelContent(session) : this.historyOpen ? this.renderTransactionHistoryPanelContent(session) : this.renderPanelContent(session);
|
|
21651
21656
|
const title = this.addressQrOpen ? messages.addressQr : this.historyOpen ? messages.recentTransactions : messages.connected;
|
|
21652
21657
|
const hasTransactions = !this.addressQrOpen && !this.historyOpen && this.options.showRecentTransactions && this.getVisibleTransactions(session).length > 0;
|
|
@@ -21687,24 +21692,20 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21687
21692
|
renderAddressQrPanelContent(session) {
|
|
21688
21693
|
const messages = this.messages();
|
|
21689
21694
|
const address = this.getSessionAddress(session);
|
|
21690
|
-
if (!address)
|
|
21691
|
-
return "";
|
|
21695
|
+
if (!address) return "";
|
|
21692
21696
|
const copyFeedbackIcon = this.copied ? this.copiedIcon() : this.copyIcon();
|
|
21693
21697
|
const copy = this.options.copyAddress ? `<button type="button" data-xwk-copy-address>${copyFeedbackIcon}<span>${this.copied ? this.escapeHtml(messages.copied) : this.escapeHtml(messages.copyAddress)}</span></button>` : "";
|
|
21694
21698
|
return `<div class="xwk-address-qr-content"><div class="xwk-address-qr-code" data-xwk-address-qr-code data-address="${this.escapeHtml(address)}" aria-hidden="true"></div><div class="xwk-address-qr-chip">${this.escapeHtml(address)}</div><div class="xwk-account-panel-actions">${copy}</div></div>`;
|
|
21695
21699
|
}
|
|
21696
21700
|
renderAddressQrButton(address) {
|
|
21697
|
-
if (!this.options.showAddressQr || !address)
|
|
21698
|
-
return "";
|
|
21701
|
+
if (!this.options.showAddressQr || !address) return "";
|
|
21699
21702
|
const messages = this.messages();
|
|
21700
21703
|
return `<button class="xwk-address-qr-trigger" type="button" data-xwk-address-qr aria-label="${this.escapeHtml(messages.showAddressQr)}" title="${this.escapeHtml(messages.showAddressQr)}">${this.qrIcon()}</button>`;
|
|
21701
21704
|
}
|
|
21702
21705
|
renderTransactionHistory(session) {
|
|
21703
|
-
if (!this.options.showRecentTransactions)
|
|
21704
|
-
return "";
|
|
21706
|
+
if (!this.options.showRecentTransactions) return "";
|
|
21705
21707
|
const allTransactions = this.getVisibleTransactions(session);
|
|
21706
|
-
if (!allTransactions.length)
|
|
21707
|
-
return "";
|
|
21708
|
+
if (!allTransactions.length) return "";
|
|
21708
21709
|
const transactions2 = allTransactions.slice(0, Math.min(3, allTransactions.length));
|
|
21709
21710
|
const messages = this.messages();
|
|
21710
21711
|
const count = allTransactions.length > 9 ? "9+" : String(allTransactions.length);
|
|
@@ -21715,34 +21716,32 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21715
21716
|
renderTransactionHistoryPanelContent(session) {
|
|
21716
21717
|
const messages = this.messages();
|
|
21717
21718
|
const transactions2 = this.getVisibleTransactions(session, Math.max(10, this.options.maxVisibleTransactions));
|
|
21718
|
-
if (!transactions2.length)
|
|
21719
|
-
return `<div class="xwk-tx-empty">${this.escapeHtml(messages.noRecentTransactions)}</div>`;
|
|
21719
|
+
if (!transactions2.length) return `<div class="xwk-tx-empty">${this.escapeHtml(messages.noRecentTransactions)}</div>`;
|
|
21720
21720
|
return `<section class="xwk-tx-history-view" aria-label="${this.escapeHtml(messages.recentTransactions)}"><div class="xwk-tx-list" role="list"><div class="xwk-tx-list-inner">${transactions2.map((transaction2) => this.renderTransactionRow(transaction2)).join("")}</div></div></section>`;
|
|
21721
21721
|
}
|
|
21722
21722
|
renderTransactionRow(transaction2) {
|
|
21723
21723
|
const messages = this.messages();
|
|
21724
21724
|
const label = this.transactionStatusLabel(transaction2);
|
|
21725
|
+
const title = this.transactionTitle(transaction2);
|
|
21725
21726
|
const explorerUrl = this.getTransactionExplorerUrl(transaction2);
|
|
21726
21727
|
const link = explorerUrl ? `<a class="xwk-tx-link" href="${this.escapeHtml(explorerUrl)}" target="_blank" rel="noreferrer">${this.escapeHtml(messages.view)}${this.externalIcon()}</a>` : "";
|
|
21727
|
-
return `<div class="xwk-tx-row xwk-tx-row-${this.escapeHtml(transaction2.status)}" role="listitem"><span class="xwk-tx-status" aria-hidden="true">${this.transactionStatusIcon(transaction2.status)}</span><div class="xwk-tx-main"><span class="xwk-tx-label">${this.escapeHtml(
|
|
21728
|
+
return `<div class="xwk-tx-row xwk-tx-row-${this.escapeHtml(transaction2.status)}" role="listitem"><span class="xwk-tx-status" aria-hidden="true">${this.transactionStatusIcon(transaction2.status)}</span><div class="xwk-tx-main"><span class="xwk-tx-label">${this.escapeHtml(title)}</span><span class="xwk-tx-hash"><span class="xwk-tx-state">${this.escapeHtml(label)}</span> · ${this.escapeHtml(this.formatHash(transaction2.hash))} · ${this.escapeHtml(this.formatRelativeTime(transaction2))}</span></div>${link}</div>`;
|
|
21729
|
+
}
|
|
21730
|
+
transactionTitle(transaction2) {
|
|
21731
|
+
const description = typeof transaction2.description === "string" ? transaction2.description.trim() : "";
|
|
21732
|
+
return description || "Transaction";
|
|
21728
21733
|
}
|
|
21729
21734
|
transactionStatusLabel(transaction2) {
|
|
21730
21735
|
const messages = this.messages();
|
|
21731
|
-
if (transaction2.status === "confirmed")
|
|
21732
|
-
|
|
21733
|
-
if (transaction2.status === "
|
|
21734
|
-
return messages.transactionFailed;
|
|
21735
|
-
if (transaction2.status === "unknown")
|
|
21736
|
-
return messages.transactionUnknown;
|
|
21736
|
+
if (transaction2.status === "confirmed") return messages.transactionConfirmed;
|
|
21737
|
+
if (transaction2.status === "failed") return messages.transactionFailed;
|
|
21738
|
+
if (transaction2.status === "unknown") return messages.transactionUnknown;
|
|
21737
21739
|
return messages.transactionSubmitted;
|
|
21738
21740
|
}
|
|
21739
21741
|
transactionStatusIcon(status) {
|
|
21740
|
-
if (status === "confirmed")
|
|
21741
|
-
|
|
21742
|
-
if (status === "
|
|
21743
|
-
return this.closeIcon();
|
|
21744
|
-
if (status === "unknown")
|
|
21745
|
-
return this.questionIcon();
|
|
21742
|
+
if (status === "confirmed") return this.checkIcon();
|
|
21743
|
+
if (status === "failed") return this.closeIcon();
|
|
21744
|
+
if (status === "unknown") return this.questionIcon();
|
|
21746
21745
|
return `<span class="xwk-tx-spinner" aria-hidden="true"></span>`;
|
|
21747
21746
|
}
|
|
21748
21747
|
getVisibleTransactions(session, limit = this.options.maxVisibleTransactions) {
|
|
@@ -21771,8 +21770,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21771
21770
|
getTransactionExplorerUrl(transaction2) {
|
|
21772
21771
|
var _a2, _b, _c, _d;
|
|
21773
21772
|
const custom = (_c = (_b = this.options).transactionExplorerUrl) == null ? void 0 : _c.call(_b, transaction2.hash, (_a2 = transaction2.account) == null ? void 0 : _a2.network);
|
|
21774
|
-
if (custom)
|
|
21775
|
-
return custom;
|
|
21773
|
+
if (custom) return custom;
|
|
21776
21774
|
return getExplorerTxUrl((_d = transaction2.account) == null ? void 0 : _d.network, transaction2.hash);
|
|
21777
21775
|
}
|
|
21778
21776
|
formatHash(hash2) {
|
|
@@ -21780,27 +21778,20 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21780
21778
|
}
|
|
21781
21779
|
formatRelativeTime(transaction2) {
|
|
21782
21780
|
const timestamp = this.transactionTimestamp(transaction2);
|
|
21783
|
-
if (!timestamp)
|
|
21784
|
-
return "";
|
|
21781
|
+
if (!timestamp) return "";
|
|
21785
21782
|
const seconds = Math.max(0, Math.floor((Date.now() - timestamp) / 1e3));
|
|
21786
|
-
if (seconds < 60)
|
|
21787
|
-
return "just now";
|
|
21783
|
+
if (seconds < 60) return "just now";
|
|
21788
21784
|
const minutes = Math.floor(seconds / 60);
|
|
21789
|
-
if (minutes < 60)
|
|
21790
|
-
return `${minutes} min ago`;
|
|
21785
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
21791
21786
|
const hours = Math.floor(minutes / 60);
|
|
21792
|
-
if (hours < 24)
|
|
21793
|
-
|
|
21794
|
-
if (hours < 48)
|
|
21795
|
-
return "yesterday";
|
|
21787
|
+
if (hours < 24) return `${hours} hr ago`;
|
|
21788
|
+
if (hours < 48) return "yesterday";
|
|
21796
21789
|
return `${Math.floor(hours / 24)} days ago`;
|
|
21797
21790
|
}
|
|
21798
21791
|
getAccountLabel(session) {
|
|
21799
21792
|
var _a2, _b;
|
|
21800
|
-
if (this.shouldShowWeb3Name() && this.identityName)
|
|
21801
|
-
|
|
21802
|
-
if (!this.options.fallbackToAddress)
|
|
21803
|
-
return ((_a2 = session.wallet) == null ? void 0 : _a2.name) ?? session.adapterId;
|
|
21793
|
+
if (this.shouldShowWeb3Name() && this.identityName) return this.identityName;
|
|
21794
|
+
if (!this.options.fallbackToAddress) return ((_a2 = session.wallet) == null ? void 0 : _a2.name) ?? session.adapterId;
|
|
21804
21795
|
const address = this.getSessionAddress(session);
|
|
21805
21796
|
return address ? (this.options.formatAddress ?? this.formatAddress)(address) : ((_b = session.wallet) == null ? void 0 : _b.name) ?? session.adapterId;
|
|
21806
21797
|
}
|
|
@@ -21816,34 +21807,26 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21816
21807
|
}
|
|
21817
21808
|
getExplorerUrl(session) {
|
|
21818
21809
|
var _a2;
|
|
21819
|
-
if (this.options.explorerUrl)
|
|
21820
|
-
return this.options.explorerUrl(session);
|
|
21810
|
+
if (this.options.explorerUrl) return this.options.explorerUrl(session);
|
|
21821
21811
|
const address = this.getSessionAddress(session);
|
|
21822
|
-
if (!address)
|
|
21823
|
-
return void 0;
|
|
21812
|
+
if (!address) return void 0;
|
|
21824
21813
|
const configured = getExplorerAccountUrl(session.account.network, address);
|
|
21825
|
-
if (configured)
|
|
21826
|
-
return configured;
|
|
21814
|
+
if (configured) return configured;
|
|
21827
21815
|
const networkType = ((_a2 = session.account.network) == null ? void 0 : _a2.networkType) ?? session.account.networkType;
|
|
21828
|
-
if (networkType === "TESTNET")
|
|
21829
|
-
|
|
21830
|
-
if (networkType === "DEVNET")
|
|
21831
|
-
return `https://devnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
21816
|
+
if (networkType === "TESTNET") return `https://testnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
21817
|
+
if (networkType === "DEVNET") return `https://devnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
21832
21818
|
return `https://livenet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
21833
21819
|
}
|
|
21834
21820
|
getSessionAddress(session) {
|
|
21835
21821
|
const account = session == null ? void 0 : session.account;
|
|
21836
21822
|
const address = typeof (account == null ? void 0 : account.address) === "string" ? account.address : "";
|
|
21837
|
-
if (address)
|
|
21838
|
-
return address;
|
|
21823
|
+
if (address) return address;
|
|
21839
21824
|
return typeof (account == null ? void 0 : account.classicAddress) === "string" ? account.classicAddress : "";
|
|
21840
21825
|
}
|
|
21841
21826
|
isIdentityResolving(session) {
|
|
21842
|
-
if (!session || !this.shouldShowWeb3Name() || this.identityName)
|
|
21843
|
-
return false;
|
|
21827
|
+
if (!session || !this.shouldShowWeb3Name() || this.identityName) return false;
|
|
21844
21828
|
const address = this.getSessionAddress(session);
|
|
21845
|
-
if (!address || !this.options.identityResolver)
|
|
21846
|
-
return false;
|
|
21829
|
+
if (!address || !this.options.identityResolver) return false;
|
|
21847
21830
|
return this.identityResolvingKey === this.identityCacheKey(session);
|
|
21848
21831
|
}
|
|
21849
21832
|
shouldShowWeb3Name() {
|
|
@@ -21854,17 +21837,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21854
21837
|
}
|
|
21855
21838
|
renderWalletIcon(wallet, fallbackIcon) {
|
|
21856
21839
|
const icon = (wallet == null ? void 0 : wallet.icon) ?? fallbackIcon;
|
|
21857
|
-
if (icon)
|
|
21858
|
-
|
|
21859
|
-
if (!wallet)
|
|
21860
|
-
return `<span class="xwk-button-icon xwk-button-icon-fallback xwk-button-icon-svg-fallback" aria-hidden="true">${this.walletIcon()}</span>`;
|
|
21840
|
+
if (icon) return `<img class="xwk-button-icon" src="${this.escapeHtml(icon)}" alt="">`;
|
|
21841
|
+
if (!wallet) return `<span class="xwk-button-icon xwk-button-icon-fallback xwk-button-icon-svg-fallback" aria-hidden="true">${this.walletIcon()}</span>`;
|
|
21861
21842
|
const label = wallet.name.slice(0, 1).toUpperCase();
|
|
21862
21843
|
return `<span class="xwk-button-icon xwk-button-icon-fallback xwk-button-icon-initial" aria-hidden="true">${this.escapeHtml(label)}</span>`;
|
|
21863
21844
|
}
|
|
21864
21845
|
renderPreConnectIcon() {
|
|
21865
21846
|
const icon = this.options.icon;
|
|
21866
|
-
if (!icon || icon.type === "default")
|
|
21867
|
-
return this.renderWalletIcon(void 0);
|
|
21847
|
+
if (!icon || icon.type === "default") return this.renderWalletIcon(void 0);
|
|
21868
21848
|
if (icon.type === "image") {
|
|
21869
21849
|
const aria = icon.alt ? ` role="img" aria-label="${this.escapeHtml(icon.alt)}"` : ` aria-hidden="true"`;
|
|
21870
21850
|
return `<span class="xwk-button-icon xwk-button-icon-custom xwk-button-icon-custom-image"${aria}><img src="${this.escapeHtml(icon.src)}" alt="" decoding="async"></span>`;
|
|
@@ -21877,15 +21857,13 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21877
21857
|
}
|
|
21878
21858
|
repairFallbackIcon(root) {
|
|
21879
21859
|
root.querySelectorAll(".xwk-button-icon-svg-fallback").forEach((icon) => {
|
|
21880
|
-
if (icon.querySelector("svg"))
|
|
21881
|
-
return;
|
|
21860
|
+
if (icon.querySelector("svg")) return;
|
|
21882
21861
|
icon.innerHTML = this.walletIcon();
|
|
21883
21862
|
});
|
|
21884
21863
|
}
|
|
21885
21864
|
getAccountPanelFocusableElements() {
|
|
21886
21865
|
const panel = this.getAccountPanelRoot();
|
|
21887
|
-
if (!panel)
|
|
21888
|
-
return [];
|
|
21866
|
+
if (!panel) return [];
|
|
21889
21867
|
const selectors = [
|
|
21890
21868
|
"button:not([disabled])",
|
|
21891
21869
|
"a[href]",
|
|
@@ -21910,12 +21888,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21910
21888
|
return `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M4 4h6v6H4V4Zm10 0h6v6h-6V4ZM4 14h6v6H4v-6Z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M14 14h2v2h-2v-2Zm4 0h2v2h-2v-2Zm-4 4h2v2h-2v-2Zm4 0h2v2h-2v-2Z" fill="currentColor"/></svg>`;
|
|
21911
21889
|
}
|
|
21912
21890
|
renderAddressQrIfNeeded(root) {
|
|
21913
|
-
if (!this.addressQrOpen)
|
|
21914
|
-
return;
|
|
21891
|
+
if (!this.addressQrOpen) return;
|
|
21915
21892
|
const container = root.querySelector("[data-xwk-address-qr-code]");
|
|
21916
21893
|
const address = container == null ? void 0 : container.dataset.address;
|
|
21917
|
-
if (!container || !address || container.dataset.xwkRendered === address)
|
|
21918
|
-
return;
|
|
21894
|
+
if (!container || !address || container.dataset.xwkRendered === address) return;
|
|
21919
21895
|
container.dataset.xwkRendered = address;
|
|
21920
21896
|
container.replaceChildren();
|
|
21921
21897
|
try {
|
|
@@ -21956,8 +21932,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21956
21932
|
}
|
|
21957
21933
|
normalizeBalance(result) {
|
|
21958
21934
|
var _a2;
|
|
21959
|
-
if (result == null)
|
|
21960
|
-
return null;
|
|
21935
|
+
if (result == null) return null;
|
|
21961
21936
|
const symbol = getNativeAsset((_a2 = this.options.manager.getSession()) == null ? void 0 : _a2.account.network);
|
|
21962
21937
|
if (typeof result === "string" || typeof result === "number") {
|
|
21963
21938
|
return { value: String(result), formatted: `${result} ${symbol}`, symbol };
|
|
@@ -21970,8 +21945,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21970
21945
|
};
|
|
21971
21946
|
}
|
|
21972
21947
|
scheduleBalanceRefresh(delays) {
|
|
21973
|
-
if (!this.options.showBalance || !this.options.balanceResolver)
|
|
21974
|
-
return;
|
|
21948
|
+
if (!this.options.showBalance || !this.options.balanceResolver) return;
|
|
21975
21949
|
this.clearBalanceRefreshTimers();
|
|
21976
21950
|
delays.forEach((delay2) => {
|
|
21977
21951
|
let timer = 0;
|
|
@@ -21987,8 +21961,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21987
21961
|
this.balanceRefreshTimers.clear();
|
|
21988
21962
|
}
|
|
21989
21963
|
queueBalanceRefresh(session, delay2 = 300) {
|
|
21990
|
-
if (!this.options.showBalance || !this.options.balanceResolver)
|
|
21991
|
-
return;
|
|
21964
|
+
if (!this.options.showBalance || !this.options.balanceResolver) return;
|
|
21992
21965
|
this.balanceDebounceSession = session;
|
|
21993
21966
|
this.clearBalanceDebounce();
|
|
21994
21967
|
if (typeof window === "undefined") {
|
|
@@ -22027,7 +22000,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22027
22000
|
return `<svg width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><rect x="8" y="8" width="11" height="11" rx="2" stroke="currentColor" stroke-width="2"/><path d="M5 15H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v1" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`;
|
|
22028
22001
|
}
|
|
22029
22002
|
copiedIcon() {
|
|
22030
|
-
return `<svg class="xwk-copied-icon" width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="currentColor"/><path d="m7.8 12.4 2.7 2.7 5.9-6.2" stroke="
|
|
22003
|
+
return `<svg class="xwk-copied-icon" width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><circle cx="12" cy="12" r="10" fill="currentColor"/><path d="m7.8 12.4 2.7 2.7 5.9-6.2" stroke="var(--xwk-success-icon-foreground,currentColor)" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
22031
22004
|
}
|
|
22032
22005
|
externalIcon() {
|
|
22033
22006
|
return `<svg width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M14 4h6v6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M20 4 10 14" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M11 5H7a3 3 0 0 0-3 3v9a3 3 0 0 0 3 3h9a3 3 0 0 0 3-3v-4" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`;
|
|
@@ -22058,7 +22031,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22058
22031
|
const fallbackIconBackground = theme.fallbackIconBackground;
|
|
22059
22032
|
const fallbackIconColor = theme.fallbackIconColor;
|
|
22060
22033
|
const overlayBlur = theme.overlayBlur > 0 ? `blur(${theme.overlayBlur}px)` : "none";
|
|
22061
|
-
const baseStyles = `.xwk-button-root{display:inline-block;max-width:100%;position:relative;font-family:${theme.fontFamily};font-size:14px}.xwk-account-button{align-items:center;background:${background};border:1px solid ${border};border-radius:${radius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:inline-flex;gap:8px;font:inherit;font-weight:560;max-width:100%;min-height:${height};overflow:hidden;padding:0 12px 0 10px;touch-action:manipulation;transition:background-color .16s ease,border-color .16s ease;white-space:nowrap;-webkit-tap-highlight-color:transparent;transform:none}.xwk-account-button:hover{background:${hoverBackground};box-shadow:none;opacity:1;transform:none}.xwk-account-button:active{background:${hoverBackground};opacity:1;transform:none}.xwk-account-button:focus-visible,.xwk-button-chevron:focus-visible,.xwk-account-panel-actions button:focus-visible,.xwk-account-panel-actions a:focus-visible,.xwk-address-qr-trigger:focus-visible,.xwk-tx-header-link:focus-visible,.xwk-tx-link:focus-visible{outline:2px solid ${theme.accent};outline-offset:2px;text-decoration:none}.xwk-button-icon{background:${theme.background};border:1px solid ${iconBorder};border-radius:10px;box-sizing:border-box;display:inline-flex;flex:0 0 28px;height:28px;isolation:isolate;line-height:0;max-width:28px;min-width:28px;object-fit:contain;overflow:hidden;position:relative;width:28px}.xwk-button-icon-fallback{align-items:center;background:${fallbackIconBackground};color:${fallbackIconColor};justify-content:center}.xwk-button-icon-initial{font-size:12px;line-height:1}.xwk-button-icon-svg-fallback{font-size:0}.xwk-button-icon-svg-fallback svg{display:block;flex:0 0 17px;height:17px;max-height:17px;max-width:17px;min-height:17px;min-width:17px;width:17px}.xwk-button-icon-custom{align-items:center;justify-content:center}.xwk-button-icon-custom img,.xwk-button-icon-custom svg{display:block;max-height:18px;max-width:18px}.xwk-button-icon-custom img{height:18px;object-fit:contain;width:18px}.xwk-button-icon-custom-html>*{max-height:18px;max-width:18px}.xwk-skeleton{animation:xwk-skeleton-pulse 1.4s ease-in-out infinite;background:linear-gradient(90deg,${theme.surface} 25%,${theme.surfaceHover} 50%,${theme.surface} 75%);background-size:200% 100%;border-radius:999px;display:inline-block}.xwk-skeleton-button-balance{height:12px;width:44px}.xwk-skeleton-balance{height:14px;width:70px}.xwk-skeleton-name{height:24px;width:132px}.xwk-account-name-skeleton{align-items:center;display:flex;justify-content:center;min-height:26px}.xwk-button-pending-dot{background:${theme.accent};border:2px solid ${background};border-radius:999px;box-sizing:border-box;flex:0 0 9px;height:9px;margin-left:-13px;margin-right:4px;position:relative;width:9px;z-index:1}.xwk-button-label{display:inline-block;flex:1 1 0;font-size:13px;font-weight:560;line-height:1.1;max-width:220px;min-width:0;overflow:hidden;padding-right:2px;text-overflow:ellipsis;white-space:nowrap}.xwk-button-balance{color:${theme.muted};font-weight:500;margin-left:4px}.xwk-button-balance-loading{display:inline-flex;vertical-align:-2px}.xwk-balance-spinner{animation:xwk-action-spin .8s linear infinite;border:2px solid ${theme.spinnerTrail};border-top-color:${theme.muted};border-radius:999px;box-sizing:border-box;display:inline-block;flex:0 0 13px;height:13px;width:13px}.xwk-button-chevron{align-items:center;background:${theme.background};border:1px solid ${iconBorder};border-radius:999px;color:${theme.muted};display:inline-flex;flex:0 0 26px;height:26px;justify-content:center;line-height:1;touch-action:manipulation;width:26px}.xwk-button-chevron:hover{background:${theme.surfaceHover};color:${theme.foreground}}.xwk-account-overlay{align-items:center;background:${theme.overlay};-webkit-backdrop-filter:${overlayBlur};backdrop-filter:${overlayBlur};display:flex;inset:0;justify-content:center;overscroll-behavior:contain;padding:max(24px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));position:fixed;z-index:2147483647}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-overlay{animation:xwk-account-overlay-in .18s ease-out}.xwk-account-panel{background:${theme.background};border:1px solid ${theme.border};border-radius:${theme.radius};box-shadow:${theme.shadow};box-sizing:border-box;color:${theme.foreground};display:grid;gap:12px;overflow:hidden;z-index:2147483647}.xwk-account-panel:focus{outline:none}.xwk-account-panel-dropdown{box-shadow:none;justify-items:center;margin-top:10px;min-width:320px;padding:18px;position:absolute;right:0;top:100%;width:min(360px,calc(100vw - 32px))}.xwk-account-dropdown-header{align-items:center;display:grid;grid-template-columns:44px minmax(0,1fr) 44px;margin:-4px 0 0;width:100%}.xwk-account-dropdown-header strong{font-size:14px;font-weight:600;line-height:1.2;min-width:0;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-account-panel-modal{gap:0;grid-template-rows:auto minmax(0,1fr);height:min(527px,calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));max-width:520px;position:relative;transform-origin:center bottom;width:min(520px,100%)}.xwk-account-panel-modal.xwk-account-panel-with-transactions,.xwk-account-panel-modal.xwk-account-panel-history{height:min(650px,calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)))}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-panel-modal{animation:xwk-account-panel-in .22s cubic-bezier(.22,1,.36,1)}.xwk-account-modal-header{align-items:center;background:${theme.headerBackground};border-bottom:1px solid ${theme.border};display:grid;grid-template-columns:44px minmax(0,1fr) 44px;column-gap:8px;padding:8px 18px}.xwk-account-modal-header h2{color:${theme.foreground};font-size:16px;font-weight:500;line-height:1.2;margin:0;min-width:0;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-account-modal-body{-webkit-overflow-scrolling:touch;align-items:center;display:flex;flex-direction:column;gap:12px;min-height:0;overflow:hidden;overscroll-behavior:contain;padding:22px 28px 28px}.xwk-account-panel-with-transactions .xwk-account-modal-body,.xwk-account-panel-history .xwk-account-modal-body{overflow:auto;padding-top:14px}.xwk-account-modal-body>.xwk-account-hero,.xwk-account-modal-body>.xwk-account-name,.xwk-account-modal-body>.xwk-account-meta-pill,.xwk-account-modal-body>.xwk-account-warning,.xwk-account-modal-body>.xwk-tx-section,.xwk-account-modal-body>.xwk-tx-history-view,.xwk-account-modal-body>.xwk-account-panel-actions{flex-shrink:0}.xwk-account-close,.xwk-account-back{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent!important;border:0!important;border-radius:999px;box-shadow:none!important;color:${theme.muted};cursor:pointer;display:inline-flex;font:inherit;font-size:26px;font-weight:500;height:44px;justify-content:center;line-height:1;margin:0;min-height:0;outline:none!important;padding:0;touch-action:manipulation;transform:none;width:44px}.xwk-account-back{font-size:0;justify-self:start}.xwk-account-close{justify-self:end}.xwk-account-close:hover,.xwk-account-back:hover{background:${theme.surfaceHover}!important;box-shadow:none!important;color:${theme.foreground};transform:none}.xwk-account-close:focus-visible,.xwk-account-back:focus-visible{outline:2px solid ${theme.accent}!important;outline-offset:0}.xwk-account-hero{height:154px;margin-top:4px;position:relative;width:180px}.xwk-account-panel-with-transactions .xwk-account-hero{height:126px;margin-bottom:0}.xwk-account-panel-with-transactions .xwk-account-art,.xwk-account-panel-with-transactions .xwk-account-avatar{top:0}.xwk-account-panel-dropdown .xwk-account-hero{height:132px;width:160px}.xwk-account-art,.xwk-account-avatar{border-radius:999px;height:118px;left:31px;position:absolute;top:8px;width:118px}.xwk-account-panel-dropdown .xwk-account-art,.xwk-account-panel-dropdown .xwk-account-avatar{height:104px;left:28px;width:104px}.xwk-account-art{align-items:center;background:radial-gradient(circle at 58% 38%,var(--xwk-avatar-spot),transparent 0 22%,transparent 23%),linear-gradient(160deg,var(--xwk-avatar-from),var(--xwk-avatar-to));display:flex;justify-content:center}.xwk-account-art span{background:rgba(255,255,255,.18);border-radius:999px;height:50px;width:50px}.xwk-account-panel-dropdown .xwk-account-art span{height:42px;width:42px}.xwk-account-avatar{background:${theme.surface};border:1px solid ${iconBorder};box-sizing:border-box;display:block;object-fit:cover;overflow:hidden}.xwk-account-panel-with-transactions .xwk-account-name{position:relative;z-index:1}.xwk-account-name{color:${theme.foreground};font-size:21px;font-weight:650;line-height:1.2;max-width:100%;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-account-panel-dropdown .xwk-account-name{font-size:18px}.xwk-account-meta-pill{align-items:center;background:${theme.surface};border:1px solid ${actionBorder};border-radius:14px;box-sizing:border-box;color:${theme.muted};display:inline-flex;font-size:13px;font-weight:560;gap:8px;justify-content:center;line-height:1.2;max-width:100%;min-height:44px;overflow:hidden;padding:2px 4px 2px 12px}.xwk-pill-address{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-pill-divider{background:${actionBorder};display:inline-block;flex:0 0 1px;height:18px;opacity:.8}.xwk-pill-balance{color:${theme.foreground};white-space:nowrap}.xwk-account-name-with-qr,.xwk-account-address{align-items:center;display:inline-flex;gap:6px;justify-content:center}.xwk-account-name-with-qr span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-account-name-address{background:${theme.surface};border:1px solid ${theme.border};border-radius:14px;color:${theme.muted};font-size:16px;font-weight:600;line-height:1.2;max-width:min(260px,100%);padding:7px 6px 7px 14px}.xwk-account-address{background:${theme.surface};border:1px solid ${theme.border};border-radius:12px;color:${theme.muted};font-size:14px;font-weight:520;line-height:1.25;max-width:100%;overflow:hidden;padding:8px 8px 8px 12px;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-address-qr-trigger{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent;border:0;border-radius:10px;box-shadow:none;color:currentColor;cursor:pointer;display:inline-flex;flex:0 0 40px;height:40px;justify-content:center;margin:0 -2px 0 0;min-height:40px;outline:none;overflow:visible;padding:0;touch-action:manipulation;transform:none;width:40px}.xwk-address-qr-trigger svg{display:block;height:17px;overflow:visible;width:17px}.xwk-address-qr-trigger:hover{background:${theme.surfaceHover};box-shadow:none;transform:none}.xwk-account-meta-row{align-items:center;display:flex;gap:8px;justify-content:center;max-width:100%;min-height:42px}.xwk-account-balance{align-items:center;background:${theme.surface};border:1px solid ${actionBorder};border-radius:999px;box-sizing:border-box;color:${theme.muted};display:inline-flex;font-size:13px;font-weight:560;height:42px;justify-content:center;letter-spacing:0;line-height:1;padding:0 14px;text-align:center}.xwk-account-balance-loading{align-items:center;display:inline-flex;gap:6px}.xwk-account-warning{align-items:center;background:${theme.surface};border:1px solid ${actionBorder};border-radius:12px;box-sizing:border-box;color:${theme.muted};display:flex;font-size:13px;font-weight:520;justify-content:center;line-height:1.25;min-height:54px;padding:0 14px;text-align:center;width:100%}.xwk-address-qr-content{align-content:center;display:grid;gap:14px;justify-items:center;min-height:100%;width:100%}.xwk-address-qr-code{aspect-ratio:1/1;background:${theme.surface};border:1px solid ${theme.border};border-radius:14px;box-sizing:border-box;display:grid;max-width:304px;padding:12px;place-items:center;width:min(304px,100%)}.xwk-address-qr-code svg,.xwk-address-qr-code canvas,.xwk-address-qr-code img{aspect-ratio:1/1;display:block;height:auto;max-width:100%;width:100%}.xwk-address-qr-chip{background:${theme.surface};border:1px solid ${theme.border};border-radius:12px;box-sizing:border-box;color:${theme.muted};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;font-weight:520;line-height:1.45;max-width:100%;overflow-wrap:anywhere;padding:9px 11px;text-align:center;width:100%}.xwk-address-qr-fallback{color:${theme.muted};font-size:12px;line-height:1.45;overflow-wrap:anywhere}.xwk-tx-section{background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-sizing:border-box;display:grid;overflow:hidden;width:100%}.xwk-tx-header{-webkit-tap-highlight-color:transparent;align-items:center;background:${theme.surface};border:0;box-shadow:none;color:${theme.muted};display:flex;font:inherit;font-size:10px;font-weight:650;gap:6px;letter-spacing:.07em;line-height:1.2;margin:0;min-height:34px;outline:none;padding:0 12px;text-align:left;text-transform:uppercase;transform:none;width:100%}.xwk-tx-header-link{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent;border:0;border-radius:9px;box-shadow:none;color:${theme.accent};cursor:pointer;display:inline-flex;font:inherit;font-size:11px;font-weight:650;gap:2px;line-height:1;margin-left:auto;min-height:28px;padding:0 6px;text-decoration:none;text-transform:none;touch-action:manipulation;transform:none}.xwk-tx-header-link:hover,.xwk-tx-header-link:active{background:${theme.surfaceHover};box-shadow:none;color:${theme.accent};opacity:1;text-decoration:none;transform:none}.xwk-tx-header-link svg{display:block;height:13px;width:13px}.xwk-tx-count{align-items:center;background:${theme.background};border:1px solid ${actionBorder};border-radius:999px;box-sizing:border-box;color:${theme.muted};display:inline-flex;font-size:10px;font-weight:650;height:16px;justify-content:center;letter-spacing:0;line-height:1;min-width:18px;padding:0 5px;text-transform:none}.xwk-tx-list{display:grid;overflow:hidden}.xwk-tx-list-inner{min-height:0;overflow:hidden}.xwk-tx-history-view{background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-sizing:border-box;display:grid;overflow:hidden;width:100%}.xwk-tx-history-view .xwk-tx-list-inner{max-height:468px;overflow:auto}.xwk-tx-row{align-items:center;background:${theme.surface};border-top:1px solid ${actionBorder};box-sizing:border-box;display:grid;gap:8px;grid-template-columns:24px minmax(0,1fr) auto;min-height:42px;padding:7px 10px;transition:background-color .16s ease}.xwk-tx-row:hover{background:${theme.surface};box-shadow:none;transform:none}.xwk-tx-row:first-child{border-top:0}.xwk-tx-status{align-items:center;background:${theme.background};border-radius:999px;color:${theme.accent};display:inline-flex;height:24px;justify-content:center;position:relative;width:24px}.xwk-tx-row-submitted .xwk-tx-status:before{animation:xwk-pulse-ring 1.4s ease-out infinite;border:1px solid currentColor;border-radius:999px;content:"";inset:2px;opacity:.42;position:absolute}.xwk-tx-row-confirmed .xwk-tx-status{color:${theme.success}}.xwk-tx-row-failed .xwk-tx-status{color:${theme.error}}.xwk-tx-row-unknown .xwk-tx-status{color:${theme.muted}}.xwk-tx-main{display:grid;gap:2px;min-width:0}.xwk-tx-label{color:${theme.foreground};font-size:12px;font-weight:600;line-height:1.15;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-tx-hash{color:${theme.muted};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px;line-height:1.15;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-tx-link{align-items:center;border-radius:9px;color:${theme.accent};display:inline-flex;font:inherit;font-size:12px;font-weight:650;gap:3px;line-height:1.2;min-height:28px;padding:0 6px;text-decoration:none}.xwk-tx-link:hover{background:${theme.surfaceHover};box-shadow:none;text-decoration:none;transform:none}.xwk-tx-link svg{height:12px;width:12px}.xwk-tx-empty{background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-sizing:border-box;color:${theme.muted};font-size:13px;line-height:1.35;padding:14px;text-align:center;width:100%}.xwk-tx-spinner{animation:xwk-action-spin .8s linear infinite;border:2px solid ${theme.spinnerTrail};border-top-color:${theme.accent};border-radius:999px;box-sizing:border-box;display:block;height:14px;width:14px}.xwk-account-panel-actions{display:grid;gap:10px;grid-template-columns:1fr;width:100%}.xwk-account-modal-body .xwk-account-panel-actions{margin-top:auto}.xwk-account-panel-with-transactions .xwk-account-modal-body .xwk-account-panel-actions{margin-top:0}.xwk-account-panel-actions button,.xwk-account-panel-actions a{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:flex;font:inherit;font-size:14px;font-weight:560;gap:8px;justify-content:center;line-height:1.2;min-height:46px;min-width:0;outline:none;overflow:hidden;padding:0 12px;text-decoration:none;touch-action:manipulation;transform:none;transition:background-color .16s ease,border-color .16s ease;width:100%}.xwk-account-panel-actions button:disabled{cursor:wait;opacity:1}.xwk-account-panel-actions svg{flex:0 0 auto;opacity:.58}.xwk-account-panel-actions span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-account-panel-actions button:hover,.xwk-account-panel-actions a:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;text-decoration:none;transform:none}.xwk-account-panel-actions button:active,.xwk-account-panel-actions a:active{background:${theme.surfaceHover};opacity:1;text-decoration:none;transform:none}.xwk-copied-icon{color:${theme.success};opacity:1!important}.xwk-action-spinner{animation:xwk-action-spin .8s linear infinite;border:2px solid ${theme.spinnerTrail};border-top-color:${theme.muted};border-radius:999px;box-sizing:border-box;display:inline-block;height:17px;width:17px}@keyframes xwk-action-spin{to{transform:rotate(360deg)}}@keyframes xwk-skeleton-pulse{0%{background-position:200% 0}100%{background-position:-200% 0}}@keyframes xwk-pulse-ring{0%{opacity:.42;transform:scale(.8)}80%,100%{opacity:0;transform:scale(1.45)}}@keyframes xwk-account-overlay-in{from{opacity:0}to{opacity:1}}@keyframes xwk-account-panel-in{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media(prefers-reduced-motion:reduce){.xwk-account-button,.xwk-tx-header-link,.xwk-account-panel-actions button,.xwk-account-panel-actions a{transition:none}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-overlay,.xwk-account-portal[data-xwk-entering="true"] .xwk-account-panel-modal{animation-duration:1ms!important}.xwk-action-spinner,.xwk-balance-spinner,.xwk-tx-spinner,.xwk-skeleton,.xwk-tx-row-submitted .xwk-tx-status:before{animation:none}}@media(max-width:520px){.xwk-account-panel-dropdown{bottom:0;left:0;margin-top:0;min-width:0;position:fixed;right:0;top:auto;width:100vw}.xwk-account-overlay{align-items:flex-end;padding:max(12px,env(safe-area-inset-top)) 0 0}.xwk-account-panel-modal{align-self:flex-end;border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;border-left:0;border-right:0;border-top-left-radius:${theme.radius};border-top-right-radius:${theme.radius};height:min(527px,calc(100dvh - env(safe-area-inset-top)));max-width:none;width:100vw}.xwk-account-panel-modal.xwk-account-panel-with-transactions,.xwk-account-panel-modal.xwk-account-panel-history{height:min(650px,calc(100dvh - env(safe-area-inset-top)))}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-panel-modal{animation:xwk-account-sheet-in .28s cubic-bezier(.32,.72,0,1)}.xwk-account-modal-header{border-top-left-radius:${theme.radius};border-top-right-radius:${theme.radius};grid-template-columns:44px minmax(0,1fr) 44px;padding:10px 16px}.xwk-account-modal-body{min-height:0;padding:18px 20px max(22px,calc(22px + env(safe-area-inset-bottom)))}.xwk-button-label{max-width:min(150px,calc(100vw - 140px))}}@keyframes xwk-account-sheet-in{from{opacity:1;transform:translateY(100%)}to{opacity:1;transform:translateY(0)}}`;
|
|
22034
|
+
const baseStyles = `.xwk-button-root{display:inline-block;max-width:100%;position:relative;font-family:${theme.fontFamily};font-size:14px}.xwk-account-button{align-items:center;background:${background};border:1px solid ${border};border-radius:${radius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:inline-flex;gap:8px;font:inherit;font-weight:560;max-width:100%;min-height:${height};overflow:hidden;padding:0 12px 0 10px;touch-action:manipulation;transition:background-color .16s ease,border-color .16s ease;white-space:nowrap;-webkit-tap-highlight-color:transparent;transform:none}.xwk-account-button:hover{background:${hoverBackground};box-shadow:none;opacity:1;transform:none}.xwk-account-button:active{background:${hoverBackground};opacity:1;transform:none}.xwk-account-button:focus-visible,.xwk-button-chevron:focus-visible,.xwk-account-panel-actions button:focus-visible,.xwk-account-panel-actions a:focus-visible,.xwk-address-qr-trigger:focus-visible,.xwk-tx-header-link:focus-visible,.xwk-tx-link:focus-visible{outline:2px solid ${theme.accent};outline-offset:2px;text-decoration:none}.xwk-button-icon{background:${theme.background};border:1px solid ${iconBorder};border-radius:10px;box-sizing:border-box;display:inline-flex;flex:0 0 28px;height:28px;isolation:isolate;line-height:0;max-width:28px;min-width:28px;object-fit:contain;overflow:hidden;position:relative;width:28px}.xwk-button-icon-fallback{align-items:center;background:${fallbackIconBackground};color:${fallbackIconColor};justify-content:center}.xwk-button-icon-initial{font-size:12px;line-height:1}.xwk-button-icon-svg-fallback{font-size:0}.xwk-button-icon-svg-fallback svg{display:block;flex:0 0 17px;height:17px;max-height:17px;max-width:17px;min-height:17px;min-width:17px;width:17px}.xwk-button-icon-custom{align-items:center;justify-content:center}.xwk-button-icon-custom img,.xwk-button-icon-custom svg{display:block;max-height:18px;max-width:18px}.xwk-button-icon-custom img{height:18px;object-fit:contain;width:18px}.xwk-button-icon-custom-html>*{max-height:18px;max-width:18px}.xwk-skeleton{animation:xwk-skeleton-pulse 1.4s ease-in-out infinite;background:linear-gradient(90deg,${theme.surface} 25%,${theme.surfaceHover} 50%,${theme.surface} 75%);background-size:200% 100%;border-radius:999px;display:inline-block}.xwk-skeleton-button-balance{height:12px;width:44px}.xwk-skeleton-balance{height:14px;width:70px}.xwk-skeleton-name{height:24px;width:132px}.xwk-account-name-skeleton{align-items:center;display:flex;justify-content:center;min-height:26px}.xwk-button-pending-dot{background:${theme.accent};border:2px solid ${background};border-radius:999px;box-sizing:border-box;flex:0 0 9px;height:9px;margin-left:-13px;margin-right:4px;position:relative;width:9px;z-index:1}.xwk-button-label{display:inline-block;flex:1 1 0;font-size:13px;font-weight:560;line-height:1.1;max-width:220px;min-width:0;overflow:hidden;padding-right:2px;text-overflow:ellipsis;white-space:nowrap}.xwk-button-balance{color:${theme.muted};font-weight:500;margin-left:4px}.xwk-button-balance-loading{display:inline-flex;vertical-align:-2px}.xwk-balance-spinner{animation:xwk-action-spin .8s linear infinite;border:2px solid ${theme.spinnerTrail};border-top-color:${theme.muted};border-radius:999px;box-sizing:border-box;display:inline-block;flex:0 0 13px;height:13px;width:13px}.xwk-button-chevron{align-items:center;background:${theme.background};border:1px solid ${iconBorder};border-radius:999px;color:${theme.muted};display:inline-flex;flex:0 0 26px;height:26px;justify-content:center;line-height:1;touch-action:manipulation;width:26px}.xwk-button-chevron:hover{background:${theme.surfaceHover};color:${theme.foreground}}.xwk-account-overlay{align-items:center;background:${theme.overlay};-webkit-backdrop-filter:${overlayBlur};backdrop-filter:${overlayBlur};display:flex;inset:0;justify-content:center;overscroll-behavior:contain;padding:max(24px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));position:fixed;z-index:var(--xwk-layer-modal,2147483000)}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-overlay{animation:xwk-account-overlay-in .18s ease-out}.xwk-account-panel{background:${theme.background};border:1px solid ${theme.border};border-radius:${theme.radius};box-shadow:${theme.shadow};box-sizing:border-box;color:${theme.foreground};display:grid;gap:12px;overflow:hidden;z-index:var(--xwk-layer-modal,2147483000)}.xwk-account-panel:focus{outline:none}.xwk-account-panel-dropdown{box-shadow:none;justify-items:center;margin-top:10px;min-width:320px;padding:18px;position:absolute;right:0;top:100%;width:min(360px,calc(100dvw - 32px))}.xwk-account-dropdown-header{align-items:center;display:grid;grid-template-columns:44px minmax(0,1fr) 44px;margin:-4px 0 0;width:100%}.xwk-account-dropdown-header strong{font-size:14px;font-weight:600;line-height:1.2;min-width:0;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-account-panel-modal{gap:0;grid-template-rows:auto minmax(0,1fr);height:min(527px,calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));max-width:520px;position:relative;transform-origin:center bottom;width:min(520px,100%)}.xwk-account-panel-modal.xwk-account-panel-with-transactions,.xwk-account-panel-modal.xwk-account-panel-history{height:min(650px,calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)))}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-panel-modal{animation:xwk-account-panel-in .22s cubic-bezier(.22,1,.36,1)}.xwk-account-modal-header{align-items:center;background:${theme.headerBackground};border-bottom:1px solid ${theme.border};display:grid;grid-template-columns:44px minmax(0,1fr) 44px;column-gap:8px;padding:8px 18px}.xwk-account-modal-header h2{color:${theme.foreground};font-size:16px;font-weight:600;letter-spacing:0;line-height:1.2;margin:0;min-width:0;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-account-modal-body{-webkit-overflow-scrolling:touch;align-items:center;display:flex;flex-direction:column;gap:12px;min-height:0;overflow:hidden;overscroll-behavior:contain;padding:22px 28px 28px}.xwk-account-panel-with-transactions .xwk-account-modal-body,.xwk-account-panel-history .xwk-account-modal-body{overflow:auto;padding-top:14px}.xwk-account-modal-body>.xwk-account-hero,.xwk-account-modal-body>.xwk-account-name,.xwk-account-modal-body>.xwk-account-meta-pill,.xwk-account-modal-body>.xwk-account-warning,.xwk-account-modal-body>.xwk-tx-section,.xwk-account-modal-body>.xwk-tx-history-view,.xwk-account-modal-body>.xwk-account-panel-actions{flex-shrink:0}.xwk-account-close,.xwk-account-back{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent!important;border:0!important;border-radius:999px;box-shadow:none!important;color:${theme.muted};cursor:pointer;display:inline-flex;font:inherit;font-size:26px;font-weight:500;height:44px;justify-content:center;line-height:1;margin:0;min-height:0;outline:none!important;padding:0;touch-action:manipulation;transform:none;width:44px}.xwk-account-back{font-size:0;justify-self:start}.xwk-account-close{justify-self:end}.xwk-account-close:hover,.xwk-account-back:hover{background:${theme.surfaceHover}!important;box-shadow:none!important;color:${theme.foreground};transform:none}.xwk-account-close:focus-visible,.xwk-account-back:focus-visible{outline:2px solid ${theme.accent}!important;outline-offset:0}.xwk-account-hero{height:154px;margin-top:4px;position:relative;width:180px}.xwk-account-panel-with-transactions .xwk-account-hero{height:126px;margin-bottom:0}.xwk-account-panel-with-transactions .xwk-account-art,.xwk-account-panel-with-transactions .xwk-account-avatar{top:0}.xwk-account-panel-dropdown .xwk-account-hero{height:132px;width:160px}.xwk-account-art,.xwk-account-avatar{border-radius:999px;height:118px;left:31px;position:absolute;top:8px;width:118px}.xwk-account-panel-dropdown .xwk-account-art,.xwk-account-panel-dropdown .xwk-account-avatar{height:104px;left:28px;width:104px}.xwk-account-art{align-items:center;background:radial-gradient(circle at 58% 38%,var(--xwk-avatar-spot),transparent 0 22%,transparent 23%),linear-gradient(160deg,var(--xwk-avatar-from),var(--xwk-avatar-to));display:flex;justify-content:center}.xwk-account-art span{background:rgba(255,255,255,.18);border-radius:999px;height:50px;width:50px}.xwk-account-panel-dropdown .xwk-account-art span{height:42px;width:42px}.xwk-account-avatar{background:${theme.surface};border:1px solid ${iconBorder};box-sizing:border-box;display:block;object-fit:cover;overflow:hidden}.xwk-account-panel-with-transactions .xwk-account-name{position:relative;z-index:1}.xwk-account-name{color:${theme.foreground};font-size:21px;font-weight:650;line-height:1.2;max-width:100%;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-account-panel-dropdown .xwk-account-name{font-size:18px}.xwk-account-meta-pill{align-items:center;background:${theme.surface};border:1px solid ${actionBorder};border-radius:14px;box-sizing:border-box;color:${theme.muted};display:inline-flex;font-size:13px;font-weight:560;gap:8px;justify-content:center;line-height:1.2;max-width:100%;min-height:44px;overflow:hidden;padding:2px 4px 2px 12px}.xwk-pill-address{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-pill-divider{background:${actionBorder};display:inline-block;flex:0 0 1px;height:18px;opacity:.8}.xwk-pill-balance{color:${theme.foreground};white-space:nowrap}.xwk-account-name-with-qr,.xwk-account-address{align-items:center;display:inline-flex;gap:6px;justify-content:center}.xwk-account-name-with-qr span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-account-name-address{background:${theme.surface};border:1px solid ${theme.border};border-radius:14px;color:${theme.muted};font-size:16px;font-weight:600;line-height:1.2;max-width:min(260px,100%);padding:7px 6px 7px 14px}.xwk-account-address{background:${theme.surface};border:1px solid ${theme.border};border-radius:12px;color:${theme.muted};font-size:14px;font-weight:520;line-height:1.25;max-width:100%;overflow:hidden;padding:8px 8px 8px 12px;text-align:center;text-overflow:ellipsis;white-space:nowrap}.xwk-address-qr-trigger{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent;border:0;border-radius:10px;box-shadow:none;color:currentColor;cursor:pointer;display:inline-flex;flex:0 0 40px;height:40px;justify-content:center;margin:0 -2px 0 0;min-height:40px;outline:none;overflow:visible;padding:0;touch-action:manipulation;transform:none;width:40px}.xwk-address-qr-trigger svg{display:block;height:17px;overflow:visible;width:17px}.xwk-address-qr-trigger:hover{background:${theme.surfaceHover};box-shadow:none;transform:none}.xwk-account-meta-row{align-items:center;display:flex;gap:8px;justify-content:center;max-width:100%;min-height:42px}.xwk-account-balance{align-items:center;background:${theme.surface};border:1px solid ${actionBorder};border-radius:999px;box-sizing:border-box;color:${theme.muted};display:inline-flex;font-size:13px;font-weight:560;height:42px;justify-content:center;letter-spacing:0;line-height:1;padding:0 14px;text-align:center}.xwk-account-balance-loading{align-items:center;display:inline-flex;gap:6px}.xwk-account-warning{align-items:center;background:${theme.surface};border:1px solid ${actionBorder};border-radius:12px;box-sizing:border-box;color:${theme.muted};display:flex;font-size:13px;font-weight:520;justify-content:center;line-height:1.25;min-height:54px;padding:0 14px;text-align:center;width:100%}.xwk-address-qr-content{align-content:center;display:grid;gap:14px;justify-items:center;min-height:100%;width:100%}.xwk-address-qr-code{aspect-ratio:1/1;background:${theme.surface};border:1px solid ${theme.border};border-radius:14px;box-sizing:border-box;display:grid;max-width:304px;padding:12px;place-items:center;width:min(304px,100%)}.xwk-address-qr-code svg,.xwk-address-qr-code canvas,.xwk-address-qr-code img{aspect-ratio:1/1;display:block;height:auto;max-width:100%;width:100%}.xwk-address-qr-chip{background:${theme.surface};border:1px solid ${theme.border};border-radius:12px;box-sizing:border-box;color:${theme.muted};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;font-weight:520;line-height:1.45;max-width:100%;overflow-wrap:anywhere;padding:9px 11px;text-align:center;width:100%}.xwk-address-qr-fallback{color:${theme.muted};font-size:12px;line-height:1.45;overflow-wrap:anywhere}.xwk-tx-section{background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-sizing:border-box;display:grid;overflow:hidden;width:100%}.xwk-tx-header{-webkit-tap-highlight-color:transparent;align-items:center;background:${theme.surface};border:0;box-shadow:none;color:${theme.muted};display:flex;font:inherit;font-size:10px;font-weight:650;gap:6px;letter-spacing:.07em;line-height:1.2;margin:0;min-height:34px;outline:none;padding:0 12px;text-align:left;text-transform:uppercase;transform:none;width:100%}.xwk-tx-header-link{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent;border:0;border-radius:9px;box-shadow:none;color:${theme.accent};cursor:pointer;display:inline-flex;font:inherit;font-size:11px;font-weight:650;gap:2px;line-height:1;margin-left:auto;min-height:28px;padding:0 6px;text-decoration:none;text-transform:none;touch-action:manipulation;transform:none}.xwk-tx-header-link:hover,.xwk-tx-header-link:active{background:${theme.surfaceHover};box-shadow:none;color:${theme.accent};opacity:1;text-decoration:none;transform:none}.xwk-tx-header-link svg{display:block;height:13px;width:13px}.xwk-tx-count{align-items:center;background:${theme.background};border:1px solid ${actionBorder};border-radius:999px;box-sizing:border-box;color:${theme.muted};display:inline-flex;font-size:10px;font-weight:650;height:16px;justify-content:center;letter-spacing:0;line-height:1;min-width:18px;padding:0 5px;text-transform:none}.xwk-tx-list{display:grid;overflow:hidden}.xwk-tx-list-inner{min-height:0;overflow:hidden}.xwk-tx-history-view{background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-sizing:border-box;display:grid;overflow:hidden;width:100%}.xwk-tx-history-view .xwk-tx-list-inner{max-height:468px;overflow:auto}.xwk-tx-row{align-items:center;background:${theme.surface};border-top:1px solid ${actionBorder};box-sizing:border-box;display:grid;gap:8px;grid-template-columns:24px minmax(0,1fr) auto;min-height:42px;padding:7px 10px;transition:background-color .16s ease}.xwk-tx-row:hover{background:${theme.surface};box-shadow:none;transform:none}.xwk-tx-row:first-child{border-top:0}.xwk-tx-status{align-items:center;background:${theme.background};border-radius:999px;color:${theme.accent};display:inline-flex;height:24px;justify-content:center;position:relative;width:24px}.xwk-tx-row-submitted .xwk-tx-status:before{animation:xwk-pulse-ring 1.4s ease-out infinite;border:1px solid currentColor;border-radius:999px;content:"";inset:2px;opacity:.42;position:absolute}.xwk-tx-row-confirmed .xwk-tx-status{color:${theme.success}}.xwk-tx-row-failed .xwk-tx-status{color:${theme.error}}.xwk-tx-row-unknown .xwk-tx-status{color:${theme.muted}}.xwk-tx-main{display:grid;gap:2px;min-width:0}.xwk-tx-label{color:${theme.foreground};font-size:12px;font-weight:600;line-height:1.15;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-tx-hash{color:${theme.muted};font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px;line-height:1.15;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-tx-state{color:${theme.foreground};font-family:${theme.fontFamily};font-weight:560}.xwk-tx-link{align-items:center;border-radius:9px;color:${theme.accent};display:inline-flex;font:inherit;font-size:12px;font-weight:650;gap:3px;line-height:1.2;min-height:28px;padding:0 6px;text-decoration:none}.xwk-tx-link:hover{background:${theme.surfaceHover};box-shadow:none;text-decoration:none;transform:none}.xwk-tx-link svg{height:12px;width:12px}.xwk-tx-empty{background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-sizing:border-box;color:${theme.muted};font-size:13px;line-height:1.35;padding:14px;text-align:center;width:100%}.xwk-tx-spinner{animation:xwk-action-spin .8s linear infinite;border:2px solid ${theme.spinnerTrail};border-top-color:${theme.accent};border-radius:999px;box-sizing:border-box;display:block;height:14px;width:14px}.xwk-account-panel-actions{display:grid;gap:10px;grid-template-columns:1fr;width:100%}.xwk-account-modal-body .xwk-account-panel-actions{margin-top:auto}.xwk-account-panel-with-transactions .xwk-account-modal-body .xwk-account-panel-actions{margin-top:0}.xwk-account-panel-actions button,.xwk-account-panel-actions a{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:${theme.surface};border:1px solid ${actionBorder};border-radius:${theme.walletRadius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:flex;font:inherit;font-size:14px;font-weight:560;gap:8px;justify-content:center;line-height:1.2;min-height:46px;min-width:0;outline:none;overflow:hidden;padding:0 12px;text-decoration:none;touch-action:manipulation;transform:none;transition:background-color .16s ease,border-color .16s ease;width:100%}.xwk-account-panel-actions button:disabled{cursor:wait;opacity:1}.xwk-account-panel-actions svg{flex:0 0 auto;opacity:.58}.xwk-account-panel-actions span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-account-panel-actions button:hover,.xwk-account-panel-actions a:hover{background:${theme.surfaceHover};border-color:${actionBorder};box-shadow:none;text-decoration:none;transform:none}.xwk-account-panel-actions button:active,.xwk-account-panel-actions a:active{background:${theme.surfaceHover};opacity:1;text-decoration:none;transform:none}.xwk-copied-icon{--xwk-success-icon-foreground:${theme.background};color:${theme.success};opacity:1!important}.xwk-action-spinner{animation:xwk-action-spin .8s linear infinite;border:2px solid ${theme.spinnerTrail};border-top-color:${theme.muted};border-radius:999px;box-sizing:border-box;display:inline-block;height:17px;width:17px}@keyframes xwk-action-spin{to{transform:rotate(360deg)}}@keyframes xwk-skeleton-pulse{0%{background-position:200% 0}100%{background-position:-200% 0}}@keyframes xwk-pulse-ring{0%{opacity:.42;transform:scale(.8)}80%,100%{opacity:0;transform:scale(1.45)}}@keyframes xwk-account-overlay-in{from{opacity:0}to{opacity:1}}@keyframes xwk-account-panel-in{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media(prefers-reduced-motion:reduce){.xwk-account-button,.xwk-tx-header-link,.xwk-account-panel-actions button,.xwk-account-panel-actions a{transition:none}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-overlay,.xwk-account-portal[data-xwk-entering="true"] .xwk-account-panel-modal{animation-duration:1ms!important}.xwk-action-spinner,.xwk-balance-spinner,.xwk-tx-spinner,.xwk-skeleton,.xwk-tx-row-submitted .xwk-tx-status:before{animation:none}}@media(max-width:520px){.xwk-account-panel-dropdown{bottom:0;left:0;margin-top:0;min-width:0;position:fixed;right:0;top:auto;width:100%}.xwk-account-overlay{align-items:flex-end;padding:max(12px,env(safe-area-inset-top)) 0 0}.xwk-account-panel-modal{align-self:flex-end;border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;border-left:0;border-right:0;border-top-left-radius:${theme.radius};border-top-right-radius:${theme.radius};height:min(527px,calc(100dvh - env(safe-area-inset-top)));max-width:none;width:100%}.xwk-account-panel-modal.xwk-account-panel-with-transactions,.xwk-account-panel-modal.xwk-account-panel-history{height:min(650px,calc(100dvh - env(safe-area-inset-top)))}.xwk-account-portal[data-xwk-entering="true"] .xwk-account-panel-modal{animation:xwk-account-sheet-in .28s cubic-bezier(.32,.72,0,1)}.xwk-account-modal-header{border-top-left-radius:${theme.radius};border-top-right-radius:${theme.radius};grid-template-columns:44px minmax(0,1fr) 44px;padding:10px 16px}.xwk-account-modal-body{min-height:0;padding:18px 20px max(22px,calc(22px + env(safe-area-inset-bottom)))}.xwk-button-label{max-width:min(150px,calc(100dvw - 140px))}}@keyframes xwk-account-sheet-in{from{opacity:1;transform:translateY(100%)}to{opacity:1;transform:translateY(0)}}`;
|
|
22062
22035
|
return `${baseStyles}${this.renderSkeletonPrimitiveStyles(theme, iconBorder)}`;
|
|
22063
22036
|
}
|
|
22064
22037
|
renderSkeletonPrimitiveStyles(theme, iconBorder) {
|
|
@@ -22083,13 +22056,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22083
22056
|
return this.options.themeMode === "auto" ? this.getSystemThemeMode() : this.options.themeMode;
|
|
22084
22057
|
}
|
|
22085
22058
|
resolveTarget(target) {
|
|
22086
|
-
if (!target)
|
|
22087
|
-
|
|
22088
|
-
if (typeof target !== "string")
|
|
22089
|
-
return target;
|
|
22059
|
+
if (!target) return void 0;
|
|
22060
|
+
if (typeof target !== "string") return target;
|
|
22090
22061
|
const element = document.querySelector(target);
|
|
22091
|
-
if (!element)
|
|
22092
|
-
throw new Error(`Wallet button target was not found: ${target}`);
|
|
22062
|
+
if (!element) throw new Error(`Wallet button target was not found: ${target}`);
|
|
22093
22063
|
return element;
|
|
22094
22064
|
}
|
|
22095
22065
|
formatAddress(address) {
|
|
@@ -22112,8 +22082,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22112
22082
|
return [colors[0], colors[1], colors[2]];
|
|
22113
22083
|
}
|
|
22114
22084
|
getSystemThemeMode() {
|
|
22115
|
-
if (typeof window === "undefined" || !window.matchMedia)
|
|
22116
|
-
return "light";
|
|
22085
|
+
if (typeof window === "undefined" || !window.matchMedia) return "light";
|
|
22117
22086
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
22118
22087
|
}
|
|
22119
22088
|
escapeHtml(value) {
|
|
@@ -22133,19 +22102,16 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22133
22102
|
const cacheTtlMs = options.cacheTtlMs ?? 6e5;
|
|
22134
22103
|
const cache = /* @__PURE__ */ new Map();
|
|
22135
22104
|
return async (address, session, context) => {
|
|
22136
|
-
if (!session || !isMainnetNetwork(session.account.network))
|
|
22137
|
-
return null;
|
|
22105
|
+
if (!session || !isMainnetNetwork(session.account.network)) return null;
|
|
22138
22106
|
const cached = cache.get(address);
|
|
22139
|
-
if (!(context == null ? void 0 : context.force) && cached && cached.expiresAt > Date.now())
|
|
22140
|
-
return cached.value;
|
|
22107
|
+
if (!(context == null ? void 0 : context.force) && cached && cached.expiresAt > Date.now()) return cached.value;
|
|
22141
22108
|
const controller = new AbortController();
|
|
22142
22109
|
const timeout = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
22143
22110
|
try {
|
|
22144
22111
|
const params = `address=${encodeURIComponent(address)}${(context == null ? void 0 : context.force) ? `&_=${Date.now()}` : ""}`;
|
|
22145
22112
|
const url = `${endpoint}${endpoint.includes("?") ? "&" : "?"}${params}`;
|
|
22146
22113
|
const response = await fetch(url, { signal: controller.signal });
|
|
22147
|
-
if (!response.ok)
|
|
22148
|
-
return null;
|
|
22114
|
+
if (!response.ok) return null;
|
|
22149
22115
|
const json = await response.json();
|
|
22150
22116
|
const name = typeof json.data === "string" ? json.data : typeof json.name === "string" ? json.name : null;
|
|
22151
22117
|
const avatar = name ? await resolveXrpDomainAvatar(profileEndpoint, name, controller.signal) : void 0;
|
|
@@ -22161,8 +22127,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22161
22127
|
try {
|
|
22162
22128
|
const url = `${endpoint}${endpoint.includes("?") ? "&" : "?"}domain=${encodeURIComponent(domain)}`;
|
|
22163
22129
|
const response = await fetch(url, { signal });
|
|
22164
|
-
if (!response.ok)
|
|
22165
|
-
return void 0;
|
|
22130
|
+
if (!response.ok) return void 0;
|
|
22166
22131
|
const json = await response.json();
|
|
22167
22132
|
return normalizeAvatarUrl(findAvatarUrl(json), endpoint);
|
|
22168
22133
|
} catch {
|
|
@@ -22170,29 +22135,22 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22170
22135
|
}
|
|
22171
22136
|
}
|
|
22172
22137
|
function findAvatarUrl(value) {
|
|
22173
|
-
if (!value || typeof value !== "object")
|
|
22174
|
-
return void 0;
|
|
22138
|
+
if (!value || typeof value !== "object") return void 0;
|
|
22175
22139
|
const record = value;
|
|
22176
22140
|
const direct = record.avatar;
|
|
22177
|
-
if (typeof direct === "string" && direct.trim())
|
|
22178
|
-
return direct.trim();
|
|
22141
|
+
if (typeof direct === "string" && direct.trim()) return direct.trim();
|
|
22179
22142
|
const profileInfo = record.profile_info ?? record.profileInfo;
|
|
22180
22143
|
const profileAvatar = findAvatarUrl(profileInfo);
|
|
22181
|
-
if (profileAvatar)
|
|
22182
|
-
return profileAvatar;
|
|
22144
|
+
if (profileAvatar) return profileAvatar;
|
|
22183
22145
|
const dataAvatar = findAvatarUrl(record.data);
|
|
22184
|
-
if (dataAvatar)
|
|
22185
|
-
return dataAvatar;
|
|
22146
|
+
if (dataAvatar) return dataAvatar;
|
|
22186
22147
|
const resultAvatar = findAvatarUrl(record.result);
|
|
22187
|
-
if (resultAvatar)
|
|
22188
|
-
return resultAvatar;
|
|
22148
|
+
if (resultAvatar) return resultAvatar;
|
|
22189
22149
|
return void 0;
|
|
22190
22150
|
}
|
|
22191
22151
|
function normalizeAvatarUrl(value, endpoint) {
|
|
22192
|
-
if (!value)
|
|
22193
|
-
|
|
22194
|
-
if (/^(?:https?:|data:|blob:|ipfs:|ar:)/i.test(value))
|
|
22195
|
-
return value;
|
|
22152
|
+
if (!value) return void 0;
|
|
22153
|
+
if (/^(?:https?:|data:|blob:|ipfs:|ar:)/i.test(value)) return value;
|
|
22196
22154
|
if (value.startsWith("//")) {
|
|
22197
22155
|
try {
|
|
22198
22156
|
return `${new URL(endpoint).protocol}${value}`;
|
|
@@ -22212,8 +22170,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22212
22170
|
}
|
|
22213
22171
|
function createWalletButton(options) {
|
|
22214
22172
|
const button = new WalletButtonController(options);
|
|
22215
|
-
if (options.target)
|
|
22216
|
-
button.mount(options.target);
|
|
22173
|
+
if (options.target) button.mount(options.target);
|
|
22217
22174
|
return button;
|
|
22218
22175
|
}
|
|
22219
22176
|
const DEFAULT_AUTO_DISMISS_MS = 5e3;
|
|
@@ -22224,31 +22181,34 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22224
22181
|
this.offEvents = [];
|
|
22225
22182
|
this.dismissTimers = /* @__PURE__ */ new Map();
|
|
22226
22183
|
this.toasts = /* @__PURE__ */ new Map();
|
|
22227
|
-
this.offEvents.push(
|
|
22228
|
-
hash: hash2,
|
|
22229
|
-
status: "submitted",
|
|
22230
|
-
submittedAt: Date.now()
|
|
22231
|
-
})), options.manager.on("tx_confirmed", ({ hash: hash2, transaction: transaction2 }) => this.upsert(hash2, transaction2 ?? {
|
|
22232
|
-
hash: hash2,
|
|
22233
|
-
status: "confirmed",
|
|
22234
|
-
submittedAt: Date.now(),
|
|
22235
|
-
confirmedAt: Date.now()
|
|
22236
|
-
})), options.manager.on("tx_failed", ({ hash: hash2, transaction: transaction2, error }) => {
|
|
22237
|
-
if (!hash2)
|
|
22238
|
-
return;
|
|
22239
|
-
this.upsert(hash2, transaction2 ?? {
|
|
22184
|
+
this.offEvents.push(
|
|
22185
|
+
options.manager.on("tx_submitted", ({ hash: hash2, transaction: transaction2 }) => this.upsert(hash2, transaction2 ?? {
|
|
22240
22186
|
hash: hash2,
|
|
22241
|
-
status: "
|
|
22187
|
+
status: "submitted",
|
|
22188
|
+
submittedAt: Date.now()
|
|
22189
|
+
})),
|
|
22190
|
+
options.manager.on("tx_confirmed", ({ hash: hash2, transaction: transaction2 }) => this.upsert(hash2, transaction2 ?? {
|
|
22191
|
+
hash: hash2,
|
|
22192
|
+
status: "confirmed",
|
|
22242
22193
|
submittedAt: Date.now(),
|
|
22243
|
-
|
|
22244
|
-
|
|
22245
|
-
})
|
|
22246
|
-
|
|
22194
|
+
confirmedAt: Date.now()
|
|
22195
|
+
})),
|
|
22196
|
+
options.manager.on("tx_failed", ({ hash: hash2, transaction: transaction2, error }) => {
|
|
22197
|
+
if (!hash2) return;
|
|
22198
|
+
this.upsert(hash2, transaction2 ?? {
|
|
22199
|
+
hash: hash2,
|
|
22200
|
+
status: "failed",
|
|
22201
|
+
submittedAt: Date.now(),
|
|
22202
|
+
failedAt: Date.now(),
|
|
22203
|
+
error
|
|
22204
|
+
});
|
|
22205
|
+
}),
|
|
22206
|
+
options.manager.on("disconnected", () => this.clearAll())
|
|
22207
|
+
);
|
|
22247
22208
|
}
|
|
22248
22209
|
mount(container = this.options.mount ?? document.body) {
|
|
22249
22210
|
var _a2;
|
|
22250
|
-
if ((_a2 = this.root) == null ? void 0 : _a2.isConnected)
|
|
22251
|
-
return;
|
|
22211
|
+
if ((_a2 = this.root) == null ? void 0 : _a2.isConnected) return;
|
|
22252
22212
|
this.root = document.createElement("div");
|
|
22253
22213
|
this.root.className = `xwk-toast-root xwk-toast-root--${this.position()}`;
|
|
22254
22214
|
this.root.setAttribute("aria-live", "polite");
|
|
@@ -22273,8 +22233,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22273
22233
|
upsert(hash2, transaction2) {
|
|
22274
22234
|
var _a2;
|
|
22275
22235
|
this.toasts.set(hash2, transaction2);
|
|
22276
|
-
if (!((_a2 = this.root) == null ? void 0 : _a2.isConnected) && typeof document !== "undefined")
|
|
22277
|
-
this.mount();
|
|
22236
|
+
if (!((_a2 = this.root) == null ? void 0 : _a2.isConnected) && typeof document !== "undefined") this.mount();
|
|
22278
22237
|
this.enforceLimit();
|
|
22279
22238
|
this.render();
|
|
22280
22239
|
if (transaction2.status === "confirmed" || transaction2.status === "failed") {
|
|
@@ -22288,25 +22247,21 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22288
22247
|
}
|
|
22289
22248
|
scheduleDismiss(hash2) {
|
|
22290
22249
|
const autoDismissMs = this.options.autoDismissMs ?? DEFAULT_AUTO_DISMISS_MS;
|
|
22291
|
-
if (autoDismissMs <= 0)
|
|
22292
|
-
return;
|
|
22250
|
+
if (autoDismissMs <= 0) return;
|
|
22293
22251
|
const previous = this.dismissTimers.get(hash2);
|
|
22294
|
-
if (previous)
|
|
22295
|
-
window.clearTimeout(previous);
|
|
22252
|
+
if (previous) window.clearTimeout(previous);
|
|
22296
22253
|
const timer = window.setTimeout(() => this.remove(hash2), autoDismissMs);
|
|
22297
22254
|
this.dismissTimers.set(hash2, timer);
|
|
22298
22255
|
}
|
|
22299
22256
|
remove(hash2) {
|
|
22300
22257
|
const timer = this.dismissTimers.get(hash2);
|
|
22301
|
-
if (timer)
|
|
22302
|
-
window.clearTimeout(timer);
|
|
22258
|
+
if (timer) window.clearTimeout(timer);
|
|
22303
22259
|
this.dismissTimers.delete(hash2);
|
|
22304
22260
|
this.toasts.delete(hash2);
|
|
22305
22261
|
this.render();
|
|
22306
22262
|
}
|
|
22307
22263
|
render() {
|
|
22308
|
-
if (!this.root)
|
|
22309
|
-
return;
|
|
22264
|
+
if (!this.root) return;
|
|
22310
22265
|
this.root.className = `xwk-toast-root xwk-toast-root--${this.position()}`;
|
|
22311
22266
|
this.ensureStyles();
|
|
22312
22267
|
const toasts = [...this.toasts.values()].sort((a2, b2) => this.getTimestamp(a2) - this.getTimestamp(b2)).map((transaction2) => this.renderToast(transaction2)).join("");
|
|
@@ -22314,8 +22269,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22314
22269
|
this.root.querySelectorAll("[data-xwk-toast-dismiss]").forEach((button) => {
|
|
22315
22270
|
button.addEventListener("click", () => {
|
|
22316
22271
|
const hash2 = button.dataset.xwkToastDismiss;
|
|
22317
|
-
if (hash2)
|
|
22318
|
-
this.remove(hash2);
|
|
22272
|
+
if (hash2) this.remove(hash2);
|
|
22319
22273
|
});
|
|
22320
22274
|
});
|
|
22321
22275
|
}
|
|
@@ -22330,17 +22284,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22330
22284
|
return `<div class="xwk-toast xwk-toast--${transaction2.status}" data-hash="${this.escapeHtml(hash2)}" role="status"><div class="xwk-toast-icon">${this.renderStatusIcon(transaction2.status)}</div><div class="xwk-toast-body"><span class="xwk-toast-label">${this.escapeHtml(label)}</span><span class="xwk-toast-hash">${this.escapeHtml(hashLabel)}</span></div>${link}<button class="xwk-toast-dismiss" data-xwk-toast-dismiss="${this.escapeHtml(hash2)}" aria-label="${this.escapeHtml(messages.close)}" type="button">×</button></div>`;
|
|
22331
22285
|
}
|
|
22332
22286
|
renderStatusIcon(status) {
|
|
22333
|
-
if (status === "confirmed")
|
|
22334
|
-
|
|
22335
|
-
if (status === "
|
|
22336
|
-
return `<span class="xwk-toast-icon-mark" aria-hidden="true">${this.closeIcon()}</span>`;
|
|
22337
|
-
if (status === "unknown")
|
|
22338
|
-
return `<span class="xwk-toast-icon-mark" aria-hidden="true">?</span>`;
|
|
22287
|
+
if (status === "confirmed") return `<span class="xwk-toast-icon-mark" aria-hidden="true">${this.checkIcon()}</span>`;
|
|
22288
|
+
if (status === "failed") return `<span class="xwk-toast-icon-mark" aria-hidden="true">${this.closeIcon()}</span>`;
|
|
22289
|
+
if (status === "unknown") return `<span class="xwk-toast-icon-mark" aria-hidden="true">?</span>`;
|
|
22339
22290
|
return `<span class="xwk-toast-spinner" aria-hidden="true"></span>`;
|
|
22340
22291
|
}
|
|
22341
22292
|
renderStyles() {
|
|
22342
22293
|
const theme = this.resolveTheme();
|
|
22343
|
-
return `.xwk-toast-root{bottom:24px;display:flex;flex-direction:column-reverse;font-family:${theme.fontFamily};gap:10px;pointer-events:none;position:fixed;z-index:
|
|
22294
|
+
return `.xwk-toast-root{bottom:24px;display:flex;flex-direction:column-reverse;font-family:${theme.fontFamily};gap:10px;pointer-events:none;position:fixed;z-index:var(--xwk-layer-toast,2147482990)}.xwk-toast-root--bottom-right{right:24px}.xwk-toast-root--bottom-left{left:24px}.xwk-toast-root--bottom-center{left:50%;transform:translateX(-50%)}.xwk-toast{align-items:center;animation:xwk-toast-in .18s ease-out both;background:${theme.background};border:1px solid ${theme.border};border-radius:${theme.radius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};display:flex;gap:12px;max-width:420px;min-width:330px;padding:12px 12px 12px 16px;pointer-events:auto}.xwk-toast-icon{align-items:center;border-radius:999px;display:flex;flex:0 0 32px;height:32px;justify-content:center;width:32px}.xwk-toast-spinner{animation:xwk-spin .9s linear infinite;border:2px solid ${theme.spinnerTrail};border-top-color:${theme.accent};border-radius:999px;display:block;height:18px;width:18px}.xwk-toast--submitted .xwk-toast-icon{background:${theme.surface};color:${theme.accent}}.xwk-toast--confirmed .xwk-toast-icon{background:${theme.surface};color:${theme.success}}.xwk-toast--failed .xwk-toast-icon{background:${theme.surface};color:${theme.error}}.xwk-toast--unknown .xwk-toast-icon{background:${theme.surface};color:${theme.muted}}.xwk-toast-icon-mark{display:inline-flex}.xwk-toast-body{display:flex;flex:1 1 auto;flex-direction:column;gap:2px;min-width:0}.xwk-toast-label{color:${theme.foreground};font-size:13px;font-weight:600;white-space:nowrap}.xwk-toast-hash{color:${theme.muted};font-family:ui-monospace,"Cascadia Code",monospace;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.xwk-toast-link{-webkit-tap-highlight-color:transparent;align-items:center;border-radius:${theme.walletRadius};box-sizing:border-box;color:${theme.accent};display:inline-flex;flex:0 0 auto;font:inherit;font-size:12px;font-weight:600;gap:4px;line-height:1.2;min-height:32px;outline:none;overflow:hidden;padding:0 6px;text-decoration:none;touch-action:manipulation;transform:none;white-space:nowrap}.xwk-toast-link:hover{background:${theme.surfaceHover};text-decoration:none}.xwk-toast-link svg{height:13px;width:13px}.xwk-toast-dismiss{-webkit-appearance:none;-webkit-tap-highlight-color:transparent;align-items:center;appearance:none;background:transparent;border:1px solid ${theme.border};border-radius:${theme.walletRadius};box-shadow:none;box-sizing:border-box;color:${theme.foreground};cursor:pointer;display:inline-flex;flex:0 0 44px;font:inherit;font-size:24px;font-weight:400;height:44px;justify-content:center;line-height:1;margin:0;min-height:0;outline:none;overflow:hidden;padding:0;touch-action:manipulation;transform:none;width:44px}.xwk-toast-dismiss:hover{background:${theme.surfaceHover};border-color:${theme.border};box-shadow:none;color:${theme.foreground};transform:none}.xwk-toast-dismiss:focus-visible,.xwk-toast-link:focus-visible{outline:2px solid ${theme.accent};outline-offset:2px}@keyframes xwk-toast-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes xwk-spin{to{transform:rotate(360deg)}}@media(max-width:480px){.xwk-toast-root{bottom:max(12px,env(safe-area-inset-bottom));left:12px;right:12px;transform:none}.xwk-toast{max-width:100%;min-width:0;width:100%}}@media(prefers-reduced-motion:reduce){.xwk-toast,.xwk-toast-spinner{animation:none}}`;
|
|
22344
22295
|
}
|
|
22345
22296
|
ensureStyles() {
|
|
22346
22297
|
const styles2 = this.renderStyles();
|
|
@@ -22349,8 +22300,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22349
22300
|
getExplorerUrl(hash2, network) {
|
|
22350
22301
|
var _a2, _b;
|
|
22351
22302
|
const custom = (_b = (_a2 = this.options).explorerUrl) == null ? void 0 : _b.call(_a2, hash2, network);
|
|
22352
|
-
if (custom)
|
|
22353
|
-
return custom;
|
|
22303
|
+
if (custom) return custom;
|
|
22354
22304
|
return getExplorerTxUrl(network, hash2);
|
|
22355
22305
|
}
|
|
22356
22306
|
getTimestamp(transaction2) {
|
|
@@ -22377,8 +22327,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22377
22327
|
return this.options.themeMode === "auto" ? this.getSystemThemeMode() : this.options.themeMode ?? "light";
|
|
22378
22328
|
}
|
|
22379
22329
|
getSystemThemeMode() {
|
|
22380
|
-
if (typeof window === "undefined" || !window.matchMedia)
|
|
22381
|
-
return "light";
|
|
22330
|
+
if (typeof window === "undefined" || !window.matchMedia) return "light";
|
|
22382
22331
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
22383
22332
|
}
|
|
22384
22333
|
clearTimers() {
|
|
@@ -22406,8 +22355,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22406
22355
|
}
|
|
22407
22356
|
function createWalletToast(options) {
|
|
22408
22357
|
const toast = new WalletToast(options);
|
|
22409
|
-
if (options.mount)
|
|
22410
|
-
toast.mount(options.mount);
|
|
22358
|
+
if (options.mount) toast.mount(options.mount);
|
|
22411
22359
|
return toast;
|
|
22412
22360
|
}
|
|
22413
22361
|
function createWalletClient(options) {
|
|
@@ -22517,8 +22465,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22517
22465
|
var _a2;
|
|
22518
22466
|
const modalConfig = typeof options.modal === "object" ? options.modal : {};
|
|
22519
22467
|
const raw = modalConfig.toast ?? ((_a2 = options.ui) == null ? void 0 : _a2.toast);
|
|
22520
|
-
if (!raw)
|
|
22521
|
-
return void 0;
|
|
22468
|
+
if (!raw) return void 0;
|
|
22522
22469
|
const toast = raw === true ? {} : raw;
|
|
22523
22470
|
return {
|
|
22524
22471
|
language: modalUi.language,
|
|
@@ -22536,14 +22483,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22536
22483
|
if (shouldInclude(ids, "xaman") && options.xamanClientId) {
|
|
22537
22484
|
adapters.push(createXamanAdapter({ apiKey: options.xamanClientId, onQr }));
|
|
22538
22485
|
}
|
|
22539
|
-
if (shouldInclude(ids, "gemwallet"))
|
|
22540
|
-
|
|
22541
|
-
if (shouldInclude(ids, "
|
|
22542
|
-
|
|
22543
|
-
if (shouldInclude(ids, "dropfi"))
|
|
22544
|
-
adapters.push(createDropFiAdapter());
|
|
22545
|
-
if (shouldInclude(ids, "xrplsnap"))
|
|
22546
|
-
adapters.push(createXrplSnapAdapter());
|
|
22486
|
+
if (shouldInclude(ids, "gemwallet")) adapters.push(createGemWalletAdapter());
|
|
22487
|
+
if (shouldInclude(ids, "crossmark")) adapters.push(createCrossmarkAdapter());
|
|
22488
|
+
if (shouldInclude(ids, "dropfi")) adapters.push(createDropFiAdapter());
|
|
22489
|
+
if (shouldInclude(ids, "xrplsnap")) adapters.push(createXrplSnapAdapter());
|
|
22547
22490
|
if (options.walletConnectProjectId && shouldIncludeWalletConnect(ids)) {
|
|
22548
22491
|
const walletConnectUiMode = getWalletConnectUiMode(options);
|
|
22549
22492
|
const appMetadata = resolveAppMetadata(options);
|
|
@@ -22558,13 +22501,12 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22558
22501
|
modalMode: walletConnectUiMode === "default" ? "always" : void 0
|
|
22559
22502
|
}));
|
|
22560
22503
|
}
|
|
22504
|
+
if (shouldInclude(ids, "ledger")) adapters.push(createLedgerAdapter());
|
|
22561
22505
|
return adapters;
|
|
22562
22506
|
}
|
|
22563
22507
|
function resolveStorage(storage) {
|
|
22564
|
-
if (storage === "localStorage")
|
|
22565
|
-
|
|
22566
|
-
if (storage === "memory")
|
|
22567
|
-
return void 0;
|
|
22508
|
+
if (storage === "localStorage") return createBrowserWalletStorage();
|
|
22509
|
+
if (storage === "memory") return void 0;
|
|
22568
22510
|
return storage;
|
|
22569
22511
|
}
|
|
22570
22512
|
function resolveModalOptions(options) {
|
|
@@ -22594,13 +22536,17 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22594
22536
|
}
|
|
22595
22537
|
function resolveButtonOptions(options) {
|
|
22596
22538
|
var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j;
|
|
22597
|
-
if (!options.connectButton)
|
|
22598
|
-
return void 0;
|
|
22539
|
+
if (!options.connectButton) return void 0;
|
|
22599
22540
|
const raw = isConnectButtonTarget(options.connectButton) ? { target: options.connectButton } : options.connectButton;
|
|
22600
22541
|
const buttonInput = raw;
|
|
22601
|
-
if (!buttonInput.target)
|
|
22602
|
-
|
|
22603
|
-
|
|
22542
|
+
if (!buttonInput.target) return void 0;
|
|
22543
|
+
const {
|
|
22544
|
+
accountStatus: _accountStatus,
|
|
22545
|
+
accountPanelMode: _accountPanelMode,
|
|
22546
|
+
showBalance,
|
|
22547
|
+
target,
|
|
22548
|
+
...buttonConfig
|
|
22549
|
+
} = buttonInput;
|
|
22604
22550
|
const identity2 = options.identity ?? {};
|
|
22605
22551
|
const modalConfig = typeof options.modal === "object" ? options.modal : {};
|
|
22606
22552
|
const ui = {
|
|
@@ -22637,8 +22583,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22637
22583
|
}
|
|
22638
22584
|
function resolveResponsiveValue(value) {
|
|
22639
22585
|
var _a2;
|
|
22640
|
-
if (value == null || typeof value !== "object" || !("smallScreen" in value || "largeScreen" in value))
|
|
22641
|
-
return value;
|
|
22586
|
+
if (value == null || typeof value !== "object" || !("smallScreen" in value || "largeScreen" in value)) return value;
|
|
22642
22587
|
const isSmallScreen = typeof window !== "undefined" && ((_a2 = window.matchMedia) == null ? void 0 : _a2.call(window, "(max-width: 640px)").matches);
|
|
22643
22588
|
return isSmallScreen ? value.smallScreen ?? value.largeScreen : value.largeScreen ?? value.smallScreen;
|
|
22644
22589
|
}
|
|
@@ -22647,21 +22592,18 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22647
22592
|
return ((_b = (_a2 = options.ui) == null ? void 0 : _a2.walletConnect) == null ? void 0 : _b.mode) ?? "default";
|
|
22648
22593
|
}
|
|
22649
22594
|
function shouldInclude(ids, id2) {
|
|
22650
|
-
if (!ids)
|
|
22651
|
-
return true;
|
|
22595
|
+
if (!ids) return true;
|
|
22652
22596
|
if (id2 === "xrplsnap") {
|
|
22653
22597
|
return ids.has("xrplsnap") || ids.has("xrpl-snap");
|
|
22654
22598
|
}
|
|
22655
22599
|
return ids.has(id2);
|
|
22656
22600
|
}
|
|
22657
22601
|
function shouldIncludeWalletConnect(ids) {
|
|
22658
|
-
if (!ids)
|
|
22659
|
-
return true;
|
|
22602
|
+
if (!ids) return true;
|
|
22660
22603
|
return ids.has("walletconnect") || ["staticbit", "bitget", "joey", "girin", "bifrost"].some((id2) => ids.has(id2));
|
|
22661
22604
|
}
|
|
22662
22605
|
function resolveWalletConnectWallets(ids) {
|
|
22663
|
-
if (!ids || ids.has("walletconnect"))
|
|
22664
|
-
return "all";
|
|
22606
|
+
if (!ids || ids.has("walletconnect")) return "all";
|
|
22665
22607
|
const walletIds = ["staticbit", "bitget", "joey", "girin", "bifrost"].filter((id2) => ids.has(id2));
|
|
22666
22608
|
return walletIds.length ? walletIds : "all";
|
|
22667
22609
|
}
|
|
@@ -22682,18 +22624,25 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22682
22624
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
22683
22625
|
}
|
|
22684
22626
|
function normalizeIcons(icons) {
|
|
22685
|
-
if (!Array.isArray(icons))
|
|
22686
|
-
return [];
|
|
22627
|
+
if (!Array.isArray(icons)) return [];
|
|
22687
22628
|
return icons.filter((icon) => typeof icon === "string" && icon.trim().length > 0);
|
|
22688
22629
|
}
|
|
22689
22630
|
function withoutKitOnlyOptions(options) {
|
|
22690
|
-
const {
|
|
22631
|
+
const {
|
|
22632
|
+
adapters: _adapters,
|
|
22633
|
+
storage: _storage,
|
|
22634
|
+
walletConnectProjectId: _walletConnectProjectId,
|
|
22635
|
+
walletConnectSignMessageDestination: _walletConnectSignMessageDestination,
|
|
22636
|
+
xamanClientId: _xamanClientId,
|
|
22637
|
+
wallets: _wallets,
|
|
22638
|
+
ui: _ui,
|
|
22639
|
+
...managerConfig
|
|
22640
|
+
} = options;
|
|
22691
22641
|
return managerConfig;
|
|
22692
22642
|
}
|
|
22693
22643
|
const createXrplWalletKit = createWalletClient;
|
|
22694
22644
|
function isConnectButtonTarget(value) {
|
|
22695
|
-
if (typeof value === "string")
|
|
22696
|
-
return true;
|
|
22645
|
+
if (typeof value === "string") return true;
|
|
22697
22646
|
return typeof HTMLElement !== "undefined" && value instanceof HTMLElement;
|
|
22698
22647
|
}
|
|
22699
22648
|
var npm = {};
|
|
@@ -77938,6 +77887,7 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
77938
77887
|
exports.JOEY_ICON = JOEY_ICON;
|
|
77939
77888
|
exports.LEDGER_ICON = LEDGER_ICON;
|
|
77940
77889
|
exports.LedgerAdapter = LedgerAdapter;
|
|
77890
|
+
exports.LedgerDeviceState = LedgerDeviceState;
|
|
77941
77891
|
exports.METAMASK_ICON = METAMASK_ICON;
|
|
77942
77892
|
exports.MemoryWalletStorage = MemoryWalletStorage;
|
|
77943
77893
|
exports.NetworkRegistry = NetworkRegistry;
|
|
@@ -77956,12 +77906,14 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
77956
77906
|
exports.WalletEventEmitter = WalletEventEmitter;
|
|
77957
77907
|
exports.WalletInline = WalletInline;
|
|
77958
77908
|
exports.WalletKitError = WalletKitError;
|
|
77909
|
+
exports.WalletKitErrorCode = WalletKitErrorCode;
|
|
77959
77910
|
exports.WalletManager = WalletManager;
|
|
77960
77911
|
exports.WalletModal = WalletModal;
|
|
77961
77912
|
exports.WalletToast = WalletToast;
|
|
77962
77913
|
exports.WalletTransactionStore = WalletTransactionStore;
|
|
77963
77914
|
exports.XAMAN_ICON = XAMAN_ICON;
|
|
77964
77915
|
exports.XRPLSNAP_ICON = XRPLSNAP_ICON;
|
|
77916
|
+
exports.XRPLWalletConnectMethod = XRPLWalletConnectMethod;
|
|
77965
77917
|
exports.XRPL_DEVNET = XRPL_DEVNET;
|
|
77966
77918
|
exports.XRPL_MAINNET = XRPL_MAINNET;
|
|
77967
77919
|
exports.XRPL_TESTNET = XRPL_TESTNET;
|
|
@@ -78002,6 +77954,7 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
78002
77954
|
exports.crispTheme = crispTheme;
|
|
78003
77955
|
exports.darkTheme = darkTheme;
|
|
78004
77956
|
exports.defaultFontFamily = defaultFontFamily;
|
|
77957
|
+
exports.enUSMessages = enUSMessages;
|
|
78005
77958
|
exports.getErrorMessage = getErrorMessage;
|
|
78006
77959
|
exports.getExplorerAccountUrl = getExplorerAccountUrl;
|
|
78007
77960
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
@@ -78028,6 +77981,7 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
78028
77981
|
exports.softTheme = softTheme;
|
|
78029
77982
|
exports.utf8ToHex = utf8ToHex;
|
|
78030
77983
|
exports.validateWalletAdapter = validateWalletAdapter;
|
|
77984
|
+
exports.viVNMessages = viVNMessages;
|
|
78031
77985
|
exports.walletConnectDeeplinks = walletConnectDeeplinks;
|
|
78032
77986
|
exports.walletUiThemes = walletUiThemes;
|
|
78033
77987
|
exports.xrplTheme = xrplTheme;
|