|  | 
| 229 | 229 |       const testRequest = await requestNetwork?.fromRequestId(requestId); | 
| 230 | 230 |       const data = testRequest?.getData(); | 
| 231 | 231 | 
 | 
| 232 |  | -      // Check if the request has encrypted data | 
|  | 232 | +      // Check both extensions and transactions for encrypted data | 
| 233 | 233 |       const hasEncryptedData = data?.extensionsData?.some( | 
| 234 | 234 |         (ext: any) => ext.value?.encryptedData | 
| 235 | 235 |       ); | 
| 236 |  | -
 | 
| 237 |  | -      // Also check transactions for encryption | 
| 238 | 236 |       const hasEncryptedTransactions = data?.transactions?.some( | 
| 239 | 237 |         (tx: any) => tx.transaction?.encryptedData | 
| 240 | 238 |       ); | 
|  | 
| 245 | 243 |       if (String(error).includes("Decryption is not available")) { | 
| 246 | 244 |         return true; | 
| 247 | 245 |       } | 
|  | 246 | +      // For other errors, assume not encrypted | 
| 248 | 247 |       console.log("Error checking encryption status:", error); | 
| 249 | 248 |       return false; | 
| 250 | 249 |     } | 
|  | 
| 478 | 477 |       localStorage.removeItem("lit-wallet-sig"); | 
| 479 | 478 |     } | 
| 480 | 479 | 
 | 
|  | 480 | +    // Only attempt decryption setup if needed | 
|  | 481 | +    if (isDecryptionEnabled && requestId) { | 
|  | 482 | +      const isEncrypted = await isRequestEncrypted(requestId); | 
|  | 483 | +      if (isEncrypted) { | 
|  | 484 | +        await ensureDecryption(); | 
|  | 485 | +      } else { | 
|  | 486 | +        // For non-encrypted requests, just disable decryption | 
|  | 487 | +        cipherProvider?.enableDecryption(false); | 
|  | 488 | +      } | 
|  | 489 | +    } | 
|  | 490 | +
 | 
| 481 | 491 |     if (requestId && requestNetwork) { | 
| 482 | 492 |       await getOneRequest(requestId); | 
| 483 | 493 |     } | 
|  | 
| 508 | 518 |       handleWalletDisconnection(); | 
| 509 | 519 | 
 | 
| 510 | 520 |       // Initialize new wallet state | 
| 511 |  | -      await handleWalletConnection(); | 
|  | 521 | +      account = getAccount(wagmiConfig); | 
|  | 522 | +
 | 
|  | 523 | +      // Only attempt decryption setup if the request is encrypted | 
|  | 524 | +      if (isDecryptionEnabled && requestId) { | 
|  | 525 | +        const isEncrypted = await isRequestEncrypted(requestId); | 
|  | 526 | +        if (isEncrypted) { | 
|  | 527 | +          await ensureDecryption(); | 
|  | 528 | +        } else { | 
|  | 529 | +          // For non-encrypted requests, just disable decryption | 
|  | 530 | +          cipherProvider?.enableDecryption(false); | 
|  | 531 | +        } | 
|  | 532 | +      } | 
|  | 533 | +
 | 
|  | 534 | +      if (requestId && requestNetwork) { | 
|  | 535 | +        await getOneRequest(requestId); | 
|  | 536 | +      } | 
| 512 | 537 |     } else if (account?.address) { | 
| 513 | 538 |       await handleWalletConnection(); | 
| 514 | 539 |     } else { | 
|  | 
0 commit comments