diff --git a/apps/connect/.env.development b/apps/connect/.env.development index 5f7f438b..df06992b 100644 --- a/apps/connect/.env.development +++ b/apps/connect/.env.development @@ -1,4 +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" diff --git a/apps/connect/src/routes/__root.tsx b/apps/connect/src/routes/__root.tsx index 175f1624..7d04ed6e 100644 --- a/apps/connect/src/routes/__root.tsx +++ b/apps/connect/src/routes/__root.tsx @@ -1,10 +1,13 @@ import { Logout } from '@/components/logout'; +import { StoreConnect } from '@graphprotocol/hypergraph'; import { usePrivy } from '@privy-io/react-auth'; import { Link, Outlet, createRootRoute, useLayoutEffect, useRouter } from '@tanstack/react-router'; import { TanStackRouterDevtools } from '@tanstack/router-devtools'; +import { useSelector } from '@xstate/store/react'; export const Route = createRootRoute({ component: () => { + const accountAddress = useSelector(StoreConnect.store, (state) => state.context.accountAddress); const { authenticated, ready } = usePrivy(); const router = useRouter(); @@ -13,7 +16,7 @@ export const Route = createRootRoute({ return; } - if (ready && !authenticated) { + if (ready && (!authenticated || !accountAddress)) { if (router.state.location.href.startsWith('/authenticate')) { localStorage.setItem('geo-connect-authenticate-redirect', router.state.location.href); } @@ -21,7 +24,7 @@ export const Route = createRootRoute({ to: '/login', }); } - }, [authenticated, ready]); + }, [authenticated, ready, accountAddress]); return ( <> diff --git a/apps/connect/src/routes/authenticate.tsx b/apps/connect/src/routes/authenticate.tsx index f50016ab..2afca5d4 100644 --- a/apps/connect/src/routes/authenticate.tsx +++ b/apps/connect/src/routes/authenticate.tsx @@ -396,6 +396,7 @@ function AuthenticateComponent() { console.log('smart session created'); const smartAccountClient = await getSmartAccountWalletClient({ owner: walletClient, + address: accountAddress, chain: CHAIN, rpcUrl: import.meta.env.VITE_HYPERGRAPH_RPC_URL, }); diff --git a/apps/connect/src/routes/login.lazy.tsx b/apps/connect/src/routes/login.lazy.tsx index 8c955777..fa39c47b 100644 --- a/apps/connect/src/routes/login.lazy.tsx +++ b/apps/connect/src/routes/login.lazy.tsx @@ -23,6 +23,7 @@ function Login() { const hypergraphLogin = useCallback( async (walletClient: WalletClient, embeddedWallet: ConnectedWallet) => { + console.log('hypergraphLogin'); if (!identityToken) { return; } @@ -57,12 +58,14 @@ function Login() { ); useEffect(() => { + console.log('useEffect in login.lazy.tsx'); if ( !hypergraphLoginStarted && // avoid re-running the effect to often privyAuthenticated && // privy must be authenticated to run it walletsReady && // wallets must be ready to run it wallets.length > 0 // wallets must have at least one wallet to run it ) { + console.log('running login effect'); setHypergraphLoginStarted(true); (async () => { try { diff --git a/apps/events/src/Boot.tsx b/apps/events/src/Boot.tsx index 0dc57d91..37278af4 100644 --- a/apps/events/src/Boot.tsx +++ b/apps/events/src/Boot.tsx @@ -15,7 +15,12 @@ declare module '@tanstack/react-router' { export function Boot() { return ( - + ); diff --git a/apps/events/src/components/create-events.tsx b/apps/events/src/components/create-events.tsx index 20484ae9..408aa2ce 100644 --- a/apps/events/src/components/create-events.tsx +++ b/apps/events/src/components/create-events.tsx @@ -1,12 +1,12 @@ -import { getSmartAccountWalletClient } from '@/lib/smart-account'; -import { type GeoSmartAccount, Graph, type Op } from '@graphprotocol/grc-20'; -import { publishOps } from '@graphprotocol/hypergraph-react'; +import { Graph, type Op } from '@graphprotocol/grc-20'; +import type { Connect } from '@graphprotocol/hypergraph'; +import { publishOps, useHypergraphApp } from '@graphprotocol/hypergraph-react'; import { Button } from './ui/button'; const createEvents = async ({ - smartAccountWalletClient, + smartSessionClient, space, -}: { smartAccountWalletClient: GeoSmartAccount; space: string }) => { +}: { smartSessionClient: Connect.SmartSessionClient; space: string }) => { try { const ops: Array = []; @@ -46,7 +46,7 @@ const createEvents = async ({ }); ops.push(...createCompanyTypeOps); - const { id: eventTypeId, ops: createEventTypeOps } = Graph.createEntity({ + const { ops: createEventTypeOps } = Graph.createEntity({ name: 'My Test Event', types: ['6b8dbe76-389f-4bde-acdd-db9d5e387882'], relations: { @@ -57,10 +57,9 @@ const createEvents = async ({ const result = await publishOps({ ops, - walletClient: smartAccountWalletClient, + walletClient: smartSessionClient, space, name: 'Create Job Offers, Companies and Events', - network: 'TESTNET', }); console.log('result', result); alert('Events created'); @@ -70,17 +69,17 @@ const createEvents = async ({ }; export const CreateEvents = ({ space }: { space: string }) => { + const { getSmartSessionClient } = useHypergraphApp(); return (