@supanovaapp/sdk 0.2.14 → 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 +20052 -19955
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { CantonWallet } from '../utils/wallet';
|
|
3
3
|
import { CantonService, CantonSubmitPreparedOptions } from '../services/cantonService';
|
|
4
4
|
import { CantonMeResponseDto, CantonActiveContractsResponseDto, CantonQueryCompletionResponseDto, CantonWalletBalancesResponseDto, CantonIncomingTransferDto, CantonTransactionDto, CantonTransactionsParams, CantonPriceInterval, CantonPriceCandleDto } from '../core/types';
|
|
5
5
|
export interface CantonSendCoinOptions extends CantonSubmitPreparedOptions {
|
|
@@ -8,11 +8,11 @@ export interface CantonSendCoinOptions extends CantonSubmitPreparedOptions {
|
|
|
8
8
|
}
|
|
9
9
|
export interface CantonContextValue {
|
|
10
10
|
/** First Stellar wallet (primary) */
|
|
11
|
-
|
|
11
|
+
cantonWallet: CantonWallet | null;
|
|
12
12
|
/** All Stellar wallets */
|
|
13
|
-
|
|
13
|
+
cantonWallets: CantonWallet[];
|
|
14
14
|
/** Create new Stellar wallet */
|
|
15
|
-
|
|
15
|
+
createCantonWallet: () => Promise<CantonWallet | null>;
|
|
16
16
|
/** Register Canton wallet on backend */
|
|
17
17
|
registerCanton: (inviteCode?: string) => Promise<void>;
|
|
18
18
|
/** Whether Canton wallet is registered */
|
|
@@ -47,6 +47,8 @@ export interface CantonContextValue {
|
|
|
47
47
|
getTransactions: (params?: CantonTransactionsParams) => Promise<CantonTransactionDto[]>;
|
|
48
48
|
/** Get Canton price history (candles from Bybit) */
|
|
49
49
|
getPriceHistory: (interval: CantonPriceInterval) => Promise<CantonPriceCandleDto[]>;
|
|
50
|
+
/** Reset all Canton state (for logout) */
|
|
51
|
+
resetState: () => void;
|
|
50
52
|
/** Loading state */
|
|
51
53
|
loading: boolean;
|
|
52
54
|
/** Error state */
|
|
@@ -57,8 +59,10 @@ export interface CantonContextValue {
|
|
|
57
59
|
export interface CantonProviderProps {
|
|
58
60
|
cantonService: CantonService;
|
|
59
61
|
children: ReactNode;
|
|
62
|
+
/** Enable wallet export (uses Solana instead of Stellar). Default: false */
|
|
63
|
+
withExport?: boolean;
|
|
60
64
|
/** Enable automatic onboarding (create wallet + register Canton on login). Default: true */
|
|
61
65
|
autoOnboarding?: boolean;
|
|
62
66
|
}
|
|
63
|
-
export declare function CantonProvider({ cantonService, children, autoOnboarding }: CantonProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
export declare function CantonProvider({ cantonService, children, withExport, autoOnboarding }: CantonProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
64
68
|
export declare function useCantonContext(): CantonContextValue;
|
|
@@ -32,6 +32,13 @@ export interface SupaConfig {
|
|
|
32
32
|
defaultChain?: any;
|
|
33
33
|
/** Supported chains for the app */
|
|
34
34
|
supportedChains?: any[];
|
|
35
|
+
/**
|
|
36
|
+
* Enable wallet export functionality (uses Solana wallets instead of Stellar)
|
|
37
|
+
* When false (default): Uses Stellar wallets, export will throw an error
|
|
38
|
+
* When true: Uses Solana wallets, export is available
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
withExport?: boolean;
|
|
35
42
|
/** Enable automatic onboarding (create wallet + register Canton on login). Default: true */
|
|
36
43
|
autoOnboarding?: boolean;
|
|
37
44
|
}
|
|
@@ -14,22 +14,22 @@ export declare class ApiService {
|
|
|
14
14
|
private readonly USER_CACHE_TTL;
|
|
15
15
|
constructor(client: ApiClient);
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Invalidate /user/me cache
|
|
18
|
+
* Called after operations that modify user data
|
|
19
19
|
*/
|
|
20
20
|
private invalidateUserCache;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Invalidate /supa_points/balance cache
|
|
23
23
|
*/
|
|
24
24
|
private invalidateSupaPointsCache;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Invalidate /privy/balance cache
|
|
27
27
|
*/
|
|
28
28
|
private invalidatePrivyBalanceCache;
|
|
29
29
|
/**
|
|
30
30
|
* Get current user information
|
|
31
31
|
* GET /user/me
|
|
32
|
-
*
|
|
32
|
+
* With 5 minute caching and request deduplication
|
|
33
33
|
*/
|
|
34
34
|
getCurrentUser(force?: boolean): Promise<UserResponseDto>;
|
|
35
35
|
/**
|
|
@@ -134,7 +134,7 @@ export declare class ApiService {
|
|
|
134
134
|
/**
|
|
135
135
|
* Get SupaPoints balance
|
|
136
136
|
* GET /supa_points/balance
|
|
137
|
-
*
|
|
137
|
+
* With 5 minute caching and request deduplication
|
|
138
138
|
*/
|
|
139
139
|
getSupaPointsBalance(force?: boolean): Promise<SupaPointsBalanceResponseDto>;
|
|
140
140
|
/**
|
|
@@ -155,7 +155,7 @@ export declare class ApiService {
|
|
|
155
155
|
/**
|
|
156
156
|
* Get Privy balance
|
|
157
157
|
* GET /privy/balance
|
|
158
|
-
*
|
|
158
|
+
* With 5 minute caching and request deduplication
|
|
159
159
|
*/
|
|
160
160
|
getPrivyBalance(force?: boolean): Promise<any>;
|
|
161
161
|
}
|
|
@@ -31,8 +31,8 @@ export declare class CantonService {
|
|
|
31
31
|
private readonly CACHE_TTL;
|
|
32
32
|
constructor(client: ApiClient);
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Invalidate /me cache
|
|
35
|
+
* Called after registration/user modification operations
|
|
36
36
|
*/
|
|
37
37
|
private invalidateMeCache;
|
|
38
38
|
/**
|
|
@@ -81,7 +81,7 @@ export declare class CantonService {
|
|
|
81
81
|
/**
|
|
82
82
|
* Get current Canton user info (partyId and email)
|
|
83
83
|
* Only works after registration
|
|
84
|
-
*
|
|
84
|
+
* With 5 minute caching and request deduplication
|
|
85
85
|
*/
|
|
86
86
|
getMe(force?: boolean): Promise<CantonMeResponseDto>;
|
|
87
87
|
/**
|
|
@@ -65,3 +65,16 @@ export declare const stripLeadingZero: (hex: string) => string;
|
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
67
|
export declare const privyPublicKeyToCantonBase64: (publicKeyHex: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* Decodes a base58 string to bytes using BigInt for precision
|
|
70
|
+
* @param str - Base58 encoded string
|
|
71
|
+
* @returns Byte array
|
|
72
|
+
*/
|
|
73
|
+
export declare const base58ToBytes: (str: string) => Uint8Array;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a Solana address (base58) to base64 for Canton Network
|
|
76
|
+
* @param address - Solana address in base58 format
|
|
77
|
+
* @returns Public key in base64 format (32 bytes Ed25519 key)
|
|
78
|
+
* @throws {Error} If decoded key is not 32 bytes
|
|
79
|
+
*/
|
|
80
|
+
export declare const solanaAddressToBase64: (address: string) => string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellar wallet utilities for Privy integration
|
|
3
|
+
* Stellar chain type is used for Ed25519 signing required by Canton Network
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Stellar/Solana wallet interface representing a Privy Ed25519 wallet
|
|
7
|
+
*/
|
|
8
|
+
export interface CantonWallet {
|
|
9
|
+
/** Wallet address (public key in Stellar/Solana format) */
|
|
10
|
+
address: string;
|
|
11
|
+
/** Raw public key in hex format (camelCase) - only for Stellar */
|
|
12
|
+
publicKey?: string;
|
|
13
|
+
/** Raw public key in hex format (snake_case from Privy API) - only for Stellar */
|
|
14
|
+
public_key?: string;
|
|
15
|
+
/** Chain type: 'stellar' (default) or 'solana' (with export) */
|
|
16
|
+
chainType: 'stellar' | 'solana';
|
|
17
|
+
/** Wallet client type (e.g., 'privy') */
|
|
18
|
+
walletClientType?: string;
|
|
19
|
+
/** Whether the wallet was imported or created */
|
|
20
|
+
imported?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Extracts all Ed25519 wallets (Stellar or Solana) from Privy user and wallets array
|
|
24
|
+
* Combines wallets from both user.linkedAccounts and useWallets hook,
|
|
25
|
+
* removing duplicates by address.
|
|
26
|
+
*
|
|
27
|
+
* @param user - Privy user object
|
|
28
|
+
* @param wallets - Privy wallets array from useWallets hook
|
|
29
|
+
* @param chainType - Chain type to filter by: 'stellar' (default) or 'solana' (with export)
|
|
30
|
+
* @returns Array of unique wallets
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const { user } = usePrivy();
|
|
35
|
+
* const { wallets } = useWallets();
|
|
36
|
+
* const cantonWallets = getCantonWallets(user, wallets, 'stellar');
|
|
37
|
+
* console.log(`Found ${cantonWallets.length} wallets`);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const getCantonWallets: (user: any, wallets: any[], chainType?: "stellar" | "solana") => CantonWallet[];
|
|
41
|
+
/**
|
|
42
|
+
* Converts Stellar wallet public key to Canton Network base64 format
|
|
43
|
+
* Handles removal of leading 00 byte and conversion from hex to base64
|
|
44
|
+
*
|
|
45
|
+
* @param wallet - Stellar wallet object containing publicKey
|
|
46
|
+
* @returns Public key in base64 format ready for Canton Network API
|
|
47
|
+
* @throws {Error} If wallet is invalid or publicKey is missing/malformed
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const publicKeyBase64 = getPublicKeyBase64(stellarWallet);
|
|
52
|
+
* // Use with Canton Network API
|
|
53
|
+
* await fetch('/canton/register/prepare', {
|
|
54
|
+
* body: JSON.stringify({ publicKey: publicKeyBase64 })
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare const getPublicKeyBase64: (wallet: CantonWallet | any) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Type guard to check if a wallet is a Stellar/Solana Ed25519 wallet
|
|
61
|
+
* @param wallet - Wallet object to check
|
|
62
|
+
* @returns True if wallet is a valid Ed25519 wallet (Stellar or Solana)
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* if (isCantonWallet(wallet)) {
|
|
67
|
+
* console.log('Ed25519 wallet address:', wallet.address);
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const isCantonWallet: (wallet: any) => wallet is CantonWallet;
|
|
72
|
+
/**
|
|
73
|
+
* Gets the first Ed25519 wallet from user and wallets array
|
|
74
|
+
* Convenience function that throws if no wallet is found
|
|
75
|
+
*
|
|
76
|
+
* @param user - Privy user object
|
|
77
|
+
* @param wallets - Privy wallets array from useWallets hook
|
|
78
|
+
* @param chainType - Chain type to filter by: 'stellar' (default) or 'solana' (with export)
|
|
79
|
+
* @returns First wallet found
|
|
80
|
+
* @throws {Error} If no wallet found
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* try {
|
|
85
|
+
* const wallet = getFirstCantonWallet(user, wallets, 'stellar');
|
|
86
|
+
* console.log('Using wallet:', wallet.address);
|
|
87
|
+
* } catch (err) {
|
|
88
|
+
* console.error('No wallet available');
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare const getFirstCantonWallet: (user: any, wallets: any[], chainType?: "stellar" | "solana") => CantonWallet;
|
package/package.json
CHANGED
package/dist/utils/stellar.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stellar wallet utilities for Privy integration
|
|
3
|
-
* Stellar chain type is used for Ed25519 signing required by Canton Network
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Stellar wallet interface representing a Privy Stellar wallet
|
|
7
|
-
*/
|
|
8
|
-
export interface StellarWallet {
|
|
9
|
-
/** Stellar address (public key in Stellar format) */
|
|
10
|
-
address: string;
|
|
11
|
-
/** Raw public key in hex format (camelCase) */
|
|
12
|
-
publicKey?: string;
|
|
13
|
-
/** Raw public key in hex format (snake_case from Privy API) */
|
|
14
|
-
public_key?: string;
|
|
15
|
-
/** Chain type, always 'stellar' for Stellar wallets */
|
|
16
|
-
chainType: 'stellar';
|
|
17
|
-
/** Wallet client type (e.g., 'privy') */
|
|
18
|
-
walletClientType?: string;
|
|
19
|
-
/** Whether the wallet was imported or created */
|
|
20
|
-
imported?: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Extracts all Stellar wallets from Privy user and wallets array
|
|
24
|
-
* Combines wallets from both user.linkedAccounts and useWallets hook,
|
|
25
|
-
* removing duplicates by address.
|
|
26
|
-
*
|
|
27
|
-
* @param user - Privy user object
|
|
28
|
-
* @param wallets - Privy wallets array from useWallets hook
|
|
29
|
-
* @returns Array of unique Stellar wallets
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* const { user } = usePrivy();
|
|
34
|
-
* const { wallets } = useWallets();
|
|
35
|
-
* const stellarWallets = getStellarWallets(user, wallets);
|
|
36
|
-
* console.log(`Found ${stellarWallets.length} Stellar wallets`);
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare const getStellarWallets: (user: any, wallets: any[]) => StellarWallet[];
|
|
40
|
-
/**
|
|
41
|
-
* Converts Stellar wallet public key to Canton Network base64 format
|
|
42
|
-
* Handles removal of leading 00 byte and conversion from hex to base64
|
|
43
|
-
*
|
|
44
|
-
* @param wallet - Stellar wallet object containing publicKey
|
|
45
|
-
* @returns Public key in base64 format ready for Canton Network API
|
|
46
|
-
* @throws {Error} If wallet is invalid or publicKey is missing/malformed
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* const publicKeyBase64 = getPublicKeyBase64(stellarWallet);
|
|
51
|
-
* // Use with Canton Network API
|
|
52
|
-
* await fetch('/canton/register/prepare', {
|
|
53
|
-
* body: JSON.stringify({ publicKey: publicKeyBase64 })
|
|
54
|
-
* });
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare const getPublicKeyBase64: (wallet: StellarWallet | any) => string;
|
|
58
|
-
/**
|
|
59
|
-
* Type guard to check if a wallet is a Stellar wallet
|
|
60
|
-
* @param wallet - Wallet object to check
|
|
61
|
-
* @returns True if wallet is a valid Stellar wallet
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```ts
|
|
65
|
-
* if (isStellarWallet(wallet)) {
|
|
66
|
-
* console.log('Stellar wallet address:', wallet.address);
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export declare const isStellarWallet: (wallet: any) => wallet is StellarWallet;
|
|
71
|
-
/**
|
|
72
|
-
* Gets the first Stellar wallet from user and wallets array
|
|
73
|
-
* Convenience function that throws if no Stellar wallet is found
|
|
74
|
-
*
|
|
75
|
-
* @param user - Privy user object
|
|
76
|
-
* @param wallets - Privy wallets array from useWallets hook
|
|
77
|
-
* @returns First Stellar wallet found
|
|
78
|
-
* @throws {Error} If no Stellar wallet found
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```ts
|
|
82
|
-
* try {
|
|
83
|
-
* const wallet = getFirstStellarWallet(user, wallets);
|
|
84
|
-
* console.log('Using wallet:', wallet.address);
|
|
85
|
-
* } catch (err) {
|
|
86
|
-
* console.error('No Stellar wallet available');
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
export declare const getFirstStellarWallet: (user: any, wallets: any[]) => StellarWallet;
|