@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
@@ -1,70 +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
- * 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
@@ -1 +0,0 @@
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"}
@@ -1,19 +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
- * 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
@@ -1 +0,0 @@
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"}
@@ -1,59 +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
- * LimitsManager - Enforces transaction, daily, and wallet count limits
10
- */
11
- import type { LimitsConfig } from '../types/config.js';
12
- import type { UserScopedStorage } from './UserScopedStorage.js';
13
- /**
14
- * Result of a limit check
15
- */
16
- export interface LimitCheckResult {
17
- allowed: boolean;
18
- reason?: string;
19
- }
20
- /**
21
- * LimitsManager enforces safety limits on transactions and wallet counts.
22
- */
23
- export declare class LimitsManager {
24
- private readonly limits;
25
- constructor(limits?: LimitsConfig);
26
- /**
27
- * Check if a transaction amount is within limits
28
- */
29
- checkTransactionLimit(storage: UserScopedStorage, amountTon: number): Promise<LimitCheckResult>;
30
- /**
31
- * Record a transaction for daily limit tracking
32
- */
33
- recordTransaction(storage: UserScopedStorage, amountTon: number): Promise<void>;
34
- /**
35
- * Check if user can create another wallet
36
- */
37
- checkWalletCountLimit(currentWalletCount: number): Promise<LimitCheckResult>;
38
- /**
39
- * Get the configured limits
40
- */
41
- getLimits(): Required<LimitsConfig>;
42
- /**
43
- * Get today's date as ISO string (YYYY-MM-DD)
44
- */
45
- private getTodayDate;
46
- /**
47
- * Get daily usage for a specific date
48
- */
49
- private getDailyUsage;
50
- /**
51
- * Convert TON to nanoTON string
52
- */
53
- private tonToNano;
54
- /**
55
- * Convert nanoTON string to TON
56
- */
57
- private nanoToTon;
58
- }
59
- //# sourceMappingURL=LimitsManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LimitsManager.d.ts","sourceRoot":"","sources":["../../src/core/LimitsManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAehE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;gBAEpC,MAAM,CAAC,EAAE,YAAY;IASjC;;OAEG;IACG,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0BrG;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrF;;OAEG;IACG,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAUlF;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,YAAY,CAAC;IAInC;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;YACW,aAAa;IAK3B;;OAEG;IACH,OAAO,CAAC,SAAS;IAKjB;;OAEG;IACH,OAAO,CAAC,SAAS;CAGpB"}
@@ -1,122 +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
- * PendingTransactionManager - Manages two-step transaction confirmation flow
10
- *
11
- * When requireConfirmation is enabled:
12
- * 1. send_ton/send_jetton/execute_swap creates a pending transaction
13
- * 2. User must call confirm_transaction to execute
14
- * 3. Or cancel_transaction to abort
15
- */
16
- import type { UserScopedStorage } from './UserScopedStorage.js';
17
- /**
18
- * Pending transaction types
19
- */
20
- export type PendingTransactionType = 'send_ton' | 'send_jetton' | 'swap';
21
- /**
22
- * Pending transaction data stored in storage
23
- */
24
- export interface PendingTransaction {
25
- /** Unique transaction ID */
26
- id: string;
27
- /** Transaction type */
28
- type: PendingTransactionType;
29
- /** Wallet name to send from */
30
- walletName: string;
31
- /** ISO timestamp when created */
32
- createdAt: string;
33
- /** ISO timestamp when expires */
34
- expiresAt: string;
35
- /** Human-readable description for confirmation */
36
- description: string;
37
- /** Transaction-specific data */
38
- data: PendingTonTransfer | PendingJettonTransfer | PendingSwap;
39
- }
40
- /**
41
- * Pending TON transfer data
42
- */
43
- export interface PendingTonTransfer {
44
- type: 'send_ton';
45
- toAddress: string;
46
- /** Amount in nanoTON */
47
- amountNano: string;
48
- /** Human-readable amount */
49
- amountTon: string;
50
- comment?: string;
51
- }
52
- /**
53
- * Pending Jetton transfer data
54
- */
55
- export interface PendingJettonTransfer {
56
- type: 'send_jetton';
57
- toAddress: string;
58
- jettonAddress: string;
59
- /** Raw amount */
60
- amountRaw: string;
61
- /** Human-readable amount */
62
- amountHuman: string;
63
- symbol?: string;
64
- decimals: number;
65
- comment?: string;
66
- }
67
- /**
68
- * Pending swap data
69
- */
70
- export interface PendingSwap {
71
- type: 'swap';
72
- fromToken: string;
73
- toToken: string;
74
- fromAmount: string;
75
- toAmount: string;
76
- minReceived: string;
77
- provider: string;
78
- /** Serialized quote for execution */
79
- quoteJson: string;
80
- }
81
- /**
82
- * PendingTransactionManager handles the confirmation flow for transactions.
83
- */
84
- export declare class PendingTransactionManager {
85
- private readonly ttlSeconds;
86
- constructor(ttlSeconds?: number);
87
- /**
88
- * Generate a unique transaction ID
89
- */
90
- generateId(): string;
91
- /**
92
- * Create a pending transaction
93
- */
94
- createPending(storage: UserScopedStorage, params: {
95
- type: PendingTransactionType;
96
- walletName: string;
97
- description: string;
98
- data: PendingTonTransfer | PendingJettonTransfer | PendingSwap;
99
- }): Promise<PendingTransaction>;
100
- /**
101
- * Get a pending transaction by ID
102
- */
103
- getPending(storage: UserScopedStorage, transactionId: string): Promise<PendingTransaction | null>;
104
- /**
105
- * List all pending transactions for the user
106
- */
107
- listPending(storage: UserScopedStorage): Promise<PendingTransaction[]>;
108
- /**
109
- * Delete a pending transaction
110
- */
111
- deletePending(storage: UserScopedStorage, transactionId: string): Promise<boolean>;
112
- /**
113
- * Mark a pending transaction as confirmed (delete it)
114
- * The actual execution is handled by the caller
115
- */
116
- confirmPending(storage: UserScopedStorage, transactionId: string): Promise<PendingTransaction | null>;
117
- /**
118
- * Cancel a pending transaction
119
- */
120
- cancelPending(storage: UserScopedStorage, transactionId: string): Promise<boolean>;
121
- }
122
- //# sourceMappingURL=PendingTransactionManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PendingTransactionManager.d.ts","sourceRoot":"","sources":["../../src/core/PendingTransactionManager.ts"],"names":[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license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- /**
9
- * UserScopedSigner - Wraps ISignerAdapter with user ownership verification
10
- *
11
- * All wallet IDs are prefixed with userId to ensure User A cannot
12
- * access User B's wallets. Returns generic "not found" error for both
13
- * missing and unauthorized wallets to prevent enumeration attacks.
14
- */
15
- import type { ISignerAdapter, WalletInfo, CreateWalletParams, ImportWalletParams } from '../types/signer.js';
16
- /**
17
- * User-scoped signer wrapper.
18
- * Ensures all operations are scoped to the authenticated user.
19
- */
20
- export declare class UserScopedSigner {
21
- private readonly signer;
22
- private readonly userId;
23
- private readonly userPrefix;
24
- constructor(signer: ISignerAdapter, userId: string);
25
- /**
26
- * Get the user ID this signer is scoped to
27
- */
28
- getUserId(): string;
29
- /**
30
- * Build user-scoped wallet ID from wallet name
31
- */
32
- private scopedId;
33
- /**
34
- * Extract wallet name from scoped ID
35
- */
36
- private extractName;
37
- /**
38
- * Check if a wallet ID belongs to this user
39
- */
40
- private isOwnedByUser;
41
- /**
42
- * Transform wallet info to expose wallet name instead of internal ID
43
- */
44
- private transformWalletInfo;
45
- /**
46
- * Create a new wallet (user-scoped)
47
- */
48
- createWallet(params: Omit<CreateWalletParams, 'walletId'> & {
49
- name: string;
50
- }): Promise<WalletInfo & {
51
- name: string;
52
- }>;
53
- /**
54
- * Import a wallet from mnemonic (user-scoped)
55
- * Note: Mnemonic is passed to signer and stored securely, never returned
56
- */
57
- importWallet(params: Omit<ImportWalletParams, 'walletId'> & {
58
- name: string;
59
- }): Promise<WalletInfo & {
60
- name: string;
61
- }>;
62
- /**
63
- * Get wallet by name (user-scoped)
64
- * Returns null for both "not found" and "not owned" to prevent enumeration
65
- */
66
- getWallet(walletName: string): Promise<(WalletInfo & {
67
- name: string;
68
- }) | null>;
69
- /**
70
- * List all wallets for this user
71
- */
72
- listWallets(): Promise<(WalletInfo & {
73
- name: string;
74
- })[]>;
75
- /**
76
- * Delete a wallet (user-scoped)
77
- * Returns false for both "not found" and "not owned"
78
- */
79
- deleteWallet(walletName: string): Promise<boolean>;
80
- /**
81
- * Sign a transaction (user-scoped)
82
- * Verifies ownership before signing
83
- */
84
- signTransaction(walletName: string, unsignedBoc: string): Promise<string>;
85
- /**
86
- * Sign a message (user-scoped)
87
- * Verifies ownership before signing
88
- */
89
- signMessage(walletName: string, message: Buffer): Promise<Buffer>;
90
- /**
91
- * Get the underlying signer adapter.
92
- * Use with caution - bypasses user isolation.
93
- */
94
- getUnderlyingSigner(): ISignerAdapter;
95
- }
96
- //# sourceMappingURL=UserScopedSigner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserScopedSigner.d.ts","sourceRoot":"","sources":["../../src/core/UserScopedSigner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7G;;;GAGG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM;IAMlD;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACG,YAAY,CACd,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IASzC;;;OAGG;IACG,YAAY,CACd,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAUzC;;;OAGG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAgBpF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAc/D;;;OAGG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYxD;;;OAGG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAY/E;;;OAGG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYvE;;;OAGG;IACH,mBAAmB,IAAI,cAAc;CAGxC"}
@@ -1,59 +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
- * UserScopedStorage - Wraps IStorageAdapter with user namespace isolation
10
- *
11
- * All storage keys are prefixed with user:{userId}: to ensure
12
- * User A cannot access User B's data.
13
- */
14
- import type { IStorageAdapter } from '../types/storage.js';
15
- /**
16
- * User-scoped storage wrapper.
17
- * Automatically prefixes all keys with user namespace.
18
- */
19
- export declare class UserScopedStorage {
20
- private readonly storage;
21
- private readonly userId;
22
- private readonly prefix;
23
- constructor(storage: IStorageAdapter, userId: string);
24
- /**
25
- * Get the user ID this storage is scoped to
26
- */
27
- getUserId(): string;
28
- /**
29
- * Build full key with user prefix
30
- */
31
- private buildKey;
32
- /**
33
- * Strip user prefix from a key
34
- */
35
- private stripPrefix;
36
- /**
37
- * Get a value by key (user-scoped)
38
- */
39
- get<T>(key: string): Promise<T | null>;
40
- /**
41
- * Set a value (user-scoped)
42
- */
43
- set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
44
- /**
45
- * Delete a key (user-scoped)
46
- */
47
- delete(key: string): Promise<boolean>;
48
- /**
49
- * List keys matching prefix (user-scoped)
50
- * Returns keys with user prefix stripped.
51
- */
52
- list(subPrefix: string): Promise<string[]>;
53
- /**
54
- * Get the underlying storage adapter.
55
- * Use with caution - bypasses user isolation.
56
- */
57
- getUnderlyingStorage(): IStorageAdapter;
58
- }
59
- //# sourceMappingURL=UserScopedStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserScopedStorage.d.ts","sourceRoot":"","sources":["../../src/core/UserScopedStorage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM;IAMpD;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAI5C;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3C;;;OAGG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAMhD;;;OAGG;IACH,oBAAoB,IAAI,eAAe;CAG1C"}
@@ -1,15 +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
- * Core module exports
10
- */
11
- export { UserScopedStorage } from './UserScopedStorage.js';
12
- export { UserScopedSigner } from './UserScopedSigner.js';
13
- export { LimitsManager } from './LimitsManager.js';
14
- export { PendingTransactionManager } from './PendingTransactionManager.js';
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,144 +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 type { SwapQuote } from '@ton/walletkit';
9
- export interface CreateWalletResult {
10
- name: string;
11
- address: string;
12
- mnemonic: string[];
13
- network: 'mainnet' | 'testnet';
14
- }
15
- export interface ImportWalletResult {
16
- name: string;
17
- address: string;
18
- network: 'mainnet' | 'testnet';
19
- }
20
- export interface WalletInfo {
21
- name: string;
22
- address: string;
23
- network: 'mainnet' | 'testnet';
24
- version: 'v5r1' | 'v4r2';
25
- createdAt: string;
26
- }
27
- export interface JettonInfoResult {
28
- address: string;
29
- balance: string;
30
- name?: string;
31
- symbol?: string;
32
- decimals?: number;
33
- }
34
- export interface TransactionInfo {
35
- eventId: string;
36
- timestamp: number;
37
- type: 'TonTransfer' | 'JettonTransfer' | 'JettonSwap' | 'NftItemTransfer' | 'ContractDeploy' | 'SmartContractExec' | 'Unknown';
38
- status: 'success' | 'failure';
39
- from?: string;
40
- to?: string;
41
- amount?: string;
42
- comment?: string;
43
- jettonAddress?: string;
44
- jettonSymbol?: string;
45
- jettonAmount?: string;
46
- dex?: string;
47
- amountIn?: string;
48
- amountOut?: string;
49
- description?: string;
50
- isScam: boolean;
51
- }
52
- export interface TransferResult {
53
- success: boolean;
54
- message: string;
55
- }
56
- export interface SwapQuoteResult {
57
- quote: SwapQuote;
58
- fromToken: string;
59
- toToken: string;
60
- fromAmount: string;
61
- toAmount: string;
62
- minReceived: string;
63
- provider: string;
64
- expiresAt?: number;
65
- }
66
- export interface SwapResult {
67
- success: boolean;
68
- message: string;
69
- }
70
- /**
71
- * WalletService manages TON wallets using TonWalletKit
72
- * Supports both mainnet and testnet simultaneously
73
- */
74
- export declare class WalletService {
75
- private storage;
76
- private kit;
77
- private loadedWallets;
78
- constructor();
79
- /**
80
- * Get Network instance from network name
81
- */
82
- private getNetwork;
83
- /**
84
- * Initialize the TonWalletKit instance (supports both networks)
85
- */
86
- private getKit;
87
- /**
88
- * Create a new wallet with generated mnemonic
89
- */
90
- createWallet(name: string, version?: 'v5r1' | 'v4r2', networkName?: 'mainnet' | 'testnet'): Promise<CreateWalletResult>;
91
- /**
92
- * Import a wallet from mnemonic
93
- */
94
- importWallet(name: string, mnemonic: string[], version?: 'v5r1' | 'v4r2', networkName?: 'mainnet' | 'testnet'): Promise<ImportWalletResult>;
95
- /**
96
- * List all stored wallets
97
- */
98
- listWallets(): Promise<WalletInfo[]>;
99
- /**
100
- * Remove a wallet by name
101
- */
102
- removeWallet(name: string): Promise<boolean>;
103
- /**
104
- * Get or load a wallet by name
105
- */
106
- private getWalletByName;
107
- /**
108
- * Get TON balance for a wallet
109
- */
110
- getBalance(walletName: string): Promise<string>;
111
- /**
112
- * Get Jetton balance for a wallet
113
- */
114
- getJettonBalance(walletName: string, jettonAddress: string): Promise<string>;
115
- /**
116
- * Get all Jettons for a wallet
117
- */
118
- getJettons(walletName: string): Promise<JettonInfoResult[]>;
119
- /**
120
- * Get transaction history for a wallet using events API (like demo wallet)
121
- */
122
- getTransactions(walletName: string, limit?: number): Promise<TransactionInfo[]>;
123
- /**
124
- * Send TON to an address
125
- */
126
- sendTon(walletName: string, toAddress: string, amount: string, comment?: string): Promise<TransferResult>;
127
- /**
128
- * Send Jetton to an address
129
- */
130
- sendJetton(walletName: string, toAddress: string, jettonAddress: string, amount: string, comment?: string): Promise<TransferResult>;
131
- /**
132
- * Get a swap quote
133
- */
134
- getSwapQuote(walletName: string, fromToken: string, toToken: string, amount: string, slippageBps?: number): Promise<SwapQuoteResult>;
135
- /**
136
- * Execute a swap using a quote
137
- */
138
- executeSwap(walletName: string, quote: SwapQuote): Promise<SwapResult>;
139
- /**
140
- * Close the service and cleanup
141
- */
142
- close(): Promise<void>;
143
- }
144
- //# sourceMappingURL=WalletService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WalletService.d.ts","sourceRoot":"","sources":["../../src/services/WalletService.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH,OAAO,KAAK,EAAU,SAAS,EAA+B,MAAM,gBAAgB,CAAC;AAMrF,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB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