@blazium/ton-connect-mobile 1.0.2 → 1.0.4

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.
@@ -44,25 +44,21 @@ 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);
48
- const canOpen = await Linking.canOpenURL(url);
49
- console.log('[ExpoAdapter] canOpenURL result:', canOpen);
50
- if (!canOpen) {
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.`);
53
- }
54
- console.log('[ExpoAdapter] Opening URL...');
47
+ console.log('[ExpoAdapter] Opening URL:', url);
48
+ // CRITICAL FIX: Android'de canOpenURL() tonconnect:// protokolünü tanımayabilir
49
+ // Bu yüzden direkt openURL() çağırıyoruz. Eğer açılamazsa hata fırlatır.
55
50
  await Linking.openURL(url);
56
51
  console.log('[ExpoAdapter] URL opened successfully');
57
52
  return true;
58
53
  }
59
54
  catch (error) {
60
55
  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;
56
+ // Android'de tonconnect:// protokolü tanınmıyorsa veya cüzdan yüklü değilse hata verir
57
+ const errorMessage = error?.message || String(error);
58
+ if (errorMessage.includes('No Activity found') || errorMessage.includes('No app found')) {
59
+ throw new Error('No TON wallet app found. Please install Tonkeeper or another TON Connect compatible wallet from Google Play Store.');
64
60
  }
65
- throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
61
+ throw new Error(`Failed to open wallet app: ${errorMessage}`);
66
62
  }
67
63
  }
68
64
  async getInitialURL() {
@@ -42,25 +42,21 @@ 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);
46
- const canOpen = await Linking.canOpenURL(url);
47
- console.log('[ReactNativeAdapter] canOpenURL result:', canOpen);
48
- if (!canOpen) {
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.`);
51
- }
52
- console.log('[ReactNativeAdapter] Opening URL...');
45
+ console.log('[ReactNativeAdapter] Opening URL:', url);
46
+ // CRITICAL FIX: Android'de canOpenURL() tonconnect:// protokolünü tanımayabilir
47
+ // Bu yüzden direkt openURL() çağırıyoruz. Eğer açılamazsa hata fırlatır.
53
48
  await Linking.openURL(url);
54
49
  console.log('[ReactNativeAdapter] URL opened successfully');
55
50
  return true;
56
51
  }
57
52
  catch (error) {
58
53
  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;
54
+ // Android'de tonconnect:// protokolü tanınmıyorsa veya cüzdan yüklü değilse hata verir
55
+ const errorMessage = error?.message || String(error);
56
+ if (errorMessage.includes('No Activity found') || errorMessage.includes('No app found')) {
57
+ throw new Error('No TON wallet app found. Please install Tonkeeper or another TON Connect compatible wallet from Google Play Store.');
62
58
  }
63
- throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
59
+ throw new Error(`Failed to open wallet app: ${errorMessage}`);
64
60
  }
65
61
  }
66
62
  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
