Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@babylonlabs-io/babylon-proto-ts": "1.12.0",
"@babylonlabs-io/bsn-registry": "0.2.2",
"@babylonlabs-io/btc-staking-ts": "2.5.6",
"@babylonlabs-io/core-ui": "1.35.3",
"@babylonlabs-io/wallet-connector": "1.11.6",
"@babylonlabs-io/core-ui": "1.36.0",
"@babylonlabs-io/wallet-connector": "1.12.0",
"@bitcoin-js/tiny-secp256k1-asmjs": "2.2.3",
"@cosmjs/proto-signing": "^0.33.1",
"@cosmjs/stargate": "^0.33.1",
Expand Down
45 changes: 32 additions & 13 deletions src/ui/common/components/Wallet/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { useMemo, useState } from "react";
import { AiOutlineInfoCircle } from "react-icons/ai";
import { PiWalletBold } from "react-icons/pi";
import { useLocation } from "react-router";
import { Tooltip } from "react-tooltip";
import { twMerge } from "tailwind-merge";

Expand Down Expand Up @@ -42,6 +43,10 @@ export const Connect: React.FC<ConnectProps> = ({
setIsWalletMenuOpen(open);
};

const location = useLocation();
const isBabyRoute = location.pathname.startsWith("/baby");

Copilot AI Sep 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded route prefix '/baby' is duplicated from WalletConnectionProvider.tsx. This should be extracted as a shared constant to maintain consistency and avoid duplication.

Copilot uses AI. Check for mistakes.
const requireBothWallets = !isBabyRoute;

// App state and wallet context
const { includeOrdinals, excludeOrdinals, ordinalsExcluded } = useAppState();
const { linkedDelegationsVisibility, displayLinkedDelegations } =
Expand Down Expand Up @@ -108,14 +113,26 @@ export const Connect: React.FC<ConnectProps> = ({
apiMessage,
isLoading: isHealthcheckLoading,
} = useHealthCheck();

const isConnected = useMemo(
() =>
btcConnected && bbnConnected && !isGeoBlocked && !isHealthcheckLoading,
[btcConnected, bbnConnected, isGeoBlocked, isHealthcheckLoading],
(requireBothWallets ? btcConnected && bbnConnected : bbnConnected) &&
!isGeoBlocked &&
!isHealthcheckLoading,
[
requireBothWallets,
btcConnected,
bbnConnected,
isGeoBlocked,
isHealthcheckLoading,
],
);

const isLoading =
isConnected || !isApiNormal || loading || btcLoading || bbnLoading;
isConnected ||
!isApiNormal ||
loading ||
(requireBothWallets ? btcLoading || bbnLoading : bbnLoading);

const transformedWallets = useMemo(() => {
const result: Record<string, { name: string; icon: string }> = {};
Expand Down Expand Up @@ -174,16 +191,18 @@ export const Connect: React.FC<ConnectProps> = ({
trigger={
<div className="cursor-pointer">
<AvatarGroup max={2} variant="circular">
<Avatar
alt={selectedWallets["BTC"]?.name}
url={selectedWallets["BTC"]?.icon}
size="large"
className={twMerge(
"object-contain bg-accent-contrast box-content",
isWalletMenuOpen &&
"outline outline-[2px] outline-accent-primary",
)}
/>
{selectedWallets["BTC"] ? (
<Avatar
alt={selectedWallets["BTC"]?.name}
url={selectedWallets["BTC"]?.icon}
size="large"
className={twMerge(
"object-contain bg-accent-contrast box-content",
isWalletMenuOpen &&
"outline outline-[2px] outline-accent-primary",
)}
/>
) : null}
<Avatar
alt={selectedWallets["BBN"]?.name}
url={selectedWallets["BBN"]?.icon}
Expand Down
3 changes: 2 additions & 1 deletion src/ui/common/context/wallet/BTCWalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ export const BTCWalletProvider = ({ children }: PropsWithChildren) => {
);

useEffect(() => {
if (!btcConnector) return;
// Ensure loading is cleared even when BTC connector is not configured
setLoading(false);
if (!btcConnector) return;
if (btcConnector.connectedWallet) {
connectBTC(btcConnector?.connectedWallet.provider);
}
Expand Down
11 changes: 9 additions & 2 deletions src/ui/common/context/wallet/WalletConnectionProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from "@babylonlabs-io/wallet-connector";
import { useTheme } from "next-themes";
import { useCallback, type PropsWithChildren } from "react";
import { useLocation } from "react-router";

import { logTermsAcceptance } from "@/ui/common/api/logTermAcceptance";
import { verifyBTCAddress } from "@/ui/common/api/verifyBTCAddress";
Expand All @@ -29,7 +30,7 @@ const config: ChainConfigArr = [
connectors: [
{
id: "tomo-btc-connector",
widget: ({ onError }) => (
widget: ({ onError }: { onError?: (e: Error) => void }) => (
<ExternalWallets chainName="bitcoin" onError={onError} />
),
},
Expand All @@ -41,7 +42,7 @@ const config: ChainConfigArr = [
connectors: [
{
id: "tomo-bbn-connector",
widget: ({ onError }) => (
widget: ({ onError }: { onError?: (e: Error) => void }) => (
<ExternalWallets chainName="cosmos" onError={onError} />
),
},
Expand All @@ -54,6 +55,7 @@ export const WalletConnectionProvider = ({ children }: PropsWithChildren) => {
const { handleError } = useError();
const { theme } = useTheme();
const logger = useLogger();
const location = useLocation();

const onError = useCallback(
(error: Error) => {
Expand All @@ -74,6 +76,10 @@ export const WalletConnectionProvider = ({ children }: PropsWithChildren) => {
[handleError, logger],
);

const requiredChains = (
location.pathname.startsWith("/baby") ? ["BBN"] : ["BTC", "BBN"]
) as ("BTC" | "BBN")[];
Comment on lines +79 to +81

Copilot AI Sep 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded route prefix '/baby' should be extracted as a constant to improve maintainability and avoid magic strings. Consider defining a constant like BABY_ROUTE_PREFIX = '/baby' at the module level.

Copilot uses AI. Check for mistakes.

return (
<WalletProvider
persistent
Expand All @@ -83,6 +89,7 @@ export const WalletConnectionProvider = ({ children }: PropsWithChildren) => {
context={context}
onError={onError}
disabledWallets={FeatureFlagService.IsLedgerEnabled ? [] : ["ledget_btc"]}
requiredChains={requiredChains}
>
{children}
</WalletProvider>
Expand Down
3 changes: 1 addition & 2 deletions src/ui/common/hooks/useAuthGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {

export function useAuthGuard() {
const { connected } = useWalletConnect();
const btc = useChainConnector("BTC");
const baby = useChainConnector("BBN");

return { connected, loading: !btc || !baby };
return { connected, loading: !baby };
}