@blazium/ton-connect-mobile 1.0.5 → 1.0.6

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.
@@ -15,14 +15,16 @@ export declare function decodeBase64URL<T>(encoded: string): T;
15
15
  * Build connection request URL
16
16
  * Format: tonconnect://connect?<base64_encoded_payload>
17
17
  * Or universal link: https://app.tonkeeper.com/ton-connect?<base64_encoded_payload>
18
+ * Or custom wallet universal link
18
19
  */
19
- export declare function buildConnectionRequest(manifestUrl: string, returnScheme: string, useUniversalLink?: boolean): string;
20
+ export declare function buildConnectionRequest(manifestUrl: string, returnScheme: string, walletUniversalLink?: string): string;
20
21
  /**
21
22
  * Build transaction request URL
22
23
  * Format: tonconnect://send-transaction?<base64_encoded_payload>
23
24
  * Or universal link: https://app.tonkeeper.com/ton-connect/send-transaction?<base64_encoded_payload>
25
+ * Or custom wallet universal link
24
26
  */
25
- export declare function buildTransactionRequest(manifestUrl: string, request: SendTransactionRequest, returnScheme: string, useUniversalLink?: boolean): string;
27
+ export declare function buildTransactionRequest(manifestUrl: string, request: SendTransactionRequest, returnScheme: string, walletUniversalLink?: string): string;
26
28
  /**
27
29
  * Parse callback URL
28
30
  * Format: <scheme>://tonconnect?<base64_encoded_response>
@@ -103,26 +103,29 @@ function decodeBase64URL(encoded) {
103
103
  * Build connection request URL
104
104
  * Format: tonconnect://connect?<base64_encoded_payload>
105
105
  * Or universal link: https://app.tonkeeper.com/ton-connect?<base64_encoded_payload>
106
+ * Or custom wallet universal link
106
107
  */