@@ -135,21 +140,29 @@ class TonConnectMobile {
135
140
  * Set up URL listener for wallet callbacks
136
141
  */
137
142
  setupURLListener() {
143
+ console.log('[TON Connect] Setting up URL listener...');
138
144
  this.urlUnsubscribe = this.adapter.addURLListener((url) => {
145
+ console.log('[TON Connect] URL callback received:', url);
139
146
  this.handleCallback(url);
140
147
  });
141
148
  // Also check initial URL (when app was opened via deep link)
142
149
  this.adapter.getInitialURL().then((url) => {
143
150
  if (url) {
151
+ console.log('[TON Connect] Initial URL found:', url);
144
152
  this.handleCallback(url);
145
153
  }
154
+ else {
155
+ console.log('[TON Connect] No initial URL');
156
+ }
146
157
  });
147
158
  }
148
159
  /**
149
160
  * Handle callback from wallet
150
161
  */
151
162
  handleCallback(url) {
163
+ console.log('[TON Connect] handleCallback called with URL:', url);
152
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');
153
166
  if (parsed.type === 'connect' && parsed.data) {
154
167
  this.handleConnectionResponse(parsed.data);
155
168
  }
@@ -254,20 +267,25 @@ class TonConnectMobile {
254
267
  * Connect to wallet
255
268
  */
256
269
  async connect() {
270
+ console.log('[TON Connect] connect() called');
257
271
  // If already connected, return current wallet
258
272
  if (this.currentStatus.connected && this.currentStatus.wallet) {
273
+ console.log('[TON Connect] Already connected, returning existing wallet');
259
274
  return this.currentStatus.wallet;
260
275
  }
261
276
  // CRITICAL FIX: Check if connection is already in progress
262
277
  if (this.connectionPromise) {
278
+ console.log('[TON Connect] Connection already in progress');
263
279
  throw new ConnectionInProgressError();
264
280
  }
265
281
  // Build connection request URL
282
+ console.log('[TON Connect] Building connection request URL...');
266
283
  const url = (0, protocol_1.buildConnectionRequest)(this.config.manifestUrl, this.config.scheme);
267
284
  // DEBUG: Log the URL being opened
268
285
  console.log('[TON Connect] Opening URL:', url);
269
286
  console.log('[TON Connect] Manifest URL:', this.config.manifestUrl);
270
287
  console.log('[TON Connect] Return scheme:', this.config.scheme);
288
+ console.log('[TON Connect] Adapter type:', this.adapter.constructor.name);
271
289
  // Create promise for connection
272
290
  return new Promise((resolve, reject) => {
273
291
  let timeout = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazium/ton-connect-mobile",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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",
@@ -53,24 +53,22 @@ 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);
57
- const canOpen = await Linking.canOpenURL(url);
58
- console.log('[ExpoAdapter] canOpenURL result:', canOpen);
59
- if (!canOpen) {
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.`);
62
- }
63
- console.log('[ExpoAdapter] Opening URL...');
56
+ console.log('[ExpoAdapter] Opening URL:', url);
57
+ // CRITICAL FIX: Android'de canOpenURL() tonconnect:// protokolünü tanımayabilir
58
+ // Bu yüzden direkt openURL() çağırıyoruz. Eğer açılamazsa hata fırlatır.
64
59
  await Linking.openURL(url);
65
60
  console.log('[ExpoAdapter] URL opened successfully');
66
61
  return true;
67
62
  } catch (error: any) {
68
63
  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;
64
+ // Android'de tonconnect:// protokolü tanınmıyorsa veya cüzdan yüklü değilse hata verir
65
+ const errorMessage = error?.message || String(error);
66
+ if (errorMessage.includes('No Activity found') || errorMessage.includes('No app found')) {
67
+ throw new Error(
68
+ 'No TON wallet app found. Please install Tonkeeper or another TON Connect compatible wallet from Google Play Store.'
69
+ );
72
70
  }
73
- throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
71
+ throw new Error(`Failed to open wallet app: ${errorMessage}`);
74
72
  }
75
73
  }
76
74
 
@@ -51,24 +51,22 @@ 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);
55
- const canOpen = await Linking.canOpenURL(url);
56
- console.log('[ReactNativeAdapter] canOpenURL result:', canOpen);
57
- if (!canOpen) {
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.`);
60
- }
61
- console.log('[ReactNativeAdapter] Opening URL...');
54
+ console.log('[ReactNativeAdapter] Opening URL:', url);
55
+ // CRITICAL FIX: Android'de canOpenURL() tonconnect:// protokolünü tanımayabilir
56
+ // Bu yüzden direkt openURL() çağırıyoruz. Eğer açılamazsa hata fırlatır.
62
57
  await Linking.openURL(url);
63
58
  console.log('[ReactNativeAdapter] URL opened successfully');
64
59
  return true;
65
60
  } catch (error: any) {
66
61
  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;
62
+ // Android'de tonconnect:// protokolü tanınmıyorsa veya cüzdan yüklü değilse hata verir
63
+ const errorMessage = error?.message || String(error);
64
+ if (errorMessage.includes('No Activity found') || errorMessage.includes('No app found')) {
65
+ throw new Error(
66
+ 'No TON wallet app found. Please install Tonkeeper or another TON Connect compatible wallet from Google Play Store.'
67
+ );
70
68
  }
71
- throw new Error(`Failed to open URL: ${url}. ${error?.message || String(error)}`);
69
+ throw new Error(`Failed to open wallet app: ${errorMessage}`);
72
70
  }
73
71
  }
74
72
 
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();
@@ -161,14 +167,19 @@ export class TonConnectMobile {
161
167
  * Set up URL listener for wallet callbacks
162
168
  */
163
169
  private setupURLListener(): void {
170
+ console.log('[TON Connect] Setting up URL listener...');
164
171
  this.urlUnsubscribe = this.adapter.addURLListener((url) => {
172
+ console.log('[TON Connect] URL callback received:', url);
165
173
  this.handleCallback(url);
166
174
  });
167
175
 
168
176
  // Also check initial URL (when app was opened via deep link)
169
177
  this.adapter.getInitialURL().then((url) => {
170
178
  if (url) {
179
+ console.log('[TON Connect] Initial URL found:', url);
171
180
  this.handleCallback(url);
181
+ } else {
182
+ console.log('[TON Connect] No initial URL');
172
183
  }
173
184
  });
174
185
  }
@@ -177,7 +188,9 @@ export class TonConnectMobile {
177
188
  * Handle callback from wallet
178
189
  */
179
190
  private handleCallback(url: string): void {
191
+ console.log('[TON Connect] handleCallback called with URL:', url);
180
192
  const parsed = parseCallbackURL(url, this.config.scheme);
193
+ console.log('[TON Connect] Parsed callback:', parsed.type, parsed.data ? 'has data' : 'no data');
181
194
 
182
195
  if (parsed.type === 'connect' && parsed.data) {
183
196
  this.handleConnectionResponse(parsed.data as ConnectionResponsePayload);
@@ -292,23 +305,29 @@ export class TonConnectMobile {
292
305
  * Connect to wallet
293
306
  */
294
307
  async connect(): Promise<WalletInfo> {
308
+ console.log('[TON Connect] connect() called');
309
+
295
310
  // If already connected, return current wallet
296
311
  if (this.currentStatus.connected && this.currentStatus.wallet) {
312
+ console.log('[TON Connect] Already connected, returning existing wallet');
297
313
  return this.currentStatus.wallet;
298
314
  }
299
315
 
300
316
  // CRITICAL FIX: Check if connection is already in progress
301
317
  if (this.connectionPromise) {
318
+ console.log('[TON Connect] Connection already in progress');
302
319
  throw new ConnectionInProgressError();
303
320
  }
304
321
 
305
322
  // Build connection request URL
323
+ console.log('[TON Connect] Building connection request URL...');
306
324
  const url = buildConnectionRequest(this.config.manifestUrl, this.config.scheme);
307
325
 
308
326
  // DEBUG: Log the URL being opened
309
327
  console.log('[TON Connect] Opening URL:', url);
310
328
  console.log('[TON Connect] Manifest URL:', this.config.manifestUrl);
311
329
  console.log('[TON Connect] Return scheme:', this.config.scheme);
330
+ console.log('[TON Connect] Adapter type:', this.adapter.constructor.name);
312
331
 
313
332
  // Create promise for connection
314
333
  return new Promise<WalletInfo>((resolve, reject) => {