Skip to content

Commit 91362fd

Browse files
committed
feat: use expo-router
1 parent f418597 commit 91362fd

27 files changed

+2105
-666
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// App.tsx (in the project root, next to package.json, etc.)
2+
import { Bridge } from "@web3auth/react-native-mpc-core-kit";
3+
import { Slot } from "expo-router";
4+
5+
import { useBridgeReady } from "./hooks/useBridgeReady";
6+
export default function App() {
7+
const { setBridgeReady } = useBridgeReady();
8+
console.log("App.tsx");
9+
return (
10+
<>
11+
{/* Renders at the absolute top of the entire app */}
12+
<Bridge
13+
logLevel={"DEBUG"}
14+
resolveReady={(ready) => {
15+
setBridgeReady(ready);
16+
}}
17+
/>
18+
{/* The router content (equivalent to `_layout.tsx` root) */}
19+
<Slot />
20+
</>
21+
);
22+
}

mpc-core-kit-react-native/mpc-core-kit-expo-ed25519/app.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"expo": {
33
"name": "mpc-core-kit-expo-ed25519",
44
"slug": "mpc-core-kit-expo-ed25519",
5+
"entryPoint": "./App.tsx",
56
"version": "1.0.0",
67
"orientation": "portrait",
78
"icon": "./assets/images/icon.png",
@@ -14,14 +15,14 @@
1415
},
1516
"ios": {
1617
"supportsTablet": true,
17-
"bundleIdentifier": "com.expo.mpc-core-kit-expo-ed25519"
18+
"bundleIdentifier": "com.torus.reactnativeexpo"
1819
},
1920
"android": {
2021
"adaptiveIcon": {
2122
"foregroundImage": "./assets/images/adaptive-icon.png",
2223
"backgroundColor": "#ffffff"
2324
},
24-
"package": "com.expo.mpccorekitexpoed25519"
25+
"package": "com.torus.mpccorekitexpoed25519"
2526
},
2627
"web": {
2728
"bundler": "metro",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "../../global";
2+
3+
import { Slot } from "expo-router";
4+
5+
export default function Layout() {
6+
return <Slot />;
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ScrollView } from "react-native";
2+
import { EIP1193Provider } from "viem";
3+
import { sepolia } from "viem/chains";
4+
5+
import { ConsoleUI } from "@/components/mpc/ConsoleUI";
6+
import MPCAccoutFunction from "@/components/mpc/MpcAccountFunction";
7+
import { ViemView } from "@/components/mpc/ViemView";
8+
import { ZeroComponent } from "@/components/mpc/Zerosdk";
9+
import { useConsoleUI } from "@/hooks/useConsoleUI";
10+
import { useMPCCoreKitStore } from "@/hooks/useMPCCoreKit";
11+
12+
export default function Index() {
13+
const { evmProvider, coreKitInstance, setCoreKitStatus } = useMPCCoreKitStore();
14+
const { consoleUI, loading, uiConsole, setLoading } = useConsoleUI();
15+
return (
16+
<ScrollView>
17+
<ViemView signer={evmProvider as EIP1193Provider} chain={sepolia} uiConsole={uiConsole} />
18+
<ZeroComponent uiConsole={uiConsole} signer={evmProvider as EIP1193Provider} />
19+
20+
<MPCAccoutFunction uiConsole={uiConsole} setLoading={setLoading} coreKitInstance={coreKitInstance} setCoreKitStatus={setCoreKitStatus} />
21+
<ConsoleUI consoleUI={consoleUI} loading={loading} />
22+
</ScrollView>
23+
);
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ScrollView } from "react-native";
2+
3+
import { ConsoleUI } from "@/components/mpc/ConsoleUI";
4+
import MPCAccoutFunction from "@/components/mpc/MpcAccountFunction";
5+
import { SolanaView } from "@/components/mpc/SolanaView";
6+
import { useConsoleUI } from "@/hooks/useConsoleUI";
7+
import { useMPCCoreKitStore } from "@/hooks/useMPCCoreKit";
8+
9+
export default function Index() {
10+
const { coreKitEd25519Instance, setCoreKitEd25519Status } = useMPCCoreKitStore();
11+
const { consoleUI, loading, uiConsole, setLoading } = useConsoleUI();
12+
return (
13+
<ScrollView>
14+
<SolanaView coreKitInstance={coreKitEd25519Instance} uiConsole={uiConsole} />
15+
<MPCAccoutFunction
16+
uiConsole={uiConsole}
17+
setLoading={setLoading}
18+
coreKitInstance={coreKitEd25519Instance}
19+
setCoreKitStatus={setCoreKitEd25519Status}
20+
/>
21+
<ConsoleUI consoleUI={consoleUI} loading={loading} />
22+
</ScrollView>
23+
);
24+
}
Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,56 @@
1-
import { Stack } from "expo-router";
1+
import "../global";
2+
3+
import { Bridge, COREKIT_STATUS } from "@web3auth/react-native-mpc-core-kit";
4+
import { router, Stack, usePathname } from "expo-router";
5+
import { useEffect } from "react";
6+
7+
import { useMPCCoreKitStore } from "@/hooks/useMPCCoreKit";
28

39
export default function RootLayout() {
10+
const { coreKitStatus, coreKitInit, coreKitEd25519Status, coreKitEd25519Init } = useMPCCoreKitStore();
11+
const pathname = usePathname();
12+
console.log(pathname);
13+
14+
useEffect(() => {
15+
if (coreKitStatus === COREKIT_STATUS.NOT_INITIALIZED) {
16+
coreKitInit();
17+
}
18+
}, [coreKitStatus]);
19+
useEffect(() => {
20+
if (coreKitEd25519Status === COREKIT_STATUS.NOT_INITIALIZED) {
21+
coreKitEd25519Init();
22+
}
23+
}, [coreKitEd25519Status]);
24+
25+
useEffect(() => {
26+
console.log(coreKitStatus);
27+
if (coreKitStatus === COREKIT_STATUS.LOGGED_IN) {
28+
router.navigate({ pathname: "/(mpc-demo)/evm" });
29+
} else if (coreKitStatus === COREKIT_STATUS.REQUIRED_SHARE) {
30+
router.navigate({ pathname: "/recovery" });
31+
} else if (coreKitEd25519Status === COREKIT_STATUS.LOGGED_IN) {
32+
router.navigate({ pathname: "/solana" });
33+
} else if (coreKitEd25519Status === COREKIT_STATUS.REQUIRED_SHARE) {
34+
router.navigate({ pathname: "/recovery" });
35+
} else if (router.canDismiss()) {
36+
router.dismissAll();
37+
} else if (pathname !== "/") {
38+
router.replace({ pathname: "/" });
39+
}
40+
}, [coreKitStatus, coreKitEd25519Status]);
41+
442
return (
5-
<Stack>
6-
<Stack.Screen name="index" />
7-
</Stack>
43+
<>
44+
<Stack>
45+
<Stack.Screen
46+
name="(mpc-demo)"
47+
options={{
48+
title: "DEMO",
49+
}}
50+
/>
51+
<Stack.Screen name="index" />
52+
</Stack>
53+
<Bridge logLevel={"DEBUG"} />
54+
</>
855
);
956
}
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
import { Text, View } from "react-native";
2-
import '../global'
3-
import MPCDemo from "./mpcDemo";
1+
import { ScrollView } from "react-native";
2+
3+
import { LoginView } from "@/components/mpc/LoginView";
44

55
export default function Index() {
66
return (
7-
<View
8-
style={{
9-
flex: 1,
10-
justifyContent: "center",
11-
alignItems: "center",
12-
}}
13-
>
14-
<Text>Edit app/index.tsx to edit this screen test me here what happend.</Text>
15-
<MPCDemo />
16-
</View>
7+
<ScrollView>
8+
<LoginView />
9+
</ScrollView>
1710
);
1811
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ScrollView } from "react-native";
2+
3+
import { LoginView } from "@/components/mpc/LoginView";
4+
5+
export default function Index() {
6+
return (
7+
<ScrollView>
8+
<LoginView />
9+
</ScrollView>
10+
);
11+
}

0 commit comments

Comments
 (0)