107
- function buildConnectionRequest(manifestUrl, returnScheme, useUniversalLink = true) {
108
+ function buildConnectionRequest(manifestUrl, returnScheme, walletUniversalLink) {
108
109
  const payload = {
109
110
  manifestUrl,
110
111
  items: [{ name: 'ton_addr' }],
111
112
  returnStrategy: 'back',
112
113
  };
113
114
  const encoded = encodeBase64URL(payload);
114
- // Use universal link for better Android compatibility
115
- if (useUniversalLink) {
116
- return `${CONNECT_UNIVERSAL_PREFIX}?${encoded}`;
115
+ // Use custom wallet universal link if provided
116
+ if (walletUniversalLink) {
117
+ return `${walletUniversalLink}?${encoded}`;
117
118
  }
118
- return `${CONNECT_PREFIX}?${encoded}`;
119
+ // Default to Tonkeeper universal link for Android compatibility
120
+ return `${CONNECT_UNIVERSAL_PREFIX}?${encoded}`;
119
121
  }
120
122
  /**
121
123
  * Build transaction request URL
122
124
  * Format: tonconnect://send-transaction?<base64_encoded_payload>
123
125
  * Or universal link: https://app.tonkeeper.com/ton-connect/send-transaction?<base64_encoded_payload>
126
+ * Or custom wallet universal link
124
127
  */
125
- function buildTransactionRequest(manifestUrl, request, returnScheme, useUniversalLink = true) {
128
+ function buildTransactionRequest(manifestUrl, request, returnScheme, walletUniversalLink) {
126
129
  const payload = {
127
130
  manifestUrl,
128
131
  request: {
@@ -139,11 +142,16 @@ function buildTransactionRequest(manifestUrl, request, returnScheme, useUniversa
139
142
  returnStrategy: 'back',
140
143
  };
141
144
  const encoded = encodeBase64URL(payload);
142
- // Use universal link for better Android compatibility
143
- if (useUniversalLink) {
144
- return `${SEND_TRANSACTION_UNIVERSAL_PREFIX}?${encoded}`;
145
+ // Use custom wallet universal link if provided
146
+ if (walletUniversalLink) {
147
+ // For transaction, append /send-transaction to the base universal link
148
+ const baseUrl = walletUniversalLink.endsWith('/ton-connect')
149
+ ? walletUniversalLink
150
+ : `${walletUniversalLink}/ton-connect`;
151
+ return `${baseUrl}/send-transaction?${encoded}`;
145
152
  }
146
- return `${SEND_TRANSACTION_PREFIX}?${encoded}`;
153
+ // Default to Tonkeeper universal link for Android compatibility
154
+ return `${SEND_TRANSACTION_UNIVERSAL_PREFIX}?${encoded}`;
147
155
  }
148
156
  /**
149
157
  * Parse callback URL
@@ -0,0 +1,34 @@
1
+ /**
2
+ * TON Connect compatible wallet definitions
3
+ * Each wallet has its own universal link format
4
+ */
5
+ export interface WalletDefinition {
6
+ /** Wallet name for display */
7
+ name: string;
8
+ /** Wallet app name */
9
+ appName: string;
10
+ /** Universal link base URL for this wallet */
11
+ universalLink: string;
12
+ /** Deep link scheme (if supported) */
13
+ deepLink?: string;
14
+ /** Wallet icon URL (optional) */
15
+ iconUrl?: string;
16
+ /** Platform support */
17
+ platforms: ('ios' | 'android' | 'web')[];
18
+ }
19
+ /**
20
+ * List of supported TON Connect wallets
21
+ */
22
+ export declare const SUPPORTED_WALLETS: WalletDefinition[];
23
+ /**
24
+ * Get wallet definition by name
25
+ */
26
+ export declare function getWalletByName(name: string): WalletDefinition | undefined;
27
+ /**
28
+ * Get default wallet (Tonkeeper)
29
+ */
30
+ export declare function getDefaultWallet(): WalletDefinition;
31
+ /**
32
+ * Get all wallets for a specific platform
33
+ */
34
+ export declare function getWalletsForPlatform(platform: 'ios' | 'android' | 'web'): WalletDefinition[];
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * TON Connect compatible wallet definitions
4
+ * Each wallet has its own universal link format
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SUPPORTED_WALLETS = void 0;
8
+ exports.getWalletByName = getWalletByName;
9
+ exports.getDefaultWallet = getDefaultWallet;
10
+ exports.getWalletsForPlatform = getWalletsForPlatform;
11
+ /**
12
+ * List of supported TON Connect wallets
13
+ */
14
+ exports.SUPPORTED_WALLETS = [
15
+ {
16
+ name: 'Tonkeeper',
17
+ appName: 'Tonkeeper',
18
+ universalLink: 'https://app.tonkeeper.com/ton-connect',
19
+ deepLink: 'tonkeeper://',
20
+ platforms: ['ios', 'android'],
21
+ },
22
+ {
23
+ name: 'MyTonWallet',
24
+ appName: 'MyTonWallet',
25
+ universalLink: 'https://connect.mytonwallet.org',
26
+ deepLink: 'mytonwallet://',
27
+ platforms: ['ios', 'android', 'web'],
28
+ },
29
+ {
30
+ name: 'Wallet in Telegram',
31
+ appName: 'Wallet',
32
+ universalLink: 'https://wallet.tonapi.io/ton-connect',
33
+ deepLink: 'tg://',
34
+ platforms: ['ios', 'android'],
35
+ },
36
+ {
37
+ name: 'Tonhub',
38
+ appName: 'Tonhub',
39
+ universalLink: 'https://tonhub.com/ton-connect',
40
+ deepLink: 'tonhub://',
41
+ platforms: ['ios', 'android'],
42
+ },
43
+ ];
44
+ /**
45
+ * Get wallet definition by name
46
+ */
47
+ function getWalletByName(name) {
48
+ return exports.SUPPORTED_WALLETS.find((wallet) => wallet.name.toLowerCase() === name.toLowerCase() || wallet.appName.toLowerCase() === name.toLowerCase());
49
+ }
50
+ /**
51
+ * Get default wallet (Tonkeeper)
52
+ */
53
+ function getDefaultWallet() {
54
+ return exports.SUPPORTED_WALLETS[0]; // Tonkeeper
55
+ }
56
+ /**
57
+ * Get all wallets for a specific platform
58
+ */
59
+ function getWalletsForPlatform(platform) {
60
+ return exports.SUPPORTED_WALLETS.filter((wallet) => wallet.platforms.includes(platform));
61
+ }
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Production-ready implementation for React Native and Expo
4
4
  */
5
5
  import { TonConnectMobileConfig, ConnectionStatus, WalletInfo, SendTransactionRequest, StatusChangeCallback } from './types';
6
+ import { type WalletDefinition } from './core/wallets';
6
7
  /**
7
8
  * Custom error classes
8
9
  */
@@ -34,6 +35,7 @@ export declare class TonConnectMobile {
34
35
  private statusChangeCallbacks;
35
36
  private currentStatus;
36
37
  private urlUnsubscribe;
38
+ private currentWallet;
37
39
  private connectionPromise;
38
40
  private transactionPromise;
39
41
  constructor(config: TonConnectMobileConfig);
@@ -80,6 +82,18 @@ export declare class TonConnectMobile {
80
82
  * Get current connection status
81
83
  */
82
84
  getStatus(): ConnectionStatus;
85
+ /**
86
+ * Get list of supported wallets
87
+ */
88
+ getSupportedWallets(): WalletDefinition[];
89
+ /**
90
+ * Get current wallet being used
91
+ */
92
+ getCurrentWallet(): WalletDefinition;
93
+ /**
94
+ * Set preferred wallet for connections
95
+ */
96
+ setPreferredWallet(walletName: string): void;
83
97
  /**
84
98
  * Subscribe to status changes
85
99
  */
@@ -110,3 +124,5 @@ export declare class TonConnectMobile {
110
124
  destroy(): void;
111
125
  }
112
126
  export * from './types';
127
+ export type { WalletDefinition } from './core/wallets';
128
+ export { SUPPORTED_WALLETS, getWalletByName, getDefaultWallet, getWalletsForPlatform } from './core/wallets';
package/dist/index.js CHANGED
@@ -18,12 +18,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.TonConnectMobile = exports.TransactionInProgressError = exports.ConnectionInProgressError = exports.UserRejectedError = exports.TransactionTimeoutError = exports.ConnectionTimeoutError = exports.TonConnectError = void 0;
21
+ exports.getWalletsForPlatform = exports.getDefaultWallet = exports.getWalletByName = exports.SUPPORTED_WALLETS = exports.TonConnectMobile = exports.TransactionInProgressError = exports.ConnectionInProgressError = exports.UserRejectedError = exports.TransactionTimeoutError = exports.ConnectionTimeoutError = exports.TonConnectError = void 0;
22
22
  const protocol_1 = require("./core/protocol");
23
23
  const crypto_1 = require("./core/crypto");
24
24
  const expo_1 = require("./adapters/expo");
25
25
  const react_native_1 = require("./adapters/react-native");
26
26
  const web_1 = require("./adapters/web");
27
+ const wallets_1 = require("./core/wallets");
27
28
  /**
28
29
  * Custom error classes
29
30
  */
@@ -92,11 +93,29 @@ class TonConnectMobile {
92
93
  connectionTimeout: 300000, // 5 minutes
93
94
  transactionTimeout: 300000, // 5 minutes
94
95
  skipCanOpenURLCheck: true, // Skip canOpenURL check by default (Android issue)
96
+ preferredWallet: config.preferredWallet,
95
97
  ...config,
96
98
  };
99
+ // Determine which wallet to use
100
+ if (this.config.preferredWallet) {
101
+ const wallet = (0, wallets_1.getWalletByName)(this.config.preferredWallet);
102
+ if (wallet) {
103
+ this.currentWallet = wallet;
104
+ console.log('[TON Connect] Using preferred wallet:', wallet.name);
105
+ }
106
+ else {
107
+ console.warn('[TON Connect] Preferred wallet not found, using default');
108
+ this.currentWallet = (0, wallets_1.getDefaultWallet)();
109
+ }
110
+ }
111
+ else {
112
+ this.currentWallet = (0, wallets_1.getDefaultWallet)();
113
+ }
97
114
  console.log('[TON Connect] Initializing SDK with config:', {
98
115
  manifestUrl: this.config.manifestUrl,
99
116
  scheme: this.config.scheme,
117
+ wallet: this.currentWallet.name,
118
+ universalLink: this.currentWallet.universalLink,
100
119
  });
101
120
  // Initialize platform adapter
102
121
  this.adapter = this.createAdapter();
@@ -279,9 +298,11 @@ class TonConnectMobile {
279
298
  console.log('[TON Connect] Connection already in progress');
280
299
  throw new ConnectionInProgressError();
281
300
  }
282
- // Build connection request URL (use universal link for Android compatibility)
283
- console.log('[TON Connect] Building connection request URL...');
284
- const url = (0, protocol_1.buildConnectionRequest)(this.config.manifestUrl, this.config.scheme, true);
301
+ // Build connection request URL (use wallet's universal link)
302
+ console.log('[TON Connect] Building connection request URL for wallet:', this.currentWallet.name);
303
+ console.log('[TON Connect] Using universal link:', this.currentWallet.universalLink);
304
+ const url = (0, protocol_1.buildConnectionRequest)(this.config.manifestUrl, this.config.scheme, this.currentWallet.universalLink);
305
+ console.log('[TON Connect] Built URL:', url.substring(0, 100) + '...');
285
306
  // DEBUG: Log the URL being opened
286
307
  console.log('[TON Connect] Opening URL:', url);
287
308
  console.log('[TON Connect] Manifest URL:', this.config.manifestUrl);
@@ -355,7 +376,7 @@ class TonConnectMobile {
355
376
  throw new TransactionInProgressError();
356
377
  }
357
378
  // Build transaction request URL (use universal link for Android compatibility)
358
- const url = (0, protocol_1.buildTransactionRequest)(this.config.manifestUrl, request, this.config.scheme, true);
379
+ const url = (0, protocol_1.buildTransactionRequest)(this.config.manifestUrl, request, this.config.scheme, this.currentWallet.universalLink);
359
380
  // Create promise for transaction
360
381
  return new Promise((resolve, reject) => {
361
382
  let timeout = null;
@@ -414,6 +435,29 @@ class TonConnectMobile {
414
435
  getStatus() {
415
436
  return { ...this.currentStatus };
416
437
  }
438
+ /**
439
+ * Get list of supported wallets
440
+ */
441
+ getSupportedWallets() {
442
+ return wallets_1.SUPPORTED_WALLETS;
443
+ }
444
+ /**
445
+ * Get current wallet being used
446
+ */
447
+ getCurrentWallet() {
448
+ return this.currentWallet;
449
+ }
450
+ /**
451
+ * Set preferred wallet for connections
452
+ */
453
+ setPreferredWallet(walletName) {
454
+ const wallet = (0, wallets_1.getWalletByName)(walletName);
455
+ if (!wallet) {
456
+ throw new TonConnectError(`Wallet "${walletName}" not found. Available wallets: ${wallets_1.SUPPORTED_WALLETS.map(w => w.name).join(', ')}`);
457
+ }
458
+ this.currentWallet = wallet;
459
+ console.log('[TON Connect] Preferred wallet changed to:', wallet.name);
460
+ }
417
461
  /**
418
462
  * Subscribe to status changes
419
463
  */
@@ -549,3 +593,8 @@ class TonConnectMobile {
549
593
  exports.TonConnectMobile = TonConnectMobile;
550
594
  // Export types
551
595
  __exportStar(require("./types"), exports);
596
+ var wallets_2 = require("./core/wallets");
597
+ Object.defineProperty(exports, "SUPPORTED_WALLETS", { enumerable: true, get: function () { return wallets_2.SUPPORTED_WALLETS; } });
598
+ Object.defineProperty(exports, "getWalletByName", { enumerable: true, get: function () { return wallets_2.getWalletByName; } });
599
+ Object.defineProperty(exports, "getDefaultWallet", { enumerable: true, get: function () { return wallets_2.getDefaultWallet; } });
600
+ Object.defineProperty(exports, "getWalletsForPlatform", { enumerable: true, get: function () { return wallets_2.getWalletsForPlatform; } });
@@ -190,6 +190,11 @@ export interface TonConnectMobileConfig {
190
190
  * Note: On Android, canOpenURL may return false for tonconnect:// even if wallet is installed.
191
191
  */
192
192
  skipCanOpenURLCheck?: boolean;
193
+ /** Preferred wallet name (optional)
194
+ * If not specified, will use default wallet (Tonkeeper)
195
+ * Available: 'Tonkeeper', 'MyTonWallet', 'Wallet in Telegram', 'Tonhub'
196
+ */
197
+ preferredWallet?: string;
193
198
  }
194
199
  /**
195
200
  * Event listener callback type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazium/ton-connect-mobile",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
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",
@@ -125,11 +125,12 @@ export function decodeBase64URL<T>(encoded: string): T {
125
125
  * Build connection request URL
126
126
  * Format: tonconnect://connect?<base64_encoded_payload>
127
127
  * Or universal link: https://app.tonkeeper.com/ton-connect?<base64_encoded_payload>
128
+ * Or custom wallet universal link
128
129
  */
129
130
  export function buildConnectionRequest(
130
131
  manifestUrl: string,
131
132
  returnScheme: string,
132
- useUniversalLink: boolean = true
133
+ walletUniversalLink?: string
133
134
  ): string {
134
135
  const payload: ConnectionRequestPayload = {
135
136
  manifestUrl,
@@ -139,24 +140,26 @@ export function buildConnectionRequest(
139
140
 
140
141
  const encoded = encodeBase64URL(payload);
141
142
 
142
- // Use universal link for better Android compatibility
143
- if (useUniversalLink) {
144
- return `${CONNECT_UNIVERSAL_PREFIX}?${encoded}`;
143
+ // Use custom wallet universal link if provided
144
+ if (walletUniversalLink) {
145
+ return `${walletUniversalLink}?${encoded}`;
145
146
  }
146
147
 
147
- return `${CONNECT_PREFIX}?${encoded}`;
148
+ // Default to Tonkeeper universal link for Android compatibility
149
+ return `${CONNECT_UNIVERSAL_PREFIX}?${encoded}`;
148
150
  }
149
151
 
150
152
  /**
151
153
  * Build transaction request URL
152
154
  * Format: tonconnect://send-transaction?<base64_encoded_payload>
153
155
  * Or universal link: https://app.tonkeeper.com/ton-connect/send-transaction?<base64_encoded_payload>
156
+ * Or custom wallet universal link
154
157
  */
155
158
  export function buildTransactionRequest(
156
159
  manifestUrl: string,
157
160
  request: SendTransactionRequest,
158
161
  returnScheme: string,
159
- useUniversalLink: boolean = true
162
+ walletUniversalLink?: string
160
163
  ): string {
161
164
  const payload: TransactionRequestPayload = {
162
165
  manifestUrl,
@@ -176,12 +179,17 @@ export function buildTransactionRequest(
176
179
 
177
180
  const encoded = encodeBase64URL(payload);
178
181
 
179
- // Use universal link for better Android compatibility
180
- if (useUniversalLink) {
181
- return `${SEND_TRANSACTION_UNIVERSAL_PREFIX}?${encoded}`;
182
+ // Use custom wallet universal link if provided
183
+ if (walletUniversalLink) {
184
+ // For transaction, append /send-transaction to the base universal link
185
+ const baseUrl = walletUniversalLink.endsWith('/ton-connect')
186
+ ? walletUniversalLink
187
+ : `${walletUniversalLink}/ton-connect`;
188
+ return `${baseUrl}/send-transaction?${encoded}`;
182
189
  }
183
190
 
184
- return `${SEND_TRANSACTION_PREFIX}?${encoded}`;
191
+ // Default to Tonkeeper universal link for Android compatibility
192
+ return `${SEND_TRANSACTION_UNIVERSAL_PREFIX}?${encoded}`;
185
193
  }
186
194
 
187
195
  /**
@@ -0,0 +1,77 @@
1
+ /**
2
+ * TON Connect compatible wallet definitions
3
+ * Each wallet has its own universal link format
4
+ */
5
+
6
+ export interface WalletDefinition {
7
+ /** Wallet name for display */
8
+ name: string;
9
+ /** Wallet app name */
10
+ appName: string;
11
+ /** Universal link base URL for this wallet */
12
+ universalLink: string;
13
+ /** Deep link scheme (if supported) */
14
+ deepLink?: string;
15
+ /** Wallet icon URL (optional) */
16
+ iconUrl?: string;
17
+ /** Platform support */
18
+ platforms: ('ios' | 'android' | 'web')[];
19
+ }
20
+
21
+ /**
22
+ * List of supported TON Connect wallets
23
+ */
24
+ export const SUPPORTED_WALLETS: WalletDefinition[] = [
25
+ {
26
+ name: 'Tonkeeper',
27
+ appName: 'Tonkeeper',
28
+ universalLink: 'https://app.tonkeeper.com/ton-connect',
29
+ deepLink: 'tonkeeper://',
30
+ platforms: ['ios', 'android'],
31
+ },
32
+ {
33
+ name: 'MyTonWallet',
34
+ appName: 'MyTonWallet',
35
+ universalLink: 'https://connect.mytonwallet.org',
36
+ deepLink: 'mytonwallet://',
37
+ platforms: ['ios', 'android', 'web'],
38
+ },
39
+ {
40
+ name: 'Wallet in Telegram',
41
+ appName: 'Wallet',
42
+ universalLink: 'https://wallet.tonapi.io/ton-connect',
43
+ deepLink: 'tg://',
44
+ platforms: ['ios', 'android'],
45
+ },
46
+ {
47
+ name: 'Tonhub',
48
+ appName: 'Tonhub',
49
+ universalLink: 'https://tonhub.com/ton-connect',
50
+ deepLink: 'tonhub://',
51
+ platforms: ['ios', 'android'],
52
+ },
53
+ ];
54
+
55
+ /**
56
+ * Get wallet definition by name
57
+ */
58
+ export function getWalletByName(name: string): WalletDefinition | undefined {
59
+ return SUPPORTED_WALLETS.find(
60
+ (wallet) => wallet.name.toLowerCase() === name.toLowerCase() || wallet.appName.toLowerCase() === name.toLowerCase()
61
+ );
62
+ }
63
+
64
+ /**
65
+ * Get default wallet (Tonkeeper)
66
+ */
67
+ export function getDefaultWallet(): WalletDefinition {
68
+ return SUPPORTED_WALLETS[0]; // Tonkeeper
69
+ }
70
+
71
+ /**
72
+ * Get all wallets for a specific platform
73
+ */
74
+ export function getWalletsForPlatform(platform: 'ios' | 'android' | 'web'): WalletDefinition[] {
75
+ return SUPPORTED_WALLETS.filter((wallet) => wallet.platforms.includes(platform));
76
+ }
77
+
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ import { verifyConnectionProof, generateSessionId } from './core/crypto';
32
32
  import { ExpoAdapter } from './adapters/expo';
33
33
  import { ReactNativeAdapter } from './adapters/react-native';
34
34
  import { WebAdapter } from './adapters/web';
35
+ import { getWalletByName, getDefaultWallet, SUPPORTED_WALLETS, type WalletDefinition } from './core/wallets';
35
36
 
36
37
  /**
37
38
  * Custom error classes
@@ -83,10 +84,11 @@ export class TransactionInProgressError extends TonConnectError {
83
84
  */
84
85
  export class TonConnectMobile {
85
86
  private adapter: PlatformAdapter;
86
- private config: Required<TonConnectMobileConfig>;
87
+ private config: Required<Omit<TonConnectMobileConfig, 'preferredWallet'>> & { preferredWallet?: string };
87
88
  private statusChangeCallbacks: Set<StatusChangeCallback> = new Set();
88
89
  private currentStatus: ConnectionStatus = { connected: false, wallet: null };
89
90
  private urlUnsubscribe: (() => void) | null = null;
91
+ private currentWallet!: WalletDefinition;
90
92
  private connectionPromise: {
91
93
  resolve: (wallet: WalletInfo) => void;
92
94
  reject: (error: Error) => void;
@@ -112,12 +114,29 @@ export class TonConnectMobile {
112
114
  connectionTimeout: 300000, // 5 minutes
113
115
  transactionTimeout: 300000, // 5 minutes
114
116
  skipCanOpenURLCheck: true, // Skip canOpenURL check by default (Android issue)
117
+ preferredWallet: config.preferredWallet,
115
118
  ...config,
116
- };
119
+ } as Required<Omit<TonConnectMobileConfig, 'preferredWallet'>> & { preferredWallet?: string };
120
+
121
+ // Determine which wallet to use
122
+ if (this.config.preferredWallet) {
123
+ const wallet = getWalletByName(this.config.preferredWallet);
124
+ if (wallet) {
125
+ this.currentWallet = wallet;
126
+ console.log('[TON Connect] Using preferred wallet:', wallet.name);
127
+ } else {
128
+ console.warn('[TON Connect] Preferred wallet not found, using default');
129
+ this.currentWallet = getDefaultWallet();
130
+ }
131
+ } else {
132
+ this.currentWallet = getDefaultWallet();
133
+ }
117
134
 
118
135
  console.log('[TON Connect] Initializing SDK with config:', {
119
136
  manifestUrl: this.config.manifestUrl,
120
137
  scheme: this.config.scheme,
138
+ wallet: this.currentWallet.name,
139
+ universalLink: this.currentWallet.universalLink,
121
140
  });
122
141
 
123
142
  // Initialize platform adapter
@@ -320,9 +339,11 @@ export class TonConnectMobile {
320
339
  throw new ConnectionInProgressError();
321
340
  }
322
341
 
323
- // Build connection request URL (use universal link for Android compatibility)
324
- console.log('[TON Connect] Building connection request URL...');
325
- const url = buildConnectionRequest(this.config.manifestUrl, this.config.scheme, true);
342
+ // Build connection request URL (use wallet's universal link)
343
+ console.log('[TON Connect] Building connection request URL for wallet:', this.currentWallet.name);
344
+ console.log('[TON Connect] Using universal link:', this.currentWallet.universalLink);
345
+ const url = buildConnectionRequest(this.config.manifestUrl, this.config.scheme, this.currentWallet.universalLink);
346
+ console.log('[TON Connect] Built URL:', url.substring(0, 100) + '...');
326
347
 
327
348
  // DEBUG: Log the URL being opened
328
349
  console.log('[TON Connect] Opening URL:', url);
@@ -409,7 +430,7 @@ export class TonConnectMobile {
409
430
  }
410
431
 
411
432
  // Build transaction request URL (use universal link for Android compatibility)
412
- const url = buildTransactionRequest(this.config.manifestUrl, request, this.config.scheme, true);
433
+ const url = buildTransactionRequest(this.config.manifestUrl, request, this.config.scheme, this.currentWallet.universalLink);
413
434
 
414
435
  // Create promise for transaction
415
436
  return new Promise<{ boc: string; signature: string }>((resolve, reject) => {
@@ -481,6 +502,32 @@ export class TonConnectMobile {
481
502
  return { ...this.currentStatus };
482
503
  }
483
504
 
505
+ /**
506
+ * Get list of supported wallets
507
+ */
508
+ getSupportedWallets(): WalletDefinition[] {
509
+ return SUPPORTED_WALLETS;
510
+ }
511
+
512
+ /**
513
+ * Get current wallet being used
514
+ */
515
+ getCurrentWallet(): WalletDefinition {
516
+ return this.currentWallet;
517
+ }
518
+
519
+ /**
520
+ * Set preferred wallet for connections
521
+ */
522
+ setPreferredWallet(walletName: string): void {
523
+ const wallet = getWalletByName(walletName);
524
+ if (!wallet) {
525
+ throw new TonConnectError(`Wallet "${walletName}" not found. Available wallets: ${SUPPORTED_WALLETS.map(w => w.name).join(', ')}`);
526
+ }
527
+ this.currentWallet = wallet;
528
+ console.log('[TON Connect] Preferred wallet changed to:', wallet.name);
529
+ }
530
+
484
531
  /**
485
532
  * Subscribe to status changes
486
533
  */
@@ -629,4 +676,6 @@ export class TonConnectMobile {
629
676
 
630
677
  // Export types
631
678
  export * from './types';
679
+ export type { WalletDefinition } from './core/wallets';
680
+ export { SUPPORTED_WALLETS, getWalletByName, getDefaultWallet, getWalletsForPlatform } from './core/wallets';
632
681
 
@@ -202,6 +202,11 @@ export interface TonConnectMobileConfig {
202
202
  * Note: On Android, canOpenURL may return false for tonconnect:// even if wallet is installed.
203
203
  */
204
204
  skipCanOpenURLCheck?: boolean;
205
+ /** Preferred wallet name (optional)
206
+ * If not specified, will use default wallet (Tonkeeper)
207
+ * Available: 'Tonkeeper', 'MyTonWallet', 'Wallet in Telegram', 'Tonhub'
208
+ */
209
+ preferredWallet?: string;
205
210
  }
206
211
 
207
212
  /**