From e5d148dfd66693a43455d01f2dffac2c8711b698 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 24 Jun 2025 22:13:10 -0300 Subject: [PATCH 1/5] fix: use testnet for development --- apps/connect/.env.development | 12 ++++++------ apps/events/src/Boot.tsx | 2 +- apps/server/.env.example | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/connect/.env.development b/apps/connect/.env.development index df06992b..1a660658 100644 --- a/apps/connect/.env.development +++ b/apps/connect/.env.development @@ -1,7 +1,7 @@ VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="http://localhost:3030" -# VITE_HYPERGRAPH_CHAIN="geo-testnet" -# VITE_HYPERGRAPH_API_URL="https://hypergraph-v2-testnet.up.railway.app/graphql" -# VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz" -VITE_HYPERGRAPH_CHAIN="geogenesis" -VITE_HYPERGRAPH_API_URL="https://hypergraph-v2.up.railway.app/graphql" -VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-genesis-h0q2s21xx8.t.conduit.xyz" +VITE_HYPERGRAPH_CHAIN="geo-testnet" +VITE_HYPERGRAPH_API_URL="https://hypergraph-v2-testnet.up.railway.app/graphql" +VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz" +# VITE_HYPERGRAPH_CHAIN="geogenesis" +# VITE_HYPERGRAPH_API_URL="https://hypergraph-v2.up.railway.app/graphql" +# VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-genesis-h0q2s21xx8.t.conduit.xyz" diff --git a/apps/events/src/Boot.tsx b/apps/events/src/Boot.tsx index 37278af4..8c3229ba 100644 --- a/apps/events/src/Boot.tsx +++ b/apps/events/src/Boot.tsx @@ -19,7 +19,7 @@ export function Boot() { storage={localStorage} syncServerUri="http://localhost:3030" mapping={mapping} - chainId={80451} + chainId={19411} > diff --git a/apps/server/.env.example b/apps/server/.env.example index b7276318..0c0af8cf 100644 --- a/apps/server/.env.example +++ b/apps/server/.env.example @@ -1,4 +1,4 @@ DATABASE_URL="file:./dev.db" PRIVY_APP_SECRET="TODO" PRIVY_APP_ID="TODO" -HYPERGRAPH_CHAIN="geogenesis" +HYPERGRAPH_CHAIN="geo-testnet" From 8ab6d62ae32c5c0a217c6cf4ea720d32624979a6 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 24 Jun 2025 23:30:45 -0300 Subject: [PATCH 2/5] feat: use the Connect signaturePrivateKey as an additional owner in the smart account --- apps/connect/src/components/logout.tsx | 2 + apps/connect/src/routes/authenticate.tsx | 16 +++-- packages/hypergraph/src/connect/abis.ts | 19 ++++++ .../hypergraph/src/connect/auth-storage.ts | 9 +++ packages/hypergraph/src/connect/login.ts | 51 +++++++--------- .../hypergraph/src/connect/smart-account.ts | 58 +++++++++++++++++-- .../src/identity/prove-ownership.ts | 1 - 7 files changed, 113 insertions(+), 43 deletions(-) diff --git a/apps/connect/src/components/logout.tsx b/apps/connect/src/components/logout.tsx index fec38a3c..ee160eff 100644 --- a/apps/connect/src/components/logout.tsx +++ b/apps/connect/src/components/logout.tsx @@ -1,3 +1,4 @@ +import { Connect } from '@graphprotocol/hypergraph'; import { usePrivy } from '@privy-io/react-auth'; import { useRouter } from '@tanstack/react-router'; import { Loader2 } from 'lucide-react'; @@ -10,6 +11,7 @@ export function Logout() { const [isLoading, setIsLoading] = useState(false); const disconnectWallet = async () => { setIsLoading(true); + Connect.wipeAllAuthData(localStorage); await privyLogout(); router.navigate({ to: '/login', diff --git a/apps/connect/src/routes/authenticate.tsx b/apps/connect/src/routes/authenticate.tsx index 2afca5d4..fa5de3a4 100644 --- a/apps/connect/src/routes/authenticate.tsx +++ b/apps/connect/src/routes/authenticate.tsx @@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button'; import { usePrivateSpaces } from '@/hooks/use-private-spaces'; import { type PublicSpaceData, usePublicSpaces } from '@/hooks/use-public-spaces'; import { Connect, Identity, Key, type Messages, StoreConnect, Utils } from '@graphprotocol/hypergraph'; -import { GEOGENESIS, GEO_TESTNET, getSmartAccountWalletClient } from '@graphprotocol/hypergraph/connect/smart-account'; + import { useIdentityToken, usePrivy, useWallets } from '@privy-io/react-auth'; import { createFileRoute } from '@tanstack/react-router'; import { createStore } from '@xstate/store'; @@ -11,8 +11,9 @@ import { useSelector } from '@xstate/store/react'; import { Effect, Schema } from 'effect'; import { useEffect } from 'react'; import { createWalletClient, custom } from 'viem'; +import { privateKeyToAccount } from 'viem/accounts'; -const CHAIN = import.meta.env.VITE_HYPERGRAPH_CHAIN === 'geogenesis' ? GEOGENESIS : GEO_TESTNET; +const CHAIN = import.meta.env.VITE_HYPERGRAPH_CHAIN === 'geogenesis' ? Connect.GEOGENESIS : Connect.GEO_TESTNET; type AuthenticateSearch = { data: unknown; @@ -380,9 +381,11 @@ function AuthenticateComponent() { })) ?? []; console.log('spaces', spaces); + const localAccount = privateKeyToAccount(keys.signaturePrivateKey as `0x${string}`); + console.log('local account', localAccount.address); // TODO: add additional actions (must be passed from the app) const permissionId = await Connect.createSmartSession( - walletClient, + localAccount, accountAddress, newAppIdentity.addressPrivateKey, CHAIN, @@ -394,13 +397,14 @@ function AuthenticateComponent() { }, ); console.log('smart session created'); - const smartAccountClient = await getSmartAccountWalletClient({ - owner: walletClient, + const smartAccountClient = await Connect.getSmartAccountWalletClient({ + owner: localAccount, address: accountAddress, chain: CHAIN, rpcUrl: import.meta.env.VITE_HYPERGRAPH_RPC_URL, }); + console.log('encrypting app identity'); const { ciphertext, nonce } = await Connect.encryptAppIdentity( signer, newAppIdentity.address, @@ -408,8 +412,8 @@ function AuthenticateComponent() { permissionId, keys, ); + console.log('proving ownership'); const { accountProof, keyProof } = await Identity.proveIdentityOwnership( - walletClient, smartAccountClient, accountAddress, keys, diff --git a/packages/hypergraph/src/connect/abis.ts b/packages/hypergraph/src/connect/abis.ts index 4b4d5a76..b3b3015f 100644 --- a/packages/hypergraph/src/connect/abis.ts +++ b/packages/hypergraph/src/connect/abis.ts @@ -52,6 +52,25 @@ export const safeOwnerManagerAbi = [ stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'isOwner', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, ]; // We only use this for revokeEnableSignature to use as a noop when creating a smart session diff --git a/packages/hypergraph/src/connect/auth-storage.ts b/packages/hypergraph/src/connect/auth-storage.ts index 4bb78862..0f7296b1 100644 --- a/packages/hypergraph/src/connect/auth-storage.ts +++ b/packages/hypergraph/src/connect/auth-storage.ts @@ -65,3 +65,12 @@ export const storeAccountAddress = (storage: Storage, accountId: string) => { export const wipeAccountAddress = (storage: Storage) => { storage.removeItem(buildAccountAddressStorageKey()); }; + +export const wipeAllAuthData = (storage: Storage) => { + const accountAddress = loadAccountAddress(storage); + wipeAccountAddress(storage); + if (accountAddress) { + wipeKeys(storage, accountAddress); + wipeSyncServerSessionToken(storage, accountAddress); + } +}; diff --git a/packages/hypergraph/src/connect/login.ts b/packages/hypergraph/src/connect/login.ts index c613007e..7a4cb57e 100644 --- a/packages/hypergraph/src/connect/login.ts +++ b/packages/hypergraph/src/connect/login.ts @@ -1,14 +1,16 @@ import * as Schema from 'effect/Schema'; import type { SmartAccountClient } from 'permissionless'; import type { Address, Chain, Hex, WalletClient } from 'viem'; +import { privateKeyToAccount } from 'viem/accounts'; import { proveIdentityOwnership } from '../identity/prove-ownership.js'; import * as Messages from '../messages/index.js'; import { store } from '../store-connect.js'; -import { loadAccountAddress, storeAccountAddress, storeKeys, wipeAccountAddress } from './auth-storage.js'; +import { loadAccountAddress, storeAccountAddress, storeKeys } from './auth-storage.js'; import { createIdentityKeys } from './create-identity-keys.js'; import { decryptIdentity, encryptIdentity } from './identity-encryption.js'; import { type SmartAccountParams, + addSmartAccountOwner, getSmartAccountWalletClient, isSmartAccountDeployed, smartAccountNeedsUpdate, @@ -31,15 +33,23 @@ export async function signup( syncServerUri: string, storage: Storage, identityToken: string, + chain: Chain, + rpcUrl: string, ) { const keys = createIdentityKeys(); const { ciphertext, nonce } = await encryptIdentity(signer, keys); - const { accountProof, keyProof } = await proveIdentityOwnership( - walletClient, - smartAccountClient, - accountAddress, - keys, - ); + + const localAccount = privateKeyToAccount(keys.signaturePrivateKey as `0x${string}`); + // This will deploy the smart account if it's not deployed + await addSmartAccountOwner(smartAccountClient, localAccount.address, chain, rpcUrl); + const localSmartAccountClient = await getSmartAccountWalletClient({ + owner: localAccount, + address: accountAddress, + rpcUrl, + chain, + }); + + const { accountProof, keyProof } = await proveIdentityOwnership(localSmartAccountClient, accountAddress, keys); const req: Messages.RequestConnectCreateIdentity = { keyBox: { signer: await signer.getAddress(), accountAddress, ciphertext, nonce }, @@ -103,7 +113,7 @@ export async function restoreKeys( throw new Error(`Error fetching identity ${res.status}`); } -const getAndDeploySmartAccount = async (walletClient: WalletClient, rpcUrl: string, chain: Chain, storage: Storage) => { +const getAndUpdateSmartAccount = async (walletClient: WalletClient, rpcUrl: string, chain: Chain, storage: Storage) => { const accountAddressFromStorage = loadAccountAddress(storage) as Hex; const smartAccountParams: SmartAccountParams = { owner: walletClient, @@ -128,21 +138,6 @@ const getAndDeploySmartAccount = async (walletClient: WalletClient, rpcUrl: stri // Create the client again to ensure we have the 7579 config now return getSmartAccountWalletClient(smartAccountParams); } - if (!(await isSmartAccountDeployed(smartAccountWalletClient))) { - // TODO: remove this once we manage to get counterfactual signatures working - console.log('sending dummy userOp to deploy smart account'); - if (!walletClient.account) { - throw new Error('Wallet client account not found'); - } - const tx = await smartAccountWalletClient.sendUserOperation({ - calls: [{ to: walletClient.account.address, data: '0x' }], - account: smartAccountWalletClient.account, - }); - - console.log('tx', tx); - const receipt = await smartAccountWalletClient.waitForUserOperationReceipt({ hash: tx }); - console.log('receipt', receipt); - } return smartAccountWalletClient; }; @@ -163,13 +158,7 @@ export async function login({ rpcUrl: string; chain: Chain; }) { - let smartAccountWalletClient: SmartAccountClient; - try { - smartAccountWalletClient = await getAndDeploySmartAccount(walletClient, rpcUrl, chain, storage); - } catch (error) { - wipeAccountAddress(storage); - smartAccountWalletClient = await getAndDeploySmartAccount(walletClient, rpcUrl, chain, storage); - } + const smartAccountWalletClient = await getAndUpdateSmartAccount(walletClient, rpcUrl, chain, storage); if (!smartAccountWalletClient.account) { throw new Error('Smart account wallet client account not found'); } @@ -189,6 +178,8 @@ export async function login({ syncServerUri, storage, identityToken, + chain, + rpcUrl, ); } else { authData = await restoreKeys(signer, accountAddress, syncServerUri, storage, identityToken); diff --git a/packages/hypergraph/src/connect/smart-account.ts b/packages/hypergraph/src/connect/smart-account.ts index ea25265c..23e6b12e 100644 --- a/packages/hypergraph/src/connect/smart-account.ts +++ b/packages/hypergraph/src/connect/smart-account.ts @@ -36,6 +36,7 @@ import { ContractFunctionExecutionError, type Hex, type Narrow, + type PrivateKeyAccount, type SignableMessage, type WalletClient, createPublicClient, @@ -582,13 +583,61 @@ const getSpaceActions = (space: { address: Hex; type: 'personal' | 'public' }) = return actions; }; +export const addSmartAccountOwner = async ( + smartAccountClient: SmartAccountClient, + newOwner: Address, + chain: Chain, + rpcUrl: string, +) => { + if (!smartAccountClient.account) { + throw new Error('Invalid smart account'); + } + const publicClient = createPublicClient({ + transport: http(rpcUrl), + chain, + }); + if (await isSmartAccountDeployed(smartAccountClient)) { + const isOwner = await publicClient.readContract({ + abi: safeOwnerManagerAbi, + address: smartAccountClient.account.address, + functionName: 'isOwner', + args: [newOwner], + }); + if (isOwner) { + return; + } + } + + const tx = await smartAccountClient.sendUserOperation({ + calls: [ + { + to: smartAccountClient.account.address, + data: encodeFunctionData({ + abi: safeOwnerManagerAbi, + functionName: 'addOwnerWithThreshold', + args: [newOwner, BigInt(1)], + }), + value: BigInt(0), + }, + ], + account: smartAccountClient.account, + }); + const receipt = await smartAccountClient.waitForUserOperationReceipt({ + hash: tx, + }); + if (!receipt.success) { + throw new Error('Transaction to add smart account owner failed'); + } + return receipt; +}; + // This is the function that the Connect app uses to create a smart session and // enable it on the smart account. // It will prompt the user to sign the message to enable the session, and then // execute the transaction to enable the session. // It will return the permissionId that can be used to create a smart session client. export const createSmartSession = async ( - owner: WalletClient, + owner: WalletClient | PrivateKeyAccount, accountAddress: Hex, sessionPrivateKey: Hex, chain: Chain, @@ -624,9 +673,6 @@ export const createSmartSession = async ( if (!smartAccountClient.chain) { throw new Error('Invalid smart account chain'); } - if (!owner.account) { - throw new Error('Invalid wallet client'); - } const sessionKeyAccount = privateKeyToAccount(sessionPrivateKey); const transport = http(rpcUrl); @@ -751,9 +797,9 @@ export const createSmartSession = async ( console.log('signing session details'); // This will prompt the user to sign the message to enable the session - sessionDetails.enableSessionData.enableSession.permissionEnableSig = await owner.signMessage({ + sessionDetails.enableSessionData.enableSession.permissionEnableSig = await (owner as WalletClient).signMessage({ message: { raw: sessionDetails.permissionEnableHash }, - account: owner.account.address, + account: (owner as WalletClient).account?.address ?? (owner as PrivateKeyAccount).address, }); console.log('session details signed'); const smartSessions = getSmartSessionsValidator({}); diff --git a/packages/hypergraph/src/identity/prove-ownership.ts b/packages/hypergraph/src/identity/prove-ownership.ts index 847ff45b..f8df3623 100644 --- a/packages/hypergraph/src/identity/prove-ownership.ts +++ b/packages/hypergraph/src/identity/prove-ownership.ts @@ -20,7 +20,6 @@ export const accountProofDomain = { }; export const proveIdentityOwnership = async ( - walletClient: WalletClient, smartAccountClient: SmartAccountClient, accountAddress: string, keys: IdentityKeys, From 6aefe651237985eddca246211338585082d79492 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 24 Jun 2025 23:49:59 -0300 Subject: [PATCH 3/5] lint --- packages/hypergraph/src/identity/prove-ownership.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hypergraph/src/identity/prove-ownership.ts b/packages/hypergraph/src/identity/prove-ownership.ts index f8df3623..e986e640 100644 --- a/packages/hypergraph/src/identity/prove-ownership.ts +++ b/packages/hypergraph/src/identity/prove-ownership.ts @@ -1,4 +1,4 @@ -import { http, type Chain, type Hex, type WalletClient, createPublicClient, verifyMessage } from 'viem'; +import { http, type Chain, type Hex, createPublicClient, verifyMessage } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import type { SmartAccountClient } from 'permissionless'; From c2286f9e315769e5f5df691a653e332669342bea Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Wed, 25 Jun 2025 00:03:31 -0300 Subject: [PATCH 4/5] use sessionStorage for keys --- apps/connect/src/Boot.tsx | 7 ++-- apps/connect/src/components/logout.tsx | 2 +- apps/connect/src/routes/login.lazy.tsx | 14 ++++++- .../hypergraph/src/connect/auth-storage.ts | 10 ++--- packages/hypergraph/src/connect/login.ts | 38 ++++++++++++------- 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/apps/connect/src/Boot.tsx b/apps/connect/src/Boot.tsx index c9515fc7..b5da662d 100644 --- a/apps/connect/src/Boot.tsx +++ b/apps/connect/src/Boot.tsx @@ -18,7 +18,8 @@ declare module '@tanstack/react-router' { const queryClient = new QueryClient(); -const storage = localStorage; +const addressStorage = localStorage; +const keysStorage = sessionStorage; export function Boot() { // check if the user is already authenticated on initial render @@ -26,9 +27,9 @@ export function Boot() { // using a layout effect to avoid a re-render useLayoutEffect(() => { if (!initialRenderAuthCheckRef.current) { - const accountAddress = Connect.loadAccountAddress(storage); + const accountAddress = Connect.loadAccountAddress(addressStorage); if (accountAddress) { - const keys = Connect.loadKeys(storage, accountAddress); + const keys = Connect.loadKeys(keysStorage, accountAddress); if (keys) { // user is already authenticated, set state StoreConnect.store.send({ diff --git a/apps/connect/src/components/logout.tsx b/apps/connect/src/components/logout.tsx index ee160eff..f144d976 100644 --- a/apps/connect/src/components/logout.tsx +++ b/apps/connect/src/components/logout.tsx @@ -11,7 +11,7 @@ export function Logout() { const [isLoading, setIsLoading] = useState(false); const disconnectWallet = async () => { setIsLoading(true); - Connect.wipeAllAuthData(localStorage); + Connect.wipeAllAuthData(localStorage, sessionStorage); await privyLogout(); router.navigate({ to: '/login', diff --git a/apps/connect/src/routes/login.lazy.tsx b/apps/connect/src/routes/login.lazy.tsx index fa39c47b..a30aeb02 100644 --- a/apps/connect/src/routes/login.lazy.tsx +++ b/apps/connect/src/routes/login.lazy.tsx @@ -8,7 +8,8 @@ import { type WalletClient, createWalletClient, custom } from 'viem'; const CHAIN = import.meta.env.VITE_HYPERGRAPH_CHAIN === 'geogenesis' ? GEOGENESIS : GEO_TESTNET; const syncServerUri = import.meta.env.VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN; -const storage = localStorage; +const addressStorage = localStorage; +const keysStorage = sessionStorage; export const Route = createLazyFileRoute('/login')({ component: () => , @@ -52,7 +53,16 @@ function Login() { console.log(walletClient); console.log(rpcUrl); console.log(CHAIN); - await Connect.login({ walletClient, signer, syncServerUri, storage, identityToken, rpcUrl, chain: CHAIN }); + await Connect.login({ + walletClient, + signer, + syncServerUri, + addressStorage, + keysStorage, + identityToken, + rpcUrl, + chain: CHAIN, + }); }, [identityToken, signMessage], ); diff --git a/packages/hypergraph/src/connect/auth-storage.ts b/packages/hypergraph/src/connect/auth-storage.ts index 0f7296b1..706a3631 100644 --- a/packages/hypergraph/src/connect/auth-storage.ts +++ b/packages/hypergraph/src/connect/auth-storage.ts @@ -66,11 +66,11 @@ export const wipeAccountAddress = (storage: Storage) => { storage.removeItem(buildAccountAddressStorageKey()); }; -export const wipeAllAuthData = (storage: Storage) => { - const accountAddress = loadAccountAddress(storage); - wipeAccountAddress(storage); +export const wipeAllAuthData = (addressStorage: Storage, keysAndTokenStorage: Storage) => { + const accountAddress = loadAccountAddress(addressStorage); + wipeAccountAddress(addressStorage); if (accountAddress) { - wipeKeys(storage, accountAddress); - wipeSyncServerSessionToken(storage, accountAddress); + wipeKeys(keysAndTokenStorage, accountAddress); + wipeSyncServerSessionToken(keysAndTokenStorage, accountAddress); } }; diff --git a/packages/hypergraph/src/connect/login.ts b/packages/hypergraph/src/connect/login.ts index 7a4cb57e..4dc01328 100644 --- a/packages/hypergraph/src/connect/login.ts +++ b/packages/hypergraph/src/connect/login.ts @@ -31,7 +31,8 @@ export async function signup( smartAccountClient: SmartAccountClient, accountAddress: Address, syncServerUri: string, - storage: Storage, + addressStorage: Storage, + keysStorage: Storage, identityToken: string, chain: Chain, rpcUrl: string, @@ -74,8 +75,8 @@ export async function signup( if (!decoded.success) { throw new Error('Error creating identity'); } - storeKeys(storage, accountAddress, keys); - storeAccountAddress(storage, accountAddress); + storeKeys(keysStorage, accountAddress, keys); + storeAccountAddress(addressStorage, accountAddress); return { accountAddress, keys, @@ -86,7 +87,8 @@ export async function restoreKeys( signer: Signer, accountAddress: Address, syncServerUri: string, - storage: Storage, + addressStorage: Storage, + keysStorage: Storage, identityToken: string, ) { const res = await fetch(new URL('/connect/identity/encrypted', syncServerUri), { @@ -103,8 +105,8 @@ export async function restoreKeys( const { keyBox } = decoded; const { ciphertext, nonce } = keyBox; const keys = await decryptIdentity(signer, ciphertext, nonce); - storeKeys(storage, accountAddress, keys); - storeAccountAddress(storage, accountAddress); + storeKeys(keysStorage, accountAddress, keys); + storeAccountAddress(addressStorage, accountAddress); return { accountAddress, keys, @@ -113,8 +115,13 @@ export async function restoreKeys( throw new Error(`Error fetching identity ${res.status}`); } -const getAndUpdateSmartAccount = async (walletClient: WalletClient, rpcUrl: string, chain: Chain, storage: Storage) => { - const accountAddressFromStorage = loadAccountAddress(storage) as Hex; +const getAndUpdateSmartAccount = async ( + walletClient: WalletClient, + rpcUrl: string, + chain: Chain, + addressStorage: Storage, +) => { + const accountAddressFromStorage = loadAccountAddress(addressStorage) as Hex; const smartAccountParams: SmartAccountParams = { owner: walletClient, rpcUrl, @@ -145,7 +152,8 @@ export async function login({ walletClient, signer, syncServerUri, - storage, + addressStorage, + keysStorage, identityToken, rpcUrl, chain, @@ -153,17 +161,18 @@ export async function login({ walletClient: WalletClient; signer: Signer; syncServerUri: string; - storage: Storage; + addressStorage: Storage; + keysStorage: Storage; identityToken: string; rpcUrl: string; chain: Chain; }) { - const smartAccountWalletClient = await getAndUpdateSmartAccount(walletClient, rpcUrl, chain, storage); + const smartAccountWalletClient = await getAndUpdateSmartAccount(walletClient, rpcUrl, chain, addressStorage); if (!smartAccountWalletClient.account) { throw new Error('Smart account wallet client account not found'); } const accountAddress = smartAccountWalletClient.account.address; - // const keys = loadKeys(storage, accountAddress); + let authData: { accountAddress: Address; keys: IdentityKeys; @@ -176,13 +185,14 @@ export async function login({ smartAccountWalletClient, accountAddress, syncServerUri, - storage, + addressStorage, + keysStorage, identityToken, chain, rpcUrl, ); } else { - authData = await restoreKeys(signer, accountAddress, syncServerUri, storage, identityToken); + authData = await restoreKeys(signer, accountAddress, syncServerUri, addressStorage, keysStorage, identityToken); } store.send({ type: 'reset' }); store.send({ From abc46a1a6f169b2147fb25cd3a5b8296472948a3 Mon Sep 17 00:00:00 2001 From: Nik Graf Date: Fri, 27 Jun 2025 20:14:19 +0200 Subject: [PATCH 5/5] lint fix --- apps/server/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 3db21057..5744bcf4 100755 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -1,9 +1,9 @@ +import { parse } from 'node:url'; import { Connect, Identity, Inboxes, Messages, SpaceEvents, Utils } from '@graphprotocol/hypergraph'; 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 { parse } from 'node:url'; import WebSocket, { WebSocketServer } from 'ws'; import { addAppIdentityToSpaces } from './handlers/add-app-identity-to-spaces.js'; import { applySpaceEvent } from './handlers/applySpaceEvent.js';