@supanovaapp/sdk 0.2.15 → 0.2.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 +75 -1
- package/dist/hooks/useAuth.d.ts +5 -1
- package/dist/hooks/useCantonWallet.d.ts +10 -0
- package/dist/hooks/useSendTransaction.d.ts +3 -3
- package/dist/hooks/useSignMessage.d.ts +3 -3
- package/dist/hooks/useSignRawHashWithModal.d.ts +11 -3
- package/dist/hooks/useSupa.d.ts +4 -1
- package/dist/index.cjs.js +327 -327
- package/dist/index.d.ts +7 -7
- package/dist/index.esm.js +20051 -19954
- package/dist/providers/CantonProvider.d.ts +9 -5
- package/dist/providers/SupaProvider.d.ts +7 -0
- package/dist/services/apiService.d.ts +7 -7
- package/dist/services/cantonService.d.ts +3 -3
- package/dist/utils/converters.d.ts +13 -0
- package/dist/utils/wallet.d.ts +92 -0
- package/package.json +1 -1
- package/dist/hooks/useStellarWallet.d.ts +0 -6
- package/dist/utils/stellar.d.ts +0 -90
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ For a quick overview of the code, check out the demo application in the `/demo`
|
|
|
9
9
|
## Key Features
|
|
10
10
|
|
|
11
11
|
- **Privy.io Authentication** - Email, wallet, and social login methods
|
|
12
|
+
- **Wallet Export** - Export private keys for Solana wallets (with `withExport: true`)
|
|
12
13
|
- **EVM Smart Wallets** - Support for Privy Smart Wallets with gas sponsorship
|
|
13
14
|
- **Built-in Confirmation Modals** - User-friendly signing confirmations
|
|
14
15
|
- **Theme Support** - Light/dark mode with customizable appearance
|
|
@@ -274,6 +275,78 @@ function LoginButton() {
|
|
|
274
275
|
|
|
275
276
|
After successful authentication, `authenticated` becomes `true` and `user` object contains user data.
|
|
276
277
|
|
|
278
|
+
#### Export Wallet Private Key
|
|
279
|
+
|
|
280
|
+
**Note:** Wallet export is only available when `withExport: true` is set in SupaProvider config (Solana wallets).
|
|
281
|
+
|
|
282
|
+
Export your wallet's private key to use it with other wallet clients like Phantom:
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
import { useAuth, useCantonWallet } from '@supa/sdk';
|
|
286
|
+
|
|
287
|
+
function ExportWalletButton() {
|
|
288
|
+
const { exportWallet, authenticated } = useAuth();
|
|
289
|
+
const { cantonWallet } = useCantonWallet();
|
|
290
|
+
|
|
291
|
+
const handleExport = async () => {
|
|
292
|
+
if (!cantonWallet) return;
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
// Export the primary Canton wallet
|
|
296
|
+
await exportWallet({ address: cantonWallet.address });
|
|
297
|
+
|
|
298
|
+
// Or export without specifying address (exports first wallet)
|
|
299
|
+
await exportWallet();
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.error('Export failed:', error);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<button onClick={handleExport} disabled={!authenticated || !cantonWallet}>
|
|
307
|
+
Export Private Key
|
|
308
|
+
</button>
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**What happens:**
|
|
314
|
+
- Privy modal opens showing your private key
|
|
315
|
+
- You can copy the key to use with MetaMask, Phantom, or other wallet clients
|
|
316
|
+
- The key is assembled securely on a different origin - neither you nor Privy can access it during transmission
|
|
317
|
+
|
|
318
|
+
**Security Warning:** Never share your private key! Anyone with your private key has full control over your wallet.
|
|
319
|
+
|
|
320
|
+
#### Complete Logout with State Cleanup
|
|
321
|
+
|
|
322
|
+
For a complete logout that clears all SDK state (Canton balances, registration, etc.), use the `useSupa` hook:
|
|
323
|
+
|
|
324
|
+
```tsx
|
|
325
|
+
import { useSupa } from '@supa/sdk';
|
|
326
|
+
|
|
327
|
+
function App() {
|
|
328
|
+
const { auth, canton, logout } = useSupa();
|
|
329
|
+
|
|
330
|
+
if (!auth.authenticated) {
|
|
331
|
+
return <button onClick={auth.login}>Login</button>;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return (
|
|
335
|
+
<div>
|
|
336
|
+
<p>Welcome! Canton registered: {canton.isRegistered ? 'Yes' : 'No'}</p>
|
|
337
|
+
<button onClick={logout}>Complete Logout</button>
|
|
338
|
+
</div>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**What `useSupa().logout()` does:**
|
|
344
|
+
1. Clears all Canton state (balances, user info, registration flags)
|
|
345
|
+
2. Terminates Privy session
|
|
346
|
+
3. Resets all internal SDK state
|
|
347
|
+
|
|
348
|
+
**Note:** Using `auth.logout()` directly only logs out from Privy but doesn't clear Canton state. For complete cleanup, always use `useSupa().logout()`.
|
|
349
|
+
|
|
277
350
|
---
|
|
278
351
|
|
|
279
352
|
### 3. Canton Network Operations
|
|
@@ -658,8 +731,9 @@ await sendTransaction(command, contracts, {
|
|
|
658
731
|
|
|
659
732
|
| Hook | Purpose | Key Methods |
|
|
660
733
|
|------|---------|-------------|
|
|
734
|
+
| `useSupa` | Main SDK hook | `auth`, `canton`, `api`, `onboard`, `logout` (recommended for complete cleanup) |
|
|
661
735
|
| `useAuth` | Authentication | `login`, `logout`, `authenticated`, `user` |
|
|
662
|
-
| `useCanton` | Canton Network | `registerCanton`, `getBalances`, `sendCantonCoin`, `signMessage`, `sendTransaction`, `getActiveContracts`, `tapDevnet`, `getPendingIncomingTransfers`, `respondToIncomingTransfer` |
|
|
736
|
+
| `useCanton` | Canton Network | `registerCanton`, `getBalances`, `sendCantonCoin`, `signMessage`, `sendTransaction`, `getActiveContracts`, `tapDevnet`, `getPendingIncomingTransfers`, `respondToIncomingTransfer`, `resetState` |
|
|
663
737
|
| `useSignMessage` | Enhanced message signing | `signMessage` with custom modals |
|
|
664
738
|
| `useSendTransaction` | Enhanced transactions | `sendTransaction` with custom modals |
|
|
665
739
|
| `useConfirmModal` | Generic modals | `confirm`, `signMessageConfirm`, `signTransactionConfirm` |
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { User as PrivyUser } from '@privy-io/react-auth';
|
|
|
5
5
|
export interface UseAuthReturn {
|
|
6
6
|
/** Opens Privy login modal */
|
|
7
7
|
login: () => void;
|
|
8
|
-
/** Logs out the current user */
|
|
8
|
+
/** Logs out the current user and clears all SDK state */
|
|
9
9
|
logout: () => Promise<void>;
|
|
10
10
|
/** Whether user is authenticated */
|
|
11
11
|
authenticated: boolean;
|
|
@@ -17,6 +17,10 @@ export interface UseAuthReturn {
|
|
|
17
17
|
getAccessToken: () => Promise<string | null>;
|
|
18
18
|
/** Whether SDK is ready (not loading) */
|
|
19
19
|
ready: boolean;
|
|
20
|
+
/** Export wallet private key (opens Privy modal). Address is optional - defaults to first wallet */
|
|
21
|
+
exportWallet: (options?: {
|
|
22
|
+
address?: string;
|
|
23
|
+
}) => Promise<void>;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Hook for managing user authentication via Privy
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CantonWallet } from '../utils/wallet';
|
|
2
|
+
export interface UseCantonWalletReturn {
|
|
3
|
+
cantonWallets: CantonWallet[];
|
|
4
|
+
cantonWallet: CantonWallet | null;
|
|
5
|
+
}
|
|
6
|
+
/** @deprecated Use useCantonWallet instead */
|
|
7
|
+
export type UseStellarWalletReturn = UseCantonWalletReturn;
|
|
8
|
+
export declare function useCantonWallet(): UseCantonWalletReturn;
|
|
9
|
+
/** @deprecated Use useCantonWallet instead */
|
|
10
|
+
export declare const useStellarWallet: typeof useCantonWallet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CantonWallet } from '../utils/wallet';
|
|
2
2
|
import { CantonQueryCompletionResponseDto, CantonSubmitPreparedOptions } from '../services/cantonService';
|
|
3
3
|
export interface SendTransactionOptions {
|
|
4
4
|
onSuccess?: (result: CantonQueryCompletionResponseDto) => void;
|
|
@@ -21,7 +21,7 @@ export interface UseSendTransactionReturn {
|
|
|
21
21
|
loading: boolean;
|
|
22
22
|
error: Error | null;
|
|
23
23
|
clearError: () => void;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
cantonWallets: CantonWallet[];
|
|
25
|
+
cantonWallet: CantonWallet | null;
|
|
26
26
|
}
|
|
27
27
|
export declare function useSendTransaction(): UseSendTransactionReturn;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CantonWallet } from '../utils/wallet';
|
|
2
2
|
export interface SignMessageOptions {
|
|
3
3
|
onSuccess?: (signature: string) => void;
|
|
4
4
|
onRejection?: () => void;
|
|
@@ -19,7 +19,7 @@ export interface UseSignMessageReturn {
|
|
|
19
19
|
loading: boolean;
|
|
20
20
|
error: Error | null;
|
|
21
21
|
clearError: () => void;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
cantonWallets: CantonWallet[];
|
|
23
|
+
cantonWallet: CantonWallet | null;
|
|
24
24
|
}
|
|
25
25
|
export declare function useSignMessage(): UseSignMessageReturn;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper over Privy's signing with automatic confirmation modals
|
|
3
|
+
*
|
|
4
|
+
* Shows a confirmation modal before every signing operation
|
|
5
|
+
* Supports both Stellar (rawSign) and Solana (signMessage) based on withExport config
|
|
6
|
+
*/
|
|
2
7
|
export interface SignRawHashModalOptions {
|
|
3
8
|
skipModal?: boolean;
|
|
4
9
|
title?: string;
|
|
@@ -11,7 +16,11 @@ export interface SignRawHashModalOptions {
|
|
|
11
16
|
/** Show technical details (address, chainType, hash) as JSON. Default: false */
|
|
12
17
|
showTechnicalDetails?: boolean;
|
|
13
18
|
}
|
|
14
|
-
|
|
19
|
+
export interface SignRawHashParams {
|
|
20
|
+
address: string;
|
|
21
|
+
chainType: string;
|
|
22
|
+
hash: `0x${string}`;
|
|
23
|
+
}
|
|
15
24
|
export interface UseSignRawHashWithModalReturn {
|
|
16
25
|
/** Sign a raw hash with confirmation modal */
|
|
17
26
|
signRawHashWithModal: (params: SignRawHashParams, modalOptions?: SignRawHashModalOptions) => Promise<{
|
|
@@ -19,4 +28,3 @@ export interface UseSignRawHashWithModalReturn {
|
|
|
19
28
|
} | null>;
|
|
20
29
|
}
|
|
21
30
|
export declare function useSignRawHashWithModal(): UseSignRawHashWithModalReturn;
|
|
22
|
-
export {};
|
package/dist/hooks/useSupa.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface UseSupaReturn {
|
|
|
13
13
|
api: UseAPIReturn;
|
|
14
14
|
/** Automated onboarding flow (login → create wallet → register Canton) */
|
|
15
15
|
onboard: () => Promise<void>;
|
|
16
|
+
/** Complete logout (Privy + clear all SDK state) */
|
|
17
|
+
logout: () => Promise<void>;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Main hook for accessing all Supa SDK features
|
|
@@ -27,7 +29,7 @@ export interface UseSupaReturn {
|
|
|
27
29
|
* Basic usage
|
|
28
30
|
* ```tsx
|
|
29
31
|
* function Dashboard() {
|
|
30
|
-
* const { auth, canton, api } = useSupa();
|
|
32
|
+
* const { auth, canton, api, logout } = useSupa();
|
|
31
33
|
*
|
|
32
34
|
* if (!auth.authenticated) {
|
|
33
35
|
* return <button onClick={auth.login}>Login</button>;
|
|
@@ -39,6 +41,7 @@ export interface UseSupaReturn {
|
|
|
39
41
|
* <button onClick={() => canton.registerCanton()}>
|
|
40
42
|
* Register Canton
|
|
41
43
|
* </button>
|
|
44
|
+
* <button onClick={logout}>Logout</button>
|
|
42
45
|
* </div>
|
|
43
46
|
* );
|
|
44
47
|
* }
|