@t402/evm 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.
Files changed (63) hide show
  1. package/README.md +183 -0
  2. package/dist/cjs/exact/client/index.d.ts +53 -0
  3. package/dist/cjs/exact/client/index.js +270 -0
  4. package/dist/cjs/exact/client/index.js.map +1 -0
  5. package/dist/cjs/exact/facilitator/index.d.ts +118 -0
  6. package/dist/cjs/exact/facilitator/index.js +735 -0
  7. package/dist/cjs/exact/facilitator/index.js.map +1 -0
  8. package/dist/cjs/exact/server/index.d.ts +36 -0
  9. package/dist/cjs/exact/server/index.js +438 -0
  10. package/dist/cjs/exact/server/index.js.map +1 -0
  11. package/dist/cjs/exact/v1/client/index.d.ts +37 -0
  12. package/dist/cjs/exact/v1/client/index.js +147 -0
  13. package/dist/cjs/exact/v1/client/index.js.map +1 -0
  14. package/dist/cjs/exact/v1/facilitator/index.d.ts +62 -0
  15. package/dist/cjs/exact/v1/facilitator/index.js +401 -0
  16. package/dist/cjs/exact/v1/facilitator/index.js.map +1 -0
  17. package/dist/cjs/index.d.ts +1537 -0
  18. package/dist/cjs/index.js +2368 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/cjs/scheme-C6uD7PdY.d.ts +130 -0
  21. package/dist/cjs/scheme-OojTBKAz.d.ts +35 -0
  22. package/dist/cjs/scheme-yqGaK9rK.d.ts +130 -0
  23. package/dist/cjs/signer-BkcAzwYi.d.ts +79 -0
  24. package/dist/cjs/v1/index.d.ts +7 -0
  25. package/dist/cjs/v1/index.js +171 -0
  26. package/dist/cjs/v1/index.js.map +1 -0
  27. package/dist/esm/chunk-ACDQ5QNT.mjs +305 -0
  28. package/dist/esm/chunk-ACDQ5QNT.mjs.map +1 -0
  29. package/dist/esm/chunk-JBWWBRYY.mjs +92 -0
  30. package/dist/esm/chunk-JBWWBRYY.mjs.map +1 -0
  31. package/dist/esm/chunk-LGSG73NJ.mjs +88 -0
  32. package/dist/esm/chunk-LGSG73NJ.mjs.map +1 -0
  33. package/dist/esm/chunk-OEXW2OK2.mjs +251 -0
  34. package/dist/esm/chunk-OEXW2OK2.mjs.map +1 -0
  35. package/dist/esm/chunk-QLXM7BIB.mjs +23 -0
  36. package/dist/esm/chunk-QLXM7BIB.mjs.map +1 -0
  37. package/dist/esm/chunk-XYKAO6KJ.mjs +141 -0
  38. package/dist/esm/chunk-XYKAO6KJ.mjs.map +1 -0
  39. package/dist/esm/exact/client/index.d.mts +53 -0
  40. package/dist/esm/exact/client/index.mjs +36 -0
  41. package/dist/esm/exact/client/index.mjs.map +1 -0
  42. package/dist/esm/exact/facilitator/index.d.mts +118 -0
  43. package/dist/esm/exact/facilitator/index.mjs +324 -0
  44. package/dist/esm/exact/facilitator/index.mjs.map +1 -0
  45. package/dist/esm/exact/server/index.d.mts +36 -0
  46. package/dist/esm/exact/server/index.mjs +218 -0
  47. package/dist/esm/exact/server/index.mjs.map +1 -0
  48. package/dist/esm/exact/v1/client/index.d.mts +37 -0
  49. package/dist/esm/exact/v1/client/index.mjs +8 -0
  50. package/dist/esm/exact/v1/client/index.mjs.map +1 -0
  51. package/dist/esm/exact/v1/facilitator/index.d.mts +62 -0
  52. package/dist/esm/exact/v1/facilitator/index.mjs +8 -0
  53. package/dist/esm/exact/v1/facilitator/index.mjs.map +1 -0
  54. package/dist/esm/index.d.mts +1537 -0
  55. package/dist/esm/index.mjs +1875 -0
  56. package/dist/esm/index.mjs.map +1 -0
  57. package/dist/esm/scheme-D4mOqq9l.d.mts +35 -0
  58. package/dist/esm/scheme-yqGaK9rK.d.mts +130 -0
  59. package/dist/esm/signer-BkcAzwYi.d.mts +79 -0
  60. package/dist/esm/v1/index.d.mts +7 -0
  61. package/dist/esm/v1/index.mjs +13 -0
  62. package/dist/esm/v1/index.mjs.map +1 -0
  63. package/package.json +127 -0
