@dynamic-labs/ton 4.52.4 → 4.53.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -5
  5. package/src/TonWalletConnector.cjs +87 -0
  6. package/src/TonWalletConnector.d.ts +38 -0
  7. package/src/TonWalletConnector.js +83 -0
  8. package/src/index.cjs +40 -0
  9. package/src/index.d.ts +9 -1
  10. package/src/index.js +20 -0
  11. package/src/types.cjs +13 -0
  12. package/src/types.d.ts +80 -4
  13. package/src/types.js +11 -0
  14. package/src/utils/convertSendTransactionRequest/convertSendTransactionRequest.cjs +117 -0
  15. package/src/utils/convertSendTransactionRequest/convertSendTransactionRequest.d.ts +9 -0
  16. package/src/utils/convertSendTransactionRequest/convertSendTransactionRequest.js +113 -0
  17. package/src/utils/convertSendTransactionRequest/index.d.ts +1 -0
  18. package/src/utils/createWalletStateInit/createWalletStateInit.cjs +23 -0
  19. package/src/utils/createWalletStateInit/createWalletStateInit.d.ts +15 -0
  20. package/src/utils/createWalletStateInit/createWalletStateInit.js +19 -0
  21. package/src/utils/createWalletStateInit/index.d.ts +1 -0
  22. package/src/utils/executeTransaction/executeTransaction.cjs +51 -0
  23. package/src/utils/executeTransaction/executeTransaction.d.ts +28 -0
  24. package/src/utils/executeTransaction/executeTransaction.js +47 -0
  25. package/src/utils/executeTransaction/index.d.ts +1 -0
  26. package/src/utils/extractDisplayInfoFromRequest/extractDisplayInfoFromRequest.cjs +51 -0
  27. package/src/utils/extractDisplayInfoFromRequest/extractDisplayInfoFromRequest.d.ts +18 -0
  28. package/src/utils/extractDisplayInfoFromRequest/extractDisplayInfoFromRequest.js +47 -0
  29. package/src/utils/extractDisplayInfoFromRequest/index.d.ts +1 -0
  30. package/src/utils/generateTonConnectProofHash/generateTonConnectProofHash.cjs +89 -0
  31. package/src/utils/generateTonConnectProofHash/generateTonConnectProofHash.d.ts +24 -0
  32. package/src/utils/generateTonConnectProofHash/generateTonConnectProofHash.js +85 -0
  33. package/src/utils/generateTonConnectProofHash/index.d.ts +1 -0
  34. package/src/utils/getJettonWalletAddress/getJettonWalletAddress.cjs +32 -0
  35. package/src/utils/getJettonWalletAddress/getJettonWalletAddress.d.ts +17 -0
  36. package/src/utils/getJettonWalletAddress/getJettonWalletAddress.js +28 -0
  37. package/src/utils/getJettonWalletAddress/index.d.ts +1 -0
  38. package/src/utils/getWalletSeqno/getWalletSeqno.cjs +22 -0
  39. package/src/utils/getWalletSeqno/getWalletSeqno.d.ts +9 -0
  40. package/src/utils/getWalletSeqno/getWalletSeqno.js +18 -0
  41. package/src/utils/getWalletSeqno/index.d.ts +1 -0
  42. package/src/utils/index.d.ts +13 -1
  43. package/src/utils/isWalletDeployed/index.d.ts +1 -0
  44. package/src/utils/isWalletDeployed/isWalletDeployed.cjs +22 -0
  45. package/src/utils/isWalletDeployed/isWalletDeployed.d.ts +14 -0
  46. package/src/utils/isWalletDeployed/isWalletDeployed.js +18 -0
  47. package/src/utils/logger/logger.cjs +14 -0
  48. package/src/utils/logger/logger.d.ts +3 -0
  49. package/src/utils/logger/logger.js +7 -0
  50. package/src/utils/prepareJettonTransfer/index.d.ts +1 -0
  51. package/src/utils/prepareJettonTransfer/prepareJettonTransfer.cjs +78 -0
  52. package/src/utils/prepareJettonTransfer/prepareJettonTransfer.d.ts +31 -0
  53. package/src/utils/prepareJettonTransfer/prepareJettonTransfer.js +74 -0
  54. package/src/utils/prepareTonTransfer/index.d.ts +1 -0
  55. package/src/utils/prepareTonTransfer/prepareTonTransfer.cjs +45 -0
  56. package/src/utils/prepareTonTransfer/prepareTonTransfer.d.ts +23 -0
  57. package/src/utils/prepareTonTransfer/prepareTonTransfer.js +41 -0
  58. package/src/utils/prepareTransaction/index.d.ts +1 -0
  59. package/src/utils/prepareTransaction/prepareTransaction.cjs +74 -0
  60. package/src/utils/prepareTransaction/prepareTransaction.d.ts +32 -0
  61. package/src/utils/prepareTransaction/prepareTransaction.js +70 -0
  62. package/src/waas/DynamicWaasTonConnectors.cjs +12 -0
  63. package/src/waas/DynamicWaasTonConnectors.d.ts +2 -0
  64. package/src/waas/DynamicWaasTonConnectors.js +8 -0
  65. package/src/waas/connector/DynamicWaasTonConnector.cjs +293 -0
  66. package/src/waas/connector/DynamicWaasTonConnector.d.ts +160 -0
  67. package/src/waas/connector/DynamicWaasTonConnector.js +289 -0
  68. package/src/waas/signer/DynamicWaasTonSigner.cjs +56 -0
  69. package/src/waas/signer/DynamicWaasTonSigner.d.ts +20 -0
  70. package/src/waas/signer/DynamicWaasTonSigner.js +52 -0
  71. package/src/wallet/TonWallet.cjs +26 -0
  72. package/src/wallet/TonWallet.d.ts +16 -0
  73. package/src/wallet/TonWallet.js +22 -0
  74. package/src/wallet/WaasTonWallet.cjs +34 -0
  75. package/src/wallet/WaasTonWallet.d.ts +12 -0
  76. package/src/wallet/WaasTonWallet.js +30 -0
  77. package/src/wallet/index.d.ts +3 -0
  78. package/src/wallet/isTonWallet/index.d.ts +1 -0
  79. package/src/wallet/isTonWallet/isTonWallet.cjs +8 -0
  80. package/src/wallet/isTonWallet/isTonWallet.d.ts +3 -0
  81. package/src/wallet/isTonWallet/isTonWallet.js +4 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,34 @@
