@blazium/ton-connect-mobile 1.1.5 → 1.2.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 +424 -145
- package/dist/index.d.ts +10 -2
- package/dist/index.js +31 -5
- package/dist/react/TonConnectUIProvider.js +8 -3
- package/dist/react/WalletSelectionModal.d.ts +20 -0
- package/dist/react/WalletSelectionModal.js +213 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +3 -1
- package/dist/utils/retry.d.ts +31 -0
- package/dist/utils/retry.js +67 -0
- package/dist/utils/transactionBuilder.d.ts +67 -0
- package/dist/utils/transactionBuilder.js +131 -0
- package/package.json +1 -1
- package/src/index.ts +47 -5
- package/src/react/TonConnectUIProvider.tsx +15 -3
- package/src/react/WalletSelectionModal.tsx +292 -0
- package/src/react/index.ts +2 -0
- package/src/utils/retry.ts +101 -0
- package/src/utils/transactionBuilder.ts +153 -0
package/README.md
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @blazium/ton-connect-mobile
|
|
2
2
|
|
|
3
|
-
Production-ready TON Connect Mobile SDK for React Native and Expo.
|
|
3
|
+
Production-ready TON Connect Mobile SDK for React Native and Expo. Implements the real TonConnect protocol for mobile applications using deep links and callbacks.
|
|
4
|
+
|
|
5
|
+
**Full compatibility with `@tonconnect/ui-react` API** - Use the same hooks, components, and functions you're familiar with!
|
|
4
6
|
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
|
-
- ✅ **
|
|
8
|
-
- ✅ **
|
|
9
|
+
- ✅ **Full `@tonconnect/ui-react` Compatibility** - Drop-in replacement
|
|
10
|
+
- ✅ **React Native & Expo Support** - Works with both Expo and React Native CLI
|
|
11
|
+
- ✅ **Android & iOS Support** - Full deep linking support
|
|
12
|
+
- ✅ **Multiple Wallet Support** - Tonkeeper, Tonhub, MyTonWallet, Telegram Wallet
|
|
13
|
+
- ✅ **Beautiful Wallet Selection Modal** - Built-in wallet picker UI
|
|
14
|
+
- ✅ **Transaction Signing** - Send transactions with wallet approval
|
|
15
|
+
- ✅ **Data Signing** - Sign arbitrary data for authentication
|
|
16
|
+
- ✅ **Transaction Builder Utilities** - Helper functions for building transactions
|
|
17
|
+
- ✅ **Connection Retry Logic** - Automatic retry with exponential backoff
|
|
18
|
+
- ✅ **Enhanced Error Messages** - Clear error messages with recovery suggestions
|
|
19
|
+
- ✅ **Wallet Availability Checking** - Check if wallets are available
|
|
9
20
|
- ✅ **Session Persistence** - Maintains connection across app restarts
|
|
10
|
-
- ✅ **
|
|
11
|
-
- ✅ **
|
|
12
|
-
- ✅ **Cross-Platform** - Works with Expo Managed, Expo Bare, and React Native CLI
|
|
13
|
-
- ⚠️ **Web Limitation** - Deep links (`tonconnect://`) only work on mobile devices (Android/iOS), not in web browsers
|
|
14
|
-
- ✅ **TypeScript** - Fully typed with TypeScript
|
|
15
|
-
- ✅ **Production Ready** - No placeholders, no mocks, ready for production use
|
|
21
|
+
- ✅ **TypeScript** - Full type safety
|
|
22
|
+
- ✅ **Production Ready** - Battle-tested implementation
|
|
16
23
|
|
|
17
24
|
## Installation
|
|
18
25
|
|
|
@@ -20,113 +27,266 @@ Production-ready TON Connect Mobile SDK for React Native and Expo. This SDK impl
|
|
|
20
27
|
npm install @blazium/ton-connect-mobile
|
|
21
28
|
```
|
|
22
29
|
|
|
23
|
-
###
|
|
24
|
-
|
|
25
|
-
**IMPORTANT**: You must install `react-native-get-random-values` for secure random number generation:
|
|
30
|
+
### Peer Dependencies
|
|
26
31
|
|
|
27
32
|
```bash
|
|
28
|
-
|
|
33
|
+
# For Expo projects
|
|
34
|
+
npm install expo-linking expo-crypto @react-native-async-storage/async-storage
|
|
35
|
+
|
|
36
|
+
# For React Native CLI projects
|
|
37
|
+
npm install @react-native-async-storage/async-storage react-native-get-random-values
|
|
29
38
|
```
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### React Integration (Recommended - @tonconnect/ui-react Compatible)
|
|
32
43
|
|
|
33
44
|
```typescript
|
|
34
|
-
import '
|
|
35
|
-
|
|
45
|
+
import { TonConnectUIProvider, useTonConnectUI, useTonWallet, TonConnectButton } from '@blazium/ton-connect-mobile/react';
|
|
46
|
+
|
|
47
|
+
function App() {
|
|
48
|
+
return (
|
|
49
|
+
<TonConnectUIProvider
|
|
50
|
+
config={{
|
|
51
|
+
manifestUrl: 'https://yourdomain.com/tonconnect-manifest.json',
|
|
52
|
+
scheme: 'myapp',
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<YourApp />
|
|
56
|
+
</TonConnectUIProvider>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function YourApp() {
|
|
61
|
+
const tonConnectUI = useTonConnectUI();
|
|
62
|
+
const wallet = useTonWallet();
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<View>
|
|
66
|
+
<TonConnectButton />
|
|
67
|
+
{wallet?.connected && (
|
|
68
|
+
<Text>Connected: {wallet.account?.address}</Text>
|
|
69
|
+
)}
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
36
73
|
```
|
|
37
74
|
|
|
38
|
-
###
|
|
75
|
+
### Direct SDK Usage
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { TonConnectMobile } from '@blazium/ton-connect-mobile';
|
|
39
79
|
|
|
40
|
-
|
|
80
|
+
const ton = new TonConnectMobile({
|
|
81
|
+
manifestUrl: 'https://yourdomain.com/tonconnect-manifest.json',
|
|
82
|
+
scheme: 'myapp',
|
|
83
|
+
});
|
|
41
84
|
|
|
42
|
-
|
|
43
|
-
|
|
85
|
+
// Connect to wallet
|
|
86
|
+
const wallet = await ton.connect();
|
|
87
|
+
|
|
88
|
+
// Send transaction
|
|
89
|
+
const response = await ton.sendTransaction({
|
|
90
|
+
validUntil: Date.now() + 5 * 60 * 1000,
|
|
91
|
+
messages: [
|
|
92
|
+
{
|
|
93
|
+
address: 'EQD0vdSA_NedR9uvbgN9EikRX-suesDxGeFg69XQMavfLqIo',
|
|
94
|
+
amount: '10000000', // 0.01 TON
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
});
|
|
44
98
|
|
|
45
|
-
|
|
99
|
+
// Sign data
|
|
100
|
+
const signed = await ton.signData('Hello, TON!', '1.0');
|
|
46
101
|
|
|
47
|
-
|
|
48
|
-
|
|
102
|
+
// Disconnect
|
|
103
|
+
await ton.disconnect();
|
|
49
104
|
```
|
|
50
105
|
|
|
51
|
-
##
|
|
106
|
+
## React Integration API
|
|
52
107
|
|
|
53
|
-
###
|
|
108
|
+
### Components
|
|
109
|
+
|
|
110
|
+
#### `TonConnectUIProvider`
|
|
111
|
+
|
|
112
|
+
React context provider that wraps your app and provides TON Connect functionality.
|
|
54
113
|
|
|
55
114
|
```typescript
|
|
56
|
-
|
|
115
|
+
<TonConnectUIProvider config={config}>
|
|
116
|
+
<YourApp />
|
|
117
|
+
</TonConnectUIProvider>
|
|
118
|
+
```
|
|
57
119
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
120
|
+
#### `TonConnectButton`
|
|
121
|
+
|
|
122
|
+
Pre-built button component for connecting/disconnecting wallets.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
<TonConnectButton
|
|
126
|
+
text="Connect Wallet"
|
|
127
|
+
connectedText="Disconnect"
|
|
128
|
+
onPress={() => {
|
|
129
|
+
// Custom handler (optional)
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
62
132
|
```
|
|
63
133
|
|
|
64
|
-
###
|
|
134
|
+
### Hooks
|
|
135
|
+
|
|
136
|
+
#### `useTonConnectUI()`
|
|
137
|
+
|
|
138
|
+
Access the TonConnectUI instance with all methods.
|
|
65
139
|
|
|
66
140
|
```typescript
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log('Connection timed out');
|
|
77
|
-
} else {
|
|
78
|
-
console.error('Connection failed:', error.message);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
141
|
+
const tonConnectUI = useTonConnectUI();
|
|
142
|
+
|
|
143
|
+
// Methods:
|
|
144
|
+
await tonConnectUI.connectWallet();
|
|
145
|
+
await tonConnectUI.disconnect();
|
|
146
|
+
await tonConnectUI.sendTransaction({ ... });
|
|
147
|
+
await tonConnectUI.signData({ data: '...', version: '1.0' });
|
|
148
|
+
await tonConnectUI.openModal();
|
|
149
|
+
tonConnectUI.closeModal();
|
|
81
150
|
```
|
|
82
151
|
|
|
83
|
-
|
|
152
|
+
#### `useTonWallet()`
|
|
153
|
+
|
|
154
|
+
Get current wallet state.
|
|
84
155
|
|
|
85
156
|
```typescript
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
157
|
+
const wallet = useTonWallet();
|
|
158
|
+
|
|
159
|
+
// wallet?.connected - boolean
|
|
160
|
+
// wallet?.account?.address - string
|
|
161
|
+
// wallet?.account?.publicKey - string
|
|
162
|
+
// wallet?.account?.chain - number
|
|
163
|
+
// wallet?.wallet?.name - string
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### `useTonConnectModal()`
|
|
167
|
+
|
|
168
|
+
Access modal state and controls.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const modal = useTonConnectModal();
|
|
172
|
+
|
|
173
|
+
// modal.open - boolean
|
|
174
|
+
// modal.openModal() - Promise<void>
|
|
175
|
+
// modal.close() - void
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### `useTonConnectSDK()`
|
|
179
|
+
|
|
180
|
+
Access the underlying SDK instance for advanced usage.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const sdk = useTonConnectSDK();
|
|
184
|
+
|
|
185
|
+
// Advanced methods:
|
|
186
|
+
sdk.setPreferredWallet('Tonhub');
|
|
187
|
+
sdk.getSupportedWallets();
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Direct SDK API
|
|
191
|
+
|
|
192
|
+
### `TonConnectMobile`
|
|
193
|
+
|
|
194
|
+
Main SDK class.
|
|
195
|
+
|
|
196
|
+
#### Constructor
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
new TonConnectMobile(config: TonConnectMobileConfig)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Config Options:**
|
|
203
|
+
|
|
204
|
+
- `manifestUrl` (required): URL to your TonConnect manifest file
|
|
205
|
+
- `scheme` (required): Your app's deep link scheme
|
|
206
|
+
- `storageKeyPrefix` (optional): Prefix for storage keys (default: `'tonconnect_'`)
|
|
207
|
+
- `connectionTimeout` (optional): Connection timeout in ms (default: `30000`)
|
|
208
|
+
- `transactionTimeout` (optional): Transaction timeout in ms (default: `300000`)
|
|
209
|
+
- `skipCanOpenURLCheck` (optional): Skip canOpenURL check (default: `true` for Android compatibility)
|
|
210
|
+
- `preferredWallet` (optional): Default wallet name
|
|
211
|
+
|
|
212
|
+
#### Methods
|
|
213
|
+
|
|
214
|
+
##### `connect(): Promise<WalletInfo>`
|
|
215
|
+
|
|
216
|
+
Connect to a wallet.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
const wallet = await ton.connect();
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
##### `sendTransaction(request: SendTransactionRequest): Promise<{ boc: string; signature: string }>`
|
|
223
|
+
|
|
224
|
+
Send a transaction.
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
const response = await ton.sendTransaction({
|
|
228
|
+
validUntil: Date.now() + 5 * 60 * 1000, // 5 minutes
|
|
229
|
+
messages: [
|
|
230
|
+
{
|
|
231
|
+
address: 'EQD0vdSA_NedR9uvbgN9EikRX-suesDxGeFg69XQMavfLqIo',
|
|
232
|
+
amount: '10000000', // 0.01 TON in nanotons
|
|
233
|
+
},
|
|
234
|
+
],
|
|
93
235
|
});
|
|
94
236
|
```
|
|
95
237
|
|
|
96
|
-
|
|
238
|
+
##### `signData(data: string | Uint8Array, version?: string): Promise<{ signature: string; timestamp: number }>`
|
|
239
|
+
|
|
240
|
+
Sign arbitrary data.
|
|
97
241
|
|
|
98
242
|
```typescript
|
|
99
|
-
|
|
100
|
-
const response = await ton.sendTransaction({
|
|
101
|
-
validUntil: Date.now() + 5 * 60 * 1000, // 5 minutes
|
|
102
|
-
messages: [
|
|
103
|
-
{
|
|
104
|
-
address: 'EQD0vdSA_NedR9uvbgN9EikRX-suesDxGeFg69XQMavfLqIo',
|
|
105
|
-
amount: '10000000', // 0.01 TON in nanotons
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
console.log('Transaction BOC:', response.boc);
|
|
111
|
-
console.log('Signature:', response.signature);
|
|
112
|
-
|
|
113
|
-
// IMPORTANT: Transaction signatures must be verified server-side
|
|
114
|
-
// The SDK does not perform cryptographic signature verification
|
|
115
|
-
// Use @ton/core or @ton/crypto on your backend to verify signatures
|
|
116
|
-
} catch (error) {
|
|
117
|
-
if (error instanceof UserRejectedError) {
|
|
118
|
-
console.log('User rejected the transaction');
|
|
119
|
-
} else if (error instanceof TransactionTimeoutError) {
|
|
120
|
-
console.log('Transaction timed out');
|
|
121
|
-
} else if (error instanceof TransactionInProgressError) {
|
|
122
|
-
console.log('Transaction already in progress');
|
|
123
|
-
} else {
|
|
124
|
-
console.error('Transaction failed:', error.message);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
243
|
+
const signed = await ton.signData('Hello, TON!', '1.0');
|
|
127
244
|
```
|
|
128
245
|
|
|
129
|
-
|
|
246
|
+
##### `disconnect(): Promise<void>`
|
|
247
|
+
|
|
248
|
+
Disconnect from wallet.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
await ton.disconnect();
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
##### `getStatus(): ConnectionStatus`
|
|
255
|
+
|
|
256
|
+
Get current connection status.
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
const status = ton.getStatus();
|
|
260
|
+
// { connected: boolean, wallet: WalletInfo | null }
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
##### `getSupportedWallets(): WalletDefinition[]`
|
|
264
|
+
|
|
265
|
+
Get list of supported wallets.
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
const wallets = ton.getSupportedWallets();
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
##### `setPreferredWallet(name: string): void`
|
|
272
|
+
|
|
273
|
+
Set preferred wallet.
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
ton.setPreferredWallet('Tonhub');
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
##### `onStatusChange(callback: (status: ConnectionStatus) => void): () => void`
|
|
280
|
+
|
|
281
|
+
Subscribe to connection status changes.
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
const unsubscribe = ton.onStatusChange((status) => {
|
|
285
|
+
console.log('Status changed:', status);
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Platform Support
|
|
130
290
|
|
|
131
291
|
**⚠️ Important**: TON Connect deep links (`tonconnect://`) only work on **mobile devices** (Android/iOS). They do not work in web browsers.
|
|
132
292
|
|
|
@@ -141,12 +301,6 @@ try {
|
|
|
141
301
|
- iOS device or simulator
|
|
142
302
|
- Not web browsers
|
|
143
303
|
|
|
144
|
-
### Disconnect
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
await ton.disconnect();
|
|
148
|
-
```
|
|
149
|
-
|
|
150
304
|
## Configuration
|
|
151
305
|
|
|
152
306
|
### Expo Setup
|
|
@@ -198,93 +352,218 @@ Create a `tonconnect-manifest.json` file on your server with the following struc
|
|
|
198
352
|
{
|
|
199
353
|
"url": "https://yourdomain.com",
|
|
200
354
|
"name": "Your App Name",
|
|
201
|
-
"iconUrl": "https://yourdomain.com/icon.png"
|
|
355
|
+
"iconUrl": "https://yourdomain.com/icon.png",
|
|
356
|
+
"termsOfUseUrl": "https://yourdomain.com/terms",
|
|
357
|
+
"privacyPolicyUrl": "https://yourdomain.com/privacy"
|
|
202
358
|
}
|
|
203
359
|
```
|
|
204
360
|
|
|
205
361
|
The manifest URL must be accessible via HTTPS.
|
|
206
362
|
|
|
207
|
-
|
|
363
|
+
**Important Notes:**
|
|
364
|
+
- The `url` field should match your app's domain
|
|
365
|
+
- The `iconUrl` must be a valid, accessible URL
|
|
366
|
+
- The manifest file must be served with proper CORS headers
|
|
367
|
+
- For local development, you can use a production manifest for testing
|
|
208
368
|
|
|
209
|
-
|
|
369
|
+
## Supported Wallets
|
|
210
370
|
|
|
211
|
-
|
|
371
|
+
- **Tonkeeper** - Full support
|
|
372
|
+
- **Tonhub** - Full support
|
|
373
|
+
- **MyTonWallet** - Full support
|
|
374
|
+
- **Wallet in Telegram** - Full support
|
|
212
375
|
|
|
213
|
-
|
|
376
|
+
## Migration from @tonconnect/ui-react
|
|
377
|
+
|
|
378
|
+
This SDK is a drop-in replacement for `@tonconnect/ui-react` in React Native/Expo environments.
|
|
379
|
+
|
|
380
|
+
### Before (Web only)
|
|
214
381
|
|
|
215
382
|
```typescript
|
|
216
|
-
|
|
383
|
+
import { TonConnectUIProvider, useTonConnectUI } from '@tonconnect/ui-react';
|
|
217
384
|
```
|
|
218
385
|
|
|
219
|
-
|
|
386
|
+
### After (React Native/Expo)
|
|
220
387
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
- `connectionTimeout` (optional): Connection timeout in ms (default: `300000`)
|
|
225
|
-
- `transactionTimeout` (optional): Transaction timeout in ms (default: `300000`)
|
|
226
|
-
- `skipCanOpenURLCheck` (optional): Skip canOpenURL check before opening URL (default: `true`)
|
|
227
|
-
- Set to `false` if you want to check if URL can be opened before attempting to open it
|
|
228
|
-
- Note: On Android, `canOpenURL` may return `false` for `tonconnect://` even if wallet is installed
|
|
388
|
+
```typescript
|
|
389
|
+
import { TonConnectUIProvider, useTonConnectUI } from '@blazium/ton-connect-mobile/react';
|
|
390
|
+
```
|
|
229
391
|
|
|
230
|
-
|
|
392
|
+
**That's it!** The API is identical, so your existing code will work without changes.
|
|
231
393
|
|
|
232
|
-
|
|
233
|
-
- `disconnect(): Promise<void>` - Disconnect from wallet
|
|
234
|
-
- `sendTransaction(request: SendTransactionRequest): Promise<TransactionResponse>` - Send transaction
|
|
235
|
-
- `getStatus(): ConnectionStatus` - Get current connection status
|
|
236
|
-
- `onStatusChange(callback: StatusChangeCallback): () => void` - Subscribe to status changes
|
|
237
|
-
- `destroy(): void` - Cleanup resources
|
|
394
|
+
## Error Handling
|
|
238
395
|
|
|
239
|
-
|
|
396
|
+
The SDK provides specific error types:
|
|
240
397
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
398
|
+
```typescript
|
|
399
|
+
import {
|
|
400
|
+
TonConnectError,
|
|
401
|
+
ConnectionTimeoutError,
|
|
402
|
+
TransactionTimeoutError,
|
|
403
|
+
UserRejectedError,
|
|
404
|
+
ConnectionInProgressError,
|
|
405
|
+
TransactionInProgressError,
|
|
406
|
+
} from '@blazium/ton-connect-mobile';
|
|
247
407
|
|
|
248
|
-
|
|
408
|
+
try {
|
|
409
|
+
await ton.connect();
|
|
410
|
+
} catch (error) {
|
|
411
|
+
if (error instanceof UserRejectedError) {
|
|
412
|
+
// User rejected the connection
|
|
413
|
+
} else if (error instanceof ConnectionTimeoutError) {
|
|
414
|
+
// Connection timed out
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
```
|
|
249
418
|
|
|
250
|
-
|
|
419
|
+
## Examples
|
|
251
420
|
|
|
252
|
-
|
|
253
|
-
-
|
|
254
|
-
-
|
|
421
|
+
See the `test-project` directory for a complete example application demonstrating:
|
|
422
|
+
- React integration with `@tonconnect/ui-react` compatibility
|
|
423
|
+
- Direct SDK usage
|
|
424
|
+
- Transaction sending
|
|
425
|
+
- Data signing
|
|
426
|
+
- Wallet selection
|
|
427
|
+
- Error handling
|
|
255
428
|
|
|
256
|
-
|
|
429
|
+
## TypeScript
|
|
257
430
|
|
|
258
|
-
|
|
431
|
+
Full TypeScript support with comprehensive type definitions.
|
|
259
432
|
|
|
260
|
-
|
|
433
|
+
```typescript
|
|
434
|
+
import type {
|
|
435
|
+
TonConnectMobileConfig,
|
|
436
|
+
WalletInfo,
|
|
437
|
+
ConnectionStatus,
|
|
438
|
+
SendTransactionRequest,
|
|
439
|
+
TransactionResponse,
|
|
440
|
+
} from '@blazium/ton-connect-mobile';
|
|
441
|
+
```
|
|
261
442
|
|
|
262
|
-
|
|
263
|
-
- Receiving wallet information
|
|
264
|
-
- Sending transactions
|
|
265
|
-
- Handling errors
|
|
443
|
+
## Contributing
|
|
266
444
|
|
|
267
|
-
|
|
445
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
268
446
|
|
|
269
|
-
|
|
447
|
+
## License
|
|
270
448
|
|
|
271
|
-
|
|
449
|
+
MIT
|
|
272
450
|
|
|
273
|
-
|
|
274
|
-
- `@ton/core` - For BOC parsing and transaction verification
|
|
275
|
-
- `@ton/crypto` - For cryptographic operations
|
|
451
|
+
## Support
|
|
276
452
|
|
|
277
|
-
|
|
453
|
+
For issues and questions:
|
|
454
|
+
- GitHub Issues: [https://github.com/blaziumdev/ton-connect-mobile/issues](https://github.com/blaziumdev/ton-connect-mobile/issues)
|
|
278
455
|
|
|
279
|
-
|
|
456
|
+
## New Features in v1.2.0
|
|
280
457
|
|
|
281
|
-
###
|
|
458
|
+
### 🎨 Wallet Selection Modal
|
|
459
|
+
Beautiful, built-in wallet selection modal that automatically appears when you call `openModal()`:
|
|
282
460
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
461
|
+
```typescript
|
|
462
|
+
import { WalletSelectionModal } from '@blazium/ton-connect-mobile/react';
|
|
463
|
+
|
|
464
|
+
// The modal is automatically shown by TonConnectUIProvider when openModal() is called
|
|
465
|
+
// Or use it manually:
|
|
466
|
+
<WalletSelectionModal
|
|
467
|
+
visible={showModal}
|
|
468
|
+
onClose={() => setShowModal(false)}
|
|
469
|
+
/>
|
|
470
|
+
```
|
|
286
471
|
|
|
287
|
-
|
|
472
|
+
### 🛠️ Transaction Builder Utilities
|
|
473
|
+
Helper functions for building transactions easily:
|
|
288
474
|
|
|
289
|
-
|
|
475
|
+
```typescript
|
|
476
|
+
import {
|
|
477
|
+
buildTransferTransaction,
|
|
478
|
+
buildMultiTransferTransaction,
|
|
479
|
+
tonToNano,
|
|
480
|
+
nanoToTon,
|
|
481
|
+
formatTonAddress,
|
|
482
|
+
isValidTonAddress,
|
|
483
|
+
} from '@blazium/ton-connect-mobile';
|
|
484
|
+
|
|
485
|
+
// Simple transfer
|
|
486
|
+
const tx = buildTransferTransaction(
|
|
487
|
+
'EQD0vdSA_NedR9uvbgN9EikRX-suesDxGeFg69XQMavfLqIo',
|
|
488
|
+
0.1 // 0.1 TON
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
// Multiple transfers
|
|
492
|
+
const multiTx = buildMultiTransferTransaction([
|
|
493
|
+
{ to: 'EQ...', amount: 0.1 },
|
|
494
|
+
{ to: 'EQ...', amount: 0.2 },
|
|
495
|
+
]);
|
|
496
|
+
|
|
497
|
+
// Convert TON to nanotons
|
|
498
|
+
const nanotons = tonToNano(1.5); // "1500000000"
|
|
499
|
+
|
|
500
|
+
// Format address for display
|
|
501
|
+
const formatted = formatTonAddress('EQD0vdSA_NedR9uvbgN9EikRX-suesDxGeFg69XQMavfLqIo');
|
|
502
|
+
// "EQD0vd...qIo"
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### 🔄 Retry Utilities
|
|
506
|
+
Automatic retry logic with exponential backoff:
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
import { retry } from '@blazium/ton-connect-mobile';
|
|
510
|
+
|
|
511
|
+
try {
|
|
512
|
+
await retry(
|
|
513
|
+
() => ton.connect(),
|
|
514
|
+
{
|
|
515
|
+
maxAttempts: 3,
|
|
516
|
+
initialDelay: 1000,
|
|
517
|
+
multiplier: 2,
|
|
518
|
+
shouldRetry: (error) => error.name !== 'UserRejectedError',
|
|
519
|
+
}
|
|
520
|
+
);
|
|
521
|
+
} catch (error) {
|
|
522
|
+
// Handle error
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### 📱 Wallet Availability Checking
|
|
527
|
+
Check if a wallet is available on the current platform:
|
|
528
|
+
|
|
529
|
+
```typescript
|
|
530
|
+
const isAvailable = await ton.isWalletAvailable('Tonkeeper');
|
|
531
|
+
if (isAvailable) {
|
|
532
|
+
await ton.connect();
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### 💬 Enhanced Error Messages
|
|
537
|
+
All errors now include helpful recovery suggestions:
|
|
538
|
+
|
|
539
|
+
```typescript
|
|
540
|
+
try {
|
|
541
|
+
await ton.connect();
|
|
542
|
+
} catch (error) {
|
|
543
|
+
if (error instanceof ConnectionTimeoutError) {
|
|
544
|
+
console.error(error.message);
|
|
545
|
+
console.log('Suggestion:', error.recoverySuggestion);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
```
|
|
290
549
|
|
|
550
|
+
## Changelog
|
|
551
|
+
|
|
552
|
+
### v1.2.0
|
|
553
|
+
- ✅ **NEW**: Beautiful wallet selection modal component
|
|
554
|
+
- ✅ **NEW**: Transaction builder utilities (`buildTransferTransaction`, `tonToNano`, etc.)
|
|
555
|
+
- ✅ **NEW**: Retry utilities with exponential backoff
|
|
556
|
+
- ✅ **NEW**: Enhanced error messages with recovery suggestions
|
|
557
|
+
- ✅ **NEW**: Wallet availability checking (`isWalletAvailable`)
|
|
558
|
+
- ✅ Improved wallet callback handling
|
|
559
|
+
- ✅ Enhanced logging and debugging
|
|
560
|
+
- ✅ Better TypeScript types
|
|
561
|
+
|
|
562
|
+
### v1.1.5
|
|
563
|
+
- ✅ Full `@tonconnect/ui-react` compatibility
|
|
564
|
+
- ✅ React integration layer with hooks and components
|
|
565
|
+
- ✅ Improved wallet callback handling
|
|
566
|
+
- ✅ Enhanced logging and debugging
|
|
567
|
+
- ✅ Better error messages
|
|
568
|
+
- ✅ Android emulator localhost fix (10.0.2.2)
|
|
569
|
+
- ✅ `post_redirect` return strategy for better compatibility
|