@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
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { Breadcrumb } from '@/components/docs/breadcrumb'
|
|
4
|
+
import { TableOfContents } from '@/components/docs/table-of-contents'
|
|
5
|
+
import { CodeBlock } from '@/components/docs/code-block'
|
|
6
|
+
import { Callout } from '@/components/docs/callout'
|
|
7
|
+
|
|
8
|
+
export default function EndpointsPage() {
|
|
9
|
+
const headings = [
|
|
10
|
+
{ id: 'wallets', level: 2, text: 'Wallets' },
|
|
11
|
+
{ id: 'transactions', level: 2, text: 'Transactions' },
|
|
12
|
+
{ id: 'users', level: 2, text: 'Users' },
|
|
13
|
+
{ id: 'networks', level: 2, text: 'Networks' },
|
|
14
|
+
{ id: 'analytics', level: 2, text: 'Analytics' },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="flex gap-8 max-w-7xl mx-auto px-4 py-8">
|
|
19
|
+
<main className="flex-1 min-w-0">
|
|
20
|
+
<Breadcrumb
|
|
21
|
+
items={[
|
|
22
|
+
{ label: 'Docs', href: '/docs' },
|
|
23
|
+
{ label: 'API', href: '/docs/api/overview' },
|
|
24
|
+
{ label: 'Endpoints' },
|
|
25
|
+
]}
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<div className="mt-8 prose prose-invert max-w-none">
|
|
29
|
+
<h1>API Endpoints</h1>
|
|
30
|
+
|
|
31
|
+
<p className="text-lg text-foreground/80">
|
|
32
|
+
Complete reference for all Lumina REST API endpoints. Each endpoint includes request/response examples.
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
<h2 id="wallets">Wallets</h2>
|
|
36
|
+
|
|
37
|
+
<h3>Create Wallet</h3>
|
|
38
|
+
<CodeBlock
|
|
39
|
+
code={`POST /wallets
|
|
40
|
+
|
|
41
|
+
{
|
|
42
|
+
"user_id": "user_abc123",
|
|
43
|
+
"network": "ethereum",
|
|
44
|
+
"name": "My Wallet",
|
|
45
|
+
"metadata": {
|
|
46
|
+
"app_id": "myapp"
|
|
47
|
+
}
|
|
48
|
+
}`}
|
|
49
|
+
language="bash"
|
|
50
|
+
title="Request"
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<CodeBlock
|
|
54
|
+
code={`{
|
|
55
|
+
"success": true,
|
|
56
|
+
"data": {
|
|
57
|
+
"id": "wallet_abc123",
|
|
58
|
+
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f42e0d",
|
|
59
|
+
"network": "ethereum",
|
|
60
|
+
"balance": "0",
|
|
61
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
62
|
+
}
|
|
63
|
+
}`}
|
|
64
|
+
language="json"
|
|
65
|
+
title="Response"
|
|
66
|
+
/>
|
|
67
|
+
|
|
68
|
+
<h3>Get Wallet</h3>
|
|
69
|
+
<CodeBlock
|
|
70
|
+
code={`GET /wallets/{wallet_id}
|
|
71
|
+
|
|
72
|
+
Response:
|
|
73
|
+
{
|
|
74
|
+
"success": true,
|
|
75
|
+
"data": {
|
|
76
|
+
"id": "wallet_abc123",
|
|
77
|
+
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f42e0d",
|
|
78
|
+
"network": "ethereum",
|
|
79
|
+
"balance": "2.5",
|
|
80
|
+
"nonce": 42,
|
|
81
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
82
|
+
}
|
|
83
|
+
}`}
|
|
84
|
+
language="bash"
|
|
85
|
+
title="Get Wallet"
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
<h3>List Wallets</h3>
|
|
89
|
+
<CodeBlock
|
|
90
|
+
code={`GET /wallets?user_id=user_abc123&limit=10&offset=0
|
|
91
|
+
|
|
92
|
+
Response:
|
|
93
|
+
{
|
|
94
|
+
"success": true,
|
|
95
|
+
"data": {
|
|
96
|
+
"wallets": [
|
|
97
|
+
{
|
|
98
|
+
"id": "wallet_1",
|
|
99
|
+
"address": "0x742d...",
|
|
100
|
+
"balance": "2.5",
|
|
101
|
+
"network": "ethereum"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "wallet_2",
|
|
105
|
+
"address": "0x123...",
|
|
106
|
+
"balance": "0.5",
|
|
107
|
+
"network": "polygon"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"total": 2,
|
|
111
|
+
"limit": 10,
|
|
112
|
+
"offset": 0
|
|
113
|
+
}
|
|
114
|
+
}`}
|
|
115
|
+
language="bash"
|
|
116
|
+
title="List Wallets"
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
<h3>Update Wallet</h3>
|
|
120
|
+
<CodeBlock
|
|
121
|
+
code={`PATCH /wallets/{wallet_id}
|
|
122
|
+
|
|
123
|
+
{
|
|
124
|
+
"name": "Updated Wallet Name",
|
|
125
|
+
"metadata": {
|
|
126
|
+
"custom_field": "value"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
Response:
|
|
131
|
+
{
|
|
132
|
+
"success": true,
|
|
133
|
+
"data": {
|
|
134
|
+
"id": "wallet_abc123",
|
|
135
|
+
"name": "Updated Wallet Name",
|
|
136
|
+
"updated_at": "2024-01-15T10:35:00Z"
|
|
137
|
+
}
|
|
138
|
+
}`}
|
|
139
|
+
language="bash"
|
|
140
|
+
title="Update Wallet"
|
|
141
|
+
/>
|
|
142
|
+
|
|
143
|
+
<h2 id="transactions">Transactions</h2>
|
|
144
|
+
|
|
145
|
+
<h3>Create Transaction</h3>
|
|
146
|
+
<CodeBlock
|
|
147
|
+
code={`POST /transactions
|
|
148
|
+
|
|
149
|
+
{
|
|
150
|
+
"wallet_id": "wallet_abc123",
|
|
151
|
+
"to": "0x123456789...",
|
|
152
|
+
"amount": "1.5",
|
|
153
|
+
"token": "ETH",
|
|
154
|
+
"data": "0x",
|
|
155
|
+
"gas_limit": "21000",
|
|
156
|
+
"gas_price": "50",
|
|
157
|
+
"description": "Payment for order #12345"
|
|
158
|
+
}`}
|
|
159
|
+
language="bash"
|
|
160
|
+
title="Request"
|
|
161
|
+
/>
|
|
162
|
+
|
|
163
|
+
<CodeBlock
|
|
164
|
+
code={`{
|
|
165
|
+
"success": true,
|
|
166
|
+
"data": {
|
|
167
|
+
"id": "txn_abc123",
|
|
168
|
+
"hash": null,
|
|
169
|
+
"from": "0x742d35Cc6634C0532925a3b844Bc9e7595f42e0d",
|
|
170
|
+
"to": "0x123456789...",
|
|
171
|
+
"amount": "1.5",
|
|
172
|
+
"status": "pending",
|
|
173
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
174
|
+
}
|
|
175
|
+
}`}
|
|
176
|
+
language="json"
|
|
177
|
+
title="Response"
|
|
178
|
+
/>
|
|
179
|
+
|
|
180
|
+
<h3>Confirm Transaction</h3>
|
|
181
|
+
<CodeBlock
|
|
182
|
+
code={`POST /transactions/{txn_id}/confirm
|
|
183
|
+
|
|
184
|
+
{
|
|
185
|
+
"signature": "0x...",
|
|
186
|
+
"nonce": 42
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
Response:
|
|
190
|
+
{
|
|
191
|
+
"success": true,
|
|
192
|
+
"data": {
|
|
193
|
+
"id": "txn_abc123",
|
|
194
|
+
"hash": "0xabc123...",
|
|
195
|
+
"status": "submitted",
|
|
196
|
+
"confirmed_at": "2024-01-15T10:30:15Z"
|
|
197
|
+
}
|
|
198
|
+
}`}
|
|
199
|
+
language="bash"
|
|
200
|
+
title="Confirm Transaction"
|
|
201
|
+
/>
|
|
202
|
+
|
|
203
|
+
<h3>Get Transaction</h3>
|
|
204
|
+
<CodeBlock
|
|
205
|
+
code={`GET /transactions/{txn_id}
|
|
206
|
+
|
|
207
|
+
Response:
|
|
208
|
+
{
|
|
209
|
+
"success": true,
|
|
210
|
+
"data": {
|
|
211
|
+
"id": "txn_abc123",
|
|
212
|
+
"hash": "0xabc123...",
|
|
213
|
+
"from": "0x742d35Cc...",
|
|
214
|
+
"to": "0x123456789...",
|
|
215
|
+
"amount": "1.5",
|
|
216
|
+
"status": "confirmed",
|
|
217
|
+
"gas_used": "21000",
|
|
218
|
+
"gas_price": "50",
|
|
219
|
+
"fee": "0.00105",
|
|
220
|
+
"block_number": 19234567,
|
|
221
|
+
"created_at": "2024-01-15T10:30:00Z",
|
|
222
|
+
"confirmed_at": "2024-01-15T10:30:15Z"
|
|
223
|
+
}
|
|
224
|
+
}`}
|
|
225
|
+
language="bash"
|
|
226
|
+
title="Get Transaction"
|
|
227
|
+
/>
|
|
228
|
+
|
|
229
|
+
<h3>List Transactions</h3>
|
|
230
|
+
<CodeBlock
|
|
231
|
+
code={`GET /transactions?wallet_id=wallet_abc123&status=confirmed&limit=20
|
|
232
|
+
|
|
233
|
+
Response:
|
|
234
|
+
{
|
|
235
|
+
"success": true,
|
|
236
|
+
"data": {
|
|
237
|
+
"transactions": [
|
|
238
|
+
{
|
|
239
|
+
"id": "txn_1",
|
|
240
|
+
"hash": "0xabc123...",
|
|
241
|
+
"status": "confirmed",
|
|
242
|
+
"amount": "1.5"
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"total": 42,
|
|
246
|
+
"limit": 20,
|
|
247
|
+
"offset": 0
|
|
248
|
+
}
|
|
249
|
+
}`}
|
|
250
|
+
language="bash"
|
|
251
|
+
title="List Transactions"
|
|
252
|
+
/>
|
|
253
|
+
|
|
254
|
+
<h2 id="users">Users</h2>
|
|
255
|
+
|
|
256
|
+
<h3>Create User</h3>
|
|
257
|
+
<CodeBlock
|
|
258
|
+
code={`POST /users
|
|
259
|
+
|
|
260
|
+
{
|
|
261
|
+
"email": "user@example.com",
|
|
262
|
+
"name": "John Doe",
|
|
263
|
+
"metadata": {
|
|
264
|
+
"app_user_id": "app_123"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
Response:
|
|
269
|
+
{
|
|
270
|
+
"success": true,
|
|
271
|
+
"data": {
|
|
272
|
+
"id": "user_abc123",
|
|
273
|
+
"email": "user@example.com",
|
|
274
|
+
"name": "John Doe",
|
|
275
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
276
|
+
}
|
|
277
|
+
}`}
|
|
278
|
+
language="bash"
|
|
279
|
+
title="Create User"
|
|
280
|
+
/>
|
|
281
|
+
|
|
282
|
+
<h3>Get User</h3>
|
|
283
|
+
<CodeBlock
|
|
284
|
+
code={`GET /users/{user_id}
|
|
285
|
+
|
|
286
|
+
Response:
|
|
287
|
+
{
|
|
288
|
+
"success": true,
|
|
289
|
+
"data": {
|
|
290
|
+
"id": "user_abc123",
|
|
291
|
+
"email": "user@example.com",
|
|
292
|
+
"name": "John Doe",
|
|
293
|
+
"wallet_count": 2,
|
|
294
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
295
|
+
}
|
|
296
|
+
}`}
|
|
297
|
+
language="bash"
|
|
298
|
+
title="Get User"
|
|
299
|
+
/>
|
|
300
|
+
|
|
301
|
+
<h2 id="networks">Networks</h2>
|
|
302
|
+
|
|
303
|
+
<h3>List Supported Networks</h3>
|
|
304
|
+
<CodeBlock
|
|
305
|
+
code={`GET /networks
|
|
306
|
+
|
|
307
|
+
Response:
|
|
308
|
+
{
|
|
309
|
+
"success": true,
|
|
310
|
+
"data": {
|
|
311
|
+
"networks": [
|
|
312
|
+
{
|
|
313
|
+
"id": "ethereum",
|
|
314
|
+
"name": "Ethereum",
|
|
315
|
+
"chain_id": 1,
|
|
316
|
+
"rpc_url": "https://eth-mainnet.g.alchemy.com/v2/...",
|
|
317
|
+
"explorer": "https://etherscan.io"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"id": "polygon",
|
|
321
|
+
"name": "Polygon",
|
|
322
|
+
"chain_id": 137,
|
|
323
|
+
"rpc_url": "https://polygon-mainnet.g.alchemy.com/v2/...",
|
|
324
|
+
"explorer": "https://polygonscan.com"
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
}`}
|
|
329
|
+
language="bash"
|
|
330
|
+
title="List Networks"
|
|
331
|
+
/>
|
|
332
|
+
|
|
333
|
+
<h2 id="analytics">Analytics</h2>
|
|
334
|
+
|
|
335
|
+
<h3>Get Wallet Analytics</h3>
|
|
336
|
+
<CodeBlock
|
|
337
|
+
code={`GET /analytics/wallets?user_id=user_abc123&period=30d
|
|
338
|
+
|
|
339
|
+
Response:
|
|
340
|
+
{
|
|
341
|
+
"success": true,
|
|
342
|
+
"data": {
|
|
343
|
+
"total_balance": "5.25",
|
|
344
|
+
"wallet_count": 2,
|
|
345
|
+
"transaction_count": 15,
|
|
346
|
+
"total_volume": "42.5",
|
|
347
|
+
"average_transaction": "2.83"
|
|
348
|
+
}
|
|
349
|
+
}`}
|
|
350
|
+
language="bash"
|
|
351
|
+
title="Wallet Analytics"
|
|
352
|
+
/>
|
|
353
|
+
|
|
354
|
+
<h3>Get Transaction Analytics</h3>
|
|
355
|
+
<CodeBlock
|
|
356
|
+
code={`GET /analytics/transactions?wallet_id=wallet_abc123&period=7d
|
|
357
|
+
|
|
358
|
+
Response:
|
|
359
|
+
{
|
|
360
|
+
"success": true,
|
|
361
|
+
"data": {
|
|
362
|
+
"transaction_count": 5,
|
|
363
|
+
"total_volume": "10.5",
|
|
364
|
+
"average_fee": "0.05",
|
|
365
|
+
"success_rate": 0.95,
|
|
366
|
+
"by_type": {
|
|
367
|
+
"send": 3,
|
|
368
|
+
"swap": 1,
|
|
369
|
+
"contract_interaction": 1
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}`}
|
|
373
|
+
language="bash"
|
|
374
|
+
title="Transaction Analytics"
|
|
375
|
+
/>
|
|
376
|
+
|
|
377
|
+
<Callout type="info">
|
|
378
|
+
All timestamps are in ISO 8601 format (UTC). All amounts are in wei for ETH and ERC-20 tokens unless specified otherwise.
|
|
379
|
+
</Callout>
|
|
380
|
+
</div>
|
|
381
|
+
|
|
382
|
+
<div className="flex justify-between mt-12 pt-8 border-t border-white/10">
|
|
383
|
+
<a href="/docs/api/overview" className="text-emerald-400 hover:text-emerald-300">
|
|
384
|
+
← Overview
|
|
385
|
+
</a>
|
|
386
|
+
<a href="/docs/api/errors" className="text-emerald-400 hover:text-emerald-300">
|
|
387
|
+
Error Handling →
|
|
388
|
+
</a>
|
|
389
|
+
</div>
|
|
390
|
+
</main>
|
|
391
|
+
|
|
392
|
+
<aside className="hidden lg:block w-64 flex-shrink-0">
|
|
393
|
+
<TableOfContents headings={headings} />
|
|
394
|
+
</aside>
|
|
395
|
+
</div>
|
|
396
|
+
)
|
|
397
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { Breadcrumb } from '@/components/docs/breadcrumb'
|
|
4
|
+
import { CodeBlock } from '@/components/docs/code-block'
|
|
5
|
+
import { Callout } from '@/components/docs/callout'
|
|
6
|
+
|
|
7
|
+
export default function ErrorHandlingPage() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="flex gap-8 max-w-7xl mx-auto px-4 py-8">
|
|
10
|
+
<main className="flex-1 min-w-0">
|
|
11
|
+
<Breadcrumb
|
|
12
|
+
items={[
|
|
13
|
+
{ label: 'Docs', href: '/docs' },
|
|
14
|
+
{ label: 'API', href: '/docs/api/overview' },
|
|
15
|
+
{ label: 'Error Handling' },
|
|
16
|
+
]}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<div className="mt-8 prose prose-invert max-w-none">
|
|
20
|
+
<h1>Error Handling</h1>
|
|
21
|
+
|
|
22
|
+
<p className="text-lg text-foreground/80">
|
|
23
|
+
Comprehensive guide to handling errors from the Lumina API.
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
<h2>HTTP Status Codes</h2>
|
|
27
|
+
|
|
28
|
+
<CodeBlock
|
|
29
|
+
code={`200 OK - Request successful
|
|
30
|
+
201 Created - Resource created successfully
|
|
31
|
+
400 Bad Request - Invalid request parameters
|
|
32
|
+
401 Unauthorized - Missing or invalid API key
|
|
33
|
+
403 Forbidden - API key lacks required permissions
|
|
34
|
+
404 Not Found - Resource not found
|
|
35
|
+
409 Conflict - Resource already exists or state conflict
|
|
36
|
+
429 Too Many Requests - Rate limit exceeded
|
|
37
|
+
500 Internal Server Error - Server error
|
|
38
|
+
503 Service Unavailable - Service temporarily unavailable`}
|
|
39
|
+
language="text"
|
|
40
|
+
title="Status Codes"
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<h2>Error Response Format</h2>
|
|
44
|
+
|
|
45
|
+
<CodeBlock
|
|
46
|
+
code={`{
|
|
47
|
+
"success": false,
|
|
48
|
+
"error": {
|
|
49
|
+
"code": "INSUFFICIENT_BALANCE",
|
|
50
|
+
"message": "Wallet has insufficient balance for this transaction",
|
|
51
|
+
"details": {
|
|
52
|
+
"required": "2.5",
|
|
53
|
+
"available": "1.0",
|
|
54
|
+
"shortfall": "1.5"
|
|
55
|
+
},
|
|
56
|
+
"request_id": "req_abc123xyz"
|
|
57
|
+
},
|
|
58
|
+
"timestamp": "2024-01-15T10:30:00Z"
|
|
59
|
+
}`}
|
|
60
|
+
language="json"
|
|
61
|
+
title="Error Response"
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<h2>Common Error Codes</h2>
|
|
65
|
+
|
|
66
|
+
<h3>Authentication Errors</h3>
|
|
67
|
+
<CodeBlock
|
|
68
|
+
code={`AUTHENTICATION_FAILED
|
|
69
|
+
Message: Invalid API key
|
|
70
|
+
Status: 401
|
|
71
|
+
|
|
72
|
+
INVALID_API_KEY_FORMAT
|
|
73
|
+
Message: API key format is invalid
|
|
74
|
+
Status: 401
|
|
75
|
+
|
|
76
|
+
API_KEY_EXPIRED
|
|
77
|
+
Message: API key has expired
|
|
78
|
+
Status: 401
|
|
79
|
+
|
|
80
|
+
INVALID_SIGNATURE
|
|
81
|
+
Message: Request signature is invalid
|
|
82
|
+
Status: 401`}
|
|
83
|
+
language="text"
|
|
84
|
+
title="Auth Errors"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<h3>Validation Errors</h3>
|
|
88
|
+
<CodeBlock
|
|
89
|
+
code={`INVALID_REQUEST
|
|
90
|
+
Message: Request validation failed
|
|
91
|
+
Details: Field-specific error messages
|
|
92
|
+
|
|
93
|
+
INVALID_ADDRESS
|
|
94
|
+
Message: Invalid wallet address format
|
|
95
|
+
Status: 400
|
|
96
|
+
|
|
97
|
+
INVALID_AMOUNT
|
|
98
|
+
Message: Invalid amount value
|
|
99
|
+
Status: 400
|
|
100
|
+
|
|
101
|
+
INVALID_NETWORK
|
|
102
|
+
Message: Network not supported
|
|
103
|
+
Status: 400
|
|
104
|
+
|
|
105
|
+
MISSING_REQUIRED_FIELD
|
|
106
|
+
Message: Required field missing in request
|
|
107
|
+
Status: 400`}
|
|
108
|
+
language="text"
|
|
109
|
+
title="Validation Errors"
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<h3>Business Logic Errors</h3>
|
|
113
|
+
<CodeBlock
|
|
114
|
+
code={`INSUFFICIENT_BALANCE
|
|
115
|
+
Message: Wallet balance is insufficient
|
|
116
|
+
Details: required, available, shortfall
|
|
117
|
+
|
|
118
|
+
INSUFFICIENT_GAS
|
|
119
|
+
Message: Insufficient gas for transaction
|
|
120
|
+
Details: required_gas, available_balance
|
|
121
|
+
|
|
122
|
+
WALLET_NOT_FOUND
|
|
123
|
+
Message: Wallet doesn't exist
|
|
124
|
+
Status: 404
|
|
125
|
+
|
|
126
|
+
USER_NOT_FOUND
|
|
127
|
+
Message: User doesn't exist
|
|
128
|
+
Status: 404
|
|
129
|
+
|
|
130
|
+
TRANSACTION_NOT_FOUND
|
|
131
|
+
Message: Transaction not found
|
|
132
|
+
Status: 404
|
|
133
|
+
|
|
134
|
+
TRANSACTION_FAILED
|
|
135
|
+
Message: Transaction execution failed
|
|
136
|
+
Details: failure_reason, revert_data
|
|
137
|
+
|
|
138
|
+
NETWORK_ERROR
|
|
139
|
+
Message: Network connectivity issue
|
|
140
|
+
Status: 503`}
|
|
141
|
+
language="text"
|
|
142
|
+
title="Business Logic Errors"
|
|
143
|
+
/>
|
|
144
|
+
|
|
145
|
+
<h3>Rate Limit Errors</h3>
|
|
146
|
+
<CodeBlock
|
|
147
|
+
code={`RATE_LIMIT_EXCEEDED
|
|
148
|
+
Message: Too many requests
|
|
149
|
+
Status: 429
|
|
150
|
+
Headers:
|
|
151
|
+
X-RateLimit-Limit: 100
|
|
152
|
+
X-RateLimit-Remaining: 0
|
|
153
|
+
X-RateLimit-Reset: 1705318200`}
|
|
154
|
+
language="text"
|
|
155
|
+
title="Rate Limit Error"
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
<h2>Handling Errors in Code</h2>
|
|
159
|
+
|
|
160
|
+
<h3>JavaScript/TypeScript</h3>
|
|
161
|
+
<CodeBlock
|
|
162
|
+
code={`async function createWallet(userId: string) {
|
|
163
|
+
try {
|
|
164
|
+
const response = await fetch(
|
|
165
|
+
'https://api.lumina.dev/v1/wallets',
|
|
166
|
+
{
|
|
167
|
+
method: 'POST',
|
|
168
|
+
headers: {
|
|
169
|
+
'Authorization': \`Bearer \${apiKey}\`,
|
|
170
|
+
'Content-Type': 'application/json',
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify({ user_id: userId }),
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
const result = await response.json()
|
|
177
|
+
|
|
178
|
+
if (!response.ok) {
|
|
179
|
+
switch (result.error.code) {
|
|
180
|
+
case 'AUTHENTICATION_FAILED':
|
|
181
|
+
console.error('Invalid API key')
|
|
182
|
+
// Refresh API key or redirect to login
|
|
183
|
+
break
|
|
184
|
+
case 'INVALID_REQUEST':
|
|
185
|
+
console.error('Invalid request:', result.error.details)
|
|
186
|
+
// Fix request parameters
|
|
187
|
+
break
|
|
188
|
+
case 'RATE_LIMIT_EXCEEDED':
|
|
189
|
+
// Wait until X-RateLimit-Reset
|
|
190
|
+
const resetTime = response.headers.get('X-RateLimit-Reset')
|
|
191
|
+
console.error('Rate limited. Reset at:', new Date(resetTime * 1000))
|
|
192
|
+
break
|
|
193
|
+
default:
|
|
194
|
+
console.error('API error:', result.error)
|
|
195
|
+
}
|
|
196
|
+
throw new Error(result.error.message)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return result.data
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error('Failed to create wallet:', error)
|
|
202
|
+
throw error
|
|
203
|
+
}
|
|
204
|
+
}`}
|
|
205
|
+
language="typescript"
|
|
206
|
+
title="Error Handling Example"
|
|
207
|
+
/>
|
|
208
|
+
|
|
209
|
+
<h3>Python</h3>
|
|
210
|
+
<CodeBlock
|
|
211
|
+
code={`import requests
|
|
212
|
+
from time import sleep
|
|
213
|
+
|
|
214
|
+
def create_wallet(user_id: str):
|
|
215
|
+
try:
|
|
216
|
+
response = requests.post(
|
|
217
|
+
'https://api.lumina.dev/v1/wallets',
|
|
218
|
+
headers={
|
|
219
|
+
'Authorization': f'Bearer {api_key}',
|
|
220
|
+
'Content-Type': 'application/json',
|
|
221
|
+
},
|
|
222
|
+
json={'user_id': user_id}
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
if response.status_code == 429:
|
|
226
|
+
reset_time = int(response.headers.get('X-RateLimit-Reset'))
|
|
227
|
+
wait_seconds = reset_time - int(time.time())
|
|
228
|
+
print(f'Rate limited. Waiting {wait_seconds}s...')
|
|
229
|
+
sleep(wait_seconds)
|
|
230
|
+
return create_wallet(user_id)
|
|
231
|
+
|
|
232
|
+
response.raise_for_status()
|
|
233
|
+
return response.json()['data']
|
|
234
|
+
|
|
235
|
+
except requests.exceptions.HTTPError as e:
|
|
236
|
+
error = e.response.json()
|
|
237
|
+
print(f"Error {error['error']['code']}: {error['error']['message']}")
|
|
238
|
+
raise`}
|
|
239
|
+
language="python"
|
|
240
|
+
title="Python Error Handling"
|
|
241
|
+
/>
|
|
242
|
+
|
|
243
|
+
<h2>Retry Strategy</h2>
|
|
244
|
+
|
|
245
|
+
<CodeBlock
|
|
246
|
+
code={`async function apiCallWithRetry(
|
|
247
|
+
url: string,
|
|
248
|
+
options: RequestInit,
|
|
249
|
+
maxAttempts: number = 3
|
|
250
|
+
): Promise<any> {
|
|
251
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
252
|
+
try {
|
|
253
|
+
const response = await fetch(url, options)
|
|
254
|
+
const data = await response.json()
|
|
255
|
+
|
|
256
|
+
if (response.ok) {
|
|
257
|
+
return data
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Don't retry client errors
|
|
261
|
+
if (response.status >= 400 && response.status < 500) {
|
|
262
|
+
throw new Error(data.error.message)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Retry server errors with exponential backoff
|
|
266
|
+
if (response.status >= 500) {
|
|
267
|
+
if (attempt < maxAttempts) {
|
|
268
|
+
const delay = Math.pow(2, attempt - 1) * 1000
|
|
269
|
+
console.log(\`Attempt \${attempt} failed. Retrying in \${delay}ms...\`)
|
|
270
|
+
await new Promise(r => setTimeout(r, delay))
|
|
271
|
+
continue
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
throw new Error(data.error.message)
|
|
276
|
+
} catch (error) {
|
|
277
|
+
if (attempt === maxAttempts) {
|
|
278
|
+
throw error
|
|
279
|
+
}
|
|
280
|
+
const delay = Math.pow(2, attempt) * 1000
|
|
281
|
+
await new Promise(r => setTimeout(r, delay))
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}`}
|
|
285
|
+
language="typescript"
|
|
286
|
+
title="Retry with Exponential Backoff"
|
|
287
|
+
/>
|
|
288
|
+
|
|
289
|
+
<Callout type="warning">
|
|
290
|
+
Always include the request_id from error responses when contacting support. It helps us trace the issue.
|
|
291
|
+
</Callout>
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
<div className="flex justify-between mt-12 pt-8 border-t border-white/10">
|
|
295
|
+
<a href="/docs/api/endpoints" className="text-emerald-400 hover:text-emerald-300">
|
|
296
|
+
← Endpoints
|
|
297
|
+
</a>
|
|
298
|
+
<a href="/docs/guides/nextjs" className="text-emerald-400 hover:text-emerald-300">
|
|
299
|
+
Next.js Guide →
|
|
300
|
+
</a>
|
|
301
|
+
</div>
|
|
302
|
+
</main>
|
|
303
|
+
</div>
|
|
304
|
+
)
|
|
305
|
+
}
|