@dynamic-labs/ton 4.61.1 → 4.61.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/CHANGELOG.md +24 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connectors/TonConnectConnector/TonConnectConnector.cjs +58 -18
- package/src/connectors/TonConnectConnector/TonConnectConnector.d.ts +13 -1
- package/src/connectors/TonConnectConnector/TonConnectConnector.js +60 -20
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.cjs +6 -33
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.js +2 -29
- package/src/waas/connector/DynamicWaasTonConnector.cjs +2 -2
- package/src/waas/connector/DynamicWaasTonConnector.d.ts +2 -1
- package/src/waas/connector/DynamicWaasTonConnector.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.61.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.2...v4.61.3) (2026-02-13)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add reset widget password flow for WaaS wallets ([#10437](https://github.com/dynamic-labs/dynamic-auth/issues/10437)) ([7490069](https://github.com/dynamic-labs/dynamic-auth/commit/7490069b70b04be5d70c472c17b132c6a5eddcd5))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* add broken ton wallet mobile connection ([#10435](https://github.com/dynamic-labs/dynamic-auth/issues/10435)) ([a71cd88](https://github.com/dynamic-labs/dynamic-auth/commit/a71cd88fd4e80af6a8956cdb5cc389a34e4e00f1))
|
|
13
|
+
* infinite loop when rapidly entering phone number ([#10434](https://github.com/dynamic-labs/dynamic-auth/issues/10434)) ([39a57cc](https://github.com/dynamic-labs/dynamic-auth/commit/39a57cc51b879abbb63bd129a489adcd8522b261))
|
|
14
|
+
* invalidate non matching ton connect proof ([#10438](https://github.com/dynamic-labs/dynamic-auth/issues/10438)) ([406ba34](https://github.com/dynamic-labs/dynamic-auth/commit/406ba34ba9053953a4b5a5d6ead6d7e8a1718423))
|
|
15
|
+
|
|
16
|
+
### [4.61.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.1...v4.61.2) (2026-02-12)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* export wallet password hook ([#10433](https://github.com/dynamic-labs/dynamic-auth/issues/10433)) ([dd6170e](https://github.com/dynamic-labs/dynamic-auth/commit/dd6170ec42a863b33baea92f9716083e3c4941d0))
|
|
22
|
+
* only prompt braavos wallet once to connect ([#10405](https://github.com/dynamic-labs/dynamic-auth/issues/10405)) ([2aff336](https://github.com/dynamic-labs/dynamic-auth/commit/2aff336a6222404b7907be65ef9af6806c357a07))
|
|
23
|
+
* remove signedSessionId from validateActiveWallet ([#10422](https://github.com/dynamic-labs/dynamic-auth/issues/10422)) ([700a953](https://github.com/dynamic-labs/dynamic-auth/commit/700a95383c8754f1cc0c87f53c50d04b57ef1b52))
|
|
24
|
+
* ton wallets not showing download links ([#10421](https://github.com/dynamic-labs/dynamic-auth/issues/10421)) ([cc8a8f8](https://github.com/dynamic-labs/dynamic-auth/commit/cc8a8f82485e4cc94aacd63d2e6a1bd8ca291f9c))
|
|
25
|
+
|
|
2
26
|
### [4.61.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.61.0...v4.61.1) (2026-02-11)
|
|
3
27
|
|
|
4
28
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ton",
|
|
3
|
-
"version": "4.61.
|
|
3
|
+
"version": "4.61.3",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/assert-package-version": "4.61.
|
|
22
|
-
"@dynamic-labs/logger": "4.61.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.61.3",
|
|
22
|
+
"@dynamic-labs/logger": "4.61.3",
|
|
23
23
|
"@dynamic-labs/sdk-api-core": "0.0.864",
|
|
24
|
-
"@dynamic-labs/types": "4.61.
|
|
25
|
-
"@dynamic-labs/utils": "4.61.
|
|
26
|
-
"@dynamic-labs/waas": "4.61.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.61.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.61.
|
|
24
|
+
"@dynamic-labs/types": "4.61.3",
|
|
25
|
+
"@dynamic-labs/utils": "4.61.3",
|
|
26
|
+
"@dynamic-labs/waas": "4.61.3",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.61.3",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.61.3",
|
|
29
29
|
"@ton/core": "0.62.0",
|
|
30
30
|
"@ton/crypto": "3.3.0",
|
|
31
31
|
"@ton/ton": "16.0.0",
|
|
@@ -56,9 +56,11 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
56
56
|
this.overrideKey = 'tonconnect';
|
|
57
57
|
this.connectedChain = 'TON';
|
|
58
58
|
this.supportedChains = ['TON'];
|
|
59
|
-
this.canConnectViaQrCode =
|
|
59
|
+
this.canConnectViaQrCode = false;
|
|
60
|
+
this.canHandleMultipleConnections = false;
|
|
60
61
|
this.connectedWallet = null;
|
|
61
62
|
this.pendingProofPayload = null;
|
|
63
|
+
this.lastConnectionUrl = null;
|
|
62
64
|
this.tonNetworks = opts.tonNetworks || [];
|
|
63
65
|
this.overrideKey = opts.overrideKey || 'tonconnect';
|
|
64
66
|
// Only initialize TonConnect in browser environment
|
|
@@ -109,12 +111,21 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
113
|
/**
|
|
112
|
-
* Check if
|
|
114
|
+
* Check if the wallet's browser extension is installed
|
|
113
115
|
*/
|
|
114
116
|
isInstalledOnBrowser() {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
if (typeof window === 'undefined') {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return sdk.TonConnect.isWalletInjected(this.overrideKey);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Retry opening the wallet deep link on mobile
|
|
124
|
+
*/
|
|
125
|
+
retryDeeplinkConnection() {
|
|
126
|
+
if (this.lastConnectionUrl) {
|
|
127
|
+
utils.PlatformService.openURL(this.lastConnectionUrl);
|
|
128
|
+
}
|
|
118
129
|
}
|
|
119
130
|
/**
|
|
120
131
|
* Connect to a TON wallet
|
|
@@ -143,6 +154,19 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
143
154
|
const connectOptions = proofPayload
|
|
144
155
|
? { request: { tonProof: proofPayload } }
|
|
145
156
|
: undefined;
|
|
157
|
+
// On mobile, use bridge connection to avoid injection attempts
|
|
158
|
+
// and open the resulting connection URL as a deep link
|
|
159
|
+
if (utils.isMobile() && sdk.isWalletInfoRemote(matchingWallet)) {
|
|
160
|
+
const connectionUrl = tonConnect.connect({
|
|
161
|
+
bridgeUrl: matchingWallet.bridgeUrl,
|
|
162
|
+
universalLink: matchingWallet.universalLink,
|
|
163
|
+
}, connectOptions);
|
|
164
|
+
// Append return strategy so the wallet redirects back to the browser
|
|
165
|
+
const urlWithReturn = this.appendReturnStrategy(connectionUrl);
|
|
166
|
+
this.lastConnectionUrl = urlWithReturn;
|
|
167
|
+
utils.PlatformService.openURL(urlWithReturn);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
146
170
|
tonConnect.connect(matchingWallet, connectOptions);
|
|
147
171
|
}
|
|
148
172
|
catch (error) {
|
|
@@ -182,25 +206,24 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
182
206
|
if (tonConnect.connected && ((_a = tonConnect.account) === null || _a === void 0 ? void 0 : _a.address)) {
|
|
183
207
|
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
184
208
|
}
|
|
185
|
-
// If not connected, initiate connection and wait for it to complete
|
|
209
|
+
// If not connected, initiate connection and wait for it to complete.
|
|
210
|
+
// connect() handles platform differences internally (injected provider,
|
|
211
|
+
// bridge deep link, etc.). Unlike other chain connectors whose
|
|
212
|
+
// providers return a promise that resolves on connection completion,
|
|
213
|
+
// TonConnect SDK's connect() on mobile bridge connections returns the
|
|
214
|
+
// URL synchronously and notifies later via onStatusChange. We poll
|
|
215
|
+
// until `tonConnect.connected` becomes true as a workaround.
|
|
186
216
|
try {
|
|
187
|
-
// Start the connection process (shows QR code/deep link)
|
|
188
217
|
yield this.connect();
|
|
189
|
-
// After connect() returns, the QR code is shown but connection is not yet established
|
|
190
|
-
// Wait for the connection to be established by polling or waiting for status change
|
|
191
|
-
// TON Connect SDK doesn't provide a clean way to wait, so we poll
|
|
192
218
|
const maxWaitTime = 300000; // 5 minutes
|
|
193
219
|
const pollInterval = 500; // Check every 500ms
|
|
194
220
|
const startTime = Date.now();
|
|
195
221
|
while (!tonConnect.connected && Date.now() - startTime < maxWaitTime) {
|
|
196
222
|
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
197
|
-
// Check if connected after the delay
|
|
198
223
|
if (tonConnect.connected && ((_b = tonConnect.account) === null || _b === void 0 ? void 0 : _b.address)) {
|
|
199
|
-
|
|
200
|
-
return userFriendlyAddress;
|
|
224
|
+
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
201
225
|
}
|
|
202
226
|
}
|
|
203
|
-
// If we get here, either timeout or still not connected
|
|
204
227
|
if (!tonConnect.connected) {
|
|
205
228
|
throw new utils.DynamicError('Connection timeout - user did not approve the connection');
|
|
206
229
|
}
|
|
@@ -530,6 +553,23 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
530
553
|
// Serialize to base64 BOC (Bag of Cells) format
|
|
531
554
|
return mainCell.toBoc().toString('base64');
|
|
532
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* Append a return strategy to a TonConnect universal link.
|
|
558
|
+
* The `ret` parameter tells the wallet where to redirect after approval.
|
|
559
|
+
* `back` instructs the wallet to return to the previous app (browser).
|
|
560
|
+
*/
|
|
561
|
+
appendReturnStrategy(url) {
|
|
562
|
+
try {
|
|
563
|
+
const parsed = new URL(url);
|
|
564
|
+
parsed.searchParams.append('ret', 'back');
|
|
565
|
+
return parsed.toString();
|
|
566
|
+
}
|
|
567
|
+
catch (_a) {
|
|
568
|
+
// If URL parsing fails, append as query string manually
|
|
569
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
570
|
+
return `${url}${separator}ret=back`;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
533
573
|
/**
|
|
534
574
|
* Check if error is a user rejection
|
|
535
575
|
*/
|
|
@@ -548,10 +588,10 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
548
588
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
549
589
|
var _a, _b, _c, _d, _e, _f;
|
|
550
590
|
const tonConnect = this.getTonConnect();
|
|
551
|
-
// If already connected with a proof, return it
|
|
591
|
+
// If already connected with a proof that matches the requested payload, return it
|
|
552
592
|
if ((_b = (_a = this.connectedWallet) === null || _a === void 0 ? void 0 : _a.connectItems) === null || _b === void 0 ? void 0 : _b.tonProof) {
|
|
553
593
|
const { tonProof } = this.connectedWallet.connectItems;
|
|
554
|
-
if ('proof' in tonProof) {
|
|
594
|
+
if ('proof' in tonProof && tonProof.proof.payload === payload) {
|
|
555
595
|
debugLog.debugLog('[TON Connect] Returning existing proof from connection');
|
|
556
596
|
return {
|
|
557
597
|
address: this.connectedWallet.account.address,
|
|
@@ -562,9 +602,9 @@ class TonConnectConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
562
602
|
};
|
|
563
603
|
}
|
|
564
604
|
}
|
|
565
|
-
// If connected but no proof, disconnect and reconnect with proof
|
|
605
|
+
// If connected but no matching proof, disconnect and reconnect with new proof
|
|
566
606
|
if (tonConnect.connected) {
|
|
567
|
-
debugLog.debugLog('[TON Connect] Already connected without proof, disconnecting to reconnect with tonProof');
|
|
607
|
+
debugLog.debugLog('[TON Connect] Already connected without matching proof, disconnecting to reconnect with tonProof');
|
|
568
608
|
yield tonConnect.disconnect();
|
|
569
609
|
this.connectedWallet = null;
|
|
570
610
|
}
|
|
@@ -17,10 +17,12 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
17
17
|
connectedChain: Chain;
|
|
18
18
|
supportedChains: Chain[];
|
|
19
19
|
canConnectViaQrCode: boolean;
|
|
20
|
+
canHandleMultipleConnections: boolean;
|
|
20
21
|
private tonConnect;
|
|
21
22
|
private tonNetworks;
|
|
22
23
|
private connectedWallet;
|
|
23
24
|
private pendingProofPayload;
|
|
25
|
+
private lastConnectionUrl;
|
|
24
26
|
/**
|
|
25
27
|
* Get the TonConnect instance (for discovering wallets and advanced usage)
|
|
26
28
|
*/
|
|
@@ -36,9 +38,13 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
36
38
|
*/
|
|
37
39
|
setupEventListeners(): void;
|
|
38
40
|
/**
|
|
39
|
-
* Check if
|
|
41
|
+
* Check if the wallet's browser extension is installed
|
|
40
42
|
*/
|
|
41
43
|
isInstalledOnBrowser(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Retry opening the wallet deep link on mobile
|
|
46
|
+
*/
|
|
47
|
+
retryDeeplinkConnection(): void;
|
|
42
48
|
/**
|
|
43
49
|
* Connect to a TON wallet
|
|
44
50
|
* @param tonProofPayload - Optional payload for tonProof authentication
|
|
@@ -120,6 +126,12 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
120
126
|
* The Cell is then serialized to base64 BOC format for TON Connect SDK
|
|
121
127
|
*/
|
|
122
128
|
encodeComment(comment: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Append a return strategy to a TonConnect universal link.
|
|
131
|
+
* The `ret` parameter tells the wallet where to redirect after approval.
|
|
132
|
+
* `back` instructs the wallet to return to the previous app (browser).
|
|
133
|
+
*/
|
|
134
|
+
private appendReturnStrategy;
|
|
123
135
|
/**
|
|
124
136
|
* Check if error is a user rejection
|
|
125
137
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
-
import { TonConnect } from '@tonconnect/sdk';
|
|
3
|
+
import { TonConnect, isWalletInfoRemote } from '@tonconnect/sdk';
|
|
4
4
|
import { Address, beginCell, Cell, loadStateInit } from '@ton/core';
|
|
5
5
|
import { TonClient, fromNano } from '@ton/ton';
|
|
6
6
|
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
7
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
7
|
+
import { PlatformService, DynamicError, isMobile } from '@dynamic-labs/utils';
|
|
8
8
|
import { TonWallet } from '../../wallet/TonWallet/TonWallet.js';
|
|
9
9
|
import { debugLogMultiline, debugLogWithLevel, debugLog } from '../../utils/debugLog/debugLog.js';
|
|
10
10
|
import { TonUiTransaction, NANOTON_PER_TON } from '../../utils/TonUiTransaction/TonUiTransaction.js';
|
|
@@ -52,9 +52,11 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
52
52
|
this.overrideKey = 'tonconnect';
|
|
53
53
|
this.connectedChain = 'TON';
|
|
54
54
|
this.supportedChains = ['TON'];
|
|
55
|
-
this.canConnectViaQrCode =
|
|
55
|
+
this.canConnectViaQrCode = false;
|
|
56
|
+
this.canHandleMultipleConnections = false;
|
|
56
57
|
this.connectedWallet = null;
|
|
57
58
|
this.pendingProofPayload = null;
|
|
59
|
+
this.lastConnectionUrl = null;
|
|
58
60
|
this.tonNetworks = opts.tonNetworks || [];
|
|
59
61
|
this.overrideKey = opts.overrideKey || 'tonconnect';
|
|
60
62
|
// Only initialize TonConnect in browser environment
|
|
@@ -105,12 +107,21 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
105
107
|
});
|
|
106
108
|
}
|
|
107
109
|
/**
|
|
108
|
-
* Check if
|
|
110
|
+
* Check if the wallet's browser extension is installed
|
|
109
111
|
*/
|
|
110
112
|
isInstalledOnBrowser() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
if (typeof window === 'undefined') {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return TonConnect.isWalletInjected(this.overrideKey);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Retry opening the wallet deep link on mobile
|
|
120
|
+
*/
|
|
121
|
+
retryDeeplinkConnection() {
|
|
122
|
+
if (this.lastConnectionUrl) {
|
|
123
|
+
PlatformService.openURL(this.lastConnectionUrl);
|
|
124
|
+
}
|
|
114
125
|
}
|
|
115
126
|
/**
|
|
116
127
|
* Connect to a TON wallet
|
|
@@ -139,6 +150,19 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
139
150
|
const connectOptions = proofPayload
|
|
140
151
|
? { request: { tonProof: proofPayload } }
|
|
141
152
|
: undefined;
|
|
153
|
+
// On mobile, use bridge connection to avoid injection attempts
|
|
154
|
+
// and open the resulting connection URL as a deep link
|
|
155
|
+
if (isMobile() && isWalletInfoRemote(matchingWallet)) {
|
|
156
|
+
const connectionUrl = tonConnect.connect({
|
|
157
|
+
bridgeUrl: matchingWallet.bridgeUrl,
|
|
158
|
+
universalLink: matchingWallet.universalLink,
|
|
159
|
+
}, connectOptions);
|
|
160
|
+
// Append return strategy so the wallet redirects back to the browser
|
|
161
|
+
const urlWithReturn = this.appendReturnStrategy(connectionUrl);
|
|
162
|
+
this.lastConnectionUrl = urlWithReturn;
|
|
163
|
+
PlatformService.openURL(urlWithReturn);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
142
166
|
tonConnect.connect(matchingWallet, connectOptions);
|
|
143
167
|
}
|
|
144
168
|
catch (error) {
|
|
@@ -178,25 +202,24 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
178
202
|
if (tonConnect.connected && ((_a = tonConnect.account) === null || _a === void 0 ? void 0 : _a.address)) {
|
|
179
203
|
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
180
204
|
}
|
|
181
|
-
// If not connected, initiate connection and wait for it to complete
|
|
205
|
+
// If not connected, initiate connection and wait for it to complete.
|
|
206
|
+
// connect() handles platform differences internally (injected provider,
|
|
207
|
+
// bridge deep link, etc.). Unlike other chain connectors whose
|
|
208
|
+
// providers return a promise that resolves on connection completion,
|
|
209
|
+
// TonConnect SDK's connect() on mobile bridge connections returns the
|
|
210
|
+
// URL synchronously and notifies later via onStatusChange. We poll
|
|
211
|
+
// until `tonConnect.connected` becomes true as a workaround.
|
|
182
212
|
try {
|
|
183
|
-
// Start the connection process (shows QR code/deep link)
|
|
184
213
|
yield this.connect();
|
|
185
|
-
// After connect() returns, the QR code is shown but connection is not yet established
|
|
186
|
-
// Wait for the connection to be established by polling or waiting for status change
|
|
187
|
-
// TON Connect SDK doesn't provide a clean way to wait, so we poll
|
|
188
214
|
const maxWaitTime = 300000; // 5 minutes
|
|
189
215
|
const pollInterval = 500; // Check every 500ms
|
|
190
216
|
const startTime = Date.now();
|
|
191
217
|
while (!tonConnect.connected && Date.now() - startTime < maxWaitTime) {
|
|
192
218
|
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
193
|
-
// Check if connected after the delay
|
|
194
219
|
if (tonConnect.connected && ((_b = tonConnect.account) === null || _b === void 0 ? void 0 : _b.address)) {
|
|
195
|
-
|
|
196
|
-
return userFriendlyAddress;
|
|
220
|
+
return this.convertAddressToUserFriendly(tonConnect.account.address);
|
|
197
221
|
}
|
|
198
222
|
}
|
|
199
|
-
// If we get here, either timeout or still not connected
|
|
200
223
|
if (!tonConnect.connected) {
|
|
201
224
|
throw new DynamicError('Connection timeout - user did not approve the connection');
|
|
202
225
|
}
|
|
@@ -526,6 +549,23 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
526
549
|
// Serialize to base64 BOC (Bag of Cells) format
|
|
527
550
|
return mainCell.toBoc().toString('base64');
|
|
528
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Append a return strategy to a TonConnect universal link.
|
|
554
|
+
* The `ret` parameter tells the wallet where to redirect after approval.
|
|
555
|
+
* `back` instructs the wallet to return to the previous app (browser).
|
|
556
|
+
*/
|
|
557
|
+
appendReturnStrategy(url) {
|
|
558
|
+
try {
|
|
559
|
+
const parsed = new URL(url);
|
|
560
|
+
parsed.searchParams.append('ret', 'back');
|
|
561
|
+
return parsed.toString();
|
|
562
|
+
}
|
|
563
|
+
catch (_a) {
|
|
564
|
+
// If URL parsing fails, append as query string manually
|
|
565
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
566
|
+
return `${url}${separator}ret=back`;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
529
569
|
/**
|
|
530
570
|
* Check if error is a user rejection
|
|
531
571
|
*/
|
|
@@ -544,10 +584,10 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
544
584
|
return __awaiter(this, void 0, void 0, function* () {
|
|
545
585
|
var _a, _b, _c, _d, _e, _f;
|
|
546
586
|
const tonConnect = this.getTonConnect();
|
|
547
|
-
// If already connected with a proof, return it
|
|
587
|
+
// If already connected with a proof that matches the requested payload, return it
|
|
548
588
|
if ((_b = (_a = this.connectedWallet) === null || _a === void 0 ? void 0 : _a.connectItems) === null || _b === void 0 ? void 0 : _b.tonProof) {
|
|
549
589
|
const { tonProof } = this.connectedWallet.connectItems;
|
|
550
|
-
if ('proof' in tonProof) {
|
|
590
|
+
if ('proof' in tonProof && tonProof.proof.payload === payload) {
|
|
551
591
|
debugLog('[TON Connect] Returning existing proof from connection');
|
|
552
592
|
return {
|
|
553
593
|
address: this.connectedWallet.account.address,
|
|
@@ -558,9 +598,9 @@ class TonConnectConnector extends WalletConnectorBase {
|
|
|
558
598
|
};
|
|
559
599
|
}
|
|
560
600
|
}
|
|
561
|
-
// If connected but no proof, disconnect and reconnect with proof
|
|
601
|
+
// If connected but no matching proof, disconnect and reconnect with new proof
|
|
562
602
|
if (tonConnect.connected) {
|
|
563
|
-
debugLog('[TON Connect] Already connected without proof, disconnecting to reconnect with tonProof');
|
|
603
|
+
debugLog('[TON Connect] Already connected without matching proof, disconnecting to reconnect with tonProof');
|
|
564
604
|
yield tonConnect.disconnect();
|
|
565
605
|
this.connectedWallet = null;
|
|
566
606
|
}
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
6
|
var TonConnectConnector = require('../../connectors/TonConnectConnector/TonConnectConnector.cjs');
|
|
8
7
|
var debugLog = require('../debugLog/debugLog.cjs');
|
|
9
8
|
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
11
9
|
/**
|
|
12
10
|
* Checks if a wallet configuration supports TON Connect.
|
|
13
11
|
*
|
|
@@ -42,10 +40,10 @@ const isValidTonConnectWallet = (wallet) => { var _a; return Boolean((_a = walle
|
|
|
42
40
|
* // Returns connectors for wallets like Tonkeeper, MyTonWallet, etc.
|
|
43
41
|
* ```
|
|
44
42
|
*/
|
|
45
|
-
const fetchTonWalletConnectors = ({ walletBook
|
|
43
|
+
const fetchTonWalletConnectors = ({ walletBook, tonNetworks = [], }) => {
|
|
46
44
|
var _a;
|
|
47
45
|
// Create connectors from wallet book entries (these provide custom metadata/icons)
|
|
48
|
-
const allWallets = Object.entries((_a = walletBook
|
|
46
|
+
const allWallets = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {});
|
|
49
47
|
const tonWallets = allWallets.filter(([_, wallet]) => isValidTonConnectWallet(wallet));
|
|
50
48
|
// Debug logging
|
|
51
49
|
debugLog.debugLogMultiline(['[TON] Total wallets in wallet book:', allWallets.length], ['[TON] TON wallets found:', tonWallets.length], ['[TON] TON wallet keys:', tonWallets.map(([key]) => key)]);
|
|
@@ -55,22 +53,8 @@ const fetchTonWalletConnectors = ({ walletBook: walletBook$1, tonNetworks = [],
|
|
|
55
53
|
return class extends TonConnectConnector.TonConnectConnector {
|
|
56
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
55
|
constructor(props) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
brandColor: undefined,
|
|
61
|
-
deepLinks: undefined,
|
|
62
|
-
downloadLinks: undefined,
|
|
63
|
-
groupKey: undefined,
|
|
64
|
-
icon: ((_a = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _a === void 0 ? void 0 : _a.spriteId)
|
|
65
|
-
? walletBook.renderTemplate('iconicUrl', wallet.brand.spriteId)
|
|
66
|
-
: '',
|
|
67
|
-
id: key,
|
|
68
|
-
name: name,
|
|
69
|
-
rdns: undefined,
|
|
70
|
-
supportedHardwareWallets: undefined,
|
|
71
|
-
walletLimitations: undefined,
|
|
72
|
-
}, overrideKey: key, tonNetworks,
|
|
73
|
-
walletBook: walletBook$1 }));
|
|
56
|
+
super(Object.assign(Object.assign({}, props), { overrideKey: key, tonNetworks,
|
|
57
|
+
walletBook }));
|
|
74
58
|
this.name = name;
|
|
75
59
|
this.overrideKey = key;
|
|
76
60
|
}
|
|
@@ -89,19 +73,8 @@ const fetchTonWalletConnectors = ({ walletBook: walletBook$1, tonNetworks = [],
|
|
|
89
73
|
class extends TonConnectConnector.TonConnectConnector {
|
|
90
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
75
|
constructor(props) {
|
|
92
|
-
super(Object.assign(Object.assign({}, props), {
|
|
93
|
-
|
|
94
|
-
deepLinks: undefined,
|
|
95
|
-
downloadLinks: undefined,
|
|
96
|
-
groupKey: undefined,
|
|
97
|
-
icon: '', // Will use default TON icon from chain icon mapping
|
|
98
|
-
id: 'tonconnect',
|
|
99
|
-
name: 'TON Connect',
|
|
100
|
-
rdns: undefined,
|
|
101
|
-
supportedHardwareWallets: undefined,
|
|
102
|
-
walletLimitations: undefined,
|
|
103
|
-
}, tonNetworks,
|
|
104
|
-
walletBook: walletBook$1 }));
|
|
76
|
+
super(Object.assign(Object.assign({}, props), { tonNetworks,
|
|
77
|
+
walletBook }));
|
|
105
78
|
this.name = 'TON Connect';
|
|
106
79
|
this.overrideKey = 'tonconnect';
|
|
107
80
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { renderTemplate } from '@dynamic-labs/wallet-book';
|
|
3
2
|
import { TonConnectConnector } from '../../connectors/TonConnectConnector/TonConnectConnector.js';
|
|
4
3
|
import { debugLogMultiline, debugLog } from '../debugLog/debugLog.js';
|
|
5
4
|
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7
5
|
/**
|
|
8
6
|
* Checks if a wallet configuration supports TON Connect.
|
|
9
7
|
*
|
|
@@ -51,21 +49,7 @@ const fetchTonWalletConnectors = ({ walletBook, tonNetworks = [], }) => {
|
|
|
51
49
|
return class extends TonConnectConnector {
|
|
52
50
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
51
|
constructor(props) {
|
|
54
|
-
|
|
55
|
-
super(Object.assign(Object.assign({}, props), { metadata: {
|
|
56
|
-
brandColor: undefined,
|
|
57
|
-
deepLinks: undefined,
|
|
58
|
-
downloadLinks: undefined,
|
|
59
|
-
groupKey: undefined,
|
|
60
|
-
icon: ((_a = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _a === void 0 ? void 0 : _a.spriteId)
|
|
61
|
-
? renderTemplate('iconicUrl', wallet.brand.spriteId)
|
|
62
|
-
: '',
|
|
63
|
-
id: key,
|
|
64
|
-
name: name,
|
|
65
|
-
rdns: undefined,
|
|
66
|
-
supportedHardwareWallets: undefined,
|
|
67
|
-
walletLimitations: undefined,
|
|
68
|
-
}, overrideKey: key, tonNetworks,
|
|
52
|
+
super(Object.assign(Object.assign({}, props), { overrideKey: key, tonNetworks,
|
|
69
53
|
walletBook }));
|
|
70
54
|
this.name = name;
|
|
71
55
|
this.overrideKey = key;
|
|
@@ -85,18 +69,7 @@ const fetchTonWalletConnectors = ({ walletBook, tonNetworks = [], }) => {
|
|
|
85
69
|
class extends TonConnectConnector {
|
|
86
70
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
71
|
constructor(props) {
|
|
88
|
-
super(Object.assign(Object.assign({}, props), {
|
|
89
|
-
brandColor: undefined,
|
|
90
|
-
deepLinks: undefined,
|
|
91
|
-
downloadLinks: undefined,
|
|
92
|
-
groupKey: undefined,
|
|
93
|
-
icon: '', // Will use default TON icon from chain icon mapping
|
|
94
|
-
id: 'tonconnect',
|
|
95
|
-
name: 'TON Connect',
|
|
96
|
-
rdns: undefined,
|
|
97
|
-
supportedHardwareWallets: undefined,
|
|
98
|
-
walletLimitations: undefined,
|
|
99
|
-
}, tonNetworks,
|
|
72
|
+
super(Object.assign(Object.assign({}, props), { tonNetworks,
|
|
100
73
|
walletBook }));
|
|
101
74
|
this.name = 'TON Connect';
|
|
102
75
|
this.overrideKey = 'tonconnect';
|
|
@@ -120,11 +120,11 @@ class DynamicWaasTonConnector extends waas.withDynamicWaas(TonWalletConnector.To
|
|
|
120
120
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
121
121
|
var _a;
|
|
122
122
|
const walletClient = yield this.getWaasWalletClient();
|
|
123
|
-
const signedSessionId = yield this.requireSignedSessionId();
|
|
124
123
|
const targetWallet = yield walletClient.getWallet({
|
|
125
124
|
accountAddress: expectedAddress,
|
|
126
125
|
authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
|
|
127
|
-
|
|
126
|
+
// TODO: This is a hack - validateActiveWallet is a no-op operation that shouldn't require nonce signing
|
|
127
|
+
signedSessionId: '',
|
|
128
128
|
});
|
|
129
129
|
if (!targetWallet) {
|
|
130
130
|
throw new utils.DynamicError('Account not found');
|
|
@@ -60,12 +60,13 @@ declare const DynamicWaasTonConnector_base: (abstract new (...args: any[]) => {
|
|
|
60
60
|
publicKeyHex: string;
|
|
61
61
|
rawPublicKey: string | Uint8Array | undefined;
|
|
62
62
|
}>;
|
|
63
|
-
importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, }: {
|
|
63
|
+
importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, password, }: {
|
|
64
64
|
privateKey: string;
|
|
65
65
|
thresholdSignatureScheme?: string | undefined;
|
|
66
66
|
publicAddressCheck?: string | undefined;
|
|
67
67
|
addressType?: string | undefined;
|
|
68
68
|
legacyWalletId?: string | undefined;
|
|
69
|
+
password?: string | undefined;
|
|
69
70
|
}): Promise<void>;
|
|
70
71
|
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
71
72
|
accountAddress?: string | undefined;
|
|
@@ -116,11 +116,11 @@ class DynamicWaasTonConnector extends withDynamicWaas(TonWalletConnector) {
|
|
|
116
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
117
|
var _a;
|
|
118
118
|
const walletClient = yield this.getWaasWalletClient();
|
|
119
|
-
const signedSessionId = yield this.requireSignedSessionId();
|
|
120
119
|
const targetWallet = yield walletClient.getWallet({
|
|
121
120
|
accountAddress: expectedAddress,
|
|
122
121
|
authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
|
|
123
|
-
|
|
122
|
+
// TODO: This is a hack - validateActiveWallet is a no-op operation that shouldn't require nonce signing
|
|
123
|
+
signedSessionId: '',
|
|
124
124
|
});
|
|
125
125
|
if (!targetWallet) {
|
|
126
126
|
throw new DynamicError('Account not found');
|