@tonconnect/ui-react 0.0.5 → 0.0.7
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 +46 -0
- package/lib/components/TonConnectUIProvider.d.ts +24 -11
- package/lib/components/index.d.ts +2 -2
- package/lib/index.d.ts +1 -3
- package/lib/index.js +716 -460
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +717 -461
- package/lib/index.umd.js.map +1 -1
- package/lib/library.d.ts +3 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -144,3 +144,49 @@ export const Settings = () => {
|
|
|
144
144
|
);
|
|
145
145
|
};
|
|
146
146
|
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
## Add connect request parameters (ton_proof)
|
|
150
|
+
Pass `getConnectParameters` async function to the `TonConnectUIProvider`. This callback will be called after `connectWallet` method call or `Connect Button` click before wallets list render.
|
|
151
|
+
|
|
152
|
+
In other words, if `getConnectParameters` is passed, there will be a following steps:
|
|
153
|
+
1. User clicks to the 'Connect Wallet' button, or `connectWallet` method is called
|
|
154
|
+
2. Wallets modal opens
|
|
155
|
+
3. Loader renders in the center of the modal
|
|
156
|
+
4. TonConnectUI calls `getConnectParameters` and waits while it resolves
|
|
157
|
+
5. Wallets list renders in the center of the modal
|
|
158
|
+
|
|
159
|
+
Note that there is no any caching for `getConnectParameters` -- every time wallets modal opens there will be the 5 steps above.
|
|
160
|
+
|
|
161
|
+
If you have to make a http-request to your backend it this case, it is better to do it after app initialization (if possible) and return (probably completed) promise from the `getConnectParameters` to reduce loading time for the user.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
const tonProofPayloadPromise = getTonProofFromYourBackend(); // will be executed during app initialization
|
|
165
|
+
// don't forget to manage to refetch payload from your backend if needed
|
|
166
|
+
<TonConnectUIProvider
|
|
167
|
+
manifestUrl="https://<YOUR_APP_URL>/tonconnect-manifest.json"
|
|
168
|
+
getConnectParameters={async () => {
|
|
169
|
+
const tonProof = await tonProofPayloadPromise; // will be executed every time when wallets modal is opened. It is recommended to make an http-request in advance
|
|
170
|
+
return {
|
|
171
|
+
tonProof
|
|
172
|
+
};
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
{ /* Your app */ }
|
|
176
|
+
</TonConnectUIProvider>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
You can find `ton_proof` result in the `wallet` object when wallet will be connected:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import {useEffect} from "react";
|
|
183
|
+
|
|
184
|
+
const wallet = useTonWallet();
|
|
185
|
+
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (wallet && wallet.connectItems?.tonProof && 'proof' in wallet.connectItems.tonProof) {
|
|
188
|
+
checkProofInYourBackend(wallet.connectItems.tonProof.proof);
|
|
189
|
+
}
|
|
190
|
+
}, [wallet]);
|
|
191
|
+
```
|
|
192
|
+
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Locales, Theme, TonConnectUI } from '@tonconnect/ui';
|
|
2
|
-
import { ITonConnect } from '@tonconnect/sdk';
|
|
3
|
-
import type * as CSS from 'csstype';
|
|
4
|
-
declare type Color = CSS.Property.Color;
|
|
1
|
+
import { ActionConfiguration, Locales, Theme, TonConnectUI, UIPreferences, WalletsListConfiguration } from '@tonconnect/ui';
|
|
2
|
+
import type { ConnectAdditionalRequest, ITonConnect } from '@tonconnect/sdk';
|
|
5
3
|
export declare const TonConnectUIContext: import("react").Context<TonConnectUI | null>;
|
|
6
4
|
export declare type TonConnectUIProviderProps = {
|
|
7
5
|
children: JSX.Element;
|
|
@@ -30,11 +28,6 @@ export interface TonConnectUIProviderPropsBase {
|
|
|
30
28
|
* @default SYSTEM theme.
|
|
31
29
|
*/
|
|
32
30
|
theme: Theme;
|
|
33
|
-
/**
|
|
34
|
-
* Accent color for the UI elements.
|
|
35
|
-
* @default #31A6F5 (blue).
|
|
36
|
-
*/
|
|
37
|
-
accentColor: Color;
|
|
38
31
|
/**
|
|
39
32
|
* Language for the phrases it the UI elements.
|
|
40
33
|
* @default system
|
|
@@ -46,9 +39,29 @@ export interface TonConnectUIProviderPropsBase {
|
|
|
46
39
|
*/
|
|
47
40
|
widgetRootId: string;
|
|
48
41
|
/**
|
|
49
|
-
*
|
|
42
|
+
* UI elements configuration.
|
|
43
|
+
*/
|
|
44
|
+
uiPreferences?: UIPreferences;
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for the wallets list in the connect wallet modal.
|
|
47
|
+
*/
|
|
48
|
+
walletsList?: WalletsListConfiguration;
|
|
49
|
+
/**
|
|
50
|
+
* Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications.
|
|
51
|
+
*/
|
|
52
|
+
actionsConfiguration?: ActionConfiguration;
|
|
53
|
+
/**
|
|
54
|
+
* Redefine wallets list source URL. Must be a link to a json file with [following structure]{@link https://github.com/ton-connect/wallets-list}
|
|
55
|
+
* @default https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json
|
|
56
|
+
* @
|
|
57
|
+
*/
|
|
58
|
+
walletsListSource?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Use it to customize ConnectRequest and add `tonProof` payload.
|
|
61
|
+
* The function will be called after wallets modal opens, and wallets selection will be blocked until it's resolved.
|
|
62
|
+
* 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.
|
|
50
63
|
*/
|
|
51
|
-
|
|
64
|
+
getConnectParameters?: () => Promise<ConnectAdditionalRequest>;
|
|
52
65
|
}
|
|
53
66
|
declare const _default: import("react").NamedExoticComponent<TonConnectUIProviderProps>;
|
|
54
67
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as TonConnectButton } from './TonConnectButton';
|
|
2
|
-
export { default as TonConnectUIProvider } from './TonConnectUIProvider';
|
|
1
|
+
export { default as TonConnectButton, type TonConnectButtonProps } from './TonConnectButton';
|
|
2
|
+
export { default as TonConnectUIProvider, type TonConnectUIProviderProps, type TonConnectUIProviderPropsBase, type TonConnectUIProviderPropsWithConnector, type TonConnectUIProviderPropsWithManifest, TonConnectUIContext } from './TonConnectUIProvider';
|
package/lib/index.d.ts
CHANGED