@@ -0,0 +1,2368 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ACCOUNT_ABI: () => ACCOUNT_ABI,
24
+ BUNDLER_METHODS: () => BUNDLER_METHODS,
25
+ BundlerClient: () => BundlerClient,
26
+ BundlerError: () => BundlerError,
27
+ DEFAULT_GAS_LIMITS: () => DEFAULT_GAS_LIMITS,
28
+ ENTRYPOINT_V06_ADDRESS: () => ENTRYPOINT_V06_ADDRESS,
29
+ ENTRYPOINT_V07_ABI: () => ENTRYPOINT_V07_ABI,
30
+ ENTRYPOINT_V07_ADDRESS: () => ENTRYPOINT_V07_ADDRESS,
31
+ ExactEvmScheme: () => ExactEvmScheme,
32
+ ExactLegacyEvmClientScheme: () => ExactLegacyEvmScheme,
33
+ ExactLegacyEvmFacilitatorScheme: () => ExactLegacyEvmScheme3,
34
+ ExactLegacyEvmServerScheme: () => ExactLegacyEvmScheme2,
35
+ GaslessT402Client: () => GaslessT402Client,
36
+ LAYERZERO_ENDPOINT_IDS: () => LAYERZERO_ENDPOINT_IDS,
37
+ LAYERZERO_ENDPOINT_V2: () => LAYERZERO_ENDPOINT_V2,
38
+ PaymasterClient: () => PaymasterClient,
39
+ PaymasterType: () => PaymasterType,
40
+ TOKEN_PRIORITY: () => TOKEN_PRIORITY,
41
+ TOKEN_REGISTRY: () => TOKEN_REGISTRY,
42
+ USDC_ADDRESSES: () => USDC_ADDRESSES,
43
+ USDT0_ADDRESSES: () => USDT0_ADDRESSES,
44
+ USDT0_OFT_ADDRESSES: () => USDT0_OFT_ADDRESSES,
45
+ USDT_LEGACY_ADDRESSES: () => USDT_LEGACY_ADDRESSES,
46
+ Usdt0Bridge: () => Usdt0Bridge,
47
+ UserOpBuilder: () => UserOpBuilder,
48
+ addressToBytes32: () => addressToBytes32,
49
+ authorizationTypes: () => authorizationTypes,
50
+ bytes32ToAddress: () => bytes32ToAddress,
51
+ createBundlerClient: () => createBundlerClient,
52
+ createGaslessT402Client: () => createGaslessT402Client,
53
+ createPaymasterClient: () => createPaymasterClient,
54
+ createUsdt0Bridge: () => createUsdt0Bridge,
55
+ createUserOpBuilder: () => createUserOpBuilder,
56
+ decodePaymasterAndData: () => decodePaymasterAndData,
57
+ eip3009ABI: () => eip3009ABI,
58
+ encodePaymasterAndData: () => encodePaymasterAndData,
59
+ erc20LegacyABI: () => erc20LegacyABI,
60
+ getBridgeableChains: () => getBridgeableChains,
61
+ getDefaultToken: () => getDefaultToken,
62
+ getEIP712Domain: () => getEIP712Domain,
63
+ getEndpointId: () => getEndpointId,
64
+ getNetworkTokens: () => getNetworkTokens,
65
+ getNetworksForToken: () => getNetworksForToken,
66
+ getTokenByAddress: () => getTokenByAddress,
67
+ getTokenConfig: () => getTokenConfig,
68
+ getUsdt0Networks: () => getUsdt0Networks,
69
+ getUsdt0OftAddress: () => getUsdt0OftAddress,
70
+ legacyAuthorizationTypes: () => legacyAuthorizationTypes,
71
+ packAccountGasLimits: () => packAccountGasLimits,
72
+ packGasFees: () => packGasFees,
73
+ supportsBridging: () => supportsBridging,
74
+ supportsEIP3009: () => supportsEIP3009,
75
+ toClientEvmSigner: () => toClientEvmSigner,
76
+ toFacilitatorEvmSigner: () => toFacilitatorEvmSigner,
77
+ unpackAccountGasLimits: () => unpackAccountGasLimits,
78
+ unpackGasFees: () => unpackGasFees
79
+ });
80
+ module.exports = __toCommonJS(src_exports);
81
+
82
+ // src/exact/client/scheme.ts
83
+ var import_viem2 = require("viem");
84
+
85
+ // src/constants.ts
86
+ var authorizationTypes = {
87
+ TransferWithAuthorization: [
88
+ { name: "from", type: "address" },
89
+ { name: "to", type: "address" },
90
+ { name: "value", type: "uint256" },
91
+ { name: "validAfter", type: "uint256" },
92
+ { name: "validBefore", type: "uint256" },
93
+ { name: "nonce", type: "bytes32" }
94
+ ]
95
+ };
96
+ var legacyAuthorizationTypes = {
97
+ LegacyTransferAuthorization: [
98
+ { name: "from", type: "address" },
99
+ { name: "to", type: "address" },
100
+ { name: "value", type: "uint256" },
101
+ { name: "validAfter", type: "uint256" },
102
+ { name: "validBefore", type: "uint256" },
103
+ { name: "nonce", type: "bytes32" },
104
+ { name: "spender", type: "address" }
105
+ ]
106
+ };
107
+ var eip3009ABI = [
108
+ {
109
+ inputs: [
110
+ { name: "from", type: "address" },
111
+ { name: "to", type: "address" },
112
+ { name: "value", type: "uint256" },
113
+ { name: "validAfter", type: "uint256" },
114
+ { name: "validBefore", type: "uint256" },
115
+ { name: "nonce", type: "bytes32" },
116
+ { name: "v", type: "uint8" },
117
+ { name: "r", type: "bytes32" },
118
+ { name: "s", type: "bytes32" }
119
+ ],
120
+ name: "transferWithAuthorization",
121
+ outputs: [],
122
+ stateMutability: "nonpayable",
123
+ type: "function"
124
+ },
125
+ {
126
+ inputs: [
127
+ { name: "from", type: "address" },
128
+ { name: "to", type: "address" },
129
+ { name: "value", type: "uint256" },
130
+ { name: "validAfter", type: "uint256" },
131
+ { name: "validBefore", type: "uint256" },
132
+ { name: "nonce", type: "bytes32" },
133
+ { name: "signature", type: "bytes" }
134
+ ],
135
+ name: "transferWithAuthorization",
136
+ outputs: [],
137
+ stateMutability: "nonpayable",
138
+ type: "function"
139
+ },
140
+ {
141
+ inputs: [{ name: "account", type: "address" }],
142
+ name: "balanceOf",
143
+ outputs: [{ name: "", type: "uint256" }],
144
+ stateMutability: "view",
145
+ type: "function"
146
+ },
147
+ {
148
+ inputs: [],
149
+ name: "version",
150
+ outputs: [{ name: "", type: "string" }],
151
+ stateMutability: "view",
152
+ type: "function"
153
+ }
154
+ ];
155
+ var erc20LegacyABI = [
156
+ {
157
+ inputs: [{ name: "account", type: "address" }],
158
+ name: "balanceOf",
159
+ outputs: [{ name: "", type: "uint256" }],
160
+ stateMutability: "view",
161
+ type: "function"
162
+ },
163
+ {
164
+ inputs: [
165
+ { name: "owner", type: "address" },
166
+ { name: "spender", type: "address" }
167
+ ],
168
+ name: "allowance",
169
+ outputs: [{ name: "", type: "uint256" }],
170
+ stateMutability: "view",
171
+ type: "function"
172
+ },
173
+ {
174
+ inputs: [
175
+ { name: "spender", type: "address" },
176
+ { name: "amount", type: "uint256" }
177
+ ],
178
+ name: "approve",
179
+ outputs: [{ name: "", type: "bool" }],
180
+ stateMutability: "nonpayable",
181
+ type: "function"
182
+ },
183
+ {
184
+ inputs: [
185
+ { name: "from", type: "address" },
186
+ { name: "to", type: "address" },
187
+ { name: "amount", type: "uint256" }
188
+ ],
189
+ name: "transferFrom",
190
+ outputs: [{ name: "", type: "bool" }],
191
+ stateMutability: "nonpayable",
192
+ type: "function"
193
+ }
194
+ ];
195
+
196
+ // src/utils.ts
197
+ var import_viem = require("viem");
198
+ function createNonce() {
199
+ const cryptoObj = typeof globalThis.crypto !== "undefined" ? globalThis.crypto : globalThis.crypto;
200
+ if (!cryptoObj) {
201
+ throw new Error("Crypto API not available");
202
+ }
203
+ return (0, import_viem.toHex)(cryptoObj.getRandomValues(new Uint8Array(32)));
204
+ }
205
+
206
+ // src/exact/client/scheme.ts
207
+ var ExactEvmScheme = class {
208
+ /**
209
+ * Creates a new ExactEvmClient instance.
210
+ *
211
+ * @param signer - The EVM signer for client operations
212
+ */
213
+ constructor(signer) {
214
+ this.signer = signer;
215
+ this.scheme = "exact";
216
+ }
217
+ /**
218
+ * Creates a payment payload for the Exact scheme.
219
+ *
220
+ * @param t402Version - The t402 protocol version
221
+ * @param paymentRequirements - The payment requirements
222
+ * @returns Promise resolving to a payment payload
223
+ */
224
+ async createPaymentPayload(t402Version, paymentRequirements) {
225
+ const nonce = createNonce();
226
+ const now = Math.floor(Date.now() / 1e3);
227
+ const authorization = {
228
+ from: this.signer.address,
229
+ to: (0, import_viem2.getAddress)(paymentRequirements.payTo),
230
+ value: paymentRequirements.amount,
231
+ validAfter: (now - 600).toString(),
232
+ // 10 minutes before
233
+ validBefore: (now + paymentRequirements.maxTimeoutSeconds).toString(),
234
+ nonce
235
+ };
236
+ const signature = await this.signAuthorization(authorization, paymentRequirements);
237
+ const payload = {
238
+ authorization,
239
+ signature
240
+ };
241
+ return {
242
+ t402Version,
243
+ payload
244
+ };
245
+ }
246
+ /**
247
+ * Sign the EIP-3009 authorization using EIP-712
248
+ *
249
+ * @param authorization - The authorization to sign
250
+ * @param requirements - The payment requirements
251
+ * @returns Promise resolving to the signature
252
+ */
253
+ async signAuthorization(authorization, requirements) {
254
+ const chainId = parseInt(requirements.network.split(":")[1]);
255
+ if (!requirements.extra?.name || !requirements.extra?.version) {
256
+ throw new Error(
257
+ `EIP-712 domain parameters (name, version) are required in payment requirements for asset ${requirements.asset}`
258
+ );
259
+ }
260
+ const { name, version } = requirements.extra;
261
+ const domain = {
262
+ name,
263
+ version,
264
+ chainId,
265
+ verifyingContract: (0, import_viem2.getAddress)(requirements.asset)
266
+ };
267
+ const message = {
268
+ from: (0, import_viem2.getAddress)(authorization.from),
269
+ to: (0, import_viem2.getAddress)(authorization.to),
270
+ value: BigInt(authorization.value),
271
+ validAfter: BigInt(authorization.validAfter),
272
+ validBefore: BigInt(authorization.validBefore),
273
+ nonce: authorization.nonce
274
+ };
275
+ return await this.signer.signTypedData({
276
+ domain,
277
+ types: authorizationTypes,
278
+ primaryType: "TransferWithAuthorization",
279
+ message
280
+ });
281
+ }
282
+ };
283
+
284
+ // src/exact-legacy/client/scheme.ts
285
+ var import_viem3 = require("viem");
286
+ var ExactLegacyEvmScheme = class {
287
+ /**
288
+ * Creates a new ExactLegacyEvmScheme instance.
289
+ *
290
+ * @param signer - The EVM signer for client operations
291
+ */
292
+ constructor(signer) {
293
+ this.signer = signer;
294
+ this.scheme = "exact-legacy";
295
+ }
296
+ /**
297
+ * Creates a payment payload for the exact-legacy scheme.
298
+ *
299
+ * @param t402Version - The t402 protocol version
300
+ * @param paymentRequirements - The payment requirements
301
+ * @returns Promise resolving to a payment payload
302
+ */
303
+ async createPaymentPayload(t402Version, paymentRequirements) {
304
+ if (!paymentRequirements.extra?.spender) {
305
+ throw new Error(
306
+ "exact-legacy scheme requires 'spender' (facilitator address) in payment requirements extra field"
307
+ );
308
+ }
309
+ const spender = (0, import_viem3.getAddress)(paymentRequirements.extra.spender);
310
+ const nonce = createNonce();
311
+ const now = Math.floor(Date.now() / 1e3);
312
+ const authorization = {
313
+ from: this.signer.address,
314
+ to: (0, import_viem3.getAddress)(paymentRequirements.payTo),
315
+ value: paymentRequirements.amount,
316
+ validAfter: (now - 600).toString(),
317
+ // 10 minutes before
318
+ validBefore: (now + paymentRequirements.maxTimeoutSeconds).toString(),
319
+ nonce,
320
+ spender
321
+ };
322
+ const signature = await this.signAuthorization(authorization, paymentRequirements);
323
+ const payload = {
324
+ authorization,
325
+ signature
326
+ };
327
+ return {
328
+ t402Version,
329
+ payload
330
+ };
331
+ }
332
+ /**
333
+ * Sign the legacy transfer authorization using EIP-712
334
+ *
335
+ * @param authorization - The authorization to sign
336
+ * @param requirements - The payment requirements
337
+ * @returns Promise resolving to the signature
338
+ */
339
+ async signAuthorization(authorization, requirements) {
340
+ const chainId = parseInt(requirements.network.split(":")[1]);
341
+ const name = requirements.extra?.name || "T402LegacyTransfer";
342
+ const version = requirements.extra?.version || "1";
343
+ const domain = {
344
+ name,
345
+ version,
346
+ chainId,
347
+ verifyingContract: (0, import_viem3.getAddress)(requirements.asset)
348
+ };
349
+ const message = {
350
+ from: (0, import_viem3.getAddress)(authorization.from),
351
+ to: (0, import_viem3.getAddress)(authorization.to),
352
+ value: BigInt(authorization.value),
353
+ validAfter: BigInt(authorization.validAfter),
354
+ validBefore: BigInt(authorization.validBefore),
355
+ nonce: authorization.nonce,
356
+ spender: (0, import_viem3.getAddress)(authorization.spender)
357
+ };
358
+ return await this.signer.signTypedData({
359
+ domain,
360
+ types: legacyAuthorizationTypes,
361
+ primaryType: "LegacyTransferAuthorization",
362
+ message
363
+ });
364
+ }
365
+ };
366
+
367
+ // src/tokens.ts
368
+ var USDT0_ADDRESSES = {
369
+ // Ethereum Mainnet - OFT Adapter (bridge endpoint)
370
+ "eip155:1": "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee",
371
+ // Arbitrum One - Native USDT0
372
+ "eip155:42161": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
373
+ // Ink Mainnet
374
+ "eip155:57073": "0x0200C29006150606B650577BBE7B6248F58470c1",
375
+ // Berachain Mainnet
376
+ "eip155:80094": "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
377
+ // Unichain Mainnet
378
+ "eip155:130": "0x588ce4F028D8e7B53B687865d6A67b3A54C75518"
379
+ };
380
+ var USDC_ADDRESSES = {
381
+ // Ethereum Mainnet
382
+ "eip155:1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
383
+ // Base Mainnet
384
+ "eip155:8453": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
385
+ // Base Sepolia (testnet)
386
+ "eip155:84532": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
387
+ // Sepolia (testnet)
388
+ "eip155:11155111": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
389
+ // Arbitrum One
390
+ "eip155:42161": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
391
+ // Polygon Mainnet
392
+ "eip155:137": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
393
+ };
394
+ var USDT_LEGACY_ADDRESSES = {
395
+ // Ethereum Mainnet
396
+ "eip155:1": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
397
+ // Polygon Mainnet
398
+ "eip155:137": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
399
+ };
400
+ var TOKEN_REGISTRY = {
401
+ // Ethereum Mainnet
402
+ "eip155:1": {
403
+ USDT0: {
404
+ address: USDT0_ADDRESSES["eip155:1"],
405
+ symbol: "USDT0",
406
+ name: "TetherToken",
407
+ version: "1",
408
+ decimals: 6,
409
+ tokenType: "eip3009",
410
+ priority: 1
411
+ },
412
+ USDC: {
413
+ address: USDC_ADDRESSES["eip155:1"],
414
+ symbol: "USDC",
415
+ name: "USD Coin",
416
+ version: "2",
417
+ decimals: 6,
418
+ tokenType: "eip3009",
419
+ priority: 2
420
+ },
421
+ USDT: {
422
+ address: USDT_LEGACY_ADDRESSES["eip155:1"],
423
+ symbol: "USDT",
424
+ name: "TetherUSD",
425
+ version: "1",
426
+ decimals: 6,
427
+ tokenType: "legacy",
428
+ priority: 10
429
+ // Lower priority due to legacy flow
430
+ }
431
+ },
432
+ // Arbitrum One
433
+ "eip155:42161": {
434
+ USDT0: {
435
+ address: USDT0_ADDRESSES["eip155:42161"],
436
+ symbol: "USDT0",
437
+ name: "TetherToken",
438
+ version: "1",
439
+ decimals: 6,
440
+ tokenType: "eip3009",
441
+ priority: 1
442
+ },
443
+ USDC: {
444
+ address: USDC_ADDRESSES["eip155:42161"],
445
+ symbol: "USDC",
446
+ name: "USD Coin",
447
+ version: "2",
448
+ decimals: 6,
449
+ tokenType: "eip3009",
450
+ priority: 2
451
+ }
452
+ },
453
+ // Ink Mainnet
454
+ "eip155:57073": {
455
+ USDT0: {
456
+ address: USDT0_ADDRESSES["eip155:57073"],
457
+ symbol: "USDT0",
458
+ name: "TetherToken",
459
+ version: "1",
460
+ decimals: 6,
461
+ tokenType: "eip3009",
462
+ priority: 1
463
+ }
464
+ },
465
+ // Berachain Mainnet
466
+ "eip155:80094": {
467
+ USDT0: {
468
+ address: USDT0_ADDRESSES["eip155:80094"],
469
+ symbol: "USDT0",
470
+ name: "TetherToken",
471
+ version: "1",
472
+ decimals: 6,
473
+ tokenType: "eip3009",
474
+ priority: 1
475
+ }
476
+ },
477
+ // Unichain Mainnet
478
+ "eip155:130": {
479
+ USDT0: {
480
+ address: USDT0_ADDRESSES["eip155:130"],
481
+ symbol: "USDT0",
482
+ name: "TetherToken",
483
+ version: "1",
484
+ decimals: 6,
485
+ tokenType: "eip3009",
486
+ priority: 1
487
+ }
488
+ },
489
+ // Base Mainnet
490
+ "eip155:8453": {
491
+ USDC: {
492
+ address: USDC_ADDRESSES["eip155:8453"],
493
+ symbol: "USDC",
494
+ name: "USD Coin",
495
+ version: "2",
496
+ decimals: 6,
497
+ tokenType: "eip3009",
498
+ priority: 2
499
+ }
500
+ },
501
+ // Base Sepolia (testnet)
502
+ "eip155:84532": {
503
+ USDC: {
504
+ address: USDC_ADDRESSES["eip155:84532"],
505
+ symbol: "USDC",
506
+ name: "USDC",
507
+ version: "2",
508
+ decimals: 6,
509
+ tokenType: "eip3009",
510
+ priority: 2
511
+ }
512
+ },
513
+ // Sepolia (testnet)
514
+ "eip155:11155111": {
515
+ USDC: {
516
+ address: USDC_ADDRESSES["eip155:11155111"],
517
+ symbol: "USDC",
518
+ name: "USDC",
519
+ version: "2",
520
+ decimals: 6,
521
+ tokenType: "eip3009",
522
+ priority: 2
523
+ }
524
+ },
525
+ // Polygon Mainnet
526
+ "eip155:137": {
527
+ USDC: {
528
+ address: USDC_ADDRESSES["eip155:137"],
529
+ symbol: "USDC",
530
+ name: "USD Coin",
531
+ version: "2",
532
+ decimals: 6,
533
+ tokenType: "eip3009",
534
+ priority: 2
535
+ },
536
+ USDT: {
537
+ address: USDT_LEGACY_ADDRESSES["eip155:137"],
538
+ symbol: "USDT",
539
+ name: "TetherUSD",
540
+ version: "1",
541
+ decimals: 6,
542
+ tokenType: "legacy",
543
+ priority: 10
544
+ }
545
+ }
546
+ };
547
+ var TOKEN_PRIORITY = {
548
+ USDT0: 1,
549
+ // Highest priority - gasless, cross-chain
550
+ USDC: 2,
551
+ // Second - wide support, EIP-3009
552
+ USDT: 10,
553
+ // Lower - requires approval transaction
554
+ DAI: 5
555
+ // Medium - good support
556
+ };
557
+ function getTokenConfig(network, symbol) {
558
+ return TOKEN_REGISTRY[network]?.[symbol.toUpperCase()];
559
+ }
560
+ function getNetworkTokens(network) {
561
+ const tokens = TOKEN_REGISTRY[network];
562
+ if (!tokens) return [];
563
+ return Object.values(tokens).sort((a, b) => a.priority - b.priority);
564
+ }
565
+ function getDefaultToken(network) {
566
+ const tokens = getNetworkTokens(network);
567
+ return tokens[0];
568
+ }
569
+ function getTokenByAddress(network, address) {
570
+ const tokens = TOKEN_REGISTRY[network];
571
+ if (!tokens) return void 0;
572
+ const lowerAddress = address.toLowerCase();
573
+ return Object.values(tokens).find((t) => t.address.toLowerCase() === lowerAddress);
574
+ }
575
+ function supportsEIP3009(network, symbol) {
576
+ const config = getTokenConfig(network, symbol);
577
+ return config?.tokenType === "eip3009";
578
+ }
579
+ function getNetworksForToken(symbol) {
580
+ const networks = [];
581
+ for (const [network, tokens] of Object.entries(TOKEN_REGISTRY)) {
582
+ if (tokens[symbol.toUpperCase()]) {
583
+ networks.push(network);
584
+ }
585
+ }
586
+ return networks;
587
+ }
588
+ function getUsdt0Networks() {
589
+ return getNetworksForToken("USDT0");
590
+ }
591
+ function getEIP712Domain(network, tokenAddress, chainId) {
592
+ const token = getTokenByAddress(network, tokenAddress);
593
+ if (!token) return void 0;
594
+ return {
595
+ name: token.name,
596
+ version: token.version,
597
+ chainId,
598
+ verifyingContract: token.address
599
+ };
600
+ }
601
+
602
+ // src/exact-legacy/server/scheme.ts
603
+ var ExactLegacyEvmScheme2 = class {
604
+ constructor(config = {}) {
605
+ this.scheme = "exact-legacy";
606
+ this.moneyParsers = [];
607
+ this.config = config;
608
+ }
609
+ /**
610
+ * Register a custom money parser in the parser chain.
611
+ */
612
+ registerMoneyParser(parser) {
613
+ this.moneyParsers.push(parser);
614
+ return this;
615
+ }
616
+ /**
617
+ * Parses a price into an asset amount for legacy tokens.
618
+ */
619
+ async parsePrice(price, network) {
620
+ if (typeof price === "object" && price !== null && "amount" in price) {
621
+ if (!price.asset) {
622
+ throw new Error(`Asset address must be specified for AssetAmount on network ${network}`);
623
+ }
624
+ return {
625
+ amount: price.amount,
626
+ asset: price.asset,
627
+ extra: {
628
+ ...price.extra,
629
+ tokenType: "legacy"
630
+ }
631
+ };
632
+ }
633
+ const amount = this.parseMoneyToDecimal(price);
634
+ for (const parser of this.moneyParsers) {
635
+ const result = await parser(amount, network);
636
+ if (result !== null) {
637
+ return result;
638
+ }
639
+ }
640
+ return this.defaultMoneyConversion(amount, network);
641
+ }
642
+ /**
643
+ * Build payment requirements for this scheme/network combination.
644
+ * Adds the spender (facilitator) address to the extra field.
645
+ */
646
+ enhancePaymentRequirements(paymentRequirements, supportedKind, extensionKeys) {
647
+ void extensionKeys;
648
+ const spender = supportedKind.extra?.spender;
649
+ return Promise.resolve({
650
+ ...paymentRequirements,
651
+ extra: {
652
+ ...paymentRequirements.extra,
653
+ tokenType: "legacy",
654
+ ...spender && { spender }
655
+ }
656
+ });
657
+ }
658
+ /**
659
+ * Parse Money (string | number) to a decimal number.
660
+ */
661
+ parseMoneyToDecimal(money) {
662
+ if (typeof money === "number") {
663
+ return money;
664
+ }
665
+ const cleanMoney = money.replace(/^\$/, "").trim();
666
+ const amount = parseFloat(cleanMoney);
667
+ if (isNaN(amount)) {
668
+ throw new Error(`Invalid money format: ${money}`);
669
+ }
670
+ return amount;
671
+ }
672
+ /**
673
+ * Default money conversion implementation for legacy tokens.
674
+ */
675
+ defaultMoneyConversion(amount, network) {
676
+ const token = this.getDefaultAsset(network);
677
+ const tokenAmount = this.convertToTokenAmount(amount.toString(), token.decimals);
678
+ return {
679
+ amount: tokenAmount,
680
+ asset: token.address,
681
+ extra: {
682
+ name: token.name,
683
+ version: token.version,
684
+ symbol: token.symbol,
685
+ tokenType: "legacy"
686
+ }
687
+ };
688
+ }
689
+ /**
690
+ * Convert decimal amount to token units
691
+ */
692
+ convertToTokenAmount(decimalAmount, decimals) {
693
+ const amount = parseFloat(decimalAmount);
694
+ if (isNaN(amount)) {
695
+ throw new Error(`Invalid amount: ${decimalAmount}`);
696
+ }
697
+ const tokenAmount = Math.floor(amount * Math.pow(10, decimals));
698
+ return tokenAmount.toString();
699
+ }
700
+ /**
701
+ * Get the default legacy token for a network.
702
+ */
703
+ getDefaultAsset(network) {
704
+ if (this.config.preferredToken) {
705
+ const preferred = getTokenConfig(network, this.config.preferredToken);
706
+ if (preferred && preferred.tokenType === "legacy") {
707
+ return preferred;
708
+ }
709
+ }
710
+ const usdt = getTokenConfig(network, "USDT");
711
+ if (usdt && usdt.tokenType === "legacy") {
712
+ return usdt;
713
+ }
714
+ const tokens = TOKEN_REGISTRY[network];
715
+ if (tokens) {
716
+ const legacyToken = Object.values(tokens).find((t) => t.tokenType === "legacy");
717
+ if (legacyToken) return legacyToken;
718
+ }
719
+ throw new Error(`No legacy tokens configured for network ${network}`);
720
+ }
721
+ /**
722
+ * Get all supported networks that have legacy tokens
723
+ */
724
+ static getSupportedNetworks() {
725
+ return Object.keys(USDT_LEGACY_ADDRESSES);
726
+ }
727
+ /**
728
+ * Check if a network has legacy token support
729
+ */
730
+ static isNetworkSupported(network) {
731
+ return network in USDT_LEGACY_ADDRESSES;
732
+ }
733
+ };
734
+
735
+ // src/exact-legacy/facilitator/scheme.ts
736
+ var import_viem4 = require("viem");
737
+ var ExactLegacyEvmScheme3 = class {
738
+ /**
739
+ * Creates a new ExactLegacyEvmScheme instance.
740
+ *
741
+ * @param signer - The EVM signer for facilitator operations
742
+ * @param config - Optional configuration
743
+ */
744
+ constructor(signer, config) {
745
+ this.signer = signer;
746
+ this.scheme = "exact-legacy";
747
+ this.caipFamily = "eip155:*";
748
+ this.config = {
749
+ minAllowanceRatio: config?.minAllowanceRatio ?? 1
750
+ };
751
+ }
752
+ /**
753
+ * Get mechanism-specific extra data for the supported kinds endpoint.
754
+ * For exact-legacy, returns the spender (facilitator) addresses.
755
+ *
756
+ * @param network - The network identifier
757
+ * @returns Extra data including spender addresses
758
+ */
759
+ getExtra(network) {
760
+ void network;
761
+ const addresses = this.signer.getAddresses();
762
+ if (addresses.length > 0) {
763
+ return {
764
+ spender: addresses[0],
765
+ tokenType: "legacy"
766
+ };
767
+ }
768
+ return { tokenType: "legacy" };
769
+ }
770
+ /**
771
+ * Get signer addresses used by this facilitator.
772
+ */
773
+ getSigners(network) {
774
+ void network;
775
+ return [...this.signer.getAddresses()];
776
+ }
777
+ /**
778
+ * Verifies a payment payload.
779
+ */
780
+ async verify(payload, requirements) {
781
+ const legacyPayload = payload.payload;
782
+ if (payload.accepted.scheme !== "exact-legacy" || requirements.scheme !== "exact-legacy") {
783
+ return {
784
+ isValid: false,
785
+ invalidReason: "unsupported_scheme",
786
+ payer: legacyPayload.authorization.from
787
+ };
788
+ }
789
+ if (payload.accepted.network !== requirements.network) {
790
+ return {
791
+ isValid: false,
792
+ invalidReason: "network_mismatch",
793
+ payer: legacyPayload.authorization.from
794
+ };
795
+ }
796
+ const erc20Address = (0, import_viem4.getAddress)(requirements.asset);
797
+ const spender = (0, import_viem4.getAddress)(legacyPayload.authorization.spender);
798
+ const facilitatorAddresses = this.signer.getAddresses();
799
+ const isValidSpender = facilitatorAddresses.some((addr) => (0, import_viem4.isAddressEqual)(addr, spender));
800
+ if (!isValidSpender) {
801
+ return {
802
+ isValid: false,
803
+ invalidReason: "invalid_spender",
804
+ payer: legacyPayload.authorization.from
805
+ };
806
+ }
807
+ const name = requirements.extra?.name || "T402LegacyTransfer";
808
+ const version = requirements.extra?.version || "1";
809
+ const chainId = parseInt(requirements.network.split(":")[1]);
810
+ const domain = {
811
+ name,
812
+ version,
813
+ chainId,
814
+ verifyingContract: erc20Address
815
+ };
816
+ const message = {
817
+ from: legacyPayload.authorization.from,
818
+ to: legacyPayload.authorization.to,
819
+ value: BigInt(legacyPayload.authorization.value),
820
+ validAfter: BigInt(legacyPayload.authorization.validAfter),
821
+ validBefore: BigInt(legacyPayload.authorization.validBefore),
822
+ nonce: legacyPayload.authorization.nonce,
823
+ spender: legacyPayload.authorization.spender
824
+ };
825
+ try {
826
+ const isValid = await this.signer.verifyTypedData({
827
+ address: legacyPayload.authorization.from,
828
+ domain,
829
+ types: legacyAuthorizationTypes,
830
+ primaryType: "LegacyTransferAuthorization",
831
+ message,
832
+ signature: legacyPayload.signature
833
+ });
834
+ if (!isValid) {
835
+ return {
836
+ isValid: false,
837
+ invalidReason: "invalid_signature",
838
+ payer: legacyPayload.authorization.from
839
+ };
840
+ }
841
+ } catch {
842
+ return {
843
+ isValid: false,
844
+ invalidReason: "signature_verification_failed",
845
+ payer: legacyPayload.authorization.from
846
+ };
847
+ }
848
+ if ((0, import_viem4.getAddress)(legacyPayload.authorization.to) !== (0, import_viem4.getAddress)(requirements.payTo)) {
849
+ return {
850
+ isValid: false,
851
+ invalidReason: "recipient_mismatch",
852
+ payer: legacyPayload.authorization.from
853
+ };
854
+ }
855
+ const now = Math.floor(Date.now() / 1e3);
856
+ if (BigInt(legacyPayload.authorization.validBefore) < BigInt(now + 6)) {
857
+ return {
858
+ isValid: false,
859
+ invalidReason: "authorization_expired",
860
+ payer: legacyPayload.authorization.from
861
+ };
862
+ }
863
+ if (BigInt(legacyPayload.authorization.validAfter) > BigInt(now)) {
864
+ return {
865
+ isValid: false,
866
+ invalidReason: "authorization_not_yet_valid",
867
+ payer: legacyPayload.authorization.from
868
+ };
869
+ }
870
+ try {
871
+ const balance = await this.signer.readContract({
872
+ address: erc20Address,
873
+ abi: erc20LegacyABI,
874
+ functionName: "balanceOf",
875
+ args: [legacyPayload.authorization.from]
876
+ });
877
+ if (BigInt(balance) < BigInt(requirements.amount)) {
878
+ return {
879
+ isValid: false,
880
+ invalidReason: "insufficient_balance",
881
+ payer: legacyPayload.authorization.from
882
+ };
883
+ }
884
+ } catch {
885
+ }
886
+ try {
887
+ const allowance = await this.signer.readContract({
888
+ address: erc20Address,
889
+ abi: erc20LegacyABI,
890
+ functionName: "allowance",
891
+ args: [legacyPayload.authorization.from, spender]
892
+ });
893
+ const requiredAllowance = BigInt(
894
+ Math.floor(Number(requirements.amount) * this.config.minAllowanceRatio)
895
+ );
896
+ if (allowance < requiredAllowance) {
897
+ return {
898
+ isValid: false,
899
+ invalidReason: "insufficient_allowance",
900
+ payer: legacyPayload.authorization.from
901
+ };
902
+ }
903
+ } catch {
904
+ return {
905
+ isValid: false,
906
+ invalidReason: "allowance_check_failed",
907
+ payer: legacyPayload.authorization.from
908
+ };
909
+ }
910
+ if (BigInt(legacyPayload.authorization.value) < BigInt(requirements.amount)) {
911
+ return {
912
+ isValid: false,
913
+ invalidReason: "insufficient_amount",
914
+ payer: legacyPayload.authorization.from
915
+ };
916
+ }
917
+ return {
918
+ isValid: true,
919
+ invalidReason: void 0,
920
+ payer: legacyPayload.authorization.from
921
+ };
922
+ }
923
+ /**
924
+ * Settles a payment by executing transferFrom.
925
+ */
926
+ async settle(payload, requirements) {
927
+ const legacyPayload = payload.payload;
928
+ const valid = await this.verify(payload, requirements);
929
+ if (!valid.isValid) {
930
+ return {
931
+ success: false,
932
+ network: payload.accepted.network,
933
+ transaction: "",
934
+ errorReason: valid.invalidReason ?? "invalid_payment",
935
+ payer: legacyPayload.authorization.from
936
+ };
937
+ }
938
+ try {
939
+ const tx = await this.signer.writeContract({
940
+ address: (0, import_viem4.getAddress)(requirements.asset),
941
+ abi: erc20LegacyABI,
942
+ functionName: "transferFrom",
943
+ args: [
944
+ (0, import_viem4.getAddress)(legacyPayload.authorization.from),
945
+ (0, import_viem4.getAddress)(legacyPayload.authorization.to),
946
+ BigInt(legacyPayload.authorization.value)
947
+ ]
948
+ });
949
+ const receipt = await this.signer.waitForTransactionReceipt({ hash: tx });
950
+ if (receipt.status !== "success") {
951
+ return {
952
+ success: false,
953
+ errorReason: "transaction_failed",
954
+ transaction: tx,
955
+ network: payload.accepted.network,
956
+ payer: legacyPayload.authorization.from
957
+ };
958
+ }
959
+ return {
960
+ success: true,
961
+ transaction: tx,
962
+ network: payload.accepted.network,
963
+ payer: legacyPayload.authorization.from
964
+ };
965
+ } catch (error) {
966
+ console.error("Failed to settle legacy transaction:", error);
967
+ return {
968
+ success: false,
969
+ errorReason: "settlement_failed",
970
+ transaction: "",
971
+ network: payload.accepted.network,
972
+ payer: legacyPayload.authorization.from
973
+ };
974
+ }
975
+ }
976
+ };
977
+
978
+ // src/signer.ts
979
+ function toClientEvmSigner(signer) {
980
+ return signer;
981
+ }
982
+ function toFacilitatorEvmSigner(client) {
983
+ return {
984
+ ...client,
985
+ getAddresses: () => [client.address]
986
+ };
987
+ }
988
+
989
+ // src/bridge/constants.ts
990
+ var LAYERZERO_ENDPOINT_IDS = {
991
+ // Mainnets
992
+ ethereum: 30101,
993
+ arbitrum: 30110,
994
+ base: 30184,
995
+ optimism: 30111,
996
+ polygon: 30109,
997
+ avalanche: 30106,
998
+ bsc: 30102,
999
+ // USDT0 specific chains
1000
+ ink: 30291,
1001
+ // Ink mainnet
1002
+ berachain: 30362,
1003
+ // Berachain mainnet
1004
+ unichain: 30320,
1005
+ // Unichain mainnet
1006
+ // Testnets
1007
+ sepolia: 40161,
1008
+ arbitrumSepolia: 40231,
1009
+ baseSepolia: 40245
1010
+ };
1011
+ var NETWORK_TO_CHAIN = {
1012
+ "eip155:1": "ethereum",
1013
+ "eip155:42161": "arbitrum",
1014
+ "eip155:8453": "base",
1015
+ "eip155:10": "optimism",
1016
+ "eip155:137": "polygon",
1017
+ "eip155:43114": "avalanche",
1018
+ "eip155:56": "bsc",
1019
+ "eip155:57073": "ink",
1020
+ "eip155:80094": "berachain",
1021
+ "eip155:130": "unichain",
1022
+ // Testnets
1023
+ "eip155:11155111": "sepolia",
1024
+ "eip155:421614": "arbitrumSepolia",
1025
+ "eip155:84532": "baseSepolia"
1026
+ };
1027
+ var CHAIN_TO_NETWORK = Object.fromEntries(
1028
+ Object.entries(NETWORK_TO_CHAIN).map(([k, v]) => [v, k])
1029
+ );
1030
+ var USDT0_OFT_ADDRESSES = {
1031
+ // Ethereum is the OFT Adapter (locks/unlocks tokens)
1032
+ ethereum: "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee",
1033
+ // Other chains have native USDT0 OFT contracts
1034
+ arbitrum: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
1035
+ ink: "0x0200C29006150606B650577BBE7B6248F58470c1",
1036
+ berachain: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
1037
+ unichain: "0x588ce4F028D8e7B53B687865d6A67b3A54C75518"
1038
+ };
1039
+ var LAYERZERO_ENDPOINT_V2 = "0x1a44076050125825900e736c501f859c50fE728c";
1040
+ var DEFAULT_EXTRA_OPTIONS = "0x00030100110100000000000000000000000000030d40";
1041
+ var OFT_SEND_ABI = [
1042
+ {
1043
+ inputs: [
1044
+ {
1045
+ components: [
1046
+ { name: "dstEid", type: "uint32" },
1047
+ { name: "to", type: "bytes32" },
1048
+ { name: "amountLD", type: "uint256" },
1049
+ { name: "minAmountLD", type: "uint256" },
1050
+ { name: "extraOptions", type: "bytes" },
1051
+ { name: "composeMsg", type: "bytes" },
1052
+ { name: "oftCmd", type: "bytes" }
1053
+ ],
1054
+ name: "_sendParam",
1055
+ type: "tuple"
1056
+ },
1057
+ {
1058
+ components: [
1059
+ { name: "nativeFee", type: "uint256" },
1060
+ { name: "lzTokenFee", type: "uint256" }
1061
+ ],
1062
+ name: "_fee",
1063
+ type: "tuple"
1064
+ },
1065
+ { name: "_refundAddress", type: "address" }
1066
+ ],
1067
+ name: "send",
1068
+ outputs: [
1069
+ {
1070
+ components: [
1071
+ { name: "guid", type: "bytes32" },
1072
+ { name: "nonce", type: "uint64" },
1073
+ {
1074
+ components: [
1075
+ { name: "nativeFee", type: "uint256" },
1076
+ { name: "lzTokenFee", type: "uint256" }
1077
+ ],
1078
+ name: "fee",
1079
+ type: "tuple"
1080
+ }
1081
+ ],
1082
+ name: "msgReceipt",
1083
+ type: "tuple"
1084
+ },
1085
+ {
1086
+ components: [
1087
+ { name: "amountSentLD", type: "uint256" },
1088
+ { name: "amountReceivedLD", type: "uint256" }
1089
+ ],
1090
+ name: "oftReceipt",
1091
+ type: "tuple"
1092
+ }
1093
+ ],
1094
+ stateMutability: "payable",
1095
+ type: "function"
1096
+ },
1097
+ {
1098
+ inputs: [
1099
+ {
1100
+ components: [
1101
+ { name: "dstEid", type: "uint32" },
1102
+ { name: "to", type: "bytes32" },
1103
+ { name: "amountLD", type: "uint256" },
1104
+ { name: "minAmountLD", type: "uint256" },
1105
+ { name: "extraOptions", type: "bytes" },
1106
+ { name: "composeMsg", type: "bytes" },
1107
+ { name: "oftCmd", type: "bytes" }
1108
+ ],
1109
+ name: "_sendParam",
1110
+ type: "tuple"
1111
+ },
1112
+ { name: "_payInLzToken", type: "bool" }
1113
+ ],
1114
+ name: "quoteSend",
1115
+ outputs: [
1116
+ {
1117
+ components: [
1118
+ { name: "nativeFee", type: "uint256" },
1119
+ { name: "lzTokenFee", type: "uint256" }
1120
+ ],
1121
+ name: "msgFee",
1122
+ type: "tuple"
1123
+ }
1124
+ ],
1125
+ stateMutability: "view",
1126
+ type: "function"
1127
+ }
1128
+ ];
1129
+ var ERC20_APPROVE_ABI = [
1130
+ {
1131
+ inputs: [
1132
+ { name: "spender", type: "address" },
1133
+ { name: "amount", type: "uint256" }
1134
+ ],
1135
+ name: "approve",
1136
+ outputs: [{ name: "", type: "bool" }],
1137
+ stateMutability: "nonpayable",
1138
+ type: "function"
1139
+ },
1140
+ {
1141
+ inputs: [
1142
+ { name: "owner", type: "address" },
1143
+ { name: "spender", type: "address" }
1144
+ ],
1145
+ name: "allowance",
1146
+ outputs: [{ name: "", type: "uint256" }],
1147
+ stateMutability: "view",
1148
+ type: "function"
1149
+ }
1150
+ ];
1151
+ function getEndpointId(chain) {
1152
+ return LAYERZERO_ENDPOINT_IDS[chain];
1153
+ }
1154
+ function getUsdt0OftAddress(chain) {
1155
+ return USDT0_OFT_ADDRESSES[chain];
1156
+ }
1157
+ function supportsBridging(chain) {
1158
+ return chain in USDT0_OFT_ADDRESSES && chain in LAYERZERO_ENDPOINT_IDS;
1159
+ }
1160
+ function getBridgeableChains() {
1161
+ return Object.keys(USDT0_OFT_ADDRESSES).filter(
1162
+ (chain) => chain in LAYERZERO_ENDPOINT_IDS
1163
+ );
1164
+ }
1165
+ function addressToBytes32(address) {
1166
+ const cleanAddress = address.slice(2).toLowerCase();
1167
+ return `0x${cleanAddress.padStart(64, "0")}`;
1168
+ }
1169
+ function bytes32ToAddress(bytes32) {
1170
+ return `0x${bytes32.slice(-40)}`;
1171
+ }
1172
+
1173
+ // src/bridge/client.ts
1174
+ var DEFAULT_SLIPPAGE = 0.5;
1175
+ var ESTIMATED_BRIDGE_TIME = 300;
1176
+ var Usdt0Bridge = class {
1177
+ /**
1178
+ * Create a new bridge client
1179
+ *
1180
+ * @param signer - Wallet signer with read/write capabilities
1181
+ * @param chain - Source chain name (e.g., "arbitrum", "ethereum")
1182
+ */
1183
+ constructor(signer, chain) {
1184
+ if (!supportsBridging(chain)) {
1185
+ throw new Error(
1186
+ `Chain "${chain}" does not support USDT0 bridging. Supported chains: ${getBridgeableChains().join(", ")}`
1187
+ );
1188
+ }
1189
+ this.signer = signer;
1190
+ this.chain = chain;
1191
+ }
1192
+ /**
1193
+ * Get a quote for bridging USDT0
1194
+ *
1195
+ * @param params - Bridge parameters
1196
+ * @returns Quote with fee and amount information
1197
+ */
1198
+ async quote(params) {
1199
+ this.validateBridgeParams(params);
1200
+ const sendParam = this.buildSendParam(params);
1201
+ const oftAddress = getUsdt0OftAddress(params.fromChain);
1202
+ const fee = await this.signer.readContract({
1203
+ address: oftAddress,
1204
+ abi: OFT_SEND_ABI,
1205
+ functionName: "quoteSend",
1206
+ args: [sendParam, false]
1207
+ });
1208
+ return {
1209
+ nativeFee: fee.nativeFee,
1210
+ amountToSend: params.amount,
1211
+ minAmountToReceive: sendParam.minAmountLD,
1212
+ estimatedTime: ESTIMATED_BRIDGE_TIME,
1213
+ fromChain: params.fromChain,
1214
+ toChain: params.toChain
1215
+ };
1216
+ }
1217
+ /**
1218
+ * Execute a bridge transaction
1219
+ *
1220
+ * @param params - Bridge execution parameters
1221
+ * @returns Bridge result with transaction hash
1222
+ */
1223
+ async send(params) {
1224
+ this.validateBridgeParams(params);
1225
+ const oftAddress = getUsdt0OftAddress(params.fromChain);
1226
+ const sendParam = this.buildSendParam(params);
1227
+ const refundAddress = params.refundAddress ?? this.signer.address;
1228
+ const fee = await this.signer.readContract({
1229
+ address: oftAddress,
1230
+ abi: OFT_SEND_ABI,
1231
+ functionName: "quoteSend",
1232
+ args: [sendParam, false]
1233
+ });
1234
+ await this.ensureAllowance(oftAddress, params.amount);
1235
+ const txHash = await this.signer.writeContract({
1236
+ address: oftAddress,
1237
+ abi: OFT_SEND_ABI,
1238
+ functionName: "send",
1239
+ args: [sendParam, fee, refundAddress],
1240
+ value: fee.nativeFee
1241
+ });
1242
+ const receipt = await this.signer.waitForTransactionReceipt({ hash: txHash });
1243
+ if (receipt.status !== "success") {
1244
+ throw new Error(`Bridge transaction failed: ${txHash}`);
1245
+ }
1246
+ return {
1247
+ txHash,
1248
+ messageGuid: "0x" + "0".repeat(64),
1249
+ // Would be extracted from event logs
1250
+ amountSent: params.amount,
1251
+ amountToReceive: sendParam.minAmountLD,
1252
+ fromChain: params.fromChain,
1253
+ toChain: params.toChain,
1254
+ estimatedTime: ESTIMATED_BRIDGE_TIME
1255
+ };
1256
+ }
1257
+ /**
1258
+ * Ensure sufficient token allowance for the OFT contract
1259
+ */
1260
+ async ensureAllowance(oftAddress, amount) {
1261
+ const allowance = await this.signer.readContract({
1262
+ address: oftAddress,
1263
+ abi: ERC20_APPROVE_ABI,
1264
+ functionName: "allowance",
1265
+ args: [this.signer.address, oftAddress]
1266
+ });
1267
+ if (allowance < amount) {
1268
+ const approveTx = await this.signer.writeContract({
1269
+ address: oftAddress,
1270
+ abi: ERC20_APPROVE_ABI,
1271
+ functionName: "approve",
1272
+ args: [oftAddress, amount]
1273
+ });
1274
+ await this.signer.waitForTransactionReceipt({ hash: approveTx });
1275
+ }
1276
+ }
1277
+ /**
1278
+ * Build SendParam struct for LayerZero
1279
+ */
1280
+ buildSendParam(params) {
1281
+ const dstEid = getEndpointId(params.toChain);
1282
+ if (!dstEid) {
1283
+ throw new Error(`Unknown destination chain: ${params.toChain}`);
1284
+ }
1285
+ const slippage = "slippageTolerance" in params ? params.slippageTolerance ?? DEFAULT_SLIPPAGE : DEFAULT_SLIPPAGE;
1286
+ const minAmount = params.amount - params.amount * BigInt(Math.floor(slippage * 100)) / 10000n;
1287
+ return {
1288
+ dstEid,
1289
+ to: addressToBytes32(params.recipient),
1290
+ amountLD: params.amount,
1291
+ minAmountLD: minAmount,
1292
+ extraOptions: DEFAULT_EXTRA_OPTIONS,
1293
+ composeMsg: "0x",
1294
+ oftCmd: "0x"
1295
+ };
1296
+ }
1297
+ /**
1298
+ * Validate bridge parameters
1299
+ */
1300
+ validateBridgeParams(params) {
1301
+ if (params.fromChain !== this.chain) {
1302
+ throw new Error(
1303
+ `Source chain mismatch: bridge initialized for "${this.chain}" but got "${params.fromChain}"`
1304
+ );
1305
+ }
1306
+ if (!supportsBridging(params.fromChain)) {
1307
+ throw new Error(`Source chain "${params.fromChain}" does not support USDT0 bridging`);
1308
+ }
1309
+ if (!supportsBridging(params.toChain)) {
1310
+ throw new Error(`Destination chain "${params.toChain}" does not support USDT0 bridging`);
1311
+ }
1312
+ if (params.fromChain === params.toChain) {
1313
+ throw new Error("Source and destination chains must be different");
1314
+ }
1315
+ if (params.amount <= 0n) {
1316
+ throw new Error("Amount must be greater than 0");
1317
+ }
1318
+ }
1319
+ /**
1320
+ * Get all supported destination chains from current chain
1321
+ */
1322
+ getSupportedDestinations() {
1323
+ return getBridgeableChains().filter((chain) => chain !== this.chain);
1324
+ }
1325
+ /**
1326
+ * Check if a destination chain is supported
1327
+ */
1328
+ supportsDestination(toChain) {
1329
+ return toChain !== this.chain && supportsBridging(toChain);
1330
+ }
1331
+ };
1332
+ function createUsdt0Bridge(signer, chain) {
1333
+ return new Usdt0Bridge(signer, chain);
1334
+ }
1335
+
1336
+ // src/erc4337/constants.ts
1337
+ var ENTRYPOINT_V07_ADDRESS = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
1338
+ var ENTRYPOINT_V06_ADDRESS = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
1339
+ var DEFAULT_GAS_LIMITS = {
1340
+ /** Gas for account validation */
1341
+ verificationGasLimit: 150000n,
1342
+ /** Gas for callData execution */
1343
+ callGasLimit: 100000n,
1344
+ /** Gas paid to bundler for overhead */
1345
+ preVerificationGas: 50000n,
1346
+ /** Gas for paymaster validation */
1347
+ paymasterVerificationGasLimit: 50000n,
1348
+ /** Gas for paymaster post-op */
1349
+ paymasterPostOpGasLimit: 50000n
1350
+ };
1351
+ var ENTRYPOINT_V07_ABI = [
1352
+ {
1353
+ inputs: [
1354
+ {
1355
+ components: [
1356
+ { name: "sender", type: "address" },
1357
+ { name: "nonce", type: "uint256" },
1358
+ { name: "initCode", type: "bytes" },
1359
+ { name: "callData", type: "bytes" },
1360
+ { name: "accountGasLimits", type: "bytes32" },
1361
+ { name: "preVerificationGas", type: "uint256" },
1362
+ { name: "gasFees", type: "bytes32" },
1363
+ { name: "paymasterAndData", type: "bytes" },
1364
+ { name: "signature", type: "bytes" }
1365
+ ],
1366
+ name: "ops",
1367
+ type: "tuple[]"
1368
+ },
1369
+ { name: "beneficiary", type: "address" }
1370
+ ],
1371
+ name: "handleOps",
1372
+ outputs: [],
1373
+ stateMutability: "nonpayable",
1374
+ type: "function"
1375
+ },
1376
+ {
1377
+ inputs: [{ name: "sender", type: "address" }],
1378
+ name: "getNonce",
1379
+ outputs: [{ name: "nonce", type: "uint256" }],
1380
+ stateMutability: "view",
1381
+ type: "function"
1382
+ },
1383
+ {
1384
+ inputs: [
1385
+ { name: "sender", type: "address" },
1386
+ { name: "key", type: "uint192" }
1387
+ ],
1388
+ name: "getNonce",
1389
+ outputs: [{ name: "nonce", type: "uint256" }],
1390
+ stateMutability: "view",
1391
+ type: "function"
1392
+ },
1393
+ {
1394
+ inputs: [
1395
+ {
1396
+ components: [
1397
+ { name: "sender", type: "address" },
1398
+ { name: "nonce", type: "uint256" },
1399
+ { name: "initCode", type: "bytes" },
1400
+ { name: "callData", type: "bytes" },
1401
+ { name: "accountGasLimits", type: "bytes32" },
1402
+ { name: "preVerificationGas", type: "uint256" },
1403
+ { name: "gasFees", type: "bytes32" },
1404
+ { name: "paymasterAndData", type: "bytes" },
1405
+ { name: "signature", type: "bytes" }
1406
+ ],
1407
+ name: "userOp",
1408
+ type: "tuple"
1409
+ }
1410
+ ],
1411
+ name: "getUserOpHash",
1412
+ outputs: [{ name: "", type: "bytes32" }],
1413
+ stateMutability: "view",
1414
+ type: "function"
1415
+ }
1416
+ ];
1417
+ var ACCOUNT_ABI = [
1418
+ {
1419
+ inputs: [
1420
+ {
1421
+ components: [
1422
+ { name: "sender", type: "address" },
1423
+ { name: "nonce", type: "uint256" },
1424
+ { name: "initCode", type: "bytes" },
1425
+ { name: "callData", type: "bytes" },
1426
+ { name: "accountGasLimits", type: "bytes32" },
1427
+ { name: "preVerificationGas", type: "uint256" },
1428
+ { name: "gasFees", type: "bytes32" },
1429
+ { name: "paymasterAndData", type: "bytes" },
1430
+ { name: "signature", type: "bytes" }
1431
+ ],
1432
+ name: "userOp",
1433
+ type: "tuple"
1434
+ },
1435
+ { name: "userOpHash", type: "bytes32" },
1436
+ { name: "missingAccountFunds", type: "uint256" }
1437
+ ],
1438
+ name: "validateUserOp",
1439
+ outputs: [{ name: "validationData", type: "uint256" }],
1440
+ stateMutability: "nonpayable",
1441
+ type: "function"
1442
+ },
1443
+ {
1444
+ inputs: [
1445
+ { name: "dest", type: "address" },
1446
+ { name: "value", type: "uint256" },
1447
+ { name: "func", type: "bytes" }
1448
+ ],
1449
+ name: "execute",
1450
+ outputs: [],
1451
+ stateMutability: "nonpayable",
1452
+ type: "function"
1453
+ },
1454
+ {
1455
+ inputs: [
1456
+ { name: "dest", type: "address[]" },
1457
+ { name: "value", type: "uint256[]" },
1458
+ { name: "func", type: "bytes[]" }
1459
+ ],
1460
+ name: "executeBatch",
1461
+ outputs: [],
1462
+ stateMutability: "nonpayable",
1463
+ type: "function"
1464
+ }
1465
+ ];
1466
+ var BUNDLER_METHODS = {
1467
+ sendUserOperation: "eth_sendUserOperation",
1468
+ estimateUserOperationGas: "eth_estimateUserOperationGas",
1469
+ getUserOperationByHash: "eth_getUserOperationByHash",
1470
+ getUserOperationReceipt: "eth_getUserOperationReceipt",
1471
+ supportedEntryPoints: "eth_supportedEntryPoints",
1472
+ chainId: "eth_chainId"
1473
+ };
1474
+ var PaymasterType = /* @__PURE__ */ ((PaymasterType2) => {
1475
+ PaymasterType2["None"] = "none";
1476
+ PaymasterType2["Verifying"] = "verifying";
1477
+ PaymasterType2["Token"] = "token";
1478
+ PaymasterType2["Sponsoring"] = "sponsoring";
1479
+ return PaymasterType2;
1480
+ })(PaymasterType || {});
1481
+ function packAccountGasLimits(verificationGasLimit, callGasLimit) {
1482
+ const verificationHex = verificationGasLimit.toString(16).padStart(32, "0");
1483
+ const callHex = callGasLimit.toString(16).padStart(32, "0");
1484
+ return `0x${verificationHex}${callHex}`;
1485
+ }
1486
+ function unpackAccountGasLimits(packed) {
1487
+ const hex = packed.slice(2);
1488
+ const verificationHex = hex.slice(0, 32);
1489
+ const callHex = hex.slice(32, 64);
1490
+ return {
1491
+ verificationGasLimit: BigInt("0x" + verificationHex),
1492
+ callGasLimit: BigInt("0x" + callHex)
1493
+ };
1494
+ }
1495
+ function packGasFees(maxPriorityFeePerGas, maxFeePerGas) {
1496
+ const priorityHex = maxPriorityFeePerGas.toString(16).padStart(32, "0");
1497
+ const maxHex = maxFeePerGas.toString(16).padStart(32, "0");
1498
+ return `0x${priorityHex}${maxHex}`;
1499
+ }
1500
+ function unpackGasFees(packed) {
1501
+ const hex = packed.slice(2);
1502
+ const priorityHex = hex.slice(0, 32);
1503
+ const maxHex = hex.slice(32, 64);
1504
+ return {
1505
+ maxPriorityFeePerGas: BigInt("0x" + priorityHex),
1506
+ maxFeePerGas: BigInt("0x" + maxHex)
1507
+ };
1508
+ }
1509
+
1510
+ // src/erc4337/builder.ts
1511
+ var import_viem5 = require("viem");
1512
+ var UserOpBuilder = class {
1513
+ constructor(options = {}) {
1514
+ this.entryPoint = options.entryPoint ?? ENTRYPOINT_V07_ADDRESS;
1515
+ this.gasMultiplier = options.gasMultiplier ?? 1.2;
1516
+ }
1517
+ /**
1518
+ * Build a UserOperation from a transaction intent
1519
+ */
1520
+ async buildUserOp(signer, intent, client, gasEstimate, paymaster) {
1521
+ const sender = await signer.getAddress();
1522
+ const nonce = await this.getNonce(client, sender);
1523
+ const isDeployed = await signer.isDeployed();
1524
+ const initCode = isDeployed ? "0x" : await signer.getInitCode();
1525
+ const callData = signer.encodeExecute(
1526
+ intent.to,
1527
+ intent.value ?? 0n,
1528
+ intent.data ?? "0x"
1529
+ );
1530
+ const { maxFeePerGas, maxPriorityFeePerGas } = await this.getGasPrices(client);
1531
+ const gas = gasEstimate ?? DEFAULT_GAS_LIMITS;
1532
+ const verificationGasLimit = this.applyMultiplier(gas.verificationGasLimit);
1533
+ const callGasLimit = this.applyMultiplier(gas.callGasLimit);
1534
+ const preVerificationGas = this.applyMultiplier(gas.preVerificationGas);
1535
+ const paymasterAndData = paymaster ? this.encodePaymasterData(paymaster) : "0x";
1536
+ return {
1537
+ sender,
1538
+ nonce,
1539
+ initCode,
1540
+ callData,
1541
+ verificationGasLimit,
1542
+ callGasLimit,
1543
+ preVerificationGas,
1544
+ maxPriorityFeePerGas,
1545
+ maxFeePerGas,
1546
+ paymasterAndData,
1547
+ signature: "0x"
1548
+ // Will be filled after signing
1549
+ };
1550
+ }
1551
+ /**
1552
+ * Build a batch UserOperation from multiple transaction intents
1553
+ */
1554
+ async buildBatchUserOp(signer, intents, client, gasEstimate, paymaster) {
1555
+ const sender = await signer.getAddress();
1556
+ const nonce = await this.getNonce(client, sender);
1557
+ const isDeployed = await signer.isDeployed();
1558
+ const initCode = isDeployed ? "0x" : await signer.getInitCode();
1559
+ const targets = intents.map((i) => i.to);
1560
+ const values = intents.map((i) => i.value ?? 0n);
1561
+ const datas = intents.map((i) => i.data ?? "0x");
1562
+ const callData = signer.encodeExecuteBatch(targets, values, datas);
1563
+ const { maxFeePerGas, maxPriorityFeePerGas } = await this.getGasPrices(client);
1564
+ const gas = gasEstimate ?? {
1565
+ verificationGasLimit: DEFAULT_GAS_LIMITS.verificationGasLimit,
1566
+ callGasLimit: DEFAULT_GAS_LIMITS.callGasLimit * BigInt(intents.length),
1567
+ preVerificationGas: DEFAULT_GAS_LIMITS.preVerificationGas
1568
+ };
1569
+ const verificationGasLimit = this.applyMultiplier(gas.verificationGasLimit);
1570
+ const callGasLimit = this.applyMultiplier(gas.callGasLimit);
1571
+ const preVerificationGas = this.applyMultiplier(gas.preVerificationGas);
1572
+ const paymasterAndData = paymaster ? this.encodePaymasterData(paymaster) : "0x";
1573
+ return {
1574
+ sender,
1575
+ nonce,
1576
+ initCode,
1577
+ callData,
1578
+ verificationGasLimit,
1579
+ callGasLimit,
1580
+ preVerificationGas,
1581
+ maxPriorityFeePerGas,
1582
+ maxFeePerGas,
1583
+ paymasterAndData,
1584
+ signature: "0x"
1585
+ };
1586
+ }
1587
+ /**
1588
+ * Pack a UserOperation for on-chain submission (v0.7 format)
1589
+ */
1590
+ packUserOp(userOp) {
1591
+ return {
1592
+ sender: userOp.sender,
1593
+ nonce: userOp.nonce,
1594
+ initCode: userOp.initCode,
1595
+ callData: userOp.callData,
1596
+ accountGasLimits: packAccountGasLimits(
1597
+ userOp.verificationGasLimit,
1598
+ userOp.callGasLimit
1599
+ ),
1600
+ preVerificationGas: userOp.preVerificationGas,
1601
+ gasFees: packGasFees(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas),
1602
+ paymasterAndData: userOp.paymasterAndData,
1603
+ signature: userOp.signature
1604
+ };
1605
+ }
1606
+ /**
1607
+ * Compute the UserOperation hash for signing
1608
+ */
1609
+ async getUserOpHash(userOp, client, chainId) {
1610
+ const packed = this.packUserOp(userOp);
1611
+ const userOpTuple = {
1612
+ sender: packed.sender,
1613
+ nonce: packed.nonce,
1614
+ initCode: packed.initCode,
1615
+ callData: packed.callData,
1616
+ accountGasLimits: packed.accountGasLimits,
1617
+ preVerificationGas: packed.preVerificationGas,
1618
+ gasFees: packed.gasFees,
1619
+ paymasterAndData: packed.paymasterAndData,
1620
+ signature: packed.signature
1621
+ };
1622
+ const hash = await client.readContract({
1623
+ address: this.entryPoint,
1624
+ abi: ENTRYPOINT_V07_ABI,
1625
+ functionName: "getUserOpHash",
1626
+ args: [userOpTuple]
1627
+ });
1628
+ return hash;
1629
+ }
1630
+ /**
1631
+ * Sign a UserOperation
1632
+ */
1633
+ async signUserOp(userOp, signer, client, chainId) {
1634
+ const userOpHash = await this.getUserOpHash(userOp, client, chainId);
1635
+ const signature = await signer.signUserOpHash(userOpHash);
1636
+ return {
1637
+ ...userOp,
1638
+ signature
1639
+ };
1640
+ }
1641
+ /**
1642
+ * Get the nonce for an account from EntryPoint
1643
+ */
1644
+ async getNonce(client, sender) {
1645
+ try {
1646
+ const nonce = await client.readContract({
1647
+ address: this.entryPoint,
1648
+ abi: ENTRYPOINT_V07_ABI,
1649
+ functionName: "getNonce",
1650
+ args: [sender, 0n]
1651
+ // Use key 0 for default nonce space
1652
+ });
1653
+ return nonce;
1654
+ } catch {
1655
+ return 0n;
1656
+ }
1657
+ }
1658
+ /**
1659
+ * Get current gas prices from the chain
1660
+ */
1661
+ async getGasPrices(client) {
1662
+ const block = await client.getBlock({ blockTag: "latest" });
1663
+ const baseFee = block.baseFeePerGas ?? 0n;
1664
+ const maxPriorityFeePerGas = 1500000000n;
1665
+ const maxFeePerGas = baseFee * 2n + maxPriorityFeePerGas;
1666
+ return { maxFeePerGas, maxPriorityFeePerGas };
1667
+ }
1668
+ /**
1669
+ * Apply gas multiplier for safety margin
1670
+ */
1671
+ applyMultiplier(gas) {
1672
+ return BigInt(Math.ceil(Number(gas) * this.gasMultiplier));
1673
+ }
1674
+ /**
1675
+ * Encode paymaster data for the UserOperation
1676
+ */
1677
+ encodePaymasterData(paymaster) {
1678
+ const paymasterAddress = paymaster.paymaster;
1679
+ const verificationGas = (0, import_viem5.pad)((0, import_viem5.toHex)(paymaster.paymasterVerificationGasLimit), {
1680
+ size: 16
1681
+ });
1682
+ const postOpGas = (0, import_viem5.pad)((0, import_viem5.toHex)(paymaster.paymasterPostOpGasLimit), { size: 16 });
1683
+ return (0, import_viem5.concat)([
1684
+ paymasterAddress,
1685
+ verificationGas,
1686
+ postOpGas,
1687
+ paymaster.paymasterData
1688
+ ]);
1689
+ }
1690
+ };
1691
+ function createUserOpBuilder(options) {
1692
+ return new UserOpBuilder(options);
1693
+ }
1694
+
1695
+ // src/erc4337/bundler.ts
1696
+ var BundlerError = class extends Error {
1697
+ constructor(message, code, data) {
1698
+ super(message);
1699
+ this.code = code;
1700
+ this.data = data;
1701
+ this.name = "BundlerError";
1702
+ }
1703
+ };
1704
+ var BundlerClient = class {
1705
+ constructor(config) {
1706
+ this.requestId = 0;
1707
+ this.bundlerUrl = config.bundlerUrl;
1708
+ this.entryPoint = config.entryPoint ?? ENTRYPOINT_V07_ADDRESS;
1709
+ this.chainId = config.chainId;
1710
+ }
1711
+ /**
1712
+ * Send a UserOperation to the bundler
1713
+ */
1714
+ async sendUserOperation(userOp) {
1715
+ const packed = this.packForRpc(userOp);
1716
+ const userOpHash = await this.rpcCall(
1717
+ BUNDLER_METHODS.sendUserOperation,
1718
+ [packed, this.entryPoint]
1719
+ );
1720
+ return {
1721
+ userOpHash,
1722
+ wait: () => this.waitForReceipt(userOpHash)
1723
+ };
1724
+ }
1725
+ /**
1726
+ * Estimate gas for a UserOperation
1727
+ */
1728
+ async estimateUserOperationGas(userOp) {
1729
+ const estimationOp = {
1730
+ sender: userOp.sender,
1731
+ nonce: userOp.nonce ?? 0n,
1732
+ initCode: userOp.initCode ?? "0x",
1733
+ callData: userOp.callData,
1734
+ verificationGasLimit: userOp.verificationGasLimit ?? 1000000n,
1735
+ callGasLimit: userOp.callGasLimit ?? 1000000n,
1736
+ preVerificationGas: userOp.preVerificationGas ?? 100000n,
1737
+ maxPriorityFeePerGas: userOp.maxPriorityFeePerGas ?? 1000000000n,
1738
+ maxFeePerGas: userOp.maxFeePerGas ?? 10000000000n,
1739
+ paymasterAndData: userOp.paymasterAndData ?? "0x",
1740
+ signature: userOp.signature ?? // Dummy signature for estimation
1741
+ "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
1742
+ };
1743
+ const packed = this.packForRpc(estimationOp);
1744
+ const result = await this.rpcCall(BUNDLER_METHODS.estimateUserOperationGas, [packed, this.entryPoint]);
1745
+ return {
1746
+ verificationGasLimit: BigInt(result.verificationGasLimit),
1747
+ callGasLimit: BigInt(result.callGasLimit),
1748
+ preVerificationGas: BigInt(result.preVerificationGas),
1749
+ paymasterVerificationGasLimit: result.paymasterVerificationGasLimit ? BigInt(result.paymasterVerificationGasLimit) : void 0,
1750
+ paymasterPostOpGasLimit: result.paymasterPostOpGasLimit ? BigInt(result.paymasterPostOpGasLimit) : void 0
1751
+ };
1752
+ }
1753
+ /**
1754
+ * Get UserOperation by hash
1755
+ */
1756
+ async getUserOperationByHash(userOpHash) {
1757
+ const result = await this.rpcCall(BUNDLER_METHODS.getUserOperationByHash, [userOpHash]);
1758
+ return result;
1759
+ }
1760
+ /**
1761
+ * Get UserOperation receipt
1762
+ */
1763
+ async getUserOperationReceipt(userOpHash) {
1764
+ const result = await this.rpcCall(BUNDLER_METHODS.getUserOperationReceipt, [userOpHash]);
1765
+ if (!result) return null;
1766
+ return {
1767
+ userOpHash: result.userOpHash,
1768
+ sender: result.sender,
1769
+ nonce: BigInt(result.nonce),
1770
+ paymaster: result.paymaster,
1771
+ actualGasCost: BigInt(result.actualGasCost),
1772
+ actualGasUsed: BigInt(result.actualGasUsed),
1773
+ success: result.success,
1774
+ reason: result.reason,
1775
+ receipt: {
1776
+ transactionHash: result.receipt.transactionHash,
1777
+ blockNumber: BigInt(result.receipt.blockNumber),
1778
+ blockHash: result.receipt.blockHash
1779
+ }
1780
+ };
1781
+ }
1782
+ /**
1783
+ * Get supported EntryPoints
1784
+ */
1785
+ async getSupportedEntryPoints() {
1786
+ return this.rpcCall(BUNDLER_METHODS.supportedEntryPoints, []);
1787
+ }
1788
+ /**
1789
+ * Get chain ID from bundler
1790
+ */
1791
+ async getChainId() {
1792
+ const result = await this.rpcCall(BUNDLER_METHODS.chainId, []);
1793
+ return Number(result);
1794
+ }
1795
+ /**
1796
+ * Wait for UserOperation receipt with polling
1797
+ */
1798
+ async waitForReceipt(userOpHash, options = {}) {
1799
+ const timeout = options.timeout ?? 6e4;
1800
+ const pollingInterval = options.pollingInterval ?? 2e3;
1801
+ const startTime = Date.now();
1802
+ while (Date.now() - startTime < timeout) {
1803
+ const receipt = await this.getUserOperationReceipt(userOpHash);
1804
+ if (receipt) {
1805
+ return receipt;
1806
+ }
1807
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
1808
+ }
1809
+ throw new BundlerError(
1810
+ `Timeout waiting for UserOperation receipt: ${userOpHash}`
1811
+ );
1812
+ }
1813
+ /**
1814
+ * Pack UserOperation for RPC (convert bigints to hex strings)
1815
+ */
1816
+ packForRpc(userOp) {
1817
+ return {
1818
+ sender: userOp.sender,
1819
+ nonce: this.toHex(userOp.nonce),
1820
+ initCode: userOp.initCode,
1821
+ callData: userOp.callData,
1822
+ accountGasLimits: packAccountGasLimits(
1823
+ userOp.verificationGasLimit,
1824
+ userOp.callGasLimit
1825
+ ),
1826
+ preVerificationGas: this.toHex(userOp.preVerificationGas),
1827
+ gasFees: packGasFees(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas),
1828
+ paymasterAndData: userOp.paymasterAndData,
1829
+ signature: userOp.signature
1830
+ };
1831
+ }
1832
+ /**
1833
+ * Convert bigint to hex string
1834
+ */
1835
+ toHex(value) {
1836
+ return `0x${value.toString(16)}`;
1837
+ }
1838
+ /**
1839
+ * Make a JSON-RPC call to the bundler
1840
+ */
1841
+ async rpcCall(method, params) {
1842
+ const request = {
1843
+ jsonrpc: "2.0",
1844
+ id: ++this.requestId,
1845
+ method,
1846
+ params
1847
+ };
1848
+ const response = await fetch(this.bundlerUrl, {
1849
+ method: "POST",
1850
+ headers: {
1851
+ "Content-Type": "application/json"
1852
+ },
1853
+ body: JSON.stringify(request)
1854
+ });
1855
+ if (!response.ok) {
1856
+ throw new BundlerError(
1857
+ `HTTP error: ${response.status} ${response.statusText}`
1858
+ );
1859
+ }
1860
+ const json = await response.json();
1861
+ if (json.error) {
1862
+ throw new BundlerError(json.error.message, json.error.code, json.error.data);
1863
+ }
1864
+ return json.result;
1865
+ }
1866
+ };
1867
+ function createBundlerClient(config) {
1868
+ return new BundlerClient(config);
1869
+ }
1870
+
1871
+ // src/erc4337/paymaster.ts
1872
+ var import_viem6 = require("viem");
1873
+ var PaymasterClient = class {
1874
+ constructor(config) {
1875
+ this.config = config;
1876
+ }
1877
+ /**
1878
+ * Get paymaster data for a UserOperation
1879
+ */
1880
+ async getPaymasterData(userOp, chainId, entryPoint, context) {
1881
+ switch (this.config.type) {
1882
+ case "verifying":
1883
+ return this.getVerifyingPaymasterData(userOp, chainId, entryPoint);
1884
+ case "sponsoring":
1885
+ return this.getSponsoringPaymasterData(
1886
+ userOp,
1887
+ chainId,
1888
+ entryPoint,
1889
+ context
1890
+ );
1891
+ case "token":
1892
+ return this.getTokenPaymasterData(userOp, chainId, entryPoint);
1893
+ default:
1894
+ throw new Error(`Unknown paymaster type: ${this.config.type}`);
1895
+ }
1896
+ }
1897
+ /**
1898
+ * Get gas estimates including paymaster gas
1899
+ */
1900
+ async estimatePaymasterGas(userOp, _chainId) {
1901
+ return {
1902
+ verificationGasLimit: DEFAULT_GAS_LIMITS.verificationGasLimit,
1903
+ callGasLimit: DEFAULT_GAS_LIMITS.callGasLimit,
1904
+ preVerificationGas: DEFAULT_GAS_LIMITS.preVerificationGas,
1905
+ paymasterVerificationGasLimit: DEFAULT_GAS_LIMITS.paymasterVerificationGasLimit,
1906
+ paymasterPostOpGasLimit: DEFAULT_GAS_LIMITS.paymasterPostOpGasLimit
1907
+ };
1908
+ }
1909
+ /**
1910
+ * Check if the paymaster will sponsor this operation
1911
+ */
1912
+ async willSponsor(userOp, chainId, entryPoint, context) {
1913
+ if (!this.config.url) {
1914
+ return true;
1915
+ }
1916
+ try {
1917
+ const response = await fetch(`${this.config.url}/check`, {
1918
+ method: "POST",
1919
+ headers: { "Content-Type": "application/json" },
1920
+ body: JSON.stringify({
1921
+ userOp: this.serializeUserOp(userOp),
1922
+ chainId,
1923
+ entryPoint,
1924
+ context
1925
+ })
1926
+ });
1927
+ if (!response.ok) return false;
1928
+ const result = await response.json();
1929
+ return result.willSponsor;
1930
+ } catch {
1931
+ return false;
1932
+ }
1933
+ }
1934
+ /**
1935
+ * Get verifying paymaster data (off-chain signature)
1936
+ */
1937
+ async getVerifyingPaymasterData(userOp, chainId, entryPoint) {
1938
+ if (this.config.url) {
1939
+ return this.callPaymasterService(userOp, chainId, entryPoint);
1940
+ }
1941
+ return {
1942
+ paymaster: this.config.address,
1943
+ paymasterVerificationGasLimit: DEFAULT_GAS_LIMITS.paymasterVerificationGasLimit,
1944
+ paymasterPostOpGasLimit: DEFAULT_GAS_LIMITS.paymasterPostOpGasLimit,
1945
+ paymasterData: "0x"
1946
+ };
1947
+ }
1948
+ /**
1949
+ * Get sponsoring paymaster data (third-party pays)
1950
+ */
1951
+ async getSponsoringPaymasterData(userOp, chainId, entryPoint, context) {
1952
+ if (!this.config.url) {
1953
+ throw new Error("Sponsoring paymaster requires a service URL");
1954
+ }
1955
+ const response = await fetch(`${this.config.url}/sponsor`, {
1956
+ method: "POST",
1957
+ headers: { "Content-Type": "application/json" },
1958
+ body: JSON.stringify({
1959
+ userOp: this.serializeUserOp(userOp),
1960
+ chainId,
1961
+ entryPoint,
1962
+ context
1963
+ })
1964
+ });
1965
+ if (!response.ok) {
1966
+ const error = await response.text();
1967
+ throw new Error(`Paymaster rejected sponsorship: ${error}`);
1968
+ }
1969
+ const result = await response.json();
1970
+ return {
1971
+ paymaster: result.paymaster,
1972
+ paymasterVerificationGasLimit: result.paymasterVerificationGasLimit,
1973
+ paymasterPostOpGasLimit: result.paymasterPostOpGasLimit,
1974
+ paymasterData: result.paymasterData
1975
+ };
1976
+ }
1977
+ /**
1978
+ * Get token paymaster data (pay gas with ERC20)
1979
+ */
1980
+ async getTokenPaymasterData(userOp, chainId, entryPoint) {
1981
+ const tokenAddress = this.config.options?.tokenAddress;
1982
+ if (!tokenAddress) {
1983
+ throw new Error("Token paymaster requires tokenAddress in options");
1984
+ }
1985
+ if (this.config.url) {
1986
+ return this.callPaymasterService(userOp, chainId, entryPoint, {
1987
+ tokenAddress
1988
+ });
1989
+ }
1990
+ return {
1991
+ paymaster: this.config.address,
1992
+ paymasterVerificationGasLimit: DEFAULT_GAS_LIMITS.paymasterVerificationGasLimit,
1993
+ paymasterPostOpGasLimit: DEFAULT_GAS_LIMITS.paymasterPostOpGasLimit,
1994
+ paymasterData: tokenAddress
1995
+ // Token address as data
1996
+ };
1997
+ }
1998
+ /**
1999
+ * Call paymaster service API
2000
+ */
2001
+ async callPaymasterService(userOp, chainId, entryPoint, context) {
2002
+ if (!this.config.url) {
2003
+ throw new Error("Paymaster service URL not configured");
2004
+ }
2005
+ const response = await fetch(`${this.config.url}/getPaymasterData`, {
2006
+ method: "POST",
2007
+ headers: { "Content-Type": "application/json" },
2008
+ body: JSON.stringify({
2009
+ userOp: this.serializeUserOp(userOp),
2010
+ chainId,
2011
+ entryPoint,
2012
+ context
2013
+ })
2014
+ });
2015
+ if (!response.ok) {
2016
+ const error = await response.text();
2017
+ throw new Error(`Paymaster service error: ${error}`);
2018
+ }
2019
+ const result = await response.json();
2020
+ return {
2021
+ paymaster: result.paymaster,
2022
+ paymasterVerificationGasLimit: BigInt(result.paymasterVerificationGasLimit),
2023
+ paymasterPostOpGasLimit: BigInt(result.paymasterPostOpGasLimit),
2024
+ paymasterData: result.paymasterData
2025
+ };
2026
+ }
2027
+ /**
2028
+ * Serialize UserOperation for API calls
2029
+ */
2030
+ serializeUserOp(userOp) {
2031
+ const result = {};
2032
+ if (userOp.sender) result.sender = userOp.sender;
2033
+ if (userOp.nonce !== void 0)
2034
+ result.nonce = `0x${userOp.nonce.toString(16)}`;
2035
+ if (userOp.initCode) result.initCode = userOp.initCode;
2036
+ if (userOp.callData) result.callData = userOp.callData;
2037
+ if (userOp.verificationGasLimit !== void 0)
2038
+ result.verificationGasLimit = `0x${userOp.verificationGasLimit.toString(16)}`;
2039
+ if (userOp.callGasLimit !== void 0)
2040
+ result.callGasLimit = `0x${userOp.callGasLimit.toString(16)}`;
2041
+ if (userOp.preVerificationGas !== void 0)
2042
+ result.preVerificationGas = `0x${userOp.preVerificationGas.toString(16)}`;
2043
+ if (userOp.maxPriorityFeePerGas !== void 0)
2044
+ result.maxPriorityFeePerGas = `0x${userOp.maxPriorityFeePerGas.toString(16)}`;
2045
+ if (userOp.maxFeePerGas !== void 0)
2046
+ result.maxFeePerGas = `0x${userOp.maxFeePerGas.toString(16)}`;
2047
+ if (userOp.paymasterAndData) result.paymasterAndData = userOp.paymasterAndData;
2048
+ if (userOp.signature) result.signature = userOp.signature;
2049
+ return result;
2050
+ }
2051
+ };
2052
+ function createPaymasterClient(config) {
2053
+ return new PaymasterClient(config);
2054
+ }
2055
+ function encodePaymasterAndData(data) {
2056
+ return (0, import_viem6.concat)([
2057
+ data.paymaster,
2058
+ (0, import_viem6.pad)((0, import_viem6.toHex)(data.paymasterVerificationGasLimit), { size: 16 }),
2059
+ (0, import_viem6.pad)((0, import_viem6.toHex)(data.paymasterPostOpGasLimit), { size: 16 }),
2060
+ data.paymasterData
2061
+ ]);
2062
+ }
2063
+ function decodePaymasterAndData(paymasterAndData) {
2064
+ if (paymasterAndData === "0x" || paymasterAndData.length < 86) {
2065
+ return null;
2066
+ }
2067
+ const paymaster = `0x${paymasterAndData.slice(2, 42)}`;
2068
+ const paymasterVerificationGasLimit = BigInt(
2069
+ `0x${paymasterAndData.slice(42, 74)}`
2070
+ );
2071
+ const paymasterPostOpGasLimit = BigInt(`0x${paymasterAndData.slice(74, 106)}`);
2072
+ const paymasterData = `0x${paymasterAndData.slice(106)}`;
2073
+ return {
2074
+ paymaster,
2075
+ paymasterVerificationGasLimit,
2076
+ paymasterPostOpGasLimit,
2077
+ paymasterData
2078
+ };
2079
+ }
2080
+
2081
+ // src/erc4337/t402.ts
2082
+ var import_viem7 = require("viem");
2083
+ var ERC20_TRANSFER_ABI = [
2084
+ {
2085
+ inputs: [
2086
+ { name: "to", type: "address" },
2087
+ { name: "amount", type: "uint256" }
2088
+ ],
2089
+ name: "transfer",
2090
+ outputs: [{ name: "", type: "bool" }],
2091
+ stateMutability: "nonpayable",
2092
+ type: "function"
2093
+ }
2094
+ ];
2095
+ var EIP3009_TRANSFER_ABI = [
2096
+ {
2097
+ inputs: [
2098
+ { name: "from", type: "address" },
2099
+ { name: "to", type: "address" },
2100
+ { name: "value", type: "uint256" },
2101
+ { name: "validAfter", type: "uint256" },
2102
+ { name: "validBefore", type: "uint256" },
2103
+ { name: "nonce", type: "bytes32" },
2104
+ { name: "v", type: "uint8" },
2105
+ { name: "r", type: "bytes32" },
2106
+ { name: "s", type: "bytes32" }
2107
+ ],
2108
+ name: "transferWithAuthorization",
2109
+ outputs: [],
2110
+ stateMutability: "nonpayable",
2111
+ type: "function"
2112
+ }
2113
+ ];
2114
+ var GaslessT402Client = class {
2115
+ constructor(config) {
2116
+ this.signer = config.signer;
2117
+ this.builder = new UserOpBuilder();
2118
+ this.bundler = new BundlerClient(config.bundler);
2119
+ this.paymaster = config.paymaster ? new PaymasterClient(config.paymaster) : void 0;
2120
+ this.chainId = config.chainId;
2121
+ this.publicClient = config.publicClient;
2122
+ }
2123
+ /**
2124
+ * Execute a T402 payment via ERC-4337
2125
+ *
2126
+ * This submits the payment as a UserOperation which can be:
2127
+ * - Sponsored by a paymaster (truly gasless)
2128
+ * - Paid from the smart account's balance
2129
+ */
2130
+ async executePayment(params) {
2131
+ const callData = params.authorization ? this.buildAuthorizedTransferCallData(params) : this.buildTransferCallData(params);
2132
+ const intent = {
2133
+ to: params.tokenAddress,
2134
+ value: 0n,
2135
+ data: callData
2136
+ };
2137
+ const gasEstimate = await this.estimateGas(intent);
2138
+ const paymasterData = await this.getPaymasterData(gasEstimate);
2139
+ const userOp = await this.builder.buildUserOp(
2140
+ this.signer,
2141
+ intent,
2142
+ this.publicClient,
2143
+ gasEstimate,
2144
+ paymasterData
2145
+ );
2146
+ const signedUserOp = await this.builder.signUserOp(
2147
+ userOp,
2148
+ this.signer,
2149
+ this.publicClient,
2150
+ this.chainId
2151
+ );
2152
+ return this.bundler.sendUserOperation(signedUserOp);
2153
+ }
2154
+ /**
2155
+ * Execute multiple T402 payments in a single UserOperation
2156
+ */
2157
+ async executeBatchPayments(payments) {
2158
+ const intents = payments.map((params) => ({
2159
+ to: params.tokenAddress,
2160
+ value: 0n,
2161
+ data: params.authorization ? this.buildAuthorizedTransferCallData(params) : this.buildTransferCallData(params)
2162
+ }));
2163
+ const gasEstimate = await this.estimateBatchGas(intents);
2164
+ const paymasterData = await this.getPaymasterData(gasEstimate);
2165
+ const userOp = await this.builder.buildBatchUserOp(
2166
+ this.signer,
2167
+ intents,
2168
+ this.publicClient,
2169
+ gasEstimate,
2170
+ paymasterData
2171
+ );
2172
+ const signedUserOp = await this.builder.signUserOp(
2173
+ userOp,
2174
+ this.signer,
2175
+ this.publicClient,
2176
+ this.chainId
2177
+ );
2178
+ return this.bundler.sendUserOperation(signedUserOp);
2179
+ }
2180
+ /**
2181
+ * Check if a payment can be sponsored (gasless)
2182
+ */
2183
+ async canSponsor(params) {
2184
+ if (!this.paymaster) return false;
2185
+ const intent = {
2186
+ to: params.tokenAddress,
2187
+ value: 0n,
2188
+ data: this.buildTransferCallData(params)
2189
+ };
2190
+ const sender = await this.signer.getAddress();
2191
+ return this.paymaster.willSponsor(
2192
+ { sender, callData: this.signer.encodeExecute(intent.to, 0n, intent.data) },
2193
+ this.chainId,
2194
+ ENTRYPOINT_V07_ADDRESS
2195
+ );
2196
+ }
2197
+ /**
2198
+ * Get the smart account address
2199
+ */
2200
+ async getAccountAddress() {
2201
+ return this.signer.getAddress();
2202
+ }
2203
+ /**
2204
+ * Check if the smart account is deployed
2205
+ */
2206
+ async isAccountDeployed() {
2207
+ return this.signer.isDeployed();
2208
+ }
2209
+ /**
2210
+ * Build call data for a simple ERC20 transfer
2211
+ */
2212
+ buildTransferCallData(params) {
2213
+ return (0, import_viem7.encodeFunctionData)({
2214
+ abi: ERC20_TRANSFER_ABI,
2215
+ functionName: "transfer",
2216
+ args: [params.to, params.amount]
2217
+ });
2218
+ }
2219
+ /**
2220
+ * Build call data for an authorized transfer (EIP-3009)
2221
+ */
2222
+ buildAuthorizedTransferCallData(params) {
2223
+ if (!params.authorization) {
2224
+ throw new Error("Authorization required for authorized transfer");
2225
+ }
2226
+ const sig = params.authorization.signature;
2227
+ const r = `0x${sig.slice(2, 66)}`;
2228
+ const s = `0x${sig.slice(66, 130)}`;
2229
+ const v = parseInt(sig.slice(130, 132), 16);
2230
+ return (0, import_viem7.encodeFunctionData)({
2231
+ abi: EIP3009_TRANSFER_ABI,
2232
+ functionName: "transferWithAuthorization",
2233
+ args: [
2234
+ params.to,
2235
+ // from (will be overwritten by smart account)
2236
+ params.to,
2237
+ params.amount,
2238
+ params.authorization.validAfter,
2239
+ params.authorization.validBefore,
2240
+ params.authorization.nonce,
2241
+ v,
2242
+ r,
2243
+ s
2244
+ ]
2245
+ });
2246
+ }
2247
+ /**
2248
+ * Estimate gas for a single transaction
2249
+ */
2250
+ async estimateGas(intent) {
2251
+ const sender = await this.signer.getAddress();
2252
+ const callData = this.signer.encodeExecute(
2253
+ intent.to,
2254
+ intent.value ?? 0n,
2255
+ intent.data ?? "0x"
2256
+ );
2257
+ try {
2258
+ return await this.bundler.estimateUserOperationGas({
2259
+ sender,
2260
+ callData
2261
+ });
2262
+ } catch {
2263
+ return {
2264
+ verificationGasLimit: 150000n,
2265
+ callGasLimit: 100000n,
2266
+ preVerificationGas: 50000n
2267
+ };
2268
+ }
2269
+ }
2270
+ /**
2271
+ * Estimate gas for a batch transaction
2272
+ */
2273
+ async estimateBatchGas(intents) {
2274
+ const sender = await this.signer.getAddress();
2275
+ const callData = this.signer.encodeExecuteBatch(
2276
+ intents.map((i) => i.to),
2277
+ intents.map((i) => i.value ?? 0n),
2278
+ intents.map((i) => i.data ?? "0x")
2279
+ );
2280
+ try {
2281
+ return await this.bundler.estimateUserOperationGas({
2282
+ sender,
2283
+ callData
2284
+ });
2285
+ } catch {
2286
+ return {
2287
+ verificationGasLimit: 150000n,
2288
+ callGasLimit: 100000n * BigInt(intents.length),
2289
+ preVerificationGas: 50000n
2290
+ };
2291
+ }
2292
+ }
2293
+ /**
2294
+ * Get paymaster data if configured
2295
+ */
2296
+ async getPaymasterData(_gasEstimate) {
2297
+ if (!this.paymaster) return void 0;
2298
+ const sender = await this.signer.getAddress();
2299
+ return this.paymaster.getPaymasterData(
2300
+ { sender },
2301
+ this.chainId,
2302
+ ENTRYPOINT_V07_ADDRESS
2303
+ );
2304
+ }
2305
+ };
2306
+ function createGaslessT402Client(config) {
2307
+ return new GaslessT402Client(config);
2308
+ }
2309
+ // Annotate the CommonJS export names for ESM import in node:
2310
+ 0 && (module.exports = {
2311
+ ACCOUNT_ABI,
2312
+ BUNDLER_METHODS,
2313
+ BundlerClient,
2314
+ BundlerError,
2315
+ DEFAULT_GAS_LIMITS,
2316
+ ENTRYPOINT_V06_ADDRESS,
2317
+ ENTRYPOINT_V07_ABI,
2318
+ ENTRYPOINT_V07_ADDRESS,
2319
+ ExactEvmScheme,
2320
+ ExactLegacyEvmClientScheme,
2321
+ ExactLegacyEvmFacilitatorScheme,
2322
+ ExactLegacyEvmServerScheme,
2323
+ GaslessT402Client,
2324
+ LAYERZERO_ENDPOINT_IDS,
2325
+ LAYERZERO_ENDPOINT_V2,
2326
+ PaymasterClient,
2327
+ PaymasterType,
2328
+ TOKEN_PRIORITY,
2329
+ TOKEN_REGISTRY,
2330
+ USDC_ADDRESSES,
2331
+ USDT0_ADDRESSES,
2332
+ USDT0_OFT_ADDRESSES,
2333
+ USDT_LEGACY_ADDRESSES,
2334
+ Usdt0Bridge,
2335
+ UserOpBuilder,
2336
+ addressToBytes32,
2337
+ authorizationTypes,
2338
+ bytes32ToAddress,
2339
+ createBundlerClient,
2340
+ createGaslessT402Client,
2341
+ createPaymasterClient,
2342
+ createUsdt0Bridge,
2343
+ createUserOpBuilder,
2344
+ decodePaymasterAndData,
2345
+ eip3009ABI,
2346
+ encodePaymasterAndData,
2347
+ erc20LegacyABI,
2348
+ getBridgeableChains,
2349
+ getDefaultToken,
2350
+ getEIP712Domain,
2351
+ getEndpointId,
2352
+ getNetworkTokens,
2353
+ getNetworksForToken,
2354
+ getTokenByAddress,
2355
+ getTokenConfig,
2356
+ getUsdt0Networks,
2357
+ getUsdt0OftAddress,
2358
+ legacyAuthorizationTypes,
2359
+ packAccountGasLimits,
2360
+ packGasFees,
2361
+ supportsBridging,
2362
+ supportsEIP3009,
2363
+ toClientEvmSigner,
2364
+ toFacilitatorEvmSigner,
2365
+ unpackAccountGasLimits,
2366
+ unpackGasFees
2367
+ });
2368
+ //# sourceMappingURL=index.js.map