droplinked-web3-ui 0.0.13 → 0.0.16
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/README.md +48 -13
- package/dist/index.cjs +34 -29
- package/dist/index.d.ts +0 -4
- package/dist/index.js +2866 -2584
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ enum Actions {
|
|
|
53
53
|
|
|
54
54
|
### 1️⃣ Payment Action 💰
|
|
55
55
|
|
|
56
|
-
Process cryptocurrency payments:
|
|
56
|
+
Process cryptocurrency payments. The component automatically fetches cart and shop data from the API:
|
|
57
57
|
|
|
58
58
|
```tsx
|
|
59
59
|
import { DroplinkedWeb3Ui, Actions } from 'droplinked-web3-ui';
|
|
@@ -65,10 +65,6 @@ function PaymentPage() {
|
|
|
65
65
|
inputs={{
|
|
66
66
|
cartId: "cart-id-here",
|
|
67
67
|
shopId: "shop-id-here",
|
|
68
|
-
price: 100,
|
|
69
|
-
priceInShopCurrency: 100,
|
|
70
|
-
abbreviation: "USD",
|
|
71
|
-
symbol: "$",
|
|
72
68
|
onError: (error) => console.error(error),
|
|
73
69
|
onSuccess: (orderId) => console.log('Success:', orderId),
|
|
74
70
|
}}
|
|
@@ -83,13 +79,11 @@ function PaymentPage() {
|
|
|
83
79
|
|------|------|-------------|
|
|
84
80
|
| 🛒 `cartId` | `string` | Shopping cart ID |
|
|
85
81
|
| 🏪 `shopId` | `string` | Shop ID |
|
|
86
|
-
| 💵 `price` | `number` | Payment amount |
|
|
87
|
-
| 💱 `priceInShopCurrency` | `number` | Amount in shop currency |
|
|
88
|
-
| 🏷️ `abbreviation` | `string` | Currency symbol (e.g., USD) |
|
|
89
|
-
| 💲 `symbol` | `string` | Display symbol (e.g., $) |
|
|
90
82
|
| ❌ `onError` | `(error: string) => void` | Error callback |
|
|
91
83
|
| ✅ `onSuccess` | `(orderId?: string) => void` | Success callback |
|
|
92
84
|
|
|
85
|
+
> 💡 **Note:** The component automatically fetches cart data (price, items) and shop data (currency, symbol) from the API using the provided `cartId` and `shopId`.
|
|
86
|
+
|
|
93
87
|
---
|
|
94
88
|
|
|
95
89
|
### 2️⃣ ClaimNFT Action 🎨
|
|
@@ -171,6 +165,14 @@ The component uses TypeScript generics to provide type-safe inputs based on the
|
|
|
171
165
|
│ └── 📂 dropWeb3Context/ # 🌐 Web3 context
|
|
172
166
|
├── 📂 hooks/ # ⚓ Custom hooks
|
|
173
167
|
├── 📂 stores/ # 🏪 Zustand stores
|
|
168
|
+
│ ├── paymentUiStore.ts # 💳 Payment UI state
|
|
169
|
+
│ ├── cartStore/ # 🛒 Cart data
|
|
170
|
+
│ ├── shopStore/ # 🏪 Shop data
|
|
171
|
+
│ ├── claimNftStore.ts # 🎨 NFT claim state
|
|
172
|
+
│ ├── modalStore.ts # 🪟 Modal state
|
|
173
|
+
│ ├── walletStore.ts # 👛 Wallet state
|
|
174
|
+
│ ├── tokenStore.ts # 🪙 Token state
|
|
175
|
+
│ └── orderStore.ts # 📋 Order state
|
|
174
176
|
├── 📂 apis/ # 🔌 API services
|
|
175
177
|
└── 📂 utils/ # 🛠️ Utilities
|
|
176
178
|
```
|
|
@@ -274,16 +276,14 @@ Hook for formatting financial amounts.
|
|
|
274
276
|
|
|
275
277
|
### 💳 paymentUiStore
|
|
276
278
|
|
|
277
|
-
Manages payment state:
|
|
279
|
+
Manages payment UI state:
|
|
278
280
|
|
|
279
281
|
```tsx
|
|
280
282
|
import { usePaymentUiStore } from '@/stores/paymentUiStore';
|
|
281
283
|
|
|
282
284
|
const {
|
|
283
285
|
cartId, # 🛒
|
|
284
|
-
|
|
285
|
-
abbreviation, # 🏷️
|
|
286
|
-
symbol, # 💲
|
|
286
|
+
shopId, # 🏪
|
|
287
287
|
onError, # ❌
|
|
288
288
|
onMainProcessSuccess, # ✅
|
|
289
289
|
setPaymentUiData, # 📝 (props) => set state
|
|
@@ -293,6 +293,8 @@ const {
|
|
|
293
293
|
} = usePaymentUiStore();
|
|
294
294
|
```
|
|
295
295
|
|
|
296
|
+
> 💡 Cart price and shop currency are stored in `cartStore` and `shopStore` respectively.
|
|
297
|
+
|
|
296
298
|
---
|
|
297
299
|
|
|
298
300
|
### 🎨 claimNftStore
|
|
@@ -389,6 +391,37 @@ Manages order state.
|
|
|
389
391
|
|
|
390
392
|
---
|
|
391
393
|
|
|
394
|
+
### 🛒 cartStore
|
|
395
|
+
|
|
396
|
+
Manages cart data fetched from API:
|
|
397
|
+
|
|
398
|
+
```tsx
|
|
399
|
+
import { useCartStore } from '@/stores/cartStore';
|
|
400
|
+
|
|
401
|
+
const {
|
|
402
|
+
cart, # 🛒 ICart - Cart data
|
|
403
|
+
updateCart, # 📝 (cart) => Update cart
|
|
404
|
+
resetCart, # 🔄 () => Reset cart
|
|
405
|
+
} = useCartStore();
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
### 🏪 shopStore
|
|
411
|
+
|
|
412
|
+
Manages shop data fetched from API:
|
|
413
|
+
|
|
414
|
+
```tsx
|
|
415
|
+
import { useShopStore } from '@/stores/shopStore';
|
|
416
|
+
|
|
417
|
+
const {
|
|
418
|
+
shop, # 🏪 IShop - Shop data
|
|
419
|
+
updateShop, # 📝 (shop) => Update shop
|
|
420
|
+
} = useShopStore();
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
392
425
|
## 🧩 Main Components
|
|
393
426
|
|
|
394
427
|
### 🌐 DropWeb3Provider
|
|
@@ -431,6 +464,8 @@ Services are located in `src/apis/`:
|
|
|
431
464
|
| 💳 Payment | `payment/services.ts` | Payment services |
|
|
432
465
|
| 📋 Orders | `orders/services.ts` | Order services |
|
|
433
466
|
| 🌐 Web3 | `web3/services.ts` | Web3 services |
|
|
467
|
+
| 🛒 Cart | `cart/services.ts` | Cart data fetching |
|
|
468
|
+
| 🏪 Shop | `shop/services.ts` | Shop data fetching |
|
|
434
469
|
|
|
435
470
|
---
|
|
436
471
|
|