Skip to content

Commit

Permalink
show warning if connecting with safe wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Jan 6, 2025
1 parent 8b44ba2 commit 4869f52
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/nextjs/app/cow/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { useEffect, useState } from "react";
import { PoolConfiguration, PoolCreation } from "./_components";
import type { NextPage } from "next";
import { CowAMM } from "~~/components/assets/CowAMM";
import { Alert } from "~~/components/common/Alert";
import { usePoolCreationStore } from "~~/hooks/cow/usePoolCreationStore";
import { useIsSafeWallet } from "~~/hooks/safe";

const CowAmm: NextPage = () => {
const [isMounted, setIsMounted] = useState(false);

const { poolCreation, updatePoolCreation, clearPoolCreation } = usePoolCreationStore();

const isSafeWallet = useIsSafeWallet();

useEffect(() => {
setIsMounted(true);
}, []);
Expand All @@ -23,6 +27,11 @@ const CowAmm: NextPage = () => {
<CowAMM width="333" />
{!isMounted ? (
<CowLoadingSkeleton />
) : isSafeWallet ? (
<Alert type="warning">
Safe wallets are not yet supported for CoW AMM pool creation. Please create the pool with an externally
owned account, and then add liquidity on balancer.fi with your Safe wallet.
</Alert>
) : !poolCreation ? (
<PoolConfiguration />
) : (
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/hooks/safe/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./useSafe";
12 changes: 12 additions & 0 deletions packages/nextjs/hooks/safe/useSafe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useAccount } from "wagmi";

export const useIsSafeWallet = () => {
const { connector } = useAccount();
return connector?.id === "safe";
};

// export function useShouldBatchTransactions(pool: Pool): boolean {
// const isSafeWallet = useIsSafeWallet()

// return isSafeWallet && isCowAmmPool(pool.type)
// }

0 comments on commit 4869f52

Please sign in to comment.