@embarkai/ui-kit 0.4.46 → 0.4.47
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/iframe/index.html +1 -1
- package/dist/iframe/main.js +1 -1
- package/dist/index.cjs +340 -341
- package/dist/index.js +246 -247
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2432,15 +2432,11 @@ function useBackupStatusChanges() {
|
|
|
2432
2432
|
onSuccess: ({ stats, detail }) => {
|
|
2433
2433
|
const hasRecoveryData = stats && (!!stats.created || !!stats?.devices?.length);
|
|
2434
2434
|
if (!!hasRecoveryData) {
|
|
2435
|
-
console.log(
|
|
2436
|
-
"[BACKUP STATUS] Recovery data found after backup status change.\n Redirect to main menu:",
|
|
2437
|
-
detail?.navigateToMainMenu
|
|
2438
|
-
);
|
|
2439
2435
|
setHasServerVault(true);
|
|
2440
|
-
if (!!detail?.
|
|
2441
|
-
|
|
2436
|
+
if (!!detail?.navigateToNicknameMenu) {
|
|
2437
|
+
console.log("[BACKUP STATUS] New user backup created, navigating to nickname settings");
|
|
2438
|
+
setTimeout(() => setPage("nickname-settings" /* NICKNAME_SETTINGS */), 1e3);
|
|
2442
2439
|
}
|
|
2443
|
-
console.info("[BACKUP STATUS] Recovery data found in vault, marking as has-server-vault");
|
|
2444
2440
|
} else {
|
|
2445
2441
|
setHasServerVault(false);
|
|
2446
2442
|
setPage("keysare-backup" /* KEYSARE_BACKUP */);
|
|
@@ -7586,25 +7582,15 @@ function useAuthMenuHandlers() {
|
|
|
7586
7582
|
const { config, callbacksRef } = useProviderConfig();
|
|
7587
7583
|
const qc = useQueryClient2();
|
|
7588
7584
|
const pendingLoginResponseRef = useRef6(null);
|
|
7589
|
-
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
7590
|
-
const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
|
|
7591
7585
|
const [telegramCleanup, setTelegramCleanup] = useState2(null);
|
|
7592
|
-
const
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
activeChainId,
|
|
7596
|
-
setError,
|
|
7597
|
-
setStatus,
|
|
7598
|
-
setSession,
|
|
7599
|
-
setAddress,
|
|
7600
|
-
setRecoveryUserId,
|
|
7601
|
-
setHasServerVault,
|
|
7602
|
-
setIsLoading
|
|
7603
|
-
} = useSession();
|
|
7586
|
+
const usePaymaster = useSession((st) => st.usePaymaster);
|
|
7587
|
+
const publicClient = useSession((st) => st.publicClient);
|
|
7588
|
+
const activeChainId = useSession((st) => st.activeChainId);
|
|
7604
7589
|
const setStep = useAuthStore((st) => st.setStep);
|
|
7605
7590
|
const setAlert = useAuthStore((st) => st.setAlert);
|
|
7606
7591
|
const createSessionWithKeyshare = useCallback8(
|
|
7607
7592
|
async (userId, hasServerKeyshare, isNewUser) => {
|
|
7593
|
+
const { setStatus } = useSession.getState();
|
|
7608
7594
|
try {
|
|
7609
7595
|
try {
|
|
7610
7596
|
callbacksRef.current?.onConnecting?.({ method: "wallet" });
|
|
@@ -7642,9 +7628,19 @@ function useAuthMenuHandlers() {
|
|
|
7642
7628
|
throw error;
|
|
7643
7629
|
}
|
|
7644
7630
|
},
|
|
7645
|
-
[
|
|
7631
|
+
[usePaymaster, activeChainId]
|
|
7646
7632
|
);
|
|
7647
7633
|
const onAuthSuccess = useCallback8(async () => {
|
|
7634
|
+
const {
|
|
7635
|
+
//
|
|
7636
|
+
setSession,
|
|
7637
|
+
setAddress,
|
|
7638
|
+
setStatus,
|
|
7639
|
+
setIsLoading,
|
|
7640
|
+
setError,
|
|
7641
|
+
setHasServerVault,
|
|
7642
|
+
setRecoveryUserId
|
|
7643
|
+
} = useSession.getState();
|
|
7648
7644
|
setIsLoading(true);
|
|
7649
7645
|
setStep("loading");
|
|
7650
7646
|
const loginResponse = pendingLoginResponseRef.current;
|
|
@@ -7708,11 +7704,11 @@ function useAuthMenuHandlers() {
|
|
|
7708
7704
|
if (!!jwt?.isNewUser || !hasKeyshareVaultBackup) {
|
|
7709
7705
|
if (!!jwt?.isNewUser) console.log("[AuthMenu] New user detected - forcing backup flow");
|
|
7710
7706
|
if (!hasKeyshareVaultBackup) console.log("[AuthMenu] No recovery data found - forcing backup flow");
|
|
7711
|
-
setIsDialogForced(true);
|
|
7712
|
-
setPage("keysare-backup" /* KEYSARE_BACKUP */);
|
|
7707
|
+
useLayoutStore.getState().setIsDialogForced(true);
|
|
7708
|
+
useLayoutDataStore.getState().setPage("keysare-backup" /* KEYSARE_BACKUP */);
|
|
7713
7709
|
} else {
|
|
7714
|
-
setIsDialogForced(false);
|
|
7715
|
-
setPage(null);
|
|
7710
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
7711
|
+
useLayoutDataStore.getState().setPage(null);
|
|
7716
7712
|
}
|
|
7717
7713
|
}, 100);
|
|
7718
7714
|
} catch (error) {
|
|
@@ -7724,9 +7720,7 @@ function useAuthMenuHandlers() {
|
|
|
7724
7720
|
setAddress(null);
|
|
7725
7721
|
setRecoveryUserId(userId);
|
|
7726
7722
|
setStatus("recovery_needed");
|
|
7727
|
-
setTimeout(() =>
|
|
7728
|
-
setPage("keyshare-restore" /* KEYSHARE_RESTORE */);
|
|
7729
|
-
}, 100);
|
|
7723
|
+
setTimeout(() => useLayoutDataStore.getState().setPage("keyshare-restore" /* KEYSHARE_RESTORE */), 100);
|
|
7730
7724
|
} else {
|
|
7731
7725
|
pendingLoginResponseRef.current = null;
|
|
7732
7726
|
await jwtTokenManager2.clearTokens();
|
|
@@ -7742,20 +7736,7 @@ function useAuthMenuHandlers() {
|
|
|
7742
7736
|
setIsLoading(false);
|
|
7743
7737
|
setStep("signin");
|
|
7744
7738
|
}
|
|
7745
|
-
}, [
|
|
7746
|
-
qc,
|
|
7747
|
-
setStep,
|
|
7748
|
-
setPage,
|
|
7749
|
-
setError,
|
|
7750
|
-
setStatus,
|
|
7751
|
-
setSession,
|
|
7752
|
-
setAlert,
|
|
7753
|
-
setAddress,
|
|
7754
|
-
setRecoveryUserId,
|
|
7755
|
-
setHasServerVault,
|
|
7756
|
-
setIsDialogForced,
|
|
7757
|
-
createSessionWithKeyshare
|
|
7758
|
-
]);
|
|
7739
|
+
}, [qc, setStep, setAlert, createSessionWithKeyshare]);
|
|
7759
7740
|
const goBackToSignIn = useCallback8(() => {
|
|
7760
7741
|
setStep("signin");
|
|
7761
7742
|
setAlert(null);
|
|
@@ -11590,75 +11571,51 @@ var init_LumiaIcon2 = __esm({
|
|
|
11590
11571
|
}
|
|
11591
11572
|
});
|
|
11592
11573
|
|
|
11593
|
-
// src/
|
|
11574
|
+
// src/internal/assets/networks/index.ts
|
|
11594
11575
|
import {
|
|
11595
11576
|
ARBITRUM_SEPOLIA_CHAIN_ID,
|
|
11596
11577
|
BASE_SEPOLIA_CHAIN_ID,
|
|
11578
|
+
BSC_MAINNET_CHAIN_ID,
|
|
11597
11579
|
BSC_TESTNET_CHAIN_ID as BSC_TESTNET_CHAIN_ID3,
|
|
11598
|
-
LUMIA_PULSAR_TESTNET_CHAIN_ID,
|
|
11599
11580
|
LUMIA_MAINNET_CHAIN_ID as LUMIA_MAINNET_CHAIN_ID3,
|
|
11600
|
-
|
|
11601
|
-
|
|
11581
|
+
LUMIA_PULSAR_TESTNET_CHAIN_ID,
|
|
11582
|
+
LUMIA_TESTNET_CHAIN_ID as LUMIA_TESTNET_CHAIN_ID3
|
|
11602
11583
|
} from "@embarkai/core/read";
|
|
11603
|
-
var
|
|
11584
|
+
var NETWORKS_ICONS;
|
|
11604
11585
|
var init_networks3 = __esm({
|
|
11605
|
-
"src/
|
|
11586
|
+
"src/internal/assets/networks/index.ts"() {
|
|
11606
11587
|
init_ArbitrumIcon();
|
|
11607
11588
|
init_BaseIcon();
|
|
11608
11589
|
init_BscIcon();
|
|
11609
11590
|
init_EthereumIcon();
|
|
11610
11591
|
init_LumiaIcon2();
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
isActive: true
|
|
11639
|
-
},
|
|
11640
|
-
{
|
|
11641
|
-
chainId: ARBITRUM_SEPOLIA_CHAIN_ID,
|
|
11642
|
-
name: "Arbitrum Sepolia",
|
|
11643
|
-
badge: "TESTNET",
|
|
11644
|
-
Icon: ArbitrumIcon,
|
|
11645
|
-
isActive: true
|
|
11646
|
-
},
|
|
11647
|
-
{
|
|
11648
|
-
chainId: BASE_SEPOLIA_CHAIN_ID,
|
|
11649
|
-
name: "Base Sepolia",
|
|
11650
|
-
badge: "TESTNET",
|
|
11651
|
-
Icon: BaseIcon,
|
|
11652
|
-
isActive: true
|
|
11653
|
-
},
|
|
11654
|
-
{
|
|
11655
|
-
chainId: LUMIA_PULSAR_TESTNET_CHAIN_ID,
|
|
11656
|
-
name: "Lumia Pulsar Testnet",
|
|
11657
|
-
badge: "TESTNET",
|
|
11658
|
-
Icon: LumiaIcon2,
|
|
11659
|
-
isActive: true
|
|
11660
|
-
}
|
|
11661
|
-
];
|
|
11592
|
+
NETWORKS_ICONS = {
|
|
11593
|
+
[LUMIA_MAINNET_CHAIN_ID3]: LumiaIcon2,
|
|
11594
|
+
[LUMIA_TESTNET_CHAIN_ID3]: LumiaIcon2,
|
|
11595
|
+
[LUMIA_PULSAR_TESTNET_CHAIN_ID]: LumiaIcon2,
|
|
11596
|
+
[BASE_SEPOLIA_CHAIN_ID]: BaseIcon,
|
|
11597
|
+
[BSC_MAINNET_CHAIN_ID]: BSCIcon,
|
|
11598
|
+
[BSC_TESTNET_CHAIN_ID3]: BSCIcon,
|
|
11599
|
+
1: EthereumIcon,
|
|
11600
|
+
[ARBITRUM_SEPOLIA_CHAIN_ID]: ArbitrumIcon
|
|
11601
|
+
};
|
|
11602
|
+
}
|
|
11603
|
+
});
|
|
11604
|
+
|
|
11605
|
+
// src/config/networks.ts
|
|
11606
|
+
import { SUPPORTED_CHAINS, SUPPORTED_MAINNETS } from "@embarkai/core/read";
|
|
11607
|
+
var NETWORK_OPTIONS;
|
|
11608
|
+
var init_networks4 = __esm({
|
|
11609
|
+
"src/config/networks.ts"() {
|
|
11610
|
+
init_networks3();
|
|
11611
|
+
init_EmbarkIcon();
|
|
11612
|
+
NETWORK_OPTIONS = [...SUPPORTED_CHAINS].map(([chainId, chain]) => ({
|
|
11613
|
+
chainId,
|
|
11614
|
+
name: chain.name,
|
|
11615
|
+
badge: SUPPORTED_MAINNETS.includes(chainId) ? "MAINNET" : "TESTNET",
|
|
11616
|
+
Icon: NETWORKS_ICONS[chainId] || EmbarkIcon,
|
|
11617
|
+
isActive: true
|
|
11618
|
+
}));
|
|
11662
11619
|
}
|
|
11663
11620
|
});
|
|
11664
11621
|
|
|
@@ -11855,7 +11812,7 @@ function ChainsMenu() {
|
|
|
11855
11812
|
}
|
|
11856
11813
|
var init_ChainsMenu = __esm({
|
|
11857
11814
|
"src/internal/components/ChainsMenu/ChainsMenu.tsx"() {
|
|
11858
|
-
|
|
11815
|
+
init_networks4();
|
|
11859
11816
|
init_ProviderContext();
|
|
11860
11817
|
init_SessionContext();
|
|
11861
11818
|
init_useT();
|
|
@@ -11959,7 +11916,7 @@ function ChainSwitchRequest() {
|
|
|
11959
11916
|
}
|
|
11960
11917
|
var init_ChainSwitchRequest = __esm({
|
|
11961
11918
|
"src/internal/components/ChainsMenu/ChainSwitchRequest.tsx"() {
|
|
11962
|
-
|
|
11919
|
+
init_networks4();
|
|
11963
11920
|
init_ProviderContext();
|
|
11964
11921
|
init_SessionContext();
|
|
11965
11922
|
init_useT();
|
|
@@ -13765,42 +13722,45 @@ var init_cloudStorage = __esm({
|
|
|
13765
13722
|
|
|
13766
13723
|
// src/internal/components/KeyshareRestoreMenu/hooks/useCreateBackup.ts
|
|
13767
13724
|
import { useMutation as useMutation9, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
|
|
13768
|
-
import { useEffect as useEffect20 } from "react";
|
|
13725
|
+
import { useCallback as useCallback17, useEffect as useEffect20 } from "react";
|
|
13769
13726
|
function useCreateBackup() {
|
|
13770
13727
|
const qc = useQueryClient9();
|
|
13771
13728
|
const session = useSession((st) => st.session);
|
|
13772
13729
|
const address = useSession((st) => st.address);
|
|
13773
13730
|
const hasServerVault = useSession((st) => st.hasServerVault);
|
|
13774
|
-
const
|
|
13775
|
-
const
|
|
13731
|
+
const usePasskey = useRestoreStore((st) => st.usePasskey);
|
|
13732
|
+
const restorePassword = useRestoreStore((st) => st.restorePassword);
|
|
13733
|
+
const selectedCloudProvider = useRestoreStore((st) => st.selectedCloudProvider);
|
|
13776
13734
|
useEffect20(() => {
|
|
13777
13735
|
if (!hasServerVault) {
|
|
13778
|
-
setMethod("server");
|
|
13779
|
-
setIsDialogForced(true);
|
|
13736
|
+
useRestoreStore.getState().setMethod("server");
|
|
13737
|
+
useLayoutStore.getState().setIsDialogForced(true);
|
|
13780
13738
|
}
|
|
13781
|
-
}, [hasServerVault
|
|
13739
|
+
}, [hasServerVault]);
|
|
13782
13740
|
const recoveryUserId = useSession((st) => st.recoveryUserId);
|
|
13783
13741
|
const passportUserId = session?.mpcUserId || recoveryUserId || "";
|
|
13784
|
-
const onBackupSuccess = () =>
|
|
13742
|
+
const onBackupSuccess = useCallback17(() => {
|
|
13743
|
+
console.log("[EMBARKAI BACKUP] Backup created successfully");
|
|
13744
|
+
}, [hasServerVault]);
|
|
13785
13745
|
const { mutate: createPasswordBackup, isPending: isPasswordBackupCreating } = useMutation9({
|
|
13786
13746
|
mutationFn: async () => {
|
|
13787
13747
|
const iframeManager = getIframeManager();
|
|
13788
13748
|
if (!iframeManager) {
|
|
13789
13749
|
throw new Error("Iframe manager not initialized");
|
|
13790
13750
|
}
|
|
13791
|
-
const jwt =
|
|
13751
|
+
const jwt = jwtTokenManager2.getTokens();
|
|
13792
13752
|
if (!usePasskey && !restorePassword) {
|
|
13793
13753
|
throw new Error("Please provide a password for the backup");
|
|
13794
13754
|
}
|
|
13795
13755
|
const password = !usePasskey ? restorePassword : void 0;
|
|
13796
|
-
|
|
13797
|
-
console.log("[BACKUP STATUS] is new user:", jwt.isNewUser, !hasServerVault, "usePasskey:", usePasskey);
|
|
13756
|
+
console.log("[BACKUP STATUS] is new user:", jwt.isNewUser);
|
|
13798
13757
|
return {
|
|
13799
13758
|
response: await iframeManager.createBackup(passportUserId, { method: "server", password }, jwt.accessToken),
|
|
13800
|
-
|
|
13759
|
+
isNewUser: jwt.isNewUser
|
|
13801
13760
|
};
|
|
13802
13761
|
},
|
|
13803
|
-
onSuccess: async ({ response,
|
|
13762
|
+
onSuccess: async ({ response, isNewUser }) => {
|
|
13763
|
+
const { setError, setSuccess } = useRestoreStore.getState();
|
|
13804
13764
|
qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
|
|
13805
13765
|
if (response.success) {
|
|
13806
13766
|
setError("");
|
|
@@ -13808,7 +13768,11 @@ function useCreateBackup() {
|
|
|
13808
13768
|
if (typeof window !== "undefined") {
|
|
13809
13769
|
window.dispatchEvent(
|
|
13810
13770
|
new CustomEvent("lumia-passport-backup-status-changed", {
|
|
13811
|
-
detail: {
|
|
13771
|
+
detail: {
|
|
13772
|
+
method: "server",
|
|
13773
|
+
success: true,
|
|
13774
|
+
navigateToNicknameMenu: !!isNewUser
|
|
13775
|
+
}
|
|
13812
13776
|
})
|
|
13813
13777
|
);
|
|
13814
13778
|
}
|
|
@@ -13816,9 +13780,10 @@ function useCreateBackup() {
|
|
|
13816
13780
|
} else {
|
|
13817
13781
|
setError(response.error || "Server backup failed");
|
|
13818
13782
|
}
|
|
13819
|
-
setIsDialogForced(false);
|
|
13783
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
13820
13784
|
},
|
|
13821
13785
|
onError: async (error) => {
|
|
13786
|
+
const { setError, setSuccess } = useRestoreStore.getState();
|
|
13822
13787
|
setSuccess("");
|
|
13823
13788
|
if (error?.name === "NotAllowedError" || error?.message?.includes("timed out or was not allowed")) {
|
|
13824
13789
|
setError("Passkey selection was cancelled. Please try again or create a new passkey.");
|
|
@@ -13847,7 +13812,7 @@ function useCreateBackup() {
|
|
|
13847
13812
|
},
|
|
13848
13813
|
onSuccess: async () => {
|
|
13849
13814
|
qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
|
|
13850
|
-
setSuccess("Backup file downloaded successfully");
|
|
13815
|
+
useRestoreStore.getState().setSuccess("Backup file downloaded successfully");
|
|
13851
13816
|
if (typeof window !== "undefined") {
|
|
13852
13817
|
window.dispatchEvent(
|
|
13853
13818
|
new CustomEvent("lumia-passport-backup-status-changed", {
|
|
@@ -13858,13 +13823,13 @@ function useCreateBackup() {
|
|
|
13858
13823
|
onBackupSuccess();
|
|
13859
13824
|
},
|
|
13860
13825
|
onError: async (error) => {
|
|
13861
|
-
setError(error?.message || "Backup creation failed");
|
|
13826
|
+
useRestoreStore.getState().setError(error?.message || "Backup creation failed");
|
|
13862
13827
|
qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
|
|
13863
13828
|
}
|
|
13864
13829
|
});
|
|
13865
13830
|
const { mutate: createPasskey, isPending: isPasskeyCreating } = useMutation9({
|
|
13866
13831
|
mutationFn: async () => {
|
|
13867
|
-
setIsCreatingPasskey(true);
|
|
13832
|
+
useRestoreStore.getState().setIsCreatingPasskey(true);
|
|
13868
13833
|
const { linkPasskeyWithWebAuthn: linkPasskeyWithWebAuthn2 } = await Promise.resolve().then(() => (init_passkey2(), passkey_exports2));
|
|
13869
13834
|
const { createPasskeyHelpers: createPasskeyHelpers2 } = await Promise.resolve().then(() => (init_passkey(), passkey_exports));
|
|
13870
13835
|
const { credentialId, rawId } = await linkPasskeyWithWebAuthn2();
|
|
@@ -13874,11 +13839,13 @@ function useCreateBackup() {
|
|
|
13874
13839
|
return { credentialId, rawId };
|
|
13875
13840
|
},
|
|
13876
13841
|
onSuccess: async () => {
|
|
13842
|
+
const { setError, setSuccess, setIsCreatingPasskey } = useRestoreStore.getState();
|
|
13877
13843
|
setIsCreatingPasskey(false);
|
|
13878
13844
|
setError(null);
|
|
13879
13845
|
setSuccess("Passkey created successfully. You can now create a backup.");
|
|
13880
13846
|
},
|
|
13881
13847
|
onError: async (error) => {
|
|
13848
|
+
const { setError, setIsCreatingPasskey } = useRestoreStore.getState();
|
|
13882
13849
|
setIsCreatingPasskey(false);
|
|
13883
13850
|
if (error.name === "NotAllowedError") {
|
|
13884
13851
|
setError("Passkey creation cancelled. Please try again.");
|
|
@@ -13911,7 +13878,7 @@ function useCreateBackup() {
|
|
|
13911
13878
|
},
|
|
13912
13879
|
onSuccess: async ({ provider, uploadResult }) => {
|
|
13913
13880
|
console.log("[KeyshareBackup] Cloud backup upload result:", uploadResult);
|
|
13914
|
-
setSuccess(`Successfully created cloud backup on ${provider.name}`);
|
|
13881
|
+
useRestoreStore.getState().setSuccess(`Successfully created cloud backup on ${provider.name}`);
|
|
13915
13882
|
qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
|
|
13916
13883
|
if (typeof window !== "undefined") {
|
|
13917
13884
|
window.dispatchEvent(
|
|
@@ -13923,7 +13890,7 @@ function useCreateBackup() {
|
|
|
13923
13890
|
onBackupSuccess();
|
|
13924
13891
|
},
|
|
13925
13892
|
onError: async (error) => {
|
|
13926
|
-
setError(error?.message || "Backup creation failed");
|
|
13893
|
+
useRestoreStore.getState().setError(error?.message || "Backup creation failed");
|
|
13927
13894
|
qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
|
|
13928
13895
|
}
|
|
13929
13896
|
});
|
|
@@ -13941,6 +13908,7 @@ function useCreateBackup() {
|
|
|
13941
13908
|
var init_useCreateBackup = __esm({
|
|
13942
13909
|
"src/internal/components/KeyshareRestoreMenu/hooks/useCreateBackup.ts"() {
|
|
13943
13910
|
init_SessionContext();
|
|
13911
|
+
init_auth();
|
|
13944
13912
|
init_useLayoutStore();
|
|
13945
13913
|
init_iframe_manager();
|
|
13946
13914
|
init_constants4();
|
|
@@ -15041,23 +15009,14 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
15041
15009
|
const qc = useQueryClient11();
|
|
15042
15010
|
const { callbacksRef } = useProviderConfig();
|
|
15043
15011
|
const { t } = useT();
|
|
15044
|
-
const
|
|
15012
|
+
const address = useSession((st) => st.address);
|
|
15045
15013
|
const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
|
|
15046
|
-
const
|
|
15047
|
-
const
|
|
15048
|
-
const
|
|
15049
|
-
method: currentRestoreMethod,
|
|
15050
|
-
error,
|
|
15051
|
-
success,
|
|
15052
|
-
setError,
|
|
15053
|
-
setShowPassword,
|
|
15054
|
-
setUsePasskey,
|
|
15055
|
-
setRestoreFile,
|
|
15056
|
-
setRestorePassword,
|
|
15057
|
-
setSuccess,
|
|
15058
|
-
setMethod
|
|
15059
|
-
} = useRestoreStore();
|
|
15014
|
+
const error = useRestoreStore((st) => st.error);
|
|
15015
|
+
const success = useRestoreStore((st) => st.success);
|
|
15016
|
+
const currentRestoreMethod = useRestoreStore((st) => st.method);
|
|
15060
15017
|
useEffect25(() => {
|
|
15018
|
+
const { setIsDialogForced } = useLayoutStore.getState();
|
|
15019
|
+
const { setRestorePassword, setRestoreFile, setShowPassword, setUsePasskey, setMethod } = useRestoreStore.getState();
|
|
15061
15020
|
setIsDialogForced(true);
|
|
15062
15021
|
return () => {
|
|
15063
15022
|
setRestorePassword("");
|
|
@@ -15084,14 +15043,17 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
15084
15043
|
});
|
|
15085
15044
|
const hasServerBackup = serverRecoveryStatus?.created || serverRecoveryStatus?.devices?.length > 0;
|
|
15086
15045
|
useEffect25(() => {
|
|
15087
|
-
if (!!hasServerBackup) setMethod("server");
|
|
15046
|
+
if (!!hasServerBackup) useRestoreStore.getState().setMethod("server");
|
|
15088
15047
|
}, [hasServerBackup]);
|
|
15089
15048
|
const { mutate: disconnect, isPending: isDisconnecting } = useMutation11({
|
|
15090
15049
|
mutationFn: async () => {
|
|
15050
|
+
const { setStatus, setIsLoading } = useSession.getState();
|
|
15051
|
+
const { setError, setMethod } = useRestoreStore.getState();
|
|
15091
15052
|
setError(null);
|
|
15092
15053
|
setMethod(null);
|
|
15093
15054
|
setStatus("disconnecting");
|
|
15094
15055
|
setIsLoading(true);
|
|
15056
|
+
useLayoutStore.getState().setIsDialogForced(true);
|
|
15095
15057
|
const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
15096
15058
|
const userId = jwtTokenManager4.getUserId() || null;
|
|
15097
15059
|
const { logout: logout2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
@@ -15100,20 +15062,22 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
15100
15062
|
},
|
|
15101
15063
|
onSuccess: async ({ disconnectedUserId }) => {
|
|
15102
15064
|
await qc.resetQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY] });
|
|
15065
|
+
const { setStatus, setIsLoading, setSession, setAddress } = useSession.getState();
|
|
15103
15066
|
setSession(null);
|
|
15104
15067
|
setAddress(null);
|
|
15105
|
-
setError(null);
|
|
15106
15068
|
setStatus("idle");
|
|
15107
15069
|
setIsLoading(false);
|
|
15108
|
-
|
|
15070
|
+
useRestoreStore.getState().setError(null);
|
|
15071
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
15109
15072
|
callbacksRef.current?.onDisconnect?.({ address: "0x", userId: disconnectedUserId });
|
|
15110
|
-
setTimeout(() => setPage("auth" /* AUTH */), 50);
|
|
15073
|
+
setTimeout(() => useLayoutDataStore.getState().setPage("auth" /* AUTH */), 50);
|
|
15111
15074
|
},
|
|
15112
15075
|
onError: (err) => {
|
|
15113
|
-
|
|
15076
|
+
const { setStatus, setIsLoading } = useSession.getState();
|
|
15114
15077
|
setStatus("idle");
|
|
15115
15078
|
setIsLoading(false);
|
|
15116
|
-
|
|
15079
|
+
useRestoreStore.getState().setError(err.message || "An unknown error occurred during sign out");
|
|
15080
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
15117
15081
|
}
|
|
15118
15082
|
});
|
|
15119
15083
|
const RestoreComponent = currentRestoreMethod ? RESTORE_COMPONENTS[currentRestoreMethod] : null;
|
|
@@ -15147,6 +15111,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
15147
15111
|
labels: { checked: t("passport:common.standard"), unchecked: t("passport:common.advanced") },
|
|
15148
15112
|
checked: currentRestoreMethod !== "server",
|
|
15149
15113
|
onChange: () => {
|
|
15114
|
+
const { setError, setRestorePassword, setRestoreFile, setMethod } = useRestoreStore.getState();
|
|
15150
15115
|
if (!!error) setError(null);
|
|
15151
15116
|
if (currentRestoreMethod === "server") {
|
|
15152
15117
|
setRestorePassword("");
|
|
@@ -15176,6 +15141,15 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
15176
15141
|
size: "large",
|
|
15177
15142
|
variant: "ghost",
|
|
15178
15143
|
onClick: () => {
|
|
15144
|
+
const {
|
|
15145
|
+
setError,
|
|
15146
|
+
setShowPassword,
|
|
15147
|
+
setUsePasskey,
|
|
15148
|
+
setRestoreFile,
|
|
15149
|
+
setRestorePassword,
|
|
15150
|
+
setSuccess,
|
|
15151
|
+
setMethod
|
|
15152
|
+
} = useRestoreStore.getState();
|
|
15179
15153
|
setError(null);
|
|
15180
15154
|
setShowPassword(false);
|
|
15181
15155
|
setUsePasskey(false);
|
|
@@ -15222,20 +15196,11 @@ function KeyshareBackupMenu() {
|
|
|
15222
15196
|
const { t } = useT();
|
|
15223
15197
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
15224
15198
|
const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
|
|
15225
|
-
const
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
success,
|
|
15229
|
-
setSelectedCloudProvider,
|
|
15230
|
-
setSuccess,
|
|
15231
|
-
setError,
|
|
15232
|
-
setRestorePassword,
|
|
15233
|
-
setRestoreFile,
|
|
15234
|
-
setShowPassword,
|
|
15235
|
-
setUsePasskey,
|
|
15236
|
-
setMethod
|
|
15237
|
-
} = useRestoreStore();
|
|
15199
|
+
const currentBackupMethod = useRestoreStore((st) => st.method);
|
|
15200
|
+
const error = useRestoreStore((st) => st.error);
|
|
15201
|
+
const success = useRestoreStore((st) => st.success);
|
|
15238
15202
|
useEffect26(() => {
|
|
15203
|
+
const { setSuccess, setError, setRestorePassword, setRestoreFile, setShowPassword, setUsePasskey, setMethod } = useRestoreStore.getState();
|
|
15239
15204
|
return () => {
|
|
15240
15205
|
setSuccess(null);
|
|
15241
15206
|
setError(null);
|
|
@@ -15249,13 +15214,12 @@ function KeyshareBackupMenu() {
|
|
|
15249
15214
|
const { data: serverRecoveryStatus, isLoading: isRecoveryLoading } = useQuery8({
|
|
15250
15215
|
retry: false,
|
|
15251
15216
|
enabled: !!address,
|
|
15252
|
-
// Prevent query from running with undefined address
|
|
15253
15217
|
queryKey: [CHECK_BACKUP_QUERY_KEY, address],
|
|
15254
15218
|
queryFn: async () => await getShareRecoveryStats()
|
|
15255
15219
|
});
|
|
15256
15220
|
const hasRecoveryData = serverRecoveryStatus?.created || serverRecoveryStatus?.devices?.length > 0;
|
|
15257
15221
|
useEffect26(() => {
|
|
15258
|
-
if (!!hasRecoveryData) setMethod("server");
|
|
15222
|
+
if (!!hasRecoveryData) useRestoreStore.getState().setMethod("server");
|
|
15259
15223
|
}, [hasRecoveryData]);
|
|
15260
15224
|
const {
|
|
15261
15225
|
isPasswordBackupCreating,
|
|
@@ -15288,6 +15252,16 @@ function KeyshareBackupMenu() {
|
|
|
15288
15252
|
size: "icon",
|
|
15289
15253
|
title: "Back",
|
|
15290
15254
|
onClick: () => {
|
|
15255
|
+
const {
|
|
15256
|
+
setSuccess,
|
|
15257
|
+
setError,
|
|
15258
|
+
setRestorePassword,
|
|
15259
|
+
setRestoreFile,
|
|
15260
|
+
setShowPassword,
|
|
15261
|
+
setUsePasskey,
|
|
15262
|
+
setMethod,
|
|
15263
|
+
setSelectedCloudProvider
|
|
15264
|
+
} = useRestoreStore.getState();
|
|
15291
15265
|
setRestorePassword("");
|
|
15292
15266
|
setRestoreFile(null);
|
|
15293
15267
|
setShowPassword(false);
|
|
@@ -15310,6 +15284,7 @@ function KeyshareBackupMenu() {
|
|
|
15310
15284
|
labels: { checked: t("passport:common.standard"), unchecked: t("passport:common.advanced") },
|
|
15311
15285
|
checked: currentBackupMethod !== "server",
|
|
15312
15286
|
onChange: () => {
|
|
15287
|
+
const { setError, setRestorePassword, setRestoreFile, setMethod } = useRestoreStore.getState();
|
|
15313
15288
|
if (!!error) setError(null);
|
|
15314
15289
|
if (currentBackupMethod === "server") {
|
|
15315
15290
|
setRestorePassword("");
|
|
@@ -15342,21 +15317,12 @@ function KeyshareBackupMenu() {
|
|
|
15342
15317
|
/* @__PURE__ */ jsx63(AlertCircle3, { className: "h-4 w-4 flex-shrink-0" }),
|
|
15343
15318
|
/* @__PURE__ */ jsx63("span", { className: "block w-full flex-1", children: error })
|
|
15344
15319
|
] }),
|
|
15345
|
-
success && /* @__PURE__ */ jsxs58(
|
|
15346
|
-
/* @__PURE__ */ jsxs58(
|
|
15320
|
+
success && /* @__PURE__ */ jsxs58(Highlight, { type: "success", className: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
|
|
15321
|
+
/* @__PURE__ */ jsxs58("div", { className: "w-full flex gap-[var(--ui-kit-gap)]", children: [
|
|
15347
15322
|
/* @__PURE__ */ jsx63(CheckCircle22, { className: "h-4 w-4 flex-shrink-0" }),
|
|
15348
15323
|
/* @__PURE__ */ jsx63("span", { className: "block w-full flex-1", children: success })
|
|
15349
15324
|
] }),
|
|
15350
|
-
/* @__PURE__ */ jsx63(
|
|
15351
|
-
Button,
|
|
15352
|
-
{
|
|
15353
|
-
variant: "default",
|
|
15354
|
-
size: "large",
|
|
15355
|
-
className: "w-full",
|
|
15356
|
-
onClick: () => setPage("settings" /* SETTINGS */),
|
|
15357
|
-
children: "Done"
|
|
15358
|
-
}
|
|
15359
|
-
)
|
|
15325
|
+
/* @__PURE__ */ jsx63(Button, { variant: "default", size: "large", className: "w-full", onClick: () => setPage("settings" /* SETTINGS */), children: t("passport:common.continue") })
|
|
15360
15326
|
] })
|
|
15361
15327
|
] })
|
|
15362
15328
|
}
|
|
@@ -15396,7 +15362,7 @@ var init_KeyshareRestoreMenu2 = __esm({
|
|
|
15396
15362
|
});
|
|
15397
15363
|
|
|
15398
15364
|
// src/hooks/useColorMode.ts
|
|
15399
|
-
import { useCallback as
|
|
15365
|
+
import { useCallback as useCallback18, useEffect as useEffect27 } from "react";
|
|
15400
15366
|
function useColorMode() {
|
|
15401
15367
|
const {
|
|
15402
15368
|
config: { current: config }
|
|
@@ -15404,7 +15370,7 @@ function useColorMode() {
|
|
|
15404
15370
|
const preferedColorMode = config?.preferedColorMode;
|
|
15405
15371
|
const colorMode = useLayoutStore((st) => st.colorMode);
|
|
15406
15372
|
const handleStoreColorMode = useLayoutStore((st) => st.setColorMode);
|
|
15407
|
-
const setColorMode =
|
|
15373
|
+
const setColorMode = useCallback18(
|
|
15408
15374
|
(mode) => {
|
|
15409
15375
|
localStorage.setItem(LOCAL_COLOR_MODE_KEY, mode);
|
|
15410
15376
|
handleStoreColorMode(mode);
|
|
@@ -15900,7 +15866,7 @@ var init_MainMenu2 = __esm({
|
|
|
15900
15866
|
|
|
15901
15867
|
// src/modules/linkedProfiles.ts
|
|
15902
15868
|
import { useQuery as useQuery11, useQueryClient as useQueryClient12 } from "@tanstack/react-query";
|
|
15903
|
-
import { useCallback as
|
|
15869
|
+
import { useCallback as useCallback19 } from "react";
|
|
15904
15870
|
function useLinkedProfiles() {
|
|
15905
15871
|
const qc = useQueryClient12();
|
|
15906
15872
|
const address = useSession((st) => st.address);
|
|
@@ -15924,7 +15890,7 @@ function useLinkedProfiles() {
|
|
|
15924
15890
|
}
|
|
15925
15891
|
});
|
|
15926
15892
|
const { profiles = [], avatar = null } = data || {};
|
|
15927
|
-
const refresh =
|
|
15893
|
+
const refresh = useCallback19(async () => {
|
|
15928
15894
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
|
|
15929
15895
|
}, [qc, address]);
|
|
15930
15896
|
return { profiles, avatar, isLoading, isFetching, error, refresh };
|
|
@@ -16561,7 +16527,7 @@ var init_telegram2 = __esm({
|
|
|
16561
16527
|
|
|
16562
16528
|
// src/internal/components/ManageWalletMenu/hooks/useLinkTelegram.ts
|
|
16563
16529
|
import { useQueryClient as useQueryClient16 } from "@tanstack/react-query";
|
|
16564
|
-
import { useCallback as
|
|
16530
|
+
import { useCallback as useCallback20, useEffect as useEffect31, useState as useState17 } from "react";
|
|
16565
16531
|
function useLinkTelegram() {
|
|
16566
16532
|
const {
|
|
16567
16533
|
config: { current: config },
|
|
@@ -16572,7 +16538,7 @@ function useLinkTelegram() {
|
|
|
16572
16538
|
const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
|
|
16573
16539
|
const { providerType, linkIsLoading, setLinkIsLoading, setProviderType, setAlert } = useManageWalletStore();
|
|
16574
16540
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
16575
|
-
const handleLinkTelegram =
|
|
16541
|
+
const handleLinkTelegram = useCallback20(async () => {
|
|
16576
16542
|
try {
|
|
16577
16543
|
if (shouldBlockSocialAuthInTelegram("telegram")) {
|
|
16578
16544
|
setAlert(buildTelegramBrowserRestriction("Telegram", "linking"));
|
|
@@ -17212,7 +17178,7 @@ var init_nickname_validation = __esm({
|
|
|
17212
17178
|
// src/internal/components/NicknameMenu/NicknameEditForm.tsx
|
|
17213
17179
|
import { useMutation as useMutation16, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
|
|
17214
17180
|
import { AtSign, Check as Check2, ChevronRight as ChevronRight5, Copy as Copy2, Loader as Loader17 } from "lucide-react";
|
|
17215
|
-
import { useCallback as
|
|
17181
|
+
import { useCallback as useCallback21, useState as useState19 } from "react";
|
|
17216
17182
|
import { Fragment as Fragment29, jsx as jsx76, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
17217
17183
|
function NicknameEditForm(props) {
|
|
17218
17184
|
const {
|
|
@@ -17263,7 +17229,7 @@ function NicknameEditForm(props) {
|
|
|
17263
17229
|
);
|
|
17264
17230
|
}
|
|
17265
17231
|
});
|
|
17266
|
-
const handleInputChange =
|
|
17232
|
+
const handleInputChange = useCallback21(
|
|
17267
17233
|
(e) => {
|
|
17268
17234
|
const value = e.target.value;
|
|
17269
17235
|
setInputValue(value);
|
|
@@ -17277,7 +17243,7 @@ function NicknameEditForm(props) {
|
|
|
17277
17243
|
},
|
|
17278
17244
|
[clientError, isNicknameChangeError, isNicknameChangeSuccess, reset, t]
|
|
17279
17245
|
);
|
|
17280
|
-
const handleSubmit =
|
|
17246
|
+
const handleSubmit = useCallback21(
|
|
17281
17247
|
(e) => {
|
|
17282
17248
|
if (!canChange) return;
|
|
17283
17249
|
e.preventDefault();
|
|
@@ -17679,7 +17645,7 @@ var init_useWatchTokens = __esm({
|
|
|
17679
17645
|
// src/internal/hooks/useBlockscoutAssets.ts
|
|
17680
17646
|
import { createBlockscoutClient } from "@embarkai/core/clients";
|
|
17681
17647
|
import { useQuery as useQuery15 } from "@tanstack/react-query";
|
|
17682
|
-
import { useCallback as
|
|
17648
|
+
import { useCallback as useCallback22, useMemo as useMemo9, useRef as useRef16 } from "react";
|
|
17683
17649
|
import { formatEther, formatUnits as formatUnits3 } from "viem";
|
|
17684
17650
|
function resolveIpfsUri(uri) {
|
|
17685
17651
|
if (!uri) return "";
|
|
@@ -17986,7 +17952,7 @@ function useBlockscoutAssets(options) {
|
|
|
17986
17952
|
if (!tokensError) return null;
|
|
17987
17953
|
return createError(tokensError);
|
|
17988
17954
|
}, [tokensError]);
|
|
17989
|
-
const refreshBalances =
|
|
17955
|
+
const refreshBalances = useCallback22(async () => {
|
|
17990
17956
|
const now = Date.now();
|
|
17991
17957
|
if (now - lastRefreshRef.current < BLOCKSCOUT_REFRESH_DEBOUNCE) {
|
|
17992
17958
|
return;
|
|
@@ -17994,7 +17960,7 @@ function useBlockscoutAssets(options) {
|
|
|
17994
17960
|
lastRefreshRef.current = now;
|
|
17995
17961
|
await Promise.all([refetchNative(), refetchTokens(), refetchNfts(), refetchWatchTokens()]);
|
|
17996
17962
|
}, [refetchNative, refetchTokens, refetchNfts, refetchWatchTokens]);
|
|
17997
|
-
const getTokenBalance =
|
|
17963
|
+
const getTokenBalance = useCallback22(
|
|
17998
17964
|
(tokenAddress) => {
|
|
17999
17965
|
return assets.find((a) => a.address?.toLowerCase() === tokenAddress.toLowerCase()) || null;
|
|
18000
17966
|
},
|
|
@@ -18270,7 +18236,7 @@ var init_PortfolioItem = __esm({
|
|
|
18270
18236
|
// src/internal/components/PortfolioMenu/PortfolioMenu.tsx
|
|
18271
18237
|
import { useQueryClient as useQueryClient20 } from "@tanstack/react-query";
|
|
18272
18238
|
import { AlertCircle as AlertCircle4, ArrowLeft as ArrowLeft16, Gem, Loader as Loader20, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
18273
|
-
import { useCallback as
|
|
18239
|
+
import { useCallback as useCallback23 } from "react";
|
|
18274
18240
|
import { jsx as jsx80, jsxs as jsxs75 } from "react/jsx-runtime";
|
|
18275
18241
|
function PortfolioMenu() {
|
|
18276
18242
|
const { assets: projectAssets = [] } = useProviderConfig().config.current?.projectAssets || {};
|
|
@@ -18290,7 +18256,7 @@ function PortfolioMenu() {
|
|
|
18290
18256
|
enabled: !!address
|
|
18291
18257
|
});
|
|
18292
18258
|
const shownProjectAssests = projectAssets.filter((asset) => !asset.hideInPortfolio);
|
|
18293
|
-
const refreshAllAssetsBalances =
|
|
18259
|
+
const refreshAllAssetsBalances = useCallback23(() => {
|
|
18294
18260
|
Promise.all(shownProjectAssests.map((asset) => qc.invalidateQueries({ queryKey: asset.balanceQueryKey })));
|
|
18295
18261
|
refreshBlockscoutBalances();
|
|
18296
18262
|
}, [qc, shownProjectAssests, refreshBlockscoutBalances]);
|
|
@@ -18445,7 +18411,7 @@ var init_nickname_fingerprint = __esm({
|
|
|
18445
18411
|
// src/internal/components/ReceiveMenu/ReceiveMenu.tsx
|
|
18446
18412
|
import { ArrowLeft as ArrowLeft17, CheckCircle2 as CheckCircle23, Copy as Copy3, Info as Info5, Loader as Loader21, Shield } from "lucide-react";
|
|
18447
18413
|
import QRCode from "qrcode";
|
|
18448
|
-
import { useCallback as
|
|
18414
|
+
import { useCallback as useCallback24, useEffect as useEffect33, useMemo as useMemo10, useState as useState23 } from "react";
|
|
18449
18415
|
import { Fragment as Fragment31, jsx as jsx81, jsxs as jsxs76 } from "react/jsx-runtime";
|
|
18450
18416
|
function ReceiveMenu() {
|
|
18451
18417
|
const session = useSession((st) => st.session);
|
|
@@ -18480,7 +18446,7 @@ function ReceiveMenu() {
|
|
|
18480
18446
|
});
|
|
18481
18447
|
}
|
|
18482
18448
|
}, [open, address]);
|
|
18483
|
-
const handleCopy =
|
|
18449
|
+
const handleCopy = useCallback24(async () => {
|
|
18484
18450
|
if (!address) return;
|
|
18485
18451
|
try {
|
|
18486
18452
|
await navigator.clipboard.writeText(address);
|
|
@@ -18490,7 +18456,7 @@ function ReceiveMenu() {
|
|
|
18490
18456
|
console.error("Failed to copy address:", error);
|
|
18491
18457
|
}
|
|
18492
18458
|
}, [address]);
|
|
18493
|
-
const handleCopyFingerprint =
|
|
18459
|
+
const handleCopyFingerprint = useCallback24(async () => {
|
|
18494
18460
|
if (!fingerprint) return;
|
|
18495
18461
|
try {
|
|
18496
18462
|
await navigator.clipboard.writeText(fingerprint);
|
|
@@ -19979,7 +19945,7 @@ function isOririnChainEmbarkSupported(originChain) {
|
|
|
19979
19945
|
}
|
|
19980
19946
|
var init_utils8 = __esm({
|
|
19981
19947
|
"src/internal/components/SendMenu/hyperbridge/utils.ts"() {
|
|
19982
|
-
|
|
19948
|
+
init_networks4();
|
|
19983
19949
|
init_chains();
|
|
19984
19950
|
}
|
|
19985
19951
|
});
|
|
@@ -19987,7 +19953,7 @@ var init_utils8 = __esm({
|
|
|
19987
19953
|
// src/internal/components/SendMenu/hyperbridge/hooks/useHyperlaneHistory.ts
|
|
19988
19954
|
import { useInfiniteQuery as useInfiniteQuery3 } from "@tanstack/react-query";
|
|
19989
19955
|
import { debounce as debounce6 } from "lodash-es";
|
|
19990
|
-
import { useCallback as
|
|
19956
|
+
import { useCallback as useCallback25, useEffect as useEffect36, useMemo as useMemo11 } from "react";
|
|
19991
19957
|
function useHyperlaneHistory() {
|
|
19992
19958
|
const address = useSession((st) => st.address);
|
|
19993
19959
|
const page = useLayoutDataStore((st) => st.page);
|
|
@@ -20007,7 +19973,7 @@ function useHyperlaneHistory() {
|
|
|
20007
19973
|
() => txHistoryData?.pages?.map((p) => p.data).flat(Infinity) || [],
|
|
20008
19974
|
[txHistoryData]
|
|
20009
19975
|
);
|
|
20010
|
-
const updateExpandable =
|
|
19976
|
+
const updateExpandable = useCallback25(
|
|
20011
19977
|
debounce6(() => {
|
|
20012
19978
|
useFlowSelectorStore.getState().setRenderKey(`hyperlane-history-loaded-${Date.now()}`);
|
|
20013
19979
|
}, 250),
|
|
@@ -20049,7 +20015,7 @@ var init_useOperationHashesStore = __esm({
|
|
|
20049
20015
|
|
|
20050
20016
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts
|
|
20051
20017
|
import { useMutation as useMutation19, useQueryClient as useQueryClient22 } from "@tanstack/react-query";
|
|
20052
|
-
import { useCallback as
|
|
20018
|
+
import { useCallback as useCallback26 } from "react";
|
|
20053
20019
|
import { useSwitchChain, useWalletClient } from "wagmi";
|
|
20054
20020
|
function useBridge() {
|
|
20055
20021
|
const qc = useQueryClient22();
|
|
@@ -20057,7 +20023,7 @@ function useBridge() {
|
|
|
20057
20023
|
const address = useSession((st) => st.address);
|
|
20058
20024
|
const { data: walletClient } = useWalletClient();
|
|
20059
20025
|
const { switchChainAsync } = useSwitchChain();
|
|
20060
|
-
const swapDirection =
|
|
20026
|
+
const swapDirection = useCallback26(() => {
|
|
20061
20027
|
const {
|
|
20062
20028
|
bridgeStep,
|
|
20063
20029
|
originChain,
|
|
@@ -20109,7 +20075,7 @@ function useBridge() {
|
|
|
20109
20075
|
useFlowSelectorStore.getState().setError(error instanceof Error ? error.message : String(error));
|
|
20110
20076
|
}
|
|
20111
20077
|
});
|
|
20112
|
-
const handleQuoteEstimation =
|
|
20078
|
+
const handleQuoteEstimation = useCallback26((amnt) => {
|
|
20113
20079
|
const { originChain, destinationChain, bridgeSender } = useBridgeStore.getState();
|
|
20114
20080
|
if (!amnt || !Number(amnt)) {
|
|
20115
20081
|
useBridgeStore.getState().setQuote(null);
|
|
@@ -20369,7 +20335,7 @@ var init_ResolveChainIcon = __esm({
|
|
|
20369
20335
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridgeBalance.ts
|
|
20370
20336
|
import { CHAINS_BROWSERS_TRANSPORTS as CHAINS_BROWSERS_TRANSPORTS2 } from "@embarkai/core";
|
|
20371
20337
|
import { useQuery as useQuery20, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
|
|
20372
|
-
import { useCallback as
|
|
20338
|
+
import { useCallback as useCallback27, useEffect as useEffect39 } from "react";
|
|
20373
20339
|
import { createPublicClient as createPublicClient2, erc20Abi as erc20Abi2, formatUnits as formatUnits7, http as http3 } from "viem";
|
|
20374
20340
|
import { useSwitchChain as useSwitchChain2 } from "wagmi";
|
|
20375
20341
|
function useBridgeBalance(hyperlaneWarpRoutes) {
|
|
@@ -20458,7 +20424,7 @@ function useBridgeBalance(hyperlaneWarpRoutes) {
|
|
|
20458
20424
|
};
|
|
20459
20425
|
}
|
|
20460
20426
|
});
|
|
20461
|
-
const refreshRouteTokenBalance =
|
|
20427
|
+
const refreshRouteTokenBalance = useCallback27(
|
|
20462
20428
|
(senderWallet) => {
|
|
20463
20429
|
switch (true) {
|
|
20464
20430
|
case senderWallet === "embarkai-wallet":
|
|
@@ -21667,7 +21633,7 @@ var init_useNicknameResolve = __esm({
|
|
|
21667
21633
|
});
|
|
21668
21634
|
|
|
21669
21635
|
// src/hooks/useSendTransaction.ts
|
|
21670
|
-
import { useCallback as
|
|
21636
|
+
import { useCallback as useCallback28, useState as useState29 } from "react";
|
|
21671
21637
|
import { encodeFunctionData as encodeFunctionData2, isAddress, parseEther as parseEther2, parseUnits } from "viem";
|
|
21672
21638
|
function useSendTransaction() {
|
|
21673
21639
|
const session = useSession((st) => st.session);
|
|
@@ -21675,7 +21641,7 @@ function useSendTransaction() {
|
|
|
21675
21641
|
const [isLoading, setIsLoading] = useState29(false);
|
|
21676
21642
|
const [error, setError] = useState29(null);
|
|
21677
21643
|
const [userOpHash, setUserOpHash] = useState29(null);
|
|
21678
|
-
const sendTransaction =
|
|
21644
|
+
const sendTransaction = useCallback28(
|
|
21679
21645
|
async (params) => {
|
|
21680
21646
|
if (!session || !address) {
|
|
21681
21647
|
setError("No active session");
|
|
@@ -21772,7 +21738,7 @@ function useSendTransaction() {
|
|
|
21772
21738
|
},
|
|
21773
21739
|
[session, address]
|
|
21774
21740
|
);
|
|
21775
|
-
const reset =
|
|
21741
|
+
const reset = useCallback28(() => {
|
|
21776
21742
|
setError(null);
|
|
21777
21743
|
setUserOpHash(null);
|
|
21778
21744
|
setIsLoading(false);
|
|
@@ -23159,7 +23125,7 @@ import {
|
|
|
23159
23125
|
BSC_TESTNET_CHAIN_ID as BSC_TESTNET_CHAIN_ID4,
|
|
23160
23126
|
LUMIA_MAINNET_CHAIN_ID as LUMIA_MAINNET_CHAIN_ID4,
|
|
23161
23127
|
LUMIA_TESTNET_CHAIN_ID as LUMIA_TESTNET_CHAIN_ID4,
|
|
23162
|
-
SEPOLIA_CHAIN_ID
|
|
23128
|
+
SEPOLIA_CHAIN_ID
|
|
23163
23129
|
} from "@embarkai/core/read";
|
|
23164
23130
|
function isTransactionHistorySupported(chainId) {
|
|
23165
23131
|
return !UNSUPPORTED_HISTORY_CHAINS.has(chainId);
|
|
@@ -23229,7 +23195,7 @@ var init_txUrls = __esm({
|
|
|
23229
23195
|
};
|
|
23230
23196
|
CHAIN_SPECIFIC_API_URLS = {};
|
|
23231
23197
|
ETHERSCAN_CHAINS = /* @__PURE__ */ new Set([
|
|
23232
|
-
|
|
23198
|
+
SEPOLIA_CHAIN_ID,
|
|
23233
23199
|
ARBITRUM_SEPOLIA_CHAIN_ID2,
|
|
23234
23200
|
BASE_SEPOLIA_CHAIN_ID2
|
|
23235
23201
|
]);
|
|
@@ -24037,7 +24003,7 @@ var init_TransactionsGroup = __esm({
|
|
|
24037
24003
|
// src/internal/components/TransactionsMenu/TransactionsMenu.tsx
|
|
24038
24004
|
import { useQuery as useQuery23, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
|
|
24039
24005
|
import { ArrowLeft as ArrowLeft22, Loader as Loader32, RefreshCw as RefreshCw3, XCircle } from "lucide-react";
|
|
24040
|
-
import { useCallback as
|
|
24006
|
+
import { useCallback as useCallback29, useState as useState31 } from "react";
|
|
24041
24007
|
import { jsx as jsx114, jsxs as jsxs104 } from "react/jsx-runtime";
|
|
24042
24008
|
function TransactionsMenu() {
|
|
24043
24009
|
const qc = useQueryClient25();
|
|
@@ -24059,7 +24025,7 @@ function TransactionsMenu() {
|
|
|
24059
24025
|
queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address],
|
|
24060
24026
|
queryFn: () => getTransactionsListQuery({ address, chainConfig })
|
|
24061
24027
|
});
|
|
24062
|
-
const refreshTxHistory =
|
|
24028
|
+
const refreshTxHistory = useCallback29(
|
|
24063
24029
|
() => qc.invalidateQueries({ queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address] }),
|
|
24064
24030
|
[qc, chainConfig.id, address]
|
|
24065
24031
|
);
|
|
@@ -24298,7 +24264,7 @@ var init_PageMap = __esm({
|
|
|
24298
24264
|
});
|
|
24299
24265
|
|
|
24300
24266
|
// src/internal/hooks/usePageMapper.tsx
|
|
24301
|
-
import { useCallback as
|
|
24267
|
+
import { useCallback as useCallback30, useEffect as useEffect45 } from "react";
|
|
24302
24268
|
import { jsx as jsx115 } from "react/jsx-runtime";
|
|
24303
24269
|
function usePageMapper() {
|
|
24304
24270
|
const page = useLayoutDataStore((st) => st.page);
|
|
@@ -24310,7 +24276,7 @@ function usePageMapper() {
|
|
|
24310
24276
|
setIsDialogOpen,
|
|
24311
24277
|
setIsDialogClosing
|
|
24312
24278
|
} = useLayoutStore();
|
|
24313
|
-
const closeDialog =
|
|
24279
|
+
const closeDialog = useCallback30(() => {
|
|
24314
24280
|
setIsDialogClosing(true);
|
|
24315
24281
|
setTimeout(() => {
|
|
24316
24282
|
setDialogContent(null);
|
|
@@ -24321,7 +24287,7 @@ function usePageMapper() {
|
|
|
24321
24287
|
setIsDialogOpen(false);
|
|
24322
24288
|
}, CLEAR_DIALOG_TIMEOUT);
|
|
24323
24289
|
}, [setDialogContent, setDialogDescription, setDialogTitle, setIsDialogForced, setIsDialogOpen, setIsDialogClosing]);
|
|
24324
|
-
const openDialog =
|
|
24290
|
+
const openDialog = useCallback30(
|
|
24325
24291
|
(pageItem) => {
|
|
24326
24292
|
const PageContentComponent = pageItem.component;
|
|
24327
24293
|
setDialogTitle(pageItem.title);
|
|
@@ -24407,7 +24373,7 @@ var init_package = __esm({
|
|
|
24407
24373
|
"package.json"() {
|
|
24408
24374
|
package_default = {
|
|
24409
24375
|
name: "@embarkai/ui-kit",
|
|
24410
|
-
version: "0.4.
|
|
24376
|
+
version: "0.4.47",
|
|
24411
24377
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
24412
24378
|
type: "module",
|
|
24413
24379
|
main: "./dist/index.cjs",
|
|
@@ -24507,19 +24473,32 @@ var init_package = __esm({
|
|
|
24507
24473
|
// src/internal/components/Footer/Footer.tsx
|
|
24508
24474
|
import { useMutation as useMutation20, useQueryClient as useQueryClient26 } from "@tanstack/react-query";
|
|
24509
24475
|
import { Loader as Loader33, LogOut } from "lucide-react";
|
|
24476
|
+
import { useDisconnect as useDisconnect2 } from "wagmi";
|
|
24510
24477
|
import { jsx as jsx116, jsxs as jsxs105 } from "react/jsx-runtime";
|
|
24511
24478
|
function Footer() {
|
|
24512
24479
|
const qc = useQueryClient26();
|
|
24513
24480
|
const { callbacksRef } = useProviderConfig();
|
|
24514
|
-
const { address, setSession, setAddress, setStatus, setError, setIsLoading } = useSession();
|
|
24515
|
-
const chainConfig = useSession((st) => st.chainConfig);
|
|
24516
24481
|
const { t } = useT();
|
|
24517
|
-
const
|
|
24518
|
-
const
|
|
24482
|
+
const address = useSession((st) => st.address);
|
|
24483
|
+
const chainConfig = useSession((st) => st.chainConfig);
|
|
24484
|
+
const directWalletAddress = useExternalWalletStore((st) => st.externalAddress);
|
|
24485
|
+
const { disconnect: wagmiDisconnect } = useDisconnect2({
|
|
24486
|
+
mutation: {
|
|
24487
|
+
onSuccess: () => {
|
|
24488
|
+
useExternalWalletStore.getState().clearExternalWallet();
|
|
24489
|
+
useExternalWalletStore.getState().setExternalChainId(null);
|
|
24490
|
+
console.log("[ExternalWalletStore] Disconnected from external wallet");
|
|
24491
|
+
},
|
|
24492
|
+
onError: (err) => {
|
|
24493
|
+
console.error("[ExternalWalletStore] Error disconnecting from external wallet:", err);
|
|
24494
|
+
}
|
|
24495
|
+
}
|
|
24496
|
+
});
|
|
24519
24497
|
const { mutate: disconnect, isPending: isDisconnecting } = useMutation20({
|
|
24520
24498
|
mutationFn: async (disconnectAddress) => {
|
|
24521
24499
|
if (!disconnectAddress) throw new Error("No address to disconnect");
|
|
24522
|
-
|
|
24500
|
+
const { setError, setStatus, setIsLoading } = useSession.getState();
|
|
24501
|
+
useLayoutStore.getState().setIsDialogForced(true);
|
|
24523
24502
|
setError(null);
|
|
24524
24503
|
setStatus("disconnecting");
|
|
24525
24504
|
setIsLoading(true);
|
|
@@ -24530,6 +24509,8 @@ function Footer() {
|
|
|
24530
24509
|
},
|
|
24531
24510
|
onSuccess: async ({ disconnectAddress, disconnectedUserId }) => {
|
|
24532
24511
|
await qc.resetQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY] });
|
|
24512
|
+
if (!!directWalletAddress) wagmiDisconnect();
|
|
24513
|
+
const { setError, setStatus, setIsLoading, setSession, setAddress } = useSession.getState();
|
|
24533
24514
|
setSession(null);
|
|
24534
24515
|
setAddress(null);
|
|
24535
24516
|
setError(null);
|
|
@@ -24537,15 +24518,16 @@ function Footer() {
|
|
|
24537
24518
|
setIsLoading(false);
|
|
24538
24519
|
callbacksRef.current?.onDisconnect?.({ address: disconnectAddress, userId: disconnectedUserId });
|
|
24539
24520
|
setTimeout(() => {
|
|
24540
|
-
setPage("auth" /* AUTH */);
|
|
24541
|
-
setIsDialogForced(false);
|
|
24521
|
+
useLayoutDataStore.getState().setPage("auth" /* AUTH */);
|
|
24522
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
24542
24523
|
}, 200);
|
|
24543
24524
|
},
|
|
24544
24525
|
onError: (err) => {
|
|
24526
|
+
const { setError, setStatus, setIsLoading } = useSession.getState();
|
|
24545
24527
|
setError(err.message || "An unknown error occurred during sign out");
|
|
24546
24528
|
setStatus("idle");
|
|
24547
24529
|
setIsLoading(false);
|
|
24548
|
-
setIsDialogForced(false);
|
|
24530
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
24549
24531
|
}
|
|
24550
24532
|
});
|
|
24551
24533
|
const ChainIcon = NETWORK_OPTIONS.find((net) => net.chainId === chainConfig.id)?.Icon || (() => /* @__PURE__ */ jsx116("div", { className: "flex-none w-4 h-4 rounded-full flex items-center justify-center bg-[var(--ui-kit-primary)]", children: /* @__PURE__ */ jsx116("span", { className: "text-[var(--ui-kit-fg-inverted)] text-xs font-bold", children: chainConfig.name.charAt(0) }) }));
|
|
@@ -24601,7 +24583,7 @@ function Footer() {
|
|
|
24601
24583
|
var init_Footer = __esm({
|
|
24602
24584
|
"src/internal/components/Footer/Footer.tsx"() {
|
|
24603
24585
|
init_package();
|
|
24604
|
-
|
|
24586
|
+
init_networks4();
|
|
24605
24587
|
init_ProviderContext();
|
|
24606
24588
|
init_SessionContext();
|
|
24607
24589
|
init_i18n();
|
|
@@ -24610,6 +24592,7 @@ var init_Footer = __esm({
|
|
|
24610
24592
|
init_useLayoutDataStore();
|
|
24611
24593
|
init_useLayoutStore();
|
|
24612
24594
|
init_utils2();
|
|
24595
|
+
init_useExternalWalletStore();
|
|
24613
24596
|
init_constants4();
|
|
24614
24597
|
init_button();
|
|
24615
24598
|
}
|
|
@@ -24625,7 +24608,7 @@ var init_Footer2 = __esm({
|
|
|
24625
24608
|
// src/internal/components/Header/Header.tsx
|
|
24626
24609
|
import { useQuery as useQuery25 } from "@tanstack/react-query";
|
|
24627
24610
|
import { Copy as Copy5, Loader as Loader34 } from "lucide-react";
|
|
24628
|
-
import { useCallback as
|
|
24611
|
+
import { useCallback as useCallback31, useRef as useRef20, useState as useState32 } from "react";
|
|
24629
24612
|
import { Fragment as Fragment44, jsx as jsx117, jsxs as jsxs106 } from "react/jsx-runtime";
|
|
24630
24613
|
function formatAddress2(addr) {
|
|
24631
24614
|
if (!addr) return "";
|
|
@@ -24641,7 +24624,7 @@ function Header() {
|
|
|
24641
24624
|
const [copied, setCopied] = useState32(false);
|
|
24642
24625
|
const clickCountRef = useRef20(0);
|
|
24643
24626
|
const clickTimerRef = useRef20(null);
|
|
24644
|
-
const handleAvatarClick =
|
|
24627
|
+
const handleAvatarClick = useCallback31(() => {
|
|
24645
24628
|
clickCountRef.current += 1;
|
|
24646
24629
|
if (clickTimerRef.current) {
|
|
24647
24630
|
clearTimeout(clickTimerRef.current);
|
|
@@ -24744,7 +24727,7 @@ function Header() {
|
|
|
24744
24727
|
var init_Header = __esm({
|
|
24745
24728
|
"src/internal/components/Header/Header.tsx"() {
|
|
24746
24729
|
init_LumiaIcon3();
|
|
24747
|
-
|
|
24730
|
+
init_networks4();
|
|
24748
24731
|
init_ProviderContext();
|
|
24749
24732
|
init_SessionContext();
|
|
24750
24733
|
init_useT();
|
|
@@ -25021,7 +25004,7 @@ var init_Dialog2 = __esm({
|
|
|
25021
25004
|
});
|
|
25022
25005
|
|
|
25023
25006
|
// src/internal/components/TssManager.tsx
|
|
25024
|
-
import React8, { useCallback as
|
|
25007
|
+
import React8, { useCallback as useCallback32 } from "react";
|
|
25025
25008
|
var TssManagerWithRef;
|
|
25026
25009
|
var init_TssManager = __esm({
|
|
25027
25010
|
"src/internal/components/TssManager.tsx"() {
|
|
@@ -25036,7 +25019,7 @@ var init_TssManager = __esm({
|
|
|
25036
25019
|
const setStatus = useSession((st) => st.setStatus);
|
|
25037
25020
|
const setSession = useSession((st) => st.setSession);
|
|
25038
25021
|
const setAddress = useSession((st) => st.setAddress);
|
|
25039
|
-
const onSessionCreated =
|
|
25022
|
+
const onSessionCreated = useCallback32(
|
|
25040
25023
|
(session, address) => {
|
|
25041
25024
|
setSession(session);
|
|
25042
25025
|
setAddress(address);
|
|
@@ -25077,15 +25060,15 @@ var init_TssManager = __esm({
|
|
|
25077
25060
|
// src/internal/components/WalletConnectHandler.tsx
|
|
25078
25061
|
import { useConnectModal as useConnectModal2 } from "@rainbow-me/rainbowkit";
|
|
25079
25062
|
import { useMutation as useMutation21, useQueryClient as useQueryClient27 } from "@tanstack/react-query";
|
|
25080
|
-
import React9, { useCallback as
|
|
25081
|
-
import { useAccount, useDisconnect as
|
|
25063
|
+
import React9, { useCallback as useCallback33, useEffect as useEffect48 } from "react";
|
|
25064
|
+
import { useAccount, useDisconnect as useDisconnect3, useSignMessage as useSignMessage2 } from "wagmi";
|
|
25082
25065
|
function WalletConnectHandler() {
|
|
25083
25066
|
const qc = useQueryClient27();
|
|
25084
25067
|
const { callbacksRef } = useProviderConfig();
|
|
25085
25068
|
const passportWalletAddress = useSession((st) => st.address);
|
|
25086
25069
|
const { address: walletAddress, isConnected, chain, connector } = useAccount();
|
|
25087
25070
|
const { openConnectModal, connectModalOpen } = useConnectModal2();
|
|
25088
|
-
const { disconnect } =
|
|
25071
|
+
const { disconnect } = useDisconnect3();
|
|
25089
25072
|
const { signMessageAsync } = useSignMessage2();
|
|
25090
25073
|
const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
|
|
25091
25074
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
@@ -25100,7 +25083,7 @@ function WalletConnectHandler() {
|
|
|
25100
25083
|
const projectId = providerConfig?.projectId;
|
|
25101
25084
|
const setExternalWallet = useExternalWalletStore((st) => st.setExternalWallet);
|
|
25102
25085
|
const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
|
|
25103
|
-
const onLinkingComplete =
|
|
25086
|
+
const onLinkingComplete = useCallback33(
|
|
25104
25087
|
async (success) => {
|
|
25105
25088
|
setIsWalletLinking(false);
|
|
25106
25089
|
if (!success && !passportWalletAddress) {
|
|
@@ -28219,7 +28202,7 @@ import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
|
|
|
28219
28202
|
import { merge as merge3 } from "lodash-es";
|
|
28220
28203
|
import {
|
|
28221
28204
|
createContext,
|
|
28222
|
-
useCallback as
|
|
28205
|
+
useCallback as useCallback34,
|
|
28223
28206
|
useContext,
|
|
28224
28207
|
useEffect as useEffect50,
|
|
28225
28208
|
useMemo as useMemo16,
|
|
@@ -28246,7 +28229,7 @@ function Provider(props) {
|
|
|
28246
28229
|
const callbacksRef = useRef21(callbacks);
|
|
28247
28230
|
useEffect50(() => notifyNoProjetctId(projectId), [projectId]);
|
|
28248
28231
|
const config = useRef21(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
|
|
28249
|
-
const updateConfig =
|
|
28232
|
+
const updateConfig = useCallback34((updates) => {
|
|
28250
28233
|
const prev = config.current;
|
|
28251
28234
|
const next = { ...prev };
|
|
28252
28235
|
if (updates.projectId !== void 0) next.projectId = updates.projectId;
|
|
@@ -28280,7 +28263,7 @@ function Provider(props) {
|
|
|
28280
28263
|
if (updates.translations) next.translations = { ...next.translations, ...updates.translations };
|
|
28281
28264
|
config.current = next;
|
|
28282
28265
|
}, []);
|
|
28283
|
-
const updateCallbacks =
|
|
28266
|
+
const updateCallbacks = useCallback34((updates) => {
|
|
28284
28267
|
const prev = callbacksRef.current;
|
|
28285
28268
|
const next = updates ? { ...prev, ...updates } : void 0;
|
|
28286
28269
|
callbacksRef.current = next;
|
|
@@ -28702,13 +28685,13 @@ var useHydrated = () => useSession((st) => st.hasHydrated);
|
|
|
28702
28685
|
// src/hooks/useOpenPage.ts
|
|
28703
28686
|
init_SessionContext();
|
|
28704
28687
|
init_useLayoutDataStore();
|
|
28705
|
-
import { useCallback as
|
|
28688
|
+
import { useCallback as useCallback35 } from "react";
|
|
28706
28689
|
function useOpenPage() {
|
|
28707
28690
|
const page = useLayoutDataStore((st) => st.page);
|
|
28708
28691
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
28709
28692
|
const setPageParams = useLayoutDataStore((st) => st.setPageParams);
|
|
28710
28693
|
const address = useSession((st) => st.address);
|
|
28711
|
-
const open =
|
|
28694
|
+
const open = useCallback35(
|
|
28712
28695
|
(passportPage, params) => {
|
|
28713
28696
|
if (!address) return setPage("auth" /* AUTH */);
|
|
28714
28697
|
if (!!address && passportPage === "auth" /* AUTH */) return setPage("manage-wallet" /* MANAGE_WALLET */);
|
|
@@ -28717,7 +28700,7 @@ function useOpenPage() {
|
|
|
28717
28700
|
},
|
|
28718
28701
|
[setPage, setPageParams, address]
|
|
28719
28702
|
);
|
|
28720
|
-
const close =
|
|
28703
|
+
const close = useCallback35(() => setPage(null), [setPage]);
|
|
28721
28704
|
return { open, close, isOpen: page !== null };
|
|
28722
28705
|
}
|
|
28723
28706
|
|
|
@@ -29477,12 +29460,12 @@ init_useErc3643Compliance();
|
|
|
29477
29460
|
|
|
29478
29461
|
// src/hooks/useWalletMode.ts
|
|
29479
29462
|
init_useExternalWalletStore();
|
|
29480
|
-
import { useCallback as
|
|
29463
|
+
import { useCallback as useCallback38 } from "react";
|
|
29481
29464
|
function useWalletMode() {
|
|
29482
29465
|
const configMode = useExternalWalletStore((st) => st.configMode);
|
|
29483
29466
|
const activeMode = useExternalWalletStore((st) => st.activeMode);
|
|
29484
29467
|
const setActiveMode = useExternalWalletStore((st) => st.setActiveMode);
|
|
29485
|
-
const switchMode =
|
|
29468
|
+
const switchMode = useCallback38(
|
|
29486
29469
|
(mode) => {
|
|
29487
29470
|
if (configMode !== "both") return;
|
|
29488
29471
|
setActiveMode(mode);
|
|
@@ -29500,25 +29483,25 @@ function useWalletMode() {
|
|
|
29500
29483
|
// src/hooks/useDirectWallet.ts
|
|
29501
29484
|
init_useExternalWalletStore();
|
|
29502
29485
|
init_useLayoutDataStore();
|
|
29503
|
-
import { useCallback as
|
|
29486
|
+
import { useCallback as useCallback39 } from "react";
|
|
29504
29487
|
import { useConnectModal as useConnectModal3 } from "@rainbow-me/rainbowkit";
|
|
29505
|
-
import { useDisconnect as
|
|
29488
|
+
import { useDisconnect as useDisconnect4 } from "wagmi";
|
|
29506
29489
|
function useDirectWallet() {
|
|
29507
29490
|
const address = useExternalWalletStore((st) => st.externalAddress);
|
|
29508
29491
|
const chainId = useExternalWalletStore((st) => st.externalChainId);
|
|
29509
29492
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
29510
29493
|
const connectorName = useExternalWalletStore((st) => st.connectorName);
|
|
29511
29494
|
const clearExternalWallet = useExternalWalletStore((st) => st.clearExternalWallet);
|
|
29512
|
-
const { disconnect: wagmiDisconnect } =
|
|
29495
|
+
const { disconnect: wagmiDisconnect } = useDisconnect4();
|
|
29513
29496
|
const { openConnectModal } = useConnectModal3();
|
|
29514
29497
|
const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
|
|
29515
|
-
const connect =
|
|
29498
|
+
const connect = useCallback39(() => {
|
|
29516
29499
|
setIsWalletLinking(true);
|
|
29517
29500
|
}, [setIsWalletLinking]);
|
|
29518
|
-
const reconnect =
|
|
29501
|
+
const reconnect = useCallback39(() => {
|
|
29519
29502
|
if (openConnectModal) openConnectModal();
|
|
29520
29503
|
}, [openConnectModal]);
|
|
29521
|
-
const disconnect =
|
|
29504
|
+
const disconnect = useCallback39(() => {
|
|
29522
29505
|
wagmiDisconnect();
|
|
29523
29506
|
clearExternalWallet();
|
|
29524
29507
|
}, [wagmiDisconnect, clearExternalWallet]);
|
|
@@ -29535,7 +29518,7 @@ function useDirectWallet() {
|
|
|
29535
29518
|
|
|
29536
29519
|
// src/hooks/useSendDirectTransaction.ts
|
|
29537
29520
|
init_useExternalWalletStore();
|
|
29538
|
-
import { useCallback as
|
|
29521
|
+
import { useCallback as useCallback40, useState as useState38 } from "react";
|
|
29539
29522
|
import { isAddress as isAddress3, parseEther as parseEther3 } from "viem";
|
|
29540
29523
|
import { useSendTransaction as useWagmiSendTransaction, useSwitchChain as useSwitchChain3 } from "wagmi";
|
|
29541
29524
|
function useSendDirectTransaction() {
|
|
@@ -29546,7 +29529,7 @@ function useSendDirectTransaction() {
|
|
|
29546
29529
|
const [isPending, setIsPending] = useState38(false);
|
|
29547
29530
|
const [error, setError] = useState38(null);
|
|
29548
29531
|
const [txHash, setTxHash] = useState38(null);
|
|
29549
|
-
const sendTransaction =
|
|
29532
|
+
const sendTransaction = useCallback40(
|
|
29550
29533
|
async (params) => {
|
|
29551
29534
|
if (!isConnected) {
|
|
29552
29535
|
setError("No external wallet connected");
|
|
@@ -29580,7 +29563,7 @@ function useSendDirectTransaction() {
|
|
|
29580
29563
|
},
|
|
29581
29564
|
[isConnected, externalChainId, sendTransactionAsync, switchChainAsync]
|
|
29582
29565
|
);
|
|
29583
|
-
const reset =
|
|
29566
|
+
const reset = useCallback40(() => {
|
|
29584
29567
|
setError(null);
|
|
29585
29568
|
setTxHash(null);
|
|
29586
29569
|
setIsPending(false);
|
|
@@ -29592,7 +29575,7 @@ function useSendDirectTransaction() {
|
|
|
29592
29575
|
init_SessionContext();
|
|
29593
29576
|
init_account2();
|
|
29594
29577
|
init_linkedProfiles();
|
|
29595
|
-
import { useCallback as
|
|
29578
|
+
import { useCallback as useCallback41, useMemo as useMemo18, useState as useState39 } from "react";
|
|
29596
29579
|
import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress4, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
|
|
29597
29580
|
var ERC20_TRANSFER_ABI2 = [
|
|
29598
29581
|
{
|
|
@@ -29615,7 +29598,7 @@ function useTransferToLinkedWallet() {
|
|
|
29615
29598
|
() => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
|
|
29616
29599
|
[profiles]
|
|
29617
29600
|
);
|
|
29618
|
-
const transfer =
|
|
29601
|
+
const transfer = useCallback41(
|
|
29619
29602
|
async (params) => {
|
|
29620
29603
|
if (!session) {
|
|
29621
29604
|
setError("No active session");
|
|
@@ -29666,7 +29649,7 @@ function useTransferToLinkedWallet() {
|
|
|
29666
29649
|
},
|
|
29667
29650
|
[session, linkedWallets]
|
|
29668
29651
|
);
|
|
29669
|
-
const reset =
|
|
29652
|
+
const reset = useCallback41(() => {
|
|
29670
29653
|
setError(null);
|
|
29671
29654
|
setUserOpHash(null);
|
|
29672
29655
|
setIsPending(false);
|
|
@@ -29691,12 +29674,27 @@ function useNativeWalletSignature() {
|
|
|
29691
29674
|
// src/hooks/useLogout.ts
|
|
29692
29675
|
init_ProviderContext();
|
|
29693
29676
|
init_SessionContext();
|
|
29677
|
+
init_useExternalWalletStore();
|
|
29694
29678
|
import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
|
|
29695
|
-
import { useCallback as
|
|
29679
|
+
import { useCallback as useCallback42 } from "react";
|
|
29680
|
+
import { useDisconnect as useDisconnect5 } from "wagmi";
|
|
29696
29681
|
function useLogout() {
|
|
29697
|
-
const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
|
|
29698
29682
|
const { callbacksRef } = useProviderConfig();
|
|
29699
|
-
const
|
|
29683
|
+
const address = useSession((st) => st.address);
|
|
29684
|
+
const { disconnect: wagmiDisconnect } = useDisconnect5({
|
|
29685
|
+
mutation: {
|
|
29686
|
+
onSuccess: () => {
|
|
29687
|
+
useExternalWalletStore.getState().clearExternalWallet();
|
|
29688
|
+
useExternalWalletStore.getState().setExternalChainId(null);
|
|
29689
|
+
console.log("[ExternalWalletStore] Disconnected from external wallet");
|
|
29690
|
+
},
|
|
29691
|
+
onError: (err) => {
|
|
29692
|
+
console.error("[ExternalWalletStore] Error disconnecting from external wallet:", err);
|
|
29693
|
+
}
|
|
29694
|
+
}
|
|
29695
|
+
});
|
|
29696
|
+
const logout2 = useCallback42(async () => {
|
|
29697
|
+
const { setSession, setIsLoading, setAddress, setStatus, setError } = useSession.getState();
|
|
29700
29698
|
const prevAddress = address;
|
|
29701
29699
|
let userId = null;
|
|
29702
29700
|
setIsLoading(true);
|
|
@@ -29710,6 +29708,7 @@ function useLogout() {
|
|
|
29710
29708
|
} catch (error) {
|
|
29711
29709
|
console.warn("[useLogout] Core logout failed:", error);
|
|
29712
29710
|
}
|
|
29711
|
+
if (!!useExternalWalletStore.getState().externalAddress) wagmiDisconnect();
|
|
29713
29712
|
setSession(null);
|
|
29714
29713
|
setAddress(null);
|
|
29715
29714
|
setStatus("idle");
|
|
@@ -29723,7 +29722,7 @@ function useLogout() {
|
|
|
29723
29722
|
} catch (error) {
|
|
29724
29723
|
console.warn("[useLogout] Callback error:", error);
|
|
29725
29724
|
}
|
|
29726
|
-
}, [address
|
|
29725
|
+
}, [address]);
|
|
29727
29726
|
return { logout: logout2 };
|
|
29728
29727
|
}
|
|
29729
29728
|
|