@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,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExactTonScheme
|
|
3
|
+
} from "./chunk-ZCMWKFVA.mjs";
|
|
4
|
+
import {
|
|
5
|
+
JETTON_REGISTRY,
|
|
6
|
+
USDT_ADDRESSES,
|
|
7
|
+
getDefaultJetton,
|
|
8
|
+
getJettonByAddress,
|
|
9
|
+
getJettonConfig,
|
|
10
|
+
getNetworkJettons,
|
|
11
|
+
getNetworksForJetton,
|
|
12
|
+
getSupportedNetworks,
|
|
13
|
+
getUsdtNetworks,
|
|
14
|
+
isNetworkSupported
|
|
15
|
+
} from "./chunk-RST5PY7E.mjs";
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_FORWARD_TON,
|
|
18
|
+
DEFAULT_JETTON_TRANSFER_TON,
|
|
19
|
+
DEFAULT_VALIDITY_DURATION,
|
|
20
|
+
JETTON_BURN_OP,
|
|
21
|
+
JETTON_INTERNAL_TRANSFER_OP,
|
|
22
|
+
JETTON_TRANSFER_NOTIFICATION_OP,
|
|
23
|
+
JETTON_TRANSFER_OP,
|
|
24
|
+
MAX_JETTON_TRANSFER_TON,
|
|
25
|
+
MIN_JETTON_TRANSFER_TON,
|
|
26
|
+
NETWORK_ENDPOINTS,
|
|
27
|
+
NETWORK_V4_ENDPOINTS,
|
|
28
|
+
SCHEME_EXACT,
|
|
29
|
+
TON_MAINNET_CAIP2,
|
|
30
|
+
TON_MAINNET_ENDPOINT,
|
|
31
|
+
TON_MAINNET_V4_ENDPOINT,
|
|
32
|
+
TON_NETWORKS,
|
|
33
|
+
TON_TESTNET_CAIP2,
|
|
34
|
+
TON_TESTNET_ENDPOINT,
|
|
35
|
+
TON_TESTNET_V4_ENDPOINT,
|
|
36
|
+
addressesEqual,
|
|
37
|
+
buildJettonTransferBody,
|
|
38
|
+
convertFromJettonAmount,
|
|
39
|
+
convertToJettonAmount,
|
|
40
|
+
estimateJettonTransferGas,
|
|
41
|
+
formatAddress,
|
|
42
|
+
generateQueryId,
|
|
43
|
+
getEndpoint,
|
|
44
|
+
isTonNetwork,
|
|
45
|
+
normalizeNetwork,
|
|
46
|
+
parseJettonTransferBody,
|
|
47
|
+
parseTonAddress,
|
|
48
|
+
validateTonAddress
|
|
49
|
+
} from "./chunk-6LOUEHJT.mjs";
|
|
50
|
+
|
|
51
|
+
// src/signer.ts
|
|
52
|
+
function toClientTonSigner(signer) {
|
|
53
|
+
return signer;
|
|
54
|
+
}
|
|
55
|
+
function toFacilitatorTonSigner(client) {
|
|
56
|
+
return {
|
|
57
|
+
...client,
|
|
58
|
+
getAddresses: () => [client.address]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
DEFAULT_FORWARD_TON,
|
|
63
|
+
DEFAULT_JETTON_TRANSFER_TON,
|
|
64
|
+
DEFAULT_VALIDITY_DURATION,
|
|
65
|
+
ExactTonScheme,
|
|
66
|
+
JETTON_BURN_OP,
|
|
67
|
+
JETTON_INTERNAL_TRANSFER_OP,
|
|
68
|
+
JETTON_REGISTRY,
|
|
69
|
+
JETTON_TRANSFER_NOTIFICATION_OP,
|
|
70
|
+
JETTON_TRANSFER_OP,
|
|
71
|
+
MAX_JETTON_TRANSFER_TON,
|
|
72
|
+
MIN_JETTON_TRANSFER_TON,
|
|
73
|
+
NETWORK_ENDPOINTS,
|
|
74
|
+
NETWORK_V4_ENDPOINTS,
|
|
75
|
+
SCHEME_EXACT,
|
|
76
|
+
TON_MAINNET_CAIP2,
|
|
77
|
+
TON_MAINNET_ENDPOINT,
|
|
78
|
+
TON_MAINNET_V4_ENDPOINT,
|
|
79
|
+
TON_NETWORKS,
|
|
80
|
+
TON_TESTNET_CAIP2,
|
|
81
|
+
TON_TESTNET_ENDPOINT,
|
|
82
|
+
TON_TESTNET_V4_ENDPOINT,
|
|
83
|
+
USDT_ADDRESSES,
|
|
84
|
+
addressesEqual,
|
|
85
|
+
buildJettonTransferBody,
|
|
86
|
+
convertFromJettonAmount,
|
|
87
|
+
convertToJettonAmount,
|
|
88
|
+
estimateJettonTransferGas,
|
|
89
|
+
formatAddress,
|
|
90
|
+
generateQueryId,
|
|
91
|
+
getDefaultJetton,
|
|
92
|
+
getEndpoint,
|
|
93
|
+
getJettonByAddress,
|
|
94
|
+
getJettonConfig,
|
|
95
|
+
getNetworkJettons,
|
|
96
|
+
getNetworksForJetton,
|
|
97
|
+
getSupportedNetworks,
|
|
98
|
+
getUsdtNetworks,
|
|
99
|
+
isNetworkSupported,
|
|
100
|
+
isTonNetwork,
|
|
101
|
+
normalizeNetwork,
|
|
102
|
+
parseJettonTransferBody,
|
|
103
|
+
parseTonAddress,
|
|
104
|
+
toClientTonSigner,
|
|
105
|
+
toFacilitatorTonSigner,
|
|
106
|
+
validateTonAddress
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/signer.ts"],"sourcesContent":["/**\n * TON Signer Interfaces\n *\n * Defines the signer interfaces for t402 client and facilitator operations.\n * These interfaces abstract away the specific wallet implementation,\n * allowing integration with various TON wallets and signing mechanisms.\n */\n\nimport type { Address, Cell, SendMode } from \"@ton/core\";\nimport type { VerifyMessageResult, TransactionConfirmation } from \"./types.js\";\n\n/**\n * Parameters for signing a TON internal message\n */\nexport type SignMessageParams = {\n /** Destination address (typically Jetton wallet contract) */\n to: Address;\n /** Amount of TON to attach (for gas) in nanoTON */\n value: bigint;\n /** Message body (Jetton transfer cell) */\n body: Cell;\n /** Send mode flags (optional, defaults to PAY_GAS_SEPARATELY) */\n sendMode?: SendMode;\n /** Bounce flag (optional, defaults to true) */\n bounce?: boolean;\n /** Message validity timeout in seconds (optional) */\n timeout?: number;\n};\n\n/**\n * ClientTonSigner - Used by t402 clients to sign Jetton transfer messages\n *\n * This interface represents a TON wallet that can:\n * - Sign internal messages for Jetton transfers\n * - Query its own seqno (sequence number)\n *\n * Implementations may include:\n * - WalletContractV4 with private key\n * - TonConnect wallet adapter\n * - Hardware wallet integration\n */\nexport type ClientTonSigner = {\n /** The wallet address */\n readonly address: Address;\n\n /**\n * Sign an internal message for Jetton transfer\n * Returns the complete signed external message ready for broadcast\n *\n * @param params - Message parameters\n * @returns Signed external message as Cell (BOC)\n */\n signMessage(params: SignMessageParams): Promise<Cell>;\n\n /**\n * Get current seqno for the wallet\n * Used for replay protection\n *\n * @returns Current sequence number\n */\n getSeqno(): Promise<number>;\n};\n\n/**\n * Parameters for verifying a signed message\n */\nexport type VerifyMessageParams = {\n /** The signed BOC from client (base64) */\n signedBoc: string;\n /** Expected sender address */\n expectedFrom: string;\n /** Expected Jetton transfer details */\n expectedTransfer: {\n /** Expected Jetton amount */\n jettonAmount: bigint;\n /** Expected destination address */\n destination: string;\n /** Jetton master address */\n jettonMaster: string;\n };\n};\n\n/**\n * Parameters for waiting on transaction confirmation\n */\nexport type WaitForTransactionParams = {\n /** Address to monitor */\n address: string;\n /** Expected seqno after transaction */\n seqno: number;\n /** Timeout in milliseconds (optional) */\n timeout?: number;\n};\n\n/**\n * FacilitatorTonSigner - Used by t402 facilitators to verify and settle payments\n *\n * This interface combines RPC capabilities with signing abilities:\n * - Query Jetton balances and wallet addresses\n * - Verify signed messages\n * - Broadcast transactions\n * - Wait for confirmations\n */\nexport type FacilitatorTonSigner = {\n /**\n * Get all addresses this facilitator can use for signing\n * Enables dynamic address selection for load balancing\n */\n getAddresses(): readonly string[];\n\n /**\n * Query Jetton balance for an owner\n *\n * @param params - Owner and Jetton master addresses\n * @returns Balance in smallest units\n */\n getJettonBalance(params: { ownerAddress: string; jettonMasterAddress: string }): Promise<bigint>;\n\n /**\n * Get Jetton wallet address for an owner\n * Derives the associated Jetton wallet contract address\n *\n * @param params - Owner and Jetton master addresses\n * @returns Jetton wallet address\n */\n getJettonWalletAddress(params: {\n ownerAddress: string;\n jettonMasterAddress: string;\n }): Promise<string>;\n\n /**\n * Verify a signed message matches expected parameters\n * Validates the BOC structure and transfer details\n *\n * @param params - Verification parameters\n * @returns Verification result\n */\n verifyMessage(params: VerifyMessageParams): Promise<VerifyMessageResult>;\n\n /**\n * Send a pre-signed external message to the network\n *\n * @param signedBoc - Base64 encoded signed BOC\n * @returns Transaction hash or identifier\n */\n sendExternalMessage(signedBoc: string): Promise<string>;\n\n /**\n * Wait for transaction confirmation\n *\n * @param params - Transaction monitoring parameters\n * @returns Confirmation result\n */\n waitForTransaction(params: WaitForTransactionParams): Promise<TransactionConfirmation>;\n\n /**\n * Get current seqno for an address\n *\n * @param address - Wallet address to query\n * @returns Current seqno\n */\n getSeqno(address: string): Promise<number>;\n\n /**\n * Check if a wallet is deployed (active)\n *\n * @param address - Address to check\n * @returns true if deployed\n */\n isDeployed(address: string): Promise<boolean>;\n};\n\n/**\n * Converts a TON wallet to a ClientTonSigner\n * Identity function for type compatibility\n *\n * @param signer - The signer to convert\n * @returns The same signer with ClientTonSigner type\n */\nexport function toClientTonSigner(signer: ClientTonSigner): ClientTonSigner {\n return signer;\n}\n\n/**\n * Creates a FacilitatorTonSigner from a single-address facilitator\n * Wraps the single address in a getAddresses() function for compatibility\n *\n * @param client - Facilitator client with single address\n * @returns FacilitatorTonSigner with getAddresses() support\n */\nexport function toFacilitatorTonSigner(\n client: Omit<FacilitatorTonSigner, \"getAddresses\"> & { address: string },\n): FacilitatorTonSigner {\n return {\n ...client,\n getAddresses: () => [client.address],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmLO,SAAS,kBAAkB,QAA0C;AAC1E,SAAO;AACT;AASO,SAAS,uBACd,QACsB;AACtB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,MAAM,CAAC,OAAO,OAAO;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { Address, Cell, SendMode } from '@ton/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TON Payment Payload Types
|
|
5
|
+
*
|
|
6
|
+
* Defines the payload structure for TON Jetton payments in the t402 protocol.
|
|
7
|
+
* Uses BOC (Bag of Cells) format for message serialization.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* TON payment payload for the exact scheme (V2)
|
|
11
|
+
* Contains a pre-signed external message for Jetton transfer
|
|
12
|
+
*/
|
|
13
|
+
type ExactTonPayloadV2 = {
|
|
14
|
+
/**
|
|
15
|
+
* Base64 encoded signed external message (BOC format)
|
|
16
|
+
* Contains the complete Jetton transfer message ready for broadcast
|
|
17
|
+
* The message is signed by the client's wallet private key
|
|
18
|
+
*/
|
|
19
|
+
signedBoc: string;
|
|
20
|
+
/**
|
|
21
|
+
* Transfer authorization metadata
|
|
22
|
+
* Provides human-readable and verifiable parameters
|
|
23
|
+
*/
|
|
24
|
+
authorization: {
|
|
25
|
+
/**
|
|
26
|
+
* Sender wallet address (friendly format, bounceable)
|
|
27
|
+
* This is the TON wallet address that will send the Jetton transfer
|
|
28
|
+
*/
|
|
29
|
+
from: string;
|
|
30
|
+
/**
|
|
31
|
+
* Recipient wallet address (friendly format)
|
|
32
|
+
* Final destination for the Jetton tokens
|
|
33
|
+
*/
|
|
34
|
+
to: string;
|
|
35
|
+
/**
|
|
36
|
+
* Jetton master contract address
|
|
37
|
+
* Identifies which Jetton token is being transferred
|
|
38
|
+
*/
|
|
39
|
+
jettonMaster: string;
|
|
40
|
+
/**
|
|
41
|
+
* Jetton amount in smallest units (e.g., 1000000 for 1 USDT with 6 decimals)
|
|
42
|
+
*/
|
|
43
|
+
jettonAmount: string;
|
|
44
|
+
/**
|
|
45
|
+
* TON amount attached for gas (in nanoTON)
|
|
46
|
+
* Required to pay for the internal message execution
|
|
47
|
+
*/
|
|
48
|
+
tonAmount: string;
|
|
49
|
+
/**
|
|
50
|
+
* Unix timestamp (seconds) after which the authorization expires
|
|
51
|
+
* Message will be rejected by the network after this time
|
|
52
|
+
*/
|
|
53
|
+
validUntil: number;
|
|
54
|
+
/**
|
|
55
|
+
* Wallet sequence number at time of signing
|
|
56
|
+
* Prevents replay attacks - each seqno can only be used once
|
|
57
|
+
*/
|
|
58
|
+
seqno: number;
|
|
59
|
+
/**
|
|
60
|
+
* Query ID for the Jetton transfer
|
|
61
|
+
* Used for message correlation and deduplication
|
|
62
|
+
*/
|
|
63
|
+
queryId: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Alias for the current payload version
|
|
68
|
+
*/
|
|
69
|
+
type ExactTonPayload = ExactTonPayloadV2;
|
|
70
|
+
/**
|
|
71
|
+
* Result of message verification
|
|
72
|
+
*/
|
|
73
|
+
type VerifyMessageResult = {
|
|
74
|
+
/** Whether the message is valid */
|
|
75
|
+
valid: boolean;
|
|
76
|
+
/** Reason for invalidity (if applicable) */
|
|
77
|
+
reason?: string;
|
|
78
|
+
/** Extracted transfer parameters */
|
|
79
|
+
transfer?: {
|
|
80
|
+
from: string;
|
|
81
|
+
to: string;
|
|
82
|
+
jettonAmount: bigint;
|
|
83
|
+
queryId: bigint;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Transaction confirmation result
|
|
88
|
+
*/
|
|
89
|
+
type TransactionConfirmation = {
|
|
90
|
+
/** Whether the transaction was confirmed */
|
|
91
|
+
success: boolean;
|
|
92
|
+
/** Logical time of the transaction */
|
|
93
|
+
lt?: bigint;
|
|
94
|
+
/** Transaction hash */
|
|
95
|
+
hash?: string;
|
|
96
|
+
/** Error message if failed */
|
|
97
|
+
error?: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* TON Signer Interfaces
|
|
102
|
+
*
|
|
103
|
+
* Defines the signer interfaces for t402 client and facilitator operations.
|
|
104
|
+
* These interfaces abstract away the specific wallet implementation,
|
|
105
|
+
* allowing integration with various TON wallets and signing mechanisms.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Parameters for signing a TON internal message
|
|
110
|
+
*/
|
|
111
|
+
type SignMessageParams = {
|
|
112
|
+
/** Destination address (typically Jetton wallet contract) */
|
|
113
|
+
to: Address;
|
|
114
|
+
/** Amount of TON to attach (for gas) in nanoTON */
|
|
115
|
+
value: bigint;
|
|
116
|
+
/** Message body (Jetton transfer cell) */
|
|
117
|
+
body: Cell;
|
|
118
|
+
/** Send mode flags (optional, defaults to PAY_GAS_SEPARATELY) */
|
|
119
|
+
sendMode?: SendMode;
|
|
120
|
+
/** Bounce flag (optional, defaults to true) */
|
|
121
|
+
bounce?: boolean;
|
|
122
|
+
/** Message validity timeout in seconds (optional) */
|
|
123
|
+
timeout?: number;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* ClientTonSigner - Used by t402 clients to sign Jetton transfer messages
|
|
127
|
+
*
|
|
128
|
+
* This interface represents a TON wallet that can:
|
|
129
|
+
* - Sign internal messages for Jetton transfers
|
|
130
|
+
* - Query its own seqno (sequence number)
|
|
131
|
+
*
|
|
132
|
+
* Implementations may include:
|
|
133
|
+
* - WalletContractV4 with private key
|
|
134
|
+
* - TonConnect wallet adapter
|
|
135
|
+
* - Hardware wallet integration
|
|
136
|
+
*/
|
|
137
|
+
type ClientTonSigner = {
|
|
138
|
+
/** The wallet address */
|
|
139
|
+
readonly address: Address;
|
|
140
|
+
/**
|
|
141
|
+
* Sign an internal message for Jetton transfer
|
|
142
|
+
* Returns the complete signed external message ready for broadcast
|
|
143
|
+
*
|
|
144
|
+
* @param params - Message parameters
|
|
145
|
+
* @returns Signed external message as Cell (BOC)
|
|
146
|
+
*/
|
|
147
|
+
signMessage(params: SignMessageParams): Promise<Cell>;
|
|
148
|
+
/**
|
|
149
|
+
* Get current seqno for the wallet
|
|
150
|
+
* Used for replay protection
|
|
151
|
+
*
|
|
152
|
+
* @returns Current sequence number
|
|
153
|
+
*/
|
|
154
|
+
getSeqno(): Promise<number>;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Parameters for verifying a signed message
|
|
158
|
+
*/
|
|
159
|
+
type VerifyMessageParams = {
|
|
160
|
+
/** The signed BOC from client (base64) */
|
|
161
|
+
signedBoc: string;
|
|
162
|
+
/** Expected sender address */
|
|
163
|
+
expectedFrom: string;
|
|
164
|
+
/** Expected Jetton transfer details */
|
|
165
|
+
expectedTransfer: {
|
|
166
|
+
/** Expected Jetton amount */
|
|
167
|
+
jettonAmount: bigint;
|
|
168
|
+
/** Expected destination address */
|
|
169
|
+
destination: string;
|
|
170
|
+
/** Jetton master address */
|
|
171
|
+
jettonMaster: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Parameters for waiting on transaction confirmation
|
|
176
|
+
*/
|
|
177
|
+
type WaitForTransactionParams = {
|
|
178
|
+
/** Address to monitor */
|
|
179
|
+
address: string;
|
|
180
|
+
/** Expected seqno after transaction */
|
|
181
|
+
seqno: number;
|
|
182
|
+
/** Timeout in milliseconds (optional) */
|
|
183
|
+
timeout?: number;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* FacilitatorTonSigner - Used by t402 facilitators to verify and settle payments
|
|
187
|
+
*
|
|
188
|
+
* This interface combines RPC capabilities with signing abilities:
|
|
189
|
+
* - Query Jetton balances and wallet addresses
|
|
190
|
+
* - Verify signed messages
|
|
191
|
+
* - Broadcast transactions
|
|
192
|
+
* - Wait for confirmations
|
|
193
|
+
*/
|
|
194
|
+
type FacilitatorTonSigner = {
|
|
195
|
+
/**
|
|
196
|
+
* Get all addresses this facilitator can use for signing
|
|
197
|
+
* Enables dynamic address selection for load balancing
|
|
198
|
+
*/
|
|
199
|
+
getAddresses(): readonly string[];
|
|
200
|
+
/**
|
|
201
|
+
* Query Jetton balance for an owner
|
|
202
|
+
*
|
|
203
|
+
* @param params - Owner and Jetton master addresses
|
|
204
|
+
* @returns Balance in smallest units
|
|
205
|
+
*/
|
|
206
|
+
getJettonBalance(params: {
|
|
207
|
+
ownerAddress: string;
|
|
208
|
+
jettonMasterAddress: string;
|
|
209
|
+
}): Promise<bigint>;
|
|
210
|
+
/**
|
|
211
|
+
* Get Jetton wallet address for an owner
|
|
212
|
+
* Derives the associated Jetton wallet contract address
|
|
213
|
+
*
|
|
214
|
+
* @param params - Owner and Jetton master addresses
|
|
215
|
+
* @returns Jetton wallet address
|
|
216
|
+
*/
|
|
217
|
+
getJettonWalletAddress(params: {
|
|
218
|
+
ownerAddress: string;
|
|
219
|
+
jettonMasterAddress: string;
|
|
220
|
+
}): Promise<string>;
|
|
221
|
+
/**
|
|
222
|
+
* Verify a signed message matches expected parameters
|
|
223
|
+
* Validates the BOC structure and transfer details
|
|
224
|
+
*
|
|
225
|
+
* @param params - Verification parameters
|
|
226
|
+
* @returns Verification result
|
|
227
|
+
*/
|
|
228
|
+
verifyMessage(params: VerifyMessageParams): Promise<VerifyMessageResult>;
|
|
229
|
+
/**
|
|
230
|
+
* Send a pre-signed external message to the network
|
|
231
|
+
*
|
|
232
|
+
* @param signedBoc - Base64 encoded signed BOC
|
|
233
|
+
* @returns Transaction hash or identifier
|
|
234
|
+
*/
|
|
235
|
+
sendExternalMessage(signedBoc: string): Promise<string>;
|
|
236
|
+
/**
|
|
237
|
+
* Wait for transaction confirmation
|
|
238
|
+
*
|
|
239
|
+
* @param params - Transaction monitoring parameters
|
|
240
|
+
* @returns Confirmation result
|
|
241
|
+
*/
|
|
242
|
+
waitForTransaction(params: WaitForTransactionParams): Promise<TransactionConfirmation>;
|
|
243
|
+
/**
|
|
244
|
+
* Get current seqno for an address
|
|
245
|
+
*
|
|
246
|
+
* @param address - Wallet address to query
|
|
247
|
+
* @returns Current seqno
|
|
248
|
+
*/
|
|
249
|
+
getSeqno(address: string): Promise<number>;
|
|
250
|
+
/**
|
|
251
|
+
* Check if a wallet is deployed (active)
|
|
252
|
+
*
|
|
253
|
+
* @param address - Address to check
|
|
254
|
+
* @returns true if deployed
|
|
255
|
+
*/
|
|
256
|
+
isDeployed(address: string): Promise<boolean>;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Converts a TON wallet to a ClientTonSigner
|
|
260
|
+
* Identity function for type compatibility
|
|
261
|
+
*
|
|
262
|
+
* @param signer - The signer to convert
|
|
263
|
+
* @returns The same signer with ClientTonSigner type
|
|
264
|
+
*/
|
|
265
|
+
declare function toClientTonSigner(signer: ClientTonSigner): ClientTonSigner;
|
|
266
|
+
/**
|
|
267
|
+
* Creates a FacilitatorTonSigner from a single-address facilitator
|
|
268
|
+
* Wraps the single address in a getAddresses() function for compatibility
|
|
269
|
+
*
|
|
270
|
+
* @param client - Facilitator client with single address
|
|
271
|
+
* @returns FacilitatorTonSigner with getAddresses() support
|
|
272
|
+
*/
|
|
273
|
+
declare function toFacilitatorTonSigner(client: Omit<FacilitatorTonSigner, "getAddresses"> & {
|
|
274
|
+
address: string;
|
|
275
|
+
}): FacilitatorTonSigner;
|
|
276
|
+
|
|
277
|
+
export { type ClientTonSigner as C, type ExactTonPayloadV2 as E, type FacilitatorTonSigner as F, type SignMessageParams as S, type TransactionConfirmation as T, type VerifyMessageParams as V, type WaitForTransactionParams as W, toFacilitatorTonSigner as a, type ExactTonPayload as b, type VerifyMessageResult as c, toClientTonSigner as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@t402/ton",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"main": "./dist/cjs/index.js",
|
|
5
|
+
"module": "./dist/esm/index.js",
|
|
6
|
+
"types": "./dist/cjs/index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"t402",
|
|
9
|
+
"payment",
|
|
10
|
+
"protocol",
|
|
11
|
+
"ton",
|
|
12
|
+
"blockchain",
|
|
13
|
+
"jetton"
|
|
14
|
+
],
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"author": "T402 Team",
|
|
17
|
+
"repository": "https://github.com/t402-io/t402",
|
|
18
|
+
"description": "t402 Payment Protocol TON Implementation",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^9.24.0",
|
|
21
|
+
"@types/node": "^22.13.4",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
|
23
|
+
"@typescript-eslint/parser": "^8.29.1",
|
|
24
|
+
"eslint": "^9.24.0",
|
|
25
|
+
"eslint-plugin-import": "^2.31.0",
|
|
26
|
+
"eslint-plugin-jsdoc": "^50.6.9",
|
|
27
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
28
|
+
"prettier": "3.5.2",
|
|
29
|
+
"tsup": "^8.4.0",
|
|
30
|
+
"tsx": "^4.19.2",
|
|
31
|
+
"typescript": "^5.7.3",
|
|
32
|
+
"vite": "^6.2.6",
|
|
33
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
34
|
+
"vitest": "^3.0.5"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@ton/core": "^0.62.0",
|
|
38
|
+
"@ton/ton": "^15.0.0",
|
|
39
|
+
"@ton/crypto": "^3.2.0",
|
|
40
|
+
"@t402/core": "2.0.0"
|
|
41
|
+
},
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/esm/index.d.mts",
|
|
46
|
+
"default": "./dist/esm/index.mjs"
|
|
47
|
+
},
|
|
48
|
+
"require": {
|
|
49
|
+
"types": "./dist/cjs/index.d.ts",
|
|
50
|
+
"default": "./dist/cjs/index.js"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"./exact/client": {
|
|
54
|
+
"import": {
|
|
55
|
+
"types": "./dist/esm/exact/client/index.d.mts",
|
|
56
|
+
"default": "./dist/esm/exact/client/index.mjs"
|
|
57
|
+
},
|
|
58
|
+
"require": {
|
|
59
|
+
"types": "./dist/cjs/exact/client/index.d.ts",
|
|
60
|
+
"default": "./dist/cjs/exact/client/index.js"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"./exact/server": {
|
|
64
|
+
"import": {
|
|
65
|
+
"types": "./dist/esm/exact/server/index.d.mts",
|
|
66
|
+
"default": "./dist/esm/exact/server/index.mjs"
|
|
67
|
+
},
|
|
68
|
+
"require": {
|
|
69
|
+
"types": "./dist/cjs/exact/server/index.d.ts",
|
|
70
|
+
"default": "./dist/cjs/exact/server/index.js"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"./exact/facilitator": {
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./dist/esm/exact/facilitator/index.d.mts",
|
|
76
|
+
"default": "./dist/esm/exact/facilitator/index.mjs"
|
|
77
|
+
},
|
|
78
|
+
"require": {
|
|
79
|
+
"types": "./dist/cjs/exact/facilitator/index.d.ts",
|
|
80
|
+
"default": "./dist/cjs/exact/facilitator/index.js"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"files": [
|
|
85
|
+
"dist"
|
|
86
|
+
],
|
|
87
|
+
"scripts": {
|
|
88
|
+
"start": "tsx --env-file=.env index.ts",
|
|
89
|
+
"build": "tsup",
|
|
90
|
+
"test": "vitest run",
|
|
91
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
92
|
+
"test:watch": "vitest",
|
|
93
|
+
"watch": "tsc --watch",
|
|
94
|
+
"format": "prettier -c .prettierrc --write \"**/*.{ts,js,cjs,json,md}\"",
|
|
95
|
+
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\"",
|
|
96
|
+
"lint": "eslint . --ext .ts --fix",
|
|
97
|
+
"lint:check": "eslint . --ext .ts"
|
|
98
|
+
}
|
|
99
|
+
}
|