Skip to content

Commit 226db70

Browse files
authored
Merge Auth and App provider (#126)
1 parent 0c517b7 commit 226db70

File tree

8 files changed

+402
-432
lines changed

8 files changed

+402
-432
lines changed

apps/events/src/Boot.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RouterProvider, createRouter } from '@tanstack/react-router';
22

3-
import { Auth } from '@graphprotocol/hypergraph-react';
3+
import { Hypergraph } from '@graphprotocol/hypergraph-react';
44
import { PrivyProvider } from '@privy-io/react-auth';
55

66
import { routeTree } from './routeTree.gen';
@@ -33,9 +33,9 @@ export function Boot() {
3333
},
3434
}}
3535
>
36-
<Auth.HypergraphAuthProvider storage={localStorage}>
36+
<Hypergraph.HypergraphAppProvider storage={localStorage}>
3737
<RouterProvider router={router} />
38-
</Auth.HypergraphAuthProvider>
38+
</Hypergraph.HypergraphAppProvider>
3939
</PrivyProvider>
4040
);
4141
}

apps/events/src/components/logout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Auth } from '@graphprotocol/hypergraph-react';
1+
import { Hypergraph } from '@graphprotocol/hypergraph-react';
22
import { usePrivy } from '@privy-io/react-auth';
33
import { useRouter } from '@tanstack/react-router';
44
import { Button } from './ui/button';
55

66
export function Logout() {
7-
const { logout: graphLogout } = Auth.useHypergraphAuth();
7+
const { logout: graphLogout } = Hypergraph.useHypergraphApp();
88
const { logout: privyLogout } = usePrivy();
99
const router = useRouter();
1010
const disconnectWallet = async () => {

apps/events/src/routes/__root.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { Logout } from '@/components/logout';
2-
import { Auth, Hypergraph } from '@graphprotocol/hypergraph-react';
2+
import { Hypergraph } from '@graphprotocol/hypergraph-react';
33
import { Link, Outlet, createRootRoute, useLayoutEffect, useRouter } from '@tanstack/react-router';
44
import { TanStackRouterDevtools } from '@tanstack/router-devtools';
55

66
export const Route = createRootRoute({
77
component: () => {
8-
const { authenticated, getIdentity, getSessionToken } = Auth.useHypergraphAuth();
8+
const { authenticated, getIdentity } = Hypergraph.useHypergraphApp();
99

1010
const graphIdentity = getIdentity();
11-
const loggedInSessionToken = getSessionToken();
1211

1312
const router = useRouter();
1413

@@ -44,20 +43,7 @@ export const Route = createRootRoute({
4443
</header>
4544
<hr />
4645

47-
{authenticated && graphIdentity && loggedInSessionToken ? (
48-
<Hypergraph.HypergraphAppProvider
49-
accountId={graphIdentity.accountId}
50-
sessionToken={loggedInSessionToken}
51-
encryptionPublicKey={graphIdentity.encryptionPublicKey}
52-
encryptionPrivateKey={graphIdentity.encryptionPrivateKey}
53-
signaturePrivateKey={graphIdentity.signaturePrivateKey}
54-
signaturePublicKey={graphIdentity.signaturePublicKey}
55-
>
56-
<Outlet />
57-
</Hypergraph.HypergraphAppProvider>
58-
) : (
59-
<Outlet />
60-
)}
46+
<Outlet />
6147

6248
<TanStackRouterDevtools />
6349

apps/events/src/routes/login.lazy.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Identity } from '@graphprotocol/hypergraph';
2-
import { Auth } from '@graphprotocol/hypergraph-react';
2+
import { Hypergraph } from '@graphprotocol/hypergraph-react';
33
import { usePrivy, useWallets } from '@privy-io/react-auth';
44
import { createLazyFileRoute, useRouter } from '@tanstack/react-router';
55
import { Loader2 } from 'lucide-react';
@@ -17,7 +17,7 @@ export const Route = createLazyFileRoute('/login')({
1717
function Login() {
1818
const { ready: privyReady, login: privyLogin, signMessage, authenticated: privyAuthenticated } = usePrivy();
1919
const { ready: walletsReady, wallets } = useWallets();
20-
const { setIdentityAndSessionToken, login: hypergraphLogin } = Auth.useHypergraphAuth();
20+
const { setIdentityAndSessionToken, login: hypergraphLogin } = Hypergraph.useHypergraphApp();
2121
const { navigate } = useRouter();
2222
const [hypergraphLoginStarted, setHypergraphLoginStarted] = useState(false);
2323

0 commit comments

Comments
 (0)