-
Notifications
You must be signed in to change notification settings - Fork 9
feat: lit signature modal #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request modifies the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
packages/invoice-dashboard/src/lib/view-requests.svelte (1)
Line range hint
388-415: Enhance error handling and state managementThe Lit Protocol signature flow implementation has several areas for improvement:
- Add user feedback for signature rejection
- Handle localStorage access errors
- Prevent potential race conditions with loadSessionSignatures state
Consider applying these improvements:
const loadRequests = async (sliderValue: string, currentAccount: GetAccountReturnType | undefined, currentRequestNetwork: RequestNetwork | undefined | null) => { if (!currentAccount?.address || !currentRequestNetwork || !cipherProvider) return; loading = true; if (sliderValue === "on") { try { const signer = await getEthersSigner(wagmiConfig); if (signer && currentAccount?.address) { - loadSessionSignatures = localStorage?.getItem("lit-wallet-sig") === null; + try { + loadSessionSignatures = localStorage?.getItem("lit-wallet-sig") === null; + } catch (error) { + console.error("Failed to access localStorage:", error); + loadSessionSignatures = true; + } await cipherProvider?.getSessionSignatures(signer, currentAccount.address, window.location.host, "Sign in to Lit Protocol through Request Network"); cipherProvider?.enableDecryption(true); - localStorage?.setItem("isDecryptionEnabled", JSON.stringify(true)); + try { + localStorage?.setItem("isDecryptionEnabled", JSON.stringify(true)); + } catch (error) { + console.error("Failed to save to localStorage:", error); + } } } catch (error) { console.error("Failed to enable decryption:", error); - toast.error("Failed to enable decryption."); + toast.error("Failed to enable decryption.", { + description: error instanceof Error && error.message === "User rejected signature" + ? "Please approve the signature request to access encrypted invoices." + : "An unexpected error occurred while enabling decryption.", + }); loading = false; return; } finally { loadSessionSignatures = false; } } else { cipherProvider?.enableDecryption(false); - localStorage?.setItem("isDecryptionEnabled", JSON.stringify(false)); + try { + localStorage?.setItem("isDecryptionEnabled", JSON.stringify(false)); + } catch (error) { + console.error("Failed to save to localStorage:", error); + } } await getRequests(currentAccount, currentRequestNetwork); loading = false; };
🧹 Nitpick comments (2)
packages/invoice-dashboard/src/lib/view-requests.svelte (2)
423-436: Enhance modal content for better user guidanceWhile the modal effectively explains the basic purpose, it could provide more comprehensive information to help users make an informed decision.
Consider enhancing the modal content:
<Modal config={config} isOpen={true} title="Lit Protocol Signature Required" > <div class="modal-content"> - <p>This signature is required only once and will allow you to:</p> + <p>A one-time signature is required to enable secure access to encrypted invoice details through Lit Protocol.</p> + <p>By signing, you will be able to:</p> <ul> - <li>Access encrypted invoice details</li> + <li>View confidential invoice information securely</li> + <li>Maintain privacy of sensitive business data</li> + <li>Access encrypted attachments and notes</li> </ul> + <p class="modal-note">Note: This signature is only required once per browser session and does not incur any gas fees.</p> </div> </Modal>
1059-1072: Enhance modal styling for better readabilityThe current styling is functional but could be improved for better visual hierarchy and user experience.
Consider applying these styling enhancements:
.modal-content { padding: 1rem; + line-height: 1.5; } +.modal-content p { + margin-bottom: 1rem; + color: #1F2937; +} + +.modal-note { + margin-top: 1rem; + font-size: 0.875rem; + color: #6B7280; + font-style: italic; +} + .modal-content ul { list-style-type: disc; margin-left: 1.5rem; margin-top: 0.5rem; + margin-bottom: 1rem; } .modal-content li { margin-bottom: 0.5rem; - color: #4B5563; + color: #374151; + font-size: 0.9375rem; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/invoice-dashboard/src/lib/view-requests.svelte(6 hunks)
🔇 Additional comments (1)
packages/invoice-dashboard/src/lib/view-requests.svelte (1)
19-19: LGTM: Clean implementation of Modal component integration
The Modal import and state variable declaration are well-organized and follow the component's existing patterns.
Also applies to: 94-94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved 👍 contingent on comment resolution 🚧
Co-authored-by: MantisClone <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/invoice-dashboard/src/lib/view-requests.svelte (3)
Line range hint
388-407: Enhance error handling in loadRequests function.While the function logic is correct, the error handling could be improved:
- The error message "Failed to enable decryption" doesn't provide enough context about what went wrong
- The catch block swallows the original error details
Consider this improvement:
} catch (error) { console.error("Failed to enable decryption:", error); - toast.error("Failed to enable decryption."); + toast.error("Failed to enable decryption", { + description: error instanceof Error ? error.message : String(error), + action: { + label: "X", + onClick: () => console.info("Close"), + }, + }); loading = false; return; }
423-436: Enhance the modal content for better user understanding.While the modal implementation is correct, the content could be more informative about the security implications and purpose of the Lit Protocol signature.
Consider this improvement:
<div class="modal-content"> - <p>This signature is required only once per session and will allow you to:</p> + <p>This secure signature is required only once per session. By signing, you:</p> <ul> - <li>Access encrypted invoice details</li> + <li>Verify your identity to access encrypted invoice details</li> + <li>Enable secure decryption of sensitive invoice information</li> + <li>Maintain privacy of your invoice data through Lit Protocol</li> </ul> + <p class="security-note">Your signature never leaves your wallet and is used only for authentication.</p> </div>
1059-1072: Align modal styles with the theme configuration.The modal styles could be improved by using the theme colors from the config.
Consider this improvement:
.modal-content { padding: 1rem; } .modal-content ul { list-style-type: disc; margin-left: 1.5rem; margin-top: 0.5rem; } .modal-content li { margin-bottom: 0.5rem; - color: #4B5563; + color: var(--secondaryColor); } +.security-note { + margin-top: 1rem; + padding: 0.5rem; + border-radius: 0.25rem; + background-color: #F3F4F6; + color: var(--mainColor); + font-size: 0.875rem; +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/invoice-dashboard/src/lib/view-requests.svelte(6 hunks)
🔇 Additional comments (1)
packages/invoice-dashboard/src/lib/view-requests.svelte (1)
19-19: LGTM: Clean import and state variable declaration.
The Modal component import and loadSessionSignatures state variable are properly declared.
Also applies to: 94-94
Changes
feat: Add modal for Lit Protocol signature requirement in invoice dashboard
Fixes #249
Summary by CodeRabbit
New Features
Bug Fixes
Style