@jerydam/lumina-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUTTON_FIXES.md +59 -0
- package/DOCS_INDEX.md +332 -0
- package/DOCUMENTATION.md +252 -0
- package/DOCUMENTATION_BUILD_SUMMARY.md +376 -0
- package/DOCUMENTATION_COMPLETE.md +311 -0
- package/FEATURES.md +333 -0
- package/Lumina-sdk/src/components/lumina-provider.tsx +46 -0
- package/Lumina-sdk/src/components/transaction-confirm.tsx +242 -0
- package/Lumina-sdk/src/components/wallet-display.tsx +157 -0
- package/Lumina-sdk/src/components/wallet-login.tsx +163 -0
- package/Lumina-sdk/src/hooks/use-mobile.ts +19 -0
- package/Lumina-sdk/src/hooks/use-toast.ts +191 -0
- package/Lumina-sdk/src/index.ts +0 -0
- package/Lumina-sdk/src/lib/api.ts +66 -0
- package/Lumina-sdk/src/lib/utils.ts +6 -0
- package/Lumina-sdk/src/package.json +42 -0
- package/Lumina-sdk/src/tsconfig.json +19 -0
- package/NEW_FILES_MANIFEST.txt +146 -0
- package/README.md +298 -0
- package/app/dashboard/analytics/page.tsx +218 -0
- package/app/dashboard/api-keys/page.tsx +260 -0
- package/app/dashboard/billing/page.tsx +412 -0
- package/app/dashboard/integration/page.tsx +185 -0
- package/app/dashboard/layout.tsx +18 -0
- package/app/dashboard/page.tsx +244 -0
- package/app/dashboard/settings/page.tsx +285 -0
- package/app/dashboard/users/page.tsx +148 -0
- package/app/docs/api/authentication/page.tsx +246 -0
- package/app/docs/api/endpoints/page.tsx +397 -0
- package/app/docs/api/errors/page.tsx +305 -0
- package/app/docs/api/overview/page.tsx +306 -0
- package/app/docs/examples/basic-setup/page.tsx +256 -0
- package/app/docs/examples/multi-chain/page.tsx +331 -0
- package/app/docs/examples/nextjs-full-stack/page.tsx +332 -0
- package/app/docs/getting-started/environment-setup/page.tsx +243 -0
- package/app/docs/getting-started/installation/page.tsx +187 -0
- package/app/docs/getting-started/introduction/page.tsx +178 -0
- package/app/docs/getting-started/quick-start/page.tsx +199 -0
- package/app/docs/guides/nextjs/page.tsx +358 -0
- package/app/docs/guides/react/page.tsx +230 -0
- package/app/docs/guides/security/page.tsx +284 -0
- package/app/docs/layout.tsx +32 -0
- package/app/docs/page.tsx +180 -0
- package/app/docs/sdk/lumina-provider/page.tsx +186 -0
- package/app/docs/sdk/transaction-confirm/page.tsx +331 -0
- package/app/docs/sdk/wallet-display/page.tsx +224 -0
- package/app/docs/sdk/wallet-login/page.tsx +207 -0
- package/app/docs/troubleshooting/common-issues/page.tsx +301 -0
- package/app/docs/troubleshooting/faq/page.tsx +105 -0
- package/app/globals.css +125 -0
- package/app/invite/[token]/page.tsx +78 -0
- package/app/layout.tsx +36 -0
- package/app/login/page.tsx +175 -0
- package/app/page.tsx +336 -0
- package/app/sdk-demo/page.tsx +239 -0
- package/components/dashboard-sidebar.tsx +113 -0
- package/components/docs/breadcrumb.tsx +51 -0
- package/components/docs/callout.tsx +53 -0
- package/components/docs/code-block.tsx +77 -0
- package/components/docs/docs-sidebar.tsx +214 -0
- package/components/docs/table-of-contents.tsx +83 -0
- package/components/sdk/lumina-provider.tsx +46 -0
- package/components/sdk/transaction-confirm.tsx +242 -0
- package/components/sdk/wallet-display.tsx +157 -0
- package/components/sdk/wallet-login.tsx +163 -0
- package/components/theme-provider.tsx +11 -0
- package/components/ui/accordion.tsx +66 -0
- package/components/ui/alert-dialog.tsx +157 -0
- package/components/ui/alert.tsx +66 -0
- package/components/ui/aspect-ratio.tsx +11 -0
- package/components/ui/avatar.tsx +53 -0
- package/components/ui/badge.tsx +46 -0
- package/components/ui/breadcrumb.tsx +109 -0
- package/components/ui/button-group.tsx +83 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/calendar.tsx +213 -0
- package/components/ui/card.tsx +92 -0
- package/components/ui/carousel.tsx +241 -0
- package/components/ui/chart.tsx +351 -0
- package/components/ui/checkbox.tsx +32 -0
- package/components/ui/collapsible.tsx +33 -0
- package/components/ui/command.tsx +184 -0
- package/components/ui/context-menu.tsx +252 -0
- package/components/ui/dialog.tsx +143 -0
- package/components/ui/drawer.tsx +135 -0
- package/components/ui/dropdown-menu.tsx +257 -0
- package/components/ui/empty.tsx +104 -0
- package/components/ui/field.tsx +244 -0
- package/components/ui/form.tsx +167 -0
- package/components/ui/hover-card.tsx +44 -0
- package/components/ui/input-group.tsx +169 -0
- package/components/ui/input-otp.tsx +77 -0
- package/components/ui/input.tsx +21 -0
- package/components/ui/item.tsx +193 -0
- package/components/ui/kbd.tsx +28 -0
- package/components/ui/label.tsx +24 -0
- package/components/ui/menubar.tsx +276 -0
- package/components/ui/navigation-menu.tsx +166 -0
- package/components/ui/pagination.tsx +127 -0
- package/components/ui/popover.tsx +48 -0
- package/components/ui/progress.tsx +31 -0
- package/components/ui/radio-group.tsx +45 -0
- package/components/ui/resizable.tsx +56 -0
- package/components/ui/scroll-area.tsx +58 -0
- package/components/ui/select.tsx +185 -0
- package/components/ui/separator.tsx +28 -0
- package/components/ui/sheet.tsx +139 -0
- package/components/ui/sidebar.tsx +726 -0
- package/components/ui/skeleton.tsx +13 -0
- package/components/ui/slider.tsx +59 -0
- package/components/ui/sonner.tsx +25 -0
- package/components/ui/spinner.tsx +16 -0
- package/components/ui/switch.tsx +29 -0
- package/components/ui/table.tsx +116 -0
- package/components/ui/tabs.tsx +66 -0
- package/components/ui/textarea.tsx +18 -0
- package/components/ui/toast.tsx +129 -0
- package/components/ui/toaster.tsx +35 -0
- package/components/ui/toggle-group.tsx +73 -0
- package/components/ui/toggle.tsx +47 -0
- package/components/ui/tooltip.tsx +61 -0
- package/components/ui/use-mobile.tsx +19 -0
- package/components/ui/use-toast.ts +191 -0
- package/components.json +21 -0
- package/hooks/use-mobile.ts +19 -0
- package/hooks/use-toast.ts +191 -0
- package/lib/api.ts +66 -0
- package/lib/utils.ts +6 -0
- package/next-env.d.ts +6 -0
- package/next.config.mjs +11 -0
- package/package.json +73 -0
- package/pnpm-workspace.yaml +5 -0
- package/postcss.config.mjs +8 -0
- package/public/apple-icon.png +0 -0
- package/public/fav.jpeg +0 -0
- package/public/fav.png +0 -0
- package/public/icon-dark-32x32.png +0 -0
- package/public/icon-light-32x32.png +0 -0
- package/public/icon.png +0 -0
- package/public/icon.svg +26 -0
- package/public/logo.jpeg +0 -0
- package/public/logo.png +0 -0
- package/public/logo2.jpeg +0 -0
- package/public/logo2.png +0 -0
- package/public/placeholder-logo.png +0 -0
- package/public/placeholder-logo.svg +1 -0
- package/public/placeholder-user.jpg +0 -0
- package/public/placeholder.jpg +0 -0
- package/public/placeholder.svg +1 -0
- package/styles/globals.css +209 -0
- package/tailwind.config.ts +15 -0
- package/tsconfig.json +41 -0
package/FEATURES.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# Lumina Design System - Complete Features
|
|
2
|
+
|
|
3
|
+
This document outlines all features and components included in the Lumina embedded wallet platform.
|
|
4
|
+
|
|
5
|
+
## 🎨 Design System
|
|
6
|
+
|
|
7
|
+
### Color Scheme
|
|
8
|
+
- **Primary**: Emerald Green (#10B981) - Main brand color
|
|
9
|
+
- **Background**: Deep Navy (#0A0A0A) - Dark theme foundation
|
|
10
|
+
- **Cards**: Slightly lighter navy (#1F2937) - Subtle elevation
|
|
11
|
+
- **Accent**: Emerald variations - Highlights and CTAs
|
|
12
|
+
- **Neutrals**: Grays and whites - Text and borders
|
|
13
|
+
|
|
14
|
+
### Design Features
|
|
15
|
+
- **Glassmorphism Effects** - Frosted glass backgrounds with backdrop blur
|
|
16
|
+
- **Smooth Animations** - Fade-in, slide-up, and glow effects
|
|
17
|
+
- **Dark Theme** - Premium dark aesthetic throughout
|
|
18
|
+
- **Responsive Design** - Mobile-first approach with Tailwind CSS
|
|
19
|
+
- **Custom Utilities** - Emerald gradients, glass effects, animations
|
|
20
|
+
|
|
21
|
+
## 📄 Pages & Routes
|
|
22
|
+
|
|
23
|
+
### Landing Page (`/`)
|
|
24
|
+
- Hero section with emerald gradient headline
|
|
25
|
+
- Feature grid with 6 key benefits
|
|
26
|
+
- How it works section with 4-step process
|
|
27
|
+
- Pricing tiers (Starter, Professional, Enterprise)
|
|
28
|
+
- Trust metrics and stats
|
|
29
|
+
- CTA sections throughout
|
|
30
|
+
- Navigation with product links
|
|
31
|
+
- Footer with company info and social links
|
|
32
|
+
|
|
33
|
+
### Developer Dashboard (`/dashboard`)
|
|
34
|
+
|
|
35
|
+
#### Overview Page (`/dashboard`)
|
|
36
|
+
- Key metrics cards (Wallets, Users, Volume, Requests)
|
|
37
|
+
- Monthly activity chart with visual bars
|
|
38
|
+
- Network status indicator
|
|
39
|
+
- Recent transactions table
|
|
40
|
+
- System health metrics
|
|
41
|
+
- Dashboard sidebar navigation
|
|
42
|
+
|
|
43
|
+
#### Users & Wallets (`/dashboard/users`)
|
|
44
|
+
- User management interface
|
|
45
|
+
- Search and filter capabilities
|
|
46
|
+
- Data table with pagination
|
|
47
|
+
- User verification status
|
|
48
|
+
- Account status indicators
|
|
49
|
+
- Add/remove user actions
|
|
50
|
+
|
|
51
|
+
#### Analytics (`/dashboard/analytics`)
|
|
52
|
+
- 4 key performance metrics
|
|
53
|
+
- Transaction volume chart
|
|
54
|
+
- Network distribution breakdown
|
|
55
|
+
- Top wallets leaderboard
|
|
56
|
+
- Date range selector
|
|
57
|
+
- Export functionality
|
|
58
|
+
|
|
59
|
+
#### API Keys (`/dashboard/api-keys`)
|
|
60
|
+
- Create and manage API credentials
|
|
61
|
+
- Public/secret key display
|
|
62
|
+
- Webhook configuration
|
|
63
|
+
- Rate limit information
|
|
64
|
+
- Usage metrics per key
|
|
65
|
+
- Security guidelines
|
|
66
|
+
- Key revocation
|
|
67
|
+
|
|
68
|
+
#### Billing (`/dashboard/billing`)
|
|
69
|
+
- Current plan display (Professional, Enterprise, etc.)
|
|
70
|
+
- Monthly usage metrics
|
|
71
|
+
- Billing history and invoices
|
|
72
|
+
- Payment method management
|
|
73
|
+
- Invoice downloads (PDF)
|
|
74
|
+
- Next payment date
|
|
75
|
+
- Cost optimization information
|
|
76
|
+
|
|
77
|
+
#### Integration (`/dashboard/integration`)
|
|
78
|
+
- SDK installation guides
|
|
79
|
+
- Code examples for React, Next.js, Vue, Svelte
|
|
80
|
+
- Network support matrix
|
|
81
|
+
- Authentication method overview
|
|
82
|
+
- Integration documentation links
|
|
83
|
+
- Framework-specific examples
|
|
84
|
+
|
|
85
|
+
#### Settings (`/dashboard/settings`)
|
|
86
|
+
- Account information management
|
|
87
|
+
- Team member management
|
|
88
|
+
- Notification preferences
|
|
89
|
+
- Two-factor authentication
|
|
90
|
+
- Data export functionality
|
|
91
|
+
- Security settings
|
|
92
|
+
- Danger zone (account deletion)
|
|
93
|
+
|
|
94
|
+
### SDK Demo Page (`/sdk-demo`)
|
|
95
|
+
- Interactive component demonstrations
|
|
96
|
+
- Step-by-step wallet creation flow
|
|
97
|
+
- Live code examples
|
|
98
|
+
- Feature showcase
|
|
99
|
+
- API documentation snippets
|
|
100
|
+
|
|
101
|
+
## 🧩 SDK Components
|
|
102
|
+
|
|
103
|
+
### 1. LuminaProvider
|
|
104
|
+
Context provider for wallet initialization
|
|
105
|
+
- API key configuration
|
|
106
|
+
- Environment settings (dev/prod)
|
|
107
|
+
- Theme management
|
|
108
|
+
- Child component access to Lumina context
|
|
109
|
+
|
|
110
|
+
### 2. WalletLogin
|
|
111
|
+
Authentication and wallet creation component
|
|
112
|
+
- Email authentication with OTP
|
|
113
|
+
- Biometric/Passkey support
|
|
114
|
+
- Social login integration (Google, GitHub)
|
|
115
|
+
- Loading states and error handling
|
|
116
|
+
- Responsive design for mobile/desktop
|
|
117
|
+
|
|
118
|
+
### 3. WalletDisplay
|
|
119
|
+
User wallet information and balance display
|
|
120
|
+
- Wallet address with copy functionality
|
|
121
|
+
- Balance display with token
|
|
122
|
+
- Network information
|
|
123
|
+
- Send/Receive action buttons
|
|
124
|
+
- Explorer link
|
|
125
|
+
- Network status indicator
|
|
126
|
+
|
|
127
|
+
### 4. TransactionConfirm
|
|
128
|
+
Transaction review and confirmation flow
|
|
129
|
+
- Transaction detail review
|
|
130
|
+
- Gas fee display
|
|
131
|
+
- Network and time estimates
|
|
132
|
+
- Security information badge
|
|
133
|
+
- Confirm/Cancel actions
|
|
134
|
+
- Confirmation status animation
|
|
135
|
+
- Success/failure states with transaction hash
|
|
136
|
+
|
|
137
|
+
## 📊 Dashboard Features
|
|
138
|
+
|
|
139
|
+
### Analytics & Metrics
|
|
140
|
+
- Real-time wallet statistics
|
|
141
|
+
- Transaction volume tracking
|
|
142
|
+
- Network distribution analysis
|
|
143
|
+
- Top user identification
|
|
144
|
+
- Revenue tracking
|
|
145
|
+
- API usage monitoring
|
|
146
|
+
- System health checks
|
|
147
|
+
|
|
148
|
+
### User Management
|
|
149
|
+
- User list with detailed information
|
|
150
|
+
- Verification status tracking
|
|
151
|
+
- Account creation dates
|
|
152
|
+
- Status indicators
|
|
153
|
+
- Bulk actions (import/export)
|
|
154
|
+
- User role management
|
|
155
|
+
|
|
156
|
+
### Billing & Subscription
|
|
157
|
+
- Current plan information
|
|
158
|
+
- Monthly usage breakdown
|
|
159
|
+
- Invoice history
|
|
160
|
+
- Payment method updates
|
|
161
|
+
- Cost optimization recommendations
|
|
162
|
+
- API rate limits
|
|
163
|
+
- Feature availability by plan
|
|
164
|
+
|
|
165
|
+
### Security & Access
|
|
166
|
+
- API key management (create, revoke, rotate)
|
|
167
|
+
- Webhook configuration
|
|
168
|
+
- Environment management
|
|
169
|
+
- Team member access control
|
|
170
|
+
- Two-factor authentication
|
|
171
|
+
- Session management
|
|
172
|
+
- Data retention policies
|
|
173
|
+
|
|
174
|
+
## 🔐 Security Features
|
|
175
|
+
|
|
176
|
+
- **Multi-Signature Wallets** - Requires multiple approvals
|
|
177
|
+
- **Hardware Security Modules** - HSM-backed key storage
|
|
178
|
+
- **End-to-End Encryption** - AES-256 encryption
|
|
179
|
+
- **Insurance Coverage** - Up to $1B protection
|
|
180
|
+
- **SOC 2 Type II** - Compliance certified
|
|
181
|
+
- **GDPR Compliant** - Data protection standards
|
|
182
|
+
- **Regular Audits** - Third-party security reviews
|
|
183
|
+
- **2FA Support** - Multi-factor authentication
|
|
184
|
+
|
|
185
|
+
## 🌐 Network Support
|
|
186
|
+
|
|
187
|
+
- **Ethereum** - Mainnet and Sepolia testnet
|
|
188
|
+
- **Polygon** - Mainnet and Mumbai testnet
|
|
189
|
+
- **Solana** - Mainnet and Devnet
|
|
190
|
+
- **Arbitrum** - Mainnet and Goerli testnet
|
|
191
|
+
- **Optimism** - Mainnet and Goerli testnet
|
|
192
|
+
- **Base** - Mainnet and Goerli testnet
|
|
193
|
+
|
|
194
|
+
## 🔑 Authentication Methods
|
|
195
|
+
|
|
196
|
+
1. **Email Authentication**
|
|
197
|
+
- Email verification
|
|
198
|
+
- OTP confirmation
|
|
199
|
+
- Secure session management
|
|
200
|
+
|
|
201
|
+
2. **Passkey / Biometric**
|
|
202
|
+
- Face ID support
|
|
203
|
+
- Fingerprint recognition
|
|
204
|
+
- Hardware security key support
|
|
205
|
+
|
|
206
|
+
3. **Social Login**
|
|
207
|
+
- Google OAuth
|
|
208
|
+
- GitHub OAuth
|
|
209
|
+
- Discord integration
|
|
210
|
+
|
|
211
|
+
4. **Web3 Wallet**
|
|
212
|
+
- MetaMask integration
|
|
213
|
+
- WalletConnect support
|
|
214
|
+
- Hardware wallet compatibility
|
|
215
|
+
|
|
216
|
+
## 🎯 Pricing Plans
|
|
217
|
+
|
|
218
|
+
### Free Plan
|
|
219
|
+
- 100 wallets
|
|
220
|
+
- Basic API access
|
|
221
|
+
- Community support
|
|
222
|
+
- Testnet only
|
|
223
|
+
- Email support
|
|
224
|
+
|
|
225
|
+
### Professional Plan ($499/month)
|
|
226
|
+
- 100K wallets
|
|
227
|
+
- Priority support
|
|
228
|
+
- Advanced analytics
|
|
229
|
+
- Multi-chain support
|
|
230
|
+
- Custom branding
|
|
231
|
+
- Webhook support
|
|
232
|
+
- SLA: 99.9% uptime
|
|
233
|
+
|
|
234
|
+
### Enterprise Plan
|
|
235
|
+
- Unlimited wallets
|
|
236
|
+
- 24/7 dedicated support
|
|
237
|
+
- Custom infrastructure
|
|
238
|
+
- SLA guarantee (99.99%)
|
|
239
|
+
- Advanced security features
|
|
240
|
+
- Custom contracts
|
|
241
|
+
- Compliance assistance
|
|
242
|
+
|
|
243
|
+
## 📱 Responsive Design
|
|
244
|
+
|
|
245
|
+
- **Mobile** - Optimized for small screens
|
|
246
|
+
- **Tablet** - Enhanced layout for medium screens
|
|
247
|
+
- **Desktop** - Full-featured experience for large screens
|
|
248
|
+
- **Touch-Friendly** - Large buttons and inputs
|
|
249
|
+
- **Accessible** - ARIA labels and semantic HTML
|
|
250
|
+
|
|
251
|
+
## 🛠 Technology Stack
|
|
252
|
+
|
|
253
|
+
- **Framework** - Next.js 16 with App Router
|
|
254
|
+
- **UI Components** - shadcn/ui with Tailwind CSS
|
|
255
|
+
- **Styling** - Tailwind CSS v4 with custom theme
|
|
256
|
+
- **Animations** - CSS animations and Framer Motion
|
|
257
|
+
- **Icons** - lucide-react
|
|
258
|
+
- **State Management** - React hooks and context
|
|
259
|
+
- **Type Safety** - TypeScript throughout
|
|
260
|
+
- **Build Tool** - Turbopack (Next.js)
|
|
261
|
+
|
|
262
|
+
## 📚 Documentation
|
|
263
|
+
|
|
264
|
+
- **README.md** - Getting started guide
|
|
265
|
+
- **FEATURES.md** - This file
|
|
266
|
+
- **Inline Comments** - Code documentation
|
|
267
|
+
- **SDK Demo** - Interactive examples
|
|
268
|
+
- **Dashboard Help** - In-context guidance
|
|
269
|
+
|
|
270
|
+
## 🚀 Getting Started
|
|
271
|
+
|
|
272
|
+
1. Visit the landing page at `/` for product information
|
|
273
|
+
2. View the SDK demo at `/sdk-demo` for component examples
|
|
274
|
+
3. Access the dashboard at `/dashboard` for full management interface
|
|
275
|
+
4. Read README.md for API documentation and integration guides
|
|
276
|
+
5. Check FEATURES.md (this file) for complete feature overview
|
|
277
|
+
|
|
278
|
+
## 📦 File Structure
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
/app
|
|
282
|
+
/dashboard
|
|
283
|
+
/page.tsx (overview)
|
|
284
|
+
/users/page.tsx
|
|
285
|
+
/analytics/page.tsx
|
|
286
|
+
/api-keys/page.tsx
|
|
287
|
+
/billing/page.tsx
|
|
288
|
+
/integration/page.tsx
|
|
289
|
+
/settings/page.tsx
|
|
290
|
+
/sdk-demo/page.tsx
|
|
291
|
+
/page.tsx (landing page)
|
|
292
|
+
layout.tsx
|
|
293
|
+
|
|
294
|
+
/components
|
|
295
|
+
/sdk
|
|
296
|
+
/lumina-provider.tsx
|
|
297
|
+
/wallet-login.tsx
|
|
298
|
+
/wallet-display.tsx
|
|
299
|
+
/transaction-confirm.tsx
|
|
300
|
+
/dashboard-sidebar.tsx
|
|
301
|
+
/ui/* (shadcn components)
|
|
302
|
+
|
|
303
|
+
/styles
|
|
304
|
+
/globals.css (theme variables and utilities)
|
|
305
|
+
|
|
306
|
+
/public
|
|
307
|
+
/images (assets)
|
|
308
|
+
|
|
309
|
+
/lib
|
|
310
|
+
/utils.ts
|
|
311
|
+
|
|
312
|
+
README.md
|
|
313
|
+
FEATURES.md
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## ✨ Key Highlights
|
|
317
|
+
|
|
318
|
+
✓ Complete dark theme with emerald green accents
|
|
319
|
+
✓ 7 fully-featured dashboard pages
|
|
320
|
+
✓ 4 reusable SDK components
|
|
321
|
+
✓ Interactive demo page
|
|
322
|
+
✓ Comprehensive documentation
|
|
323
|
+
✓ Type-safe React/TypeScript
|
|
324
|
+
✓ Responsive mobile-first design
|
|
325
|
+
✓ Glassmorphism effects
|
|
326
|
+
✓ Smooth animations
|
|
327
|
+
✓ Professional UI/UX
|
|
328
|
+
✓ Production-ready code
|
|
329
|
+
✓ SEO optimized landing page
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
For more information, see README.md or visit the dashboard at `/dashboard`.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext, ReactNode } from 'react'
|
|
4
|
+
import { apiClient } from '../lib/api' // Adjust path as needed
|
|
5
|
+
|
|
6
|
+
interface LuminaConfig {
|
|
7
|
+
apiKey: string
|
|
8
|
+
environment?: 'development' | 'production'
|
|
9
|
+
theme?: 'light' | 'dark'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface LuminaContextType extends LuminaConfig {
|
|
13
|
+
// Expose a pre-configured fetcher for SDK components
|
|
14
|
+
fetchApi: (endpoint: string, options?: RequestInit) => Promise<any>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const LuminaContext = createContext<LuminaContextType | undefined>(undefined)
|
|
18
|
+
|
|
19
|
+
export function LuminaProvider({
|
|
20
|
+
children,
|
|
21
|
+
apiKey,
|
|
22
|
+
environment = 'production',
|
|
23
|
+
theme = 'dark',
|
|
24
|
+
}: {
|
|
25
|
+
children: ReactNode
|
|
26
|
+
} & LuminaConfig) {
|
|
27
|
+
|
|
28
|
+
// Wrap the SDK client so components just call fetchApi('/v1/auth/login', {...})
|
|
29
|
+
const fetchApi = async (endpoint: string, options?: RequestInit) => {
|
|
30
|
+
return apiClient.sdk(endpoint, apiKey, options);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<LuminaContext.Provider value={{ apiKey, environment, theme, fetchApi }}>
|
|
35
|
+
{children}
|
|
36
|
+
</LuminaContext.Provider>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function useLumina() {
|
|
41
|
+
const context = useContext(LuminaContext)
|
|
42
|
+
if (!context) {
|
|
43
|
+
throw new Error('useLumina must be used within a LuminaProvider')
|
|
44
|
+
}
|
|
45
|
+
return context
|
|
46
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
import { Loader2, CheckCircle, AlertCircle, ExternalLink, Shield } from 'lucide-react'
|
|
5
|
+
import { Button } from '@/components/ui/button'
|
|
6
|
+
import { Card } from '@/components/ui/card'
|
|
7
|
+
import { useLumina } from './lumina-provider'
|
|
8
|
+
import { encodeFunctionData, parseEther } from 'viem'
|
|
9
|
+
|
|
10
|
+
interface TransactionDetails {
|
|
11
|
+
from: string // The smart account address
|
|
12
|
+
signerAddress: string // The underlying Turnkey embedded wallet EOA
|
|
13
|
+
to: string
|
|
14
|
+
amount: string
|
|
15
|
+
token?: string
|
|
16
|
+
network?: string
|
|
17
|
+
chainId?: string
|
|
18
|
+
gasFee?: string
|
|
19
|
+
estimatedTime?: string
|
|
20
|
+
callData?: string // Raw hex data for contract interactions
|
|
21
|
+
isDeployed?: boolean // Tells us if we need to append initCode
|
|
22
|
+
factoryAddress?: string // Required if !isDeployed
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface TransactionConfirmProps {
|
|
26
|
+
transaction: TransactionDetails
|
|
27
|
+
onConfirm?: () => Promise<void>
|
|
28
|
+
onCancel?: () => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type TransactionStatus = 'pending' | 'sponsoring' | 'signing' | 'submitting' | 'confirmed' | 'failed'
|
|
32
|
+
|
|
33
|
+
export function TransactionConfirm({
|
|
34
|
+
transaction,
|
|
35
|
+
onConfirm,
|
|
36
|
+
onCancel,
|
|
37
|
+
}: TransactionConfirmProps) {
|
|
38
|
+
const { fetchApi } = useLumina()
|
|
39
|
+
const [status, setStatus] = useState<TransactionStatus>('pending')
|
|
40
|
+
const [txHash, setTxHash] = useState<string>('')
|
|
41
|
+
const [errorMessage, setErrorMessage] = useState<string>('')
|
|
42
|
+
|
|
43
|
+
const handleConfirm = async () => {
|
|
44
|
+
setStatus('sponsoring')
|
|
45
|
+
setErrorMessage('')
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
if (onConfirm) await onConfirm()
|
|
49
|
+
|
|
50
|
+
const chainId = transaction.chainId || '1'
|
|
51
|
+
|
|
52
|
+
// ── 1. Handle Counterfactual Deployment (initCode) ──────────────────────
|
|
53
|
+
let finalInitCode = '0x'
|
|
54
|
+
|
|
55
|
+
if (!transaction.isDeployed && transaction.factoryAddress && transaction.signerAddress) {
|
|
56
|
+
const factoryABI = [{
|
|
57
|
+
name: 'createAccount',
|
|
58
|
+
type: 'function',
|
|
59
|
+
inputs: [
|
|
60
|
+
{ name: 'owner', type: 'address' },
|
|
61
|
+
{ name: 'salt', type: 'uint256' }
|
|
62
|
+
]
|
|
63
|
+
}]
|
|
64
|
+
|
|
65
|
+
const createAccountData = encodeFunctionData({
|
|
66
|
+
abi: factoryABI,
|
|
67
|
+
functionName: 'createAccount',
|
|
68
|
+
args: [transaction.signerAddress as `0x${string}`, 0n] // salt = 0 matches auth.py
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// initCode is Factory Address + calldata
|
|
72
|
+
finalInitCode = `${transaction.factoryAddress}${createAccountData.replace('0x', '')}`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ── 2. Encode SmartAccount execution (callData) ─────────────────────────
|
|
76
|
+
const smartAccountABI = [{
|
|
77
|
+
name: 'execute',
|
|
78
|
+
type: 'function',
|
|
79
|
+
inputs: [
|
|
80
|
+
{ name: 'target', type: 'address' },
|
|
81
|
+
{ name: 'value', type: 'uint256' },
|
|
82
|
+
{ name: 'data', type: 'bytes' }
|
|
83
|
+
]
|
|
84
|
+
}]
|
|
85
|
+
|
|
86
|
+
const finalCallData = encodeFunctionData({
|
|
87
|
+
abi: smartAccountABI,
|
|
88
|
+
functionName: 'execute',
|
|
89
|
+
args: [
|
|
90
|
+
transaction.to as `0x${string}`,
|
|
91
|
+
transaction.amount ? parseEther(transaction.amount) : 0n,
|
|
92
|
+
(transaction.callData as `0x${string}`) || '0x'
|
|
93
|
+
]
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// ── 3. Build the UserOperation ──────────────────────────────────────────
|
|
97
|
+
const partialUserOp = {
|
|
98
|
+
sender: transaction.from,
|
|
99
|
+
nonce: 0, // In production, fetch this via eth_call to the EntryPoint
|
|
100
|
+
init_code: finalInitCode,
|
|
101
|
+
call_data: finalCallData,
|
|
102
|
+
call_gas_limit: 50000,
|
|
103
|
+
verification_gas_limit: 150000,
|
|
104
|
+
pre_verification_gas: 21000,
|
|
105
|
+
max_fee_per_gas: 2000000000,
|
|
106
|
+
max_priority_fee_per_gas: 1000000000,
|
|
107
|
+
chain_id: chainId
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── 4. Get Paymaster Sponsorship ────────────────────────────────────────
|
|
111
|
+
const signRes = await fetchApi('/v1/paymaster/sign', {
|
|
112
|
+
method: 'POST',
|
|
113
|
+
body: JSON.stringify(partialUserOp)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
setStatus('signing')
|
|
117
|
+
|
|
118
|
+
// ── 5. Local User Signature (Turnkey integration goes here) ─────────────
|
|
119
|
+
// Simulating a Passkey/Biometric signing delay
|
|
120
|
+
await new Promise(resolve => setTimeout(resolve, 1500))
|
|
121
|
+
const mockUserSignature = "0xabcd1234..." // Replace with Turnkey sign output
|
|
122
|
+
|
|
123
|
+
const fullySignedOp = {
|
|
124
|
+
...partialUserOp,
|
|
125
|
+
paymasterAndData: signRes.paymaster_and_data,
|
|
126
|
+
signature: mockUserSignature
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
setStatus('submitting')
|
|
130
|
+
|
|
131
|
+
// ── 6. Submit to the Bundler ────────────────────────────────────────────
|
|
132
|
+
const submitRes = await fetchApi('/v1/paymaster/submit', {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
body: JSON.stringify({
|
|
135
|
+
user_op_id: signRes.user_op_id,
|
|
136
|
+
signed_user_op: fullySignedOp,
|
|
137
|
+
chain_id: chainId
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
setTxHash(submitRes.user_op_hash)
|
|
142
|
+
setStatus('confirmed')
|
|
143
|
+
|
|
144
|
+
} catch (error: any) {
|
|
145
|
+
console.error("Transaction failed:", error)
|
|
146
|
+
setStatus('failed')
|
|
147
|
+
setErrorMessage(error.message || "Failed to process transaction")
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<Card className="glassmorphism-dark p-8 border-border w-full max-w-lg mx-auto">
|
|
153
|
+
{status === 'pending' && (
|
|
154
|
+
<>
|
|
155
|
+
<div className="mb-6">
|
|
156
|
+
<h2 className="text-2xl font-bold mb-2">Confirm Transaction</h2>
|
|
157
|
+
<p className="text-foreground/60 text-sm">Review the details before confirming</p>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div className="space-y-4 mb-6 p-4 bg-white/5 rounded-lg border border-border/50">
|
|
161
|
+
<div className="flex justify-between items-start">
|
|
162
|
+
<span className="text-foreground/60">To Address</span>
|
|
163
|
+
<span className="font-mono text-sm">{transaction.to.slice(0, 6)}...{transaction.to.slice(-4)}</span>
|
|
164
|
+
</div>
|
|
165
|
+
<div className="flex justify-between items-start border-t border-border/30 pt-4">
|
|
166
|
+
<span className="text-foreground/60">Amount</span>
|
|
167
|
+
<span className="font-bold text-lg">{transaction.amount} {transaction.token || 'ETH'}</span>
|
|
168
|
+
</div>
|
|
169
|
+
{transaction.gasFee && (
|
|
170
|
+
<div className="flex justify-between items-start border-t border-border/30 pt-4">
|
|
171
|
+
<span className="text-foreground/60">Gas Fee</span>
|
|
172
|
+
<span className="font-medium text-emerald-400">Sponsored by Paymaster</span>
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<div className="mb-6 p-4 bg-emerald-600/10 rounded-lg border border-emerald-600/30 flex gap-3">
|
|
178
|
+
<Shield className="text-emerald-500 shrink-0 mt-0.5" size={20} />
|
|
179
|
+
<div className="text-sm">
|
|
180
|
+
<p className="font-medium mb-1">Gasless Transaction</p>
|
|
181
|
+
<p className="text-foreground/70">The network fees for this action are being covered by the application.</p>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div className="flex gap-3">
|
|
186
|
+
<Button onClick={onCancel} variant="outline" className="flex-1">
|
|
187
|
+
Cancel
|
|
188
|
+
</Button>
|
|
189
|
+
<Button onClick={handleConfirm} className="flex-1 bg-emerald-600 hover:bg-emerald-700">
|
|
190
|
+
Confirm Transaction
|
|
191
|
+
</Button>
|
|
192
|
+
</div>
|
|
193
|
+
</>
|
|
194
|
+
)}
|
|
195
|
+
|
|
196
|
+
{(status === 'sponsoring' || status === 'signing' || status === 'submitting') && (
|
|
197
|
+
<div className="text-center py-8">
|
|
198
|
+
<Loader2 className="animate-spin mx-auto mb-4 text-emerald-500" size={48} />
|
|
199
|
+
<h3 className="text-xl font-bold mb-2">
|
|
200
|
+
{status === 'sponsoring' && "Sponsoring Gas..."}
|
|
201
|
+
{status === 'signing' && "Awaiting Signature..."}
|
|
202
|
+
{status === 'submitting' && "Submitting to Network..."}
|
|
203
|
+
</h3>
|
|
204
|
+
<p className="text-foreground/60 text-sm">Please do not close this window.</p>
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
|
|
208
|
+
{status === 'confirmed' && (
|
|
209
|
+
<div className="text-center py-8">
|
|
210
|
+
<CheckCircle className="mx-auto mb-4 text-emerald-500" size={48} />
|
|
211
|
+
<h3 className="text-xl font-bold mb-2">Transaction Submitted</h3>
|
|
212
|
+
<p className="text-foreground/60 mb-4 text-sm">Your operation has been sent to the bundler network.</p>
|
|
213
|
+
|
|
214
|
+
<div className="p-3 bg-white/5 rounded-lg border border-border/50 mb-6 text-left">
|
|
215
|
+
<p className="text-xs text-foreground/60 mb-1">UserOp Hash</p>
|
|
216
|
+
<div className="flex items-center gap-2">
|
|
217
|
+
<code className="text-xs font-mono flex-1 truncate">{txHash}</code>
|
|
218
|
+
<button className="p-1 hover:bg-white/10 rounded">
|
|
219
|
+
<ExternalLink size={16} className="text-foreground/60" />
|
|
220
|
+
</button>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
<Button onClick={onCancel} className="w-full bg-emerald-600 hover:bg-emerald-700">
|
|
224
|
+
Return to Wallet
|
|
225
|
+
</Button>
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
228
|
+
|
|
229
|
+
{status === 'failed' && (
|
|
230
|
+
<div className="text-center py-8">
|
|
231
|
+
<AlertCircle className="mx-auto mb-4 text-red-500" size={48} />
|
|
232
|
+
<h3 className="text-xl font-bold mb-2">Transaction Failed</h3>
|
|
233
|
+
<p className="text-foreground/60 mb-6 text-sm">{errorMessage}</p>
|
|
234
|
+
|
|
235
|
+
<Button onClick={() => setStatus('pending')} className="w-full bg-emerald-600 hover:bg-emerald-700">
|
|
236
|
+
Try Again
|
|
237
|
+
</Button>
|
|
238
|
+
</div>
|
|
239
|
+
)}
|
|
240
|
+
</Card>
|
|
241
|
+
)
|
|
242
|
+
}
|