Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/connect/src/routes/authenticate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function AuthenticateComponent() {

try {
const privyProvider = await embeddedWallet.getEthereumProvider();
const _walletClient = createWalletClient({
createWalletClient({
account: embeddedWallet.address as `0x${string}`,
chain: CHAIN,
transport: custom(privyProvider),
Expand Down
2 changes: 1 addition & 1 deletion apps/events/src/components/todos2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const Todos2 = () => {
due: new Date('2025-08-20'),
amount: 100,
point: [12.34, 56.78],
website: new URL('https://example.com'),
website: 'https://example.com',
});
setNewTodoName('');
}}
Expand Down
4 changes: 2 additions & 2 deletions apps/events/src/mapping.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Mapping } from '@graphprotocol/hypergraph';
import { Id } from '@graphprotocol/hypergraph';
import type { Mapping } from '@graphprotocol/hypergraph/mapping';

export const mapping: Mapping = {
export const mapping: Mapping.Mapping = {
User: {
typeIds: [Id('bffa181e-a333-495b-949c-57f2831d7eca')],
properties: {
Expand Down
40 changes: 20 additions & 20 deletions apps/events/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Route as rootRoute } from './routes/__root'
import { Route as AuthenticateSuccessImport } from './routes/authenticate-success'
import { Route as IndexImport } from './routes/index'
import { Route as SpaceSpaceIdImport } from './routes/space/$spaceId'
import { Route as FriendsAccountIdImport } from './routes/friends/$accountId'
import { Route as FriendsAccountAddressImport } from './routes/friends/$accountAddress'
import { Route as AccountInboxInboxIdImport } from './routes/account-inbox/$inboxId'
import { Route as SpaceSpaceIdIndexImport } from './routes/space/$spaceId/index'
import { Route as SpaceSpaceIdUsersImport } from './routes/space/$spaceId/users'
Expand Down Expand Up @@ -62,9 +62,9 @@ const SpaceSpaceIdRoute = SpaceSpaceIdImport.update({
getParentRoute: () => rootRoute,
} as any)

const FriendsAccountIdRoute = FriendsAccountIdImport.update({
id: '/friends/$accountId',
path: '/friends/$accountId',
const FriendsAccountAddressRoute = FriendsAccountAddressImport.update({
id: '/friends/$accountAddress',
path: '/friends/$accountAddress',
getParentRoute: () => rootRoute,
} as any)

Expand Down Expand Up @@ -150,11 +150,11 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AccountInboxInboxIdImport
parentRoute: typeof rootRoute
}
'/friends/$accountId': {
id: '/friends/$accountId'
path: '/friends/$accountId'
fullPath: '/friends/$accountId'
preLoaderRoute: typeof FriendsAccountIdImport
'/friends/$accountAddress': {
id: '/friends/$accountAddress'
path: '/friends/$accountAddress'
fullPath: '/friends/$accountAddress'
preLoaderRoute: typeof FriendsAccountAddressImport
parentRoute: typeof rootRoute
}
'/space/$spaceId': {
Expand Down Expand Up @@ -239,7 +239,7 @@ export interface FileRoutesByFullPath {
'/login': typeof LoginLazyRoute
'/playground': typeof PlaygroundLazyRoute
'/account-inbox/$inboxId': typeof AccountInboxInboxIdRoute
'/friends/$accountId': typeof FriendsAccountIdRoute
'/friends/$accountAddress': typeof FriendsAccountAddressRoute
'/space/$spaceId': typeof SpaceSpaceIdRouteWithChildren
'/space/$spaceId/chat': typeof SpaceSpaceIdChatRoute
'/space/$spaceId/events': typeof SpaceSpaceIdEventsRoute
Expand All @@ -255,7 +255,7 @@ export interface FileRoutesByTo {
'/login': typeof LoginLazyRoute
'/playground': typeof PlaygroundLazyRoute
'/account-inbox/$inboxId': typeof AccountInboxInboxIdRoute
'/friends/$accountId': typeof FriendsAccountIdRoute
'/friends/$accountAddress': typeof FriendsAccountAddressRoute
'/space/$spaceId/chat': typeof SpaceSpaceIdChatRoute
'/space/$spaceId/events': typeof SpaceSpaceIdEventsRoute
'/space/$spaceId/playground': typeof SpaceSpaceIdPlaygroundRoute
Expand All @@ -271,7 +271,7 @@ export interface FileRoutesById {
'/login': typeof LoginLazyRoute
'/playground': typeof PlaygroundLazyRoute
'/account-inbox/$inboxId': typeof AccountInboxInboxIdRoute
'/friends/$accountId': typeof FriendsAccountIdRoute
'/friends/$accountAddress': typeof FriendsAccountAddressRoute
'/space/$spaceId': typeof SpaceSpaceIdRouteWithChildren
'/space/$spaceId/chat': typeof SpaceSpaceIdChatRoute
'/space/$spaceId/events': typeof SpaceSpaceIdEventsRoute
Expand All @@ -289,7 +289,7 @@ export interface FileRouteTypes {
| '/login'
| '/playground'
| '/account-inbox/$inboxId'
| '/friends/$accountId'
| '/friends/$accountAddress'
| '/space/$spaceId'
| '/space/$spaceId/chat'
| '/space/$spaceId/events'
Expand All @@ -304,7 +304,7 @@ export interface FileRouteTypes {
| '/login'
| '/playground'
| '/account-inbox/$inboxId'
| '/friends/$accountId'
| '/friends/$accountAddress'
| '/space/$spaceId/chat'
| '/space/$spaceId/events'
| '/space/$spaceId/playground'
Expand All @@ -318,7 +318,7 @@ export interface FileRouteTypes {
| '/login'
| '/playground'
| '/account-inbox/$inboxId'
| '/friends/$accountId'
| '/friends/$accountAddress'
| '/space/$spaceId'
| '/space/$spaceId/chat'
| '/space/$spaceId/events'
Expand All @@ -335,7 +335,7 @@ export interface RootRouteChildren {
LoginLazyRoute: typeof LoginLazyRoute
PlaygroundLazyRoute: typeof PlaygroundLazyRoute
AccountInboxInboxIdRoute: typeof AccountInboxInboxIdRoute
FriendsAccountIdRoute: typeof FriendsAccountIdRoute
FriendsAccountAddressRoute: typeof FriendsAccountAddressRoute
SpaceSpaceIdRoute: typeof SpaceSpaceIdRouteWithChildren
}

Expand All @@ -345,7 +345,7 @@ const rootRouteChildren: RootRouteChildren = {
LoginLazyRoute: LoginLazyRoute,
PlaygroundLazyRoute: PlaygroundLazyRoute,
AccountInboxInboxIdRoute: AccountInboxInboxIdRoute,
FriendsAccountIdRoute: FriendsAccountIdRoute,
FriendsAccountAddressRoute: FriendsAccountAddressRoute,
SpaceSpaceIdRoute: SpaceSpaceIdRouteWithChildren,
}

Expand All @@ -364,7 +364,7 @@ export const routeTree = rootRoute
"/login",
"/playground",
"/account-inbox/$inboxId",
"/friends/$accountId",
"/friends/$accountAddress",
"/space/$spaceId"
]
},
Expand All @@ -383,8 +383,8 @@ export const routeTree = rootRoute
"/account-inbox/$inboxId": {
"filePath": "account-inbox/$inboxId.tsx"
},
"/friends/$accountId": {
"filePath": "friends/$accountId.tsx"
"/friends/$accountAddress": {
"filePath": "friends/$accountAddress.tsx"
},
"/space/$spaceId": {
"filePath": "space/$spaceId.tsx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { usePublicAccountInboxes } from '@graphprotocol/hypergraph-react';
import { createFileRoute } from '@tanstack/react-router';
import { InboxCard } from '../../components/InboxCard';

export const Route = createFileRoute('/friends/$accountId')({
export const Route = createFileRoute('/friends/$accountAddress')({
component: RouteComponent,
});

Expand Down
2 changes: 0 additions & 2 deletions apps/next-example/src/components/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { HypergraphAppProvider } from '@graphprotocol/hypergraph-react';

// recommended by https://docs.privy.io/basics/troubleshooting/react-frameworks#next-js
export default function Providers({ children }: { children: React.ReactNode }) {
const _storage = typeof window !== 'undefined' ? window.localStorage : (undefined as unknown as Storage);

return (
<HypergraphAppProvider
syncServerUri="http://localhost:3030"
Expand Down
10 changes: 6 additions & 4 deletions apps/next-example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"target": "ES2022",
"lib": ["dom", "dom.iterable", "esnext", "ES2022"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -20,8 +20,10 @@
],
"paths": {
"@/*": ["./src/*"],
// "@graphprotocol/hypergraph": ["../../packages/hypergraph/src"],
// "@graphprotocol/hypergraph-react": ["../../packages/hypergraph-react/src"]
"@graphprotocol/hypergraph": ["../../packages/hypergraph/src/index.js"],
"@graphprotocol/hypergraph/*": ["../../packages/hypergraph/src/*.js"],
"@graphprotocol/hypergraph-react": ["../../packages/hypergraph-react/src/index.js"],
"@graphprotocol/hypergraph-react/*": ["../../packages/hypergraph-react/src/*.js"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
Expand Down
4 changes: 2 additions & 2 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"@hpke/core": "^1.7.2",
"@noble/ciphers": "^1.3.0",
"@noble/hashes": "^1.8.0",
"@prisma/client": "^6.7.0",
"@prisma/client": "^6.14.0",
"@privy-io/server-auth": "^1.26.0",
"body-parser": "^2.2.0",
"cors": "^2.8.5",
"effect": "^3.17.6",
"express": "^5.1.0",
"prisma": "^6.7.0",
"prisma": "^6.14.0",
"siwe": "^3.0.0",
"viem": "^2.29.0",
"ws": "^8.18.2"
Expand Down
1 change: 0 additions & 1 deletion apps/server/src/handlers/create-app-identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type Params = {
address: string;
appId: string;
ciphertext: string;
nonce: string;
signaturePublicKey: string;
encryptionPublicKey: string;
accountProof: string;
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/handlers/createUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const createUpdate = async ({

while (!success && retries < maxRetries) {
try {
// @ts-expect-error - fix it
result = await prisma.$transaction(async (prisma) => {
const lastUpdate = await prisma.update.findFirst({
where: { spaceId },
Expand Down
7 changes: 3 additions & 4 deletions apps/server/src/handlers/getAppOrConnectIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ type Params =
spaceId?: string;
};

export type GetIdentityResult = {
export type GetAppOrConnectIdentityResult = {
accountAddress: string;
ciphertext: string;
nonce: string;
nonce?: string;
signaturePublicKey: string;
encryptionPublicKey: string;
accountProof: string;
keyProof: string;
appId: string | null;
};

export const getAppOrConnectIdentity = async (params: Params): Promise<GetIdentityResult> => {
export const getAppOrConnectIdentity = async (params: Params): Promise<GetAppOrConnectIdentityResult> => {
if (!('appId' in params)) {
const where: { address: string; connectSignaturePublicKey?: string } = { address: params.accountAddress };
if ('signaturePublicKey' in params) {
Expand Down Expand Up @@ -70,7 +70,6 @@ export const getAppOrConnectIdentity = async (params: Params): Promise<GetIdenti
return {
accountAddress: appIdentity.accountAddress,
ciphertext: appIdentity.ciphertext,
nonce: appIdentity.nonce,
signaturePublicKey: appIdentity.signaturePublicKey,
encryptionPublicKey: appIdentity.encryptionPublicKey,
accountProof: appIdentity.accountProof,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/handlers/getConnectIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Params =
connectSignaturePublicKey: string;
};

export type GetIdentityResult = {
export type GetConnectIdentityResult = {
accountAddress: string;
ciphertext: string;
nonce: string;
Expand All @@ -20,7 +20,7 @@ export type GetIdentityResult = {
keyProof: string;
};

export const getConnectIdentity = async (params: Params): Promise<GetIdentityResult> => {
export const getConnectIdentity = async (params: Params): Promise<GetConnectIdentityResult> => {
if (!params.accountAddress && !params.connectSignaturePublicKey) {
throw new Error('Either accountAddress or connectSignaturePublicKey must be provided');
}
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/handlers/listUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Params = {
export const listUpdates = async ({ spaceId, accountAddress, after }: Params) => {
// throw error if account is not a member of the space
await prisma.space.findUniqueOrThrow({
where: { id: spaceId, members: { some: { id: accountAddress } } },
where: { id: spaceId, members: { some: { address: accountAddress } } },
});

return await prisma.update.findMany({
Expand Down
29 changes: 5 additions & 24 deletions apps/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Connect, Identity, Inboxes, Messages, SpaceEvents, Utils } from '@graph
import { bytesToHex, randomBytes } from '@noble/hashes/utils.js';
import cors from 'cors';
import { Effect, Exit, Schema } from 'effect';
import express, { type Request, type Response } from 'express';
import express, { type Request } from 'express';
import WebSocket, { WebSocketServer } from 'ws';
import { addAppIdentityToSpaces } from './handlers/add-app-identity-to-spaces.js';
import { applySpaceEvent } from './handlers/applySpaceEvent.js';
Expand All @@ -17,8 +17,8 @@ import { createUpdate } from './handlers/createUpdate.js';
import { findAppIdentity } from './handlers/find-app-identity.js';
import { getAppIdentityBySessionToken } from './handlers/get-app-identity-by-session-token.js';
import { getAccountInbox } from './handlers/getAccountInbox.js';
import { getAppOrConnectIdentity } from './handlers/getAppOrConnectIdentity.js';
import { type GetIdentityResult, getConnectIdentity } from './handlers/getConnectIdentity.js';
import { type GetAppOrConnectIdentityResult, getAppOrConnectIdentity } from './handlers/getAppOrConnectIdentity.js';
import { getConnectIdentity } from './handlers/getConnectIdentity.js';
import { getLatestAccountInboxMessages } from './handlers/getLatestAccountInboxMessages.js';
import { getLatestSpaceInboxMessages } from './handlers/getLatestSpaceInboxMessages.js';
import { getSpace } from './handlers/getSpace.js';
Expand Down Expand Up @@ -46,25 +46,6 @@ const app = express();
const CHAIN = process.env.HYPERGRAPH_CHAIN === 'geogenesis' ? Connect.GEOGENESIS : Connect.GEO_TESTNET;
const RPC_URL = process.env.HYPERGRAPH_RPC_URL ?? CHAIN.rpcUrls.default.http[0];

type AuthenticatedRequest = Request & { accountAddress?: string };

async function _verifyAuth(req: AuthenticatedRequest, res: Response, next: (err?: Error) => void) {
const auth = req.headers.authorization;
if (!auth) {
res.status(401).send('Unauthorized');
return;
}
try {
const sessionToken = auth.split(' ')[1];
const { accountAddress } = await getAppIdentityBySessionToken({ sessionToken });
req.accountAddress = accountAddress;
next();
} catch (_error) {
res.status(401).send('Unauthorized');
return;
}
}

app.use(express.json({ limit: '2mb' }));

app.use(cors());
Expand Down Expand Up @@ -516,7 +497,7 @@ app.post('/spaces/:spaceId/inboxes/:inboxId/messages', async (req, res) => {
const authorPublicKey = Inboxes.recoverSpaceInboxMessageSigner(message, spaceId, inboxId);

// Check if this public key corresponds to a user's identity
let authorIdentity: GetIdentityResult;
let authorIdentity: GetAppOrConnectIdentityResult;
try {
authorIdentity = await getAppOrConnectIdentity({
accountAddress: message.authorAccountAddress,
Expand Down Expand Up @@ -617,7 +598,7 @@ app.post('/accounts/:accountAddress/inboxes/:inboxId/messages', async (req, res)
const authorPublicKey = Inboxes.recoverAccountInboxMessageSigner(message, accountAddress, inboxId);

// Check if this public key corresponds to a user's identity
let authorIdentity: GetIdentityResult;
let authorIdentity: GetAppOrConnectIdentityResult;
try {
authorIdentity = await getAppOrConnectIdentity({
accountAddress: message.authorAccountAddress,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { PrismaClient } from '../prisma/generated/client';
import { PrismaClient } from '../prisma/generated/client/client';

export const prisma = new PrismaClient();
6 changes: 5 additions & 1 deletion apps/template-nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2017",
"target": "ES2022",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand All @@ -19,6 +19,10 @@
}
],
"paths": {
"@graphprotocol/hypergraph": ["../../packages/hypergraph/src/index.js"],
"@graphprotocol/hypergraph/*": ["../../packages/hypergraph/src/*.js"],
"@graphprotocol/hypergraph-react": ["../../packages/hypergraph-react/src/index.js"],
"@graphprotocol/hypergraph-react/*": ["../../packages/hypergraph-react/src/*.js"],
"@/*": ["./*"]
}
},
Expand Down
10 changes: 9 additions & 1 deletion apps/template-vite-react/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@
"noUncheckedIndexedAccess": false,
"baseUrl": ".",
"paths": {
"@graphprotocol/hypergraph": ["../../packages/hypergraph/src/index.js"],
"@graphprotocol/hypergraph/*": ["../../packages/hypergraph/src/*.js"],
"@graphprotocol/hypergraph-react": ["../../packages/hypergraph-react/src/index.js"],
"@graphprotocol/hypergraph-react/*": ["../../packages/hypergraph-react/src/*.js"],
"@/*": ["./src/*"]
}
},
"include": ["src"]
"include": [
"src",
"../../packages/hypergraph/src/**/*",
"../../packages/hypergraph-react/src/**/*"
]
}
Loading
Loading