From 8da8ce3fdd68856d6de9e87ecd45dcb3b11d4cbe Mon Sep 17 00:00:00 2001 From: DC Date: Sun, 29 Sep 2024 17:36:11 -0700 Subject: [PATCH] web: fix ConnectWalletFlow --- .../src/app/l/[[...slug]]/LinkPage.tsx | 4 ++-- .../src/app/link/[[...slug]]/page.tsx | 4 ++-- .../src/components/ConnectWalletFlow.tsx | 7 +++--- apps/daimo-web/src/components/Providers.tsx | 23 +++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/daimo-web/src/app/l/[[...slug]]/LinkPage.tsx b/apps/daimo-web/src/app/l/[[...slug]]/LinkPage.tsx index e34907988..22d8bf147 100644 --- a/apps/daimo-web/src/app/l/[[...slug]]/LinkPage.tsx +++ b/apps/daimo-web/src/app/l/[[...slug]]/LinkPage.tsx @@ -3,7 +3,7 @@ import Image from "next/image"; import { CallToAction } from "../../../components/CallToAction"; -import { chainsDaimoL2, Providers } from "../../../components/Providers"; +import { Providers } from "../../../components/Providers"; import { I18NProvider, useI18N } from "../../../i18n/context"; import { LinkStatusDesc } from "../../../utils/linkStatus"; @@ -17,7 +17,7 @@ export default function LinkPage({ pfp: string | undefined; }) { return ( - + diff --git a/apps/daimo-web/src/app/link/[[...slug]]/page.tsx b/apps/daimo-web/src/app/link/[[...slug]]/page.tsx index 918e4fec6..8db0370c3 100644 --- a/apps/daimo-web/src/app/link/[[...slug]]/page.tsx +++ b/apps/daimo-web/src/app/link/[[...slug]]/page.tsx @@ -16,7 +16,7 @@ import { Metadata } from "next"; import Image from "next/image"; import { CallToAction } from "../../../components/CallToAction"; -import { Providers, chainsDaimoL2 } from "../../../components/Providers"; +import { Providers } from "../../../components/Providers"; import { getI18N } from "../../../i18n"; import { getReqLang } from "../../../i18n/server"; import { getAbsoluteUrl } from "../../../utils/getAbsoluteUrl"; @@ -86,7 +86,7 @@ export async function generateMetadata(props: LinkProps): Promise { export default async function LinkPage(props: LinkProps) { return ( - + ); diff --git a/apps/daimo-web/src/components/ConnectWalletFlow.tsx b/apps/daimo-web/src/components/ConnectWalletFlow.tsx index 6581c1386..19d7d508c 100644 --- a/apps/daimo-web/src/components/ConnectWalletFlow.tsx +++ b/apps/daimo-web/src/components/ConnectWalletFlow.tsx @@ -135,10 +135,11 @@ function WagmiButton({ isSuccess, data: txHash, } = useWriteContract(); - // const { data, isLoading, isSuccess, write } = usweWrite(wagmiPrep); const humanReadableError = useMemo(() => { - if (!error || !error.message) return undefined; + if (error == null) return undefined; + + console.warn("Connect wallet error", error); if (error.message.match(/ERC20: transfer amount exceeds balance/)) { return i18.errors.notEnoughFunds(); } else if (error.message.match(/note does not exist/)) { @@ -148,7 +149,7 @@ function WagmiButton({ } else if (error instanceof InsufficientFundsError) { return i18.errors.insufficientEth(); } else { - return error.message; + return error.message || "Unknown error"; } }, [error, i18]); diff --git a/apps/daimo-web/src/components/Providers.tsx b/apps/daimo-web/src/components/Providers.tsx index d61c4760e..0a5be66b9 100644 --- a/apps/daimo-web/src/components/Providers.tsx +++ b/apps/daimo-web/src/components/Providers.tsx @@ -1,33 +1,27 @@ "use client"; import { - RainbowKitProvider, connectorsForWallets, getDefaultWallets, + RainbowKitProvider, } from "@rainbow-me/rainbowkit"; import { ConnectorsForWalletsParameters } from "@rainbow-me/rainbowkit/dist/wallets/connectorsForWallets"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import * as React from "react"; import { useMemo, useState } from "react"; -import { Chain } from "viem/chains"; +import { http, Transport } from "viem"; import { createConfig, WagmiProvider } from "wagmi"; import { chainConfig } from "../env"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -export const chainsDaimoL2 = [chainConfig.chainL2] as const; +export const chains = [chainConfig.chainL2] as const; const appInfo = { appName: "Daimo", learnMoreUrl: "https://daimo.com", }; -export function Providers({ - chains, - children, -}: { - chains: readonly [Chain, ...Chain[]]; - children: React.ReactNode; -}) { +export function Providers({ children }: { children: React.ReactNode }) { const [mounted, setMounted] = React.useState(false); React.useEffect(() => setMounted(true), []); @@ -39,10 +33,15 @@ export function Providers({ const { wallets } = getDefaultWallets(walletConnectParams); const connectors = connectorsForWallets([...wallets], walletConnectParams); + const transports: Record = {}; + chains.forEach((c) => { + transports[c.id] = http(); + }); + return createConfig({ connectors, chains, - transports: [], + transports, }); }, [chains]);