@truecarry/mcp 0.1.3 → 0.1.5

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 (70) hide show
  1. package/dist/cli.js +654 -1579
  2. package/dist/factory.d.ts +35 -21
  3. package/dist/factory.d.ts.map +1 -1
  4. package/dist/index.cjs +781 -4180
  5. package/dist/index.d.ts +5 -16
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +781 -4167
  8. package/dist/services/McpWalletService.d.ts +74 -133
  9. package/dist/services/McpWalletService.d.ts.map +1 -1
  10. package/dist/tools/balance-tools.d.ts +61 -0
  11. package/dist/tools/balance-tools.d.ts.map +1 -0
  12. package/dist/tools/index.d.ts +5 -7
  13. package/dist/tools/index.d.ts.map +1 -1
  14. package/dist/tools/known-jettons-tools.d.ts +44 -0
  15. package/dist/tools/known-jettons-tools.d.ts.map +1 -0
  16. package/dist/tools/nft-tools.d.ts +85 -0
  17. package/dist/tools/nft-tools.d.ts.map +1 -0
  18. package/dist/tools/swap-tools.d.ts +49 -0
  19. package/dist/tools/swap-tools.d.ts.map +1 -0
  20. package/dist/tools/transfer-tools.d.ts +159 -0
  21. package/dist/tools/transfer-tools.d.ts.map +1 -0
  22. package/dist/tools/types.d.ts +21 -0
  23. package/dist/tools/types.d.ts.map +1 -0
  24. package/dist/types/config.d.ts +12 -36
  25. package/dist/types/config.d.ts.map +1 -1
  26. package/dist/types/index.d.ts +1 -4
  27. package/dist/types/index.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/adapters/InMemoryStorageAdapter.d.ts +0 -49
  30. package/dist/adapters/InMemoryStorageAdapter.d.ts.map +0 -1
  31. package/dist/adapters/LocalSignerAdapter.d.ts +0 -107
  32. package/dist/adapters/LocalSignerAdapter.d.ts.map +0 -1
  33. package/dist/adapters/SqliteSignerAdapter.d.ts +0 -119
  34. package/dist/adapters/SqliteSignerAdapter.d.ts.map +0 -1
  35. package/dist/adapters/SqliteStorageAdapter.d.ts +0 -81
  36. package/dist/adapters/SqliteStorageAdapter.d.ts.map +0 -1
  37. package/dist/adapters/TelegramUserContextProvider.d.ts +0 -70
  38. package/dist/adapters/TelegramUserContextProvider.d.ts.map +0 -1
  39. package/dist/adapters/index.d.ts +0 -19
  40. package/dist/adapters/index.d.ts.map +0 -1
  41. package/dist/core/LimitsManager.d.ts +0 -59
  42. package/dist/core/LimitsManager.d.ts.map +0 -1
  43. package/dist/core/PendingTransactionManager.d.ts +0 -122
  44. package/dist/core/PendingTransactionManager.d.ts.map +0 -1
  45. package/dist/core/UserScopedSigner.d.ts +0 -96
  46. package/dist/core/UserScopedSigner.d.ts.map +0 -1
  47. package/dist/core/UserScopedStorage.d.ts +0 -59
  48. package/dist/core/UserScopedStorage.d.ts.map +0 -1
  49. package/dist/core/index.d.ts +0 -15
  50. package/dist/core/index.d.ts.map +0 -1
  51. package/dist/services/WalletService.d.ts +0 -144
  52. package/dist/services/WalletService.d.ts.map +0 -1
  53. package/dist/storage/SecureStorage.d.ts +0 -79
  54. package/dist/storage/SecureStorage.d.ts.map +0 -1
  55. package/dist/tools/balance.d.ts +0 -167
  56. package/dist/tools/balance.d.ts.map +0 -1
  57. package/dist/tools/mcp-tools.d.ts +0 -439
  58. package/dist/tools/mcp-tools.d.ts.map +0 -1
  59. package/dist/tools/swap.d.ts +0 -110
  60. package/dist/tools/swap.d.ts.map +0 -1
  61. package/dist/tools/transfer.d.ts +0 -146
  62. package/dist/tools/transfer.d.ts.map +0 -1
  63. package/dist/tools/wallet.d.ts +0 -138
  64. package/dist/tools/wallet.d.ts.map +0 -1
  65. package/dist/types/signer.d.ts +0 -120
  66. package/dist/types/signer.d.ts.map +0 -1
  67. package/dist/types/storage.d.ts +0 -41
  68. package/dist/types/storage.d.ts.map +0 -1
  69. package/dist/types/user-context.d.ts +0 -48
  70. package/dist/types/user-context.d.ts.map +0 -1
