@@ -2,14 +2,35 @@ import * as React from "react";
22import { useNavigate } from "react-router-dom" ;
33import { Button } from "../../Button" ;
44import { Card } from "../../Card" ;
5+ import { useCoreKit } from "../../../composibles/useCoreKit" ;
6+ import { BN } from "bn.js" ;
7+ import { COREKIT_STATUS } from "@web3auth/mpc-core-kit" ;
58
69const RecoveryOptionsCard : React . FC = ( ) => {
710 const navigate = useNavigate ( ) ;
11+ const { coreKitInstance, setCoreKitStatus } = useCoreKit ( ) ;
812
913 const handleRecoveryOption = ( option : string ) => {
1014 navigate ( `/verify-${ option } ` ) ;
1115 } ;
1216
17+ const criticalReset = async ( ) => {
18+ if ( ! coreKitInstance ) {
19+ throw new Error ( "coreKitInstance is not set" ) ;
20+ }
21+ //@ts -ignore
22+ // if (selectedNetwork === WEB3AUTH_NETWORK.MAINNET) {
23+ // throw new Error("reset account is not recommended on mainnet");
24+ // }
25+ await coreKitInstance . tKey . storageLayer . setMetadata ( {
26+ privKey : new BN ( coreKitInstance . state . postBoxKey ! , "hex" ) ,
27+ input : { message : "KEY_NOT_FOUND" } ,
28+ } ) ;
29+ await coreKitInstance . logout ( ) ;
30+ setCoreKitStatus ( COREKIT_STATUS . NOT_INITIALIZED )
31+ navigate ( "/" ) ;
32+ }
33+
1334 return (
1435 < div className = "w-full flex flex-col justify-center h-[90%] items-center bg-app-gray-100 dark:bg-app-gray-900" >
1536 < Card className = "px-8 !h-[300px] flex justify-center items-start py-6 !rounded-2xl !shadow-modal !border-0 dark:!border-app-gray-800 dark:!shadow-dark" >
@@ -24,6 +45,9 @@ const RecoveryOptionsCard: React.FC = () => {
2445 < Button className = "w-full mb-4" variant = "primary" onClick = { ( ) => handleRecoveryOption ( "password" ) } >
2546 Password
2647 </ Button >
48+ < Button className = "w-full mb-4" variant = "primary" onClick = { ( ) => criticalReset ( ) } >
49+ Critical Reset
50+ </ Button >
2751 </ div >
2852 </ Card >
2953 </ div >
0 commit comments