@quantabit/points-sdk 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 QuantaBit Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # @quantabit/points-sdk
2
+
3
+ > QuantaBit Points System SDK - Points balance, check-in, transactions, and gifting
4
+
5
+ ## 📦 Installation
6
+
7
+ ```bash
8
+ npm install @quantabit/points-sdk
9
+ # or
10
+ yarn add @quantabit/points-sdk
11
+ ```
12
+
13
+ ## 🚀 Quick Start
14
+
15
+ ### 1. Setup Provider
16
+
17
+ ```jsx
18
+ import { PointsProvider } from "@quantabit/points-sdk";
19
+ import "@quantabit/points-sdk/styles.css";
20
+
21
+ function App() {
22
+ return (
23
+ <PointsProvider
24
+ apiUrl="https://api.example.com/v1"
25
+ token="your-auth-token"
26
+ language="en"
27
+ onCheckIn={(result) => console.log("Check-in successful:", result)}
28
+ >
29
+ <YourComponent />
30
+ </PointsProvider>
31
+ );
32
+ }
33
+ ```
34
+
35
+ ### 2. Using Components
36
+
37
+ ```jsx
38
+ import {
39
+ PointsBalance,
40
+ CheckInCalendar,
41
+ PointsHistory,
42
+ TransferPoints
43
+ } from '@quantabit/points-sdk';
44
+
45
+ // Points balance display
46
+ <PointsBalance showDetails showStats />
47
+
48
+ // Check-in calendar
49
+ <CheckInCalendar
50
+ onCheckIn={() => console.log('Checked in!')}
51
+ showStreak
52
+ showRewards
53
+ />
54
+
55
+ // Points history
56
+ <PointsHistory
57
+ pageSize={20}
58
+ showFilter
59
+ />
60
+
61
+ // Points transfer
62
+ <TransferPoints
63
+ onSuccess={(result) => console.log('Transfer successful:', result)}
64
+ />
65
+ ```
66
+
67
+ ### 3. Using Hooks
68
+
69
+ ```jsx
70
+ import { usePoints } from "@quantabit/points-sdk";
71
+
72
+ function MyComponent() {
73
+ const {
74
+ account, // Points account info
75
+ balance, // Current balance
76
+ checkInStatus, // Check-in status
77
+ loading,
78
+ loadAccount, // Load account
79
+ checkIn, // Execute check-in
80
+ transfer, // Transfer points
81
+ exchange, // Exchange
82
+ } = usePoints();
83
+
84
+ return (
85
+ <div>
86
+ <p>Balance: {balance}</p>
87
+ <button onClick={checkIn}>Check In</button>
88
+ </div>
89
+ );
90
+ }
91
+ ```
92
+
93
+ ## 📚 Components
94
+
95
+ | Component | Description |
96
+ | ----------------- | --------------------------------------------- |
97
+ | `PointsBalance` | Points balance display card |
98
+ | `CheckInCalendar` | Check-in calendar with streak rewards display |
99
+ | `PointsHistory` | Points transaction history list |
100
+ | `TransferPoints` | Points gifting form component |
101
+
102
+ ## 🪝 Hooks
103
+
104
+ | Hook | Description |
105
+ | ----------- | ----------------------------------------------------------------- |
106
+ | `usePoints` | Get Points Context, includes account, check-in, transfer features |
107
+
108
+ ## ⚙️ PointsProvider Configuration
109
+
110
+ | Prop | Type | Required | Description |
111
+ | ------------ | ------------------ | -------- | ------------------------------ |
112
+ | `apiUrl` | `string` | Yes | API base URL |
113
+ | `token` | `string` | No | Auth Token |
114
+ | `language` | `'zh' \| 'en'` | No | Language setting, default `zh` |
115
+ | `onCheckIn` | `(result) => void` | No | Check-in success callback |
116
+ | `onTransfer` | `(result) => void` | No | Transfer success callback |
117
+ | `onError` | `(error) => void` | No | Error callback |
118
+
119
+ ## 📖 API Types
120
+
121
+ ```typescript
122
+ // Points account
123
+ interface PointsAccount {
124
+ user_did: string;
125
+ balance: number; // Available balance
126
+ frozen_balance: number; // Frozen balance
127
+ total_earned: number; // Total earned
128
+ total_spent: number; // Total spent
129
+ created_at: string;
130
+ updated_at: string;
131
+ }
132
+
133
+ // Transaction types
134
+ type TransactionType =
135
+ | "earn" // Earn
136
+ | "spend" // Spend
137
+ | "transfer" // Transfer
138
+ | "exchange" // Exchange
139
+ | "expire" // Expire
140
+ | "refund"; // Refund
141
+
142
+ // Points sources
143
+ type PointSource =
144
+ | "check_in" // Check-in
145
+ | "task" // Task
146
+ | "referral" // Referral
147
+ | "activity" // Activity
148
+ | "purchase" // Purchase
149
+ | "transfer_in" // Transfer in
150
+ | "admin_grant"; // System grant
151
+ ```
152
+
153
+ ## 🎨 Custom Styling
154
+
155
+ Use CSS variables for custom theming:
156
+
157
+ ```css
158
+ :root {
159
+ --points-primary: #f59e0b;
160
+ --points-success: #10b981;
161
+ --points-bg: #ffffff;
162
+ }
163
+ ```
164
+
165
+ ## 📄 License
166
+
167
+ MIT License
168
+
169
+
170
+
171
+ ---
172
+
173
+ ## 🌐 Brand & Links
174
+ - Official Mainnet: [QuantaBit Chain](https://qbitchain.io/)
175
+ - Developer Platform: [Developer Platform](https://developer.quantabit.io/)
176
+ - Open Platform: [Open Platform](https://open.quantabit.io/)
177
+ - Payment Platform: [Pay Platform](https://pay.qbitwallet.io/)
178
+ - Feedback: [Feedback](https://xwin.live/qbit)