Skip to content

Commit

Permalink
fix: update with init
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Dec 18, 2024
1 parent 01a0168 commit 3dccfc3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 38 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"dependencies": {
"@ethereumjs/util": "^9.1.0",
"@react-oauth/google": "^0.12.1",
"@tkey/common-types": "^15.0.2",
"@toruslabs/tss-dkls-lib": "^4.0.0",
"@toruslabs/tss-frost-lib": "^1.0.0",
"@tkey/common-types": "15.2.1-alpha.0",

"@toruslabs/tss-dkls-lib": "^5.0.0-alpha.0",
"@toruslabs/tss-frost-lib": "^2.0.0-alpha.0",
"@toruslabs/tss-frost-lib-bip340": "^0.1.0-alpha.0",
"@types/node": "^18.11.18",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ if (typeof window !== "undefined") {


// Setup provider for EVM Chain
// evmProvider = new EthereumSigningProvider({ config: { chainConfig } });
// evmProvider.setupProvider(makeEthereumSigner(coreKitInstance));
evmProvider = new EthereumSigningProvider({ config: { chainConfig } });
evmProvider.setupProvider(makeEthereumSigner(coreKitInstance));
}
// IMP END - SDK Initialization

Expand Down Expand Up @@ -124,15 +124,19 @@ function App() {
await coreKitInstance.init();
// IMP END - SDK Initialization

if (coreKitInstance.status === COREKIT_STATUS.LOGGED_IN) {
if (coreKitInstance.status !== COREKIT_STATUS.NOT_INITIALIZED) {
const authenticatorService = new AuthenticatorService({
backendUrl : "http://localhost:3021",
remoteSignerInstance: coreKitInstance,
storage: window.localStorage,
})
await authenticatorService.init();
const smsService = new SmsService({
backendUrl : "http://localhost:3021",
remoteSignerInstance: coreKitInstance,
storage: window.localStorage,
})
await smsService.init();
setAuthenticatorService(authenticatorService)
setSmsService(smsService)
}
Expand Down Expand Up @@ -191,11 +195,16 @@ function App() {
const authenticatorService = new AuthenticatorService({
backendUrl : "http://localhost:3021",
remoteSignerInstance: coreKitInstance,
storage: window.localStorage,
})
await authenticatorService.init();

const smsService = new SmsService({
backendUrl : "http://localhost:3021",
remoteSignerInstance: coreKitInstance,
storage: window.localStorage,
})
await smsService.init();
setAuthenticatorService(authenticatorService)
setSmsService(smsService)
setCoreKitStatus(coreKitInstance.status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import {QRCodeSVG} from "qrcode.react";
import { COREKIT_STATUS, generateFactorKey, Web3AuthMPCCoreKit } from "@web3auth/mpc-core-kit";
import { AuthenticatorService, getFactorDetailsAndDescriptions } from "@web3auth/mpc-remote-signer-plugin";




export const RemoteSignerFeature = (params:{coreKitInstance: Web3AuthMPCCoreKit, authenticatorService?: AuthenticatorService<Web3AuthMPCCoreKit>}) => {
const {coreKitInstance, authenticatorService} = params;
const [showQrCode, setShowQrCode] = useState(false);
Expand All @@ -26,11 +23,11 @@ export const RemoteSignerFeature = (params:{coreKitInstance: Web3AuthMPCCoreKit,
setShowQrCode(true);
};

const removeAuthenticator = async () => {
const removeAuthenticator = async (force: boolean = false) => {
if (!coreKitInstance || !authenticatorService) {
throw new Error("coreKitInstance not found");
}
await authenticatorService.unregisterFactor();
await authenticatorService.unregisterFactor(force);
}

const verifyRegistration = async ( code : string) => {
Expand Down Expand Up @@ -60,9 +57,13 @@ export const RemoteSignerFeature = (params:{coreKitInstance: Web3AuthMPCCoreKit,
Register Authenticator
</button>
<input value={otpValue} onChange={(e) => setOtpValue(e.target.value)}/>
<button onClick={removeAuthenticator} className="card">
<button onClick={()=>removeAuthenticator(false)} className="card">
Delete Authenticator
</button>

<button onClick={()=>removeAuthenticator(true)} className="card">
Force Delete Authenticator
</button>
</div>
}

Expand Down

0 comments on commit 3dccfc3

Please sign in to comment.