@truecarry/mcp 0.1.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -0
  3. package/dist/adapters/InMemoryStorageAdapter.d.ts +49 -0
  4. package/dist/adapters/InMemoryStorageAdapter.d.ts.map +1 -0
  5. package/dist/adapters/LocalSignerAdapter.d.ts +107 -0
  6. package/dist/adapters/LocalSignerAdapter.d.ts.map +1 -0
  7. package/dist/adapters/SqliteSignerAdapter.d.ts +119 -0
  8. package/dist/adapters/SqliteSignerAdapter.d.ts.map +1 -0
  9. package/dist/adapters/SqliteStorageAdapter.d.ts +81 -0
  10. package/dist/adapters/SqliteStorageAdapter.d.ts.map +1 -0
  11. package/dist/adapters/TelegramUserContextProvider.d.ts +70 -0
  12. package/dist/adapters/TelegramUserContextProvider.d.ts.map +1 -0
  13. package/dist/adapters/index.d.ts +19 -0
  14. package/dist/adapters/index.d.ts.map +1 -0
  15. package/dist/cli.d.ts +9 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +90209 -0
  18. package/dist/core/LimitsManager.d.ts +59 -0
  19. package/dist/core/LimitsManager.d.ts.map +1 -0
  20. package/dist/core/PendingTransactionManager.d.ts +122 -0
  21. package/dist/core/PendingTransactionManager.d.ts.map +1 -0
  22. package/dist/core/UserScopedSigner.d.ts +96 -0
  23. package/dist/core/UserScopedSigner.d.ts.map +1 -0
  24. package/dist/core/UserScopedStorage.d.ts +59 -0
  25. package/dist/core/UserScopedStorage.d.ts.map +1 -0
  26. package/dist/core/index.d.ts +15 -0
  27. package/dist/core/index.d.ts.map +1 -0
  28. package/dist/factory.d.ts +53 -0
  29. package/dist/factory.d.ts.map +1 -0
  30. package/dist/index.cjs +91029 -0
  31. package/dist/index.d.ts +30 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +91015 -0
  34. package/dist/services/McpWalletService.d.ts +253 -0
  35. package/dist/services/McpWalletService.d.ts.map +1 -0
  36. package/dist/services/WalletService.d.ts +144 -0
  37. package/dist/services/WalletService.d.ts.map +1 -0
  38. package/dist/storage/SecureStorage.d.ts +79 -0
  39. package/dist/storage/SecureStorage.d.ts.map +1 -0
  40. package/dist/tools/balance.d.ts +167 -0
  41. package/dist/tools/balance.d.ts.map +1 -0
  42. package/dist/tools/index.d.ts +15 -0
  43. package/dist/tools/index.d.ts.map +1 -0
  44. package/dist/tools/mcp-tools.d.ts +439 -0
  45. package/dist/tools/mcp-tools.d.ts.map +1 -0
  46. package/dist/tools/swap.d.ts +110 -0
  47. package/dist/tools/swap.d.ts.map +1 -0
  48. package/dist/tools/transfer.d.ts +146 -0
  49. package/dist/tools/transfer.d.ts.map +1 -0
  50. package/dist/tools/wallet.d.ts +138 -0
  51. package/dist/tools/wallet.d.ts.map +1 -0
  52. package/dist/types/config.d.ts +65 -0
  53. package/dist/types/config.d.ts.map +1 -0
  54. package/dist/types/contacts.d.ts +61 -0
  55. package/dist/types/contacts.d.ts.map +1 -0
  56. package/dist/types/index.d.ts +16 -0
  57. package/dist/types/index.d.ts.map +1 -0
  58. package/dist/types/signer.d.ts +120 -0
  59. package/dist/types/signer.d.ts.map +1 -0
  60. package/dist/types/storage.d.ts +41 -0
  61. package/dist/types/storage.d.ts.map +1 -0
  62. package/dist/types/user-context.d.ts +48 -0
  63. package/dist/types/user-context.d.ts.map +1 -0
  64. package/package.json +76 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 TonTech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # @ton/mcp - TON MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for TON blockchain wallet operations. Built on top of `@ton/walletkit`.
