@trustware/sdk-staging 1.1.9-staging.5 → 1.1.9-staging.6
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/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-CwT8Wd1x.d.ts → core-2oZuxC1J.d.ts} +1 -1
- package/dist/{core-Dy_rZl5y.d.cts → core-BTPkApRH.d.cts} +1 -1
- package/dist/core.cjs +172 -29
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +172 -29
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-d2PUaxE_.d.ts → detect-B8xXLwHK.d.ts} +1 -1
- package/dist/{detect-DVpECOTa.d.cts → detect-C8xpZRrL.d.cts} +1 -1
- package/dist/index.cjs +532 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +784 -341
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-xFiq0SHr.d.ts → manager-BMO1O-cW.d.ts} +7 -2
- package/dist/{manager-B5aklGtm.d.cts → manager-BZwbtOyf.d.cts} +7 -2
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/wallet.cjs +196 -37
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +6 -4
- package/dist/wallet.d.ts +6 -4
- package/dist/wallet.mjs +194 -37
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +532 -91
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +750 -307
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -563,7 +563,7 @@ var init_constants = __esm({
|
|
|
563
563
|
"src/constants.ts"() {
|
|
564
564
|
"use strict";
|
|
565
565
|
SDK_NAME = "@trustware/sdk";
|
|
566
|
-
SDK_VERSION = "1.1.9-staging.
|
|
566
|
+
SDK_VERSION = "1.1.9-staging.6";
|
|
567
567
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
568
568
|
GTM_ID = "GTM-TZDGNCXB";
|
|
569
569
|
API_PREFIX = "/api";
|
|
@@ -6213,21 +6213,28 @@ function formatDeepLink(id, currentUrl) {
|
|
|
6213
6213
|
const enc = encodeURIComponent(currentUrl);
|
|
6214
6214
|
switch (id) {
|
|
6215
6215
|
// EVM
|
|
6216
|
+
// MetaMask's dapp browser also exposes its Wallet Standard Solana
|
|
6217
|
+
// provider in the same session, so "metamask-solana" reuses this link.
|
|
6216
6218
|
case "metamask":
|
|
6219
|
+
case "metamask-solana":
|
|
6217
6220
|
return `metamask://dapp/${currentUrl}`;
|
|
6218
6221
|
case "coinbase":
|
|
6219
6222
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
6220
6223
|
case "rainbow":
|
|
6221
|
-
return `rainbow
|
|
6224
|
+
return `https://rainbow.me/dapp?url=${enc}`;
|
|
6222
6225
|
case "trust":
|
|
6223
6226
|
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
6224
6227
|
case "okx":
|
|
6225
6228
|
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
6226
6229
|
// Solana
|
|
6230
|
+
// Phantom is one app with one in-app browser — browsing there injects
|
|
6231
|
+
// both window.ethereum and window.phantom.solana, so "phantom-evm"
|
|
6232
|
+
// reuses the same browse link as "phantom-solana".
|
|
6227
6233
|
case "phantom-solana":
|
|
6228
|
-
|
|
6234
|
+
case "phantom-evm":
|
|
6235
|
+
return `https://phantom.app/ul/browse/${enc}?ref=${enc}`;
|
|
6229
6236
|
case "solflare":
|
|
6230
|
-
return `solflare
|
|
6237
|
+
return `https://solflare.com/ul/v1/browse/${enc}?ref=${enc}`;
|
|
6231
6238
|
case "backpack":
|
|
6232
6239
|
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
6233
6240
|
// No confirmed deep link scheme
|
|
@@ -6337,8 +6344,10 @@ var init_metadata = __esm({
|
|
|
6337
6344
|
homepage: "https://phantom.app/",
|
|
6338
6345
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
6339
6346
|
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
6340
|
-
detectFlags: ["isPhantom"]
|
|
6341
|
-
//
|
|
6347
|
+
detectFlags: ["isPhantom"],
|
|
6348
|
+
// Same app/in-app browser as "phantom-solana" — browsing there injects
|
|
6349
|
+
// window.ethereum too.
|
|
6350
|
+
deepLink: (url) => formatDeepLink("phantom-evm", url) ?? ""
|
|
6342
6351
|
},
|
|
6343
6352
|
{
|
|
6344
6353
|
id: "phantom-solana",
|
|
@@ -6386,8 +6395,10 @@ var init_metadata = __esm({
|
|
|
6386
6395
|
emoji: "\u{1F98A}",
|
|
6387
6396
|
homepage: "https://metamask.io/",
|
|
6388
6397
|
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
6389
|
-
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
6390
|
-
//
|
|
6398
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
6399
|
+
// Same app/in-app browser as "metamask" — its Wallet Standard Solana
|
|
6400
|
+
// provider is exposed in that same browse session.
|
|
6401
|
+
deepLink: (url) => formatDeepLink("metamask-solana", url) ?? ""
|
|
6391
6402
|
},
|
|
6392
6403
|
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
6393
6404
|
{
|
|
@@ -6898,7 +6909,7 @@ var init_walletconnect = __esm({
|
|
|
6898
6909
|
solanaMainnet = {
|
|
6899
6910
|
id: 900,
|
|
6900
6911
|
chainNamespace: "solana",
|
|
6901
|
-
caipNetworkId: "solana:
|
|
6912
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
6902
6913
|
name: "Solana Mainnet",
|
|
6903
6914
|
nativeCurrency: {
|
|
6904
6915
|
name: "Solana",
|
|
@@ -7777,8 +7788,62 @@ function getChainMeta(chainId) {
|
|
|
7777
7788
|
rpcUrls: chain.rpcUrls.default.http
|
|
7778
7789
|
};
|
|
7779
7790
|
}
|
|
7780
|
-
|
|
7791
|
+
function extractSolanaAddress(connector) {
|
|
7792
|
+
const caipAccount = connector.provider.session?.namespaces?.solana?.accounts?.[0];
|
|
7793
|
+
if (!caipAccount) return null;
|
|
7794
|
+
return caipAccount.split(":")[2] ?? null;
|
|
7795
|
+
}
|
|
7796
|
+
function buildWalletConnectSolanaProvider(connector) {
|
|
7797
|
+
return {
|
|
7798
|
+
get publicKey() {
|
|
7799
|
+
const address = extractSolanaAddress(connector);
|
|
7800
|
+
return address ? { toString: () => address } : void 0;
|
|
7801
|
+
},
|
|
7802
|
+
async connect() {
|
|
7803
|
+
const address = extractSolanaAddress(connector);
|
|
7804
|
+
if (!address) {
|
|
7805
|
+
throw new Error(
|
|
7806
|
+
"This wallet did not approve a Solana account over WalletConnect."
|
|
7807
|
+
);
|
|
7808
|
+
}
|
|
7809
|
+
return { publicKey: { toString: () => address } };
|
|
7810
|
+
},
|
|
7811
|
+
async disconnect() {
|
|
7812
|
+
},
|
|
7813
|
+
async signTransaction(transaction) {
|
|
7814
|
+
const tx = transaction;
|
|
7815
|
+
const rawBytes = "version" in tx ? tx.serialize() : tx.serialize({
|
|
7816
|
+
requireAllSignatures: false,
|
|
7817
|
+
verifySignatures: false
|
|
7818
|
+
});
|
|
7819
|
+
const result = await connector.provider.request(
|
|
7820
|
+
{
|
|
7821
|
+
method: "solana_signTransaction",
|
|
7822
|
+
params: { transaction: encodeBase64(rawBytes) }
|
|
7823
|
+
},
|
|
7824
|
+
solanaMainnet.caipNetworkId
|
|
7825
|
+
);
|
|
7826
|
+
if (!result.transaction) {
|
|
7827
|
+
throw new Error(
|
|
7828
|
+
"WalletConnect wallet did not return a signed Solana transaction."
|
|
7829
|
+
);
|
|
7830
|
+
}
|
|
7831
|
+
const signedBytes = decodeBase64(result.transaction);
|
|
7832
|
+
return { serialize: () => signedBytes };
|
|
7833
|
+
},
|
|
7834
|
+
on() {
|
|
7835
|
+
},
|
|
7836
|
+
off() {
|
|
7837
|
+
},
|
|
7838
|
+
removeListener() {
|
|
7839
|
+
}
|
|
7840
|
+
};
|
|
7841
|
+
}
|
|
7842
|
+
async function buildWalletConnectAPI(walletCfg, ecosystem = "evm") {
|
|
7781
7843
|
const connector = await getUniversalConnector(walletCfg);
|
|
7844
|
+
if (ecosystem === "solana") {
|
|
7845
|
+
return toSolanaWalletInterface(buildWalletConnectSolanaProvider(connector));
|
|
7846
|
+
}
|
|
7782
7847
|
const provider = connector.provider;
|
|
7783
7848
|
const api = {
|
|
7784
7849
|
ecosystem: "evm",
|
|
@@ -7848,7 +7913,7 @@ function bindWalletConnectEvents(provider, callbacks) {
|
|
|
7848
7913
|
function useWalletConnectConnect(walletCfg) {
|
|
7849
7914
|
const cfgRef = { current: walletCfg };
|
|
7850
7915
|
return useCallback4(
|
|
7851
|
-
() => walletManager.connectWalletConnect(cfgRef.current),
|
|
7916
|
+
(ecosystem) => walletManager.connectWalletConnect(cfgRef.current, ecosystem),
|
|
7852
7917
|
[]
|
|
7853
7918
|
);
|
|
7854
7919
|
}
|
|
@@ -7868,6 +7933,7 @@ function useWalletInfo(wagmi) {
|
|
|
7868
7933
|
connectedVia: snapshot.connectedVia,
|
|
7869
7934
|
walletType: snapshot.walletType,
|
|
7870
7935
|
status: snapshot.status,
|
|
7936
|
+
detected: snapshot.detected,
|
|
7871
7937
|
disconnect
|
|
7872
7938
|
};
|
|
7873
7939
|
}
|
|
@@ -8018,44 +8084,39 @@ var init_manager = __esm({
|
|
|
8018
8084
|
this.emit();
|
|
8019
8085
|
}
|
|
8020
8086
|
}
|
|
8021
|
-
async connectWalletConnect(walletCfg) {
|
|
8022
|
-
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet) {
|
|
8087
|
+
async connectWalletConnect(walletCfg, ecosystem = "evm") {
|
|
8088
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet && this._wallet.ecosystem === ecosystem) {
|
|
8023
8089
|
this.emit();
|
|
8024
8090
|
return { error: null, api: this._wallet };
|
|
8025
8091
|
}
|
|
8092
|
+
if (this._connectedVia === "walletconnect" && this._wallet) {
|
|
8093
|
+
await this._wallet.disconnect?.().catch(() => {
|
|
8094
|
+
});
|
|
8095
|
+
resetUniversalConnector();
|
|
8096
|
+
}
|
|
8026
8097
|
this._status = "connecting";
|
|
8027
8098
|
this.clearConnectedState();
|
|
8028
8099
|
this.emit();
|
|
8029
8100
|
try {
|
|
8030
8101
|
const connector = await getUniversalConnector(walletCfg);
|
|
8031
8102
|
await connector.connect();
|
|
8032
|
-
const api = await buildWalletConnectAPI(walletCfg);
|
|
8103
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
8104
|
+
try {
|
|
8105
|
+
await api.getAddress();
|
|
8106
|
+
} catch {
|
|
8107
|
+
await api.disconnect?.().catch(() => {
|
|
8108
|
+
});
|
|
8109
|
+
resetUniversalConnector();
|
|
8110
|
+
throw new Error(
|
|
8111
|
+
`This wallet did not approve a${ecosystem === "evm" ? "n" : ""} ${ecosystem === "evm" ? "EVM" : "Solana"} account over WalletConnect.`
|
|
8112
|
+
);
|
|
8113
|
+
}
|
|
8033
8114
|
this._wallet = api;
|
|
8034
8115
|
this._connectedVia = "walletconnect";
|
|
8035
8116
|
this._connectedWalletId = "walletconnect";
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
if (accounts.length === 0) {
|
|
8040
|
-
this.fullReset();
|
|
8041
|
-
this.triggerExternalDisconnect();
|
|
8042
|
-
this.emit();
|
|
8043
|
-
return;
|
|
8044
|
-
}
|
|
8045
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
8046
|
-
this.emit();
|
|
8047
|
-
},
|
|
8048
|
-
onChainChanged: () => {
|
|
8049
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
8050
|
-
this.emit();
|
|
8051
|
-
},
|
|
8052
|
-
onDisconnect: () => {
|
|
8053
|
-
this.fullReset();
|
|
8054
|
-
resetUniversalConnector();
|
|
8055
|
-
this.triggerExternalDisconnect();
|
|
8056
|
-
this.emit();
|
|
8057
|
-
}
|
|
8058
|
-
});
|
|
8117
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
8118
|
+
connector.provider
|
|
8119
|
+
);
|
|
8059
8120
|
await this.syncIdentityFromWallet("walletconnect");
|
|
8060
8121
|
this._status = "connected";
|
|
8061
8122
|
this._error = null;
|
|
@@ -8070,6 +8131,100 @@ var init_manager = __esm({
|
|
|
8070
8131
|
return { error: message, api: null };
|
|
8071
8132
|
}
|
|
8072
8133
|
}
|
|
8134
|
+
bindWalletConnectProviderEvents(provider) {
|
|
8135
|
+
return bindWalletConnectEvents(provider, {
|
|
8136
|
+
onAccountsChanged: (accounts) => {
|
|
8137
|
+
if (accounts.length === 0) {
|
|
8138
|
+
this.fullReset();
|
|
8139
|
+
this.triggerExternalDisconnect();
|
|
8140
|
+
this.emit();
|
|
8141
|
+
return;
|
|
8142
|
+
}
|
|
8143
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
8144
|
+
this.emit();
|
|
8145
|
+
},
|
|
8146
|
+
onChainChanged: () => {
|
|
8147
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
8148
|
+
this.emit();
|
|
8149
|
+
},
|
|
8150
|
+
onDisconnect: () => {
|
|
8151
|
+
this.fullReset();
|
|
8152
|
+
resetUniversalConnector();
|
|
8153
|
+
this.triggerExternalDisconnect();
|
|
8154
|
+
this.emit();
|
|
8155
|
+
}
|
|
8156
|
+
});
|
|
8157
|
+
}
|
|
8158
|
+
// WalletConnect's own SignClient auto-restores the last persisted session
|
|
8159
|
+
// from storage on every init — including after a fresh page load — but
|
|
8160
|
+
// that restoration happens silently inside the library. Nothing calls back
|
|
8161
|
+
// into our code for it. On mobile, backgrounding the tab to approve in a
|
|
8162
|
+
// wallet app can cause the OS to reload the page before the original
|
|
8163
|
+
// connect() promise ever resolves, so the connect flow that triggered the
|
|
8164
|
+
// approval never gets to record it as "connected" here — even though
|
|
8165
|
+
// WalletConnect itself already has a live, approved session sitting in
|
|
8166
|
+
// storage. Call this on mount to pick that back up.
|
|
8167
|
+
async restoreWalletConnectSession(walletCfg) {
|
|
8168
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect") {
|
|
8169
|
+
return this._wallet?.ecosystem === "solana" ? "solana" : "evm";
|
|
8170
|
+
}
|
|
8171
|
+
if (typeof window === "undefined") return null;
|
|
8172
|
+
try {
|
|
8173
|
+
if (!Object.keys(window.localStorage).some((key) => key.startsWith("wc@2"))) {
|
|
8174
|
+
return null;
|
|
8175
|
+
}
|
|
8176
|
+
} catch {
|
|
8177
|
+
}
|
|
8178
|
+
let connector;
|
|
8179
|
+
try {
|
|
8180
|
+
connector = await getUniversalConnector(walletCfg);
|
|
8181
|
+
} catch (e2) {
|
|
8182
|
+
console.warn(
|
|
8183
|
+
"[Trustware SDK] Failed to restore WalletConnect session:",
|
|
8184
|
+
e2
|
|
8185
|
+
);
|
|
8186
|
+
return null;
|
|
8187
|
+
}
|
|
8188
|
+
const session = connector.provider.session;
|
|
8189
|
+
if (!session) return null;
|
|
8190
|
+
const ecosystem = session.namespaces?.solana?.accounts?.length ? "solana" : session.namespaces?.eip155?.accounts?.length ? "evm" : null;
|
|
8191
|
+
if (!ecosystem) return null;
|
|
8192
|
+
try {
|
|
8193
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
8194
|
+
this._wallet = api;
|
|
8195
|
+
this._connectedVia = "walletconnect";
|
|
8196
|
+
this._connectedWalletId = "walletconnect";
|
|
8197
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
8198
|
+
connector.provider
|
|
8199
|
+
);
|
|
8200
|
+
await this.syncIdentityFromWallet("walletconnect");
|
|
8201
|
+
this._status = "connected";
|
|
8202
|
+
this._error = null;
|
|
8203
|
+
this.emit();
|
|
8204
|
+
return ecosystem;
|
|
8205
|
+
} catch {
|
|
8206
|
+
return null;
|
|
8207
|
+
}
|
|
8208
|
+
}
|
|
8209
|
+
// Forcibly abandon an in-progress connect() call the caller has decided is
|
|
8210
|
+
// stuck (e.g. the UI's own connect timeout elapsed with no response).
|
|
8211
|
+
// There's no clean way to cancel a pending WalletConnect pairing proposal
|
|
8212
|
+
// from this side, so this tears down the whole connector — the next
|
|
8213
|
+
// connect attempt starts against a brand new SignClient/pairing instead of
|
|
8214
|
+
// racing the abandoned one, which would otherwise risk reproducing the
|
|
8215
|
+
// "No matching key. proposal" class of error a real retry needs to avoid.
|
|
8216
|
+
cancelWalletConnectAttempt() {
|
|
8217
|
+
if (this._connectedVia === "walletconnect" && this._status === "connected") {
|
|
8218
|
+
return;
|
|
8219
|
+
}
|
|
8220
|
+
resetUniversalConnector();
|
|
8221
|
+
if (this._status === "connecting") {
|
|
8222
|
+
this.clearConnectedState();
|
|
8223
|
+
this._status = "idle";
|
|
8224
|
+
this._error = null;
|
|
8225
|
+
this.emit();
|
|
8226
|
+
}
|
|
8227
|
+
}
|
|
8073
8228
|
async disconnect(wagmi) {
|
|
8074
8229
|
if (wagmi && this._connectedVia === "extension") {
|
|
8075
8230
|
await wagmi.disconnect().catch(() => {
|
|
@@ -9270,15 +9425,74 @@ var init_useWalletSessionState = __esm({
|
|
|
9270
9425
|
});
|
|
9271
9426
|
|
|
9272
9427
|
// src/widget/state/deposit/useWalletConnect.ts
|
|
9273
|
-
import { useCallback as useCallback10 } from "react";
|
|
9428
|
+
import { useCallback as useCallback10, useEffect as useEffect13, useRef as useRef5, useState as useState13 } from "react";
|
|
9274
9429
|
function useWalletConnect({
|
|
9275
9430
|
setWalletType,
|
|
9276
|
-
setCurrentStep
|
|
9431
|
+
setCurrentStep,
|
|
9432
|
+
selectedNamespace,
|
|
9433
|
+
setSelectedNamespace
|
|
9277
9434
|
}) {
|
|
9278
9435
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
9279
9436
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
9437
|
+
const ecosystem = selectedNamespace.trim().toLowerCase() === "solana" ? "solana" : "evm";
|
|
9438
|
+
const [wcStatus, setWcStatus] = useState13("idle");
|
|
9439
|
+
const [wcErrorMessage, setWcErrorMessage] = useState13(null);
|
|
9440
|
+
const wcTimeoutRef = useRef5(null);
|
|
9441
|
+
const clearWcTimeout = useCallback10(() => {
|
|
9442
|
+
if (wcTimeoutRef.current !== null) {
|
|
9443
|
+
clearTimeout(wcTimeoutRef.current);
|
|
9444
|
+
wcTimeoutRef.current = null;
|
|
9445
|
+
}
|
|
9446
|
+
}, []);
|
|
9447
|
+
const beginWcAttempt = useCallback10(() => {
|
|
9448
|
+
setWcStatus("connecting");
|
|
9449
|
+
setWcErrorMessage(null);
|
|
9450
|
+
clearWcTimeout();
|
|
9451
|
+
wcTimeoutRef.current = setTimeout(() => {
|
|
9452
|
+
wcTimeoutRef.current = null;
|
|
9453
|
+
setWcStatus((prev) => prev === "connecting" ? "timedOut" : prev);
|
|
9454
|
+
}, WC_CONNECT_TIMEOUT_MS);
|
|
9455
|
+
}, [clearWcTimeout]);
|
|
9456
|
+
const resolveWcAttempt = useCallback10(() => {
|
|
9457
|
+
clearWcTimeout();
|
|
9458
|
+
setWcStatus("idle");
|
|
9459
|
+
setWcErrorMessage(null);
|
|
9460
|
+
}, [clearWcTimeout]);
|
|
9461
|
+
const failWcAttempt = useCallback10(
|
|
9462
|
+
(message) => {
|
|
9463
|
+
clearWcTimeout();
|
|
9464
|
+
setWcStatus("failed");
|
|
9465
|
+
setWcErrorMessage(message);
|
|
9466
|
+
},
|
|
9467
|
+
[clearWcTimeout]
|
|
9468
|
+
);
|
|
9469
|
+
const dismissWcStatus = useCallback10(() => {
|
|
9470
|
+
clearWcTimeout();
|
|
9471
|
+
setWcStatus("idle");
|
|
9472
|
+
setWcErrorMessage(null);
|
|
9473
|
+
}, [clearWcTimeout]);
|
|
9474
|
+
useEffect13(() => clearWcTimeout, [clearWcTimeout]);
|
|
9475
|
+
useEffect13(() => {
|
|
9476
|
+
let cancelled = false;
|
|
9477
|
+
beginWcAttempt();
|
|
9478
|
+
void (async () => {
|
|
9479
|
+
const restoredEcosystem = await walletManager.restoreWalletConnectSession(walletConnectCfg);
|
|
9480
|
+
if (cancelled) return;
|
|
9481
|
+
resolveWcAttempt();
|
|
9482
|
+
if (!restoredEcosystem) return;
|
|
9483
|
+
setWalletType("walletconnect");
|
|
9484
|
+
if (restoredEcosystem === "solana") {
|
|
9485
|
+
setSelectedNamespace("Solana");
|
|
9486
|
+
}
|
|
9487
|
+
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
9488
|
+
if (address) setCurrentStep("crypto-pay");
|
|
9489
|
+
})();
|
|
9490
|
+
return () => {
|
|
9491
|
+
cancelled = true;
|
|
9492
|
+
};
|
|
9493
|
+
}, []);
|
|
9280
9494
|
const WalletConnect = useCallback10(async () => {
|
|
9281
|
-
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect") {
|
|
9495
|
+
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" && walletManager.wallet?.ecosystem === ecosystem) {
|
|
9282
9496
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
9283
9497
|
if (address) {
|
|
9284
9498
|
setWalletType("walletconnect");
|
|
@@ -9287,38 +9501,64 @@ function useWalletConnect({
|
|
|
9287
9501
|
}
|
|
9288
9502
|
}
|
|
9289
9503
|
setWalletType("walletconnect");
|
|
9290
|
-
|
|
9504
|
+
beginWcAttempt();
|
|
9505
|
+
const { error } = await connectWC(ecosystem);
|
|
9291
9506
|
if (!error) {
|
|
9292
9507
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
9293
9508
|
if (address) {
|
|
9509
|
+
resolveWcAttempt();
|
|
9294
9510
|
setCurrentStep("crypto-pay");
|
|
9511
|
+
} else {
|
|
9512
|
+
const message = `WalletConnect session established but no address resolved for ecosystem "${ecosystem}".`;
|
|
9513
|
+
console.error(`[Trustware SDK] ${message}`);
|
|
9514
|
+
failWcAttempt(message);
|
|
9295
9515
|
}
|
|
9296
9516
|
} else {
|
|
9517
|
+
console.error("[Trustware SDK] WalletConnect connection failed:", error);
|
|
9518
|
+
failWcAttempt(error);
|
|
9297
9519
|
setWalletType("other");
|
|
9298
9520
|
}
|
|
9299
|
-
}, [
|
|
9521
|
+
}, [
|
|
9522
|
+
beginWcAttempt,
|
|
9523
|
+
connectWC,
|
|
9524
|
+
ecosystem,
|
|
9525
|
+
failWcAttempt,
|
|
9526
|
+
resolveWcAttempt,
|
|
9527
|
+
setCurrentStep,
|
|
9528
|
+
setWalletType
|
|
9529
|
+
]);
|
|
9530
|
+
const retryWalletConnect = useCallback10(() => {
|
|
9531
|
+
walletManager.cancelWalletConnectAttempt();
|
|
9532
|
+
void WalletConnect();
|
|
9533
|
+
}, [WalletConnect]);
|
|
9300
9534
|
const disconnectWalletConnect = useCallback10(async () => {
|
|
9301
9535
|
await walletManager.disconnect();
|
|
9302
9536
|
setWalletType("other");
|
|
9303
9537
|
setCurrentStep("home");
|
|
9304
9538
|
}, [setCurrentStep, setWalletType]);
|
|
9305
|
-
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.
|
|
9539
|
+
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.identity?.addresses[0]?.address ?? null : null;
|
|
9306
9540
|
return {
|
|
9307
9541
|
walletConnectAddress,
|
|
9308
9542
|
WalletConnect,
|
|
9309
|
-
disconnectWalletConnect
|
|
9543
|
+
disconnectWalletConnect,
|
|
9544
|
+
wcStatus,
|
|
9545
|
+
wcErrorMessage,
|
|
9546
|
+
retryWalletConnect,
|
|
9547
|
+
dismissWcStatus
|
|
9310
9548
|
};
|
|
9311
9549
|
}
|
|
9550
|
+
var WC_CONNECT_TIMEOUT_MS;
|
|
9312
9551
|
var init_useWalletConnect = __esm({
|
|
9313
9552
|
"src/widget/state/deposit/useWalletConnect.ts"() {
|
|
9314
9553
|
"use strict";
|
|
9315
9554
|
init_config2();
|
|
9316
9555
|
init_wallets();
|
|
9556
|
+
WC_CONNECT_TIMEOUT_MS = 3e4;
|
|
9317
9557
|
}
|
|
9318
9558
|
});
|
|
9319
9559
|
|
|
9320
9560
|
// src/widget/context/DepositContext.tsx
|
|
9321
|
-
import React2, { createContext as createContext2, useContext as useContext2, useState as
|
|
9561
|
+
import React2, { createContext as createContext2, useContext as useContext2, useState as useState14, useMemo as useMemo7 } from "react";
|
|
9322
9562
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
9323
9563
|
function DepositProvider({
|
|
9324
9564
|
children,
|
|
@@ -9343,20 +9583,30 @@ function DepositProvider({
|
|
|
9343
9583
|
connectWallet,
|
|
9344
9584
|
disconnectWallet
|
|
9345
9585
|
} = useWalletSessionState();
|
|
9346
|
-
const [amountInputMode, setAmountInputMode] =
|
|
9586
|
+
const [amountInputMode, setAmountInputMode] = useState14(
|
|
9347
9587
|
"usd"
|
|
9348
9588
|
);
|
|
9349
|
-
const [walletType, setWalletType] =
|
|
9589
|
+
const [walletType, setWalletType] = useState14(
|
|
9350
9590
|
"other"
|
|
9351
9591
|
);
|
|
9352
|
-
const
|
|
9592
|
+
const [selectedNamespace, setSelectedNamespace] = useState14("evm");
|
|
9593
|
+
const {
|
|
9594
|
+
walletConnectAddress,
|
|
9595
|
+
WalletConnect,
|
|
9596
|
+
disconnectWalletConnect,
|
|
9597
|
+
wcStatus,
|
|
9598
|
+
wcErrorMessage,
|
|
9599
|
+
retryWalletConnect,
|
|
9600
|
+
dismissWcStatus
|
|
9601
|
+
} = useWalletConnect({
|
|
9353
9602
|
setWalletType,
|
|
9354
|
-
setCurrentStep
|
|
9603
|
+
setCurrentStep,
|
|
9604
|
+
selectedNamespace,
|
|
9605
|
+
setSelectedNamespace
|
|
9355
9606
|
});
|
|
9356
|
-
const [selectedToken, setSelectedToken] =
|
|
9357
|
-
const [selectedChain, setSelectedChain] =
|
|
9358
|
-
const [amount, setAmount] =
|
|
9359
|
-
const [selectedNamespace, setSelectedNamespace] = useState13("evm");
|
|
9607
|
+
const [selectedToken, setSelectedToken] = useState14(null);
|
|
9608
|
+
const [selectedChain, setSelectedChain] = useState14(null);
|
|
9609
|
+
const [amount, setAmount] = useState14("");
|
|
9360
9610
|
const walletAddress = useMemo7(
|
|
9361
9611
|
() => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
|
|
9362
9612
|
[walletType, walletConnectAddress, otherWalletAddress]
|
|
@@ -9374,11 +9624,11 @@ function DepositProvider({
|
|
|
9374
9624
|
selectedToken,
|
|
9375
9625
|
setSelectedToken
|
|
9376
9626
|
});
|
|
9377
|
-
const [transactionStatus, setTransactionStatus] =
|
|
9378
|
-
const [transactionHash, setTransactionHash] =
|
|
9379
|
-
const [errorMessage, setErrorMessage] =
|
|
9380
|
-
const [intentId, setIntentId] =
|
|
9381
|
-
const [paymentMethod, setPaymentMethod] =
|
|
9627
|
+
const [transactionStatus, setTransactionStatus] = useState14("idle");
|
|
9628
|
+
const [transactionHash, setTransactionHash] = useState14(null);
|
|
9629
|
+
const [errorMessage, setErrorMessage] = useState14(null);
|
|
9630
|
+
const [intentId, setIntentId] = useState14(null);
|
|
9631
|
+
const [paymentMethod, setPaymentMethod] = useState14("crypto");
|
|
9382
9632
|
const resetState = React2.useCallback(() => {
|
|
9383
9633
|
resetNavigation();
|
|
9384
9634
|
setSelectedToken(null);
|
|
@@ -9428,7 +9678,11 @@ function DepositProvider({
|
|
|
9428
9678
|
setWalletType,
|
|
9429
9679
|
walletType,
|
|
9430
9680
|
selectedNamespace,
|
|
9431
|
-
setSelectedNamespace
|
|
9681
|
+
setSelectedNamespace,
|
|
9682
|
+
wcStatus,
|
|
9683
|
+
wcErrorMessage,
|
|
9684
|
+
retryWalletConnect,
|
|
9685
|
+
dismissWcStatus
|
|
9432
9686
|
}),
|
|
9433
9687
|
[
|
|
9434
9688
|
WalletConnect,
|
|
@@ -9444,7 +9698,11 @@ function DepositProvider({
|
|
|
9444
9698
|
yourWalletTokens,
|
|
9445
9699
|
yourWalletTokensLoading,
|
|
9446
9700
|
selectedNamespace,
|
|
9447
|
-
setSelectedNamespace
|
|
9701
|
+
setSelectedNamespace,
|
|
9702
|
+
wcStatus,
|
|
9703
|
+
wcErrorMessage,
|
|
9704
|
+
retryWalletConnect,
|
|
9705
|
+
dismissWcStatus
|
|
9448
9706
|
]
|
|
9449
9707
|
);
|
|
9450
9708
|
const formValue = useMemo7(
|
|
@@ -9887,7 +10145,7 @@ var init_AmountSlider = __esm({
|
|
|
9887
10145
|
});
|
|
9888
10146
|
|
|
9889
10147
|
// src/widget/components/AmountInputDisplay.tsx
|
|
9890
|
-
import { useRef as
|
|
10148
|
+
import { useRef as useRef6, useState as useState15 } from "react";
|
|
9891
10149
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
9892
10150
|
function formatDisplayAmount(value) {
|
|
9893
10151
|
if (!Number.isFinite(value) || value <= 0) return "0";
|
|
@@ -9926,8 +10184,8 @@ function AmountInputDisplay({
|
|
|
9926
10184
|
style,
|
|
9927
10185
|
inputAriaLabel = "Deposit amount"
|
|
9928
10186
|
}) {
|
|
9929
|
-
const [isEditing, setIsEditing] =
|
|
9930
|
-
const inputRef =
|
|
10187
|
+
const [isEditing, setIsEditing] = useState15(false);
|
|
10188
|
+
const inputRef = useRef6(null);
|
|
9931
10189
|
const handleAmountClick = () => {
|
|
9932
10190
|
if (isFixedAmount) return;
|
|
9933
10191
|
const isZeroish = !amount || parseFloat(amount) === 0;
|
|
@@ -10160,15 +10418,15 @@ __export(ConfettiEffect_exports, {
|
|
|
10160
10418
|
ConfettiEffect: () => ConfettiEffect,
|
|
10161
10419
|
default: () => ConfettiEffect_default
|
|
10162
10420
|
});
|
|
10163
|
-
import { useEffect as
|
|
10421
|
+
import { useEffect as useEffect14, useState as useState16 } from "react";
|
|
10164
10422
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
10165
10423
|
function ConfettiEffect({
|
|
10166
10424
|
isActive,
|
|
10167
10425
|
clearDelay = 3e3,
|
|
10168
10426
|
pieceCount = 50
|
|
10169
10427
|
}) {
|
|
10170
|
-
const [pieces, setPieces] =
|
|
10171
|
-
|
|
10428
|
+
const [pieces, setPieces] = useState16([]);
|
|
10429
|
+
useEffect14(() => {
|
|
10172
10430
|
if (isActive) {
|
|
10173
10431
|
const colors2 = [
|
|
10174
10432
|
"#10b981",
|
|
@@ -10253,7 +10511,7 @@ var init_ConfettiEffect = __esm({
|
|
|
10253
10511
|
});
|
|
10254
10512
|
|
|
10255
10513
|
// src/widget/components/Dialog.tsx
|
|
10256
|
-
import { useEffect as
|
|
10514
|
+
import { useEffect as useEffect15, useRef as useRef7 } from "react";
|
|
10257
10515
|
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
10258
10516
|
var Dialog;
|
|
10259
10517
|
var init_Dialog = __esm({
|
|
@@ -10270,11 +10528,11 @@ var init_Dialog = __esm({
|
|
|
10270
10528
|
confirmText = "Close Anyway",
|
|
10271
10529
|
isDark = false
|
|
10272
10530
|
}) => {
|
|
10273
|
-
const dialogRef =
|
|
10274
|
-
const overlayRef =
|
|
10275
|
-
const firstButtonRef =
|
|
10276
|
-
const lastButtonRef =
|
|
10277
|
-
|
|
10531
|
+
const dialogRef = useRef7(null);
|
|
10532
|
+
const overlayRef = useRef7(null);
|
|
10533
|
+
const firstButtonRef = useRef7(null);
|
|
10534
|
+
const lastButtonRef = useRef7(null);
|
|
10535
|
+
useEffect15(() => {
|
|
10278
10536
|
const handleEscape = (e2) => {
|
|
10279
10537
|
if (e2.key === "Escape" && open) {
|
|
10280
10538
|
e2.preventDefault();
|
|
@@ -10288,7 +10546,7 @@ var init_Dialog = __esm({
|
|
|
10288
10546
|
document.removeEventListener("keydown", handleEscape);
|
|
10289
10547
|
};
|
|
10290
10548
|
}, [open, onCancel]);
|
|
10291
|
-
|
|
10549
|
+
useEffect15(() => {
|
|
10292
10550
|
const handleTabKey = (e2) => {
|
|
10293
10551
|
if (!open) return;
|
|
10294
10552
|
if (e2.key === "Tab") {
|
|
@@ -10312,7 +10570,7 @@ var init_Dialog = __esm({
|
|
|
10312
10570
|
document.removeEventListener("keydown", handleTabKey);
|
|
10313
10571
|
};
|
|
10314
10572
|
}, [open]);
|
|
10315
|
-
|
|
10573
|
+
useEffect15(() => {
|
|
10316
10574
|
if (open) {
|
|
10317
10575
|
const originalStyle = window.getComputedStyle(document.body).overflow;
|
|
10318
10576
|
document.body.style.overflow = "hidden";
|
|
@@ -10618,7 +10876,7 @@ var init_TransactionHashLink = __esm({
|
|
|
10618
10876
|
});
|
|
10619
10877
|
|
|
10620
10878
|
// src/widget/components/SwipeToConfirmTokens.tsx
|
|
10621
|
-
import { useState as
|
|
10879
|
+
import { useState as useState17, useRef as useRef8, useCallback as useCallback12, useEffect as useEffect16 } from "react";
|
|
10622
10880
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
10623
10881
|
function SwipeToConfirmTokens({
|
|
10624
10882
|
fromToken,
|
|
@@ -10633,16 +10891,16 @@ function SwipeToConfirmTokens({
|
|
|
10633
10891
|
style,
|
|
10634
10892
|
text
|
|
10635
10893
|
}) {
|
|
10636
|
-
const [dragX, setDragX] =
|
|
10637
|
-
const [isDragging, setIsDragging] =
|
|
10638
|
-
const [isComplete, setIsComplete] =
|
|
10639
|
-
const trackRef =
|
|
10640
|
-
const thumbRef =
|
|
10641
|
-
const [isLongPressing, setIsLongPressing] =
|
|
10642
|
-
const [longPressProgress, setLongPressProgress] =
|
|
10643
|
-
const longPressTimerRef =
|
|
10644
|
-
const longPressStartRef =
|
|
10645
|
-
const longPressAnimationRef =
|
|
10894
|
+
const [dragX, setDragX] = useState17(0);
|
|
10895
|
+
const [isDragging, setIsDragging] = useState17(false);
|
|
10896
|
+
const [isComplete, setIsComplete] = useState17(false);
|
|
10897
|
+
const trackRef = useRef8(null);
|
|
10898
|
+
const thumbRef = useRef8(null);
|
|
10899
|
+
const [isLongPressing, setIsLongPressing] = useState17(false);
|
|
10900
|
+
const [longPressProgress, setLongPressProgress] = useState17(0);
|
|
10901
|
+
const longPressTimerRef = useRef8(null);
|
|
10902
|
+
const longPressStartRef = useRef8(null);
|
|
10903
|
+
const longPressAnimationRef = useRef8(null);
|
|
10646
10904
|
const LONG_PRESS_DURATION = 1500;
|
|
10647
10905
|
const thumbSize = 48;
|
|
10648
10906
|
const padding = 4;
|
|
@@ -10740,7 +10998,7 @@ function SwipeToConfirmTokens({
|
|
|
10740
10998
|
},
|
|
10741
10999
|
[cancelLongPress]
|
|
10742
11000
|
);
|
|
10743
|
-
|
|
11001
|
+
useEffect16(() => {
|
|
10744
11002
|
return () => {
|
|
10745
11003
|
if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
|
|
10746
11004
|
if (longPressAnimationRef.current)
|
|
@@ -10759,7 +11017,7 @@ function SwipeToConfirmTokens({
|
|
|
10759
11017
|
const handleTouchStart = () => handleDragStart();
|
|
10760
11018
|
const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
|
|
10761
11019
|
const handleTouchEnd = () => handleDragEnd();
|
|
10762
|
-
|
|
11020
|
+
useEffect16(() => {
|
|
10763
11021
|
if (isDragging) {
|
|
10764
11022
|
window.addEventListener("mousemove", handleMouseMove);
|
|
10765
11023
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -10771,8 +11029,8 @@ function SwipeToConfirmTokens({
|
|
|
10771
11029
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
10772
11030
|
const progress = getProgress();
|
|
10773
11031
|
const effectiveProgress = isLongPressing ? longPressProgress : progress;
|
|
10774
|
-
const [blinkOpacity, setBlinkOpacity] =
|
|
10775
|
-
|
|
11032
|
+
const [blinkOpacity, setBlinkOpacity] = useState17(1);
|
|
11033
|
+
useEffect16(() => {
|
|
10776
11034
|
if (disabled || isComplete || isDragging || isLongPressing) {
|
|
10777
11035
|
setBlinkOpacity(1);
|
|
10778
11036
|
return;
|
|
@@ -11234,7 +11492,7 @@ var init_ThemeToggle = __esm({
|
|
|
11234
11492
|
});
|
|
11235
11493
|
|
|
11236
11494
|
// src/widget/components/Toast.tsx
|
|
11237
|
-
import { useEffect as
|
|
11495
|
+
import { useEffect as useEffect17, useState as useState18, useCallback as useCallback13 } from "react";
|
|
11238
11496
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
11239
11497
|
function ToastItem({
|
|
11240
11498
|
id,
|
|
@@ -11244,14 +11502,14 @@ function ToastItem({
|
|
|
11244
11502
|
duration = 4e3,
|
|
11245
11503
|
onDismiss
|
|
11246
11504
|
}) {
|
|
11247
|
-
const [isExiting, setIsExiting] =
|
|
11248
|
-
|
|
11505
|
+
const [isExiting, setIsExiting] = useState18(false);
|
|
11506
|
+
useEffect17(() => {
|
|
11249
11507
|
const timer = setTimeout(() => {
|
|
11250
11508
|
setIsExiting(true);
|
|
11251
11509
|
}, duration);
|
|
11252
11510
|
return () => clearTimeout(timer);
|
|
11253
11511
|
}, [duration]);
|
|
11254
|
-
|
|
11512
|
+
useEffect17(() => {
|
|
11255
11513
|
if (isExiting) {
|
|
11256
11514
|
const exitTimer = setTimeout(() => {
|
|
11257
11515
|
onDismiss(id);
|
|
@@ -11450,8 +11708,8 @@ function toast(data) {
|
|
|
11450
11708
|
};
|
|
11451
11709
|
}
|
|
11452
11710
|
function ToastContainer() {
|
|
11453
|
-
const [activeToasts, setActiveToasts] =
|
|
11454
|
-
|
|
11711
|
+
const [activeToasts, setActiveToasts] = useState18([]);
|
|
11712
|
+
useEffect17(() => {
|
|
11455
11713
|
const listener = (newToasts) => {
|
|
11456
11714
|
setActiveToasts(newToasts);
|
|
11457
11715
|
};
|
|
@@ -11533,10 +11791,10 @@ var init_Toast = __esm({
|
|
|
11533
11791
|
|
|
11534
11792
|
// src/widget/components/TokenSwipePill.tsx
|
|
11535
11793
|
import React9, {
|
|
11536
|
-
useState as
|
|
11537
|
-
useRef as
|
|
11794
|
+
useState as useState19,
|
|
11795
|
+
useRef as useRef9,
|
|
11538
11796
|
useCallback as useCallback14,
|
|
11539
|
-
useEffect as
|
|
11797
|
+
useEffect as useEffect18,
|
|
11540
11798
|
useMemo as useMemo9
|
|
11541
11799
|
} from "react";
|
|
11542
11800
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
@@ -11549,10 +11807,10 @@ function TokenSwipePill({
|
|
|
11549
11807
|
walletAddress,
|
|
11550
11808
|
style
|
|
11551
11809
|
}) {
|
|
11552
|
-
const [isDragging, setIsDragging] =
|
|
11553
|
-
const [dragOffset, setDragOffset] =
|
|
11554
|
-
const startXRef =
|
|
11555
|
-
const containerRef =
|
|
11810
|
+
const [isDragging, setIsDragging] = useState19(false);
|
|
11811
|
+
const [dragOffset, setDragOffset] = useState19(0);
|
|
11812
|
+
const startXRef = useRef9(0);
|
|
11813
|
+
const containerRef = useRef9(null);
|
|
11556
11814
|
const currentIndex = tokens.findIndex(
|
|
11557
11815
|
(t) => normalizeAddress2(
|
|
11558
11816
|
t.address,
|
|
@@ -11623,7 +11881,7 @@ function TokenSwipePill({
|
|
|
11623
11881
|
const handleTouchEnd = () => {
|
|
11624
11882
|
handleDragEnd();
|
|
11625
11883
|
};
|
|
11626
|
-
|
|
11884
|
+
useEffect18(() => {
|
|
11627
11885
|
if (isDragging) {
|
|
11628
11886
|
window.addEventListener("mousemove", handleMouseMove);
|
|
11629
11887
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -12328,7 +12586,7 @@ var init_TransactionSteps = __esm({
|
|
|
12328
12586
|
});
|
|
12329
12587
|
|
|
12330
12588
|
// src/widget/components/WidgetContainer.tsx
|
|
12331
|
-
import { useEffect as
|
|
12589
|
+
import { useEffect as useEffect19, useState as useState20 } from "react";
|
|
12332
12590
|
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
12333
12591
|
function WidgetContainer({
|
|
12334
12592
|
children,
|
|
@@ -12336,8 +12594,8 @@ function WidgetContainer({
|
|
|
12336
12594
|
className,
|
|
12337
12595
|
style
|
|
12338
12596
|
}) {
|
|
12339
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
12340
|
-
|
|
12597
|
+
const [resolvedTheme, setResolvedTheme] = useState20("light");
|
|
12598
|
+
useEffect19(() => {
|
|
12341
12599
|
if (theme === "system") {
|
|
12342
12600
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
12343
12601
|
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
@@ -12882,7 +13140,7 @@ var init_ErrorPage = __esm({
|
|
|
12882
13140
|
});
|
|
12883
13141
|
|
|
12884
13142
|
// src/widget/components/ImageLoader.tsx
|
|
12885
|
-
import { useCallback as useCallback15, useEffect as
|
|
13143
|
+
import { useCallback as useCallback15, useEffect as useEffect20, useMemo as useMemo11, useRef as useRef10, useState as useState21 } from "react";
|
|
12886
13144
|
import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
12887
13145
|
function Skeleton({
|
|
12888
13146
|
background,
|
|
@@ -12911,18 +13169,18 @@ function ImageLoader({
|
|
|
12911
13169
|
onLoad,
|
|
12912
13170
|
onError
|
|
12913
13171
|
}) {
|
|
12914
|
-
const [status, setStatus] =
|
|
12915
|
-
const [attempt, setAttempt] =
|
|
12916
|
-
const [srcIsEmpty, setSrcIsEmpty] =
|
|
12917
|
-
const imgRef =
|
|
12918
|
-
const observerRef =
|
|
12919
|
-
const onLoadRef =
|
|
12920
|
-
const onErrorRef =
|
|
12921
|
-
|
|
13172
|
+
const [status, setStatus] = useState21("idle");
|
|
13173
|
+
const [attempt, setAttempt] = useState21(0);
|
|
13174
|
+
const [srcIsEmpty, setSrcIsEmpty] = useState21(false);
|
|
13175
|
+
const imgRef = useRef10(null);
|
|
13176
|
+
const observerRef = useRef10(null);
|
|
13177
|
+
const onLoadRef = useRef10(onLoad);
|
|
13178
|
+
const onErrorRef = useRef10(onError);
|
|
13179
|
+
useEffect20(() => {
|
|
12922
13180
|
onLoadRef.current = onLoad;
|
|
12923
13181
|
onErrorRef.current = onError;
|
|
12924
13182
|
}, [onLoad, onError]);
|
|
12925
|
-
|
|
13183
|
+
useEffect20(() => {
|
|
12926
13184
|
if (status === "error" && attempt < retry) {
|
|
12927
13185
|
const timer = setTimeout(() => {
|
|
12928
13186
|
setAttempt((prev) => prev + 1);
|
|
@@ -12949,7 +13207,7 @@ function ImageLoader({
|
|
|
12949
13207
|
onErrorRef.current?.();
|
|
12950
13208
|
};
|
|
12951
13209
|
}, [src]);
|
|
12952
|
-
|
|
13210
|
+
useEffect20(() => {
|
|
12953
13211
|
if (!lazy3) {
|
|
12954
13212
|
const timer = setTimeout(() => loadImage(), 0);
|
|
12955
13213
|
return () => clearTimeout(timer);
|
|
@@ -13419,7 +13677,7 @@ var init_AvailableTokenListItem = __esm({
|
|
|
13419
13677
|
});
|
|
13420
13678
|
|
|
13421
13679
|
// src/widget/features/token-selection/components/ChainSelectorPanel.tsx
|
|
13422
|
-
import { useState as
|
|
13680
|
+
import { useState as useState22, useMemo as useMemo12 } from "react";
|
|
13423
13681
|
import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
13424
13682
|
function ChainItem({
|
|
13425
13683
|
chain,
|
|
@@ -13631,7 +13889,7 @@ function ChainSelectorPanel({
|
|
|
13631
13889
|
otherChains,
|
|
13632
13890
|
popularChains
|
|
13633
13891
|
}) {
|
|
13634
|
-
const [chainSearch, setChainSearch] =
|
|
13892
|
+
const [chainSearch, setChainSearch] = useState22("");
|
|
13635
13893
|
const filteredPopular = useMemo12(() => {
|
|
13636
13894
|
if (!chainSearch) return popularChains;
|
|
13637
13895
|
const q = chainSearch.toLowerCase();
|
|
@@ -14390,7 +14648,7 @@ var init_WalletTokenListItem = __esm({
|
|
|
14390
14648
|
});
|
|
14391
14649
|
|
|
14392
14650
|
// src/widget/features/token-selection/components/TokenSelectorPanel.tsx
|
|
14393
|
-
import { useState as
|
|
14651
|
+
import { useState as useState23, useEffect as useEffect21 } from "react";
|
|
14394
14652
|
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
14395
14653
|
function TokenSectionLabel({
|
|
14396
14654
|
children,
|
|
@@ -14486,8 +14744,8 @@ function TokenSelectorPanel({
|
|
|
14486
14744
|
setSearchQuery,
|
|
14487
14745
|
tokensError
|
|
14488
14746
|
}) {
|
|
14489
|
-
const [showAll, setShowAll] =
|
|
14490
|
-
|
|
14747
|
+
const [showAll, setShowAll] = useState23(false);
|
|
14748
|
+
useEffect21(() => {
|
|
14491
14749
|
setShowAll(false);
|
|
14492
14750
|
}, [selectedChain, searchQuery]);
|
|
14493
14751
|
const hasWalletTokens = filteredWalletTokens.length > 0;
|
|
@@ -15411,7 +15669,7 @@ var init_CryptoPayAmountSection = __esm({
|
|
|
15411
15669
|
});
|
|
15412
15670
|
|
|
15413
15671
|
// src/widget/features/amount/hooks/useDepositAmountModel.ts
|
|
15414
|
-
import { useEffect as
|
|
15672
|
+
import { useEffect as useEffect22, useMemo as useMemo15 } from "react";
|
|
15415
15673
|
function useDepositAmountModel({
|
|
15416
15674
|
amount,
|
|
15417
15675
|
setAmount,
|
|
@@ -15432,7 +15690,7 @@ function useDepositAmountModel({
|
|
|
15432
15690
|
);
|
|
15433
15691
|
return Number.isFinite(normalized) ? normalized : 0;
|
|
15434
15692
|
}, [selectedToken?.balance, selectedToken?.decimals]);
|
|
15435
|
-
|
|
15693
|
+
useEffect22(() => {
|
|
15436
15694
|
if (fixedFromAmountString) return;
|
|
15437
15695
|
if (isReady && !hasUsdPrice && amountInputMode === "usd") {
|
|
15438
15696
|
setAmountInputMode("token");
|
|
@@ -15444,7 +15702,7 @@ function useDepositAmountModel({
|
|
|
15444
15702
|
isReady,
|
|
15445
15703
|
setAmountInputMode
|
|
15446
15704
|
]);
|
|
15447
|
-
|
|
15705
|
+
useEffect22(() => {
|
|
15448
15706
|
if (!fixedFromAmountString) return;
|
|
15449
15707
|
if (amount !== fixedFromAmountString) {
|
|
15450
15708
|
setAmount(fixedFromAmountString);
|
|
@@ -15622,7 +15880,7 @@ var init_useDepositAmountModel = __esm({
|
|
|
15622
15880
|
});
|
|
15623
15881
|
|
|
15624
15882
|
// src/widget/features/amount/hooks/useHomeAmountModel.ts
|
|
15625
|
-
import { useEffect as
|
|
15883
|
+
import { useEffect as useEffect23, useMemo as useMemo16 } from "react";
|
|
15626
15884
|
function useHomeAmountModel({
|
|
15627
15885
|
amount,
|
|
15628
15886
|
setAmount,
|
|
@@ -15633,7 +15891,7 @@ function useHomeAmountModel({
|
|
|
15633
15891
|
minAmountUsd,
|
|
15634
15892
|
maxAmountUsd
|
|
15635
15893
|
}) {
|
|
15636
|
-
|
|
15894
|
+
useEffect23(() => {
|
|
15637
15895
|
if (!fixedFromAmountString) return;
|
|
15638
15896
|
if (amount !== fixedFromAmountString) {
|
|
15639
15897
|
setAmount(fixedFromAmountString);
|
|
@@ -16043,8 +16301,20 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
16043
16301
|
});
|
|
16044
16302
|
|
|
16045
16303
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
16046
|
-
import { useEffect as
|
|
16304
|
+
import { useEffect as useEffect24, useMemo as useMemo17, useRef as useRef11, useState as useState24 } from "react";
|
|
16047
16305
|
import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
16306
|
+
function ecosystemToNamespace(ecosystem) {
|
|
16307
|
+
switch (ecosystem.trim().toLowerCase()) {
|
|
16308
|
+
case "evm":
|
|
16309
|
+
return "evm";
|
|
16310
|
+
case "solana":
|
|
16311
|
+
return "Solana";
|
|
16312
|
+
case "bitcoin":
|
|
16313
|
+
return "bitcoin";
|
|
16314
|
+
default:
|
|
16315
|
+
return null;
|
|
16316
|
+
}
|
|
16317
|
+
}
|
|
16048
16318
|
function DesktopWalletDropdownContent({
|
|
16049
16319
|
browserWallets,
|
|
16050
16320
|
handleWalletConnect,
|
|
@@ -16110,38 +16380,70 @@ function DesktopWalletDropdownContent({
|
|
|
16110
16380
|
);
|
|
16111
16381
|
}
|
|
16112
16382
|
function MobileWalletDropdownContent({
|
|
16113
|
-
|
|
16383
|
+
browserWallets,
|
|
16384
|
+
handleWalletConnect,
|
|
16385
|
+
handleWalletSelect: connectDetectedWallet2
|
|
16114
16386
|
}) {
|
|
16115
16387
|
const { setCurrentStep } = useDepositNavigation();
|
|
16116
|
-
const { selectedNamespace } = useDepositWallet();
|
|
16117
|
-
const { walletMetaId, isConnected, status } = useWalletInfo();
|
|
16118
|
-
const [hoveredId, setHoveredId] =
|
|
16119
|
-
const storeFallbackTimeoutRef =
|
|
16388
|
+
const { selectedNamespace, setSelectedNamespace } = useDepositWallet();
|
|
16389
|
+
const { walletMetaId, isConnected, status, detected } = useWalletInfo();
|
|
16390
|
+
const [hoveredId, setHoveredId] = useState24(null);
|
|
16391
|
+
const storeFallbackTimeoutRef = useRef11(
|
|
16120
16392
|
null
|
|
16121
16393
|
);
|
|
16122
|
-
|
|
16394
|
+
useEffect24(() => {
|
|
16123
16395
|
return () => {
|
|
16124
16396
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
16125
16397
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16126
16398
|
}
|
|
16127
16399
|
};
|
|
16128
16400
|
}, []);
|
|
16401
|
+
useEffect24(() => {
|
|
16402
|
+
if (browserWallets.length > 0) return;
|
|
16403
|
+
const otherEcosystemWallet = detected.find((d) => {
|
|
16404
|
+
if (d.meta.id === "walletconnect") return false;
|
|
16405
|
+
const ecosystem = d.meta.ecosystem.trim().toLowerCase();
|
|
16406
|
+
return ecosystem !== "multi" && ecosystem !== selectedNamespace.trim().toLowerCase();
|
|
16407
|
+
});
|
|
16408
|
+
if (!otherEcosystemWallet) return;
|
|
16409
|
+
const nextNamespace = ecosystemToNamespace(
|
|
16410
|
+
otherEcosystemWallet.meta.ecosystem
|
|
16411
|
+
);
|
|
16412
|
+
if (nextNamespace) setSelectedNamespace(nextNamespace);
|
|
16413
|
+
}, [browserWallets, detected, selectedNamespace, setSelectedNamespace]);
|
|
16129
16414
|
const connectedWalletId = isConnected ? walletMetaId : null;
|
|
16130
16415
|
const currentUrl = window.location.href;
|
|
16131
|
-
const mobileWallets = useMemo17(
|
|
16132
|
-
|
|
16133
|
-
if (w.id === "walletconnect")
|
|
16416
|
+
const mobileWallets = useMemo17(() => {
|
|
16417
|
+
const entries = WALLETS.filter((w) => {
|
|
16418
|
+
if (w.id === "walletconnect") {
|
|
16419
|
+
return selectedNamespace.trim().toLowerCase() === "evm";
|
|
16420
|
+
}
|
|
16421
|
+
const isDetected = browserWallets.some((d) => d.meta.id === w.id);
|
|
16134
16422
|
const hasMobileLink = Boolean(w.deepLink);
|
|
16135
|
-
if (!hasMobileLink) return false;
|
|
16423
|
+
if (!hasMobileLink && !isDetected) return false;
|
|
16136
16424
|
return w.ecosystem.trim().toLowerCase() === "multi" || w.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase();
|
|
16137
|
-
})
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16425
|
+
}).map((meta) => ({
|
|
16426
|
+
meta,
|
|
16427
|
+
detectedWallet: browserWallets.find((d) => d.meta.id === meta.id) ?? null
|
|
16428
|
+
}));
|
|
16429
|
+
const listedIds = new Set(entries.map((e2) => e2.meta.id));
|
|
16430
|
+
for (const detected2 of browserWallets) {
|
|
16431
|
+
if (!listedIds.has(detected2.meta.id)) {
|
|
16432
|
+
entries.push({ meta: detected2.meta, detectedWallet: detected2 });
|
|
16433
|
+
}
|
|
16434
|
+
}
|
|
16435
|
+
return entries;
|
|
16436
|
+
}, [browserWallets, selectedNamespace]);
|
|
16437
|
+
const handleWalletSelect = (entry) => {
|
|
16438
|
+
const { meta: wallet, detectedWallet } = entry;
|
|
16141
16439
|
if (wallet.id === "walletconnect") {
|
|
16142
16440
|
handleWalletConnect();
|
|
16143
16441
|
return;
|
|
16144
16442
|
}
|
|
16443
|
+
if (detectedWallet) {
|
|
16444
|
+
void connectDetectedWallet2(detectedWallet);
|
|
16445
|
+
return;
|
|
16446
|
+
}
|
|
16145
16447
|
if (wallet.deepLink) {
|
|
16146
16448
|
const deepLinkUrl = wallet.deepLink(currentUrl);
|
|
16147
16449
|
if (deepLinkUrl) {
|
|
@@ -16211,15 +16513,16 @@ function MobileWalletDropdownContent({
|
|
|
16211
16513
|
scrollbarWidth: "thin",
|
|
16212
16514
|
scrollbarColor: `${colors.muted} transparent`
|
|
16213
16515
|
},
|
|
16214
|
-
children: mobileWallets.map((
|
|
16516
|
+
children: mobileWallets.map((entry) => {
|
|
16517
|
+
const wallet = entry.meta;
|
|
16215
16518
|
const isConnectedWallet = wallet.id === connectedWalletId;
|
|
16216
|
-
const isDisabled = isConnected && !isConnectedWallet;
|
|
16519
|
+
const isDisabled = isConnected && !isConnectedWallet && !entry.detectedWallet;
|
|
16217
16520
|
const isHovered = hoveredId === wallet.id;
|
|
16218
16521
|
return /* @__PURE__ */ jsxs30(
|
|
16219
16522
|
"button",
|
|
16220
16523
|
{
|
|
16221
16524
|
type: "button",
|
|
16222
|
-
onClick: () => !isDisabled && handleWalletSelect(
|
|
16525
|
+
onClick: () => !isDisabled && handleWalletSelect(entry),
|
|
16223
16526
|
onMouseEnter: () => !isDisabled && setHoveredId(wallet.id),
|
|
16224
16527
|
onMouseLeave: () => setHoveredId(null),
|
|
16225
16528
|
style: {
|
|
@@ -16295,7 +16598,7 @@ function MobileWalletDropdownContent({
|
|
|
16295
16598
|
}
|
|
16296
16599
|
}
|
|
16297
16600
|
),
|
|
16298
|
-
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "
|
|
16601
|
+
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "Continue" })
|
|
16299
16602
|
]
|
|
16300
16603
|
}
|
|
16301
16604
|
)
|
|
@@ -16360,7 +16663,9 @@ function CryptoWalletDropdownContent({
|
|
|
16360
16663
|
isMobile && /* @__PURE__ */ jsx36(
|
|
16361
16664
|
MobileWalletDropdownContent,
|
|
16362
16665
|
{
|
|
16363
|
-
|
|
16666
|
+
browserWallets,
|
|
16667
|
+
handleWalletConnect,
|
|
16668
|
+
handleWalletSelect
|
|
16364
16669
|
}
|
|
16365
16670
|
)
|
|
16366
16671
|
] });
|
|
@@ -16830,7 +17135,7 @@ var init_HomePaymentOptions = __esm({
|
|
|
16830
17135
|
});
|
|
16831
17136
|
|
|
16832
17137
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
16833
|
-
import { useCallback as useCallback18, useEffect as
|
|
17138
|
+
import { useCallback as useCallback18, useEffect as useEffect25, useMemo as useMemo18, useRef as useRef12, useState as useState25 } from "react";
|
|
16834
17139
|
function useHomeWalletActions({
|
|
16835
17140
|
connectWallet,
|
|
16836
17141
|
detectedWallets,
|
|
@@ -16839,12 +17144,12 @@ function useHomeWalletActions({
|
|
|
16839
17144
|
WalletConnect
|
|
16840
17145
|
// setCurrentStepInternal,
|
|
16841
17146
|
}) {
|
|
16842
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] =
|
|
16843
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] =
|
|
16844
|
-
const cryptoDropdownRef =
|
|
16845
|
-
const fiatDropdownRef =
|
|
17147
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState25(false);
|
|
17148
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState25(false);
|
|
17149
|
+
const cryptoDropdownRef = useRef12(null);
|
|
17150
|
+
const fiatDropdownRef = useRef12(null);
|
|
16846
17151
|
const { disconnect } = useWalletInfo();
|
|
16847
|
-
|
|
17152
|
+
useEffect25(() => {
|
|
16848
17153
|
const handleClickOutside = (event) => {
|
|
16849
17154
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16850
17155
|
setIsCryptoDropdownOpen(false);
|
|
@@ -16894,9 +17199,11 @@ function useHomeWalletActions({
|
|
|
16894
17199
|
const { selectedNamespace } = useDepositWallet();
|
|
16895
17200
|
const browserWallets = useMemo18(() => {
|
|
16896
17201
|
if (!detectedWallets?.length) return [];
|
|
16897
|
-
return detectedWallets.filter(
|
|
16898
|
-
(wallet
|
|
16899
|
-
|
|
17202
|
+
return detectedWallets.filter((wallet) => {
|
|
17203
|
+
if (wallet?.meta?.id === "walletconnect") return false;
|
|
17204
|
+
const ecosystem = wallet?.meta?.ecosystem.trim().toLowerCase();
|
|
17205
|
+
return ecosystem === "multi" || ecosystem === selectedNamespace.trim().toLowerCase();
|
|
17206
|
+
});
|
|
16900
17207
|
}, [detectedWallets, selectedNamespace]);
|
|
16901
17208
|
return {
|
|
16902
17209
|
browserWallets,
|
|
@@ -16930,11 +17237,114 @@ var init_wallet = __esm({
|
|
|
16930
17237
|
});
|
|
16931
17238
|
|
|
16932
17239
|
// src/widget/pages/Home.tsx
|
|
16933
|
-
import { jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17240
|
+
import { Fragment as Fragment8, jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17241
|
+
function WalletConnectStatusBanner({
|
|
17242
|
+
status,
|
|
17243
|
+
errorMessage,
|
|
17244
|
+
onRetry,
|
|
17245
|
+
onDismiss
|
|
17246
|
+
}) {
|
|
17247
|
+
const isDone = status !== "connecting";
|
|
17248
|
+
const isFailed = status === "failed";
|
|
17249
|
+
const { text, icon } = wcBannerCopy[status];
|
|
17250
|
+
return /* @__PURE__ */ jsxs35(
|
|
17251
|
+
"div",
|
|
17252
|
+
{
|
|
17253
|
+
style: {
|
|
17254
|
+
display: "flex",
|
|
17255
|
+
alignItems: "center",
|
|
17256
|
+
gap: spacing[2],
|
|
17257
|
+
width: "100%",
|
|
17258
|
+
padding: `${spacing[2.5]} ${spacing[3]}`,
|
|
17259
|
+
marginBottom: spacing[4],
|
|
17260
|
+
borderRadius: borderRadius.lg,
|
|
17261
|
+
backgroundColor: isFailed ? "rgba(239,68,68,0.1)" : isDone ? "rgba(234,179,8,0.1)" : colors.muted,
|
|
17262
|
+
border: isFailed ? "1px solid rgba(239,68,68,0.4)" : isDone ? "1px solid rgba(234,179,8,0.4)" : `1px solid ${colors.border}`
|
|
17263
|
+
},
|
|
17264
|
+
children: [
|
|
17265
|
+
icon === "spinner" ? /* @__PURE__ */ jsx44(
|
|
17266
|
+
"div",
|
|
17267
|
+
{
|
|
17268
|
+
style: {
|
|
17269
|
+
width: "0.875rem",
|
|
17270
|
+
height: "0.875rem",
|
|
17271
|
+
border: `2px solid ${colors.mutedForeground}`,
|
|
17272
|
+
borderTopColor: "transparent",
|
|
17273
|
+
borderRadius: "9999px",
|
|
17274
|
+
animation: "tw-spin 1s linear infinite",
|
|
17275
|
+
flexShrink: 0
|
|
17276
|
+
}
|
|
17277
|
+
}
|
|
17278
|
+
) : /* @__PURE__ */ jsx44("span", { style: { fontSize: fontSize.sm, flexShrink: 0 }, "aria-hidden": true, children: icon }),
|
|
17279
|
+
/* @__PURE__ */ jsxs35(
|
|
17280
|
+
"p",
|
|
17281
|
+
{
|
|
17282
|
+
style: {
|
|
17283
|
+
flex: 1,
|
|
17284
|
+
fontSize: fontSize.xs,
|
|
17285
|
+
color: isDone ? colors.foreground : colors.mutedForeground,
|
|
17286
|
+
margin: 0
|
|
17287
|
+
},
|
|
17288
|
+
children: [
|
|
17289
|
+
text,
|
|
17290
|
+
isFailed && errorMessage ? ` ${errorMessage}` : ""
|
|
17291
|
+
]
|
|
17292
|
+
}
|
|
17293
|
+
),
|
|
17294
|
+
isDone && /* @__PURE__ */ jsxs35(Fragment8, { children: [
|
|
17295
|
+
/* @__PURE__ */ jsx44(
|
|
17296
|
+
"button",
|
|
17297
|
+
{
|
|
17298
|
+
type: "button",
|
|
17299
|
+
onClick: onRetry,
|
|
17300
|
+
style: {
|
|
17301
|
+
fontSize: fontSize.xs,
|
|
17302
|
+
fontWeight: fontWeight.semibold,
|
|
17303
|
+
color: colors.primary,
|
|
17304
|
+
backgroundColor: "transparent",
|
|
17305
|
+
border: 0,
|
|
17306
|
+
cursor: "pointer",
|
|
17307
|
+
flexShrink: 0
|
|
17308
|
+
},
|
|
17309
|
+
children: "Retry"
|
|
17310
|
+
}
|
|
17311
|
+
),
|
|
17312
|
+
/* @__PURE__ */ jsx44(
|
|
17313
|
+
"button",
|
|
17314
|
+
{
|
|
17315
|
+
type: "button",
|
|
17316
|
+
onClick: onDismiss,
|
|
17317
|
+
"aria-label": "Dismiss",
|
|
17318
|
+
style: {
|
|
17319
|
+
fontSize: fontSize.xs,
|
|
17320
|
+
color: colors.mutedForeground,
|
|
17321
|
+
backgroundColor: "transparent",
|
|
17322
|
+
border: 0,
|
|
17323
|
+
cursor: "pointer",
|
|
17324
|
+
flexShrink: 0,
|
|
17325
|
+
padding: 0,
|
|
17326
|
+
lineHeight: 1
|
|
17327
|
+
},
|
|
17328
|
+
children: "\xD7"
|
|
17329
|
+
}
|
|
17330
|
+
)
|
|
17331
|
+
] })
|
|
17332
|
+
]
|
|
17333
|
+
}
|
|
17334
|
+
);
|
|
17335
|
+
}
|
|
16934
17336
|
function Home({ style: _style }) {
|
|
16935
17337
|
const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
|
|
16936
17338
|
const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
|
|
16937
|
-
const {
|
|
17339
|
+
const {
|
|
17340
|
+
connectWallet,
|
|
17341
|
+
WalletConnect,
|
|
17342
|
+
setWalletType,
|
|
17343
|
+
wcStatus,
|
|
17344
|
+
wcErrorMessage,
|
|
17345
|
+
retryWalletConnect,
|
|
17346
|
+
dismissWcStatus
|
|
17347
|
+
} = useDepositWallet();
|
|
16938
17348
|
const { resolvedTheme } = useDepositUi();
|
|
16939
17349
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
16940
17350
|
const { detected: detectedWallets } = useWalletDetection();
|
|
@@ -17016,6 +17426,15 @@ function Home({ style: _style }) {
|
|
|
17016
17426
|
position: "relative"
|
|
17017
17427
|
},
|
|
17018
17428
|
children: [
|
|
17429
|
+
wcStatus !== "idle" && /* @__PURE__ */ jsx44(
|
|
17430
|
+
WalletConnectStatusBanner,
|
|
17431
|
+
{
|
|
17432
|
+
status: wcStatus,
|
|
17433
|
+
errorMessage: wcErrorMessage,
|
|
17434
|
+
onRetry: retryWalletConnect,
|
|
17435
|
+
onDismiss: dismissWcStatus
|
|
17436
|
+
}
|
|
17437
|
+
),
|
|
17019
17438
|
/* @__PURE__ */ jsx44(
|
|
17020
17439
|
"p",
|
|
17021
17440
|
{
|
|
@@ -17091,6 +17510,7 @@ function Home({ style: _style }) {
|
|
|
17091
17510
|
}
|
|
17092
17511
|
);
|
|
17093
17512
|
}
|
|
17513
|
+
var wcBannerCopy;
|
|
17094
17514
|
var init_Home = __esm({
|
|
17095
17515
|
"src/widget/pages/Home.tsx"() {
|
|
17096
17516
|
"use strict";
|
|
@@ -17100,6 +17520,20 @@ var init_Home = __esm({
|
|
|
17100
17520
|
init_amount();
|
|
17101
17521
|
init_wallets();
|
|
17102
17522
|
init_wallet();
|
|
17523
|
+
wcBannerCopy = {
|
|
17524
|
+
connecting: {
|
|
17525
|
+
text: "Waiting for wallet approval via WalletConnect\u2026",
|
|
17526
|
+
icon: "spinner"
|
|
17527
|
+
},
|
|
17528
|
+
timedOut: {
|
|
17529
|
+
text: "Still waiting on WalletConnect \u2014 this is taking longer than expected.",
|
|
17530
|
+
icon: "\u26A0\uFE0F"
|
|
17531
|
+
},
|
|
17532
|
+
failed: {
|
|
17533
|
+
text: "WalletConnect connection failed.",
|
|
17534
|
+
icon: "\u2715"
|
|
17535
|
+
}
|
|
17536
|
+
};
|
|
17103
17537
|
}
|
|
17104
17538
|
});
|
|
17105
17539
|
|
|
@@ -30950,7 +31384,7 @@ var init_smart_account2 = __esm({
|
|
|
30950
31384
|
});
|
|
30951
31385
|
|
|
30952
31386
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
30953
|
-
import { useCallback as useCallback19, useEffect as
|
|
31387
|
+
import { useCallback as useCallback19, useEffect as useEffect26, useMemo as useMemo20, useRef as useRef13, useState as useState26 } from "react";
|
|
30954
31388
|
import { encodeFunctionData as encodeFunctionData8, erc20Abi } from "viem";
|
|
30955
31389
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
30956
31390
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
@@ -30972,7 +31406,7 @@ function useTransactionActionModel({
|
|
|
30972
31406
|
walletAddress,
|
|
30973
31407
|
walletStatus
|
|
30974
31408
|
}) {
|
|
30975
|
-
const feeDataCacheRef =
|
|
31409
|
+
const feeDataCacheRef = useRef13({});
|
|
30976
31410
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
30977
31411
|
const { trackEvent } = useGTM(GTM_ID);
|
|
30978
31412
|
const destinationConfig = (() => {
|
|
@@ -31024,10 +31458,10 @@ function useTransactionActionModel({
|
|
|
31024
31458
|
const addr = txReq?.to ?? txReq?.target;
|
|
31025
31459
|
return addr ?? null;
|
|
31026
31460
|
}, [routeResult?.txReq]);
|
|
31027
|
-
const [allowanceWei, setAllowanceWei] =
|
|
31028
|
-
const [isReadingAllowance, setIsReadingAllowance] =
|
|
31029
|
-
const [isApproving, setIsApproving] =
|
|
31030
|
-
const [gasReservationWei, setGasReservationWei] =
|
|
31461
|
+
const [allowanceWei, setAllowanceWei] = useState26(0n);
|
|
31462
|
+
const [isReadingAllowance, setIsReadingAllowance] = useState26(false);
|
|
31463
|
+
const [isApproving, setIsApproving] = useState26(false);
|
|
31464
|
+
const [gasReservationWei, setGasReservationWei] = useState26(0n);
|
|
31031
31465
|
const readAllowance = useCallback19(async () => {
|
|
31032
31466
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
31033
31467
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
@@ -31058,7 +31492,7 @@ function useTransactionActionModel({
|
|
|
31058
31492
|
spender,
|
|
31059
31493
|
walletAddress
|
|
31060
31494
|
]);
|
|
31061
|
-
|
|
31495
|
+
useEffect26(() => {
|
|
31062
31496
|
void readAllowance();
|
|
31063
31497
|
}, [readAllowance]);
|
|
31064
31498
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
@@ -31262,13 +31696,13 @@ function useTransactionActionModel({
|
|
|
31262
31696
|
routeResult?.txReq,
|
|
31263
31697
|
walletAddress
|
|
31264
31698
|
]);
|
|
31265
|
-
|
|
31699
|
+
useEffect26(() => {
|
|
31266
31700
|
if (routeResult) {
|
|
31267
31701
|
void estimateGasReservationWei();
|
|
31268
31702
|
}
|
|
31269
31703
|
}, [estimateGasReservationWei, routeResult]);
|
|
31270
|
-
const [smartAccountFailed, setSmartAccountFailed] =
|
|
31271
|
-
|
|
31704
|
+
const [smartAccountFailed, setSmartAccountFailed] = useState26(false);
|
|
31705
|
+
useEffect26(() => {
|
|
31272
31706
|
setSmartAccountFailed(false);
|
|
31273
31707
|
}, [routeResult?.intentId]);
|
|
31274
31708
|
const handleConfirm = useCallback19(async () => {
|
|
@@ -31602,12 +32036,12 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31602
32036
|
});
|
|
31603
32037
|
|
|
31604
32038
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31605
|
-
import { useState as
|
|
32039
|
+
import { useState as useState27, useEffect as useEffect27 } from "react";
|
|
31606
32040
|
import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
31607
32041
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31608
|
-
const [messageIndex, setMessageIndex] =
|
|
31609
|
-
const [visible, setVisible] =
|
|
31610
|
-
|
|
32042
|
+
const [messageIndex, setMessageIndex] = useState27(0);
|
|
32043
|
+
const [visible, setVisible] = useState27(true);
|
|
32044
|
+
useEffect27(() => {
|
|
31611
32045
|
let t = null;
|
|
31612
32046
|
const interval = setInterval(() => {
|
|
31613
32047
|
setVisible(false);
|
|
@@ -31783,8 +32217,8 @@ var init_RouteQuoteLoader = __esm({
|
|
|
31783
32217
|
});
|
|
31784
32218
|
|
|
31785
32219
|
// src/widget/pages/CryptoPay/index.tsx
|
|
31786
|
-
import { useEffect as
|
|
31787
|
-
import { Fragment as
|
|
32220
|
+
import { useEffect as useEffect28, useMemo as useMemo21 } from "react";
|
|
32221
|
+
import { Fragment as Fragment9, jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
31788
32222
|
function CryptoPay({ style: _style }) {
|
|
31789
32223
|
const {
|
|
31790
32224
|
amount,
|
|
@@ -31893,7 +32327,7 @@ function CryptoPay({ style: _style }) {
|
|
|
31893
32327
|
});
|
|
31894
32328
|
const { emitError } = useTrustware();
|
|
31895
32329
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
31896
|
-
|
|
32330
|
+
useEffect28(() => {
|
|
31897
32331
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
31898
32332
|
emitError?.(
|
|
31899
32333
|
new TrustwareError({
|
|
@@ -32023,7 +32457,7 @@ function CryptoPay({ style: _style }) {
|
|
|
32023
32457
|
]
|
|
32024
32458
|
}
|
|
32025
32459
|
),
|
|
32026
|
-
showSkeleton ? /* @__PURE__ */ jsx50(
|
|
32460
|
+
showSkeleton ? /* @__PURE__ */ jsx50(Fragment9, { children: /* @__PURE__ */ jsx50(
|
|
32027
32461
|
"div",
|
|
32028
32462
|
{
|
|
32029
32463
|
style: {
|
|
@@ -32034,8 +32468,8 @@ function CryptoPay({ style: _style }) {
|
|
|
32034
32468
|
},
|
|
32035
32469
|
children: /* @__PURE__ */ jsx50(LoadingSkeleton, {})
|
|
32036
32470
|
}
|
|
32037
|
-
) }) : /* @__PURE__ */ jsxs40(
|
|
32038
|
-
isReady && /* @__PURE__ */ jsx50(
|
|
32471
|
+
) }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32472
|
+
isReady && /* @__PURE__ */ jsx50(Fragment9, { children: isLoadingRoute && !routeResult ? /* @__PURE__ */ jsx50(RouteQuoteLoader, { selectedToken: readySelectedToken }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32039
32473
|
/* @__PURE__ */ jsx50(
|
|
32040
32474
|
CryptoPayAmountSection,
|
|
32041
32475
|
{
|
|
@@ -32114,7 +32548,7 @@ var init_CryptoPay = __esm({
|
|
|
32114
32548
|
});
|
|
32115
32549
|
|
|
32116
32550
|
// src/widget/pages/Processing.tsx
|
|
32117
|
-
import { useEffect as
|
|
32551
|
+
import { useEffect as useEffect29, useMemo as useMemo22, useRef as useRef14 } from "react";
|
|
32118
32552
|
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
32119
32553
|
function getProgressFromStatus(status) {
|
|
32120
32554
|
switch (status) {
|
|
@@ -32153,13 +32587,13 @@ function Processing({ style }) {
|
|
|
32153
32587
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
32154
32588
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
32155
32589
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
32156
|
-
const hasStartedPolling =
|
|
32157
|
-
|
|
32590
|
+
const hasStartedPolling = useRef14(false);
|
|
32591
|
+
useEffect29(() => {
|
|
32158
32592
|
return () => {
|
|
32159
32593
|
hasStartedPolling.current = false;
|
|
32160
32594
|
};
|
|
32161
32595
|
}, []);
|
|
32162
|
-
|
|
32596
|
+
useEffect29(() => {
|
|
32163
32597
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
32164
32598
|
hasStartedPolling.current = true;
|
|
32165
32599
|
startPolling(intentId, transactionHash);
|
|
@@ -32659,14 +33093,14 @@ var init_WidgetRouter = __esm({
|
|
|
32659
33093
|
});
|
|
32660
33094
|
|
|
32661
33095
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32662
|
-
import { useCallback as useCallback20, useRef as
|
|
33096
|
+
import { useCallback as useCallback20, useRef as useRef15, useState as useState28 } from "react";
|
|
32663
33097
|
function useSwapRoute() {
|
|
32664
|
-
const [state, setState] =
|
|
33098
|
+
const [state, setState] = useState28({
|
|
32665
33099
|
data: null,
|
|
32666
33100
|
loading: false,
|
|
32667
33101
|
error: null
|
|
32668
33102
|
});
|
|
32669
|
-
const abortRef =
|
|
33103
|
+
const abortRef = useRef15(false);
|
|
32670
33104
|
const fetch2 = useCallback20(
|
|
32671
33105
|
async (params) => {
|
|
32672
33106
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
@@ -32725,7 +33159,7 @@ var init_useSwapRoute = __esm({
|
|
|
32725
33159
|
});
|
|
32726
33160
|
|
|
32727
33161
|
// src/modes/swap/hooks/useSwapExecution.ts
|
|
32728
|
-
import { useCallback as useCallback21, useRef as
|
|
33162
|
+
import { useCallback as useCallback21, useRef as useRef16, useState as useState29 } from "react";
|
|
32729
33163
|
import { encodeFunctionData as encodeFunctionData9, erc20Abi as erc20Abi2 } from "viem";
|
|
32730
33164
|
function normalizeTx(raw) {
|
|
32731
33165
|
const r = raw;
|
|
@@ -32760,7 +33194,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32760
33194
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32761
33195
|
}
|
|
32762
33196
|
function useSwapExecution(fromChain) {
|
|
32763
|
-
const [state, setState] =
|
|
33197
|
+
const [state, setState] = useState29({
|
|
32764
33198
|
txStatus: "idle",
|
|
32765
33199
|
txHash: null,
|
|
32766
33200
|
intentId: null,
|
|
@@ -32769,11 +33203,11 @@ function useSwapExecution(fromChain) {
|
|
|
32769
33203
|
isSubmitting: false,
|
|
32770
33204
|
allowanceStatus: "unknown"
|
|
32771
33205
|
});
|
|
32772
|
-
const saFailedUntilRef =
|
|
32773
|
-
const pollingRef =
|
|
32774
|
-
const timeoutRef =
|
|
32775
|
-
const abortRef =
|
|
32776
|
-
const pollCountRef =
|
|
33206
|
+
const saFailedUntilRef = useRef16(0);
|
|
33207
|
+
const pollingRef = useRef16(null);
|
|
33208
|
+
const timeoutRef = useRef16(null);
|
|
33209
|
+
const abortRef = useRef16(false);
|
|
33210
|
+
const pollCountRef = useRef16(0);
|
|
32777
33211
|
const clearPolling = useCallback21(() => {
|
|
32778
33212
|
abortRef.current = true;
|
|
32779
33213
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
@@ -33136,13 +33570,13 @@ var init_forex = __esm({
|
|
|
33136
33570
|
});
|
|
33137
33571
|
|
|
33138
33572
|
// src/modes/swap/hooks/useForex.ts
|
|
33139
|
-
import { useEffect as
|
|
33573
|
+
import { useEffect as useEffect30, useRef as useRef17, useState as useState30 } from "react";
|
|
33140
33574
|
function useForex() {
|
|
33141
|
-
const [rates, setRates] =
|
|
33142
|
-
const [error, setError] =
|
|
33143
|
-
const [lastUpdated, setLastUpdated] =
|
|
33144
|
-
const timerRef =
|
|
33145
|
-
|
|
33575
|
+
const [rates, setRates] = useState30({ USD: 1 });
|
|
33576
|
+
const [error, setError] = useState30(null);
|
|
33577
|
+
const [lastUpdated, setLastUpdated] = useState30(null);
|
|
33578
|
+
const timerRef = useRef17(null);
|
|
33579
|
+
useEffect30(() => {
|
|
33146
33580
|
let cancelled = false;
|
|
33147
33581
|
const load = () => {
|
|
33148
33582
|
fetchForexRates("USD").then((r) => {
|
|
@@ -33179,7 +33613,7 @@ var init_useForex = __esm({
|
|
|
33179
33613
|
});
|
|
33180
33614
|
|
|
33181
33615
|
// src/modes/swap/components/SwapTokenSelect.tsx
|
|
33182
|
-
import { useState as
|
|
33616
|
+
import { useState as useState31, useMemo as useMemo26, useEffect as useEffect31 } from "react";
|
|
33183
33617
|
import { jsx as jsx55, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
33184
33618
|
function SwapTokenSelect({
|
|
33185
33619
|
side,
|
|
@@ -33195,10 +33629,10 @@ function SwapTokenSelect({
|
|
|
33195
33629
|
allowedTokens,
|
|
33196
33630
|
excludeToken
|
|
33197
33631
|
}) {
|
|
33198
|
-
const [localChain, setLocalChain] =
|
|
33199
|
-
const [pinnedTokens, setPinnedTokens] =
|
|
33200
|
-
const [pinnedLoading, setPinnedLoading] =
|
|
33201
|
-
|
|
33632
|
+
const [localChain, setLocalChain] = useState31(initialChain);
|
|
33633
|
+
const [pinnedTokens, setPinnedTokens] = useState31([]);
|
|
33634
|
+
const [pinnedLoading, setPinnedLoading] = useState31(false);
|
|
33635
|
+
useEffect31(() => {
|
|
33202
33636
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
33203
33637
|
setPinnedTokens([]);
|
|
33204
33638
|
return;
|
|
@@ -33500,8 +33934,8 @@ var init_currency = __esm({
|
|
|
33500
33934
|
});
|
|
33501
33935
|
|
|
33502
33936
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorMobile.tsx
|
|
33503
|
-
import { useEffect as
|
|
33504
|
-
import { Fragment as
|
|
33937
|
+
import { useEffect as useEffect32, useMemo as useMemo27, useRef as useRef18, useState as useState32 } from "react";
|
|
33938
|
+
import { Fragment as Fragment10, jsx as jsx56, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
33505
33939
|
function SwapWalletSelectorMobile({
|
|
33506
33940
|
walletStatus,
|
|
33507
33941
|
walletAddress,
|
|
@@ -33518,14 +33952,14 @@ function SwapWalletSelectorMobile({
|
|
|
33518
33952
|
} = useWalletInfo();
|
|
33519
33953
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33520
33954
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33521
|
-
const [wcConnecting, setWcConnecting] =
|
|
33522
|
-
const [connectingId, setConnectingId] =
|
|
33523
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
33524
|
-
const prevStatusRef =
|
|
33525
|
-
const storeFallbackTimeoutRef =
|
|
33955
|
+
const [wcConnecting, setWcConnecting] = useState32(false);
|
|
33956
|
+
const [connectingId, setConnectingId] = useState32(null);
|
|
33957
|
+
const [selectedNamespace, setSelectedNamespace] = useState32("evm");
|
|
33958
|
+
const prevStatusRef = useRef18(walletStatus);
|
|
33959
|
+
const storeFallbackTimeoutRef = useRef18(
|
|
33526
33960
|
null
|
|
33527
33961
|
);
|
|
33528
|
-
|
|
33962
|
+
useEffect32(() => {
|
|
33529
33963
|
const prev = prevStatusRef.current;
|
|
33530
33964
|
if (prev !== walletStatus) {
|
|
33531
33965
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33534,7 +33968,7 @@ function SwapWalletSelectorMobile({
|
|
|
33534
33968
|
prevStatusRef.current = walletStatus;
|
|
33535
33969
|
}
|
|
33536
33970
|
}, [walletStatus]);
|
|
33537
|
-
|
|
33971
|
+
useEffect32(() => {
|
|
33538
33972
|
return () => {
|
|
33539
33973
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
33540
33974
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
@@ -33799,6 +34233,7 @@ function SwapWalletSelectorMobile({
|
|
|
33799
34233
|
const { meta } = entry;
|
|
33800
34234
|
const isWalletConnected = managerConnected && walletMetaId === meta.id;
|
|
33801
34235
|
const isConnecting = connectingId === meta.id && walletStatus === "connecting";
|
|
34236
|
+
const isRowDisabled = managerConnected && !isWalletConnected && !entry.detectedWallet;
|
|
33802
34237
|
return /* @__PURE__ */ jsxs44(
|
|
33803
34238
|
"div",
|
|
33804
34239
|
{
|
|
@@ -33816,7 +34251,8 @@ function SwapWalletSelectorMobile({
|
|
|
33816
34251
|
isWalletConnected && {
|
|
33817
34252
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
33818
34253
|
border: `1px solid ${colors.primary}`
|
|
33819
|
-
}
|
|
34254
|
+
},
|
|
34255
|
+
isRowDisabled && { opacity: 0.4 }
|
|
33820
34256
|
),
|
|
33821
34257
|
children: [
|
|
33822
34258
|
/* @__PURE__ */ jsx56(
|
|
@@ -33907,7 +34343,7 @@ function SwapWalletSelectorMobile({
|
|
|
33907
34343
|
"button",
|
|
33908
34344
|
{
|
|
33909
34345
|
onClick: () => void handleClick(entry),
|
|
33910
|
-
disabled: walletStatus === "connecting",
|
|
34346
|
+
disabled: walletStatus === "connecting" || isRowDisabled,
|
|
33911
34347
|
style: mergeStyles(
|
|
33912
34348
|
{
|
|
33913
34349
|
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
@@ -33920,7 +34356,7 @@ function SwapWalletSelectorMobile({
|
|
|
33920
34356
|
cursor: "pointer",
|
|
33921
34357
|
flexShrink: 0
|
|
33922
34358
|
},
|
|
33923
|
-
walletStatus === "connecting" && {
|
|
34359
|
+
(walletStatus === "connecting" || isRowDisabled) && {
|
|
33924
34360
|
opacity: 0.5,
|
|
33925
34361
|
cursor: "not-allowed"
|
|
33926
34362
|
}
|
|
@@ -33935,7 +34371,7 @@ function SwapWalletSelectorMobile({
|
|
|
33935
34371
|
})
|
|
33936
34372
|
}
|
|
33937
34373
|
),
|
|
33938
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(
|
|
34374
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(Fragment10, { children: [
|
|
33939
34375
|
/* @__PURE__ */ jsx56(
|
|
33940
34376
|
"div",
|
|
33941
34377
|
{
|
|
@@ -33948,6 +34384,7 @@ function SwapWalletSelectorMobile({
|
|
|
33948
34384
|
),
|
|
33949
34385
|
(() => {
|
|
33950
34386
|
const wcConnected = managerConnected && connectedVia === "walletconnect";
|
|
34387
|
+
const wcRowDisabled = managerConnected && !wcConnected;
|
|
33951
34388
|
return /* @__PURE__ */ jsxs44(
|
|
33952
34389
|
"div",
|
|
33953
34390
|
{
|
|
@@ -33966,9 +34403,10 @@ function SwapWalletSelectorMobile({
|
|
|
33966
34403
|
wcConnected && {
|
|
33967
34404
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
33968
34405
|
border: `1px solid ${colors.primary}`
|
|
33969
|
-
}
|
|
34406
|
+
},
|
|
34407
|
+
wcRowDisabled && { opacity: 0.4, cursor: "not-allowed" }
|
|
33970
34408
|
),
|
|
33971
|
-
onClick: !wcConnected ? () => void handleWalletConnect() : void 0,
|
|
34409
|
+
onClick: !wcConnected && !wcRowDisabled ? () => void handleWalletConnect() : void 0,
|
|
33972
34410
|
children: [
|
|
33973
34411
|
/* @__PURE__ */ jsx56(
|
|
33974
34412
|
"div",
|
|
@@ -34064,18 +34502,24 @@ function SwapWalletSelectorMobile({
|
|
|
34064
34502
|
e2.stopPropagation();
|
|
34065
34503
|
void handleWalletConnect();
|
|
34066
34504
|
},
|
|
34067
|
-
disabled: wcConnecting,
|
|
34068
|
-
style:
|
|
34069
|
-
|
|
34070
|
-
|
|
34071
|
-
|
|
34072
|
-
|
|
34073
|
-
|
|
34074
|
-
|
|
34075
|
-
|
|
34076
|
-
|
|
34077
|
-
|
|
34078
|
-
|
|
34505
|
+
disabled: wcConnecting || wcRowDisabled,
|
|
34506
|
+
style: mergeStyles(
|
|
34507
|
+
{
|
|
34508
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
34509
|
+
borderRadius: "9999px",
|
|
34510
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
34511
|
+
color: colors.primary,
|
|
34512
|
+
fontSize: fontSize.xs,
|
|
34513
|
+
fontWeight: fontWeight.medium,
|
|
34514
|
+
border: 0,
|
|
34515
|
+
cursor: "pointer",
|
|
34516
|
+
flexShrink: 0
|
|
34517
|
+
},
|
|
34518
|
+
(wcConnecting || wcRowDisabled) && {
|
|
34519
|
+
opacity: 0.5,
|
|
34520
|
+
cursor: "not-allowed"
|
|
34521
|
+
}
|
|
34522
|
+
),
|
|
34079
34523
|
children: "Connect"
|
|
34080
34524
|
}
|
|
34081
34525
|
)
|
|
@@ -34106,8 +34550,8 @@ var init_SwapWalletSelectorMobile = __esm({
|
|
|
34106
34550
|
});
|
|
34107
34551
|
|
|
34108
34552
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorDesktop.tsx
|
|
34109
|
-
import { useEffect as
|
|
34110
|
-
import { Fragment as
|
|
34553
|
+
import { useEffect as useEffect33, useMemo as useMemo28, useRef as useRef19, useState as useState33 } from "react";
|
|
34554
|
+
import { Fragment as Fragment11, jsx as jsx57, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
34111
34555
|
function SwapWalletSelectorDesktop({
|
|
34112
34556
|
walletStatus,
|
|
34113
34557
|
walletAddress,
|
|
@@ -34123,16 +34567,16 @@ function SwapWalletSelectorDesktop({
|
|
|
34123
34567
|
} = useWalletInfo();
|
|
34124
34568
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
34125
34569
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
34126
|
-
const [wcConnecting, setWcConnecting] =
|
|
34127
|
-
const [connectingId, setConnectingId] =
|
|
34128
|
-
const [timerExpired, setTimerExpired] =
|
|
34129
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
34130
|
-
const prevStatusRef =
|
|
34131
|
-
|
|
34570
|
+
const [wcConnecting, setWcConnecting] = useState33(false);
|
|
34571
|
+
const [connectingId, setConnectingId] = useState33(null);
|
|
34572
|
+
const [timerExpired, setTimerExpired] = useState33(false);
|
|
34573
|
+
const [selectedNamespace, setSelectedNamespace] = useState33("evm");
|
|
34574
|
+
const prevStatusRef = useRef19(walletStatus);
|
|
34575
|
+
useEffect33(() => {
|
|
34132
34576
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
34133
34577
|
return () => clearTimeout(t);
|
|
34134
34578
|
}, []);
|
|
34135
|
-
|
|
34579
|
+
useEffect33(() => {
|
|
34136
34580
|
const prev = prevStatusRef.current;
|
|
34137
34581
|
if (prev !== walletStatus) {
|
|
34138
34582
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -34565,7 +35009,7 @@ function SwapWalletSelectorDesktop({
|
|
|
34565
35009
|
})
|
|
34566
35010
|
}
|
|
34567
35011
|
),
|
|
34568
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(
|
|
35012
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(Fragment11, { children: [
|
|
34569
35013
|
/* @__PURE__ */ jsx57(
|
|
34570
35014
|
"div",
|
|
34571
35015
|
{
|
|
@@ -34729,7 +35173,7 @@ var init_SwapWalletSelectorDesktop = __esm({
|
|
|
34729
35173
|
});
|
|
34730
35174
|
|
|
34731
35175
|
// src/modes/swap/components/SwapWalletSelector/index.tsx
|
|
34732
|
-
import { Fragment as
|
|
35176
|
+
import { Fragment as Fragment12, jsx as jsx58, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
34733
35177
|
function SwapWalletSelector({
|
|
34734
35178
|
walletStatus,
|
|
34735
35179
|
walletAddress,
|
|
@@ -34737,7 +35181,7 @@ function SwapWalletSelector({
|
|
|
34737
35181
|
onBack
|
|
34738
35182
|
}) {
|
|
34739
35183
|
const isMobile = useIsMobile();
|
|
34740
|
-
return /* @__PURE__ */ jsxs46(
|
|
35184
|
+
return /* @__PURE__ */ jsxs46(Fragment12, { children: [
|
|
34741
35185
|
isMobile && /* @__PURE__ */ jsx58(
|
|
34742
35186
|
SwapWalletSelectorMobile_default,
|
|
34743
35187
|
{
|
|
@@ -34782,13 +35226,13 @@ import {
|
|
|
34782
35226
|
lazy as lazy2,
|
|
34783
35227
|
Suspense as Suspense2,
|
|
34784
35228
|
useCallback as useCallback22,
|
|
34785
|
-
useEffect as
|
|
35229
|
+
useEffect as useEffect34,
|
|
34786
35230
|
useMemo as useMemo29,
|
|
34787
|
-
useRef as
|
|
34788
|
-
useState as
|
|
35231
|
+
useRef as useRef20,
|
|
35232
|
+
useState as useState34
|
|
34789
35233
|
} from "react";
|
|
34790
35234
|
import ReactDOM from "react-dom";
|
|
34791
|
-
import { Fragment as
|
|
35235
|
+
import { Fragment as Fragment13, jsx as jsx59, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
34792
35236
|
function fmtAmount(n, max = 6) {
|
|
34793
35237
|
if (!isFinite(n) || n === 0) return "0";
|
|
34794
35238
|
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
@@ -34880,36 +35324,36 @@ function SwapMode({
|
|
|
34880
35324
|
theme: themeProp,
|
|
34881
35325
|
style
|
|
34882
35326
|
}) {
|
|
34883
|
-
const [stage, setStage] =
|
|
34884
|
-
const [fromToken, setFromToken] =
|
|
35327
|
+
const [stage, setStage] = useState34("home");
|
|
35328
|
+
const [fromToken, setFromToken] = useState34(
|
|
34885
35329
|
null
|
|
34886
35330
|
);
|
|
34887
|
-
const [fromChain, setFromChain] =
|
|
34888
|
-
const [toToken, setToToken] =
|
|
34889
|
-
const [toChain, setToChain] =
|
|
34890
|
-
const [amount, setAmount] =
|
|
34891
|
-
const [amountInputMode, setAmountInputMode] =
|
|
35331
|
+
const [fromChain, setFromChain] = useState34(null);
|
|
35332
|
+
const [toToken, setToToken] = useState34(null);
|
|
35333
|
+
const [toChain, setToChain] = useState34(null);
|
|
35334
|
+
const [amount, setAmount] = useState34("");
|
|
35335
|
+
const [amountInputMode, setAmountInputMode] = useState34(
|
|
34892
35336
|
"usd"
|
|
34893
35337
|
);
|
|
34894
|
-
const [hoverSell, setHoverSell] =
|
|
34895
|
-
const [showRateDetails, setShowRateDetails] =
|
|
34896
|
-
const [showReviewDetails, setShowReviewDetails] =
|
|
34897
|
-
const [showSettings, setShowSettings] =
|
|
34898
|
-
const [maxApproval, setMaxApproval] =
|
|
34899
|
-
const [slippage, setSlippage] =
|
|
34900
|
-
const [slippageInput, setSlippageInput] =
|
|
34901
|
-
const [selectedCurrency, setSelectedCurrency] =
|
|
34902
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] =
|
|
34903
|
-
const [completedAt, setCompletedAt] =
|
|
34904
|
-
const [copiedHash, setCopiedHash] =
|
|
34905
|
-
const [rateUpdated, setRateUpdated] =
|
|
34906
|
-
const prevToAmountRef =
|
|
34907
|
-
const [destAddress, setDestAddress] =
|
|
34908
|
-
const [quoteAge, setQuoteAge] =
|
|
34909
|
-
const quoteTimestampRef =
|
|
34910
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] =
|
|
34911
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] =
|
|
34912
|
-
const latestFetchParamsRef =
|
|
35338
|
+
const [hoverSell, setHoverSell] = useState34(false);
|
|
35339
|
+
const [showRateDetails, setShowRateDetails] = useState34(false);
|
|
35340
|
+
const [showReviewDetails, setShowReviewDetails] = useState34(false);
|
|
35341
|
+
const [showSettings, setShowSettings] = useState34(false);
|
|
35342
|
+
const [maxApproval, setMaxApproval] = useState34(false);
|
|
35343
|
+
const [slippage, setSlippage] = useState34(0.5);
|
|
35344
|
+
const [slippageInput, setSlippageInput] = useState34("");
|
|
35345
|
+
const [selectedCurrency, setSelectedCurrency] = useState34("USD");
|
|
35346
|
+
const [showCurrencyDropdown, setShowCurrencyDropdown] = useState34(false);
|
|
35347
|
+
const [completedAt, setCompletedAt] = useState34(null);
|
|
35348
|
+
const [copiedHash, setCopiedHash] = useState34(null);
|
|
35349
|
+
const [rateUpdated, setRateUpdated] = useState34(false);
|
|
35350
|
+
const prevToAmountRef = useRef20(null);
|
|
35351
|
+
const [destAddress, setDestAddress] = useState34("");
|
|
35352
|
+
const [quoteAge, setQuoteAge] = useState34(0);
|
|
35353
|
+
const quoteTimestampRef = useRef20(null);
|
|
35354
|
+
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = useState34(0);
|
|
35355
|
+
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = useState34(true);
|
|
35356
|
+
const latestFetchParamsRef = useRef20(null);
|
|
34913
35357
|
const { rates: forexRates } = useForex();
|
|
34914
35358
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
34915
35359
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
@@ -34925,8 +35369,8 @@ function SwapMode({
|
|
|
34925
35369
|
},
|
|
34926
35370
|
[currencyRate, selectedCurrency]
|
|
34927
35371
|
);
|
|
34928
|
-
const settingsRef =
|
|
34929
|
-
const currencyDropdownRef =
|
|
35372
|
+
const settingsRef = useRef20(null);
|
|
35373
|
+
const currencyDropdownRef = useRef20(null);
|
|
34930
35374
|
const { emitEvent } = useTrustware();
|
|
34931
35375
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
34932
35376
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -34960,8 +35404,8 @@ function SwapMode({
|
|
|
34960
35404
|
() => [...popularChains, ...otherChains],
|
|
34961
35405
|
[popularChains, otherChains]
|
|
34962
35406
|
);
|
|
34963
|
-
const destInitialized =
|
|
34964
|
-
|
|
35407
|
+
const destInitialized = useRef20(false);
|
|
35408
|
+
useEffect34(() => {
|
|
34965
35409
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
34966
35410
|
return;
|
|
34967
35411
|
const chain = allChains.find(
|
|
@@ -34991,7 +35435,7 @@ function SwapMode({
|
|
|
34991
35435
|
}).catch(() => {
|
|
34992
35436
|
});
|
|
34993
35437
|
}, [defaultDestRef, allChains]);
|
|
34994
|
-
const { walletAddress, walletStatus, connectWallet
|
|
35438
|
+
const { walletAddress, walletStatus, connectWallet } = useWalletSessionState();
|
|
34995
35439
|
const setFromTokenStable = useCallback22(
|
|
34996
35440
|
(t) => setFromToken(t),
|
|
34997
35441
|
[]
|
|
@@ -35366,13 +35810,13 @@ function SwapMode({
|
|
|
35366
35810
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
35367
35811
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
35368
35812
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
35369
|
-
|
|
35813
|
+
useEffect34(() => {
|
|
35370
35814
|
if (!fromToken) return;
|
|
35371
35815
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
35372
35816
|
setAmountInputMode("token");
|
|
35373
35817
|
}
|
|
35374
35818
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
35375
|
-
|
|
35819
|
+
useEffect34(() => {
|
|
35376
35820
|
if (displayToAmount === null) {
|
|
35377
35821
|
prevToAmountRef.current = null;
|
|
35378
35822
|
return;
|
|
@@ -35386,14 +35830,14 @@ function SwapMode({
|
|
|
35386
35830
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
35387
35831
|
return () => clearTimeout(t);
|
|
35388
35832
|
}, [displayToAmount]);
|
|
35389
|
-
|
|
35833
|
+
useEffect34(() => {
|
|
35390
35834
|
setDestAddress("");
|
|
35391
35835
|
}, [toChainType]);
|
|
35392
|
-
const fetchRef =
|
|
35393
|
-
|
|
35836
|
+
const fetchRef = useRef20(route.fetch);
|
|
35837
|
+
useEffect34(() => {
|
|
35394
35838
|
fetchRef.current = route.fetch;
|
|
35395
35839
|
});
|
|
35396
|
-
|
|
35840
|
+
useEffect34(() => {
|
|
35397
35841
|
if (!canGetQuote || stage !== "home") return;
|
|
35398
35842
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
35399
35843
|
return;
|
|
@@ -35422,7 +35866,7 @@ function SwapMode({
|
|
|
35422
35866
|
destAddress,
|
|
35423
35867
|
slippage
|
|
35424
35868
|
]);
|
|
35425
|
-
|
|
35869
|
+
useEffect34(() => {
|
|
35426
35870
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
35427
35871
|
latestFetchParamsRef.current = null;
|
|
35428
35872
|
return;
|
|
@@ -35449,12 +35893,12 @@ function SwapMode({
|
|
|
35449
35893
|
destAddress,
|
|
35450
35894
|
slippage
|
|
35451
35895
|
]);
|
|
35452
|
-
|
|
35896
|
+
useEffect34(() => {
|
|
35453
35897
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
35454
35898
|
setQuoteAge(0);
|
|
35455
35899
|
}, [route.data]);
|
|
35456
|
-
const msgTimeoutRef =
|
|
35457
|
-
|
|
35900
|
+
const msgTimeoutRef = useRef20(null);
|
|
35901
|
+
useEffect34(() => {
|
|
35458
35902
|
if (!route.loading) {
|
|
35459
35903
|
setQuoteLoadingMsgIdx(0);
|
|
35460
35904
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -35472,7 +35916,7 @@ function SwapMode({
|
|
|
35472
35916
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
35473
35917
|
};
|
|
35474
35918
|
}, [route.loading]);
|
|
35475
|
-
|
|
35919
|
+
useEffect34(() => {
|
|
35476
35920
|
if (!route.data) return;
|
|
35477
35921
|
const id = setInterval(() => {
|
|
35478
35922
|
const ts = quoteTimestampRef.current;
|
|
@@ -35486,7 +35930,7 @@ function SwapMode({
|
|
|
35486
35930
|
}, 1e3);
|
|
35487
35931
|
return () => clearInterval(id);
|
|
35488
35932
|
}, [route.data]);
|
|
35489
|
-
|
|
35933
|
+
useEffect34(() => {
|
|
35490
35934
|
if (stage !== "review") return;
|
|
35491
35935
|
if (!route.data || !walletAddress) return;
|
|
35492
35936
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -35497,7 +35941,7 @@ function SwapMode({
|
|
|
35497
35941
|
routeResult: route.data
|
|
35498
35942
|
});
|
|
35499
35943
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
35500
|
-
|
|
35944
|
+
useEffect34(() => {
|
|
35501
35945
|
if (!showSettings) {
|
|
35502
35946
|
setShowCurrencyDropdown(false);
|
|
35503
35947
|
return;
|
|
@@ -35510,7 +35954,7 @@ function SwapMode({
|
|
|
35510
35954
|
document.addEventListener("mousedown", handler);
|
|
35511
35955
|
return () => document.removeEventListener("mousedown", handler);
|
|
35512
35956
|
}, [showSettings]);
|
|
35513
|
-
|
|
35957
|
+
useEffect34(() => {
|
|
35514
35958
|
if (!showCurrencyDropdown) return;
|
|
35515
35959
|
const handler = (e2) => {
|
|
35516
35960
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -35997,7 +36441,7 @@ function SwapMode({
|
|
|
35997
36441
|
padding: 0,
|
|
35998
36442
|
transition: "color 0.15s"
|
|
35999
36443
|
},
|
|
36000
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(
|
|
36444
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(Fragment13, { children: [
|
|
36001
36445
|
txHash.slice(0, 6),
|
|
36002
36446
|
"\u2026",
|
|
36003
36447
|
txHash.slice(-4),
|
|
@@ -37069,7 +37513,7 @@ function SwapMode({
|
|
|
37069
37513
|
walletAddress ? /* @__PURE__ */ jsxs47(
|
|
37070
37514
|
"button",
|
|
37071
37515
|
{
|
|
37072
|
-
onClick:
|
|
37516
|
+
onClick: handleConnectAndReview,
|
|
37073
37517
|
style: {
|
|
37074
37518
|
fontSize: fontSize.xs,
|
|
37075
37519
|
color: colors.mutedForeground,
|
|
@@ -37080,8 +37524,7 @@ function SwapMode({
|
|
|
37080
37524
|
children: [
|
|
37081
37525
|
walletAddress.slice(0, 6),
|
|
37082
37526
|
"...",
|
|
37083
|
-
walletAddress.slice(-4)
|
|
37084
|
-
" \xD7"
|
|
37527
|
+
walletAddress.slice(-4)
|
|
37085
37528
|
]
|
|
37086
37529
|
}
|
|
37087
37530
|
) : /* @__PURE__ */ jsx59(
|
|
@@ -38660,8 +39103,8 @@ function ReviewDetailRow({
|
|
|
38660
39103
|
value,
|
|
38661
39104
|
tooltip
|
|
38662
39105
|
}) {
|
|
38663
|
-
const iconRef =
|
|
38664
|
-
const [tipPos, setTipPos] =
|
|
39106
|
+
const iconRef = useRef20(null);
|
|
39107
|
+
const [tipPos, setTipPos] = useState34(null);
|
|
38665
39108
|
const handleMouseEnter = () => {
|
|
38666
39109
|
if (!tooltip || !iconRef.current) return;
|
|
38667
39110
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -38996,14 +39439,14 @@ var init_swap = __esm({
|
|
|
38996
39439
|
|
|
38997
39440
|
// src/widget/TrustwareWidgetV2.tsx
|
|
38998
39441
|
import {
|
|
38999
|
-
useState as
|
|
39000
|
-
useEffect as
|
|
39001
|
-
useRef as
|
|
39442
|
+
useState as useState35,
|
|
39443
|
+
useEffect as useEffect35,
|
|
39444
|
+
useRef as useRef21,
|
|
39002
39445
|
useCallback as useCallback23,
|
|
39003
39446
|
useImperativeHandle,
|
|
39004
39447
|
forwardRef
|
|
39005
39448
|
} from "react";
|
|
39006
|
-
import { Fragment as
|
|
39449
|
+
import { Fragment as Fragment14, jsx as jsx60, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
39007
39450
|
function WidgetContent({
|
|
39008
39451
|
style,
|
|
39009
39452
|
onStateChange,
|
|
@@ -39014,7 +39457,7 @@ function WidgetContent({
|
|
|
39014
39457
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
39015
39458
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
39016
39459
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
39017
|
-
|
|
39460
|
+
useEffect35(() => {
|
|
39018
39461
|
const state = {
|
|
39019
39462
|
currentStep,
|
|
39020
39463
|
amount,
|
|
@@ -39057,7 +39500,7 @@ function WidgetInner({
|
|
|
39057
39500
|
const { transactionStatus } = useDepositTransaction();
|
|
39058
39501
|
const { resolvedTheme } = useDepositUi();
|
|
39059
39502
|
const { status, revalidate, errors } = useTrustware();
|
|
39060
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
39503
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState35(false);
|
|
39061
39504
|
const handleCloseRequest = useCallback23(() => {
|
|
39062
39505
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
39063
39506
|
setShowConfirmDialog(true);
|
|
@@ -39069,7 +39512,7 @@ function WidgetInner({
|
|
|
39069
39512
|
onClose?.();
|
|
39070
39513
|
}
|
|
39071
39514
|
}, [transactionStatus, onClose, resetState]);
|
|
39072
|
-
|
|
39515
|
+
useEffect35(() => {
|
|
39073
39516
|
closeRequestRef.current = handleCloseRequest;
|
|
39074
39517
|
}, [handleCloseRequest, closeRequestRef]);
|
|
39075
39518
|
const handleConfirmClose = useCallback23(() => {
|
|
@@ -39085,7 +39528,7 @@ function WidgetInner({
|
|
|
39085
39528
|
const handleRefresh = useCallback23(() => {
|
|
39086
39529
|
revalidate?.();
|
|
39087
39530
|
}, [revalidate]);
|
|
39088
|
-
return /* @__PURE__ */ jsxs48(
|
|
39531
|
+
return /* @__PURE__ */ jsxs48(Fragment14, { children: [
|
|
39089
39532
|
/* @__PURE__ */ jsxs48(WidgetContainer, { theme: effectiveTheme, style, children: [
|
|
39090
39533
|
/* @__PURE__ */ jsx60(
|
|
39091
39534
|
WidgetContent,
|
|
@@ -39153,8 +39596,8 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39153
39596
|
onOpen,
|
|
39154
39597
|
showThemeToggle = true
|
|
39155
39598
|
}, ref) {
|
|
39156
|
-
const [isOpen, setIsOpen] =
|
|
39157
|
-
const closeRequestRef =
|
|
39599
|
+
const [isOpen, setIsOpen] = useState35(defaultOpen);
|
|
39600
|
+
const closeRequestRef = useRef21(null);
|
|
39158
39601
|
const config = useTrustwareConfig();
|
|
39159
39602
|
const effectiveInitialStep = initialStep;
|
|
39160
39603
|
const open = useCallback23(() => {
|