@ultrade/react-sdk 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/README.md +78 -81
  2. package/package.json +2 -3
package/README.md CHANGED
@@ -4,10 +4,11 @@ Redux Toolkit Query adaptor for @ultrade/ultrade-js-sdk. Provides RTK Query endp
4
4
 
5
5
  **Repository:** [https://github.com/ultrade-org/ultrade-react-sdk](https://github.com/ultrade-org/ultrade-react-sdk)
6
6
 
7
+ **SDK Repository:** [https://github.com/ultrade-org/ultrade-js-sdk](https://github.com/ultrade-org/ultrade-js-sdk)
8
+
7
9
  ## Package Info
8
10
 
9
11
  - **Name:** `@ultrade/react-sdk`
10
- - **Purpose:** Bridge between Redux Toolkit Query and Ultrade SDK
11
12
  - **Main Entry:** `./dist/index.js`
12
13
  - **Types:** `./dist/index.d.ts`
13
14
 
@@ -27,37 +28,6 @@ yarn add @ultrade/react-sdk
27
28
  pnpm add @ultrade/react-sdk
28
29
  ```
29
30
 
30
- ## TypeScript Configuration
31
-
32
- For proper type resolution and convenient development, you need to configure your `tsconfig.json` correctly.
33
-
34
- ### Recommended Configuration
35
-
36
- The configuration should be able to resolve types that account for the `exports` field in `package.json`:
37
-
38
- ```json
39
- {
40
- "compilerOptions": {
41
- "moduleResolution": "nodenext"
42
- // Alternative options: "node16" or "bundler"
43
- }
44
- }
45
- ```
46
-
47
- ### Alternative: Manual Path Configuration
48
-
49
- If you cannot change your TypeScript settings, you can explicitly specify paths:
50
-
51
- ```json
52
- {
53
- "compilerOptions": {
54
- "paths": {
55
- "@ultrade/shared/browser/*": ["../shared/dist/browser/*"]
56
- }
57
- }
58
- }
59
- ```
60
-
61
31
  ## Structure
62
32
 
63
33
  ```
@@ -120,65 +90,92 @@ Defined in `tsconfig.alias.json`:
120
90
  | `@interfaces` | `./src/interfaces/index.ts` | TypeScript interfaces |
121
91
  | `@utils` | `./src/utils/index.ts` | Utility functions |
122
92
 
123
- ## Usage Example
93
+ ### Creating RTK SDK Client
124
94
 
125
95
  ```typescript
126
- import { marketsPairsApi, walletApi } from '@ultrade/react-sdk';
127
-
128
- // Use in React component
129
- function TradingComponent() {
130
- const { data: pairs } = marketsPairsApi.useGetPairListQuery({ companyId: 1 });
131
- const { data: transactions } = walletApi.useGetWalletTransactionsQuery({
132
- type: 'DEPOSIT',
133
- page: 1,
134
- limit: 50
135
- });
136
-
137
- return (
138
- <div>
139
- {/* Render data */}
140
- </div>
141
- );
142
- }
96
+ import RTKSDKAdaptor from '@ultrade/react-sdk';
97
+ import algosdk from 'algosdk';
98
+
99
+ // Create Algorand SDK client
100
+ const rtkAlgodClient = new algosdk.Algodv2(
101
+ '', // token
102
+ 'https://testnet-api.algonode.cloud', // server
103
+ '' // port
104
+ );
105
+
106
+ // Initialize RTK SDK client (extends Client from @ultrade/ultrade-js-sdk)
107
+ const rtkSdkClient = new RTKSDKAdaptor({
108
+ network: 'testnet', // or 'mainnet'
109
+ apiUrl: 'https://api.testnet.ultrade.org',
110
+ algoSdkClient: rtkAlgodClient,
111
+ websocketUrl: 'wss://ws.testnet.ultrade.org',
112
+ });
113
+
114
+ // Set signer (same as base SDK)
115
+ rtkSdkClient.setSigner({
116
+ signMessage,
117
+ signMessageByToken
118
+ });
143
119
  ```
144
120
 
145
- ## Build Commands
121
+ ### Redux Store Setup
146
122
 
147
- **Important:** First install node_modules from monorepo root (npm_packages)
123
+ ```typescript
124
+ import { SDKReducers, SDKMiddlewares } from '@ultrade/react-sdk';
148
125
 
149
- - `npm run build` - Production build
150
- - `npm run dev` - Development build with watch mode
126
+ export const store = configureStore({
127
+ reducer: {
128
+ // ... your other reducers
129
+ ...SDKReducers
130
+ },
131
+ middleware: (getDefaultMiddleware) =>
132
+ getDefaultMiddleware().concat(SDKMiddlewares)
133
+ });
151
134
 
152
- ## Key Features
135
+ ```
153
136
 
154
- 1. **Type-Safe RTK Query Endpoints** - All endpoints use SDK argument interfaces
155
- 2. **Cache Management** - Automatic cache invalidation with tags
156
- 3. **WebSocket Integration** - Real-time updates through WebSocket handlers
157
- 4. **Error Handling** - Centralized error handling with `withErrorHandling`
158
- 5. **SDK Client Singleton** - Single SDK client instance via `getSdkClient()`
137
+ ### Using RTK Query Hooks
159
138
 
160
- ## Cache Tags
139
+ ```typescript
140
+ import { useAppSelector } from './hooks';
141
+ import { useEffect } from 'react';
142
+
143
+ function Component() {
144
+ //...
145
+
146
+ const { useLazyGetSettingsQuery, useLazyGetPairListQuery } = rtkSdkClient.markets();
147
+ const { useGetTradingKeysQuery, useAddTradingKeyMutation } = rtkSdkClient.walletApi();
148
+
149
+ // Lazy query for settings
150
+ const [getSettings, { data: settings, isLoading: isLoadingSettings }] = useLazyGetSettingsQuery();
151
+
152
+ // Query for trading pairs
153
+ const [getPairList, { data: pairs, isLoading: isLoadingPairs }] = useLazyGetPairListQuery();
154
+
155
+ // Query for trading keys
156
+ const { data: tradingKeys, isLoading: isLoadingKeys } = useGetTradingKeysQuery();
157
+
158
+ // Mutation for creating trading key
159
+ const [addTradingKey, { isLoading: isCreatingKey }] = useAddTradingKeyMutation();
160
+
161
+ return <></>
162
+ }
163
+ ```
161
164
 
162
- All endpoints use cache tags for automatic invalidation:
165
+ ## Redux integration
163
166
 
164
- - `markets_balances` - Balance data
165
- - `markets_settings` - Market settings
166
- - `markets_depth` - Order book depth
167
- - `markets_history` - Historical candles
168
- - `markets_orders` - User orders
169
- - `markets_pair_list` - Trading pairs
170
- - `markets_last_trades` - Recent trades
171
- - `wallet_transactions` - Wallet transactions
172
- - `wallet_transfers` - Transfer history
173
- - `wallet_whitelist` - Withdrawal whitelist
174
- - `wallet_trading_keys` - Trading keys
175
- - `wallet_pending_transactions` - Pending transactions
176
- - `withdrawal_wallets` - Withdrawal wallets
167
+ ```typescript
168
+ import { Provider } from 'react-redux';
169
+ import { store } from './store';
177
170
 
178
- ## Dependencies
171
+ function App() {
172
+
173
+ //component logic
179
174
 
180
- - **Peer Dependencies:**
181
- - `@reduxjs/toolkit`
182
- - `react-redux`
183
- - `@ultrade/ultrade-js-sdk`
184
- - `@ultrade/shared`
175
+ return (
176
+ <Provider store={store}>
177
+ <YourApp />
178
+ </Provider>
179
+ );
180
+ }
181
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrade/react-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "./dist/index.js",
@@ -12,8 +12,7 @@
12
12
  },
13
13
  "author": "",
14
14
  "files": [
15
- "dist",
16
- "README.md"
15
+ "dist"
17
16
  ],
18
17
  "publishConfig": {
19
18
  "registry": "https://registry.npmjs.org/",