Skip to content

Commit f62df01

Browse files
committed
Clean up
1 parent a0207e5 commit f62df01

File tree

13 files changed

+58
-64
lines changed

13 files changed

+58
-64
lines changed

components/Onboarding/ConnectViaWallet/ConnectViaWallet.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const LoadingState = memo(function LoadingState() {
198198
const { theme } = useAppTheme();
199199

200200
return (
201-
<Center style={{ paddingTop: theme.spacing["6xl"] }}>
201+
<Center style={{ paddingTop: theme.spacing["7xl"] }}>
202202
<ActivityIndicator />
203203
</Center>
204204
);

components/PictoTitleSubtitle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const ContainerComponent = memo(function ContainerComponent({
5151

5252
const PictoComponent = memo(function PictoComponent(props: IPictoProps) {
5353
const { theme } = useAppTheme();
54-
const { size = theme.spacing["4xl"], ...rest } = props;
54+
const { size = theme.spacing["5xl"], ...rest } = props;
5555
return <Picto size={size} style={{ height: size }} {...rest} />;
5656
});
5757

design-system/IconButton/IconButton.styles.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export const getIconButtonViewStyle =
4949
height: spacing.xxl,
5050
},
5151
xl: {
52-
width: 56,
53-
height: 56,
52+
width: spacing["4xl"],
53+
height: spacing["4xl"],
5454
},
5555
};
5656

@@ -181,8 +181,8 @@ export const getIconProps =
181181
}: IconButtonStyleProps) =>
182182
(
183183
theme: Theme // TODO: fix once we fixed IconProps
184-
) => // : Partial<IIconProps>
185-
{
184+
// : Partial<IIconProps>
185+
) => {
186186
const { colors, spacing } = theme;
187187

188188
const props: any =

features/conversation-list/conversation-list-item/conversation-list-item-swipeable/conversation-list-item-swipeable.styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { useAppTheme } from "@/theme/useAppTheme";
33
export function useConversationListItemSwipeableStyles() {
44
const { theme } = useAppTheme();
55
return {
6-
swipeThreshold: theme.spacing["5xl"],
6+
swipeThreshold: theme.spacing["6xl"],
77
};
88
}

features/onboarding/Privy/usePrivyConnection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export function usePrivyConnection(args: {
1717
const privyAccountId = usePrivyAuthStoreContext(
1818
(state) => state.privyAccountId
1919
);
20-
const privySigner = usePrivySigner(true);
20+
const privySigner = usePrivySigner({
21+
isOnboarding: true,
22+
});
2123
const privyAccessToken = usePrivyAccessToken();
2224
const creatingEmbeddedWallet = useRef(false);
2325

features/onboarding/Privy/usePrivySmartWalletConnection.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export function usePrivySmartWalletConnection(args: {
2323
const privyAccountId = usePrivyAuthStoreContext(
2424
(state) => state.privyAccountId
2525
);
26-
usePrivySigner(true);
26+
usePrivySigner({
27+
isOnboarding: true,
28+
});
2729
const privyAccessToken = usePrivyAccessToken();
2830
const creatingEmbeddedWallet = useRef(false);
2931
const initializingXmtp = useRef(false);
@@ -51,7 +53,14 @@ export function usePrivySmartWalletConnection(args: {
5153
embeddedWallet
5254
.create()
5355
// TODO: Handle better error
54-
.catch(ensureErrorHandler(onConnectionError));
56+
.catch((error) => {
57+
logger.error(
58+
"[Privy connection] Error creating embedded wallet",
59+
error
60+
);
61+
creatingEmbeddedWallet.current = false;
62+
ensureErrorHandler(onConnectionError)(error);
63+
});
5564
}
5665
}, [
5766
embeddedWallet,
@@ -93,6 +102,7 @@ export function usePrivySmartWalletConnection(args: {
93102
onStatusChange("Xmtp initialized");
94103
onConnectionDone();
95104
} catch (error) {
105+
logger.error("[Privy connection] Error initializing Xmtp", error);
96106
onConnectionError(ensureError(error));
97107
}
98108
};

navigation/OnboardingNavigator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { OnboardingEphemeraScreen } from "../features/onboarding/screens/Onboard
99
import { OnboardingNotificationsScreen } from "../features/onboarding/screens/onboarding-notifications-screen";
1010
import { OnboardingPrivateKeyScreen } from "../features/onboarding/screens/OnboardingPrivateKeyScreen";
1111
import { OnboardingPrivyScreen } from "../features/onboarding/screens/OnboardingPrivyScreen";
12-
import { OnboardingWelcomeScreen } from "@/features/onboarding/screens/onboarding-weclome-screen";
12+
import { OnboardingWelcomeScreen } from "@/features/onboarding/screens/onboarding-welcome-screen";
1313
import { OnboardingContactCardScreen } from "@/features/onboarding/screens/onboarding-contact-card-screen";
1414

1515
type OnboardingParamList = {

screens/Navigation/Navigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import WebviewPreviewNav, {
4444
} from "./WebviewPreviewNav";
4545
import { screenListeners, stackGroupScreenOptions } from "./navHelpers";
4646
import { ProfileNav, ProfileNavParams } from "@/features/profiles/profile.nav";
47-
import { OnboardingWelcomeScreen } from "@features/onboarding/screens/onboarding-weclome-screen";
47+
import { OnboardingWelcomeScreen } from "@/features/onboarding/screens/onboarding-welcome-screen";
4848
import { OnboardingContactCardScreen } from "@features/onboarding/screens/onboarding-contact-card-screen";
4949
import { NewAccountContactCardScreen } from "../NewAccount/new-account-contact-card-screen";
5050

theme/spacing.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export const spacing = {
1616
xl: 32,
1717
xxl: 40,
1818
"3xl": 48,
19-
"4xl": 64,
20-
"5xl": 80,
21-
"6xl": 96,
22-
"7xl": 128,
19+
"4xl": 56,
20+
"5xl": 64,
21+
"6xl": 80,
22+
"7xl": 96,
23+
"8xl": 128, // Not Used
2324

2425
message: {
2526
replyMessage: {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"compilerOptions": {
55
"module": "ESNext",
66
"strict": true,
7+
// https://docs.privy.io/guide/expo/setup/passkey#_1-set-up-your-build-configuration
78
"moduleResolution": "Bundler",
89
"experimentalDecorators": true,
910
"emitDecoratorMetadata": true,

utils/evm/privy.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ import {
1515

1616
import logger from "@utils/logger";
1717

18-
export const usePrivySigner = (isOnboarding: boolean = false) => {
18+
type IPrivySignerParams = {
19+
isOnboarding: boolean;
20+
};
21+
22+
export const usePrivySigner = (
23+
params: IPrivySignerParams = { isOnboarding: false }
24+
) => {
25+
const { isOnboarding = false } = params;
1926
const currentAccount = useCurrentAccount();
2027
const privyAccountId = useAccountsStore((s) => s.privyAccountId);
2128
const { isReady: privyReady, user: privyUser } = usePrivy();

utils/xmtpRN/signIn.ts

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from "@utils/fileSystem";
77
import { getDbEncryptionKey } from "@utils/keychain/helpers";
88
import logger from "@utils/logger";
9-
import { Client } from "@xmtp/react-native-sdk";
9+
import { Client, Signer as XmtpSigner } from "@xmtp/react-native-sdk";
1010
import { Signer } from "ethers";
1111
import { isClientInstallationValid } from "./client";
1212
import {
@@ -21,8 +21,8 @@ const env = config.xmtpEnv as "dev" | "production" | "local";
2121
export const getInboxId = (address: string) =>
2222
Client.getOrCreateInboxId(address, env);
2323

24-
export const createXmtpClientFromSigner = async (
25-
signer: Signer,
24+
const createXmtpClientFromXmtpSigner = async (
25+
signer: XmtpSigner,
2626
onInstallationRevoked: () => Promise<void>,
2727
preAuthenticateToInboxCallback?: () => Promise<void>
2828
) => {
@@ -41,7 +41,7 @@ export const createXmtpClientFromSigner = async (
4141

4242
logger.debug("Instantiating client from signer");
4343

44-
const client = await Client.create(ethersSignerToXmtpSigner(signer), {
44+
const client = await Client.create(signer, {
4545
...options,
4646
preAuthenticateToInboxCallback,
4747
});
@@ -71,51 +71,24 @@ export const createXmtpClientFromSigner = async (
7171
logger.debug("Dropped client databases");
7272
};
7373

74+
export const createXmtpClientFromSigner = async (
75+
signer: Signer,
76+
onInstallationRevoked: () => Promise<void>,
77+
preAuthenticateToInboxCallback?: () => Promise<void>
78+
) =>
79+
createXmtpClientFromXmtpSigner(
80+
ethersSignerToXmtpSigner(signer),
81+
onInstallationRevoked,
82+
preAuthenticateToInboxCallback
83+
);
84+
7485
export const createXmtpClientFromViemAccount = async (
7586
account: ViemAccount,
7687
onInstallationRevoked: () => Promise<void>,
7788
preAuthenticateToInboxCallback?: () => Promise<void>
78-
) => {
79-
const tempDirectory = await createTemporaryDirectory();
80-
const dbEncryptionKey = await getDbEncryptionKey();
81-
82-
const options = {
83-
env,
84-
enableV3: true,
85-
dbDirectory: tempDirectory,
86-
dbEncryptionKey,
87-
};
88-
const inboxId = await getInboxId(await account.address);
89-
await copyDatabasesToTemporaryDirectory(tempDirectory, inboxId);
90-
91-
logger.debug("Instantiating client from signer");
92-
93-
const client = await Client.create(viemAccountToXmtpSigner(account), {
94-
...options,
95-
preAuthenticateToInboxCallback,
96-
});
97-
98-
if (client.inboxId !== inboxId) {
99-
throw new Error("Inbox ids don't match");
100-
}
101-
102-
// In case we're logging with an existing libxmtp database, make sure
103-
// the installation has not already been revoked
104-
const installationValid = await isClientInstallationValid(client);
105-
if (!installationValid) {
106-
await client.dropLocalDatabaseConnection();
107-
await deleteLibXmtpDatabaseForInboxId(inboxId);
108-
onInstallationRevoked();
109-
return;
110-
}
111-
112-
logger.debug("Instantiated client from signer");
113-
// This Client is only be used to extract the key, we can disconnect
114-
// it to prevent locks happening during Onboarding
115-
await client.dropLocalDatabaseConnection();
116-
await moveTemporaryDatabasesToDatabaseDirectory(
117-
tempDirectory,
118-
client.inboxId
89+
) =>
90+
createXmtpClientFromXmtpSigner(
91+
viemAccountToXmtpSigner(account),
92+
onInstallationRevoked,
93+
preAuthenticateToInboxCallback
11994
);
120-
logger.debug("Dropped client databases");
121-
};

0 commit comments

Comments
 (0)