-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
826 lines (713 loc) · 39.7 KB
/
Copy pathindex.html
File metadata and controls
826 lines (713 loc) · 39.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
<!doctype html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ShadowPay - Privacy Vault for Solana</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="/_sdk/element_sdk.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
<style>
body {
box-sizing: border-box;
}
.font-display { font-family: 'Orbitron', sans-serif; }
.font-body { font-family: 'Inter', sans-serif; }
.glow-effect {
box-shadow: 0 0 40px rgba(139, 92, 246, 0.3), 0 0 80px rgba(139, 92, 246, 0.15);
}
.glass-card {
background: rgba(17, 24, 39, 0.7);
backdrop-filter: blur(20px);
border: 1px solid rgba(139, 92, 246, 0.2);
}
.gradient-border {
position: relative;
background: linear-gradient(145deg, rgba(17, 24, 39, 0.9), rgba(31, 41, 55, 0.9));
}
.gradient-border::before {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
padding: 2px;
background: linear-gradient(145deg, #8b5cf6, #3b82f6, #06b6d4);
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
pointer-events: none;
}
@keyframes pulse-glow {
0%, 100% { opacity: 0.5; transform: scale(1); }
50% { opacity: 0.8; transform: scale(1.1); }
}
.animate-pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }
@keyframes slideInRight {
from { transform: translateX(100px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.wallet-connected { animation: slideInRight 0.4s ease-out; }
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.modal-backdrop {
backdrop-filter: blur(10px);
animation: fadeIn 0.2s ease;
}
@keyframes scaleIn {
from { transform: scale(0.9); opacity: 0; }
to { transform: scale(1); opacity: 1; }
}
.modal-content { animation: scaleIn 0.3s ease; }
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-spinner {
border: 3px solid rgba(139, 92, 246, 0.1);
border-top: 3px solid #8b5cf6;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes slideInUp {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
.copy-notification { animation: slideInUp 0.3s ease; }
@keyframes slideIn {
from { transform: translateX(-20px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.history-item { animation: slideIn 0.4s ease; }
</style>
<style>@view-transition { navigation: auto; }</style>
<script src="/_sdk/data_sdk.js" type="text/javascript"></script>
</head>
<body class="h-full bg-gray-950 text-gray-100 font-body overflow-auto">
<div class="min-h-full w-full relative"><!-- Background -->
<div class="fixed inset-0 overflow-hidden pointer-events-none">
<div class="absolute top-20 left-20 w-96 h-96 bg-purple-600/20 rounded-full blur-3xl animate-pulse-glow"></div>
<div class="absolute bottom-20 right-20 w-96 h-96 bg-blue-600/20 rounded-full blur-3xl animate-pulse-glow" style="animation-delay: 1s;"></div>
<div class="absolute top-1/2 left-1/2 w-96 h-96 bg-cyan-600/10 rounded-full blur-3xl animate-pulse-glow" style="animation-delay: 2s;"></div>
</div><!-- Header -->
<header class="relative z-10 border-b border-purple-900/30 bg-gray-900/50 backdrop-blur-xl">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="w-12 h-12 rounded-xl bg-gradient-to-br from-purple-600 to-blue-600 flex items-center justify-center glow-effect">
<svg class="w-7 h-7 text-white" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
<div>
<h1 id="app-title" class="text-2xl font-display font-bold text-transparent bg-clip-text bg-gradient-to-r from-purple-400 to-cyan-400">ShadowPay</h1>
<p id="app-tagline" class="text-xs text-gray-400">Privacy Vault for Solana</p>
</div>
</div>
<div><button id="connect-wallet-btn" class="px-6 py-2.5 rounded-xl bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 text-white font-medium transition-all duration-300 transform hover:scale-105 glow-effect"> Connect Wallet </button>
<div id="wallet-connected" class="hidden wallet-connected">
<div class="flex items-center gap-3 px-4 py-2 rounded-xl glass-card">
<div class="w-2 h-2 bg-green-400 rounded-full animate-pulse"></div><span id="wallet-address" class="text-sm font-mono text-gray-300"></span> <button id="disconnect-wallet-btn" class="ml-2 text-gray-400 hover:text-red-400 transition-colors">
<svg class="w-4 h-4" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg></button>
</div>
</div>
</div>
</div>
</div>
</header><!-- Main -->
<main class="relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12"><!-- Tabs -->
<div class="flex justify-center mb-12">
<div class="inline-flex gap-2 p-1.5 rounded-2xl glass-card"><button id="mode-deposit" class="mode-btn px-6 py-3 rounded-xl font-display font-medium transition-all duration-300 bg-gradient-to-r from-purple-600 to-blue-600 text-white text-sm"> 🔒 Shield Funds </button> <button id="mode-withdraw" class="mode-btn px-6 py-3 rounded-xl font-display font-medium transition-all duration-300 text-gray-400 hover:text-white text-sm"> 🔓 Unshield Funds </button> <button id="mode-about" class="mode-btn px-6 py-3 rounded-xl font-display font-medium transition-all duration-300 text-gray-400 hover:text-white text-sm"> ℹ️ About </button>
</div>
</div><!-- Deposit Section (Shield Funds) -->
<div id="section-deposit" class="section-content">
<div class="max-w-2xl mx-auto">
<div class="text-center mb-10">
<div class="inline-flex items-center gap-2 px-4 py-2 rounded-full glass-card mb-4"><span class="w-2 h-2 bg-purple-400 rounded-full animate-pulse"></span> <span class="text-sm text-gray-400 font-medium">Private Deposit</span>
</div>
<h2 class="text-4xl font-display font-bold text-white mb-3">🔒 Shield Your Funds</h2>
<p class="text-gray-400">Deposit SOL into encrypted privacy vault using Zero-Knowledge proofs</p>
</div>
<div class="gradient-border rounded-3xl p-8 glow-effect">
<form id="create-form" class="space-y-6">
<div><label for="amount-input" class="block text-sm font-medium text-gray-300 mb-2">Amount to Deposit (SOL)</label>
<div class="relative"><input type="number" id="amount-input" step="0.001" min="0.001" placeholder="0.00" class="w-full px-5 py-4 bg-gray-900/50 border border-purple-500/30 rounded-xl text-white text-2xl font-bold focus:outline-none focus:border-purple-500 transition-colors" required> <span class="absolute right-5 top-1/2 -translate-y-1/2 text-gray-500 font-display">SOL</span>
</div>
</div>
<div><label for="expiry-select" class="block text-sm font-medium text-gray-300 mb-2">Link Expiry</label> <select id="expiry-select" class="w-full px-5 py-3 bg-gray-900/50 border border-purple-500/30 rounded-xl text-white focus:outline-none focus:border-purple-500 transition-colors appearance-none cursor-pointer"> <option value="3600">1 Hour</option> <option value="21600">6 Hours</option> <option value="86400" selected>24 Hours</option> <option value="604800">7 Days</option> </select>
</div>
<div class="p-4 rounded-xl bg-purple-500/10 border border-purple-500/20">
<div class="flex gap-3">
<svg class="w-5 h-5 text-purple-400 flex-shrink-0 mt-0.5" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<div class="text-sm text-gray-300"><strong class="text-purple-400">How it works:</strong> Your SOL is encrypted with Zero-Knowledge proofs and stored in Privacy Cash pool. Only you can withdraw. Backend never sees your balance. 1% fee goes to protocol.
</div>
</div>
</div><button type="submit" id="create-submit-btn" class="w-full py-4 rounded-xl bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 text-white font-display font-bold text-lg transition-all duration-300 transform hover:scale-[1.02] glow-effect disabled:opacity-50 disabled:cursor-not-allowed"> <span id="create-button-text">🔒 Shield Funds</span> </button>
</form>
</div>
</div>
</div><!-- Withdraw Section (Unshield Funds) -->
<div id="section-withdraw" class="section-content hidden">
<div class="max-w-2xl mx-auto">
<div class="text-center mb-10">
<div class="inline-flex items-center gap-2 px-4 py-2 rounded-full glass-card mb-4"><span class="w-2 h-2 bg-cyan-400 rounded-full animate-pulse"></span> <span class="text-sm text-gray-400 font-medium">Private Withdrawal</span>
</div>
<h2 class="text-4xl font-display font-bold text-white mb-3">🔓 Unshield Your Funds</h2>
<p class="text-gray-400">Withdraw SOL from privacy vault back to your wallet</p>
</div>
<div class="gradient-border rounded-3xl p-8 glow-effect">
<form id="withdraw-form" class="space-y-6">
<div><label for="withdraw-amount-input" class="block text-sm font-medium text-gray-300 mb-2">Amount to Withdraw (SOL)</label>
<div class="relative"><input type="number" id="withdraw-amount-input" step="0.001" min="0.001" placeholder="0.00" class="w-full px-5 py-4 bg-gray-900/50 border border-cyan-500/30 rounded-xl text-white text-2xl font-bold focus:outline-none focus:border-cyan-500 transition-colors"> <span class="absolute right-5 top-1/2 -translate-y-1/2 text-gray-500 font-display">SOL</span>
</div>
<p class="text-xs text-gray-400 mt-2">Leave empty to withdraw entire balance</p>
</div>
<div class="p-4 rounded-xl bg-cyan-500/10 border border-cyan-500/20">
<div class="flex gap-3">
<svg class="w-5 h-5 text-cyan-400 flex-shrink-0 mt-0.5" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
</svg>
<div class="text-sm text-gray-300"><strong class="text-cyan-400">Arcium Policy:</strong> Max 5 SOL per withdrawal. Higher amounts require approval. This protects against unauthorized access.
</div>
</div>
</div>
<button type="submit" id="withdraw-submit-btn" class="w-full py-4 rounded-xl bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-700 hover:to-blue-700 text-white font-display font-bold text-lg transition-all duration-300 transform hover:scale-[1.02] glow-effect disabled:opacity-50 disabled:cursor-not-allowed"> 🔓 Unshield Funds </button>
</form>
</div>
</div>
</div><!-- About Section -->
<div id="section-about" class="section-content hidden">
<div class="max-w-3xl mx-auto">
<div class="text-center mb-10">
<h2 class="text-4xl font-display font-bold text-white mb-3">About ShadowPay</h2>
<p class="text-gray-400">Privacy Vault for Solana</p>
</div>
<div class="gradient-border rounded-3xl p-8 space-y-6">
<div>
<h3 class="text-xl font-display font-bold text-white mb-3">🔐 What is ShadowPay?</h3>
<p class="text-gray-300">ShadowPay is a non-custodial privacy vault built on Solana. Your funds are encrypted using Zero-Knowledge proofs (Privacy Cash SDK) and protected by encrypted policy enforcement (Arcium MPC).</p>
</div>
<div>
<h3 class="text-xl font-display font-bold text-white mb-3">🛡️ Privacy Guarantees</h3>
<ul class="space-y-2 text-gray-300">
<li>✅ <strong>Non-Custodial:</strong> You control your keys, we never can access your funds</li>
<li>✅ <strong>Zero-Knowledge:</strong> Encrypted UTXOs hide balance from blockchain observers</li>
<li>✅ <strong>No History Tracking:</strong> Backend does not store your transaction history</li>
<li>✅ <strong>Client-Side Encryption:</strong> All encryption happens in your browser</li>
</ul>
</div>
<div>
<h3 class="text-xl font-display font-bold text-white mb-3">🔧 Technical Stack</h3>
<ul class="space-y-2 text-gray-300 text-sm font-mono">
<li>• <strong>Privacy Cash SDK:</strong> UTXO-based shielded pool with ZK-SNARKs</li>
<li>• <strong>Arcium MXE:</strong> Encrypted withdrawal policy (max 5 SOL per withdrawal)</li>
<li>• <strong>Solana Mainnet:</strong> Fast, low-cost transactions</li>
<li>• <strong>1% Protocol Fee:</strong> Sustainable privacy infrastructure</li>
</ul>
</div>
<div class="p-4 rounded-xl bg-purple-500/10 border border-purple-500/20">
<p class="text-sm text-gray-300"><strong class="text-purple-400">Important:</strong> Your private UTXOs are tied to your wallet signature. Clearing browser cache will require blockchain re-scan. Keep your seed phrase safe!</p>
</div>
</div>
</div>
</div><!-- OLD SECTIONS REMOVED (Claim, History) -->
</main><!-- Success Card -->
<div id="success-card" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 modal-backdrop bg-black/60">
<div class="modal-content gradient-border rounded-3xl p-8 max-w-md w-full glow-effect">
<div class="text-center">
<div class="w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-br from-green-400 to-emerald-600 flex items-center justify-center glow-effect">
<svg class="w-10 h-10 text-white" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
</div>
<h3 class="text-2xl font-display font-bold text-white mb-3">✨ Payment Link Created!</h3>
<p class="text-gray-400 mb-6">Your deposit was successful. Share this link with the recipient.</p>
<div class="mb-6 p-4 rounded-xl bg-gray-900/50 border border-purple-500/30">
<label class="block text-sm font-medium text-gray-300 mb-2">Link ID</label>
<div class="text-lg font-mono font-bold text-purple-300 break-all" id="success-link-id">--</div>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-300 mb-2">Share Link (Auto-selected)</label>
<div class="flex gap-2">
<input type="text" id="success-link-url" readonly class="flex-1 px-4 py-3 bg-gray-900/50 border border-cyan-500/30 rounded-xl text-white font-mono text-sm" value="">
<button id="copy-success-link-btn" class="px-4 py-3 rounded-xl bg-cyan-600 hover:bg-cyan-700 text-white transition-colors font-medium">
Copy
</button>
</div>
</div>
<button id="close-success-card" class="w-full py-3 rounded-xl bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 text-white font-medium transition-all">
Done
</button>
</div>
</div>
</div><!-- Success Modal -->
<div id="success-modal" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 modal-backdrop bg-black/60">
<div class="modal-content gradient-border rounded-3xl p-8 max-w-md w-full glow-effect">
<div class="text-center">
<div class="w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-br from-green-400 to-emerald-600 flex items-center justify-center glow-effect">
<svg class="w-10 h-10 text-white" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
</div>
<h3 class="text-2xl font-display font-bold text-white mb-3">Success!</h3>
<p id="success-message" class="text-gray-400 mb-6"></p>
<div id="link-result" class="hidden mb-6"><label class="block text-sm font-medium text-gray-300 mb-2">Your Private Payment Link</label>
<div class="flex gap-2"><input type="text" id="generated-link" readonly class="flex-1 px-4 py-3 bg-gray-900/50 border border-purple-500/30 rounded-xl text-white font-mono text-sm"> <button id="copy-link-btn" class="px-4 py-3 rounded-xl bg-purple-600 hover:bg-purple-700 text-white transition-colors" title="Copy link">
<svg class="w-5 h-5" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
</svg></button>
</div>
</div><button id="close-success-modal" class="w-full py-3 rounded-xl bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 text-white font-medium transition-all"> Close </button>
</div>
</div>
</div><!-- Loading Modal -->
<div id="loading-modal" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 modal-backdrop bg-black/60">
<div class="modal-content gradient-border rounded-3xl p-8 max-w-sm w-full text-center glow-effect">
<div class="loading-spinner mx-auto mb-6"></div>
<h3 class="text-xl font-display font-bold text-white mb-2">Processing...</h3>
<p id="loading-message" class="text-gray-400 text-sm mb-4"></p>
<!-- ✅ NEW: Signature instruction -->
<div id="signature-instructions" class="hidden bg-blue-500/20 border border-blue-500/50 rounded-lg p-3 mb-4">
<p class="text-sm text-blue-300">
<span class="font-semibold">💡 Tip:</span> Your wallet popup should appear.
<br>Keep it open and click "Approve" to sign.
</p>
</div>
</div>
</div><!-- Notification -->
<div id="copy-notification" class="hidden fixed bottom-8 right-8 z-50 copy-notification">
<div class="px-6 py-4 rounded-xl glass-card border border-green-500/30 flex items-center gap-3 glow-effect">
<svg class="w-5 h-5 text-green-400" fill="none" viewbox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg><span class="text-white font-medium">Link copied to clipboard!</span>
</div>
</div>
</div>
<script>
const defaultConfig = {
app_title: 'ShadowPay',
tagline: 'Privacy Vault for Solana',
create_button_text: 'Deposit & Create Link',
claim_button_text: 'Claim Payment'
};
let walletState = { connected: false, address: null, isProcessing: false };
let transactionHistory = {
sent: [
{ id: 'abc123', amount: 2.5, memo: 'Freelance payment', status: 'claimed', date: Date.now() - 86400000, linkId: 'abc123def456' },
{ id: 'def456', amount: 1.2, memo: 'Tip for great service', status: 'pending', date: Date.now() - 3600000, linkId: 'def456ghi789' }
],
received: [
{ id: 'ghi789', amount: 3.0, memo: 'Payment received', date: Date.now() - 172800000 }
]
};
function switchMode(mode) {
['create', 'claim', 'history'].forEach(sec => {
document.getElementById(`section-${sec}`).classList.add('hidden');
});
['mode-create', 'mode-claim', 'mode-history'].forEach(btn => {
const el = document.getElementById(btn);
el.classList.remove('bg-gradient-to-r', 'from-purple-600', 'to-blue-600', 'text-white');
el.classList.add('text-gray-400');
});
document.getElementById(`section-${mode}`).classList.remove('hidden');
const activeBtn = document.getElementById(`mode-${mode}`);
activeBtn.classList.add('bg-gradient-to-r', 'from-purple-600', 'to-blue-600', 'text-white');
activeBtn.classList.remove('text-gray-400');
if (mode === 'history') renderHistory();
}
function switchHistoryTab(tab) {
['sent', 'received'].forEach(t => {
const tabBtn = document.getElementById(`history-${t}-tab`);
const content = document.getElementById(`history-${t}-content`);
if (t === tab) {
tabBtn.classList.add('bg-purple-500/20', 'text-purple-300');
tabBtn.classList.remove('bg-gray-800', 'text-gray-400');
content.classList.remove('hidden');
} else {
tabBtn.classList.remove('bg-purple-500/20', 'text-purple-300');
tabBtn.classList.add('bg-gray-800', 'text-gray-400');
content.classList.add('hidden');
}
});
}
function renderHistory() {
const sentList = document.getElementById('sent-list');
const receivedList = document.getElementById('received-list');
const sentEmpty = document.getElementById('sent-empty');
const receivedEmpty = document.getElementById('received-empty');
sentList.innerHTML = '';
receivedList.innerHTML = '';
if (transactionHistory.sent.length === 0) {
sentEmpty.classList.remove('hidden');
} else {
sentEmpty.classList.add('hidden');
transactionHistory.sent.forEach(tx => {
sentList.appendChild(createHistoryItem(tx, 'sent'));
});
}
if (transactionHistory.received.length === 0) {
receivedEmpty.classList.remove('hidden');
} else {
receivedEmpty.classList.add('hidden');
transactionHistory.received.forEach(tx => {
receivedList.appendChild(createHistoryItem(tx, 'received'));
});
}
}
function createHistoryItem(tx, type) {
const div = document.createElement('div');
div.className = 'history-item gradient-border rounded-2xl p-6 glow-effect';
const statusBadge = type === 'sent'
? (tx.status === 'claimed'
? '<span class="px-3 py-1 rounded-full bg-emerald-500/20 text-emerald-400 text-xs font-medium">✓ Claimed</span>'
: '<span class="px-3 py-1 rounded-full bg-amber-500/20 text-amber-400 text-xs font-medium">⏳ Pending</span>')
: '<span class="px-3 py-1 rounded-full bg-cyan-500/20 text-cyan-400 text-xs font-medium">✓ Received</span>';
const timeAgo = getTimeAgo(tx.date);
div.innerHTML = `
<div class="flex items-center justify-between mb-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-full bg-gradient-to-br ${type === 'sent' ? 'from-purple-600 to-blue-600' : 'from-cyan-600 to-blue-600'} flex items-center justify-center">
<span class="text-lg">${type === 'sent' ? '📤' : '📥'}</span>
</div>
<div>
<p class="text-2xl font-display font-bold text-white">${tx.amount} SOL</p>
<p class="text-xs text-gray-500">${timeAgo}</p>
</div>
</div>
${statusBadge}
</div>
<div class="space-y-2">
${tx.memo ? `<p class="text-sm text-gray-400"><strong class="text-gray-300">Memo:</strong> ${tx.memo}</p>` : ''}
${type === 'sent' && tx.linkId ? `
<div class="flex items-center gap-2">
<p class="text-xs text-gray-500 font-mono flex-1">${tx.linkId}</p>
<button onclick="copyLinkId('${tx.linkId}')" class="px-3 py-1 rounded-lg bg-purple-500/20 text-purple-400 text-xs hover:bg-purple-500/30 transition-colors">
Copy ID
</button>
</div>
` : ''}
</div>
`;
return div;
}
function getTimeAgo(timestamp) {
const seconds = Math.floor((Date.now() - timestamp) / 1000);
if (seconds < 60) return 'Just now';
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
return `${Math.floor(seconds / 86400)}d ago`;
}
function copyLinkId(linkId) {
navigator.clipboard.writeText(linkId).then(() => {
showNotification('Link ID copied!');
});
}
async function connectWallet() {
if (walletState.isProcessing) return;
walletState.isProcessing = true;
showLoadingModal('Connecting to Phantom wallet...');
try {
// Check if Phantom wallet is available
const provider = window.phantom?.solana || window.solana;
if (!provider) {
throw new Error('Phantom wallet not installed. Please install Phantom from https://phantom.app');
}
// Request wallet connection
const response = await provider.connect();
walletState.connected = true;
walletState.address = response.publicKey.toString();
walletState.wallet = provider;
walletState.isProcessing = false;
document.getElementById('connect-wallet-btn').classList.add('hidden');
document.getElementById('wallet-connected').classList.remove('hidden');
document.getElementById('wallet-address').textContent = formatAddress(walletState.address);
hideLoadingModal();
showNotification('✅ Phantom wallet connected successfully!');
} catch (error) {
walletState.isProcessing = false;
hideLoadingModal();
showErrorModal(`❌ Wallet connection failed: ${error.message}`);
console.error('Wallet connection error:', error);
}
}
function disconnectWallet() {
walletState.connected = false;
walletState.address = null;
document.getElementById('connect-wallet-btn').classList.remove('hidden');
document.getElementById('wallet-connected').classList.add('hidden');
}
async function handleCreateLink(event) {
event.preventDefault();
if (!walletState.connected) {
showErrorModal('❌ Please connect your Phantom wallet first');
return;
}
if (walletState.isProcessing) return;
const amount = document.getElementById('amount-input').value;
const memo = document.getElementById('memo-input').value;
if (!amount || parseFloat(amount) <= 0) {
showErrorModal('❌ Please enter a valid amount');
return;
}
walletState.isProcessing = true;
try {
const amountSOL = parseFloat(amount);
// ✅ STEP 1: Create the link metadata first
showLoadingModal('📝 Creating payment link...<br><small class="text-gray-500">Generating link ID</small>');
const BACKEND_URL = 'https://shadowpay-backend-production.up.railway.app' || 'http://localhost:3000';
const linkResponse = await fetch(`${BACKEND_URL}/api/create-link`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
amount: amountSOL,
memo: memo || '',
assetType: 'SOL'
})
});
if (!linkResponse.ok) {
const err = await linkResponse.json();
throw new Error(err.error || 'Failed to create link');
}
const linkData = await linkResponse.json();
const linkId = linkData.id;
// ✅ STEP 2: Deposit to Privacy Cash pool via SDK (not manual transfer!)
showLoadingModal(`🔐 Depositing ${amountSOL} SOL to Privacy Cash pool...<br><small class="text-gray-500">Sign messages to enable privacy</small>`);
console.log(`🚀 Depositing to Privacy Cash pool...`);
console.log(` Link: ${linkId}`);
console.log(` Amount: ${amountSOL} SOL`);
// Dynamically import the deposit function
const privacyCashDeposit = await import('./utils/solTransfer.ts');
const depositResult = await privacyCashDeposit.depositViaPriVacyCash(
walletState.wallet,
amount,
linkId,
walletState.address
);
console.log(`✅ Privacy Cash deposit successful!`);
console.log(` Deposit TX: ${depositResult.depositTxHash}`);
console.log(` Amount: ${depositResult.amount} SOL`);
// ✅ SUCCESS: Show the link
const linkUrl = `https://shadowpay.app/claim/${linkId}`;
transactionHistory.sent.unshift({
id: Date.now().toString(),
amount: amountSOL,
memo: memo || 'No memo',
status: 'confirmed',
date: Date.now(),
linkId: linkId,
depositTx: depositResult.depositTxHash
});
walletState.isProcessing = false;
hideLoadingModal();
document.getElementById('generated-link').value = linkUrl;
document.getElementById('link-result').classList.remove('hidden');
document.getElementById('success-message').textContent = `✅ Success! Deposited ${amountSOL} SOL to Privacy Cash pool. Share this link with the recipient to claim privately.`;
showSuccessModal();
document.getElementById('create-form').reset();
} catch (error) {
walletState.isProcessing = false;
hideLoadingModal();
let errorMsg = error.message || 'Deposit failed';
// Friendly error messages
if (errorMsg.includes('User rejected')) {
errorMsg = '❌ You cancelled the deposit. No SOL was sent to Privacy Cash pool.';
} else if (errorMsg.includes('insufficient')) {
errorMsg = '❌ Insufficient SOL balance. Please add SOL to your Phantom wallet.';
} else if (errorMsg.includes('Privacy Cash')) {
errorMsg = '❌ Privacy Cash deposit failed. Please try again or check the backend logs.';
}
showErrorModal(errorMsg);
console.error('Link creation error:', error);
}
}
async function handleCheckLink(event) {
event.preventDefault();
const linkId = document.getElementById('link-id-input').value.trim();
if (!linkId) {
showErrorModal('❌ Please enter a payment link ID');
return;
}
showLoadingModal('🔍 Checking link validity...');
try {
const BACKEND_URL = 'https://shadowpay-backend-production.up.railway.app' || 'http://localhost:3000';
const response = await fetch(`${BACKEND_URL}/api/link/${linkId}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
});
if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Link not found or expired');
}
const linkData = await response.json();
if (linkData.claimed) {
throw new Error('This link has already been claimed');
}
const amount = (linkData.amount / 1e9).toFixed(9); // Convert lamports to SOL
const memo = linkData.memo || 'Payment';
const expiresAt = new Date(linkData.expiresAt || Date.now() + 24 * 60 * 60 * 1000);
const now = new Date();
const diffMs = expiresAt - now;
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
const diffMins = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60));
hideLoadingModal();
document.getElementById('preview-amount').textContent = amount;
document.getElementById('preview-memo').textContent = memo;
document.getElementById('preview-expiry').textContent = `${diffHours}h ${diffMins}m`;
document.getElementById('preview-card').classList.remove('hidden');
document.getElementById('preview-card').dataset.amount = amount;
document.getElementById('preview-card').dataset.memo = memo;
document.getElementById('preview-card').dataset.linkId = linkId;
} catch (error) {
hideLoadingModal();
showErrorModal(`❌ ${error.message}`);
console.error('Check link error:', error);
}
}
async function handleConfirmClaim() {
if (!walletState.connected) {
showErrorModal('❌ Please connect your Phantom wallet first');
return;
}
if (walletState.isProcessing) return;
const linkId = document.getElementById('preview-card').dataset.linkId;
const amount = document.getElementById('preview-card').dataset.amount;
walletState.isProcessing = true;
showLoadingModal('🔐 Executing withdrawal...<br><small class="text-gray-500">Requesting signature from Phantom</small>');
try {
// Import the claim link flow (assumes it's available globally)
const claimFlow = window.claimFlow || {};
if (claimFlow.executeClaimLink) {
await claimFlow.executeClaimLink({
linkId: linkId,
recipientAddress: walletState.address
});
} else {
// Fallback: direct API call
const BACKEND_URL = 'https://shadowpay-backend-production.up.railway.app' || 'http://localhost:3000';
const claimResponse = await fetch(`${BACKEND_URL}/api/claim-link`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
linkId: linkId,
recipientAddress: walletState.address
})
});
if (!claimResponse.ok) {
const err = await claimResponse.json();
throw new Error(err.error || 'Failed to claim link');
}
const claimData = await claimResponse.json();
}
transactionHistory.received.unshift({
id: Date.now().toString(),
amount: parseFloat(amount),
memo: document.getElementById('preview-card').dataset.memo,
date: Date.now()
});
walletState.isProcessing = false;
hideLoadingModal();
document.getElementById('preview-card').classList.add('hidden');
document.getElementById('link-result').classList.add('hidden');
document.getElementById('success-message').textContent = `✅ Successfully claimed ${amount} SOL! Funds sent to your wallet.`;
showSuccessModal();
document.getElementById('claim-form').reset();
} catch (error) {
walletState.isProcessing = false;
hideLoadingModal();
showErrorModal(`❌ Claim failed: ${error.message}`);
console.error('Claim error:', error);
}
}
function showSuccessModal() {
document.getElementById('success-modal').classList.remove('hidden');
}
function hideSuccessModal() {
document.getElementById('success-modal').classList.add('hidden');
document.getElementById('link-result').classList.add('hidden');
}
function showLoadingModal(message) {
document.getElementById('loading-message').innerHTML = message;
document.getElementById('loading-modal').classList.remove('hidden');
}
function hideLoadingModal() {
document.getElementById('loading-modal').classList.add('hidden');
}
function showErrorModal(message) {
document.getElementById('success-message').textContent = message;
document.getElementById('link-result').classList.add('hidden');
showSuccessModal();
}
function showNotification(message) {
const notification = document.getElementById('copy-notification');
notification.querySelector('span').textContent = message;
notification.classList.remove('hidden');
setTimeout(() => {
notification.classList.add('hidden');
}, 3000);
}
function copyLink() {
const linkInput = document.getElementById('generated-link');
linkInput.select();
linkInput.setSelectionRange(0, 99999);
navigator.clipboard.writeText(linkInput.value).then(() => {
showNotification('Link copied to clipboard!');
}).catch(() => {
showNotification('Failed to copy link');
});
}
function formatAddress(address) {
return `${address.substring(0, 4)}...${address.substring(address.length - 4)}`;
}
function generateLinkId() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
document.getElementById('mode-create').addEventListener('click', () => switchMode('create'));
document.getElementById('mode-claim').addEventListener('click', () => switchMode('claim'));
document.getElementById('mode-history').addEventListener('click', () => switchMode('history'));
document.getElementById('history-sent-tab').addEventListener('click', () => switchHistoryTab('sent'));
document.getElementById('history-received-tab').addEventListener('click', () => switchHistoryTab('received'));
document.getElementById('connect-wallet-btn').addEventListener('click', connectWallet);
document.getElementById('disconnect-wallet-btn').addEventListener('click', disconnectWallet);
document.getElementById('create-form').addEventListener('submit', handleCreateLink);
document.getElementById('claim-form').addEventListener('submit', handleCheckLink);
document.getElementById('confirm-claim-btn').addEventListener('click', handleConfirmClaim);
document.getElementById('close-success-modal').addEventListener('click', hideSuccessModal);
document.getElementById('copy-link-btn').addEventListener('click', copyLink);
async function onConfigChange(config) {
document.getElementById('app-title').textContent = config.app_title || defaultConfig.app_title;
document.getElementById('app-tagline').textContent = config.tagline || defaultConfig.tagline;
document.getElementById('create-button-text').textContent = config.create_button_text || defaultConfig.create_button_text;
}
function mapToCapabilities(config) {
return {
recolorables: [],
borderables: [],
fontEditable: undefined,
fontSizeable: undefined
};
}
function mapToEditPanelValues(config) {
return new Map([
['app_title', config.app_title || defaultConfig.app_title],
['tagline', config.tagline || defaultConfig.tagline],
['create_button_text', config.create_button_text || defaultConfig.create_button_text],
['claim_button_text', config.claim_button_text || defaultConfig.claim_button_text]
]);
}
if (window.elementSdk) {
window.elementSdk.init({
defaultConfig,
onConfigChange,
mapToCapabilities,
mapToEditPanelValues
});
}
</script>
<script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9c145fbec260600f',t:'MTc2ODk3Mjk0OC4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body>
</html>