Skip to content

Commit

Permalink
Merge pull request #39 from BoomDAO/staging
Browse files Browse the repository at this point in the history
latest stable with native nfid and feedback fixes
  • Loading branch information
h1teshtr1path1 committed Mar 6, 2024
2 parents 6bf392a + 5587bfd commit deb4dd7
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 152 deletions.
5 changes: 2 additions & 3 deletions src/game_launcher_frontend/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import DeployToken from "./pages/TokenDeployer/DeployToken";
import Token from "./pages/TokenDeployer/Token/Token";
import Game from "./pages/UploadGames/Games/Game";
import ManageWorlds from "./pages/WorldDeployer/ManageWorlds";
import Guilds from "./pages/GamingGuilds";
import GamingGuilds from "./pages/GamingGuilds";
import VerifyPage from "./pages/GamingGuilds/VerifyOtpPage";
import EmailPage from "./pages/GamingGuilds/EmailPage";
import VerifyOtpPage from "./pages/GamingGuilds/VerifyOtpPage";
Expand All @@ -32,7 +32,6 @@ import Wallet from "./pages/Wallet";
import Profile from "./pages/Profile";
import WalletTransfer from "./pages/Wallet/WalletTransfer";
import NftWalletTransfer from "./pages/Wallet/NftWalletTransfer";
import Nft from "./pages/Wallet/Nft";

function App() {
return (
Expand All @@ -45,7 +44,7 @@ function App() {
<Route path={navPaths.home} element={<Home />} />
<Route
path={`${navPaths.gaming_guilds}`}
element={<Guilds />}
element={<GamingGuilds />}
/>

<Route element={<ProtectedRoute />}>
Expand Down
4 changes: 2 additions & 2 deletions src/game_launcher_frontend/api/guilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const months = ["January", "February", "March", "April", "May", "June", "July",


function closeToast() {
setTimeout(() => {
clearTimeout(setTimeout(() => {
toast.remove();
}, 3000);
}, 3000));
};
function isTransferIcrc(data: { 'updateEntity': UpdateEntity } | { 'updateAction': UpdateAction } | { 'transferIcrc': TransferIcrc } | { 'mintNft': MintNft }): data is { transferIcrc: TransferIcrc; } {
return (data as { transferIcrc: TransferIcrc; }).transferIcrc !== undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/game_launcher_frontend/api/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const queryKeys = {
};

function closeToast() {
setTimeout(() => {
clearTimeout(setTimeout(() => {
toast.remove();
}, 3000);
}, 3000));
};
const getTotalCompletionOfQuest = (fields: Field[], quest: string) => {
for (let i = 0; i < fields.length; i += 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/game_launcher_frontend/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Footer = () => {
<a href="https://github.com/BoomDAO" target="_blank">
<img style={{ width: 24 }} src="/github.svg" alt="medium" className="cursor-pointer" />
</a>
<a href="https://discord.com/invite/fPVqZkQ6x2" target="_blank">
<a href="https://discord.com/invite/7p9UJv8zBG" target="_blank">
<img style={{ width: 24 }} src="/discord.svg" alt="medium" className="cursor-pointer" />
</a>
</div>
Expand Down
90 changes: 45 additions & 45 deletions src/game_launcher_frontend/context/authContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Identity } from "@dfinity/agent";
import { AuthClient } from "@dfinity/auth-client";
import { getAuthClient, nfidLogin, nfidEmbedLogin, getNfid } from "@/utils";
import { getAuthClient, nfidLogin } from "@/utils";
import { NFID } from "@nfid/embed";

interface Session {
Expand All @@ -22,77 +22,77 @@ export const AuthContextProvider = ({ children }: React.PropsWithChildren) => {
const [isLoading, setIsLoading] = React.useState(true);
const [session, setSession] = React.useState<Session | null>(null);

// const assignSession = (authClient: AuthClient) => {
// const identity = authClient.getIdentity();
// const address = identity.getPrincipal().toString();

// setSession({
// identity,
// address,
// });
// };
const assignSession = (nfid : NFID) => {
const identity = nfid.getIdentity();
const assignSession = (authClient: AuthClient) => {
const identity = authClient.getIdentity();
const address = identity.getPrincipal().toString();

setSession({
identity,
address
identity,
address,
});
};
// const assignSession = (nfid : NFID) => {
// const identity = nfid.getIdentity();
// const address = identity.getPrincipal().toString();

// setSession({
// identity,
// address
// });
// };

const checkAuth = async () => {
// try {
// const authClient = await getAuthClient();
// const isAuthenticated = await authClient.isAuthenticated();
// if (!isAuthenticated) return;
// assignSession(authClient);
// } catch (error) {
// console.log("err while checking auth", error);
// setSession(null);
// } finally {
// setIsLoading(false);
// }
try {
const nfid = await getNfid();
const isAuthenticated = nfid.isAuthenticated;
if(!isAuthenticated) return;
assignSession(nfid);
const authClient = await getAuthClient();
const isAuthenticated = await authClient.isAuthenticated();
if (!isAuthenticated) return;
assignSession(authClient);
} catch (error) {
console.log("err while checking auth", error);
setSession(null);
} finally {
setIsLoading(false);
};
}
// try {
// const nfid = await getNfid();
// const isAuthenticated = nfid.isAuthenticated;
// if(!isAuthenticated) return;
// assignSession(nfid);
// } catch (error) {
// console.log("err while checking auth", error);
// setSession(null);
// } finally {
// setIsLoading(false);
// };
};

React.useEffect(() => {
checkAuth();
}, []);

const logout = async () => {
// const authClient = await getAuthClient();
// await authClient.logout();
// setSession(null);
const nfid = await getNfid();
await nfid.logout();
const authClient = await getAuthClient();
await authClient.logout();
setSession(null);
// const nfid = await getNfid();
// await nfid.logout();
// setSession(null);
};

const login = async () => {
// const authClient = await getAuthClient();
// const isAuthenticated = await authClient.isAuthenticated();
// if (isAuthenticated) return assignSession(authClient);
const authClient = await getAuthClient();
const isAuthenticated = await authClient.isAuthenticated();
if (isAuthenticated) return assignSession(authClient);

// await nfidLogin(authClient!);
// window.location.reload();
// return checkAuth();
const nfid = await getNfid();
const isAuthenticated = nfid.isAuthenticated;
if(isAuthenticated) return assignSession(nfid);
await nfidEmbedLogin(nfid);
await nfidLogin(authClient!);
window.location.reload();
return checkAuth();
// const nfid = await getNfid();
// const isAuthenticated = nfid.isAuthenticated;
// if(isAuthenticated) return assignSession(nfid);
// await nfidEmbedLogin(nfid);
// window.location.reload();
// return checkAuth();
};

const value = {
Expand Down
Loading

0 comments on commit deb4dd7

Please sign in to comment.