@dynamic-labs/ton 4.79.1 → 4.80.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,20 @@
1
1
 
2
+ ## [4.80.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.79.2...v4.80.0) (2026-05-05)
3
+
4
+
5
+ ### Features
6
+
7
+ * **aleo:** Aleo wallet connectors + send/shield token registries + UI transaction type ([#11101](https://github.com/dynamic-labs/dynamic-auth/issues/11101)) ([5478d9c](https://github.com/dynamic-labs/dynamic-auth/commit/5478d9c21ee065e2e6c8e96d37ab17b74c5aa0f8))
8
+ * **midnight:** add address query methods and getProvider to InjectedWalletBase ([#11082](https://github.com/dynamic-labs/dynamic-auth/issues/11082)) ([9b6a870](https://github.com/dynamic-labs/dynamic-auth/commit/9b6a8709f83d04673e9dbe23bb0caae5827b036c))
9
+ * **ton:** recognize v3R1/v3R2/v4 wallets in TonConnect proof verification ([#11130](https://github.com/dynamic-labs/dynamic-auth/issues/11130)) ([6c40ab1](https://github.com/dynamic-labs/dynamic-auth/commit/6c40ab11e56d56e278aeb5ee2ae982a42767b5cb))
10
+
11
+ ### [4.79.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.79.1...v4.79.2) (2026-05-04)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **react-native:** remove extra react-native turbo modules instructions ([#11126](https://github.com/dynamic-labs/dynamic-auth/issues/11126))
17
+
2
18
  ### [4.79.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.79.0...v4.79.1) (2026-05-01)
3
19
 
4
20
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.79.1";
6
+ var version = "4.80.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.79.1";
2
+ var version = "4.80.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.79.1",
3
+ "version": "4.80.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,15 +18,15 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs-sdk/client": "0.26.2",
22
- "@dynamic-labs/assert-package-version": "4.79.1",
23
- "@dynamic-labs/logger": "4.79.1",
24
- "@dynamic-labs/sdk-api-core": "0.0.956",
25
- "@dynamic-labs/types": "4.79.1",
26
- "@dynamic-labs/utils": "4.79.1",
27
- "@dynamic-labs/waas": "4.79.1",
28
- "@dynamic-labs/wallet-book": "4.79.1",
29
- "@dynamic-labs/wallet-connector-core": "4.79.1",
21
+ "@dynamic-labs-sdk/client": "0.26.9",
22
+ "@dynamic-labs/assert-package-version": "4.80.0",
23
+ "@dynamic-labs/logger": "4.80.0",
24
+ "@dynamic-labs/sdk-api-core": "0.0.964",
25
+ "@dynamic-labs/types": "4.80.0",
26
+ "@dynamic-labs/utils": "4.80.0",
27
+ "@dynamic-labs/waas": "4.80.0",
28
+ "@dynamic-labs/wallet-book": "4.80.0",
29
+ "@dynamic-labs/wallet-connector-core": "4.80.0",
30
30
  "@ton/core": "0.62.0",
31
31
  "@ton/crypto": "3.3.0",
32
32
  "@ton/ton": "16.0.0",
@@ -13,6 +13,7 @@ var debugLog = require('../../utils/debugLog/debugLog.cjs');
13
13
  var TonUiTransaction = require('../../utils/TonUiTransaction/TonUiTransaction.cjs');
14
14
  var prepareTonTransfer = require('../../utils/prepareTonTransfer/prepareTonTransfer.cjs');
15
15
  var prepareJettonTransfer = require('../../utils/prepareJettonTransfer/prepareJettonTransfer.cjs');
16
+ var walletVersion = require('../../utils/walletVersion/walletVersion.cjs');
16
17
 
17
18
  const DYNAMIC_MODAL_Z_INDEX = 2147483646;
18
19
  const CONNECTION_TIMEOUT_MS = 30000;
@@ -723,31 +724,6 @@ class TonConnectConnector extends TonWalletConnector.TonWalletConnector {
723
724
  });
724
725
  });
725
726
  }
726
- /**
727
- * Detect the wallet contract version from its code cell hash.
728
- * Returns the number of bits to skip before the public key in the data cell.
729
- *
730
- * V3R2 / V4R2: seqno(32) + subwallet_id(32) + pubkey(256) → skip 64 bits
731
- * V5R1: is_signature_allowed(1) + seqno(32) + wallet_id(32) + pubkey(256) → skip 65 bits
732
- */
733
- getPublicKeyBitOffset(codeCell) {
734
- const codeHash = codeCell.hash().toString('hex');
735
- // Known V5R1 code hashes (mainnet and testnet)
736
- const V5R1_CODE_HASHES = new Set([
737
- '2e39545f25bdc993f3bc2c1f5a3db09c1f30b70e3dd35c7ef3c25a12764fe4d0', // v5r1
738
- '20cbb8a4c59a2521eb6e890a04b27d4f72827646a0b4bc9e20d04d8ff49e2a00', // v5 beta
739
- ]);
740
- if (V5R1_CODE_HASHES.has(codeHash)) {
741
- // V5R1: 1 bit (is_signature_allowed) + 32 bits (seqno) + 32 bits (wallet_id)
742
- return 65;
743
- }
744
- // V3R2, V4R2, and other standard wallets: 32 bits (seqno) + 32 bits (subwallet_id)
745
- return 64;
746
- }
747
- /**
748
- * Extract public key from state_init cell.
749
- * Detects wallet contract version to correctly locate the public key.
750
- */
751
727
  extractPublicKeyFromStateInit(stateInitBase64) {
752
728
  try {
753
729
  const cell = core.Cell.fromBase64(stateInitBase64);
@@ -760,7 +736,14 @@ class TonConnectConnector extends TonWalletConnector.TonWalletConnector {
760
736
  if (!codeCell) {
761
737
  throw new Error('No code cell in state_init');
762
738
  }
763
- const bitOffset = this.getPublicKeyBitOffset(codeCell);
739
+ const version = walletVersion.identifyWalletVersion(codeCell);
740
+ // Unrecognized wallet contracts fall back to the v3/v4 layout (64-bit
741
+ // prefix), matching the pre-registry behavior so wallets shipped after
742
+ // this code's @ton/ton pin (e.g. future v6) still authenticate.
743
+ const bitOffset = version ? walletVersion.getPublicKeyBitOffset(version) : 64;
744
+ if (!version) {
745
+ debugLog.debugLog('[TON Connect] Unknown wallet code hash, falling back to 64-bit pubkey offset:', codeCell.hash().toString('hex'));
746
+ }
764
747
  const dataSlice = dataCell.beginParse();
765
748
  dataSlice.skip(bitOffset);
766
749
  const publicKeyBuffer = dataSlice.loadBuffer(32);
@@ -146,18 +146,6 @@ export declare class TonConnectConnector extends TonWalletConnector {
146
146
  * proveOwnership using tonProof
147
147
  */
148
148
  private proveOwnershipWithTonProof;
149
- /**
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.
152
- *
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.
160
- */
161
149
  private extractPublicKeyFromStateInit;
162
150
  /**
163
151
  * Extract the nonce from a SIWE-style message
@@ -9,6 +9,7 @@ import { debugLogMultiline, debugLogWithLevel, debugLog } from '../../utils/debu
9
9
  import { TonUiTransaction, NANOTON_PER_TON } from '../../utils/TonUiTransaction/TonUiTransaction.js';
10
10
  import { prepareTonTransfer } from '../../utils/prepareTonTransfer/prepareTonTransfer.js';
11
11
  import { prepareJettonTransfer } from '../../utils/prepareJettonTransfer/prepareJettonTransfer.js';
12
+ import { identifyWalletVersion, getPublicKeyBitOffset } from '../../utils/walletVersion/walletVersion.js';
12
13
 
13
14
  const DYNAMIC_MODAL_Z_INDEX = 2147483646;
14
15
  const CONNECTION_TIMEOUT_MS = 30000;
@@ -719,31 +720,6 @@ class TonConnectConnector extends TonWalletConnector {
719
720
  });
720
721
  });
721
722
  }
722
- /**
723
- * Detect the wallet contract version from its code cell hash.
724
- * Returns the number of bits to skip before the public key in the data cell.
725
- *
726
- * V3R2 / V4R2: seqno(32) + subwallet_id(32) + pubkey(256) → skip 64 bits
727
- * V5R1: is_signature_allowed(1) + seqno(32) + wallet_id(32) + pubkey(256) → skip 65 bits
728
- */
729
- getPublicKeyBitOffset(codeCell) {
730
- const codeHash = codeCell.hash().toString('hex');
731
- // Known V5R1 code hashes (mainnet and testnet)
732
- const V5R1_CODE_HASHES = new Set([
733
- '2e39545f25bdc993f3bc2c1f5a3db09c1f30b70e3dd35c7ef3c25a12764fe4d0', // v5r1
734
- '20cbb8a4c59a2521eb6e890a04b27d4f72827646a0b4bc9e20d04d8ff49e2a00', // v5 beta
735
- ]);
736
- if (V5R1_CODE_HASHES.has(codeHash)) {
737
- // V5R1: 1 bit (is_signature_allowed) + 32 bits (seqno) + 32 bits (wallet_id)
738
- return 65;
739
- }
740
- // V3R2, V4R2, and other standard wallets: 32 bits (seqno) + 32 bits (subwallet_id)
741
- return 64;
742
- }
743
- /**
744
- * Extract public key from state_init cell.
745
- * Detects wallet contract version to correctly locate the public key.
746
- */
747
723
  extractPublicKeyFromStateInit(stateInitBase64) {
748
724
  try {
749
725
  const cell = Cell.fromBase64(stateInitBase64);
@@ -756,7 +732,14 @@ class TonConnectConnector extends TonWalletConnector {
756
732
  if (!codeCell) {
757
733
  throw new Error('No code cell in state_init');
758
734
  }
759
- const bitOffset = this.getPublicKeyBitOffset(codeCell);
735
+ const version = identifyWalletVersion(codeCell);
736
+ // Unrecognized wallet contracts fall back to the v3/v4 layout (64-bit
737
+ // prefix), matching the pre-registry behavior so wallets shipped after
738
+ // this code's @ton/ton pin (e.g. future v6) still authenticate.
739
+ const bitOffset = version ? getPublicKeyBitOffset(version) : 64;
740
+ if (!version) {
741
+ debugLog('[TON Connect] Unknown wallet code hash, falling back to 64-bit pubkey offset:', codeCell.hash().toString('hex'));
742
+ }
760
743
  const dataSlice = dataCell.beginParse();
761
744
  dataSlice.skip(bitOffset);
762
745
  const publicKeyBuffer = dataSlice.loadBuffer(32);
package/src/index.cjs CHANGED
@@ -26,6 +26,7 @@ var generateTonConnectProofHash = require('./utils/generateTonConnectProofHash/g
26
26
  require('./utils/logger/logger.cjs');
27
27
  require('../_virtual/_tslib.cjs');
28
28
  require('@ton/ton');
29
+ require('./utils/walletVersion/walletVersion.cjs');
29
30
  var DynamicWaasTonConnector = require('./waas/connector/DynamicWaasTonConnector.cjs');
30
31
 
31
32
  assertPackageVersion.assertPackageVersion('@dynamic-labs/ton', _package.version);
package/src/index.js CHANGED
@@ -23,6 +23,7 @@ export { generateTonConnectProofHash } from './utils/generateTonConnectProofHash
23
23
  import './utils/logger/logger.js';
24
24
  import '../_virtual/_tslib.js';
25
25
  import '@ton/ton';
26
+ import './utils/walletVersion/walletVersion.js';
26
27
  export { DynamicWaasTonConnector } from './waas/connector/DynamicWaasTonConnector.js';
27
28
 
28
29
  assertPackageVersion('@dynamic-labs/ton', version);
@@ -12,3 +12,4 @@ export * from './logger/logger';
12
12
  export * from './isWalletDeployed/isWalletDeployed';
13
13
  export * from './createWalletStateInit/createWalletStateInit';
14
14
  export * from './debugLog';
15
+ export * from './walletVersion/walletVersion';
@@ -0,0 +1,62 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var ton = require('@ton/ton');
7
+
8
+ const PUBKEY_BIT_OFFSET_V5 = 65;
9
+ const PUBKEY_BIT_OFFSET_V3_V4 = 64;
10
+ const DUMMY_PUBLIC_KEY = Buffer.alloc(32);
11
+ const DEFAULT_WORKCHAIN = 0;
12
+ const codeHashHex = (init) => init.code.hash().toString('hex');
13
+ const buildCodeHashRegistry = () => new Map([
14
+ [
15
+ codeHashHex(ton.WalletContractV3R1.create({
16
+ publicKey: DUMMY_PUBLIC_KEY,
17
+ workchain: DEFAULT_WORKCHAIN,
18
+ }).init),
19
+ 'v3R1',
20
+ ],
21
+ [
22
+ codeHashHex(ton.WalletContractV3R2.create({
23
+ publicKey: DUMMY_PUBLIC_KEY,
24
+ workchain: DEFAULT_WORKCHAIN,
25
+ }).init),
26
+ 'v3R2',
27
+ ],
28
+ [
29
+ codeHashHex(ton.WalletContractV4.create({
30
+ publicKey: DUMMY_PUBLIC_KEY,
31
+ workchain: DEFAULT_WORKCHAIN,
32
+ }).init),
33
+ 'v4R2',
34
+ ],
35
+ [
36
+ codeHashHex(ton.WalletContractV5Beta.create({ publicKey: DUMMY_PUBLIC_KEY }).init),
37
+ 'v5Beta',
38
+ ],
39
+ [
40
+ codeHashHex(ton.WalletContractV5R1.create({
41
+ publicKey: DUMMY_PUBLIC_KEY,
42
+ workchain: DEFAULT_WORKCHAIN,
43
+ }).init),
44
+ 'v5R1',
45
+ ],
46
+ ]);
47
+ const WALLET_CODE_HASHES = buildCodeHashRegistry();
48
+ const identifyWalletVersion = (codeCell) => {
49
+ var _a;
50
+ const hash = codeCell.hash().toString('hex');
51
+ return (_a = WALLET_CODE_HASHES.get(hash)) !== null && _a !== void 0 ? _a : null;
52
+ };
53
+ const getPublicKeyBitOffset = (version) => {
54
+ if (version === 'v5R1' || version === 'v5Beta') {
55
+ return PUBKEY_BIT_OFFSET_V5;
56
+ }
57
+ return PUBKEY_BIT_OFFSET_V3_V4;
58
+ };
59
+
60
+ exports.WALLET_CODE_HASHES = WALLET_CODE_HASHES;
61
+ exports.getPublicKeyBitOffset = getPublicKeyBitOffset;
62
+ exports.identifyWalletVersion = identifyWalletVersion;
@@ -0,0 +1,5 @@
1
+ import type { Cell } from '@ton/core';
2
+ export type TonWalletVersion = 'v3R1' | 'v3R2' | 'v4R2' | 'v5Beta' | 'v5R1';
3
+ export declare const WALLET_CODE_HASHES: ReadonlyMap<string, TonWalletVersion>;
4
+ export declare const identifyWalletVersion: (codeCell: Cell) => TonWalletVersion | null;
5
+ export declare const getPublicKeyBitOffset: (version: TonWalletVersion) => number;
@@ -0,0 +1,56 @@
1
+ 'use client'
2
+ import { WalletContractV3R1, WalletContractV3R2, WalletContractV4, WalletContractV5Beta, WalletContractV5R1 } from '@ton/ton';
3
+
4
+ const PUBKEY_BIT_OFFSET_V5 = 65;
5
+ const PUBKEY_BIT_OFFSET_V3_V4 = 64;
6
+ const DUMMY_PUBLIC_KEY = Buffer.alloc(32);
7
+ const DEFAULT_WORKCHAIN = 0;
8
+ const codeHashHex = (init) => init.code.hash().toString('hex');
9
+ const buildCodeHashRegistry = () => new Map([
10
+ [
11
+ codeHashHex(WalletContractV3R1.create({
12
+ publicKey: DUMMY_PUBLIC_KEY,
13
+ workchain: DEFAULT_WORKCHAIN,
14
+ }).init),
15
+ 'v3R1',
16
+ ],
17
+ [
18
+ codeHashHex(WalletContractV3R2.create({
19
+ publicKey: DUMMY_PUBLIC_KEY,
20
+ workchain: DEFAULT_WORKCHAIN,
21
+ }).init),
22
+ 'v3R2',
23
+ ],
24
+ [
25
+ codeHashHex(WalletContractV4.create({
26
+ publicKey: DUMMY_PUBLIC_KEY,
27
+ workchain: DEFAULT_WORKCHAIN,
28
+ }).init),
29
+ 'v4R2',
30
+ ],
31
+ [
32
+ codeHashHex(WalletContractV5Beta.create({ publicKey: DUMMY_PUBLIC_KEY }).init),
33
+ 'v5Beta',
34
+ ],
35
+ [
36
+ codeHashHex(WalletContractV5R1.create({
37
+ publicKey: DUMMY_PUBLIC_KEY,
38
+ workchain: DEFAULT_WORKCHAIN,
39
+ }).init),
40
+ 'v5R1',
41
+ ],
42
+ ]);
43
+ const WALLET_CODE_HASHES = buildCodeHashRegistry();
44
+ const identifyWalletVersion = (codeCell) => {
45
+ var _a;
46
+ const hash = codeCell.hash().toString('hex');
47
+ return (_a = WALLET_CODE_HASHES.get(hash)) !== null && _a !== void 0 ? _a : null;
48
+ };
49
+ const getPublicKeyBitOffset = (version) => {
50
+ if (version === 'v5R1' || version === 'v5Beta') {
51
+ return PUBKEY_BIT_OFFSET_V5;
52
+ }
53
+ return PUBKEY_BIT_OFFSET_V3_V4;
54
+ };
55
+
56
+ export { WALLET_CODE_HASHES, getPublicKeyBitOffset, identifyWalletVersion };