@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.
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/dist/adapters/InMemoryStorageAdapter.d.ts +49 -0
- package/dist/adapters/InMemoryStorageAdapter.d.ts.map +1 -0
- package/dist/adapters/LocalSignerAdapter.d.ts +107 -0
- package/dist/adapters/LocalSignerAdapter.d.ts.map +1 -0
- package/dist/adapters/SqliteSignerAdapter.d.ts +119 -0
- package/dist/adapters/SqliteSignerAdapter.d.ts.map +1 -0
- package/dist/adapters/SqliteStorageAdapter.d.ts +81 -0
- package/dist/adapters/SqliteStorageAdapter.d.ts.map +1 -0
- package/dist/adapters/TelegramUserContextProvider.d.ts +70 -0
- package/dist/adapters/TelegramUserContextProvider.d.ts.map +1 -0
- package/dist/adapters/index.d.ts +19 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +90209 -0
- package/dist/core/LimitsManager.d.ts +59 -0
- package/dist/core/LimitsManager.d.ts.map +1 -0
- package/dist/core/PendingTransactionManager.d.ts +122 -0
- package/dist/core/PendingTransactionManager.d.ts.map +1 -0
- package/dist/core/UserScopedSigner.d.ts +96 -0
- package/dist/core/UserScopedSigner.d.ts.map +1 -0
- package/dist/core/UserScopedStorage.d.ts +59 -0
- package/dist/core/UserScopedStorage.d.ts.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/factory.d.ts +53 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/index.cjs +91029 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91015 -0
- package/dist/services/McpWalletService.d.ts +253 -0
- package/dist/services/McpWalletService.d.ts.map +1 -0
- package/dist/services/WalletService.d.ts +144 -0
- package/dist/services/WalletService.d.ts.map +1 -0
- package/dist/storage/SecureStorage.d.ts +79 -0
- package/dist/storage/SecureStorage.d.ts.map +1 -0
- package/dist/tools/balance.d.ts +167 -0
- package/dist/tools/balance.d.ts.map +1 -0
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/mcp-tools.d.ts +439 -0
- package/dist/tools/mcp-tools.d.ts.map +1 -0
- package/dist/tools/swap.d.ts +110 -0
- package/dist/tools/swap.d.ts.map +1 -0
- package/dist/tools/transfer.d.ts +146 -0
- package/dist/tools/transfer.d.ts.map +1 -0
- package/dist/tools/wallet.d.ts +138 -0
- package/dist/tools/wallet.d.ts.map +1 -0
- package/dist/types/config.d.ts +65 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/contacts.d.ts +61 -0
- package/dist/types/contacts.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/signer.d.ts +120 -0
- package/dist/types/signer.d.ts.map +1 -0
- package/dist/types/storage.d.ts +41 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/user-context.d.ts +48 -0
- package/dist/types/user-context.d.ts.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,253 @@
|
|
|
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
|
+
import type { LimitsConfig } from '../types/config.js';
|
|
10
|
+
import type { IStorageAdapter } from '../types/storage.js';
|
|
11
|
+
import type { ISignerAdapter } from '../types/signer.js';
|
|
12
|
+
import type { IContactResolver } from '../types/contacts.js';
|
|
13
|
+
import { UserScopedStorage } from '../core/UserScopedStorage.js';
|
|
14
|
+
import { UserScopedSigner } from '../core/UserScopedSigner.js';
|
|
15
|
+
import { LimitsManager } from '../core/LimitsManager.js';
|
|
16
|
+
import { PendingTransactionManager } from '../core/PendingTransactionManager.js';
|
|
17
|
+
import type { PendingTransaction } from '../core/PendingTransactionManager.js';
|
|
18
|
+
/**
|
|
19
|
+
* Wallet info returned to tools (no sensitive data)
|
|
20
|
+
*/
|
|
21
|
+
export interface McpWalletInfo {
|
|
22
|
+
name: string;
|
|
23
|
+
address: string;
|
|
24
|
+
network: 'mainnet' | 'testnet';
|
|
25
|
+
version: 'v5r1' | 'v4r2';
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Result of creating a wallet (no mnemonic!)
|
|
30
|
+
*/
|
|
31
|
+
export interface CreateWalletResult {
|
|
32
|
+
name: string;
|
|
33
|
+
address: string;
|
|
34
|
+
network: 'mainnet' | 'testnet';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Result of importing a wallet
|
|
38
|
+
*/
|
|
39
|
+
export interface ImportWalletResult {
|
|
40
|
+
name: string;
|
|
41
|
+
address: string;
|
|
42
|
+
network: 'mainnet' | 'testnet';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Jetton information
|
|
46
|
+
*/
|
|
47
|
+
export interface JettonInfoResult {
|
|
48
|
+
address: string;
|
|
49
|
+
balance: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
symbol?: string;
|
|
52
|
+
decimals?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Transaction info (from events API)
|
|
56
|
+
*/
|
|
57
|
+
export interface TransactionInfo {
|
|
58
|
+
eventId: string;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
type: 'TonTransfer' | 'JettonTransfer' | 'JettonSwap' | 'NftItemTransfer' | 'ContractDeploy' | 'SmartContractExec' | 'Unknown';
|
|
61
|
+
status: 'success' | 'failure';
|
|
62
|
+
from?: string;
|
|
63
|
+
to?: string;
|
|
64
|
+
amount?: string;
|
|
65
|
+
comment?: string;
|
|
66
|
+
jettonAddress?: string;
|
|
67
|
+
jettonSymbol?: string;
|
|
68
|
+
jettonAmount?: string;
|
|
69
|
+
dex?: string;
|
|
70
|
+
amountIn?: string;
|
|
71
|
+
amountOut?: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
isScam: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Transfer result
|
|
77
|
+
*/
|
|
78
|
+
export interface TransferResult {
|
|
79
|
+
success: boolean;
|
|
80
|
+
message: string;
|
|
81
|
+
pendingTransactionId?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Swap quote result
|
|
85
|
+
*/
|
|
86
|
+
export interface SwapQuoteResult {
|
|
87
|
+
quote: SwapQuote;
|
|
88
|
+
fromToken: string;
|
|
89
|
+
toToken: string;
|
|
90
|
+
fromAmount: string;
|
|
91
|
+
toAmount: string;
|
|
92
|
+
minReceived: string;
|
|
93
|
+
provider: string;
|
|
94
|
+
expiresAt?: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Swap result
|
|
98
|
+
*/
|
|
99
|
+
export interface SwapResult {
|
|
100
|
+
success: boolean;
|
|
101
|
+
message: string;
|
|
102
|
+
pendingTransactionId?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Network configuration with optional API key
|
|
106
|
+
*/
|
|
107
|
+
export interface NetworkConfig {
|
|
108
|
+
/** TonCenter API key for this network */
|
|
109
|
+
apiKey?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Configuration for McpWalletService
|
|
113
|
+
*/
|
|
114
|
+
export interface McpWalletServiceConfig {
|
|
115
|
+
storage: IStorageAdapter;
|
|
116
|
+
signer: ISignerAdapter;
|
|
117
|
+
contacts?: IContactResolver;
|
|
118
|
+
defaultNetwork?: 'mainnet' | 'testnet';
|
|
119
|
+
limits?: LimitsConfig;
|
|
120
|
+
requireConfirmation?: boolean;
|
|
121
|
+
/** Network-specific configuration */
|
|
122
|
+
networks?: {
|
|
123
|
+
mainnet?: NetworkConfig;
|
|
124
|
+
testnet?: NetworkConfig;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* McpWalletService manages wallet operations for multi-user MCP deployments.
|
|
129
|
+
*/
|
|
130
|
+
export declare class McpWalletService {
|
|
131
|
+
private readonly config;
|
|
132
|
+
private readonly limitsManager;
|
|
133
|
+
private readonly pendingManager;
|
|
134
|
+
private kit;
|
|
135
|
+
private loadedWallets;
|
|
136
|
+
constructor(config: McpWalletServiceConfig);
|
|
137
|
+
/**
|
|
138
|
+
* Get Network instance from network name
|
|
139
|
+
*/
|
|
140
|
+
private getNetwork;
|
|
141
|
+
/**
|
|
142
|
+
* Initialize TonWalletKit
|
|
143
|
+
*/
|
|
144
|
+
private getKit;
|
|
145
|
+
/**
|
|
146
|
+
* Create user-scoped storage wrapper
|
|
147
|
+
*/
|
|
148
|
+
createUserStorage(userId: string): UserScopedStorage;
|
|
149
|
+
/**
|
|
150
|
+
* Create user-scoped signer wrapper
|
|
151
|
+
*/
|
|
152
|
+
createUserSigner(userId: string): UserScopedSigner;
|
|
153
|
+
/**
|
|
154
|
+
* Get limits manager
|
|
155
|
+
*/
|
|
156
|
+
getLimitsManager(): LimitsManager;
|
|
157
|
+
/**
|
|
158
|
+
* Get pending transaction manager
|
|
159
|
+
*/
|
|
160
|
+
getPendingManager(): PendingTransactionManager;
|
|
161
|
+
/**
|
|
162
|
+
* Check if confirmation is required
|
|
163
|
+
*/
|
|
164
|
+
requiresConfirmation(): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Create a new wallet for a user
|
|
167
|
+
*/
|
|
168
|
+
createWallet(userSigner: UserScopedSigner, userStorage: UserScopedStorage, name: string, version?: 'v5r1' | 'v4r2', networkName?: 'mainnet' | 'testnet'): Promise<CreateWalletResult>;
|
|
169
|
+
/**
|
|
170
|
+
* Import a wallet for a user
|
|
171
|
+
*/
|
|
172
|
+
importWallet(userSigner: UserScopedSigner, userStorage: UserScopedStorage, name: string, mnemonic: string[], version?: 'v5r1' | 'v4r2', networkName?: 'mainnet' | 'testnet'): Promise<ImportWalletResult>;
|
|
173
|
+
/**
|
|
174
|
+
* List all wallets for a user
|
|
175
|
+
*/
|
|
176
|
+
listWallets(userSigner: UserScopedSigner): Promise<McpWalletInfo[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Remove a wallet for a user
|
|
179
|
+
*/
|
|
180
|
+
removeWallet(userSigner: UserScopedSigner, userStorage: UserScopedStorage, name: string): Promise<boolean>;
|
|
181
|
+
/**
|
|
182
|
+
* Get or load a wallet for balance/transfer operations
|
|
183
|
+
*/
|
|
184
|
+
private getWalletForOperations;
|
|
185
|
+
/**
|
|
186
|
+
* Get TON balance
|
|
187
|
+
*/
|
|
188
|
+
getBalance(userSigner: UserScopedSigner, walletName: string): Promise<string>;
|
|
189
|
+
/**
|
|
190
|
+
* Get Jetton balance
|
|
191
|
+
*/
|
|
192
|
+
getJettonBalance(userSigner: UserScopedSigner, walletName: string, jettonAddress: string): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Get all Jettons
|
|
195
|
+
*/
|
|
196
|
+
getJettons(userSigner: UserScopedSigner, walletName: string): Promise<JettonInfoResult[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Get transaction history for a wallet
|
|
199
|
+
*/
|
|
200
|
+
/**
|
|
201
|
+
* Get transaction history using events API (like demo wallet)
|
|
202
|
+
*/
|
|
203
|
+
getTransactions(userSigner: UserScopedSigner, walletName: string, limit?: number): Promise<TransactionInfo[]>;
|
|
204
|
+
/**
|
|
205
|
+
* Send TON (with optional confirmation flow)
|
|
206
|
+
*/
|
|
207
|
+
sendTon(userSigner: UserScopedSigner, userStorage: UserScopedStorage, walletName: string, toAddress: string, amountNano: string, amountTon: string, comment?: string): Promise<TransferResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Execute TON transfer (internal)
|
|
210
|
+
*/
|
|
211
|
+
executeTonTransfer(userSigner: UserScopedSigner, userStorage: UserScopedStorage, walletName: string, toAddress: string, amountNano: string, comment?: string): Promise<TransferResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Send Jetton (with optional confirmation flow)
|
|
214
|
+
*/
|
|
215
|
+
sendJetton(userSigner: UserScopedSigner, userStorage: UserScopedStorage, walletName: string, toAddress: string, jettonAddress: string, amountRaw: string, amountHuman: string, symbol: string | undefined, decimals: number, comment?: string): Promise<TransferResult>;
|
|
216
|
+
/**
|
|
217
|
+
* Execute Jetton transfer (internal)
|
|
218
|
+
*/
|
|
219
|
+
executeJettonTransfer(userSigner: UserScopedSigner, walletName: string, toAddress: string, jettonAddress: string, amountRaw: string, comment?: string): Promise<TransferResult>;
|
|
220
|
+
/**
|
|
221
|
+
* Get swap quote
|
|
222
|
+
*/
|
|
223
|
+
getSwapQuote(userSigner: UserScopedSigner, walletName: string, fromToken: string, toToken: string, amount: string, slippageBps?: number): Promise<SwapQuoteResult>;
|
|
224
|
+
/**
|
|
225
|
+
* Execute swap (with optional confirmation flow)
|
|
226
|
+
*/
|
|
227
|
+
executeSwap(userSigner: UserScopedSigner, userStorage: UserScopedStorage, walletName: string, quote: SwapQuote): Promise<SwapResult>;
|
|
228
|
+
/**
|
|
229
|
+
* Execute swap (internal)
|
|
230
|
+
*/
|
|
231
|
+
executeSwapInternal(userSigner: UserScopedSigner, walletName: string, quote: SwapQuote): Promise<SwapResult>;
|
|
232
|
+
/**
|
|
233
|
+
* Confirm a pending transaction
|
|
234
|
+
*/
|
|
235
|
+
confirmTransaction(userSigner: UserScopedSigner, userStorage: UserScopedStorage, transactionId: string): Promise<TransferResult | SwapResult>;
|
|
236
|
+
/**
|
|
237
|
+
* Cancel a pending transaction
|
|
238
|
+
*/
|
|
239
|
+
cancelTransaction(userStorage: UserScopedStorage, transactionId: string): Promise<boolean>;
|
|
240
|
+
/**
|
|
241
|
+
* List pending transactions
|
|
242
|
+
*/
|
|
243
|
+
listPendingTransactions(userStorage: UserScopedStorage): Promise<PendingTransaction[]>;
|
|
244
|
+
/**
|
|
245
|
+
* Resolve contact name to address
|
|
246
|
+
*/
|
|
247
|
+
resolveContact(userId: string, name: string): Promise<string | null>;
|
|
248
|
+
/**
|
|
249
|
+
* Close and cleanup
|
|
250
|
+
*/
|
|
251
|
+
close(): Promise<void>;
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=McpWalletService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpWalletService.d.ts","sourceRoot":"","sources":["../../src/services/McpWalletService.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH,OAAO,KAAK,EAAU,SAAS,EAAgD,MAAM,gBAAgB,CAAC;AAGtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EACR,kBAAkB,EAIrB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,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;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAA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;IAyB1B;;OAEG;IACG,YAAY,CACd,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC;IA+B3B;;OAEG;IACG,WAAW,CACb,UAAU,EAAE,gBAAgB,EAC5B,WAAW,EAAE,iBAAiB,EAC9B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,GACjB,OAAO,CAAC,UAAU,CAAC;IA8BtB;;OAEG;IACG,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IAgClH;;OAEG;IACG,kBAAkB,CACpB,UAAU,EAAE,gBAAgB,EAC5B,WAAW,EAAE,iBAAiB,EAC9B,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,cAAc,GAAG,UAAU,CAAC;IAuCvC;;OAEG;IACG,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhG;;OAEG;IACG,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAI5F;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAO1E;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,MA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e;IA4C7B;;OAEG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMrD;;OAEG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMlF;;OAEG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAmBjE;;OAEG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA2FzF;;OAEG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAwB/G;;OAEG;IACG,UAAU,CACZ,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC;IAyB1B;;OAEG;IACG,YAAY,CACd,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC;IAgC3B;;OAEG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IAiC5E;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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 WalletData {
|
|
9
|
+
name: string;
|
|
10
|
+
address: string;
|
|
11
|
+
mnemonic: string[];
|
|
12
|
+
network: 'mainnet' | 'testnet';
|
|
13
|
+
version: 'v5r1' | 'v4r2';
|
|
14
|
+
createdAt: string;
|
|
15
|
+
}
|
|
16
|
+
export interface StorageFile {
|
|
17
|
+
version: number;
|
|
18
|
+
wallets: WalletData[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Storage provider interface - allows swapping plaintext for encrypted storage
|
|
22
|
+
*/
|
|
23
|
+
export interface StorageProvider {
|
|
24
|
+
save(data: StorageFile): Promise<void>;
|
|
25
|
+
load(): Promise<StorageFile>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Plaintext storage provider - stores data as JSON
|
|
29
|
+
* TODO: Replace with EncryptedStorageProvider for production use
|
|
30
|
+
*/
|
|
31
|
+
export declare class PlaintextStorageProvider implements StorageProvider {
|
|
32
|
+
private filePath;
|
|
33
|
+
constructor(filePath: string);
|
|
34
|
+
save(data: StorageFile): Promise<void>;
|
|
35
|
+
load(): Promise<StorageFile>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* SecureStorage class - manages wallet data with pluggable storage providers
|
|
39
|
+
*/
|
|
40
|
+
export declare class SecureStorage {
|
|
41
|
+
private provider;
|
|
42
|
+
private cache;
|
|
43
|
+
constructor(provider?: StorageProvider);
|
|
44
|
+
/**
|
|
45
|
+
* Get all stored wallets
|
|
46
|
+
*/
|
|
47
|
+
getWallets(): Promise<WalletData[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Get a wallet by name
|
|
50
|
+
*/
|
|
51
|
+
getWallet(name: string): Promise<WalletData | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Get a wallet by address
|
|
54
|
+
*/
|
|
55
|
+
getWalletByAddress(address: string): Promise<WalletData | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Get wallet ID (network:address format, matching @ton/walletkit pattern)
|
|
58
|
+
*/
|
|
59
|
+
getWalletId(wallet: WalletData): string;
|
|
60
|
+
/**
|
|
61
|
+
* Add a new wallet
|
|
62
|
+
*/
|
|
63
|
+
addWallet(wallet: WalletData): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Remove a wallet by name
|
|
66
|
+
*/
|
|
67
|
+
removeWallet(name: string): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Update a wallet
|
|
70
|
+
*/
|
|
71
|
+
updateWallet(name: string, updates: Partial<Omit<WalletData, 'name'>>): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Clear all wallets
|
|
74
|
+
*/
|
|
75
|
+
clearAll(): Promise<void>;
|
|
76
|
+
private loadData;
|
|
77
|
+
private saveData;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=SecureStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecureStorage.d.ts","sourceRoot":"","sources":["../../src/storage/SecureStorage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,eAAe;IAC5D,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,EAAE,MAAM;IAItB,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtC,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;CAOrC;AAED;;GAEG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,KAAK,CAA4B;gBAE7B,QAAQ,CAAC,EAAE,eAAe;IAKtC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAKzC;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAK9D;;OAEG;IACG,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAK1E;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAIvC;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBlD;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAalD;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAa9F;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAIjB,QAAQ;YAOR,QAAQ;CAIzB"}
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
* Balance query MCP tools
|
|
10
|
+
*
|
|
11
|
+
* All balance responses include both raw and human-readable amounts:
|
|
12
|
+
* - rawBalance: The balance in smallest units (nanoTON for TON, raw units for jettons)
|
|
13
|
+
* - balance: Human-readable amount with proper decimal formatting
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import type { WalletService } from '../services/WalletService.js';
|
|
17
|
+
/**
|
|
18
|
+
* Converts raw units to human-readable amount.
|
|
19
|
+
*
|
|
20
|
+
* @param rawAmount - Raw amount as string (e.g., "1500000000")
|
|
21
|
+
* @param decimals - Number of decimal places for the token
|
|
22
|
+
* @returns Human-readable amount as string (e.g., "1.5")
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* fromRawAmount("1500000000", 9) // "1.5" (1.5 TON)
|
|
26
|
+
* fromRawAmount("1000", 6) // "0.001" (0.001 USDT)
|
|
27
|
+
* fromRawAmount("100000000000", 9) // "100" (100 TON)
|
|
28
|
+
*/
|
|
29
|
+
declare function fromRawAmount(rawAmount: string, decimals: number): string;
|
|
30
|
+
/** TON has 9 decimal places (1 TON = 1,000,000,000 nanoTON) */
|
|
31
|
+
declare const TON_DECIMALS = 9;
|
|
32
|
+
export declare const getBalanceSchema: z.ZodObject<{
|
|
33
|
+
wallet: z.ZodString;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
wallet: string;
|
|
36
|
+
}, {
|
|
37
|
+
wallet: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const getJettonBalanceSchema: z.ZodObject<{
|
|
40
|
+
wallet: z.ZodString;
|
|
41
|
+
jettonAddress: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
wallet: string;
|
|
44
|
+
jettonAddress: string;
|
|
45
|
+
}, {
|
|
46
|
+
wallet: string;
|
|
47
|
+
jettonAddress: string;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const getJettonsSchema: z.ZodObject<{
|
|
50
|
+
wallet: z.ZodString;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
wallet: string;
|
|
53
|
+
}, {
|
|
54
|
+
wallet: string;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const getTransactionsSchema: z.ZodObject<{
|
|
57
|
+
wallet: z.ZodString;
|
|
58
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
wallet: string;
|
|
61
|
+
limit?: number | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
wallet: string;
|
|
64
|
+
limit?: number | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
export declare function createBalanceTools(walletService: WalletService): {
|
|
67
|
+
get_balance: {
|
|
68
|
+
description: string;
|
|
69
|
+
inputSchema: z.ZodObject<{
|
|
70
|
+
wallet: z.ZodString;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
wallet: string;
|
|
73
|
+
}, {
|
|
74
|
+
wallet: string;
|
|
75
|
+
}>;
|
|
76
|
+
handler: (args: z.infer<typeof getBalanceSchema>) => Promise<{
|
|
77
|
+
content: {
|
|
78
|
+
type: "text";
|
|
79
|
+
text: string;
|
|
80
|
+
}[];
|
|
81
|
+
isError?: undefined;
|
|
82
|
+
} | {
|
|
83
|
+
content: {
|
|
84
|
+
type: "text";
|
|
85
|
+
text: string;
|
|
86
|
+
}[];
|
|
87
|
+
isError: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
};
|
|
90
|
+
get_jetton_balance: {
|
|
91
|
+
description: string;
|
|
92
|
+
inputSchema: z.ZodObject<{
|
|
93
|
+
wallet: z.ZodString;
|
|
94
|
+
jettonAddress: z.ZodString;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
wallet: string;
|
|
97
|
+
jettonAddress: string;
|
|
98
|
+
}, {
|
|
99
|
+
wallet: string;
|
|
100
|
+
jettonAddress: string;
|
|
101
|
+
}>;
|
|
102
|
+
handler: (args: z.infer<typeof getJettonBalanceSchema>) => Promise<{
|
|
103
|
+
content: {
|
|
104
|
+
type: "text";
|
|
105
|
+
text: string;
|
|
106
|
+
}[];
|
|
107
|
+
isError: boolean;
|
|
108
|
+
} | {
|
|
109
|
+
content: {
|
|
110
|
+
type: "text";
|
|
111
|
+
text: string;
|
|
112
|
+
}[];
|
|
113
|
+
isError?: undefined;
|
|
114
|
+
}>;
|
|
115
|
+
};
|
|
116
|
+
get_jettons: {
|
|
117
|
+
description: string;
|
|
118
|
+
inputSchema: z.ZodObject<{
|
|
119
|
+
wallet: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
wallet: string;
|
|
122
|
+
}, {
|
|
123
|
+
wallet: string;
|
|
124
|
+
}>;
|
|
125
|
+
handler: (args: z.infer<typeof getJettonsSchema>) => Promise<{
|
|
126
|
+
content: {
|
|
127
|
+
type: "text";
|
|
128
|
+
text: string;
|
|
129
|
+
}[];
|
|
130
|
+
isError?: undefined;
|
|
131
|
+
} | {
|
|
132
|
+
content: {
|
|
133
|
+
type: "text";
|
|
134
|
+
text: string;
|
|
135
|
+
}[];
|
|
136
|
+
isError: boolean;
|
|
137
|
+
}>;
|
|
138
|
+
};
|
|
139
|
+
get_transactions: {
|
|
140
|
+
description: string;
|
|
141
|
+
inputSchema: z.ZodObject<{
|
|
142
|
+
wallet: z.ZodString;
|
|
143
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
wallet: string;
|
|
146
|
+
limit?: number | undefined;
|
|
147
|
+
}, {
|
|
148
|
+
wallet: string;
|
|
149
|
+
limit?: number | undefined;
|
|
150
|
+
}>;
|
|
151
|
+
handler: (args: z.infer<typeof getTransactionsSchema>) => Promise<{
|
|
152
|
+
content: {
|
|
153
|
+
type: "text";
|
|
154
|
+
text: string;
|
|
155
|
+
}[];
|
|
156
|
+
isError?: undefined;
|
|
157
|
+
} | {
|
|
158
|
+
content: {
|
|
159
|
+
type: "text";
|
|
160
|
+
text: string;
|
|
161
|
+
}[];
|
|
162
|
+
isError: boolean;
|
|
163
|
+
}>;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
export { fromRawAmount, TON_DECIMALS };
|
|
167
|
+
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/tools/balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQlE;AAED,+DAA+D;AAC/D,QAAA,MAAM,YAAY,IAAI,CAAC;AAEvB,eAAO,MAAM,gBAAgB;;;;;;EAE3B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;EAE3B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;EAQhC,CAAC;AAEH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,aAAa;;;;;;;;;;wBAM7B,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;wBA6ChC,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;wBA8FtC,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuDhC,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC;;;;;;;;;;;;;;EA0EtE;AAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
* Tool registration and exports
|
|
10
|
+
*/
|
|
11
|
+
export { createWalletTools } from './wallet.js';
|
|
12
|
+
export { createBalanceTools } from './balance.js';
|
|
13
|
+
export { createTransferTools } from './transfer.js';
|
|
14
|
+
export { createSwapTools } from './swap.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|