@@ -0,0 +1,159 @@
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 { z } from 'zod';
9
+ import type { McpWalletService } from '../services/McpWalletService.js';
10
+ import type { ToolResponse } from './types.js';
11
+ export declare const sendTonSchema: z.ZodObject<{
12
+ toAddress: z.ZodString;
13
+ amount: z.ZodString;
14
+ comment: z.ZodOptional<z.ZodString>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ toAddress: string;
17
+ amount: string;
18
+ comment?: string | undefined;
19
+ }, {
20
+ toAddress: string;
21
+ amount: string;
22
+ comment?: string | undefined;
23
+ }>;
24
+ export declare const sendJettonSchema: z.ZodObject<{
25
+ toAddress: z.ZodString;
26
+ jettonAddress: z.ZodString;
27
+ amount: z.ZodString;
28
+ comment: z.ZodOptional<z.ZodString>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ jettonAddress: string;
31
+ toAddress: string;
32
+ amount: string;
33
+ comment?: string | undefined;
34
+ }, {
35
+ jettonAddress: string;
36
+ toAddress: string;
37
+ amount: string;
38
+ comment?: string | undefined;
39
+ }>;
40
+ export declare const sendRawTransactionSchema: z.ZodObject<{
41
+ messages: z.ZodArray<z.ZodObject<{
42
+ address: z.ZodString;
43
+ amount: z.ZodString;
44
+ stateInit: z.ZodOptional<z.ZodString>;
45
+ payload: z.ZodOptional<z.ZodString>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ address: string;
48
+ amount: string;
49
+ stateInit?: string | undefined;
50
+ payload?: string | undefined;
51
+ }, {
52
+ address: string;
53
+ amount: string;
54
+ stateInit?: string | undefined;
55
+ payload?: string | undefined;
56
+ }>, "many">;
57
+ validUntil: z.ZodOptional<z.ZodNumber>;
58
+ fromAddress: z.ZodOptional<z.ZodString>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ messages: {
61
+ address: string;
62
+ amount: string;
63
+ stateInit?: string | undefined;
64
+ payload?: string | undefined;
65
+ }[];
66
+ validUntil?: number | undefined;
67
+ fromAddress?: string | undefined;
68
+ }, {
69
+ messages: {
70
+ address: string;
71
+ amount: string;
72
+ stateInit?: string | undefined;
73
+ payload?: string | undefined;
74
+ }[];
75
+ validUntil?: number | undefined;
76
+ fromAddress?: string | undefined;
77
+ }>;
78
+ export declare function createMcpTransferTools(service: McpWalletService): {
79
+ send_ton: {
80
+ description: string;
81
+ inputSchema: z.ZodObject<{
82
+ toAddress: z.ZodString;
83
+ amount: z.ZodString;
84
+ comment: z.ZodOptional<z.ZodString>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ toAddress: string;
87
+ amount: string;
88
+ comment?: string | undefined;
89
+ }, {
90
+ toAddress: string;
91
+ amount: string;
92
+ comment?: string | undefined;
93
+ }>;
94
+ handler: (args: z.infer<typeof sendTonSchema>) => Promise<ToolResponse>;
95
+ };
96
+ send_jetton: {
97
+ description: string;
98
+ inputSchema: z.ZodObject<{
99
+ toAddress: z.ZodString;
100
+ jettonAddress: z.ZodString;
101
+ amount: z.ZodString;
102
+ comment: z.ZodOptional<z.ZodString>;
103
+ }, "strip", z.ZodTypeAny, {
104
+ jettonAddress: string;
105
+ toAddress: string;
106
+ amount: string;
107
+ comment?: string | undefined;
108
+ }, {
109
+ jettonAddress: string;
110
+ toAddress: string;
111
+ amount: string;
112
+ comment?: string | undefined;
113
+ }>;
114
+ handler: (args: z.infer<typeof sendJettonSchema>) => Promise<ToolResponse>;
115
+ };
116
+ send_raw_transaction: {
117
+ description: string;
118
+ inputSchema: z.ZodObject<{
119
+ messages: z.ZodArray<z.ZodObject<{
120
+ address: z.ZodString;
121
+ amount: z.ZodString;
122
+ stateInit: z.ZodOptional<z.ZodString>;
123
+ payload: z.ZodOptional<z.ZodString>;
124
+ }, "strip", z.ZodTypeAny, {
125
+ address: string;
126
+ amount: string;
127
+ stateInit?: string | undefined;
128
+ payload?: string | undefined;
129
+ }, {
130
+ address: string;
131
+ amount: string;
132
+ stateInit?: string | undefined;
133
+ payload?: string | undefined;
134
+ }>, "many">;
135
+ validUntil: z.ZodOptional<z.ZodNumber>;
136
+ fromAddress: z.ZodOptional<z.ZodString>;
137
+ }, "strip", z.ZodTypeAny, {
138
+ messages: {
139
+ address: string;
140
+ amount: string;
141
+ stateInit?: string | undefined;
142
+ payload?: string | undefined;
143
+ }[];
144
+ validUntil?: number | undefined;
145
+ fromAddress?: string | undefined;
146
+ }, {
147
+ messages: {
148
+ address: string;
149
+ amount: string;
150
+ stateInit?: string | undefined;
151
+ payload?: string | undefined;
152
+ }[];
153
+ validUntil?: number | undefined;
154
+ fromAddress?: string | undefined;
155
+ }>;
156
+ handler: (args: z.infer<typeof sendRawTransactionSchema>) => Promise<ToolResponse>;
157
+ };
158
+ };
159
+ //# sourceMappingURL=transfer-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer-tools.d.ts","sourceRoot":"","sources":["../../src/tools/transfer-tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,aAAa;;;;;;;;;;;;EAIxB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AASH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAInC,CAAC;AAEH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB;;;;;;;;;;;;;;;;wBAK9B,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,KAAG,OAAO,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;wBA8CrD,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,KAAG,OAAO,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyFxD,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,KAAG,OAAO,CAAC,YAAY,CAAC;;EA+CjG"}
@@ -0,0 +1,21 @@
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 interface ToolResponse {
9
+ [key: string]: unknown;
10
+ content: Array<{
11
+ type: 'text';
12
+ text: string;
13
+ }>;
14
+ isError?: boolean;
15
+ }
16
+ /**
17
+ * Converts a human-readable amount to raw units.
18
+ */
19
+ export declare function toRawAmount(amount: string, decimals: number): string;
20
+ export declare const TON_DECIMALS = 9;
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,MAAM,WAAW,YAAY;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKpE;AAED,eAAO,MAAM,YAAY,IAAI,CAAC"}
@@ -8,58 +8,34 @@
8
8
  /**
9
9
  * Configuration types for createTonWalletMCP factory
10
10
  */