4
+
5
+ ## Features
6
+
7
+ - **Wallet Management**: Create, import, list, and remove TON wallets
8
+ - **Balance Queries**: Check TON and Jetton balances
9
+ - **Transfers**: Send TON and Jettons to any address
10
+ - **Secure Storage**: Wallets stored locally with encryption-ready design
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # In the monorepo
16
+ pnpm install
17
+ pnpm --filter @ton/mcp build
18
+ ```
19
+
20
+ ## Usage with MCP Clients
21
+
22
+ ### Claude Desktop / Cursor
23
+
24
+ Add to your MCP configuration:
25
+
26
+ ```json
27
+ {
28
+ "mcpServers": {
29
+ "ton": {
30
+ "command": "node",
31
+ "args": ["/path/to/kit/apps/mcp/dist/index.js"]
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ ## Available Tools
38
+
39
+ ### Wallet Management
40
+
41
+ #### `create_wallet`
42
+ Create a new TON wallet with a generated 24-word mnemonic.
43
+
44
+ **Parameters:**
45
+ - `name` (required): Unique name for the wallet
46
+ - `version` (optional): Wallet version - `v5r1` (default, recommended) or `v4r2`
47
+
48
+ **Returns:** Wallet address and mnemonic (save securely!)
49
+
50
+ #### `import_wallet`
51
+ Import an existing wallet using a mnemonic phrase.
52
+
53
+ **Parameters:**
54
+ - `name` (required): Unique name for the wallet
55
+ - `mnemonic` (required): 24-word mnemonic phrase (space-separated)
56
+ - `version` (optional): Wallet version - `v5r1` (default) or `v4r2`
57
+
58
+ #### `list_wallets`
59
+ List all stored wallets with their addresses and metadata.
60
+
61
+ #### `remove_wallet`
62
+ Remove a wallet from storage.
63
+
64
+ **Parameters:**
65
+ - `name` (required): Name of the wallet to remove
66
+
67
+ ### Balance Queries
68
+
69
+ #### `get_balance`
70
+ Get the TON balance for a wallet.
71
+
72
+ **Parameters:**
73
+ - `wallet` (required): Name of the wallet
74
+
75
+ **Returns:** Balance in nanoTON and TON
76
+
77
+ #### `get_jetton_balance`
78
+ Get the balance of a specific Jetton.
79
+
80
+ **Parameters:**
81
+ - `wallet` (required): Name of the wallet
82
+ - `jettonAddress` (required): Jetton master contract address
83
+
84
+ #### `get_jettons`
85
+ List all Jettons held by a wallet.
86
+
87
+ **Parameters:**
88
+ - `wallet` (required): Name of the wallet
89
+
90
+ ### Transfers
91
+
92
+ #### `send_ton`
93
+ Send TON to an address.
94
+
95
+ **Parameters:**
96
+ - `wallet` (required): Name of the wallet to send from
97
+ - `toAddress` (required): Recipient TON address
98
+ - `amount` (required): Amount in nanoTON (1 TON = 1,000,000,000 nanoTON)
99
+ - `comment` (optional): Transaction comment/memo
100
+
101
+ #### `send_jetton`
102
+ Send Jettons to an address.
103
+
104
+ **Parameters:**
105
+ - `wallet` (required): Name of the wallet to send from
106
+ - `toAddress` (required): Recipient TON address
107
+ - `jettonAddress` (required): Jetton master contract address
108
+ - `amount` (required): Amount in raw units (apply decimals yourself)
109
+ - `comment` (optional): Transaction comment/memo
110
+
111
+ ## Storage
112
+
113
+ Wallet data is stored in `~/.ton-mcp/wallets.json`.
114
+
115
+ **Current Implementation:** Plaintext JSON storage
116
+
117
+ **Security Note:** Mnemonics are currently stored in plaintext. The storage interface is designed to easily support encrypted storage in the future. Do not use this for production wallets with significant funds until encryption is implemented.
118
+
119
+ ## Development
120
+
121
+ ```bash
122
+ # Build
123
+ pnpm build
124
+
125
+ # Watch mode
126
+ pnpm dev
127
+
128
+ # Run directly
129
+ pnpm start
130
+ ```
131
+
132
+ ## Network
133
+
134
+ The server uses TON Mainnet by default. This can be configured in the WalletService constructor.
135
+
136
+ ## License
137
+
138
+ MIT
139
+
140
+
141
+
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * InMemoryStorageAdapter - Simple in-memory storage for testing and development
10
+ *
11
+ * Features:
12
+ * - Map-based storage
13
+ * - TTL support via setTimeout
14
+ * - Not persistent - data lost on restart
15
+ */
16
+ import type { IStorageAdapter } from '../types/storage.js';
17
+ /**
18
+ * In-memory storage adapter for testing and development.
19
+ * Data is not persistent and will be lost on process restart.
20
+ */
21
+ export declare class InMemoryStorageAdapter implements IStorageAdapter {
22
+ private data;
23
+ private timers;
24
+ /**
25
+ * Get a value by key
26
+ */
27
+ get<T>(key: string): Promise<T | null>;
28
+ /**
29
+ * Set a value with optional TTL
30
+ */
31
+ set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
32
+ /**
33
+ * Delete a key
34
+ */
35
+ delete(key: string): Promise<boolean>;
36
+ /**
37
+ * List keys matching prefix
38
+ */
39
+ list(prefix: string): Promise<string[]>;
40
+ /**
41
+ * Clear all data (useful for testing)
42
+ */
43
+ clear(): void;
44
+ /**
45
+ * Get the number of stored items (useful for testing)
46
+ */
47
+ size(): number;
48
+ }
49
+ //# sourceMappingURL=InMemoryStorageAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InMemoryStorageAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/InMemoryStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC1D,OAAO,CAAC,IAAI,CAAmC;IAC/C,OAAO,CAAC,MAAM,CAAyD;IAEvE;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAK5C;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBvE;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW3C;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAU7C;;OAEG;IACH,KAAK,IAAI,IAAI;IASb;;OAEG;IACH,IAAI,IAAI,MAAM;CAGjB"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * LocalSignerAdapter - Local signer using @ton/walletkit
10
+ *
11
+ * This adapter uses TonWalletKit for wallet operations.
12
+ * For production use with encryption, extend this class or implement
13
+ * your own ISignerAdapter with proper key encryption.
14
+ *
15
+ * Note: This is a reference implementation. For production custody,
16
+ * consider using HSM, KMS, or Vault-based signers.
17
+ */
18
+ import { TonWalletKit } from '@ton/walletkit';
19
+ import type { Wallet } from '@ton/walletkit';
20
+ import type { ISignerAdapter, WalletInfo, CreateWalletParams, ImportWalletParams } from '../types/signer.js';
21
+ /**
22
+ * Internal wallet data stored by the adapter
23
+ */
24
+ interface StoredWallet {
25
+ walletId: string;
26
+ mnemonic: string[];
27
+ publicKey: string;
28
+ address: string;
29
+ network: 'mainnet' | 'testnet';
30
+ version: 'v5r1' | 'v4r2';
31
+ createdAt: string;
32
+ }
33
+ /**
34
+ * Local signer adapter using TonWalletKit.
35
+ *
36
+ * This implementation stores mnemonics in memory. For production use,
37
+ * implement encryption or use a secure key management system.
38
+ */
39
+ export declare class LocalSignerAdapter implements ISignerAdapter {
40
+ private wallets;
41
+ private kit;
42
+ private loadedWallets;
43
+ /**
44
+ * Get Network instance from network name
45
+ */
46
+ private getNetwork;
47
+ /**
48
+ * Initialize or get TonWalletKit instance
49
+ */
50
+ private getKit;
51
+ /**
52
+ * Create wallet adapter from mnemonic
53
+ */
54
+ private createWalletAdapter;
55
+ /**
56
+ * Create a new wallet with generated mnemonic
57
+ */
58
+ createWallet(params: CreateWalletParams): Promise<WalletInfo>;
59
+ /**
60
+ * Import a wallet from mnemonic
61
+ */
62
+ importWallet(params: ImportWalletParams): Promise<WalletInfo>;
63
+ /**
64
+ * Get wallet info by ID
65
+ */
66
+ getWallet(walletId: string): Promise<WalletInfo | null>;
67
+ /**
68
+ * List all wallet IDs
69
+ */
70
+ listWalletIds(): Promise<string[]>;
71
+ /**
72
+ * Delete a wallet
73
+ */
74
+ deleteWallet(walletId: string): Promise<boolean>;
75
+ /**
76
+ * Get or load a wallet for signing
77
+ */
78
+ private getWalletForSigning;
79
+ /**
80
+ * Sign a transaction
81
+ */
82
+ signTransaction(_walletId: string, _unsignedBoc: string): Promise<string>;
83
+ /**
84
+ * Sign a message
85
+ */
86
+ signMessage(walletId: string, message: Buffer): Promise<Buffer>;
87
+ /**
88
+ * Close and cleanup
89
+ */
90
+ close(): Promise<void>;
91
+ /**
92
+ * Get TonWalletKit instance for direct wallet operations
93
+ * Used by WalletService for balance/transfer operations
94
+ */
95
+ getKitInstance(): Promise<TonWalletKit>;
96
+ /**
97
+ * Get a loaded wallet by ID for direct operations
98
+ * Used by WalletService for balance/transfer operations
99
+ */
100
+ getLoadedWallet(walletId: string): Promise<Wallet>;
101
+ /**
102
+ * Get stored wallet data (internal use only)
103
+ */
104
+ getStoredWallet(walletId: string): StoredWallet | undefined;
105
+ }
106
+ export {};
107
+ //# sourceMappingURL=LocalSignerAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalSignerAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/LocalSignerAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACH,YAAY,EAOf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7G;;GAEG;AACH,UAAU,YAAY;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACrD,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,GAAG,CAA6B;IACxC,OAAO,CAAC,aAAa,CAAkC;IAEvD;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;YACW,MAAM;IAcpB;;OAEG;YACW,mBAAmB;IAyBjC;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IA4CnE;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IAgDnE;;OAEG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAgB7D;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIxC;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAatD;;OAEG;YACW,mBAAmB;IA8BjC;;OAEG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAc/E;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYrE;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC;IAI7C;;;OAGG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxD;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAG9D"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { TonWalletKit } from '@ton/walletkit';
9
+ import type { Wallet } from '@ton/walletkit';
10
+ import type { ISignerAdapter, WalletInfo, CreateWalletParams, ImportWalletParams } from '../types/signer.js';
11
+ import type { SqliteDatabase } from './SqliteStorageAdapter.js';
12
+ /**
13
+ * Configuration for SqliteSignerAdapter
14
+ */
15
+ export interface SqliteSignerConfig {
16
+ /** SQLite database instance */
17
+ db: SqliteDatabase;
18
+ /** Encryption key (32-byte hex string or raw bytes) */
19
+ encryptionKey: string | Buffer;
20
+ /** Table name for wallets (default: 'wallets') */
21
+ tableName?: string;
22
+ }
23
+ /**
24
+ * SQLite-based signer adapter with encrypted mnemonic storage.
25
+ *
26
+ * Mnemonics are encrypted using AES-256-GCM before storage.
27
+ * The encryption key should be provided via environment variable.
28
+ */
29
+ export declare class SqliteSignerAdapter implements ISignerAdapter {
30
+ private readonly db;
31
+ private readonly tableName;
32
+ private readonly encryptionKey;
33
+ private kit;
34
+ private loadedWallets;
35
+ constructor(config: SqliteSignerConfig);
36
+ /**
37
+ * Derive a 32-byte encryption key
38
+ */
39
+ private deriveKey;
40
+ /**
41
+ * Initialize the wallets table
42
+ */
43
+ private initializeTable;
44
+ /**
45
+ * Encrypt mnemonic using AES-256-GCM
46
+ */
47
+ private encryptMnemonic;
48
+ /**
49
+ * Decrypt mnemonic using AES-256-GCM
50
+ */
51
+ private decryptMnemonic;
52
+ /**
53
+ * Get Network instance from network name
54
+ */
55
+ private getNetwork;
56
+ /**
57
+ * Initialize or get TonWalletKit instance
58
+ */
59
+ private getKit;
60
+ /**
61
+ * Create wallet adapter from mnemonic
62
+ */
63
+ private createWalletAdapter;
64
+ /**
65
+ * Create a new wallet with generated mnemonic
66
+ */
67
+ createWallet(params: CreateWalletParams): Promise<WalletInfo>;
68
+ /**
69
+ * Import a wallet from mnemonic
70
+ */
71
+ importWallet(params: ImportWalletParams): Promise<WalletInfo>;
72
+ /**
73
+ * Get wallet info by ID
74
+ */
75
+ getWallet(walletId: string): Promise<WalletInfo | null>;
76
+ /**
77
+ * List all wallet IDs
78
+ */
79
+ listWalletIds(): Promise<string[]>;
80
+ /**
81
+ * Delete a wallet
82
+ */
83
+ deleteWallet(walletId: string): Promise<boolean>;
84
+ /**
85
+ * Get or load a wallet for signing
86
+ */
87
+ private getWalletForSigning;
88
+ /**
89
+ * Sign a transaction
90
+ */
91
+ signTransaction(_walletId: string, _unsignedBoc: string): Promise<string>;
92
+ /**
93
+ * Sign a message
94
+ */
95
+ signMessage(walletId: string, message: Buffer): Promise<Buffer>;
96
+ /**
97
+ * Close and cleanup
98
+ */
99
+ close(): Promise<void>;
100
+ /**
101
+ * Get TonWalletKit instance for direct wallet operations
102
+ * Used by WalletService for balance/transfer operations
103
+ */
104
+ getKitInstance(): Promise<TonWalletKit>;
105
+ /**
106
+ * Get a loaded wallet by ID for direct operations
107
+ * Used by WalletService for balance/transfer operations
108
+ */
109
+ getLoadedWallet(walletId: string): Promise<Wallet>;
110
+ /**
111
+ * Get stored wallet data (internal use only)
112
+ * Returns mnemonic for internal operations (like McpWalletService)
113
+ */
114
+ getStoredWallet(walletId: string): {
115
+ mnemonic: string[];
116
+ version: 'v5r1' | 'v4r2';
117
+ } | undefined;
118
+ }
119
+ //# sourceMappingURL=SqliteSignerAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SqliteSignerAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/SqliteSignerAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH,OAAO,EACH,YAAY,EAOf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAehE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,+BAA+B;IAC/B,EAAE,EAAE,cAAc,CAAC;IACnB,uDAAuD;IACvD,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,cAAc;IACtD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAiB;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,GAAG,CAA6B;IACxC,OAAO,CAAC,aAAa,CAAkC;gBAE3C,MAAM,EAAE,kBAAkB;IAOtC;;OAEG;IACH,OAAO,CAAC,SAAS;IAiBjB;;OAEG;IACH,OAAO,CAAC,eAAe;IAoBvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;YACW,MAAM;IAcpB;;OAEG;YACW,mBAAmB;IAyBjC;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IA0CnE;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IA8CnE;;OAEG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmB7D;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKxC;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQtD;;OAEG;YACW,mBAAmB;IAkCjC;;OAEG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/E;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBrE;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC;IAI7C;;;OAGG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxD;;;OAGG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,SAAS;CAclG"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * SqliteStorageAdapter - SQLite-based persistent storage
10
+ *
11
+ * Features:
12
+ * - Persistent key-value storage using SQLite
13
+ * - TTL support with automatic cleanup
14
+ * - Thread-safe operations via better-sqlite3
15
+ */
16
+ import type { IStorageAdapter } from '../types/storage.js';
17
+ /**
18
+ * Database interface for SQLite operations.
19
+ * This allows injecting a better-sqlite3 database instance.
20
+ */
21
+ export interface SqliteDatabase {
22
+ prepare(sql: string): {
23
+ run(...params: unknown[]): {
24
+ changes: number;
25
+ };
26
+ get(...params: unknown[]): unknown;
27
+ all(...params: unknown[]): unknown[];
28
+ };
29
+ exec(sql: string): void;
30
+ }
31
+ /**
32
+ * Configuration for SqliteStorageAdapter
33
+ */
34
+ export interface SqliteStorageConfig {
35
+ /** SQLite database instance */
36
+ db: SqliteDatabase;
37
+ /** Table name for storage (default: 'storage') */
38
+ tableName?: string;
39
+ }
40
+ /**
41
+ * SQLite-based storage adapter for persistent key-value storage.
42
+ * Uses better-sqlite3 for synchronous, thread-safe operations.
43
+ */
44
+ export declare class SqliteStorageAdapter implements IStorageAdapter {
45
+ private readonly db;
46
+ private readonly tableName;
47
+ constructor(config: SqliteStorageConfig);
48
+ /**
49
+ * Initialize the storage table
50
+ */
51
+ private initializeTable;
52
+ /**
53
+ * Clean up expired entries
54
+ */
55
+ private cleanupExpired;
56
+ /**
57
+ * Get a value by key
58
+ */
59
+ get<T>(key: string): Promise<T | null>;
60
+ /**
61
+ * Set a value with optional TTL
62
+ */
63
+ set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
64
+ /**
65
+ * Delete a key
66
+ */
67
+ delete(key: string): Promise<boolean>;
68
+ /**
69
+ * List keys matching prefix
70
+ */
71
+ list(prefix: string): Promise<string[]>;
72
+ /**
73
+ * Clear all data (useful for testing)
74
+ */
75
+ clear(): void;
76
+ /**
77
+ * Get the number of stored items
78
+ */
79
+ size(): number;
80
+ }
81
+ //# sourceMappingURL=SqliteStorageAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SqliteStorageAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/SqliteStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QAClB,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/C,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACnC,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;KACxC,CAAC;IACF,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,+BAA+B;IAC/B,EAAE,EAAE,cAAc,CAAC;IACnB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IACxD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAiB;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,MAAM,EAAE,mBAAmB;IAMvC;;OAEG;IACH,OAAO,CAAC,eAAe;IAiBvB;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAwB5C;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASvE;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3C;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAU7C;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,MAAM;CAKjB"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * TelegramUserContextProvider - Extract user ID from Telegram bot context
10
+ *
11
+ * This provider extracts the Telegram user ID from:
12
+ * 1. x-telegram-user-id header
13
+ * 2. metadata.telegramUserId field
14
+ *
15
+ * For use with Telegram bot integrations.
16
+ */
17
+ import type { IUserContextProvider, RequestContext } from '../types/user-context.js';
18
+ /**
19
+ * Configuration for TelegramUserContextProvider
20
+ */
21
+ export interface TelegramUserContextConfig {
22
+ /**
23
+ * Header name to extract user ID from
24
+ * @default 'x-telegram-user-id'
25
+ */
26
+ headerName?: string;
27
+ /**
28
+ * Metadata key to extract user ID from
29
+ * @default 'telegramUserId'
30
+ */
31
+ metadataKey?: string;
32
+ /**
33
+ * Optional prefix to add to user IDs
34
+ * @default 'tg:'
35
+ */
36
+ userIdPrefix?: string;
37
+ }
38
+ /**
39
+ * User context provider for Telegram bot integrations.
40
+ * Extracts user ID from headers or metadata.
41
+ */
42
+ export declare class TelegramUserContextProvider implements IUserContextProvider {
43
+ private readonly headerName;
44
+ private readonly metadataKey;
45
+ private readonly userIdPrefix;
46
+ constructor(config?: TelegramUserContextConfig);
47
+ /**
48
+ * Extract user ID from request context
49
+ */
50
+ getUserId(context: RequestContext): Promise<string | null>;
51
+ /**
52
+ * Get user metadata (optional)
53
+ */
54
+ getUserMetadata(userId: string): Promise<Record<string, unknown> | null>;
55
+ /**
56
+ * Validate user ID format
57
+ */
58
+ private isValidUserId;
59
+ }
60
+ /**
61
+ * Simple user context provider that always returns a fixed user ID.
62
+ * Useful for single-user CLI applications or testing.
63
+ */
64
+ export declare class StaticUserContextProvider implements IUserContextProvider {
65
+ private readonly userId;
66
+ constructor(userId: string);
67
+ getUserId(): Promise<string>;
68
+ getUserMetadata(): Promise<Record<string, unknown> | null>;
69
+ }
70
+ //# sourceMappingURL=TelegramUserContextProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TelegramUserContextProvider.d.ts","sourceRoot":"","sources":["../../src/adapters/TelegramUserContextProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,2BAA4B,YAAW,oBAAoB;IACpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAE1B,MAAM,CAAC,EAAE,yBAAyB;IAM9C;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAuBhE;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAU9E;;OAEG;IACH,OAAO,CAAC,aAAa;CAIxB;AAED;;;GAGG;AACH,qBAAa,yBAA0B,YAAW,oBAAoB;IAClE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,MAAM,EAAE,MAAM;IAIpB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAMnE"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * Example adapter exports
10
+ */
11
+ export { InMemoryStorageAdapter } from './InMemoryStorageAdapter.js';
12
+ export { SqliteStorageAdapter } from './SqliteStorageAdapter.js';
13
+ export type { SqliteDatabase, SqliteStorageConfig } from './SqliteStorageAdapter.js';
14
+ export { LocalSignerAdapter } from './LocalSignerAdapter.js';
15
+ export { SqliteSignerAdapter } from './SqliteSignerAdapter.js';
16
+ export type { SqliteSignerConfig } from './SqliteSignerAdapter.js';
17
+ export { TelegramUserContextProvider, StaticUserContextProvider } from './TelegramUserContextProvider.js';
18
+ export type { TelegramUserContextConfig } from './TelegramUserContextProvider.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC1G,YAAY,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}