@@ -134,37 +134,13 @@ function AuthenticateComponent() {
134134 const accountAddress = useSelector ( StoreConnect . store , ( state ) => state . context . accountAddress ) ;
135135 const keys = useSelector ( StoreConnect . store , ( state ) => state . context . keys ) ;
136136
137- const { signMessage } = usePrivy ( ) ;
138137 const { wallets } = useWallets ( ) ;
139138 const embeddedWallet = wallets . find ( ( wallet ) => wallet . walletClientType === 'privy' ) || wallets [ 0 ] ;
140139
141140 const state = useSelector ( componentStore , ( state ) => state . context ) ;
142141
143142 const { isPending : privateSpacesPending , error : privateSpacesError , data : privateSpacesData } = usePrivateSpaces ( ) ;
144- const {
145- isPending : publicSpacesPending ,
146- error : publicSpacesError ,
147- data : publicSpacesData ,
148- } = usePublicSpaces ( import . meta. env . VITE_HYPERGRAPH_API_URL ) ;
149-
150- const selectedPrivateSpaces = new Set < string > ( ) ;
151- const selectedPublicSpaces = new Set < string > ( ) ;
152-
153- const handlePrivateSpaceToggle = ( spaceId : string , checked : boolean ) => {
154- if ( checked ) {
155- selectedPrivateSpaces . add ( spaceId ) ;
156- } else {
157- selectedPrivateSpaces . delete ( spaceId ) ;
158- }
159- } ;
160-
161- const handlePublicSpaceToggle = ( spaceId : string , checked : boolean ) => {
162- if ( checked ) {
163- selectedPublicSpaces . add ( spaceId ) ;
164- } else {
165- selectedPublicSpaces . delete ( spaceId ) ;
166- }
167- } ;
143+ const { data : publicSpacesData } = usePublicSpaces ( import . meta. env . VITE_HYPERGRAPH_API_URL ) ;
168144
169145 useEffect ( ( ) => {
170146 const run = async ( ) => {
@@ -351,21 +327,6 @@ function AuthenticateComponent() {
351327 transport : custom ( privyProvider ) ,
352328 } ) ;
353329
354- const signer : Identity . Signer = {
355- getAddress : async ( ) => {
356- const [ address ] = await walletClient . getAddresses ( ) ;
357- return address ;
358- } ,
359- signMessage : async ( message : string ) => {
360- if ( embeddedWallet . walletClientType === 'privy' ) {
361- const { signature } = await signMessage ( { message } ) ;
362- return signature ;
363- }
364- const [ address ] = await walletClient . getAddresses ( ) ;
365- return await walletClient . signMessage ( { account : address , message } ) ;
366- } ,
367- } ;
368-
369330 const newAppIdentity = Connect . createAppIdentity ( ) ;
370331
371332 console . log ( 'creating smart session' ) ;
@@ -406,13 +367,7 @@ function AuthenticateComponent() {
406367 } ) ;
407368
408369 console . log ( 'encrypting app identity' ) ;
409- const { ciphertext, nonce } = await Connect . encryptAppIdentity (
410- signer ,
411- newAppIdentity . address ,
412- newAppIdentity . addressPrivateKey ,
413- permissionId ,
414- keys ,
415- ) ;
370+ const { ciphertext } = await Connect . encryptAppIdentity ( { ...newAppIdentity , permissionId } , keys ) ;
416371 console . log ( 'proving ownership' ) ;
417372 const { accountProof, keyProof } = await Identity . proveIdentityOwnership (
418373 smartAccountClient ,
@@ -427,7 +382,6 @@ function AuthenticateComponent() {
427382 signaturePublicKey : newAppIdentity . signaturePublicKey ,
428383 encryptionPublicKey : newAppIdentity . encryptionPublicKey ,
429384 ciphertext,
430- nonce,
431385 accountProof,
432386 keyProof,
433387 } ;
@@ -468,48 +422,16 @@ function AuthenticateComponent() {
468422 } ;
469423
470424 const decryptAppIdentityAndRedirect = async ( ) => {
471- if ( ! state . appIdentityResponse ) {
425+ if ( ! state . appIdentityResponse || ! keys ) {
472426 return ;
473427 }
474428
475- const privyProvider = await embeddedWallet . getEthereumProvider ( ) ;
476- const walletClient = createWalletClient ( {
477- account : embeddedWallet . address as `0x${string } `,
478- chain : CHAIN ,
479- transport : custom ( privyProvider ) ,
480- } ) ;
481-
482- const signer : Identity . Signer = {
483- getAddress : async ( ) => {
484- const [ address ] = await walletClient . getAddresses ( ) ;
485- return address ;
486- } ,
487- signMessage : async ( message : string ) => {
488- if ( embeddedWallet . walletClientType === 'privy' ) {
489- const { signature } = await signMessage ( { message } ) ;
490- return signature ;
491- }
492- const [ address ] = await walletClient . getAddresses ( ) ;
493- return await walletClient . signMessage ( { account : address , message } ) ;
494- } ,
495- } ;
496-
497- const decryptedIdentity = await Connect . decryptAppIdentity (
498- signer ,
499- state . appIdentityResponse . ciphertext ,
500- state . appIdentityResponse . nonce ,
501- ) ;
429+ const decryptedIdentity = await Connect . decryptAppIdentity ( state . appIdentityResponse . ciphertext , keys ) ;
502430 await encryptSpacesAndRedirect ( {
503431 accountAddress : state . appIdentityResponse . accountAddress ,
504432 appIdentity : {
505- address : decryptedIdentity . address ,
506- addressPrivateKey : decryptedIdentity . addressPrivateKey ,
433+ ...decryptedIdentity ,
507434 accountAddress : state . appIdentityResponse . accountAddress ,
508- permissionId : decryptedIdentity . permissionId ,
509- encryptionPrivateKey : decryptedIdentity . encryptionPrivateKey ,
510- signaturePrivateKey : decryptedIdentity . signaturePrivateKey ,
511- encryptionPublicKey : decryptedIdentity . encryptionPublicKey ,
512- signaturePublicKey : decryptedIdentity . signaturePublicKey ,
513435 sessionToken : state . appIdentityResponse . sessionToken ,
514436 sessionTokenExpires : new Date ( state . appIdentityResponse . sessionTokenExpires ) ,
515437 } ,
0 commit comments