11
- import type { IStorageAdapter } from './storage.js';
12
- import type { ISignerAdapter } from './signer.js';
13
- import type { IUserContextProvider } from './user-context.js';
11
+ import type { Wallet } from '@ton/walletkit';
14
12
  import type { IContactResolver } from './contacts.js';
15
13
  /**
16
- * Safety limits configuration
14
+ * Network-specific configuration
17
15
  */
18
- export interface LimitsConfig {
19
- /** Maximum TON amount per single transaction */
20
- maxTransactionTon?: number;
21
- /** Maximum TON amount per day per user */
22
- dailyLimitTon?: number;
23
- /** Maximum number of wallets per user */
24
- maxWalletsPerUser?: number;
16
+ export interface NetworkConfig {
17
+ /** TonCenter API key for this network */
18
+ apiKey?: string;
25
19
  }
26
20
  /**
27
21
  * Configuration for createTonWalletMCP factory
28
22
  */
29
23
  export interface TonMcpConfig {
30
24
  /**
31
- * Storage adapter for wallet metadata, contacts, pending transactions.
25
+ * Wallet instance to use for operations.
32
26
  * Required.
33
27
  */
34
- storage: IStorageAdapter;
35
- /**
36
- * Signer adapter for secure key management and signing.
37
- * Required.
38
- */
39
- signer: ISignerAdapter;
40
- /**
41
- * User context provider for extracting authenticated user ID.
42
- * Required.
43
- */
44
- userContext: IUserContextProvider;
28
+ wallet: Wallet;
45
29
  /**
46
30
  * Optional contact resolver for name-to-address resolution.
47
31
  */
48
32
  contacts?: IContactResolver;
49
33
  /**
50
- * Default network for new wallets.
51
- * @default 'mainnet'
52
- */
53
- network?: 'mainnet' | 'testnet';
54
- /**
55
- * Safety limits for transactions and wallets.
56
- */
57
- limits?: LimitsConfig;
58
- /**
59
- * If true, transactions require explicit confirmation via confirm_transaction tool.
60
- * Recommended for Telegram bots and other user-facing applications.
61
- * @default false
34
+ * Network-specific configuration (API keys).
62
35
  */
63
- requireConfirmation?: boolean;
36
+ networks?: {
37
+ mainnet?: NetworkConfig;
38
+ testnet?: NetworkConfig;
39
+ };
64
40
  }
65
41
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,OAAO,EAAE,eAAe,CAAC;IAEzB;;;OAGG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;;OAGG;IACH,WAAW,EAAE,oBAAoB,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,aAAa,CAAC;QACxB,OAAO,CAAC,EAAE,aAAa,CAAC;KAC3B,CAAC;CACL"}
@@ -8,9 +8,6 @@
8
8
  /**
9
9
  * Type exports for @ton/mcp package
10
10
  */
11
- export type { IStorageAdapter } from './storage.js';
12
- export type { ISignerAdapter, WalletInfo, CreateWalletParams, ImportWalletParams } from './signer.js';
13
- export type { IUserContextProvider, RequestContext } from './user-context.js';
14
11
  export type { IContactResolver, Contact } from './contacts.js';
15
- export type { TonMcpConfig, LimitsConfig } from './config.js';
12
+ export type { TonMcpConfig, NetworkConfig } from './config.js';
16
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAGH,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtG,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG9E,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG/D,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAGH,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG/D,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truecarry/mcp",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "TON MCP Server - Model Context Protocol server for TON blockchain wallet operations",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,49 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,107 +0,0 @@
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
@@ -1 +0,0 @@
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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AAO,CAAC,MAAM,CAAC;IAIxD;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAG9D"}
@@ -1,119 +0,0 @@
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
@@ -1 +0,0 @@
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,KA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M,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"}
@@ -1,81 +0,0 @@
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
@@ -1 +0,0 @@
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;IA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