@t402/evm 2.2.0 → 2.3.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 +2 -2
- package/dist/cjs/exact/client/index.js +4 -2
- package/dist/cjs/exact/client/index.js.map +1 -1
- package/dist/cjs/exact/facilitator/index.d.ts +1 -1
- package/dist/cjs/exact/facilitator/index.js +40 -4
- package/dist/cjs/exact/facilitator/index.js.map +1 -1
- package/dist/cjs/exact/server/index.d.ts +1 -1
- package/dist/cjs/exact/server/index.js +301 -33
- package/dist/cjs/exact/server/index.js.map +1 -1
- package/dist/cjs/exact/v1/client/index.d.ts +1 -1
- package/dist/cjs/exact/v1/client/index.js +3 -1
- package/dist/cjs/exact/v1/client/index.js.map +1 -1
- package/dist/cjs/exact/v1/facilitator/index.d.ts +1 -1
- package/dist/cjs/exact/v1/facilitator/index.js +21 -2
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -1
- package/dist/cjs/index.d.ts +606 -352
- package/dist/cjs/index.js +1436 -268
- package/dist/cjs/index.js.map +1 -1
- package/dist/{esm/scheme-yqGaK9rK.d.mts → cjs/scheme-B4rXSKCN.d.ts} +18 -16
- package/dist/cjs/scheme-CIar5W2B.d.ts +200 -0
- package/dist/cjs/{scheme-OojTBKAz.d.ts → scheme-CjijeY7y.d.ts} +1 -1
- package/dist/{esm/signer-BkcAzwYi.d.mts → cjs/signer-DcavxxZt.d.ts} +1 -18
- package/dist/cjs/upto/client/index.d.ts +61 -0
- package/dist/cjs/upto/client/index.js +154 -0
- package/dist/cjs/upto/client/index.js.map +1 -0
- package/dist/cjs/upto/index.d.ts +111 -0
- package/dist/cjs/upto/index.js +1030 -0
- package/dist/cjs/upto/index.js.map +1 -0
- package/dist/cjs/v1/index.d.ts +1 -1
- package/dist/cjs/v1/index.js +3 -1
- package/dist/cjs/v1/index.js.map +1 -1
- package/dist/esm/{chunk-ACDQ5QNT.mjs → chunk-4FBTQTNM.mjs} +27 -5
- package/dist/esm/chunk-4FBTQTNM.mjs.map +1 -0
- package/dist/esm/chunk-IWSDEZKI.mjs +477 -0
- package/dist/esm/chunk-IWSDEZKI.mjs.map +1 -0
- package/dist/esm/{chunk-LGSG73NJ.mjs → chunk-LM5RZBVP.mjs} +9 -4
- package/dist/esm/{chunk-LGSG73NJ.mjs.map → chunk-LM5RZBVP.mjs.map} +1 -1
- package/dist/esm/chunk-NSSMTXJJ.mjs +8 -0
- package/dist/esm/chunk-NSSMTXJJ.mjs.map +1 -0
- package/dist/esm/chunk-SJ52GTJJ.mjs +411 -0
- package/dist/esm/chunk-SJ52GTJJ.mjs.map +1 -0
- package/dist/esm/chunk-SURTCHSX.mjs +129 -0
- package/dist/esm/chunk-SURTCHSX.mjs.map +1 -0
- package/dist/esm/chunk-SYVPLXYV.mjs +26 -0
- package/dist/esm/chunk-SYVPLXYV.mjs.map +1 -0
- package/dist/esm/{chunk-XYKAO6KJ.mjs → chunk-Y4U7Q543.mjs} +2 -25
- package/dist/esm/chunk-Y4U7Q543.mjs.map +1 -0
- package/dist/esm/{chunk-JBWWBRYY.mjs → chunk-ZWEYARER.mjs} +9 -4
- package/dist/esm/{chunk-JBWWBRYY.mjs.map → chunk-ZWEYARER.mjs.map} +1 -1
- package/dist/esm/exact/client/index.d.mts +2 -2
- package/dist/esm/exact/client/index.mjs +6 -4
- package/dist/esm/exact/client/index.mjs.map +1 -1
- package/dist/esm/exact/facilitator/index.d.mts +1 -1
- package/dist/esm/exact/facilitator/index.mjs +26 -5
- package/dist/esm/exact/facilitator/index.mjs.map +1 -1
- package/dist/esm/exact/server/index.d.mts +1 -1
- package/dist/esm/exact/server/index.mjs +29 -30
- package/dist/esm/exact/server/index.mjs.map +1 -1
- package/dist/esm/exact/v1/client/index.d.mts +1 -1
- package/dist/esm/exact/v1/client/index.mjs +4 -2
- package/dist/esm/exact/v1/facilitator/index.d.mts +1 -1
- package/dist/esm/exact/v1/facilitator/index.mjs +4 -2
- package/dist/esm/index.d.mts +606 -352
- package/dist/esm/index.mjs +626 -138
- package/dist/esm/index.mjs.map +1 -1
- package/dist/{cjs/scheme-yqGaK9rK.d.ts → esm/scheme-B4rXSKCN.d.mts} +18 -16
- package/dist/esm/scheme-DATfd6oM.d.mts +200 -0
- package/dist/esm/{scheme-D4mOqq9l.d.mts → scheme-Ddb0dG_F.d.mts} +1 -1
- package/dist/{cjs/signer-BkcAzwYi.d.ts → esm/signer-DcavxxZt.d.mts} +1 -18
- package/dist/esm/upto/client/index.d.mts +61 -0
- package/dist/esm/upto/client/index.mjs +11 -0
- package/dist/esm/upto/client/index.mjs.map +1 -0
- package/dist/esm/upto/index.d.mts +111 -0
- package/dist/esm/upto/index.mjs +26 -0
- package/dist/esm/upto/index.mjs.map +1 -0
- package/dist/esm/v1/index.d.mts +1 -1
- package/dist/esm/v1/index.mjs +5 -3
- package/package.json +30 -6
- package/dist/cjs/scheme-C6uD7PdY.d.ts +0 -130
- package/dist/esm/chunk-ACDQ5QNT.mjs.map +0 -1
- package/dist/esm/chunk-OEXW2OK2.mjs +0 -251
- package/dist/esm/chunk-OEXW2OK2.mjs.map +0 -1
- package/dist/esm/chunk-XYKAO6KJ.mjs.map +0 -1
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
1
|
+
export * from '@t402/evm-core';
|
|
2
|
+
export { E as ExactEvmScheme } from './scheme-Ddb0dG_F.mjs';
|
|
3
|
+
export { a as ExactEvmSchemeConfig } from './scheme-B4rXSKCN.mjs';
|
|
3
4
|
import { SchemeNetworkClient, PaymentRequirements, PaymentPayload, SchemeNetworkServer, MoneyParser, Price, Network, AssetAmount, SchemeNetworkFacilitator, VerifyResponse, SettleResponse } from '@t402/core/types';
|
|
4
|
-
import { C as ClientEvmSigner, F as FacilitatorEvmSigner } from './signer-
|
|
5
|
-
export {
|
|
5
|
+
import { C as ClientEvmSigner, F as FacilitatorEvmSigner } from './signer-DcavxxZt.mjs';
|
|
6
|
+
export { UptoEvmScheme, createUptoEvmScheme } from './upto/client/index.mjs';
|
|
7
|
+
export { b as UptoEvmFacilitatorScheme, e as UptoEvmFacilitatorSchemeConfig, U as UptoEvmServerScheme, a as UptoEvmServerSchemeConfig, d as createUptoEvmFacilitatorScheme, c as createUptoEvmServerScheme } from './scheme-DATfd6oM.mjs';
|
|
6
8
|
import { Address, Hex, PublicClient } from 'viem';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -59,18 +61,52 @@ declare class ExactLegacyEvmScheme$1 implements SchemeNetworkServer {
|
|
|
59
61
|
readonly scheme = "exact-legacy";
|
|
60
62
|
private moneyParsers;
|
|
61
63
|
private config;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new ExactLegacyEvmScheme instance.
|
|
66
|
+
*
|
|
67
|
+
* @param config - Optional configuration options for the scheme
|
|
68
|
+
*/
|
|
62
69
|
constructor(config?: ExactLegacyEvmSchemeConfig$1);
|
|
70
|
+
/**
|
|
71
|
+
* Get all supported networks that have legacy tokens
|
|
72
|
+
*
|
|
73
|
+
* @returns Array of network identifiers with legacy token support
|
|
74
|
+
*/
|
|
75
|
+
static getSupportedNetworks(): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Check if a network has legacy token support
|
|
78
|
+
*
|
|
79
|
+
* @param network - The network identifier to check
|
|
80
|
+
* @returns True if the network has legacy token support
|
|
81
|
+
*/
|
|
82
|
+
static isNetworkSupported(network: string): boolean;
|
|
63
83
|
/**
|
|
64
84
|
* Register a custom money parser in the parser chain.
|
|
85
|
+
*
|
|
86
|
+
* @param parser - Custom function to convert amount to AssetAmount
|
|
87
|
+
* @returns The scheme instance for method chaining
|
|
65
88
|
*/
|
|
66
89
|
registerMoneyParser(parser: MoneyParser): ExactLegacyEvmScheme$1;
|
|
67
90
|
/**
|
|
68
91
|
* Parses a price into an asset amount for legacy tokens.
|
|
92
|
+
*
|
|
93
|
+
* @param price - The price to parse (Money or AssetAmount)
|
|
94
|
+
* @param network - The network identifier in CAIP-2 format
|
|
95
|
+
* @returns Promise resolving to the parsed asset amount
|
|
69
96
|
*/
|
|
70
97
|
parsePrice(price: Price, network: Network): Promise<AssetAmount>;
|
|
71
98
|
/**
|
|
72
99
|
* Build payment requirements for this scheme/network combination.
|
|
73
100
|
* Adds the spender (facilitator) address to the extra field.
|
|
101
|
+
*
|
|
102
|
+
* @param paymentRequirements - The base payment requirements to enhance
|
|
103
|
+
* @param supportedKind - The supported kind from facilitator
|
|
104
|
+
* @param supportedKind.t402Version - The t402 protocol version
|
|
105
|
+
* @param supportedKind.scheme - The logical payment scheme identifier
|
|
106
|
+
* @param supportedKind.network - The network identifier in CAIP-2 format
|
|
107
|
+
* @param supportedKind.extra - Optional extra metadata with spender address
|
|
108
|
+
* @param extensionKeys - Extension keys supported by the facilitator (unused)
|
|
109
|
+
* @returns Promise resolving to enhanced payment requirements
|
|
74
110
|
*/
|
|
75
111
|
enhancePaymentRequirements(paymentRequirements: PaymentRequirements, supportedKind: {
|
|
76
112
|
t402Version: number;
|
|
@@ -80,28 +116,34 @@ declare class ExactLegacyEvmScheme$1 implements SchemeNetworkServer {
|
|
|
80
116
|
}, extensionKeys: string[]): Promise<PaymentRequirements>;
|
|
81
117
|
/**
|
|
82
118
|
* Parse Money (string | number) to a decimal number.
|
|
119
|
+
*
|
|
120
|
+
* @param money - The money value to parse (e.g., "$1.50" or 1.50)
|
|
121
|
+
* @returns The decimal number representation
|
|
83
122
|
*/
|
|
84
123
|
private parseMoneyToDecimal;
|
|
85
124
|
/**
|
|
86
125
|
* Default money conversion implementation for legacy tokens.
|
|
126
|
+
*
|
|
127
|
+
* @param amount - The decimal amount to convert (e.g., 1.50)
|
|
128
|
+
* @param network - The network identifier in CAIP-2 format
|
|
129
|
+
* @returns The asset amount in token units
|
|
87
130
|
*/
|
|
88
131
|
private defaultMoneyConversion;
|
|
89
132
|
/**
|
|
90
133
|
* Convert decimal amount to token units
|
|
134
|
+
*
|
|
135
|
+
* @param decimalAmount - The decimal amount as a string (e.g., "1.50")
|
|
136
|
+
* @param decimals - The number of decimal places for the token
|
|
137
|
+
* @returns The token amount as a string in smallest units
|
|
91
138
|
*/
|
|
92
139
|
private convertToTokenAmount;
|
|
93
140
|
/**
|
|
94
141
|
* Get the default legacy token for a network.
|
|
142
|
+
*
|
|
143
|
+
* @param network - The network identifier in CAIP-2 format
|
|
144
|
+
* @returns The token configuration for the default legacy token
|
|
95
145
|
*/
|
|
96
146
|
private getDefaultAsset;
|
|
97
|
-
/**
|
|
98
|
-
* Get all supported networks that have legacy tokens
|
|
99
|
-
*/
|
|
100
|
-
static getSupportedNetworks(): string[];
|
|
101
|
-
/**
|
|
102
|
-
* Check if a network has legacy token support
|
|
103
|
-
*/
|
|
104
|
-
static isNetworkSupported(network: string): boolean;
|
|
105
147
|
}
|
|
106
148
|
|
|
107
149
|
interface ExactLegacyEvmSchemeConfig {
|
|
@@ -140,349 +182,29 @@ declare class ExactLegacyEvmScheme implements SchemeNetworkFacilitator {
|
|
|
140
182
|
getExtra(network: string): Record<string, unknown> | undefined;
|
|
141
183
|
/**
|
|
142
184
|
* Get signer addresses used by this facilitator.
|
|
185
|
+
*
|
|
186
|
+
* @param network - The network identifier (unused, returns same addresses for all networks)
|
|
187
|
+
* @returns Array of signer addresses
|
|
143
188
|
*/
|
|
144
189
|
getSigners(network: string): string[];
|
|
145
190
|
/**
|
|
146
191
|
* Verifies a payment payload.
|
|
192
|
+
*
|
|
193
|
+
* @param payload - The payment payload to verify
|
|
194
|
+
* @param requirements - The payment requirements to verify against
|
|
195
|
+
* @returns Promise resolving to verification response with validity status
|
|
147
196
|
*/
|
|
148
197
|
verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
|
|
149
198
|
/**
|
|
150
199
|
* Settles a payment by executing transferFrom.
|
|
200
|
+
*
|
|
201
|
+
* @param payload - The payment payload containing transfer authorization
|
|
202
|
+
* @param requirements - The payment requirements specifying amount and recipient
|
|
203
|
+
* @returns Promise resolving to settlement response with transaction hash
|
|
151
204
|
*/
|
|
152
205
|
settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
|
|
153
206
|
}
|
|
154
207
|
|
|
155
|
-
/**
|
|
156
|
-
* Token configuration for T402 EVM payments
|
|
157
|
-
*
|
|
158
|
-
* This module provides comprehensive token definitions including:
|
|
159
|
-
* - USDT0 (Tether's new omnichain token with EIP-3009 support)
|
|
160
|
-
* - USDC (USD Coin with EIP-3009 support)
|
|
161
|
-
* - Legacy tokens configuration
|
|
162
|
-
*/
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Token type classification for payment scheme selection
|
|
166
|
-
*/
|
|
167
|
-
type TokenType = "eip3009" | "legacy";
|
|
168
|
-
/**
|
|
169
|
-
* Token configuration with EIP-712 domain parameters
|
|
170
|
-
*/
|
|
171
|
-
interface TokenConfig {
|
|
172
|
-
/** Token contract address */
|
|
173
|
-
address: Address;
|
|
174
|
-
/** Token symbol (e.g., "USDT0", "USDC") */
|
|
175
|
-
symbol: string;
|
|
176
|
-
/** EIP-712 domain name for signing */
|
|
177
|
-
name: string;
|
|
178
|
-
/** EIP-712 domain version for signing */
|
|
179
|
-
version: string;
|
|
180
|
-
/** Number of decimal places */
|
|
181
|
-
decimals: number;
|
|
182
|
-
/** Token type for scheme selection */
|
|
183
|
-
tokenType: TokenType;
|
|
184
|
-
/** Payment priority (lower = higher priority) */
|
|
185
|
-
priority: number;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Network token registry mapping network -> symbol -> config
|
|
189
|
-
*/
|
|
190
|
-
type NetworkTokenRegistry = Record<string, Record<string, TokenConfig>>;
|
|
191
|
-
/**
|
|
192
|
-
* USDT0 Contract Addresses by Network
|
|
193
|
-
* Source: https://docs.tether.io/usdt0/integration-guide/deployed-contracts
|
|
194
|
-
*
|
|
195
|
-
* USDT0 is Tether's new omnichain token using LayerZero OFT standard.
|
|
196
|
-
* Key features:
|
|
197
|
-
* - Supports EIP-3009 transferWithAuthorization (gasless transfers)
|
|
198
|
-
* - Supports EIP-2612 permit
|
|
199
|
-
* - Native cross-chain via LayerZero
|
|
200
|
-
*/
|
|
201
|
-
declare const USDT0_ADDRESSES: Record<string, Address>;
|
|
202
|
-
/**
|
|
203
|
-
* USDC Contract Addresses by Network
|
|
204
|
-
* Native USDC with EIP-3009 support
|
|
205
|
-
*/
|
|
206
|
-
declare const USDC_ADDRESSES: Record<string, Address>;
|
|
207
|
-
/**
|
|
208
|
-
* Traditional USDT Addresses (Legacy - no EIP-3009 support)
|
|
209
|
-
* These require the approve + transferFrom pattern
|
|
210
|
-
*/
|
|
211
|
-
declare const USDT_LEGACY_ADDRESSES: Record<string, Address>;
|
|
212
|
-
/**
|
|
213
|
-
* Complete token registry with all supported tokens per network
|
|
214
|
-
*/
|
|
215
|
-
declare const TOKEN_REGISTRY: NetworkTokenRegistry;
|
|
216
|
-
/**
|
|
217
|
-
* Token priority for payment method selection
|
|
218
|
-
* Lower number = higher priority
|
|
219
|
-
*/
|
|
220
|
-
declare const TOKEN_PRIORITY: Record<string, number>;
|
|
221
|
-
/**
|
|
222
|
-
* Get token configuration for a specific token on a network
|
|
223
|
-
*/
|
|
224
|
-
declare function getTokenConfig(network: string, symbol: string): TokenConfig | undefined;
|
|
225
|
-
/**
|
|
226
|
-
* Get all tokens available on a network
|
|
227
|
-
*/
|
|
228
|
-
declare function getNetworkTokens(network: string): TokenConfig[];
|
|
229
|
-
/**
|
|
230
|
-
* Get the default/preferred token for a network
|
|
231
|
-
* Prefers USDT0 > USDC > others based on priority
|
|
232
|
-
*/
|
|
233
|
-
declare function getDefaultToken(network: string): TokenConfig | undefined;
|
|
234
|
-
/**
|
|
235
|
-
* Get token by contract address on a network
|
|
236
|
-
*/
|
|
237
|
-
declare function getTokenByAddress(network: string, address: Address): TokenConfig | undefined;
|
|
238
|
-
/**
|
|
239
|
-
* Check if a token supports EIP-3009 (gasless transfers)
|
|
240
|
-
*/
|
|
241
|
-
declare function supportsEIP3009(network: string, symbol: string): boolean;
|
|
242
|
-
/**
|
|
243
|
-
* Get all networks that support a specific token
|
|
244
|
-
*/
|
|
245
|
-
declare function getNetworksForToken(symbol: string): string[];
|
|
246
|
-
/**
|
|
247
|
-
* Get USDT0 networks (primary T402 token)
|
|
248
|
-
*/
|
|
249
|
-
declare function getUsdt0Networks(): string[];
|
|
250
|
-
/**
|
|
251
|
-
* EIP-712 domain configuration for a token
|
|
252
|
-
*/
|
|
253
|
-
declare function getEIP712Domain(network: string, tokenAddress: Address, chainId: number): {
|
|
254
|
-
name: string;
|
|
255
|
-
version: string;
|
|
256
|
-
chainId: number;
|
|
257
|
-
verifyingContract: Address;
|
|
258
|
-
} | undefined;
|
|
259
|
-
|
|
260
|
-
type ExactEIP3009Payload = {
|
|
261
|
-
signature?: `0x${string}`;
|
|
262
|
-
authorization: {
|
|
263
|
-
from: `0x${string}`;
|
|
264
|
-
to: `0x${string}`;
|
|
265
|
-
value: string;
|
|
266
|
-
validAfter: string;
|
|
267
|
-
validBefore: string;
|
|
268
|
-
nonce: `0x${string}`;
|
|
269
|
-
};
|
|
270
|
-
};
|
|
271
|
-
type ExactEvmPayloadV1 = ExactEIP3009Payload;
|
|
272
|
-
type ExactEvmPayloadV2 = ExactEIP3009Payload;
|
|
273
|
-
/**
|
|
274
|
-
* Payload for exact-legacy scheme (approve + transferFrom pattern)
|
|
275
|
-
* Used for legacy USDT and other tokens without EIP-3009 support
|
|
276
|
-
*/
|
|
277
|
-
type ExactLegacyPayload = {
|
|
278
|
-
signature?: `0x${string}`;
|
|
279
|
-
authorization: {
|
|
280
|
-
/** Payer address */
|
|
281
|
-
from: `0x${string}`;
|
|
282
|
-
/** Recipient address */
|
|
283
|
-
to: `0x${string}`;
|
|
284
|
-
/** Payment amount in token units */
|
|
285
|
-
value: string;
|
|
286
|
-
/** Unix timestamp after which the authorization is valid */
|
|
287
|
-
validAfter: string;
|
|
288
|
-
/** Unix timestamp before which the authorization is valid */
|
|
289
|
-
validBefore: string;
|
|
290
|
-
/** Unique nonce to prevent replay attacks */
|
|
291
|
-
nonce: `0x${string}`;
|
|
292
|
-
/** Facilitator address that will call transferFrom */
|
|
293
|
-
spender: `0x${string}`;
|
|
294
|
-
};
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
declare const authorizationTypes: {
|
|
298
|
-
readonly TransferWithAuthorization: readonly [{
|
|
299
|
-
readonly name: "from";
|
|
300
|
-
readonly type: "address";
|
|
301
|
-
}, {
|
|
302
|
-
readonly name: "to";
|
|
303
|
-
readonly type: "address";
|
|
304
|
-
}, {
|
|
305
|
-
readonly name: "value";
|
|
306
|
-
readonly type: "uint256";
|
|
307
|
-
}, {
|
|
308
|
-
readonly name: "validAfter";
|
|
309
|
-
readonly type: "uint256";
|
|
310
|
-
}, {
|
|
311
|
-
readonly name: "validBefore";
|
|
312
|
-
readonly type: "uint256";
|
|
313
|
-
}, {
|
|
314
|
-
readonly name: "nonce";
|
|
315
|
-
readonly type: "bytes32";
|
|
316
|
-
}];
|
|
317
|
-
};
|
|
318
|
-
declare const legacyAuthorizationTypes: {
|
|
319
|
-
readonly LegacyTransferAuthorization: readonly [{
|
|
320
|
-
readonly name: "from";
|
|
321
|
-
readonly type: "address";
|
|
322
|
-
}, {
|
|
323
|
-
readonly name: "to";
|
|
324
|
-
readonly type: "address";
|
|
325
|
-
}, {
|
|
326
|
-
readonly name: "value";
|
|
327
|
-
readonly type: "uint256";
|
|
328
|
-
}, {
|
|
329
|
-
readonly name: "validAfter";
|
|
330
|
-
readonly type: "uint256";
|
|
331
|
-
}, {
|
|
332
|
-
readonly name: "validBefore";
|
|
333
|
-
readonly type: "uint256";
|
|
334
|
-
}, {
|
|
335
|
-
readonly name: "nonce";
|
|
336
|
-
readonly type: "bytes32";
|
|
337
|
-
}, {
|
|
338
|
-
readonly name: "spender";
|
|
339
|
-
readonly type: "address";
|
|
340
|
-
}];
|
|
341
|
-
};
|
|
342
|
-
declare const eip3009ABI: readonly [{
|
|
343
|
-
readonly inputs: readonly [{
|
|
344
|
-
readonly name: "from";
|
|
345
|
-
readonly type: "address";
|
|
346
|
-
}, {
|
|
347
|
-
readonly name: "to";
|
|
348
|
-
readonly type: "address";
|
|
349
|
-
}, {
|
|
350
|
-
readonly name: "value";
|
|
351
|
-
readonly type: "uint256";
|
|
352
|
-
}, {
|
|
353
|
-
readonly name: "validAfter";
|
|
354
|
-
readonly type: "uint256";
|
|
355
|
-
}, {
|
|
356
|
-
readonly name: "validBefore";
|
|
357
|
-
readonly type: "uint256";
|
|
358
|
-
}, {
|
|
359
|
-
readonly name: "nonce";
|
|
360
|
-
readonly type: "bytes32";
|
|
361
|
-
}, {
|
|
362
|
-
readonly name: "v";
|
|
363
|
-
readonly type: "uint8";
|
|
364
|
-
}, {
|
|
365
|
-
readonly name: "r";
|
|
366
|
-
readonly type: "bytes32";
|
|
367
|
-
}, {
|
|
368
|
-
readonly name: "s";
|
|
369
|
-
readonly type: "bytes32";
|
|
370
|
-
}];
|
|
371
|
-
readonly name: "transferWithAuthorization";
|
|
372
|
-
readonly outputs: readonly [];
|
|
373
|
-
readonly stateMutability: "nonpayable";
|
|
374
|
-
readonly type: "function";
|
|
375
|
-
}, {
|
|
376
|
-
readonly inputs: readonly [{
|
|
377
|
-
readonly name: "from";
|
|
378
|
-
readonly type: "address";
|
|
379
|
-
}, {
|
|
380
|
-
readonly name: "to";
|
|
381
|
-
readonly type: "address";
|
|
382
|
-
}, {
|
|
383
|
-
readonly name: "value";
|
|
384
|
-
readonly type: "uint256";
|
|
385
|
-
}, {
|
|
386
|
-
readonly name: "validAfter";
|
|
387
|
-
readonly type: "uint256";
|
|
388
|
-
}, {
|
|
389
|
-
readonly name: "validBefore";
|
|
390
|
-
readonly type: "uint256";
|
|
391
|
-
}, {
|
|
392
|
-
readonly name: "nonce";
|
|
393
|
-
readonly type: "bytes32";
|
|
394
|
-
}, {
|
|
395
|
-
readonly name: "signature";
|
|
396
|
-
readonly type: "bytes";
|
|
397
|
-
}];
|
|
398
|
-
readonly name: "transferWithAuthorization";
|
|
399
|
-
readonly outputs: readonly [];
|
|
400
|
-
readonly stateMutability: "nonpayable";
|
|
401
|
-
readonly type: "function";
|
|
402
|
-
}, {
|
|
403
|
-
readonly inputs: readonly [{
|
|
404
|
-
readonly name: "account";
|
|
405
|
-
readonly type: "address";
|
|
406
|
-
}];
|
|
407
|
-
readonly name: "balanceOf";
|
|
408
|
-
readonly outputs: readonly [{
|
|
409
|
-
readonly name: "";
|
|
410
|
-
readonly type: "uint256";
|
|
411
|
-
}];
|
|
412
|
-
readonly stateMutability: "view";
|
|
413
|
-
readonly type: "function";
|
|
414
|
-
}, {
|
|
415
|
-
readonly inputs: readonly [];
|
|
416
|
-
readonly name: "version";
|
|
417
|
-
readonly outputs: readonly [{
|
|
418
|
-
readonly name: "";
|
|
419
|
-
readonly type: "string";
|
|
420
|
-
}];
|
|
421
|
-
readonly stateMutability: "view";
|
|
422
|
-
readonly type: "function";
|
|
423
|
-
}];
|
|
424
|
-
declare const erc20LegacyABI: readonly [{
|
|
425
|
-
readonly inputs: readonly [{
|
|
426
|
-
readonly name: "account";
|
|
427
|
-
readonly type: "address";
|
|
428
|
-
}];
|
|
429
|
-
readonly name: "balanceOf";
|
|
430
|
-
readonly outputs: readonly [{
|
|
431
|
-
readonly name: "";
|
|
432
|
-
readonly type: "uint256";
|
|
433
|
-
}];
|
|
434
|
-
readonly stateMutability: "view";
|
|
435
|
-
readonly type: "function";
|
|
436
|
-
}, {
|
|
437
|
-
readonly inputs: readonly [{
|
|
438
|
-
readonly name: "owner";
|
|
439
|
-
readonly type: "address";
|
|
440
|
-
}, {
|
|
441
|
-
readonly name: "spender";
|
|
442
|
-
readonly type: "address";
|
|
443
|
-
}];
|
|
444
|
-
readonly name: "allowance";
|
|
445
|
-
readonly outputs: readonly [{
|
|
446
|
-
readonly name: "";
|
|
447
|
-
readonly type: "uint256";
|
|
448
|
-
}];
|
|
449
|
-
readonly stateMutability: "view";
|
|
450
|
-
readonly type: "function";
|
|
451
|
-
}, {
|
|
452
|
-
readonly inputs: readonly [{
|
|
453
|
-
readonly name: "spender";
|
|
454
|
-
readonly type: "address";
|
|
455
|
-
}, {
|
|
456
|
-
readonly name: "amount";
|
|
457
|
-
readonly type: "uint256";
|
|
458
|
-
}];
|
|
459
|
-
readonly name: "approve";
|
|
460
|
-
readonly outputs: readonly [{
|
|
461
|
-
readonly name: "";
|
|
462
|
-
readonly type: "bool";
|
|
463
|
-
}];
|
|
464
|
-
readonly stateMutability: "nonpayable";
|
|
465
|
-
readonly type: "function";
|
|
466
|
-
}, {
|
|
467
|
-
readonly inputs: readonly [{
|
|
468
|
-
readonly name: "from";
|
|
469
|
-
readonly type: "address";
|
|
470
|
-
}, {
|
|
471
|
-
readonly name: "to";
|
|
472
|
-
readonly type: "address";
|
|
473
|
-
}, {
|
|
474
|
-
readonly name: "amount";
|
|
475
|
-
readonly type: "uint256";
|
|
476
|
-
}];
|
|
477
|
-
readonly name: "transferFrom";
|
|
478
|
-
readonly outputs: readonly [{
|
|
479
|
-
readonly name: "";
|
|
480
|
-
readonly type: "bool";
|
|
481
|
-
}];
|
|
482
|
-
readonly stateMutability: "nonpayable";
|
|
483
|
-
readonly type: "function";
|
|
484
|
-
}];
|
|
485
|
-
|
|
486
208
|
/**
|
|
487
209
|
* Type definitions for USDT0 cross-chain bridging
|
|
488
210
|
*/
|
|
@@ -622,6 +344,86 @@ interface BridgeSigner {
|
|
|
622
344
|
hash: `0x${string}`;
|
|
623
345
|
}): Promise<TransactionReceipt>;
|
|
624
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* LayerZero message status from Scan API
|
|
349
|
+
*/
|
|
350
|
+
type LayerZeroMessageStatus = "INFLIGHT" | "CONFIRMING" | "DELIVERED" | "FAILED" | "BLOCKED";
|
|
351
|
+
/**
|
|
352
|
+
* LayerZero message from Scan API
|
|
353
|
+
*/
|
|
354
|
+
interface LayerZeroMessage {
|
|
355
|
+
/** Unique message identifier */
|
|
356
|
+
guid: string;
|
|
357
|
+
/** Source chain LayerZero endpoint ID */
|
|
358
|
+
srcEid: number;
|
|
359
|
+
/** Destination chain LayerZero endpoint ID */
|
|
360
|
+
dstEid: number;
|
|
361
|
+
/** Source chain OApp address */
|
|
362
|
+
srcUaAddress: string;
|
|
363
|
+
/** Destination chain OApp address */
|
|
364
|
+
dstUaAddress: string;
|
|
365
|
+
/** Source chain transaction hash */
|
|
366
|
+
srcTxHash: string;
|
|
367
|
+
/** Destination chain transaction hash (when delivered) */
|
|
368
|
+
dstTxHash?: string;
|
|
369
|
+
/** Current message status */
|
|
370
|
+
status: LayerZeroMessageStatus;
|
|
371
|
+
/** Source chain block number */
|
|
372
|
+
srcBlockNumber: number;
|
|
373
|
+
/** Destination chain block number (when delivered) */
|
|
374
|
+
dstBlockNumber?: number;
|
|
375
|
+
/** Timestamp when message was created */
|
|
376
|
+
created: string;
|
|
377
|
+
/** Timestamp when message was last updated */
|
|
378
|
+
updated: string;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Options for waiting for message delivery
|
|
382
|
+
*/
|
|
383
|
+
interface WaitForDeliveryOptions {
|
|
384
|
+
/** Maximum time to wait in milliseconds (default: 600000 = 10 minutes) */
|
|
385
|
+
timeout?: number;
|
|
386
|
+
/** Polling interval in milliseconds (default: 10000 = 10 seconds) */
|
|
387
|
+
pollInterval?: number;
|
|
388
|
+
/** Callback when status changes */
|
|
389
|
+
onStatusChange?: (status: LayerZeroMessageStatus) => void;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Parameters for cross-chain payment routing
|
|
393
|
+
*/
|
|
394
|
+
interface CrossChainPaymentParams {
|
|
395
|
+
/** Source chain where user has funds */
|
|
396
|
+
sourceChain: string;
|
|
397
|
+
/** Destination chain where payment is needed */
|
|
398
|
+
destinationChain: string;
|
|
399
|
+
/** Amount to transfer (in token units, 6 decimals for USDT0) */
|
|
400
|
+
amount: bigint;
|
|
401
|
+
/** Payment recipient on destination chain */
|
|
402
|
+
payTo: Address;
|
|
403
|
+
/** Payer address (receives bridged funds on destination) */
|
|
404
|
+
payer: Address;
|
|
405
|
+
/** Slippage tolerance percentage (default: 0.5) */
|
|
406
|
+
slippageTolerance?: number;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Result of cross-chain payment routing
|
|
410
|
+
*/
|
|
411
|
+
interface CrossChainPaymentResult {
|
|
412
|
+
/** Bridge transaction hash on source chain */
|
|
413
|
+
bridgeTxHash: `0x${string}`;
|
|
414
|
+
/** LayerZero message GUID for tracking */
|
|
415
|
+
messageGuid: `0x${string}`;
|
|
416
|
+
/** Amount bridged from source chain */
|
|
417
|
+
amountBridged: bigint;
|
|
418
|
+
/** Estimated amount to receive on destination */
|
|
419
|
+
estimatedReceiveAmount: bigint;
|
|
420
|
+
/** Source chain name */
|
|
421
|
+
sourceChain: string;
|
|
422
|
+
/** Destination chain name */
|
|
423
|
+
destinationChain: string;
|
|
424
|
+
/** Estimated delivery time in seconds */
|
|
425
|
+
estimatedDeliveryTime: number;
|
|
426
|
+
}
|
|
625
427
|
|
|
626
428
|
/**
|
|
627
429
|
* USDT0 Bridge Client
|
|
@@ -687,6 +489,19 @@ declare class Usdt0Bridge {
|
|
|
687
489
|
* @returns Bridge result with transaction hash
|
|
688
490
|
*/
|
|
689
491
|
send(params: BridgeExecuteParams): Promise<BridgeResult>;
|
|
492
|
+
/**
|
|
493
|
+
* Get all supported destination chains from current chain
|
|
494
|
+
*
|
|
495
|
+
* @returns Array of supported destination chain names
|
|
496
|
+
*/
|
|
497
|
+
getSupportedDestinations(): string[];
|
|
498
|
+
/**
|
|
499
|
+
* Check if a destination chain is supported
|
|
500
|
+
*
|
|
501
|
+
* @param toChain - The destination chain to check
|
|
502
|
+
* @returns True if the destination chain is supported
|
|
503
|
+
*/
|
|
504
|
+
supportsDestination(toChain: string): boolean;
|
|
690
505
|
/**
|
|
691
506
|
* Extract LayerZero message GUID from OFTSent event logs
|
|
692
507
|
*
|
|
@@ -696,29 +511,250 @@ declare class Usdt0Bridge {
|
|
|
696
511
|
private extractMessageGuid;
|
|
697
512
|
/**
|
|
698
513
|
* Ensure sufficient token allowance for the OFT contract
|
|
514
|
+
*
|
|
515
|
+
* @param oftAddress - The OFT contract address
|
|
516
|
+
* @param amount - The amount to approve
|
|
699
517
|
*/
|
|
700
518
|
private ensureAllowance;
|
|
701
519
|
/**
|
|
702
520
|
* Build SendParam struct for LayerZero
|
|
521
|
+
*
|
|
522
|
+
* @param params - Bridge parameters
|
|
523
|
+
* @returns SendParam struct for the OFT contract
|
|
703
524
|
*/
|
|
704
525
|
private buildSendParam;
|
|
705
526
|
/**
|
|
706
527
|
* Validate bridge parameters
|
|
528
|
+
*
|
|
529
|
+
* @param params - Bridge parameters to validate
|
|
707
530
|
*/
|
|
708
531
|
private validateBridgeParams;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Create a bridge client for a specific chain
|
|
535
|
+
*
|
|
536
|
+
* @param signer - Wallet signer with read/write capabilities
|
|
537
|
+
* @param chain - Source chain name
|
|
538
|
+
* @returns New Usdt0Bridge instance
|
|
539
|
+
*/
|
|
540
|
+
declare function createUsdt0Bridge(signer: BridgeSigner, chain: string): Usdt0Bridge;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* LayerZero Scan API Client
|
|
544
|
+
*
|
|
545
|
+
* Provides tracking for cross-chain messages via LayerZero Scan.
|
|
546
|
+
*
|
|
547
|
+
* @see https://docs.layerzero.network/v2/tools/api/scan/mainnet
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* ```typescript
|
|
551
|
+
* import { LayerZeroScanClient } from '@t402/evm';
|
|
552
|
+
*
|
|
553
|
+
* const scanClient = new LayerZeroScanClient();
|
|
554
|
+
*
|
|
555
|
+
* // Get message status
|
|
556
|
+
* const message = await scanClient.getMessage(messageGuid);
|
|
557
|
+
* console.log(`Status: ${message.status}`);
|
|
558
|
+
*
|
|
559
|
+
* // Wait for delivery
|
|
560
|
+
* const delivered = await scanClient.waitForDelivery(messageGuid, {
|
|
561
|
+
* onStatusChange: (status) => console.log(`Status changed: ${status}`),
|
|
562
|
+
* });
|
|
563
|
+
* console.log(`Delivered! Destination TX: ${delivered.dstTxHash}`);
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* LayerZero Scan API base URL
|
|
569
|
+
*/
|
|
570
|
+
declare const LAYERZERO_SCAN_BASE_URL = "https://scan.layerzero-api.com/v1";
|
|
571
|
+
/**
|
|
572
|
+
* LayerZero Scan API Client
|
|
573
|
+
*
|
|
574
|
+
* Use this client to track the status of cross-chain messages sent via LayerZero.
|
|
575
|
+
*/
|
|
576
|
+
declare class LayerZeroScanClient {
|
|
577
|
+
private readonly baseUrl;
|
|
709
578
|
/**
|
|
710
|
-
*
|
|
579
|
+
* Create a new LayerZero Scan client
|
|
580
|
+
*
|
|
581
|
+
* @param baseUrl - API base URL (default: production endpoint)
|
|
582
|
+
*/
|
|
583
|
+
constructor(baseUrl?: string);
|
|
584
|
+
/**
|
|
585
|
+
* Get message by GUID
|
|
586
|
+
*
|
|
587
|
+
* @param guid - LayerZero message GUID
|
|
588
|
+
* @returns Message details including status
|
|
589
|
+
* @throws Error if message not found or API error
|
|
590
|
+
*/
|
|
591
|
+
getMessage(guid: string): Promise<LayerZeroMessage>;
|
|
592
|
+
/**
|
|
593
|
+
* Get messages by wallet address
|
|
594
|
+
*
|
|
595
|
+
* @param address - Wallet address that initiated messages
|
|
596
|
+
* @param limit - Maximum number of messages to return (default: 20)
|
|
597
|
+
* @returns Array of messages
|
|
598
|
+
*/
|
|
599
|
+
getMessagesByWallet(address: string, limit?: number): Promise<LayerZeroMessage[]>;
|
|
600
|
+
/**
|
|
601
|
+
* Poll message status until delivered or failed
|
|
602
|
+
*
|
|
603
|
+
* @param guid - LayerZero message GUID
|
|
604
|
+
* @param options - Wait configuration options
|
|
605
|
+
* @returns Final message state (DELIVERED)
|
|
606
|
+
* @throws Error if message fails, is blocked, or times out
|
|
607
|
+
*/
|
|
608
|
+
waitForDelivery(guid: string, options?: WaitForDeliveryOptions): Promise<LayerZeroMessage>;
|
|
609
|
+
/**
|
|
610
|
+
* Check if a message has been delivered
|
|
611
|
+
*
|
|
612
|
+
* @param guid - LayerZero message GUID
|
|
613
|
+
* @returns True if delivered, false otherwise
|
|
614
|
+
*/
|
|
615
|
+
isDelivered(guid: string): Promise<boolean>;
|
|
616
|
+
/**
|
|
617
|
+
* Map API response to our interface
|
|
618
|
+
*
|
|
619
|
+
* @param data - The raw API response data
|
|
620
|
+
* @returns The mapped LayerZeroMessage object
|
|
621
|
+
*/
|
|
622
|
+
private mapApiResponse;
|
|
623
|
+
/**
|
|
624
|
+
* Sleep helper
|
|
625
|
+
*
|
|
626
|
+
* @param ms - The number of milliseconds to sleep
|
|
627
|
+
* @returns A promise that resolves after the specified delay
|
|
628
|
+
*/
|
|
629
|
+
private sleep;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Create a LayerZero Scan client
|
|
633
|
+
*
|
|
634
|
+
* @param baseUrl - Optional custom API base URL
|
|
635
|
+
* @returns A new LayerZeroScanClient instance
|
|
636
|
+
*/
|
|
637
|
+
declare function createLayerZeroScanClient(baseUrl?: string): LayerZeroScanClient;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Cross-Chain Payment Router
|
|
641
|
+
*
|
|
642
|
+
* Enables payments on a destination chain using funds from a source chain.
|
|
643
|
+
* Uses USDT0 bridge via LayerZero for cross-chain transfers.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```typescript
|
|
647
|
+
* import { CrossChainPaymentRouter } from '@t402/evm';
|
|
648
|
+
*
|
|
649
|
+
* const router = new CrossChainPaymentRouter(signer, 'arbitrum');
|
|
650
|
+
*
|
|
651
|
+
* // Route payment from Arbitrum to Ethereum
|
|
652
|
+
* const result = await router.routePayment({
|
|
653
|
+
* sourceChain: 'arbitrum',
|
|
654
|
+
* destinationChain: 'ethereum',
|
|
655
|
+
* amount: 100_000000n, // 100 USDT0
|
|
656
|
+
* payTo: recipientAddress,
|
|
657
|
+
* payer: userAddress,
|
|
658
|
+
* });
|
|
659
|
+
*
|
|
660
|
+
* // Track delivery
|
|
661
|
+
* const message = await router.trackMessage(result.messageGuid);
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Cross-Chain Payment Router
|
|
667
|
+
*
|
|
668
|
+
* Routes payments across chains using USDT0 bridge.
|
|
669
|
+
* Handles fee estimation, bridge execution, and delivery tracking.
|
|
670
|
+
*/
|
|
671
|
+
declare class CrossChainPaymentRouter {
|
|
672
|
+
private readonly bridge;
|
|
673
|
+
private readonly scanClient;
|
|
674
|
+
private readonly sourceChain;
|
|
675
|
+
/**
|
|
676
|
+
* Create a cross-chain payment router
|
|
677
|
+
*
|
|
678
|
+
* @param signer - Wallet signer for bridge operations
|
|
679
|
+
* @param sourceChain - Chain where user's funds are located
|
|
680
|
+
*/
|
|
681
|
+
constructor(signer: BridgeSigner, sourceChain: string);
|
|
682
|
+
/**
|
|
683
|
+
* Get all bridgeable chains
|
|
684
|
+
*
|
|
685
|
+
* @returns Array of all chain names that support USDT0 bridging
|
|
686
|
+
*/
|
|
687
|
+
static getBridgeableChains(): string[];
|
|
688
|
+
/**
|
|
689
|
+
* Route payment across chains
|
|
690
|
+
*
|
|
691
|
+
* This method:
|
|
692
|
+
* 1. Bridges USDT0 from source chain to destination chain
|
|
693
|
+
* 2. Sends funds to the payer's address on destination chain
|
|
694
|
+
* 3. Returns tracking info for monitoring delivery
|
|
695
|
+
*
|
|
696
|
+
* After delivery, the payer can use the bridged funds to pay on the destination chain.
|
|
697
|
+
*
|
|
698
|
+
* @param params - Payment routing parameters
|
|
699
|
+
* @returns Result with transaction hash and tracking info
|
|
700
|
+
*/
|
|
701
|
+
routePayment(params: CrossChainPaymentParams): Promise<CrossChainPaymentResult>;
|
|
702
|
+
/**
|
|
703
|
+
* Get estimated fees for routing a payment
|
|
704
|
+
*
|
|
705
|
+
* @param params - Payment parameters
|
|
706
|
+
* @returns Quote with native fee and estimated receive amount
|
|
707
|
+
*/
|
|
708
|
+
estimateFees(params: CrossChainPaymentParams): Promise<{
|
|
709
|
+
nativeFee: bigint;
|
|
710
|
+
estimatedReceiveAmount: bigint;
|
|
711
|
+
estimatedTime: number;
|
|
712
|
+
}>;
|
|
713
|
+
/**
|
|
714
|
+
* Track message delivery status
|
|
715
|
+
*
|
|
716
|
+
* @param messageGuid - LayerZero message GUID from routePayment result
|
|
717
|
+
* @returns Current message status
|
|
718
|
+
*/
|
|
719
|
+
trackMessage(messageGuid: string): Promise<LayerZeroMessage>;
|
|
720
|
+
/**
|
|
721
|
+
* Wait for payment to be delivered on destination chain
|
|
722
|
+
*
|
|
723
|
+
* @param messageGuid - LayerZero message GUID from routePayment result
|
|
724
|
+
* @param options - Wait options (timeout, poll interval, callbacks)
|
|
725
|
+
* @returns Final message state when delivered
|
|
726
|
+
*/
|
|
727
|
+
waitForDelivery(messageGuid: string, options?: WaitForDeliveryOptions): Promise<LayerZeroMessage>;
|
|
728
|
+
/**
|
|
729
|
+
* Check if routing between two chains is supported
|
|
730
|
+
*
|
|
731
|
+
* @param sourceChain - Source chain name
|
|
732
|
+
* @param destinationChain - Destination chain name
|
|
733
|
+
* @returns True if routing is supported
|
|
734
|
+
*/
|
|
735
|
+
canRoute(sourceChain: string, destinationChain: string): boolean;
|
|
736
|
+
/**
|
|
737
|
+
* Get all supported destination chains from source chain
|
|
738
|
+
*
|
|
739
|
+
* @returns Array of chain names that can receive bridged funds
|
|
711
740
|
*/
|
|
712
741
|
getSupportedDestinations(): string[];
|
|
713
742
|
/**
|
|
714
|
-
*
|
|
743
|
+
* Validate routing parameters
|
|
744
|
+
*
|
|
745
|
+
* @param params - The cross-chain payment parameters to validate
|
|
746
|
+
* @throws Error if parameters are invalid or routing is not supported
|
|
715
747
|
*/
|
|
716
|
-
|
|
748
|
+
private validateParams;
|
|
717
749
|
}
|
|
718
750
|
/**
|
|
719
|
-
* Create a
|
|
751
|
+
* Create a cross-chain payment router
|
|
752
|
+
*
|
|
753
|
+
* @param signer - Wallet signer for bridge operations
|
|
754
|
+
* @param sourceChain - Chain where funds are located
|
|
755
|
+
* @returns A new CrossChainPaymentRouter instance
|
|
720
756
|
*/
|
|
721
|
-
declare function
|
|
757
|
+
declare function createCrossChainPaymentRouter(signer: BridgeSigner, sourceChain: string): CrossChainPaymentRouter;
|
|
722
758
|
|
|
723
759
|
/**
|
|
724
760
|
* LayerZero OFT Bridge Constants for USDT0
|
|
@@ -748,27 +784,44 @@ declare const USDT0_OFT_ADDRESSES: Record<string, Address>;
|
|
|
748
784
|
declare const LAYERZERO_ENDPOINT_V2: Address;
|
|
749
785
|
/**
|
|
750
786
|
* Get LayerZero endpoint ID for a chain
|
|
787
|
+
*
|
|
788
|
+
* @param chain - The chain name (e.g., 'ethereum', 'arbitrum')
|
|
789
|
+
* @returns The LayerZero endpoint ID, or undefined if chain not supported
|
|
751
790
|
*/
|
|
752
791
|
declare function getEndpointId(chain: string): number | undefined;
|
|
753
792
|
/**
|
|
754
793
|
* Get USDT0 OFT contract address for a chain
|
|
794
|
+
*
|
|
795
|
+
* @param chain - The chain name (e.g., 'ethereum', 'arbitrum')
|
|
796
|
+
* @returns The USDT0 OFT contract address, or undefined if chain not supported
|
|
755
797
|
*/
|
|
756
798
|
declare function getUsdt0OftAddress(chain: string): Address | undefined;
|
|
757
799
|
/**
|
|
758
800
|
* Check if a chain supports USDT0 bridging
|
|
801
|
+
*
|
|
802
|
+
* @param chain - The chain name to check (e.g., 'ethereum', 'arbitrum')
|
|
803
|
+
* @returns True if the chain supports USDT0 bridging, false otherwise
|
|
759
804
|
*/
|
|
760
805
|
declare function supportsBridging(chain: string): boolean;
|
|
761
806
|
/**
|
|
762
807
|
* Get all chains that support USDT0 bridging
|
|
808
|
+
*
|
|
809
|
+
* @returns Array of chain names that support USDT0 bridging
|
|
763
810
|
*/
|
|
764
811
|
declare function getBridgeableChains(): string[];
|
|
765
812
|
/**
|
|
766
813
|
* Convert address to bytes32 format for LayerZero
|
|
767
814
|
* Pads address with leading zeros to 32 bytes
|
|
815
|
+
*
|
|
816
|
+
* @param address - The EVM address to convert
|
|
817
|
+
* @returns The address as a bytes32 hex string with leading zeros
|
|
768
818
|
*/
|
|
769
819
|
declare function addressToBytes32(address: Address): `0x${string}`;
|
|
770
820
|
/**
|
|
771
821
|
* Convert bytes32 to address
|
|
822
|
+
*
|
|
823
|
+
* @param bytes32 - The bytes32 hex string to convert
|
|
824
|
+
* @returns The extracted EVM address from the last 20 bytes
|
|
772
825
|
*/
|
|
773
826
|
declare function bytes32ToAddress(bytes32: `0x${string}`): Address;
|
|
774
827
|
|
|
@@ -1210,10 +1263,17 @@ declare enum PaymasterType {
|
|
|
1210
1263
|
}
|
|
1211
1264
|
/**
|
|
1212
1265
|
* Pack verification and call gas limits into bytes32
|
|
1266
|
+
*
|
|
1267
|
+
* @param verificationGasLimit - The verification gas limit
|
|
1268
|
+
* @param callGasLimit - The call gas limit
|
|
1269
|
+
* @returns Packed bytes32 with gas limits
|
|
1213
1270
|
*/
|
|
1214
1271
|
declare function packAccountGasLimits(verificationGasLimit: bigint, callGasLimit: bigint): `0x${string}`;
|
|
1215
1272
|
/**
|
|
1216
1273
|
* Unpack account gas limits from bytes32
|
|
1274
|
+
*
|
|
1275
|
+
* @param packed - The packed bytes32 containing gas limits
|
|
1276
|
+
* @returns Object containing verificationGasLimit and callGasLimit
|
|
1217
1277
|
*/
|
|
1218
1278
|
declare function unpackAccountGasLimits(packed: `0x${string}`): {
|
|
1219
1279
|
verificationGasLimit: bigint;
|
|
@@ -1221,10 +1281,17 @@ declare function unpackAccountGasLimits(packed: `0x${string}`): {
|
|
|
1221
1281
|
};
|
|
1222
1282
|
/**
|
|
1223
1283
|
* Pack max priority fee and max fee per gas into bytes32
|
|
1284
|
+
*
|
|
1285
|
+
* @param maxPriorityFeePerGas - The max priority fee per gas (tip)
|
|
1286
|
+
* @param maxFeePerGas - The max fee per gas
|
|
1287
|
+
* @returns Packed bytes32 with gas fees
|
|
1224
1288
|
*/
|
|
1225
1289
|
declare function packGasFees(maxPriorityFeePerGas: bigint, maxFeePerGas: bigint): `0x${string}`;
|
|
1226
1290
|
/**
|
|
1227
1291
|
* Unpack gas fees from bytes32
|
|
1292
|
+
*
|
|
1293
|
+
* @param packed - The packed bytes32 containing gas fees
|
|
1294
|
+
* @returns Object containing maxPriorityFeePerGas and maxFeePerGas
|
|
1228
1295
|
*/
|
|
1229
1296
|
declare function unpackGasFees(packed: `0x${string}`): {
|
|
1230
1297
|
maxPriorityFeePerGas: bigint;
|
|
@@ -1253,46 +1320,95 @@ interface UserOpBuilderOptions {
|
|
|
1253
1320
|
declare class UserOpBuilder {
|
|
1254
1321
|
private readonly entryPoint;
|
|
1255
1322
|
private readonly gasMultiplier;
|
|
1323
|
+
/**
|
|
1324
|
+
* Create a new UserOpBuilder instance
|
|
1325
|
+
*
|
|
1326
|
+
* @param options - Optional configuration for the builder
|
|
1327
|
+
*/
|
|
1256
1328
|
constructor(options?: UserOpBuilderOptions);
|
|
1257
1329
|
/**
|
|
1258
1330
|
* Build a UserOperation from a transaction intent
|
|
1331
|
+
*
|
|
1332
|
+
* @param signer - The smart account signer
|
|
1333
|
+
* @param intent - The transaction intent to execute
|
|
1334
|
+
* @param client - The public client for chain interaction
|
|
1335
|
+
* @param gasEstimate - Optional gas estimates (uses defaults if not provided)
|
|
1336
|
+
* @param paymaster - Optional paymaster data for sponsored transactions
|
|
1337
|
+
* @returns A UserOperation ready for signing
|
|
1259
1338
|
*/
|
|
1260
1339
|
buildUserOp(signer: SmartAccountSigner, intent: TransactionIntent, client: PublicClient, gasEstimate?: GasEstimate, paymaster?: PaymasterData): Promise<UserOperation>;
|
|
1261
1340
|
/**
|
|
1262
1341
|
* Build a batch UserOperation from multiple transaction intents
|
|
1342
|
+
*
|
|
1343
|
+
* @param signer - The smart account signer
|
|
1344
|
+
* @param intents - Array of transaction intents to execute
|
|
1345
|
+
* @param client - The public client for chain interaction
|
|
1346
|
+
* @param gasEstimate - Optional gas estimates (uses defaults if not provided)
|
|
1347
|
+
* @param paymaster - Optional paymaster data for sponsored transactions
|
|
1348
|
+
* @returns A UserOperation ready for signing
|
|
1263
1349
|
*/
|
|
1264
1350
|
buildBatchUserOp(signer: SmartAccountSigner, intents: TransactionIntent[], client: PublicClient, gasEstimate?: GasEstimate, paymaster?: PaymasterData): Promise<UserOperation>;
|
|
1265
1351
|
/**
|
|
1266
1352
|
* Pack a UserOperation for on-chain submission (v0.7 format)
|
|
1353
|
+
*
|
|
1354
|
+
* @param userOp - The UserOperation to pack
|
|
1355
|
+
* @returns The packed UserOperation for on-chain submission
|
|
1267
1356
|
*/
|
|
1268
1357
|
packUserOp(userOp: UserOperation): PackedUserOperation;
|
|
1269
1358
|
/**
|
|
1270
1359
|
* Compute the UserOperation hash for signing
|
|
1360
|
+
*
|
|
1361
|
+
* @param userOp - The UserOperation to hash
|
|
1362
|
+
* @param client - The public client for chain interaction
|
|
1363
|
+
* @param _ - The chain ID (reserved for future use)
|
|
1364
|
+
* @returns The UserOperation hash
|
|
1271
1365
|
*/
|
|
1272
|
-
getUserOpHash(userOp: UserOperation, client: PublicClient,
|
|
1366
|
+
getUserOpHash(userOp: UserOperation, client: PublicClient, _: number): Promise<Hex>;
|
|
1273
1367
|
/**
|
|
1274
1368
|
* Sign a UserOperation
|
|
1369
|
+
*
|
|
1370
|
+
* @param userOp - The UserOperation to sign
|
|
1371
|
+
* @param signer - The smart account signer
|
|
1372
|
+
* @param client - The public client for chain interaction
|
|
1373
|
+
* @param chainId - The chain ID for the signature
|
|
1374
|
+
* @returns The UserOperation with signature attached
|
|
1275
1375
|
*/
|
|
1276
1376
|
signUserOp(userOp: UserOperation, signer: SmartAccountSigner, client: PublicClient, chainId: number): Promise<UserOperation>;
|
|
1277
1377
|
/**
|
|
1278
1378
|
* Get the nonce for an account from EntryPoint
|
|
1379
|
+
*
|
|
1380
|
+
* @param client - The public client for chain interaction
|
|
1381
|
+
* @param sender - The smart account address
|
|
1382
|
+
* @returns The current nonce for the account
|
|
1279
1383
|
*/
|
|
1280
1384
|
private getNonce;
|
|
1281
1385
|
/**
|
|
1282
1386
|
* Get current gas prices from the chain
|
|
1387
|
+
*
|
|
1388
|
+
* @param client - The public client for chain interaction
|
|
1389
|
+
* @returns The current gas prices for EIP-1559 transactions
|
|
1283
1390
|
*/
|
|
1284
1391
|
private getGasPrices;
|
|
1285
1392
|
/**
|
|
1286
1393
|
* Apply gas multiplier for safety margin
|
|
1394
|
+
*
|
|
1395
|
+
* @param gas - The gas amount to multiply
|
|
1396
|
+
* @returns The gas amount with safety margin applied
|
|
1287
1397
|
*/
|
|
1288
1398
|
private applyMultiplier;
|
|
1289
1399
|
/**
|
|
1290
1400
|
* Encode paymaster data for the UserOperation
|
|
1401
|
+
*
|
|
1402
|
+
* @param paymaster - The paymaster configuration
|
|
1403
|
+
* @returns The encoded paymaster data
|
|
1291
1404
|
*/
|
|
1292
1405
|
private encodePaymasterData;
|
|
1293
1406
|
}
|
|
1294
1407
|
/**
|
|
1295
1408
|
* Create a UserOpBuilder instance
|
|
1409
|
+
*
|
|
1410
|
+
* @param options - Optional configuration for the builder
|
|
1411
|
+
* @returns A new UserOpBuilder instance
|
|
1296
1412
|
*/
|
|
1297
1413
|
declare function createUserOpBuilder(options?: UserOpBuilderOptions): UserOpBuilder;
|
|
1298
1414
|
|
|
@@ -1309,6 +1425,13 @@ declare function createUserOpBuilder(options?: UserOpBuilderOptions): UserOpBuil
|
|
|
1309
1425
|
declare class BundlerError extends Error {
|
|
1310
1426
|
code?: number | undefined;
|
|
1311
1427
|
data?: unknown | undefined;
|
|
1428
|
+
/**
|
|
1429
|
+
* Create a new BundlerError
|
|
1430
|
+
*
|
|
1431
|
+
* @param message - The error message
|
|
1432
|
+
* @param code - Optional JSON-RPC error code
|
|
1433
|
+
* @param data - Optional additional error data
|
|
1434
|
+
*/
|
|
1312
1435
|
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
|
1313
1436
|
}
|
|
1314
1437
|
/**
|
|
@@ -1317,15 +1440,25 @@ declare class BundlerError extends Error {
|
|
|
1317
1440
|
declare class BundlerClient {
|
|
1318
1441
|
private readonly bundlerUrl;
|
|
1319
1442
|
private readonly entryPoint;
|
|
1320
|
-
private readonly chainId;
|
|
1321
1443
|
private requestId;
|
|
1444
|
+
/**
|
|
1445
|
+
* Create a new BundlerClient instance
|
|
1446
|
+
*
|
|
1447
|
+
* @param config - Configuration for the bundler client
|
|
1448
|
+
*/
|
|
1322
1449
|
constructor(config: BundlerConfig);
|
|
1323
1450
|
/**
|
|
1324
1451
|
* Send a UserOperation to the bundler
|
|
1452
|
+
*
|
|
1453
|
+
* @param userOp - The UserOperation to send
|
|
1454
|
+
* @returns The result containing the userOpHash and a wait function
|
|
1325
1455
|
*/
|
|
1326
1456
|
sendUserOperation(userOp: UserOperation): Promise<UserOperationResult>;
|
|
1327
1457
|
/**
|
|
1328
1458
|
* Estimate gas for a UserOperation
|
|
1459
|
+
*
|
|
1460
|
+
* @param userOp - Partial UserOperation with required sender and callData
|
|
1461
|
+
* @returns Gas estimates for the UserOperation
|
|
1329
1462
|
*/
|
|
1330
1463
|
estimateUserOperationGas(userOp: Partial<UserOperation> & {
|
|
1331
1464
|
sender: Address;
|
|
@@ -1333,6 +1466,9 @@ declare class BundlerClient {
|
|
|
1333
1466
|
}): Promise<GasEstimate>;
|
|
1334
1467
|
/**
|
|
1335
1468
|
* Get UserOperation by hash
|
|
1469
|
+
*
|
|
1470
|
+
* @param userOpHash - The hash of the UserOperation to retrieve
|
|
1471
|
+
* @returns The UserOperation and EntryPoint, or null if not found
|
|
1336
1472
|
*/
|
|
1337
1473
|
getUserOperationByHash(userOpHash: Hex): Promise<{
|
|
1338
1474
|
userOperation: PackedUserOperation;
|
|
@@ -1340,18 +1476,31 @@ declare class BundlerClient {
|
|
|
1340
1476
|
} | null>;
|
|
1341
1477
|
/**
|
|
1342
1478
|
* Get UserOperation receipt
|
|
1479
|
+
*
|
|
1480
|
+
* @param userOpHash - The hash of the UserOperation
|
|
1481
|
+
* @returns The receipt, or null if not yet included
|
|
1343
1482
|
*/
|
|
1344
1483
|
getUserOperationReceipt(userOpHash: Hex): Promise<UserOperationReceipt | null>;
|
|
1345
1484
|
/**
|
|
1346
1485
|
* Get supported EntryPoints
|
|
1486
|
+
*
|
|
1487
|
+
* @returns Array of supported EntryPoint addresses
|
|
1347
1488
|
*/
|
|
1348
1489
|
getSupportedEntryPoints(): Promise<Address[]>;
|
|
1349
1490
|
/**
|
|
1350
1491
|
* Get chain ID from bundler
|
|
1492
|
+
*
|
|
1493
|
+
* @returns The chain ID
|
|
1351
1494
|
*/
|
|
1352
1495
|
getChainId(): Promise<number>;
|
|
1353
1496
|
/**
|
|
1354
1497
|
* Wait for UserOperation receipt with polling
|
|
1498
|
+
*
|
|
1499
|
+
* @param userOpHash - The hash of the UserOperation to wait for
|
|
1500
|
+
* @param options - Polling options
|
|
1501
|
+
* @param options.timeout - Maximum time to wait in milliseconds (default: 60000)
|
|
1502
|
+
* @param options.pollingInterval - Interval between polls in milliseconds (default: 2000)
|
|
1503
|
+
* @returns The UserOperation receipt
|
|
1355
1504
|
*/
|
|
1356
1505
|
waitForReceipt(userOpHash: Hex, options?: {
|
|
1357
1506
|
timeout?: number;
|
|
@@ -1359,19 +1508,32 @@ declare class BundlerClient {
|
|
|
1359
1508
|
}): Promise<UserOperationReceipt>;
|
|
1360
1509
|
/**
|
|
1361
1510
|
* Pack UserOperation for RPC (convert bigints to hex strings)
|
|
1511
|
+
*
|
|
1512
|
+
* @param userOp - The UserOperation to pack
|
|
1513
|
+
* @returns The packed UserOperation for RPC transmission
|
|
1362
1514
|
*/
|
|
1363
1515
|
private packForRpc;
|
|
1364
1516
|
/**
|
|
1365
1517
|
* Convert bigint to hex string
|
|
1518
|
+
*
|
|
1519
|
+
* @param value - The bigint value to convert
|
|
1520
|
+
* @returns The hex string representation
|
|
1366
1521
|
*/
|
|
1367
1522
|
private toHex;
|
|
1368
1523
|
/**
|
|
1369
1524
|
* Make a JSON-RPC call to the bundler
|
|
1525
|
+
*
|
|
1526
|
+
* @param method - The JSON-RPC method name
|
|
1527
|
+
* @param params - The method parameters
|
|
1528
|
+
* @returns The result from the bundler
|
|
1370
1529
|
*/
|
|
1371
1530
|
private rpcCall;
|
|
1372
1531
|
}
|
|
1373
1532
|
/**
|
|
1374
1533
|
* Create a BundlerClient instance
|
|
1534
|
+
*
|
|
1535
|
+
* @param config - Configuration for the bundler client
|
|
1536
|
+
* @returns A new BundlerClient instance
|
|
1375
1537
|
*/
|
|
1376
1538
|
declare function createBundlerClient(config: BundlerConfig): BundlerClient;
|
|
1377
1539
|
|
|
@@ -1413,50 +1575,106 @@ interface SponsorRequest {
|
|
|
1413
1575
|
*/
|
|
1414
1576
|
declare class PaymasterClient {
|
|
1415
1577
|
private readonly config;
|
|
1578
|
+
/**
|
|
1579
|
+
* Creates a new PaymasterClient instance
|
|
1580
|
+
*
|
|
1581
|
+
* @param config - Paymaster configuration including type, address, and optional URL
|
|
1582
|
+
*/
|
|
1416
1583
|
constructor(config: PaymasterConfig);
|
|
1417
1584
|
/**
|
|
1418
1585
|
* Get paymaster data for a UserOperation
|
|
1586
|
+
*
|
|
1587
|
+
* @param userOp - Partial UserOperation to get paymaster data for
|
|
1588
|
+
* @param chainId - The chain ID for the operation
|
|
1589
|
+
* @param entryPoint - The EntryPoint contract address
|
|
1590
|
+
* @param context - Optional context data for the paymaster
|
|
1591
|
+
* @returns Paymaster data including address and gas limits
|
|
1419
1592
|
*/
|
|
1420
1593
|
getPaymasterData(userOp: Partial<UserOperation>, chainId: number, entryPoint: Address, context?: Record<string, unknown>): Promise<PaymasterData>;
|
|
1421
1594
|
/**
|
|
1422
1595
|
* Get gas estimates including paymaster gas
|
|
1596
|
+
*
|
|
1597
|
+
* @param _userOp - Partial UserOperation to estimate gas for (reserved for future use)
|
|
1598
|
+
* @param _chainId - The chain ID for the operation (reserved for future use)
|
|
1599
|
+
* @returns Gas estimates including paymaster verification and postOp gas
|
|
1423
1600
|
*/
|
|
1424
|
-
estimatePaymasterGas(
|
|
1601
|
+
estimatePaymasterGas(_userOp: Partial<UserOperation>, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1602
|
+
_chainId: number): Promise<GasEstimate>;
|
|
1425
1603
|
/**
|
|
1426
1604
|
* Check if the paymaster will sponsor this operation
|
|
1605
|
+
*
|
|
1606
|
+
* @param userOp - Partial UserOperation to check sponsorship for
|
|
1607
|
+
* @param chainId - The chain ID for the operation
|
|
1608
|
+
* @param entryPoint - The EntryPoint contract address
|
|
1609
|
+
* @param context - Optional context data for policy validation
|
|
1610
|
+
* @returns True if the paymaster will sponsor the operation
|
|
1427
1611
|
*/
|
|
1428
1612
|
willSponsor(userOp: Partial<UserOperation>, chainId: number, entryPoint: Address, context?: Record<string, unknown>): Promise<boolean>;
|
|
1429
1613
|
/**
|
|
1430
1614
|
* Get verifying paymaster data (off-chain signature)
|
|
1615
|
+
*
|
|
1616
|
+
* @param userOp - Partial UserOperation to get paymaster data for
|
|
1617
|
+
* @param chainId - The chain ID for the operation
|
|
1618
|
+
* @param entryPoint - The EntryPoint contract address
|
|
1619
|
+
* @returns Paymaster data with verification signature
|
|
1431
1620
|
*/
|
|
1432
1621
|
private getVerifyingPaymasterData;
|
|
1433
1622
|
/**
|
|
1434
1623
|
* Get sponsoring paymaster data (third-party pays)
|
|
1624
|
+
*
|
|
1625
|
+
* @param userOp - Partial UserOperation to get sponsorship for
|
|
1626
|
+
* @param chainId - The chain ID for the operation
|
|
1627
|
+
* @param entryPoint - The EntryPoint contract address
|
|
1628
|
+
* @param context - Optional context data for sponsorship validation
|
|
1629
|
+
* @returns Paymaster data for sponsored operation
|
|
1435
1630
|
*/
|
|
1436
1631
|
private getSponsoringPaymasterData;
|
|
1437
1632
|
/**
|
|
1438
1633
|
* Get token paymaster data (pay gas with ERC20)
|
|
1634
|
+
*
|
|
1635
|
+
* @param userOp - Partial UserOperation to get token paymaster data for
|
|
1636
|
+
* @param chainId - The chain ID for the operation
|
|
1637
|
+
* @param entryPoint - The EntryPoint contract address
|
|
1638
|
+
* @returns Paymaster data for ERC20 token payment
|
|
1439
1639
|
*/
|
|
1440
1640
|
private getTokenPaymasterData;
|
|
1441
1641
|
/**
|
|
1442
1642
|
* Call paymaster service API
|
|
1643
|
+
*
|
|
1644
|
+
* @param userOp - Partial UserOperation to send to the service
|
|
1645
|
+
* @param chainId - The chain ID for the operation
|
|
1646
|
+
* @param entryPoint - The EntryPoint contract address
|
|
1647
|
+
* @param context - Optional context data for the service
|
|
1648
|
+
* @returns Paymaster data from the service response
|
|
1443
1649
|
*/
|
|
1444
1650
|
private callPaymasterService;
|
|
1445
1651
|
/**
|
|
1446
1652
|
* Serialize UserOperation for API calls
|
|
1653
|
+
*
|
|
1654
|
+
* @param userOp - Partial UserOperation to serialize
|
|
1655
|
+
* @returns Serialized UserOperation with hex-encoded values
|
|
1447
1656
|
*/
|
|
1448
1657
|
private serializeUserOp;
|
|
1449
1658
|
}
|
|
1450
1659
|
/**
|
|
1451
1660
|
* Create a PaymasterClient instance
|
|
1661
|
+
*
|
|
1662
|
+
* @param config - Paymaster configuration including type, address, and optional URL
|
|
1663
|
+
* @returns A new PaymasterClient instance
|
|
1452
1664
|
*/
|
|
1453
1665
|
declare function createPaymasterClient(config: PaymasterConfig): PaymasterClient;
|
|
1454
1666
|
/**
|
|
1455
1667
|
* Encode paymaster data for inclusion in UserOperation
|
|
1668
|
+
*
|
|
1669
|
+
* @param data - Paymaster data to encode
|
|
1670
|
+
* @returns Encoded paymasterAndData hex string
|
|
1456
1671
|
*/
|
|
1457
1672
|
declare function encodePaymasterAndData(data: PaymasterData): Hex;
|
|
1458
1673
|
/**
|
|
1459
1674
|
* Decode paymaster and data from UserOperation
|
|
1675
|
+
*
|
|
1676
|
+
* @param paymasterAndData - Encoded paymasterAndData hex string
|
|
1677
|
+
* @returns Decoded PaymasterData or null if invalid/empty
|
|
1460
1678
|
*/
|
|
1461
1679
|
declare function decodePaymasterAndData(paymasterAndData: Hex): PaymasterData | null;
|
|
1462
1680
|
|
|
@@ -1510,6 +1728,11 @@ declare class GaslessT402Client {
|
|
|
1510
1728
|
private readonly paymaster?;
|
|
1511
1729
|
private readonly chainId;
|
|
1512
1730
|
private readonly publicClient;
|
|
1731
|
+
/**
|
|
1732
|
+
* Creates a new GaslessT402Client instance
|
|
1733
|
+
*
|
|
1734
|
+
* @param config - Configuration including signer, bundler, paymaster, and chain settings
|
|
1735
|
+
*/
|
|
1513
1736
|
constructor(config: GaslessClientConfig);
|
|
1514
1737
|
/**
|
|
1515
1738
|
* Execute a T402 payment via ERC-4337
|
|
@@ -1517,48 +1740,79 @@ declare class GaslessT402Client {
|
|
|
1517
1740
|
* This submits the payment as a UserOperation which can be:
|
|
1518
1741
|
* - Sponsored by a paymaster (truly gasless)
|
|
1519
1742
|
* - Paid from the smart account's balance
|
|
1743
|
+
*
|
|
1744
|
+
* @param params - Payment parameters including token, recipient, and amount
|
|
1745
|
+
* @returns Result containing the user operation hash and wait function
|
|
1520
1746
|
*/
|
|
1521
1747
|
executePayment(params: GaslessPaymentParams): Promise<UserOperationResult>;
|
|
1522
1748
|
/**
|
|
1523
1749
|
* Execute multiple T402 payments in a single UserOperation
|
|
1750
|
+
*
|
|
1751
|
+
* @param payments - Array of payment parameters to batch together
|
|
1752
|
+
* @returns Result containing the user operation hash and wait function
|
|
1524
1753
|
*/
|
|
1525
1754
|
executeBatchPayments(payments: GaslessPaymentParams[]): Promise<UserOperationResult>;
|
|
1526
1755
|
/**
|
|
1527
1756
|
* Check if a payment can be sponsored (gasless)
|
|
1757
|
+
*
|
|
1758
|
+
* @param params - Payment parameters to check for sponsorship eligibility
|
|
1759
|
+
* @returns True if the payment can be sponsored by the paymaster
|
|
1528
1760
|
*/
|
|
1529
1761
|
canSponsor(params: GaslessPaymentParams): Promise<boolean>;
|
|
1530
1762
|
/**
|
|
1531
1763
|
* Get the smart account address
|
|
1764
|
+
*
|
|
1765
|
+
* @returns The address of the smart account
|
|
1532
1766
|
*/
|
|
1533
1767
|
getAccountAddress(): Promise<Address>;
|
|
1534
1768
|
/**
|
|
1535
1769
|
* Check if the smart account is deployed
|
|
1770
|
+
*
|
|
1771
|
+
* @returns True if the smart account contract is deployed on-chain
|
|
1536
1772
|
*/
|
|
1537
1773
|
isAccountDeployed(): Promise<boolean>;
|
|
1538
1774
|
/**
|
|
1539
1775
|
* Build call data for a simple ERC20 transfer
|
|
1776
|
+
*
|
|
1777
|
+
* @param params - Payment parameters including recipient and amount
|
|
1778
|
+
* @returns Encoded call data for ERC20 transfer function
|
|
1540
1779
|
*/
|
|
1541
1780
|
private buildTransferCallData;
|
|
1542
1781
|
/**
|
|
1543
1782
|
* Build call data for an authorized transfer (EIP-3009)
|
|
1783
|
+
*
|
|
1784
|
+
* @param params - Payment parameters including authorization signature
|
|
1785
|
+
* @returns Encoded call data for transferWithAuthorization function
|
|
1544
1786
|
*/
|
|
1545
1787
|
private buildAuthorizedTransferCallData;
|
|
1546
1788
|
/**
|
|
1547
1789
|
* Estimate gas for a single transaction
|
|
1790
|
+
*
|
|
1791
|
+
* @param intent - Transaction intent with target, value, and data
|
|
1792
|
+
* @returns Gas estimates for the UserOperation
|
|
1548
1793
|
*/
|
|
1549
1794
|
private estimateGas;
|
|
1550
1795
|
/**
|
|
1551
1796
|
* Estimate gas for a batch transaction
|
|
1797
|
+
*
|
|
1798
|
+
* @param intents - Array of transaction intents to batch
|
|
1799
|
+
* @returns Gas estimates for the batched UserOperation
|
|
1552
1800
|
*/
|
|
1553
1801
|
private estimateBatchGas;
|
|
1554
1802
|
/**
|
|
1555
1803
|
* Get paymaster data if configured
|
|
1804
|
+
*
|
|
1805
|
+
* @param _ - Gas estimates (unused but kept for potential future use)
|
|
1806
|
+
* @returns Paymaster data or undefined if no paymaster configured
|
|
1556
1807
|
*/
|
|
1557
1808
|
private getPaymasterData;
|
|
1558
1809
|
}
|
|
1559
1810
|
/**
|
|
1560
1811
|
* Create a GaslessT402Client instance
|
|
1812
|
+
*
|
|
1813
|
+
* @param config - Configuration including signer, bundler, paymaster, and chain settings
|
|
1814
|
+
* @returns A new GaslessT402Client instance
|
|
1561
1815
|
*/
|
|
1562
1816
|
declare function createGaslessT402Client(config: GaslessClientConfig): GaslessT402Client;
|
|
1563
1817
|
|
|
1564
|
-
export { ACCOUNT_ABI, BUNDLER_METHODS, type BridgeExecuteParams, type BridgeQuote, type BridgeQuoteParams, type BridgeResult, type BridgeSigner, type BridgeStatus, type BridgeTransaction, BundlerClient, type BundlerConfig, BundlerError,
|
|
1818
|
+
export { ACCOUNT_ABI, BUNDLER_METHODS, type BridgeExecuteParams, type BridgeQuote, type BridgeQuoteParams, type BridgeResult, type BridgeSigner, type BridgeStatus, type BridgeTransaction, BundlerClient, type BundlerConfig, BundlerError, type CrossChainPaymentParams, type CrossChainPaymentResult, CrossChainPaymentRouter, DEFAULT_GAS_LIMITS, ENTRYPOINT_V06_ADDRESS, ENTRYPOINT_V07_ABI, ENTRYPOINT_V07_ADDRESS, ExactLegacyEvmScheme$2 as ExactLegacyEvmClientScheme, ExactLegacyEvmScheme as ExactLegacyEvmFacilitatorScheme, type ExactLegacyEvmSchemeConfig as ExactLegacyEvmFacilitatorSchemeConfig, ExactLegacyEvmScheme$1 as ExactLegacyEvmServerScheme, type ExactLegacyEvmSchemeConfig$1 as ExactLegacyEvmServerSchemeConfig, type GasEstimate, type GaslessClientConfig, type GaslessPaymentParams, GaslessT402Client, LAYERZERO_ENDPOINT_IDS, LAYERZERO_ENDPOINT_V2, LAYERZERO_SCAN_BASE_URL, type LayerZeroMessage, type LayerZeroMessageStatus, LayerZeroScanClient, type PackedUserOperation, PaymasterClient, type PaymasterConfig, type PaymasterData, type PaymasterResponse, PaymasterType, type SmartAccountSigner, type SponsorRequest, type TransactionIntent, type TransactionLog, type TransactionReceipt, USDT0_OFT_ADDRESSES, Usdt0Bridge, UserOpBuilder, type UserOpBuilderConfig, type UserOpBuilderOptions, type UserOperation, type UserOperationReceipt, type UserOperationResult, type WaitForDeliveryOptions, addressToBytes32, bytes32ToAddress, createBundlerClient, createCrossChainPaymentRouter, createGaslessT402Client, createLayerZeroScanClient, createPaymasterClient, createUsdt0Bridge, createUserOpBuilder, decodePaymasterAndData, encodePaymasterAndData, getBridgeableChains, getEndpointId, getUsdt0OftAddress, packAccountGasLimits, packGasFees, supportsBridging, unpackAccountGasLimits, unpackGasFees };
|