@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/index.mjs
CHANGED
|
@@ -408,7 +408,7 @@ var init_constants = __esm({
|
|
|
408
408
|
"src/constants.ts"() {
|
|
409
409
|
"use strict";
|
|
410
410
|
SDK_NAME = "@trustware/sdk";
|
|
411
|
-
SDK_VERSION = "1.1.9-staging.
|
|
411
|
+
SDK_VERSION = "1.1.9-staging.6";
|
|
412
412
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
413
413
|
GTM_ID = "GTM-TZDGNCXB";
|
|
414
414
|
API_PREFIX = "/api";
|
|
@@ -1013,21 +1013,28 @@ function formatDeepLink(id, currentUrl) {
|
|
|
1013
1013
|
const enc = encodeURIComponent(currentUrl);
|
|
1014
1014
|
switch (id) {
|
|
1015
1015
|
// EVM
|
|
1016
|
+
// MetaMask's dapp browser also exposes its Wallet Standard Solana
|
|
1017
|
+
// provider in the same session, so "metamask-solana" reuses this link.
|
|
1016
1018
|
case "metamask":
|
|
1019
|
+
case "metamask-solana":
|
|
1017
1020
|
return `metamask://dapp/${currentUrl}`;
|
|
1018
1021
|
case "coinbase":
|
|
1019
1022
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
1020
1023
|
case "rainbow":
|
|
1021
|
-
return `rainbow
|
|
1024
|
+
return `https://rainbow.me/dapp?url=${enc}`;
|
|
1022
1025
|
case "trust":
|
|
1023
1026
|
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
1024
1027
|
case "okx":
|
|
1025
1028
|
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
1026
1029
|
// Solana
|
|
1030
|
+
// Phantom is one app with one in-app browser — browsing there injects
|
|
1031
|
+
// both window.ethereum and window.phantom.solana, so "phantom-evm"
|
|
1032
|
+
// reuses the same browse link as "phantom-solana".
|
|
1027
1033
|
case "phantom-solana":
|
|
1028
|
-
|
|
1034
|
+
case "phantom-evm":
|
|
1035
|
+
return `https://phantom.app/ul/browse/${enc}?ref=${enc}`;
|
|
1029
1036
|
case "solflare":
|
|
1030
|
-
return `solflare
|
|
1037
|
+
return `https://solflare.com/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1031
1038
|
case "backpack":
|
|
1032
1039
|
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1033
1040
|
// No confirmed deep link scheme
|
|
@@ -1137,8 +1144,10 @@ var init_metadata = __esm({
|
|
|
1137
1144
|
homepage: "https://phantom.app/",
|
|
1138
1145
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1139
1146
|
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1140
|
-
detectFlags: ["isPhantom"]
|
|
1141
|
-
//
|
|
1147
|
+
detectFlags: ["isPhantom"],
|
|
1148
|
+
// Same app/in-app browser as "phantom-solana" — browsing there injects
|
|
1149
|
+
// window.ethereum too.
|
|
1150
|
+
deepLink: (url) => formatDeepLink("phantom-evm", url) ?? ""
|
|
1142
1151
|
},
|
|
1143
1152
|
{
|
|
1144
1153
|
id: "phantom-solana",
|
|
@@ -1186,8 +1195,10 @@ var init_metadata = __esm({
|
|
|
1186
1195
|
emoji: "\u{1F98A}",
|
|
1187
1196
|
homepage: "https://metamask.io/",
|
|
1188
1197
|
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
1189
|
-
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
1190
|
-
//
|
|
1198
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
1199
|
+
// Same app/in-app browser as "metamask" — its Wallet Standard Solana
|
|
1200
|
+
// provider is exposed in that same browse session.
|
|
1201
|
+
deepLink: (url) => formatDeepLink("metamask-solana", url) ?? ""
|
|
1191
1202
|
},
|
|
1192
1203
|
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
1193
1204
|
{
|
|
@@ -2776,7 +2787,7 @@ var init_walletconnect = __esm({
|
|
|
2776
2787
|
solanaMainnet = {
|
|
2777
2788
|
id: 900,
|
|
2778
2789
|
chainNamespace: "solana",
|
|
2779
|
-
caipNetworkId: "solana:
|
|
2790
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
2780
2791
|
name: "Solana Mainnet",
|
|
2781
2792
|
nativeCurrency: {
|
|
2782
2793
|
name: "Solana",
|
|
@@ -3655,8 +3666,62 @@ function getChainMeta(chainId) {
|
|
|
3655
3666
|
rpcUrls: chain.rpcUrls.default.http
|
|
3656
3667
|
};
|
|
3657
3668
|
}
|
|
3658
|
-
|
|
3669
|
+
function extractSolanaAddress(connector) {
|
|
3670
|
+
const caipAccount = connector.provider.session?.namespaces?.solana?.accounts?.[0];
|
|
3671
|
+
if (!caipAccount) return null;
|
|
3672
|
+
return caipAccount.split(":")[2] ?? null;
|
|
3673
|
+
}
|
|
3674
|
+
function buildWalletConnectSolanaProvider(connector) {
|
|
3675
|
+
return {
|
|
3676
|
+
get publicKey() {
|
|
3677
|
+
const address = extractSolanaAddress(connector);
|
|
3678
|
+
return address ? { toString: () => address } : void 0;
|
|
3679
|
+
},
|
|
3680
|
+
async connect() {
|
|
3681
|
+
const address = extractSolanaAddress(connector);
|
|
3682
|
+
if (!address) {
|
|
3683
|
+
throw new Error(
|
|
3684
|
+
"This wallet did not approve a Solana account over WalletConnect."
|
|
3685
|
+
);
|
|
3686
|
+
}
|
|
3687
|
+
return { publicKey: { toString: () => address } };
|
|
3688
|
+
},
|
|
3689
|
+
async disconnect() {
|
|
3690
|
+
},
|
|
3691
|
+
async signTransaction(transaction) {
|
|
3692
|
+
const tx = transaction;
|
|
3693
|
+
const rawBytes = "version" in tx ? tx.serialize() : tx.serialize({
|
|
3694
|
+
requireAllSignatures: false,
|
|
3695
|
+
verifySignatures: false
|
|
3696
|
+
});
|
|
3697
|
+
const result = await connector.provider.request(
|
|
3698
|
+
{
|
|
3699
|
+
method: "solana_signTransaction",
|
|
3700
|
+
params: { transaction: encodeBase64(rawBytes) }
|
|
3701
|
+
},
|
|
3702
|
+
solanaMainnet.caipNetworkId
|
|
3703
|
+
);
|
|
3704
|
+
if (!result.transaction) {
|
|
3705
|
+
throw new Error(
|
|
3706
|
+
"WalletConnect wallet did not return a signed Solana transaction."
|
|
3707
|
+
);
|
|
3708
|
+
}
|
|
3709
|
+
const signedBytes = decodeBase64(result.transaction);
|
|
3710
|
+
return { serialize: () => signedBytes };
|
|
3711
|
+
},
|
|
3712
|
+
on() {
|
|
3713
|
+
},
|
|
3714
|
+
off() {
|
|
3715
|
+
},
|
|
3716
|
+
removeListener() {
|
|
3717
|
+
}
|
|
3718
|
+
};
|
|
3719
|
+
}
|
|
3720
|
+
async function buildWalletConnectAPI(walletCfg, ecosystem = "evm") {
|
|
3659
3721
|
const connector = await getUniversalConnector(walletCfg);
|
|
3722
|
+
if (ecosystem === "solana") {
|
|
3723
|
+
return toSolanaWalletInterface(buildWalletConnectSolanaProvider(connector));
|
|
3724
|
+
}
|
|
3660
3725
|
const provider = connector.provider;
|
|
3661
3726
|
const api = {
|
|
3662
3727
|
ecosystem: "evm",
|
|
@@ -3732,7 +3797,7 @@ function useWireDetectionIntoManager() {
|
|
|
3732
3797
|
function useWalletConnectConnect(walletCfg) {
|
|
3733
3798
|
const cfgRef = { current: walletCfg };
|
|
3734
3799
|
return useCallback(
|
|
3735
|
-
() => walletManager.connectWalletConnect(cfgRef.current),
|
|
3800
|
+
(ecosystem) => walletManager.connectWalletConnect(cfgRef.current, ecosystem),
|
|
3736
3801
|
[]
|
|
3737
3802
|
);
|
|
3738
3803
|
}
|
|
@@ -3752,6 +3817,7 @@ function useWalletInfo(wagmi) {
|
|
|
3752
3817
|
connectedVia: snapshot.connectedVia,
|
|
3753
3818
|
walletType: snapshot.walletType,
|
|
3754
3819
|
status: snapshot.status,
|
|
3820
|
+
detected: snapshot.detected,
|
|
3755
3821
|
disconnect
|
|
3756
3822
|
};
|
|
3757
3823
|
}
|
|
@@ -3903,44 +3969,39 @@ var init_manager = __esm({
|
|
|
3903
3969
|
this.emit();
|
|
3904
3970
|
}
|
|
3905
3971
|
}
|
|
3906
|
-
async connectWalletConnect(walletCfg) {
|
|
3907
|
-
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet) {
|
|
3972
|
+
async connectWalletConnect(walletCfg, ecosystem = "evm") {
|
|
3973
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet && this._wallet.ecosystem === ecosystem) {
|
|
3908
3974
|
this.emit();
|
|
3909
3975
|
return { error: null, api: this._wallet };
|
|
3910
3976
|
}
|
|
3977
|
+
if (this._connectedVia === "walletconnect" && this._wallet) {
|
|
3978
|
+
await this._wallet.disconnect?.().catch(() => {
|
|
3979
|
+
});
|
|
3980
|
+
resetUniversalConnector();
|
|
3981
|
+
}
|
|
3911
3982
|
this._status = "connecting";
|
|
3912
3983
|
this.clearConnectedState();
|
|
3913
3984
|
this.emit();
|
|
3914
3985
|
try {
|
|
3915
3986
|
const connector = await getUniversalConnector(walletCfg);
|
|
3916
3987
|
await connector.connect();
|
|
3917
|
-
const api = await buildWalletConnectAPI(walletCfg);
|
|
3988
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
3989
|
+
try {
|
|
3990
|
+
await api.getAddress();
|
|
3991
|
+
} catch {
|
|
3992
|
+
await api.disconnect?.().catch(() => {
|
|
3993
|
+
});
|
|
3994
|
+
resetUniversalConnector();
|
|
3995
|
+
throw new Error(
|
|
3996
|
+
`This wallet did not approve a${ecosystem === "evm" ? "n" : ""} ${ecosystem === "evm" ? "EVM" : "Solana"} account over WalletConnect.`
|
|
3997
|
+
);
|
|
3998
|
+
}
|
|
3918
3999
|
this._wallet = api;
|
|
3919
4000
|
this._connectedVia = "walletconnect";
|
|
3920
4001
|
this._connectedWalletId = "walletconnect";
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
if (accounts.length === 0) {
|
|
3925
|
-
this.fullReset();
|
|
3926
|
-
this.triggerExternalDisconnect();
|
|
3927
|
-
this.emit();
|
|
3928
|
-
return;
|
|
3929
|
-
}
|
|
3930
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3931
|
-
this.emit();
|
|
3932
|
-
},
|
|
3933
|
-
onChainChanged: () => {
|
|
3934
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3935
|
-
this.emit();
|
|
3936
|
-
},
|
|
3937
|
-
onDisconnect: () => {
|
|
3938
|
-
this.fullReset();
|
|
3939
|
-
resetUniversalConnector();
|
|
3940
|
-
this.triggerExternalDisconnect();
|
|
3941
|
-
this.emit();
|
|
3942
|
-
}
|
|
3943
|
-
});
|
|
4002
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
4003
|
+
connector.provider
|
|
4004
|
+
);
|
|
3944
4005
|
await this.syncIdentityFromWallet("walletconnect");
|
|
3945
4006
|
this._status = "connected";
|
|
3946
4007
|
this._error = null;
|
|
@@ -3955,6 +4016,100 @@ var init_manager = __esm({
|
|
|
3955
4016
|
return { error: message, api: null };
|
|
3956
4017
|
}
|
|
3957
4018
|
}
|
|
4019
|
+
bindWalletConnectProviderEvents(provider) {
|
|
4020
|
+
return bindWalletConnectEvents(provider, {
|
|
4021
|
+
onAccountsChanged: (accounts) => {
|
|
4022
|
+
if (accounts.length === 0) {
|
|
4023
|
+
this.fullReset();
|
|
4024
|
+
this.triggerExternalDisconnect();
|
|
4025
|
+
this.emit();
|
|
4026
|
+
return;
|
|
4027
|
+
}
|
|
4028
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
4029
|
+
this.emit();
|
|
4030
|
+
},
|
|
4031
|
+
onChainChanged: () => {
|
|
4032
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
4033
|
+
this.emit();
|
|
4034
|
+
},
|
|
4035
|
+
onDisconnect: () => {
|
|
4036
|
+
this.fullReset();
|
|
4037
|
+
resetUniversalConnector();
|
|
4038
|
+
this.triggerExternalDisconnect();
|
|
4039
|
+
this.emit();
|
|
4040
|
+
}
|
|
4041
|
+
});
|
|
4042
|
+
}
|
|
4043
|
+
// WalletConnect's own SignClient auto-restores the last persisted session
|
|
4044
|
+
// from storage on every init — including after a fresh page load — but
|
|
4045
|
+
// that restoration happens silently inside the library. Nothing calls back
|
|
4046
|
+
// into our code for it. On mobile, backgrounding the tab to approve in a
|
|
4047
|
+
// wallet app can cause the OS to reload the page before the original
|
|
4048
|
+
// connect() promise ever resolves, so the connect flow that triggered the
|
|
4049
|
+
// approval never gets to record it as "connected" here — even though
|
|
4050
|
+
// WalletConnect itself already has a live, approved session sitting in
|
|
4051
|
+
// storage. Call this on mount to pick that back up.
|
|
4052
|
+
async restoreWalletConnectSession(walletCfg) {
|
|
4053
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect") {
|
|
4054
|
+
return this._wallet?.ecosystem === "solana" ? "solana" : "evm";
|
|
4055
|
+
}
|
|
4056
|
+
if (typeof window === "undefined") return null;
|
|
4057
|
+
try {
|
|
4058
|
+
if (!Object.keys(window.localStorage).some((key) => key.startsWith("wc@2"))) {
|
|
4059
|
+
return null;
|
|
4060
|
+
}
|
|
4061
|
+
} catch {
|
|
4062
|
+
}
|
|
4063
|
+
let connector;
|
|
4064
|
+
try {
|
|
4065
|
+
connector = await getUniversalConnector(walletCfg);
|
|
4066
|
+
} catch (e2) {
|
|
4067
|
+
console.warn(
|
|
4068
|
+
"[Trustware SDK] Failed to restore WalletConnect session:",
|
|
4069
|
+
e2
|
|
4070
|
+
);
|
|
4071
|
+
return null;
|
|
4072
|
+
}
|
|
4073
|
+
const session = connector.provider.session;
|
|
4074
|
+
if (!session) return null;
|
|
4075
|
+
const ecosystem = session.namespaces?.solana?.accounts?.length ? "solana" : session.namespaces?.eip155?.accounts?.length ? "evm" : null;
|
|
4076
|
+
if (!ecosystem) return null;
|
|
4077
|
+
try {
|
|
4078
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
4079
|
+
this._wallet = api;
|
|
4080
|
+
this._connectedVia = "walletconnect";
|
|
4081
|
+
this._connectedWalletId = "walletconnect";
|
|
4082
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
4083
|
+
connector.provider
|
|
4084
|
+
);
|
|
4085
|
+
await this.syncIdentityFromWallet("walletconnect");
|
|
4086
|
+
this._status = "connected";
|
|
4087
|
+
this._error = null;
|
|
4088
|
+
this.emit();
|
|
4089
|
+
return ecosystem;
|
|
4090
|
+
} catch {
|
|
4091
|
+
return null;
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
// Forcibly abandon an in-progress connect() call the caller has decided is
|
|
4095
|
+
// stuck (e.g. the UI's own connect timeout elapsed with no response).
|
|
4096
|
+
// There's no clean way to cancel a pending WalletConnect pairing proposal
|
|
4097
|
+
// from this side, so this tears down the whole connector — the next
|
|
4098
|
+
// connect attempt starts against a brand new SignClient/pairing instead of
|
|
4099
|
+
// racing the abandoned one, which would otherwise risk reproducing the
|
|
4100
|
+
// "No matching key. proposal" class of error a real retry needs to avoid.
|
|
4101
|
+
cancelWalletConnectAttempt() {
|
|
4102
|
+
if (this._connectedVia === "walletconnect" && this._status === "connected") {
|
|
4103
|
+
return;
|
|
4104
|
+
}
|
|
4105
|
+
resetUniversalConnector();
|
|
4106
|
+
if (this._status === "connecting") {
|
|
4107
|
+
this.clearConnectedState();
|
|
4108
|
+
this._status = "idle";
|
|
4109
|
+
this._error = null;
|
|
4110
|
+
this.emit();
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
3958
4113
|
async disconnect(wagmi) {
|
|
3959
4114
|
if (wagmi && this._connectedVia === "extension") {
|
|
3960
4115
|
await wagmi.disconnect().catch(() => {
|
|
@@ -7654,15 +7809,74 @@ var init_useWalletSessionState = __esm({
|
|
|
7654
7809
|
});
|
|
7655
7810
|
|
|
7656
7811
|
// src/widget/state/deposit/useWalletConnect.ts
|
|
7657
|
-
import { useCallback as useCallback6 } from "react";
|
|
7812
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useRef, useState as useState8 } from "react";
|
|
7658
7813
|
function useWalletConnect({
|
|
7659
7814
|
setWalletType,
|
|
7660
|
-
setCurrentStep
|
|
7815
|
+
setCurrentStep,
|
|
7816
|
+
selectedNamespace,
|
|
7817
|
+
setSelectedNamespace
|
|
7661
7818
|
}) {
|
|
7662
7819
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
7663
7820
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
7821
|
+
const ecosystem = selectedNamespace.trim().toLowerCase() === "solana" ? "solana" : "evm";
|
|
7822
|
+
const [wcStatus, setWcStatus] = useState8("idle");
|
|
7823
|
+
const [wcErrorMessage, setWcErrorMessage] = useState8(null);
|
|
7824
|
+
const wcTimeoutRef = useRef(null);
|
|
7825
|
+
const clearWcTimeout = useCallback6(() => {
|
|
7826
|
+
if (wcTimeoutRef.current !== null) {
|
|
7827
|
+
clearTimeout(wcTimeoutRef.current);
|
|
7828
|
+
wcTimeoutRef.current = null;
|
|
7829
|
+
}
|
|
7830
|
+
}, []);
|
|
7831
|
+
const beginWcAttempt = useCallback6(() => {
|
|
7832
|
+
setWcStatus("connecting");
|
|
7833
|
+
setWcErrorMessage(null);
|
|
7834
|
+
clearWcTimeout();
|
|
7835
|
+
wcTimeoutRef.current = setTimeout(() => {
|
|
7836
|
+
wcTimeoutRef.current = null;
|
|
7837
|
+
setWcStatus((prev) => prev === "connecting" ? "timedOut" : prev);
|
|
7838
|
+
}, WC_CONNECT_TIMEOUT_MS);
|
|
7839
|
+
}, [clearWcTimeout]);
|
|
7840
|
+
const resolveWcAttempt = useCallback6(() => {
|
|
7841
|
+
clearWcTimeout();
|
|
7842
|
+
setWcStatus("idle");
|
|
7843
|
+
setWcErrorMessage(null);
|
|
7844
|
+
}, [clearWcTimeout]);
|
|
7845
|
+
const failWcAttempt = useCallback6(
|
|
7846
|
+
(message) => {
|
|
7847
|
+
clearWcTimeout();
|
|
7848
|
+
setWcStatus("failed");
|
|
7849
|
+
setWcErrorMessage(message);
|
|
7850
|
+
},
|
|
7851
|
+
[clearWcTimeout]
|
|
7852
|
+
);
|
|
7853
|
+
const dismissWcStatus = useCallback6(() => {
|
|
7854
|
+
clearWcTimeout();
|
|
7855
|
+
setWcStatus("idle");
|
|
7856
|
+
setWcErrorMessage(null);
|
|
7857
|
+
}, [clearWcTimeout]);
|
|
7858
|
+
useEffect8(() => clearWcTimeout, [clearWcTimeout]);
|
|
7859
|
+
useEffect8(() => {
|
|
7860
|
+
let cancelled = false;
|
|
7861
|
+
beginWcAttempt();
|
|
7862
|
+
void (async () => {
|
|
7863
|
+
const restoredEcosystem = await walletManager.restoreWalletConnectSession(walletConnectCfg);
|
|
7864
|
+
if (cancelled) return;
|
|
7865
|
+
resolveWcAttempt();
|
|
7866
|
+
if (!restoredEcosystem) return;
|
|
7867
|
+
setWalletType("walletconnect");
|
|
7868
|
+
if (restoredEcosystem === "solana") {
|
|
7869
|
+
setSelectedNamespace("Solana");
|
|
7870
|
+
}
|
|
7871
|
+
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
7872
|
+
if (address) setCurrentStep("crypto-pay");
|
|
7873
|
+
})();
|
|
7874
|
+
return () => {
|
|
7875
|
+
cancelled = true;
|
|
7876
|
+
};
|
|
7877
|
+
}, []);
|
|
7664
7878
|
const WalletConnect = useCallback6(async () => {
|
|
7665
|
-
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect") {
|
|
7879
|
+
if (walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" && walletManager.wallet?.ecosystem === ecosystem) {
|
|
7666
7880
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
7667
7881
|
if (address) {
|
|
7668
7882
|
setWalletType("walletconnect");
|
|
@@ -7671,40 +7885,66 @@ function useWalletConnect({
|
|
|
7671
7885
|
}
|
|
7672
7886
|
}
|
|
7673
7887
|
setWalletType("walletconnect");
|
|
7674
|
-
|
|
7888
|
+
beginWcAttempt();
|
|
7889
|
+
const { error } = await connectWC(ecosystem);
|
|
7675
7890
|
if (!error) {
|
|
7676
7891
|
const address = walletManager.identity?.addresses[0]?.address ?? null;
|
|
7677
7892
|
if (address) {
|
|
7893
|
+
resolveWcAttempt();
|
|
7678
7894
|
setCurrentStep("crypto-pay");
|
|
7895
|
+
} else {
|
|
7896
|
+
const message = `WalletConnect session established but no address resolved for ecosystem "${ecosystem}".`;
|
|
7897
|
+
console.error(`[Trustware SDK] ${message}`);
|
|
7898
|
+
failWcAttempt(message);
|
|
7679
7899
|
}
|
|
7680
7900
|
} else {
|
|
7901
|
+
console.error("[Trustware SDK] WalletConnect connection failed:", error);
|
|
7902
|
+
failWcAttempt(error);
|
|
7681
7903
|
setWalletType("other");
|
|
7682
7904
|
}
|
|
7683
|
-
}, [
|
|
7905
|
+
}, [
|
|
7906
|
+
beginWcAttempt,
|
|
7907
|
+
connectWC,
|
|
7908
|
+
ecosystem,
|
|
7909
|
+
failWcAttempt,
|
|
7910
|
+
resolveWcAttempt,
|
|
7911
|
+
setCurrentStep,
|
|
7912
|
+
setWalletType
|
|
7913
|
+
]);
|
|
7914
|
+
const retryWalletConnect = useCallback6(() => {
|
|
7915
|
+
walletManager.cancelWalletConnectAttempt();
|
|
7916
|
+
void WalletConnect();
|
|
7917
|
+
}, [WalletConnect]);
|
|
7684
7918
|
const disconnectWalletConnect = useCallback6(async () => {
|
|
7685
7919
|
await walletManager.disconnect();
|
|
7686
7920
|
setWalletType("other");
|
|
7687
7921
|
setCurrentStep("home");
|
|
7688
7922
|
}, [setCurrentStep, setWalletType]);
|
|
7689
|
-
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.
|
|
7923
|
+
const walletConnectAddress = walletManager.status === "connected" && walletManager.connectedVia === "walletconnect" ? walletManager.identity?.addresses[0]?.address ?? null : null;
|
|
7690
7924
|
return {
|
|
7691
7925
|
walletConnectAddress,
|
|
7692
7926
|
WalletConnect,
|
|
7693
|
-
disconnectWalletConnect
|
|
7927
|
+
disconnectWalletConnect,
|
|
7928
|
+
wcStatus,
|
|
7929
|
+
wcErrorMessage,
|
|
7930
|
+
retryWalletConnect,
|
|
7931
|
+
dismissWcStatus
|
|
7694
7932
|
};
|
|
7695
7933
|
}
|
|
7934
|
+
var WC_CONNECT_TIMEOUT_MS;
|
|
7696
7935
|
var init_useWalletConnect = __esm({
|
|
7697
7936
|
"src/widget/state/deposit/useWalletConnect.ts"() {
|
|
7698
7937
|
"use strict";
|
|
7699
7938
|
init_config2();
|
|
7700
7939
|
init_wallets();
|
|
7940
|
+
WC_CONNECT_TIMEOUT_MS = 3e4;
|
|
7701
7941
|
}
|
|
7702
7942
|
});
|
|
7703
7943
|
|
|
7704
7944
|
// src/hooks/useTrustwareConfig.ts
|
|
7705
|
-
import { useEffect as
|
|
7945
|
+
import { useEffect as useEffect9, useState as useState9 } from "react";
|
|
7706
7946
|
function useTrustwareConfig() {
|
|
7707
|
-
const [cfg, setCfg] =
|
|
7947
|
+
const [cfg, setCfg] = useState9(() => {
|
|
7708
7948
|
try {
|
|
7709
7949
|
return TrustwareConfigStore.get();
|
|
7710
7950
|
} catch {
|
|
@@ -7741,7 +7981,7 @@ function useTrustwareConfig() {
|
|
|
7741
7981
|
};
|
|
7742
7982
|
}
|
|
7743
7983
|
});
|
|
7744
|
-
|
|
7984
|
+
useEffect9(() => {
|
|
7745
7985
|
const unsubscribe = TrustwareConfigStore.subscribe(setCfg);
|
|
7746
7986
|
return () => {
|
|
7747
7987
|
unsubscribe();
|
|
@@ -7758,7 +7998,7 @@ var init_useTrustwareConfig = __esm({
|
|
|
7758
7998
|
});
|
|
7759
7999
|
|
|
7760
8000
|
// src/widget/context/DepositContext.tsx
|
|
7761
|
-
import React2, { createContext as createContext2, useContext as useContext2, useState as
|
|
8001
|
+
import React2, { createContext as createContext2, useContext as useContext2, useState as useState10, useMemo as useMemo5 } from "react";
|
|
7762
8002
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
7763
8003
|
function DepositProvider({
|
|
7764
8004
|
children,
|
|
@@ -7783,20 +8023,30 @@ function DepositProvider({
|
|
|
7783
8023
|
connectWallet,
|
|
7784
8024
|
disconnectWallet
|
|
7785
8025
|
} = useWalletSessionState();
|
|
7786
|
-
const [amountInputMode, setAmountInputMode] =
|
|
8026
|
+
const [amountInputMode, setAmountInputMode] = useState10(
|
|
7787
8027
|
"usd"
|
|
7788
8028
|
);
|
|
7789
|
-
const [walletType, setWalletType] =
|
|
8029
|
+
const [walletType, setWalletType] = useState10(
|
|
7790
8030
|
"other"
|
|
7791
8031
|
);
|
|
7792
|
-
const
|
|
8032
|
+
const [selectedNamespace, setSelectedNamespace] = useState10("evm");
|
|
8033
|
+
const {
|
|
8034
|
+
walletConnectAddress,
|
|
8035
|
+
WalletConnect,
|
|
8036
|
+
disconnectWalletConnect,
|
|
8037
|
+
wcStatus,
|
|
8038
|
+
wcErrorMessage,
|
|
8039
|
+
retryWalletConnect,
|
|
8040
|
+
dismissWcStatus
|
|
8041
|
+
} = useWalletConnect({
|
|
7793
8042
|
setWalletType,
|
|
7794
|
-
setCurrentStep
|
|
8043
|
+
setCurrentStep,
|
|
8044
|
+
selectedNamespace,
|
|
8045
|
+
setSelectedNamespace
|
|
7795
8046
|
});
|
|
7796
|
-
const [selectedToken, setSelectedToken] =
|
|
7797
|
-
const [selectedChain, setSelectedChain] =
|
|
7798
|
-
const [amount, setAmount] =
|
|
7799
|
-
const [selectedNamespace, setSelectedNamespace] = useState9("evm");
|
|
8047
|
+
const [selectedToken, setSelectedToken] = useState10(null);
|
|
8048
|
+
const [selectedChain, setSelectedChain] = useState10(null);
|
|
8049
|
+
const [amount, setAmount] = useState10("");
|
|
7800
8050
|
const walletAddress = useMemo5(
|
|
7801
8051
|
() => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
|
|
7802
8052
|
[walletType, walletConnectAddress, otherWalletAddress]
|
|
@@ -7814,11 +8064,11 @@ function DepositProvider({
|
|
|
7814
8064
|
selectedToken,
|
|
7815
8065
|
setSelectedToken
|
|
7816
8066
|
});
|
|
7817
|
-
const [transactionStatus, setTransactionStatus] =
|
|
7818
|
-
const [transactionHash, setTransactionHash] =
|
|
7819
|
-
const [errorMessage, setErrorMessage] =
|
|
7820
|
-
const [intentId, setIntentId] =
|
|
7821
|
-
const [paymentMethod, setPaymentMethod] =
|
|
8067
|
+
const [transactionStatus, setTransactionStatus] = useState10("idle");
|
|
8068
|
+
const [transactionHash, setTransactionHash] = useState10(null);
|
|
8069
|
+
const [errorMessage, setErrorMessage] = useState10(null);
|
|
8070
|
+
const [intentId, setIntentId] = useState10(null);
|
|
8071
|
+
const [paymentMethod, setPaymentMethod] = useState10("crypto");
|
|
7822
8072
|
const resetState = React2.useCallback(() => {
|
|
7823
8073
|
resetNavigation();
|
|
7824
8074
|
setSelectedToken(null);
|
|
@@ -7868,7 +8118,11 @@ function DepositProvider({
|
|
|
7868
8118
|
setWalletType,
|
|
7869
8119
|
walletType,
|
|
7870
8120
|
selectedNamespace,
|
|
7871
|
-
setSelectedNamespace
|
|
8121
|
+
setSelectedNamespace,
|
|
8122
|
+
wcStatus,
|
|
8123
|
+
wcErrorMessage,
|
|
8124
|
+
retryWalletConnect,
|
|
8125
|
+
dismissWcStatus
|
|
7872
8126
|
}),
|
|
7873
8127
|
[
|
|
7874
8128
|
WalletConnect,
|
|
@@ -7884,7 +8138,11 @@ function DepositProvider({
|
|
|
7884
8138
|
yourWalletTokens,
|
|
7885
8139
|
yourWalletTokensLoading,
|
|
7886
8140
|
selectedNamespace,
|
|
7887
|
-
setSelectedNamespace
|
|
8141
|
+
setSelectedNamespace,
|
|
8142
|
+
wcStatus,
|
|
8143
|
+
wcErrorMessage,
|
|
8144
|
+
retryWalletConnect,
|
|
8145
|
+
dismissWcStatus
|
|
7888
8146
|
]
|
|
7889
8147
|
);
|
|
7890
8148
|
const formValue = useMemo5(
|
|
@@ -7987,7 +8245,7 @@ var init_DepositContext = __esm({
|
|
|
7987
8245
|
});
|
|
7988
8246
|
|
|
7989
8247
|
// src/widget/hooks/useRouteBuilder.ts
|
|
7990
|
-
import { useEffect as
|
|
8248
|
+
import { useEffect as useEffect10, useMemo as useMemo6, useRef as useRef2, useState as useState11 } from "react";
|
|
7991
8249
|
function useRouteBuilder({
|
|
7992
8250
|
enabled = true,
|
|
7993
8251
|
debounceMs = 300,
|
|
@@ -8008,7 +8266,7 @@ function useRouteBuilder({
|
|
|
8008
8266
|
const { selectedToken, selectedChain, amount } = useDepositForm();
|
|
8009
8267
|
const { walletAddress } = useDepositWallet();
|
|
8010
8268
|
const { errorMessage } = useDepositTransaction();
|
|
8011
|
-
const [state, setState] =
|
|
8269
|
+
const [state, setState] = useState11({
|
|
8012
8270
|
isLoadingRoute: false,
|
|
8013
8271
|
networkFees: null,
|
|
8014
8272
|
estimatedReceive: null,
|
|
@@ -8016,8 +8274,8 @@ function useRouteBuilder({
|
|
|
8016
8274
|
intentId: null,
|
|
8017
8275
|
routeResult: null
|
|
8018
8276
|
});
|
|
8019
|
-
const abortRef =
|
|
8020
|
-
const [refreshTick, setRefreshTick] =
|
|
8277
|
+
const abortRef = useRef2(null);
|
|
8278
|
+
const [refreshTick, setRefreshTick] = useState11(0);
|
|
8021
8279
|
const routeKey = useMemo6(() => {
|
|
8022
8280
|
if (!enabled || !selectedToken || !selectedChain || !amount || !walletAddress) {
|
|
8023
8281
|
return null;
|
|
@@ -8058,7 +8316,7 @@ function useRouteBuilder({
|
|
|
8058
8316
|
]);
|
|
8059
8317
|
const hasFromChainId = fromChainId !== void 0 && fromChainId !== null && String(fromChainId).trim() !== "";
|
|
8060
8318
|
const hasToChainId = toChainId !== void 0 && toChainId !== null && String(toChainId).trim() !== "";
|
|
8061
|
-
|
|
8319
|
+
useEffect10(() => {
|
|
8062
8320
|
if (!fromChain || !hasFromChainId || !hasToChainId || !fromToken || !toToken || !fromAmountWei || !fromAddress || !toAddress)
|
|
8063
8321
|
return;
|
|
8064
8322
|
abortRef.current?.abort();
|
|
@@ -8194,7 +8452,7 @@ function useRouteBuilder({
|
|
|
8194
8452
|
walletAddress,
|
|
8195
8453
|
errorMessage
|
|
8196
8454
|
]);
|
|
8197
|
-
|
|
8455
|
+
useEffect10(() => {
|
|
8198
8456
|
if (!enabled || !routeKey || !refreshMs || refreshMs <= 0) return;
|
|
8199
8457
|
const id = setInterval(() => {
|
|
8200
8458
|
setRefreshTick((tick) => tick + 1);
|
|
@@ -8317,7 +8575,7 @@ var init_useAmountConstraints = __esm({
|
|
|
8317
8575
|
});
|
|
8318
8576
|
|
|
8319
8577
|
// src/widget/hooks/useTransactionSubmit.ts
|
|
8320
|
-
import { useCallback as useCallback7, useState as
|
|
8578
|
+
import { useCallback as useCallback7, useState as useState12 } from "react";
|
|
8321
8579
|
function useTransactionSubmit() {
|
|
8322
8580
|
const { selectedChain } = useDepositForm();
|
|
8323
8581
|
const { setCurrentStep } = useDepositNavigation();
|
|
@@ -8327,7 +8585,7 @@ function useTransactionSubmit() {
|
|
|
8327
8585
|
setErrorMessage,
|
|
8328
8586
|
setIntentId
|
|
8329
8587
|
} = useDepositTransaction();
|
|
8330
|
-
const [state, setState] =
|
|
8588
|
+
const [state, setState] = useState12({
|
|
8331
8589
|
isSubmitting: false,
|
|
8332
8590
|
txHash: null,
|
|
8333
8591
|
error: null
|
|
@@ -8461,10 +8719,10 @@ var init_useTransactionSubmit = __esm({
|
|
|
8461
8719
|
});
|
|
8462
8720
|
|
|
8463
8721
|
// src/hooks/useGTM.ts
|
|
8464
|
-
import { useEffect as
|
|
8722
|
+
import { useEffect as useEffect11, useRef as useRef3, useCallback as useCallback8 } from "react";
|
|
8465
8723
|
function useGTM(gtmId) {
|
|
8466
|
-
const isInitialized =
|
|
8467
|
-
const scriptRef =
|
|
8724
|
+
const isInitialized = useRef3(false);
|
|
8725
|
+
const scriptRef = useRef3(null);
|
|
8468
8726
|
const isGA4Allowed = useCallback8(() => {
|
|
8469
8727
|
try {
|
|
8470
8728
|
return Trustware.getConfig().features.shouldAllowGA4;
|
|
@@ -8472,7 +8730,7 @@ function useGTM(gtmId) {
|
|
|
8472
8730
|
return false;
|
|
8473
8731
|
}
|
|
8474
8732
|
}, []);
|
|
8475
|
-
|
|
8733
|
+
useEffect11(() => {
|
|
8476
8734
|
if (!isGA4Allowed()) {
|
|
8477
8735
|
console.warn(
|
|
8478
8736
|
"useGTM: GA4 tracking is disabled or Trustware config not initialized."
|
|
@@ -8610,7 +8868,7 @@ var init_hooks = __esm({
|
|
|
8610
8868
|
});
|
|
8611
8869
|
|
|
8612
8870
|
// src/widget/hooks/useTransactionPolling.ts
|
|
8613
|
-
import { useCallback as useCallback9, useEffect as
|
|
8871
|
+
import { useCallback as useCallback9, useEffect as useEffect12, useRef as useRef4, useState as useState13 } from "react";
|
|
8614
8872
|
function useTransactionPolling() {
|
|
8615
8873
|
const { setCurrentStep } = useDepositNavigation();
|
|
8616
8874
|
const { setTransactionStatus, setErrorMessage } = useDepositTransaction();
|
|
@@ -8624,18 +8882,18 @@ function useTransactionPolling() {
|
|
|
8624
8882
|
}
|
|
8625
8883
|
})();
|
|
8626
8884
|
const { trackEvent } = useGTM(GTM_ID);
|
|
8627
|
-
const [state, setState] =
|
|
8885
|
+
const [state, setState] = useState13({
|
|
8628
8886
|
isPolling: false,
|
|
8629
8887
|
apiStatus: null,
|
|
8630
8888
|
error: null,
|
|
8631
8889
|
transaction: null,
|
|
8632
8890
|
receiptSubmitted: false
|
|
8633
8891
|
});
|
|
8634
|
-
const pollingRef =
|
|
8635
|
-
const timeoutRef =
|
|
8636
|
-
const abortRef =
|
|
8637
|
-
const startTimeRef =
|
|
8638
|
-
const pollCountRef =
|
|
8892
|
+
const pollingRef = useRef4(null);
|
|
8893
|
+
const timeoutRef = useRef4(null);
|
|
8894
|
+
const abortRef = useRef4(false);
|
|
8895
|
+
const startTimeRef = useRef4(0);
|
|
8896
|
+
const pollCountRef = useRef4(0);
|
|
8639
8897
|
const clearPolling = useCallback9(() => {
|
|
8640
8898
|
abortRef.current = true;
|
|
8641
8899
|
if (pollingRef.current) {
|
|
@@ -8793,9 +9051,9 @@ function useTransactionPolling() {
|
|
|
8793
9051
|
receiptSubmitted: false
|
|
8794
9052
|
});
|
|
8795
9053
|
}, [clearPolling]);
|
|
8796
|
-
const clearPollingRef =
|
|
9054
|
+
const clearPollingRef = useRef4(clearPolling);
|
|
8797
9055
|
clearPollingRef.current = clearPolling;
|
|
8798
|
-
|
|
9056
|
+
useEffect12(() => {
|
|
8799
9057
|
return () => {
|
|
8800
9058
|
clearPollingRef.current();
|
|
8801
9059
|
};
|
|
@@ -8884,7 +9142,7 @@ var init_hooks2 = __esm({
|
|
|
8884
9142
|
});
|
|
8885
9143
|
|
|
8886
9144
|
// src/widget/state/deposit/useWalletTokenState.ts
|
|
8887
|
-
import { useCallback as useCallback10, useEffect as
|
|
9145
|
+
import { useCallback as useCallback10, useEffect as useEffect13, useRef as useRef5, useState as useState14 } from "react";
|
|
8888
9146
|
function useWalletTokenState({
|
|
8889
9147
|
walletAddress,
|
|
8890
9148
|
selectedChain,
|
|
@@ -8892,19 +9150,19 @@ function useWalletTokenState({
|
|
|
8892
9150
|
selectedToken,
|
|
8893
9151
|
setSelectedToken
|
|
8894
9152
|
}) {
|
|
8895
|
-
const [yourWalletTokens, setYourWalletTokens] =
|
|
8896
|
-
const [yourWalletTokensLoading, setYourWalletTokensLoading] =
|
|
8897
|
-
const [walletTokensReloadNonce, setWalletTokensReloadNonce] =
|
|
8898
|
-
const lastLoadedWalletRef =
|
|
9153
|
+
const [yourWalletTokens, setYourWalletTokens] = useState14([]);
|
|
9154
|
+
const [yourWalletTokensLoading, setYourWalletTokensLoading] = useState14(false);
|
|
9155
|
+
const [walletTokensReloadNonce, setWalletTokensReloadNonce] = useState14(0);
|
|
9156
|
+
const lastLoadedWalletRef = useRef5(null);
|
|
8899
9157
|
const { tokens } = useTokens(null);
|
|
8900
9158
|
const { chains } = useChains();
|
|
8901
|
-
const selectedChainRef =
|
|
9159
|
+
const selectedChainRef = useRef5(selectedChain);
|
|
8902
9160
|
selectedChainRef.current = selectedChain;
|
|
8903
|
-
const selectedTokenRef =
|
|
9161
|
+
const selectedTokenRef = useRef5(selectedToken);
|
|
8904
9162
|
selectedTokenRef.current = selectedToken;
|
|
8905
|
-
const setSelectedChainRef =
|
|
9163
|
+
const setSelectedChainRef = useRef5(setSelectedChain);
|
|
8906
9164
|
setSelectedChainRef.current = setSelectedChain;
|
|
8907
|
-
const setSelectedTokenRef =
|
|
9165
|
+
const setSelectedTokenRef = useRef5(setSelectedToken);
|
|
8908
9166
|
setSelectedTokenRef.current = setSelectedToken;
|
|
8909
9167
|
const { address: fallbackAddress } = useWalletInfo();
|
|
8910
9168
|
const getCurrentWalletAddress = useCallback10(
|
|
@@ -8913,7 +9171,7 @@ function useWalletTokenState({
|
|
|
8913
9171
|
},
|
|
8914
9172
|
[fallbackAddress]
|
|
8915
9173
|
);
|
|
8916
|
-
|
|
9174
|
+
useEffect13(() => {
|
|
8917
9175
|
if (!walletAddress || chains.length === 0 || tokens.length === 0) {
|
|
8918
9176
|
setYourWalletTokens([]);
|
|
8919
9177
|
if (!walletAddress) {
|
|
@@ -10016,7 +10274,7 @@ var init_AmountSlider = __esm({
|
|
|
10016
10274
|
});
|
|
10017
10275
|
|
|
10018
10276
|
// src/widget/components/AmountInputDisplay.tsx
|
|
10019
|
-
import { useRef as
|
|
10277
|
+
import { useRef as useRef6, useState as useState15 } from "react";
|
|
10020
10278
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
10021
10279
|
function formatDisplayAmount(value) {
|
|
10022
10280
|
if (!Number.isFinite(value) || value <= 0) return "0";
|
|
@@ -10055,8 +10313,8 @@ function AmountInputDisplay({
|
|
|
10055
10313
|
style,
|
|
10056
10314
|
inputAriaLabel = "Deposit amount"
|
|
10057
10315
|
}) {
|
|
10058
|
-
const [isEditing, setIsEditing] =
|
|
10059
|
-
const inputRef =
|
|
10316
|
+
const [isEditing, setIsEditing] = useState15(false);
|
|
10317
|
+
const inputRef = useRef6(null);
|
|
10060
10318
|
const handleAmountClick = () => {
|
|
10061
10319
|
if (isFixedAmount) return;
|
|
10062
10320
|
const isZeroish = !amount || parseFloat(amount) === 0;
|
|
@@ -10289,15 +10547,15 @@ __export(ConfettiEffect_exports, {
|
|
|
10289
10547
|
ConfettiEffect: () => ConfettiEffect,
|
|
10290
10548
|
default: () => ConfettiEffect_default
|
|
10291
10549
|
});
|
|
10292
|
-
import { useEffect as
|
|
10550
|
+
import { useEffect as useEffect14, useState as useState16 } from "react";
|
|
10293
10551
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
10294
10552
|
function ConfettiEffect({
|
|
10295
10553
|
isActive,
|
|
10296
10554
|
clearDelay = 3e3,
|
|
10297
10555
|
pieceCount = 50
|
|
10298
10556
|
}) {
|
|
10299
|
-
const [pieces, setPieces] =
|
|
10300
|
-
|
|
10557
|
+
const [pieces, setPieces] = useState16([]);
|
|
10558
|
+
useEffect14(() => {
|
|
10301
10559
|
if (isActive) {
|
|
10302
10560
|
const colors2 = [
|
|
10303
10561
|
"#10b981",
|
|
@@ -10382,7 +10640,7 @@ var init_ConfettiEffect = __esm({
|
|
|
10382
10640
|
});
|
|
10383
10641
|
|
|
10384
10642
|
// src/widget/components/Dialog.tsx
|
|
10385
|
-
import { useEffect as
|
|
10643
|
+
import { useEffect as useEffect15, useRef as useRef7 } from "react";
|
|
10386
10644
|
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
10387
10645
|
var Dialog;
|
|
10388
10646
|
var init_Dialog = __esm({
|
|
@@ -10399,11 +10657,11 @@ var init_Dialog = __esm({
|
|
|
10399
10657
|
confirmText = "Close Anyway",
|
|
10400
10658
|
isDark = false
|
|
10401
10659
|
}) => {
|
|
10402
|
-
const dialogRef =
|
|
10403
|
-
const overlayRef =
|
|
10404
|
-
const firstButtonRef =
|
|
10405
|
-
const lastButtonRef =
|
|
10406
|
-
|
|
10660
|
+
const dialogRef = useRef7(null);
|
|
10661
|
+
const overlayRef = useRef7(null);
|
|
10662
|
+
const firstButtonRef = useRef7(null);
|
|
10663
|
+
const lastButtonRef = useRef7(null);
|
|
10664
|
+
useEffect15(() => {
|
|
10407
10665
|
const handleEscape = (e2) => {
|
|
10408
10666
|
if (e2.key === "Escape" && open) {
|
|
10409
10667
|
e2.preventDefault();
|
|
@@ -10417,7 +10675,7 @@ var init_Dialog = __esm({
|
|
|
10417
10675
|
document.removeEventListener("keydown", handleEscape);
|
|
10418
10676
|
};
|
|
10419
10677
|
}, [open, onCancel]);
|
|
10420
|
-
|
|
10678
|
+
useEffect15(() => {
|
|
10421
10679
|
const handleTabKey = (e2) => {
|
|
10422
10680
|
if (!open) return;
|
|
10423
10681
|
if (e2.key === "Tab") {
|
|
@@ -10441,7 +10699,7 @@ var init_Dialog = __esm({
|
|
|
10441
10699
|
document.removeEventListener("keydown", handleTabKey);
|
|
10442
10700
|
};
|
|
10443
10701
|
}, [open]);
|
|
10444
|
-
|
|
10702
|
+
useEffect15(() => {
|
|
10445
10703
|
if (open) {
|
|
10446
10704
|
const originalStyle = window.getComputedStyle(document.body).overflow;
|
|
10447
10705
|
document.body.style.overflow = "hidden";
|
|
@@ -10747,7 +11005,7 @@ var init_TransactionHashLink = __esm({
|
|
|
10747
11005
|
});
|
|
10748
11006
|
|
|
10749
11007
|
// src/widget/components/SwipeToConfirmTokens.tsx
|
|
10750
|
-
import { useState as
|
|
11008
|
+
import { useState as useState17, useRef as useRef8, useCallback as useCallback12, useEffect as useEffect16 } from "react";
|
|
10751
11009
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
10752
11010
|
function SwipeToConfirmTokens({
|
|
10753
11011
|
fromToken,
|
|
@@ -10762,16 +11020,16 @@ function SwipeToConfirmTokens({
|
|
|
10762
11020
|
style,
|
|
10763
11021
|
text
|
|
10764
11022
|
}) {
|
|
10765
|
-
const [dragX, setDragX] =
|
|
10766
|
-
const [isDragging, setIsDragging] =
|
|
10767
|
-
const [isComplete, setIsComplete] =
|
|
10768
|
-
const trackRef =
|
|
10769
|
-
const thumbRef =
|
|
10770
|
-
const [isLongPressing, setIsLongPressing] =
|
|
10771
|
-
const [longPressProgress, setLongPressProgress] =
|
|
10772
|
-
const longPressTimerRef =
|
|
10773
|
-
const longPressStartRef =
|
|
10774
|
-
const longPressAnimationRef =
|
|
11023
|
+
const [dragX, setDragX] = useState17(0);
|
|
11024
|
+
const [isDragging, setIsDragging] = useState17(false);
|
|
11025
|
+
const [isComplete, setIsComplete] = useState17(false);
|
|
11026
|
+
const trackRef = useRef8(null);
|
|
11027
|
+
const thumbRef = useRef8(null);
|
|
11028
|
+
const [isLongPressing, setIsLongPressing] = useState17(false);
|
|
11029
|
+
const [longPressProgress, setLongPressProgress] = useState17(0);
|
|
11030
|
+
const longPressTimerRef = useRef8(null);
|
|
11031
|
+
const longPressStartRef = useRef8(null);
|
|
11032
|
+
const longPressAnimationRef = useRef8(null);
|
|
10775
11033
|
const LONG_PRESS_DURATION = 1500;
|
|
10776
11034
|
const thumbSize = 48;
|
|
10777
11035
|
const padding = 4;
|
|
@@ -10869,7 +11127,7 @@ function SwipeToConfirmTokens({
|
|
|
10869
11127
|
},
|
|
10870
11128
|
[cancelLongPress]
|
|
10871
11129
|
);
|
|
10872
|
-
|
|
11130
|
+
useEffect16(() => {
|
|
10873
11131
|
return () => {
|
|
10874
11132
|
if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
|
|
10875
11133
|
if (longPressAnimationRef.current)
|
|
@@ -10888,7 +11146,7 @@ function SwipeToConfirmTokens({
|
|
|
10888
11146
|
const handleTouchStart = () => handleDragStart();
|
|
10889
11147
|
const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
|
|
10890
11148
|
const handleTouchEnd = () => handleDragEnd();
|
|
10891
|
-
|
|
11149
|
+
useEffect16(() => {
|
|
10892
11150
|
if (isDragging) {
|
|
10893
11151
|
window.addEventListener("mousemove", handleMouseMove);
|
|
10894
11152
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -10900,8 +11158,8 @@ function SwipeToConfirmTokens({
|
|
|
10900
11158
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
10901
11159
|
const progress = getProgress();
|
|
10902
11160
|
const effectiveProgress = isLongPressing ? longPressProgress : progress;
|
|
10903
|
-
const [blinkOpacity, setBlinkOpacity] =
|
|
10904
|
-
|
|
11161
|
+
const [blinkOpacity, setBlinkOpacity] = useState17(1);
|
|
11162
|
+
useEffect16(() => {
|
|
10905
11163
|
if (disabled || isComplete || isDragging || isLongPressing) {
|
|
10906
11164
|
setBlinkOpacity(1);
|
|
10907
11165
|
return;
|
|
@@ -11363,7 +11621,7 @@ var init_ThemeToggle = __esm({
|
|
|
11363
11621
|
});
|
|
11364
11622
|
|
|
11365
11623
|
// src/widget/components/Toast.tsx
|
|
11366
|
-
import { useEffect as
|
|
11624
|
+
import { useEffect as useEffect17, useState as useState18, useCallback as useCallback13 } from "react";
|
|
11367
11625
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
11368
11626
|
function ToastItem({
|
|
11369
11627
|
id,
|
|
@@ -11373,14 +11631,14 @@ function ToastItem({
|
|
|
11373
11631
|
duration = 4e3,
|
|
11374
11632
|
onDismiss
|
|
11375
11633
|
}) {
|
|
11376
|
-
const [isExiting, setIsExiting] =
|
|
11377
|
-
|
|
11634
|
+
const [isExiting, setIsExiting] = useState18(false);
|
|
11635
|
+
useEffect17(() => {
|
|
11378
11636
|
const timer = setTimeout(() => {
|
|
11379
11637
|
setIsExiting(true);
|
|
11380
11638
|
}, duration);
|
|
11381
11639
|
return () => clearTimeout(timer);
|
|
11382
11640
|
}, [duration]);
|
|
11383
|
-
|
|
11641
|
+
useEffect17(() => {
|
|
11384
11642
|
if (isExiting) {
|
|
11385
11643
|
const exitTimer = setTimeout(() => {
|
|
11386
11644
|
onDismiss(id);
|
|
@@ -11579,8 +11837,8 @@ function toast(data) {
|
|
|
11579
11837
|
};
|
|
11580
11838
|
}
|
|
11581
11839
|
function ToastContainer() {
|
|
11582
|
-
const [activeToasts, setActiveToasts] =
|
|
11583
|
-
|
|
11840
|
+
const [activeToasts, setActiveToasts] = useState18([]);
|
|
11841
|
+
useEffect17(() => {
|
|
11584
11842
|
const listener = (newToasts) => {
|
|
11585
11843
|
setActiveToasts(newToasts);
|
|
11586
11844
|
};
|
|
@@ -11662,10 +11920,10 @@ var init_Toast = __esm({
|
|
|
11662
11920
|
|
|
11663
11921
|
// src/widget/components/TokenSwipePill.tsx
|
|
11664
11922
|
import React9, {
|
|
11665
|
-
useState as
|
|
11666
|
-
useRef as
|
|
11923
|
+
useState as useState19,
|
|
11924
|
+
useRef as useRef9,
|
|
11667
11925
|
useCallback as useCallback14,
|
|
11668
|
-
useEffect as
|
|
11926
|
+
useEffect as useEffect18,
|
|
11669
11927
|
useMemo as useMemo9
|
|
11670
11928
|
} from "react";
|
|
11671
11929
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
@@ -11678,10 +11936,10 @@ function TokenSwipePill({
|
|
|
11678
11936
|
walletAddress,
|
|
11679
11937
|
style
|
|
11680
11938
|
}) {
|
|
11681
|
-
const [isDragging, setIsDragging] =
|
|
11682
|
-
const [dragOffset, setDragOffset] =
|
|
11683
|
-
const startXRef =
|
|
11684
|
-
const containerRef =
|
|
11939
|
+
const [isDragging, setIsDragging] = useState19(false);
|
|
11940
|
+
const [dragOffset, setDragOffset] = useState19(0);
|
|
11941
|
+
const startXRef = useRef9(0);
|
|
11942
|
+
const containerRef = useRef9(null);
|
|
11685
11943
|
const currentIndex = tokens.findIndex(
|
|
11686
11944
|
(t) => normalizeAddress2(
|
|
11687
11945
|
t.address,
|
|
@@ -11752,7 +12010,7 @@ function TokenSwipePill({
|
|
|
11752
12010
|
const handleTouchEnd = () => {
|
|
11753
12011
|
handleDragEnd();
|
|
11754
12012
|
};
|
|
11755
|
-
|
|
12013
|
+
useEffect18(() => {
|
|
11756
12014
|
if (isDragging) {
|
|
11757
12015
|
window.addEventListener("mousemove", handleMouseMove);
|
|
11758
12016
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -12457,7 +12715,7 @@ var init_TransactionSteps = __esm({
|
|
|
12457
12715
|
});
|
|
12458
12716
|
|
|
12459
12717
|
// src/widget/components/WidgetContainer.tsx
|
|
12460
|
-
import { useEffect as
|
|
12718
|
+
import { useEffect as useEffect19, useState as useState20 } from "react";
|
|
12461
12719
|
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
12462
12720
|
function WidgetContainer({
|
|
12463
12721
|
children,
|
|
@@ -12465,8 +12723,8 @@ function WidgetContainer({
|
|
|
12465
12723
|
className,
|
|
12466
12724
|
style
|
|
12467
12725
|
}) {
|
|
12468
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
12469
|
-
|
|
12726
|
+
const [resolvedTheme, setResolvedTheme] = useState20("light");
|
|
12727
|
+
useEffect19(() => {
|
|
12470
12728
|
if (theme === "system") {
|
|
12471
12729
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
12472
12730
|
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
@@ -13011,7 +13269,7 @@ var init_ErrorPage = __esm({
|
|
|
13011
13269
|
});
|
|
13012
13270
|
|
|
13013
13271
|
// src/widget/components/ImageLoader.tsx
|
|
13014
|
-
import { useCallback as useCallback15, useEffect as
|
|
13272
|
+
import { useCallback as useCallback15, useEffect as useEffect20, useMemo as useMemo11, useRef as useRef10, useState as useState21 } from "react";
|
|
13015
13273
|
import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
13016
13274
|
function Skeleton({
|
|
13017
13275
|
background,
|
|
@@ -13040,18 +13298,18 @@ function ImageLoader({
|
|
|
13040
13298
|
onLoad,
|
|
13041
13299
|
onError
|
|
13042
13300
|
}) {
|
|
13043
|
-
const [status, setStatus] =
|
|
13044
|
-
const [attempt, setAttempt] =
|
|
13045
|
-
const [srcIsEmpty, setSrcIsEmpty] =
|
|
13046
|
-
const imgRef =
|
|
13047
|
-
const observerRef =
|
|
13048
|
-
const onLoadRef =
|
|
13049
|
-
const onErrorRef =
|
|
13050
|
-
|
|
13301
|
+
const [status, setStatus] = useState21("idle");
|
|
13302
|
+
const [attempt, setAttempt] = useState21(0);
|
|
13303
|
+
const [srcIsEmpty, setSrcIsEmpty] = useState21(false);
|
|
13304
|
+
const imgRef = useRef10(null);
|
|
13305
|
+
const observerRef = useRef10(null);
|
|
13306
|
+
const onLoadRef = useRef10(onLoad);
|
|
13307
|
+
const onErrorRef = useRef10(onError);
|
|
13308
|
+
useEffect20(() => {
|
|
13051
13309
|
onLoadRef.current = onLoad;
|
|
13052
13310
|
onErrorRef.current = onError;
|
|
13053
13311
|
}, [onLoad, onError]);
|
|
13054
|
-
|
|
13312
|
+
useEffect20(() => {
|
|
13055
13313
|
if (status === "error" && attempt < retry) {
|
|
13056
13314
|
const timer = setTimeout(() => {
|
|
13057
13315
|
setAttempt((prev) => prev + 1);
|
|
@@ -13078,7 +13336,7 @@ function ImageLoader({
|
|
|
13078
13336
|
onErrorRef.current?.();
|
|
13079
13337
|
};
|
|
13080
13338
|
}, [src]);
|
|
13081
|
-
|
|
13339
|
+
useEffect20(() => {
|
|
13082
13340
|
if (!lazy3) {
|
|
13083
13341
|
const timer = setTimeout(() => loadImage(), 0);
|
|
13084
13342
|
return () => clearTimeout(timer);
|
|
@@ -13548,7 +13806,7 @@ var init_AvailableTokenListItem = __esm({
|
|
|
13548
13806
|
});
|
|
13549
13807
|
|
|
13550
13808
|
// src/widget/features/token-selection/components/ChainSelectorPanel.tsx
|
|
13551
|
-
import { useState as
|
|
13809
|
+
import { useState as useState22, useMemo as useMemo12 } from "react";
|
|
13552
13810
|
import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
13553
13811
|
function ChainItem({
|
|
13554
13812
|
chain,
|
|
@@ -13760,7 +14018,7 @@ function ChainSelectorPanel({
|
|
|
13760
14018
|
otherChains,
|
|
13761
14019
|
popularChains
|
|
13762
14020
|
}) {
|
|
13763
|
-
const [chainSearch, setChainSearch] =
|
|
14021
|
+
const [chainSearch, setChainSearch] = useState22("");
|
|
13764
14022
|
const filteredPopular = useMemo12(() => {
|
|
13765
14023
|
if (!chainSearch) return popularChains;
|
|
13766
14024
|
const q = chainSearch.toLowerCase();
|
|
@@ -14519,7 +14777,7 @@ var init_WalletTokenListItem = __esm({
|
|
|
14519
14777
|
});
|
|
14520
14778
|
|
|
14521
14779
|
// src/widget/features/token-selection/components/TokenSelectorPanel.tsx
|
|
14522
|
-
import { useState as
|
|
14780
|
+
import { useState as useState23, useEffect as useEffect21 } from "react";
|
|
14523
14781
|
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
14524
14782
|
function TokenSectionLabel({
|
|
14525
14783
|
children,
|
|
@@ -14615,8 +14873,8 @@ function TokenSelectorPanel({
|
|
|
14615
14873
|
setSearchQuery,
|
|
14616
14874
|
tokensError
|
|
14617
14875
|
}) {
|
|
14618
|
-
const [showAll, setShowAll] =
|
|
14619
|
-
|
|
14876
|
+
const [showAll, setShowAll] = useState23(false);
|
|
14877
|
+
useEffect21(() => {
|
|
14620
14878
|
setShowAll(false);
|
|
14621
14879
|
}, [selectedChain, searchQuery]);
|
|
14622
14880
|
const hasWalletTokens = filteredWalletTokens.length > 0;
|
|
@@ -15540,7 +15798,7 @@ var init_CryptoPayAmountSection = __esm({
|
|
|
15540
15798
|
});
|
|
15541
15799
|
|
|
15542
15800
|
// src/widget/features/amount/hooks/useDepositAmountModel.ts
|
|
15543
|
-
import { useEffect as
|
|
15801
|
+
import { useEffect as useEffect22, useMemo as useMemo15 } from "react";
|
|
15544
15802
|
function useDepositAmountModel({
|
|
15545
15803
|
amount,
|
|
15546
15804
|
setAmount,
|
|
@@ -15561,7 +15819,7 @@ function useDepositAmountModel({
|
|
|
15561
15819
|
);
|
|
15562
15820
|
return Number.isFinite(normalized) ? normalized : 0;
|
|
15563
15821
|
}, [selectedToken?.balance, selectedToken?.decimals]);
|
|
15564
|
-
|
|
15822
|
+
useEffect22(() => {
|
|
15565
15823
|
if (fixedFromAmountString) return;
|
|
15566
15824
|
if (isReady && !hasUsdPrice && amountInputMode === "usd") {
|
|
15567
15825
|
setAmountInputMode("token");
|
|
@@ -15573,7 +15831,7 @@ function useDepositAmountModel({
|
|
|
15573
15831
|
isReady,
|
|
15574
15832
|
setAmountInputMode
|
|
15575
15833
|
]);
|
|
15576
|
-
|
|
15834
|
+
useEffect22(() => {
|
|
15577
15835
|
if (!fixedFromAmountString) return;
|
|
15578
15836
|
if (amount !== fixedFromAmountString) {
|
|
15579
15837
|
setAmount(fixedFromAmountString);
|
|
@@ -15751,7 +16009,7 @@ var init_useDepositAmountModel = __esm({
|
|
|
15751
16009
|
});
|
|
15752
16010
|
|
|
15753
16011
|
// src/widget/features/amount/hooks/useHomeAmountModel.ts
|
|
15754
|
-
import { useEffect as
|
|
16012
|
+
import { useEffect as useEffect23, useMemo as useMemo16 } from "react";
|
|
15755
16013
|
function useHomeAmountModel({
|
|
15756
16014
|
amount,
|
|
15757
16015
|
setAmount,
|
|
@@ -15762,7 +16020,7 @@ function useHomeAmountModel({
|
|
|
15762
16020
|
minAmountUsd,
|
|
15763
16021
|
maxAmountUsd
|
|
15764
16022
|
}) {
|
|
15765
|
-
|
|
16023
|
+
useEffect23(() => {
|
|
15766
16024
|
if (!fixedFromAmountString) return;
|
|
15767
16025
|
if (amount !== fixedFromAmountString) {
|
|
15768
16026
|
setAmount(fixedFromAmountString);
|
|
@@ -16172,8 +16430,20 @@ var init_WalletNamespaceTabs = __esm({
|
|
|
16172
16430
|
});
|
|
16173
16431
|
|
|
16174
16432
|
// src/widget/features/wallet/components/CryptoWalletDropdownContent.tsx
|
|
16175
|
-
import { useEffect as
|
|
16433
|
+
import { useEffect as useEffect24, useMemo as useMemo17, useRef as useRef11, useState as useState24 } from "react";
|
|
16176
16434
|
import { Fragment as Fragment7, jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
16435
|
+
function ecosystemToNamespace(ecosystem) {
|
|
16436
|
+
switch (ecosystem.trim().toLowerCase()) {
|
|
16437
|
+
case "evm":
|
|
16438
|
+
return "evm";
|
|
16439
|
+
case "solana":
|
|
16440
|
+
return "Solana";
|
|
16441
|
+
case "bitcoin":
|
|
16442
|
+
return "bitcoin";
|
|
16443
|
+
default:
|
|
16444
|
+
return null;
|
|
16445
|
+
}
|
|
16446
|
+
}
|
|
16177
16447
|
function DesktopWalletDropdownContent({
|
|
16178
16448
|
browserWallets,
|
|
16179
16449
|
handleWalletConnect,
|
|
@@ -16239,38 +16509,70 @@ function DesktopWalletDropdownContent({
|
|
|
16239
16509
|
);
|
|
16240
16510
|
}
|
|
16241
16511
|
function MobileWalletDropdownContent({
|
|
16242
|
-
|
|
16512
|
+
browserWallets,
|
|
16513
|
+
handleWalletConnect,
|
|
16514
|
+
handleWalletSelect: connectDetectedWallet2
|
|
16243
16515
|
}) {
|
|
16244
16516
|
const { setCurrentStep } = useDepositNavigation();
|
|
16245
|
-
const { selectedNamespace } = useDepositWallet();
|
|
16246
|
-
const { walletMetaId, isConnected, status } = useWalletInfo();
|
|
16247
|
-
const [hoveredId, setHoveredId] =
|
|
16248
|
-
const storeFallbackTimeoutRef =
|
|
16517
|
+
const { selectedNamespace, setSelectedNamespace } = useDepositWallet();
|
|
16518
|
+
const { walletMetaId, isConnected, status, detected } = useWalletInfo();
|
|
16519
|
+
const [hoveredId, setHoveredId] = useState24(null);
|
|
16520
|
+
const storeFallbackTimeoutRef = useRef11(
|
|
16249
16521
|
null
|
|
16250
16522
|
);
|
|
16251
|
-
|
|
16523
|
+
useEffect24(() => {
|
|
16252
16524
|
return () => {
|
|
16253
16525
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
16254
16526
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
16255
16527
|
}
|
|
16256
16528
|
};
|
|
16257
16529
|
}, []);
|
|
16530
|
+
useEffect24(() => {
|
|
16531
|
+
if (browserWallets.length > 0) return;
|
|
16532
|
+
const otherEcosystemWallet = detected.find((d) => {
|
|
16533
|
+
if (d.meta.id === "walletconnect") return false;
|
|
16534
|
+
const ecosystem = d.meta.ecosystem.trim().toLowerCase();
|
|
16535
|
+
return ecosystem !== "multi" && ecosystem !== selectedNamespace.trim().toLowerCase();
|
|
16536
|
+
});
|
|
16537
|
+
if (!otherEcosystemWallet) return;
|
|
16538
|
+
const nextNamespace = ecosystemToNamespace(
|
|
16539
|
+
otherEcosystemWallet.meta.ecosystem
|
|
16540
|
+
);
|
|
16541
|
+
if (nextNamespace) setSelectedNamespace(nextNamespace);
|
|
16542
|
+
}, [browserWallets, detected, selectedNamespace, setSelectedNamespace]);
|
|
16258
16543
|
const connectedWalletId = isConnected ? walletMetaId : null;
|
|
16259
16544
|
const currentUrl = window.location.href;
|
|
16260
|
-
const mobileWallets = useMemo17(
|
|
16261
|
-
|
|
16262
|
-
if (w.id === "walletconnect")
|
|
16545
|
+
const mobileWallets = useMemo17(() => {
|
|
16546
|
+
const entries = WALLETS.filter((w) => {
|
|
16547
|
+
if (w.id === "walletconnect") {
|
|
16548
|
+
return selectedNamespace.trim().toLowerCase() === "evm";
|
|
16549
|
+
}
|
|
16550
|
+
const isDetected = browserWallets.some((d) => d.meta.id === w.id);
|
|
16263
16551
|
const hasMobileLink = Boolean(w.deepLink);
|
|
16264
|
-
if (!hasMobileLink) return false;
|
|
16552
|
+
if (!hasMobileLink && !isDetected) return false;
|
|
16265
16553
|
return w.ecosystem.trim().toLowerCase() === "multi" || w.ecosystem.trim().toLowerCase() === selectedNamespace.trim().toLowerCase();
|
|
16266
|
-
})
|
|
16267
|
-
|
|
16268
|
-
|
|
16269
|
-
|
|
16554
|
+
}).map((meta) => ({
|
|
16555
|
+
meta,
|
|
16556
|
+
detectedWallet: browserWallets.find((d) => d.meta.id === meta.id) ?? null
|
|
16557
|
+
}));
|
|
16558
|
+
const listedIds = new Set(entries.map((e2) => e2.meta.id));
|
|
16559
|
+
for (const detected2 of browserWallets) {
|
|
16560
|
+
if (!listedIds.has(detected2.meta.id)) {
|
|
16561
|
+
entries.push({ meta: detected2.meta, detectedWallet: detected2 });
|
|
16562
|
+
}
|
|
16563
|
+
}
|
|
16564
|
+
return entries;
|
|
16565
|
+
}, [browserWallets, selectedNamespace]);
|
|
16566
|
+
const handleWalletSelect = (entry) => {
|
|
16567
|
+
const { meta: wallet, detectedWallet } = entry;
|
|
16270
16568
|
if (wallet.id === "walletconnect") {
|
|
16271
16569
|
handleWalletConnect();
|
|
16272
16570
|
return;
|
|
16273
16571
|
}
|
|
16572
|
+
if (detectedWallet) {
|
|
16573
|
+
void connectDetectedWallet2(detectedWallet);
|
|
16574
|
+
return;
|
|
16575
|
+
}
|
|
16274
16576
|
if (wallet.deepLink) {
|
|
16275
16577
|
const deepLinkUrl = wallet.deepLink(currentUrl);
|
|
16276
16578
|
if (deepLinkUrl) {
|
|
@@ -16340,15 +16642,16 @@ function MobileWalletDropdownContent({
|
|
|
16340
16642
|
scrollbarWidth: "thin",
|
|
16341
16643
|
scrollbarColor: `${colors.muted} transparent`
|
|
16342
16644
|
},
|
|
16343
|
-
children: mobileWallets.map((
|
|
16645
|
+
children: mobileWallets.map((entry) => {
|
|
16646
|
+
const wallet = entry.meta;
|
|
16344
16647
|
const isConnectedWallet = wallet.id === connectedWalletId;
|
|
16345
|
-
const isDisabled = isConnected && !isConnectedWallet;
|
|
16648
|
+
const isDisabled = isConnected && !isConnectedWallet && !entry.detectedWallet;
|
|
16346
16649
|
const isHovered = hoveredId === wallet.id;
|
|
16347
16650
|
return /* @__PURE__ */ jsxs30(
|
|
16348
16651
|
"button",
|
|
16349
16652
|
{
|
|
16350
16653
|
type: "button",
|
|
16351
|
-
onClick: () => !isDisabled && handleWalletSelect(
|
|
16654
|
+
onClick: () => !isDisabled && handleWalletSelect(entry),
|
|
16352
16655
|
onMouseEnter: () => !isDisabled && setHoveredId(wallet.id),
|
|
16353
16656
|
onMouseLeave: () => setHoveredId(null),
|
|
16354
16657
|
style: {
|
|
@@ -16424,7 +16727,7 @@ function MobileWalletDropdownContent({
|
|
|
16424
16727
|
}
|
|
16425
16728
|
}
|
|
16426
16729
|
),
|
|
16427
|
-
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "
|
|
16730
|
+
/* @__PURE__ */ jsx36("span", { style: { fontSize: fontSize.xs, color: "#22c55e" }, children: "Continue" })
|
|
16428
16731
|
]
|
|
16429
16732
|
}
|
|
16430
16733
|
)
|
|
@@ -16489,7 +16792,9 @@ function CryptoWalletDropdownContent({
|
|
|
16489
16792
|
isMobile && /* @__PURE__ */ jsx36(
|
|
16490
16793
|
MobileWalletDropdownContent,
|
|
16491
16794
|
{
|
|
16492
|
-
|
|
16795
|
+
browserWallets,
|
|
16796
|
+
handleWalletConnect,
|
|
16797
|
+
handleWalletSelect
|
|
16493
16798
|
}
|
|
16494
16799
|
)
|
|
16495
16800
|
] });
|
|
@@ -16959,7 +17264,7 @@ var init_HomePaymentOptions = __esm({
|
|
|
16959
17264
|
});
|
|
16960
17265
|
|
|
16961
17266
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
16962
|
-
import { useCallback as useCallback18, useEffect as
|
|
17267
|
+
import { useCallback as useCallback18, useEffect as useEffect25, useMemo as useMemo18, useRef as useRef12, useState as useState25 } from "react";
|
|
16963
17268
|
function useHomeWalletActions({
|
|
16964
17269
|
connectWallet,
|
|
16965
17270
|
detectedWallets,
|
|
@@ -16968,12 +17273,12 @@ function useHomeWalletActions({
|
|
|
16968
17273
|
WalletConnect
|
|
16969
17274
|
// setCurrentStepInternal,
|
|
16970
17275
|
}) {
|
|
16971
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] =
|
|
16972
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] =
|
|
16973
|
-
const cryptoDropdownRef =
|
|
16974
|
-
const fiatDropdownRef =
|
|
17276
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState25(false);
|
|
17277
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState25(false);
|
|
17278
|
+
const cryptoDropdownRef = useRef12(null);
|
|
17279
|
+
const fiatDropdownRef = useRef12(null);
|
|
16975
17280
|
const { disconnect } = useWalletInfo();
|
|
16976
|
-
|
|
17281
|
+
useEffect25(() => {
|
|
16977
17282
|
const handleClickOutside = (event) => {
|
|
16978
17283
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
16979
17284
|
setIsCryptoDropdownOpen(false);
|
|
@@ -17023,9 +17328,11 @@ function useHomeWalletActions({
|
|
|
17023
17328
|
const { selectedNamespace } = useDepositWallet();
|
|
17024
17329
|
const browserWallets = useMemo18(() => {
|
|
17025
17330
|
if (!detectedWallets?.length) return [];
|
|
17026
|
-
return detectedWallets.filter(
|
|
17027
|
-
(wallet
|
|
17028
|
-
|
|
17331
|
+
return detectedWallets.filter((wallet) => {
|
|
17332
|
+
if (wallet?.meta?.id === "walletconnect") return false;
|
|
17333
|
+
const ecosystem = wallet?.meta?.ecosystem.trim().toLowerCase();
|
|
17334
|
+
return ecosystem === "multi" || ecosystem === selectedNamespace.trim().toLowerCase();
|
|
17335
|
+
});
|
|
17029
17336
|
}, [detectedWallets, selectedNamespace]);
|
|
17030
17337
|
return {
|
|
17031
17338
|
browserWallets,
|
|
@@ -17059,11 +17366,114 @@ var init_wallet = __esm({
|
|
|
17059
17366
|
});
|
|
17060
17367
|
|
|
17061
17368
|
// src/widget/pages/Home.tsx
|
|
17062
|
-
import { jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17369
|
+
import { Fragment as Fragment8, jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
17370
|
+
function WalletConnectStatusBanner({
|
|
17371
|
+
status,
|
|
17372
|
+
errorMessage,
|
|
17373
|
+
onRetry,
|
|
17374
|
+
onDismiss
|
|
17375
|
+
}) {
|
|
17376
|
+
const isDone = status !== "connecting";
|
|
17377
|
+
const isFailed = status === "failed";
|
|
17378
|
+
const { text, icon } = wcBannerCopy[status];
|
|
17379
|
+
return /* @__PURE__ */ jsxs35(
|
|
17380
|
+
"div",
|
|
17381
|
+
{
|
|
17382
|
+
style: {
|
|
17383
|
+
display: "flex",
|
|
17384
|
+
alignItems: "center",
|
|
17385
|
+
gap: spacing[2],
|
|
17386
|
+
width: "100%",
|
|
17387
|
+
padding: `${spacing[2.5]} ${spacing[3]}`,
|
|
17388
|
+
marginBottom: spacing[4],
|
|
17389
|
+
borderRadius: borderRadius.lg,
|
|
17390
|
+
backgroundColor: isFailed ? "rgba(239,68,68,0.1)" : isDone ? "rgba(234,179,8,0.1)" : colors.muted,
|
|
17391
|
+
border: isFailed ? "1px solid rgba(239,68,68,0.4)" : isDone ? "1px solid rgba(234,179,8,0.4)" : `1px solid ${colors.border}`
|
|
17392
|
+
},
|
|
17393
|
+
children: [
|
|
17394
|
+
icon === "spinner" ? /* @__PURE__ */ jsx44(
|
|
17395
|
+
"div",
|
|
17396
|
+
{
|
|
17397
|
+
style: {
|
|
17398
|
+
width: "0.875rem",
|
|
17399
|
+
height: "0.875rem",
|
|
17400
|
+
border: `2px solid ${colors.mutedForeground}`,
|
|
17401
|
+
borderTopColor: "transparent",
|
|
17402
|
+
borderRadius: "9999px",
|
|
17403
|
+
animation: "tw-spin 1s linear infinite",
|
|
17404
|
+
flexShrink: 0
|
|
17405
|
+
}
|
|
17406
|
+
}
|
|
17407
|
+
) : /* @__PURE__ */ jsx44("span", { style: { fontSize: fontSize.sm, flexShrink: 0 }, "aria-hidden": true, children: icon }),
|
|
17408
|
+
/* @__PURE__ */ jsxs35(
|
|
17409
|
+
"p",
|
|
17410
|
+
{
|
|
17411
|
+
style: {
|
|
17412
|
+
flex: 1,
|
|
17413
|
+
fontSize: fontSize.xs,
|
|
17414
|
+
color: isDone ? colors.foreground : colors.mutedForeground,
|
|
17415
|
+
margin: 0
|
|
17416
|
+
},
|
|
17417
|
+
children: [
|
|
17418
|
+
text,
|
|
17419
|
+
isFailed && errorMessage ? ` ${errorMessage}` : ""
|
|
17420
|
+
]
|
|
17421
|
+
}
|
|
17422
|
+
),
|
|
17423
|
+
isDone && /* @__PURE__ */ jsxs35(Fragment8, { children: [
|
|
17424
|
+
/* @__PURE__ */ jsx44(
|
|
17425
|
+
"button",
|
|
17426
|
+
{
|
|
17427
|
+
type: "button",
|
|
17428
|
+
onClick: onRetry,
|
|
17429
|
+
style: {
|
|
17430
|
+
fontSize: fontSize.xs,
|
|
17431
|
+
fontWeight: fontWeight.semibold,
|
|
17432
|
+
color: colors.primary,
|
|
17433
|
+
backgroundColor: "transparent",
|
|
17434
|
+
border: 0,
|
|
17435
|
+
cursor: "pointer",
|
|
17436
|
+
flexShrink: 0
|
|
17437
|
+
},
|
|
17438
|
+
children: "Retry"
|
|
17439
|
+
}
|
|
17440
|
+
),
|
|
17441
|
+
/* @__PURE__ */ jsx44(
|
|
17442
|
+
"button",
|
|
17443
|
+
{
|
|
17444
|
+
type: "button",
|
|
17445
|
+
onClick: onDismiss,
|
|
17446
|
+
"aria-label": "Dismiss",
|
|
17447
|
+
style: {
|
|
17448
|
+
fontSize: fontSize.xs,
|
|
17449
|
+
color: colors.mutedForeground,
|
|
17450
|
+
backgroundColor: "transparent",
|
|
17451
|
+
border: 0,
|
|
17452
|
+
cursor: "pointer",
|
|
17453
|
+
flexShrink: 0,
|
|
17454
|
+
padding: 0,
|
|
17455
|
+
lineHeight: 1
|
|
17456
|
+
},
|
|
17457
|
+
children: "\xD7"
|
|
17458
|
+
}
|
|
17459
|
+
)
|
|
17460
|
+
] })
|
|
17461
|
+
]
|
|
17462
|
+
}
|
|
17463
|
+
);
|
|
17464
|
+
}
|
|
17063
17465
|
function Home({ style: _style }) {
|
|
17064
17466
|
const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
|
|
17065
17467
|
const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
|
|
17066
|
-
const {
|
|
17468
|
+
const {
|
|
17469
|
+
connectWallet,
|
|
17470
|
+
WalletConnect,
|
|
17471
|
+
setWalletType,
|
|
17472
|
+
wcStatus,
|
|
17473
|
+
wcErrorMessage,
|
|
17474
|
+
retryWalletConnect,
|
|
17475
|
+
dismissWcStatus
|
|
17476
|
+
} = useDepositWallet();
|
|
17067
17477
|
const { resolvedTheme } = useDepositUi();
|
|
17068
17478
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
17069
17479
|
const { detected: detectedWallets } = useWalletDetection();
|
|
@@ -17145,6 +17555,15 @@ function Home({ style: _style }) {
|
|
|
17145
17555
|
position: "relative"
|
|
17146
17556
|
},
|
|
17147
17557
|
children: [
|
|
17558
|
+
wcStatus !== "idle" && /* @__PURE__ */ jsx44(
|
|
17559
|
+
WalletConnectStatusBanner,
|
|
17560
|
+
{
|
|
17561
|
+
status: wcStatus,
|
|
17562
|
+
errorMessage: wcErrorMessage,
|
|
17563
|
+
onRetry: retryWalletConnect,
|
|
17564
|
+
onDismiss: dismissWcStatus
|
|
17565
|
+
}
|
|
17566
|
+
),
|
|
17148
17567
|
/* @__PURE__ */ jsx44(
|
|
17149
17568
|
"p",
|
|
17150
17569
|
{
|
|
@@ -17220,6 +17639,7 @@ function Home({ style: _style }) {
|
|
|
17220
17639
|
}
|
|
17221
17640
|
);
|
|
17222
17641
|
}
|
|
17642
|
+
var wcBannerCopy;
|
|
17223
17643
|
var init_Home = __esm({
|
|
17224
17644
|
"src/widget/pages/Home.tsx"() {
|
|
17225
17645
|
"use strict";
|
|
@@ -17229,6 +17649,20 @@ var init_Home = __esm({
|
|
|
17229
17649
|
init_amount();
|
|
17230
17650
|
init_wallets();
|
|
17231
17651
|
init_wallet();
|
|
17652
|
+
wcBannerCopy = {
|
|
17653
|
+
connecting: {
|
|
17654
|
+
text: "Waiting for wallet approval via WalletConnect\u2026",
|
|
17655
|
+
icon: "spinner"
|
|
17656
|
+
},
|
|
17657
|
+
timedOut: {
|
|
17658
|
+
text: "Still waiting on WalletConnect \u2014 this is taking longer than expected.",
|
|
17659
|
+
icon: "\u26A0\uFE0F"
|
|
17660
|
+
},
|
|
17661
|
+
failed: {
|
|
17662
|
+
text: "WalletConnect connection failed.",
|
|
17663
|
+
icon: "\u2715"
|
|
17664
|
+
}
|
|
17665
|
+
};
|
|
17232
17666
|
}
|
|
17233
17667
|
});
|
|
17234
17668
|
|
|
@@ -31079,7 +31513,7 @@ var init_smart_account2 = __esm({
|
|
|
31079
31513
|
});
|
|
31080
31514
|
|
|
31081
31515
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
31082
|
-
import { useCallback as useCallback19, useEffect as
|
|
31516
|
+
import { useCallback as useCallback19, useEffect as useEffect26, useMemo as useMemo20, useRef as useRef13, useState as useState26 } from "react";
|
|
31083
31517
|
import { encodeFunctionData as encodeFunctionData8, erc20Abi } from "viem";
|
|
31084
31518
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
31085
31519
|
const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
|
|
@@ -31101,7 +31535,7 @@ function useTransactionActionModel({
|
|
|
31101
31535
|
walletAddress,
|
|
31102
31536
|
walletStatus
|
|
31103
31537
|
}) {
|
|
31104
|
-
const feeDataCacheRef =
|
|
31538
|
+
const feeDataCacheRef = useRef13({});
|
|
31105
31539
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
31106
31540
|
const { trackEvent } = useGTM(GTM_ID);
|
|
31107
31541
|
const destinationConfig = (() => {
|
|
@@ -31153,10 +31587,10 @@ function useTransactionActionModel({
|
|
|
31153
31587
|
const addr = txReq?.to ?? txReq?.target;
|
|
31154
31588
|
return addr ?? null;
|
|
31155
31589
|
}, [routeResult?.txReq]);
|
|
31156
|
-
const [allowanceWei, setAllowanceWei] =
|
|
31157
|
-
const [isReadingAllowance, setIsReadingAllowance] =
|
|
31158
|
-
const [isApproving, setIsApproving] =
|
|
31159
|
-
const [gasReservationWei, setGasReservationWei] =
|
|
31590
|
+
const [allowanceWei, setAllowanceWei] = useState26(0n);
|
|
31591
|
+
const [isReadingAllowance, setIsReadingAllowance] = useState26(false);
|
|
31592
|
+
const [isApproving, setIsApproving] = useState26(false);
|
|
31593
|
+
const [gasReservationWei, setGasReservationWei] = useState26(0n);
|
|
31160
31594
|
const readAllowance = useCallback19(async () => {
|
|
31161
31595
|
if (!isEvm || isNativeSelected || !!routeResult?.sponsorship || // sponsored routes: SA approves bridge inside the UO batch
|
|
31162
31596
|
!backendChainId2 || !selectedTokenOnBackendChain || !walletAddress || !spender || !selectedToken?.address) {
|
|
@@ -31187,7 +31621,7 @@ function useTransactionActionModel({
|
|
|
31187
31621
|
spender,
|
|
31188
31622
|
walletAddress
|
|
31189
31623
|
]);
|
|
31190
|
-
|
|
31624
|
+
useEffect26(() => {
|
|
31191
31625
|
void readAllowance();
|
|
31192
31626
|
}, [readAllowance]);
|
|
31193
31627
|
const needsApproval = isEvm && !isNativeSelected && !routeResult?.sponsorship && // sponsored routes use Permit2 + SA internal batch — no EOA bridge approval
|
|
@@ -31391,13 +31825,13 @@ function useTransactionActionModel({
|
|
|
31391
31825
|
routeResult?.txReq,
|
|
31392
31826
|
walletAddress
|
|
31393
31827
|
]);
|
|
31394
|
-
|
|
31828
|
+
useEffect26(() => {
|
|
31395
31829
|
if (routeResult) {
|
|
31396
31830
|
void estimateGasReservationWei();
|
|
31397
31831
|
}
|
|
31398
31832
|
}, [estimateGasReservationWei, routeResult]);
|
|
31399
|
-
const [smartAccountFailed, setSmartAccountFailed] =
|
|
31400
|
-
|
|
31833
|
+
const [smartAccountFailed, setSmartAccountFailed] = useState26(false);
|
|
31834
|
+
useEffect26(() => {
|
|
31401
31835
|
setSmartAccountFailed(false);
|
|
31402
31836
|
}, [routeResult?.intentId]);
|
|
31403
31837
|
const handleConfirm = useCallback19(async () => {
|
|
@@ -31731,12 +32165,12 @@ var init_DefaultCryptoPay = __esm({
|
|
|
31731
32165
|
});
|
|
31732
32166
|
|
|
31733
32167
|
// src/widget/pages/CryptoPay/RouteQuoteLoader.tsx
|
|
31734
|
-
import { useState as
|
|
32168
|
+
import { useState as useState27, useEffect as useEffect27 } from "react";
|
|
31735
32169
|
import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
31736
32170
|
function RouteQuoteLoader({ selectedToken }) {
|
|
31737
|
-
const [messageIndex, setMessageIndex] =
|
|
31738
|
-
const [visible, setVisible] =
|
|
31739
|
-
|
|
32171
|
+
const [messageIndex, setMessageIndex] = useState27(0);
|
|
32172
|
+
const [visible, setVisible] = useState27(true);
|
|
32173
|
+
useEffect27(() => {
|
|
31740
32174
|
let t = null;
|
|
31741
32175
|
const interval = setInterval(() => {
|
|
31742
32176
|
setVisible(false);
|
|
@@ -31912,8 +32346,8 @@ var init_RouteQuoteLoader = __esm({
|
|
|
31912
32346
|
});
|
|
31913
32347
|
|
|
31914
32348
|
// src/widget/pages/CryptoPay/index.tsx
|
|
31915
|
-
import { useEffect as
|
|
31916
|
-
import { Fragment as
|
|
32349
|
+
import { useEffect as useEffect28, useMemo as useMemo21 } from "react";
|
|
32350
|
+
import { Fragment as Fragment9, jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
31917
32351
|
function CryptoPay({ style: _style }) {
|
|
31918
32352
|
const {
|
|
31919
32353
|
amount,
|
|
@@ -32022,7 +32456,7 @@ function CryptoPay({ style: _style }) {
|
|
|
32022
32456
|
});
|
|
32023
32457
|
const { emitError } = useTrustware();
|
|
32024
32458
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
32025
|
-
|
|
32459
|
+
useEffect28(() => {
|
|
32026
32460
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
32027
32461
|
emitError?.(
|
|
32028
32462
|
new TrustwareError({
|
|
@@ -32152,7 +32586,7 @@ function CryptoPay({ style: _style }) {
|
|
|
32152
32586
|
]
|
|
32153
32587
|
}
|
|
32154
32588
|
),
|
|
32155
|
-
showSkeleton ? /* @__PURE__ */ jsx50(
|
|
32589
|
+
showSkeleton ? /* @__PURE__ */ jsx50(Fragment9, { children: /* @__PURE__ */ jsx50(
|
|
32156
32590
|
"div",
|
|
32157
32591
|
{
|
|
32158
32592
|
style: {
|
|
@@ -32163,8 +32597,8 @@ function CryptoPay({ style: _style }) {
|
|
|
32163
32597
|
},
|
|
32164
32598
|
children: /* @__PURE__ */ jsx50(LoadingSkeleton, {})
|
|
32165
32599
|
}
|
|
32166
|
-
) }) : /* @__PURE__ */ jsxs40(
|
|
32167
|
-
isReady && /* @__PURE__ */ jsx50(
|
|
32600
|
+
) }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32601
|
+
isReady && /* @__PURE__ */ jsx50(Fragment9, { children: isLoadingRoute && !routeResult ? /* @__PURE__ */ jsx50(RouteQuoteLoader, { selectedToken: readySelectedToken }) : /* @__PURE__ */ jsxs40(Fragment9, { children: [
|
|
32168
32602
|
/* @__PURE__ */ jsx50(
|
|
32169
32603
|
CryptoPayAmountSection,
|
|
32170
32604
|
{
|
|
@@ -32243,7 +32677,7 @@ var init_CryptoPay = __esm({
|
|
|
32243
32677
|
});
|
|
32244
32678
|
|
|
32245
32679
|
// src/widget/pages/Processing.tsx
|
|
32246
|
-
import { useEffect as
|
|
32680
|
+
import { useEffect as useEffect29, useMemo as useMemo22, useRef as useRef14 } from "react";
|
|
32247
32681
|
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
32248
32682
|
function getProgressFromStatus(status) {
|
|
32249
32683
|
switch (status) {
|
|
@@ -32282,13 +32716,13 @@ function Processing({ style }) {
|
|
|
32282
32716
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
32283
32717
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
32284
32718
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
32285
|
-
const hasStartedPolling =
|
|
32286
|
-
|
|
32719
|
+
const hasStartedPolling = useRef14(false);
|
|
32720
|
+
useEffect29(() => {
|
|
32287
32721
|
return () => {
|
|
32288
32722
|
hasStartedPolling.current = false;
|
|
32289
32723
|
};
|
|
32290
32724
|
}, []);
|
|
32291
|
-
|
|
32725
|
+
useEffect29(() => {
|
|
32292
32726
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
32293
32727
|
hasStartedPolling.current = true;
|
|
32294
32728
|
startPolling(intentId, transactionHash);
|
|
@@ -32788,14 +33222,14 @@ var init_WidgetRouter = __esm({
|
|
|
32788
33222
|
});
|
|
32789
33223
|
|
|
32790
33224
|
// src/modes/swap/hooks/useSwapRoute.ts
|
|
32791
|
-
import { useCallback as useCallback20, useRef as
|
|
33225
|
+
import { useCallback as useCallback20, useRef as useRef15, useState as useState28 } from "react";
|
|
32792
33226
|
function useSwapRoute() {
|
|
32793
|
-
const [state, setState] =
|
|
33227
|
+
const [state, setState] = useState28({
|
|
32794
33228
|
data: null,
|
|
32795
33229
|
loading: false,
|
|
32796
33230
|
error: null
|
|
32797
33231
|
});
|
|
32798
|
-
const abortRef =
|
|
33232
|
+
const abortRef = useRef15(false);
|
|
32799
33233
|
const fetch2 = useCallback20(
|
|
32800
33234
|
async (params) => {
|
|
32801
33235
|
const { fromToken, fromChain, toToken, toChain, amount, walletAddress } = params;
|
|
@@ -32854,7 +33288,7 @@ var init_useSwapRoute = __esm({
|
|
|
32854
33288
|
});
|
|
32855
33289
|
|
|
32856
33290
|
// src/modes/swap/hooks/useSwapExecution.ts
|
|
32857
|
-
import { useCallback as useCallback21, useRef as
|
|
33291
|
+
import { useCallback as useCallback21, useRef as useRef16, useState as useState29 } from "react";
|
|
32858
33292
|
import { encodeFunctionData as encodeFunctionData9, erc20Abi as erc20Abi2 } from "viem";
|
|
32859
33293
|
function normalizeTx(raw) {
|
|
32860
33294
|
const r = raw;
|
|
@@ -32889,7 +33323,7 @@ async function waitForApprovalConfirmation(chainId, txHash) {
|
|
|
32889
33323
|
throw new Error("Timed out waiting for approval confirmation");
|
|
32890
33324
|
}
|
|
32891
33325
|
function useSwapExecution(fromChain) {
|
|
32892
|
-
const [state, setState] =
|
|
33326
|
+
const [state, setState] = useState29({
|
|
32893
33327
|
txStatus: "idle",
|
|
32894
33328
|
txHash: null,
|
|
32895
33329
|
intentId: null,
|
|
@@ -32898,11 +33332,11 @@ function useSwapExecution(fromChain) {
|
|
|
32898
33332
|
isSubmitting: false,
|
|
32899
33333
|
allowanceStatus: "unknown"
|
|
32900
33334
|
});
|
|
32901
|
-
const saFailedUntilRef =
|
|
32902
|
-
const pollingRef =
|
|
32903
|
-
const timeoutRef =
|
|
32904
|
-
const abortRef =
|
|
32905
|
-
const pollCountRef =
|
|
33335
|
+
const saFailedUntilRef = useRef16(0);
|
|
33336
|
+
const pollingRef = useRef16(null);
|
|
33337
|
+
const timeoutRef = useRef16(null);
|
|
33338
|
+
const abortRef = useRef16(false);
|
|
33339
|
+
const pollCountRef = useRef16(0);
|
|
32906
33340
|
const clearPolling = useCallback21(() => {
|
|
32907
33341
|
abortRef.current = true;
|
|
32908
33342
|
if (pollingRef.current) clearTimeout(pollingRef.current);
|
|
@@ -33265,13 +33699,13 @@ var init_forex = __esm({
|
|
|
33265
33699
|
});
|
|
33266
33700
|
|
|
33267
33701
|
// src/modes/swap/hooks/useForex.ts
|
|
33268
|
-
import { useEffect as
|
|
33702
|
+
import { useEffect as useEffect30, useRef as useRef17, useState as useState30 } from "react";
|
|
33269
33703
|
function useForex() {
|
|
33270
|
-
const [rates, setRates] =
|
|
33271
|
-
const [error, setError] =
|
|
33272
|
-
const [lastUpdated, setLastUpdated] =
|
|
33273
|
-
const timerRef =
|
|
33274
|
-
|
|
33704
|
+
const [rates, setRates] = useState30({ USD: 1 });
|
|
33705
|
+
const [error, setError] = useState30(null);
|
|
33706
|
+
const [lastUpdated, setLastUpdated] = useState30(null);
|
|
33707
|
+
const timerRef = useRef17(null);
|
|
33708
|
+
useEffect30(() => {
|
|
33275
33709
|
let cancelled = false;
|
|
33276
33710
|
const load = () => {
|
|
33277
33711
|
fetchForexRates("USD").then((r) => {
|
|
@@ -33308,7 +33742,7 @@ var init_useForex = __esm({
|
|
|
33308
33742
|
});
|
|
33309
33743
|
|
|
33310
33744
|
// src/modes/swap/components/SwapTokenSelect.tsx
|
|
33311
|
-
import { useState as
|
|
33745
|
+
import { useState as useState31, useMemo as useMemo26, useEffect as useEffect31 } from "react";
|
|
33312
33746
|
import { jsx as jsx55, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
33313
33747
|
function SwapTokenSelect({
|
|
33314
33748
|
side,
|
|
@@ -33324,10 +33758,10 @@ function SwapTokenSelect({
|
|
|
33324
33758
|
allowedTokens,
|
|
33325
33759
|
excludeToken
|
|
33326
33760
|
}) {
|
|
33327
|
-
const [localChain, setLocalChain] =
|
|
33328
|
-
const [pinnedTokens, setPinnedTokens] =
|
|
33329
|
-
const [pinnedLoading, setPinnedLoading] =
|
|
33330
|
-
|
|
33761
|
+
const [localChain, setLocalChain] = useState31(initialChain);
|
|
33762
|
+
const [pinnedTokens, setPinnedTokens] = useState31([]);
|
|
33763
|
+
const [pinnedLoading, setPinnedLoading] = useState31(false);
|
|
33764
|
+
useEffect31(() => {
|
|
33331
33765
|
if (!allowedTokens || allowedTokens.length === 0 || !localChain) {
|
|
33332
33766
|
setPinnedTokens([]);
|
|
33333
33767
|
return;
|
|
@@ -33629,8 +34063,8 @@ var init_currency = __esm({
|
|
|
33629
34063
|
});
|
|
33630
34064
|
|
|
33631
34065
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorMobile.tsx
|
|
33632
|
-
import { useEffect as
|
|
33633
|
-
import { Fragment as
|
|
34066
|
+
import { useEffect as useEffect32, useMemo as useMemo27, useRef as useRef18, useState as useState32 } from "react";
|
|
34067
|
+
import { Fragment as Fragment10, jsx as jsx56, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
33634
34068
|
function SwapWalletSelectorMobile({
|
|
33635
34069
|
walletStatus,
|
|
33636
34070
|
walletAddress,
|
|
@@ -33647,14 +34081,14 @@ function SwapWalletSelectorMobile({
|
|
|
33647
34081
|
} = useWalletInfo();
|
|
33648
34082
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
33649
34083
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
33650
|
-
const [wcConnecting, setWcConnecting] =
|
|
33651
|
-
const [connectingId, setConnectingId] =
|
|
33652
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
33653
|
-
const prevStatusRef =
|
|
33654
|
-
const storeFallbackTimeoutRef =
|
|
34084
|
+
const [wcConnecting, setWcConnecting] = useState32(false);
|
|
34085
|
+
const [connectingId, setConnectingId] = useState32(null);
|
|
34086
|
+
const [selectedNamespace, setSelectedNamespace] = useState32("evm");
|
|
34087
|
+
const prevStatusRef = useRef18(walletStatus);
|
|
34088
|
+
const storeFallbackTimeoutRef = useRef18(
|
|
33655
34089
|
null
|
|
33656
34090
|
);
|
|
33657
|
-
|
|
34091
|
+
useEffect32(() => {
|
|
33658
34092
|
const prev = prevStatusRef.current;
|
|
33659
34093
|
if (prev !== walletStatus) {
|
|
33660
34094
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -33663,7 +34097,7 @@ function SwapWalletSelectorMobile({
|
|
|
33663
34097
|
prevStatusRef.current = walletStatus;
|
|
33664
34098
|
}
|
|
33665
34099
|
}, [walletStatus]);
|
|
33666
|
-
|
|
34100
|
+
useEffect32(() => {
|
|
33667
34101
|
return () => {
|
|
33668
34102
|
if (storeFallbackTimeoutRef.current !== null) {
|
|
33669
34103
|
clearTimeout(storeFallbackTimeoutRef.current);
|
|
@@ -33928,6 +34362,7 @@ function SwapWalletSelectorMobile({
|
|
|
33928
34362
|
const { meta } = entry;
|
|
33929
34363
|
const isWalletConnected = managerConnected && walletMetaId === meta.id;
|
|
33930
34364
|
const isConnecting = connectingId === meta.id && walletStatus === "connecting";
|
|
34365
|
+
const isRowDisabled = managerConnected && !isWalletConnected && !entry.detectedWallet;
|
|
33931
34366
|
return /* @__PURE__ */ jsxs44(
|
|
33932
34367
|
"div",
|
|
33933
34368
|
{
|
|
@@ -33945,7 +34380,8 @@ function SwapWalletSelectorMobile({
|
|
|
33945
34380
|
isWalletConnected && {
|
|
33946
34381
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
33947
34382
|
border: `1px solid ${colors.primary}`
|
|
33948
|
-
}
|
|
34383
|
+
},
|
|
34384
|
+
isRowDisabled && { opacity: 0.4 }
|
|
33949
34385
|
),
|
|
33950
34386
|
children: [
|
|
33951
34387
|
/* @__PURE__ */ jsx56(
|
|
@@ -34036,7 +34472,7 @@ function SwapWalletSelectorMobile({
|
|
|
34036
34472
|
"button",
|
|
34037
34473
|
{
|
|
34038
34474
|
onClick: () => void handleClick(entry),
|
|
34039
|
-
disabled: walletStatus === "connecting",
|
|
34475
|
+
disabled: walletStatus === "connecting" || isRowDisabled,
|
|
34040
34476
|
style: mergeStyles(
|
|
34041
34477
|
{
|
|
34042
34478
|
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
@@ -34049,7 +34485,7 @@ function SwapWalletSelectorMobile({
|
|
|
34049
34485
|
cursor: "pointer",
|
|
34050
34486
|
flexShrink: 0
|
|
34051
34487
|
},
|
|
34052
|
-
walletStatus === "connecting" && {
|
|
34488
|
+
(walletStatus === "connecting" || isRowDisabled) && {
|
|
34053
34489
|
opacity: 0.5,
|
|
34054
34490
|
cursor: "not-allowed"
|
|
34055
34491
|
}
|
|
@@ -34064,7 +34500,7 @@ function SwapWalletSelectorMobile({
|
|
|
34064
34500
|
})
|
|
34065
34501
|
}
|
|
34066
34502
|
),
|
|
34067
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(
|
|
34503
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs44(Fragment10, { children: [
|
|
34068
34504
|
/* @__PURE__ */ jsx56(
|
|
34069
34505
|
"div",
|
|
34070
34506
|
{
|
|
@@ -34077,6 +34513,7 @@ function SwapWalletSelectorMobile({
|
|
|
34077
34513
|
),
|
|
34078
34514
|
(() => {
|
|
34079
34515
|
const wcConnected = managerConnected && connectedVia === "walletconnect";
|
|
34516
|
+
const wcRowDisabled = managerConnected && !wcConnected;
|
|
34080
34517
|
return /* @__PURE__ */ jsxs44(
|
|
34081
34518
|
"div",
|
|
34082
34519
|
{
|
|
@@ -34095,9 +34532,10 @@ function SwapWalletSelectorMobile({
|
|
|
34095
34532
|
wcConnected && {
|
|
34096
34533
|
boxShadow: `0 0 0 2px ${colors.primary}`,
|
|
34097
34534
|
border: `1px solid ${colors.primary}`
|
|
34098
|
-
}
|
|
34535
|
+
},
|
|
34536
|
+
wcRowDisabled && { opacity: 0.4, cursor: "not-allowed" }
|
|
34099
34537
|
),
|
|
34100
|
-
onClick: !wcConnected ? () => void handleWalletConnect() : void 0,
|
|
34538
|
+
onClick: !wcConnected && !wcRowDisabled ? () => void handleWalletConnect() : void 0,
|
|
34101
34539
|
children: [
|
|
34102
34540
|
/* @__PURE__ */ jsx56(
|
|
34103
34541
|
"div",
|
|
@@ -34193,18 +34631,24 @@ function SwapWalletSelectorMobile({
|
|
|
34193
34631
|
e2.stopPropagation();
|
|
34194
34632
|
void handleWalletConnect();
|
|
34195
34633
|
},
|
|
34196
|
-
disabled: wcConnecting,
|
|
34197
|
-
style:
|
|
34198
|
-
|
|
34199
|
-
|
|
34200
|
-
|
|
34201
|
-
|
|
34202
|
-
|
|
34203
|
-
|
|
34204
|
-
|
|
34205
|
-
|
|
34206
|
-
|
|
34207
|
-
|
|
34634
|
+
disabled: wcConnecting || wcRowDisabled,
|
|
34635
|
+
style: mergeStyles(
|
|
34636
|
+
{
|
|
34637
|
+
padding: `${spacing[1.5]} ${spacing[3]}`,
|
|
34638
|
+
borderRadius: "9999px",
|
|
34639
|
+
backgroundColor: "rgba(59,130,246,0.1)",
|
|
34640
|
+
color: colors.primary,
|
|
34641
|
+
fontSize: fontSize.xs,
|
|
34642
|
+
fontWeight: fontWeight.medium,
|
|
34643
|
+
border: 0,
|
|
34644
|
+
cursor: "pointer",
|
|
34645
|
+
flexShrink: 0
|
|
34646
|
+
},
|
|
34647
|
+
(wcConnecting || wcRowDisabled) && {
|
|
34648
|
+
opacity: 0.5,
|
|
34649
|
+
cursor: "not-allowed"
|
|
34650
|
+
}
|
|
34651
|
+
),
|
|
34208
34652
|
children: "Connect"
|
|
34209
34653
|
}
|
|
34210
34654
|
)
|
|
@@ -34235,8 +34679,8 @@ var init_SwapWalletSelectorMobile = __esm({
|
|
|
34235
34679
|
});
|
|
34236
34680
|
|
|
34237
34681
|
// src/modes/swap/components/SwapWalletSelector/SwapWalletSelectorDesktop.tsx
|
|
34238
|
-
import { useEffect as
|
|
34239
|
-
import { Fragment as
|
|
34682
|
+
import { useEffect as useEffect33, useMemo as useMemo28, useRef as useRef19, useState as useState33 } from "react";
|
|
34683
|
+
import { Fragment as Fragment11, jsx as jsx57, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
34240
34684
|
function SwapWalletSelectorDesktop({
|
|
34241
34685
|
walletStatus,
|
|
34242
34686
|
walletAddress,
|
|
@@ -34252,16 +34696,16 @@ function SwapWalletSelectorDesktop({
|
|
|
34252
34696
|
} = useWalletInfo();
|
|
34253
34697
|
const walletConnectCfg = TrustwareConfigStore.peek()?.walletConnect;
|
|
34254
34698
|
const connectWC = useWalletConnectConnect(walletConnectCfg);
|
|
34255
|
-
const [wcConnecting, setWcConnecting] =
|
|
34256
|
-
const [connectingId, setConnectingId] =
|
|
34257
|
-
const [timerExpired, setTimerExpired] =
|
|
34258
|
-
const [selectedNamespace, setSelectedNamespace] =
|
|
34259
|
-
const prevStatusRef =
|
|
34260
|
-
|
|
34699
|
+
const [wcConnecting, setWcConnecting] = useState33(false);
|
|
34700
|
+
const [connectingId, setConnectingId] = useState33(null);
|
|
34701
|
+
const [timerExpired, setTimerExpired] = useState33(false);
|
|
34702
|
+
const [selectedNamespace, setSelectedNamespace] = useState33("evm");
|
|
34703
|
+
const prevStatusRef = useRef19(walletStatus);
|
|
34704
|
+
useEffect33(() => {
|
|
34261
34705
|
const t = setTimeout(() => setTimerExpired(true), 450);
|
|
34262
34706
|
return () => clearTimeout(t);
|
|
34263
34707
|
}, []);
|
|
34264
|
-
|
|
34708
|
+
useEffect33(() => {
|
|
34265
34709
|
const prev = prevStatusRef.current;
|
|
34266
34710
|
if (prev !== walletStatus) {
|
|
34267
34711
|
if (prev === "connecting" && (walletStatus === "connected" || walletStatus === "error")) {
|
|
@@ -34694,7 +35138,7 @@ function SwapWalletSelectorDesktop({
|
|
|
34694
35138
|
})
|
|
34695
35139
|
}
|
|
34696
35140
|
),
|
|
34697
|
-
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(
|
|
35141
|
+
selectedNamespace === "evm" && /* @__PURE__ */ jsxs45(Fragment11, { children: [
|
|
34698
35142
|
/* @__PURE__ */ jsx57(
|
|
34699
35143
|
"div",
|
|
34700
35144
|
{
|
|
@@ -34858,7 +35302,7 @@ var init_SwapWalletSelectorDesktop = __esm({
|
|
|
34858
35302
|
});
|
|
34859
35303
|
|
|
34860
35304
|
// src/modes/swap/components/SwapWalletSelector/index.tsx
|
|
34861
|
-
import { Fragment as
|
|
35305
|
+
import { Fragment as Fragment12, jsx as jsx58, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
34862
35306
|
function SwapWalletSelector({
|
|
34863
35307
|
walletStatus,
|
|
34864
35308
|
walletAddress,
|
|
@@ -34866,7 +35310,7 @@ function SwapWalletSelector({
|
|
|
34866
35310
|
onBack
|
|
34867
35311
|
}) {
|
|
34868
35312
|
const isMobile = useIsMobile();
|
|
34869
|
-
return /* @__PURE__ */ jsxs46(
|
|
35313
|
+
return /* @__PURE__ */ jsxs46(Fragment12, { children: [
|
|
34870
35314
|
isMobile && /* @__PURE__ */ jsx58(
|
|
34871
35315
|
SwapWalletSelectorMobile_default,
|
|
34872
35316
|
{
|
|
@@ -34911,13 +35355,13 @@ import {
|
|
|
34911
35355
|
lazy as lazy2,
|
|
34912
35356
|
Suspense as Suspense2,
|
|
34913
35357
|
useCallback as useCallback22,
|
|
34914
|
-
useEffect as
|
|
35358
|
+
useEffect as useEffect34,
|
|
34915
35359
|
useMemo as useMemo29,
|
|
34916
|
-
useRef as
|
|
34917
|
-
useState as
|
|
35360
|
+
useRef as useRef20,
|
|
35361
|
+
useState as useState34
|
|
34918
35362
|
} from "react";
|
|
34919
35363
|
import ReactDOM from "react-dom";
|
|
34920
|
-
import { Fragment as
|
|
35364
|
+
import { Fragment as Fragment13, jsx as jsx59, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
34921
35365
|
function fmtAmount(n, max = 6) {
|
|
34922
35366
|
if (!isFinite(n) || n === 0) return "0";
|
|
34923
35367
|
return n.toLocaleString(void 0, { maximumFractionDigits: max });
|
|
@@ -35009,36 +35453,36 @@ function SwapMode({
|
|
|
35009
35453
|
theme: themeProp,
|
|
35010
35454
|
style
|
|
35011
35455
|
}) {
|
|
35012
|
-
const [stage, setStage] =
|
|
35013
|
-
const [fromToken, setFromToken] =
|
|
35456
|
+
const [stage, setStage] = useState34("home");
|
|
35457
|
+
const [fromToken, setFromToken] = useState34(
|
|
35014
35458
|
null
|
|
35015
35459
|
);
|
|
35016
|
-
const [fromChain, setFromChain] =
|
|
35017
|
-
const [toToken, setToToken] =
|
|
35018
|
-
const [toChain, setToChain] =
|
|
35019
|
-
const [amount, setAmount] =
|
|
35020
|
-
const [amountInputMode, setAmountInputMode] =
|
|
35460
|
+
const [fromChain, setFromChain] = useState34(null);
|
|
35461
|
+
const [toToken, setToToken] = useState34(null);
|
|
35462
|
+
const [toChain, setToChain] = useState34(null);
|
|
35463
|
+
const [amount, setAmount] = useState34("");
|
|
35464
|
+
const [amountInputMode, setAmountInputMode] = useState34(
|
|
35021
35465
|
"usd"
|
|
35022
35466
|
);
|
|
35023
|
-
const [hoverSell, setHoverSell] =
|
|
35024
|
-
const [showRateDetails, setShowRateDetails] =
|
|
35025
|
-
const [showReviewDetails, setShowReviewDetails] =
|
|
35026
|
-
const [showSettings, setShowSettings] =
|
|
35027
|
-
const [maxApproval, setMaxApproval] =
|
|
35028
|
-
const [slippage, setSlippage] =
|
|
35029
|
-
const [slippageInput, setSlippageInput] =
|
|
35030
|
-
const [selectedCurrency, setSelectedCurrency] =
|
|
35031
|
-
const [showCurrencyDropdown, setShowCurrencyDropdown] =
|
|
35032
|
-
const [completedAt, setCompletedAt] =
|
|
35033
|
-
const [copiedHash, setCopiedHash] =
|
|
35034
|
-
const [rateUpdated, setRateUpdated] =
|
|
35035
|
-
const prevToAmountRef =
|
|
35036
|
-
const [destAddress, setDestAddress] =
|
|
35037
|
-
const [quoteAge, setQuoteAge] =
|
|
35038
|
-
const quoteTimestampRef =
|
|
35039
|
-
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] =
|
|
35040
|
-
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] =
|
|
35041
|
-
const latestFetchParamsRef =
|
|
35467
|
+
const [hoverSell, setHoverSell] = useState34(false);
|
|
35468
|
+
const [showRateDetails, setShowRateDetails] = useState34(false);
|
|
35469
|
+
const [showReviewDetails, setShowReviewDetails] = useState34(false);
|
|
35470
|
+
const [showSettings, setShowSettings] = useState34(false);
|
|
35471
|
+
const [maxApproval, setMaxApproval] = useState34(false);
|
|
35472
|
+
const [slippage, setSlippage] = useState34(0.5);
|
|
35473
|
+
const [slippageInput, setSlippageInput] = useState34("");
|
|
35474
|
+
const [selectedCurrency, setSelectedCurrency] = useState34("USD");
|
|
35475
|
+
const [showCurrencyDropdown, setShowCurrencyDropdown] = useState34(false);
|
|
35476
|
+
const [completedAt, setCompletedAt] = useState34(null);
|
|
35477
|
+
const [copiedHash, setCopiedHash] = useState34(null);
|
|
35478
|
+
const [rateUpdated, setRateUpdated] = useState34(false);
|
|
35479
|
+
const prevToAmountRef = useRef20(null);
|
|
35480
|
+
const [destAddress, setDestAddress] = useState34("");
|
|
35481
|
+
const [quoteAge, setQuoteAge] = useState34(0);
|
|
35482
|
+
const quoteTimestampRef = useRef20(null);
|
|
35483
|
+
const [quoteLoadingMsgIdx, setQuoteLoadingMsgIdx] = useState34(0);
|
|
35484
|
+
const [quoteLoadingMsgVisible, setQuoteLoadingMsgVisible] = useState34(true);
|
|
35485
|
+
const latestFetchParamsRef = useRef20(null);
|
|
35042
35486
|
const { rates: forexRates } = useForex();
|
|
35043
35487
|
const currencyMeta = getCurrencyMeta(selectedCurrency);
|
|
35044
35488
|
const currencyRate = forexRates[selectedCurrency] ?? 1;
|
|
@@ -35054,8 +35498,8 @@ function SwapMode({
|
|
|
35054
35498
|
},
|
|
35055
35499
|
[currencyRate, selectedCurrency]
|
|
35056
35500
|
);
|
|
35057
|
-
const settingsRef =
|
|
35058
|
-
const currencyDropdownRef =
|
|
35501
|
+
const settingsRef = useRef20(null);
|
|
35502
|
+
const currencyDropdownRef = useRef20(null);
|
|
35059
35503
|
const { emitEvent } = useTrustware();
|
|
35060
35504
|
const { features, theme: configTheme } = useTrustwareConfig();
|
|
35061
35505
|
const effectiveThemeSetting = themeProp ?? configTheme ?? "system";
|
|
@@ -35089,8 +35533,8 @@ function SwapMode({
|
|
|
35089
35533
|
() => [...popularChains, ...otherChains],
|
|
35090
35534
|
[popularChains, otherChains]
|
|
35091
35535
|
);
|
|
35092
|
-
const destInitialized =
|
|
35093
|
-
|
|
35536
|
+
const destInitialized = useRef20(false);
|
|
35537
|
+
useEffect34(() => {
|
|
35094
35538
|
if (!defaultDestRef || destInitialized.current || allChains.length === 0)
|
|
35095
35539
|
return;
|
|
35096
35540
|
const chain = allChains.find(
|
|
@@ -35120,7 +35564,7 @@ function SwapMode({
|
|
|
35120
35564
|
}).catch(() => {
|
|
35121
35565
|
});
|
|
35122
35566
|
}, [defaultDestRef, allChains]);
|
|
35123
|
-
const { walletAddress, walletStatus, connectWallet
|
|
35567
|
+
const { walletAddress, walletStatus, connectWallet } = useWalletSessionState();
|
|
35124
35568
|
const setFromTokenStable = useCallback22(
|
|
35125
35569
|
(t) => setFromToken(t),
|
|
35126
35570
|
[]
|
|
@@ -35495,13 +35939,13 @@ function SwapMode({
|
|
|
35495
35939
|
const hasAmount = rawSellNum > 0 && (amountInputMode === "token" || hasFromUsdPrice);
|
|
35496
35940
|
const isConnected = walletStatus === "connected" && !!walletAddress;
|
|
35497
35941
|
const canGetQuote = hasTokens && hasAmount && !insufficient && isConnected && (!needsDestAddress || isValidDestAddress);
|
|
35498
|
-
|
|
35942
|
+
useEffect34(() => {
|
|
35499
35943
|
if (!fromToken) return;
|
|
35500
35944
|
if (!hasFromUsdPrice && amountInputMode === "usd") {
|
|
35501
35945
|
setAmountInputMode("token");
|
|
35502
35946
|
}
|
|
35503
35947
|
}, [fromToken, hasFromUsdPrice, amountInputMode]);
|
|
35504
|
-
|
|
35948
|
+
useEffect34(() => {
|
|
35505
35949
|
if (displayToAmount === null) {
|
|
35506
35950
|
prevToAmountRef.current = null;
|
|
35507
35951
|
return;
|
|
@@ -35515,14 +35959,14 @@ function SwapMode({
|
|
|
35515
35959
|
const t = setTimeout(() => setRateUpdated(false), 700);
|
|
35516
35960
|
return () => clearTimeout(t);
|
|
35517
35961
|
}, [displayToAmount]);
|
|
35518
|
-
|
|
35962
|
+
useEffect34(() => {
|
|
35519
35963
|
setDestAddress("");
|
|
35520
35964
|
}, [toChainType]);
|
|
35521
|
-
const fetchRef =
|
|
35522
|
-
|
|
35965
|
+
const fetchRef = useRef20(route.fetch);
|
|
35966
|
+
useEffect34(() => {
|
|
35523
35967
|
fetchRef.current = route.fetch;
|
|
35524
35968
|
});
|
|
35525
|
-
|
|
35969
|
+
useEffect34(() => {
|
|
35526
35970
|
if (!canGetQuote || stage !== "home") return;
|
|
35527
35971
|
if (!fromToken || !fromChain || !toToken || !toChain || !walletAddress)
|
|
35528
35972
|
return;
|
|
@@ -35551,7 +35995,7 @@ function SwapMode({
|
|
|
35551
35995
|
destAddress,
|
|
35552
35996
|
slippage
|
|
35553
35997
|
]);
|
|
35554
|
-
|
|
35998
|
+
useEffect34(() => {
|
|
35555
35999
|
if (!canGetQuote || !fromToken || !fromChain || !toToken || !toChain || !walletAddress) {
|
|
35556
36000
|
latestFetchParamsRef.current = null;
|
|
35557
36001
|
return;
|
|
@@ -35578,12 +36022,12 @@ function SwapMode({
|
|
|
35578
36022
|
destAddress,
|
|
35579
36023
|
slippage
|
|
35580
36024
|
]);
|
|
35581
|
-
|
|
36025
|
+
useEffect34(() => {
|
|
35582
36026
|
quoteTimestampRef.current = route.data ? Date.now() : null;
|
|
35583
36027
|
setQuoteAge(0);
|
|
35584
36028
|
}, [route.data]);
|
|
35585
|
-
const msgTimeoutRef =
|
|
35586
|
-
|
|
36029
|
+
const msgTimeoutRef = useRef20(null);
|
|
36030
|
+
useEffect34(() => {
|
|
35587
36031
|
if (!route.loading) {
|
|
35588
36032
|
setQuoteLoadingMsgIdx(0);
|
|
35589
36033
|
setQuoteLoadingMsgVisible(true);
|
|
@@ -35601,7 +36045,7 @@ function SwapMode({
|
|
|
35601
36045
|
if (msgTimeoutRef.current !== null) clearTimeout(msgTimeoutRef.current);
|
|
35602
36046
|
};
|
|
35603
36047
|
}, [route.loading]);
|
|
35604
|
-
|
|
36048
|
+
useEffect34(() => {
|
|
35605
36049
|
if (!route.data) return;
|
|
35606
36050
|
const id = setInterval(() => {
|
|
35607
36051
|
const ts = quoteTimestampRef.current;
|
|
@@ -35615,7 +36059,7 @@ function SwapMode({
|
|
|
35615
36059
|
}, 1e3);
|
|
35616
36060
|
return () => clearInterval(id);
|
|
35617
36061
|
}, [route.data]);
|
|
35618
|
-
|
|
36062
|
+
useEffect34(() => {
|
|
35619
36063
|
if (stage !== "review") return;
|
|
35620
36064
|
if (!route.data || !walletAddress) return;
|
|
35621
36065
|
const fromTokenAddress = fromToken?.address;
|
|
@@ -35626,7 +36070,7 @@ function SwapMode({
|
|
|
35626
36070
|
routeResult: route.data
|
|
35627
36071
|
});
|
|
35628
36072
|
}, [stage, route.data, walletAddress, fromToken]);
|
|
35629
|
-
|
|
36073
|
+
useEffect34(() => {
|
|
35630
36074
|
if (!showSettings) {
|
|
35631
36075
|
setShowCurrencyDropdown(false);
|
|
35632
36076
|
return;
|
|
@@ -35639,7 +36083,7 @@ function SwapMode({
|
|
|
35639
36083
|
document.addEventListener("mousedown", handler);
|
|
35640
36084
|
return () => document.removeEventListener("mousedown", handler);
|
|
35641
36085
|
}, [showSettings]);
|
|
35642
|
-
|
|
36086
|
+
useEffect34(() => {
|
|
35643
36087
|
if (!showCurrencyDropdown) return;
|
|
35644
36088
|
const handler = (e2) => {
|
|
35645
36089
|
if (currencyDropdownRef.current && !currencyDropdownRef.current.contains(e2.target)) {
|
|
@@ -36126,7 +36570,7 @@ function SwapMode({
|
|
|
36126
36570
|
padding: 0,
|
|
36127
36571
|
transition: "color 0.15s"
|
|
36128
36572
|
},
|
|
36129
|
-
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(
|
|
36573
|
+
children: isCopied ? "Copied!" : /* @__PURE__ */ jsxs47(Fragment13, { children: [
|
|
36130
36574
|
txHash.slice(0, 6),
|
|
36131
36575
|
"\u2026",
|
|
36132
36576
|
txHash.slice(-4),
|
|
@@ -37198,7 +37642,7 @@ function SwapMode({
|
|
|
37198
37642
|
walletAddress ? /* @__PURE__ */ jsxs47(
|
|
37199
37643
|
"button",
|
|
37200
37644
|
{
|
|
37201
|
-
onClick:
|
|
37645
|
+
onClick: handleConnectAndReview,
|
|
37202
37646
|
style: {
|
|
37203
37647
|
fontSize: fontSize.xs,
|
|
37204
37648
|
color: colors.mutedForeground,
|
|
@@ -37209,8 +37653,7 @@ function SwapMode({
|
|
|
37209
37653
|
children: [
|
|
37210
37654
|
walletAddress.slice(0, 6),
|
|
37211
37655
|
"...",
|
|
37212
|
-
walletAddress.slice(-4)
|
|
37213
|
-
" \xD7"
|
|
37656
|
+
walletAddress.slice(-4)
|
|
37214
37657
|
]
|
|
37215
37658
|
}
|
|
37216
37659
|
) : /* @__PURE__ */ jsx59(
|
|
@@ -38789,8 +39232,8 @@ function ReviewDetailRow({
|
|
|
38789
39232
|
value,
|
|
38790
39233
|
tooltip
|
|
38791
39234
|
}) {
|
|
38792
|
-
const iconRef =
|
|
38793
|
-
const [tipPos, setTipPos] =
|
|
39235
|
+
const iconRef = useRef20(null);
|
|
39236
|
+
const [tipPos, setTipPos] = useState34(null);
|
|
38794
39237
|
const handleMouseEnter = () => {
|
|
38795
39238
|
if (!tooltip || !iconRef.current) return;
|
|
38796
39239
|
const r = iconRef.current.getBoundingClientRect();
|
|
@@ -39125,14 +39568,14 @@ var init_swap = __esm({
|
|
|
39125
39568
|
|
|
39126
39569
|
// src/widget/TrustwareWidgetV2.tsx
|
|
39127
39570
|
import {
|
|
39128
|
-
useState as
|
|
39129
|
-
useEffect as
|
|
39130
|
-
useRef as
|
|
39571
|
+
useState as useState35,
|
|
39572
|
+
useEffect as useEffect35,
|
|
39573
|
+
useRef as useRef21,
|
|
39131
39574
|
useCallback as useCallback23,
|
|
39132
39575
|
useImperativeHandle,
|
|
39133
39576
|
forwardRef
|
|
39134
39577
|
} from "react";
|
|
39135
|
-
import { Fragment as
|
|
39578
|
+
import { Fragment as Fragment14, jsx as jsx60, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
39136
39579
|
function WidgetContent({
|
|
39137
39580
|
style,
|
|
39138
39581
|
onStateChange,
|
|
@@ -39143,7 +39586,7 @@ function WidgetContent({
|
|
|
39143
39586
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
39144
39587
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
39145
39588
|
useWalletExternalDisconnect(() => setCurrentStep("home"));
|
|
39146
|
-
|
|
39589
|
+
useEffect35(() => {
|
|
39147
39590
|
const state = {
|
|
39148
39591
|
currentStep,
|
|
39149
39592
|
amount,
|
|
@@ -39186,7 +39629,7 @@ function WidgetInner({
|
|
|
39186
39629
|
const { transactionStatus } = useDepositTransaction();
|
|
39187
39630
|
const { resolvedTheme } = useDepositUi();
|
|
39188
39631
|
const { status, revalidate, errors } = useTrustware();
|
|
39189
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
39632
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState35(false);
|
|
39190
39633
|
const handleCloseRequest = useCallback23(() => {
|
|
39191
39634
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
39192
39635
|
setShowConfirmDialog(true);
|
|
@@ -39198,7 +39641,7 @@ function WidgetInner({
|
|
|
39198
39641
|
onClose?.();
|
|
39199
39642
|
}
|
|
39200
39643
|
}, [transactionStatus, onClose, resetState]);
|
|
39201
|
-
|
|
39644
|
+
useEffect35(() => {
|
|
39202
39645
|
closeRequestRef.current = handleCloseRequest;
|
|
39203
39646
|
}, [handleCloseRequest, closeRequestRef]);
|
|
39204
39647
|
const handleConfirmClose = useCallback23(() => {
|
|
@@ -39214,7 +39657,7 @@ function WidgetInner({
|
|
|
39214
39657
|
const handleRefresh = useCallback23(() => {
|
|
39215
39658
|
revalidate?.();
|
|
39216
39659
|
}, [revalidate]);
|
|
39217
|
-
return /* @__PURE__ */ jsxs48(
|
|
39660
|
+
return /* @__PURE__ */ jsxs48(Fragment14, { children: [
|
|
39218
39661
|
/* @__PURE__ */ jsxs48(WidgetContainer, { theme: effectiveTheme, style, children: [
|
|
39219
39662
|
/* @__PURE__ */ jsx60(
|
|
39220
39663
|
WidgetContent,
|
|
@@ -39282,8 +39725,8 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39282
39725
|
onOpen,
|
|
39283
39726
|
showThemeToggle = true
|
|
39284
39727
|
}, ref) {
|
|
39285
|
-
const [isOpen, setIsOpen] =
|
|
39286
|
-
const closeRequestRef =
|
|
39728
|
+
const [isOpen, setIsOpen] = useState35(defaultOpen);
|
|
39729
|
+
const closeRequestRef = useRef21(null);
|
|
39287
39730
|
const config = useTrustwareConfig();
|
|
39288
39731
|
const effectiveInitialStep = initialStep;
|
|
39289
39732
|
const open = useCallback23(() => {
|