From 62262b56b62d9bccad6bbc2e2ba36a8a850526e5 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Wed, 4 Dec 2024 12:41:03 -0500 Subject: [PATCH 1/2] fix: Wallet Connect Removed Second Signature Handling Removed check for isOnXmtp network Removed unused translations --- .../ConnectViaWallet.store.tsx | 2 -- .../ConnectViaWallet/ConnectViaWallet.tsx | 22 ++++--------------- .../useConnectViaWalletInitXmtpClient.tsx | 1 - .../useInitConnectViaWalletState.ts | 21 ++++++------------ i18n/translations/en.ts | 5 ----- 5 files changed, 11 insertions(+), 40 deletions(-) diff --git a/components/Onboarding/ConnectViaWallet/ConnectViaWallet.store.tsx b/components/Onboarding/ConnectViaWallet/ConnectViaWallet.store.tsx index 6f3e63dc7..532ec7cc9 100644 --- a/components/Onboarding/ConnectViaWallet/ConnectViaWallet.store.tsx +++ b/components/Onboarding/ConnectViaWallet/ConnectViaWallet.store.tsx @@ -5,7 +5,6 @@ import { createStore, useStore } from "zustand"; type IConnectViaWalletStoreProps = { address: string; alreadyV3Db: boolean; - onXmtp: boolean; signer: Signer; }; @@ -43,7 +42,6 @@ const createConnectViaWalletStore = (props: IConnectViaWalletStoreProps) => createStore()((set) => ({ address: props.address, signer: props.signer, - onXmtp: props.onXmtp, alreadyV3Db: props.alreadyV3Db, loading: false, numberOfSignaturesDone: 0, diff --git a/components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx b/components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx index f0026b970..ab659d789 100644 --- a/components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx +++ b/components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx @@ -79,7 +79,7 @@ export const ConnectViaWallet = memo(function ConnectViaWallet( // Wrapper to init the wallet state and then provide the data to the UI const ConnectViaWalletStateWrapper = memo( function ConnectViaWalletStateWrapper({ address }: { address: string }) { - const { isInitializing, alreadyV3Db, onXmtp, signer } = + const { isInitializing, alreadyV3Db, signer } = useInitConnectViaWalletState({ address }); if (isInitializing) { @@ -95,7 +95,6 @@ const ConnectViaWalletStateWrapper = memo( @@ -112,7 +111,6 @@ const ConnectViaWalletUI = memo(function ConnectViaWalletUI(props: object) { loading, waitingForNextSignature, signer, - onXmtp, alreadyV3Db, signaturesDone, } = useConnectViaWalletStoreContext((state) => ({ @@ -120,7 +118,6 @@ const ConnectViaWalletUI = memo(function ConnectViaWalletUI(props: object) { loading: state.loading, waitingForNextSignature: state.waitingForNextSignature, signer: state.signer, - onXmtp: state.onXmtp, alreadyV3Db: state.alreadyV3Db, signaturesDone: state.numberOfSignaturesDone, })); @@ -156,23 +153,12 @@ const ConnectViaWalletUI = memo(function ConnectViaWalletUI(props: object) { let showValueProps = true; // On XMTP, needs V3 DB signature - if (onXmtp && !alreadyV3Db) { - title = `${translate("connectViaWallet.sign")} (${signaturesDone + 1}/2)`; + if (!alreadyV3Db) { + title = translate("connectViaWallet.sign"); subtitle = translate("connectViaWallet.firstSignature.explanation"); } // On XMTP, has V3 DB signature - else if (onXmtp && alreadyV3Db) { - title = translate("connectViaWallet.firstSignature.title"); - subtitle = translate("connectViaWallet.secondSignature.explanation"); - } - // Waiting for second signature - else if (waitingForNextSignature && !loading) { - title = translate("connectViaWallet.secondSignature.title"); - subtitle = translate("connectViaWallet.secondSignature.explanation"); - showValueProps = false; - } - // Not on XMTP, needs first signature - else { + else if (alreadyV3Db) { title = translate("connectViaWallet.firstSignature.title"); subtitle = translate("connectViaWallet.firstSignature.explanation"); } diff --git a/components/Onboarding/ConnectViaWallet/useConnectViaWalletInitXmtpClient.tsx b/components/Onboarding/ConnectViaWallet/useConnectViaWalletInitXmtpClient.tsx index 1265a848f..f4df8a0a2 100644 --- a/components/Onboarding/ConnectViaWallet/useConnectViaWalletInitXmtpClient.tsx +++ b/components/Onboarding/ConnectViaWallet/useConnectViaWalletInitXmtpClient.tsx @@ -52,7 +52,6 @@ export function useInitXmptClient() { try { const signer = connectViewWalletStore.getState().signer!; // We can assume that signer is set at this point const address = connectViewWalletStore.getState().address!; // We can assume that address is set at this point - const onXmtp = connectViewWalletStore.getState().onXmtp; const alreadyV3Db = connectViewWalletStore.getState().alreadyV3Db; const waitForClickSignature = async () => { diff --git a/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts b/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts index 3cc2a0ea7..6a2829322 100644 --- a/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts +++ b/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts @@ -10,10 +10,9 @@ import { } from "thirdweb/react"; import { useConnectViaWalletContext } from "./ConnectViaWallet.context"; -import { ensureError } from "../../../utils/error"; -import { thirdwebClient } from "../../../utils/thirdweb"; -import { getInboxId } from "../../../utils/xmtpRN/signIn"; -import { canMessageByAccount } from "@utils/xmtpRN/contacts"; +import { ensureError } from "@utils/error"; +import { thirdwebClient } from "@utils/thirdweb"; +import { getInboxId } from "@utils/xmtpRN/signIn"; /** * For now let's keep Thirdweb and the hooks because I haven't found a better way to do it. @@ -26,7 +25,6 @@ export function useInitConnectViaWalletState(args: { address: string }) { const { onErrorConnecting } = useConnectViaWalletContext(); const [isInitializing, setIsInitializing] = useState(true); - const [onXmtp, setOnXmtp] = useState(false); const [alreadyV3Db, setAlreadyV3Db] = useState(false); const [signer, setSigner] = useState(); @@ -84,22 +82,17 @@ export function useInitConnectViaWalletState(args: { address: string }) { setIsInitializing(true); - const [isOnNetwork, inboxId] = await Promise.all([ - canMessageByAccount({ account: address, peer: address }), - getInboxId(address), - ]); + const [inboxId] = await Promise.all([getInboxId(address)]); const v3Dbs = await getDatabaseFilesForInboxId(inboxId); const hasV3 = v3Dbs.filter((n) => n.name.endsWith(".db3")).length > 0; - setOnXmtp(isOnNetwork); + // setOnXmtp(isOnNetwork); setAlreadyV3Db(hasV3); setSigner(thirdwebSigner); logger.debug( - `[Connect Wallet] User connected wallet ${thirdwebWallet?.id} (${address}). ${ - isOnNetwork ? "Already" : "Not yet" - } on XMTP. V3 database ${hasV3 ? "already" : "not"} present` + `[Connect Wallet] User connected wallet ${thirdwebWallet?.id} (${address}). V3 database ${hasV3 ? "already" : "not"} present` ); } catch (error) { logger.error("[Connect Wallet] Error initializing wallet:", error); @@ -120,5 +113,5 @@ export function useInitConnectViaWalletState(args: { address: string }) { onErrorConnecting, ]); - return { isInitializing, onXmtp, alreadyV3Db, signer }; + return { isInitializing, alreadyV3Db, signer }; } diff --git a/i18n/translations/en.ts b/i18n/translations/en.ts index eec9b69ac..13f6b9ef8 100644 --- a/i18n/translations/en.ts +++ b/i18n/translations/en.ts @@ -80,11 +80,6 @@ export const en = { explanation: "The secure inbox you own.\nConverse is built on XMTP, an open-source secure messaging protocol.", }, - secondSignature: { - title: "Allow Converse", - explanation: - "Converse needs your permission\nto send and receive messages.\nYou can revoke this anytime.", - }, valueProps: { e2eEncryption: { title: "End-to-end encrypted with MLS", From cf94c83fa1777b5cf34c734833c692aa7b404563 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Wed, 4 Dec 2024 13:06:22 -0500 Subject: [PATCH 2/2] remove commented code and promise.all --- .../ConnectViaWallet/useInitConnectViaWalletState.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts b/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts index 6a2829322..16c700156 100644 --- a/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts +++ b/components/Onboarding/ConnectViaWallet/useInitConnectViaWalletState.ts @@ -82,12 +82,11 @@ export function useInitConnectViaWalletState(args: { address: string }) { setIsInitializing(true); - const [inboxId] = await Promise.all([getInboxId(address)]); + const inboxId = await getInboxId(address); const v3Dbs = await getDatabaseFilesForInboxId(inboxId); const hasV3 = v3Dbs.filter((n) => n.name.endsWith(".db3")).length > 0; - // setOnXmtp(isOnNetwork); setAlreadyV3Db(hasV3); setSigner(thirdwebSigner);