@blazium/ton-connect-mobile 1.2.4 → 1.2.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.
@@ -1,27 +1,23 @@
1
- /**
2
- * React integration exports
3
- * Re-export all React components and hooks
4
- */
5
-
6
- export {
7
- TonConnectUIProvider,
8
- useTonConnectUI,
9
- useTonWallet,
10
- useTonConnectModal,
11
- useTonConnectSDK,
12
- } from './TonConnectUIProvider';
13
- export type {
14
- TonConnectUIProviderProps,
15
- TonConnectUI,
16
- WalletState,
17
- Account,
18
- TransactionResponse,
19
- SignDataRequest,
20
- SignDataResponse,
21
- } from './TonConnectUIProvider';
22
- export type { Network, BalanceResponse, TransactionStatusResponse, TransactionStatus } from '../types';
23
- export { TonConnectButton } from './TonConnectButton';
24
- export type { TonConnectButtonProps } from './TonConnectButton';
25
- export { WalletSelectionModal } from './WalletSelectionModal';
26
- export type { WalletSelectionModalProps } from './WalletSelectionModal';
27
-
1
+ /**
2
+ * React integration exports
3
+ */
4
+
5
+ export {
6
+ TonConnectUIProvider,
7
+ useTonConnectUI,
8
+ useTonWallet,
9
+ useTonConnectModal,
10
+ useTonConnectSDK,
11
+ } from './TonConnectUIProvider';
12
+ export type {
13
+ TonConnectUIProviderProps,
14
+ TonConnectUI,
15
+ WalletState,
16
+ Account,
17
+ TransactionResponse,
18
+ } from './TonConnectUIProvider';
19
+ export type { Network, BalanceResponse, TransactionStatusResponse, TransactionStatus } from '../types';
20
+ export { TonConnectButton } from './TonConnectButton';
21
+ export type { TonConnectButtonProps } from './TonConnectButton';
22
+ export { WalletSelectionModal } from './WalletSelectionModal';
23
+ export type { WalletSelectionModalProps } from './WalletSelectionModal';
@@ -1,272 +1,217 @@
1
- /**
2
- * Core types for TON Connect Mobile SDK
3
- * These types define the protocol structure for TonConnect
4
- */
5
-
6
- /**
7
- * Wallet information returned after successful connection
8
- */
9
- export interface WalletInfo {
10
- /** Wallet name (e.g., "Tonkeeper", "MyTonWallet") */
11
- name: string;
12
- /** Wallet app name */
13
- appName: string;
14
- /** Wallet app version */
15
- version: string;
16
- /** Platform (ios/android) */
17
- platform: 'ios' | 'android' | 'unknown';
18
- /** TON address of the connected wallet */
19
- address: string;
20
- /** Public key in hex format */
21
- publicKey: string;
22
- /** Wallet icon URL */
23
- icon?: string;
24
- }
25
-
26
- /**
27
- * Connection status
28
- */
29
- export interface ConnectionStatus {
30
- /** Whether a wallet is currently connected */
31
- connected: boolean;
32
- /** Wallet information if connected, null otherwise */
33
- wallet: WalletInfo | null;
34
- }
35
-
36
- /**
37
- * Transaction message to send
38
- */
39
- export interface TransactionMessage {
40
- /** Recipient address in TON format (EQ...) */
41
- address: string;
42
- /** Amount in nanotons (1 TON = 1,000,000,000 nanotons) */
43
- amount: string;
44
- /** Optional message payload (base64 encoded) */
45
- payload?: string;
46
- /** Optional state init (base64 encoded) */
47
- stateInit?: string;
48
- }
49
-
50
- /**
51
- * Transaction request parameters
52
- */
53
- export interface SendTransactionRequest {
54
- /** Unix timestamp (ms) when the request expires */
55
- validUntil: number;
56
- /** Array of messages to send */
57
- messages: TransactionMessage[];
58
- /** Optional network (mainnet/testnet) */
59
- network?: 'mainnet' | 'testnet';
60
- /** Optional from address */
61
- from?: string;
62
- }
63
-
64
- /**
65
- * Transaction response from wallet
66
- */
67
- export interface TransactionResponse {
68
- /** Base64 encoded BOC of the transaction */
69
- boc: string;
70
- /** Transaction signature */
71
- signature: string;
72
- }
73
-
74
- /**
75
- * Connection request payload (sent to wallet)
76
- */
77
- export interface ConnectionRequestPayload {
78
- /** Manifest URL for the app */
79
- manifestUrl: string;
80
- /** Items requested from wallet */
81
- items: Array<{
82
- name: 'ton_addr';
83
- }>;
84
- /** Return strategy - how wallet should return to the app */
85
- returnStrategy?: 'back' | 'post_redirect' | 'none';
86
- /** Return scheme for mobile apps (required by many wallets for proper callback handling) */
87
- returnScheme?: string;
88
- }
89
-
90
- /**
91
- * Connection response payload (received from wallet)
92
- */
93
- export interface ConnectionResponsePayload {
94
- /** Session ID */
95
- session: string;
96
- /** Wallet information */
97
- name: string;
98
- /** Wallet app name */
99
- appName: string;
100
- /** Wallet version */
101
- version: string;
102
- /** Platform */
103
- platform: 'ios' | 'android' | 'unknown';
104
- /** TON address */
105
- address: string;
106
- /** Public key in hex */
107
- publicKey: string;
108
- /** Wallet icon URL */
109
- icon?: string;
110
- /** Proof (signature) for verification */
111
- proof?: {
112
- timestamp: number;
113
- domain: {
114
- lengthBytes: number;
115
- value: string;
116
- };
117
- signature: string;
118
- };
119
- }
120
-
121
- /**
122
- * Transaction request payload (sent to wallet)
123
- */
124
- export interface TransactionRequestPayload {
125
- /** Manifest URL */
126
- manifestUrl: string;
127
- /** Transaction request */
128
- request: {
129
- /** Unix timestamp (ms) when request expires */
130
- validUntil: number;
131
- /** Array of messages */
132
- messages: Array<{
133
- address: string;
134
- amount: string;
135
- payload?: string;
136
- stateInit?: string;
137
- }>;
138
- /** Optional network */
139
- network?: 'mainnet' | 'testnet';
140
- /** Optional from address */
141
- from?: string;
142
- };
143
- /** Return URL scheme (for mobile apps) */
144
- returnScheme?: string;
145
- /** Return strategy */
146
- returnStrategy?: 'back' | 'post_redirect' | 'none';
147
- }
148
-
149
- /**
150
- * Transaction response payload (received from wallet)
151
- */
152
- export interface TransactionResponsePayload {
153
- /** Base64 encoded BOC */
154
- boc: string;
155
- /** Transaction signature */
156
- signature: string;
157
- }
158
-
159
- /**
160
- * Error response from wallet
161
- */
162
- export interface ErrorResponse {
163
- /** Error code */
164
- error: {
165
- code: number;
166
- message: string;
167
- };
168
- }
169
-
170
- /**
171
- * Platform adapter interface for deep linking and storage
172
- */
173
- export interface PlatformAdapter {
174
- /** Open a deep link URL */
175
- openURL(url: string, skipCanOpenURLCheck?: boolean): Promise<boolean>;
176
- /** Get initial URL when app was opened via deep link */
177
- getInitialURL(): Promise<string | null>;
178
- /** Add listener for URL changes */
179
- addURLListener(callback: (url: string) => void): () => void;
180
- /** Store data */
181
- setItem(key: string, value: string): Promise<void>;
182
- /** Retrieve data */
183
- getItem(key: string): Promise<string | null>;
184
- /** Remove data */
185
- removeItem(key: string): Promise<void>;
186
- /** Generate random bytes */
187
- randomBytes(length: number): Promise<Uint8Array>;
188
- }
189
-
190
- /**
191
- * Network type
192
- */
193
- export type Network = 'mainnet' | 'testnet';
194
-
195
- /**
196
- * SDK configuration
197
- */
198
- export interface TonConnectMobileConfig {
199
- /** Manifest URL (required) */
200
- manifestUrl: string;
201
- /** Deep link scheme for callbacks (required) */
202
- scheme: string;
203
- /** Optional storage key prefix */
204
- storageKeyPrefix?: string;
205
- /** Optional connection timeout in ms (default: 300000 = 5 minutes) */
206
- connectionTimeout?: number;
207
- /** Optional transaction timeout in ms (default: 300000 = 5 minutes) */
208
- transactionTimeout?: number;
209
- /** Skip canOpenURL check before opening URL (optional, default: true)
210
- * Set to false if you want to check if URL can be opened before attempting to open it.
211
- * Note: On Android, canOpenURL may return false for tonconnect:// even if wallet is installed.
212
- */
213
- skipCanOpenURLCheck?: boolean;
214
- /** Preferred wallet name (optional)
215
- * If not specified, will use default wallet (Tonkeeper)
216
- * Available: 'Tonkeeper', 'MyTonWallet', 'Wallet in Telegram', 'Tonhub'
217
- */
218
- preferredWallet?: string;
219
- /** Network (mainnet/testnet) - default: 'mainnet' */
220
- network?: Network;
221
- /** TON API endpoint for balance checking (optional)
222
- * Default: 'https://toncenter.com/api/v2' for mainnet, 'https://testnet.toncenter.com/api/v2' for testnet
223
- */
224
- tonApiEndpoint?: string;
225
- }
226
-
227
- /**
228
- * Event listener callback type
229
- */
230
- export type StatusChangeCallback = (status: ConnectionStatus) => void;
231
-
232
- /**
233
- * Event types for TonConnectMobile
234
- */
235
- export type TonConnectEventType = 'connect' | 'disconnect' | 'transaction' | 'error' | 'statusChange';
236
-
237
- /**
238
- * Event listener callback
239
- */
240
- export type TonConnectEventListener<T = any> = (data: T) => void;
241
-
242
- /**
243
- * Transaction status
244
- */
245
- export type TransactionStatus = 'pending' | 'confirmed' | 'failed' | 'unknown';
246
-
247
- /**
248
- * Transaction status response
249
- */
250
- export interface TransactionStatusResponse {
251
- /** Transaction status */
252
- status: TransactionStatus;
253
- /** Transaction hash (if available) */
254
- hash?: string;
255
- /** Block number (if confirmed) */
256
- blockNumber?: number;
257
- /** Error message (if failed) */
258
- error?: string;
259
- }
260
-
261
- /**
262
- * Balance response
263
- */
264
- export interface BalanceResponse {
265
- /** Balance in nanotons */
266
- balance: string;
267
- /** Balance in TON (formatted) */
268
- balanceTon: string;
269
- /** Network */
270
- network: Network;
271
- }
272
-
1
+ /**
2
+ * Core types for TON Connect Mobile SDK
3
+ * Types for TON Connect v2 protocol
4
+ */
5
+
6
+ /**
7
+ * Wallet information returned after successful connection
8
+ */
9
+ export interface WalletInfo {
10
+ /** Wallet name (e.g., "Tonkeeper") */
11
+ name: string;
12
+ /** Wallet app name */
13
+ appName: string;
14
+ /** Wallet app version */
15
+ version: string;
16
+ /** Platform */
17
+ platform: 'ios' | 'android' | 'unknown';
18
+ /** TON address (raw format: workchain:hash) */
19
+ address: string;
20
+ /** Public key in hex format */
21
+ publicKey: string;
22
+ /** Network identifier ("-239" = mainnet, "-3" = testnet) */
23
+ network?: string;
24
+ /** Wallet state init (base64) */
25
+ walletStateInit?: string;
26
+ /** Wallet icon URL */
27
+ icon?: string;
28
+ }
29
+
30
+ /**
31
+ * Connection status
32
+ */
33
+ export interface ConnectionStatus {
34
+ connected: boolean;
35
+ wallet: WalletInfo | null;
36
+ }
37
+
38
+ /**
39
+ * Transaction message to send
40
+ */
41
+ export interface TransactionMessage {
42
+ /** Recipient address */
43
+ address: string;
44
+ /** Amount in nanotons */
45
+ amount: string;
46
+ /** Optional message payload (base64 encoded) */
47
+ payload?: string;
48
+ /** Optional state init (base64 encoded) */
49
+ stateInit?: string;
50
+ }
51
+
52
+ /**
53
+ * Transaction request parameters
54
+ */
55
+ export interface SendTransactionRequest {
56
+ /** Unix timestamp (ms) when the request expires */
57
+ validUntil: number;
58
+ /** Array of messages to send */
59
+ messages: TransactionMessage[];
60
+ /** Optional network */
61
+ network?: 'mainnet' | 'testnet';
62
+ /** Optional from address */
63
+ from?: string;
64
+ }
65
+
66
+ /**
67
+ * Platform adapter interface
68
+ */
69
+ export interface PlatformAdapter {
70
+ openURL(url: string, skipCanOpenURLCheck?: boolean): Promise<boolean>;
71
+ getInitialURL(): Promise<string | null>;
72
+ addURLListener(callback: (url: string) => void): () => void;
73
+ setItem(key: string, value: string): Promise<void>;
74
+ getItem(key: string): Promise<string | null>;
75
+ removeItem(key: string): Promise<void>;
76
+ randomBytes(length: number): Promise<Uint8Array>;
77
+ }
78
+
79
+ /**
80
+ * Network type
81
+ */
82
+ export type Network = 'mainnet' | 'testnet';
83
+
84
+ /**
85
+ * SDK configuration
86
+ */
87
+ export interface TonConnectMobileConfig {
88
+ /** Manifest URL (required) */
89
+ manifestUrl: string;
90
+ /** Deep link scheme for callbacks (required for return strategy) */
91
+ scheme: string;
92
+ /** Optional storage key prefix */
93
+ storageKeyPrefix?: string;
94
+ /** Optional connection timeout in ms (default: 300000 = 5 minutes) */
95
+ connectionTimeout?: number;
96
+ /** Optional transaction timeout in ms (default: 300000 = 5 minutes) */
97
+ transactionTimeout?: number;
98
+ /** Skip canOpenURL check (default: true) */
99
+ skipCanOpenURLCheck?: boolean;
100
+ /** Preferred wallet name */
101
+ preferredWallet?: string;
102
+ /** Network (default: 'mainnet') */
103
+ network?: Network;
104
+ /** Custom TON API endpoint */
105
+ tonApiEndpoint?: string;
106
+ }
107
+
108
+ /**
109
+ * Status change callback
110
+ */
111
+ export type StatusChangeCallback = (status: ConnectionStatus) => void;
112
+
113
+ /**
114
+ * Event types
115
+ */
116
+ export type TonConnectEventType = 'connect' | 'disconnect' | 'transaction' | 'error' | 'statusChange';
117
+
118
+ /**
119
+ * Event listener callback
120
+ */
121
+ export type TonConnectEventListener<T = any> = (data: T) => void;
122
+
123
+ /**
124
+ * Transaction status
125
+ */
126
+ export type TransactionStatus = 'pending' | 'confirmed' | 'failed' | 'unknown';
127
+
128
+ /**
129
+ * Transaction status response
130
+ */
131
+ export interface TransactionStatusResponse {
132
+ status: TransactionStatus;
133
+ hash?: string;
134
+ blockNumber?: number;
135
+ error?: string;
136
+ }
137
+
138
+ /**
139
+ * Balance response
140
+ */
141
+ export interface BalanceResponse {
142
+ balance: string;
143
+ balanceTon: string;
144
+ network: Network;
145
+ }
146
+
147
+ // ─── TON Connect v2 Bridge Protocol Types ───
148
+
149
+ /**
150
+ * Connect event from wallet (received via bridge after decryption)
151
+ */
152
+ export interface ConnectEvent {
153
+ event: 'connect';
154
+ id: number;
155
+ payload: {
156
+ items: Array<{
157
+ name: string;
158
+ address: string;
159
+ network: string;
160
+ publicKey: string;
161
+ walletStateInit?: string;
162
+ [key: string]: any;
163
+ }>;
164
+ device: {
165
+ platform: string;
166
+ appName: string;
167
+ appVersion: string;
168
+ maxProtocolVersion: number;
169
+ features: any[];
170
+ };
171
+ };
172
+ }
173
+
174
+ /**
175
+ * Connect error event from wallet
176
+ */
177
+ export interface ConnectErrorEvent {
178
+ event: 'connect_error';
179
+ id: number;
180
+ payload: {
181
+ code: number;
182
+ message: string;
183
+ };
184
+ }
185
+
186
+ /**
187
+ * JSON-RPC response (success)
188
+ */
189
+ export interface RpcResponse {
190
+ result: string;
191
+ id: number;
192
+ }
193
+
194
+ /**
195
+ * JSON-RPC response (error)
196
+ */
197
+ export interface RpcErrorResponse {
198
+ error: {
199
+ code: number;
200
+ message: string;
201
+ };
202
+ id: number;
203
+ }
204
+
205
+ /**
206
+ * Persisted session data
207
+ */
208
+ export interface PersistedSession {
209
+ /** Hex-encoded session secret key */
210
+ sessionSecretKey: string;
211
+ /** Hex-encoded wallet public key (from bridge "from" field) */
212
+ walletPublicKey: string;
213
+ /** Wallet bridge URL */
214
+ bridgeUrl: string;
215
+ /** Wallet info */
216
+ wallet: WalletInfo;
217
+ }