@tonconnect/ui 2.0.0-beta.1 → 2.0.0-beta.10
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 +170 -24
- package/dist/tonconnect-ui.min.js +208 -207
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +10628 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +135 -3
- package/lib/{index.js → index.mjs} +863 -168
- package/lib/index.mjs.map +1 -0
- package/package.json +7 -7
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -9933
- package/lib/index.umd.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ interface ActionConfiguration {
|
|
|
131
131
|
*/
|
|
132
132
|
twaReturnUrl?: `${string}://${string}`;
|
|
133
133
|
/**
|
|
134
|
+
* @deprecated Shouldn't be used anymore, SDK will automatically detect return strategy for TWA-TWA connections.
|
|
134
135
|
* Specifies whether the method should redirect user to the connected wallet
|
|
135
136
|
* @default 'ios'
|
|
136
137
|
*/
|
|
@@ -160,6 +161,11 @@ interface TonConnectUiOptions {
|
|
|
160
161
|
* Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications and wallet behaviour (return strategy).
|
|
161
162
|
*/
|
|
162
163
|
actionsConfiguration?: ActionConfiguration;
|
|
164
|
+
/**
|
|
165
|
+
* Specifies whether the Android back button should be used to close modals and notifications on Android devices.
|
|
166
|
+
* @default true
|
|
167
|
+
*/
|
|
168
|
+
enableAndroidBackHandler?: boolean;
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
declare type TonConnectUiCreateOptions = TonConnectUiOptionsWithConnector | TonConnectUiOptionsWithManifest;
|
|
@@ -189,7 +195,7 @@ interface TonConnectUiCreateOptionsBase extends TonConnectUiOptions {
|
|
|
189
195
|
widgetRootId?: string;
|
|
190
196
|
}
|
|
191
197
|
|
|
192
|
-
declare type WalletOpenMethod = 'qrcode' | 'universal-link';
|
|
198
|
+
declare type WalletOpenMethod = 'qrcode' | 'universal-link' | 'custom-deeplink';
|
|
193
199
|
declare type WalletInfoWithOpenMethod = WalletInfoInjectable | WalletInfoRemoteWithOpenMethod | (WalletInfoInjectable & WalletInfoRemoteWithOpenMethod);
|
|
194
200
|
declare type WalletInfoRemoteWithOpenMethod = WalletInfoRemote & {
|
|
195
201
|
openMethod?: WalletOpenMethod;
|
|
@@ -205,16 +211,81 @@ declare type LoadableReady<T> = {
|
|
|
205
211
|
value: T;
|
|
206
212
|
};
|
|
207
213
|
|
|
214
|
+
interface WalletsModal {
|
|
215
|
+
/**
|
|
216
|
+
* Open the modal.
|
|
217
|
+
*/
|
|
218
|
+
open: () => void;
|
|
219
|
+
/**
|
|
220
|
+
* Close the modal.
|
|
221
|
+
*/
|
|
222
|
+
close: () => void;
|
|
223
|
+
/**
|
|
224
|
+
* Subscribe to the modal window status changes.
|
|
225
|
+
*/
|
|
226
|
+
onStateChange: (callback: (state: WalletsModalState) => void) => () => void;
|
|
227
|
+
/**
|
|
228
|
+
* Current modal window state.
|
|
229
|
+
*/
|
|
230
|
+
state: WalletsModalState;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Opened modal window state.
|
|
234
|
+
*/
|
|
235
|
+
declare type WalletModalOpened = {
|
|
236
|
+
/**
|
|
237
|
+
* Modal window status.
|
|
238
|
+
*/
|
|
239
|
+
status: 'opened';
|
|
240
|
+
/**
|
|
241
|
+
* Always `null` for opened modal window.
|
|
242
|
+
*/
|
|
243
|
+
closeReason: null;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Closed modal window state.
|
|
247
|
+
*/
|
|
248
|
+
declare type WalletModalClosed = {
|
|
249
|
+
/**
|
|
250
|
+
* Modal window status.
|
|
251
|
+
*/
|
|
252
|
+
status: 'closed';
|
|
253
|
+
/**
|
|
254
|
+
* Close reason, if the modal window was closed.
|
|
255
|
+
*/
|
|
256
|
+
closeReason: WalletsModalCloseReason | null;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Modal window state.
|
|
260
|
+
*/
|
|
261
|
+
declare type WalletsModalState = WalletModalOpened | WalletModalClosed;
|
|
262
|
+
/**
|
|
263
|
+
* Modal window close reason.
|
|
264
|
+
*/
|
|
265
|
+
declare type WalletsModalCloseReason = 'action-cancelled' | 'wallet-selected';
|
|
266
|
+
|
|
208
267
|
declare class TonConnectUI {
|
|
209
268
|
static getWallets(): Promise<WalletInfo[]>;
|
|
210
269
|
private readonly walletInfoStorage;
|
|
211
270
|
private readonly preferredWalletStorage;
|
|
212
|
-
readonly connector: ITonConnect;
|
|
213
271
|
private walletInfo;
|
|
214
272
|
private systemThemeChangeUnsubscribe;
|
|
215
273
|
private actionsConfiguration?;
|
|
216
274
|
private readonly walletsList;
|
|
217
275
|
private connectRequestParametersCallback?;
|
|
276
|
+
/**
|
|
277
|
+
* TonConnect instance.
|
|
278
|
+
*/
|
|
279
|
+
readonly connector: ITonConnect;
|
|
280
|
+
/**
|
|
281
|
+
* Manages the modal window state.
|
|
282
|
+
*/
|
|
283
|
+
readonly modal: WalletsModal;
|
|
284
|
+
/**
|
|
285
|
+
* Manages the transaction modal window state.
|
|
286
|
+
* TODO: make it public when interface will be ready for external usage.
|
|
287
|
+
*/
|
|
288
|
+
private readonly transactionModal;
|
|
218
289
|
/**
|
|
219
290
|
* Promise that resolves after end of th connection restoring process (promise will fire after `onStatusChange`, so you can get actual information about wallet and session after when promise resolved).
|
|
220
291
|
* Resolved value `true`/`false` indicates if the session was restored successfully.
|
|
@@ -255,7 +326,26 @@ declare class TonConnectUI {
|
|
|
255
326
|
*/
|
|
256
327
|
onStatusChange(callback: (wallet: ConnectedWallet | null) => void, errorsHandler?: (err: TonConnectError) => void): ReturnType<ITonConnect['onStatusChange']>;
|
|
257
328
|
/**
|
|
329
|
+
* Opens the modal window, returns a promise that resolves after the modal window is opened.
|
|
330
|
+
*/
|
|
331
|
+
openModal(): Promise<void>;
|
|
332
|
+
/**
|
|
333
|
+
* Closes the modal window.
|
|
334
|
+
*/
|
|
335
|
+
closeModal(): void;
|
|
336
|
+
/**
|
|
337
|
+
* Subscribe to the modal window state changes, returns a function which has to be called to unsubscribe.
|
|
338
|
+
*/
|
|
339
|
+
onModalStateChange(onChange: (state: WalletsModalState) => void): () => void;
|
|
340
|
+
/**
|
|
341
|
+
* Returns current modal window state.
|
|
342
|
+
*/
|
|
343
|
+
get modalState(): WalletsModalState;
|
|
344
|
+
/**
|
|
345
|
+
* @deprecated Use `tonConnectUI.openModal()` instead. Will be removed in the next major version.
|
|
258
346
|
* Opens the modal window and handles a wallet connection.
|
|
347
|
+
* @return Connected wallet.
|
|
348
|
+
* @throws TonConnectUIError if connection was aborted.
|
|
259
349
|
*/
|
|
260
350
|
connectWallet(): Promise<ConnectedWallet>;
|
|
261
351
|
/**
|
|
@@ -268,6 +358,48 @@ declare class TonConnectUI {
|
|
|
268
358
|
* @param options modal and notifications behaviour settings. Default is show only 'before' modal and all notifications.
|
|
269
359
|
*/
|
|
270
360
|
sendTransaction(tx: SendTransactionRequest, options?: ActionConfiguration): Promise<SendTransactionResponse>;
|
|
361
|
+
/**
|
|
362
|
+
* TODO: remove in the next major version.
|
|
363
|
+
* Initiates a connection with an embedded wallet, awaits its completion, and returns the connected wallet information.
|
|
364
|
+
* @param embeddedWallet - Information about the embedded wallet to connect to.
|
|
365
|
+
* @throws Error if the connection process fails.
|
|
366
|
+
* @internal
|
|
367
|
+
*/
|
|
368
|
+
private connectEmbeddedWallet;
|
|
369
|
+
/**
|
|
370
|
+
* TODO: remove in the next major version.
|
|
371
|
+
* Initiates the connection process for an external wallet by opening the wallet modal
|
|
372
|
+
* and returns the connected wallet information upon successful connection.
|
|
373
|
+
* @throws Error if the user cancels the connection process or if the connection process fails.
|
|
374
|
+
* @internal
|
|
375
|
+
*/
|
|
376
|
+
private connectExternalWallet;
|
|
377
|
+
/**
|
|
378
|
+
* TODO: remove in the next major version.
|
|
379
|
+
* Waits for a wallet connection based on provided options, returning connected wallet information.
|
|
380
|
+
* @param options - Configuration for connection statuses and errors handling.
|
|
381
|
+
* @options.ignoreErrors - If true, ignores errors during waiting, waiting continues until a valid wallet connects. Default is false.
|
|
382
|
+
* @options.abortSignal - Optional AbortSignal for external cancellation. Throws TonConnectUIError if aborted.
|
|
383
|
+
* @throws TonConnectUIError if waiting is aborted or no valid wallet connection is received and ignoreErrors is false.
|
|
384
|
+
* @internal
|
|
385
|
+
*/
|
|
386
|
+
private waitForWalletConnection;
|
|
387
|
+
/**
|
|
388
|
+
* Waits for a transaction to be sent based on provided options, returning the transaction response.
|
|
389
|
+
* @param options - Configuration for transaction statuses and errors handling.
|
|
390
|
+
* @options.transaction - Transaction to send.
|
|
391
|
+
* @options.ignoreErrors - If true, ignores errors during waiting, waiting continues until a valid transaction is sent. Default is false.
|
|
392
|
+
* @options.abortSignal - Optional AbortSignal for external cancellation. Throws TonConnectUIError if aborted.
|
|
393
|
+
* @param onRequestSent (optional) will be called after the transaction is sent to the wallet.
|
|
394
|
+
* @throws TonConnectUIError if waiting is aborted or no valid transaction response is received and ignoreErrors is false.
|
|
395
|
+
* @internal
|
|
396
|
+
*/
|
|
397
|
+
private waitForSendTransaction;
|
|
398
|
+
/**
|
|
399
|
+
* Subscribe to the transaction modal window state changes, returns a function which has to be called to unsubscribe.
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
private onTransactionModalStateChange;
|
|
271
403
|
private subscribeToWalletChange;
|
|
272
404
|
private setPreferredWalletAppName;
|
|
273
405
|
private getSelectedWalletInfo;
|
|
@@ -283,4 +415,4 @@ declare class TonConnectUIError extends TonConnectError {
|
|
|
283
415
|
constructor(...args: ConstructorParameters<typeof Error>);
|
|
284
416
|
}
|
|
285
417
|
|
|
286
|
-
export { ActionConfiguration, BorderRadius, Color, ColorsSet, ConnectedWallet, Loadable, LoadableLoading, LoadableReady, Locales, PartialColorsSet, ReturnStrategy, THEME, Theme, TonConnectUI, TonConnectUIError, TonConnectUiCreateOptions, TonConnectUiCreateOptionsBase, TonConnectUiOptions, TonConnectUiOptionsWithConnector, TonConnectUiOptionsWithManifest, UIPreferences, UIWallet, WalletInfoRemoteWithOpenMethod, WalletInfoWithOpenMethod, WalletOpenMethod, WalletsListConfiguration };
|
|
418
|
+
export { ActionConfiguration, BorderRadius, Color, ColorsSet, ConnectedWallet, Loadable, LoadableLoading, LoadableReady, Locales, PartialColorsSet, ReturnStrategy, THEME, Theme, TonConnectUI, TonConnectUIError, TonConnectUiCreateOptions, TonConnectUiCreateOptionsBase, TonConnectUiOptions, TonConnectUiOptionsWithConnector, TonConnectUiOptionsWithManifest, UIPreferences, UIWallet, WalletInfoRemoteWithOpenMethod, WalletInfoWithOpenMethod, WalletModalClosed, WalletModalOpened, WalletOpenMethod, WalletsListConfiguration, WalletsModal, WalletsModalCloseReason, WalletsModalState };
|