Skip to content

Commit 607bc85

Browse files
committed
feat(separate react): pull in updates from main to auth
1 parent 033c8db commit 607bc85

File tree

3 files changed

+8
-27
lines changed

3 files changed

+8
-27
lines changed

apps/events/src/Boot.tsx

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

3-
import { Identity } from '@graphprotocol/hypergraph';
3+
import { Auth } from '@graphprotocol/hypergraph-react';
44
import { PrivyProvider } from '@privy-io/react-auth';
5+
56
import { routeTree } from './routeTree.gen';
67

78
// Create a new router instance
@@ -32,9 +33,9 @@ export function Boot() {
3233
},
3334
}}
3435
>
35-
<Identity.GraphLogin storage={localStorage}>
36+
<Auth.HypergraphAuthProvider storage={localStorage}>
3637
<RouterProvider router={router} />
37-
</Identity.GraphLogin>
38+
</Auth.HypergraphAuthProvider>
3839
</PrivyProvider>
3940
);
4041
}

packages/hypergraph-react/src/HypergraphAuthContext.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export function useHypergraphSessionToken() {
5858

5959
export type HypergraphAuthProviderProps = Readonly<{
6060
storage: Identity.Storage;
61-
signer: Identity.Signer | null;
6261
syncServerUri?: string;
6362
chainId?: number;
6463
children: ReactNode;
@@ -70,7 +69,6 @@ export type HypergraphAuthProviderProps = Readonly<{
7069
// (and store it in the sync server)
7170
export function HypergraphAuthProvider({
7271
storage,
73-
signer,
7472
syncServerUri = 'http://localhost:3030',
7573
chainId = 80451,
7674
children,

packages/hypergraph-react/test/HypergraphAuthContext.test.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import '@testing-library/jest-dom/vitest';
22
import { cleanup, renderHook } from '@testing-library/react';
33
// biome-ignore lint/style/useImportType: <explanation>
44
import React from 'react';
5-
import { type PrivateKeyAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
65
import { afterEach, describe, expect, it } from 'vitest';
76

8-
import type { Identity } from '@graphprotocol/hypergraph';
9-
107
import { HypergraphAuthProvider, useAuthenticated, useHypergraphAccountId } from '../src/HypergraphAuthContext.js';
118

129
afterEach(() => {
@@ -15,36 +12,21 @@ afterEach(() => {
1512

1613
const storageMockDict = {} as { [key: string]: string };
1714
const storageMock = {
18-
getItem: (key: string) => {
15+
getItem(key: string) {
1916
return storageMockDict[key] || null;
2017
},
21-
setItem: (key: string, value: string) => {
18+
setItem(key: string, value: string) {
2219
storageMockDict[key] = value;
2320
},
24-
removeItem: (key: string) => {
21+
removeItem(key: string) {
2522
delete storageMockDict[key];
2623
},
2724
};
28-
const accountSigner = (account: PrivateKeyAccount): Identity.Signer => {
29-
return {
30-
signMessage: async (message: string) => {
31-
return account.signMessage({ message });
32-
},
33-
getAddress: async () => {
34-
return account.address;
35-
},
36-
};
37-
};
3825

3926
describe('HypergraphAuthContext', () => {
4027
it('should render the HypergraphAuthProvider and be initially unauthenticetd', async () => {
41-
// generate a random private key to simulate a user wallet
42-
const account = privateKeyToAccount(generatePrivateKey());
43-
const signer = accountSigner(account);
4428
const wrapper = ({ children }: Readonly<{ children: React.ReactNode }>) => (
45-
<HypergraphAuthProvider storage={storageMock} signer={signer}>
46-
{children}
47-
</HypergraphAuthProvider>
29+
<HypergraphAuthProvider storage={storageMock}>{children}</HypergraphAuthProvider>
4830
);
4931

5032
const { result: authenticatedResult } = renderHook(() => useAuthenticated(), { wrapper });

0 commit comments

Comments
 (0)