diff --git a/src/components/pages/wallet/governance/drep/registerDrep.tsx b/src/components/pages/wallet/governance/drep/registerDrep.tsx index 1c46af35..0c789ac3 100644 --- a/src/components/pages/wallet/governance/drep/registerDrep.tsx +++ b/src/components/pages/wallet/governance/drep/registerDrep.tsx @@ -1,7 +1,6 @@ import { Plus } from "lucide-react"; import { useState, useCallback } from "react"; import useAppWallet from "@/hooks/useAppWallet"; -import { useWallet } from "@meshsdk/react"; import { useUserStore } from "@/lib/zustand/user"; import { useSiteStore } from "@/lib/zustand/site"; import { getTxBuilder } from "@/utils/get-tx-builder"; @@ -14,7 +13,6 @@ import type { UTxO } from "@meshsdk/core"; import router from "next/router"; import useMultisigWallet from "@/hooks/useMultisigWallet"; import { MeshProxyContract } from "@/components/multisig/proxy/offchain"; -import { getProvider } from "@/utils/get-provider"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { api } from "@/utils/api"; @@ -33,8 +31,7 @@ interface RegisterDRepProps { export default function RegisterDRep({ onClose }: RegisterDRepProps = {}) { const { appWallet } = useAppWallet(); - const { connected, wallet } = useWallet(); - const { isAnyWalletConnected, isWalletReady } = useActiveWallet(); + const { activeWallet } = useActiveWallet(); const userAddress = useUserStore((state) => state.userAddress); const network = useSiteStore((state) => state.network); const loading = useSiteStore((state) => state.loading); @@ -95,16 +92,6 @@ export default function RegisterDRep({ onClose }: RegisterDRepProps = {}) { }); throw new Error(errorMessage); } - if (!multisigWallet) { - const errorMessage = "Multisig wallet not connected. Please ensure your multisig wallet is properly configured."; - toast({ - title: "Multisig Wallet Not Connected", - description: errorMessage, - variant: "destructive", - duration: 5000, - }); - throw new Error(errorMessage); - } // Get metadata with both compacted (for upload) and normalized (for hashing) forms const metadataResult = await getDRepMetadata( formState, @@ -133,8 +120,8 @@ export default function RegisterDRep({ onClose }: RegisterDRepProps = {}) { } async function registerDrep(): Promise { - if (!isWalletReady || !userAddress || !multisigWallet || !appWallet) { - const errorMessage = "Multisig wallet not connected. Please ensure your wallet is connected and try again."; + if (!activeWallet || !userAddress || !appWallet) { + const errorMessage = "Wallet not connected. Please ensure your wallet is connected and try again."; toast({ title: "Wallet Not Connected", description: errorMessage, @@ -263,8 +250,13 @@ export default function RegisterDRep({ onClose }: RegisterDRepProps = {}) { } async function registerProxyDrep(): Promise { - if (!isWalletReady || !userAddress || !multisigWallet || !appWallet) { - const errorMessage = "Multisig wallet not connected. Please ensure your wallet is connected and try again."; + if (!hasValidProxy) { + // Fall back to standard registration if no valid proxy + return registerDrep(); + } + + if (!activeWallet || !userAddress || !multisigWallet || !appWallet) { + const errorMessage = "Proxy registration requires both connected wallet signer and multisig wallet configuration."; toast({ title: "Wallet Not Connected", description: errorMessage, @@ -274,11 +266,6 @@ export default function RegisterDRep({ onClose }: RegisterDRepProps = {}) { throw new Error(errorMessage); } - if (!hasValidProxy) { - // Fall back to standard registration if no valid proxy - return registerDrep(); - } - setLoading(true); try { const { anchorUrl, anchorHash } = await createAnchor(); @@ -298,7 +285,7 @@ export default function RegisterDRep({ onClose }: RegisterDRepProps = {}) { const proxyContract = new MeshProxyContract( { mesh: txBuilder, - wallet: wallet, + wallet: activeWallet, networkId: network, }, { diff --git a/src/components/pages/wallet/governance/drep/retire.tsx b/src/components/pages/wallet/governance/drep/retire.tsx index afa9e726..1e454ee9 100644 --- a/src/components/pages/wallet/governance/drep/retire.tsx +++ b/src/components/pages/wallet/governance/drep/retire.tsx @@ -4,7 +4,6 @@ import { useSiteStore } from "@/lib/zustand/site"; import { getProvider } from "@/utils/get-provider"; import { getTxBuilder } from "@/utils/get-tx-builder"; import { keepRelevant, Quantity, Unit, UTxO } from "@meshsdk/core"; -import { useWallet } from "@meshsdk/react"; import { useUserStore } from "@/lib/zustand/user"; import { useWalletsStore } from "@/lib/zustand/wallets"; import useTransaction from "@/hooks/useTransaction"; @@ -15,10 +14,11 @@ import { api } from "@/utils/api"; import { useCallback } from "react"; import { useToast } from "@/hooks/use-toast"; import { DREP_DEPOSIT_STRING } from "@/utils/protocol-deposit-constants"; +import useActiveWallet from "@/hooks/useActiveWallet"; export default function Retire({ appWallet, manualUtxos }: { appWallet: Wallet; manualUtxos: UTxO[] }) { const network = useSiteStore((state) => state.network); - const { wallet, connected } = useWallet(); + const { activeWallet } = useActiveWallet(); const userAddress = useUserStore((state) => state.userAddress); const drepInfo = useWalletsStore((state) => state.drepInfo); const { newTransaction } = useTransaction(); @@ -53,18 +53,19 @@ export default function Retire({ appWallet, manualUtxos }: { appWallet: Wallet; }, [multisigWallet?.getScript().address, manualUtxos]); async function retireProxyDrep(): Promise { - if (!connected || !userAddress || !multisigWallet || !appWallet) { + if (!hasValidProxy) { + // Fall back to standard retire if no valid proxy + return retireDrep(); + } + + if (!activeWallet || !userAddress || !multisigWallet || !appWallet) { toast({ title: "Connection Error", - description: "Multisig wallet not connected", + description: "Proxy retirement requires both connected wallet signer and multisig wallet configuration.", variant: "destructive", }); return; } - if (!hasValidProxy) { - // Fall back to standard retire if no valid proxy - return retireDrep(); - } setLoading(true); @@ -96,7 +97,7 @@ export default function Retire({ appWallet, manualUtxos }: { appWallet: Wallet; const proxyContract = new MeshProxyContract( { mesh: txBuilder, - wallet: wallet, + wallet: activeWallet, networkId: network, }, { @@ -127,7 +128,7 @@ export default function Retire({ appWallet, manualUtxos }: { appWallet: Wallet; } async function retireDrep() { - if (!connected) { + if (!activeWallet) { toast({ title: "Connection Error", description: "Not connected to wallet", @@ -143,15 +144,6 @@ export default function Retire({ appWallet, manualUtxos }: { appWallet: Wallet; }); return; } - if (!multisigWallet) { - toast({ - title: "Wallet Error", - description: "Multisig Wallet could not be built", - variant: "destructive", - }); - return; - } - setLoading(true); try {