@dynamic-labs/ton 4.62.0 → 4.63.1
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 +31 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/connectors/TonConnectConnector/TonConnectConnector.cjs +394 -353
- package/src/connectors/TonConnectConnector/TonConnectConnector.d.ts +77 -92
- package/src/connectors/TonConnectConnector/TonConnectConnector.js +396 -355
- package/src/index.d.ts +0 -1
- package/src/types.d.ts +12 -8
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.cjs +23 -53
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.d.ts +4 -19
- package/src/utils/fetchTonWalletConnectors/fetchTonWalletConnectors.js +23 -53
- package/src/waas/connector/DynamicWaasTonConnector.d.ts +6 -0
- package/src/wallet/TonWallet/TonWallet.cjs +35 -11
- package/src/wallet/TonWallet/TonWallet.d.ts +10 -4
- package/src/wallet/TonWallet/TonWallet.js +35 -11
- package/src/utils/selectTonWallet/index.d.ts +0 -1
- package/src/utils/selectTonWallet/selectTonWallet.d.ts +0 -16
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
5
|
-
|
|
6
|
-
import { type SendJettonOptions, type TonConnectConnectorOpts, type TonConnectProof, type TonTransactionResult } from '../../types';
|
|
1
|
+
import { TonConnectUI } from '@tonconnect/ui';
|
|
2
|
+
import type { IUITransaction } from '@dynamic-labs/types';
|
|
3
|
+
import { TonWalletConnector } from '../../TonWalletConnector';
|
|
4
|
+
import { type SendTransactionRequest, type TonConnectConnectorOpts, type TonConnectProof } from '../../types';
|
|
5
|
+
export declare const resetSharedTonConnectUI: () => void;
|
|
7
6
|
/**
|
|
8
7
|
* TON Connect connector implementation
|
|
9
8
|
*
|
|
10
|
-
* Uses
|
|
11
|
-
*
|
|
9
|
+
* Uses @tonconnect/ui to present a wallet selection modal and handle
|
|
10
|
+
* QR codes, deep links, and bridge connections automatically.
|
|
11
|
+
* All TON connector instances share a single TonConnectUI to avoid
|
|
12
|
+
* DOM conflicts and localStorage key collisions.
|
|
12
13
|
*/
|
|
13
|
-
export declare class TonConnectConnector extends
|
|
14
|
-
ChainWallet: typeof TonWallet;
|
|
14
|
+
export declare class TonConnectConnector extends TonWalletConnector {
|
|
15
15
|
name: string;
|
|
16
16
|
overrideKey: string;
|
|
17
|
-
connectedChain: Chain;
|
|
18
|
-
supportedChains: Chain[];
|
|
19
17
|
canConnectViaQrCode: boolean;
|
|
20
18
|
canHandleMultipleConnections: boolean;
|
|
21
|
-
private
|
|
22
|
-
private tonNetworks;
|
|
19
|
+
private manifestUrl;
|
|
23
20
|
private connectedWallet;
|
|
24
21
|
private pendingProofPayload;
|
|
25
|
-
private
|
|
22
|
+
private tonConnectAppName;
|
|
23
|
+
private statusUnsubscribe;
|
|
24
|
+
private elevateCleanup;
|
|
26
25
|
/**
|
|
27
|
-
* Get the
|
|
26
|
+
* Get the shared TonConnectUI instance
|
|
28
27
|
*/
|
|
29
|
-
|
|
28
|
+
getTonConnectUI(): TonConnectUI;
|
|
30
29
|
/**
|
|
31
30
|
* Creates a new TON Connect connector
|
|
32
31
|
*
|
|
@@ -34,72 +33,54 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
34
33
|
*/
|
|
35
34
|
constructor(opts: TonConnectConnectorOpts);
|
|
36
35
|
/**
|
|
37
|
-
* Setup event listeners for
|
|
36
|
+
* Setup event listeners for TonConnect UI status changes.
|
|
37
|
+
* Filters events by wallet appName so each connector only reacts
|
|
38
|
+
* to its own wallet's status changes.
|
|
38
39
|
*/
|
|
39
40
|
setupEventListeners(): void;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* Teardown event listeners
|
|
43
|
+
*/
|
|
44
|
+
teardownEventListeners(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Always return true so the SDK proceeds to connect() instead of
|
|
47
|
+
* showing an "install extension" prompt. TonConnect UI handles
|
|
48
|
+
* wallet discovery and selection internally via its own modal.
|
|
42
49
|
*/
|
|
43
50
|
isInstalledOnBrowser(): boolean;
|
|
44
51
|
/**
|
|
45
|
-
*
|
|
52
|
+
* Re-open the TonConnect UI modal for the configured wallet.
|
|
53
|
+
* Called when the user taps "Open [WalletName]" in the mobile redirect view.
|
|
46
54
|
*/
|
|
47
55
|
retryDeeplinkConnection(): void;
|
|
48
56
|
/**
|
|
49
|
-
* Connect to a TON wallet
|
|
57
|
+
* Connect to a TON wallet via TonConnect UI modal.
|
|
58
|
+
* When tonProofPayload is provided, the proof request is bundled into
|
|
59
|
+
* the connection handshake so the wallet returns address + proof in one shot.
|
|
50
60
|
* @param tonProofPayload - Optional payload for tonProof authentication
|
|
51
61
|
*/
|
|
52
62
|
connect(tonProofPayload?: string): Promise<void>;
|
|
53
63
|
/**
|
|
54
|
-
*
|
|
55
|
-
*/
|
|
56
|
-
private findMatchingWallet;
|
|
57
|
-
/**
|
|
58
|
-
* Get the current wallet address in user-friendly format (EQ... or UQ...)
|
|
64
|
+
* Get the current wallet address in user-friendly format (EQ... or UQ...).
|
|
59
65
|
*/
|
|
60
66
|
getAddress(): Promise<string | undefined>;
|
|
61
67
|
/**
|
|
62
|
-
* Get connected accounts
|
|
68
|
+
* Get connected accounts.
|
|
69
|
+
* Awaits session restoration so a persisted session is not missed.
|
|
63
70
|
*/
|
|
64
71
|
getConnectedAccounts(): Promise<string[]>;
|
|
65
72
|
/**
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
getNetwork(): Promise<string | undefined>;
|
|
69
|
-
/**
|
|
70
|
-
* Check if current network is testnet
|
|
71
|
-
*/
|
|
72
|
-
isTestnet(): Promise<boolean>;
|
|
73
|
-
/**
|
|
74
|
-
* Sign a message
|
|
73
|
+
* Sign a message using TonConnect UI
|
|
75
74
|
*/
|
|
76
75
|
signMessage(messageToSign: string): Promise<string>;
|
|
77
76
|
/**
|
|
78
|
-
* Send a transaction
|
|
79
|
-
|
|
80
|
-
sendTransaction(request: SendTransactionRequest): Promise<TonTransactionResult>;
|
|
81
|
-
/**
|
|
82
|
-
* Send Jetton transaction
|
|
83
|
-
*/
|
|
84
|
-
sendJettonTransaction(_options: SendJettonOptions): Promise<TonTransactionResult>;
|
|
85
|
-
/**
|
|
86
|
-
* Get TonClient for the current or specified network.
|
|
87
|
-
*/
|
|
88
|
-
getTonClient(chainId?: string): TonClient;
|
|
89
|
-
/**
|
|
90
|
-
* Get balance of an address
|
|
91
|
-
*/
|
|
92
|
-
getBalance(address: string): Promise<string | undefined>;
|
|
93
|
-
/**
|
|
94
|
-
* Get enabled networks
|
|
77
|
+
* Send a transaction via TonConnect UI.
|
|
78
|
+
* Returns the BOC string from the wallet response.
|
|
95
79
|
*/
|
|
96
|
-
|
|
80
|
+
sendTransaction(request: SendTransactionRequest): Promise<string>;
|
|
97
81
|
/**
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
switchNetwork(): Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Disconnect and cleanup
|
|
82
|
+
* Disconnect and cleanup.
|
|
83
|
+
* Only disconnects if this connector owns the current connection.
|
|
103
84
|
*/
|
|
104
85
|
endSession(): Promise<void>;
|
|
105
86
|
/**
|
|
@@ -112,26 +93,34 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
112
93
|
private internalSendUiTransaction;
|
|
113
94
|
/**
|
|
114
95
|
* Convert TON address from raw format (0:hex) to user-friendly format (UQ...)
|
|
115
|
-
* TON Connect SDK expects user-friendly format for message addresses
|
|
116
96
|
*/
|
|
117
97
|
private convertAddressToUserFriendly;
|
|
118
98
|
/**
|
|
119
|
-
* Encode a comment as TON message payload
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* For long messages, the comment is split across multiple cells using references.
|
|
126
|
-
* The Cell is then serialized to base64 BOC format for TON Connect SDK
|
|
99
|
+
* Encode a comment as TON message payload.
|
|
100
|
+
* NOTE: TON cells support a maximum of 4 references per cell.
|
|
101
|
+
* Comments longer than 123 + (4 * 127) = 631 bytes will exceed
|
|
102
|
+
* this limit. Consider implementing proper snake-cell encoding
|
|
103
|
+
* for arbitrarily long comments if needed.
|
|
127
104
|
*/
|
|
128
105
|
encodeComment(comment: string): string;
|
|
129
106
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
107
|
+
* Elevate the TonConnect UI above the Dynamic auth modal and prevent
|
|
108
|
+
* the Dynamic backdrop from intercepting pointer events.
|
|
109
|
+
* Returns a cleanup function that restores the original state.
|
|
110
|
+
* Uses a MutationObserver fallback for when #tc-widget-root is created lazily.
|
|
111
|
+
*/
|
|
112
|
+
private elevateTonConnectUI;
|
|
113
|
+
/**
|
|
114
|
+
* Run and clear the elevation cleanup function
|
|
115
|
+
*/
|
|
116
|
+
private cleanupElevation;
|
|
117
|
+
/**
|
|
118
|
+
* Hook called after this wallet is selected as primary.
|
|
119
|
+
* Reconnects the shared TonConnectUI singleton to this connector's
|
|
120
|
+
* wallet so that subsequent operations (sign, send) route to the
|
|
121
|
+
* correct wallet app.
|
|
133
122
|
*/
|
|
134
|
-
|
|
123
|
+
afterWalletSelectHook(): Promise<void>;
|
|
135
124
|
/**
|
|
136
125
|
* Check if error is a user rejection
|
|
137
126
|
*/
|
|
@@ -142,40 +131,36 @@ export declare class TonConnectConnector extends WalletConnectorBase<typeof TonW
|
|
|
142
131
|
* @returns TON Connect proof object
|
|
143
132
|
*/
|
|
144
133
|
generateTonConnectProof(payload: string): Promise<TonConnectProof>;
|
|
134
|
+
/**
|
|
135
|
+
* Reconnect to a browser extension wallet directly via the JS bridge,
|
|
136
|
+
* bypassing the TonConnect modal UI. Used during proof reconnection
|
|
137
|
+
* (where the modal would fail due to internal state not being fully
|
|
138
|
+
* reset after a disconnect) and during wallet switching.
|
|
139
|
+
*/
|
|
140
|
+
private connectViaJsBridge;
|
|
145
141
|
/**
|
|
146
142
|
* Override proveOwnership to use tonProof for wallet verification
|
|
147
|
-
*
|
|
148
|
-
* For TON wallets, we use the tonProof mechanism during connection
|
|
149
|
-
* which is the standard way to prove wallet ownership in TON Connect.
|
|
150
|
-
* The backend expects a specific format with state_init and public_key.
|
|
151
143
|
*/
|
|
152
144
|
proveOwnership(address: string, messageToSign: string): Promise<string | undefined>;
|
|
153
145
|
/**
|
|
154
146
|
* proveOwnership using tonProof
|
|
155
|
-
*
|
|
156
|
-
* Returns the proof in the format expected by the backend:
|
|
157
|
-
* {
|
|
158
|
-
* address: string,
|
|
159
|
-
* proof: { domain, payload, signature, state_init, timestamp },
|
|
160
|
-
* public_key: string
|
|
161
|
-
* }
|
|
162
147
|
*/
|
|
163
148
|
private proveOwnershipWithTonProof;
|
|
164
149
|
/**
|
|
165
|
-
*
|
|
150
|
+
* Detect the wallet contract version from its code cell hash.
|
|
151
|
+
* Returns the number of bits to skip before the public key in the data cell.
|
|
166
152
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
153
|
+
* V3R2 / V4R2: seqno(32) + subwallet_id(32) + pubkey(256) → skip 64 bits
|
|
154
|
+
* V5R1: is_signature_allowed(1) + seqno(32) + wallet_id(32) + pubkey(256) → skip 65 bits
|
|
155
|
+
*/
|
|
156
|
+
private getPublicKeyBitOffset;
|
|
157
|
+
/**
|
|
158
|
+
* Extract public key from state_init cell.
|
|
159
|
+
* Detects wallet contract version to correctly locate the public key.
|
|
172
160
|
*/
|
|
173
161
|
private extractPublicKeyFromStateInit;
|
|
174
162
|
/**
|
|
175
163
|
* Extract the nonce from a SIWE-style message
|
|
176
|
-
*
|
|
177
|
-
* @param message - The full message to extract nonce from
|
|
178
|
-
* @returns A short payload suitable for tonProof
|
|
179
164
|
*/
|
|
180
165
|
private extractNonceFromMessage;
|
|
181
166
|
}
|