@tuwaio/quasar-sdk 0.0.18 → 0.1.1
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 +56 -166
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +69 -170
- package/dist/index.d.ts +69 -170
- package/dist/index.js +2 -1
- package/package.json +9 -55
- package/dist/chunk-C3D4A4ZL.cjs +0 -1
- package/dist/chunk-C6JAMIC3.js +0 -1
- package/dist/chunk-GZ7OST4D.js +0 -1
- package/dist/chunk-NJH5FYLU.cjs +0 -2
- package/dist/chunk-RSHZA2NR.js +0 -1
- package/dist/chunk-UIDJZGQ7.cjs +0 -1
- package/dist/chunk-VABKD4LZ.js +0 -1
- package/dist/chunk-VLHVLJGE.cjs +0 -1
- package/dist/chunk-YPUBFZPR.js +0 -2
- package/dist/chunk-YUZXHNP6.cjs +0 -1
- package/dist/react/evm.cjs +0 -1
- package/dist/react/evm.d.cts +0 -56
- package/dist/react/evm.d.ts +0 -56
- package/dist/react/evm.js +0 -1
- package/dist/react/shared.cjs +0 -1
- package/dist/react/shared.d.cts +0 -59
- package/dist/react/shared.d.ts +0 -59
- package/dist/react/shared.js +0 -1
- package/dist/react/solana.cjs +0 -1
- package/dist/react/solana.d.cts +0 -52
- package/dist/react/solana.d.ts +0 -52
- package/dist/react/solana.js +0 -1
- package/dist/react.cjs +0 -1
- package/dist/react.d.cts +0 -60
- package/dist/react.d.ts +0 -60
- package/dist/react.js +0 -1
- package/dist/types-C4cwIvHT.d.cts +0 -190
- package/dist/types-C4cwIvHT.d.ts +0 -190
package/README.md
CHANGED
|
@@ -7,25 +7,24 @@
|
|
|
7
7
|
<img src="https://cdn.jsdelivr.net/gh/TuwaIO/workflows@main/preview/repos/quasar_sdk.png" alt="Quasar SDK Architecture" width="100%" />
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
-
> The official **Layer 5 (L5)** server-side Node.js & Edge SDK for the **TUWA Quasar Cloud
|
|
10
|
+
> The official **Layer 5 (L5)** server-side Node.js & Edge SDK for the **TUWA Quasar Cloud**.
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
## 🏛️ What is `@tuwaio/quasar-sdk`?
|
|
15
15
|
|
|
16
|
-
`@tuwaio/quasar-sdk` is **Layer 5 (L5)** of the TUWA ecosystem architecture — the official backend companion to the TUWA client libraries. It serves as the gateway to the **Quasar Cloud Engine**, allowing your server to securely push transaction logs, query paginated transaction histories, and
|
|
16
|
+
`@tuwaio/quasar-sdk` is **Layer 5 (L5)** of the TUWA ecosystem architecture — the official backend companion to the TUWA client libraries. It serves as the gateway to the **Quasar Cloud Engine**, allowing your server to securely push transaction logs, query paginated transaction histories, and sync infrastructure states.
|
|
17
17
|
|
|
18
|
-
It operates strictly on the server (Node.js, Next.js Server Actions, or Edge functions) and uses Secret Keys to communicate with Quasar's iron-dome guarded endpoints.
|
|
18
|
+
It operates strictly on the server (Node.js, Next.js Server Actions, or Edge functions) and uses Secret Keys to communicate with Quasar's iron-dome guarded endpoints.
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
## ✨ Key Features
|
|
23
23
|
|
|
24
24
|
- **☁️ Cloud Sync**: Automatically persist pending and terminal transaction states to the Quasar Database for cross-device history.
|
|
25
|
-
- **🔐
|
|
25
|
+
- **🔐 Headless SIWX (CAIP-122) Auth Ready**: Seamlessly pairs with `@tuwaio/sdk/siwx/server` for strict cryptographic verification of user sessions before allowing database writes.
|
|
26
26
|
- **⚡ Edge Ready**: Uses `ofetch` and lightweight cryptography to run seamlessly in Cloudflare Workers and Vercel Edge.
|
|
27
27
|
- **📦 InMemory Sync**: Perfectly pairs with `@tuwaio/sdk/pulsar` (`createTxInMemoryStore`) to fetch history and hydrate local React states.
|
|
28
|
-
- **⛓️ Multi-Chain Support**: Provides separate lightweight bridges for EVM (`react/evm`) and Solana (`react/solana`), ensuring minimal bundle sizes.
|
|
29
28
|
|
|
30
29
|
---
|
|
31
30
|
|
|
@@ -44,7 +43,8 @@ _Note: `ofetch` and `@tuwaio/pulsar-core` are required as peer dependencies to e
|
|
|
44
43
|
This is a basic example of how to interact with the Quasar Cloud directly from your secure backend environments (like Next.js API Routes, Server Actions, or NestJS).
|
|
45
44
|
|
|
46
45
|
```typescript
|
|
47
|
-
import { Quasar
|
|
46
|
+
import { Quasar } from '@tuwaio/quasar-sdk';
|
|
47
|
+
import { verifySiwxPayload, type SiwxSession } from '@tuwaio/sdk/siwx/server';
|
|
48
48
|
import type { Transaction } from '@tuwaio/sdk/pulsar';
|
|
49
49
|
|
|
50
50
|
// Initialize Quasar with your Secret Key from the Dashboard
|
|
@@ -53,9 +53,9 @@ const quasar = new Quasar({ secretKey: process.env.QUASAR_SDK_SK ?? '' });
|
|
|
53
53
|
/**
|
|
54
54
|
* Example Next.js Server Action to Sync a Transaction
|
|
55
55
|
*/
|
|
56
|
-
export async function syncTransaction(tx: Transaction,
|
|
56
|
+
export async function syncTransaction(tx: Transaction, sessionData: SiwxSession) {
|
|
57
57
|
// 1. Verify the client's signature (prevent unauthorized spoofing)
|
|
58
|
-
const isValid = await
|
|
58
|
+
const isValid = await verifySiwxPayload(sessionData);
|
|
59
59
|
if (!isValid) throw new Error('Invalid signature.');
|
|
60
60
|
|
|
61
61
|
// 2. Sync the transaction securely to the Quasar Cloud
|
|
@@ -68,9 +68,9 @@ export async function syncTransaction(tx: Transaction, authData: MiniSessionAuth
|
|
|
68
68
|
*/
|
|
69
69
|
export async function getHistory(
|
|
70
70
|
params: { walletAddress: string; page: number; limit: number; appName: string },
|
|
71
|
-
|
|
71
|
+
sessionData: SiwxSession,
|
|
72
72
|
) {
|
|
73
|
-
const isValid = await
|
|
73
|
+
const isValid = await verifySiwxPayload(sessionData);
|
|
74
74
|
if (!isValid) throw new Error('Invalid signature.');
|
|
75
75
|
|
|
76
76
|
// Return the paginated transaction history
|
|
@@ -80,83 +80,19 @@ export async function getHistory(
|
|
|
80
80
|
|
|
81
81
|
---
|
|
82
82
|
|
|
83
|
-
## 🔐
|
|
83
|
+
## 🔐 Frontend Authentication (SIWX)
|
|
84
84
|
|
|
85
|
-
The SDK
|
|
85
|
+
The Quasar SDK relies on the standard **SIWX (CAIP-122)** protocol for authenticating requests.
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
You should use the headless `useSatelliteSiwxAutoAuth` hook provided by `@tuwaio/sdk/siwx` on your frontend. This hook automatically prompts users to sign a CAIP-122 message when they connect their wallet, and establishes a secure session with your backend.
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
// src/hooks/useAuthStore.ts
|
|
93
|
-
import { utils } from '@tuwaio/quasar-sdk';
|
|
94
|
-
|
|
95
|
-
export const useAuthStore = utils.createMiniSessionStore('quasar-mini-session-storage');
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
To prevent issues with missing optional peer dependencies at build time, the SDK exposes separate ecosystem entry points for the Bridge:
|
|
99
|
-
|
|
100
|
-
### EVM-Only Bridge (No Solana dependencies required)
|
|
101
|
-
|
|
102
|
-
If your project only supports EVM chains, import from the `/react/evm` subpath.
|
|
103
|
-
|
|
104
|
-
```tsx
|
|
105
|
-
import { QuasarEvmAuthBridge } from '@tuwaio/quasar-sdk/react/evm';
|
|
106
|
-
import { useAuthStore } from '@/hooks/useAuthStore';
|
|
107
|
-
|
|
108
|
-
export function MyApp({ activeConnection, store, wagmiConfig }) {
|
|
109
|
-
const session = useAuthStore((s) => s.miniSession);
|
|
110
|
-
const setSession = useAuthStore((s) => s.setMiniSession);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<QuasarEvmAuthBridge
|
|
114
|
-
activeConnection={activeConnection} // Structural interface for wallet state
|
|
115
|
-
store={store} // Zustand store API
|
|
116
|
-
wagmiConfig={wagmiConfig} // Wagmi config
|
|
117
|
-
session={session} // Current session state
|
|
118
|
-
setSession={setSession} // Session setter
|
|
119
|
-
/>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Solana-Only Bridge (No EVM dependencies required)
|
|
125
|
-
|
|
126
|
-
If your project only supports Solana, import from the `/react/solana` subpath.
|
|
127
|
-
|
|
128
|
-
```tsx
|
|
129
|
-
import { QuasarSolanaAuthBridge } from '@tuwaio/quasar-sdk/react/solana';
|
|
130
|
-
import { useAuthStore } from '@/hooks/useAuthStore';
|
|
131
|
-
|
|
132
|
-
export function MyApp({ activeConnection, store }) {
|
|
133
|
-
const session = useAuthStore((s) => s.miniSession);
|
|
134
|
-
const setSession = useAuthStore((s) => s.setMiniSession);
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<QuasarSolanaAuthBridge
|
|
138
|
-
activeConnection={activeConnection}
|
|
139
|
-
store={store}
|
|
140
|
-
session={session}
|
|
141
|
-
setSession={setSession}
|
|
142
|
-
/>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Unified Cross-Chain Bridge
|
|
148
|
-
|
|
149
|
-
If your project supports both ecosystems and has all peer dependencies installed (`@wagmi/core`, `@solana/react`, etc.), you can use the unified bridge:
|
|
150
|
-
|
|
151
|
-
```tsx
|
|
152
|
-
import { QuasarAuthBridge } from '@tuwaio/quasar-sdk/react';
|
|
153
|
-
```
|
|
89
|
+
For detailed frontend integration, see the [SIWX Documentation](https://sdk.docs.tuwa.io/quasar-cloud/react-bridges).
|
|
154
90
|
|
|
155
91
|
---
|
|
156
92
|
|
|
157
93
|
## 🌍 The Full Flow (Production Architecture)
|
|
158
94
|
|
|
159
|
-
To see how incredibly powerful `@tuwaio/quasar-sdk` is when combined with `@tuwaio/sdk`, here is a complete architectural overview without any skipped steps. Notice how the **
|
|
95
|
+
To see how incredibly powerful `@tuwaio/quasar-sdk` is when combined with `@tuwaio/sdk`, here is a complete architectural overview without any skipped steps. Notice how the **Pulsar Store** and **Headless SIWX** dance together effortlessly:
|
|
160
96
|
|
|
161
97
|
### 1. Define Your Transaction Types (`types.ts`)
|
|
162
98
|
|
|
@@ -186,39 +122,28 @@ Proxy calls to Quasar Cloud using your backend to protect secret keys.
|
|
|
186
122
|
// src/app/actions.ts
|
|
187
123
|
'use server';
|
|
188
124
|
|
|
189
|
-
import { Quasar
|
|
125
|
+
import { Quasar } from '@tuwaio/quasar-sdk';
|
|
126
|
+
import { verifySiwxPayload, type SiwxSession } from '@tuwaio/sdk/siwx/server';
|
|
190
127
|
import { TransactionUnion } from '@/types';
|
|
191
128
|
|
|
192
129
|
const quasar = new Quasar({ secretKey: process.env.QUASAR_SDK_SK ?? '' });
|
|
193
130
|
|
|
194
|
-
export async function syncTransaction(tx: TransactionUnion,
|
|
195
|
-
const isValid = await
|
|
131
|
+
export async function syncTransaction(tx: TransactionUnion, sessionData: SiwxSession) {
|
|
132
|
+
const isValid = await verifySiwxPayload(sessionData);
|
|
196
133
|
if (!isValid) throw new Error('Invalid signature.');
|
|
197
134
|
|
|
198
135
|
await quasar.pulsar.syncCreate(tx, 'My App');
|
|
199
136
|
return { success: true };
|
|
200
137
|
}
|
|
201
138
|
|
|
202
|
-
export async function getHistory(params: any,
|
|
203
|
-
const isValid = await
|
|
139
|
+
export async function getHistory(params: any, sessionData: SiwxSession) {
|
|
140
|
+
const isValid = await verifySiwxPayload(sessionData);
|
|
204
141
|
if (!isValid) throw new Error('Invalid signature.');
|
|
205
142
|
|
|
206
143
|
return quasar.pulsar.getHistory(params);
|
|
207
144
|
}
|
|
208
145
|
```
|
|
209
146
|
|
|
210
|
-
### 3. The Client Auth Store (`useAuthStore.ts`)
|
|
211
|
-
|
|
212
|
-
```tsx
|
|
213
|
-
// src/hooks/useAuthStore.ts
|
|
214
|
-
import { utils } from '@tuwaio/quasar-sdk';
|
|
215
|
-
|
|
216
|
-
// Automatically persists the verified signature in localStorage
|
|
217
|
-
export const useAuthStore = utils.createMiniSessionStore('quasar-mini-session-storage');
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### 4. The Headless Tracking Store (`usePulsarStore.ts`)
|
|
221
|
-
|
|
222
147
|
```ts
|
|
223
148
|
// src/hooks/usePulsarStore.ts
|
|
224
149
|
'use client';
|
|
@@ -226,7 +151,8 @@ export const useAuthStore = utils.createMiniSessionStore('quasar-mini-session-st
|
|
|
226
151
|
import { createPulsarStore, createTxInMemoryStore, createBoundedUseStore } from '@tuwaio/sdk/pulsar';
|
|
227
152
|
import { pulsarEvmAdapter } from '@tuwaio/evm-sdk/pulsar';
|
|
228
153
|
import { pulsarSolanaAdapter } from '@tuwaio/solana-sdk/pulsar';
|
|
229
|
-
import {
|
|
154
|
+
import { useSiwxSessionStore } from '@tuwaio/sdk/siwx';
|
|
155
|
+
import { preFlightTxCheck } from '@tuwaio/quasar-sdk';
|
|
230
156
|
|
|
231
157
|
import { getHistory, syncTransaction } from '@/app/actions';
|
|
232
158
|
import { wagmiConfig, appEVMChains, solanaRPCUrls } from '@/configs/appConfig';
|
|
@@ -238,14 +164,16 @@ const initialStore = createPulsarStore<TransactionUnion>({
|
|
|
238
164
|
name: storageName,
|
|
239
165
|
adapter: [pulsarEvmAdapter(wagmiConfig, appEVMChains), pulsarSolanaAdapter({ rpcUrls: solanaRPCUrls })],
|
|
240
166
|
beforeTxProcess: async () => {
|
|
241
|
-
// Ensures we have a valid
|
|
242
|
-
await
|
|
167
|
+
// Ensures we have a valid SIWX session and Quasar Cloud is reachable before executing blockchain logic
|
|
168
|
+
await preFlightTxCheck();
|
|
243
169
|
},
|
|
244
170
|
onRemoteCreate: async (tx) => {
|
|
245
171
|
try {
|
|
246
172
|
// Syncs the new transaction to Quasar via Next.js Server Actions
|
|
247
|
-
const
|
|
248
|
-
|
|
173
|
+
const session = useSiwxSessionStore.getState().session;
|
|
174
|
+
if (session) {
|
|
175
|
+
await syncTransaction(tx as TransactionUnion, session);
|
|
176
|
+
}
|
|
249
177
|
} catch (err) {
|
|
250
178
|
console.error('[PulsarHook] Remote sync failed:', err);
|
|
251
179
|
}
|
|
@@ -259,8 +187,10 @@ const pulsarInMemoryStore = createTxInMemoryStore<TransactionUnion>({
|
|
|
259
187
|
localTransactionsPool: initialStore.getState().transactionsPool,
|
|
260
188
|
getHistory: async ({ page, walletAddress }) => {
|
|
261
189
|
try {
|
|
262
|
-
const
|
|
263
|
-
|
|
190
|
+
const session = useSiwxSessionStore.getState().session;
|
|
191
|
+
if (!session) return null;
|
|
192
|
+
|
|
193
|
+
const history = await getHistory({ walletAddress, page, limit: 10, appName: 'My App' }, session);
|
|
264
194
|
|
|
265
195
|
if (!history) return null;
|
|
266
196
|
|
|
@@ -280,49 +210,7 @@ initialStore.subscribe((state) => pulsarInMemoryStore.getState().syncWithLocalPo
|
|
|
280
210
|
export const usePulsarInMemoryStore = createBoundedUseStore(pulsarInMemoryStore);
|
|
281
211
|
```
|
|
282
212
|
|
|
283
|
-
###
|
|
284
|
-
|
|
285
|
-
```tsx
|
|
286
|
-
// src/providers/QuasarSDKAuthProvider.tsx
|
|
287
|
-
'use client';
|
|
288
|
-
|
|
289
|
-
import { useContext, useEffect } from 'react';
|
|
290
|
-
import { useSatelliteConnectStore, SatelliteStoreContext } from '@tuwaio/sdk/satellite';
|
|
291
|
-
import { QuasarActiveConnection, QuasarAuthBridge as QuasarSDKAuthBridge } from '@tuwaio/quasar-sdk/react';
|
|
292
|
-
|
|
293
|
-
import { wagmiConfig } from '@/configs/appConfig';
|
|
294
|
-
import { useAuthStore } from '@/hooks/useAuthStore';
|
|
295
|
-
|
|
296
|
-
export function QuasarAuthBridge() {
|
|
297
|
-
const activeConnection = useSatelliteConnectStore((s) => s.activeConnection);
|
|
298
|
-
const store = useContext(SatelliteStoreContext);
|
|
299
|
-
|
|
300
|
-
const session = useAuthStore((s) => s.miniSession);
|
|
301
|
-
const setSession = useAuthStore((s) => s.setMiniSession);
|
|
302
|
-
const clearSession = useAuthStore((s) => s.clearSession);
|
|
303
|
-
|
|
304
|
-
// Clear Quasar Mini-Session when wallet disconnects
|
|
305
|
-
useEffect(() => {
|
|
306
|
-
if (!activeConnection?.isConnected) {
|
|
307
|
-
clearSession();
|
|
308
|
-
}
|
|
309
|
-
}, [activeConnection?.isConnected, clearSession]);
|
|
310
|
-
|
|
311
|
-
if (!activeConnection || !store) return null;
|
|
312
|
-
|
|
313
|
-
return (
|
|
314
|
-
<QuasarSDKAuthBridge
|
|
315
|
-
activeConnection={activeConnection as QuasarActiveConnection}
|
|
316
|
-
store={store as any}
|
|
317
|
-
wagmiConfig={wagmiConfig}
|
|
318
|
-
session={session}
|
|
319
|
-
setSession={setSession}
|
|
320
|
-
/>
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
### 6. Nova Transactions Provider (`NovaTransactionsProvider.tsx`)
|
|
213
|
+
### 4. Nova Transactions Provider (`NovaTransactionsProvider.tsx`)
|
|
326
214
|
|
|
327
215
|
```tsx
|
|
328
216
|
// src/providers/NovaTransactionsProvider.tsx
|
|
@@ -361,24 +249,24 @@ export function NovaTransactionsProvider({ pagination }: { pagination: TxInMemor
|
|
|
361
249
|
}
|
|
362
250
|
```
|
|
363
251
|
|
|
364
|
-
###
|
|
252
|
+
### 5. The Seamless UI Integration (`AppProviders.tsx`)
|
|
365
253
|
|
|
366
254
|
```tsx
|
|
367
255
|
// src/providers/AppProviders.tsx
|
|
368
256
|
'use client';
|
|
369
257
|
|
|
370
|
-
import { SatelliteConnectProvider } from '@tuwaio/sdk/satellite';
|
|
258
|
+
import { SatelliteConnectProvider, useSatelliteConnection } from '@tuwaio/sdk/satellite';
|
|
371
259
|
import { NovaConnectProvider } from '@tuwaio/sdk/nova-connect';
|
|
372
260
|
import { satelliteEVMAdapter } from '@tuwaio/evm-sdk/satellite';
|
|
373
261
|
import { EVMConnectorsWatcher } from '@tuwaio/evm-sdk/nova-connect';
|
|
374
262
|
import { satelliteSolanaAdapter } from '@tuwaio/solana-sdk/satellite';
|
|
375
263
|
import { SolanaConnectorsWatcher } from '@tuwaio/solana-sdk/nova-connect';
|
|
376
|
-
import {
|
|
264
|
+
import { useSiwx, useSiwxSession } from '@tuwaio/sdk/siwx';
|
|
265
|
+
import { isSafeApp, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/sdk/orbit';
|
|
377
266
|
|
|
378
267
|
import { appEVMChains, solanaRPCUrls, wagmiConfig } from '@/configs/appConfig';
|
|
379
268
|
import { usePulsarInMemoryStore, usePulsarStore } from '@/hooks/usePulsarStore';
|
|
380
269
|
import { NovaTransactionsProvider } from '@/providers/NovaTransactionsProvider';
|
|
381
|
-
import { QuasarAuthBridge } from '@/providers/QuasarSDKAuthProvider';
|
|
382
270
|
|
|
383
271
|
export function AppProviders({ children }: { children: React.ReactNode }) {
|
|
384
272
|
const getAdapter = usePulsarStore((state) => state.getAdapter);
|
|
@@ -393,31 +281,35 @@ export function AppProviders({ children }: { children: React.ReactNode }) {
|
|
|
393
281
|
|
|
394
282
|
const pagination = { isLoading, isError, currentPage, hasMore, fetchNextPage };
|
|
395
283
|
|
|
284
|
+
// Watch SIWX session to keep connection state aligned
|
|
285
|
+
const siwxSession = useSiwxSession();
|
|
286
|
+
const { signIn } = useSiwx();
|
|
287
|
+
|
|
396
288
|
return (
|
|
397
289
|
<SatelliteConnectProvider
|
|
398
290
|
adapter={[satelliteEVMAdapter(wagmiConfig, appEVMChains), satelliteSolanaAdapter({ rpcUrls: solanaRPCUrls })]}
|
|
399
291
|
autoConnect={true}
|
|
400
292
|
callbackAfterConnected={async (connection) => {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
293
|
+
const isEVM = getAdapterFromConnectorType(connection.connectorType) === OrbitAdapter.EVM;
|
|
294
|
+
if (isEVM && isSafeApp) return;
|
|
295
|
+
|
|
296
|
+
// Trigger SIWX flow
|
|
297
|
+
await signIn();
|
|
298
|
+
|
|
299
|
+
// Fetch history slightly after connection and sign-in
|
|
300
|
+
setTimeout(() => fetchInitial(connection.address), 2000);
|
|
408
301
|
}}
|
|
409
302
|
>
|
|
410
|
-
<EVMConnectorsWatcher wagmiConfig={wagmiConfig} />
|
|
411
|
-
<SolanaConnectorsWatcher />
|
|
303
|
+
<EVMConnectorsWatcher wagmiConfig={wagmiConfig} siwx={siwxSession} />
|
|
304
|
+
<SolanaConnectorsWatcher siwx={siwxSession} />
|
|
412
305
|
|
|
413
|
-
<QuasarAuthBridge />
|
|
414
306
|
<NovaTransactionsProvider pagination={pagination} />
|
|
415
307
|
|
|
416
308
|
<NovaConnectProvider
|
|
417
309
|
appChains={appEVMChains}
|
|
418
310
|
solanaRPCUrls={solanaRPCUrls}
|
|
419
311
|
transactionPool={transactionsPool}
|
|
420
|
-
pulsarAdapter={getAdapter()
|
|
312
|
+
pulsarAdapter={getAdapter()}
|
|
421
313
|
withImpersonated
|
|
422
314
|
withBalance
|
|
423
315
|
withChain
|
|
@@ -430,7 +322,7 @@ export function AppProviders({ children }: { children: React.ReactNode }) {
|
|
|
430
322
|
}
|
|
431
323
|
```
|
|
432
324
|
|
|
433
|
-
###
|
|
325
|
+
### 6. Creating a Transaction (Usage)
|
|
434
326
|
|
|
435
327
|
Now you can safely execute strictly-typed, cross-chain transactions anywhere in your app. The store automatically routes the transaction to the correct adapter, and Quasar syncs it to the cloud.
|
|
436
328
|
|
|
@@ -485,12 +377,10 @@ export function SwapButton() {
|
|
|
485
377
|
|
|
486
378
|
## 📦 Available Namespaces
|
|
487
379
|
|
|
488
|
-
This package provides the following server-side utilities and React
|
|
380
|
+
This package provides the following server-side utilities and React helpers:
|
|
489
381
|
|
|
490
382
|
- `Quasar` — The main server-side client class instance used to access `quasar.pulsar.*` methods.
|
|
491
|
-
- `
|
|
492
|
-
- `QuasarAuthBridge` (exported via subpaths) — The client-side React component for triggering and managing the signature flow automatically when the wallet connects.
|
|
493
|
-
- `MiniSessionAuth` — The strict type definition mapping the structure of the authentication payload.
|
|
383
|
+
- `preFlightTxCheck` — A client-side helper to ensure the user has a valid SIWX session and Quasar Cloud is reachable before prompting wallet signatures.
|
|
494
384
|
|
|
495
385
|
---
|
|
496
386
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var siwxReact=require('@tuwaio/siwx-react'),ofetch=require('ofetch');var a="https://api.tuwa.io",c="/v1/engine/pulsar/sync",u="/v1/engine/pulsar/history";var i=class extends Error{status;originalError;constructor(r,e,t){super(r),this.name="QuasarSDKError",this.status=e,this.originalError=t;}},n=class{secretKey;internalSecret;baseUrl;timeout;constructor(r){if(!r.secretKey)throw new Error("[Quasar SDK] Missing API Key. Provide a secretKey starting with sk_live_.");this.secretKey=r.secretKey,this.internalSecret=r.internalSecret,this.baseUrl=r.baseUrl||a,this.timeout=r.timeout||1e4;}async request(r,e={}){try{return await ofetch.ofetch(r,{baseURL:this.baseUrl,timeout:this.timeout,...e,headers:{"Content-Type":"application/json","x-tuwa-secret-key":this.secretKey,...this.internalSecret?{"x-internal-secret":this.internalSecret}:{},...e.headers}})}catch(t){throw this.buildError(t)}}buildError(r){let e=r,t=e.statusCode??e.response?.status,p=(e.data??e.response?._data)?.error??e.message??"Unknown Error";return (t===401||t===403)&&console.error("\u{1F6A8} [Quasar SDK] Auth Error. Check your Secret Key and scopes."),new i(`[Quasar SDK] Request Failed (${t}): ${p}`,t,e)}};var o=class{constructor(r){this.client=r;}async syncCreate(r,e){return this.client.request(c,{method:"POST",body:{...r,appName:e}})}async getHistory(r={}){return this.client.request(u,{method:"GET",query:{page:r.page??1,limit:r.limit??10,chainId:r.chainId,status:r.status,txKey:r.txKey,appName:r.appName,walletAddress:r.walletAddress}})}};async function Q(s){if(!siwxReact.useSiwxSessionStore.getState().session)throw new Error("[QuasarSDK] No SIWX Session found. User must be signed in.");let e=s||a;try{let t=await fetch(`${e}/v1/engine/monitoring/health`,{method:"GET",cache:"no-store"});if(!t.ok)throw new Error(`[QuasarSDK] API Health check failed with status: ${t.status}`)}catch(t){throw new Error("[QuasarSDK] Quasar Cloud Engine is currently unreachable.",{cause:t})}}var l=class{client;pulsar;constructor(r){this.client=new n(r),this.pulsar=new o(this.client);}};
|
|
2
|
+
exports.BASE_API_URL=a;exports.PULSAR_HISTORY_ENDPOINT=u;exports.PULSAR_SYNC_ENDPOINT=c;exports.PulsarModule=o;exports.Quasar=l;exports.QuasarSDKError=i;exports.preFlightTxCheck=Q;
|