@blazium/ton-connect-mobile 1.0.1 → 1.0.3
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/dist/adapters/expo.js +12 -2
- package/dist/adapters/react-native.js +12 -2
- package/dist/index.js +51 -3
- package/package.json +1 -1
- package/src/adapters/expo.ts +13 -3
- package/src/adapters/react-native.ts +13 -3
- package/src/index.ts +56 -3
package/dist/adapters/expo.js
CHANGED
|
@@ -44,15 +44,25 @@ class ExpoAdapter {
|
|
|
44
44
|
throw new Error('expo-linking is not available');
|
|
45
45
|
}
|
|
46
46
|
try {
|
|
47
|
+
console.log('[ExpoAdapter] Checking if URL can be opened:', url);
|
|
47
48
|
const canOpen = await Linking.canOpenURL(url);
|
|
49
|
+
console.log('[ExpoAdapter] canOpenURL result:', canOpen);
|
|
48
50
|
if (!canOpen) {
|
|
49
|
-
|
|
51
|
+
console.error('[ExpoAdapter] Cannot open URL - no app found that handles tonconnect:// protocol');
|
|
52
|
+
throw new Error(`Cannot open URL: ${url}. Make sure a wallet app is installed that supports tonconnect:// protocol.`);
|
|
50
53
|
}
|
|
54
|
+
console.log('[ExpoAdapter] Opening URL...');
|
|
51
55
|
await Linking.openURL(url);
|
|
56
|
+
console.log('[ExpoAdapter] URL opened successfully');
|
|
52
57
|
return true;
|
|
53
58
|
}
|
|
54
59
|
catch (error) {
|
|
55
|
-
|
|
60
|
+
console.error('[ExpoAdapter] Error in openURL:', error);
|
|
61
|
+
// Re-throw with more context
|
|
62
|
+
if (error.message && error.message.includes('Cannot open URL')) {
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
68
|
async getInitialURL() {
|
|
@@ -42,15 +42,25 @@ class ReactNativeAdapter {
|
|
|
42
42
|
throw new Error('react-native Linking is not available');
|
|
43
43
|
}
|
|
44
44
|
try {
|
|
45
|
+
console.log('[ReactNativeAdapter] Checking if URL can be opened:', url);
|
|
45
46
|
const canOpen = await Linking.canOpenURL(url);
|
|
47
|
+
console.log('[ReactNativeAdapter] canOpenURL result:', canOpen);
|
|
46
48
|
if (!canOpen) {
|
|
47
|
-
|
|
49
|
+
console.error('[ReactNativeAdapter] Cannot open URL - no app found that handles tonconnect:// protocol');
|
|
50
|
+
throw new Error(`Cannot open URL: ${url}. Make sure a wallet app is installed that supports tonconnect:// protocol.`);
|
|
48
51
|
}
|
|
52
|
+
console.log('[ReactNativeAdapter] Opening URL...');
|
|
49
53
|
await Linking.openURL(url);
|
|
54
|
+
console.log('[ReactNativeAdapter] URL opened successfully');
|
|
50
55
|
return true;
|
|
51
56
|
}
|
|
52
57
|
catch (error) {
|
|
53
|
-
|
|
58
|
+
console.error('[ReactNativeAdapter] Error in openURL:', error);
|
|
59
|
+
// Re-throw with more context
|
|
60
|
+
if (error.message && error.message.includes('Cannot open URL')) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
async getInitialURL() {
|
package/dist/index.js
CHANGED
|
@@ -93,8 +93,13 @@ class TonConnectMobile {
|
|
|
93
93
|
transactionTimeout: 300000, // 5 minutes
|
|
94
94
|
...config,
|
|
95
95
|
};
|
|
96
|
+
console.log('[TON Connect] Initializing SDK with config:', {
|
|
97
|
+
manifestUrl: this.config.manifestUrl,
|
|
98
|
+
scheme: this.config.scheme,
|
|
99
|
+
});
|
|
96
100
|
// Initialize platform adapter
|
|
97
101
|
this.adapter = this.createAdapter();
|
|
102
|
+
console.log('[TON Connect] Adapter initialized:', this.adapter.constructor.name);
|
|
98
103
|
// Set up URL listener
|
|
99
104
|
this.setupURLListener();
|
|
100
105
|
// Load persisted session
|
|
@@ -108,6 +113,7 @@ class TonConnectMobile {
|
|
|
108
113
|
// eslint-disable-next-line no-undef
|
|
109
114
|
if (typeof globalThis !== 'undefined' && globalThis.window && globalThis.document) {
|
|
110
115
|
// Web platform
|
|
116
|
+
console.log('[TON Connect] Using WebAdapter');
|
|
111
117
|
return new web_1.WebAdapter();
|
|
112
118
|
}
|
|
113
119
|
// Try to detect Expo environment
|
|
@@ -116,36 +122,47 @@ class TonConnectMobile {
|
|
|
116
122
|
if (typeof require !== 'undefined') {
|
|
117
123
|
const expoLinking = require('expo-linking');
|
|
118
124
|
if (expoLinking) {
|
|
125
|
+
console.log('[TON Connect] Using ExpoAdapter');
|
|
119
126
|
return new expo_1.ExpoAdapter();
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
|
-
catch {
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.log('[TON Connect] ExpoAdapter not available:', error);
|
|
124
132
|
// expo-linking not available, continue to React Native adapter
|
|
125
133
|
}
|
|
126
134
|
// Fall back to React Native adapter
|
|
127
135
|
// This will work for both React Native CLI and Expo (since Expo also has react-native)
|
|
136
|
+
console.log('[TON Connect] Using ReactNativeAdapter');
|
|
128
137
|
return new react_native_1.ReactNativeAdapter();
|
|
129
138
|
}
|
|
130
139
|
/**
|
|
131
140
|
* Set up URL listener for wallet callbacks
|
|
132
141
|
*/
|
|
133
142
|
setupURLListener() {
|
|
143
|
+
console.log('[TON Connect] Setting up URL listener...');
|
|
134
144
|
this.urlUnsubscribe = this.adapter.addURLListener((url) => {
|
|
145
|
+
console.log('[TON Connect] URL callback received:', url);
|
|
135
146
|
this.handleCallback(url);
|
|
136
147
|
});
|
|
137
148
|
// Also check initial URL (when app was opened via deep link)
|
|
138
149
|
this.adapter.getInitialURL().then((url) => {
|
|
139
150
|
if (url) {
|
|
151
|
+
console.log('[TON Connect] Initial URL found:', url);
|
|
140
152
|
this.handleCallback(url);
|
|
141
153
|
}
|
|
154
|
+
else {
|
|
155
|
+
console.log('[TON Connect] No initial URL');
|
|
156
|
+
}
|
|
142
157
|
});
|
|
143
158
|
}
|
|
144
159
|
/**
|
|
145
160
|
* Handle callback from wallet
|
|
146
161
|
*/
|
|
147
162
|
handleCallback(url) {
|
|
163
|
+
console.log('[TON Connect] handleCallback called with URL:', url);
|
|
148
164
|
const parsed = (0, protocol_1.parseCallbackURL)(url, this.config.scheme);
|
|
165
|
+
console.log('[TON Connect] Parsed callback:', parsed.type, parsed.data ? 'has data' : 'no data');
|
|
149
166
|
if (parsed.type === 'connect' && parsed.data) {
|
|
150
167
|
this.handleConnectionResponse(parsed.data);
|
|
151
168
|
}
|
|
@@ -250,16 +267,25 @@ class TonConnectMobile {
|
|
|
250
267
|
* Connect to wallet
|
|
251
268
|
*/
|
|
252
269
|
async connect() {
|
|
270
|
+
console.log('[TON Connect] connect() called');
|
|
253
271
|
// If already connected, return current wallet
|
|
254
272
|
if (this.currentStatus.connected && this.currentStatus.wallet) {
|
|
273
|
+
console.log('[TON Connect] Already connected, returning existing wallet');
|
|
255
274
|
return this.currentStatus.wallet;
|
|
256
275
|
}
|
|
257
276
|
// CRITICAL FIX: Check if connection is already in progress
|
|
258
277
|
if (this.connectionPromise) {
|
|
278
|
+
console.log('[TON Connect] Connection already in progress');
|
|
259
279
|
throw new ConnectionInProgressError();
|
|
260
280
|
}
|
|
261
281
|
// Build connection request URL
|
|
282
|
+
console.log('[TON Connect] Building connection request URL...');
|
|
262
283
|
const url = (0, protocol_1.buildConnectionRequest)(this.config.manifestUrl, this.config.scheme);
|
|
284
|
+
// DEBUG: Log the URL being opened
|
|
285
|
+
console.log('[TON Connect] Opening URL:', url);
|
|
286
|
+
console.log('[TON Connect] Manifest URL:', this.config.manifestUrl);
|
|
287
|
+
console.log('[TON Connect] Return scheme:', this.config.scheme);
|
|
288
|
+
console.log('[TON Connect] Adapter type:', this.adapter.constructor.name);
|
|
263
289
|
// Create promise for connection
|
|
264
290
|
return new Promise((resolve, reject) => {
|
|
265
291
|
let timeout = null;
|
|
@@ -283,12 +309,27 @@ class TonConnectMobile {
|
|
|
283
309
|
// Set timeout
|
|
284
310
|
timeout = setTimeout(() => {
|
|
285
311
|
if (this.connectionPromise) {
|
|
312
|
+
console.log('[TON Connect] Connection timeout after', this.config.connectionTimeout, 'ms');
|
|
286
313
|
this.connectionPromise.reject(new ConnectionTimeoutError());
|
|
287
314
|
}
|
|
288
315
|
}, this.config.connectionTimeout);
|
|
289
316
|
this.connectionPromise.timeout = timeout;
|
|
290
317
|
// Open wallet app
|
|
291
|
-
|
|
318
|
+
console.log('[TON Connect] Attempting to open wallet app...');
|
|
319
|
+
this.adapter.openURL(url).then((success) => {
|
|
320
|
+
console.log('[TON Connect] openURL result:', success);
|
|
321
|
+
// URL opened successfully, wait for callback
|
|
322
|
+
// If success is false, it should have thrown an error
|
|
323
|
+
if (!success && this.connectionPromise) {
|
|
324
|
+
console.log('[TON Connect] openURL returned false, rejecting promise');
|
|
325
|
+
this.connectionPromise.reject(new TonConnectError('Failed to open wallet app. Please make sure a TON wallet is installed.'));
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
console.log('[TON Connect] URL opened successfully, waiting for wallet callback...');
|
|
329
|
+
}
|
|
330
|
+
}).catch((error) => {
|
|
331
|
+
// Error opening URL - reject the promise
|
|
332
|
+
console.error('[TON Connect] Error opening URL:', error);
|
|
292
333
|
if (this.connectionPromise) {
|
|
293
334
|
this.connectionPromise.reject(new TonConnectError(`Failed to open wallet: ${error?.message || String(error)}`));
|
|
294
335
|
}
|
|
@@ -342,7 +383,14 @@ class TonConnectMobile {
|
|
|
342
383
|
}, this.config.transactionTimeout);
|
|
343
384
|
this.transactionPromise.timeout = timeout;
|
|
344
385
|
// Open wallet app
|
|
345
|
-
this.adapter.openURL(url).
|
|
386
|
+
this.adapter.openURL(url).then((success) => {
|
|
387
|
+
// URL opened successfully, wait for callback
|
|
388
|
+
// If success is false, it should have thrown an error
|
|
389
|
+
if (!success && this.transactionPromise) {
|
|
390
|
+
this.transactionPromise.reject(new TonConnectError('Failed to open wallet app. Please make sure a TON wallet is installed.'));
|
|
391
|
+
}
|
|
392
|
+
}).catch((error) => {
|
|
393
|
+
// Error opening URL - reject the promise
|
|
346
394
|
if (this.transactionPromise) {
|
|
347
395
|
this.transactionPromise.reject(new TonConnectError(`Failed to open wallet: ${error?.message || String(error)}`));
|
|
348
396
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazium/ton-connect-mobile",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Production-ready TON Connect Mobile SDK for React Native and Expo. Implements the real TonConnect protocol for mobile applications using deep links and callbacks.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/src/adapters/expo.ts
CHANGED
|
@@ -53,14 +53,24 @@ export class ExpoAdapter implements PlatformAdapter {
|
|
|
53
53
|
throw new Error('expo-linking is not available');
|
|
54
54
|
}
|
|
55
55
|
try {
|
|
56
|
+
console.log('[ExpoAdapter] Checking if URL can be opened:', url);
|
|
56
57
|
const canOpen = await Linking.canOpenURL(url);
|
|
58
|
+
console.log('[ExpoAdapter] canOpenURL result:', canOpen);
|
|
57
59
|
if (!canOpen) {
|
|
58
|
-
|
|
60
|
+
console.error('[ExpoAdapter] Cannot open URL - no app found that handles tonconnect:// protocol');
|
|
61
|
+
throw new Error(`Cannot open URL: ${url}. Make sure a wallet app is installed that supports tonconnect:// protocol.`);
|
|
59
62
|
}
|
|
63
|
+
console.log('[ExpoAdapter] Opening URL...');
|
|
60
64
|
await Linking.openURL(url);
|
|
65
|
+
console.log('[ExpoAdapter] URL opened successfully');
|
|
61
66
|
return true;
|
|
62
|
-
} catch (error) {
|
|
63
|
-
|
|
67
|
+
} catch (error: any) {
|
|
68
|
+
console.error('[ExpoAdapter] Error in openURL:', error);
|
|
69
|
+
// Re-throw with more context
|
|
70
|
+
if (error.message && error.message.includes('Cannot open URL')) {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
|
|
@@ -51,14 +51,24 @@ export class ReactNativeAdapter implements PlatformAdapter {
|
|
|
51
51
|
throw new Error('react-native Linking is not available');
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
|
+
console.log('[ReactNativeAdapter] Checking if URL can be opened:', url);
|
|
54
55
|
const canOpen = await Linking.canOpenURL(url);
|
|
56
|
+
console.log('[ReactNativeAdapter] canOpenURL result:', canOpen);
|
|
55
57
|
if (!canOpen) {
|
|
56
|
-
|
|
58
|
+
console.error('[ReactNativeAdapter] Cannot open URL - no app found that handles tonconnect:// protocol');
|
|
59
|
+
throw new Error(`Cannot open URL: ${url}. Make sure a wallet app is installed that supports tonconnect:// protocol.`);
|
|
57
60
|
}
|
|
61
|
+
console.log('[ReactNativeAdapter] Opening URL...');
|
|
58
62
|
await Linking.openURL(url);
|
|
63
|
+
console.log('[ReactNativeAdapter] URL opened successfully');
|
|
59
64
|
return true;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
|
|
65
|
+
} catch (error: any) {
|
|
66
|
+
console.error('[ReactNativeAdapter] Error in openURL:', error);
|
|
67
|
+
// Re-throw with more context
|
|
68
|
+
if (error.message && error.message.includes('Cannot open URL')) {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
|
package/src/index.ts
CHANGED
|
@@ -114,8 +114,14 @@ export class TonConnectMobile {
|
|
|
114
114
|
...config,
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
+
console.log('[TON Connect] Initializing SDK with config:', {
|
|
118
|
+
manifestUrl: this.config.manifestUrl,
|
|
119
|
+
scheme: this.config.scheme,
|
|
120
|
+
});
|
|
121
|
+
|
|
117
122
|
// Initialize platform adapter
|
|
118
123
|
this.adapter = this.createAdapter();
|
|
124
|
+
console.log('[TON Connect] Adapter initialized:', this.adapter.constructor.name);
|
|
119
125
|
|
|
120
126
|
// Set up URL listener
|
|
121
127
|
this.setupURLListener();
|
|
@@ -132,6 +138,7 @@ export class TonConnectMobile {
|
|
|
132
138
|
// eslint-disable-next-line no-undef
|
|
133
139
|
if (typeof globalThis !== 'undefined' && (globalThis as any).window && (globalThis as any).document) {
|
|
134
140
|
// Web platform
|
|
141
|
+
console.log('[TON Connect] Using WebAdapter');
|
|
135
142
|
return new WebAdapter();
|
|
136
143
|
}
|
|
137
144
|
|
|
@@ -141,15 +148,18 @@ export class TonConnectMobile {
|
|
|
141
148
|
if (typeof require !== 'undefined') {
|
|
142
149
|
const expoLinking = require('expo-linking');
|
|
143
150
|
if (expoLinking) {
|
|
151
|
+
console.log('[TON Connect] Using ExpoAdapter');
|
|
144
152
|
return new ExpoAdapter();
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
|
-
} catch {
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.log('[TON Connect] ExpoAdapter not available:', error);
|
|
148
157
|
// expo-linking not available, continue to React Native adapter
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
// Fall back to React Native adapter
|
|
152
161
|
// This will work for both React Native CLI and Expo (since Expo also has react-native)
|
|
162
|
+
console.log('[TON Connect] Using ReactNativeAdapter');
|
|
153
163
|
return new ReactNativeAdapter();
|
|
154
164
|
}
|
|
155
165
|
|
|
@@ -157,14 +167,19 @@ export class TonConnectMobile {
|
|
|
157
167
|
* Set up URL listener for wallet callbacks
|
|
158
168
|
*/
|
|
159
169
|
private setupURLListener(): void {
|
|
170
|
+
console.log('[TON Connect] Setting up URL listener...');
|
|
160
171
|
this.urlUnsubscribe = this.adapter.addURLListener((url) => {
|
|
172
|
+
console.log('[TON Connect] URL callback received:', url);
|
|
161
173
|
this.handleCallback(url);
|
|
162
174
|
});
|
|
163
175
|
|
|
164
176
|
// Also check initial URL (when app was opened via deep link)
|
|
165
177
|
this.adapter.getInitialURL().then((url) => {
|
|
166
178
|
if (url) {
|
|
179
|
+
console.log('[TON Connect] Initial URL found:', url);
|
|
167
180
|
this.handleCallback(url);
|
|
181
|
+
} else {
|
|
182
|
+
console.log('[TON Connect] No initial URL');
|
|
168
183
|
}
|
|
169
184
|
});
|
|
170
185
|
}
|
|
@@ -173,7 +188,9 @@ export class TonConnectMobile {
|
|
|
173
188
|
* Handle callback from wallet
|
|
174
189
|
*/
|
|
175
190
|
private handleCallback(url: string): void {
|
|
191
|
+
console.log('[TON Connect] handleCallback called with URL:', url);
|
|
176
192
|
const parsed = parseCallbackURL(url, this.config.scheme);
|
|
193
|
+
console.log('[TON Connect] Parsed callback:', parsed.type, parsed.data ? 'has data' : 'no data');
|
|
177
194
|
|
|
178
195
|
if (parsed.type === 'connect' && parsed.data) {
|
|
179
196
|
this.handleConnectionResponse(parsed.data as ConnectionResponsePayload);
|
|
@@ -288,18 +305,29 @@ export class TonConnectMobile {
|
|
|
288
305
|
* Connect to wallet
|
|
289
306
|
*/
|
|
290
307
|
async connect(): Promise<WalletInfo> {
|
|
308
|
+
console.log('[TON Connect] connect() called');
|
|
309
|
+
|
|
291
310
|
// If already connected, return current wallet
|
|
292
311
|
if (this.currentStatus.connected && this.currentStatus.wallet) {
|
|
312
|
+
console.log('[TON Connect] Already connected, returning existing wallet');
|
|
293
313
|
return this.currentStatus.wallet;
|
|
294
314
|
}
|
|
295
315
|
|
|
296
316
|
// CRITICAL FIX: Check if connection is already in progress
|
|
297
317
|
if (this.connectionPromise) {
|
|
318
|
+
console.log('[TON Connect] Connection already in progress');
|
|
298
319
|
throw new ConnectionInProgressError();
|
|
299
320
|
}
|
|
300
321
|
|
|
301
322
|
// Build connection request URL
|
|
323
|
+
console.log('[TON Connect] Building connection request URL...');
|
|
302
324
|
const url = buildConnectionRequest(this.config.manifestUrl, this.config.scheme);
|
|
325
|
+
|
|
326
|
+
// DEBUG: Log the URL being opened
|
|
327
|
+
console.log('[TON Connect] Opening URL:', url);
|
|
328
|
+
console.log('[TON Connect] Manifest URL:', this.config.manifestUrl);
|
|
329
|
+
console.log('[TON Connect] Return scheme:', this.config.scheme);
|
|
330
|
+
console.log('[TON Connect] Adapter type:', this.adapter.constructor.name);
|
|
303
331
|
|
|
304
332
|
// Create promise for connection
|
|
305
333
|
return new Promise<WalletInfo>((resolve, reject) => {
|
|
@@ -326,6 +354,7 @@ export class TonConnectMobile {
|
|
|
326
354
|
// Set timeout
|
|
327
355
|
timeout = setTimeout(() => {
|
|
328
356
|
if (this.connectionPromise) {
|
|
357
|
+
console.log('[TON Connect] Connection timeout after', this.config.connectionTimeout, 'ms');
|
|
329
358
|
this.connectionPromise.reject(new ConnectionTimeoutError());
|
|
330
359
|
}
|
|
331
360
|
}, this.config.connectionTimeout) as unknown as number;
|
|
@@ -333,7 +362,22 @@ export class TonConnectMobile {
|
|
|
333
362
|
this.connectionPromise.timeout = timeout;
|
|
334
363
|
|
|
335
364
|
// Open wallet app
|
|
336
|
-
|
|
365
|
+
console.log('[TON Connect] Attempting to open wallet app...');
|
|
366
|
+
this.adapter.openURL(url).then((success) => {
|
|
367
|
+
console.log('[TON Connect] openURL result:', success);
|
|
368
|
+
// URL opened successfully, wait for callback
|
|
369
|
+
// If success is false, it should have thrown an error
|
|
370
|
+
if (!success && this.connectionPromise) {
|
|
371
|
+
console.log('[TON Connect] openURL returned false, rejecting promise');
|
|
372
|
+
this.connectionPromise.reject(
|
|
373
|
+
new TonConnectError('Failed to open wallet app. Please make sure a TON wallet is installed.')
|
|
374
|
+
);
|
|
375
|
+
} else {
|
|
376
|
+
console.log('[TON Connect] URL opened successfully, waiting for wallet callback...');
|
|
377
|
+
}
|
|
378
|
+
}).catch((error) => {
|
|
379
|
+
// Error opening URL - reject the promise
|
|
380
|
+
console.error('[TON Connect] Error opening URL:', error);
|
|
337
381
|
if (this.connectionPromise) {
|
|
338
382
|
this.connectionPromise.reject(
|
|
339
383
|
new TonConnectError(`Failed to open wallet: ${error?.message || String(error)}`)
|
|
@@ -398,7 +442,16 @@ export class TonConnectMobile {
|
|
|
398
442
|
this.transactionPromise.timeout = timeout;
|
|
399
443
|
|
|
400
444
|
// Open wallet app
|
|
401
|
-
this.adapter.openURL(url).
|
|
445
|
+
this.adapter.openURL(url).then((success) => {
|
|
446
|
+
// URL opened successfully, wait for callback
|
|
447
|
+
// If success is false, it should have thrown an error
|
|
448
|
+
if (!success && this.transactionPromise) {
|
|
449
|
+
this.transactionPromise.reject(
|
|
450
|
+
new TonConnectError('Failed to open wallet app. Please make sure a TON wallet is installed.')
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
}).catch((error) => {
|
|
454
|
+
// Error opening URL - reject the promise
|
|
402
455
|
if (this.transactionPromise) {
|
|
403
456
|
this.transactionPromise.reject(
|
|
404
457
|
new TonConnectError(`Failed to open wallet: ${error?.message || String(error)}`)
|