Skip to content

Commit 3775fb9

Browse files
feat: lit signature modal (#266)
Co-authored-by: MantisClone <david.huntmateo@request.network>
1 parent a24e463 commit 3775fb9

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

packages/invoice-dashboard/src/lib/view-requests.svelte

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import TxType from "@requestnetwork/shared-components/tx-type.svelte";
1717
import DashboardSkeleton from "@requestnetwork/shared-components/dashboard-skeleton.svelte";
1818
import { toast } from "svelte-sonner";
19+
import Modal from "@requestnetwork/shared-components/modal.svelte";
1920
// Icons
2021
import ChevronDown from "@requestnetwork/shared-icons/chevron-down.svelte";
2122
import ChevronLeft from "@requestnetwork/shared-icons/chevron-left.svelte";
@@ -90,6 +91,7 @@
9091
})
9192
| undefined;
9293
let currencyManager: CurrencyManager;
94+
let loadSessionSignatures = false;
9395
9496
let columns = {
9597
issuedAt: false,
@@ -383,14 +385,15 @@
383385
activeRequest = undefined;
384386
};
385387
386-
const loadRequests = async (sliderValue: string, currentAccount: GetAccountReturnType, currentRequestNetwork: RequestNetwork | undefined | null) => {
388+
const loadRequests = async (sliderValue: string, currentAccount: GetAccountReturnType | undefined, currentRequestNetwork: RequestNetwork | undefined | null) => {
387389
if (!currentAccount?.address || !currentRequestNetwork || !cipherProvider) return;
388390
389391
loading = true;
390392
if (sliderValue === "on") {
391393
try {
392394
const signer = await getEthersSigner(wagmiConfig);
393395
if (signer && currentAccount?.address) {
396+
loadSessionSignatures = localStorage?.getItem("lit-wallet-sig") === null;
394397
await cipherProvider?.getSessionSignatures(signer, currentAccount.address, window.location.host, "Sign in to Lit Protocol through Request Network");
395398
cipherProvider?.enableDecryption(true);
396399
localStorage?.setItem("isDecryptionEnabled", JSON.stringify(true));
@@ -400,6 +403,8 @@
400403
toast.error("Failed to enable decryption.");
401404
loading = false;
402405
return;
406+
} finally {
407+
loadSessionSignatures = false;
403408
}
404409
} else {
405410
cipherProvider?.enableDecryption(false);
@@ -415,6 +420,20 @@
415420
class="main-table"
416421
style="--mainColor: {mainColor}; --secondaryColor: {secondaryColor}; "
417422
>
423+
{#if loadSessionSignatures}
424+
<Modal
425+
config={config}
426+
isOpen={true}
427+
title="Lit Protocol Signature Required"
428+
>
429+
<div class="modal-content">
430+
<p>This signature is required only once per session and will allow you to:</p>
431+
<ul>
432+
<li>Access encrypted invoice details</li>
433+
</ul>
434+
</div>
435+
</Modal>
436+
{/if}
418437
<div class="tabs">
419438
<ul>
420439
<li
@@ -1036,4 +1055,19 @@
10361055
font-size: 20px;
10371056
margin-bottom: 0;
10381057
}
1058+
1059+
.modal-content {
1060+
padding: 1rem;
1061+
}
1062+
1063+
.modal-content ul {
1064+
list-style-type: disc;
1065+
margin-left: 1.5rem;
1066+
margin-top: 0.5rem;
1067+
}
1068+
1069+
.modal-content li {
1070+
margin-bottom: 0.5rem;
1071+
color: #4B5563;
1072+
}
10391073
</style>

0 commit comments

Comments
 (0)