Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { useEffect, useState } from "react";
// import RPC from "./viemRPC";
import RPC from "./web3RPC";
import { OffNetworkRecovery, styles as RecoveryStyle } from "./recovery";
import { criticalResetAccount } from "./resetAccount";
// IMP END - Blockchain Calls

// IMP START - Dashboard Registration
Expand All @@ -44,7 +45,8 @@ const verifier = "w3a-firebase-demo";
const chainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0xaa36a7",
rpcTarget: "https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
rpcTarget:
"https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
// Avoid using public rpcTarget in production.
// Use services like Infura, Quicknode etc
displayName: "Ethereum Sepolia Testnet",
Expand Down Expand Up @@ -353,6 +355,14 @@ function App() {
const transactionReceipt = await RPC.sendTransaction(evmProvider);
uiConsole(transactionReceipt);
};

const resetAccount = async () => {
if (!coreKitInstance) {
throw new Error("coreKitInstance not found");
}
await criticalResetAccount(coreKitInstance);
uiConsole("account reset");
};
// IMP END - Blockchain Calls

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -416,6 +426,11 @@ function App() {
Generate Backup (Mnemonic)
</button>
</div>
<div>
<button onClick={resetAccount} className="card">
Reset Account (Critical)
</button>
</div>
</div>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Web3AuthMPCCoreKit } from "@web3auth/mpc-core-kit";
import BN from "bn.js";

export const criticalResetAccount = async (coreKitInstance: Web3AuthMPCCoreKit): Promise<void> => {
// This is a critical function that should only be used for testing purposes
// Resetting your account means clearing all the metadata associated with it from the metadata server
// The key details will be deleted from our server and you will not be able to recover your account
if (!coreKitInstance.state.postBoxKey) {
throw new Error("missing PostboxKey, Please try login with social account first");
}
await coreKitInstance.tKey.storageLayer.setMetadata({
privKey: new BN(coreKitInstance.state.postBoxKey, "hex"),
input: { message: "KEY_NOT_FOUND" },
});
};
Loading