@tonconnect/ui
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -1,2 +0,2 @@ | ||
import { WalletInfoBase, WalletInfoInjected, WalletInfoRemote, ITonConnect, WalletInfo, Account, Wallet, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk'; | ||
import { WalletInfoBase, WalletInfoInjected, WalletInfoRemote, ITonConnect, ConnectAdditionalRequest, WalletInfo, Account, Wallet, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk'; | ||
import { Property } from 'csstype'; | ||
@@ -152,6 +152,2 @@ | ||
actionsConfiguration?: ActionConfiguration; | ||
/** | ||
* @deprecated Don't use it | ||
*/ | ||
walletsListSource?: string; | ||
} | ||
@@ -184,2 +180,14 @@ | ||
widgetRootId?: string; | ||
/** | ||
* Use it to customize ConnectRequest and add `tonProof` payload. | ||
* The function will be called after wallets modal opens, and wallets selection will be blocked until it's resolved. | ||
* 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. | ||
*/ | ||
getConnectParameters?: () => Promise<ConnectAdditionalRequest>; | ||
/** | ||
* Redefine wallets list source URL. Must be a link to a json file with [following structure]{@link https://github.com/ton-connect/wallets-list} | ||
* @default https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json | ||
* @ | ||
*/ | ||
walletsListSource?: string; | ||
} | ||
@@ -186,0 +194,0 @@ |
{ | ||
"name": "@tonconnect/ui", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"scripts": { | ||
@@ -53,3 +53,3 @@ "start": "vite --host", | ||
"is-plain-object": "^5.0.0", | ||
"@tonconnect/sdk": "^2.0.5", | ||
"@tonconnect/sdk": "^2.0.6", | ||
"@solid-primitives/i18n": "^1.1.2", | ||
@@ -56,0 +56,0 @@ "@floating-ui/dom": "^1.0.12", |
@@ -437,1 +437,41 @@ # TON Connect UI | ||
[See all available options](https://ton-connect.github.io/sdk/types/_tonconnect_ui.WalletsListConfiguration.html) | ||
## Add connect request parameters (ton_proof) | ||
Pass `getConnectParameters` async function to the `TonConnectUI` constructor. This callback will be called after `connectWallet` method call or `Connect Button` click before wallets list render. | ||
In other words, if `getConnectParameters` is passed, there will be a following steps: | ||
1. User clicks to the 'Connect Wallet' button, or `connectWallet` method is called | ||
2. Wallets modal opens | ||
3. Loader renders in the center of the modal | ||
4. TonConnectUI calls `getConnectParameters` and waits while it resolves | ||
5. Wallets list renders in the center of the modal | ||
Note that there is no any caching for `getConnectParameters` -- every time wallets modal opens there will be the 5 steps above. | ||
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. | ||
```ts | ||
const tonProofPayloadPromise = getTonProofFromYourBackend(); // will be executed during app initialization | ||
// don't forget to manage to refetch payload from your backend if needed | ||
const tonConnectUI = new TonConnectUI({ | ||
manifestUrl: 'https://<YOUR_APP_URL>/tonconnect-manifest.json', | ||
buttonRootId: '<YOUR_CONNECT_BUTTON_ANCHOR_ID>', | ||
getConnectParameters: async () => { | ||
const tonProof = await tonProofPayloadPromise; // will be executed every time when wallets modal is opened. It is recommended to make an http-request in advance | ||
return { | ||
tonProof | ||
}; | ||
} | ||
}); | ||
``` | ||
You can find `ton_proof` result in the `wallet` object when wallet will be connected: | ||
```ts | ||
tonConnectUI.onStatusChange(wallet => { | ||
if (wallet && wallet.connectItems?.tonProof && 'proof' in wallet.connectItems.tonProof) { | ||
checkProofInYourBackend(wallet.connectItems.tonProof.proof); | ||
} | ||
}); | ||
``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3133691
23453
477
Updated@tonconnect/sdk@^2.0.6