@t402/ton 2.0.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/dist/cjs/exact/client/index.d.ts +53 -0
- package/dist/cjs/exact/client/index.js +181 -0
- package/dist/cjs/exact/client/index.js.map +1 -0
- package/dist/cjs/exact/facilitator/index.d.ts +79 -0
- package/dist/cjs/exact/facilitator/index.js +331 -0
- package/dist/cjs/exact/facilitator/index.js.map +1 -0
- package/dist/cjs/exact/server/index.d.ts +135 -0
- package/dist/cjs/exact/server/index.js +318 -0
- package/dist/cjs/exact/server/index.js.map +1 -0
- package/dist/cjs/index.d.ts +293 -0
- package/dist/cjs/index.js +442 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/signer-CFiw2DST.d.ts +277 -0
- package/dist/esm/chunk-6LOUEHJT.mjs +192 -0
- package/dist/esm/chunk-6LOUEHJT.mjs.map +1 -0
- package/dist/esm/chunk-RST5PY7E.mjs +85 -0
- package/dist/esm/chunk-RST5PY7E.mjs.map +1 -0
- package/dist/esm/chunk-ZCMWKFVA.mjs +101 -0
- package/dist/esm/chunk-ZCMWKFVA.mjs.map +1 -0
- package/dist/esm/exact/client/index.d.mts +53 -0
- package/dist/esm/exact/client/index.mjs +8 -0
- package/dist/esm/exact/client/index.mjs.map +1 -0
- package/dist/esm/exact/facilitator/index.d.mts +79 -0
- package/dist/esm/exact/facilitator/index.mjs +258 -0
- package/dist/esm/exact/facilitator/index.mjs.map +1 -0
- package/dist/esm/exact/server/index.d.mts +135 -0
- package/dist/esm/exact/server/index.mjs +212 -0
- package/dist/esm/exact/server/index.mjs.map +1 -0
- package/dist/esm/index.d.mts +293 -0
- package/dist/esm/index.mjs +108 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/signer-CFiw2DST.d.mts +277 -0
- package/package.json +99 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
export { ExactTonScheme } from './exact/client/index.js';
|
|
2
|
+
export { C as ClientTonSigner, b as ExactTonPayload, E as ExactTonPayloadV2, F as FacilitatorTonSigner, S as SignMessageParams, T as TransactionConfirmation, V as VerifyMessageParams, c as VerifyMessageResult, W as WaitForTransactionParams, t as toClientTonSigner, a as toFacilitatorTonSigner } from './signer-CFiw2DST.js';
|
|
3
|
+
import { Address, Cell } from '@ton/core';
|
|
4
|
+
import { Network } from '@t402/core/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* TON Jetton Token Configuration
|
|
8
|
+
*
|
|
9
|
+
* This module provides comprehensive Jetton token definitions including:
|
|
10
|
+
* - USDT (Tether USD on TON)
|
|
11
|
+
* - Network-specific configurations
|
|
12
|
+
* - Helper functions for token lookups
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Jetton token configuration
|
|
16
|
+
*/
|
|
17
|
+
interface JettonConfig {
|
|
18
|
+
/** Jetton master contract address (friendly format) */
|
|
19
|
+
masterAddress: string;
|
|
20
|
+
/** Token symbol */
|
|
21
|
+
symbol: string;
|
|
22
|
+
/** Token name */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Number of decimal places */
|
|
25
|
+
decimals: number;
|
|
26
|
+
/** Payment priority (lower = higher priority) */
|
|
27
|
+
priority: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Network token registry mapping network -> symbol -> config
|
|
31
|
+
*/
|
|
32
|
+
type NetworkJettonRegistry = Record<string, Record<string, JettonConfig>>;
|
|
33
|
+
/**
|
|
34
|
+
* USDT Jetton Master Contract Addresses by Network
|
|
35
|
+
*
|
|
36
|
+
* USDT on TON follows the TEP-74 Jetton standard.
|
|
37
|
+
* @see https://docs.tether.to/tether-on-ton
|
|
38
|
+
*/
|
|
39
|
+
declare const USDT_ADDRESSES: Record<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* Complete Jetton registry with all supported tokens per network
|
|
42
|
+
*/
|
|
43
|
+
declare const JETTON_REGISTRY: NetworkJettonRegistry;
|
|
44
|
+
/**
|
|
45
|
+
* Get Jetton configuration for a specific token on a network
|
|
46
|
+
*
|
|
47
|
+
* @param network - Network identifier (CAIP-2 format)
|
|
48
|
+
* @param symbol - Token symbol (e.g., "USDT")
|
|
49
|
+
* @returns Jetton configuration or undefined
|
|
50
|
+
*/
|
|
51
|
+
declare function getJettonConfig(network: string, symbol: string): JettonConfig | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get all Jettons available on a network
|
|
54
|
+
*
|
|
55
|
+
* @param network - Network identifier
|
|
56
|
+
* @returns Array of Jetton configurations sorted by priority
|
|
57
|
+
*/
|
|
58
|
+
declare function getNetworkJettons(network: string): JettonConfig[];
|
|
59
|
+
/**
|
|
60
|
+
* Get the default/preferred Jetton for a network
|
|
61
|
+
* Prefers USDT based on priority
|
|
62
|
+
*
|
|
63
|
+
* @param network - Network identifier
|
|
64
|
+
* @returns Default Jetton configuration or undefined
|
|
65
|
+
*/
|
|
66
|
+
declare function getDefaultJetton(network: string): JettonConfig | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Get Jetton by master contract address on a network
|
|
69
|
+
*
|
|
70
|
+
* @param network - Network identifier
|
|
71
|
+
* @param address - Jetton master contract address
|
|
72
|
+
* @returns Jetton configuration or undefined
|
|
73
|
+
*/
|
|
74
|
+
declare function getJettonByAddress(network: string, address: string): JettonConfig | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Get all networks that support a specific Jetton
|
|
77
|
+
*
|
|
78
|
+
* @param symbol - Token symbol
|
|
79
|
+
* @returns Array of network identifiers
|
|
80
|
+
*/
|
|
81
|
+
declare function getNetworksForJetton(symbol: string): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Get USDT networks on TON
|
|
84
|
+
*
|
|
85
|
+
* @returns Array of networks supporting USDT
|
|
86
|
+
*/
|
|
87
|
+
declare function getUsdtNetworks(): string[];
|
|
88
|
+
/**
|
|
89
|
+
* Check if a network is supported
|
|
90
|
+
*
|
|
91
|
+
* @param network - Network identifier to check
|
|
92
|
+
* @returns true if network has configured Jettons
|
|
93
|
+
*/
|
|
94
|
+
declare function isNetworkSupported(network: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Get all supported networks
|
|
97
|
+
*
|
|
98
|
+
* @returns Array of all supported network identifiers
|
|
99
|
+
*/
|
|
100
|
+
declare function getSupportedNetworks(): string[];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* TON Network Constants
|
|
104
|
+
*
|
|
105
|
+
* This module provides constants for TON blockchain integration including:
|
|
106
|
+
* - CAIP-2 network identifiers
|
|
107
|
+
* - RPC endpoints
|
|
108
|
+
* - Jetton transfer operation codes
|
|
109
|
+
* - Default gas amounts
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* CAIP-2 Network Identifiers for TON
|
|
113
|
+
* Using simple identifiers for mainnet/testnet
|
|
114
|
+
*/
|
|
115
|
+
declare const TON_MAINNET_CAIP2 = "ton:mainnet";
|
|
116
|
+
declare const TON_TESTNET_CAIP2 = "ton:testnet";
|
|
117
|
+
/**
|
|
118
|
+
* Supported TON networks
|
|
119
|
+
*/
|
|
120
|
+
declare const TON_NETWORKS: readonly ["ton:mainnet", "ton:testnet"];
|
|
121
|
+
type TonNetwork = (typeof TON_NETWORKS)[number];
|
|
122
|
+
/**
|
|
123
|
+
* Default RPC endpoints (TonCenter API v2)
|
|
124
|
+
*/
|
|
125
|
+
declare const TON_MAINNET_ENDPOINT = "https://toncenter.com/api/v2/jsonRPC";
|
|
126
|
+
declare const TON_TESTNET_ENDPOINT = "https://testnet.toncenter.com/api/v2/jsonRPC";
|
|
127
|
+
/**
|
|
128
|
+
* TON API v4 endpoints (for @ton/ton TonClient4)
|
|
129
|
+
*/
|
|
130
|
+
declare const TON_MAINNET_V4_ENDPOINT = "https://mainnet-v4.tonhubapi.com";
|
|
131
|
+
declare const TON_TESTNET_V4_ENDPOINT = "https://testnet-v4.tonhubapi.com";
|
|
132
|
+
/**
|
|
133
|
+
* Network endpoint mapping
|
|
134
|
+
*/
|
|
135
|
+
declare const NETWORK_ENDPOINTS: Record<string, string>;
|
|
136
|
+
declare const NETWORK_V4_ENDPOINTS: Record<string, string>;
|
|
137
|
+
/**
|
|
138
|
+
* Jetton Transfer Operation Codes (TEP-74)
|
|
139
|
+
* @see https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md
|
|
140
|
+
*/
|
|
141
|
+
declare const JETTON_TRANSFER_OP = 260734629;
|
|
142
|
+
declare const JETTON_INTERNAL_TRANSFER_OP = 395134233;
|
|
143
|
+
declare const JETTON_TRANSFER_NOTIFICATION_OP = 1935855772;
|
|
144
|
+
declare const JETTON_BURN_OP = 1499400124;
|
|
145
|
+
/**
|
|
146
|
+
* Default gas amounts for Jetton transfers
|
|
147
|
+
* TON requires attaching TON for gas to internal messages
|
|
148
|
+
*/
|
|
149
|
+
declare const DEFAULT_JETTON_TRANSFER_TON = 100000000n;
|
|
150
|
+
declare const DEFAULT_FORWARD_TON = 1n;
|
|
151
|
+
declare const MIN_JETTON_TRANSFER_TON = 50000000n;
|
|
152
|
+
/**
|
|
153
|
+
* Maximum gas amounts to prevent excessive fees
|
|
154
|
+
*/
|
|
155
|
+
declare const MAX_JETTON_TRANSFER_TON = 500000000n;
|
|
156
|
+
/**
|
|
157
|
+
* Scheme identifier for exact payments
|
|
158
|
+
*/
|
|
159
|
+
declare const SCHEME_EXACT = "exact";
|
|
160
|
+
/**
|
|
161
|
+
* Default timeout for payment validity (in seconds)
|
|
162
|
+
*/
|
|
163
|
+
declare const DEFAULT_VALIDITY_DURATION = 3600;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* TON Utility Functions
|
|
167
|
+
*
|
|
168
|
+
* Helper functions for TON address handling, message building,
|
|
169
|
+
* and network operations.
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Normalize network identifier to CAIP-2 format
|
|
174
|
+
*
|
|
175
|
+
* @param network - Network identifier (may be legacy format)
|
|
176
|
+
* @returns Normalized CAIP-2 network identifier
|
|
177
|
+
* @throws Error if network is not supported
|
|
178
|
+
*/
|
|
179
|
+
declare function normalizeNetwork(network: Network): Network;
|
|
180
|
+
/**
|
|
181
|
+
* Get RPC endpoint for a network
|
|
182
|
+
*
|
|
183
|
+
* @param network - Network identifier
|
|
184
|
+
* @returns RPC endpoint URL
|
|
185
|
+
*/
|
|
186
|
+
declare function getEndpoint(network: Network): string;
|
|
187
|
+
/**
|
|
188
|
+
* Check if a network identifier is a supported TON network
|
|
189
|
+
*
|
|
190
|
+
* @param network - Network identifier to check
|
|
191
|
+
* @returns true if supported
|
|
192
|
+
*/
|
|
193
|
+
declare function isTonNetwork(network: string): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Validate TON address format
|
|
196
|
+
*
|
|
197
|
+
* @param address - Address to validate
|
|
198
|
+
* @returns true if valid TON address
|
|
199
|
+
*/
|
|
200
|
+
declare function validateTonAddress(address: string): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Parse TON address from string
|
|
203
|
+
*
|
|
204
|
+
* @param address - Address string (friendly or raw format)
|
|
205
|
+
* @returns Parsed Address object
|
|
206
|
+
* @throws Error if invalid format
|
|
207
|
+
*/
|
|
208
|
+
declare function parseTonAddress(address: string): Address;
|
|
209
|
+
/**
|
|
210
|
+
* Compare two TON addresses for equality
|
|
211
|
+
* Handles different address formats (friendly, raw, bounceable/non-bounceable)
|
|
212
|
+
*
|
|
213
|
+
* @param addr1 - First address
|
|
214
|
+
* @param addr2 - Second address
|
|
215
|
+
* @returns true if addresses are equal
|
|
216
|
+
*/
|
|
217
|
+
declare function addressesEqual(addr1: string, addr2: string): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Format address to friendly format
|
|
220
|
+
*
|
|
221
|
+
* @param address - Address to format
|
|
222
|
+
* @param options - Formatting options
|
|
223
|
+
* @returns Friendly format address string
|
|
224
|
+
*/
|
|
225
|
+
declare function formatAddress(address: string | Address, options?: {
|
|
226
|
+
bounceable?: boolean;
|
|
227
|
+
testOnly?: boolean;
|
|
228
|
+
}): string;
|
|
229
|
+
/**
|
|
230
|
+
* Convert decimal amount to smallest units (e.g., nano-Jettons)
|
|
231
|
+
*
|
|
232
|
+
* @param decimalAmount - Amount in decimal format (e.g., "1.50")
|
|
233
|
+
* @param decimals - Number of decimal places
|
|
234
|
+
* @returns Amount in smallest units as string
|
|
235
|
+
*/
|
|
236
|
+
declare function convertToJettonAmount(decimalAmount: string, decimals: number): string;
|
|
237
|
+
/**
|
|
238
|
+
* Convert smallest units to decimal amount
|
|
239
|
+
*
|
|
240
|
+
* @param jettonAmount - Amount in smallest units
|
|
241
|
+
* @param decimals - Number of decimal places
|
|
242
|
+
* @returns Amount in decimal format as string
|
|
243
|
+
*/
|
|
244
|
+
declare function convertFromJettonAmount(jettonAmount: string | bigint, decimals: number): string;
|
|
245
|
+
/**
|
|
246
|
+
* Generate a unique query ID for Jetton transfer
|
|
247
|
+
* Uses timestamp + random component for uniqueness
|
|
248
|
+
*
|
|
249
|
+
* @returns BigInt query ID
|
|
250
|
+
*/
|
|
251
|
+
declare function generateQueryId(): bigint;
|
|
252
|
+
/**
|
|
253
|
+
* Build Jetton transfer message body (TEP-74)
|
|
254
|
+
*
|
|
255
|
+
* @param params - Transfer parameters
|
|
256
|
+
* @returns Cell containing the transfer message
|
|
257
|
+
*/
|
|
258
|
+
declare function buildJettonTransferBody(params: {
|
|
259
|
+
queryId: bigint;
|
|
260
|
+
amount: bigint;
|
|
261
|
+
destination: Address;
|
|
262
|
+
responseDestination: Address;
|
|
263
|
+
forwardAmount?: bigint;
|
|
264
|
+
forwardPayload?: Cell;
|
|
265
|
+
}): Cell;
|
|
266
|
+
/**
|
|
267
|
+
* Parse Jetton transfer message from Cell
|
|
268
|
+
*
|
|
269
|
+
* @param body - Cell containing the message
|
|
270
|
+
* @returns Parsed transfer parameters
|
|
271
|
+
* @throws Error if not a valid Jetton transfer message
|
|
272
|
+
*/
|
|
273
|
+
declare function parseJettonTransferBody(body: Cell): {
|
|
274
|
+
op: number;
|
|
275
|
+
queryId: bigint;
|
|
276
|
+
amount: bigint;
|
|
277
|
+
destination: Address;
|
|
278
|
+
responseDestination: Address;
|
|
279
|
+
forwardAmount: bigint;
|
|
280
|
+
forwardPayload?: Cell;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Calculate estimated gas for Jetton transfer
|
|
284
|
+
* Based on typical TON network fees
|
|
285
|
+
*
|
|
286
|
+
* @param params - Optional parameters for estimation
|
|
287
|
+
* @returns Estimated gas in nanoTON
|
|
288
|
+
*/
|
|
289
|
+
declare function estimateJettonTransferGas(_params?: {
|
|
290
|
+
hasForwardPayload?: boolean;
|
|
291
|
+
}): bigint;
|
|
292
|
+
|
|
293
|
+
export { DEFAULT_FORWARD_TON, DEFAULT_JETTON_TRANSFER_TON, DEFAULT_VALIDITY_DURATION, JETTON_BURN_OP, JETTON_INTERNAL_TRANSFER_OP, JETTON_REGISTRY, JETTON_TRANSFER_NOTIFICATION_OP, JETTON_TRANSFER_OP, type JettonConfig, MAX_JETTON_TRANSFER_TON, MIN_JETTON_TRANSFER_TON, NETWORK_ENDPOINTS, NETWORK_V4_ENDPOINTS, type NetworkJettonRegistry, SCHEME_EXACT, TON_MAINNET_CAIP2, TON_MAINNET_ENDPOINT, TON_MAINNET_V4_ENDPOINT, TON_NETWORKS, TON_TESTNET_CAIP2, TON_TESTNET_ENDPOINT, TON_TESTNET_V4_ENDPOINT, type TonNetwork, USDT_ADDRESSES, addressesEqual, buildJettonTransferBody, convertFromJettonAmount, convertToJettonAmount, estimateJettonTransferGas, formatAddress, generateQueryId, getDefaultJetton, getEndpoint, getJettonByAddress, getJettonConfig, getNetworkJettons, getNetworksForJetton, getSupportedNetworks, getUsdtNetworks, isNetworkSupported, isTonNetwork, normalizeNetwork, parseJettonTransferBody, parseTonAddress, validateTonAddress };
|