@supanovaapp/sdk 0.2.35 → 0.2.37

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.
@@ -1,73 +1,4 @@
1
- import { ReactNode } from 'react';
2
- import { CantonWallet } from '../utils/wallet';
3
- import { CantonService, CantonSubmitPreparedOptions } from '../services/cantonService';
4
- import { CantonMeResponseDto, CantonActiveContractsResponseDto, CantonQueryCompletionResponseDto, CantonWalletBalancesResponseDto, CantonIncomingTransferDto, CantonTransactionDto, CantonTransactionsParams, CantonPriceInterval, CantonPriceCandleDto } from '../core/types';
5
- export interface CantonSendCoinOptions extends CantonSubmitPreparedOptions {
6
- /** Skip confirmation modal. Default: false */
7
- skipModal?: boolean;
8
- }
9
- export interface CantonContextValue {
10
- /** First Stellar wallet (primary) */
11
- cantonWallet: CantonWallet | null;
12
- /** All Stellar wallets */
13
- cantonWallets: CantonWallet[];
14
- /** Create new Stellar wallet */
15
- createCantonWallet: () => Promise<CantonWallet | null>;
16
- /** Register Canton wallet on backend */
17
- registerCanton: (inviteCode?: string) => Promise<void>;
18
- /** Whether Canton wallet is registered */
19
- isRegistered: boolean;
20
- /** Canton user info (partyId, email, transferPreapprovalSet) */
21
- cantonUser: CantonMeResponseDto | null;
22
- /** Get Canton user info */
23
- getMe: () => Promise<CantonMeResponseDto>;
24
- /** Get active contracts with optional filtering */
25
- getActiveContracts: (templateIds?: string[]) => Promise<CantonActiveContractsResponseDto>;
26
- /** Canton wallet balances */
27
- cantonBalances: CantonWalletBalancesResponseDto | null;
28
- /** Get Canton wallet balances */
29
- getBalances: () => Promise<CantonWalletBalancesResponseDto>;
30
- /** Tap devnet faucet */
31
- tapDevnet: (amount: string, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
32
- /** Sign hash with Stellar wallet */
33
- signHash: (hashBase64: string) => Promise<string>;
34
- /** Sign text message */
35
- signMessage: (message: string) => Promise<string>;
36
- /** Prepare and submit transaction with polling for completion */
37
- sendTransaction: (commands: unknown, disclosedContracts?: unknown, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
38
- /** Send Canton Coin (Amulet) to another party */
39
- sendCantonCoin: (receiverPartyId: string, amount: string, memo?: string, options?: CantonSendCoinOptions) => Promise<CantonQueryCompletionResponseDto>;
40
- /** Setup transfer preapproval (internal, called automatically) */
41
- setupTransferPreapproval: () => Promise<void>;
42
- /** Get pending incoming transfers */
43
- getPendingIncomingTransfers: () => Promise<CantonIncomingTransferDto[]>;
44
- /** Respond to incoming transfer (accept or reject) */
45
- respondToIncomingTransfer: (contractId: string, accept: boolean, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
46
- /** Get Canton transactions history with pagination */
47
- getTransactions: (params?: CantonTransactionsParams) => Promise<CantonTransactionDto[]>;
48
- /** Get Canton price history (candles from Bybit) */
49
- getPriceHistory: (interval: CantonPriceInterval) => Promise<CantonPriceCandleDto[]>;
50
- /** Reset all Canton state (for logout) */
51
- resetState: () => void;
52
- /** Loading state */
53
- loading: boolean;
54
- /** Error state */
55
- error: Error | null;
56
- /** Clear error */
57
- clearError: () => void;
58
- }
59
- export interface CantonProviderProps {
60
- cantonService: CantonService;
61
- children: ReactNode;
62
- /** Enable wallet export (uses Solana instead of Stellar). Default: false */
63
- withExport?: boolean;
64
- /** Enable automatic onboarding (create wallet + register Canton on login). Default: true */
65
- autoOnboarding?: boolean;
66
- /**
67
- * Legacy onboarding stage: automatically setup transfer preapproval after registration.
68
- * Default: false (new onboarding uses prepare_initialization_transactions).
69
- */
70
- autoTransferPreapproval?: boolean;
71
- }
1
+ import { CantonContextValue, CantonProviderProps } from './canton/types';
2
+ export type { CantonContextValue, CantonProviderProps, CantonSendCoinOptions, } from './canton/types';
72
3
  export declare function CantonProvider({ cantonService, children, withExport, autoOnboarding, autoTransferPreapproval, }: CantonProviderProps): import("react/jsx-runtime").JSX.Element;
73
4
  export declare function useCantonContext(): CantonContextValue;
@@ -0,0 +1,16 @@
1
+ import { CantonWallet } from '../../utils/wallet';
2
+ export type CantonChainType = 'stellar' | 'solana';
3
+ export interface SigningWalletInfo {
4
+ wallet: CantonWallet;
5
+ chainType: CantonChainType;
6
+ }
7
+ export interface ResolveSigningWalletParams {
8
+ primaryWallet: CantonWallet | null;
9
+ stellarWallets: CantonWallet[];
10
+ solanaWallets: CantonWallet[];
11
+ cantonPublicKey?: string | null;
12
+ defaultChainType: CantonChainType;
13
+ }
14
+ export declare const normalizeBase64Key: (value?: string | null) => string | null;
15
+ export declare const collectWalletsByChainType: (user: any, wallets: any[], targetChainType: CantonChainType) => CantonWallet[];
16
+ export declare const resolveSigningWalletFromCandidates: ({ primaryWallet, stellarWallets, solanaWallets, cantonPublicKey, defaultChainType, }: ResolveSigningWalletParams) => SigningWalletInfo;
@@ -0,0 +1,83 @@
1
+ import { ReactNode } from 'react';
2
+ import { CantonService, CantonSubmitPreparedOptions } from '../../services/cantonService';
3
+ import { CantonMeResponseDto, CantonActiveContractsResponseDto, CantonQueryCompletionResponseDto, CantonWalletBalancesResponseDto, CantonIncomingTransferDto, CantonTransactionDto, CantonTransactionsParams, CantonPriceInterval, CantonPriceCandleDto, CantonPrepareTransferRequestDto, CantonCalculateTransferFeeResponseDto } from '../../core/types';
4
+ import { CantonWallet } from '../../utils/wallet';
5
+ export interface CantonSendCoinOptions extends CantonSubmitPreparedOptions {
6
+ /** Skip confirmation modal. Default: false */
7
+ skipModal?: boolean;
8
+ /**
9
+ * Instrument ID to transfer.
10
+ * Defaults to "Amulet" (CC).
11
+ */
12
+ instrumentId?: CantonPrepareTransferRequestDto['instrumentId'];
13
+ /**
14
+ * Optional instrument admin party ID.
15
+ * Useful for CIP-56 tokens.
16
+ */
17
+ instrumentAdmin?: CantonPrepareTransferRequestDto['instrumentAdmin'];
18
+ }
19
+ export interface CantonContextValue {
20
+ /** First Stellar wallet (primary) */
21
+ cantonWallet: CantonWallet | null;
22
+ /** All Stellar wallets */
23
+ cantonWallets: CantonWallet[];
24
+ /** Create new Stellar wallet */
25
+ createCantonWallet: () => Promise<CantonWallet | null>;
26
+ /** Register Canton wallet on backend */
27
+ registerCanton: (inviteCode?: string) => Promise<void>;
28
+ /** Whether Canton wallet is registered */
29
+ isRegistered: boolean;
30
+ /** Canton user info (partyId, email, transferPreapprovalSet) */
31
+ cantonUser: CantonMeResponseDto | null;
32
+ /** Get Canton user info */
33
+ getMe: () => Promise<CantonMeResponseDto>;
34
+ /** Get active contracts with optional filtering */
35
+ getActiveContracts: (templateIds?: string[]) => Promise<CantonActiveContractsResponseDto>;
36
+ /** Canton wallet balances */
37
+ cantonBalances: CantonWalletBalancesResponseDto | null;
38
+ /** Get Canton wallet balances */
39
+ getBalances: () => Promise<CantonWalletBalancesResponseDto>;
40
+ /** Tap devnet faucet */
41
+ tapDevnet: (amount: string, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
42
+ /** Sign hash with Stellar wallet */
43
+ signHash: (hashBase64: string) => Promise<string>;
44
+ /** Sign text message */
45
+ signMessage: (message: string) => Promise<string>;
46
+ /** Prepare and submit transaction with polling for completion */
47
+ sendTransaction: (commands: unknown, disclosedContracts?: unknown, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
48
+ /** Send transfer to another party (defaults to Canton Coin / Amulet) */
49
+ sendCantonCoin: (receiverPartyId: string, amount: string, memo?: string, options?: CantonSendCoinOptions) => Promise<CantonQueryCompletionResponseDto>;
50
+ /** Calculate transfer fee in CC for current user party */
51
+ calculateTransferFee: (instrumentId?: string, instrumentAdmin?: string) => Promise<CantonCalculateTransferFeeResponseDto>;
52
+ /** Setup transfer preapproval (internal, called automatically) */
53
+ setupTransferPreapproval: () => Promise<void>;
54
+ /** Get pending incoming transfers */
55
+ getPendingIncomingTransfers: () => Promise<CantonIncomingTransferDto[]>;
56
+ /** Respond to incoming transfer (accept or reject) */
57
+ respondToIncomingTransfer: (contractId: string, accept: boolean, options?: CantonSubmitPreparedOptions) => Promise<CantonQueryCompletionResponseDto>;
58
+ /** Get Canton transactions history with pagination */
59
+ getTransactions: (params?: CantonTransactionsParams) => Promise<CantonTransactionDto[]>;
60
+ /** Get Canton price history (candles from Bybit) */
61
+ getPriceHistory: (interval: CantonPriceInterval) => Promise<CantonPriceCandleDto[]>;
62
+ /** Reset all Canton state (for logout) */
63
+ resetState: () => void;
64
+ /** Loading state */
65
+ loading: boolean;
66
+ /** Error state */
67
+ error: Error | null;
68
+ /** Clear error */
69
+ clearError: () => void;
70
+ }
71
+ export interface CantonProviderProps {
72
+ cantonService: CantonService;
73
+ children: ReactNode;
74
+ /** Enable wallet export (uses Solana instead of Stellar). Default: false */
75
+ withExport?: boolean;
76
+ /** Enable automatic onboarding (create wallet + register Canton on login). Default: true */
77
+ autoOnboarding?: boolean;
78
+ /**
79
+ * Legacy onboarding stage: automatically setup transfer preapproval after registration.
80
+ * Default: false (new onboarding uses prepare_initialization_transactions).
81
+ */
82
+ autoTransferPreapproval?: boolean;
83
+ }
@@ -1,6 +1,6 @@
1
1
  import { ApiClient } from '../core/client';
2
- import { CantonPrepareTransactionResponseDto, CantonSubmitRegisterRequestDto, CantonSubmitTransactionResponseDto, CantonMeResponseDto, CantonActiveContractsResponseDto, CantonQueryCompletionResponseDto, CantonWalletBalancesResponseDto, CantonPrepareAmuletTransferRequestDto, CantonPrepareAmuletTransferResponseDto, CantonIncomingTransferDto, CantonPrepareResponseIncomingTransferRequestDto, CantonCostEstimationDto, CantonTransactionDto, CantonTransactionsParams, CantonPriceInterval, CantonPriceCandleDto, CantonSubmitMultipleResultDto } from '../core/types';
3
- export type { CantonMeResponseDto, CantonActiveContractsResponseDto, CantonPrepareTransactionResponseDto, CantonQueryCompletionResponseDto, CantonWalletBalancesResponseDto, CantonPrepareAmuletTransferRequestDto, CantonPrepareAmuletTransferResponseDto, CantonIncomingTransferDto, CantonPrepareResponseIncomingTransferRequestDto, CantonCostEstimationDto, CantonTransactionDto, CantonTransactionsParams, CantonPriceInterval, CantonPriceCandleDto, CantonSubmitMultipleResultDto, };
2
+ import { CantonPrepareTransactionResponseDto, CantonSubmitRegisterRequestDto, CantonSubmitTransactionResponseDto, CantonMeResponseDto, CantonActiveContractsResponseDto, CantonQueryCompletionResponseDto, CantonWalletBalancesResponseDto, CantonPrepareTransferRequestDto, CantonPrepareTransferResponseDto, CantonCalculateTransferFeeRequestDto, CantonCalculateTransferFeeResponseDto, CantonPrepareAmuletTransferRequestDto, CantonPrepareAmuletTransferResponseDto, CantonIncomingTransferDto, CantonPrepareResponseIncomingTransferRequestDto, CantonCostEstimationDto, CantonTransactionDto, CantonTransactionsParams, CantonPriceInterval, CantonPriceCandleDto, CantonSubmitMultipleResultDto } from '../core/types';
3
+ export type { CantonMeResponseDto, CantonActiveContractsResponseDto, CantonPrepareTransactionResponseDto, CantonQueryCompletionResponseDto, CantonWalletBalancesResponseDto, CantonPrepareTransferRequestDto, CantonPrepareTransferResponseDto, CantonCalculateTransferFeeRequestDto, CantonCalculateTransferFeeResponseDto, CantonPrepareAmuletTransferRequestDto, CantonPrepareAmuletTransferResponseDto, CantonIncomingTransferDto, CantonPrepareResponseIncomingTransferRequestDto, CantonCostEstimationDto, CantonTransactionDto, CantonTransactionsParams, CantonPriceInterval, CantonPriceCandleDto, CantonSubmitMultipleResultDto, };
4
4
  export interface CantonRegisterParams {
5
5
  /** Base64 public key from Stellar wallet */
6
6
  publicKey: string;
@@ -35,12 +35,17 @@ export declare class CantonService {
35
35
  private meCacheTimestamp;
36
36
  private mePendingPromise;
37
37
  private readonly CACHE_TTL;
38
+ private static readonly AMULET_INSTRUMENT_ID;
38
39
  constructor(client: ApiClient);
39
40
  /**
40
41
  * Invalidate /me cache
41
42
  * Called after registration/user modification operations
42
43
  */
43
44
  private invalidateMeCache;
45
+ /**
46
+ * Validate decimal places for transfer amount (max 10)
47
+ */
48
+ private validateTransferAmount;
44
49
  /**
45
50
  * Register Canton wallet
46
51
  * Flow:
@@ -137,11 +142,23 @@ export declare class CantonService {
137
142
  */
138
143
  getBalances(): Promise<CantonWalletBalancesResponseDto>;
139
144
  /**
140
- * Prepare Amulet (Canton Coin) transfer
141
- * @param params Transfer parameters (receiverPartyId, amount, memo)
145
+ * Prepare Canton transfer (Amulet or CIP-56 token)
146
+ * @param params Transfer parameters
142
147
  * @throws Error if amount has more than 10 decimal places
143
148
  */
149
+ prepareTransfer(params: CantonPrepareTransferRequestDto): Promise<CantonPrepareTransferResponseDto>;
150
+ /**
151
+ * Calculate transfer fee (always returned in CC)
152
+ */
153
+ calculateTransferFee(params: CantonCalculateTransferFeeRequestDto): Promise<CantonCalculateTransferFeeResponseDto>;
154
+ /**
155
+ * @deprecated Use `prepareTransfer` with `instrumentId: "Amulet"`.
156
+ */
144
157
  prepareAmuletTransfer(params: CantonPrepareAmuletTransferRequestDto): Promise<CantonPrepareAmuletTransferResponseDto>;
158
+ /**
159
+ * @deprecated Typo alias. Use `prepareAmuletTransfer`.
160
+ */
161
+ prepareAmuletTranafer(params: CantonPrepareAmuletTransferRequestDto): Promise<CantonPrepareAmuletTransferResponseDto>;
145
162
  /**
146
163
  * Get pending incoming transfers for the current user
147
164
  * Returns a list of transfer offers that can be accepted or rejected
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supanovaapp/sdk",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "description": "React SDK for Supa Backend + Privy.io integration with Canton Network and EVM Smart Wallets support",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",