@t402/ton 2.3.0 → 2.4.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/README.md +154 -0
- package/dist/cjs/exact/client/index.js +3 -2
- package/dist/cjs/exact/client/index.js.map +1 -1
- package/dist/cjs/exact/facilitator/index.js +1 -0
- package/dist/cjs/exact/facilitator/index.js.map +1 -1
- package/dist/cjs/exact/server/index.js +4 -2
- package/dist/cjs/exact/server/index.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +19 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/upto/index.d.ts +126 -0
- package/dist/cjs/upto/index.js +41 -0
- package/dist/cjs/upto/index.js.map +1 -0
- package/dist/esm/{chunk-3BN2G4M7.mjs → chunk-2EIGZGJU.mjs} +4 -8
- package/dist/esm/chunk-2EIGZGJU.mjs.map +1 -0
- package/dist/esm/{chunk-NGYEU24R.mjs → chunk-HIUPRMQV.mjs} +8 -5
- package/dist/esm/chunk-HIUPRMQV.mjs.map +1 -0
- package/dist/esm/chunk-NSSMTXJJ.mjs +8 -0
- package/dist/esm/chunk-NSSMTXJJ.mjs.map +1 -0
- package/dist/esm/{chunk-ZJA7AWWH.mjs → chunk-OOC4E2LE.mjs} +5 -3
- package/dist/esm/{chunk-ZJA7AWWH.mjs.map → chunk-OOC4E2LE.mjs.map} +1 -1
- package/dist/esm/{chunk-7OE2PWYP.mjs → chunk-QTEA4ZJU.mjs} +5 -3
- package/dist/esm/{chunk-7OE2PWYP.mjs.map → chunk-QTEA4ZJU.mjs.map} +1 -1
- package/dist/esm/chunk-TC3EU5ZU.mjs +15 -0
- package/dist/esm/chunk-TC3EU5ZU.mjs.map +1 -0
- package/dist/esm/exact/client/index.mjs +3 -2
- package/dist/esm/exact/facilitator/index.mjs +3 -2
- package/dist/esm/exact/server/index.mjs +3 -2
- package/dist/esm/index.d.mts +3 -2
- package/dist/esm/index.mjs +9 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/upto/index.d.mts +126 -0
- package/dist/esm/upto/index.mjs +8 -0
- package/dist/esm/upto/index.mjs.map +1 -0
- package/package.json +14 -4
- package/dist/esm/chunk-3BN2G4M7.mjs.map +0 -1
- package/dist/esm/chunk-NGYEU24R.mjs.map +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TON Up-To Payment Scheme Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the payload structure for TON Jetton upto payments in the t402 protocol.
|
|
5
|
+
* Uses an escrow pattern: client transfers maxAmount to the facilitator address,
|
|
6
|
+
* facilitator forwards settleAmount to payTo and refunds the rest.
|
|
7
|
+
*
|
|
8
|
+
* Uses BOC (Bag of Cells) format for message serialization.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* TON upto authorization metadata
|
|
12
|
+
*
|
|
13
|
+
* Contains all parameters for verifying the signed transfer message.
|
|
14
|
+
*/
|
|
15
|
+
type UptoTonAuthorization = {
|
|
16
|
+
/**
|
|
17
|
+
* Sender wallet address (friendly format, bounceable)
|
|
18
|
+
* This is the TON wallet address that will send the Jetton transfer
|
|
19
|
+
*/
|
|
20
|
+
from: string;
|
|
21
|
+
/**
|
|
22
|
+
* Facilitator holding address that receives the initial transfer
|
|
23
|
+
* The facilitator will forward settleAmount to payTo and refund the rest
|
|
24
|
+
*/
|
|
25
|
+
facilitator: string;
|
|
26
|
+
/**
|
|
27
|
+
* Jetton master contract address
|
|
28
|
+
* Identifies which Jetton token is being transferred (e.g., USDT)
|
|
29
|
+
*/
|
|
30
|
+
jettonMaster: string;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum authorized amount in smallest units (as string)
|
|
33
|
+
* The actual settlement amount may be less than this
|
|
34
|
+
*/
|
|
35
|
+
maxAmount: string;
|
|
36
|
+
/**
|
|
37
|
+
* TON amount attached for gas (in nanoTON, as string)
|
|
38
|
+
* Required to pay for the internal message execution
|
|
39
|
+
*/
|
|
40
|
+
tonAmount: string;
|
|
41
|
+
/**
|
|
42
|
+
* Unix timestamp (seconds) until which the message is valid
|
|
43
|
+
* Message will be rejected by the network after this time
|
|
44
|
+
*/
|
|
45
|
+
validUntil: number;
|
|
46
|
+
/**
|
|
47
|
+
* Wallet sequence number at time of signing
|
|
48
|
+
* Prevents replay attacks - each seqno can only be used once
|
|
49
|
+
*/
|
|
50
|
+
seqno: number;
|
|
51
|
+
/**
|
|
52
|
+
* Query ID for the Jetton transfer (as string for large numbers)
|
|
53
|
+
* Used for message correlation and deduplication
|
|
54
|
+
*/
|
|
55
|
+
queryId: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* TON upto payment payload (V2)
|
|
59
|
+
*
|
|
60
|
+
* Contains a pre-signed transfer message to the facilitator's holding address.
|
|
61
|
+
* The facilitator will broadcast the transfer, then forward settleAmount to payTo
|
|
62
|
+
* and refund (maxAmount - settleAmount) back to the client.
|
|
63
|
+
*/
|
|
64
|
+
type UptoTonPayload = {
|
|
65
|
+
/**
|
|
66
|
+
* Base64 encoded signed external message (BOC format)
|
|
67
|
+
* Contains the complete Jetton transfer message ready for broadcast
|
|
68
|
+
* The message transfers maxAmount to the facilitator's holding address
|
|
69
|
+
*/
|
|
70
|
+
signedBoc: string;
|
|
71
|
+
/**
|
|
72
|
+
* Transfer authorization metadata for verification
|
|
73
|
+
* Provides human-readable and verifiable parameters
|
|
74
|
+
*/
|
|
75
|
+
authorization: UptoTonAuthorization;
|
|
76
|
+
/**
|
|
77
|
+
* Unique nonce for replay protection (hex string)
|
|
78
|
+
* Separate from the wallet seqno - used by the t402 protocol
|
|
79
|
+
*/
|
|
80
|
+
paymentNonce: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* TON upto-specific extra fields for payment requirements
|
|
84
|
+
*
|
|
85
|
+
* Included in PaymentRequirements.extra to provide upto-specific parameters.
|
|
86
|
+
*/
|
|
87
|
+
type UptoTonExtra = {
|
|
88
|
+
/**
|
|
89
|
+
* Facilitator address that will receive the initial transfer
|
|
90
|
+
* Client should send maxAmount to this address
|
|
91
|
+
*/
|
|
92
|
+
facilitator?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Maximum payment amount authorized
|
|
95
|
+
* The upper bound for the escrow transfer
|
|
96
|
+
*/
|
|
97
|
+
maxAmount?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Minimum acceptable settlement amount
|
|
100
|
+
* Server may reject if usage is below this threshold
|
|
101
|
+
*/
|
|
102
|
+
minAmount?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Billing unit (e.g., "token", "request", "second")
|
|
105
|
+
* Describes what is being measured for usage-based billing
|
|
106
|
+
*/
|
|
107
|
+
unit?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Price per unit in smallest denomination
|
|
110
|
+
* Used with unit to calculate the final settlement amount
|
|
111
|
+
*/
|
|
112
|
+
unitPrice?: string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Type guard for UptoTonPayload
|
|
116
|
+
*
|
|
117
|
+
* Checks if the given data has the correct structure for a TON upto payload.
|
|
118
|
+
* Validates the presence and types of required fields including signedBoc,
|
|
119
|
+
* authorization (with from, facilitator, jettonMaster, maxAmount), and paymentNonce.
|
|
120
|
+
*
|
|
121
|
+
* @param data - The data to check
|
|
122
|
+
* @returns True if the data is a valid UptoTonPayload
|
|
123
|
+
*/
|
|
124
|
+
declare function isUptoTonPayload(data: unknown): data is UptoTonPayload;
|
|
125
|
+
|
|
126
|
+
export { type UptoTonAuthorization, type UptoTonExtra, type UptoTonPayload, isUptoTonPayload };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t402/ton",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/cjs/index.d.ts",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"description": "t402 Payment Protocol TON Implementation",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@eslint/js": "^9.24.0",
|
|
21
|
-
"@types/node": "^
|
|
21
|
+
"@types/node": "^25.2.0",
|
|
22
22
|
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
|
23
23
|
"@typescript-eslint/parser": "^8.29.1",
|
|
24
24
|
"eslint": "^9.24.0",
|
|
25
25
|
"eslint-plugin-import": "^2.31.0",
|
|
26
|
-
"eslint-plugin-jsdoc": "^
|
|
26
|
+
"eslint-plugin-jsdoc": "^62.5.0",
|
|
27
27
|
"eslint-plugin-prettier": "^5.2.6",
|
|
28
28
|
"glob": "^13.0.0",
|
|
29
29
|
"prettier": "3.5.2",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@ton/core": "^0.62.1",
|
|
39
39
|
"@ton/crypto": "^3.2.0",
|
|
40
40
|
"@ton/ton": "^16.1.0",
|
|
41
|
-
"@t402/core": "2.
|
|
41
|
+
"@t402/core": "2.4.0"
|
|
42
42
|
},
|
|
43
43
|
"exports": {
|
|
44
44
|
".": {
|
|
@@ -80,6 +80,16 @@
|
|
|
80
80
|
"types": "./dist/cjs/exact/facilitator/index.d.ts",
|
|
81
81
|
"default": "./dist/cjs/exact/facilitator/index.js"
|
|
82
82
|
}
|
|
83
|
+
},
|
|
84
|
+
"./upto": {
|
|
85
|
+
"import": {
|
|
86
|
+
"types": "./dist/esm/upto/index.d.mts",
|
|
87
|
+
"default": "./dist/esm/upto/index.mjs"
|
|
88
|
+
},
|
|
89
|
+
"require": {
|
|
90
|
+
"types": "./dist/cjs/upto/index.d.ts",
|
|
91
|
+
"default": "./dist/cjs/upto/index.js"
|
|
92
|
+
}
|
|
83
93
|
}
|
|
84
94
|
},
|
|
85
95
|
"files": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants.ts","../../src/utils.ts"],"sourcesContent":["/**\n * TON Network Constants\n *\n * This module provides constants for TON blockchain integration including:\n * - CAIP-2 network identifiers\n * - RPC endpoints\n * - Jetton transfer operation codes\n * - Default gas amounts\n */\n\n/**\n * CAIP-2 Network Identifiers for TON\n * Using simple identifiers for mainnet/testnet\n */\nexport const TON_MAINNET_CAIP2 = 'ton:mainnet'\nexport const TON_TESTNET_CAIP2 = 'ton:testnet'\n\n/**\n * Supported TON networks\n */\nexport const TON_NETWORKS = [TON_MAINNET_CAIP2, TON_TESTNET_CAIP2] as const\n\nexport type TonNetwork = (typeof TON_NETWORKS)[number]\n\n/**\n * Default RPC endpoints (TonCenter API v2)\n */\nexport const TON_MAINNET_ENDPOINT = 'https://toncenter.com/api/v2/jsonRPC'\nexport const TON_TESTNET_ENDPOINT = 'https://testnet.toncenter.com/api/v2/jsonRPC'\n\n/**\n * TON API v4 endpoints (for @ton/ton TonClient4)\n */\nexport const TON_MAINNET_V4_ENDPOINT = 'https://mainnet-v4.tonhubapi.com'\nexport const TON_TESTNET_V4_ENDPOINT = 'https://testnet-v4.tonhubapi.com'\n\n/**\n * Network endpoint mapping\n */\nexport const NETWORK_ENDPOINTS: Record<string, string> = {\n [TON_MAINNET_CAIP2]: TON_MAINNET_ENDPOINT,\n [TON_TESTNET_CAIP2]: TON_TESTNET_ENDPOINT,\n}\n\nexport const NETWORK_V4_ENDPOINTS: Record<string, string> = {\n [TON_MAINNET_CAIP2]: TON_MAINNET_V4_ENDPOINT,\n [TON_TESTNET_CAIP2]: TON_TESTNET_V4_ENDPOINT,\n}\n\n/**\n * Jetton Transfer Operation Codes (TEP-74)\n * @see https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md\n */\nexport const JETTON_TRANSFER_OP = 0x0f8a7ea5 // transfer\nexport const JETTON_INTERNAL_TRANSFER_OP = 0x178d4519 // internal_transfer\nexport const JETTON_TRANSFER_NOTIFICATION_OP = 0x7362d09c // transfer_notification\nexport const JETTON_BURN_OP = 0x595f07bc // burn\n\n/**\n * Default gas amounts for Jetton transfers\n * TON requires attaching TON for gas to internal messages\n */\nexport const DEFAULT_JETTON_TRANSFER_TON = 100_000_000n // 0.1 TON for gas\nexport const DEFAULT_FORWARD_TON = 1n // Minimal forward amount (notification)\nexport const MIN_JETTON_TRANSFER_TON = 50_000_000n // 0.05 TON minimum\n\n/**\n * Maximum gas amounts to prevent excessive fees\n */\nexport const MAX_JETTON_TRANSFER_TON = 500_000_000n // 0.5 TON maximum\n\n/**\n * Scheme identifier for exact payments\n */\nexport const SCHEME_EXACT = 'exact'\n\n/**\n * Default timeout for payment validity (in seconds)\n */\nexport const DEFAULT_VALIDITY_DURATION = 3600 // 1 hour\n\n/**\n * Address format constants\n */\nexport const TON_ADDRESS_LENGTH = 48 // Friendly format length (base64url)\nexport const TON_RAW_ADDRESS_LENGTH = 66 // Raw format: workchain:hash (0:64hex)\n","/**\n * TON Utility Functions\n *\n * Helper functions for TON address handling, message building,\n * and network operations.\n */\n\nimport { Address, beginCell, Cell } from '@ton/core'\nimport type { Network } from '@t402/core/types'\nimport {\n TON_MAINNET_CAIP2,\n TON_TESTNET_CAIP2,\n TON_NETWORKS,\n NETWORK_ENDPOINTS,\n JETTON_TRANSFER_OP,\n} from './constants.js'\n\n/**\n * Normalize network identifier to CAIP-2 format\n *\n * @param network - Network identifier (may be legacy format)\n * @returns Normalized CAIP-2 network identifier\n * @throws Error if network is not supported\n */\nexport function normalizeNetwork(network: Network): Network {\n // Already in CAIP-2 format\n if (network.startsWith('ton:')) {\n if (!TON_NETWORKS.includes(network as (typeof TON_NETWORKS)[number])) {\n throw new Error(`Unsupported TON network: ${network}`)\n }\n return network as Network\n }\n\n // Handle legacy format conversions\n const mapping: Record<string, Network> = {\n ton: TON_MAINNET_CAIP2 as Network,\n 'ton-mainnet': TON_MAINNET_CAIP2 as Network,\n mainnet: TON_MAINNET_CAIP2 as Network,\n 'ton-testnet': TON_TESTNET_CAIP2 as Network,\n testnet: TON_TESTNET_CAIP2 as Network,\n }\n\n const caip2 = mapping[network.toLowerCase()]\n if (!caip2) {\n throw new Error(`Unsupported TON network: ${network}`)\n }\n return caip2\n}\n\n/**\n * Get RPC endpoint for a network\n *\n * @param network - Network identifier\n * @returns RPC endpoint URL\n */\nexport function getEndpoint(network: Network): string {\n const caip2 = normalizeNetwork(network)\n const endpoint = NETWORK_ENDPOINTS[caip2]\n if (!endpoint) {\n throw new Error(`No endpoint configured for network: ${network}`)\n }\n return endpoint\n}\n\n/**\n * Check if a network identifier is a supported TON network\n *\n * @param network - Network identifier to check\n * @returns true if supported\n */\nexport function isTonNetwork(network: string): boolean {\n try {\n normalizeNetwork(network as Network)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Validate TON address format\n *\n * @param address - Address to validate\n * @returns true if valid TON address\n */\nexport function validateTonAddress(address: string): boolean {\n try {\n Address.parse(address)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Parse TON address from string\n *\n * @param address - Address string (friendly or raw format)\n * @returns Parsed Address object\n * @throws Error if invalid format\n */\nexport function parseTonAddress(address: string): Address {\n return Address.parse(address)\n}\n\n/**\n * Compare two TON addresses for equality\n * Handles different address formats (friendly, raw, bounceable/non-bounceable)\n *\n * @param addr1 - First address\n * @param addr2 - Second address\n * @returns true if addresses are equal\n */\nexport function addressesEqual(addr1: string, addr2: string): boolean {\n try {\n const a1 = Address.parse(addr1)\n const a2 = Address.parse(addr2)\n return a1.equals(a2)\n } catch {\n return false\n }\n}\n\n/**\n * Format address to friendly format\n *\n * @param address - Address to format\n * @param options - Formatting options\n * @returns Friendly format address string\n */\nexport function formatAddress(\n address: string | Address,\n options?: { bounceable?: boolean; testOnly?: boolean },\n): string {\n const addr = typeof address === 'string' ? Address.parse(address) : address\n return addr.toString({\n bounceable: options?.bounceable ?? true,\n testOnly: options?.testOnly ?? false,\n })\n}\n\n/**\n * Convert decimal amount to smallest units (e.g., nano-Jettons)\n *\n * @param decimalAmount - Amount in decimal format (e.g., \"1.50\")\n * @param decimals - Number of decimal places\n * @returns Amount in smallest units as string\n */\nexport function convertToJettonAmount(decimalAmount: string, decimals: number): string {\n const amount = parseFloat(decimalAmount)\n if (isNaN(amount)) {\n throw new Error(`Invalid amount: ${decimalAmount}`)\n }\n const jettonAmount = Math.floor(amount * Math.pow(10, decimals))\n return jettonAmount.toString()\n}\n\n/**\n * Convert smallest units to decimal amount\n *\n * @param jettonAmount - Amount in smallest units\n * @param decimals - Number of decimal places\n * @returns Amount in decimal format as string\n */\nexport function convertFromJettonAmount(jettonAmount: string | bigint, decimals: number): string {\n const amount = typeof jettonAmount === 'string' ? BigInt(jettonAmount) : jettonAmount\n const divisor = BigInt(Math.pow(10, decimals))\n const wholePart = amount / divisor\n const fractionalPart = amount % divisor\n\n if (fractionalPart === 0n) {\n return wholePart.toString()\n }\n\n const fractionalStr = fractionalPart.toString().padStart(decimals, '0')\n return `${wholePart}.${fractionalStr}`.replace(/\\.?0+$/, '')\n}\n\n/**\n * Generate a unique query ID for Jetton transfer\n * Uses timestamp + random component for uniqueness\n *\n * @returns BigInt query ID\n */\nexport function generateQueryId(): bigint {\n const timestamp = BigInt(Date.now())\n const random = BigInt(Math.floor(Math.random() * 1000000))\n return timestamp * 1000000n + random\n}\n\n/**\n * Build Jetton transfer message body (TEP-74)\n *\n * @param params - Transfer parameters\n * @returns Cell containing the transfer message\n */\nexport function buildJettonTransferBody(params: {\n queryId: bigint\n amount: bigint\n destination: Address\n responseDestination: Address\n forwardAmount?: bigint\n forwardPayload?: Cell\n}): Cell {\n const builder = beginCell()\n .storeUint(JETTON_TRANSFER_OP, 32) // op: transfer\n .storeUint(params.queryId, 64) // query_id\n .storeCoins(params.amount) // amount\n .storeAddress(params.destination) // destination\n .storeAddress(params.responseDestination) // response_destination\n .storeBit(false) // no custom payload\n\n // Forward amount (for notification)\n builder.storeCoins(params.forwardAmount ?? 1n)\n\n // Forward payload (optional)\n if (params.forwardPayload) {\n builder.storeBit(true).storeRef(params.forwardPayload)\n } else {\n builder.storeBit(false)\n }\n\n return builder.endCell()\n}\n\n/**\n * Parse Jetton transfer message from Cell\n *\n * @param body - Cell containing the message\n * @returns Parsed transfer parameters\n * @throws Error if not a valid Jetton transfer message\n */\nexport function parseJettonTransferBody(body: Cell): {\n op: number\n queryId: bigint\n amount: bigint\n destination: Address\n responseDestination: Address\n forwardAmount: bigint\n forwardPayload?: Cell\n} {\n const slice = body.beginParse()\n\n const op = slice.loadUint(32)\n if (op !== JETTON_TRANSFER_OP) {\n throw new Error(`Not a Jetton transfer message. Expected op ${JETTON_TRANSFER_OP}, got ${op}`)\n }\n\n const queryId = slice.loadUintBig(64)\n const amount = slice.loadCoins()\n const destination = slice.loadAddress()\n const responseDestination = slice.loadAddress()\n\n // Skip custom_payload bit\n const hasCustomPayload = slice.loadBit()\n if (hasCustomPayload) {\n slice.loadRef() // Skip custom payload\n }\n\n const forwardAmount = slice.loadCoins()\n\n // Forward payload\n const hasForwardPayload = slice.loadBit()\n const forwardPayload = hasForwardPayload ? slice.loadRef() : undefined\n\n return {\n op,\n queryId,\n amount,\n destination,\n responseDestination,\n forwardAmount,\n forwardPayload,\n }\n}\n\n/**\n * Calculate estimated gas for Jetton transfer\n * Based on typical TON network fees\n *\n * @param params - Optional parameters for estimation\n * @returns Estimated gas in nanoTON\n */\nexport function estimateJettonTransferGas(_params?: { hasForwardPayload?: boolean }): bigint {\n // Base cost for Jetton transfer (typical)\n // Includes: external message, wallet internal message, Jetton wallet message\n return 100_000_000n // 0.1 TON (conservative estimate)\n}\n"],"mappings":";;;;;AAcO,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAK1B,IAAM,eAAe,CAAC,mBAAmB,iBAAiB;AAO1D,IAAM,uBAAuB;AAC7B,IAAM,uBAAuB;AAK7B,IAAM,0BAA0B;AAChC,IAAM,0BAA0B;AAKhC,IAAM,oBAA4C;AAAA,EACvD,CAAC,iBAAiB,GAAG;AAAA,EACrB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,YAAY,WAAW;AAChC;AAQO,SAAS,wBAAwB,QAO/B;AACP,QAAM,UAAU,UAAU,EACvB,UAAU,oBAAoB,EAAE,EAChC,UAAU,OAAO,SAAS,EAAE,EAC5B,WAAW,OAAO,MAAM,EACxB,aAAa,OAAO,WAAW,EAC/B,aAAa,OAAO,mBAAmB,EACvC,SAAS,KAAK;AAGjB,UAAQ,WAAW,OAAO,iBAAiB,EAAE;AAG7C,MAAI,OAAO,gBAAgB;AACzB,YAAQ,SAAS,IAAI,EAAE,SAAS,OAAO,cAAc;AAAA,EACvD,OAAO;AACL,YAAQ,SAAS,KAAK;AAAA,EACxB;AAEA,SAAO,QAAQ,QAAQ;AACzB;AASO,SAAS,wBAAwB,MAQtC;AACA,QAAM,QAAQ,KAAK,WAAW;AAE9B,QAAM,KAAK,MAAM,SAAS,EAAE;AAC5B,MAAI,OAAO,oBAAoB;AAC7B,UAAM,IAAI,MAAM,8CAA8C,kBAAkB,SAAS,EAAE,EAAE;AAAA,EAC/F;AAEA,QAAM,UAAU,MAAM,YAAY,EAAE;AACpC,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,cAAc,MAAM,YAAY;AACtC,QAAM,sBAAsB,MAAM,YAAY;AAG9C,QAAM,mBAAmB,MAAM,QAAQ;AACvC,MAAI,kBAAkB;AACpB,UAAM,QAAQ;AAAA,EAChB;AAEA,QAAM,gBAAgB,MAAM,UAAU;AAGtC,QAAM,oBAAoB,MAAM,QAAQ;AACxC,QAAM,iBAAiB,oBAAoB,MAAM,QAAQ,IAAI;AAE7D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AASO,SAAS,0BAA0B,SAAmD;AAG3F,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tokens.ts","../../src/exact/server/scheme.ts","../../src/exact/server/register.ts"],"sourcesContent":["/**\n * TON Jetton Token Configuration\n *\n * This module provides comprehensive Jetton token definitions including:\n * - USDT (Tether USD on TON)\n * - Network-specific configurations\n * - Helper functions for token lookups\n */\n\nimport { TON_MAINNET_CAIP2, TON_TESTNET_CAIP2 } from './constants.js'\n\n/**\n * Jetton token configuration\n */\nexport interface JettonConfig {\n /** Jetton master contract address (friendly format) */\n masterAddress: string\n /** Token symbol */\n symbol: string\n /** Token name */\n name: string\n /** Number of decimal places */\n decimals: number\n /** Payment priority (lower = higher priority) */\n priority: number\n}\n\n/**\n * Network token registry mapping network -> symbol -> config\n */\nexport type NetworkJettonRegistry = Record<string, Record<string, JettonConfig>>\n\n/**\n * USDT Jetton Master Contract Addresses by Network\n *\n * USDT on TON follows the TEP-74 Jetton standard.\n * @see https://docs.tether.to/tether-on-ton\n */\nexport const USDT_ADDRESSES: Record<string, string> = {\n // TON Mainnet - Official Tether USDT\n [TON_MAINNET_CAIP2]: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',\n // TON Testnet - Test USDT (may vary)\n [TON_TESTNET_CAIP2]: 'kQBqSpvo4S87mX9tTc4FX3Sfqf4uSp3Tx-Fz4RBUfTRWBx',\n}\n\n/**\n * Complete Jetton registry with all supported tokens per network\n */\nexport const JETTON_REGISTRY: NetworkJettonRegistry = {\n // TON Mainnet\n [TON_MAINNET_CAIP2]: {\n USDT: {\n masterAddress: USDT_ADDRESSES[TON_MAINNET_CAIP2],\n symbol: 'USDT',\n name: 'Tether USD',\n decimals: 6,\n priority: 1,\n },\n },\n\n // TON Testnet\n [TON_TESTNET_CAIP2]: {\n USDT: {\n masterAddress: USDT_ADDRESSES[TON_TESTNET_CAIP2],\n symbol: 'USDT',\n name: 'Tether USD (Testnet)',\n decimals: 6,\n priority: 1,\n },\n },\n}\n\n/**\n * Get Jetton configuration for a specific token on a network\n *\n * @param network - Network identifier (CAIP-2 format)\n * @param symbol - Token symbol (e.g., \"USDT\")\n * @returns Jetton configuration or undefined\n */\nexport function getJettonConfig(network: string, symbol: string): JettonConfig | undefined {\n return JETTON_REGISTRY[network]?.[symbol.toUpperCase()]\n}\n\n/**\n * Get all Jettons available on a network\n *\n * @param network - Network identifier\n * @returns Array of Jetton configurations sorted by priority\n */\nexport function getNetworkJettons(network: string): JettonConfig[] {\n const jettons = JETTON_REGISTRY[network]\n if (!jettons) return []\n return Object.values(jettons).sort((a, b) => a.priority - b.priority)\n}\n\n/**\n * Get the default/preferred Jetton for a network\n * Prefers USDT based on priority\n *\n * @param network - Network identifier\n * @returns Default Jetton configuration or undefined\n */\nexport function getDefaultJetton(network: string): JettonConfig | undefined {\n const jettons = getNetworkJettons(network)\n return jettons[0] // Already sorted by priority\n}\n\n/**\n * Get Jetton by master contract address on a network\n *\n * @param network - Network identifier\n * @param address - Jetton master contract address\n * @returns Jetton configuration or undefined\n */\nexport function getJettonByAddress(network: string, address: string): JettonConfig | undefined {\n const jettons = JETTON_REGISTRY[network]\n if (!jettons) return undefined\n\n // Normalize address comparison (case-insensitive for base64)\n return Object.values(jettons).find((j) => j.masterAddress.toLowerCase() === address.toLowerCase())\n}\n\n/**\n * Get all networks that support a specific Jetton\n *\n * @param symbol - Token symbol\n * @returns Array of network identifiers\n */\nexport function getNetworksForJetton(symbol: string): string[] {\n const networks: string[] = []\n for (const [network, jettons] of Object.entries(JETTON_REGISTRY)) {\n if (jettons[symbol.toUpperCase()]) {\n networks.push(network)\n }\n }\n return networks\n}\n\n/**\n * Get USDT networks on TON\n *\n * @returns Array of networks supporting USDT\n */\nexport function getUsdtNetworks(): string[] {\n return getNetworksForJetton('USDT')\n}\n\n/**\n * Check if a network is supported\n *\n * @param network - Network identifier to check\n * @returns true if network has configured Jettons\n */\nexport function isNetworkSupported(network: string): boolean {\n return network in JETTON_REGISTRY\n}\n\n/**\n * Get all supported networks\n *\n * @returns Array of all supported network identifiers\n */\nexport function getSupportedNetworks(): string[] {\n return Object.keys(JETTON_REGISTRY)\n}\n","/**\n * TON Server Scheme Implementation\n *\n * Handles price parsing and payment requirement enhancement for\n * TON Jetton payments using the exact scheme.\n */\n\nimport type {\n AssetAmount,\n Network,\n PaymentRequirements,\n Price,\n SchemeNetworkServer,\n MoneyParser,\n} from '@t402/core/types'\nimport { SCHEME_EXACT } from '../../constants.js'\nimport { getDefaultJetton, getJettonConfig, JETTON_REGISTRY } from '../../tokens.js'\nimport { normalizeNetwork } from '../../utils.js'\n\n/**\n * Configuration options for ExactTonScheme server\n */\nexport interface ExactTonSchemeConfig {\n /** Preferred Jetton symbol (e.g., \"USDT\"). Defaults to network's highest priority token. */\n preferredJetton?: string\n}\n\n/**\n * TON server implementation for the Exact payment scheme.\n * Handles price parsing and converts user-friendly amounts to Jetton amounts.\n */\nexport class ExactTonScheme implements SchemeNetworkServer {\n readonly scheme = SCHEME_EXACT\n private moneyParsers: MoneyParser[] = []\n private config: ExactTonSchemeConfig\n\n constructor(config: ExactTonSchemeConfig = {}) {\n this.config = config\n }\n\n /**\n * Register a custom money parser in the parser chain.\n * Multiple parsers can be registered - they will be tried in registration order.\n * Each parser receives a decimal amount (e.g., 1.50 for $1.50).\n * If a parser returns null, the next parser in the chain will be tried.\n * The default parser is always the final fallback.\n *\n * @param parser - Custom function to convert amount to AssetAmount (or null to skip)\n * @returns The server instance for chaining\n *\n * @example\n * tonServer.registerMoneyParser(async (amount, network) => {\n * // Use custom Jetton for large amounts\n * if (amount > 1000) {\n * return {\n * amount: (amount * 1e9).toString(),\n * asset: \"EQCustomJettonAddress...\",\n * extra: { tier: \"premium\" }\n * };\n * }\n * return null; // Use next parser\n * });\n */\n registerMoneyParser(parser: MoneyParser): ExactTonScheme {\n this.moneyParsers.push(parser)\n return this\n }\n\n /**\n * Parses a price into an asset amount.\n * If price is already an AssetAmount, returns it directly.\n * If price is Money (string | number), parses to decimal and tries custom parsers.\n * Falls back to default conversion if all custom parsers return null.\n *\n * @param price - The price to parse\n * @param network - The network to use\n * @returns Promise that resolves to the parsed asset amount\n */\n async parsePrice(price: Price, network: Network): Promise<AssetAmount> {\n // Normalize network to CAIP-2 format\n const normalizedNetwork = normalizeNetwork(network)\n\n // If already an AssetAmount, return it directly\n if (typeof price === 'object' && price !== null && 'amount' in price) {\n if (!price.asset) {\n throw new Error(`Asset address must be specified for AssetAmount on network ${network}`)\n }\n return {\n amount: price.amount,\n asset: price.asset,\n extra: price.extra || {},\n }\n }\n\n // Parse Money to decimal number\n const amount = this.parseMoneyToDecimal(price)\n\n // Try each custom money parser in order\n for (const parser of this.moneyParsers) {\n const result = await parser(amount, normalizedNetwork)\n if (result !== null) {\n return result\n }\n }\n\n // All custom parsers returned null, use default conversion\n return this.defaultMoneyConversion(amount, normalizedNetwork)\n }\n\n /**\n * Build payment requirements for this scheme/network combination.\n * Adds TON-specific fields like gas sponsor if provided by facilitator.\n *\n * @param paymentRequirements - Base payment requirements with amount/asset already set\n * @param supportedKind - The supported kind from facilitator's /supported endpoint\n * @param extensionKeys - Extensions supported by the facilitator (unused)\n * @returns Enhanced payment requirements ready to be sent to clients\n */\n async enhancePaymentRequirements(\n paymentRequirements: PaymentRequirements,\n supportedKind: {\n t402Version: number\n scheme: string\n network: Network\n extra?: Record<string, unknown>\n },\n extensionKeys: string[],\n ): Promise<PaymentRequirements> {\n // Mark unused parameters to satisfy linter\n void extensionKeys\n\n // Start with existing extra fields\n const extra = { ...paymentRequirements.extra }\n\n // Add gas sponsor from facilitator if provided\n if (supportedKind.extra?.gasSponsor) {\n extra.gasSponsor = supportedKind.extra.gasSponsor\n }\n\n return {\n ...paymentRequirements,\n extra,\n }\n }\n\n /**\n * Parse Money (string | number) to a decimal number.\n * Handles formats like \"$1.50\", \"1.50\", 1.50, etc.\n *\n * @param money - The money value to parse\n * @returns Decimal number\n */\n private parseMoneyToDecimal(money: string | number): number {\n if (typeof money === 'number') {\n return money\n }\n\n // Remove $ sign and whitespace, then parse\n const cleanMoney = money.replace(/^\\$/, '').trim()\n const amount = parseFloat(cleanMoney)\n\n if (isNaN(amount)) {\n throw new Error(`Invalid money format: ${money}`)\n }\n\n return amount\n }\n\n /**\n * Default money conversion implementation.\n * Converts decimal amount to the preferred Jetton on the specified network.\n *\n * @param amount - The decimal amount (e.g., 1.50)\n * @param network - The network to use\n * @returns The parsed asset amount\n */\n private defaultMoneyConversion(amount: number, network: Network): AssetAmount {\n const jetton = this.getDefaultAsset(network)\n\n // Convert decimal amount to token amount\n const tokenAmount = this.convertToTokenAmount(amount.toString(), jetton.decimals)\n\n return {\n amount: tokenAmount,\n asset: jetton.masterAddress,\n extra: {\n symbol: jetton.symbol,\n name: jetton.name,\n decimals: jetton.decimals,\n },\n }\n }\n\n /**\n * Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal tokens)\n *\n * @param decimalAmount - The decimal amount to convert\n * @param decimals - Number of decimals for the token\n * @returns The token amount as a string\n */\n private convertToTokenAmount(decimalAmount: string, decimals: number): string {\n const amount = parseFloat(decimalAmount)\n if (isNaN(amount)) {\n throw new Error(`Invalid amount: ${decimalAmount}`)\n }\n // Convert to smallest unit (e.g., for USDT with 6 decimals: 0.10 * 10^6 = 100000)\n const tokenAmount = Math.floor(amount * Math.pow(10, decimals))\n return tokenAmount.toString()\n }\n\n /**\n * Get the default asset info for a network.\n * Priority: configured preferredJetton > USDT > first available\n *\n * @param network - The network to get asset info for\n * @returns The Jetton configuration\n */\n private getDefaultAsset(network: Network): {\n masterAddress: string\n symbol: string\n name: string\n decimals: number\n } {\n // If a preferred Jetton is configured, try to use it\n if (this.config.preferredJetton) {\n const preferred = getJettonConfig(network, this.config.preferredJetton)\n if (preferred) return preferred\n }\n\n // Use the network's default token (sorted by priority)\n const defaultJetton = getDefaultJetton(network)\n if (defaultJetton) return defaultJetton\n\n throw new Error(`No Jettons configured for network ${network}`)\n }\n\n /**\n * Get all supported networks\n */\n static getSupportedNetworks(): string[] {\n return Object.keys(JETTON_REGISTRY)\n }\n\n /**\n * Check if a network is supported\n */\n static isNetworkSupported(network: string): boolean {\n return network in JETTON_REGISTRY\n }\n}\n","import { t402ResourceServer } from '@t402/core/server'\nimport { Network } from '@t402/core/types'\nimport { ExactTonScheme, ExactTonSchemeConfig } from './scheme.js'\n\n/**\n * Configuration options for registering TON schemes to an t402ResourceServer\n */\nexport interface TonResourceServerConfig {\n /**\n * Optional specific networks to register\n * If not provided, registers wildcard support (ton:*)\n */\n networks?: Network[]\n\n /**\n * Optional scheme configuration (preferred Jetton, etc.)\n */\n schemeConfig?: ExactTonSchemeConfig\n}\n\n/**\n * Registers TON exact payment schemes to an t402ResourceServer instance.\n *\n * This function registers:\n * - V2: ton:* wildcard scheme with ExactTonScheme (or specific networks if provided)\n *\n * @param server - The t402ResourceServer instance to register schemes to\n * @param config - Configuration for TON resource server registration\n * @returns The server instance for chaining\n *\n * @example\n * ```typescript\n * import { registerExactTonScheme } from \"@t402/ton/exact/server/register\";\n * import { t402ResourceServer } from \"@t402/core/server\";\n *\n * const server = new t402ResourceServer(facilitatorClient);\n * registerExactTonScheme(server, {});\n *\n * // Or with specific Jetton preference\n * registerExactTonScheme(server, {\n * schemeConfig: { preferredJetton: \"USDT\" }\n * });\n * ```\n */\nexport function registerExactTonScheme(\n server: t402ResourceServer,\n config: TonResourceServerConfig = {},\n): t402ResourceServer {\n const scheme = new ExactTonScheme(config.schemeConfig)\n\n // Register V2 scheme\n if (config.networks && config.networks.length > 0) {\n // Register specific networks\n config.networks.forEach((network) => {\n server.register(network, scheme)\n })\n } else {\n // Register wildcard for all TON networks\n server.register('ton:*', scheme)\n }\n\n return server\n}\n"],"mappings":";;;;;;;;;AAsCO,IAAM,iBAAyC;AAAA;AAAA,EAEpD,CAAC,iBAAiB,GAAG;AAAA;AAAA,EAErB,CAAC,iBAAiB,GAAG;AACvB;AAKO,IAAM,kBAAyC;AAAA;AAAA,EAEpD,CAAC,iBAAiB,GAAG;AAAA,IACnB,MAAM;AAAA,MACJ,eAAe,eAAe,iBAAiB;AAAA,MAC/C,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,MACV,UAAU;AA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