@supanovaapp/sdk 0.2.1 → 0.2.4
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 +115 -6
- package/dist/index.cjs.js +521 -519
- package/dist/index.d.ts +211 -13
- package/dist/index.esm.js +58741 -53214
- package/package.json +14 -3
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { JSX } from 'react/jsx-runtime';
|
|
|
45
45
|
import { ReactNode } from 'react';
|
|
46
46
|
import { User } from '@privy-io/react-auth';
|
|
47
47
|
import { useSignRawHash } from '@privy-io/react-auth/extended-chains';
|
|
48
|
+
import { useSmartWallets as useSmartWallets_2 } from '@privy-io/react-auth/smart-wallets';
|
|
48
49
|
|
|
49
50
|
export declare interface AccountTokenBalance {
|
|
50
51
|
contractAddress: string;
|
|
@@ -63,6 +64,8 @@ export declare class ApiClient {
|
|
|
63
64
|
private client;
|
|
64
65
|
private getAccessToken?;
|
|
65
66
|
private nodeIdentifier;
|
|
67
|
+
private cache;
|
|
68
|
+
private cacheTTL;
|
|
66
69
|
constructor(config?: ClientConfig);
|
|
67
70
|
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
68
71
|
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
@@ -86,12 +89,36 @@ export declare interface ApiResponse<T = any> {
|
|
|
86
89
|
|
|
87
90
|
export declare class ApiService {
|
|
88
91
|
private client;
|
|
92
|
+
private userMeCache;
|
|
93
|
+
private userMeCacheTimestamp;
|
|
94
|
+
private userMePendingPromise;
|
|
95
|
+
private supaPointsBalanceCache;
|
|
96
|
+
private supaPointsBalanceCacheTimestamp;
|
|
97
|
+
private supaPointsBalancePendingPromise;
|
|
98
|
+
private privyBalanceCache;
|
|
99
|
+
private privyBalanceCacheTimestamp;
|
|
100
|
+
private privyBalancePendingPromise;
|
|
101
|
+
private readonly USER_CACHE_TTL;
|
|
89
102
|
constructor(client: ApiClient);
|
|
103
|
+
/**
|
|
104
|
+
* Инвалидация кеша /user/me
|
|
105
|
+
* Вызывается после операций, изменяющих данные пользователя
|
|
106
|
+
*/
|
|
107
|
+
private invalidateUserCache;
|
|
108
|
+
/**
|
|
109
|
+
* Инвалидация кеша /supa_points/balance
|
|
110
|
+
*/
|
|
111
|
+
private invalidateSupaPointsCache;
|
|
112
|
+
/**
|
|
113
|
+
* Инвалидация кеша /privy/balance
|
|
114
|
+
*/
|
|
115
|
+
private invalidatePrivyBalanceCache;
|
|
90
116
|
/**
|
|
91
117
|
* Get current user information
|
|
92
118
|
* GET /user/me
|
|
119
|
+
* С мемоизацией на 5 минут и дедупликацией одновременных запросов
|
|
93
120
|
*/
|
|
94
|
-
getCurrentUser(): Promise<UserResponseDto>;
|
|
121
|
+
getCurrentUser(force?: boolean): Promise<UserResponseDto>;
|
|
95
122
|
/**
|
|
96
123
|
* Get all users
|
|
97
124
|
* GET /user/all
|
|
@@ -194,8 +221,9 @@ export declare class ApiService {
|
|
|
194
221
|
/**
|
|
195
222
|
* Get SupaPoints balance
|
|
196
223
|
* GET /supa_points/balance
|
|
224
|
+
* С мемоизацией на 5 минут и дедупликацией одновременных запросов
|
|
197
225
|
*/
|
|
198
|
-
getSupaPointsBalance(): Promise<SupaPointsBalanceResponseDto>;
|
|
226
|
+
getSupaPointsBalance(force?: boolean): Promise<SupaPointsBalanceResponseDto>;
|
|
199
227
|
/**
|
|
200
228
|
* Get SupaPoints history
|
|
201
229
|
* GET /supa_points/history
|
|
@@ -214,8 +242,9 @@ export declare class ApiService {
|
|
|
214
242
|
/**
|
|
215
243
|
* Get Privy balance
|
|
216
244
|
* GET /privy/balance
|
|
245
|
+
* С мемоизацией на 5 минут и дедупликацией одновременных запросов
|
|
217
246
|
*/
|
|
218
|
-
getPrivyBalance(): Promise<any>;
|
|
247
|
+
getPrivyBalance(force?: boolean): Promise<any>;
|
|
219
248
|
}
|
|
220
249
|
|
|
221
250
|
/**
|
|
@@ -327,6 +356,26 @@ export declare interface CantonCreatedEvent {
|
|
|
327
356
|
acsDelta: boolean;
|
|
328
357
|
}
|
|
329
358
|
|
|
359
|
+
/** Lock information for locked UTXO */
|
|
360
|
+
export declare interface CantonHoldingLockDto {
|
|
361
|
+
/** Party IDs holding the lock */
|
|
362
|
+
holders: string[];
|
|
363
|
+
/** Lock expiration timestamp (ISO 8601, can be null) */
|
|
364
|
+
expiresAt: string | null;
|
|
365
|
+
/** Relative expiration duration (can be null) */
|
|
366
|
+
expiresAfter: Record<string, unknown> | null;
|
|
367
|
+
/** Context describing why the UTXO is locked (can be null) */
|
|
368
|
+
context: string | null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** Canton instrument/token identifier */
|
|
372
|
+
export declare interface CantonInstrumentIdDto {
|
|
373
|
+
/** DSO party ID (instrument administrator) */
|
|
374
|
+
admin: string;
|
|
375
|
+
/** Token identifier (e.g., "Amulet" for Canton Coin) */
|
|
376
|
+
id: string;
|
|
377
|
+
}
|
|
378
|
+
|
|
330
379
|
/** Active contract in Canton */
|
|
331
380
|
export declare interface CantonJsActiveContract {
|
|
332
381
|
/** Created event with all contract details */
|
|
@@ -337,11 +386,37 @@ export declare interface CantonJsActiveContract {
|
|
|
337
386
|
reassignmentCounter: number;
|
|
338
387
|
}
|
|
339
388
|
|
|
389
|
+
/** Locked UTXO with lock information */
|
|
390
|
+
export declare interface CantonLockedUtxoDto {
|
|
391
|
+
/** Contract ID of the locked UTXO */
|
|
392
|
+
contractId: string;
|
|
393
|
+
/** Locked amount as decimal string */
|
|
394
|
+
amount: string;
|
|
395
|
+
/** Lock information including holders, expiration, and context */
|
|
396
|
+
lock: CantonHoldingLockDto;
|
|
397
|
+
/** UTXO metadata including creation info and demurrage rate */
|
|
398
|
+
metadata: CantonUtxoMetadataDto;
|
|
399
|
+
}
|
|
400
|
+
|
|
340
401
|
export declare interface CantonMeResponseDto {
|
|
341
402
|
/** Canton party ID */
|
|
342
403
|
partyId: string;
|
|
343
404
|
/** User email (can be null if not set) */
|
|
344
405
|
email: string | null;
|
|
406
|
+
/** Indicates whether the transfer preapproval is set and NOT EXPIRED for the party */
|
|
407
|
+
transferPreapprovalSet: boolean;
|
|
408
|
+
/** Transfer preapproval expiration date (ISO 8601, can be null) */
|
|
409
|
+
transferPreapprovalExpiresAt: string | null;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** Request for preparing Amulet (Canton Coin) transfer */
|
|
413
|
+
export declare interface CantonPrepareAmuletTransferRequestDto {
|
|
414
|
+
/** Canton party ID of the receiver wallet */
|
|
415
|
+
receiverPartyId: string;
|
|
416
|
+
/** Amount of Amulet to transfer (decimal string with max 10 decimal places) */
|
|
417
|
+
amount: string;
|
|
418
|
+
/** Optional memo for the transfer */
|
|
419
|
+
memo?: string;
|
|
345
420
|
}
|
|
346
421
|
|
|
347
422
|
export declare interface CantonPrepareRegisterRequestDto {
|
|
@@ -356,7 +431,7 @@ export declare interface CantonPrepareTapRequestDto {
|
|
|
356
431
|
|
|
357
432
|
export declare interface CantonPrepareTransactionRequestDto {
|
|
358
433
|
/** Command or array of commands */
|
|
359
|
-
|
|
434
|
+
commands: unknown;
|
|
360
435
|
/** Optional disclosed contracts */
|
|
361
436
|
disclosedContracts?: unknown;
|
|
362
437
|
}
|
|
@@ -386,7 +461,16 @@ export declare interface CantonRegisterParams {
|
|
|
386
461
|
|
|
387
462
|
export declare class CantonService {
|
|
388
463
|
private client;
|
|
464
|
+
private meCache;
|
|
465
|
+
private meCacheTimestamp;
|
|
466
|
+
private mePendingPromise;
|
|
467
|
+
private readonly CACHE_TTL;
|
|
389
468
|
constructor(client: ApiClient);
|
|
469
|
+
/**
|
|
470
|
+
* Инвалидация кеша /me
|
|
471
|
+
* Вызывается после операций регистрации/изменения пользователя
|
|
472
|
+
*/
|
|
473
|
+
private invalidateMeCache;
|
|
390
474
|
/**
|
|
391
475
|
* Register Canton wallet
|
|
392
476
|
* Flow:
|
|
@@ -433,8 +517,9 @@ export declare class CantonService {
|
|
|
433
517
|
/**
|
|
434
518
|
* Get current Canton user info (partyId and email)
|
|
435
519
|
* Only works after registration
|
|
520
|
+
* С мемоизацией на 5 минут и дедупликацией одновременных запросов
|
|
436
521
|
*/
|
|
437
|
-
getMe(): Promise<CantonMeResponseDto>;
|
|
522
|
+
getMe(force?: boolean): Promise<CantonMeResponseDto>;
|
|
438
523
|
/**
|
|
439
524
|
* Get active contracts with optional template filtering
|
|
440
525
|
* Returns array of active contract items with full contract details
|
|
@@ -450,16 +535,33 @@ export declare class CantonService {
|
|
|
450
535
|
signMessage(message: string, signFunction: (hashHex: string) => Promise<string>): Promise<string>;
|
|
451
536
|
/**
|
|
452
537
|
* Prepare Canton transaction
|
|
453
|
-
* @param
|
|
538
|
+
* @param commands Command or array of commands
|
|
454
539
|
* @param disclosedContracts Optional disclosed contracts
|
|
455
540
|
*/
|
|
456
|
-
prepareTransaction(
|
|
541
|
+
prepareTransaction(commands: unknown, disclosedContracts?: unknown): Promise<CantonPrepareTransactionResponseDto>;
|
|
457
542
|
/**
|
|
458
543
|
* Check if user has Canton wallet registered
|
|
459
|
-
* This is inferred - if
|
|
460
|
-
* If it fails with 409 or similar, wallet already exists
|
|
544
|
+
* This is inferred - if /me succeeds, user has wallet
|
|
461
545
|
*/
|
|
462
546
|
checkRegistrationStatus(): Promise<boolean>;
|
|
547
|
+
/**
|
|
548
|
+
* Prepare transfer preapproval
|
|
549
|
+
* Flow: prepare -> sign -> submit
|
|
550
|
+
* No request body required
|
|
551
|
+
*/
|
|
552
|
+
prepareTransferPreapproval(): Promise<CantonPrepareTransactionResponseDto>;
|
|
553
|
+
/**
|
|
554
|
+
* Get Canton wallet balances
|
|
555
|
+
* Returns balances for all tokens grouped by instrument ID
|
|
556
|
+
* Includes unlocked and locked UTXOs
|
|
557
|
+
*/
|
|
558
|
+
getBalances(): Promise<CantonWalletBalancesResponseDto>;
|
|
559
|
+
/**
|
|
560
|
+
* Prepare Amulet (Canton Coin) transfer
|
|
561
|
+
* @param params Transfer parameters (receiverPartyId, amount, memo)
|
|
562
|
+
* @throws Error if amount has more than 10 decimal places
|
|
563
|
+
*/
|
|
564
|
+
prepareAmuletTransfer(params: CantonPrepareAmuletTransferRequestDto): Promise<CantonPrepareTransactionResponseDto>;
|
|
463
565
|
}
|
|
464
566
|
|
|
465
567
|
export declare interface CantonSubmitPreparedOptions {
|
|
@@ -488,6 +590,54 @@ export declare interface CantonTapParams {
|
|
|
488
590
|
signFunction: (hashHex: string) => Promise<string>;
|
|
489
591
|
}
|
|
490
592
|
|
|
593
|
+
/** Token balance with unlocked and locked UTXOs */
|
|
594
|
+
export declare interface CantonTokenBalanceDto {
|
|
595
|
+
/** Unique identifier for this token type */
|
|
596
|
+
instrumentId: CantonInstrumentIdDto;
|
|
597
|
+
/** Total unlocked balance as decimal string */
|
|
598
|
+
totalUnlockedBalance: string;
|
|
599
|
+
/** Total locked balance as decimal string */
|
|
600
|
+
totalLockedBalance: string;
|
|
601
|
+
/** Total balance (unlocked + locked) as decimal string */
|
|
602
|
+
totalBalance: string;
|
|
603
|
+
/** Number of unlocked UTXOs */
|
|
604
|
+
unlockedUtxoCount: number;
|
|
605
|
+
/** Number of locked UTXOs */
|
|
606
|
+
lockedUtxoCount: number;
|
|
607
|
+
/** List of unlocked UTXOs */
|
|
608
|
+
unlockedUtxos: CantonUnlockedUtxoDto[];
|
|
609
|
+
/** List of locked UTXOs */
|
|
610
|
+
lockedUtxos: CantonLockedUtxoDto[];
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/** Unlocked UTXO */
|
|
614
|
+
export declare interface CantonUnlockedUtxoDto {
|
|
615
|
+
/** Contract ID of the UTXO */
|
|
616
|
+
contractId: string;
|
|
617
|
+
/** Amount as decimal string */
|
|
618
|
+
amount: string;
|
|
619
|
+
/** UTXO metadata including creation info and demurrage rate */
|
|
620
|
+
metadata: CantonUtxoMetadataDto;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/** UTXO metadata including creation info and demurrage rate */
|
|
624
|
+
export declare interface CantonUtxoMetadataDto {
|
|
625
|
+
/** Round number when the UTXO was created */
|
|
626
|
+
createdInRound: string;
|
|
627
|
+
/** Demurrage rate per round (balance decrease rate for Canton Coin) */
|
|
628
|
+
demurrageRate: string;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** Canton wallet balances response */
|
|
632
|
+
export declare interface CantonWalletBalancesResponseDto {
|
|
633
|
+
/** Party ID of the wallet owner */
|
|
634
|
+
partyId: string;
|
|
635
|
+
/** Token balances grouped by instrument ID */
|
|
636
|
+
tokens: CantonTokenBalanceDto[];
|
|
637
|
+
/** Timestamp when balances were fetched (ISO 8601) */
|
|
638
|
+
fetchedAt: string;
|
|
639
|
+
}
|
|
640
|
+
|
|
491
641
|
export declare interface ClientConfig {
|
|
492
642
|
baseURL?: string;
|
|
493
643
|
nodeIdentifier: string;
|
|
@@ -547,6 +697,10 @@ export declare interface DialogWithMessagesResponseDto {
|
|
|
547
697
|
|
|
548
698
|
export declare function getApiClient(): ApiClient;
|
|
549
699
|
|
|
700
|
+
export declare function getApiService(): ApiService;
|
|
701
|
+
|
|
702
|
+
export declare function getCantonService(): CantonService;
|
|
703
|
+
|
|
550
704
|
/**
|
|
551
705
|
* Gets the first Stellar wallet from user and wallets array
|
|
552
706
|
* Convenience function that throws if no Stellar wallet is found
|
|
@@ -881,7 +1035,26 @@ export declare interface SupaConfig {
|
|
|
881
1035
|
accentColor?: string;
|
|
882
1036
|
logo?: string;
|
|
883
1037
|
};
|
|
884
|
-
loginMethods?: Array<'email' | 'wallet' | 'google' | 'twitter' | 'discord' | 'github' | 'linkedin'>;
|
|
1038
|
+
loginMethods?: Array<'email' | 'wallet' | 'google' | 'twitter' | 'discord' | 'github' | 'linkedin' | 'telegram'>;
|
|
1039
|
+
smartWallets?: {
|
|
1040
|
+
enabled?: boolean;
|
|
1041
|
+
paymasterContext?: {
|
|
1042
|
+
mode?: string;
|
|
1043
|
+
calculateGasLimits?: boolean;
|
|
1044
|
+
expiryDuration?: number;
|
|
1045
|
+
sponsorshipInfo?: {
|
|
1046
|
+
webhookData?: Record<string, any>;
|
|
1047
|
+
smartAccountInfo?: {
|
|
1048
|
+
name?: string;
|
|
1049
|
+
version?: string;
|
|
1050
|
+
};
|
|
1051
|
+
};
|
|
1052
|
+
};
|
|
1053
|
+
};
|
|
1054
|
+
/** Default chain for smart wallets and transactions */
|
|
1055
|
+
defaultChain?: any;
|
|
1056
|
+
/** Supported chains for the app */
|
|
1057
|
+
supportedChains?: any[];
|
|
885
1058
|
}
|
|
886
1059
|
|
|
887
1060
|
export declare interface SupaContextValue {
|
|
@@ -1132,12 +1305,16 @@ export declare interface UseCantonReturn {
|
|
|
1132
1305
|
registerCanton: () => Promise<void>;
|
|
1133
1306
|
/** Whether Canton wallet is registered */
|
|
1134
1307
|
isRegistered: boolean;
|
|
1135
|
-
/** Canton user info (partyId
|
|
1308
|
+
/** Canton user info (partyId, email, transferPreapprovalSet) */
|
|
1136
1309
|
cantonUser: CantonMeResponseDto | null;
|
|
1137
1310
|
/** Get Canton user info */
|
|
1138
1311
|
getMe: () => Promise<CantonMeResponseDto>;
|
|
1139
1312
|
/** Get active contracts with optional filtering */
|
|
1140
1313
|
getActiveContracts: (templateIds?: string[]) => Promise<CantonActiveContractsResponseDto>;
|
|
1314
|
+
/** Canton wallet balances */
|
|
1315
|
+
cantonBalances: CantonWalletBalancesResponseDto | null;
|
|
1316
|
+
/** Get Canton wallet balances */
|
|
1317
|
+
getBalances: () => Promise<CantonWalletBalancesResponseDto>;
|
|
1141
1318
|
/** Tap devnet faucet */
|
|
1142
1319
|
tapDevnet: (amount: string, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
|
|
1143
1320
|
/** Sign hash with Stellar wallet */
|
|
@@ -1145,7 +1322,11 @@ export declare interface UseCantonReturn {
|
|
|
1145
1322
|
/** Sign text message */
|
|
1146
1323
|
signMessage: (message: string) => Promise<string>;
|
|
1147
1324
|
/** Prepare and submit transaction with polling for completion */
|
|
1148
|
-
sendTransaction: (
|
|
1325
|
+
sendTransaction: (commands: unknown, disclosedContracts?: unknown, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
|
|
1326
|
+
/** Send Canton Coin (Amulet) to another party */
|
|
1327
|
+
sendCantonCoin: (receiverPartyId: string, amount: string, memo?: string, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
|
|
1328
|
+
/** Setup transfer preapproval (internal, called automatically) */
|
|
1329
|
+
setupTransferPreapproval: () => Promise<void>;
|
|
1149
1330
|
/** Loading state */
|
|
1150
1331
|
loading: boolean;
|
|
1151
1332
|
/** Error state */
|
|
@@ -1205,7 +1386,7 @@ export declare function useSendTransaction(): UseSendTransactionReturn;
|
|
|
1205
1386
|
|
|
1206
1387
|
export declare interface UseSendTransactionReturn {
|
|
1207
1388
|
/** Sign and send a Canton transaction with confirmation modal */
|
|
1208
|
-
sendTransaction: (
|
|
1389
|
+
sendTransaction: (commands: unknown, disclosedContracts?: unknown, options?: SendTransactionOptions) => Promise<CantonQueryCompletionResponseDto | null>;
|
|
1209
1390
|
loading: boolean;
|
|
1210
1391
|
error: Error | null;
|
|
1211
1392
|
clearError: () => void;
|
|
@@ -1234,6 +1415,23 @@ export declare interface UseSignRawHashWithModalReturn {
|
|
|
1234
1415
|
} | null>;
|
|
1235
1416
|
}
|
|
1236
1417
|
|
|
1418
|
+
/**
|
|
1419
|
+
* Hook for using Privy Smart Wallets
|
|
1420
|
+
* Must be used within SmartWalletsProvider (automatically enabled in SupaProvider when smartWallets.enabled = true)
|
|
1421
|
+
*/
|
|
1422
|
+
export declare function useSmartWallets(): UseSmartWalletsReturn;
|
|
1423
|
+
|
|
1424
|
+
export declare interface UseSmartWalletsReturn {
|
|
1425
|
+
/** Client for interacting with smart wallets */
|
|
1426
|
+
client: ReturnType<typeof useSmartWallets_2>['client'];
|
|
1427
|
+
/** Get client for specific chain */
|
|
1428
|
+
getClientForChain: ReturnType<typeof useSmartWallets_2>['getClientForChain'];
|
|
1429
|
+
/** Get user's smart wallet address */
|
|
1430
|
+
address: string | undefined;
|
|
1431
|
+
/** Whether smart wallets are ready to use */
|
|
1432
|
+
ready: boolean;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1237
1435
|
export declare function useStellarWallet(): UseStellarWalletReturn;
|
|
1238
1436
|
|
|
1239
1437
|
export declare interface UseStellarWalletReturn {
|