@xrpl-wallet-kit/browser 0.1.11 → 0.1.13
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 +1143 -1007
- package/dist/xrpl-wallet-kit.iife.min.js +49 -49
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @xrpl-wallet-kit/browser v0.1.
|
|
1
|
+
/*! @xrpl-wallet-kit/browser v0.1.13 | 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,28 +1848,102 @@ 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["NETWORK_NOT_SUPPORTED"] = "NETWORK_NOT_SUPPORTED";
|
|
1864
|
+
WalletKitErrorCode2["NOT_CONNECTED"] = "NOT_CONNECTED";
|
|
1865
|
+
WalletKitErrorCode2["ALREADY_CONNECTED"] = "ALREADY_CONNECTED";
|
|
1866
|
+
WalletKitErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
1867
|
+
return WalletKitErrorCode2;
|
|
1868
|
+
})(WalletKitErrorCode || {});
|
|
1869
|
+
var WalletKitErrorCategory = /* @__PURE__ */ ((WalletKitErrorCategory2) => {
|
|
1870
|
+
WalletKitErrorCategory2["WALLET_UNAVAILABLE"] = "WALLET_UNAVAILABLE";
|
|
1871
|
+
WalletKitErrorCategory2["USER_ACTION"] = "USER_ACTION";
|
|
1872
|
+
WalletKitErrorCategory2["NETWORK"] = "NETWORK";
|
|
1873
|
+
WalletKitErrorCategory2["INVALID_INPUT"] = "INVALID_INPUT";
|
|
1874
|
+
WalletKitErrorCategory2["TIMEOUT"] = "TIMEOUT";
|
|
1875
|
+
WalletKitErrorCategory2["INTERNAL"] = "INTERNAL";
|
|
1876
|
+
return WalletKitErrorCategory2;
|
|
1877
|
+
})(WalletKitErrorCategory || {});
|
|
1878
|
+
const WALLET_KIT_ERROR_CATEGORY_BY_CODE = {
|
|
1879
|
+
[
|
|
1880
|
+
"WALLET_NOT_FOUND"
|
|
1881
|
+
/* WALLET_NOT_FOUND */
|
|
1882
|
+
]: "WALLET_UNAVAILABLE",
|
|
1883
|
+
[
|
|
1884
|
+
"WALLET_NOT_INSTALLED"
|
|
1885
|
+
/* WALLET_NOT_INSTALLED */
|
|
1886
|
+
]: "WALLET_UNAVAILABLE",
|
|
1887
|
+
[
|
|
1888
|
+
"WALLET_NOT_AVAILABLE"
|
|
1889
|
+
/* WALLET_NOT_AVAILABLE */
|
|
1890
|
+
]: "WALLET_UNAVAILABLE",
|
|
1891
|
+
[
|
|
1892
|
+
"CONNECTION_FAILED"
|
|
1893
|
+
/* CONNECTION_FAILED */
|
|
1894
|
+
]: "INTERNAL",
|
|
1895
|
+
[
|
|
1896
|
+
"CONNECTION_REJECTED"
|
|
1897
|
+
/* CONNECTION_REJECTED */
|
|
1898
|
+
]: "USER_ACTION",
|
|
1899
|
+
[
|
|
1900
|
+
"SIGN_FAILED"
|
|
1901
|
+
/* SIGN_FAILED */
|
|
1902
|
+
]: "INTERNAL",
|
|
1903
|
+
[
|
|
1904
|
+
"SIGN_REJECTED"
|
|
1905
|
+
/* SIGN_REJECTED */
|
|
1906
|
+
]: "USER_ACTION",
|
|
1907
|
+
[
|
|
1908
|
+
"REQUEST_TIMEOUT"
|
|
1909
|
+
/* REQUEST_TIMEOUT */
|
|
1910
|
+
]: "TIMEOUT",
|
|
1911
|
+
[
|
|
1912
|
+
"UNSUPPORTED_METHOD"
|
|
1913
|
+
/* UNSUPPORTED_METHOD */
|
|
1914
|
+
]: "INVALID_INPUT",
|
|
1915
|
+
[
|
|
1916
|
+
"INVALID_ADAPTER"
|
|
1917
|
+
/* INVALID_ADAPTER */
|
|
1918
|
+
]: "INVALID_INPUT",
|
|
1919
|
+
[
|
|
1920
|
+
"NETWORK_MISMATCH"
|
|
1921
|
+
/* NETWORK_MISMATCH */
|
|
1922
|
+
]: "NETWORK",
|
|
1923
|
+
[
|
|
1924
|
+
"NETWORK_NOT_SUPPORTED"
|
|
1925
|
+
/* NETWORK_NOT_SUPPORTED */
|
|
1926
|
+
]: "NETWORK",
|
|
1927
|
+
[
|
|
1928
|
+
"NOT_CONNECTED"
|
|
1929
|
+
/* NOT_CONNECTED */
|
|
1930
|
+
]: "USER_ACTION",
|
|
1931
|
+
[
|
|
1932
|
+
"ALREADY_CONNECTED"
|
|
1933
|
+
/* ALREADY_CONNECTED */
|
|
1934
|
+
]: "USER_ACTION",
|
|
1935
|
+
[
|
|
1936
|
+
"UNKNOWN_ERROR"
|
|
1937
|
+
/* UNKNOWN_ERROR */
|
|
1938
|
+
]: "INTERNAL"
|
|
1939
|
+
/* INTERNAL */
|
|
1940
|
+
};
|
|
1868
1941
|
class WalletKitError extends Error {
|
|
1869
1942
|
constructor(code, message, options = {}) {
|
|
1870
1943
|
super(message);
|
|
1871
1944
|
this.name = "WalletKitError";
|
|
1872
1945
|
this.code = code;
|
|
1946
|
+
this.category = options.category ?? WALLET_KIT_ERROR_CATEGORY_BY_CODE[code] ?? "INTERNAL";
|
|
1873
1947
|
this.cause = options.cause;
|
|
1874
1948
|
this.details = options.details;
|
|
1875
1949
|
}
|
|
@@ -1878,10 +1952,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
1878
1952
|
return error instanceof WalletKitError;
|
|
1879
1953
|
}
|
|
1880
1954
|
function getErrorMessage(error) {
|
|
1881
|
-
if (error instanceof Error)
|
|
1882
|
-
|
|
1883
|
-
if (typeof error === "string")
|
|
1884
|
-
return error;
|
|
1955
|
+
if (error instanceof Error) return error.message;
|
|
1956
|
+
if (typeof error === "string") return error;
|
|
1885
1957
|
try {
|
|
1886
1958
|
return JSON.stringify(error);
|
|
1887
1959
|
} catch {
|
|
@@ -1889,23 +1961,83 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
1889
1961
|
}
|
|
1890
1962
|
}
|
|
1891
1963
|
const createWalletError = {
|
|
1892
|
-
walletNotFound: (adapterId) => new WalletKitError(
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1964
|
+
walletNotFound: (adapterId) => new WalletKitError(
|
|
1965
|
+
"WALLET_NOT_FOUND",
|
|
1966
|
+
`Wallet adapter is not registered: ${adapterId}`,
|
|
1967
|
+
{ details: { adapterId } }
|
|
1968
|
+
),
|
|
1969
|
+
walletNotInstalled: (walletName, cause) => new WalletKitError(
|
|
1970
|
+
"WALLET_NOT_INSTALLED",
|
|
1971
|
+
`${walletName} is not installed`,
|
|
1972
|
+
{ cause, details: { walletName } }
|
|
1973
|
+
),
|
|
1974
|
+
walletNotAvailable: (walletName, cause) => new WalletKitError(
|
|
1975
|
+
"WALLET_NOT_AVAILABLE",
|
|
1976
|
+
`${walletName} provider is not available`,
|
|
1977
|
+
{ cause, details: { walletName } }
|
|
1978
|
+
),
|
|
1979
|
+
connectionFailed: (walletName, cause) => new WalletKitError(
|
|
1980
|
+
"CONNECTION_FAILED",
|
|
1981
|
+
`Failed to connect ${walletName}: ${getErrorMessage(cause)}`,
|
|
1982
|
+
{ cause, details: { walletName } }
|
|
1983
|
+
),
|
|
1984
|
+
connectionRejected: (walletName, cause) => new WalletKitError(
|
|
1985
|
+
"CONNECTION_REJECTED",
|
|
1986
|
+
`${walletName} connection was rejected`,
|
|
1987
|
+
{ cause, details: { walletName } }
|
|
1988
|
+
),
|
|
1989
|
+
signFailed: (cause) => new WalletKitError(
|
|
1990
|
+
"SIGN_FAILED",
|
|
1991
|
+
`Failed to sign request: ${getErrorMessage(cause)}`,
|
|
1992
|
+
{ cause }
|
|
1993
|
+
),
|
|
1994
|
+
signRejected: (cause) => new WalletKitError(
|
|
1995
|
+
"SIGN_REJECTED",
|
|
1996
|
+
"Signing request was rejected",
|
|
1997
|
+
{ cause }
|
|
1998
|
+
),
|
|
1999
|
+
requestTimeout: (message, cause) => new WalletKitError(
|
|
2000
|
+
"REQUEST_TIMEOUT",
|
|
2001
|
+
message,
|
|
2002
|
+
{ cause }
|
|
2003
|
+
),
|
|
2004
|
+
unsupportedMethod: (method, walletName) => new WalletKitError(
|
|
2005
|
+
"UNSUPPORTED_METHOD",
|
|
2006
|
+
walletName ? `${method} is not supported by ${walletName}` : `${method} is not supported`,
|
|
2007
|
+
{ details: { method, walletName } }
|
|
2008
|
+
),
|
|
2009
|
+
invalidAdapter: (adapterId, issues) => new WalletKitError(
|
|
2010
|
+
"INVALID_ADAPTER",
|
|
2011
|
+
`Wallet adapter is invalid: ${adapterId}`,
|
|
2012
|
+
{ details: { adapterId, issues } }
|
|
2013
|
+
),
|
|
2014
|
+
networkMismatch: (walletName, expected, actual, cause) => new WalletKitError(
|
|
2015
|
+
"NETWORK_MISMATCH",
|
|
2016
|
+
`${walletName} is connected to ${actual ?? "an unknown network"} but the app requested ${expected ?? "a different network"}`,
|
|
2017
|
+
{ cause, details: { walletName, expected, actual } }
|
|
2018
|
+
),
|
|
2019
|
+
networkNotSupported: (walletName, network, cause) => new WalletKitError(
|
|
2020
|
+
"NETWORK_NOT_SUPPORTED",
|
|
2021
|
+
`${walletName} does not support ${network ?? "the requested network"}`,
|
|
2022
|
+
{ cause, details: { walletName, network } }
|
|
2023
|
+
),
|
|
2024
|
+
notConnected: () => new WalletKitError(
|
|
2025
|
+
"NOT_CONNECTED",
|
|
2026
|
+
"No wallet is connected"
|
|
2027
|
+
),
|
|
2028
|
+
alreadyConnected: (walletName) => new WalletKitError(
|
|
2029
|
+
"ALREADY_CONNECTED",
|
|
2030
|
+
`Already connected to ${walletName}`,
|
|
2031
|
+
{ details: { walletName } }
|
|
2032
|
+
),
|
|
2033
|
+
unknown: (cause) => new WalletKitError(
|
|
2034
|
+
"UNKNOWN_ERROR",
|
|
2035
|
+
getErrorMessage(cause),
|
|
2036
|
+
{ cause }
|
|
2037
|
+
)
|
|
1905
2038
|
};
|
|
1906
2039
|
function normalizeWalletError(error) {
|
|
1907
|
-
if (isWalletKitError(error))
|
|
1908
|
-
return error;
|
|
2040
|
+
if (isWalletKitError(error)) return error;
|
|
1909
2041
|
const message = getErrorMessage(error).toLowerCase();
|
|
1910
2042
|
if (/reject|denied|cancelled|canceled|closed/i.test(message)) {
|
|
1911
2043
|
return createWalletError.signRejected(error);
|
|
@@ -1938,7 +2070,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
1938
2070
|
const walletAdapter = adapter;
|
|
1939
2071
|
const adapterId = ((_a2 = walletAdapter.metadata) == null ? void 0 : _a2.id) || "unknown";
|
|
1940
2072
|
if (walletAdapter.adapterApiVersion && !walletAdapter.adapterApiVersion.startsWith("1.")) {
|
|
1941
|
-
addIssue(
|
|
2073
|
+
addIssue(
|
|
2074
|
+
issues,
|
|
2075
|
+
"warning",
|
|
2076
|
+
"adapterApiVersion",
|
|
2077
|
+
`Adapter ${adapterId} declares API ${walletAdapter.adapterApiVersion}; this core expects ${WALLET_ADAPTER_API_VERSION}.`
|
|
2078
|
+
);
|
|
1942
2079
|
}
|
|
1943
2080
|
if (!walletAdapter.metadata || typeof walletAdapter.metadata !== "object") {
|
|
1944
2081
|
addIssue(issues, "error", "metadata", "metadata is required.");
|
|
@@ -2000,7 +2137,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2000
2137
|
const result = validateWalletAdapter(adapter);
|
|
2001
2138
|
if (!result.valid) {
|
|
2002
2139
|
const walletAdapter = adapter && typeof adapter === "object" ? adapter : void 0;
|
|
2003
|
-
throw createWalletError.invalidAdapter(
|
|
2140
|
+
throw createWalletError.invalidAdapter(
|
|
2141
|
+
((_a2 = walletAdapter == null ? void 0 : walletAdapter.metadata) == null ? void 0 : _a2.id) || "unknown",
|
|
2142
|
+
result.issues.map((issue2) => `${issue2.field}: ${issue2.message}`)
|
|
2143
|
+
);
|
|
2004
2144
|
}
|
|
2005
2145
|
}
|
|
2006
2146
|
class BaseWalletAdapter {
|
|
@@ -2029,17 +2169,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2029
2169
|
}
|
|
2030
2170
|
async waitForAvailability(timeoutMs = 2500, pollMs = 100) {
|
|
2031
2171
|
const isAvailable = this.isAvailable;
|
|
2032
|
-
if (!isAvailable)
|
|
2033
|
-
return true;
|
|
2172
|
+
if (!isAvailable) return true;
|
|
2034
2173
|
const startedAt = Date.now();
|
|
2035
2174
|
do {
|
|
2036
2175
|
try {
|
|
2037
|
-
if (await isAvailable.call(this))
|
|
2038
|
-
return true;
|
|
2176
|
+
if (await isAvailable.call(this)) return true;
|
|
2039
2177
|
} catch {
|
|
2040
2178
|
}
|
|
2041
|
-
if (timeoutMs <= 0)
|
|
2042
|
-
return false;
|
|
2179
|
+
if (timeoutMs <= 0) return false;
|
|
2043
2180
|
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
2044
2181
|
} while (Date.now() - startedAt < timeoutMs);
|
|
2045
2182
|
return false;
|
|
@@ -2102,8 +2239,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2102
2239
|
this.write("error", message, args);
|
|
2103
2240
|
}
|
|
2104
2241
|
write(level, message, args) {
|
|
2105
|
-
if (this.level === "silent" || levels[level] < levels[this.level])
|
|
2106
|
-
return;
|
|
2242
|
+
if (this.level === "silent" || levels[level] < levels[this.level]) return;
|
|
2107
2243
|
const target = console[level];
|
|
2108
2244
|
target(`${this.prefix} ${message}`, ...args);
|
|
2109
2245
|
}
|
|
@@ -2165,8 +2301,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2165
2301
|
}
|
|
2166
2302
|
resolve(id2 = "mainnet") {
|
|
2167
2303
|
const network = this.networks.get(id2);
|
|
2168
|
-
if (!network)
|
|
2169
|
-
throw new Error(`XRPL network is not registered: ${id2}`);
|
|
2304
|
+
if (!network) throw new Error(`XRPL network is not registered: ${id2}`);
|
|
2170
2305
|
return network;
|
|
2171
2306
|
}
|
|
2172
2307
|
list() {
|
|
@@ -2180,39 +2315,29 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2180
2315
|
return registry.register(network);
|
|
2181
2316
|
}
|
|
2182
2317
|
function resolveNetwork(networks, id2 = "mainnet") {
|
|
2183
|
-
if (networks instanceof NetworkRegistry)
|
|
2184
|
-
return networks.resolve(id2);
|
|
2318
|
+
if (networks instanceof NetworkRegistry) return networks.resolve(id2);
|
|
2185
2319
|
return createNetworkRegistry(networks).resolve(id2);
|
|
2186
2320
|
}
|
|
2187
2321
|
function getNativeAsset(network) {
|
|
2188
2322
|
return (network == null ? void 0 : network.nativeAsset) ?? "XRP";
|
|
2189
2323
|
}
|
|
2190
2324
|
function getHttpRpcUrl(networkOrUrl) {
|
|
2191
|
-
if (!networkOrUrl)
|
|
2192
|
-
return void 0;
|
|
2325
|
+
if (!networkOrUrl) return void 0;
|
|
2193
2326
|
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)}`;
|
|
2327
|
+
if (rpcUrl.startsWith("wss://")) return `https://${rpcUrl.slice(6)}`;
|
|
2328
|
+
if (rpcUrl.startsWith("ws://")) return `http://${rpcUrl.slice(5)}`;
|
|
2198
2329
|
return rpcUrl;
|
|
2199
2330
|
}
|
|
2200
2331
|
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)}`;
|
|
2332
|
+
if (!network) return void 0;
|
|
2333
|
+
if (network.explorerAccountUrl) return network.explorerAccountUrl.replace("{address}", encodeURIComponent(address));
|
|
2334
|
+
if (network.networkType === "TESTNET") return `https://testnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2335
|
+
if (network.networkType === "DEVNET") return `https://devnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2336
|
+
if (network.networkType === "MAINNET") return `https://livenet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
2211
2337
|
return void 0;
|
|
2212
2338
|
}
|
|
2213
2339
|
function getExplorerTxUrl(network, hash2) {
|
|
2214
|
-
if (!(network == null ? void 0 : network.explorerTxUrl))
|
|
2215
|
-
return void 0;
|
|
2340
|
+
if (!(network == null ? void 0 : network.explorerTxUrl)) return void 0;
|
|
2216
2341
|
const encodedHash = encodeURIComponent(hash2);
|
|
2217
2342
|
return network.explorerTxUrl.includes("{hash}") ? network.explorerTxUrl.replace("{hash}", encodedHash) : `${network.explorerTxUrl.replace(/\/$/, "")}/${encodedHash}`;
|
|
2218
2343
|
}
|
|
@@ -2220,16 +2345,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2220
2345
|
return (network == null ? void 0 : network.networkType) === "MAINNET" && (network.family ?? "xrpl") === "xrpl" && getNativeAsset(network) === "XRP";
|
|
2221
2346
|
}
|
|
2222
2347
|
function pickPath(source, paths) {
|
|
2223
|
-
if (!source || typeof source !== "object")
|
|
2224
|
-
return void 0;
|
|
2348
|
+
if (!source || typeof source !== "object") return void 0;
|
|
2225
2349
|
for (const path of paths) {
|
|
2226
2350
|
const value = path.split(".").reduce((current, key) => {
|
|
2227
|
-
if (!current || typeof current !== "object")
|
|
2228
|
-
return void 0;
|
|
2351
|
+
if (!current || typeof current !== "object") return void 0;
|
|
2229
2352
|
return current[key];
|
|
2230
2353
|
}, source);
|
|
2231
|
-
if (value !== void 0 && value !== null && value !== "")
|
|
2232
|
-
return value;
|
|
2354
|
+
if (value !== void 0 && value !== null && value !== "") return value;
|
|
2233
2355
|
}
|
|
2234
2356
|
return void 0;
|
|
2235
2357
|
}
|
|
@@ -2328,12 +2450,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2328
2450
|
return {
|
|
2329
2451
|
getItem: (key) => typeof localStorage === "undefined" ? null : localStorage.getItem(prefix + key),
|
|
2330
2452
|
setItem: (key, value) => {
|
|
2331
|
-
if (typeof localStorage !== "undefined")
|
|
2332
|
-
localStorage.setItem(prefix + key, value);
|
|
2453
|
+
if (typeof localStorage !== "undefined") localStorage.setItem(prefix + key, value);
|
|
2333
2454
|
},
|
|
2334
2455
|
removeItem: (key) => {
|
|
2335
|
-
if (typeof localStorage !== "undefined")
|
|
2336
|
-
localStorage.removeItem(prefix + key);
|
|
2456
|
+
if (typeof localStorage !== "undefined") localStorage.removeItem(prefix + key);
|
|
2337
2457
|
}
|
|
2338
2458
|
};
|
|
2339
2459
|
}
|
|
@@ -2357,8 +2477,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2357
2477
|
}
|
|
2358
2478
|
return transaction2;
|
|
2359
2479
|
});
|
|
2360
|
-
if (changed)
|
|
2361
|
-
await this.writeList(this.key(networkId, accountAddress), normalized);
|
|
2480
|
+
if (changed) await this.writeList(this.key(networkId, accountAddress), normalized);
|
|
2362
2481
|
return normalized;
|
|
2363
2482
|
}
|
|
2364
2483
|
async add(accountAddress, networkId, transaction2) {
|
|
@@ -2387,8 +2506,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2387
2506
|
async readList(key) {
|
|
2388
2507
|
try {
|
|
2389
2508
|
const raw = await this.storage.getItem(key);
|
|
2390
|
-
if (!raw)
|
|
2391
|
-
return [];
|
|
2509
|
+
if (!raw) return [];
|
|
2392
2510
|
const parsed = JSON.parse(raw);
|
|
2393
2511
|
return Array.isArray(parsed) ? parsed.filter(this.isStoredTransaction) : [];
|
|
2394
2512
|
} catch {
|
|
@@ -2400,15 +2518,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2400
2518
|
}
|
|
2401
2519
|
async addIndex(accountAddress, networkId) {
|
|
2402
2520
|
const current = await this.readIndex(accountAddress);
|
|
2403
|
-
if (current.includes(networkId))
|
|
2404
|
-
return;
|
|
2521
|
+
if (current.includes(networkId)) return;
|
|
2405
2522
|
await this.storage.setItem(this.indexKey(accountAddress), JSON.stringify([...current, networkId]));
|
|
2406
2523
|
}
|
|
2407
2524
|
async readIndex(accountAddress) {
|
|
2408
2525
|
try {
|
|
2409
2526
|
const raw = await this.storage.getItem(this.indexKey(accountAddress));
|
|
2410
|
-
if (!raw)
|
|
2411
|
-
return [];
|
|
2527
|
+
if (!raw) return [];
|
|
2412
2528
|
const parsed = JSON.parse(raw);
|
|
2413
2529
|
return Array.isArray(parsed) ? parsed.filter((value) => typeof value === "string") : [];
|
|
2414
2530
|
} catch {
|
|
@@ -2416,8 +2532,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2416
2532
|
}
|
|
2417
2533
|
}
|
|
2418
2534
|
isStoredTransaction(value) {
|
|
2419
|
-
if (!value || typeof value !== "object")
|
|
2420
|
-
return false;
|
|
2535
|
+
if (!value || typeof value !== "object") return false;
|
|
2421
2536
|
const transaction2 = value;
|
|
2422
2537
|
return typeof transaction2.hash === "string" && typeof transaction2.status === "string" && typeof transaction2.submittedAt === "number";
|
|
2423
2538
|
}
|
|
@@ -2433,6 +2548,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2433
2548
|
const RECOVER_SESSION_RETRY_DELAYS_MS = [0, 700, 1600, 3e3];
|
|
2434
2549
|
const DEFAULT_AUTO_RECONNECT_RESTORE_TIMEOUT_MS = 3e3;
|
|
2435
2550
|
const DEFAULT_PENDING_RETURN_RECOVERY_TIMEOUT_MS = 1e4;
|
|
2551
|
+
const DEFAULT_AVAILABILITY_CHECK_TIMEOUT_MS = 1e3;
|
|
2436
2552
|
const DEFAULT_ACCOUNT_STATUS_TIMEOUT_MS = 2500;
|
|
2437
2553
|
const DEFAULT_AUTHENTICATE_EXPIRES_IN_SECONDS = 3600;
|
|
2438
2554
|
const DEFAULT_TX_CONFIRMATION_ATTEMPTS = 6;
|
|
@@ -2472,10 +2588,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2472
2588
|
}
|
|
2473
2589
|
async getWalletAvailability() {
|
|
2474
2590
|
const entries = await Promise.all([...this.adapters.values()].map(async (adapter) => {
|
|
2475
|
-
if (!adapter.isAvailable)
|
|
2476
|
-
return [adapter.metadata.id, false];
|
|
2591
|
+
if (!adapter.isAvailable) return [adapter.metadata.id, false];
|
|
2477
2592
|
try {
|
|
2478
|
-
|
|
2593
|
+
const availability = await this.withTimeout(Promise.resolve(adapter.isAvailable()), DEFAULT_AVAILABILITY_CHECK_TIMEOUT_MS);
|
|
2594
|
+
if (availability.timedOut) {
|
|
2595
|
+
this.logger.warn(`Availability check timed out for ${adapter.metadata.id}`);
|
|
2596
|
+
return [adapter.metadata.id, false];
|
|
2597
|
+
}
|
|
2598
|
+
return [adapter.metadata.id, Boolean(availability.value)];
|
|
2479
2599
|
} catch (error) {
|
|
2480
2600
|
this.logger.warn(`Availability check failed for ${adapter.metadata.id}`, error);
|
|
2481
2601
|
return [adapter.metadata.id, false];
|
|
@@ -2485,10 +2605,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2485
2605
|
}
|
|
2486
2606
|
async getAvailableWallets() {
|
|
2487
2607
|
const results2 = await Promise.all([...this.adapters.values()].map(async (adapter) => {
|
|
2488
|
-
if (!adapter.isAvailable)
|
|
2489
|
-
return null;
|
|
2608
|
+
if (!adapter.isAvailable) return null;
|
|
2490
2609
|
try {
|
|
2491
|
-
|
|
2610
|
+
const availability = await this.withTimeout(Promise.resolve(adapter.isAvailable()), DEFAULT_AVAILABILITY_CHECK_TIMEOUT_MS);
|
|
2611
|
+
if (availability.timedOut) {
|
|
2612
|
+
this.logger.warn(`Availability check timed out for ${adapter.metadata.id}`);
|
|
2613
|
+
return null;
|
|
2614
|
+
}
|
|
2615
|
+
return availability.value ? adapter : null;
|
|
2492
2616
|
} catch (error) {
|
|
2493
2617
|
this.logger.warn(`Availability check failed for ${adapter.metadata.id}`, error);
|
|
2494
2618
|
return null;
|
|
@@ -2518,10 +2642,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2518
2642
|
return this.networkRegistry.resolve(id2);
|
|
2519
2643
|
}
|
|
2520
2644
|
async autoReconnect() {
|
|
2521
|
-
if (!this.config.autoReconnect)
|
|
2522
|
-
|
|
2523
|
-
if (this.autoReconnectPromise)
|
|
2524
|
-
return this.autoReconnectPromise;
|
|
2645
|
+
if (!this.config.autoReconnect) return null;
|
|
2646
|
+
if (this.autoReconnectPromise) return this.autoReconnectPromise;
|
|
2525
2647
|
this.autoReconnectPromise = this.runAutoReconnect().finally(() => {
|
|
2526
2648
|
this.autoReconnectPromise = void 0;
|
|
2527
2649
|
});
|
|
@@ -2529,8 +2651,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2529
2651
|
}
|
|
2530
2652
|
async runAutoReconnect() {
|
|
2531
2653
|
const serialized = await this.storage.getItem(SESSION_KEY);
|
|
2532
|
-
if (!serialized)
|
|
2533
|
-
return this.recoverPendingReturnSession();
|
|
2654
|
+
if (!serialized) return this.recoverPendingReturnSession();
|
|
2534
2655
|
const session = this.parseStoredSession(serialized);
|
|
2535
2656
|
if (!session) {
|
|
2536
2657
|
await this.storage.removeItem(SESSION_KEY);
|
|
@@ -2555,6 +2676,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2555
2676
|
await this.clearStoredSessionAsStale(session, "restore_unavailable");
|
|
2556
2677
|
return null;
|
|
2557
2678
|
}
|
|
2679
|
+
this.assertSessionNetwork(adapter, restored.session, this.getNetwork(), "restoreSession");
|
|
2558
2680
|
const enrichedSession2 = await this.enrichSession(this.withWalletMetadata(restored.session, adapter));
|
|
2559
2681
|
this.setSession(enrichedSession2);
|
|
2560
2682
|
await this.loadPersistedTransactions(enrichedSession2);
|
|
@@ -2578,6 +2700,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2578
2700
|
return null;
|
|
2579
2701
|
}
|
|
2580
2702
|
const enrichedSession = await this.enrichSession(this.withWalletMetadata(session, adapter));
|
|
2703
|
+
this.assertSessionNetwork(adapter, enrichedSession, this.getNetwork(), "autoReconnect");
|
|
2581
2704
|
this.setSession(enrichedSession);
|
|
2582
2705
|
await this.loadPersistedTransactions(enrichedSession);
|
|
2583
2706
|
this.emit("session_restored", { adapterId: enrichedSession.adapterId, account: enrichedSession.account, session: enrichedSession, stale: true });
|
|
@@ -2597,15 +2720,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2597
2720
|
const recoverableAdapters = [];
|
|
2598
2721
|
for (const adapter of adaptersWithRecovery) {
|
|
2599
2722
|
try {
|
|
2600
|
-
if (adapter.canRecoverSession && !await adapter.canRecoverSession({ network, walletId: adapter.metadata.id }))
|
|
2601
|
-
continue;
|
|
2723
|
+
if (adapter.canRecoverSession && !await adapter.canRecoverSession({ network, walletId: adapter.metadata.id })) continue;
|
|
2602
2724
|
recoverableAdapters.push(adapter);
|
|
2603
2725
|
} catch (error) {
|
|
2604
2726
|
this.logger.warn(`Session recovery availability check failed for ${adapter.metadata.id}`, error);
|
|
2605
2727
|
}
|
|
2606
2728
|
}
|
|
2607
|
-
if (!recoverableAdapters.length)
|
|
2608
|
-
return null;
|
|
2729
|
+
if (!recoverableAdapters.length) return null;
|
|
2609
2730
|
const announcedAdapters = /* @__PURE__ */ new Set();
|
|
2610
2731
|
const recoveryRetryDelaysMs = this.config.recoveryRetryDelaysMs ?? RECOVER_SESSION_RETRY_DELAYS_MS;
|
|
2611
2732
|
const recoveryDeadline = Date.now() + DEFAULT_PENDING_RETURN_RECOVERY_TIMEOUT_MS;
|
|
@@ -2616,8 +2737,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2616
2737
|
timedOut = true;
|
|
2617
2738
|
break;
|
|
2618
2739
|
}
|
|
2619
|
-
if (delayMs > 0)
|
|
2620
|
-
await this.delay(Math.min(delayMs, remainingBeforeDelay));
|
|
2740
|
+
if (delayMs > 0) await this.delay(Math.min(delayMs, remainingBeforeDelay));
|
|
2621
2741
|
for (const adapter of recoverableAdapters) {
|
|
2622
2742
|
const remaining = recoveryDeadline - Date.now();
|
|
2623
2743
|
if (remaining <= 0) {
|
|
@@ -2636,8 +2756,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2636
2756
|
break;
|
|
2637
2757
|
}
|
|
2638
2758
|
const recovered = recovery.value;
|
|
2639
|
-
if (!(recovered == null ? void 0 : recovered.session))
|
|
2640
|
-
|
|
2759
|
+
if (!(recovered == null ? void 0 : recovered.session)) continue;
|
|
2760
|
+
this.assertSessionNetwork(adapter, recovered.session, network, "recoverSession");
|
|
2641
2761
|
const enrichedSession = await this.enrichSession(this.withWalletMetadata(recovered.session, adapter));
|
|
2642
2762
|
this.setSession(enrichedSession);
|
|
2643
2763
|
await this.saveSession(enrichedSession);
|
|
@@ -2649,8 +2769,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2649
2769
|
this.logger.warn(`Session recovery failed for ${adapter.metadata.id}`, error);
|
|
2650
2770
|
}
|
|
2651
2771
|
}
|
|
2652
|
-
if (timedOut)
|
|
2653
|
-
break;
|
|
2772
|
+
if (timedOut) break;
|
|
2654
2773
|
}
|
|
2655
2774
|
recoverableAdapters.forEach((adapter) => {
|
|
2656
2775
|
var _a3;
|
|
@@ -2677,7 +2796,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2677
2796
|
this.pendingAdapterId = adapterId;
|
|
2678
2797
|
this.pendingAbortController = new AbortController();
|
|
2679
2798
|
this.emit("connecting", { adapterId });
|
|
2680
|
-
if (adapter.isAvailable && !await
|
|
2799
|
+
if (adapter.isAvailable && !await this.isAdapterAvailable(adapter)) {
|
|
2681
2800
|
throw createWalletError.walletNotAvailable(adapter.metadata.name);
|
|
2682
2801
|
}
|
|
2683
2802
|
const signal = options.signal ?? this.pendingAbortController.signal;
|
|
@@ -2685,6 +2804,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2685
2804
|
if (signal.aborted || this.pendingAdapterId !== adapterId) {
|
|
2686
2805
|
throw new Error("Wallet connection was cancelled");
|
|
2687
2806
|
}
|
|
2807
|
+
this.assertAccountNetwork(adapter, result.account, network, "connect");
|
|
2688
2808
|
const session = await this.enrichSession(this.withWalletMetadata(result.session ?? { adapterId, account: { ...result.account, network }, connectedAt: Date.now() }, adapter));
|
|
2689
2809
|
this.setSession(session);
|
|
2690
2810
|
await this.saveSession(session);
|
|
@@ -2709,8 +2829,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2709
2829
|
async cancelPendingConnection(exceptAdapterId) {
|
|
2710
2830
|
var _a2, _b, _c;
|
|
2711
2831
|
const pendingAdapterId = this.pendingAdapterId;
|
|
2712
|
-
if (!pendingAdapterId || pendingAdapterId === exceptAdapterId)
|
|
2713
|
-
return;
|
|
2832
|
+
if (!pendingAdapterId || pendingAdapterId === exceptAdapterId) return;
|
|
2714
2833
|
(_a2 = this.pendingAbortController) == null ? void 0 : _a2.abort();
|
|
2715
2834
|
this.pendingAbortController = void 0;
|
|
2716
2835
|
this.pendingAdapterId = null;
|
|
@@ -2755,7 +2874,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2755
2874
|
const adapter = this.requireActiveAdapter("signMessage");
|
|
2756
2875
|
try {
|
|
2757
2876
|
this.emit("signing", { adapterId: adapter.metadata.id, kind: "message" });
|
|
2758
|
-
const result = this.normalizeSignMessageResult(
|
|
2877
|
+
const result = this.normalizeSignMessageResult(
|
|
2878
|
+
adapter.metadata.id,
|
|
2879
|
+
await adapter.signMessage({ ...request, account: request.account ?? this.getAccount() ?? void 0 })
|
|
2880
|
+
);
|
|
2759
2881
|
this.emit("signed", { adapterId: adapter.metadata.id, kind: "message", result });
|
|
2760
2882
|
return result;
|
|
2761
2883
|
} catch (error) {
|
|
@@ -2766,8 +2888,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2766
2888
|
}
|
|
2767
2889
|
async authenticate(request) {
|
|
2768
2890
|
const account = request.account ?? this.getAccount();
|
|
2769
|
-
if (!account)
|
|
2770
|
-
throw createWalletError.notConnected();
|
|
2891
|
+
if (!account) throw createWalletError.notConnected();
|
|
2771
2892
|
const issuedAt = /* @__PURE__ */ new Date();
|
|
2772
2893
|
const expiresAt = new Date(issuedAt.getTime() + (request.expiresIn ?? DEFAULT_AUTHENTICATE_EXPIRES_IN_SECONDS) * 1e3);
|
|
2773
2894
|
const message = [
|
|
@@ -2794,11 +2915,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2794
2915
|
}
|
|
2795
2916
|
normalizeSignMessageResult(adapterId, result) {
|
|
2796
2917
|
const normalized = (() => {
|
|
2797
|
-
if (result.signatureKind === "signature" || result.signatureKind === "signedTx")
|
|
2798
|
-
return result;
|
|
2918
|
+
if (result.signatureKind === "signature" || result.signatureKind === "signedTx") return result;
|
|
2799
2919
|
const legacy2 = result;
|
|
2800
2920
|
const inferredKind = legacy2.txBlob ? "signedTx" : "signature";
|
|
2801
|
-
this.logger.warn(
|
|
2921
|
+
this.logger.warn(
|
|
2922
|
+
`Adapter "${adapterId}" returned SignMessageResult without signatureKind. Inferred "${inferredKind}" for backward compatibility; update the adapter before using auth verification.`
|
|
2923
|
+
);
|
|
2802
2924
|
return { ...legacy2, signatureKind: inferredKind };
|
|
2803
2925
|
})();
|
|
2804
2926
|
if (normalized.signatureKind === "signature" && !this.hasProofValue(normalized.signature)) {
|
|
@@ -2871,8 +2993,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2871
2993
|
}
|
|
2872
2994
|
async signTransaction(request) {
|
|
2873
2995
|
const adapter = this.getAdapter();
|
|
2874
|
-
if (!adapter)
|
|
2875
|
-
throw createWalletError.notConnected();
|
|
2996
|
+
if (!adapter) throw createWalletError.notConnected();
|
|
2876
2997
|
if (typeof adapter.signTransaction !== "function" && typeof adapter.signAndSubmit !== "function") {
|
|
2877
2998
|
throw createWalletError.unsupportedMethod("signTransaction", adapter.metadata.name);
|
|
2878
2999
|
}
|
|
@@ -2951,11 +3072,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2951
3072
|
}
|
|
2952
3073
|
async resolveActivationStatus(account) {
|
|
2953
3074
|
var _a2, _b, _c, _d, _e2;
|
|
2954
|
-
if (((_a2 = this.config.accountStatus) == null ? void 0 : _a2.enabled) === false || account.activationStatus)
|
|
2955
|
-
return account;
|
|
3075
|
+
if (((_a2 = this.config.accountStatus) == null ? void 0 : _a2.enabled) === false || account.activationStatus) return account;
|
|
2956
3076
|
const rpcUrl = ((_b = account.network) == null ? void 0 : _b.httpRpcUrl) ? getHttpRpcUrl(account.network) : void 0;
|
|
2957
|
-
if (!rpcUrl || typeof fetch !== "function")
|
|
2958
|
-
return account;
|
|
3077
|
+
if (!rpcUrl || typeof fetch !== "function") return account;
|
|
2959
3078
|
let timer;
|
|
2960
3079
|
try {
|
|
2961
3080
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
@@ -2971,34 +3090,26 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
2971
3090
|
}),
|
|
2972
3091
|
signal: controller == null ? void 0 : controller.signal
|
|
2973
3092
|
});
|
|
2974
|
-
if (timer)
|
|
2975
|
-
clearTimeout(timer);
|
|
3093
|
+
if (timer) clearTimeout(timer);
|
|
2976
3094
|
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" };
|
|
3095
|
+
if ((_d = body.result) == null ? void 0 : _d.account_data) return { ...account, activationStatus: "active" };
|
|
3096
|
+
if (((_e2 = body.result) == null ? void 0 : _e2.error) === "actNotFound") return { ...account, activationStatus: "unfunded" };
|
|
2981
3097
|
return { ...account, activationStatus: "unknown" };
|
|
2982
3098
|
} catch (error) {
|
|
2983
3099
|
this.logger.debug("Account activation status lookup failed", error);
|
|
2984
3100
|
return { ...account, activationStatus: "unknown" };
|
|
2985
3101
|
} finally {
|
|
2986
|
-
if (timer)
|
|
2987
|
-
clearTimeout(timer);
|
|
3102
|
+
if (timer) clearTimeout(timer);
|
|
2988
3103
|
}
|
|
2989
3104
|
}
|
|
2990
3105
|
confirmTransaction(transaction2) {
|
|
2991
3106
|
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;
|
|
3107
|
+
if (((_a2 = this.config.transactionConfirmation) == null ? void 0 : _a2.enabled) === false) return;
|
|
3108
|
+
if (this.pendingConfirmations.has(transaction2.hash)) return;
|
|
2996
3109
|
const rpcUrl = ((_b = transaction2.account) == null ? void 0 : _b.network) ? getHttpRpcUrl(transaction2.account.network) : void 0;
|
|
2997
|
-
if (!rpcUrl || typeof fetch !== "function")
|
|
2998
|
-
return;
|
|
3110
|
+
if (!rpcUrl || typeof fetch !== "function") return;
|
|
2999
3111
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
3000
|
-
if (controller)
|
|
3001
|
-
this.pendingConfirmations.set(transaction2.hash, controller);
|
|
3112
|
+
if (controller) this.pendingConfirmations.set(transaction2.hash, controller);
|
|
3002
3113
|
void this.runTransactionConfirmation(transaction2, rpcUrl, controller).finally(() => {
|
|
3003
3114
|
this.pendingConfirmations.delete(transaction2.hash);
|
|
3004
3115
|
});
|
|
@@ -3008,16 +3119,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3008
3119
|
const attempts = Math.max(1, ((_a2 = this.config.transactionConfirmation) == null ? void 0 : _a2.attempts) ?? DEFAULT_TX_CONFIRMATION_ATTEMPTS);
|
|
3009
3120
|
const intervalMs = Math.max(0, ((_b = this.config.transactionConfirmation) == null ? void 0 : _b.intervalMs) ?? DEFAULT_TX_CONFIRMATION_INTERVAL_MS);
|
|
3010
3121
|
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;
|
|
3122
|
+
if (controller == null ? void 0 : controller.signal.aborted) return;
|
|
3123
|
+
if (attempt > 0 && intervalMs > 0) await this.delay(intervalMs);
|
|
3124
|
+
if (controller == null ? void 0 : controller.signal.aborted) return;
|
|
3017
3125
|
try {
|
|
3018
3126
|
const result = await this.lookupTransaction(transaction2.hash, rpcUrl, controller == null ? void 0 : controller.signal);
|
|
3019
|
-
if (!result || !result.validated)
|
|
3020
|
-
continue;
|
|
3127
|
+
if (!result || !result.validated) continue;
|
|
3021
3128
|
if (result.transactionResult === "tesSUCCESS") {
|
|
3022
3129
|
this.addTransaction({
|
|
3023
3130
|
...transaction2,
|
|
@@ -3027,8 +3134,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3027
3134
|
});
|
|
3028
3135
|
return;
|
|
3029
3136
|
}
|
|
3030
|
-
if (!result.transactionResult)
|
|
3031
|
-
continue;
|
|
3137
|
+
if (!result.transactionResult) continue;
|
|
3032
3138
|
this.addTransaction({
|
|
3033
3139
|
...transaction2,
|
|
3034
3140
|
status: "failed",
|
|
@@ -3038,8 +3144,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3038
3144
|
});
|
|
3039
3145
|
return;
|
|
3040
3146
|
} catch (error) {
|
|
3041
|
-
if (controller == null ? void 0 : controller.signal.aborted)
|
|
3042
|
-
return;
|
|
3147
|
+
if (controller == null ? void 0 : controller.signal.aborted) return;
|
|
3043
3148
|
this.logger.debug(`Transaction confirmation lookup failed for ${transaction2.hash}`, error);
|
|
3044
3149
|
}
|
|
3045
3150
|
}
|
|
@@ -3051,8 +3156,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3051
3156
|
params: [{ transaction: hash2, binary: false }]
|
|
3052
3157
|
}, signal, ((_a2 = this.config.transactionConfirmation) == null ? void 0 : _a2.timeoutMs) ?? DEFAULT_TX_CONFIRMATION_TIMEOUT_MS);
|
|
3053
3158
|
const result = response.result;
|
|
3054
|
-
if (!result || result.error === "txnNotFound")
|
|
3055
|
-
return null;
|
|
3159
|
+
if (!result || result.error === "txnNotFound") return null;
|
|
3056
3160
|
const validated = result.validated === true;
|
|
3057
3161
|
const meta = result.meta ?? result.metaData ?? result.metadata;
|
|
3058
3162
|
const transactionResult = pickPath({ meta, result }, [
|
|
@@ -3070,25 +3174,20 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3070
3174
|
};
|
|
3071
3175
|
}
|
|
3072
3176
|
async loadPersistedTransactions(session) {
|
|
3073
|
-
if (!this.transactionStore)
|
|
3074
|
-
return;
|
|
3177
|
+
if (!this.transactionStore) return;
|
|
3075
3178
|
const address = session.account.address;
|
|
3076
|
-
if (!address)
|
|
3077
|
-
return;
|
|
3179
|
+
if (!address) return;
|
|
3078
3180
|
const transactions2 = await this.transactionStore.get(address, this.transactionNetworkId(session.account));
|
|
3079
3181
|
this.transactions.clear();
|
|
3080
3182
|
transactions2.forEach((transaction2) => this.transactions.set(transaction2.hash, transaction2));
|
|
3081
3183
|
transactions2.forEach((transaction2) => {
|
|
3082
|
-
if (transaction2.status === "submitted")
|
|
3083
|
-
this.confirmTransaction(transaction2);
|
|
3184
|
+
if (transaction2.status === "submitted") this.confirmTransaction(transaction2);
|
|
3084
3185
|
});
|
|
3085
3186
|
}
|
|
3086
3187
|
async persistTransaction(transaction2) {
|
|
3087
|
-
if (!this.transactionStore)
|
|
3088
|
-
return;
|
|
3188
|
+
if (!this.transactionStore) return;
|
|
3089
3189
|
const account = transaction2.account ?? this.getAccount() ?? void 0;
|
|
3090
|
-
if (!(account == null ? void 0 : account.address))
|
|
3091
|
-
return;
|
|
3190
|
+
if (!(account == null ? void 0 : account.address)) return;
|
|
3092
3191
|
await this.transactionStore.add(account.address, this.transactionNetworkId(account), {
|
|
3093
3192
|
...transaction2,
|
|
3094
3193
|
account
|
|
@@ -3119,8 +3218,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3119
3218
|
});
|
|
3120
3219
|
return await response.json();
|
|
3121
3220
|
} finally {
|
|
3122
|
-
if (timer)
|
|
3123
|
-
clearTimeout(timer);
|
|
3221
|
+
if (timer) clearTimeout(timer);
|
|
3124
3222
|
}
|
|
3125
3223
|
}
|
|
3126
3224
|
cancelTransactionConfirmations() {
|
|
@@ -3129,16 +3227,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3129
3227
|
}
|
|
3130
3228
|
requireAdapter(adapterId) {
|
|
3131
3229
|
const adapter = this.adapters.get(adapterId);
|
|
3132
|
-
if (!adapter)
|
|
3133
|
-
throw createWalletError.walletNotFound(adapterId);
|
|
3230
|
+
if (!adapter) throw createWalletError.walletNotFound(adapterId);
|
|
3134
3231
|
return adapter;
|
|
3135
3232
|
}
|
|
3136
3233
|
requireActiveAdapter(method) {
|
|
3137
3234
|
const adapter = this.getAdapter();
|
|
3138
|
-
if (!adapter)
|
|
3139
|
-
|
|
3140
|
-
if (typeof adapter[method] !== "function")
|
|
3141
|
-
throw createWalletError.unsupportedMethod(String(method), adapter.metadata.name);
|
|
3235
|
+
if (!adapter) throw createWalletError.notConnected();
|
|
3236
|
+
if (typeof adapter[method] !== "function") throw createWalletError.unsupportedMethod(String(method), adapter.metadata.name);
|
|
3142
3237
|
return adapter;
|
|
3143
3238
|
}
|
|
3144
3239
|
async saveSession(session) {
|
|
@@ -3153,8 +3248,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3153
3248
|
try {
|
|
3154
3249
|
const parsed = JSON.parse(serialized);
|
|
3155
3250
|
if ("version" in parsed && "session" in parsed) {
|
|
3156
|
-
if (parsed.version !== WALLET_STORAGE_VERSION)
|
|
3157
|
-
return null;
|
|
3251
|
+
if (parsed.version !== WALLET_STORAGE_VERSION) return null;
|
|
3158
3252
|
return this.isValidStoredSession(parsed.session) ? parsed.session : null;
|
|
3159
3253
|
}
|
|
3160
3254
|
if (this.isValidStoredSession(parsed)) {
|
|
@@ -3167,14 +3261,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3167
3261
|
}
|
|
3168
3262
|
}
|
|
3169
3263
|
isValidStoredSession(value) {
|
|
3170
|
-
if (!value || typeof value !== "object")
|
|
3171
|
-
return false;
|
|
3264
|
+
if (!value || typeof value !== "object") return false;
|
|
3172
3265
|
const session = value;
|
|
3173
3266
|
return typeof session.adapterId === "string" && typeof session.connectedAt === "number" && Boolean(session.account) && typeof session.account === "object" && typeof session.account.address === "string";
|
|
3174
3267
|
}
|
|
3175
3268
|
async withTimeout(promise, timeoutMs) {
|
|
3176
|
-
if (!promise)
|
|
3177
|
-
return { timedOut: false };
|
|
3269
|
+
if (!promise) return { timedOut: false };
|
|
3178
3270
|
let timer;
|
|
3179
3271
|
const timeout = new Promise((resolve) => {
|
|
3180
3272
|
timer = setTimeout(() => resolve({ timedOut: true }), timeoutMs);
|
|
@@ -3185,13 +3277,36 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3185
3277
|
timeout
|
|
3186
3278
|
]);
|
|
3187
3279
|
} finally {
|
|
3188
|
-
if (timer)
|
|
3189
|
-
|
|
3280
|
+
if (timer) clearTimeout(timer);
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
async isAdapterAvailable(adapter) {
|
|
3284
|
+
if (!adapter.isAvailable) return true;
|
|
3285
|
+
const availability = await this.withTimeout(Promise.resolve(adapter.isAvailable()), DEFAULT_AVAILABILITY_CHECK_TIMEOUT_MS);
|
|
3286
|
+
if (availability.timedOut) {
|
|
3287
|
+
this.logger.warn(`Availability check timed out for ${adapter.metadata.id}`);
|
|
3288
|
+
return false;
|
|
3289
|
+
}
|
|
3290
|
+
return Boolean(availability.value);
|
|
3291
|
+
}
|
|
3292
|
+
assertSessionNetwork(adapter, session, expected, source) {
|
|
3293
|
+
this.assertAccountNetwork(adapter, session.account, expected, source);
|
|
3294
|
+
}
|
|
3295
|
+
assertAccountNetwork(adapter, account, expected, source) {
|
|
3296
|
+
const actualNetwork = account.network;
|
|
3297
|
+
const actualId = actualNetwork == null ? void 0 : actualNetwork.id;
|
|
3298
|
+
const actualType = (actualNetwork == null ? void 0 : actualNetwork.networkType) ?? account.networkType;
|
|
3299
|
+
const expectedId = expected.id;
|
|
3300
|
+
const expectedType = expected.networkType;
|
|
3301
|
+
if (actualId && actualId !== expectedId) {
|
|
3302
|
+
throw createWalletError.networkMismatch(adapter.metadata.name, String(expectedId), String(actualId), new Error(`${source} returned a different network id`));
|
|
3303
|
+
}
|
|
3304
|
+
if (actualType && actualType !== expectedType) {
|
|
3305
|
+
throw createWalletError.networkMismatch(adapter.metadata.name, expectedType, actualType, new Error(`${source} returned a different network type`));
|
|
3190
3306
|
}
|
|
3191
3307
|
}
|
|
3192
3308
|
normalizeConnectionError(adapter, error) {
|
|
3193
|
-
if (isWalletKitError(error))
|
|
3194
|
-
return error;
|
|
3309
|
+
if (isWalletKitError(error)) return error;
|
|
3195
3310
|
const message = error instanceof Error ? error.message : String(error);
|
|
3196
3311
|
if (/reject|denied|cancelled|canceled|closed/i.test(message)) {
|
|
3197
3312
|
return createWalletError.connectionRejected(adapter.metadata.name, error);
|
|
@@ -3225,6 +3340,21 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
3225
3340
|
const encoder2 = new TextEncoder();
|
|
3226
3341
|
return [...encoder2.encode(value)].map((byte) => byte.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
3227
3342
|
}
|
|
3343
|
+
const EXECUTABLE_URL_PROTOCOLS = /* @__PURE__ */ new Set(["blob:", "data:", "file:", "javascript:", "vbscript:"]);
|
|
3344
|
+
const SAFE_DATA_IMAGE_PATTERN = /^data:image\/(?:avif|gif|jpeg|jpg|png|svg\+xml|webp);base64,[a-z0-9+/]+=*$/i;
|
|
3345
|
+
function isSafeWalletUrl(value, options = {}) {
|
|
3346
|
+
var _a2, _b;
|
|
3347
|
+
if (typeof value !== "string") return false;
|
|
3348
|
+
const url = value.trim();
|
|
3349
|
+
if (!url) return false;
|
|
3350
|
+
if (options.allowDataImage && SAFE_DATA_IMAGE_PATTERN.test(url)) return true;
|
|
3351
|
+
const protocol = (_b = (_a2 = url.match(/^([a-z][a-z0-9+.-]*):/i)) == null ? void 0 : _a2[1]) == null ? void 0 : _b.toLowerCase();
|
|
3352
|
+
if (!protocol) return true;
|
|
3353
|
+
return !EXECUTABLE_URL_PROTOCOLS.has(`${protocol}:`);
|
|
3354
|
+
}
|
|
3355
|
+
function sanitizeWalletUrl(value, options = {}) {
|
|
3356
|
+
return isSafeWalletUrl(value, options) ? value.trim() : void 0;
|
|
3357
|
+
}
|
|
3228
3358
|
var umd$1 = { exports: {} };
|
|
3229
3359
|
var umd = umd$1.exports;
|
|
3230
3360
|
var hasRequiredUmd;
|
|
@@ -4446,18 +4576,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4446
4576
|
const signInAndWait = this.requireMethod("signInAndWait");
|
|
4447
4577
|
const result = await this.withAbort(signInAndWait(this.randomHex()), options.signal);
|
|
4448
4578
|
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");
|
|
4579
|
+
if (!address) throw new Error("Crossmark did not return an XRPL address");
|
|
4451
4580
|
const publicKey = this.pickString(result, ["response.data.publicKey", "response.data.public_key", "response.publicKey", "publicKey"]);
|
|
4452
4581
|
return { account: { address, publicKey, network: options.network, networkType: (_a2 = options.network) == null ? void 0 : _a2.networkType }, raw: result };
|
|
4453
4582
|
}
|
|
4454
4583
|
async restoreSession(session) {
|
|
4455
|
-
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500))
|
|
4456
|
-
return null;
|
|
4584
|
+
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500)) return null;
|
|
4457
4585
|
const provider = this.getProvider(false);
|
|
4458
4586
|
const address = this.resolvePassiveAddress(provider);
|
|
4459
|
-
if (!address || address !== session.account.address)
|
|
4460
|
-
return null;
|
|
4587
|
+
if (!address || address !== session.account.address) return null;
|
|
4461
4588
|
return {
|
|
4462
4589
|
account: { ...session.account, address },
|
|
4463
4590
|
session: { ...session, account: { ...session.account, address } },
|
|
@@ -4479,8 +4606,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4479
4606
|
"signature",
|
|
4480
4607
|
"signedMessage"
|
|
4481
4608
|
]);
|
|
4482
|
-
if (typeof signature !== "string" || !signature)
|
|
4483
|
-
throw createWalletError.signRejected(result);
|
|
4609
|
+
if (typeof signature !== "string" || !signature) throw createWalletError.signRejected(result);
|
|
4484
4610
|
const publicKey = this.pickString(result, [
|
|
4485
4611
|
"response.data.publicKey",
|
|
4486
4612
|
"response.data.public_key",
|
|
@@ -4505,8 +4631,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4505
4631
|
}
|
|
4506
4632
|
getProvider(required = true) {
|
|
4507
4633
|
const provider = this.options.provider ?? CrossmarkSdk;
|
|
4508
|
-
if (!provider && required)
|
|
4509
|
-
throw new Error("Please install Crossmark Extension");
|
|
4634
|
+
if (!provider && required) throw new Error("Please install Crossmark Extension");
|
|
4510
4635
|
return provider;
|
|
4511
4636
|
}
|
|
4512
4637
|
hasInjectedProvider() {
|
|
@@ -4516,16 +4641,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4516
4641
|
var _a2;
|
|
4517
4642
|
const provider = this.getProvider();
|
|
4518
4643
|
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)}()`);
|
|
4644
|
+
if (typeof handler !== "function") throw new Error(`Crossmark provider is missing ${String(method)}()`);
|
|
4521
4645
|
return handler;
|
|
4522
4646
|
}
|
|
4523
4647
|
resolvePassiveAddress(provider) {
|
|
4524
4648
|
var _a2, _b, _c;
|
|
4525
4649
|
try {
|
|
4526
4650
|
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;
|
|
4651
|
+
if (address) return address;
|
|
4529
4652
|
} catch {
|
|
4530
4653
|
}
|
|
4531
4654
|
return (_c = provider == null ? void 0 : provider.session) == null ? void 0 : _c.address;
|
|
@@ -4544,8 +4667,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4544
4667
|
if ((_a2 = globalThis.crypto) == null ? void 0 : _a2.getRandomValues) {
|
|
4545
4668
|
globalThis.crypto.getRandomValues(bytes2);
|
|
4546
4669
|
} else {
|
|
4547
|
-
for (let index2 = 0; index2 < bytes2.length; index2 += 1)
|
|
4548
|
-
bytes2[index2] = Math.floor(Math.random() * 256);
|
|
4670
|
+
for (let index2 = 0; index2 < bytes2.length; index2 += 1) bytes2[index2] = Math.floor(Math.random() * 256);
|
|
4549
4671
|
}
|
|
4550
4672
|
return [...bytes2].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
4551
4673
|
}
|
|
@@ -4554,34 +4676,32 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4554
4676
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
4555
4677
|
}
|
|
4556
4678
|
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")));
|
|
4679
|
+
if (!signal) return promise;
|
|
4680
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4561
4681
|
return new Promise((resolve, reject) => {
|
|
4562
4682
|
let settled = false;
|
|
4563
4683
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
4564
4684
|
const abort = () => {
|
|
4565
|
-
if (settled)
|
|
4566
|
-
return;
|
|
4685
|
+
if (settled) return;
|
|
4567
4686
|
settled = true;
|
|
4568
4687
|
cleanup();
|
|
4569
4688
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4570
4689
|
};
|
|
4571
4690
|
signal.addEventListener("abort", abort, { once: true });
|
|
4572
|
-
promise.then(
|
|
4573
|
-
|
|
4574
|
-
return;
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
return;
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4691
|
+
promise.then(
|
|
4692
|
+
(value) => {
|
|
4693
|
+
if (settled) return;
|
|
4694
|
+
settled = true;
|
|
4695
|
+
cleanup();
|
|
4696
|
+
resolve(value);
|
|
4697
|
+
},
|
|
4698
|
+
(error) => {
|
|
4699
|
+
if (settled) return;
|
|
4700
|
+
settled = true;
|
|
4701
|
+
cleanup();
|
|
4702
|
+
reject(error);
|
|
4703
|
+
}
|
|
4704
|
+
);
|
|
4585
4705
|
});
|
|
4586
4706
|
}
|
|
4587
4707
|
}
|
|
@@ -4612,21 +4732,17 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4612
4732
|
const provider = this.provider();
|
|
4613
4733
|
const state2 = await this.withAbort(this.initialize(provider), options.signal);
|
|
4614
4734
|
const connected = await this.withAbort(this.resolveConnected(provider, state2), options.signal);
|
|
4615
|
-
if (!connected)
|
|
4616
|
-
throw new Error("DropFi connection was rejected");
|
|
4735
|
+
if (!connected) throw new Error("DropFi connection was rejected");
|
|
4617
4736
|
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");
|
|
4737
|
+
if (!address) throw new Error("DropFi did not return an XRPL address");
|
|
4620
4738
|
const publicKey = await this.withAbort(this.resolvePublicKey(provider, connected, state2), options.signal);
|
|
4621
4739
|
this.activeAddress = address;
|
|
4622
4740
|
return { account: { address, publicKey, network: options.network, networkType: (_a2 = options.network) == null ? void 0 : _a2.networkType }, raw: { connected, address, publicKey } };
|
|
4623
4741
|
}
|
|
4624
4742
|
async restoreSession(session) {
|
|
4625
|
-
if (!this.hasInjectedProvider() && !await this.waitForAvailability(2500))
|
|
4626
|
-
return null;
|
|
4743
|
+
if (!this.hasInjectedProvider() && !await this.waitForAvailability(2500)) return null;
|
|
4627
4744
|
const provider = this.provider(false);
|
|
4628
|
-
if (!provider)
|
|
4629
|
-
return null;
|
|
4745
|
+
if (!provider) return null;
|
|
4630
4746
|
const state2 = await this.initialize(provider);
|
|
4631
4747
|
let connected;
|
|
4632
4748
|
if (typeof provider.isConnected === "function") {
|
|
@@ -4637,8 +4753,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4637
4753
|
}
|
|
4638
4754
|
}
|
|
4639
4755
|
const address = await this.resolvePassiveAddress(provider, state2);
|
|
4640
|
-
if (!address || address !== session.account.address)
|
|
4641
|
-
return null;
|
|
4756
|
+
if (!address || address !== session.account.address) return null;
|
|
4642
4757
|
const publicKey = await this.resolvePublicKey(provider, void 0, state2);
|
|
4643
4758
|
this.activeAddress = address;
|
|
4644
4759
|
return {
|
|
@@ -4663,8 +4778,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4663
4778
|
}
|
|
4664
4779
|
async signMessage(request) {
|
|
4665
4780
|
const provider = this.provider();
|
|
4666
|
-
if (!provider.signMessage)
|
|
4667
|
-
throw new Error("DropFi provider is missing signMessage()");
|
|
4781
|
+
if (!provider.signMessage) throw new Error("DropFi provider is missing signMessage()");
|
|
4668
4782
|
const result = await provider.signMessage(request.message);
|
|
4669
4783
|
const signature = this.pickString(result, [
|
|
4670
4784
|
"signature",
|
|
@@ -4672,8 +4786,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4672
4786
|
"response.signature",
|
|
4673
4787
|
"response.data.signature"
|
|
4674
4788
|
]);
|
|
4675
|
-
if (typeof signature !== "string" || !signature)
|
|
4676
|
-
throw createWalletError.signRejected(signature);
|
|
4789
|
+
if (typeof signature !== "string" || !signature) throw createWalletError.signRejected(signature);
|
|
4677
4790
|
const publicKey = this.pickString(result, [
|
|
4678
4791
|
"publicKey",
|
|
4679
4792
|
"public_key",
|
|
@@ -4684,8 +4797,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4684
4797
|
"response.data.publicKey",
|
|
4685
4798
|
"response.data.public_key"
|
|
4686
4799
|
]);
|
|
4687
|
-
if (typeof publicKey !== "string" || !publicKey)
|
|
4688
|
-
throw createWalletError.signRejected(result);
|
|
4800
|
+
if (typeof publicKey !== "string" || !publicKey) throw createWalletError.signRejected(result);
|
|
4689
4801
|
return {
|
|
4690
4802
|
signatureKind: "signature",
|
|
4691
4803
|
proof: signature,
|
|
@@ -4696,8 +4808,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4696
4808
|
}
|
|
4697
4809
|
async signAndSubmit(request) {
|
|
4698
4810
|
const provider = this.provider();
|
|
4699
|
-
if (!provider.sendTransaction)
|
|
4700
|
-
throw new Error("DropFi provider is missing sendTransaction()");
|
|
4811
|
+
if (!provider.sendTransaction) throw new Error("DropFi provider is missing sendTransaction()");
|
|
4701
4812
|
return normalizeTxResult(await provider.sendTransaction(request.txJson));
|
|
4702
4813
|
}
|
|
4703
4814
|
async withTimeout(promise, timeoutMs) {
|
|
@@ -4708,63 +4819,59 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4708
4819
|
try {
|
|
4709
4820
|
return await Promise.race([promise, timeout]);
|
|
4710
4821
|
} finally {
|
|
4711
|
-
if (timer)
|
|
4712
|
-
clearTimeout(timer);
|
|
4822
|
+
if (timer) clearTimeout(timer);
|
|
4713
4823
|
}
|
|
4714
4824
|
}
|
|
4715
4825
|
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")));
|
|
4826
|
+
if (!signal) return promise;
|
|
4827
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4720
4828
|
return new Promise((resolve, reject) => {
|
|
4721
4829
|
let settled = false;
|
|
4722
4830
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
4723
4831
|
const abort = () => {
|
|
4724
|
-
if (settled)
|
|
4725
|
-
return;
|
|
4832
|
+
if (settled) return;
|
|
4726
4833
|
settled = true;
|
|
4727
4834
|
cleanup();
|
|
4728
4835
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
4729
4836
|
};
|
|
4730
4837
|
signal.addEventListener("abort", abort, { once: true });
|
|
4731
|
-
promise.then(
|
|
4732
|
-
|
|
4733
|
-
return;
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
return;
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4838
|
+
promise.then(
|
|
4839
|
+
(value) => {
|
|
4840
|
+
if (settled) return;
|
|
4841
|
+
settled = true;
|
|
4842
|
+
cleanup();
|
|
4843
|
+
resolve(value);
|
|
4844
|
+
},
|
|
4845
|
+
(error) => {
|
|
4846
|
+
if (settled) return;
|
|
4847
|
+
settled = true;
|
|
4848
|
+
cleanup();
|
|
4849
|
+
reject(error);
|
|
4850
|
+
}
|
|
4851
|
+
);
|
|
4744
4852
|
});
|
|
4745
4853
|
}
|
|
4746
4854
|
provider(required = true) {
|
|
4747
4855
|
const host = globalThis;
|
|
4748
4856
|
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");
|
|
4857
|
+
if (!provider && required) throw new Error("Please install DropFi Wallet");
|
|
4751
4858
|
return provider;
|
|
4752
4859
|
}
|
|
4753
4860
|
hasInjectedProvider() {
|
|
4754
4861
|
return Object.prototype.hasOwnProperty.call(this.options, "provider");
|
|
4755
4862
|
}
|
|
4756
4863
|
resolveLegacyXrplProvider(provider) {
|
|
4757
|
-
if (!provider)
|
|
4758
|
-
return void 0;
|
|
4864
|
+
if (!provider) return void 0;
|
|
4759
4865
|
return this.isDropFiProvider(provider) ? provider : void 0;
|
|
4760
4866
|
}
|
|
4761
4867
|
isDropFiProvider(provider) {
|
|
4762
4868
|
var _a2, _b;
|
|
4763
|
-
return Boolean(
|
|
4869
|
+
return Boolean(
|
|
4870
|
+
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
|
|
4871
|
+
);
|
|
4764
4872
|
}
|
|
4765
4873
|
async initialize(provider) {
|
|
4766
|
-
if (!provider.initialize)
|
|
4767
|
-
return null;
|
|
4874
|
+
if (!provider.initialize) return null;
|
|
4768
4875
|
try {
|
|
4769
4876
|
return await provider.initialize();
|
|
4770
4877
|
} catch {
|
|
@@ -4773,30 +4880,23 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4773
4880
|
}
|
|
4774
4881
|
async resolveAddress(provider, connected, state2) {
|
|
4775
4882
|
var _a2, _b, _c, _d, _e2, _f, _g;
|
|
4776
|
-
if (typeof connected === "string")
|
|
4777
|
-
return connected;
|
|
4883
|
+
if (typeof connected === "string") return connected;
|
|
4778
4884
|
if (connected && typeof connected === "object") {
|
|
4779
4885
|
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];
|
|
4886
|
+
if (result.address) return result.address;
|
|
4887
|
+
if (result.selectedAddress) return result.selectedAddress;
|
|
4888
|
+
if ((_a2 = result.connectedAccounts) == null ? void 0 : _a2[0]) return result.connectedAccounts[0];
|
|
4889
|
+
if ((_b = result.accounts) == null ? void 0 : _b[0]) return result.accounts[0];
|
|
4788
4890
|
}
|
|
4789
4891
|
if (typeof provider.getAddress === "function") {
|
|
4790
4892
|
const address = await provider.getAddress();
|
|
4791
4893
|
const normalized = this.normalizeAddressResult(address);
|
|
4792
|
-
if (normalized)
|
|
4793
|
-
return normalized;
|
|
4894
|
+
if (normalized) return normalized;
|
|
4794
4895
|
}
|
|
4795
4896
|
if (typeof provider.getAccounts === "function") {
|
|
4796
4897
|
const accounts = await provider.getAccounts();
|
|
4797
4898
|
const first = Array.isArray(accounts) ? accounts[0] : (_c = accounts.accounts) == null ? void 0 : _c[0];
|
|
4798
|
-
if (first)
|
|
4799
|
-
return first;
|
|
4899
|
+
if (first) return first;
|
|
4800
4900
|
}
|
|
4801
4901
|
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
4902
|
}
|
|
@@ -4806,8 +4906,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4806
4906
|
try {
|
|
4807
4907
|
const address = await provider.getAddress();
|
|
4808
4908
|
const normalized = this.normalizeAddressResult(address);
|
|
4809
|
-
if (normalized)
|
|
4810
|
-
return normalized;
|
|
4909
|
+
if (normalized) return normalized;
|
|
4811
4910
|
} catch {
|
|
4812
4911
|
}
|
|
4813
4912
|
}
|
|
@@ -4815,46 +4914,34 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
4815
4914
|
try {
|
|
4816
4915
|
const accounts = await provider.getAccounts();
|
|
4817
4916
|
const first = Array.isArray(accounts) ? accounts[0] : (_a2 = accounts.accounts) == null ? void 0 : _a2[0];
|
|
4818
|
-
if (first)
|
|
4819
|
-
return first;
|
|
4917
|
+
if (first) return first;
|
|
4820
4918
|
} catch {
|
|
4821
4919
|
}
|
|
4822
4920
|
}
|
|
4823
4921
|
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
4922
|
}
|
|
4825
4923
|
async resolveConnected(provider, state2) {
|
|
4826
|
-
if (typeof provider.isConnected === "function" && await provider.isConnected())
|
|
4827
|
-
return true;
|
|
4924
|
+
if (typeof provider.isConnected === "function" && await provider.isConnected()) return true;
|
|
4828
4925
|
const existingAddress = await this.resolveAddress(provider, true, state2);
|
|
4829
|
-
if (existingAddress)
|
|
4830
|
-
|
|
4831
|
-
if (typeof provider.connect === "function")
|
|
4832
|
-
return provider.connect();
|
|
4926
|
+
if (existingAddress) return true;
|
|
4927
|
+
if (typeof provider.connect === "function") return provider.connect();
|
|
4833
4928
|
return false;
|
|
4834
4929
|
}
|
|
4835
4930
|
normalizeAddressResult(value) {
|
|
4836
4931
|
var _a2;
|
|
4837
|
-
if (typeof value === "string")
|
|
4838
|
-
|
|
4839
|
-
if (!value || typeof value !== "object")
|
|
4840
|
-
return void 0;
|
|
4932
|
+
if (typeof value === "string") return value;
|
|
4933
|
+
if (!value || typeof value !== "object") return void 0;
|
|
4841
4934
|
return value.address ?? value.selectedAddress ?? ((_a2 = value.result) == null ? void 0 : _a2.address);
|
|
4842
4935
|
}
|
|
4843
4936
|
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;
|
|
4937
|
+
if (connected && typeof connected === "object" && typeof connected.publicKey === "string" && connected.publicKey) return connected.publicKey;
|
|
4938
|
+
if (typeof (state2 == null ? void 0 : state2.publicKey) === "string" && state2.publicKey) return state2.publicKey;
|
|
4939
|
+
if (typeof provider.publicKey === "string" && provider.publicKey) return provider.publicKey;
|
|
4940
|
+
if (typeof provider.getPublicKey !== "function") return void 0;
|
|
4852
4941
|
try {
|
|
4853
4942
|
const result = await provider.getPublicKey();
|
|
4854
|
-
if (typeof result === "string" && result)
|
|
4855
|
-
|
|
4856
|
-
if (!result || typeof result !== "object")
|
|
4857
|
-
return void 0;
|
|
4943
|
+
if (typeof result === "string" && result) return result;
|
|
4944
|
+
if (!result || typeof result !== "object") return void 0;
|
|
4858
4945
|
return this.pickString(result, ["publicKey", "public_key", "result.publicKey", "result.public_key"]);
|
|
4859
4946
|
} catch {
|
|
4860
4947
|
return void 0;
|
|
@@ -8947,31 +9034,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
8947
9034
|
}
|
|
8948
9035
|
async isAvailable() {
|
|
8949
9036
|
const provider = this.getProvider(false);
|
|
8950
|
-
if (!(provider == null ? void 0 : provider.isInstalled))
|
|
8951
|
-
return false;
|
|
9037
|
+
if (!(provider == null ? void 0 : provider.isInstalled)) return false;
|
|
8952
9038
|
const result = await provider.isInstalled();
|
|
8953
9039
|
return this.isInstalledResult(result);
|
|
8954
9040
|
}
|
|
8955
9041
|
async connect(options) {
|
|
8956
9042
|
var _a2, _b, _c;
|
|
8957
9043
|
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()");
|
|
9044
|
+
if (!provider.isInstalled || !this.isInstalledResult(await provider.isInstalled())) throw new Error("Please install GemWallet Extension");
|
|
9045
|
+
if (!provider.getAddress) throw new Error("GemWallet provider is missing getAddress()");
|
|
8962
9046
|
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
9047
|
const accountAddress = (_b = address.result) == null ? void 0 : _b.address;
|
|
8964
|
-
if (!accountAddress)
|
|
8965
|
-
throw new Error("GemWallet did not return an XRPL address");
|
|
9048
|
+
if (!accountAddress) throw new Error("GemWallet did not return an XRPL address");
|
|
8966
9049
|
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
9050
|
}
|
|
8968
9051
|
async restoreSession(session) {
|
|
8969
|
-
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500))
|
|
8970
|
-
return null;
|
|
9052
|
+
if (!await this.waitForAvailability(this.hasInjectedProvider() ? 0 : 2500)) return null;
|
|
8971
9053
|
const provider = this.getProvider();
|
|
8972
9054
|
const address = await this.getCurrentAddress(provider);
|
|
8973
|
-
if (!address || address.accountAddress !== session.account.address)
|
|
8974
|
-
return null;
|
|
9055
|
+
if (!address || address.accountAddress !== session.account.address) return null;
|
|
8975
9056
|
return {
|
|
8976
9057
|
account: { ...session.account, address: address.accountAddress },
|
|
8977
9058
|
session: { ...session, account: { ...session.account, address: address.accountAddress } },
|
|
@@ -8981,15 +9062,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
8981
9062
|
async signMessage(request) {
|
|
8982
9063
|
var _a2, _b, _c;
|
|
8983
9064
|
const provider = this.getProvider();
|
|
8984
|
-
if (!provider.signMessage)
|
|
8985
|
-
throw new Error("GemWallet provider is missing signMessage()");
|
|
9065
|
+
if (!provider.signMessage) throw new Error("GemWallet provider is missing signMessage()");
|
|
8986
9066
|
const [result, resolvedPublicKey] = await Promise.all([
|
|
8987
9067
|
provider.signMessage(request.message),
|
|
8988
9068
|
((_a2 = request.account) == null ? void 0 : _a2.publicKey) ? Promise.resolve(void 0) : this.getPublicKey(provider)
|
|
8989
9069
|
]);
|
|
8990
9070
|
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);
|
|
9071
|
+
if (typeof signature !== "string" || !signature) throw createWalletError.signRejected(result);
|
|
8993
9072
|
return {
|
|
8994
9073
|
signatureKind: "signature",
|
|
8995
9074
|
proof: signature,
|
|
@@ -9008,23 +9087,16 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9008
9087
|
resolveMethodHint(request) {
|
|
9009
9088
|
if (request.methodHint && request.methodHint !== "generic") {
|
|
9010
9089
|
const hint = String(request.methodHint);
|
|
9011
|
-
if (["trustset", "trustSet", "setTrustline", "trustline", "trustLine"].includes(hint))
|
|
9012
|
-
return "setTrustline";
|
|
9090
|
+
if (["trustset", "trustSet", "setTrustline", "trustline", "trustLine"].includes(hint)) return "setTrustline";
|
|
9013
9091
|
return request.methodHint;
|
|
9014
9092
|
}
|
|
9015
9093
|
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";
|
|
9094
|
+
if (transactionType === "Payment") return "payment";
|
|
9095
|
+
if (transactionType === "NFTokenCreateOffer") return "createNFTOffer";
|
|
9096
|
+
if (transactionType === "NFTokenAcceptOffer") return "acceptNFTOffer";
|
|
9097
|
+
if (transactionType === "NFTokenCancelOffer") return "cancelNFTOffer";
|
|
9098
|
+
if (transactionType === "NFTokenBurn") return "burnNFT";
|
|
9099
|
+
if (transactionType === "TrustSet") return "setTrustline";
|
|
9028
9100
|
return request.methodHint ?? "generic";
|
|
9029
9101
|
}
|
|
9030
9102
|
toGemWalletPaymentPayload(txJson) {
|
|
@@ -9032,12 +9104,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9032
9104
|
amount: txJson.Amount,
|
|
9033
9105
|
destination: txJson.Destination
|
|
9034
9106
|
};
|
|
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);
|
|
9107
|
+
if (txJson.DestinationTag !== void 0) payload.destinationTag = txJson.DestinationTag;
|
|
9108
|
+
if (txJson.InvoiceID !== void 0) payload.invoiceID = txJson.InvoiceID;
|
|
9109
|
+
if (txJson.Memos !== void 0) payload.memos = this.toGemWalletMemos(txJson.Memos);
|
|
9041
9110
|
return Object.fromEntries(Object.entries(payload).filter(([, value]) => value !== void 0));
|
|
9042
9111
|
}
|
|
9043
9112
|
toGemWalletBurnNFTPayload(txJson) {
|
|
@@ -9068,8 +9137,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9068
9137
|
return Object.fromEntries(Object.entries(payload).filter(([, value]) => value !== void 0));
|
|
9069
9138
|
}
|
|
9070
9139
|
toGemWalletMemos(memos) {
|
|
9071
|
-
if (!Array.isArray(memos))
|
|
9072
|
-
return memos;
|
|
9140
|
+
if (!Array.isArray(memos)) return memos;
|
|
9073
9141
|
return memos.map((item) => {
|
|
9074
9142
|
const memo = this.getRecord(this.getRecord(item).Memo);
|
|
9075
9143
|
return {
|
|
@@ -9086,8 +9154,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9086
9154
|
}
|
|
9087
9155
|
getProvider(required = true) {
|
|
9088
9156
|
const provider = this.options.provider ?? GemWalletApi;
|
|
9089
|
-
if (!provider && required)
|
|
9090
|
-
throw new Error("GemWallet provider is not available");
|
|
9157
|
+
if (!provider && required) throw new Error("GemWallet provider is not available");
|
|
9091
9158
|
return provider;
|
|
9092
9159
|
}
|
|
9093
9160
|
hasInjectedProvider() {
|
|
@@ -9095,8 +9162,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9095
9162
|
}
|
|
9096
9163
|
async getCurrentAddress(provider) {
|
|
9097
9164
|
var _a2;
|
|
9098
|
-
if (!provider.getAddress)
|
|
9099
|
-
return void 0;
|
|
9165
|
+
if (!provider.getAddress) return void 0;
|
|
9100
9166
|
try {
|
|
9101
9167
|
const raw = await provider.getAddress();
|
|
9102
9168
|
const accountAddress = (_a2 = raw.result) == null ? void 0 : _a2.address;
|
|
@@ -9106,14 +9172,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9106
9172
|
}
|
|
9107
9173
|
}
|
|
9108
9174
|
async getPublicKey(provider) {
|
|
9109
|
-
if (!provider.getPublicKey)
|
|
9110
|
-
return void 0;
|
|
9175
|
+
if (!provider.getPublicKey) return void 0;
|
|
9111
9176
|
try {
|
|
9112
9177
|
const raw = await provider.getPublicKey();
|
|
9113
9178
|
const payload = raw && typeof raw === "object" && "result" in raw ? raw.result : raw;
|
|
9114
9179
|
const record = payload && typeof payload === "object" ? payload : void 0;
|
|
9115
|
-
if (!record)
|
|
9116
|
-
return { raw };
|
|
9180
|
+
if (!record) return { raw };
|
|
9117
9181
|
const publicKey = typeof record.publicKey === "string" && record.publicKey ? record.publicKey : void 0;
|
|
9118
9182
|
const address = typeof record.address === "string" && record.address ? record.address : void 0;
|
|
9119
9183
|
return publicKey || address ? { publicKey, address, raw } : { raw };
|
|
@@ -9126,61 +9190,57 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9126
9190
|
}
|
|
9127
9191
|
booleanResult(result, key) {
|
|
9128
9192
|
var _a2;
|
|
9129
|
-
if (typeof result === "boolean")
|
|
9130
|
-
|
|
9131
|
-
if (typeof (result == null ? void 0 : result.result) === "boolean")
|
|
9132
|
-
return result.result;
|
|
9193
|
+
if (typeof result === "boolean") return result;
|
|
9194
|
+
if (typeof (result == null ? void 0 : result.result) === "boolean") return result.result;
|
|
9133
9195
|
return Boolean((_a2 = result == null ? void 0 : result.result) == null ? void 0 : _a2[key]);
|
|
9134
9196
|
}
|
|
9135
9197
|
networkName(network) {
|
|
9136
9198
|
return typeof network === "string" ? network : network == null ? void 0 : network.name;
|
|
9137
9199
|
}
|
|
9138
9200
|
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")));
|
|
9201
|
+
if (!signal) return promise;
|
|
9202
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
9143
9203
|
return new Promise((resolve, reject) => {
|
|
9144
9204
|
let settled = false;
|
|
9145
9205
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
9146
9206
|
const abort = () => {
|
|
9147
|
-
if (settled)
|
|
9148
|
-
return;
|
|
9207
|
+
if (settled) return;
|
|
9149
9208
|
settled = true;
|
|
9150
9209
|
cleanup();
|
|
9151
9210
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
9152
9211
|
};
|
|
9153
9212
|
signal.addEventListener("abort", abort, { once: true });
|
|
9154
|
-
promise.then(
|
|
9155
|
-
|
|
9156
|
-
return;
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
return;
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9213
|
+
promise.then(
|
|
9214
|
+
(value) => {
|
|
9215
|
+
if (settled) return;
|
|
9216
|
+
settled = true;
|
|
9217
|
+
cleanup();
|
|
9218
|
+
resolve(value);
|
|
9219
|
+
},
|
|
9220
|
+
(error) => {
|
|
9221
|
+
if (settled) return;
|
|
9222
|
+
settled = true;
|
|
9223
|
+
cleanup();
|
|
9224
|
+
reject(error);
|
|
9225
|
+
}
|
|
9226
|
+
);
|
|
9167
9227
|
});
|
|
9168
9228
|
}
|
|
9169
9229
|
}
|
|
9170
9230
|
function createGemWalletAdapter(options) {
|
|
9171
9231
|
return new GemWalletAdapter(options);
|
|
9172
9232
|
}
|
|
9173
|
-
const LEDGER_ICON = "data:image/svg+xml;base64,
|
|
9233
|
+
const LEDGER_ICON = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzAwMCIgZD0iTTAgMGgyOHYyOEgweiIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjY1IDQuNEg0LjRWOWgxLjFWNS41bDYuMTUtLjA0VjQuNFptLjA1IDUuOTV2Ny4yNWg0LjZ2LTEuMWgtMy41bC0uMDQtNi4xNUgxMS43Wk00LjQgMjMuNmg3LjI1di0xLjA2TDUuNSAyMi41VjE5SDQuNHY0LjZaTTE2LjM1IDQuNGg3LjI1VjloLTEuMVY1LjVsLTYuMTUtLjA0VjQuNFptNy4yNSAxOS4yaC03LjI1di0xLjA2bDYuMTUtLjA0VjE5aDEuMXY0LjZaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=";
|
|
9174
9234
|
const DEFAULT_TIMEOUT = 6e4;
|
|
9175
9235
|
const DEFAULT_ACCOUNT_INDEX = 0;
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
})(
|
|
9236
|
+
var LedgerDeviceState = /* @__PURE__ */ ((LedgerDeviceState2) => {
|
|
9237
|
+
LedgerDeviceState2["NOT_CONNECTED"] = "NOT_CONNECTED";
|
|
9238
|
+
LedgerDeviceState2["LOCKED"] = "LOCKED";
|
|
9239
|
+
LedgerDeviceState2["APP_NOT_OPEN"] = "APP_NOT_OPEN";
|
|
9240
|
+
LedgerDeviceState2["READY"] = "READY";
|
|
9241
|
+
LedgerDeviceState2["UNKNOWN"] = "UNKNOWN";
|
|
9242
|
+
return LedgerDeviceState2;
|
|
9243
|
+
})(LedgerDeviceState || {});
|
|
9184
9244
|
class LedgerAdapter extends BaseWalletAdapter {
|
|
9185
9245
|
constructor(options = {}) {
|
|
9186
9246
|
super();
|
|
@@ -9245,8 +9305,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9245
9305
|
this.network = void 0;
|
|
9246
9306
|
}
|
|
9247
9307
|
async signAndSubmit(request) {
|
|
9248
|
-
if (!this.session)
|
|
9249
|
-
|
|
9308
|
+
if (!this.session) throw createWalletError.notConnected();
|
|
9309
|
+
this.assertSingleSignTransaction(request.txJson);
|
|
9250
9310
|
try {
|
|
9251
9311
|
const result = await this.session.signTransaction(request.txJson, request.submit ?? true);
|
|
9252
9312
|
return {
|
|
@@ -9263,8 +9323,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9263
9323
|
}
|
|
9264
9324
|
}
|
|
9265
9325
|
async signTransaction(request) {
|
|
9266
|
-
if (!this.session)
|
|
9267
|
-
|
|
9326
|
+
if (!this.session) throw createWalletError.notConnected();
|
|
9327
|
+
this.assertSingleSignTransaction(request.txJson);
|
|
9268
9328
|
try {
|
|
9269
9329
|
const result = await this.session.signTransaction(request.txJson, false);
|
|
9270
9330
|
return {
|
|
@@ -9287,7 +9347,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9287
9347
|
const accounts = [];
|
|
9288
9348
|
for (let index2 = startIndex; index2 < startIndex + count; index2 += 1) {
|
|
9289
9349
|
const path = getDerivationPath(index2);
|
|
9290
|
-
const account = await this.withTimeout(
|
|
9350
|
+
const account = await this.withTimeout(
|
|
9351
|
+
this.xrp.getAddress(path, false, false),
|
|
9352
|
+
"Ledger account lookup timeout. Please check your Ledger device."
|
|
9353
|
+
);
|
|
9291
9354
|
accounts.push({
|
|
9292
9355
|
address: account.address,
|
|
9293
9356
|
publicKey: account.publicKey,
|
|
@@ -9299,8 +9362,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9299
9362
|
} catch (error) {
|
|
9300
9363
|
throw this.mapConnectionError(error);
|
|
9301
9364
|
} finally {
|
|
9302
|
-
if (cleanupAfter)
|
|
9303
|
-
await this.cleanup();
|
|
9365
|
+
if (cleanupAfter) await this.cleanup();
|
|
9304
9366
|
}
|
|
9305
9367
|
}
|
|
9306
9368
|
async connectDefaultLedger() {
|
|
@@ -9311,9 +9373,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9311
9373
|
this.transport = await this.createTransport();
|
|
9312
9374
|
const Xrp2 = await loadLedgerXrpApp();
|
|
9313
9375
|
this.xrp = new Xrp2(this.transport);
|
|
9314
|
-
const account = await this.withTimeout(
|
|
9315
|
-
|
|
9316
|
-
|
|
9376
|
+
const account = await this.withTimeout(
|
|
9377
|
+
this.xrp.getAddress(this.derivationPath, false, false),
|
|
9378
|
+
"Ledger connection timeout. Please check your Ledger device."
|
|
9379
|
+
);
|
|
9380
|
+
if (!account.address) throw new Error("Ledger did not return an XRPL address");
|
|
9317
9381
|
return {
|
|
9318
9382
|
address: account.address,
|
|
9319
9383
|
publicKey: account.publicKey,
|
|
@@ -9322,10 +9386,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9322
9386
|
};
|
|
9323
9387
|
}
|
|
9324
9388
|
async signWithDefaultLedger(tx, submit2 = true) {
|
|
9325
|
-
if (!this.xrp || !this.session)
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
throw createWalletError.connectionFailed(this.metadata.name, new Error("XRPL network is required for Ledger signing"));
|
|
9389
|
+
if (!this.xrp || !this.session) throw createWalletError.notConnected();
|
|
9390
|
+
if (!this.network) throw createWalletError.connectionFailed(this.metadata.name, new Error("XRPL network is required for Ledger signing"));
|
|
9391
|
+
this.assertSingleSignTransaction(tx);
|
|
9329
9392
|
const { Client, encode: encode2 } = await Promise.resolve().then(() => index$4);
|
|
9330
9393
|
const client2 = new Client(this.network.rpcUrl);
|
|
9331
9394
|
await client2.connect();
|
|
@@ -9341,9 +9404,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9341
9404
|
const publicKey = this.session.publicKey ?? (await this.xrp.getAddress(this.derivationPath, false, false)).publicKey;
|
|
9342
9405
|
txForSigning.SigningPubKey = publicKey.toUpperCase();
|
|
9343
9406
|
const signingBlob = encode2(txForSigning).toUpperCase();
|
|
9344
|
-
const signature = await this.withTimeout(
|
|
9345
|
-
|
|
9346
|
-
|
|
9407
|
+
const signature = await this.withTimeout(
|
|
9408
|
+
this.xrp.signTransaction(this.derivationPath, signingBlob),
|
|
9409
|
+
"Ledger signing timeout. Please confirm the transaction on your Ledger device."
|
|
9410
|
+
);
|
|
9411
|
+
if (!signature) throw new Error("Ledger did not return a transaction signature");
|
|
9347
9412
|
const signedTx = {
|
|
9348
9413
|
...txForSigning,
|
|
9349
9414
|
TxnSignature: signature.toUpperCase()
|
|
@@ -9372,60 +9437,49 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9372
9437
|
}
|
|
9373
9438
|
async createTransport() {
|
|
9374
9439
|
const support = getLedgerBrowserSupport();
|
|
9375
|
-
if (!support.supported)
|
|
9376
|
-
throw createWalletError.walletNotAvailable("Ledger", new Error(support.message));
|
|
9440
|
+
if (!support.supported) throw createWalletError.walletNotAvailable("Ledger", new Error(support.message));
|
|
9377
9441
|
if (this.options.preferWebHID !== false && support.webHID) {
|
|
9378
9442
|
try {
|
|
9379
9443
|
return await createWebHIDTransport();
|
|
9380
9444
|
} catch (error) {
|
|
9381
|
-
if (!support.webUSB)
|
|
9382
|
-
throw error;
|
|
9445
|
+
if (!support.webUSB) throw error;
|
|
9383
9446
|
}
|
|
9384
9447
|
}
|
|
9385
9448
|
if (support.webUSB) {
|
|
9386
9449
|
try {
|
|
9387
9450
|
return await createWebUSBTransport();
|
|
9388
9451
|
} catch (error) {
|
|
9389
|
-
if (!support.webHID || this.options.preferWebHID !== false)
|
|
9390
|
-
throw error;
|
|
9452
|
+
if (!support.webHID || this.options.preferWebHID !== false) throw error;
|
|
9391
9453
|
}
|
|
9392
9454
|
}
|
|
9393
|
-
if (support.webHID)
|
|
9394
|
-
return createWebHIDTransport();
|
|
9455
|
+
if (support.webHID) return createWebHIDTransport();
|
|
9395
9456
|
throw createWalletError.walletNotAvailable("Ledger", new Error("No compatible Ledger transport is available"));
|
|
9396
9457
|
}
|
|
9397
9458
|
async cleanup() {
|
|
9398
9459
|
const transport = this.transport;
|
|
9399
9460
|
this.transport = void 0;
|
|
9400
9461
|
this.xrp = void 0;
|
|
9401
|
-
if (!transport)
|
|
9402
|
-
return;
|
|
9462
|
+
if (!transport) return;
|
|
9403
9463
|
try {
|
|
9404
9464
|
await transport.close();
|
|
9405
9465
|
} catch {
|
|
9406
9466
|
}
|
|
9407
9467
|
}
|
|
9408
9468
|
mapConnectionError(error) {
|
|
9409
|
-
if (isWalletKitErrorLike(error))
|
|
9410
|
-
return error;
|
|
9469
|
+
if (isWalletKitErrorLike(error)) return error;
|
|
9411
9470
|
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) {
|
|
9471
|
+
if (parsed.timeout) return createWalletError.requestTimeout(parsed.message, error);
|
|
9472
|
+
if (parsed.rejected) return createWalletError.connectionRejected(this.metadata.name, error);
|
|
9473
|
+
if (parsed.state === "NOT_CONNECTED") {
|
|
9417
9474
|
return createWalletError.walletNotAvailable(this.metadata.name, new Error(parsed.message));
|
|
9418
9475
|
}
|
|
9419
9476
|
return createWalletError.connectionFailed(this.metadata.name, new Error(parsed.message));
|
|
9420
9477
|
}
|
|
9421
9478
|
mapSigningError(error) {
|
|
9422
|
-
if (isWalletKitErrorLike(error))
|
|
9423
|
-
return error;
|
|
9479
|
+
if (isWalletKitErrorLike(error)) return error;
|
|
9424
9480
|
const parsed = parseLedgerError(error);
|
|
9425
|
-
if (parsed.timeout)
|
|
9426
|
-
|
|
9427
|
-
if (parsed.rejected)
|
|
9428
|
-
return createWalletError.signRejected(error);
|
|
9481
|
+
if (parsed.timeout) return createWalletError.requestTimeout(parsed.message, error);
|
|
9482
|
+
if (parsed.rejected) return createWalletError.signRejected(error);
|
|
9429
9483
|
return createWalletError.signFailed(new Error(parsed.message));
|
|
9430
9484
|
}
|
|
9431
9485
|
async withTimeout(promise, message) {
|
|
@@ -9439,8 +9493,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9439
9493
|
})
|
|
9440
9494
|
]);
|
|
9441
9495
|
} finally {
|
|
9442
|
-
if (timer)
|
|
9443
|
-
|
|
9496
|
+
if (timer) clearTimeout(timer);
|
|
9497
|
+
}
|
|
9498
|
+
}
|
|
9499
|
+
assertSingleSignTransaction(tx) {
|
|
9500
|
+
const txJson = asRecord(tx);
|
|
9501
|
+
if (txJson.SigningPubKey === "" || Array.isArray(txJson.Signers)) {
|
|
9502
|
+
throw createWalletError.unsupportedMethod("XRPL multisigning", this.metadata.name);
|
|
9444
9503
|
}
|
|
9445
9504
|
}
|
|
9446
9505
|
}
|
|
@@ -9477,27 +9536,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9477
9536
|
const statusCode = getLedgerStatusCode(error);
|
|
9478
9537
|
const lower = message.toLowerCase();
|
|
9479
9538
|
if (statusCode === 27013 || /reject|denied|cancelled|canceled|closed|access denied/.test(lower)) {
|
|
9480
|
-
return { state:
|
|
9539
|
+
return { state: "READY", message: message || "Ledger request was rejected", rejected: true, timeout: false };
|
|
9481
9540
|
}
|
|
9482
9541
|
if (/timeout|timed out/.test(lower)) {
|
|
9483
|
-
return { state:
|
|
9542
|
+
return { state: "UNKNOWN", message: message || "Ledger request timed out", rejected: false, timeout: true };
|
|
9484
9543
|
}
|
|
9485
9544
|
if (statusCode === 26628 || /locked|pin/.test(lower)) {
|
|
9486
|
-
return { state:
|
|
9545
|
+
return { state: "LOCKED", message: "Ledger is locked. Please unlock your Ledger device.", rejected: false, timeout: false };
|
|
9487
9546
|
}
|
|
9488
9547
|
if ([28160, 25873, 25871].includes(statusCode ?? 0) || /app.*open|xrp.*app|cla_not_supported/.test(lower)) {
|
|
9489
|
-
return { state:
|
|
9548
|
+
return { state: "APP_NOT_OPEN", message: "Please open the XRP app on your Ledger device.", rejected: false, timeout: false };
|
|
9490
9549
|
}
|
|
9491
9550
|
if (/no device|not found|disconnected|cannot open device|transport/i.test(message)) {
|
|
9492
|
-
return { state:
|
|
9551
|
+
return { state: "NOT_CONNECTED", message: "Ledger device not found. Please connect and unlock your Ledger device.", rejected: false, timeout: false };
|
|
9493
9552
|
}
|
|
9494
|
-
return { state:
|
|
9553
|
+
return { state: "UNKNOWN", message: message || "Unknown Ledger error", rejected: false, timeout: false };
|
|
9495
9554
|
}
|
|
9496
9555
|
function getLedgerErrorMessage(error) {
|
|
9497
|
-
if (error instanceof Error)
|
|
9498
|
-
|
|
9499
|
-
if (typeof error === "string")
|
|
9500
|
-
return error;
|
|
9556
|
+
if (error instanceof Error) return error.message;
|
|
9557
|
+
if (typeof error === "string") return error;
|
|
9501
9558
|
try {
|
|
9502
9559
|
return JSON.stringify(error);
|
|
9503
9560
|
} catch {
|
|
@@ -9505,8 +9562,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9505
9562
|
}
|
|
9506
9563
|
}
|
|
9507
9564
|
function getLedgerStatusCode(error) {
|
|
9508
|
-
if (!error || typeof error !== "object")
|
|
9509
|
-
return void 0;
|
|
9565
|
+
if (!error || typeof error !== "object") return void 0;
|
|
9510
9566
|
const value = error.statusCode ?? error.status;
|
|
9511
9567
|
return typeof value === "number" ? value : void 0;
|
|
9512
9568
|
}
|
|
@@ -9604,12 +9660,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9604
9660
|
icon: BIFROST_ICON
|
|
9605
9661
|
}
|
|
9606
9662
|
];
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
})(
|
|
9663
|
+
var XRPLWalletConnectMethod = /* @__PURE__ */ ((XRPLWalletConnectMethod2) => {
|
|
9664
|
+
XRPLWalletConnectMethod2["SIGN_TRANSACTION"] = "xrpl_signTransaction";
|
|
9665
|
+
XRPLWalletConnectMethod2["SIGN_TRANSACTION_FOR"] = "xrpl_signTransactionFor";
|
|
9666
|
+
XRPLWalletConnectMethod2["SIGN_MESSAGE"] = "xrpl_signMessage";
|
|
9667
|
+
return XRPLWalletConnectMethod2;
|
|
9668
|
+
})(XRPLWalletConnectMethod || {});
|
|
9613
9669
|
const WALLETCONNECT_ICON = WALLETCONNECT_ICON$1;
|
|
9614
9670
|
const XRPL_NAMESPACE = "xrpl";
|
|
9615
9671
|
const USER_DISCONNECTED = { code: 6e3, message: "User disconnected" };
|
|
@@ -9619,8 +9675,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9619
9675
|
const WALLETCONNECT_REQUEST_TIMEOUT_CODE = "WALLETCONNECT_REQUEST_TIMEOUT";
|
|
9620
9676
|
function isMobile$1() {
|
|
9621
9677
|
var _a2;
|
|
9622
|
-
if (typeof navigator === "undefined")
|
|
9623
|
-
return false;
|
|
9678
|
+
if (typeof navigator === "undefined") return false;
|
|
9624
9679
|
const userAgent = navigator.userAgent;
|
|
9625
9680
|
const platform = navigator.platform;
|
|
9626
9681
|
const maxTouchPoints = navigator.maxTouchPoints ?? 0;
|
|
@@ -9668,8 +9723,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9668
9723
|
}
|
|
9669
9724
|
async preInitialize(network) {
|
|
9670
9725
|
var _a2, _b, _c, _d;
|
|
9671
|
-
if (this.pendingConnection)
|
|
9672
|
-
return;
|
|
9726
|
+
if (this.pendingConnection) return;
|
|
9673
9727
|
try {
|
|
9674
9728
|
const client2 = await this.getClient();
|
|
9675
9729
|
const resolvedNetwork = this.requireNetwork(network);
|
|
@@ -9741,10 +9795,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9741
9795
|
const client2 = await this.getClient();
|
|
9742
9796
|
const topic = typeof ((_a2 = session.metadata) == null ? void 0 : _a2.topic) === "string" ? session.metadata.topic : void 0;
|
|
9743
9797
|
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;
|
|
9798
|
+
if (!restoredSession) return null;
|
|
9799
|
+
if (restoredSession.expiry && restoredSession.expiry * 1e3 <= Date.now()) return null;
|
|
9748
9800
|
this.session = restoredSession;
|
|
9749
9801
|
this.activeNetwork = network;
|
|
9750
9802
|
this.setupEventListeners();
|
|
@@ -9763,8 +9815,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9763
9815
|
}
|
|
9764
9816
|
async recoverSession(options) {
|
|
9765
9817
|
const network = this.requireNetwork(options.network);
|
|
9766
|
-
if (!await this.canRecoverSession())
|
|
9767
|
-
return null;
|
|
9818
|
+
if (!await this.canRecoverSession()) return null;
|
|
9768
9819
|
const client2 = await this.getClient();
|
|
9769
9820
|
const recoveredSession = this.findLatestStoredWalletConnectSession(client2, network);
|
|
9770
9821
|
this.debug("recover_session_check", "modal", {
|
|
@@ -9772,8 +9823,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9772
9823
|
recovered: Boolean(recoveredSession),
|
|
9773
9824
|
network: network.id
|
|
9774
9825
|
});
|
|
9775
|
-
if (!recoveredSession)
|
|
9776
|
-
return null;
|
|
9826
|
+
if (!recoveredSession) return null;
|
|
9777
9827
|
this.clearPendingRecoveryMarker();
|
|
9778
9828
|
this.session = recoveredSession;
|
|
9779
9829
|
this.activeNetwork = network;
|
|
@@ -9796,8 +9846,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9796
9846
|
return this.shouldRecoverWithoutStoredSession() && await this.hasPendingRecoveryMarker();
|
|
9797
9847
|
}
|
|
9798
9848
|
async disconnect() {
|
|
9799
|
-
if (!this.client || !this.session)
|
|
9800
|
-
return;
|
|
9849
|
+
if (!this.client || !this.session) return;
|
|
9801
9850
|
try {
|
|
9802
9851
|
await this.client.disconnect({
|
|
9803
9852
|
topic: this.session.topic,
|
|
@@ -9843,8 +9892,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9843
9892
|
getSignMessageRequestPreview(request) {
|
|
9844
9893
|
var _a2, _b;
|
|
9845
9894
|
const network = this.requireNetwork(this.activeNetwork);
|
|
9846
|
-
const method = this.sessionSupportsMethod(
|
|
9847
|
-
|
|
9895
|
+
const method = this.sessionSupportsMethod(
|
|
9896
|
+
"xrpl_signMessage"
|
|
9897
|
+
/* SIGN_MESSAGE */
|
|
9898
|
+
) ? "xrpl_signMessage" : "xrpl_signTransaction";
|
|
9899
|
+
const params = method === "xrpl_signMessage" ? {
|
|
9848
9900
|
message: request.message,
|
|
9849
9901
|
account: (_a2 = request.account) == null ? void 0 : _a2.address
|
|
9850
9902
|
} : {
|
|
@@ -9865,46 +9917,37 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9865
9917
|
return ((_b = (_a2 = this.options).deeplink) == null ? void 0 : _b.call(_a2, uri)) ?? uri;
|
|
9866
9918
|
}
|
|
9867
9919
|
findStoredWalletConnectSession(client2, topic, network, address) {
|
|
9868
|
-
if (!this.hasSessionStore(client2))
|
|
9869
|
-
return void 0;
|
|
9920
|
+
if (!this.hasSessionStore(client2)) return void 0;
|
|
9870
9921
|
if (topic) {
|
|
9871
9922
|
try {
|
|
9872
9923
|
const stored = client2.session.get(topic);
|
|
9873
|
-
if (this.sessionMatchesWalletProfile(stored) && this.sessionHasNetworkAccount(stored, network, address))
|
|
9874
|
-
return stored;
|
|
9924
|
+
if (this.sessionMatchesWalletProfile(stored) && this.sessionHasNetworkAccount(stored, network, address)) return stored;
|
|
9875
9925
|
} catch {
|
|
9876
9926
|
}
|
|
9877
9927
|
}
|
|
9878
9928
|
const sessions = client2.session.getAll();
|
|
9879
9929
|
return sessions.find((storedSession) => {
|
|
9880
9930
|
var _a2;
|
|
9881
|
-
if (!this.sessionMatchesWalletProfile(storedSession))
|
|
9882
|
-
return false;
|
|
9931
|
+
if (!this.sessionMatchesWalletProfile(storedSession)) return false;
|
|
9883
9932
|
const accounts = ((_a2 = storedSession.namespaces[XRPL_NAMESPACE]) == null ? void 0 : _a2.accounts) ?? [];
|
|
9884
9933
|
const chainId = this.requireWalletConnectChainId(network);
|
|
9885
9934
|
return accounts.some((account) => account === `${chainId}:${address}` || account.endsWith(`:${address}`));
|
|
9886
9935
|
});
|
|
9887
9936
|
}
|
|
9888
9937
|
findLatestStoredWalletConnectSession(client2, network) {
|
|
9889
|
-
if (!this.hasSessionStore(client2))
|
|
9890
|
-
return void 0;
|
|
9938
|
+
if (!this.hasSessionStore(client2)) return void 0;
|
|
9891
9939
|
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;
|
|
9940
|
+
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now()) return false;
|
|
9941
|
+
if (!this.sessionMatchesWalletProfile(storedSession)) return false;
|
|
9896
9942
|
return this.sessionHasNetworkAccount(storedSession, network);
|
|
9897
9943
|
}).sort((a2, b2) => (b2.expiry ?? 0) - (a2.expiry ?? 0));
|
|
9898
9944
|
return sessions[0];
|
|
9899
9945
|
}
|
|
9900
9946
|
findLatestStoredWalletConnectSessionForAddress(client2, network, address) {
|
|
9901
|
-
if (!this.hasSessionStore(client2))
|
|
9902
|
-
return void 0;
|
|
9947
|
+
if (!this.hasSessionStore(client2)) return void 0;
|
|
9903
9948
|
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;
|
|
9949
|
+
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now()) return false;
|
|
9950
|
+
if (!this.sessionMatchesWalletProfile(storedSession)) return false;
|
|
9908
9951
|
return this.sessionHasNetworkAccount(storedSession, network, address);
|
|
9909
9952
|
}).sort((a2, b2) => (b2.expiry ?? 0) - (a2.expiry ?? 0));
|
|
9910
9953
|
return sessions[0];
|
|
@@ -9913,8 +9956,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9913
9956
|
return this.metadata.type === "walletconnect";
|
|
9914
9957
|
}
|
|
9915
9958
|
async getClient() {
|
|
9916
|
-
if (this.client)
|
|
9917
|
-
return this.client;
|
|
9959
|
+
if (this.client) return this.client;
|
|
9918
9960
|
if (!this.initializationPromise) {
|
|
9919
9961
|
this.initializationPromise = Promise.resolve().then(() => index$2).then(({ default: SignClient }) => SignClient.init({
|
|
9920
9962
|
projectId: this.options.projectId,
|
|
@@ -9925,8 +9967,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9925
9967
|
return this.client;
|
|
9926
9968
|
}
|
|
9927
9969
|
async initializeModal() {
|
|
9928
|
-
if (this.modal)
|
|
9929
|
-
return this.modal;
|
|
9970
|
+
if (this.modal) return this.modal;
|
|
9930
9971
|
const { WalletConnectModal: WalletConnectModal2 } = await Promise.resolve().then(() => index$1);
|
|
9931
9972
|
this.modal = new WalletConnectModal2({
|
|
9932
9973
|
projectId: this.options.projectId,
|
|
@@ -9955,8 +9996,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
9955
9996
|
}
|
|
9956
9997
|
this.pendingConnection = void 0;
|
|
9957
9998
|
this.throwIfAborted(signal);
|
|
9958
|
-
if (!connection2.uri)
|
|
9959
|
-
throw new Error("WalletConnect did not return a connection URI");
|
|
9999
|
+
if (!connection2.uri) throw new Error("WalletConnect did not return a connection URI");
|
|
9960
10000
|
let didOpen = false;
|
|
9961
10001
|
let rejectModalClose;
|
|
9962
10002
|
const modalClosed = new Promise((_2, reject) => {
|
|
@@ -10004,8 +10044,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10004
10044
|
optionalNamespaces: this.createOptionalNamespaces(network)
|
|
10005
10045
|
});
|
|
10006
10046
|
this.throwIfAborted(signal);
|
|
10007
|
-
if (!result.uri)
|
|
10008
|
-
throw new Error("WalletConnect did not return a connection URI");
|
|
10047
|
+
if (!result.uri) throw new Error("WalletConnect did not return a connection URI");
|
|
10009
10048
|
connection2 = { uri: result.uri, approval: result.approval, existingTopics };
|
|
10010
10049
|
}
|
|
10011
10050
|
this.throwIfAborted(signal);
|
|
@@ -10031,10 +10070,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10031
10070
|
let timeoutTimer;
|
|
10032
10071
|
let checkCount = 0;
|
|
10033
10072
|
const cleanup = () => {
|
|
10034
|
-
if (timer)
|
|
10035
|
-
|
|
10036
|
-
if (timeoutTimer)
|
|
10037
|
-
clearTimeout(timeoutTimer);
|
|
10073
|
+
if (timer) clearInterval(timer);
|
|
10074
|
+
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
10038
10075
|
if (typeof window !== "undefined") {
|
|
10039
10076
|
window.removeEventListener("focus", check);
|
|
10040
10077
|
window.removeEventListener("pageshow", check);
|
|
@@ -10042,8 +10079,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10042
10079
|
}
|
|
10043
10080
|
};
|
|
10044
10081
|
const settle = (callback) => {
|
|
10045
|
-
if (settled)
|
|
10046
|
-
return;
|
|
10082
|
+
if (settled) return;
|
|
10047
10083
|
settled = true;
|
|
10048
10084
|
cleanup();
|
|
10049
10085
|
callback();
|
|
@@ -10090,12 +10126,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10090
10126
|
});
|
|
10091
10127
|
check();
|
|
10092
10128
|
if (!settled) {
|
|
10093
|
-
if (!options.rejectOnApprovalError)
|
|
10094
|
-
return;
|
|
10129
|
+
if (!options.rejectOnApprovalError) return;
|
|
10095
10130
|
setTimeout(() => {
|
|
10096
10131
|
check();
|
|
10097
|
-
if (!settled)
|
|
10098
|
-
settle(() => reject(error));
|
|
10132
|
+
if (!settled) settle(() => reject(error));
|
|
10099
10133
|
}, 1500);
|
|
10100
10134
|
}
|
|
10101
10135
|
});
|
|
@@ -10123,10 +10157,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10123
10157
|
}
|
|
10124
10158
|
findNewWalletConnectSession(client2, network, existingTopics) {
|
|
10125
10159
|
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;
|
|
10160
|
+
if (existingTopics.has(storedSession.topic)) return false;
|
|
10161
|
+
if (storedSession.expiry && storedSession.expiry * 1e3 <= Date.now()) return false;
|
|
10130
10162
|
return this.sessionHasNetworkAccount(storedSession, network);
|
|
10131
10163
|
});
|
|
10132
10164
|
}
|
|
@@ -10140,8 +10172,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10140
10172
|
});
|
|
10141
10173
|
}
|
|
10142
10174
|
throwIfAborted(signal) {
|
|
10143
|
-
if (signal == null ? void 0 : signal.aborted)
|
|
10144
|
-
throw new Error("WalletConnect connection was cancelled");
|
|
10175
|
+
if (signal == null ? void 0 : signal.aborted) throw new Error("WalletConnect connection was cancelled");
|
|
10145
10176
|
}
|
|
10146
10177
|
combineSignals(first, second) {
|
|
10147
10178
|
const controller = new AbortController();
|
|
@@ -10159,20 +10190,16 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10159
10190
|
const accounts = ((_a2 = session.namespaces[XRPL_NAMESPACE]) == null ? void 0 : _a2.accounts) ?? [];
|
|
10160
10191
|
const chainId = this.requireWalletConnectChainId(network);
|
|
10161
10192
|
return accounts.some((account) => {
|
|
10162
|
-
if (!account.startsWith(`${chainId}:`))
|
|
10163
|
-
return false;
|
|
10193
|
+
if (!account.startsWith(`${chainId}:`)) return false;
|
|
10164
10194
|
return !address || account === `${chainId}:${address}` || account.endsWith(`:${address}`);
|
|
10165
10195
|
});
|
|
10166
10196
|
}
|
|
10167
10197
|
sessionMatchesWalletProfile(session) {
|
|
10168
|
-
if (this.metadata.id === "walletconnect")
|
|
10169
|
-
return true;
|
|
10198
|
+
if (this.metadata.id === "walletconnect") return true;
|
|
10170
10199
|
const peerName = this.normalizeWalletName(this.getSessionPeerName(session));
|
|
10171
|
-
if (!peerName)
|
|
10172
|
-
return true;
|
|
10200
|
+
if (!peerName) return true;
|
|
10173
10201
|
const expectedName = this.normalizeWalletName(this.options.name ?? this.metadata.name);
|
|
10174
|
-
if (!expectedName)
|
|
10175
|
-
return true;
|
|
10202
|
+
if (!expectedName) return true;
|
|
10176
10203
|
return peerName === expectedName || peerName.includes(expectedName) || expectedName.includes(peerName);
|
|
10177
10204
|
}
|
|
10178
10205
|
getSessionPeerName(session) {
|
|
@@ -10192,9 +10219,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10192
10219
|
[XRPL_NAMESPACE]: {
|
|
10193
10220
|
chains: [chainId],
|
|
10194
10221
|
methods: [
|
|
10195
|
-
|
|
10222
|
+
"xrpl_signTransaction",
|
|
10196
10223
|
// moved from requiredNamespaces
|
|
10197
|
-
|
|
10224
|
+
"xrpl_signTransactionFor"
|
|
10225
|
+
/* SIGN_TRANSACTION_FOR */
|
|
10198
10226
|
],
|
|
10199
10227
|
events: []
|
|
10200
10228
|
}
|
|
@@ -10202,13 +10230,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10202
10230
|
}
|
|
10203
10231
|
async signMessageWithWalletConnectMethod(network, request) {
|
|
10204
10232
|
var _a2, _b, _c;
|
|
10205
|
-
if (!this.client || !this.session)
|
|
10206
|
-
throw new Error("WalletConnect session not found");
|
|
10233
|
+
if (!this.client || !this.session) throw new Error("WalletConnect session not found");
|
|
10207
10234
|
return this.withRequestTimeout(this.client.request({
|
|
10208
10235
|
chainId: this.requireWalletConnectChainId(network),
|
|
10209
10236
|
topic: this.session.topic,
|
|
10210
10237
|
request: {
|
|
10211
|
-
method:
|
|
10238
|
+
method: "xrpl_signMessage",
|
|
10212
10239
|
params: {
|
|
10213
10240
|
message: request.message,
|
|
10214
10241
|
account: (_a2 = request.account) == null ? void 0 : _a2.address,
|
|
@@ -10216,7 +10243,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10216
10243
|
from: (_c = request.account) == null ? void 0 : _c.address
|
|
10217
10244
|
}
|
|
10218
10245
|
}
|
|
10219
|
-
}),
|
|
10246
|
+
}), "xrpl_signMessage", this.getSignOnlyRequestTimeoutMs());
|
|
10220
10247
|
}
|
|
10221
10248
|
signatureResponsePaths() {
|
|
10222
10249
|
return [
|
|
@@ -10283,8 +10310,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10283
10310
|
}
|
|
10284
10311
|
async resolveTxBlobProof(result) {
|
|
10285
10312
|
const direct = this.pickString(result, this.txBlobResponsePaths());
|
|
10286
|
-
if (direct)
|
|
10287
|
-
return direct;
|
|
10313
|
+
if (direct) return direct;
|
|
10288
10314
|
const txJson = pickPath(result, [
|
|
10289
10315
|
"tx_json",
|
|
10290
10316
|
"txJson",
|
|
@@ -10302,10 +10328,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10302
10328
|
"response.data.resp.txJson",
|
|
10303
10329
|
"response.data.resp.transaction"
|
|
10304
10330
|
]);
|
|
10305
|
-
if (!txJson || typeof txJson !== "object")
|
|
10306
|
-
|
|
10307
|
-
if (!this.looksSignedTxJson(txJson))
|
|
10308
|
-
return void 0;
|
|
10331
|
+
if (!txJson || typeof txJson !== "object") return void 0;
|
|
10332
|
+
if (!this.looksSignedTxJson(txJson)) return void 0;
|
|
10309
10333
|
try {
|
|
10310
10334
|
const { encode: encode2 } = await Promise.resolve().then(() => index$4);
|
|
10311
10335
|
return encode2(txJson);
|
|
@@ -10318,8 +10342,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10318
10342
|
}
|
|
10319
10343
|
}
|
|
10320
10344
|
looksSignedTxJson(value) {
|
|
10321
|
-
if (!value || typeof value !== "object")
|
|
10322
|
-
return false;
|
|
10345
|
+
if (!value || typeof value !== "object") return false;
|
|
10323
10346
|
const tx = value;
|
|
10324
10347
|
return typeof tx.TransactionType === "string" && typeof tx.Account === "string" && typeof tx.SigningPubKey === "string" && typeof tx.TxnSignature === "string";
|
|
10325
10348
|
}
|
|
@@ -10343,37 +10366,34 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10343
10366
|
if (Array.isArray(value)) {
|
|
10344
10367
|
return value.map((item) => this.sanitizeWalletConnectPayload(item)).filter((item) => item !== void 0);
|
|
10345
10368
|
}
|
|
10346
|
-
if (!value || typeof value !== "object")
|
|
10347
|
-
return value;
|
|
10369
|
+
if (!value || typeof value !== "object") return value;
|
|
10348
10370
|
const output = {};
|
|
10349
10371
|
for (const [key, item] of Object.entries(value)) {
|
|
10350
|
-
if (item === void 0 || item === null)
|
|
10351
|
-
continue;
|
|
10372
|
+
if (item === void 0 || item === null) continue;
|
|
10352
10373
|
const sanitized = this.sanitizeWalletConnectPayload(item);
|
|
10353
|
-
if (sanitized !== void 0)
|
|
10354
|
-
output[key] = sanitized;
|
|
10374
|
+
if (sanitized !== void 0) output[key] = sanitized;
|
|
10355
10375
|
}
|
|
10356
10376
|
return output;
|
|
10357
10377
|
}
|
|
10358
10378
|
async requestSignTransaction(network, txJson, submit2) {
|
|
10359
|
-
if (!this.client || !this.session)
|
|
10360
|
-
throw new Error("WalletConnect session not found");
|
|
10379
|
+
if (!this.client || !this.session) throw new Error("WalletConnect session not found");
|
|
10361
10380
|
const params = { tx_json: txJson };
|
|
10362
|
-
if (!submit2)
|
|
10363
|
-
params.submit = false;
|
|
10381
|
+
if (!submit2) params.submit = false;
|
|
10364
10382
|
return this.withRequestTimeout(this.client.request({
|
|
10365
10383
|
chainId: this.requireWalletConnectChainId(network),
|
|
10366
10384
|
topic: this.session.topic,
|
|
10367
10385
|
request: {
|
|
10368
|
-
method:
|
|
10386
|
+
method: "xrpl_signTransaction",
|
|
10369
10387
|
params
|
|
10370
10388
|
}
|
|
10371
|
-
}),
|
|
10389
|
+
}), "xrpl_signTransaction", this.getTransactionRequestTimeoutMs(submit2));
|
|
10372
10390
|
}
|
|
10373
10391
|
async requestSignOnlyTransaction(network, txJson) {
|
|
10374
|
-
if (!this.client || !this.session)
|
|
10375
|
-
|
|
10376
|
-
|
|
10392
|
+
if (!this.client || !this.session) throw new Error("WalletConnect session not found");
|
|
10393
|
+
const method = this.sessionSupportsMethod(
|
|
10394
|
+
"xrpl_signTransactionFor"
|
|
10395
|
+
/* SIGN_TRANSACTION_FOR */
|
|
10396
|
+
) ? "xrpl_signTransactionFor" : "xrpl_signTransaction";
|
|
10377
10397
|
return this.withRequestTimeout(this.client.request({
|
|
10378
10398
|
chainId: this.requireWalletConnectChainId(network),
|
|
10379
10399
|
topic: this.session.topic,
|
|
@@ -10396,8 +10416,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10396
10416
|
return /missing or invalid.*request\(\).*method|method.*not.*supported|unsupported.*method/i.test(message);
|
|
10397
10417
|
}
|
|
10398
10418
|
requireSession() {
|
|
10399
|
-
if (!this.session)
|
|
10400
|
-
throw new Error("WalletConnect session not found");
|
|
10419
|
+
if (!this.session) throw new Error("WalletConnect session not found");
|
|
10401
10420
|
return this.session;
|
|
10402
10421
|
}
|
|
10403
10422
|
getSignOnlyRequestTimeoutMs() {
|
|
@@ -10424,7 +10443,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10424
10443
|
wallet: this.metadata.id,
|
|
10425
10444
|
timeoutMs
|
|
10426
10445
|
});
|
|
10427
|
-
const timeoutDetail = method ===
|
|
10446
|
+
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
10447
|
const error = new Error(`WalletConnect request timed out after ${timeoutMs}ms: ${method}. ${timeoutDetail}`);
|
|
10429
10448
|
error.code = WALLETCONNECT_REQUEST_TIMEOUT_CODE;
|
|
10430
10449
|
reject(error);
|
|
@@ -10445,8 +10464,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10445
10464
|
}
|
|
10446
10465
|
throw error;
|
|
10447
10466
|
} finally {
|
|
10448
|
-
if (timer)
|
|
10449
|
-
clearTimeout(timer);
|
|
10467
|
+
if (timer) clearTimeout(timer);
|
|
10450
10468
|
}
|
|
10451
10469
|
}
|
|
10452
10470
|
async handleStaleWalletConnectRequest(method, error) {
|
|
@@ -10479,12 +10497,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10479
10497
|
async clearWalletConnectPairings() {
|
|
10480
10498
|
var _a2, _b;
|
|
10481
10499
|
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;
|
|
10500
|
+
if (!(pairing == null ? void 0 : pairing.getPairings) || !pairing.disconnect) return;
|
|
10484
10501
|
const pairings = pairing.getPairings();
|
|
10485
10502
|
for (const item of pairings) {
|
|
10486
|
-
if (!item.topic)
|
|
10487
|
-
continue;
|
|
10503
|
+
if (!item.topic) continue;
|
|
10488
10504
|
try {
|
|
10489
10505
|
await pairing.disconnect({ topic: item.topic });
|
|
10490
10506
|
} catch {
|
|
@@ -10492,38 +10508,32 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10492
10508
|
}
|
|
10493
10509
|
}
|
|
10494
10510
|
shouldUseModal() {
|
|
10495
|
-
if (!this.options.useModal || this.options.modalMode === "never")
|
|
10496
|
-
return false;
|
|
10511
|
+
if (!this.options.useModal || this.options.modalMode === "never") return false;
|
|
10497
10512
|
const mode2 = this.options.modalMode ?? "mobile-only";
|
|
10498
10513
|
return mode2 === "always" || mode2 === "mobile-only" && isMobile$1();
|
|
10499
10514
|
}
|
|
10500
10515
|
extractAddress(session, network) {
|
|
10501
10516
|
var _a2, _b;
|
|
10502
10517
|
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");
|
|
10518
|
+
if (!account) throw new Error("WalletConnect XRPL account not found in session");
|
|
10505
10519
|
const parts = account.split(":");
|
|
10506
10520
|
const chainId = this.requireWalletConnectChainId(network);
|
|
10507
10521
|
return parts[2] ?? account.replace(`${chainId}:`, "");
|
|
10508
10522
|
}
|
|
10509
10523
|
setupEventListeners() {
|
|
10510
|
-
if (!this.client)
|
|
10511
|
-
return;
|
|
10524
|
+
if (!this.client) return;
|
|
10512
10525
|
void this.runCleanup();
|
|
10513
10526
|
const onSessionDelete = (event) => {
|
|
10514
10527
|
var _a2;
|
|
10515
|
-
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic))
|
|
10516
|
-
this.cleanup();
|
|
10528
|
+
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic)) this.cleanup();
|
|
10517
10529
|
};
|
|
10518
10530
|
const onSessionExpire = (event) => {
|
|
10519
10531
|
var _a2;
|
|
10520
|
-
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic))
|
|
10521
|
-
this.cleanup();
|
|
10532
|
+
if (!(event == null ? void 0 : event.topic) || event.topic === ((_a2 = this.session) == null ? void 0 : _a2.topic)) this.cleanup();
|
|
10522
10533
|
};
|
|
10523
10534
|
const onSessionUpdate = (event) => {
|
|
10524
10535
|
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;
|
|
10536
|
+
if (!this.client || !(event == null ? void 0 : event.topic) || event.topic !== ((_a2 = this.session) == null ? void 0 : _a2.topic)) return;
|
|
10527
10537
|
try {
|
|
10528
10538
|
this.session = this.client.session.get(event.topic);
|
|
10529
10539
|
this.debug("session_update", "custom", { topic: event.topic });
|
|
@@ -10559,8 +10569,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10559
10569
|
if (currentTopic) {
|
|
10560
10570
|
try {
|
|
10561
10571
|
const stored = client2.session.get(currentTopic);
|
|
10562
|
-
if (this.sessionHasNetworkAccount(stored, network, address))
|
|
10563
|
-
refreshed = stored;
|
|
10572
|
+
if (this.sessionHasNetworkAccount(stored, network, address)) refreshed = stored;
|
|
10564
10573
|
} catch {
|
|
10565
10574
|
refreshed = void 0;
|
|
10566
10575
|
}
|
|
@@ -10585,7 +10594,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10585
10594
|
pairingTopic: refreshed.pairingTopic
|
|
10586
10595
|
});
|
|
10587
10596
|
this.session = refreshed;
|
|
10588
|
-
await this.handleStaleWalletConnectRequest(
|
|
10597
|
+
await this.handleStaleWalletConnectRequest("xrpl_signTransaction", new Error("WalletConnect session pairing not found"));
|
|
10589
10598
|
}
|
|
10590
10599
|
if (refreshed.topic !== ((_b = this.session) == null ? void 0 : _b.topic)) {
|
|
10591
10600
|
this.debug("request_session_refreshed", "custom", {
|
|
@@ -10604,11 +10613,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10604
10613
|
isSessionPairingStale(session) {
|
|
10605
10614
|
var _a2, _b;
|
|
10606
10615
|
const pairingTopic = session.pairingTopic;
|
|
10607
|
-
if (!pairingTopic)
|
|
10608
|
-
return false;
|
|
10616
|
+
if (!pairingTopic) return false;
|
|
10609
10617
|
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;
|
|
10618
|
+
if (!(pairing == null ? void 0 : pairing.getPairings)) return false;
|
|
10612
10619
|
try {
|
|
10613
10620
|
return !pairing.getPairings().some((item) => item.topic === pairingTopic);
|
|
10614
10621
|
} catch {
|
|
@@ -10633,8 +10640,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10633
10640
|
return `xwk.walletconnect.pending.${this.options.projectId}.${this.metadata.id}`;
|
|
10634
10641
|
}
|
|
10635
10642
|
async setPendingRecoveryMarker() {
|
|
10636
|
-
if (!this.shouldRecoverWithoutStoredSession())
|
|
10637
|
-
return;
|
|
10643
|
+
if (!this.shouldRecoverWithoutStoredSession()) return;
|
|
10638
10644
|
try {
|
|
10639
10645
|
await this.recoveryStorage.setItem(this.getPendingRecoveryKey(), String(Date.now()));
|
|
10640
10646
|
} catch {
|
|
@@ -10643,8 +10649,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10643
10649
|
async hasPendingRecoveryMarker() {
|
|
10644
10650
|
try {
|
|
10645
10651
|
const value = await this.recoveryStorage.getItem(this.getPendingRecoveryKey());
|
|
10646
|
-
if (!value)
|
|
10647
|
-
return false;
|
|
10652
|
+
if (!value) return false;
|
|
10648
10653
|
const timestamp = Number(value);
|
|
10649
10654
|
if (!Number.isFinite(timestamp) || Date.now() - timestamp > PENDING_RECOVERY_TTL_MS) {
|
|
10650
10655
|
this.clearPendingRecoveryMarker();
|
|
@@ -10662,8 +10667,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10662
10667
|
}
|
|
10663
10668
|
}
|
|
10664
10669
|
requireNetwork(network) {
|
|
10665
|
-
if (!network)
|
|
10666
|
-
throw new Error("XRPL network is required for WalletConnect");
|
|
10670
|
+
if (!network) throw new Error("XRPL network is required for WalletConnect");
|
|
10667
10671
|
return network;
|
|
10668
10672
|
}
|
|
10669
10673
|
requireWalletConnectChainId(network) {
|
|
@@ -10673,8 +10677,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10673
10677
|
return network.walletConnectChainId;
|
|
10674
10678
|
}
|
|
10675
10679
|
removeWalletConnectModalElements() {
|
|
10676
|
-
if (typeof document === "undefined")
|
|
10677
|
-
return;
|
|
10680
|
+
if (typeof document === "undefined") return;
|
|
10678
10681
|
window.setTimeout(() => {
|
|
10679
10682
|
document.querySelectorAll("wcm-modal").forEach((element) => element.remove());
|
|
10680
10683
|
}, 0);
|
|
@@ -15686,8 +15689,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15686
15689
|
await this.setPendingRecoveryMarker();
|
|
15687
15690
|
try {
|
|
15688
15691
|
const result = await this.withAbort(this.authorize(), options.signal);
|
|
15689
|
-
if (result instanceof Error)
|
|
15690
|
-
throw result;
|
|
15692
|
+
if (result instanceof Error) throw result;
|
|
15691
15693
|
const connectResult = await this.createConnectResultFromAuth(result, options);
|
|
15692
15694
|
this.clearPendingRecoveryMarker();
|
|
15693
15695
|
return connectResult;
|
|
@@ -15703,8 +15705,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15703
15705
|
this.auth = this.sdk;
|
|
15704
15706
|
}
|
|
15705
15707
|
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;
|
|
15708
|
+
if (!((_a2 = state2 == null ? void 0 : state2.account) == null ? void 0 : _a2.address) || state2.account.address !== session.account.address) return null;
|
|
15708
15709
|
const account = ((_b = state2 == null ? void 0 : state2.account) == null ? void 0 : _b.address) ? { ...session.account, ...state2.account } : session.account;
|
|
15709
15710
|
return { account, session: { ...session, account }, raw: (state2 == null ? void 0 : state2.raw) ?? null };
|
|
15710
15711
|
}
|
|
@@ -15712,8 +15713,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15712
15713
|
return this.hasPendingRecoveryMarker();
|
|
15713
15714
|
}
|
|
15714
15715
|
async recoverSession(options) {
|
|
15715
|
-
if (!await this.hasPendingRecoveryMarker())
|
|
15716
|
-
return null;
|
|
15716
|
+
if (!await this.hasPendingRecoveryMarker()) return null;
|
|
15717
15717
|
try {
|
|
15718
15718
|
const result = await this.withAbort(this.authorize(), options.signal);
|
|
15719
15719
|
if (!result || result instanceof Error) {
|
|
@@ -15734,7 +15734,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15734
15734
|
async disconnect() {
|
|
15735
15735
|
var _a2;
|
|
15736
15736
|
try {
|
|
15737
|
-
const logoutTargets = [this.sdk, this.auth].filter(
|
|
15737
|
+
const logoutTargets = [this.sdk, this.auth].filter(
|
|
15738
|
+
(target, index2, targets) => Boolean(target) && targets.indexOf(target) === index2
|
|
15739
|
+
);
|
|
15738
15740
|
for (const target of logoutTargets) {
|
|
15739
15741
|
await ((_a2 = target.logout) == null ? void 0 : _a2.call(target));
|
|
15740
15742
|
}
|
|
@@ -15756,8 +15758,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15756
15758
|
options: { submit: false }
|
|
15757
15759
|
};
|
|
15758
15760
|
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);
|
|
15761
|
+
if (!((_a2 = result == null ? void 0 : result.meta) == null ? void 0 : _a2.signed)) throw createWalletError.signRejected(result);
|
|
15761
15762
|
return {
|
|
15762
15763
|
signatureKind: "signedTx",
|
|
15763
15764
|
proof: ((_b = result.response) == null ? void 0 : _b.hex) ?? void 0,
|
|
@@ -15780,13 +15781,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15780
15781
|
}
|
|
15781
15782
|
async checkXamanState(options = {}) {
|
|
15782
15783
|
var _a2, _b, _c, _d;
|
|
15783
|
-
if (!this.sdk)
|
|
15784
|
-
return null;
|
|
15784
|
+
if (!this.sdk) return null;
|
|
15785
15785
|
await this.waitForSdkReady(this.sdk);
|
|
15786
15786
|
const openid = await this.resolveSdkValue((_a2 = this.sdk.environment) == null ? void 0 : _a2.openid);
|
|
15787
15787
|
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;
|
|
15788
|
+
if (!accountAddress) return null;
|
|
15790
15789
|
return {
|
|
15791
15790
|
account: {
|
|
15792
15791
|
address: accountAddress,
|
|
@@ -15800,28 +15799,24 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15800
15799
|
};
|
|
15801
15800
|
}
|
|
15802
15801
|
requireSdk() {
|
|
15803
|
-
if (!this.sdk)
|
|
15804
|
-
throw new Error("Xaman SDK is not available. Connect Xaman first.");
|
|
15802
|
+
if (!this.sdk) throw new Error("Xaman SDK is not available. Connect Xaman first.");
|
|
15805
15803
|
return this.sdk;
|
|
15806
15804
|
}
|
|
15807
15805
|
async authorize() {
|
|
15808
15806
|
if (!this.auth) {
|
|
15809
|
-
if (!this.options.apiKey)
|
|
15810
|
-
throw new Error("Xaman apiKey is required when auth is not injected");
|
|
15807
|
+
if (!this.options.apiKey) throw new Error("Xaman apiKey is required when auth is not injected");
|
|
15811
15808
|
this.sdk = new distExports.Xumm(this.options.apiKey);
|
|
15812
15809
|
this.auth = this.sdk;
|
|
15813
15810
|
}
|
|
15814
15811
|
const result = await this.auth.authorize();
|
|
15815
|
-
if (!result)
|
|
15816
|
-
throw new Error("Xaman authorization was cancelled");
|
|
15812
|
+
if (!result) throw new Error("Xaman authorization was cancelled");
|
|
15817
15813
|
return result;
|
|
15818
15814
|
}
|
|
15819
15815
|
async createConnectResultFromAuth(result, options) {
|
|
15820
15816
|
var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l;
|
|
15821
15817
|
this.sdk = result.sdk ?? this.sdk;
|
|
15822
15818
|
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");
|
|
15819
|
+
if (!accountAddress) throw new Error("Xaman did not return an XRPL account");
|
|
15825
15820
|
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
15821
|
const account = { address: accountAddress, network: options.network, networkType };
|
|
15827
15822
|
return {
|
|
@@ -15860,8 +15855,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15860
15855
|
emitPayloadQr(created) {
|
|
15861
15856
|
var _a2, _b, _c, _d, _e2, _f, _g, _h;
|
|
15862
15857
|
const uri = ((_a2 = created.next) == null ? void 0 : _a2.always) ?? ((_b = created.refs) == null ? void 0 : _b.qr_png);
|
|
15863
|
-
if (!uri)
|
|
15864
|
-
return;
|
|
15858
|
+
if (!uri) return;
|
|
15865
15859
|
(_h = (_g = this.options).onQr) == null ? void 0 : _h.call(_g, {
|
|
15866
15860
|
adapterId: this.metadata.id,
|
|
15867
15861
|
uri,
|
|
@@ -15879,8 +15873,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15879
15873
|
(_b = sdk.environment) == null ? void 0 : _b.retrieved,
|
|
15880
15874
|
(_c = sdk.environment) == null ? void 0 : _c.success
|
|
15881
15875
|
].filter((signal) => Boolean(signal));
|
|
15882
|
-
if (!readySignals.length)
|
|
15883
|
-
return;
|
|
15876
|
+
if (!readySignals.length) return;
|
|
15884
15877
|
await Promise.race([
|
|
15885
15878
|
Promise.race(readySignals).then(() => void 0),
|
|
15886
15879
|
new Promise((resolve) => setTimeout(resolve, XAMAN_RESTORE_READY_TIMEOUT_MS))
|
|
@@ -15888,42 +15881,39 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15888
15881
|
}
|
|
15889
15882
|
clearPkceStorage() {
|
|
15890
15883
|
var _a2;
|
|
15891
|
-
if (typeof window === "undefined")
|
|
15892
|
-
return;
|
|
15884
|
+
if (typeof window === "undefined") return;
|
|
15893
15885
|
try {
|
|
15894
15886
|
(_a2 = window.localStorage) == null ? void 0 : _a2.removeItem("XummPkceJwt");
|
|
15895
15887
|
} catch {
|
|
15896
15888
|
}
|
|
15897
15889
|
}
|
|
15898
15890
|
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")));
|
|
15891
|
+
if (!signal) return promise;
|
|
15892
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
15903
15893
|
return new Promise((resolve, reject) => {
|
|
15904
15894
|
let settled = false;
|
|
15905
15895
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
15906
15896
|
const abort = () => {
|
|
15907
|
-
if (settled)
|
|
15908
|
-
return;
|
|
15897
|
+
if (settled) return;
|
|
15909
15898
|
settled = true;
|
|
15910
15899
|
cleanup();
|
|
15911
15900
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
15912
15901
|
};
|
|
15913
15902
|
signal.addEventListener("abort", abort, { once: true });
|
|
15914
|
-
promise.then(
|
|
15915
|
-
|
|
15916
|
-
return;
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
|
|
15922
|
-
return;
|
|
15923
|
-
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15903
|
+
promise.then(
|
|
15904
|
+
(value) => {
|
|
15905
|
+
if (settled) return;
|
|
15906
|
+
settled = true;
|
|
15907
|
+
cleanup();
|
|
15908
|
+
resolve(value);
|
|
15909
|
+
},
|
|
15910
|
+
(error) => {
|
|
15911
|
+
if (settled) return;
|
|
15912
|
+
settled = true;
|
|
15913
|
+
cleanup();
|
|
15914
|
+
reject(error);
|
|
15915
|
+
}
|
|
15916
|
+
);
|
|
15927
15917
|
});
|
|
15928
15918
|
}
|
|
15929
15919
|
getPendingRecoveryKey() {
|
|
@@ -15938,8 +15928,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15938
15928
|
async hasPendingRecoveryMarker() {
|
|
15939
15929
|
try {
|
|
15940
15930
|
const value = await this.recoveryStorage.getItem(this.getPendingRecoveryKey());
|
|
15941
|
-
if (!value)
|
|
15942
|
-
return false;
|
|
15931
|
+
if (!value) return false;
|
|
15943
15932
|
const timestamp = Number(value);
|
|
15944
15933
|
if (!Number.isFinite(timestamp) || Date.now() - timestamp > XAMAN_PENDING_RECOVERY_TTL_MS) {
|
|
15945
15934
|
this.clearPendingRecoveryMarker();
|
|
@@ -15962,6 +15951,13 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15962
15951
|
}
|
|
15963
15952
|
const METAMASK_ICON = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIGlkPSJMYXllcl8xIiB4PSIwIiB5PSIwIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzMTguNiAzMTguNiI+CiAgPHN0eWxlPgogICAgLnN0MSwuc3Q2e2ZpbGw6I2U0NzYxYjtzdHJva2U6I2U0NzYxYjtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmR9LnN0NntmaWxsOiNmNjg1MWI7c3Ryb2tlOiNmNjg1MWJ9CiAgPC9zdHlsZT4KICA8cGF0aCBmaWxsPSIjZTI3NjFiIiBzdHJva2U9IiNlMjc2MWIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTI3NC4xIDM1LjUtOTkuNSA3My45TDE5MyA2NS44eiIvPgogIDxwYXRoIGQ9Im00NC40IDM1LjUgOTguNyA3NC42LTE3LjUtNDQuM3ptMTkzLjkgMTcxLjMtMjYuNSA0MC42IDU2LjcgMTUuNiAxNi4zLTU1LjN6bS0yMDQuNC45TDUwLjEgMjYzbDU2LjctMTUuNi0yNi41LTQwLjZ6IiBjbGFzcz0ic3QxIi8+CiAgPHBhdGggZD0ibTEwMy42IDEzOC4yLTE1LjggMjMuOSA1Ni4zIDIuNS0yLTYwLjV6bTExMS4zIDAtMzktMzQuOC0xLjMgNjEuMiA1Ni4yLTIuNXpNMTA2LjggMjQ3LjRsMzMuOC0xNi41LTI5LjItMjIuOHptNzEuMS0xNi41IDMzLjkgMTYuNS00LjctMzkuM3oiIGNsYXNzPSJzdDEiLz4KICA8cGF0aCBmaWxsPSIjZDdjMWIzIiBzdHJva2U9IiNkN2MxYjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTIxMS44IDI0Ny40LTMzLjktMTYuNSAyLjcgMjIuMS0uMyA5LjN6bS0xMDUgMCAzMS41IDE0LjktLjItOS4zIDIuNS0yMi4xeiIvPgogIDxwYXRoIGZpbGw9IiMyMzM0NDciIHN0cm9rZT0iIzIzMzQ0NyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJtMTM4LjggMTkzLjUtMjguMi04LjMgMTkuOS05LjF6bTQwLjkgMCA4LjMtMTcuNCAyMCA5LjF6Ii8+CiAgPHBhdGggZmlsbD0iI2NkNjExNiIgc3Ryb2tlPSIjY2Q2MTE2IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGQ9Im0xMDYuOCAyNDcuNCA0LjgtNDAuNi0zMS4zLjl6TTIwNyAyMDYuOGw0LjggNDAuNiAyNi41LTM5Ljd6bTIzLjgtNDQuNy01Ni4yIDIuNSA1LjIgMjguOSA4LjMtMTcuNCAyMCA5LjF6bS0xMjAuMiAyMy4xIDIwLTkuMSA4LjIgMTcuNCA1LjMtMjguOS01Ni4zLTIuNXoiLz4KICA8cGF0aCBmaWxsPSIjZTQ3NTFmIiBzdHJva2U9IiNlNDc1MWYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTg3LjggMTYyLjEgMjMuNiA0Ni0uOC0yMi45em0xMjAuMyAyMy4xLTEgMjIuOSAyMy43LTQ2em0tNjQtMjAuNi01LjMgMjguOSA2LjYgMzQuMSAxLjUtNDQuOXptMzAuNSAwLTIuNyAxOCAxLjIgNDUgNi43LTM0LjF6Ii8+CiAgPHBhdGggZD0ibTE3OS44IDE5My41LTYuNyAzNC4xIDQuOCAzLjMgMjkuMi0yMi44IDEtMjIuOXptLTY5LjItOC4zLjggMjIuOSAyOS4yIDIyLjggNC44LTMuMy02LjYtMzQuMXoiIGNsYXNzPSJzdDYiLz4KICA8cGF0aCBmaWxsPSIjYzBhZDllIiBzdHJva2U9IiNjMGFkOWUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0ibTE4MC4zIDI2Mi4zLjMtOS4zLTIuNS0yLjJoLTM3LjdsLTIuMyAyLjIuMiA5LjMtMzEuNS0xNC45IDExIDkgMjIuMyAxNS41aDM4LjNsMjIuNC0xNS41IDExLTl6Ii8+CiAgPHBhdGggZmlsbD0iIzE2MTYxNiIgc3Ryb2tlPSIjMTYxNjE2IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGQ9Im0xNzcuOSAyMzAuOS00LjgtMy4zaC0yNy43bC00LjggMy4zLTIuNSAyMi4xIDIuMy0yLjJoMzcuN2wyLjUgMi4yeiIvPgogIDxwYXRoIGZpbGw9IiM3NjNkMTYiIHN0cm9rZT0iIzc2M2QxNiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJtMjc4LjMgMTE0LjIgOC41LTQwLjgtMTIuNy0zNy45LTk2LjIgNzEuNCAzNyAzMS4zIDUyLjMgMTUuMyAxMS42LTEzLjUtNS0zLjYgOC03LjMtNi4yLTQuOCA4LTYuMXpNMzEuOCA3My40bDguNSA0MC44LTUuNCA0IDggNi4xLTYuMSA0LjggOCA3LjMtNSAzLjYgMTEuNSAxMy41IDUyLjMtMTUuMyAzNy0zMS4zLTk2LjItNzEuNHoiLz4KICA8cGF0aCBkPSJtMjY3LjIgMTUzLjUtNTIuMy0xNS4zIDE1LjkgMjMuOS0yMy43IDQ2IDMxLjItLjRoNDYuNXptLTE2My42LTE1LjMtNTIuMyAxNS4zLTE3LjQgNTQuMmg0Ni40bDMxLjEuNC0yMy42LTQ2em03MSAyNi40IDMuMy01Ny43IDE1LjItNDEuMWgtNjcuNWwxNSA0MS4xIDMuNSA1Ny43IDEuMiAxOC4yLjEgNDQuOGgyNy43bC4yLTQ0Ljh6IiBjbGFzcz0ic3Q2Ii8+Cjwvc3ZnPg==";
|
|
15964
15953
|
const XRPLSNAP_ICON = METAMASK_ICON;
|
|
15954
|
+
const NETWORK_TO_SNAP_CHAIN_ID = {
|
|
15955
|
+
mainnet: 0,
|
|
15956
|
+
testnet: 1,
|
|
15957
|
+
devnet: 2
|
|
15958
|
+
};
|
|
15959
|
+
const discoveredMetaMaskProviders = /* @__PURE__ */ new Set();
|
|
15960
|
+
let eip6963DiscoveryStarted = false;
|
|
15965
15961
|
class XrplSnapAdapter extends BaseWalletAdapter {
|
|
15966
15962
|
constructor(options = {}) {
|
|
15967
15963
|
super();
|
|
@@ -15976,33 +15972,63 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15976
15972
|
icon: options.icon ?? METAMASK_ICON
|
|
15977
15973
|
};
|
|
15978
15974
|
}
|
|
15979
|
-
isAvailable() {
|
|
15980
|
-
return Boolean(this.
|
|
15975
|
+
async isAvailable() {
|
|
15976
|
+
return Boolean(await this.ethereumCandidate(false));
|
|
15981
15977
|
}
|
|
15982
15978
|
async connect(options) {
|
|
15983
15979
|
var _a2;
|
|
15984
|
-
const ethereum = this.
|
|
15985
|
-
|
|
15986
|
-
|
|
15980
|
+
const ethereum = await this.ethereumCandidate().catch((error) => {
|
|
15981
|
+
throw createWalletError.walletNotAvailable("MetaMask Snaps", error);
|
|
15982
|
+
});
|
|
15983
|
+
await this.withAbort(
|
|
15984
|
+
ethereum.request({ method: "wallet_requestSnaps", params: { [this.snapId]: {} } }).catch((error) => {
|
|
15985
|
+
if (this.isSnapsUnsupportedError(error)) {
|
|
15986
|
+
throw createWalletError.walletNotAvailable("MetaMask Snaps", error);
|
|
15987
|
+
}
|
|
15988
|
+
throw error;
|
|
15989
|
+
}),
|
|
15990
|
+
options.signal
|
|
15991
|
+
);
|
|
15992
|
+
this.activeAddress = void 0;
|
|
15993
|
+
this.activeProvider = ethereum;
|
|
15994
|
+
await this.selectSnapNetwork(options);
|
|
15995
|
+
const snap = await this.withAbort(this.invokeSnap("xrpl_getAccount", void 0), options.signal);
|
|
15987
15996
|
const address = snap.account;
|
|
15988
|
-
|
|
15989
|
-
|
|
15997
|
+
const publicKey = snap.publicKey;
|
|
15998
|
+
if (!address) throw new Error("XRPL Snap did not return an XRPL address");
|
|
15990
15999
|
this.activeAddress = address;
|
|
15991
|
-
|
|
16000
|
+
this.activeProvider = ethereum;
|
|
16001
|
+
return { account: { address, publicKey, network: options.network, networkType: (_a2 = options.network) == null ? void 0 : _a2.networkType }, raw: snap };
|
|
15992
16002
|
}
|
|
15993
16003
|
async restoreSession(session) {
|
|
15994
|
-
|
|
15995
|
-
|
|
16004
|
+
const ethereum = await this.ethereum(false);
|
|
16005
|
+
if (!ethereum || !await this.providerSupportsSnaps(ethereum)) return null;
|
|
15996
16006
|
this.activeAddress = session.account.address;
|
|
16007
|
+
this.activeProvider = ethereum;
|
|
15997
16008
|
return { account: session.account, session, raw: null };
|
|
15998
16009
|
}
|
|
15999
16010
|
async signMessage(request) {
|
|
16011
|
+
var _a2;
|
|
16000
16012
|
const txJson = this.createSignMessagePaymentTx(request);
|
|
16001
|
-
const methods2 = this.options.signMessageMethods ?? ["xrpl_sign", "xrpl_signTransaction", "npm:xrpl-snap"];
|
|
16013
|
+
const methods2 = this.options.signMessageMethods ?? ["xrpl_signMessage", "xrpl_sign", "xrpl_signTransaction", "npm:xrpl-snap"];
|
|
16002
16014
|
const errors2 = [];
|
|
16003
16015
|
for (const method of methods2) {
|
|
16004
16016
|
try {
|
|
16005
|
-
const
|
|
16017
|
+
const params = method === "xrpl_signMessage" ? { message: request.message } : txJson;
|
|
16018
|
+
const result = await this.invokeSnap(method, params);
|
|
16019
|
+
const signature = this.pickString(result, [
|
|
16020
|
+
"signature",
|
|
16021
|
+
"signedMessage",
|
|
16022
|
+
"result.signature",
|
|
16023
|
+
"result.signedMessage",
|
|
16024
|
+
"response.signature",
|
|
16025
|
+
"response.signedMessage",
|
|
16026
|
+
"response.data.signature",
|
|
16027
|
+
"response.data.signedMessage"
|
|
16028
|
+
]);
|
|
16029
|
+
if (method === "xrpl_signMessage" && signature) {
|
|
16030
|
+
return { signatureKind: "signature", proof: signature, signature, publicKey: (_a2 = request.account) == null ? void 0 : _a2.publicKey, raw: result };
|
|
16031
|
+
}
|
|
16006
16032
|
const txBlob = this.pickString(result, [
|
|
16007
16033
|
"tx_blob",
|
|
16008
16034
|
"txBlob",
|
|
@@ -16029,6 +16055,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16029
16055
|
"result.signature",
|
|
16030
16056
|
"result.signedMessage"
|
|
16031
16057
|
]);
|
|
16058
|
+
if (!txBlob) throw new Error(`XRPL Snap ${method} did not return a signature or signed transaction`);
|
|
16032
16059
|
return { signatureKind: "signedTx", proof: txBlob, txBlob, raw: result };
|
|
16033
16060
|
} catch (error) {
|
|
16034
16061
|
errors2.push({ method, error: this.formatError(error) });
|
|
@@ -16037,14 +16064,14 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16037
16064
|
throw this.toSnapSignError(errors2, "XRPL Snap could not sign the message.");
|
|
16038
16065
|
}
|
|
16039
16066
|
getSignMessageRequestPreview(request) {
|
|
16040
|
-
var _a2;
|
|
16067
|
+
var _a2, _b, _c;
|
|
16041
16068
|
return {
|
|
16042
16069
|
method: "wallet_invokeSnap",
|
|
16043
16070
|
params: {
|
|
16044
16071
|
snapId: this.snapId,
|
|
16045
16072
|
request: {
|
|
16046
|
-
method: ((_a2 = this.options.signMessageMethods) == null ? void 0 : _a2[0]) ?? "
|
|
16047
|
-
params: this.createSignMessagePaymentTx(request)
|
|
16073
|
+
method: ((_a2 = this.options.signMessageMethods) == null ? void 0 : _a2[0]) ?? "xrpl_signMessage",
|
|
16074
|
+
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
16075
|
}
|
|
16049
16076
|
}
|
|
16050
16077
|
};
|
|
@@ -16052,22 +16079,40 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16052
16079
|
async signAndSubmit(request) {
|
|
16053
16080
|
try {
|
|
16054
16081
|
const result = await this.invokeSnap("xrpl_signAndSubmit", request.txJson);
|
|
16082
|
+
this.assertSuccessfulSubmit(result);
|
|
16055
16083
|
return normalizeTxResult(result);
|
|
16056
16084
|
} catch (error) {
|
|
16057
16085
|
throw this.toSnapSignError(error, "XRPL Snap could not submit this transaction.");
|
|
16058
16086
|
}
|
|
16059
16087
|
}
|
|
16060
|
-
invokeSnap(method, params) {
|
|
16061
|
-
|
|
16088
|
+
async invokeSnap(method, params) {
|
|
16089
|
+
const ethereum = await this.ethereum();
|
|
16090
|
+
const request = () => ethereum.request({
|
|
16062
16091
|
method: "wallet_invokeSnap",
|
|
16063
16092
|
params: { snapId: this.snapId, request: { method, params } }
|
|
16064
16093
|
});
|
|
16094
|
+
const retryDelays = this.options.snapRequestRetryDelaysMs ?? [120, 350, 800];
|
|
16095
|
+
try {
|
|
16096
|
+
return await request();
|
|
16097
|
+
} catch (error) {
|
|
16098
|
+
if (!this.isSnapKeyringHydratingError(error)) throw error;
|
|
16099
|
+
let lastError = error;
|
|
16100
|
+
for (const delayMs of retryDelays) {
|
|
16101
|
+
await this.delay(delayMs);
|
|
16102
|
+
try {
|
|
16103
|
+
return await request();
|
|
16104
|
+
} catch (retryError) {
|
|
16105
|
+
lastError = retryError;
|
|
16106
|
+
if (!this.isSnapKeyringHydratingError(retryError)) throw retryError;
|
|
16107
|
+
}
|
|
16108
|
+
}
|
|
16109
|
+
throw lastError;
|
|
16110
|
+
}
|
|
16065
16111
|
}
|
|
16066
16112
|
createSignMessagePaymentTx(request) {
|
|
16067
16113
|
var _a2;
|
|
16068
16114
|
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");
|
|
16115
|
+
if (!account) throw new Error("XRPL Snap account is not connected");
|
|
16071
16116
|
return {
|
|
16072
16117
|
TransactionType: "Payment",
|
|
16073
16118
|
Account: account,
|
|
@@ -16077,83 +16122,219 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16077
16122
|
Memos: [{ Memo: { MemoData: utf8ToHex(request.message) } }]
|
|
16078
16123
|
};
|
|
16079
16124
|
}
|
|
16125
|
+
async selectSnapNetwork(options) {
|
|
16126
|
+
var _a2;
|
|
16127
|
+
const networkId = (_a2 = options.network) == null ? void 0 : _a2.id;
|
|
16128
|
+
if (!networkId) return;
|
|
16129
|
+
const chainId = NETWORK_TO_SNAP_CHAIN_ID[networkId];
|
|
16130
|
+
if (chainId === void 0) return;
|
|
16131
|
+
try {
|
|
16132
|
+
const active = await this.invokeSnap("xrpl_getActiveNetwork", void 0);
|
|
16133
|
+
if ((active == null ? void 0 : active.chainId) !== chainId) await this.invokeSnap("xrpl_changeNetwork", { chainId });
|
|
16134
|
+
const applied = await this.invokeSnap("xrpl_getActiveNetwork", void 0);
|
|
16135
|
+
if ((applied == null ? void 0 : applied.chainId) !== chainId) {
|
|
16136
|
+
throw new Error(`XRPL Snap network mismatch: expected chain ${chainId}, got ${String(applied == null ? void 0 : applied.chainId)}`);
|
|
16137
|
+
}
|
|
16138
|
+
} catch (error) {
|
|
16139
|
+
if (/unknown method|method not found|not supported|unsupported/i.test(this.getErrorMessage(error))) return;
|
|
16140
|
+
throw error;
|
|
16141
|
+
}
|
|
16142
|
+
}
|
|
16143
|
+
assertSuccessfulSubmit(result) {
|
|
16144
|
+
const engineResult = this.pickString(result, [
|
|
16145
|
+
"engine_result",
|
|
16146
|
+
"result.engine_result",
|
|
16147
|
+
"response.engine_result",
|
|
16148
|
+
"response.data.engine_result",
|
|
16149
|
+
"response.data.result.engine_result"
|
|
16150
|
+
]);
|
|
16151
|
+
if (!engineResult) return;
|
|
16152
|
+
if (engineResult === "tesSUCCESS" || engineResult === "terQUEUED") return;
|
|
16153
|
+
const message = this.pickString(result, [
|
|
16154
|
+
"engine_result_message",
|
|
16155
|
+
"result.engine_result_message",
|
|
16156
|
+
"response.engine_result_message",
|
|
16157
|
+
"response.data.engine_result_message",
|
|
16158
|
+
"response.data.result.engine_result_message"
|
|
16159
|
+
]);
|
|
16160
|
+
throw new Error(message ? `XRPL Snap submission failed: ${message}` : `XRPL Snap submission failed: ${engineResult}`);
|
|
16161
|
+
}
|
|
16080
16162
|
pickString(value, paths) {
|
|
16081
16163
|
for (const path of paths) {
|
|
16082
16164
|
const found = path.split(".").reduce((current, key) => {
|
|
16083
|
-
if (current && typeof current === "object" && key in current)
|
|
16084
|
-
return current[key];
|
|
16165
|
+
if (current && typeof current === "object" && key in current) return current[key];
|
|
16085
16166
|
return void 0;
|
|
16086
16167
|
}, value);
|
|
16087
|
-
if (typeof found === "string")
|
|
16088
|
-
return found;
|
|
16168
|
+
if (typeof found === "string") return found;
|
|
16089
16169
|
}
|
|
16090
16170
|
return void 0;
|
|
16091
16171
|
}
|
|
16092
16172
|
formatError(error) {
|
|
16093
|
-
if (error instanceof Error)
|
|
16094
|
-
return { name: error.name, message: error.message };
|
|
16173
|
+
if (error instanceof Error) return { name: error.name, message: error.message };
|
|
16095
16174
|
return error;
|
|
16096
16175
|
}
|
|
16097
16176
|
toSnapSignError(cause, fallback) {
|
|
16098
16177
|
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");
|
|
16178
|
+
if (/reject|denied|cancelled|canceled|closed/i.test(message)) return createWalletError.signRejected(cause);
|
|
16179
|
+
if (/timeout|timed out/i.test(message)) return createWalletError.requestTimeout("XRPL Snap request timed out. Please try again.", cause);
|
|
16180
|
+
if (/not installed|not available|provider/i.test(message)) return createWalletError.walletNotAvailable("XRPL Snap", cause);
|
|
16181
|
+
if (/unsupported|not supported|unknown method|method not found/i.test(message)) return createWalletError.unsupportedMethod("XRPL Snap request", "MetaMask");
|
|
16107
16182
|
const safeError = new Error(fallback);
|
|
16108
16183
|
safeError.cause = cause;
|
|
16109
16184
|
return createWalletError.signFailed(safeError);
|
|
16110
16185
|
}
|
|
16111
16186
|
getErrorMessage(error) {
|
|
16112
|
-
if (error instanceof Error)
|
|
16113
|
-
|
|
16114
|
-
if (typeof error === "string")
|
|
16115
|
-
return error;
|
|
16187
|
+
if (error instanceof Error) return error.message;
|
|
16188
|
+
if (typeof error === "string") return error;
|
|
16116
16189
|
try {
|
|
16117
16190
|
return JSON.stringify(error);
|
|
16118
16191
|
} catch {
|
|
16119
16192
|
return String(error);
|
|
16120
16193
|
}
|
|
16121
16194
|
}
|
|
16122
|
-
ethereum(required = true) {
|
|
16123
|
-
const
|
|
16124
|
-
|
|
16125
|
-
|
|
16195
|
+
async ethereum(required = true) {
|
|
16196
|
+
const injected = globalThis.ethereum;
|
|
16197
|
+
this.startEip6963Discovery();
|
|
16198
|
+
const configured = this.options.ethereum;
|
|
16199
|
+
if (this.activeProvider) return this.activeProvider;
|
|
16200
|
+
if (configured) return await this.pickSnapProvider(configured, true) ?? this.pickStrongMetaMaskProvider(configured);
|
|
16201
|
+
const ethereum = await this.pickSnapProvider(injected, false) ?? await this.discoverMetaMaskProvider() ?? [...discoveredMetaMaskProviders][0] ?? this.pickStrongMetaMaskProvider(injected);
|
|
16202
|
+
if (!ethereum && required) throw new Error("No MetaMask provider installed");
|
|
16203
|
+
if (ethereum) this.activeProvider = ethereum;
|
|
16204
|
+
return ethereum;
|
|
16205
|
+
}
|
|
16206
|
+
async ethereumCandidate(required = true) {
|
|
16207
|
+
const injected = globalThis.ethereum;
|
|
16208
|
+
this.startEip6963Discovery();
|
|
16209
|
+
const configured = this.options.ethereum;
|
|
16210
|
+
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];
|
|
16211
|
+
if (!ethereum && required) throw new Error("No MetaMask provider installed");
|
|
16126
16212
|
return ethereum;
|
|
16127
16213
|
}
|
|
16214
|
+
pickStrongMetaMaskProvider(injected) {
|
|
16215
|
+
if (!injected) return void 0;
|
|
16216
|
+
const providers = Array.isArray(injected.providers) ? injected.providers : [];
|
|
16217
|
+
return providers.find((provider) => this.hasMetaMaskProviderApi(provider)) ?? (this.hasMetaMaskProviderApi(injected) ? injected : void 0);
|
|
16218
|
+
}
|
|
16219
|
+
async pickSnapProvider(injected, allowRootProvider = false) {
|
|
16220
|
+
const preferred = this.pickStrongMetaMaskProvider(injected);
|
|
16221
|
+
if (preferred && await this.providerSupportsSnaps(preferred)) return preferred;
|
|
16222
|
+
for (const provider of (injected == null ? void 0 : injected.providers) ?? []) {
|
|
16223
|
+
if (provider === preferred) continue;
|
|
16224
|
+
if (await this.providerSupportsSnaps(provider)) return provider;
|
|
16225
|
+
}
|
|
16226
|
+
if (allowRootProvider && injected && injected !== preferred && await this.providerSupportsSnaps(injected)) return injected;
|
|
16227
|
+
return void 0;
|
|
16228
|
+
}
|
|
16229
|
+
startEip6963Discovery() {
|
|
16230
|
+
if (eip6963DiscoveryStarted) return;
|
|
16231
|
+
const scope = globalThis;
|
|
16232
|
+
if (!scope.addEventListener || !scope.dispatchEvent) return;
|
|
16233
|
+
eip6963DiscoveryStarted = true;
|
|
16234
|
+
scope.addEventListener("eip6963:announceProvider", (event) => {
|
|
16235
|
+
const provider = this.pickMetaMaskProviderFromAnnounce(event);
|
|
16236
|
+
if (provider) discoveredMetaMaskProviders.add(provider);
|
|
16237
|
+
});
|
|
16238
|
+
try {
|
|
16239
|
+
scope.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
16240
|
+
} catch {
|
|
16241
|
+
}
|
|
16242
|
+
}
|
|
16243
|
+
discoverMetaMaskProvider() {
|
|
16244
|
+
const cached = [...discoveredMetaMaskProviders][0];
|
|
16245
|
+
if (cached) return Promise.resolve(cached);
|
|
16246
|
+
const scope = globalThis;
|
|
16247
|
+
if (!scope.addEventListener || !scope.removeEventListener || !scope.dispatchEvent) return Promise.resolve(void 0);
|
|
16248
|
+
const addEventListener = scope.addEventListener.bind(scope);
|
|
16249
|
+
const removeEventListener = scope.removeEventListener.bind(scope);
|
|
16250
|
+
const dispatchEvent = scope.dispatchEvent.bind(scope);
|
|
16251
|
+
return new Promise((resolve) => {
|
|
16252
|
+
let timer;
|
|
16253
|
+
let settled = false;
|
|
16254
|
+
const finish = (provider) => {
|
|
16255
|
+
if (settled) return;
|
|
16256
|
+
settled = true;
|
|
16257
|
+
if (timer) clearTimeout(timer);
|
|
16258
|
+
removeEventListener("eip6963:announceProvider", onAnnounce);
|
|
16259
|
+
resolve(provider);
|
|
16260
|
+
};
|
|
16261
|
+
const onAnnounce = (event) => {
|
|
16262
|
+
const provider = this.pickMetaMaskProviderFromAnnounce(event);
|
|
16263
|
+
if (provider) {
|
|
16264
|
+
discoveredMetaMaskProviders.add(provider);
|
|
16265
|
+
finish(provider);
|
|
16266
|
+
}
|
|
16267
|
+
};
|
|
16268
|
+
addEventListener("eip6963:announceProvider", onAnnounce);
|
|
16269
|
+
try {
|
|
16270
|
+
dispatchEvent(new Event("eip6963:requestProvider"));
|
|
16271
|
+
} catch {
|
|
16272
|
+
finish(void 0);
|
|
16273
|
+
return;
|
|
16274
|
+
}
|
|
16275
|
+
timer = setTimeout(() => finish([...discoveredMetaMaskProviders][0]), this.options.providerDiscoveryTimeoutMs ?? 1e3);
|
|
16276
|
+
});
|
|
16277
|
+
}
|
|
16278
|
+
pickMetaMaskProviderFromAnnounce(event) {
|
|
16279
|
+
var _a2, _b, _c, _d;
|
|
16280
|
+
const detail = event.detail;
|
|
16281
|
+
const provider = detail == null ? void 0 : detail.provider;
|
|
16282
|
+
const rdns = ((_b = (_a2 = detail == null ? void 0 : detail.info) == null ? void 0 : _a2.rdns) == null ? void 0 : _b.toLowerCase()) ?? "";
|
|
16283
|
+
const name = ((_d = (_c = detail == null ? void 0 : detail.info) == null ? void 0 : _c.name) == null ? void 0 : _d.toLowerCase()) ?? "";
|
|
16284
|
+
if (provider && (rdns.includes("metamask") || name.includes("metamask") || this.hasMetaMaskProviderApi(provider))) return provider;
|
|
16285
|
+
return void 0;
|
|
16286
|
+
}
|
|
16287
|
+
async providerSupportsSnaps(ethereum) {
|
|
16288
|
+
try {
|
|
16289
|
+
await ethereum.request({ method: "wallet_getSnaps" });
|
|
16290
|
+
return true;
|
|
16291
|
+
} catch (error) {
|
|
16292
|
+
if (this.isSnapsUnsupportedError(error)) return false;
|
|
16293
|
+
return false;
|
|
16294
|
+
}
|
|
16295
|
+
}
|
|
16296
|
+
hasMetaMaskProviderApi(provider) {
|
|
16297
|
+
return Boolean(provider && provider._metamask);
|
|
16298
|
+
}
|
|
16299
|
+
isSnapsUnsupportedError(error) {
|
|
16300
|
+
const message = this.getErrorMessage(error);
|
|
16301
|
+
return /-32601|wallet_requestSnaps|wallet_getSnaps|does not exist|not available|unsupported|method not found|unknown method/i.test(message);
|
|
16302
|
+
}
|
|
16303
|
+
isSnapKeyringHydratingError(error) {
|
|
16304
|
+
const message = this.getErrorMessage(error);
|
|
16305
|
+
return /KeyringController\s*-\s*Keyring not found|Keyring not found/i.test(message);
|
|
16306
|
+
}
|
|
16307
|
+
delay(ms2) {
|
|
16308
|
+
if (ms2 <= 0) return Promise.resolve();
|
|
16309
|
+
return new Promise((resolve) => setTimeout(resolve, ms2));
|
|
16310
|
+
}
|
|
16128
16311
|
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")));
|
|
16312
|
+
if (!signal) return promise;
|
|
16313
|
+
if (signal.aborted) return Promise.reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
16133
16314
|
return new Promise((resolve, reject) => {
|
|
16134
16315
|
let settled = false;
|
|
16135
16316
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
16136
16317
|
const abort = () => {
|
|
16137
|
-
if (settled)
|
|
16138
|
-
return;
|
|
16318
|
+
if (settled) return;
|
|
16139
16319
|
settled = true;
|
|
16140
16320
|
cleanup();
|
|
16141
16321
|
reject(createWalletError.connectionRejected(this.metadata.name, new Error("Connection was cancelled")));
|
|
16142
16322
|
};
|
|
16143
16323
|
signal.addEventListener("abort", abort, { once: true });
|
|
16144
|
-
promise.then(
|
|
16145
|
-
|
|
16146
|
-
return;
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
return;
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16324
|
+
promise.then(
|
|
16325
|
+
(value) => {
|
|
16326
|
+
if (settled) return;
|
|
16327
|
+
settled = true;
|
|
16328
|
+
cleanup();
|
|
16329
|
+
resolve(value);
|
|
16330
|
+
},
|
|
16331
|
+
(error) => {
|
|
16332
|
+
if (settled) return;
|
|
16333
|
+
settled = true;
|
|
16334
|
+
cleanup();
|
|
16335
|
+
reject(error);
|
|
16336
|
+
}
|
|
16337
|
+
);
|
|
16157
16338
|
});
|
|
16158
16339
|
}
|
|
16159
16340
|
}
|
|
@@ -16164,7 +16345,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16164
16345
|
const lightTheme = {
|
|
16165
16346
|
accent: "#0078ae",
|
|
16166
16347
|
accentText: "#ffffff",
|
|
16167
|
-
background: "#
|
|
16348
|
+
background: "#fbfcff",
|
|
16168
16349
|
foreground: "#111827",
|
|
16169
16350
|
error: "#b45309",
|
|
16170
16351
|
success: "#059669",
|
|
@@ -16172,15 +16353,15 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16172
16353
|
border: "rgba(17,24,39,.08)",
|
|
16173
16354
|
overlay: "rgba(15,23,42,.46)",
|
|
16174
16355
|
overlayBlur: 0,
|
|
16175
|
-
surface: "#
|
|
16176
|
-
surfaceHover: "
|
|
16356
|
+
surface: "#f3f7fb",
|
|
16357
|
+
surfaceHover: "#edf3f8",
|
|
16177
16358
|
fallbackIconBackground: "rgba(15,23,42,.06)",
|
|
16178
16359
|
fallbackIconColor: "#111827",
|
|
16179
16360
|
shadow: "0 8px 40px rgba(15,23,42,.12), 0 0 0 1px rgba(15,23,42,.04)",
|
|
16180
16361
|
radius: "14px",
|
|
16181
16362
|
walletRadius: "10px",
|
|
16182
16363
|
spinnerTrail: "rgba(0,0,0,.08)",
|
|
16183
|
-
headerBackground: "#
|
|
16364
|
+
headerBackground: "#fbfcff",
|
|
16184
16365
|
fontFamily: defaultFontFamily
|
|
16185
16366
|
};
|
|
16186
16367
|
const darkTheme = {
|
|
@@ -16214,9 +16395,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16214
16395
|
};
|
|
16215
16396
|
const minimalTheme = {
|
|
16216
16397
|
...lightTheme,
|
|
16217
|
-
background: "#
|
|
16218
|
-
headerBackground: "#
|
|
16219
|
-
surface: "#
|
|
16398
|
+
background: "#fbfcff",
|
|
16399
|
+
headerBackground: "#fbfcff",
|
|
16400
|
+
surface: "#fbfcff",
|
|
16220
16401
|
border: "#d7dee8",
|
|
16221
16402
|
radius: "8px",
|
|
16222
16403
|
walletRadius: "8px",
|
|
@@ -16338,9 +16519,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16338
16519
|
crisp: (overrides = {}) => ({ ...crispTheme, ...overrides }),
|
|
16339
16520
|
soft: (overrides = {}) => ({ ...softTheme, ...overrides })
|
|
16340
16521
|
};
|
|
16341
|
-
const
|
|
16522
|
+
const enUSMessages = {
|
|
16342
16523
|
connectWallet: "Connect Wallet",
|
|
16343
|
-
footerText: "XRPL Wallet Kit",
|
|
16344
16524
|
connect: "Connect",
|
|
16345
16525
|
connected: "Connected",
|
|
16346
16526
|
connectedAccount: "Connected account",
|
|
@@ -16367,9 +16547,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16367
16547
|
openWallet: "Open Wallet",
|
|
16368
16548
|
qrUriCopied: "QR URI copied.",
|
|
16369
16549
|
installed: "Installed",
|
|
16550
|
+
recommended: "Recommended",
|
|
16551
|
+
mobileWallet: "Mobile wallet",
|
|
16552
|
+
extensionWallet: "Extension",
|
|
16553
|
+
walletConnectWallet: "WalletConnect",
|
|
16554
|
+
xrplSnapWallet: "XRPL Snap",
|
|
16555
|
+
hardwareWallet: "Hardware",
|
|
16556
|
+
embeddedWallet: "Embedded wallet",
|
|
16370
16557
|
copyAddress: "Copy address",
|
|
16558
|
+
addressQr: "Address QR",
|
|
16559
|
+
showAddressQr: "Show address QR code",
|
|
16371
16560
|
copying: "Copying...",
|
|
16372
16561
|
viewExplorer: "View explorer",
|
|
16562
|
+
recentTransactions: "Recent transactions",
|
|
16563
|
+
noRecentTransactions: "No recent transactions",
|
|
16564
|
+
transactionSubmitted: "Submitted",
|
|
16565
|
+
transactionConfirmed: "Confirmed",
|
|
16566
|
+
transactionFailed: "Failed",
|
|
16567
|
+
transactionUnknown: "Unknown",
|
|
16568
|
+
view: "View",
|
|
16373
16569
|
disconnect: "Disconnect",
|
|
16374
16570
|
disconnecting: "Disconnecting...",
|
|
16375
16571
|
notActivated: "Not activated",
|
|
@@ -16382,8 +16578,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16382
16578
|
moreWallets: (count) => `+${count} more wallets`,
|
|
16383
16579
|
accountNotActivated: (asset) => `Account not activated. Send ${asset} to activate.`
|
|
16384
16580
|
};
|
|
16385
|
-
const
|
|
16386
|
-
...
|
|
16581
|
+
const viVNMessages = {
|
|
16582
|
+
...enUSMessages,
|
|
16387
16583
|
connectWallet: "Kết nối ví",
|
|
16388
16584
|
connect: "Kết nối",
|
|
16389
16585
|
connected: "Đã kết nối",
|
|
@@ -16411,9 +16607,25 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16411
16607
|
openWallet: "Mở ví",
|
|
16412
16608
|
qrUriCopied: "Đã sao chép QR URI.",
|
|
16413
16609
|
installed: "Đã cài",
|
|
16610
|
+
recommended: "Đề xuất",
|
|
16611
|
+
mobileWallet: "Ví di động",
|
|
16612
|
+
extensionWallet: "Extension",
|
|
16613
|
+
walletConnectWallet: "WalletConnect",
|
|
16614
|
+
xrplSnapWallet: "XRPL Snap",
|
|
16615
|
+
hardwareWallet: "Ví phần cứng",
|
|
16616
|
+
embeddedWallet: "Ví nhúng",
|
|
16414
16617
|
copyAddress: "Sao chép địa chỉ",
|
|
16618
|
+
addressQr: "Mã QR địa chỉ",
|
|
16619
|
+
showAddressQr: "Hiển thị mã QR địa chỉ",
|
|
16415
16620
|
copying: "Đang sao chép...",
|
|
16416
16621
|
viewExplorer: "Xem explorer",
|
|
16622
|
+
recentTransactions: "Giao dịch gần đây",
|
|
16623
|
+
noRecentTransactions: "Chưa có giao dịch gần đây",
|
|
16624
|
+
transactionSubmitted: "Đã gửi",
|
|
16625
|
+
transactionConfirmed: "Đã xác nhận",
|
|
16626
|
+
transactionFailed: "Thất bại",
|
|
16627
|
+
transactionUnknown: "Chưa rõ",
|
|
16628
|
+
view: "Xem",
|
|
16417
16629
|
disconnect: "Ngắt kết nối",
|
|
16418
16630
|
disconnecting: "Đang ngắt kết nối...",
|
|
16419
16631
|
notActivated: "Chưa kích hoạt",
|
|
@@ -16431,28 +16643,41 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16431
16643
|
vi: "vi-VN",
|
|
16432
16644
|
ja: "ja-JP",
|
|
16433
16645
|
ko: "ko-KR",
|
|
16646
|
+
// default to Simplified; use "zh-TW" for Traditional
|
|
16434
16647
|
zh: "zh-CN"
|
|
16435
16648
|
};
|
|
16436
16649
|
const builtInMessages = {
|
|
16437
|
-
"en-US":
|
|
16438
|
-
"vi-VN":
|
|
16439
|
-
"ja-JP": enMessages,
|
|
16440
|
-
"ko-KR": enMessages,
|
|
16441
|
-
"zh-CN": enMessages,
|
|
16442
|
-
"zh-TW": enMessages
|
|
16650
|
+
"en-US": enUSMessages,
|
|
16651
|
+
"vi-VN": viVNMessages
|
|
16443
16652
|
};
|
|
16444
|
-
function resolveWalletUiMessages(locale = "en", overrides = {}) {
|
|
16653
|
+
function resolveWalletUiMessages(locale = "en-US", overrides = {}) {
|
|
16445
16654
|
const normalizedLocale = normalizeWalletUiLocale(locale);
|
|
16655
|
+
const definedOverrides = Object.fromEntries(
|
|
16656
|
+
Object.entries(overrides).filter(([, value]) => value !== void 0)
|
|
16657
|
+
);
|
|
16446
16658
|
return {
|
|
16447
|
-
...builtInMessages[normalizedLocale] ??
|
|
16448
|
-
...
|
|
16659
|
+
...builtInMessages[normalizedLocale] ?? enUSMessages,
|
|
16660
|
+
...definedOverrides
|
|
16449
16661
|
};
|
|
16450
16662
|
}
|
|
16451
16663
|
function normalizeWalletUiLocale(locale = "en-US") {
|
|
16452
16664
|
return localeAliases[locale] ?? locale;
|
|
16453
16665
|
}
|
|
16454
16666
|
function resolveWalletUiOptions(overrides = {}) {
|
|
16455
|
-
const {
|
|
16667
|
+
const {
|
|
16668
|
+
mode: mode2,
|
|
16669
|
+
customTheme,
|
|
16670
|
+
modal,
|
|
16671
|
+
walletList,
|
|
16672
|
+
walletConnect,
|
|
16673
|
+
connectButton: _connectButton,
|
|
16674
|
+
accountPanel: _accountPanel,
|
|
16675
|
+
identity: _identity,
|
|
16676
|
+
themeName,
|
|
16677
|
+
language,
|
|
16678
|
+
messages,
|
|
16679
|
+
transactionPreview
|
|
16680
|
+
} = overrides;
|
|
16456
16681
|
const resolvedMessages = resolveWalletUiMessages(language, messages);
|
|
16457
16682
|
const walletConnectUiMode = (walletConnect == null ? void 0 : walletConnect.mode) ?? overrides.walletConnectUiMode ?? "default";
|
|
16458
16683
|
const wallets = (walletList == null ? void 0 : walletList.wallets) === "all" ? void 0 : walletList == null ? void 0 : walletList.wallets;
|
|
@@ -19809,11 +20034,9 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19809
20034
|
let savedHtmlOverscrollBehavior = "";
|
|
19810
20035
|
let savedScrollY = 0;
|
|
19811
20036
|
function lockPageScroll() {
|
|
19812
|
-
if (typeof window === "undefined" || typeof document === "undefined")
|
|
19813
|
-
return;
|
|
20037
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
19814
20038
|
pageScrollLockCount += 1;
|
|
19815
|
-
if (pageScrollLockCount > 1)
|
|
19816
|
-
return;
|
|
20039
|
+
if (pageScrollLockCount > 1) return;
|
|
19817
20040
|
savedBodyOverflow = document.body.style.overflow;
|
|
19818
20041
|
savedBodyPaddingRight = document.body.style.paddingRight;
|
|
19819
20042
|
savedBodyPosition = document.body.style.position;
|
|
@@ -19826,16 +20049,13 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19826
20049
|
document.body.style.position = "fixed";
|
|
19827
20050
|
document.body.style.top = `-${savedScrollY}px`;
|
|
19828
20051
|
document.body.style.width = "100%";
|
|
19829
|
-
if (scrollbarWidth > 0)
|
|
19830
|
-
document.body.style.paddingRight = `${scrollbarWidth}px`;
|
|
20052
|
+
if (scrollbarWidth > 0) document.body.style.paddingRight = `${scrollbarWidth}px`;
|
|
19831
20053
|
document.documentElement.style.overscrollBehavior = "contain";
|
|
19832
20054
|
}
|
|
19833
20055
|
function unlockPageScroll() {
|
|
19834
|
-
if (typeof window === "undefined" || typeof document === "undefined" || pageScrollLockCount === 0)
|
|
19835
|
-
return;
|
|
20056
|
+
if (typeof window === "undefined" || typeof document === "undefined" || pageScrollLockCount === 0) return;
|
|
19836
20057
|
pageScrollLockCount -= 1;
|
|
19837
|
-
if (pageScrollLockCount > 0)
|
|
19838
|
-
return;
|
|
20058
|
+
if (pageScrollLockCount > 0) return;
|
|
19839
20059
|
document.body.style.overflow = savedBodyOverflow;
|
|
19840
20060
|
document.body.style.paddingRight = savedBodyPaddingRight;
|
|
19841
20061
|
document.body.style.position = savedBodyPosition;
|
|
@@ -19846,8 +20066,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19846
20066
|
savedScrollY = 0;
|
|
19847
20067
|
}
|
|
19848
20068
|
function ensureWalletStyle(id2, styles2) {
|
|
19849
|
-
if (typeof document === "undefined")
|
|
19850
|
-
return;
|
|
20069
|
+
if (typeof document === "undefined") return;
|
|
19851
20070
|
const selector = `style[data-xwk-style="${id2}"]`;
|
|
19852
20071
|
let element = document.head.querySelector(selector);
|
|
19853
20072
|
if (!element) {
|
|
@@ -19857,8 +20076,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
19857
20076
|
} else if (element.nextSibling) {
|
|
19858
20077
|
document.head.appendChild(element);
|
|
19859
20078
|
}
|
|
19860
|
-
if (element.textContent !== styles2)
|
|
19861
|
-
element.textContent = styles2;
|
|
20079
|
+
if (element.textContent !== styles2) element.textContent = styles2;
|
|
19862
20080
|
}
|
|
19863
20081
|
const QR_SIZE = 304;
|
|
19864
20082
|
const QR_DARK = "#111827";
|
|
@@ -20481,30 +20699,30 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20481
20699
|
}
|
|
20482
20700
|
isRejectedError(error, message) {
|
|
20483
20701
|
if (isWalletKitError(error)) {
|
|
20484
|
-
return error.code ===
|
|
20702
|
+
return error.code === WalletKitErrorCode.CONNECTION_REJECTED || error.code === WalletKitErrorCode.SIGN_REJECTED;
|
|
20485
20703
|
}
|
|
20486
20704
|
return /reject|denied|cancelled|canceled|closed|user rejected|proposal expired|expired/i.test(message);
|
|
20487
20705
|
}
|
|
20488
20706
|
isTimeoutError(error, message) {
|
|
20489
|
-
if (isWalletKitError(error) && error.code ===
|
|
20707
|
+
if (isWalletKitError(error) && error.code === WalletKitErrorCode.REQUEST_TIMEOUT)
|
|
20490
20708
|
return true;
|
|
20491
20709
|
return /timeout|timed out/i.test(message);
|
|
20492
20710
|
}
|
|
20493
20711
|
getFriendlyErrorMessage(error) {
|
|
20494
20712
|
if (isWalletKitError(error)) {
|
|
20495
20713
|
switch (error.code) {
|
|
20496
|
-
case
|
|
20714
|
+
case WalletKitErrorCode.CONNECTION_REJECTED:
|
|
20497
20715
|
return "Connection was rejected in the wallet.";
|
|
20498
|
-
case
|
|
20716
|
+
case WalletKitErrorCode.SIGN_REJECTED:
|
|
20499
20717
|
return "Request was rejected in the wallet.";
|
|
20500
|
-
case
|
|
20718
|
+
case WalletKitErrorCode.REQUEST_TIMEOUT:
|
|
20501
20719
|
return "Wallet request timed out. Please try again.";
|
|
20502
|
-
case
|
|
20503
|
-
case
|
|
20720
|
+
case WalletKitErrorCode.WALLET_NOT_INSTALLED:
|
|
20721
|
+
case WalletKitErrorCode.WALLET_NOT_AVAILABLE:
|
|
20504
20722
|
return "Wallet is not available in this browser.";
|
|
20505
|
-
case
|
|
20723
|
+
case WalletKitErrorCode.UNSUPPORTED_METHOD:
|
|
20506
20724
|
return "This wallet does not support the requested action.";
|
|
20507
|
-
case
|
|
20725
|
+
case WalletKitErrorCode.NETWORK_MISMATCH:
|
|
20508
20726
|
return "Wallet network does not match this dApp.";
|
|
20509
20727
|
default:
|
|
20510
20728
|
return this.formatDisplayErrorMessage(error.message);
|
|
@@ -20607,7 +20825,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20607
20825
|
const textSize = this.options.textSize ?? "sm";
|
|
20608
20826
|
const hasReadyUri = state2.status === "ready" && Boolean(state2.uri);
|
|
20609
20827
|
state2.status === "ready" ? state2.uri : void 0;
|
|
20610
|
-
const deeplink = state2.status === "ready" ? state2.deeplink : void 0;
|
|
20828
|
+
const deeplink = state2.status === "ready" ? sanitizeWalletUrl(state2.deeplink) : void 0;
|
|
20611
20829
|
const qrCodeAttributes = hasReadyUri ? ` aria-hidden="true"` : "";
|
|
20612
20830
|
const openAction = hasReadyUri && deeplink ? `<a class="xwk-action xwk-action-primary" data-xwk-open href="${this.escapeHtml(deeplink)}">${this.escapeHtml(messages.openWallet)}</a>` : "";
|
|
20613
20831
|
const copyAction = hasReadyUri ? `<button class="xwk-action xwk-copy-inside" data-xwk-copy type="button">${this.renderQrCopyButtonContent()}</button>` : "";
|
|
@@ -20698,7 +20916,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20698
20916
|
const spinnerSecondary = theme.spinnerTrail;
|
|
20699
20917
|
const qrLoadingColor = theme.muted;
|
|
20700
20918
|
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}}`;
|
|
20919
|
+
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
20920
|
this.cachedStyleKey = styleKey;
|
|
20703
20921
|
this.cachedStyle = styles2;
|
|
20704
20922
|
return styles2;
|
|
@@ -20709,8 +20927,8 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20709
20927
|
}
|
|
20710
20928
|
renderMobileSheetOverrides(theme) {
|
|
20711
20929
|
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:
|
|
20930
|
+
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}}`;
|
|
20931
|
+
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
20932
|
}
|
|
20715
20933
|
renderWalletList(layout) {
|
|
20716
20934
|
const groups = this.getGroups();
|
|
@@ -20727,7 +20945,8 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20727
20945
|
const previewLimit = group.maxPreviewIcons ?? 5;
|
|
20728
20946
|
const previewWallets = wallets.slice(0, previewLimit);
|
|
20729
20947
|
const overflow = wallets.length - previewWallets.length;
|
|
20730
|
-
const
|
|
20948
|
+
const iconUrl = sanitizeWalletUrl(group.icon, { allowDataImage: true });
|
|
20949
|
+
const icon = iconUrl ? `<img src="${this.escapeHtml(iconUrl)}" alt="">` : `<span class="xwk-icon-fallback">${this.escapeHtml(group.name.slice(0, 1).toUpperCase())}</span>`;
|
|
20731
20950
|
const secondary = layout === "list" ? `<span class="xwk-group">${this.escapeHtml(messages.walletCount(wallets.length))}</span>` : layout === "card" || layout === "grid" ? `<span class="xwk-group">+${this.escapeHtml(messages.walletCount(wallets.length))}</span>` : "";
|
|
20732
20951
|
const preview = previewWallets.length ? `<span class="xwk-group-icons">${previewWallets.map((wallet) => this.renderMiniWalletIcon(wallet)).join("")}${overflow > 0 ? `<span class="xwk-mini-more" aria-label="${this.escapeHtml(messages.moreWallets(overflow))}">+${overflow}</span>` : ""}</span>` : "";
|
|
20733
20952
|
return `<button class="xwk-wallet xwk-wallet-group" data-wallet-group-id="${this.escapeHtml(group.id)}">${icon}<span class="xwk-wallet-info"><span class="xwk-name">${this.escapeHtml(group.name)}</span>${secondary}${preview}</span></button>`;
|
|
@@ -20784,14 +21003,16 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20784
21003
|
}
|
|
20785
21004
|
}
|
|
20786
21005
|
renderWalletIcon(wallet) {
|
|
20787
|
-
|
|
20788
|
-
|
|
21006
|
+
const icon = sanitizeWalletUrl(wallet == null ? void 0 : wallet.icon, { allowDataImage: true });
|
|
21007
|
+
if (icon)
|
|
21008
|
+
return `<img src="${this.escapeHtml(icon)}" alt="">`;
|
|
20789
21009
|
const letter = (wallet == null ? void 0 : wallet.name.slice(0, 1).toUpperCase()) ?? "W";
|
|
20790
21010
|
return `<span class="xwk-icon-fallback">${this.escapeHtml(letter)}</span>`;
|
|
20791
21011
|
}
|
|
20792
21012
|
renderMiniWalletIcon(wallet) {
|
|
20793
|
-
|
|
20794
|
-
|
|
21013
|
+
const icon = sanitizeWalletUrl(wallet.icon, { allowDataImage: true });
|
|
21014
|
+
if (icon)
|
|
21015
|
+
return `<img class="xwk-mini-icon" src="${this.escapeHtml(icon)}" alt="">`;
|
|
20795
21016
|
return `<span class="xwk-mini-icon xwk-mini-fallback">${this.escapeHtml(wallet.name.slice(0, 1).toUpperCase())}</span>`;
|
|
20796
21017
|
}
|
|
20797
21018
|
backIcon() {
|
|
@@ -20812,7 +21033,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20812
21033
|
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
21034
|
}
|
|
20814
21035
|
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="
|
|
21036
|
+
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
21037
|
}
|
|
20817
21038
|
messages() {
|
|
20818
21039
|
return resolveWalletUiMessages(this.options.language, this.options.messages);
|
|
@@ -20871,7 +21092,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20871
21092
|
color: qrColor
|
|
20872
21093
|
},
|
|
20873
21094
|
backgroundOptions: {
|
|
20874
|
-
color: this.qrLightMode ?
|
|
21095
|
+
color: this.qrLightMode ? QR_LIGHT : "transparent"
|
|
20875
21096
|
}
|
|
20876
21097
|
});
|
|
20877
21098
|
qrCode.append(container);
|
|
@@ -20883,7 +21104,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20883
21104
|
width: QR_SIZE,
|
|
20884
21105
|
color: {
|
|
20885
21106
|
dark: QR_DARK,
|
|
20886
|
-
light:
|
|
21107
|
+
light: QR_LIGHT
|
|
20887
21108
|
}
|
|
20888
21109
|
});
|
|
20889
21110
|
const image = document.createElement("img");
|
|
@@ -20938,12 +21159,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20938
21159
|
function createXrpBalanceResolver() {
|
|
20939
21160
|
return async ({ address, network }) => {
|
|
20940
21161
|
var _a2, _b, _c;
|
|
20941
|
-
if (!(network == null ? void 0 : network.rpcUrl))
|
|
20942
|
-
return null;
|
|
21162
|
+
if (!(network == null ? void 0 : network.rpcUrl)) return null;
|
|
20943
21163
|
const symbol = getNativeAsset(network);
|
|
20944
21164
|
const endpoint = getHttpRpcUrl(network);
|
|
20945
|
-
if (!endpoint)
|
|
20946
|
-
return null;
|
|
21165
|
+
if (!endpoint) return null;
|
|
20947
21166
|
const accountInfo = await rpc(endpoint, {
|
|
20948
21167
|
method: "account_info",
|
|
20949
21168
|
params: [{ account: address, ledger_index: "validated" }]
|
|
@@ -20967,8 +21186,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
20967
21186
|
}
|
|
20968
21187
|
const accountData = (_b = accountInfo.result) == null ? void 0 : _b.account_data;
|
|
20969
21188
|
const balanceDrops = parseDrops(accountData == null ? void 0 : accountData.Balance);
|
|
20970
|
-
if (balanceDrops == null || ((_c = accountInfo.result) == null ? void 0 : _c.error))
|
|
20971
|
-
return null;
|
|
21189
|
+
if (balanceDrops == null || ((_c = accountInfo.result) == null ? void 0 : _c.error)) return null;
|
|
20972
21190
|
const ownerCount = (accountData == null ? void 0 : accountData.OwnerCount) ?? 0;
|
|
20973
21191
|
const reserveInfo = await resolveReserve(endpoint).catch(() => ({
|
|
20974
21192
|
baseDrops: FALLBACK_RESERVE_BASE_DROPS,
|
|
@@ -21003,8 +21221,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21003
21221
|
headers: { "content-type": "application/json" },
|
|
21004
21222
|
body: JSON.stringify(payload)
|
|
21005
21223
|
});
|
|
21006
|
-
if (!response.ok)
|
|
21007
|
-
throw new Error(`Wallet RPC request failed: ${response.status}`);
|
|
21224
|
+
if (!response.ok) throw new Error(`Wallet RPC request failed: ${response.status}`);
|
|
21008
21225
|
return response.json();
|
|
21009
21226
|
}
|
|
21010
21227
|
async function resolveReserve(endpoint) {
|
|
@@ -21016,26 +21233,22 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21016
21233
|
return { baseDrops, incDrops };
|
|
21017
21234
|
}
|
|
21018
21235
|
function parseDrops(value) {
|
|
21019
|
-
if (value == null)
|
|
21020
|
-
return null;
|
|
21236
|
+
if (value == null) return null;
|
|
21021
21237
|
const parsed = typeof value === "number" ? value : Number(value);
|
|
21022
21238
|
return Number.isFinite(parsed) ? parsed : null;
|
|
21023
21239
|
}
|
|
21024
21240
|
function parseReserveDrops(drops, xrp, fallback) {
|
|
21025
21241
|
const parsedDrops = parseDrops(drops);
|
|
21026
|
-
if (parsedDrops != null)
|
|
21027
|
-
return parsedDrops;
|
|
21242
|
+
if (parsedDrops != null) return parsedDrops;
|
|
21028
21243
|
const parsedXrp = parseDrops(xrp);
|
|
21029
|
-
if (parsedXrp != null)
|
|
21030
|
-
return Math.round(parsedXrp * 1e6);
|
|
21244
|
+
if (parsedXrp != null) return Math.round(parsedXrp * 1e6);
|
|
21031
21245
|
return fallback;
|
|
21032
21246
|
}
|
|
21033
21247
|
function formatDrops(drops) {
|
|
21034
21248
|
return formatXrpBalance(drops / 1e6);
|
|
21035
21249
|
}
|
|
21036
21250
|
function formatXrpBalance(value) {
|
|
21037
|
-
if (!Number.isFinite(value))
|
|
21038
|
-
return "0";
|
|
21251
|
+
if (!Number.isFinite(value)) return "0";
|
|
21039
21252
|
const precision = value >= 100 ? 2 : value >= 1 ? 4 : 6;
|
|
21040
21253
|
return value.toLocaleString("en-US", {
|
|
21041
21254
|
maximumFractionDigits: precision,
|
|
@@ -21167,16 +21380,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21167
21380
|
this.render();
|
|
21168
21381
|
}));
|
|
21169
21382
|
this.offEvents.push(options.modal.onClose(() => {
|
|
21170
|
-
if (this.options.manager.getSession())
|
|
21171
|
-
return;
|
|
21383
|
+
if (this.options.manager.getSession()) return;
|
|
21172
21384
|
this.connecting = false;
|
|
21173
21385
|
this.render();
|
|
21174
21386
|
}));
|
|
21175
21387
|
}
|
|
21176
21388
|
mount(target = document.body) {
|
|
21177
21389
|
const nextTarget = this.resolveTarget(target);
|
|
21178
|
-
if (!nextTarget)
|
|
21179
|
-
throw new Error("Wallet button target was not found");
|
|
21390
|
+
if (!nextTarget) throw new Error("Wallet button target was not found");
|
|
21180
21391
|
this.target = nextTarget;
|
|
21181
21392
|
nextTarget.innerHTML = "";
|
|
21182
21393
|
nextTarget.appendChild(this.createRoot());
|
|
@@ -21212,18 +21423,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21212
21423
|
this.identityResolvingKey = void 0;
|
|
21213
21424
|
this.clearBalanceRefreshTimers();
|
|
21214
21425
|
this.clearBalanceDebounce();
|
|
21215
|
-
if (this.copyResetTimer)
|
|
21216
|
-
|
|
21217
|
-
if (this.identitySettleTimer)
|
|
21218
|
-
window.clearTimeout(this.identitySettleTimer);
|
|
21426
|
+
if (this.copyResetTimer) window.clearTimeout(this.copyResetTimer);
|
|
21427
|
+
if (this.identitySettleTimer) window.clearTimeout(this.identitySettleTimer);
|
|
21219
21428
|
this.offEvents.splice(0).forEach((off) => off());
|
|
21220
|
-
if (this.target)
|
|
21221
|
-
this.target.innerHTML = "";
|
|
21429
|
+
if (this.target) this.target.innerHTML = "";
|
|
21222
21430
|
this.target = void 0;
|
|
21223
21431
|
}
|
|
21224
21432
|
render() {
|
|
21225
|
-
if (!this.target)
|
|
21226
|
-
return;
|
|
21433
|
+
if (!this.target) return;
|
|
21227
21434
|
this.target.innerHTML = "";
|
|
21228
21435
|
try {
|
|
21229
21436
|
this.target.appendChild(this.createRoot());
|
|
@@ -21276,8 +21483,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21276
21483
|
this.options.modal.open();
|
|
21277
21484
|
return;
|
|
21278
21485
|
}
|
|
21279
|
-
if (!this.options.accountPanel)
|
|
21280
|
-
return;
|
|
21486
|
+
if (!this.options.accountPanel) return;
|
|
21281
21487
|
this.panelOpen = !this.panelOpen;
|
|
21282
21488
|
this.render();
|
|
21283
21489
|
}
|
|
@@ -21289,20 +21495,16 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21289
21495
|
}
|
|
21290
21496
|
handleDocumentPointerDown(event) {
|
|
21291
21497
|
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;
|
|
21498
|
+
if (!this.panelOpen || !this.target) return;
|
|
21499
|
+
if (event.target instanceof Node && this.target.contains(event.target)) return;
|
|
21500
|
+
if (event.target instanceof Node && ((_a2 = this.accountPanelPortal) == null ? void 0 : _a2.contains(event.target))) return;
|
|
21298
21501
|
this.panelOpen = false;
|
|
21299
21502
|
this.addressQrOpen = false;
|
|
21300
21503
|
this.historyOpen = false;
|
|
21301
21504
|
this.render();
|
|
21302
21505
|
}
|
|
21303
21506
|
handleDocumentKeyDown(event) {
|
|
21304
|
-
if (!this.panelOpen)
|
|
21305
|
-
return;
|
|
21507
|
+
if (!this.panelOpen) return;
|
|
21306
21508
|
if (event.key === "Escape") {
|
|
21307
21509
|
this.panelOpen = false;
|
|
21308
21510
|
this.addressQrOpen = false;
|
|
@@ -21310,8 +21512,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21310
21512
|
this.render();
|
|
21311
21513
|
return;
|
|
21312
21514
|
}
|
|
21313
|
-
if (event.key !== "Tab" || this.options.accountPanelMode !== "modal")
|
|
21314
|
-
return;
|
|
21515
|
+
if (event.key !== "Tab" || this.options.accountPanelMode !== "modal") return;
|
|
21315
21516
|
const focusable = this.getAccountPanelFocusableElements();
|
|
21316
21517
|
if (!focusable.length) {
|
|
21317
21518
|
event.preventDefault();
|
|
@@ -21333,8 +21534,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21333
21534
|
syncPanelListeners() {
|
|
21334
21535
|
this.removePanelListeners();
|
|
21335
21536
|
this.syncPanelScrollLock(this.panelOpen && this.options.accountPanelMode === "modal");
|
|
21336
|
-
if (!this.panelOpen)
|
|
21337
|
-
return;
|
|
21537
|
+
if (!this.panelOpen) return;
|
|
21338
21538
|
document.addEventListener("pointerdown", this.onDocumentPointerDown);
|
|
21339
21539
|
document.addEventListener("keydown", this.onDocumentKeyDown);
|
|
21340
21540
|
if (this.options.accountPanelMode === "modal") {
|
|
@@ -21355,8 +21555,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21355
21555
|
portal.dataset.xwkEntering = entering ? "true" : "false";
|
|
21356
21556
|
this.ensureStyles();
|
|
21357
21557
|
portal.innerHTML = this.renderPanel();
|
|
21358
|
-
if (entering)
|
|
21359
|
-
document.body.appendChild(portal);
|
|
21558
|
+
if (entering) document.body.appendChild(portal);
|
|
21360
21559
|
this.accountPanelPortal = portal;
|
|
21361
21560
|
this.bindPanelActions(portal);
|
|
21362
21561
|
this.renderAddressQrIfNeeded(portal);
|
|
@@ -21374,8 +21573,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21374
21573
|
this.closeSubView();
|
|
21375
21574
|
});
|
|
21376
21575
|
(_c = root.querySelector("[data-xwk-account-overlay]")) == null ? void 0 : _c.addEventListener("click", (event) => {
|
|
21377
|
-
if (event.target === event.currentTarget)
|
|
21378
|
-
this.closePanel();
|
|
21576
|
+
if (event.target === event.currentTarget) this.closePanel();
|
|
21379
21577
|
});
|
|
21380
21578
|
(_d = root.querySelector("[data-xwk-copy-address]")) == null ? void 0 : _d.addEventListener("click", (event) => {
|
|
21381
21579
|
event.stopPropagation();
|
|
@@ -21392,16 +21590,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21392
21590
|
(_g = root.querySelector("[data-xwk-disconnect]")) == null ? void 0 : _g.addEventListener("click", () => void this.disconnect());
|
|
21393
21591
|
}
|
|
21394
21592
|
openAddressQr() {
|
|
21395
|
-
if (!this.options.manager.getSession())
|
|
21396
|
-
return;
|
|
21593
|
+
if (!this.options.manager.getSession()) return;
|
|
21397
21594
|
this.panelOpen = true;
|
|
21398
21595
|
this.addressQrOpen = true;
|
|
21399
21596
|
this.historyOpen = false;
|
|
21400
21597
|
this.render();
|
|
21401
21598
|
}
|
|
21402
21599
|
openTransactionHistory() {
|
|
21403
|
-
if (!this.options.manager.getSession())
|
|
21404
|
-
return;
|
|
21600
|
+
if (!this.options.manager.getSession()) return;
|
|
21405
21601
|
this.panelOpen = true;
|
|
21406
21602
|
this.addressQrOpen = false;
|
|
21407
21603
|
this.historyOpen = true;
|
|
@@ -21418,8 +21614,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21418
21614
|
document.removeEventListener("keydown", this.onDocumentKeyDown);
|
|
21419
21615
|
}
|
|
21420
21616
|
syncPanelScrollLock(shouldLock) {
|
|
21421
|
-
if (shouldLock === this.panelScrollLocked)
|
|
21422
|
-
return;
|
|
21617
|
+
if (shouldLock === this.panelScrollLocked) return;
|
|
21423
21618
|
this.panelScrollLocked = shouldLock;
|
|
21424
21619
|
if (shouldLock) {
|
|
21425
21620
|
lockPageScroll();
|
|
@@ -21428,8 +21623,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21428
21623
|
}
|
|
21429
21624
|
}
|
|
21430
21625
|
async disconnect() {
|
|
21431
|
-
if (this.accountAction)
|
|
21432
|
-
return;
|
|
21626
|
+
if (this.accountAction) return;
|
|
21433
21627
|
this.accountAction = "disconnect";
|
|
21434
21628
|
this.render();
|
|
21435
21629
|
try {
|
|
@@ -21441,17 +21635,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21441
21635
|
}
|
|
21442
21636
|
}
|
|
21443
21637
|
async copyAddress() {
|
|
21444
|
-
if (this.copyInProgress || this.accountAction)
|
|
21445
|
-
return;
|
|
21638
|
+
if (this.copyInProgress || this.accountAction) return;
|
|
21446
21639
|
const address = this.getSessionAddress(this.options.manager.getSession());
|
|
21447
|
-
if (!address)
|
|
21448
|
-
return;
|
|
21640
|
+
if (!address) return;
|
|
21449
21641
|
this.copyInProgress = true;
|
|
21450
21642
|
try {
|
|
21451
21643
|
await this.copyText(address);
|
|
21452
21644
|
this.copied = true;
|
|
21453
|
-
if (this.copyResetTimer)
|
|
21454
|
-
window.clearTimeout(this.copyResetTimer);
|
|
21645
|
+
if (this.copyResetTimer) window.clearTimeout(this.copyResetTimer);
|
|
21455
21646
|
this.copyResetTimer = window.setTimeout(() => {
|
|
21456
21647
|
this.copied = false;
|
|
21457
21648
|
this.render();
|
|
@@ -21500,13 +21691,11 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21500
21691
|
}
|
|
21501
21692
|
const requestId = ++this.identityRequest;
|
|
21502
21693
|
const cacheKey = this.identityCacheKey(session);
|
|
21503
|
-
if (options.force)
|
|
21504
|
-
this.identityCache.delete(cacheKey);
|
|
21694
|
+
if (options.force) this.identityCache.delete(cacheKey);
|
|
21505
21695
|
this.identityResolvingKey = cacheKey;
|
|
21506
21696
|
try {
|
|
21507
21697
|
const result = await this.options.identityResolver(address, session, { force: options.force });
|
|
21508
|
-
if (requestId !== this.identityRequest)
|
|
21509
|
-
return;
|
|
21698
|
+
if (requestId !== this.identityRequest) return;
|
|
21510
21699
|
const identity2 = typeof result === "string" ? { name: result } : result ?? null;
|
|
21511
21700
|
this.identityName = (identity2 == null ? void 0 : identity2.name) ?? null;
|
|
21512
21701
|
this.identityAvatar = (identity2 == null ? void 0 : identity2.avatar) ?? null;
|
|
@@ -21544,14 +21733,12 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21544
21733
|
this.identityAvatar = (cached == null ? void 0 : cached.avatar) ?? null;
|
|
21545
21734
|
this.clearIdentitySettleTimer();
|
|
21546
21735
|
this.render();
|
|
21547
|
-
if (this.identityResolvingKey !== cacheKey)
|
|
21548
|
-
void this.resolveIdentity(session);
|
|
21736
|
+
if (this.identityResolvingKey !== cacheKey) void this.resolveIdentity(session);
|
|
21549
21737
|
return;
|
|
21550
21738
|
}
|
|
21551
21739
|
this.identityName = null;
|
|
21552
21740
|
this.identityAvatar = null;
|
|
21553
|
-
if (this.identityResolvingKey !== cacheKey)
|
|
21554
|
-
void this.resolveIdentity(session);
|
|
21741
|
+
if (this.identityResolvingKey !== cacheKey) void this.resolveIdentity(session);
|
|
21555
21742
|
this.clearIdentitySettleTimer();
|
|
21556
21743
|
this.identitySettleTimer = window.setTimeout(() => {
|
|
21557
21744
|
this.identitySettleTimer = void 0;
|
|
@@ -21559,8 +21746,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21559
21746
|
}, 260);
|
|
21560
21747
|
}
|
|
21561
21748
|
clearIdentitySettleTimer() {
|
|
21562
|
-
if (!this.identitySettleTimer)
|
|
21563
|
-
return;
|
|
21749
|
+
if (!this.identitySettleTimer) return;
|
|
21564
21750
|
window.clearTimeout(this.identitySettleTimer);
|
|
21565
21751
|
this.identitySettleTimer = void 0;
|
|
21566
21752
|
}
|
|
@@ -21574,8 +21760,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21574
21760
|
this.balance = null;
|
|
21575
21761
|
this.balanceLoading = false;
|
|
21576
21762
|
this.activationStatus = "unknown";
|
|
21577
|
-
if (session)
|
|
21578
|
-
delete session.balance;
|
|
21763
|
+
if (session) delete session.balance;
|
|
21579
21764
|
(_b = (_a2 = this.options).onBalanceChange) == null ? void 0 : _b.call(_a2, null, session);
|
|
21580
21765
|
this.render();
|
|
21581
21766
|
return;
|
|
@@ -21599,8 +21784,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21599
21784
|
network: session.account.network,
|
|
21600
21785
|
session
|
|
21601
21786
|
});
|
|
21602
|
-
if (requestId !== this.balanceRequest)
|
|
21603
|
-
return;
|
|
21787
|
+
if (requestId !== this.balanceRequest) return;
|
|
21604
21788
|
this.balance = this.normalizeBalance(result);
|
|
21605
21789
|
this.activationStatus = ((_e2 = this.balance) == null ? void 0 : _e2.activationStatus) ?? (this.balance ? "active" : "unknown");
|
|
21606
21790
|
session.account.activationStatus = this.activationStatus;
|
|
@@ -21622,8 +21806,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21622
21806
|
this.render();
|
|
21623
21807
|
}
|
|
21624
21808
|
} finally {
|
|
21625
|
-
if (requestId === this.balanceRequest)
|
|
21626
|
-
this.balanceLoading = false;
|
|
21809
|
+
if (requestId === this.balanceRequest) this.balanceLoading = false;
|
|
21627
21810
|
}
|
|
21628
21811
|
}
|
|
21629
21812
|
renderButton() {
|
|
@@ -21645,8 +21828,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21645
21828
|
renderPanel() {
|
|
21646
21829
|
const messages = this.messages();
|
|
21647
21830
|
const session = this.options.manager.getSession();
|
|
21648
|
-
if (!session)
|
|
21649
|
-
return "";
|
|
21831
|
+
if (!session) return "";
|
|
21650
21832
|
const content = this.addressQrOpen ? this.renderAddressQrPanelContent(session) : this.historyOpen ? this.renderTransactionHistoryPanelContent(session) : this.renderPanelContent(session);
|
|
21651
21833
|
const title = this.addressQrOpen ? messages.addressQr : this.historyOpen ? messages.recentTransactions : messages.connected;
|
|
21652
21834
|
const hasTransactions = !this.addressQrOpen && !this.historyOpen && this.options.showRecentTransactions && this.getVisibleTransactions(session).length > 0;
|
|
@@ -21687,24 +21869,20 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21687
21869
|
renderAddressQrPanelContent(session) {
|
|
21688
21870
|
const messages = this.messages();
|
|
21689
21871
|
const address = this.getSessionAddress(session);
|
|
21690
|
-
if (!address)
|
|
21691
|
-
return "";
|
|
21872
|
+
if (!address) return "";
|
|
21692
21873
|
const copyFeedbackIcon = this.copied ? this.copiedIcon() : this.copyIcon();
|
|
21693
21874
|
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
21875
|
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
21876
|
}
|
|
21696
21877
|
renderAddressQrButton(address) {
|
|
21697
|
-
if (!this.options.showAddressQr || !address)
|
|
21698
|
-
return "";
|
|
21878
|
+
if (!this.options.showAddressQr || !address) return "";
|
|
21699
21879
|
const messages = this.messages();
|
|
21700
21880
|
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
21881
|
}
|
|
21702
21882
|
renderTransactionHistory(session) {
|
|
21703
|
-
if (!this.options.showRecentTransactions)
|
|
21704
|
-
return "";
|
|
21883
|
+
if (!this.options.showRecentTransactions) return "";
|
|
21705
21884
|
const allTransactions = this.getVisibleTransactions(session);
|
|
21706
|
-
if (!allTransactions.length)
|
|
21707
|
-
return "";
|
|
21885
|
+
if (!allTransactions.length) return "";
|
|
21708
21886
|
const transactions2 = allTransactions.slice(0, Math.min(3, allTransactions.length));
|
|
21709
21887
|
const messages = this.messages();
|
|
21710
21888
|
const count = allTransactions.length > 9 ? "9+" : String(allTransactions.length);
|
|
@@ -21715,34 +21893,32 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21715
21893
|
renderTransactionHistoryPanelContent(session) {
|
|
21716
21894
|
const messages = this.messages();
|
|
21717
21895
|
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>`;
|
|
21896
|
+
if (!transactions2.length) return `<div class="xwk-tx-empty">${this.escapeHtml(messages.noRecentTransactions)}</div>`;
|
|
21720
21897
|
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
21898
|
}
|
|
21722
21899
|
renderTransactionRow(transaction2) {
|
|
21723
21900
|
const messages = this.messages();
|
|
21724
21901
|
const label = this.transactionStatusLabel(transaction2);
|
|
21902
|
+
const title = this.transactionTitle(transaction2);
|
|
21725
21903
|
const explorerUrl = this.getTransactionExplorerUrl(transaction2);
|
|
21726
21904
|
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(
|
|
21905
|
+
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>`;
|
|
21906
|
+
}
|
|
21907
|
+
transactionTitle(transaction2) {
|
|
21908
|
+
const description = typeof transaction2.description === "string" ? transaction2.description.trim() : "";
|
|
21909
|
+
return description || "Transaction";
|
|
21728
21910
|
}
|
|
21729
21911
|
transactionStatusLabel(transaction2) {
|
|
21730
21912
|
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;
|
|
21913
|
+
if (transaction2.status === "confirmed") return messages.transactionConfirmed;
|
|
21914
|
+
if (transaction2.status === "failed") return messages.transactionFailed;
|
|
21915
|
+
if (transaction2.status === "unknown") return messages.transactionUnknown;
|
|
21737
21916
|
return messages.transactionSubmitted;
|
|
21738
21917
|
}
|
|
21739
21918
|
transactionStatusIcon(status) {
|
|
21740
|
-
if (status === "confirmed")
|
|
21741
|
-
|
|
21742
|
-
if (status === "
|
|
21743
|
-
return this.closeIcon();
|
|
21744
|
-
if (status === "unknown")
|
|
21745
|
-
return this.questionIcon();
|
|
21919
|
+
if (status === "confirmed") return this.checkIcon();
|
|
21920
|
+
if (status === "failed") return this.closeIcon();
|
|
21921
|
+
if (status === "unknown") return this.questionIcon();
|
|
21746
21922
|
return `<span class="xwk-tx-spinner" aria-hidden="true"></span>`;
|
|
21747
21923
|
}
|
|
21748
21924
|
getVisibleTransactions(session, limit = this.options.maxVisibleTransactions) {
|
|
@@ -21771,8 +21947,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21771
21947
|
getTransactionExplorerUrl(transaction2) {
|
|
21772
21948
|
var _a2, _b, _c, _d;
|
|
21773
21949
|
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;
|
|
21950
|
+
if (custom) return custom;
|
|
21776
21951
|
return getExplorerTxUrl((_d = transaction2.account) == null ? void 0 : _d.network, transaction2.hash);
|
|
21777
21952
|
}
|
|
21778
21953
|
formatHash(hash2) {
|
|
@@ -21780,27 +21955,20 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21780
21955
|
}
|
|
21781
21956
|
formatRelativeTime(transaction2) {
|
|
21782
21957
|
const timestamp = this.transactionTimestamp(transaction2);
|
|
21783
|
-
if (!timestamp)
|
|
21784
|
-
return "";
|
|
21958
|
+
if (!timestamp) return "";
|
|
21785
21959
|
const seconds = Math.max(0, Math.floor((Date.now() - timestamp) / 1e3));
|
|
21786
|
-
if (seconds < 60)
|
|
21787
|
-
return "just now";
|
|
21960
|
+
if (seconds < 60) return "just now";
|
|
21788
21961
|
const minutes = Math.floor(seconds / 60);
|
|
21789
|
-
if (minutes < 60)
|
|
21790
|
-
return `${minutes} min ago`;
|
|
21962
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
21791
21963
|
const hours = Math.floor(minutes / 60);
|
|
21792
|
-
if (hours < 24)
|
|
21793
|
-
|
|
21794
|
-
if (hours < 48)
|
|
21795
|
-
return "yesterday";
|
|
21964
|
+
if (hours < 24) return `${hours} hr ago`;
|
|
21965
|
+
if (hours < 48) return "yesterday";
|
|
21796
21966
|
return `${Math.floor(hours / 24)} days ago`;
|
|
21797
21967
|
}
|
|
21798
21968
|
getAccountLabel(session) {
|
|
21799
21969
|
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;
|
|
21970
|
+
if (this.shouldShowWeb3Name() && this.identityName) return this.identityName;
|
|
21971
|
+
if (!this.options.fallbackToAddress) return ((_a2 = session.wallet) == null ? void 0 : _a2.name) ?? session.adapterId;
|
|
21804
21972
|
const address = this.getSessionAddress(session);
|
|
21805
21973
|
return address ? (this.options.formatAddress ?? this.formatAddress)(address) : ((_b = session.wallet) == null ? void 0 : _b.name) ?? session.adapterId;
|
|
21806
21974
|
}
|
|
@@ -21809,41 +21977,34 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21809
21977
|
return `<div class="xwk-account-art xwk-account-avatar-skeleton" role="status" aria-label="${this.escapeHtml(this.messages().connecting)}"><span class="xwk-skeleton xwk-skeleton-circle"></span></div>`;
|
|
21810
21978
|
}
|
|
21811
21979
|
if (this.identityAvatar) {
|
|
21812
|
-
|
|
21980
|
+
const avatar = sanitizeWalletUrl(this.identityAvatar, { allowDataImage: true });
|
|
21981
|
+
if (avatar) return `<img class="xwk-account-avatar" src="${this.escapeHtml(avatar)}" alt="">`;
|
|
21813
21982
|
}
|
|
21814
21983
|
const [from2, to2, spot] = this.getAddressGradient(this.getSessionAddress(session));
|
|
21815
21984
|
return `<div class="xwk-account-art" style="--xwk-avatar-from:${from2};--xwk-avatar-to:${to2};--xwk-avatar-spot:${spot}"><span></span></div>`;
|
|
21816
21985
|
}
|
|
21817
21986
|
getExplorerUrl(session) {
|
|
21818
21987
|
var _a2;
|
|
21819
|
-
if (this.options.explorerUrl)
|
|
21820
|
-
return this.options.explorerUrl(session);
|
|
21988
|
+
if (this.options.explorerUrl) return this.options.explorerUrl(session);
|
|
21821
21989
|
const address = this.getSessionAddress(session);
|
|
21822
|
-
if (!address)
|
|
21823
|
-
return void 0;
|
|
21990
|
+
if (!address) return void 0;
|
|
21824
21991
|
const configured = getExplorerAccountUrl(session.account.network, address);
|
|
21825
|
-
if (configured)
|
|
21826
|
-
return configured;
|
|
21992
|
+
if (configured) return configured;
|
|
21827
21993
|
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)}`;
|
|
21994
|
+
if (networkType === "TESTNET") return `https://testnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
21995
|
+
if (networkType === "DEVNET") return `https://devnet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
21832
21996
|
return `https://livenet.xrpl.org/accounts/${encodeURIComponent(address)}`;
|
|
21833
21997
|
}
|
|
21834
21998
|
getSessionAddress(session) {
|
|
21835
21999
|
const account = session == null ? void 0 : session.account;
|
|
21836
22000
|
const address = typeof (account == null ? void 0 : account.address) === "string" ? account.address : "";
|
|
21837
|
-
if (address)
|
|
21838
|
-
return address;
|
|
22001
|
+
if (address) return address;
|
|
21839
22002
|
return typeof (account == null ? void 0 : account.classicAddress) === "string" ? account.classicAddress : "";
|
|
21840
22003
|
}
|
|
21841
22004
|
isIdentityResolving(session) {
|
|
21842
|
-
if (!session || !this.shouldShowWeb3Name() || this.identityName)
|
|
21843
|
-
return false;
|
|
22005
|
+
if (!session || !this.shouldShowWeb3Name() || this.identityName) return false;
|
|
21844
22006
|
const address = this.getSessionAddress(session);
|
|
21845
|
-
if (!address || !this.options.identityResolver)
|
|
21846
|
-
return false;
|
|
22007
|
+
if (!address || !this.options.identityResolver) return false;
|
|
21847
22008
|
return this.identityResolvingKey === this.identityCacheKey(session);
|
|
21848
22009
|
}
|
|
21849
22010
|
shouldShowWeb3Name() {
|
|
@@ -21853,21 +22014,20 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21853
22014
|
return resolveWalletUiMessages(this.options.language, this.options.messages);
|
|
21854
22015
|
}
|
|
21855
22016
|
renderWalletIcon(wallet, fallbackIcon) {
|
|
21856
|
-
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>`;
|
|
22017
|
+
const icon = sanitizeWalletUrl((wallet == null ? void 0 : wallet.icon) ?? fallbackIcon, { allowDataImage: true });
|
|
22018
|
+
if (icon) return `<img class="xwk-button-icon" src="${this.escapeHtml(icon)}" alt="">`;
|
|
22019
|
+
if (!wallet) return `<span class="xwk-button-icon xwk-button-icon-fallback xwk-button-icon-svg-fallback" aria-hidden="true">${this.walletIcon()}</span>`;
|
|
21861
22020
|
const label = wallet.name.slice(0, 1).toUpperCase();
|
|
21862
22021
|
return `<span class="xwk-button-icon xwk-button-icon-fallback xwk-button-icon-initial" aria-hidden="true">${this.escapeHtml(label)}</span>`;
|
|
21863
22022
|
}
|
|
21864
22023
|
renderPreConnectIcon() {
|
|
21865
22024
|
const icon = this.options.icon;
|
|
21866
|
-
if (!icon || icon.type === "default")
|
|
21867
|
-
return this.renderWalletIcon(void 0);
|
|
22025
|
+
if (!icon || icon.type === "default") return this.renderWalletIcon(void 0);
|
|
21868
22026
|
if (icon.type === "image") {
|
|
22027
|
+
const src2 = sanitizeWalletUrl(icon.src, { allowDataImage: true });
|
|
22028
|
+
if (!src2) return this.renderWalletIcon(void 0);
|
|
21869
22029
|
const aria = icon.alt ? ` role="img" aria-label="${this.escapeHtml(icon.alt)}"` : ` aria-hidden="true"`;
|
|
21870
|
-
return `<span class="xwk-button-icon xwk-button-icon-custom xwk-button-icon-custom-image"${aria}><img src="${this.escapeHtml(
|
|
22030
|
+
return `<span class="xwk-button-icon xwk-button-icon-custom xwk-button-icon-custom-image"${aria}><img src="${this.escapeHtml(src2)}" alt="" decoding="async"></span>`;
|
|
21871
22031
|
}
|
|
21872
22032
|
return this.renderCustomHtmlIcon(icon);
|
|
21873
22033
|
}
|
|
@@ -21877,15 +22037,13 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21877
22037
|
}
|
|
21878
22038
|
repairFallbackIcon(root) {
|
|
21879
22039
|
root.querySelectorAll(".xwk-button-icon-svg-fallback").forEach((icon) => {
|
|
21880
|
-
if (icon.querySelector("svg"))
|
|
21881
|
-
return;
|
|
22040
|
+
if (icon.querySelector("svg")) return;
|
|
21882
22041
|
icon.innerHTML = this.walletIcon();
|
|
21883
22042
|
});
|
|
21884
22043
|
}
|
|
21885
22044
|
getAccountPanelFocusableElements() {
|
|
21886
22045
|
const panel = this.getAccountPanelRoot();
|
|
21887
|
-
if (!panel)
|
|
21888
|
-
return [];
|
|
22046
|
+
if (!panel) return [];
|
|
21889
22047
|
const selectors = [
|
|
21890
22048
|
"button:not([disabled])",
|
|
21891
22049
|
"a[href]",
|
|
@@ -21910,12 +22068,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21910
22068
|
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
22069
|
}
|
|
21912
22070
|
renderAddressQrIfNeeded(root) {
|
|
21913
|
-
if (!this.addressQrOpen)
|
|
21914
|
-
return;
|
|
22071
|
+
if (!this.addressQrOpen) return;
|
|
21915
22072
|
const container = root.querySelector("[data-xwk-address-qr-code]");
|
|
21916
22073
|
const address = container == null ? void 0 : container.dataset.address;
|
|
21917
|
-
if (!container || !address || container.dataset.xwkRendered === address)
|
|
21918
|
-
return;
|
|
22074
|
+
if (!container || !address || container.dataset.xwkRendered === address) return;
|
|
21919
22075
|
container.dataset.xwkRendered = address;
|
|
21920
22076
|
container.replaceChildren();
|
|
21921
22077
|
try {
|
|
@@ -21956,8 +22112,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21956
22112
|
}
|
|
21957
22113
|
normalizeBalance(result) {
|
|
21958
22114
|
var _a2;
|
|
21959
|
-
if (result == null)
|
|
21960
|
-
return null;
|
|
22115
|
+
if (result == null) return null;
|
|
21961
22116
|
const symbol = getNativeAsset((_a2 = this.options.manager.getSession()) == null ? void 0 : _a2.account.network);
|
|
21962
22117
|
if (typeof result === "string" || typeof result === "number") {
|
|
21963
22118
|
return { value: String(result), formatted: `${result} ${symbol}`, symbol };
|
|
@@ -21970,8 +22125,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21970
22125
|
};
|
|
21971
22126
|
}
|
|
21972
22127
|
scheduleBalanceRefresh(delays) {
|
|
21973
|
-
if (!this.options.showBalance || !this.options.balanceResolver)
|
|
21974
|
-
return;
|
|
22128
|
+
if (!this.options.showBalance || !this.options.balanceResolver) return;
|
|
21975
22129
|
this.clearBalanceRefreshTimers();
|
|
21976
22130
|
delays.forEach((delay2) => {
|
|
21977
22131
|
let timer = 0;
|
|
@@ -21987,8 +22141,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
21987
22141
|
this.balanceRefreshTimers.clear();
|
|
21988
22142
|
}
|
|
21989
22143
|
queueBalanceRefresh(session, delay2 = 300) {
|
|
21990
|
-
if (!this.options.showBalance || !this.options.balanceResolver)
|
|
21991
|
-
return;
|
|
22144
|
+
if (!this.options.showBalance || !this.options.balanceResolver) return;
|
|
21992
22145
|
this.balanceDebounceSession = session;
|
|
21993
22146
|
this.clearBalanceDebounce();
|
|
21994
22147
|
if (typeof window === "undefined") {
|
|
@@ -22027,7 +22180,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22027
22180
|
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
22181
|
}
|
|
22029
22182
|
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="
|
|
22183
|
+
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
22184
|
}
|
|
22032
22185
|
externalIcon() {
|
|
22033
22186
|
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 +22211,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22058
22211
|
const fallbackIconBackground = theme.fallbackIconBackground;
|
|
22059
22212
|
const fallbackIconColor = theme.fallbackIconColor;
|
|
22060
22213
|
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)}}`;
|
|
22214
|
+
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
22215
|
return `${baseStyles}${this.renderSkeletonPrimitiveStyles(theme, iconBorder)}`;
|
|
22063
22216
|
}
|
|
22064
22217
|
renderSkeletonPrimitiveStyles(theme, iconBorder) {
|
|
@@ -22083,13 +22236,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22083
22236
|
return this.options.themeMode === "auto" ? this.getSystemThemeMode() : this.options.themeMode;
|
|
22084
22237
|
}
|
|
22085
22238
|
resolveTarget(target) {
|
|
22086
|
-
if (!target)
|
|
22087
|
-
|
|
22088
|
-
if (typeof target !== "string")
|
|
22089
|
-
return target;
|
|
22239
|
+
if (!target) return void 0;
|
|
22240
|
+
if (typeof target !== "string") return target;
|
|
22090
22241
|
const element = document.querySelector(target);
|
|
22091
|
-
if (!element)
|
|
22092
|
-
throw new Error(`Wallet button target was not found: ${target}`);
|
|
22242
|
+
if (!element) throw new Error(`Wallet button target was not found: ${target}`);
|
|
22093
22243
|
return element;
|
|
22094
22244
|
}
|
|
22095
22245
|
formatAddress(address) {
|
|
@@ -22112,8 +22262,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22112
22262
|
return [colors[0], colors[1], colors[2]];
|
|
22113
22263
|
}
|
|
22114
22264
|
getSystemThemeMode() {
|
|
22115
|
-
if (typeof window === "undefined" || !window.matchMedia)
|
|
22116
|
-
return "light";
|
|
22265
|
+
if (typeof window === "undefined" || !window.matchMedia) return "light";
|
|
22117
22266
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
22118
22267
|
}
|
|
22119
22268
|
escapeHtml(value) {
|
|
@@ -22133,19 +22282,16 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22133
22282
|
const cacheTtlMs = options.cacheTtlMs ?? 6e5;
|
|
22134
22283
|
const cache = /* @__PURE__ */ new Map();
|
|
22135
22284
|
return async (address, session, context) => {
|
|
22136
|
-
if (!session || !isMainnetNetwork(session.account.network))
|
|
22137
|
-
return null;
|
|
22285
|
+
if (!session || !isMainnetNetwork(session.account.network)) return null;
|
|
22138
22286
|
const cached = cache.get(address);
|
|
22139
|
-
if (!(context == null ? void 0 : context.force) && cached && cached.expiresAt > Date.now())
|
|
22140
|
-
return cached.value;
|
|
22287
|
+
if (!(context == null ? void 0 : context.force) && cached && cached.expiresAt > Date.now()) return cached.value;
|
|
22141
22288
|
const controller = new AbortController();
|
|
22142
22289
|
const timeout = window.setTimeout(() => controller.abort(), timeoutMs);
|
|
22143
22290
|
try {
|
|
22144
22291
|
const params = `address=${encodeURIComponent(address)}${(context == null ? void 0 : context.force) ? `&_=${Date.now()}` : ""}`;
|
|
22145
22292
|
const url = `${endpoint}${endpoint.includes("?") ? "&" : "?"}${params}`;
|
|
22146
22293
|
const response = await fetch(url, { signal: controller.signal });
|
|
22147
|
-
if (!response.ok)
|
|
22148
|
-
return null;
|
|
22294
|
+
if (!response.ok) return null;
|
|
22149
22295
|
const json = await response.json();
|
|
22150
22296
|
const name = typeof json.data === "string" ? json.data : typeof json.name === "string" ? json.name : null;
|
|
22151
22297
|
const avatar = name ? await resolveXrpDomainAvatar(profileEndpoint, name, controller.signal) : void 0;
|
|
@@ -22161,8 +22307,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22161
22307
|
try {
|
|
22162
22308
|
const url = `${endpoint}${endpoint.includes("?") ? "&" : "?"}domain=${encodeURIComponent(domain)}`;
|
|
22163
22309
|
const response = await fetch(url, { signal });
|
|
22164
|
-
if (!response.ok)
|
|
22165
|
-
return void 0;
|
|
22310
|
+
if (!response.ok) return void 0;
|
|
22166
22311
|
const json = await response.json();
|
|
22167
22312
|
return normalizeAvatarUrl(findAvatarUrl(json), endpoint);
|
|
22168
22313
|
} catch {
|
|
@@ -22170,29 +22315,22 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22170
22315
|
}
|
|
22171
22316
|
}
|
|
22172
22317
|
function findAvatarUrl(value) {
|
|
22173
|
-
if (!value || typeof value !== "object")
|
|
22174
|
-
return void 0;
|
|
22318
|
+
if (!value || typeof value !== "object") return void 0;
|
|
22175
22319
|
const record = value;
|
|
22176
22320
|
const direct = record.avatar;
|
|
22177
|
-
if (typeof direct === "string" && direct.trim())
|
|
22178
|
-
return direct.trim();
|
|
22321
|
+
if (typeof direct === "string" && direct.trim()) return direct.trim();
|
|
22179
22322
|
const profileInfo = record.profile_info ?? record.profileInfo;
|
|
22180
22323
|
const profileAvatar = findAvatarUrl(profileInfo);
|
|
22181
|
-
if (profileAvatar)
|
|
22182
|
-
return profileAvatar;
|
|
22324
|
+
if (profileAvatar) return profileAvatar;
|
|
22183
22325
|
const dataAvatar = findAvatarUrl(record.data);
|
|
22184
|
-
if (dataAvatar)
|
|
22185
|
-
return dataAvatar;
|
|
22326
|
+
if (dataAvatar) return dataAvatar;
|
|
22186
22327
|
const resultAvatar = findAvatarUrl(record.result);
|
|
22187
|
-
if (resultAvatar)
|
|
22188
|
-
return resultAvatar;
|
|
22328
|
+
if (resultAvatar) return resultAvatar;
|
|
22189
22329
|
return void 0;
|
|
22190
22330
|
}
|
|
22191
22331
|
function normalizeAvatarUrl(value, endpoint) {
|
|
22192
|
-
if (!value)
|
|
22193
|
-
|
|
22194
|
-
if (/^(?:https?:|data:|blob:|ipfs:|ar:)/i.test(value))
|
|
22195
|
-
return value;
|
|
22332
|
+
if (!value) return void 0;
|
|
22333
|
+
if (/^(?:https?:|data:|blob:|ipfs:|ar:)/i.test(value)) return value;
|
|
22196
22334
|
if (value.startsWith("//")) {
|
|
22197
22335
|
try {
|
|
22198
22336
|
return `${new URL(endpoint).protocol}${value}`;
|
|
@@ -22212,8 +22350,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22212
22350
|
}
|
|
22213
22351
|
function createWalletButton(options) {
|
|
22214
22352
|
const button = new WalletButtonController(options);
|
|
22215
|
-
if (options.target)
|
|
22216
|
-
button.mount(options.target);
|
|
22353
|
+
if (options.target) button.mount(options.target);
|
|
22217
22354
|
return button;
|
|
22218
22355
|
}
|
|
22219
22356
|
const DEFAULT_AUTO_DISMISS_MS = 5e3;
|
|
@@ -22224,31 +22361,34 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22224
22361
|
this.offEvents = [];
|
|
22225
22362
|
this.dismissTimers = /* @__PURE__ */ new Map();
|
|
22226
22363
|
this.toasts = /* @__PURE__ */ new Map();
|
|
22227
|
-
this.offEvents.push(
|
|
22228
|
-
hash: hash2,
|
|
22229
|
-
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
|
|
22233
|
-
|
|
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 ?? {
|
|
22364
|
+
this.offEvents.push(
|
|
22365
|
+
options.manager.on("tx_submitted", ({ hash: hash2, transaction: transaction2 }) => this.upsert(hash2, transaction2 ?? {
|
|
22366
|
+
hash: hash2,
|
|
22367
|
+
status: "submitted",
|
|
22368
|
+
submittedAt: Date.now()
|
|
22369
|
+
})),
|
|
22370
|
+
options.manager.on("tx_confirmed", ({ hash: hash2, transaction: transaction2 }) => this.upsert(hash2, transaction2 ?? {
|
|
22240
22371
|
hash: hash2,
|
|
22241
|
-
status: "
|
|
22372
|
+
status: "confirmed",
|
|
22242
22373
|
submittedAt: Date.now(),
|
|
22243
|
-
|
|
22244
|
-
|
|
22245
|
-
})
|
|
22246
|
-
|
|
22374
|
+
confirmedAt: Date.now()
|
|
22375
|
+
})),
|
|
22376
|
+
options.manager.on("tx_failed", ({ hash: hash2, transaction: transaction2, error }) => {
|
|
22377
|
+
if (!hash2) return;
|
|
22378
|
+
this.upsert(hash2, transaction2 ?? {
|
|
22379
|
+
hash: hash2,
|
|
22380
|
+
status: "failed",
|
|
22381
|
+
submittedAt: Date.now(),
|
|
22382
|
+
failedAt: Date.now(),
|
|
22383
|
+
error
|
|
22384
|
+
});
|
|
22385
|
+
}),
|
|
22386
|
+
options.manager.on("disconnected", () => this.clearAll())
|
|
22387
|
+
);
|
|
22247
22388
|
}
|
|
22248
22389
|
mount(container = this.options.mount ?? document.body) {
|
|
22249
22390
|
var _a2;
|
|
22250
|
-
if ((_a2 = this.root) == null ? void 0 : _a2.isConnected)
|
|
22251
|
-
return;
|
|
22391
|
+
if ((_a2 = this.root) == null ? void 0 : _a2.isConnected) return;
|
|
22252
22392
|
this.root = document.createElement("div");
|
|
22253
22393
|
this.root.className = `xwk-toast-root xwk-toast-root--${this.position()}`;
|
|
22254
22394
|
this.root.setAttribute("aria-live", "polite");
|
|
@@ -22273,8 +22413,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22273
22413
|
upsert(hash2, transaction2) {
|
|
22274
22414
|
var _a2;
|
|
22275
22415
|
this.toasts.set(hash2, transaction2);
|
|
22276
|
-
if (!((_a2 = this.root) == null ? void 0 : _a2.isConnected) && typeof document !== "undefined")
|
|
22277
|
-
this.mount();
|
|
22416
|
+
if (!((_a2 = this.root) == null ? void 0 : _a2.isConnected) && typeof document !== "undefined") this.mount();
|
|
22278
22417
|
this.enforceLimit();
|
|
22279
22418
|
this.render();
|
|
22280
22419
|
if (transaction2.status === "confirmed" || transaction2.status === "failed") {
|
|
@@ -22288,25 +22427,21 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22288
22427
|
}
|
|
22289
22428
|
scheduleDismiss(hash2) {
|
|
22290
22429
|
const autoDismissMs = this.options.autoDismissMs ?? DEFAULT_AUTO_DISMISS_MS;
|
|
22291
|
-
if (autoDismissMs <= 0)
|
|
22292
|
-
return;
|
|
22430
|
+
if (autoDismissMs <= 0) return;
|
|
22293
22431
|
const previous = this.dismissTimers.get(hash2);
|
|
22294
|
-
if (previous)
|
|
22295
|
-
window.clearTimeout(previous);
|
|
22432
|
+
if (previous) window.clearTimeout(previous);
|
|
22296
22433
|
const timer = window.setTimeout(() => this.remove(hash2), autoDismissMs);
|
|
22297
22434
|
this.dismissTimers.set(hash2, timer);
|
|
22298
22435
|
}
|
|
22299
22436
|
remove(hash2) {
|
|
22300
22437
|
const timer = this.dismissTimers.get(hash2);
|
|
22301
|
-
if (timer)
|
|
22302
|
-
window.clearTimeout(timer);
|
|
22438
|
+
if (timer) window.clearTimeout(timer);
|
|
22303
22439
|
this.dismissTimers.delete(hash2);
|
|
22304
22440
|
this.toasts.delete(hash2);
|
|
22305
22441
|
this.render();
|
|
22306
22442
|
}
|
|
22307
22443
|
render() {
|
|
22308
|
-
if (!this.root)
|
|
22309
|
-
return;
|
|
22444
|
+
if (!this.root) return;
|
|
22310
22445
|
this.root.className = `xwk-toast-root xwk-toast-root--${this.position()}`;
|
|
22311
22446
|
this.ensureStyles();
|
|
22312
22447
|
const toasts = [...this.toasts.values()].sort((a2, b2) => this.getTimestamp(a2) - this.getTimestamp(b2)).map((transaction2) => this.renderToast(transaction2)).join("");
|
|
@@ -22314,8 +22449,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22314
22449
|
this.root.querySelectorAll("[data-xwk-toast-dismiss]").forEach((button) => {
|
|
22315
22450
|
button.addEventListener("click", () => {
|
|
22316
22451
|
const hash2 = button.dataset.xwkToastDismiss;
|
|
22317
|
-
if (hash2)
|
|
22318
|
-
this.remove(hash2);
|
|
22452
|
+
if (hash2) this.remove(hash2);
|
|
22319
22453
|
});
|
|
22320
22454
|
});
|
|
22321
22455
|
}
|
|
@@ -22330,17 +22464,14 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22330
22464
|
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
22465
|
}
|
|
22332
22466
|
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>`;
|
|
22467
|
+
if (status === "confirmed") return `<span class="xwk-toast-icon-mark" aria-hidden="true">${this.checkIcon()}</span>`;
|
|
22468
|
+
if (status === "failed") return `<span class="xwk-toast-icon-mark" aria-hidden="true">${this.closeIcon()}</span>`;
|
|
22469
|
+
if (status === "unknown") return `<span class="xwk-toast-icon-mark" aria-hidden="true">?</span>`;
|
|
22339
22470
|
return `<span class="xwk-toast-spinner" aria-hidden="true"></span>`;
|
|
22340
22471
|
}
|
|
22341
22472
|
renderStyles() {
|
|
22342
22473
|
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:
|
|
22474
|
+
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
22475
|
}
|
|
22345
22476
|
ensureStyles() {
|
|
22346
22477
|
const styles2 = this.renderStyles();
|
|
@@ -22349,8 +22480,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22349
22480
|
getExplorerUrl(hash2, network) {
|
|
22350
22481
|
var _a2, _b;
|
|
22351
22482
|
const custom = (_b = (_a2 = this.options).explorerUrl) == null ? void 0 : _b.call(_a2, hash2, network);
|
|
22352
|
-
if (custom)
|
|
22353
|
-
return custom;
|
|
22483
|
+
if (custom) return custom;
|
|
22354
22484
|
return getExplorerTxUrl(network, hash2);
|
|
22355
22485
|
}
|
|
22356
22486
|
getTimestamp(transaction2) {
|
|
@@ -22377,8 +22507,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22377
22507
|
return this.options.themeMode === "auto" ? this.getSystemThemeMode() : this.options.themeMode ?? "light";
|
|
22378
22508
|
}
|
|
22379
22509
|
getSystemThemeMode() {
|
|
22380
|
-
if (typeof window === "undefined" || !window.matchMedia)
|
|
22381
|
-
return "light";
|
|
22510
|
+
if (typeof window === "undefined" || !window.matchMedia) return "light";
|
|
22382
22511
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
22383
22512
|
}
|
|
22384
22513
|
clearTimers() {
|
|
@@ -22406,8 +22535,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22406
22535
|
}
|
|
22407
22536
|
function createWalletToast(options) {
|
|
22408
22537
|
const toast = new WalletToast(options);
|
|
22409
|
-
if (options.mount)
|
|
22410
|
-
toast.mount(options.mount);
|
|
22538
|
+
if (options.mount) toast.mount(options.mount);
|
|
22411
22539
|
return toast;
|
|
22412
22540
|
}
|
|
22413
22541
|
function createWalletClient(options) {
|
|
@@ -22517,8 +22645,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22517
22645
|
var _a2;
|
|
22518
22646
|
const modalConfig = typeof options.modal === "object" ? options.modal : {};
|
|
22519
22647
|
const raw = modalConfig.toast ?? ((_a2 = options.ui) == null ? void 0 : _a2.toast);
|
|
22520
|
-
if (!raw)
|
|
22521
|
-
return void 0;
|
|
22648
|
+
if (!raw) return void 0;
|
|
22522
22649
|
const toast = raw === true ? {} : raw;
|
|
22523
22650
|
return {
|
|
22524
22651
|
language: modalUi.language,
|
|
@@ -22536,14 +22663,10 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22536
22663
|
if (shouldInclude(ids, "xaman") && options.xamanClientId) {
|
|
22537
22664
|
adapters.push(createXamanAdapter({ apiKey: options.xamanClientId, onQr }));
|
|
22538
22665
|
}
|
|
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());
|
|
22666
|
+
if (shouldInclude(ids, "gemwallet")) adapters.push(createGemWalletAdapter());
|
|
22667
|
+
if (shouldInclude(ids, "crossmark")) adapters.push(createCrossmarkAdapter());
|
|
22668
|
+
if (shouldInclude(ids, "dropfi")) adapters.push(createDropFiAdapter());
|
|
22669
|
+
if (shouldInclude(ids, "xrplsnap")) adapters.push(createXrplSnapAdapter());
|
|
22547
22670
|
if (options.walletConnectProjectId && shouldIncludeWalletConnect(ids)) {
|
|
22548
22671
|
const walletConnectUiMode = getWalletConnectUiMode(options);
|
|
22549
22672
|
const appMetadata = resolveAppMetadata(options);
|
|
@@ -22558,15 +22681,12 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22558
22681
|
modalMode: walletConnectUiMode === "default" ? "always" : void 0
|
|
22559
22682
|
}));
|
|
22560
22683
|
}
|
|
22561
|
-
if (shouldInclude(ids, "ledger"))
|
|
22562
|
-
adapters.push(createLedgerAdapter());
|
|
22684
|
+
if (shouldInclude(ids, "ledger")) adapters.push(createLedgerAdapter());
|
|
22563
22685
|
return adapters;
|
|
22564
22686
|
}
|
|
22565
22687
|
function resolveStorage(storage) {
|
|
22566
|
-
if (storage === "localStorage")
|
|
22567
|
-
|
|
22568
|
-
if (storage === "memory")
|
|
22569
|
-
return void 0;
|
|
22688
|
+
if (storage === "localStorage") return createBrowserWalletStorage();
|
|
22689
|
+
if (storage === "memory") return void 0;
|
|
22570
22690
|
return storage;
|
|
22571
22691
|
}
|
|
22572
22692
|
function resolveModalOptions(options) {
|
|
@@ -22596,13 +22716,17 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22596
22716
|
}
|
|
22597
22717
|
function resolveButtonOptions(options) {
|
|
22598
22718
|
var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j;
|
|
22599
|
-
if (!options.connectButton)
|
|
22600
|
-
return void 0;
|
|
22719
|
+
if (!options.connectButton) return void 0;
|
|
22601
22720
|
const raw = isConnectButtonTarget(options.connectButton) ? { target: options.connectButton } : options.connectButton;
|
|
22602
22721
|
const buttonInput = raw;
|
|
22603
|
-
if (!buttonInput.target)
|
|
22604
|
-
|
|
22605
|
-
|
|
22722
|
+
if (!buttonInput.target) return void 0;
|
|
22723
|
+
const {
|
|
22724
|
+
accountStatus: _accountStatus,
|
|
22725
|
+
accountPanelMode: _accountPanelMode,
|
|
22726
|
+
showBalance,
|
|
22727
|
+
target,
|
|
22728
|
+
...buttonConfig
|
|
22729
|
+
} = buttonInput;
|
|
22606
22730
|
const identity2 = options.identity ?? {};
|
|
22607
22731
|
const modalConfig = typeof options.modal === "object" ? options.modal : {};
|
|
22608
22732
|
const ui = {
|
|
@@ -22639,8 +22763,7 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22639
22763
|
}
|
|
22640
22764
|
function resolveResponsiveValue(value) {
|
|
22641
22765
|
var _a2;
|
|
22642
|
-
if (value == null || typeof value !== "object" || !("smallScreen" in value || "largeScreen" in value))
|
|
22643
|
-
return value;
|
|
22766
|
+
if (value == null || typeof value !== "object" || !("smallScreen" in value || "largeScreen" in value)) return value;
|
|
22644
22767
|
const isSmallScreen = typeof window !== "undefined" && ((_a2 = window.matchMedia) == null ? void 0 : _a2.call(window, "(max-width: 640px)").matches);
|
|
22645
22768
|
return isSmallScreen ? value.smallScreen ?? value.largeScreen : value.largeScreen ?? value.smallScreen;
|
|
22646
22769
|
}
|
|
@@ -22649,21 +22772,18 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22649
22772
|
return ((_b = (_a2 = options.ui) == null ? void 0 : _a2.walletConnect) == null ? void 0 : _b.mode) ?? "default";
|
|
22650
22773
|
}
|
|
22651
22774
|
function shouldInclude(ids, id2) {
|
|
22652
|
-
if (!ids)
|
|
22653
|
-
return true;
|
|
22775
|
+
if (!ids) return true;
|
|
22654
22776
|
if (id2 === "xrplsnap") {
|
|
22655
22777
|
return ids.has("xrplsnap") || ids.has("xrpl-snap");
|
|
22656
22778
|
}
|
|
22657
22779
|
return ids.has(id2);
|
|
22658
22780
|
}
|
|
22659
22781
|
function shouldIncludeWalletConnect(ids) {
|
|
22660
|
-
if (!ids)
|
|
22661
|
-
return true;
|
|
22782
|
+
if (!ids) return true;
|
|
22662
22783
|
return ids.has("walletconnect") || ["staticbit", "bitget", "joey", "girin", "bifrost"].some((id2) => ids.has(id2));
|
|
22663
22784
|
}
|
|
22664
22785
|
function resolveWalletConnectWallets(ids) {
|
|
22665
|
-
if (!ids || ids.has("walletconnect"))
|
|
22666
|
-
return "all";
|
|
22786
|
+
if (!ids || ids.has("walletconnect")) return "all";
|
|
22667
22787
|
const walletIds = ["staticbit", "bitget", "joey", "girin", "bifrost"].filter((id2) => ids.has(id2));
|
|
22668
22788
|
return walletIds.length ? walletIds : "all";
|
|
22669
22789
|
}
|
|
@@ -22684,18 +22804,25 @@ ${new this._window.XMLSerializer().serializeToString(e4)}`;
|
|
|
22684
22804
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
22685
22805
|
}
|
|
22686
22806
|
function normalizeIcons(icons) {
|
|
22687
|
-
if (!Array.isArray(icons))
|
|
22688
|
-
return [];
|
|
22807
|
+
if (!Array.isArray(icons)) return [];
|
|
22689
22808
|
return icons.filter((icon) => typeof icon === "string" && icon.trim().length > 0);
|
|
22690
22809
|
}
|
|
22691
22810
|
function withoutKitOnlyOptions(options) {
|
|
22692
|
-
const {
|
|
22811
|
+
const {
|
|
22812
|
+
adapters: _adapters,
|
|
22813
|
+
storage: _storage,
|
|
22814
|
+
walletConnectProjectId: _walletConnectProjectId,
|
|
22815
|
+
walletConnectSignMessageDestination: _walletConnectSignMessageDestination,
|
|
22816
|
+
xamanClientId: _xamanClientId,
|
|
22817
|
+
wallets: _wallets,
|
|
22818
|
+
ui: _ui,
|
|
22819
|
+
...managerConfig
|
|
22820
|
+
} = options;
|
|
22693
22821
|
return managerConfig;
|
|
22694
22822
|
}
|
|
22695
22823
|
const createXrplWalletKit = createWalletClient;
|
|
22696
22824
|
function isConnectButtonTarget(value) {
|
|
22697
|
-
if (typeof value === "string")
|
|
22698
|
-
return true;
|
|
22825
|
+
if (typeof value === "string") return true;
|
|
22699
22826
|
return typeof HTMLElement !== "undefined" && value instanceof HTMLElement;
|
|
22700
22827
|
}
|
|
22701
22828
|
var npm = {};
|
|
@@ -77940,6 +78067,7 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
77940
78067
|
exports.JOEY_ICON = JOEY_ICON;
|
|
77941
78068
|
exports.LEDGER_ICON = LEDGER_ICON;
|
|
77942
78069
|
exports.LedgerAdapter = LedgerAdapter;
|
|
78070
|
+
exports.LedgerDeviceState = LedgerDeviceState;
|
|
77943
78071
|
exports.METAMASK_ICON = METAMASK_ICON;
|
|
77944
78072
|
exports.MemoryWalletStorage = MemoryWalletStorage;
|
|
77945
78073
|
exports.NetworkRegistry = NetworkRegistry;
|
|
@@ -77951,6 +78079,7 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
77951
78079
|
exports.WALLETCONNECT_GROUP_ICON = WALLETCONNECT_GROUP_ICON;
|
|
77952
78080
|
exports.WALLETCONNECT_ICON = WALLETCONNECT_ICON;
|
|
77953
78081
|
exports.WALLET_ADAPTER_API_VERSION = WALLET_ADAPTER_API_VERSION;
|
|
78082
|
+
exports.WALLET_KIT_ERROR_CATEGORY_BY_CODE = WALLET_KIT_ERROR_CATEGORY_BY_CODE;
|
|
77954
78083
|
exports.WALLET_STORAGE_VERSION = WALLET_STORAGE_VERSION;
|
|
77955
78084
|
exports.WalletButton = WalletButtonController;
|
|
77956
78085
|
exports.WalletButtonController = WalletButtonController;
|
|
@@ -77958,12 +78087,15 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
77958
78087
|
exports.WalletEventEmitter = WalletEventEmitter;
|
|
77959
78088
|
exports.WalletInline = WalletInline;
|
|
77960
78089
|
exports.WalletKitError = WalletKitError;
|
|
78090
|
+
exports.WalletKitErrorCategory = WalletKitErrorCategory;
|
|
78091
|
+
exports.WalletKitErrorCode = WalletKitErrorCode;
|
|
77961
78092
|
exports.WalletManager = WalletManager;
|
|
77962
78093
|
exports.WalletModal = WalletModal;
|
|
77963
78094
|
exports.WalletToast = WalletToast;
|
|
77964
78095
|
exports.WalletTransactionStore = WalletTransactionStore;
|
|
77965
78096
|
exports.XAMAN_ICON = XAMAN_ICON;
|
|
77966
78097
|
exports.XRPLSNAP_ICON = XRPLSNAP_ICON;
|
|
78098
|
+
exports.XRPLWalletConnectMethod = XRPLWalletConnectMethod;
|
|
77967
78099
|
exports.XRPL_DEVNET = XRPL_DEVNET;
|
|
77968
78100
|
exports.XRPL_MAINNET = XRPL_MAINNET;
|
|
77969
78101
|
exports.XRPL_TESTNET = XRPL_TESTNET;
|
|
@@ -78004,6 +78136,7 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
78004
78136
|
exports.crispTheme = crispTheme;
|
|
78005
78137
|
exports.darkTheme = darkTheme;
|
|
78006
78138
|
exports.defaultFontFamily = defaultFontFamily;
|
|
78139
|
+
exports.enUSMessages = enUSMessages;
|
|
78007
78140
|
exports.getErrorMessage = getErrorMessage;
|
|
78008
78141
|
exports.getExplorerAccountUrl = getExplorerAccountUrl;
|
|
78009
78142
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
@@ -78011,6 +78144,7 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
78011
78144
|
exports.getNativeAsset = getNativeAsset;
|
|
78012
78145
|
exports.glassTheme = glassTheme;
|
|
78013
78146
|
exports.isMainnetNetwork = isMainnetNetwork;
|
|
78147
|
+
exports.isSafeWalletUrl = isSafeWalletUrl;
|
|
78014
78148
|
exports.isSuccessResult = isSuccessResult;
|
|
78015
78149
|
exports.isWalletKitError = isWalletKitError;
|
|
78016
78150
|
exports.lightTheme = lightTheme;
|
|
@@ -78027,9 +78161,11 @@ ${e2.length}`, n2 = new TextEncoder().encode(t2 + e2);
|
|
|
78027
78161
|
exports.resolveWalletUiMessages = resolveWalletUiMessages;
|
|
78028
78162
|
exports.resolveWalletUiOptions = resolveWalletUiOptions;
|
|
78029
78163
|
exports.roundedTheme = roundedTheme;
|
|
78164
|
+
exports.sanitizeWalletUrl = sanitizeWalletUrl;
|
|
78030
78165
|
exports.softTheme = softTheme;
|
|
78031
78166
|
exports.utf8ToHex = utf8ToHex;
|
|
78032
78167
|
exports.validateWalletAdapter = validateWalletAdapter;
|
|
78168
|
+
exports.viVNMessages = viVNMessages;
|
|
78033
78169
|
exports.walletConnectDeeplinks = walletConnectDeeplinks;
|
|
78034
78170
|
exports.walletUiThemes = walletUiThemes;
|
|
78035
78171
|
exports.xrplTheme = xrplTheme;
|