@dynamic-labs/ton 4.53.2 → 4.55.0

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 CHANGED
@@ -1,4 +1,21 @@
1
1
 
2
+ ## [4.55.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.54.0...v4.55.0) (2026-01-17)
3
+
4
+
5
+ ### Features
6
+
7
+ * finalize psbt in sendBitcoin function ([#10250](https://github.com/dynamic-labs/dynamic-auth/issues/10250)) ([a27bc1b](https://github.com/dynamic-labs/dynamic-auth/commit/a27bc1b16ceb99a00422a62a89c37f055d3831b7))
8
+ * update getWalletsToDelegate to include denied and dismissed wal… ([#10247](https://github.com/dynamic-labs/dynamic-auth/issues/10247)) ([cea9dfc](https://github.com/dynamic-labs/dynamic-auth/commit/cea9dfcce6f05e4dbd1192d6d0ce5ab4a0f2f115))
9
+
10
+ ## [4.54.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.53.2...v4.54.0) (2026-01-16)
11
+
12
+
13
+ ### Features
14
+
15
+ * add iCloud backup method for wallet backup ([#10221](https://github.com/dynamic-labs/dynamic-auth/issues/10221)) ([36f5b8a](https://github.com/dynamic-labs/dynamic-auth/commit/36f5b8a0df50139fabbc6d6256f396a6d40313f4))
16
+ * add iCloud backup support for wallet key shares ([#10220](https://github.com/dynamic-labs/dynamic-auth/issues/10220)) ([f5f8135](https://github.com/dynamic-labs/dynamic-auth/commit/f5f813593d6ec834fc94f873fd7151b1f3e1a0ca))
17
+ * add legacyWalletId parameter to importPrivateKey ([#10244](https://github.com/dynamic-labs/dynamic-auth/issues/10244)) ([d281dd7](https://github.com/dynamic-labs/dynamic-auth/commit/d281dd7128ac1211e8ca0b72818e109ece7b9837))
18
+
2
19
  ### [4.53.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.53.1...v4.53.2) (2026-01-16)
3
20
 
4
21
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.53.2";
6
+ var version = "4.55.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.53.2";
2
+ var version = "4.55.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ton",
3
- "version": "4.53.2",
3
+ "version": "4.55.0",
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.53.2",
22
- "@dynamic-labs/logger": "4.53.2",
21
+ "@dynamic-labs/assert-package-version": "4.55.0",
22
+ "@dynamic-labs/logger": "4.55.0",
23
23
  "@dynamic-labs/sdk-api-core": "0.0.855",
24
- "@dynamic-labs/types": "4.53.2",
25
- "@dynamic-labs/utils": "4.53.2",
26
- "@dynamic-labs/waas": "4.53.2",
27
- "@dynamic-labs/wallet-book": "4.53.2",
28
- "@dynamic-labs/wallet-connector-core": "4.53.2",
24
+ "@dynamic-labs/types": "4.55.0",
25
+ "@dynamic-labs/utils": "4.55.0",
26
+ "@dynamic-labs/waas": "4.55.0",
27
+ "@dynamic-labs/wallet-book": "4.55.0",
28
+ "@dynamic-labs/wallet-connector-core": "4.55.0",
29
29
  "@ton/core": "0.62.0",
30
30
  "@ton/crypto": "3.3.0",
31
31
  "@ton/ton": "16.0.0"
@@ -2,7 +2,7 @@ import { TonClient } from '@ton/ton';
2
2
  import { Chain, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
3
3
  import { GenericNetwork } from '@dynamic-labs/types';
4
4
  import { TonWallet } from './wallet/TonWallet';
5
- import { TonWalletConnectorOpts } from './types';
5
+ import { SendTransactionRequest, TonConnectProof, TonWalletConnectorOpts } from './types';
6
6
  /**
7
7
  * Base TonWalletConnector class for TON blockchain wallets.
8
8
  * Provides core functionality for connecting to and interacting with TON wallets.
@@ -35,4 +35,22 @@ export declare abstract class TonWalletConnector extends WalletConnectorBase<typ
35
35
  * Get the balance for a TON address.
36
36
  */
37
37
  getBalance(address: string): Promise<string | undefined>;
38
+ /**
39
+ * Signs a message with the wallet.
40
+ * @param message - The message to sign
41
+ * @returns The signature as a string
42
+ */
43
+ abstract signMessage(message: string): Promise<string>;
44
+ /**
45
+ * Sends a TON Connect transaction.
46
+ * @param request - The SendTransactionRequest containing messages to send
47
+ * @returns The transaction hash
48
+ */
49
+ abstract sendTransaction(request: SendTransactionRequest): Promise<string>;
50
+ /**
51
+ * Generates a TON Connect proof for authentication.
52
+ * @param payload - The payload string to include in the proof
53
+ * @returns Complete TON Connect proof object
54
+ */
55
+ abstract generateTonConnectProof(payload: string): Promise<TonConnectProof>;
38
56
  }
@@ -0,0 +1,13 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicWaasTonConnectors = require('./waas/DynamicWaasTonConnectors.cjs');
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ const TonWalletConnectors = () => [
10
+ ...DynamicWaasTonConnectors.DynamicWaasTonConnectors(),
11
+ ];
12
+
13
+ exports.TonWalletConnectors = TonWalletConnectors;
@@ -0,0 +1,2 @@
1
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
2
+ export declare const TonWalletConnectors: () => WalletConnectorConstructor[];
@@ -0,0 +1,9 @@
1
+ 'use client'
2
+ import { DynamicWaasTonConnectors } from './waas/DynamicWaasTonConnectors.js';
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ const TonWalletConnectors = () => [
6
+ ...DynamicWaasTonConnectors(),
7
+ ];
8
+
9
+ export { TonWalletConnectors };
package/src/index.cjs CHANGED
@@ -23,9 +23,9 @@ var generateTonConnectProofHash = require('./utils/generateTonConnectProofHash/g
23
23
  require('./utils/logger/logger.cjs');
24
24
  require('../_virtual/_tslib.cjs');
25
25
  require('@ton/ton');
26
+ var TonWalletConnectors = require('./TonWalletConnectors.cjs');
26
27
  var DynamicWaasTonConnector = require('./waas/connector/DynamicWaasTonConnector.cjs');
27
28
  var DynamicWaasTonConnectors = require('./waas/DynamicWaasTonConnectors.cjs');
28
- var DynamicWaasTonSigner = require('./waas/signer/DynamicWaasTonSigner.cjs');
29
29
 
30
30
  assertPackageVersion.assertPackageVersion('@dynamic-labs/ton', _package.version);
31
31
 
@@ -48,6 +48,6 @@ exports.executeTransaction = executeTransaction.executeTransaction;
48
48
  exports.extractDisplayInfoFromRequest = extractDisplayInfoFromRequest.extractDisplayInfoFromRequest;
49
49
  exports.convertSendTransactionRequest = convertSendTransactionRequest.convertSendTransactionRequest;
50
50
  exports.generateTonConnectProofHash = generateTonConnectProofHash.generateTonConnectProofHash;
51
+ exports.TonWalletConnectors = TonWalletConnectors.TonWalletConnectors;
51
52
  exports.DynamicWaasTonConnector = DynamicWaasTonConnector.DynamicWaasTonConnector;
52
53
  exports.DynamicWaasTonConnectors = DynamicWaasTonConnectors.DynamicWaasTonConnectors;
53
- exports.DynamicWaasTonSigner = DynamicWaasTonSigner.DynamicWaasTonSigner;
package/src/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from './types';
3
3
  export { TonWallet, isTonWallet, WaasTonWallet } from './wallet';
4
4
  export { TonUiTransaction, NANOTON_PER_TON, prepareTransaction, prepareTonTransfer, prepareJettonTransfer, getJettonWalletAddress, getWalletSeqno, executeTransaction, extractDisplayInfoFromRequest, convertSendTransactionRequest, generateTonConnectProofHash, } from './utils';
5
5
  export type { PrepareTransactionParams, PrepareTransactionResult, PrepareTonTransferParams, PrepareJettonTransferParams, GetJettonWalletAddressParams, ExecuteTransactionParams, ExecuteTransactionResult, GenerateTonConnectProofHashParams, TransactionRequestDisplayInfo, } from './utils';
6
+ export { TonWalletConnectors } from './TonWalletConnectors';
6
7
  export { DynamicWaasTonConnector } from './waas/connector/DynamicWaasTonConnector';
7
8
  export type { DynamicWaasTonConnectorProps } from './waas/connector/DynamicWaasTonConnector';
8
9
  export { DynamicWaasTonConnectors } from './waas/DynamicWaasTonConnectors';
9
- export { DynamicWaasTonSigner } from './waas/signer/DynamicWaasTonSigner';
package/src/index.js CHANGED
@@ -19,8 +19,8 @@ export { generateTonConnectProofHash } from './utils/generateTonConnectProofHash
19
19
  import './utils/logger/logger.js';
20
20
  import '../_virtual/_tslib.js';
21
21
  import '@ton/ton';
22
+ export { TonWalletConnectors } from './TonWalletConnectors.js';
22
23
  export { DynamicWaasTonConnector } from './waas/connector/DynamicWaasTonConnector.js';
23
24
  export { DynamicWaasTonConnectors } from './waas/DynamicWaasTonConnectors.js';
24
- export { DynamicWaasTonSigner } from './waas/signer/DynamicWaasTonSigner.js';
25
25
 
26
26
  assertPackageVersion('@dynamic-labs/ton', version);
@@ -14,11 +14,11 @@ var types = require('../../types.cjs');
14
14
  var convertSendTransactionRequest = require('../../utils/convertSendTransactionRequest/convertSendTransactionRequest.cjs');
15
15
  var executeTransaction = require('../../utils/executeTransaction/executeTransaction.cjs');
16
16
  var extractDisplayInfoFromRequest = require('../../utils/extractDisplayInfoFromRequest/extractDisplayInfoFromRequest.cjs');
17
+ var generateTonConnectProofHash = require('../../utils/generateTonConnectProofHash/generateTonConnectProofHash.cjs');
17
18
  var getWalletSeqno = require('../../utils/getWalletSeqno/getWalletSeqno.cjs');
18
19
  var prepareJettonTransfer = require('../../utils/prepareJettonTransfer/prepareJettonTransfer.cjs');
19
20
  var prepareTransaction = require('../../utils/prepareTransaction/prepareTransaction.cjs');
20
21
  var prepareTonTransfer = require('../../utils/prepareTonTransfer/prepareTonTransfer.cjs');
21
- var DynamicWaasTonSigner = require('../signer/DynamicWaasTonSigner.cjs');
22
22
  var logger = require('../../utils/logger/logger.cjs');
23
23
  var WaasTonWallet = require('../../wallet/WaasTonWallet.cjs');
24
24
  var isWalletDeployed = require('../../utils/isWalletDeployed/isWalletDeployed.cjs');
@@ -45,11 +45,38 @@ class DynamicWaasTonConnector extends waas.withDynamicWaas(TonWalletConnector.To
45
45
  super.setEnvironmentId(environmentId);
46
46
  logger$1.Logger.setEnvironmentId(environmentId);
47
47
  }
48
- getSigner() {
48
+ /**
49
+ * Generates a TON Connect proof for authentication.
50
+ * @param payload - The payload string to include in the proof
51
+ * @returns Complete TON Connect proof object
52
+ */
53
+ generateTonConnectProof(payload) {
49
54
  return _tslib.__awaiter(this, void 0, void 0, function* () {
50
- return new DynamicWaasTonSigner.DynamicWaasTonSigner({
51
- walletConnector: this,
55
+ if (!this.activeAccountAddress) {
56
+ throw new utils.DynamicError('Active account address is required');
57
+ }
58
+ yield this.getWaasWalletClient();
59
+ const host = utils.PlatformService.getHost();
60
+ const timestamp = Math.floor(Date.now() / 1000);
61
+ const domainLengthBytes = new TextEncoder().encode(host).length;
62
+ const domain = {
63
+ lengthBytes: domainLengthBytes,
64
+ value: host,
65
+ };
66
+ const hashHex = yield generateTonConnectProofHash.generateTonConnectProofHash({
67
+ address: this.activeAccountAddress,
68
+ domain,
69
+ payload,
70
+ timestamp,
52
71
  });
72
+ const signature = yield this.signMessage(hashHex);
73
+ return {
74
+ address: this.activeAccountAddress,
75
+ domain,
76
+ payload,
77
+ signature,
78
+ timestamp,
79
+ };
53
80
  });
54
81
  }
55
82
  getPublicKeyForAddress(walletAddress) {
@@ -3,8 +3,7 @@ import { JwtVerifiedCredential, MFAAction, SignMessageContext } from '@dynamic-l
3
3
  import { IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
4
4
  import { IDynamicWaasConnector, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
5
5
  import { TonWalletConnector } from '../../TonWalletConnector';
6
- import { SendTransactionRequest, TonWalletConnectorOpts } from '../../types';
7
- import { DynamicWaasTonSigner } from '../signer/DynamicWaasTonSigner';
6
+ import { SendTransactionRequest, TonConnectProof, TonWalletConnectorOpts } from '../../types';
8
7
  import { Logger } from '../../utils/logger/logger';
9
8
  import { WaasTonWallet } from '../../wallet/WaasTonWallet';
10
9
  export type DynamicWaasTonConnectorProps = TonWalletConnectorOpts & {
@@ -56,11 +55,12 @@ declare const DynamicWaasTonConnector_base: (abstract new (...args: any[]) => {
56
55
  publicKeyHex: string;
57
56
  rawPublicKey: string | Uint8Array | undefined;
58
57
  }>;
59
- importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, }: {
58
+ importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, }: {
60
59
  privateKey: string;
61
60
  thresholdSignatureScheme?: string | undefined;
62
61
  publicAddressCheck?: string | undefined;
63
62
  addressType?: string | undefined;
63
+ legacyWalletId?: string | undefined;
64
64
  }): Promise<void>;
65
65
  exportPrivateKey({ accountAddress, displayContainer, password, }?: {
66
66
  accountAddress?: string | undefined;
@@ -141,7 +141,12 @@ export declare class DynamicWaasTonConnector extends DynamicWaasTonConnector_bas
141
141
  * Override setEnvironmentId to ensure it's set on the global logger
142
142
  */
143
143
  setEnvironmentId(environmentId: string): void;
144
- getSigner(): Promise<DynamicWaasTonSigner>;
144
+ /**
145
+ * Generates a TON Connect proof for authentication.
146
+ * @param payload - The payload string to include in the proof
147
+ * @returns Complete TON Connect proof object
148
+ */
149
+ generateTonConnectProof(payload: string): Promise<TonConnectProof>;
145
150
  getPublicKeyForAddress(walletAddress: string): Buffer;
146
151
  getWalletClientByAddress({ accountAddress, }: {
147
152
  accountAddress: string;
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../_virtual/_tslib.js';
3
3
  import { MFAAction } from '@dynamic-labs/sdk-api-core';
4
- import { DynamicError } from '@dynamic-labs/utils';
4
+ import { DynamicError, PlatformService } from '@dynamic-labs/utils';
5
5
  import { withDynamicWaas } from '@dynamic-labs/waas';
6
6
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
7
7
  import { TonUiTransaction, NANOTON_PER_TON } from '../../utils/TonUiTransaction/TonUiTransaction.js';
@@ -10,11 +10,11 @@ import { CHAIN } from '../../types.js';
10
10
  import { convertSendTransactionRequest } from '../../utils/convertSendTransactionRequest/convertSendTransactionRequest.js';
11
11
  import { executeTransaction } from '../../utils/executeTransaction/executeTransaction.js';
12
12
  import { extractDisplayInfoFromRequest } from '../../utils/extractDisplayInfoFromRequest/extractDisplayInfoFromRequest.js';
13
+ import { generateTonConnectProofHash } from '../../utils/generateTonConnectProofHash/generateTonConnectProofHash.js';
13
14
  import { getWalletSeqno } from '../../utils/getWalletSeqno/getWalletSeqno.js';
14
15
  import { prepareJettonTransfer } from '../../utils/prepareJettonTransfer/prepareJettonTransfer.js';
15
16
  import { prepareTransaction } from '../../utils/prepareTransaction/prepareTransaction.js';
16
17
  import { prepareTonTransfer } from '../../utils/prepareTonTransfer/prepareTonTransfer.js';
17
- import { DynamicWaasTonSigner } from '../signer/DynamicWaasTonSigner.js';
18
18
  import { logger } from '../../utils/logger/logger.js';
19
19
  import { WaasTonWallet } from '../../wallet/WaasTonWallet.js';
20
20
  import { isWalletDeployed } from '../../utils/isWalletDeployed/isWalletDeployed.js';
@@ -41,11 +41,38 @@ class DynamicWaasTonConnector extends withDynamicWaas(TonWalletConnector) {
41
41
  super.setEnvironmentId(environmentId);
42
42
  Logger.setEnvironmentId(environmentId);
43
43
  }
44
- getSigner() {
44
+ /**
45
+ * Generates a TON Connect proof for authentication.
46
+ * @param payload - The payload string to include in the proof
47
+ * @returns Complete TON Connect proof object
48
+ */
49
+ generateTonConnectProof(payload) {
45
50
  return __awaiter(this, void 0, void 0, function* () {
46
- return new DynamicWaasTonSigner({
47
- walletConnector: this,
51
+ if (!this.activeAccountAddress) {
52
+ throw new DynamicError('Active account address is required');
53
+ }
54
+ yield this.getWaasWalletClient();
55
+ const host = PlatformService.getHost();
56
+ const timestamp = Math.floor(Date.now() / 1000);
57
+ const domainLengthBytes = new TextEncoder().encode(host).length;
58
+ const domain = {
59
+ lengthBytes: domainLengthBytes,
60
+ value: host,
61
+ };
62
+ const hashHex = yield generateTonConnectProofHash({
63
+ address: this.activeAccountAddress,
64
+ domain,
65
+ payload,
66
+ timestamp,
48
67
  });
68
+ const signature = yield this.signMessage(hashHex);
69
+ return {
70
+ address: this.activeAccountAddress,
71
+ domain,
72
+ payload,
73
+ signature,
74
+ timestamp,
75
+ };
49
76
  });
50
77
  }
51
78
  getPublicKeyForAddress(walletAddress) {
@@ -5,6 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
+ var prepareTonTransfer = require('../utils/prepareTonTransfer/prepareTonTransfer.cjs');
9
+ var prepareJettonTransfer = require('../utils/prepareJettonTransfer/prepareJettonTransfer.cjs');
8
10
 
9
11
  /**
10
12
  * Base TonWallet class for TON blockchain wallets.
@@ -12,13 +14,94 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
12
14
  */
13
15
  class TonWallet extends walletConnectorCore.Wallet {
14
16
  /**
15
- * Sends native TON balance to a given address.
16
- * Must be implemented by subclasses.
17
+ * Get the TonClient for interacting with the TON blockchain.
18
+ * @param chainId - Optional chain ID to get client for specific network
19
+ * @returns TonClient instance
17
20
  */
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
- sendBalance(params) {
21
+ getTonClient(chainId) {
22
+ return this._connector.getTonClient(chainId);
23
+ }
24
+ /**
25
+ * Generates a TON Connect proof for authentication.
26
+ * @param payload - The payload string to include in the proof
27
+ * @returns Complete TON Connect proof object
28
+ */
29
+ generateTonConnectProof(payload) {
20
30
  return _tslib.__awaiter(this, void 0, void 0, function* () {
21
- throw new Error('Not implemented');
31
+ yield this.sync();
32
+ return this._connector.generateTonConnectProof(payload);
33
+ });
34
+ }
35
+ /**
36
+ * Signs a message with the wallet.
37
+ * @param message - The message to sign
38
+ * @returns The signature as a string
39
+ */
40
+ signMessage(message) {
41
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
42
+ yield this.sync();
43
+ return this._connector.signMessage(message);
44
+ });
45
+ }
46
+ /**
47
+ * Sends a TON Connect transaction.
48
+ * @param request - The SendTransactionRequest containing messages to send
49
+ * @returns The transaction hash
50
+ */
51
+ sendTransaction(request) {
52
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
53
+ yield this.sync();
54
+ return this._connector.sendTransaction(request);
55
+ });
56
+ }
57
+ /**
58
+ * Sends native TON to a given address.
59
+ * @param amount - The amount in TON (will be converted to nanotons)
60
+ * @param toAddress - The recipient address
61
+ * @returns The transaction hash
62
+ */
63
+ sendBalance(_a) {
64
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
65
+ yield this.sync();
66
+ const client = this.getTonClient();
67
+ const network = (yield this._connector.getNetwork());
68
+ const request = yield prepareTonTransfer.prepareTonTransfer({
69
+ amount,
70
+ client,
71
+ network,
72
+ recipient: toAddress,
73
+ timeout: 60,
74
+ walletAddress: this.address,
75
+ });
76
+ return this.sendTransaction(request);
77
+ });
78
+ }
79
+ /**
80
+ * Sends jettons (non-native tokens) to a given address.
81
+ * @param jettonMasterAddress - The jetton master contract address
82
+ * @param recipientAddress - The recipient's main wallet address
83
+ * @param jettonAmount - Amount of jettons in base units (bigint)
84
+ * @param forwardTonAmount - TON amount to forward with notification (bigint)
85
+ * @param forwardPayload - Optional comment/memo
86
+ * @returns The transaction hash
87
+ */
88
+ sendJetton(_a) {
89
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ jettonMasterAddress, recipientAddress, jettonAmount, forwardTonAmount, forwardPayload, }) {
90
+ yield this.sync();
91
+ const client = this.getTonClient();
92
+ const network = (yield this._connector.getNetwork());
93
+ const request = yield prepareJettonTransfer.prepareJettonTransfer({
94
+ client,
95
+ forwardPayload,
96
+ forwardTonAmount,
97
+ jettonAmount,
98
+ jettonMasterAddress,
99
+ network,
100
+ recipientAddress,
101
+ timeout: 60,
102
+ walletAddress: this.address,
103
+ });
104
+ return this.sendTransaction(request);
22
105
  });
23
106
  }
24
107
  }
@@ -1,16 +1,60 @@
1
+ import { TonClient } from '@ton/ton';
1
2
  import { Wallet } from '@dynamic-labs/wallet-connector-core';
2
3
  import { TonWalletConnector } from '../TonWalletConnector';
4
+ import { SendTransactionRequest, TonConnectProof } from '../types';
3
5
  /**
4
6
  * Base TonWallet class for TON blockchain wallets.
5
7
  * Provides core functionality for interacting with TON wallets.
6
8
  */
7
9
  export declare class TonWallet extends Wallet<TonWalletConnector> {
8
10
  /**
9
- * Sends native TON balance to a given address.
10
- * Must be implemented by subclasses.
11
+ * Get the TonClient for interacting with the TON blockchain.
12
+ * @param chainId - Optional chain ID to get client for specific network
13
+ * @returns TonClient instance
11
14
  */
12
- sendBalance(params: {
15
+ getTonClient(chainId?: string): TonClient;
16
+ /**
17
+ * Generates a TON Connect proof for authentication.
18
+ * @param payload - The payload string to include in the proof
19
+ * @returns Complete TON Connect proof object
20
+ */
21
+ generateTonConnectProof(payload: string): Promise<TonConnectProof>;
22
+ /**
23
+ * Signs a message with the wallet.
24
+ * @param message - The message to sign
25
+ * @returns The signature as a string
26
+ */
27
+ signMessage(message: string): Promise<string>;
28
+ /**
29
+ * Sends a TON Connect transaction.
30
+ * @param request - The SendTransactionRequest containing messages to send
31
+ * @returns The transaction hash
32
+ */
33
+ sendTransaction(request: SendTransactionRequest): Promise<string>;
34
+ /**
35
+ * Sends native TON to a given address.
36
+ * @param amount - The amount in TON (will be converted to nanotons)
37
+ * @param toAddress - The recipient address
38
+ * @returns The transaction hash
39
+ */
40
+ sendBalance({ amount, toAddress, }: {
13
41
  amount: string;
14
42
  toAddress: string;
15
43
  }): Promise<string | undefined>;
44
+ /**
45
+ * Sends jettons (non-native tokens) to a given address.
46
+ * @param jettonMasterAddress - The jetton master contract address
47
+ * @param recipientAddress - The recipient's main wallet address
48
+ * @param jettonAmount - Amount of jettons in base units (bigint)
49
+ * @param forwardTonAmount - TON amount to forward with notification (bigint)
50
+ * @param forwardPayload - Optional comment/memo
51
+ * @returns The transaction hash
52
+ */
53
+ sendJetton({ jettonMasterAddress, recipientAddress, jettonAmount, forwardTonAmount, forwardPayload, }: {
54
+ jettonMasterAddress: string;
55
+ recipientAddress: string;
56
+ jettonAmount: bigint;
57
+ forwardTonAmount: bigint;
58
+ forwardPayload?: string;
59
+ }): Promise<string>;
16
60
  }
@@ -1,6 +1,8 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { Wallet } from '@dynamic-labs/wallet-connector-core';
4
+ import { prepareTonTransfer } from '../utils/prepareTonTransfer/prepareTonTransfer.js';
5
+ import { prepareJettonTransfer } from '../utils/prepareJettonTransfer/prepareJettonTransfer.js';
4
6
 
5
7
  /**
6
8
  * Base TonWallet class for TON blockchain wallets.
@@ -8,13 +10,94 @@ import { Wallet } from '@dynamic-labs/wallet-connector-core';
8
10
  */
9
11
  class TonWallet extends Wallet {
10
12
  /**
11
- * Sends native TON balance to a given address.
12
- * Must be implemented by subclasses.
13
+ * Get the TonClient for interacting with the TON blockchain.
14
+ * @param chainId - Optional chain ID to get client for specific network
15
+ * @returns TonClient instance
13
16
  */
14
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
- sendBalance(params) {
17
+ getTonClient(chainId) {
18
+ return this._connector.getTonClient(chainId);
19
+ }
20
+ /**
21
+ * Generates a TON Connect proof for authentication.
22
+ * @param payload - The payload string to include in the proof
23
+ * @returns Complete TON Connect proof object
24
+ */
25
+ generateTonConnectProof(payload) {
16
26
  return __awaiter(this, void 0, void 0, function* () {
17
- throw new Error('Not implemented');
27
+ yield this.sync();
28
+ return this._connector.generateTonConnectProof(payload);
29
+ });
30
+ }
31
+ /**
32
+ * Signs a message with the wallet.
33
+ * @param message - The message to sign
34
+ * @returns The signature as a string
35
+ */
36
+ signMessage(message) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ yield this.sync();
39
+ return this._connector.signMessage(message);
40
+ });
41
+ }
42
+ /**
43
+ * Sends a TON Connect transaction.
44
+ * @param request - The SendTransactionRequest containing messages to send
45
+ * @returns The transaction hash
46
+ */
47
+ sendTransaction(request) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ yield this.sync();
50
+ return this._connector.sendTransaction(request);
51
+ });
52
+ }
53
+ /**
54
+ * Sends native TON to a given address.
55
+ * @param amount - The amount in TON (will be converted to nanotons)
56
+ * @param toAddress - The recipient address
57
+ * @returns The transaction hash
58
+ */
59
+ sendBalance(_a) {
60
+ return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
61
+ yield this.sync();
62
+ const client = this.getTonClient();
63
+ const network = (yield this._connector.getNetwork());
64
+ const request = yield prepareTonTransfer({
65
+ amount,
66
+ client,
67
+ network,
68
+ recipient: toAddress,
69
+ timeout: 60,
70
+ walletAddress: this.address,
71
+ });
72
+ return this.sendTransaction(request);
73
+ });
74
+ }
75
+ /**
76
+ * Sends jettons (non-native tokens) to a given address.
77
+ * @param jettonMasterAddress - The jetton master contract address
78
+ * @param recipientAddress - The recipient's main wallet address
79
+ * @param jettonAmount - Amount of jettons in base units (bigint)
80
+ * @param forwardTonAmount - TON amount to forward with notification (bigint)
81
+ * @param forwardPayload - Optional comment/memo
82
+ * @returns The transaction hash
83
+ */
84
+ sendJetton(_a) {
85
+ return __awaiter(this, arguments, void 0, function* ({ jettonMasterAddress, recipientAddress, jettonAmount, forwardTonAmount, forwardPayload, }) {
86
+ yield this.sync();
87
+ const client = this.getTonClient();
88
+ const network = (yield this._connector.getNetwork());
89
+ const request = yield prepareJettonTransfer({
90
+ client,
91
+ forwardPayload,
92
+ forwardTonAmount,
93
+ jettonAmount,
94
+ jettonMasterAddress,
95
+ network,
96
+ recipientAddress,
97
+ timeout: 60,
98
+ walletAddress: this.address,
99
+ });
100
+ return this.sendTransaction(request);
18
101
  });
19
102
  }
20
103
  }
@@ -3,32 +3,12 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var _tslib = require('../../_virtual/_tslib.cjs');
7
6
  var TonWallet = require('./TonWallet.cjs');
8
7
 
9
8
  /**
10
9
  * WaaS-specific TON wallet.
11
10
  */
12
11
  class WaasTonWallet extends TonWallet.TonWallet {
13
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
- sendBalance(params) {
15
- return _tslib.__awaiter(this, void 0, void 0, function* () {
16
- throw new Error('Not implemented');
17
- });
18
- }
19
- getSigner() {
20
- return _tslib.__awaiter(this, void 0, void 0, function* () {
21
- const connector = this._connector;
22
- yield connector.getWalletClientByAddress({
23
- accountAddress: this.address,
24
- });
25
- const signer = yield connector.getSigner();
26
- if (!signer) {
27
- throw new Error('Unable to retrieve TON signer');
28
- }
29
- return signer;
30
- });
31
- }
32
12
  }
33
13
 
34
14
  exports.WaasTonWallet = WaasTonWallet;
@@ -1,12 +1,6 @@
1
- import { DynamicWaasTonSigner } from '../waas/signer/DynamicWaasTonSigner';
2
1
  import { TonWallet } from './TonWallet';
3
2
  /**
4
3
  * WaaS-specific TON wallet.
5
4
  */
6
5
  export declare class WaasTonWallet extends TonWallet {
7
- sendBalance(params: {
8
- amount: string;
9
- toAddress: string;
10
- }): Promise<string | undefined>;
11
- getSigner(): Promise<DynamicWaasTonSigner>;
12
6
  }
@@ -1,30 +1,10 @@
1
1
  'use client'
2
- import { __awaiter } from '../../_virtual/_tslib.js';
3
2
  import { TonWallet } from './TonWallet.js';
4
3
 
5
4
  /**
6
5
  * WaaS-specific TON wallet.
7
6
  */
8
7
  class WaasTonWallet extends TonWallet {
9
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
- sendBalance(params) {
11
- return __awaiter(this, void 0, void 0, function* () {
12
- throw new Error('Not implemented');
13
- });
14
- }
15
- getSigner() {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const connector = this._connector;
18
- yield connector.getWalletClientByAddress({
19
- accountAddress: this.address,
20
- });
21
- const signer = yield connector.getSigner();
22
- if (!signer) {
23
- throw new Error('Unable to retrieve TON signer');
24
- }
25
- return signer;
26
- });
27
- }
28
8
  }
29
9
 
30
10
  export { WaasTonWallet };
@@ -1,56 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _tslib = require('../../../_virtual/_tslib.cjs');
7
- var utils = require('@dynamic-labs/utils');
8
- var generateTonConnectProofHash = require('../../utils/generateTonConnectProofHash/generateTonConnectProofHash.cjs');
9
-
10
- /**
11
- * Signer implementation for DynamicWaasTonConnector
12
- */
13
- class DynamicWaasTonSigner {
14
- constructor({ walletConnector, }) {
15
- this.walletConnector = walletConnector;
16
- this.accountAddress = this.walletConnector.activeAccountAddress;
17
- }
18
- /**
19
- * Generates a TON Connect proof by constructing the proof message,
20
- * hashing it according to TON Connect spec, and signing it.
21
- *
22
- * @param payload - The payload string to include in the proof
23
- * @returns Complete TON Connect proof object
24
- */
25
- generateTonConnectProof(payload) {
26
- return _tslib.__awaiter(this, void 0, void 0, function* () {
27
- if (!this.accountAddress) {
28
- throw new Error('Active account address is required');
29
- }
30
- yield this.walletConnector.getWaasWalletClient();
31
- const host = utils.PlatformService.getHost();
32
- const timestamp = Math.floor(Date.now() / 1000);
33
- const domainLengthBytes = new TextEncoder().encode(host).length;
34
- const domain = {
35
- lengthBytes: domainLengthBytes,
36
- value: host,
37
- };
38
- const hashHex = yield generateTonConnectProofHash.generateTonConnectProofHash({
39
- address: this.accountAddress,
40
- domain,
41
- payload,
42
- timestamp,
43
- });
44
- const signature = yield this.walletConnector.signMessage(hashHex);
45
- return {
46
- address: this.accountAddress,
47
- domain,
48
- payload,
49
- signature,
50
- timestamp,
51
- };
52
- });
53
- }
54
- }
55
-
56
- exports.DynamicWaasTonSigner = DynamicWaasTonSigner;
@@ -1,20 +0,0 @@
1
- import { TonConnectProof } from '../../types';
2
- import { DynamicWaasTonConnector } from '../connector/DynamicWaasTonConnector';
3
- /**
4
- * Signer implementation for DynamicWaasTonConnector
5
- */
6
- export declare class DynamicWaasTonSigner {
7
- private readonly accountAddress;
8
- private walletConnector;
9
- constructor({ walletConnector, }: {
10
- walletConnector: DynamicWaasTonConnector;
11
- });
12
- /**
13
- * Generates a TON Connect proof by constructing the proof message,
14
- * hashing it according to TON Connect spec, and signing it.
15
- *
16
- * @param payload - The payload string to include in the proof
17
- * @returns Complete TON Connect proof object
18
- */
19
- generateTonConnectProof(payload: string): Promise<TonConnectProof>;
20
- }
@@ -1,52 +0,0 @@
1
- 'use client'
2
- import { __awaiter } from '../../../_virtual/_tslib.js';
3
- import { PlatformService } from '@dynamic-labs/utils';
4
- import { generateTonConnectProofHash } from '../../utils/generateTonConnectProofHash/generateTonConnectProofHash.js';
5
-
6
- /**
7
- * Signer implementation for DynamicWaasTonConnector
8
- */
9
- class DynamicWaasTonSigner {
10
- constructor({ walletConnector, }) {
11
- this.walletConnector = walletConnector;
12
- this.accountAddress = this.walletConnector.activeAccountAddress;
13
- }
14
- /**
15
- * Generates a TON Connect proof by constructing the proof message,
16
- * hashing it according to TON Connect spec, and signing it.
17
- *
18
- * @param payload - The payload string to include in the proof
19
- * @returns Complete TON Connect proof object
20
- */
21
- generateTonConnectProof(payload) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!this.accountAddress) {
24
- throw new Error('Active account address is required');
25
- }
26
- yield this.walletConnector.getWaasWalletClient();
27
- const host = PlatformService.getHost();
28
- const timestamp = Math.floor(Date.now() / 1000);
29
- const domainLengthBytes = new TextEncoder().encode(host).length;
30
- const domain = {
31
- lengthBytes: domainLengthBytes,
32
- value: host,
33
- };
34
- const hashHex = yield generateTonConnectProofHash({
35
- address: this.accountAddress,
36
- domain,
37
- payload,
38
- timestamp,
39
- });
40
- const signature = yield this.walletConnector.signMessage(hashHex);
41
- return {
42
- address: this.accountAddress,
43
- domain,
44
- payload,
45
- signature,
46
- timestamp,
47
- };
48
- });
49
- }
50
- }
51
-
52
- export { DynamicWaasTonSigner };