1
1
 
2
+ ## [4.53.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.52.5...v4.53.0) (2026-01-13)
3
+
4
+
5
+ ### Features
6
+
7
+ * add contract deployment bundle into first transaction ([#10089](https://github.com/dynamic-labs/dynamic-auth/issues/10089)) ([1291f2a](https://github.com/dynamic-labs/dynamic-auth/commit/1291f2ae2d4881c047a3e6e4e6cf4281a868f626))
8
+ * add ton balance to wallet connector ([#10186](https://github.com/dynamic-labs/dynamic-auth/issues/10186)) ([7b1bdf3](https://github.com/dynamic-labs/dynamic-auth/commit/7b1bdf38f9685cb74974de0592e0e824146d343d))
9
+ * add waas btc support in demo ([#10192](https://github.com/dynamic-labs/dynamic-auth/issues/10192)) ([36aedd6](https://github.com/dynamic-labs/dynamic-auth/commit/36aedd614b7fe781c7150efb4c1a77a5fe55a1ae))
10
+ * merge waas-bitcoin to existing bitcoin package ([#10190](https://github.com/dynamic-labs/dynamic-auth/issues/10190)) ([70dfc6b](https://github.com/dynamic-labs/dynamic-auth/commit/70dfc6baca4f69af56a10ad29faca0fb361ec17b))
11
+ * update sdk-react-core to support btc from waas ([#10191](https://github.com/dynamic-labs/dynamic-auth/issues/10191)) ([c39a99c](https://github.com/dynamic-labs/dynamic-auth/commit/c39a99c544e567a75f43e9b83d4969b70d3c01d1))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * udpate ESM compatibility issues in build scripts for iconic ([#10201](https://github.com/dynamic-labs/dynamic-auth/issues/10201)) ([55059ad](https://github.com/dynamic-labs/dynamic-auth/commit/55059ad8c874b7f04699c277467242783f5d6eff))
17
+
18
+ ### [4.52.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.52.4...v4.52.5) (2026-01-08)
19
+
20
+
21
+ ### Features
22
+
23
+ * add generate ton connect proof method to demo v2 ([#9989](https://github.com/dynamic-labs/dynamic-auth/issues/9989)) ([9727e2e](https://github.com/dynamic-labs/dynamic-auth/commit/9727e2e25742c4a2b0345c8c4a83159cc88892d7))
24
+ * add waas ton to demo v2 ([#9988](https://github.com/dynamic-labs/dynamic-auth/issues/9988)) ([8edda43](https://github.com/dynamic-labs/dynamic-auth/commit/8edda43aeb58b5a77aef197d6cf20c1b633d1610))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * trigger onAuthSuccess callback for passkey MFA flows ([#10174](https://github.com/dynamic-labs/dynamic-auth/issues/10174)) ([a37753a](https://github.com/dynamic-labs/dynamic-auth/commit/a37753afd6f3b814198d2acf6dc267feb11021e2))
30
+ * **wallet-book:** add mobile app IDs for Binance Wallet to fix mobile filtering ([#10176](https://github.com/dynamic-labs/dynamic-auth/issues/10176)) ([010a48f](https://github.com/dynamic-labs/dynamic-auth/commit/010a48fd28a49861a26b9188babe4a174cefeedb))
31
+
2
32
  ### [4.52.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.52.3...v4.52.4) (2026-01-07)
3
33
 
4
34
  ### [4.52.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.52.2...v4.52.3) (2026-01-06)
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.52.4";
6
+ var version = "4.53.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.52.4";
2
+ var version = "4.53.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.52.4",
3
+ "version": "4.53.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,10 +18,16 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/assert-package-version": "4.52.4",
22
- "@dynamic-labs/types": "4.52.4",
23
- "@dynamic-labs/utils": "4.52.4",
24
- "@dynamic-labs/wallet-connector-core": "4.52.4",
21
+ "@dynamic-labs/assert-package-version": "4.53.0",
22
+ "@dynamic-labs/logger": "4.53.0",
23
+ "@dynamic-labs/sdk-api-core": "0.0.843",
24
+ "@dynamic-labs/types": "4.53.0",
25
+ "@dynamic-labs/utils": "4.53.0",
26
+ "@dynamic-labs/waas": "4.53.0",
27
+ "@dynamic-labs/wallet-book": "4.53.0",
28
+ "@dynamic-labs/wallet-connector-core": "4.53.0",
29
+ "@ton/core": "0.62.0",
30
+ "@ton/crypto": "3.3.0",
25
31
  "@ton/ton": "16.0.0"
26
32
  }
27
33
  }
@@ -0,0 +1,87 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../_virtual/_tslib.cjs');
7
+ var ton = require('@ton/ton');
8
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
+ var utils = require('@dynamic-labs/utils');
10
+ var TonWallet = require('./wallet/TonWallet.cjs');
11
+ var types = require('./types.cjs');
12
+
13
+ /**
14
+ * Base TonWalletConnector class for TON blockchain wallets.
15
+ * Provides core functionality for connecting to and interacting with TON wallets.
16
+ */
17
+ class TonWalletConnector extends walletConnectorCore.WalletConnectorBase {
18
+ constructor(opts) {
19
+ super(opts);
20
+ this.ChainWallet = TonWallet.TonWallet;
21
+ this.connectedChain = 'TON';
22
+ this.supportedChains = ['TON'];
23
+ this.tonNetworks = opts.tonNetworks;
24
+ }
25
+ /**
26
+ * Get the enabled networks for the wallet.
27
+ * Networks are configured via project settings.
28
+ */
29
+ getEnabledNetworks() {
30
+ return this.tonNetworks;
31
+ }
32
+ /**
33
+ * Get the current network ID.
34
+ * Returns the first network's networkId as default.
35
+ */
36
+ getNetwork() {
37
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
38
+ var _a, _b, _c;
39
+ return ((_c = (_b = (_a = this.tonNetworks) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.networkId) === null || _c === void 0 ? void 0 : _c.toString()) || types.CHAIN.MAINNET;
40
+ });
41
+ }
42
+ /**
43
+ * Get the currently selected network.
44
+ */
45
+ getSelectedNetwork() {
46
+ var _a;
47
+ return (_a = this.tonNetworks) === null || _a === void 0 ? void 0 : _a[0];
48
+ }
49
+ /**
50
+ * Get TonClient for the current or specified network.
51
+ */
52
+ getTonClient(chainId) {
53
+ var _a, _b, _c;
54
+ const selectedNetwork = this.getSelectedNetwork();
55
+ const targetChainId = chainId || (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.chainId);
56
+ const network = chainId
57
+ ? (_a = this.tonNetworks) === null || _a === void 0 ? void 0 : _a.find((net) => net.chainId === targetChainId)
58
+ : selectedNetwork;
59
+ if (!network) {
60
+ throw new utils.DynamicError(`Network configuration not found for chainId: ${targetChainId}`);
61
+ }
62
+ const endpoint = ((_b = network.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b[0]) || ((_c = network.rpcUrls) === null || _c === void 0 ? void 0 : _c[0]);
63
+ if (!endpoint) {
64
+ throw new utils.DynamicError(`No RPC endpoint found for chainId: ${targetChainId}`);
65
+ }
66
+ return new ton.TonClient({ endpoint });
67
+ }
68
+ /**
69
+ * Get the balance for a TON address.
70
+ */
71
+ getBalance(address) {
72
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
73
+ try {
74
+ const client = this.getTonClient();
75
+ const tonAddress = ton.Address.parse(address);
76
+ const balanceNano = yield client.getBalance(tonAddress);
77
+ return ton.fromNano(balanceNano);
78
+ }
79
+ catch (error) {
80
+ walletConnectorCore.logger.error('Error fetching TON balance', { address, error });
81
+ return undefined;
82
+ }
83
+ });
84
+ }
85
+ }
86
+
87
+ exports.TonWalletConnector = TonWalletConnector;
@@ -0,0 +1,38 @@
1
+ import { TonClient } from '@ton/ton';
2
+ import { Chain, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
3
+ import { GenericNetwork } from '@dynamic-labs/types';
4
+ import { TonWallet } from './wallet/TonWallet';
5
+ import { TonWalletConnectorOpts } from './types';
6
+ /**
7
+ * Base TonWalletConnector class for TON blockchain wallets.
8
+ * Provides core functionality for connecting to and interacting with TON wallets.
9
+ */
10
+ export declare abstract class TonWalletConnector extends WalletConnectorBase<typeof TonWallet> {
11
+ ChainWallet: typeof TonWallet;
12
+ connectedChain: Chain;
13
+ supportedChains: Chain[];
14
+ tonNetworks: GenericNetwork[];
15
+ constructor(opts: TonWalletConnectorOpts);
16
+ /**
17
+ * Get the enabled networks for the wallet.
18
+ * Networks are configured via project settings.
19
+ */
20
+ getEnabledNetworks(): GenericNetwork[];
21
+ /**
22
+ * Get the current network ID.
23
+ * Returns the first network's networkId as default.
24
+ */
25
+ getNetwork(): Promise<string | undefined>;
26
+ /**
27
+ * Get the currently selected network.
28
+ */
29
+ getSelectedNetwork(): GenericNetwork | undefined;
30
+ /**
31
+ * Get TonClient for the current or specified network.
32
+ */
33
+ getTonClient(chainId?: string): TonClient;
34
+ /**
35
+ * Get the balance for a TON address.
36
+ */
37
+ getBalance(address: string): Promise<string | undefined>;
38
+ }
@@ -0,0 +1,83 @@
1
+ 'use client'
2
+ import { __awaiter } from '../_virtual/_tslib.js';
3
+ import { TonClient, Address, fromNano } from '@ton/ton';
4
+ import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
5
+ import { DynamicError } from '@dynamic-labs/utils';
6
+ import { TonWallet } from './wallet/TonWallet.js';
7
+ import { CHAIN } from './types.js';
8
+
9
+ /**
10
+ * Base TonWalletConnector class for TON blockchain wallets.
11
+ * Provides core functionality for connecting to and interacting with TON wallets.
12
+ */
13
+ class TonWalletConnector extends WalletConnectorBase {
14
+ constructor(opts) {
15
+ super(opts);
16
+ this.ChainWallet = TonWallet;
17
+ this.connectedChain = 'TON';
18
+ this.supportedChains = ['TON'];
19
+ this.tonNetworks = opts.tonNetworks;
20
+ }
21
+ /**
22
+ * Get the enabled networks for the wallet.
23
+ * Networks are configured via project settings.
24
+ */
25
+ getEnabledNetworks() {
26
+ return this.tonNetworks;
27
+ }
28
+ /**
29
+ * Get the current network ID.
30
+ * Returns the first network's networkId as default.
31
+ */
32
+ getNetwork() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ var _a, _b, _c;
35
+ return ((_c = (_b = (_a = this.tonNetworks) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.networkId) === null || _c === void 0 ? void 0 : _c.toString()) || CHAIN.MAINNET;
36
+ });
37
+ }
38
+ /**
39
+ * Get the currently selected network.
40
+ */
41
+ getSelectedNetwork() {
42
+ var _a;
43
+ return (_a = this.tonNetworks) === null || _a === void 0 ? void 0 : _a[0];
44
+ }
45
+ /**
46
+ * Get TonClient for the current or specified network.
47
+ */
48
+ getTonClient(chainId) {
49
+ var _a, _b, _c;
50
+ const selectedNetwork = this.getSelectedNetwork();
51
+ const targetChainId = chainId || (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.chainId);
52
+ const network = chainId
53
+ ? (_a = this.tonNetworks) === null || _a === void 0 ? void 0 : _a.find((net) => net.chainId === targetChainId)
54
+ : selectedNetwork;
55
+ if (!network) {
56
+ throw new DynamicError(`Network configuration not found for chainId: ${targetChainId}`);
57
+ }
58
+ const endpoint = ((_b = network.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b[0]) || ((_c = network.rpcUrls) === null || _c === void 0 ? void 0 : _c[0]);
59
+ if (!endpoint) {
60
+ throw new DynamicError(`No RPC endpoint found for chainId: ${targetChainId}`);
61
+ }
62
+ return new TonClient({ endpoint });
63
+ }
64
+ /**
65
+ * Get the balance for a TON address.
66
+ */
67
+ getBalance(address) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ try {
70
+ const client = this.getTonClient();
71
+ const tonAddress = Address.parse(address);
72
+ const balanceNano = yield client.getBalance(tonAddress);
73
+ return fromNano(balanceNano);
74
+ }
75
+ catch (error) {
76
+ logger.error('Error fetching TON balance', { address, error });
77
+ return undefined;
78
+ }
79
+ });
80
+ }
81
+ }
82
+
83
+ export { TonWalletConnector };
package/src/index.cjs CHANGED
@@ -5,9 +5,49 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var assertPackageVersion = require('@dynamic-labs/assert-package-version');
7
7
  var _package = require('../package.cjs');
8
+ var TonWalletConnector = require('./TonWalletConnector.cjs');
9
+ var types = require('./types.cjs');
10
+ var TonWallet = require('./wallet/TonWallet.cjs');
11
+ var isTonWallet = require('./wallet/isTonWallet/isTonWallet.cjs');
12
+ var WaasTonWallet = require('./wallet/WaasTonWallet.cjs');
8
13
  var TonUiTransaction = require('./utils/TonUiTransaction/TonUiTransaction.cjs');
14
+ var prepareTransaction = require('./utils/prepareTransaction/prepareTransaction.cjs');
15
+ var prepareTonTransfer = require('./utils/prepareTonTransfer/prepareTonTransfer.cjs');
16
+ var prepareJettonTransfer = require('./utils/prepareJettonTransfer/prepareJettonTransfer.cjs');
17
+ var getJettonWalletAddress = require('./utils/getJettonWalletAddress/getJettonWalletAddress.cjs');
18
+ var getWalletSeqno = require('./utils/getWalletSeqno/getWalletSeqno.cjs');
19
+ var executeTransaction = require('./utils/executeTransaction/executeTransaction.cjs');
20
+ var extractDisplayInfoFromRequest = require('./utils/extractDisplayInfoFromRequest/extractDisplayInfoFromRequest.cjs');
21
+ var convertSendTransactionRequest = require('./utils/convertSendTransactionRequest/convertSendTransactionRequest.cjs');
22
+ var generateTonConnectProofHash = require('./utils/generateTonConnectProofHash/generateTonConnectProofHash.cjs');
23
+ require('./utils/logger/logger.cjs');
24
+ require('../_virtual/_tslib.cjs');
25
+ require('@ton/ton');
26
+ var DynamicWaasTonConnector = require('./waas/connector/DynamicWaasTonConnector.cjs');
27
+ var DynamicWaasTonConnectors = require('./waas/DynamicWaasTonConnectors.cjs');
28
+ var DynamicWaasTonSigner = require('./waas/signer/DynamicWaasTonSigner.cjs');
9
29
 
10
30
  assertPackageVersion.assertPackageVersion('@dynamic-labs/ton', _package.version);
11
31
 
32
+ exports.TonWalletConnector = TonWalletConnector.TonWalletConnector;
33
+ Object.defineProperty(exports, 'CHAIN', {
34
+ enumerable: true,
35
+ get: function () { return types.CHAIN; }
36
+ });
37
+ exports.TonWallet = TonWallet.TonWallet;
38
+ exports.isTonWallet = isTonWallet.isTonWallet;
39
+ exports.WaasTonWallet = WaasTonWallet.WaasTonWallet;
12
40
  exports.NANOTON_PER_TON = TonUiTransaction.NANOTON_PER_TON;
13
41
  exports.TonUiTransaction = TonUiTransaction.TonUiTransaction;
42
+ exports.prepareTransaction = prepareTransaction.prepareTransaction;
43
+ exports.prepareTonTransfer = prepareTonTransfer.prepareTonTransfer;
44
+ exports.prepareJettonTransfer = prepareJettonTransfer.prepareJettonTransfer;
45
+ exports.getJettonWalletAddress = getJettonWalletAddress.getJettonWalletAddress;
46
+ exports.getWalletSeqno = getWalletSeqno.getWalletSeqno;
47
+ exports.executeTransaction = executeTransaction.executeTransaction;
48
+ exports.extractDisplayInfoFromRequest = extractDisplayInfoFromRequest.extractDisplayInfoFromRequest;
49
+ exports.convertSendTransactionRequest = convertSendTransactionRequest.convertSendTransactionRequest;
50
+ exports.generateTonConnectProofHash = generateTonConnectProofHash.generateTonConnectProofHash;
51
+ exports.DynamicWaasTonConnector = DynamicWaasTonConnector.DynamicWaasTonConnector;
52
+ exports.DynamicWaasTonConnectors = DynamicWaasTonConnectors.DynamicWaasTonConnectors;
53
+ exports.DynamicWaasTonSigner = DynamicWaasTonSigner.DynamicWaasTonSigner;
package/src/index.d.ts CHANGED
@@ -1 +1,9 @@
1
- export * from './utils';
1
+ export { TonWalletConnector } from './TonWalletConnector';
2
+ export * from './types';
3
+ export { TonWallet, isTonWallet, WaasTonWallet } from './wallet';
4
+ export { TonUiTransaction, NANOTON_PER_TON, prepareTransaction, prepareTonTransfer, prepareJettonTransfer, getJettonWalletAddress, getWalletSeqno, executeTransaction, extractDisplayInfoFromRequest, convertSendTransactionRequest, generateTonConnectProofHash, } from './utils';
5
+ export type { PrepareTransactionParams, PrepareTransactionResult, PrepareTonTransferParams, PrepareJettonTransferParams, GetJettonWalletAddressParams, ExecuteTransactionParams, ExecuteTransactionResult, GenerateTonConnectProofHashParams, TransactionRequestDisplayInfo, } from './utils';
6
+ export { DynamicWaasTonConnector } from './waas/connector/DynamicWaasTonConnector';
7
+ export type { DynamicWaasTonConnectorProps } from './waas/connector/DynamicWaasTonConnector';
8
+ export { DynamicWaasTonConnectors } from './waas/DynamicWaasTonConnectors';
9
+ export { DynamicWaasTonSigner } from './waas/signer/DynamicWaasTonSigner';
package/src/index.js CHANGED
@@ -1,6 +1,26 @@
1
1
  'use client'
2
2
  import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
3
3
  import { version } from '../package.js';
4
+ export { TonWalletConnector } from './TonWalletConnector.js';
5
+ export { CHAIN } from './types.js';
6
+ export { TonWallet } from './wallet/TonWallet.js';
7
+ export { isTonWallet } from './wallet/isTonWallet/isTonWallet.js';
8
+ export { WaasTonWallet } from './wallet/WaasTonWallet.js';
4
9
  export { NANOTON_PER_TON, TonUiTransaction } from './utils/TonUiTransaction/TonUiTransaction.js';
10
+ export { prepareTransaction } from './utils/prepareTransaction/prepareTransaction.js';
11
+ export { prepareTonTransfer } from './utils/prepareTonTransfer/prepareTonTransfer.js';
12
+ export { prepareJettonTransfer } from './utils/prepareJettonTransfer/prepareJettonTransfer.js';
13
+ export { getJettonWalletAddress } from './utils/getJettonWalletAddress/getJettonWalletAddress.js';
14
+ export { getWalletSeqno } from './utils/getWalletSeqno/getWalletSeqno.js';
15
+ export { executeTransaction } from './utils/executeTransaction/executeTransaction.js';
16
+ export { extractDisplayInfoFromRequest } from './utils/extractDisplayInfoFromRequest/extractDisplayInfoFromRequest.js';
17
+ export { convertSendTransactionRequest } from './utils/convertSendTransactionRequest/convertSendTransactionRequest.js';
18
+ export { generateTonConnectProofHash } from './utils/generateTonConnectProofHash/generateTonConnectProofHash.js';
19
+ import './utils/logger/logger.js';
20
+ import '../_virtual/_tslib.js';
21
+ import '@ton/ton';
22
+ export { DynamicWaasTonConnector } from './waas/connector/DynamicWaasTonConnector.js';
23
+ export { DynamicWaasTonConnectors } from './waas/DynamicWaasTonConnectors.js';
24
+ export { DynamicWaasTonSigner } from './waas/signer/DynamicWaasTonSigner.js';
5
25
 
6
26
  assertPackageVersion('@dynamic-labs/ton', version);
package/src/types.cjs ADDED
@@ -0,0 +1,13 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Network chain identifier for TON
8
+ */
9
+ exports.CHAIN = void 0;
10
+ (function (CHAIN) {
11
+ CHAIN["MAINNET"] = "-239";
12
+ CHAIN["TESTNET"] = "-3";
13
+ })(exports.CHAIN || (exports.CHAIN = {}));
package/src/types.d.ts CHANGED
@@ -1,6 +1,82 @@
1
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
2
+ import { WalletMetadata } from '@dynamic-labs/wallet-connector-core';
3
+ import { GenericNetwork } from '@dynamic-labs/types';
1
4
  /**
2
- * Type definitions for TON (The Open Network) blockchain integration.
3
- *
4
- * This file will contain type definitions for TON-specific types,
5
- * interfaces, and utilities as the package is developed.
5
+ * Domain information for TON Connect protocol
6
6
  */
7
+ export interface TonConnectDomain {
8
+ /** Length of domain value in bytes */
9
+ lengthBytes: number;
10
+ /** Domain value (e.g., example.com) */
11
+ value: string;
12
+ }
13
+ /**
14
+ * Complete TON Connect proof object
15
+ */
16
+ export interface TonConnectProof {
17
+ /** Wallet address string */
18
+ address: string;
19
+ /** Domain information */
20
+ domain: TonConnectDomain;
21
+ /** Unix timestamp in seconds */
22
+ timestamp: number;
23
+ /** Payload string */
24
+ payload: string;
25
+ /** Signature as base64 string */
26
+ signature: string;
27
+ }
28
+ /**
29
+ * Network chain identifier for TON
30
+ */
31
+ export declare enum CHAIN {
32
+ MAINNET = "-239",
33
+ TESTNET = "-3"
34
+ }
35
+ /**
36
+ * TON Connect compatible transaction request
37
+ * @see https://ton-connect.github.io/sdk/interfaces/_tonconnect_ui.SendTransactionRequest.html
38
+ */
39
+ export interface SendTransactionRequest {
40
+ /** The sender address from which DApp intends to send the transaction */
41
+ from?: string;
42
+ /** Messages to send */
43
+ messages: {
44
+ /** Receiver's address */
45
+ address: string;
46
+ /** Amount to send in nanoTon */
47
+ amount: string;
48
+ /** Extra currencies to send */
49
+ extraCurrency?: {
50
+ [k: number]: string;
51
+ };
52
+ /** Contract specific data to add to the transaction (base64 encoded BOC) */
53
+ payload?: string;
54
+ /** Contract specific data to add to the transaction (base64 encoded BOC) */
55
+ stateInit?: string;
56
+ }[];
57
+ /** The network where DApp intends to send the transaction */
58
+ network?: CHAIN;
59
+ /** Sending transaction deadline in unix epoch seconds */
60
+ validUntil: number;
61
+ }
62
+ /**
63
+ * Generic transaction data used internally for signing and execution
64
+ */
65
+ export interface TonTransactionData {
66
+ /** Sender wallet address */
67
+ address: string;
68
+ /** Current wallet seqno */
69
+ seqno: number;
70
+ /** Base64-encoded message body (the transaction to be signed) */
71
+ messageBody: string;
72
+ /** Transaction timeout in seconds */
73
+ timeout: number;
74
+ }
75
+ /**
76
+ * Options for creating a TonWalletConnector
77
+ */
78
+ export type TonWalletConnectorOpts = {
79
+ walletBook: WalletBookSchema;
80
+ tonNetworks: GenericNetwork[];
81
+ metadata?: WalletMetadata;
82
+ };
package/src/types.js ADDED
@@ -0,0 +1,11 @@
1
+ 'use client'
2
+ /**
3
+ * Network chain identifier for TON
4
+ */
5
+ var CHAIN;
6
+ (function (CHAIN) {
7
+ CHAIN["MAINNET"] = "-239";
8
+ CHAIN["TESTNET"] = "-3";
9
+ })(CHAIN || (CHAIN = {}));
10
+
11
+ export { CHAIN };
@@ -0,0 +1,117 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var ton = require('@ton/ton');
7
+ var core = require('@ton/core');
8
+
9
+ /**
10
+ * Parses a base64 BOC payload into a Cell
11
+ *
12
+ * @param payload - Base64 encoded BOC string
13
+ * @returns Parsed Cell
14
+ */
15
+ const parsePayload = (payload) => {
16
+ if (!payload) {
17
+ return ton.beginCell().endCell();
18
+ }
19
+ try {
20
+ return ton.Cell.fromBase64(payload);
21
+ }
22
+ catch (e) {
23
+ throw new Error(`Invalid payload BOC: ${e instanceof Error ? e.message : String(e)}`);
24
+ }
25
+ };
26
+ /**
27
+ * Parses a base64 BOC stateInit into code and data cells
28
+ *
29
+ * @param stateInit - Base64 encoded BOC string
30
+ * @returns Object with code and data cells, or undefined if no stateInit
31
+ */
32
+ const parseStateInit = (stateInit) => {
33
+ if (!stateInit) {
34
+ return undefined;
35
+ }
36
+ try {
37
+ const stateInitCell = ton.Cell.fromBase64(stateInit);
38
+ const slice = stateInitCell.beginParse();
39
+ slice.skip(2); // skip split_depth and special flags
40
+ return {
41
+ code: slice.loadRef(),
42
+ data: slice.loadRef(),
43
+ };
44
+ }
45
+ catch (e) {
46
+ throw new Error(`Invalid stateInit BOC: ${e instanceof Error ? e.message : String(e)}`);
47
+ }
48
+ };
49
+ /**
50
+ * Determines the bounce flag from address format
51
+ *
52
+ * In base64 user-friendly format:
53
+ * - Bounceable addresses start with: EQ (mainnet) or kQ (testnet)
54
+ * - Non-bounceable addresses start with: UQ (mainnet) or 0Q (testnet)
55
+ * Default to true (bounceable) for safety with smart contracts
56
+ *
57
+ * @param address - TON address string
58
+ * @returns Boolean bounce flag
59
+ */
60
+ // Non-bounceable addresses start with UQ (mainnet) or 0Q (testnet)
61
+ // All other formats (EQ, kQ, raw) default to bounceable
62
+ const determineBounceFlag = (address) => !address.startsWith('UQ') && !address.startsWith('0Q');
63
+ /**
64
+ * Creates an internal message object
65
+ *
66
+ * @param destAddr - Destination address
67
+ * @param amount - Amount in nanotons
68
+ * @param body - Message body cell
69
+ * @param bounce - Bounce flag
70
+ * @param init - Optional state init with code and data
71
+ * @returns Internal message object
72
+ */
73
+ const createInternalMessage = (destAddr, amount, body, bounce, init) => (Object.assign({ body, info: {
74
+ bounce,
75
+ bounced: false,
76
+ createdAt: 0,
77
+ createdLt: BigInt(0),
78
+ dest: destAddr,
79
+ forwardFee: BigInt(0),
80
+ ihrDisabled: true,
81
+ ihrFee: BigInt(0),
82
+ src: null,
83
+ type: 'internal',
84
+ value: { coins: amount },
85
+ } }, (init && { init })));
86
+ /**
87
+ * Creates an OutActionSendMsg from an internal message
88
+ *
89
+ * @param internalMessage - The internal message object
90
+ * @returns OutActionSendMsg action
91
+ */
92
+ const createSendMsgAction = (internalMessage) => ({
93
+ mode: core.SendMode.PAY_GAS_SEPARATELY | core.SendMode.IGNORE_ERRORS,
94
+ outMsg: internalMessage,
95
+ type: 'sendMsg',
96
+ });
97
+ /**
98
+ * Converts a TON Connect SendTransactionRequest to internal actions array
99
+ *
100
+ * @param request - TON Connect transaction request
101
+ * @returns Array of OutActionSendMsg actions
102
+ */
103
+ const convertSendTransactionRequest = (request) => {
104
+ const actions = [];
105
+ for (const msg of request.messages) {
106
+ const destAddr = ton.Address.parse(msg.address);
107
+ const amount = BigInt(msg.amount);
108
+ const body = parsePayload(msg.payload);
109
+ const init = parseStateInit(msg.stateInit);
110
+ const bounce = determineBounceFlag(msg.address);
111
+ const internalMessage = createInternalMessage(destAddr, amount, body, bounce, init);
112
+ actions.push(createSendMsgAction(internalMessage));
113
+ }
114
+ return actions;
115
+ };
116
+
117
+ exports.convertSendTransactionRequest = convertSendTransactionRequest;
@@ -0,0 +1,9 @@
1
+ import { OutActionSendMsg } from '@ton/core';
2
+ import { SendTransactionRequest } from '../../types';
3
+ /**
4
+ * Converts a TON Connect SendTransactionRequest to internal actions array
5
+ *
6
+ * @param request - TON Connect transaction request
7
+ * @returns Array of OutActionSendMsg actions
8
+ */
9
+ export declare const convertSendTransactionRequest: (request: SendTransactionRequest) => OutActionSendMsg[];