@ton-pay/ui-react 0.2.0 → 0.3.0

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/dist/index.d.mts CHANGED
@@ -18,7 +18,7 @@ type PayInfo<T extends object = object> = {
18
18
  txResult: SendTransactionResponse;
19
19
  } & T;
20
20
  interface TonPayButtonProps {
21
- handlePay: (onRequestSent?: (redirectToWallet: () => void) => void) => Promise<void>;
21
+ handlePay: () => Promise<void | any>;
22
22
  isLoading?: boolean;
23
23
  variant?: TonPayVariant;
24
24
  preset?: TonPayPreset;
@@ -38,10 +38,17 @@ interface TonPayButtonProps {
38
38
  disabled?: boolean;
39
39
  amount?: number | string;
40
40
  currency?: string;
41
+ asset?: string;
41
42
  apiKey?: string;
42
43
  isOnRampAvailable?: boolean;
43
- onCardPaymentSuccess?: () => void;
44
+ onCardPaymentSuccess?: (result?: OnRampTransactionResult) => void;
44
45
  itemTitle?: string;
46
+ recipientWalletAddress?: string;
47
+ }
48
+ interface OnRampTransactionResult {
49
+ reference: string;
50
+ status: string;
51
+ txHash: string;
45
52
  }
46
53
  interface NotificationProps {
47
54
  title: string;
@@ -56,15 +63,42 @@ interface PaymentModalProps {
56
63
  onPayWithCrypto: () => void;
57
64
  amount?: string;
58
65
  currency?: string;
66
+ asset?: string;
59
67
  itemTitle?: string;
60
68
  walletAddress?: string;
69
+ apiKey?: string;
70
+ recipientWalletAddress?: string;
61
71
  onDisconnect?: () => void;
62
- fetchOnRampLink?: (providerId: string) => Promise<string>;
72
+ fetchOnRampLink?: (providerId: string) => Promise<{
73
+ link: string;
74
+ reference: string;
75
+ }>;
63
76
  onRampAvailable?: boolean;
64
- onPaymentSuccess?: () => void;
65
- isLoading?: boolean;
77
+ onPaymentSuccess?: (result?: OnRampTransactionResult) => void;
78
+ signlessEnabled?: boolean;
79
+ signlessApiUrl?: string;
80
+ onSignlessSetupComplete?: (data: SignlessSetupData) => void;
81
+ onPendingReferenceChange?: (reference: string | null) => void;
82
+ onClearPendingTransaction?: () => void;
83
+ network?: 'mainnet' | 'testnet';
84
+ /** The payment function to call when balance is sufficient (new card top-up flow) */
85
+ handlePay?: () => Promise<void | any>;
86
+ /** User's IP address for MoonPay geo check */
87
+ userIp?: string;
88
+ /** MoonPay minimum buy amount (from limits check) */
89
+ moonpayMinBuyAmount?: number;
90
+ /** Whether to use legacy card flow (direct to merchant) — default false */
91
+ legacyCardFlow?: boolean;
92
+ /** Called when top-up flow is initiated/completed to show waiting indicator below button */
93
+ onTopUpWaitingChange?: (isWaiting: boolean) => void;
94
+ }
95
+ interface SignlessSetupData {
96
+ publicKey: string;
97
+ walletAddress: string;
98
+ limit?: number;
99
+ token?: string;
66
100
  }
67
- type PaymentViewState = 'main' | 'card' | 'success' | 'error';
101
+ type PaymentViewState = 'main' | 'card' | 'confirming-card' | 'success' | 'error' | 'signless-setup' | 'signless-unlock' | 'insufficient-funds' | 'card-topup' | 'awaiting-deposit' | 'redirecting-moonpay' | 'topup-crypto' | 'topup-confirm' | 'ready-to-pay';
68
102
  interface BottomSheetProps {
69
103
  isOpen: boolean;
70
104
  onClose: () => void;
@@ -85,8 +119,29 @@ interface UseMoonPayIframeOptions {
85
119
  chain?: Chain;
86
120
  provider?: OnRampProvider;
87
121
  }
122
+ interface TonProofData {
123
+ network: string;
124
+ publicKey: string;
125
+ proof: {
126
+ timestamp: number;
127
+ domain: {
128
+ lengthBytes: number;
129
+ value: string;
130
+ };
131
+ signature: string;
132
+ payload: string;
133
+ state_init?: string;
134
+ };
135
+ }
88
136
 
89
- declare const TonPayButton: React.FC<TonPayButtonProps>;
137
+ interface TonPayButtonExtendedProps extends TonPayButtonProps {
138
+ asset?: string;
139
+ signlessEnabled?: boolean;
140
+ signlessApiUrl?: string;
141
+ signlessWalletConnection?: 'iframe' | 'merchant';
142
+ network?: 'mainnet' | 'testnet';
143
+ }
144
+ declare const TonPayButton: React.FC<TonPayButtonExtendedProps>;
90
145
 
91
146
  declare const PaymentModal: React.FC<PaymentModalProps>;
92
147
 
@@ -104,10 +159,80 @@ interface ErrorTransactionNotificationProps {
104
159
  }
105
160
  declare const ErrorTransactionNotification: React.FC<ErrorTransactionNotificationProps>;
106
161
 
107
- declare function useTonPay(): {
108
- pay: <T extends object = object>(getMessage: GetMessageFn<T>, options?: {
109
- onRequestSent?: (redirectToWallet: () => void) => void;
110
- }) => Promise<PayInfo<T>>;
162
+ type SignlessIframeMode = 'setup' | 'payment';
163
+ type SignlessWalletConnection = 'iframe' | 'merchant';
164
+ type SignlessIframeTheme = 'system' | 'light' | 'dark';
165
+ interface SignlessIframeProps {
166
+ isOpen: boolean;
167
+ mode: SignlessIframeMode;
168
+ sessionId?: string;
169
+ baseUrl?: string;
170
+ walletConnection?: SignlessWalletConnection;
171
+ theme?: SignlessIframeTheme;
172
+ network?: 'mainnet' | 'testnet';
173
+ walletAddress?: string;
174
+ tonProofData?: TonProofData;
175
+ amount?: string | number;
176
+ recipient?: string;
177
+ asset?: string;
178
+ assetSymbol?: string;
179
+ escrowTonBalance?: number;
180
+ comment?: string;
181
+ apiKey?: string;
182
+ referenceId?: string;
183
+ onSetupComplete?: (data: SignlessSetupResult) => void;
184
+ onSessionReady?: (data: {
185
+ walletAddress: string;
186
+ }) => void;
187
+ onSigned?: (data: SignlessSignedResult) => void;
188
+ onUseWallet?: () => void;
189
+ onError?: (error: string) => void;
190
+ onClose?: () => void;
191
+ onTopUpRequired?: (data: {
192
+ asset: string;
193
+ requiredAmount: string;
194
+ }) => void;
195
+ onTonProofRequestStateChange?: (isRequesting: boolean) => void;
196
+ onSetupRequired?: () => void;
197
+ variant?: 'modal' | 'embedded';
198
+ }
199
+ interface SignlessSetupResult {
200
+ publicKey: string;
201
+ walletAddress: string;
202
+ }
203
+ interface SignlessSignedResult {
204
+ signature: string;
205
+ referenceId?: string;
206
+ txHash?: string;
207
+ pin?: string;
208
+ sessionId?: string;
209
+ }
210
+ declare const SignlessIframe: React.FC<SignlessIframeProps>;
211
+
212
+ interface SignlessPaymentConfig {
213
+ apiUrl: string;
214
+ onSetupRequired?: () => void;
215
+ onUnlockRequired?: (sessionId: string) => Promise<string>;
216
+ }
217
+ interface SignlessPaymentResult {
218
+ success: boolean;
219
+ signature?: string;
220
+ publicKey?: string;
221
+ referenceId?: string;
222
+ error?: string;
223
+ txHash?: string;
224
+ }
225
+ declare function useTonPay(signlessConfig?: SignlessPaymentConfig): {
226
+ pay: <T extends object = object>(getMessage: GetMessageFn<T>) => Promise<PayInfo<T>>;
227
+ payWithSignless: <T extends object = object>(createMessageCallback: (senderAddress: string) => Promise<{
228
+ message: TonPayMessage;
229
+ referenceId: string;
230
+ } & T>) => Promise<SignlessPaymentResult & T>;
231
+ initiateSignlessSetup: (opts?: {
232
+ asset?: string;
233
+ assetSymbol?: string;
234
+ amount?: string | number;
235
+ }) => Promise<any>;
111
236
  address: string;
112
237
  };
113
238
 
@@ -115,10 +240,18 @@ declare function useMoonPayIframe({ apiKey, chain, }: UseMoonPayIframeOptions):
115
240
  loading: boolean;
116
241
  error: string | null;
117
242
  link: string | null;
118
- fetchOnRampLink: (params: CreateMoonpayTransferParams) => Promise<string>;
119
- checkAvailability: (amount: number, asset: string, ipAddress: string) => Promise<boolean>;
243
+ fetchOnRampLink: (params: CreateMoonpayTransferParams) => Promise<{
244
+ link: string;
245
+ reference: string;
246
+ }>;
247
+ checkAvailability: (_amount: number, asset: string, ipAddress: string) => Promise<boolean>;
248
+ checkAvailabilityWithLimits: (_amount: number, asset: string, ipAddress: string) => Promise<{
249
+ available: boolean;
250
+ minBuyAmount?: number;
251
+ maxBuyAmount?: number;
252
+ }>;
120
253
  geoResult: MoonpayGeoResult | null;
121
254
  limits: MoonpayAmountLimits | null;
122
255
  };
123
256
 
124
- export { BottomSheet, type BottomSheetProps, ErrorTransactionNotification, type GetMessageFn, NotificationCard, type NotificationProps, NotificationRoot, type OnRampProvider, type PayInfo, PaymentModal, type PaymentModalProps, type PaymentViewState, TonPayButton, type TonPayButtonProps, type TonPayMessage, type TonPayPreset, type TonPayVariant, type UseMoonPayIframeOptions, useMoonPayIframe, useTonPay };
257
+ export { BottomSheet, type BottomSheetProps, ErrorTransactionNotification, type GetMessageFn, NotificationCard, type NotificationProps, NotificationRoot, type OnRampProvider, type OnRampTransactionResult, type PayInfo, PaymentModal, type PaymentModalProps, type PaymentViewState, SignlessIframe, type SignlessIframeMode, type SignlessIframeProps, type SignlessPaymentConfig, type SignlessPaymentResult, type SignlessSetupData, type SignlessSetupResult, type SignlessSignedResult, TonPayButton, type TonPayButtonExtendedProps, type TonPayButtonProps, type TonPayMessage, type TonPayPreset, type TonPayVariant, type UseMoonPayIframeOptions, useMoonPayIframe, useTonPay };
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ type PayInfo<T extends object = object> = {
18
18
  txResult: SendTransactionResponse;
19
19
  } & T;
20
20
  interface TonPayButtonProps {
21
- handlePay: (onRequestSent?: (redirectToWallet: () => void) => void) => Promise<void>;
21
+ handlePay: () => Promise<void | any>;
22
22
  isLoading?: boolean;
23
23
  variant?: TonPayVariant;
24
24
  preset?: TonPayPreset;
@@ -38,10 +38,17 @@ interface TonPayButtonProps {
38
38
  disabled?: boolean;
39
39
  amount?: number | string;
40
40
  currency?: string;
41
+ asset?: string;
41
42
  apiKey?: string;
42
43
  isOnRampAvailable?: boolean;
43
- onCardPaymentSuccess?: () => void;
44
+ onCardPaymentSuccess?: (result?: OnRampTransactionResult) => void;
44
45
  itemTitle?: string;
46
+ recipientWalletAddress?: string;
47
+ }
48
+ interface OnRampTransactionResult {
49
+ reference: string;
50
+ status: string;
51
+ txHash: string;
45
52
  }
46
53
  interface NotificationProps {
47
54
  title: string;
@@ -56,15 +63,42 @@ interface PaymentModalProps {
56
63
  onPayWithCrypto: () => void;
57
64
  amount?: string;
58
65
  currency?: string;
66
+ asset?: string;
59
67
  itemTitle?: string;
60
68
  walletAddress?: string;
69
+ apiKey?: string;
70
+ recipientWalletAddress?: string;
61
71
  onDisconnect?: () => void;
62
- fetchOnRampLink?: (providerId: string) => Promise<string>;
72
+ fetchOnRampLink?: (providerId: string) => Promise<{
73
+ link: string;
74
+ reference: string;
75
+ }>;
63
76
  onRampAvailable?: boolean;
64
- onPaymentSuccess?: () => void;
65
- isLoading?: boolean;
77
+ onPaymentSuccess?: (result?: OnRampTransactionResult) => void;
78
+ signlessEnabled?: boolean;
79
+ signlessApiUrl?: string;
80
+ onSignlessSetupComplete?: (data: SignlessSetupData) => void;
81
+ onPendingReferenceChange?: (reference: string | null) => void;
82
+ onClearPendingTransaction?: () => void;
83
+ network?: 'mainnet' | 'testnet';
84
+ /** The payment function to call when balance is sufficient (new card top-up flow) */
85
+ handlePay?: () => Promise<void | any>;
86
+ /** User's IP address for MoonPay geo check */
87
+ userIp?: string;
88
+ /** MoonPay minimum buy amount (from limits check) */
89
+ moonpayMinBuyAmount?: number;
90
+ /** Whether to use legacy card flow (direct to merchant) — default false */
91
+ legacyCardFlow?: boolean;
92
+ /** Called when top-up flow is initiated/completed to show waiting indicator below button */
93
+ onTopUpWaitingChange?: (isWaiting: boolean) => void;
94
+ }
95
+ interface SignlessSetupData {
96
+ publicKey: string;
97
+ walletAddress: string;
98
+ limit?: number;
99
+ token?: string;
66
100
  }
67
- type PaymentViewState = 'main' | 'card' | 'success' | 'error';
101
+ type PaymentViewState = 'main' | 'card' | 'confirming-card' | 'success' | 'error' | 'signless-setup' | 'signless-unlock' | 'insufficient-funds' | 'card-topup' | 'awaiting-deposit' | 'redirecting-moonpay' | 'topup-crypto' | 'topup-confirm' | 'ready-to-pay';
68
102
  interface BottomSheetProps {
69
103
  isOpen: boolean;
70
104
  onClose: () => void;
@@ -85,8 +119,29 @@ interface UseMoonPayIframeOptions {
85
119
  chain?: Chain;
86
120
  provider?: OnRampProvider;
87
121
  }
122
+ interface TonProofData {
123
+ network: string;
124
+ publicKey: string;
125
+ proof: {
126
+ timestamp: number;
127
+ domain: {
128
+ lengthBytes: number;
129
+ value: string;
130
+ };
131
+ signature: string;
132
+ payload: string;
133
+ state_init?: string;
134
+ };
135
+ }
88
136
 
89
- declare const TonPayButton: React.FC<TonPayButtonProps>;
137
+ interface TonPayButtonExtendedProps extends TonPayButtonProps {
138
+ asset?: string;
139
+ signlessEnabled?: boolean;
140
+ signlessApiUrl?: string;
141
+ signlessWalletConnection?: 'iframe' | 'merchant';
142
+ network?: 'mainnet' | 'testnet';
143
+ }
144
+ declare const TonPayButton: React.FC<TonPayButtonExtendedProps>;
90
145
 
91
146
  declare const PaymentModal: React.FC<PaymentModalProps>;
92
147
 
@@ -104,10 +159,80 @@ interface ErrorTransactionNotificationProps {
104
159
  }
105
160
  declare const ErrorTransactionNotification: React.FC<ErrorTransactionNotificationProps>;
106
161
 
107
- declare function useTonPay(): {
108
- pay: <T extends object = object>(getMessage: GetMessageFn<T>, options?: {
109
- onRequestSent?: (redirectToWallet: () => void) => void;
110
- }) => Promise<PayInfo<T>>;
162
+ type SignlessIframeMode = 'setup' | 'payment';
163
+ type SignlessWalletConnection = 'iframe' | 'merchant';
164
+ type SignlessIframeTheme = 'system' | 'light' | 'dark';
165
+ interface SignlessIframeProps {
166
+ isOpen: boolean;
167
+ mode: SignlessIframeMode;
168
+ sessionId?: string;
169
+ baseUrl?: string;
170
+ walletConnection?: SignlessWalletConnection;
171
+ theme?: SignlessIframeTheme;
172
+ network?: 'mainnet' | 'testnet';
173
+ walletAddress?: string;
174
+ tonProofData?: TonProofData;
175
+ amount?: string | number;
176
+ recipient?: string;
177
+ asset?: string;
178
+ assetSymbol?: string;
179
+ escrowTonBalance?: number;
180
+ comment?: string;
181
+ apiKey?: string;
182
+ referenceId?: string;
183
+ onSetupComplete?: (data: SignlessSetupResult) => void;
184
+ onSessionReady?: (data: {
185
+ walletAddress: string;
186
+ }) => void;
187
+ onSigned?: (data: SignlessSignedResult) => void;
188
+ onUseWallet?: () => void;
189
+ onError?: (error: string) => void;
190
+ onClose?: () => void;
191
+ onTopUpRequired?: (data: {
192
+ asset: string;
193
+ requiredAmount: string;
194
+ }) => void;
195
+ onTonProofRequestStateChange?: (isRequesting: boolean) => void;
196
+ onSetupRequired?: () => void;
197
+ variant?: 'modal' | 'embedded';
198
+ }
199
+ interface SignlessSetupResult {
200
+ publicKey: string;
201
+ walletAddress: string;
202
+ }
203
+ interface SignlessSignedResult {
204
+ signature: string;
205
+ referenceId?: string;
206
+ txHash?: string;
207
+ pin?: string;
208
+ sessionId?: string;
209
+ }
210
+ declare const SignlessIframe: React.FC<SignlessIframeProps>;
211
+
212
+ interface SignlessPaymentConfig {
213
+ apiUrl: string;
214
+ onSetupRequired?: () => void;
215
+ onUnlockRequired?: (sessionId: string) => Promise<string>;
216
+ }
217
+ interface SignlessPaymentResult {
218
+ success: boolean;
219
+ signature?: string;
220
+ publicKey?: string;
221
+ referenceId?: string;
222
+ error?: string;
223
+ txHash?: string;
224
+ }
225
+ declare function useTonPay(signlessConfig?: SignlessPaymentConfig): {
226
+ pay: <T extends object = object>(getMessage: GetMessageFn<T>) => Promise<PayInfo<T>>;
227
+ payWithSignless: <T extends object = object>(createMessageCallback: (senderAddress: string) => Promise<{
228
+ message: TonPayMessage;
229
+ referenceId: string;
230
+ } & T>) => Promise<SignlessPaymentResult & T>;
231
+ initiateSignlessSetup: (opts?: {
232
+ asset?: string;
233
+ assetSymbol?: string;
234
+ amount?: string | number;
235
+ }) => Promise<any>;
111
236
  address: string;
112
237
  };
113
238
 
@@ -115,10 +240,18 @@ declare function useMoonPayIframe({ apiKey, chain, }: UseMoonPayIframeOptions):
115
240
  loading: boolean;
116
241
  error: string | null;
117
242
  link: string | null;
118
- fetchOnRampLink: (params: CreateMoonpayTransferParams) => Promise<string>;
119
- checkAvailability: (amount: number, asset: string, ipAddress: string) => Promise<boolean>;
243
+ fetchOnRampLink: (params: CreateMoonpayTransferParams) => Promise<{
244
+ link: string;
245
+ reference: string;
246
+ }>;
247
+ checkAvailability: (_amount: number, asset: string, ipAddress: string) => Promise<boolean>;
248
+ checkAvailabilityWithLimits: (_amount: number, asset: string, ipAddress: string) => Promise<{
249
+ available: boolean;
250
+ minBuyAmount?: number;
251
+ maxBuyAmount?: number;
252
+ }>;
120
253
  geoResult: MoonpayGeoResult | null;
121
254
  limits: MoonpayAmountLimits | null;
122
255
  };
123
256
 
124
- export { BottomSheet, type BottomSheetProps, ErrorTransactionNotification, type GetMessageFn, NotificationCard, type NotificationProps, NotificationRoot, type OnRampProvider, type PayInfo, PaymentModal, type PaymentModalProps, type PaymentViewState, TonPayButton, type TonPayButtonProps, type TonPayMessage, type TonPayPreset, type TonPayVariant, type UseMoonPayIframeOptions, useMoonPayIframe, useTonPay };
257
+ export { BottomSheet, type BottomSheetProps, ErrorTransactionNotification, type GetMessageFn, NotificationCard, type NotificationProps, NotificationRoot, type OnRampProvider, type OnRampTransactionResult, type PayInfo, PaymentModal, type PaymentModalProps, type PaymentViewState, SignlessIframe, type SignlessIframeMode, type SignlessIframeProps, type SignlessPaymentConfig, type SignlessPaymentResult, type SignlessSetupData, type SignlessSetupResult, type SignlessSignedResult, TonPayButton, type TonPayButtonExtendedProps, type TonPayButtonProps, type TonPayMessage, type TonPayPreset, type TonPayVariant, type UseMoonPayIframeOptions, useMoonPayIframe, useTonPay };