@tonconnect/ui 0.0.16 → 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/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WalletInfoBase, WalletInfoInjected, WalletInfoRemote, ITonConnect, ConnectAdditionalRequest, Wallet, WalletInfo, Account, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
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';
@@ -27,10 +27,12 @@ declare type ColorsSet = {
27
27
  secondary: Color$1;
28
28
  tertiary: Color$1;
29
29
  success: Color$1;
30
+ error: Color$1;
30
31
  };
31
32
  background: {
32
33
  primary: Color$1;
33
34
  secondary: Color$1;
35
+ segment: Color$1;
34
36
  };
35
37
  text: {
36
38
  primary: Color$1;
@@ -52,10 +54,12 @@ declare type PartialColorsSet = {
52
54
  secondary?: Color$1;
53
55
  tertiary?: Color$1;
54
56
  success?: Color$1;
57
+ error?: Color$1;
55
58
  };
56
59
  background?: {
57
60
  primary?: Color$1;
58
61
  secondary?: Color$1;
62
+ segment?: Color$1;
59
63
  };
60
64
  text?: {
61
65
  primary?: Color$1;
@@ -70,7 +74,7 @@ interface UIPreferences {
70
74
  */
71
75
  theme?: Theme;
72
76
  /**
73
- * Birder radius for UI elements.
77
+ * Border radius for UI elements.
74
78
  * @default 'm'
75
79
  */
76
80
  borderRadius?: BorderRadius;
@@ -80,35 +84,16 @@ interface UIPreferences {
80
84
  colorsSet?: Partial<Record<THEME, PartialColorsSet>>;
81
85
  }
82
86
 
83
- declare type UIWallet = WalletInfoBase & (Omit<WalletInfoInjected, 'injected' | 'embedded'> | WalletInfoRemote);
87
+ declare type UIWallet = WalletInfoBase & (Omit<WalletInfoInjectable, 'injected' | 'embedded'> | WalletInfoRemote);
84
88
 
85
- declare type WalletsListConfiguration = WalletsListConfigurationExplicit | WalletsListConfigurationImplicit;
86
89
  /**
87
- * Configure whole list of wallets in the modal. Only passed wallets will be displayed.
90
+ * Add corrections to the default wallets list in the modal: add custom wallets and change wallets order.
88
91
  */
89
- declare type WalletsListConfigurationExplicit = {
90
- /**
91
- * Allows to configure wallets order and add custom wallets. Must be an array of wallets names from WalletsList or custom wallets.
92
- */
93
- wallets: (string | UIWallet)[];
94
- };
95
- /**
96
- * Add corrections to the default wallets list in the modal: exclude some wallets and add custom wallets.
97
- */
98
- declare type WalletsListConfigurationImplicit = {
99
- /**
100
- * Allows to exclude wallets from wallets list in the modal by its names. Must be an array of wallet's names from WalletsList.
101
- */
102
- excludeWallets?: string[];
92
+ declare type WalletsListConfiguration = {
103
93
  /**
104
94
  * Allows to include extra wallets to the wallets list in the modal.
105
95
  */
106
96
  includeWallets?: UIWallet[];
107
- /**
108
- * Allows to specify order of the extra wallets in the wallets list in the modal. Cannot be applied if `includeWallets` is not specified.
109
- * @default 'end'.
110
- */
111
- includeWalletsOrder?: 'start' | 'end';
112
97
  };
113
98
 
114
99
  /**
@@ -153,7 +138,7 @@ interface TonConnectUiOptions {
153
138
  /**
154
139
  * Configuration for the wallets list in the connect wallet modal.
155
140
  */
156
- walletsList?: WalletsListConfiguration;
141
+ walletsListConfiguration?: WalletsListConfiguration;
157
142
  /**
158
143
  * Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications and wallet behaviour (return strategy).
159
144
  */
@@ -185,34 +170,34 @@ interface TonConnectUiCreateOptionsBase extends TonConnectUiOptions {
185
170
  * @default `div#tc-widget-root`.
186
171
  */
187
172
  widgetRootId?: string;
188
- /**
189
- * Use it to customize ConnectRequest and add `tonProof` payload.
190
- * The function will be called after wallets modal opens, and wallets selection will be blocked until it's resolved.
191
- * 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.
192
- */
193
- getConnectParameters?: () => Promise<ConnectAdditionalRequest>;
194
- /**
195
- * Redefine wallets list source URL. Must be a link to a json file with [following structure]{@link https://github.com/ton-connect/wallets-list}
196
- * @default https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json
197
- * @
198
- */
199
- walletsListSource?: string;
200
173
  }
201
174
 
202
175
  declare type WalletOpenMethod = 'qrcode' | 'universal-link';
203
- declare type WalletInfoWithOpenMethod = WalletInfoInjected | WalletInfoRemoteWithOpenMethod | (WalletInfoInjected & WalletInfoRemoteWithOpenMethod);
176
+ declare type WalletInfoWithOpenMethod = WalletInfoInjectable | WalletInfoRemoteWithOpenMethod | (WalletInfoInjectable & WalletInfoRemoteWithOpenMethod);
204
177
  declare type WalletInfoRemoteWithOpenMethod = WalletInfoRemote & {
205
178
  openMethod: WalletOpenMethod;
206
179
  };
207
180
  declare type ConnectedWallet = Wallet & WalletInfoWithOpenMethod;
208
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
+
209
191
  declare class TonConnectUI {
210
192
  static getWallets(): Promise<WalletInfo[]>;
211
193
  private readonly walletInfoStorage;
212
- private readonly connector;
213
- private _walletInfo;
194
+ private readonly preferredWalletStorage;
195
+ readonly connector: ITonConnect;
196
+ private walletInfo;
214
197
  private systemThemeChangeUnsubscribe;
215
198
  private actionsConfiguration?;
199
+ private readonly walletsList;
200
+ private connectRequestParametersCallback?;
216
201
  /**
217
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).
218
203
  * Resolved value `true`/`false` indicates if the session was restored successfully.
@@ -227,19 +212,22 @@ declare class TonConnectUI {
227
212
  */
228
213
  get account(): Account | null;
229
214
  /**
230
- * Curren connected wallet app or null.
215
+ * Curren connected wallet app and its info or null.
231
216
  */
232
- get wallet(): Wallet | null;
233
- /**
234
- * Curren connected wallet's info or null.
235
- */
236
- get walletInfo(): WalletInfoWithOpenMethod | null;
217
+ get wallet(): (Wallet & WalletInfoWithOpenMethod) | null;
237
218
  /**
238
219
  * Set and apply new UI options. Object with partial options should be passed. Passed options will be merged with current options.
239
220
  * @param options
240
221
  */
241
222
  set uiOptions(options: TonConnectUiOptions);
242
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;
243
231
  /**
244
232
  * Returns available wallets list.
245
233
  */
@@ -264,6 +252,8 @@ declare class TonConnectUI {
264
252
  */
265
253
  sendTransaction(tx: SendTransactionRequest, options?: ActionConfiguration): Promise<SendTransactionResponse>;
266
254
  private subscribeToWalletChange;
255
+ private setPreferredWalletName;
256
+ private getSelectedWalletInfo;
267
257
  private updateWalletInfo;
268
258
  private normalizeWidgetRoot;
269
259
  private checkButtonRootExist;
@@ -276,4 +266,4 @@ declare class TonConnectUIError extends TonConnectError {
276
266
  constructor(...args: ConstructorParameters<typeof Error>);
277
267
  }
278
268
 
279
- export { ActionConfiguration, BorderRadius, Color, ColorsSet, ConnectedWallet, Locales, PartialColorsSet, ReturnStrategy, THEME, Theme, TonConnectUI, TonConnectUIError, TonConnectUiCreateOptions, TonConnectUiCreateOptionsBase, TonConnectUiOptions, TonConnectUiOptionsWithConnector, TonConnectUiOptionsWithManifest, UIPreferences, UIWallet, WalletInfoRemoteWithOpenMethod, WalletInfoWithOpenMethod, WalletOpenMethod, WalletsListConfiguration, WalletsListConfigurationExplicit, WalletsListConfigurationImplicit, TonConnectUI as default };
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 };