tek-wallet 0.0.808 → 0.0.809
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 +107 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
```jsx
|
|
21
21
|
import "swiper/css";
|
|
22
|
-
import { TekWalletProvider } from "tek-wallet";
|
|
22
|
+
import { TekWalletProvider, ThemeModes } from "tek-wallet";
|
|
23
23
|
|
|
24
24
|
// Cấu hình cơ bản
|
|
25
25
|
<TekWalletProvider
|
|
@@ -30,14 +30,74 @@ import { TekWalletProvider } from "tek-wallet";
|
|
|
30
30
|
</TekWalletProvider>;
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
**Cấu hình nâng cao:**
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import { TekWalletProvider, ThemeModes } from "tek-wallet";
|
|
37
|
+
|
|
38
|
+
<TekWalletProvider
|
|
39
|
+
theme={theme} // Custom theme object
|
|
40
|
+
themeMode={ThemeModes.DARK} // Chế độ theme: DARK hoặc LIGHT
|
|
41
|
+
isSSO
|
|
42
|
+
accessToken={accessToken}
|
|
43
|
+
options={{
|
|
44
|
+
useDefaultToastMessage: true, // Sử dụng toast message mặc định
|
|
45
|
+
hideDefaultActivities: true, // Ẩn activities mặc định
|
|
46
|
+
hideActivitySectionInAssetView: true, // Ẩn section activities trong AssetView
|
|
47
|
+
useBasicAmountGroupInAssetView: true, // Sử dụng basic amount group trong AssetView
|
|
48
|
+
hideBackButtons: {
|
|
49
|
+
// Ẩn nút back trong các view cụ thể
|
|
50
|
+
activity: true,
|
|
51
|
+
},
|
|
52
|
+
}}
|
|
53
|
+
topOffset={viewportStatusBarHeight || 0} // Offset từ top (thường dùng cho mobile)
|
|
54
|
+
onLogout={handleLogout} // Callback khi logout
|
|
55
|
+
overrideQRScanMethod={isMobileApp ? scanQRCode : undefined} // Override QR scan method
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</TekWalletProvider>;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2. TekWalletProvider Props
|
|
62
|
+
|
|
63
|
+
**Props cơ bản:**
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Required | Mô tả |
|
|
66
|
+
| ------------- | --------- | -------- | ----------------------------- |
|
|
67
|
+
| `isSSO` | `boolean` | ✅ | Bật chế độ SSO authentication |
|
|
68
|
+
| `accessToken` | `string` | ✅ | Token xác thực từ SSO |
|
|
69
|
+
|
|
70
|
+
**Props nâng cao:**
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Required | Mô tả |
|
|
73
|
+
| ---------------------- | ------------ | -------- | ---------------------------------------------------- |
|
|
74
|
+
| `theme` | `object` | ❌ | Custom theme object |
|
|
75
|
+
| `themeMode` | `ThemeModes` | ❌ | Chế độ theme: `DARK` hoặc `LIGHT` |
|
|
76
|
+
| `topOffset` | `number` | ❌ | Offset từ top (thường dùng cho mobile status bar) |
|
|
77
|
+
| `onLogout` | `function` | ❌ | Callback function khi user logout |
|
|
78
|
+
| `overrideQRScanMethod` | `function` | ❌ | Override QR scan method (thường dùng cho mobile app) |
|
|
79
|
+
|
|
80
|
+
**Options object:**
|
|
81
|
+
|
|
82
|
+
| Option | Type | Default | Mô tả |
|
|
83
|
+
| -------------------------------- | --------- | ------- | ------------------------------------------- |
|
|
84
|
+
| `useDefaultToastMessage` | `boolean` | `false` | Sử dụng toast message mặc định của hệ thống |
|
|
85
|
+
| `hideDefaultActivities` | `boolean` | `false` | Ẩn activities mặc định |
|
|
86
|
+
| `hideActivitySectionInAssetView` | `boolean` | `false` | Ẩn section activities trong AssetView |
|
|
87
|
+
| `useBasicAmountGroupInAssetView` | `boolean` | `false` | Sử dụng basic amount group trong AssetView |
|
|
88
|
+
| `hideBackButtons` | `object` | `{}` | Ẩn nút back trong các view cụ thể |
|
|
89
|
+
|
|
90
|
+
**hideBackButtons object:**
|
|
91
|
+
|
|
92
|
+
| Property | Type | Mô tả |
|
|
93
|
+
| ---------- | --------- | ------------------------------- |
|
|
94
|
+
| `activity` | `boolean` | Ẩn nút back trong activity view |
|
|
95
|
+
|
|
96
|
+
### 3. Environment Variables
|
|
34
97
|
|
|
35
98
|
Các biến môi trường cần thiết:
|
|
36
99
|
|
|
37
100
|
```env
|
|
38
|
-
TEK_WALLET_API_KEY=your_api_key
|
|
39
|
-
TEK_WALLET_AUTH_SECRET=your_auth_secret
|
|
40
|
-
TEK_WALLET_REFRESH_TOKEN_URL=your_refresh_token_url
|
|
41
101
|
NEXT_PUBLIC_TEK_WALLET_APP_SLUG=your_app_slug
|
|
42
102
|
NEXT_PUBLIC_TEK_WALLET_SERVER_URL=your_server_url
|
|
43
103
|
NEXT_PUBLIC_TEK_WALLET_ABLY_API_KEY=your_ably_api_key
|
|
@@ -126,6 +186,48 @@ Nếu phía trước có path: `<path>/tek-wallet/[[...pathname]]/page.tsx` thì
|
|
|
126
186
|
</TekWalletProvider>
|
|
127
187
|
```
|
|
128
188
|
|
|
189
|
+
**Ví dụ cấu hình đầy đủ cho mobile app:**
|
|
190
|
+
|
|
191
|
+
```jsx
|
|
192
|
+
import { TekWalletProvider, ThemeModes } from "tek-wallet";
|
|
193
|
+
|
|
194
|
+
function App() {
|
|
195
|
+
const handleLogout = () => {
|
|
196
|
+
// Xử lý logout logic
|
|
197
|
+
console.log("User logged out");
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const scanQRCode = (callback) => {
|
|
201
|
+
// Custom QR scan implementation cho mobile
|
|
202
|
+
// Gọi native QR scanner
|
|
203
|
+
window.nativeQRScanner?.scan(callback);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<TekWalletProvider
|
|
208
|
+
theme={customTheme}
|
|
209
|
+
themeMode={ThemeModes.DARK}
|
|
210
|
+
isSSO
|
|
211
|
+
accessToken={accessToken}
|
|
212
|
+
options={{
|
|
213
|
+
useDefaultToastMessage: true,
|
|
214
|
+
hideDefaultActivities: true,
|
|
215
|
+
hideActivitySectionInAssetView: true,
|
|
216
|
+
useBasicAmountGroupInAssetView: true,
|
|
217
|
+
hideBackButtons: {
|
|
218
|
+
activity: true,
|
|
219
|
+
},
|
|
220
|
+
}}
|
|
221
|
+
topOffset={viewportStatusBarHeight || 0}
|
|
222
|
+
onLogout={handleLogout}
|
|
223
|
+
overrideQRScanMethod={isMobileApp ? scanQRCode : undefined}
|
|
224
|
+
>
|
|
225
|
+
<YourApp />
|
|
226
|
+
</TekWalletProvider>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
129
231
|
### ReceiveDirectly
|
|
130
232
|
|
|
131
233
|
Component cho phép hiển thị QR code và địa chỉ nhận token trực tiếp, hỗ trợ cả nhận nội bộ và nhận từ blockchain.
|