@tonconnect/ui 0.0.17 → 1.0.0-beta.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/README.md +86 -67
- package/dist/tonconnect-ui.min.js +486 -253
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.d.ts +35 -47
- package/lib/index.js +5617 -4320
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +4994 -3697
- package/lib/index.umd.js.map +1 -1
- package/package.json +3 -4
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletInfoBase,
|
|
1
|
+
import { WalletInfoBase, WalletInfoInjectable, WalletInfoRemote, ITonConnect, Wallet, WalletInfo, Account, ConnectAdditionalRequest, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
|
|
2
2
|
import { Property } from 'csstype';
|
|
3
3
|
|
|
4
4
|
declare type Locales = 'en' | 'ru';
|
|
@@ -32,6 +32,7 @@ declare type ColorsSet = {
|
|
|
32
32
|
background: {
|
|
33
33
|
primary: Color$1;
|
|
34
34
|
secondary: Color$1;
|
|
35
|
+
segment: Color$1;
|
|
35
36
|
};
|
|
36
37
|
text: {
|
|
37
38
|
primary: Color$1;
|
|
@@ -58,6 +59,7 @@ declare type PartialColorsSet = {
|
|
|
58
59
|
background?: {
|
|
59
60
|
primary?: Color$1;
|
|
60
61
|
secondary?: Color$1;
|
|
62
|
+
segment?: Color$1;
|
|
61
63
|
};
|
|
62
64
|
text?: {
|
|
63
65
|
primary?: Color$1;
|
|
@@ -72,7 +74,7 @@ interface UIPreferences {
|
|
|
72
74
|
*/
|
|
73
75
|
theme?: Theme;
|
|
74
76
|
/**
|
|
75
|
-
*
|
|
77
|
+
* Border radius for UI elements.
|
|
76
78
|
* @default 'm'
|
|
77
79
|
*/
|
|
78
80
|
borderRadius?: BorderRadius;
|
|
@@ -82,35 +84,16 @@ interface UIPreferences {
|
|
|
82
84
|
colorsSet?: Partial<Record<THEME, PartialColorsSet>>;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
declare type UIWallet = WalletInfoBase & (Omit<
|
|
87
|
+
declare type UIWallet = WalletInfoBase & (Omit<WalletInfoInjectable, 'injected' | 'embedded'> | WalletInfoRemote);
|
|
86
88
|
|
|
87
|
-
declare type WalletsListConfiguration = WalletsListConfigurationExplicit | WalletsListConfigurationImplicit;
|
|
88
89
|
/**
|
|
89
|
-
*
|
|
90
|
+
* Add corrections to the default wallets list in the modal: add custom wallets and change wallets order.
|
|
90
91
|
*/
|
|
91
|
-
declare type
|
|
92
|
-
/**
|
|
93
|
-
* Allows to configure wallets order and add custom wallets. Must be an array of wallets names from WalletsList or custom wallets.
|
|
94
|
-
*/
|
|
95
|
-
wallets: (string | UIWallet)[];
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Add corrections to the default wallets list in the modal: exclude some wallets and add custom wallets.
|
|
99
|
-
*/
|
|
100
|
-
declare type WalletsListConfigurationImplicit = {
|
|
101
|
-
/**
|
|
102
|
-
* Allows to exclude wallets from wallets list in the modal by its names. Must be an array of wallet's names from WalletsList.
|
|
103
|
-
*/
|
|
104
|
-
excludeWallets?: string[];
|
|
92
|
+
declare type WalletsListConfiguration = {
|
|
105
93
|
/**
|
|
106
94
|
* Allows to include extra wallets to the wallets list in the modal.
|
|
107
95
|
*/
|
|
108
96
|
includeWallets?: UIWallet[];
|
|
109
|
-
/**
|
|
110
|
-
* Allows to specify order of the extra wallets in the wallets list in the modal. Cannot be applied if `includeWallets` is not specified.
|
|
111
|
-
* @default 'end'.
|
|
112
|
-
*/
|
|
113
|
-
includeWalletsOrder?: 'start' | 'end';
|
|
114
97
|
};
|
|
115
98
|
|
|
116
99
|
/**
|
|
@@ -155,7 +138,7 @@ interface TonConnectUiOptions {
|
|
|
155
138
|
/**
|
|
156
139
|
* Configuration for the wallets list in the connect wallet modal.
|
|
157
140
|
*/
|
|
158
|
-
|
|
141
|
+
walletsListConfiguration?: WalletsListConfiguration;
|
|
159
142
|
/**
|
|
160
143
|
* Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications and wallet behaviour (return strategy).
|
|
161
144
|
*/
|
|
@@ -187,34 +170,34 @@ interface TonConnectUiCreateOptionsBase extends TonConnectUiOptions {
|
|
|
187
170
|
* @default `div#tc-widget-root`.
|
|
188
171
|
*/
|
|
189
172
|
widgetRootId?: string;
|
|
190
|
-
/**
|
|
191
|
-
* Use it to customize ConnectRequest and add `tonProof` payload.
|
|
192
|
-
* The function will be called after wallets modal opens, and wallets selection will be blocked until it's resolved.
|
|
193
|
-
* If you have to make a http-request to your backend, it is better to do it after app initialization (if possible) and return (probably completed) promise to reduce loading time for the user.
|
|
194
|
-
*/
|
|
195
|
-
getConnectParameters?: () => Promise<ConnectAdditionalRequest>;
|
|
196
|
-
/**
|
|
197
|
-
* Redefine wallets list source URL. Must be a link to a json file with [following structure]{@link https://github.com/ton-connect/wallets-list}
|
|
198
|
-
* @default https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json
|
|
199
|
-
* @
|
|
200
|
-
*/
|
|
201
|
-
walletsListSource?: string;
|
|
202
173
|
}
|
|
203
174
|
|
|
204
175
|
declare type WalletOpenMethod = 'qrcode' | 'universal-link';
|
|
205
|
-
declare type WalletInfoWithOpenMethod =
|
|
176
|
+
declare type WalletInfoWithOpenMethod = WalletInfoInjectable | WalletInfoRemoteWithOpenMethod | (WalletInfoInjectable & WalletInfoRemoteWithOpenMethod);
|
|
206
177
|
declare type WalletInfoRemoteWithOpenMethod = WalletInfoRemote & {
|
|
207
178
|
openMethod: WalletOpenMethod;
|
|
208
179
|
};
|
|
209
180
|
declare type ConnectedWallet = Wallet & WalletInfoWithOpenMethod;
|
|
210
181
|
|
|
182
|
+
declare type Loadable<T> = LoadableLoading | LoadableReady<T>;
|
|
183
|
+
declare type LoadableLoading = {
|
|
184
|
+
state: 'loading';
|
|
185
|
+
};
|
|
186
|
+
declare type LoadableReady<T> = {
|
|
187
|
+
state: 'ready';
|
|
188
|
+
value: T;
|
|
189
|
+
};
|
|
190
|
+
|
|
211
191
|
declare class TonConnectUI {
|
|
212
192
|
static getWallets(): Promise<WalletInfo[]>;
|
|
213
193
|
private readonly walletInfoStorage;
|
|
214
|
-
private readonly
|
|
215
|
-
|
|
194
|
+
private readonly preferredWalletStorage;
|
|
195
|
+
readonly connector: ITonConnect;
|
|
196
|
+
private walletInfo;
|
|
216
197
|
private systemThemeChangeUnsubscribe;
|
|
217
198
|
private actionsConfiguration?;
|
|
199
|
+
private readonly walletsList;
|
|
200
|
+
private connectRequestParametersCallback?;
|
|
218
201
|
/**
|
|
219
202
|
* 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
203
|
* Resolved value `true`/`false` indicates if the session was restored successfully.
|
|
@@ -229,19 +212,22 @@ declare class TonConnectUI {
|
|
|
229
212
|
*/
|
|
230
213
|
get account(): Account | null;
|
|
231
214
|
/**
|
|
232
|
-
* Curren connected wallet app or null.
|
|
215
|
+
* Curren connected wallet app and its info or null.
|
|
233
216
|
*/
|
|
234
|
-
get wallet(): Wallet | null;
|
|
235
|
-
/**
|
|
236
|
-
* Curren connected wallet's info or null.
|
|
237
|
-
*/
|
|
238
|
-
get walletInfo(): WalletInfoWithOpenMethod | null;
|
|
217
|
+
get wallet(): (Wallet & WalletInfoWithOpenMethod) | null;
|
|
239
218
|
/**
|
|
240
219
|
* Set and apply new UI options. Object with partial options should be passed. Passed options will be merged with current options.
|
|
241
220
|
* @param options
|
|
242
221
|
*/
|
|
243
222
|
set uiOptions(options: TonConnectUiOptions);
|
|
244
223
|
constructor(options?: TonConnectUiCreateOptions);
|
|
224
|
+
/**
|
|
225
|
+
* Use it to customize ConnectRequest and add `tonProof` payload.
|
|
226
|
+
* You can call it multiply times to set updated tonProof payload if previous one is outdated.
|
|
227
|
+
* If `connectRequestParameters.state === 'loading'` loader will appear instead of the qr code in the wallets modal.
|
|
228
|
+
* If `connectRequestParameters.state` was changed to 'ready' or it's value has been changed, QR will be re-rendered.
|
|
229
|
+
*/
|
|
230
|
+
setConnectRequestParameters(connectRequestParameters: Loadable<ConnectAdditionalRequest> | undefined | null): void;
|
|
245
231
|
/**
|
|
246
232
|
* Returns available wallets list.
|
|
247
233
|
*/
|
|
@@ -266,6 +252,8 @@ declare class TonConnectUI {
|
|
|
266
252
|
*/
|
|
267
253
|
sendTransaction(tx: SendTransactionRequest, options?: ActionConfiguration): Promise<SendTransactionResponse>;
|
|
268
254
|
private subscribeToWalletChange;
|
|
255
|
+
private setPreferredWalletName;
|
|
256
|
+
private getSelectedWalletInfo;
|
|
269
257
|
private updateWalletInfo;
|
|
270
258
|
private normalizeWidgetRoot;
|
|
271
259
|
private checkButtonRootExist;
|
|
@@ -278,4 +266,4 @@ declare class TonConnectUIError extends TonConnectError {
|
|
|
278
266
|
constructor(...args: ConstructorParameters<typeof Error>);
|
|
279
267
|
}
|
|
280
268
|
|
|
281
|
-
export { ActionConfiguration, BorderRadius, Color, ColorsSet, ConnectedWallet, Locales, PartialColorsSet, ReturnStrategy, THEME, Theme, TonConnectUI, TonConnectUIError, TonConnectUiCreateOptions, TonConnectUiCreateOptionsBase, TonConnectUiOptions, TonConnectUiOptionsWithConnector, TonConnectUiOptionsWithManifest, UIPreferences, UIWallet, WalletInfoRemoteWithOpenMethod, WalletInfoWithOpenMethod, WalletOpenMethod, WalletsListConfiguration,
|
|
269
|
+
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, TonConnectUI as default };
|