Skip to content

Commit

Permalink
Upgraded to latest SFA version
Browse files Browse the repository at this point in the history
  • Loading branch information
ihsraham committed Aug 27, 2024
1 parent 684968f commit b71ea68
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 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 @@ -26,8 +26,8 @@
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^4.3.1",
"@web3auth/base": "^8.12.4",
"@web3auth/base-provider": "^8.4.0",
"@web3auth/single-factor-auth": "^7.4.0",
"@web3auth/base-provider": "^8.12.4",
"@web3auth/single-factor-auth": "^8.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"source-map-loader": "^4.0.1",
Expand Down
12 changes: 6 additions & 6 deletions single-factor-auth-web/sfa-web-ton-telegram-example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useState } from "react";

import { Web3Auth, decodeToken } from "@web3auth/single-factor-auth";
import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from "@web3auth/base";
import { CommonPrivateKeyProvider } from "@web3auth/base-provider";
Expand Down Expand Up @@ -37,6 +36,7 @@ const web3authSfa = new Web3Auth({
clientId, // Get your Client ID from Web3Auth Dashboard
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
usePnPKey: false, // Setting this to true returns the same key as PnP Web SDK, By default, this SDK returns CoreKitKey.
privateKeyProvider,
});

function App() {
Expand All @@ -48,13 +48,13 @@ function App() {
useEffect(() => {
const init = async () => {
try {
await web3authSfa.init(privateKeyProvider);
await web3authSfa.init();
if (web3authSfa.status === "connected") {
setLoggedIn(true);
setProvider(web3authSfa.provider);
}
} catch (error) {
console.error(error);
console.error("Error during Web3Auth initialization:", error);
}
};

Expand All @@ -68,7 +68,7 @@ function App() {
setIsLoggingIn(true);
const idToken = (await getIdTokenClaims())?.__raw;
if (!idToken) {
console.error("No id token found");
console.error("No ID token found");
return;
}
const { payload } = decodeToken(idToken);
Expand All @@ -82,7 +82,7 @@ function App() {
setProvider(web3authSfa.provider);
} catch (err) {
setIsLoggingIn(false);
console.error(err);
console.error("Error during Web3Auth connection:", err);
}
}
};
Expand All @@ -96,7 +96,7 @@ function App() {
return;
}
if (web3authSfa.status === "not_ready") {
await web3authSfa.init(privateKeyProvider);
await web3authSfa.init();
}
await loginWithRedirect();
};
Expand Down

0 comments on commit b71ea68

Please sign in to comment.