@t402/evm-core 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.
@@ -0,0 +1,488 @@
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
+ TOKEN_PRIORITY: () => TOKEN_PRIORITY,
24
+ TOKEN_REGISTRY: () => TOKEN_REGISTRY,
25
+ USDC_ADDRESSES: () => USDC_ADDRESSES,
26
+ USDT0_ADDRESSES: () => USDT0_ADDRESSES,
27
+ USDT_LEGACY_ADDRESSES: () => USDT_LEGACY_ADDRESSES,
28
+ authorizationTypes: () => authorizationTypes,
29
+ bytesToHex: () => bytesToHex,
30
+ createNonce: () => createNonce,
31
+ eip3009ABI: () => eip3009ABI,
32
+ erc20LegacyABI: () => erc20LegacyABI,
33
+ getDefaultToken: () => getDefaultToken,
34
+ getEIP712Domain: () => getEIP712Domain,
35
+ getEvmChainId: () => getEvmChainId,
36
+ getNetworkTokens: () => getNetworkTokens,
37
+ getNetworksForToken: () => getNetworksForToken,
38
+ getTokenByAddress: () => getTokenByAddress,
39
+ getTokenConfig: () => getTokenConfig,
40
+ getUsdt0Networks: () => getUsdt0Networks,
41
+ hexToBytes: () => hexToBytes,
42
+ isUptoEIP2612Payload: () => isUptoEIP2612Payload,
43
+ legacyAuthorizationTypes: () => legacyAuthorizationTypes,
44
+ permitTypes: () => permitTypes,
45
+ supportsEIP3009: () => supportsEIP3009,
46
+ toClientEvmSigner: () => toClientEvmSigner,
47
+ toFacilitatorEvmSigner: () => toFacilitatorEvmSigner
48
+ });
49
+ module.exports = __toCommonJS(src_exports);
50
+
51
+ // src/primitives.ts
52
+ function bytesToHex(bytes) {
53
+ let hex = "0x";
54
+ for (let i = 0; i < bytes.length; i++) {
55
+ hex += bytes[i].toString(16).padStart(2, "0");
56
+ }
57
+ return hex;
58
+ }
59
+ function hexToBytes(hex) {
60
+ const stripped = hex.startsWith("0x") ? hex.slice(2) : hex;
61
+ const bytes = new Uint8Array(stripped.length / 2);
62
+ for (let i = 0; i < bytes.length; i++) {
63
+ bytes[i] = parseInt(stripped.slice(i * 2, i * 2 + 2), 16);
64
+ }
65
+ return bytes;
66
+ }
67
+
68
+ // src/types.ts
69
+ var permitTypes = {
70
+ Permit: [
71
+ { name: "owner", type: "address" },
72
+ { name: "spender", type: "address" },
73
+ { name: "value", type: "uint256" },
74
+ { name: "nonce", type: "uint256" },
75
+ { name: "deadline", type: "uint256" }
76
+ ]
77
+ };
78
+ function isUptoEIP2612Payload(payload) {
79
+ if (typeof payload !== "object" || payload === null) return false;
80
+ const p = payload;
81
+ return "signature" in p && "authorization" in p && "paymentNonce" in p && typeof p.authorization === "object" && p.authorization !== null && "owner" in p.authorization && "spender" in p.authorization && "value" in p.authorization && "deadline" in p.authorization && "nonce" in p.authorization;
82
+ }
83
+
84
+ // src/constants.ts
85
+ var authorizationTypes = {
86
+ TransferWithAuthorization: [
87
+ { name: "from", type: "address" },
88
+ { name: "to", type: "address" },
89
+ { name: "value", type: "uint256" },
90
+ { name: "validAfter", type: "uint256" },
91
+ { name: "validBefore", type: "uint256" },
92
+ { name: "nonce", type: "bytes32" }
93
+ ]
94
+ };
95
+ var legacyAuthorizationTypes = {
96
+ LegacyTransferAuthorization: [
97
+ { name: "from", type: "address" },
98
+ { name: "to", type: "address" },
99
+ { name: "value", type: "uint256" },
100
+ { name: "validAfter", type: "uint256" },
101
+ { name: "validBefore", type: "uint256" },
102
+ { name: "nonce", type: "bytes32" },
103
+ { name: "spender", type: "address" }
104
+ ]
105
+ };
106
+ var eip3009ABI = [
107
+ {
108
+ inputs: [
109
+ { name: "from", type: "address" },
110
+ { name: "to", type: "address" },
111
+ { name: "value", type: "uint256" },
112
+ { name: "validAfter", type: "uint256" },
113
+ { name: "validBefore", type: "uint256" },
114
+ { name: "nonce", type: "bytes32" },
115
+ { name: "v", type: "uint8" },
116
+ { name: "r", type: "bytes32" },
117
+ { name: "s", type: "bytes32" }
118
+ ],
119
+ name: "transferWithAuthorization",
120
+ outputs: [],
121
+ stateMutability: "nonpayable",
122
+ type: "function"
123
+ },
124
+ {
125
+ inputs: [
126
+ { name: "from", type: "address" },
127
+ { name: "to", type: "address" },
128
+ { name: "value", type: "uint256" },
129
+ { name: "validAfter", type: "uint256" },
130
+ { name: "validBefore", type: "uint256" },
131
+ { name: "nonce", type: "bytes32" },
132
+ { name: "signature", type: "bytes" }
133
+ ],
134
+ name: "transferWithAuthorization",
135
+ outputs: [],
136
+ stateMutability: "nonpayable",
137
+ type: "function"
138
+ },
139
+ {
140
+ inputs: [{ name: "account", type: "address" }],
141
+ name: "balanceOf",
142
+ outputs: [{ name: "", type: "uint256" }],
143
+ stateMutability: "view",
144
+ type: "function"
145
+ },
146
+ {
147
+ inputs: [],
148
+ name: "version",
149
+ outputs: [{ name: "", type: "string" }],
150
+ stateMutability: "view",
151
+ type: "function"
152
+ }
153
+ ];
154
+ var erc20LegacyABI = [
155
+ {
156
+ inputs: [{ name: "account", type: "address" }],
157
+ name: "balanceOf",
158
+ outputs: [{ name: "", type: "uint256" }],
159
+ stateMutability: "view",
160
+ type: "function"
161
+ },
162
+ {
163
+ inputs: [
164
+ { name: "owner", type: "address" },
165
+ { name: "spender", type: "address" }
166
+ ],
167
+ name: "allowance",
168
+ outputs: [{ name: "", type: "uint256" }],
169
+ stateMutability: "view",
170
+ type: "function"
171
+ },
172
+ {
173
+ inputs: [
174
+ { name: "spender", type: "address" },
175
+ { name: "amount", type: "uint256" }
176
+ ],
177
+ name: "approve",
178
+ outputs: [{ name: "", type: "bool" }],
179
+ stateMutability: "nonpayable",
180
+ type: "function"
181
+ },
182
+ {
183
+ inputs: [
184
+ { name: "from", type: "address" },
185
+ { name: "to", type: "address" },
186
+ { name: "amount", type: "uint256" }
187
+ ],
188
+ name: "transferFrom",
189
+ outputs: [{ name: "", type: "bool" }],
190
+ stateMutability: "nonpayable",
191
+ type: "function"
192
+ }
193
+ ];
194
+
195
+ // src/signer.ts
196
+ function toClientEvmSigner(signer) {
197
+ return signer;
198
+ }
199
+ function toFacilitatorEvmSigner(client) {
200
+ return {
201
+ ...client,
202
+ getAddresses: () => [client.address]
203
+ };
204
+ }
205
+
206
+ // src/tokens.ts
207
+ var USDT0_ADDRESSES = {
208
+ // Ethereum Mainnet - OFT Adapter (bridge endpoint)
209
+ "eip155:1": "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee",
210
+ // Arbitrum One - Native USDT0
211
+ "eip155:42161": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
212
+ // Ink Mainnet
213
+ "eip155:57073": "0x0200C29006150606B650577BBE7B6248F58470c1",
214
+ // Berachain Mainnet
215
+ "eip155:80094": "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
216
+ // Unichain Mainnet
217
+ "eip155:130": "0x588ce4F028D8e7B53B687865d6A67b3A54C75518"
218
+ };
219
+ var USDC_ADDRESSES = {
220
+ // Ethereum Mainnet
221
+ "eip155:1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
222
+ // Base Mainnet
223
+ "eip155:8453": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
224
+ // Base Sepolia (testnet)
225
+ "eip155:84532": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
226
+ // Sepolia (testnet)
227
+ "eip155:11155111": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
228
+ // Arbitrum One
229
+ "eip155:42161": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
230
+ // Polygon Mainnet
231
+ "eip155:137": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
232
+ };
233
+ var USDT_LEGACY_ADDRESSES = {
234
+ // Ethereum Mainnet
235
+ "eip155:1": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
236
+ // Polygon Mainnet
237
+ "eip155:137": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
238
+ };
239
+ var TOKEN_REGISTRY = {
240
+ // Ethereum Mainnet
241
+ "eip155:1": {
242
+ USDT0: {
243
+ address: USDT0_ADDRESSES["eip155:1"],
244
+ symbol: "USDT0",
245
+ name: "TetherToken",
246
+ version: "1",
247
+ decimals: 6,
248
+ tokenType: "eip3009",
249
+ priority: 1
250
+ },
251
+ USDC: {
252
+ address: USDC_ADDRESSES["eip155:1"],
253
+ symbol: "USDC",
254
+ name: "USD Coin",
255
+ version: "2",
256
+ decimals: 6,
257
+ tokenType: "eip3009",
258
+ priority: 2
259
+ },
260
+ USDT: {
261
+ address: USDT_LEGACY_ADDRESSES["eip155:1"],
262
+ symbol: "USDT",
263
+ name: "TetherUSD",
264
+ version: "1",
265
+ decimals: 6,
266
+ tokenType: "legacy",
267
+ priority: 10
268
+ // Lower priority due to legacy flow
269
+ }
270
+ },
271
+ // Arbitrum One
272
+ "eip155:42161": {
273
+ USDT0: {
274
+ address: USDT0_ADDRESSES["eip155:42161"],
275
+ symbol: "USDT0",
276
+ name: "TetherToken",
277
+ version: "1",
278
+ decimals: 6,
279
+ tokenType: "eip3009",
280
+ priority: 1
281
+ },
282
+ USDC: {
283
+ address: USDC_ADDRESSES["eip155:42161"],
284
+ symbol: "USDC",
285
+ name: "USD Coin",
286
+ version: "2",
287
+ decimals: 6,
288
+ tokenType: "eip3009",
289
+ priority: 2
290
+ }
291
+ },
292
+ // Ink Mainnet
293
+ "eip155:57073": {
294
+ USDT0: {
295
+ address: USDT0_ADDRESSES["eip155:57073"],
296
+ symbol: "USDT0",
297
+ name: "TetherToken",
298
+ version: "1",
299
+ decimals: 6,
300
+ tokenType: "eip3009",
301
+ priority: 1
302
+ }
303
+ },
304
+ // Berachain Mainnet
305
+ "eip155:80094": {
306
+ USDT0: {
307
+ address: USDT0_ADDRESSES["eip155:80094"],
308
+ symbol: "USDT0",
309
+ name: "TetherToken",
310
+ version: "1",
311
+ decimals: 6,
312
+ tokenType: "eip3009",
313
+ priority: 1
314
+ }
315
+ },
316
+ // Unichain Mainnet
317
+ "eip155:130": {
318
+ USDT0: {
319
+ address: USDT0_ADDRESSES["eip155:130"],
320
+ symbol: "USDT0",
321
+ name: "TetherToken",
322
+ version: "1",
323
+ decimals: 6,
324
+ tokenType: "eip3009",
325
+ priority: 1
326
+ }
327
+ },
328
+ // Base Mainnet
329
+ "eip155:8453": {
330
+ USDC: {
331
+ address: USDC_ADDRESSES["eip155:8453"],
332
+ symbol: "USDC",
333
+ name: "USD Coin",
334
+ version: "2",
335
+ decimals: 6,
336
+ tokenType: "eip3009",
337
+ priority: 2
338
+ }
339
+ },
340
+ // Base Sepolia (testnet)
341
+ "eip155:84532": {
342
+ USDC: {
343
+ address: USDC_ADDRESSES["eip155:84532"],
344
+ symbol: "USDC",
345
+ name: "USDC",
346
+ version: "2",
347
+ decimals: 6,
348
+ tokenType: "eip3009",
349
+ priority: 2
350
+ }
351
+ },
352
+ // Sepolia (testnet)
353
+ "eip155:11155111": {
354
+ USDC: {
355
+ address: USDC_ADDRESSES["eip155:11155111"],
356
+ symbol: "USDC",
357
+ name: "USDC",
358
+ version: "2",
359
+ decimals: 6,
360
+ tokenType: "eip3009",
361
+ priority: 2
362
+ }
363
+ },
364
+ // Polygon Mainnet
365
+ "eip155:137": {
366
+ USDC: {
367
+ address: USDC_ADDRESSES["eip155:137"],
368
+ symbol: "USDC",
369
+ name: "USD Coin",
370
+ version: "2",
371
+ decimals: 6,
372
+ tokenType: "eip3009",
373
+ priority: 2
374
+ },
375
+ USDT: {
376
+ address: USDT_LEGACY_ADDRESSES["eip155:137"],
377
+ symbol: "USDT",
378
+ name: "TetherUSD",
379
+ version: "1",
380
+ decimals: 6,
381
+ tokenType: "legacy",
382
+ priority: 10
383
+ }
384
+ }
385
+ };
386
+ var TOKEN_PRIORITY = {
387
+ USDT0: 1,
388
+ // Highest priority - gasless, cross-chain
389
+ USDC: 2,
390
+ // Second - wide support, EIP-3009
391
+ USDT: 10,
392
+ // Lower - requires approval transaction
393
+ DAI: 5
394
+ // Medium - good support
395
+ };
396
+ function getTokenConfig(network, symbol) {
397
+ return TOKEN_REGISTRY[network]?.[symbol.toUpperCase()];
398
+ }
399
+ function getNetworkTokens(network) {
400
+ const tokens = TOKEN_REGISTRY[network];
401
+ if (!tokens) return [];
402
+ return Object.values(tokens).sort((a, b) => a.priority - b.priority);
403
+ }
404
+ function getDefaultToken(network) {
405
+ const tokens = getNetworkTokens(network);
406
+ return tokens[0];
407
+ }
408
+ function getTokenByAddress(network, address) {
409
+ const tokens = TOKEN_REGISTRY[network];
410
+ if (!tokens) return void 0;
411
+ const lowerAddress = address.toLowerCase();
412
+ return Object.values(tokens).find((t) => t.address.toLowerCase() === lowerAddress);
413
+ }
414
+ function supportsEIP3009(network, symbol) {
415
+ const config = getTokenConfig(network, symbol);
416
+ return config?.tokenType === "eip3009";
417
+ }
418
+ function getNetworksForToken(symbol) {
419
+ const networks = [];
420
+ for (const [network, tokens] of Object.entries(TOKEN_REGISTRY)) {
421
+ if (tokens[symbol.toUpperCase()]) {
422
+ networks.push(network);
423
+ }
424
+ }
425
+ return networks;
426
+ }
427
+ function getUsdt0Networks() {
428
+ return getNetworksForToken("USDT0");
429
+ }
430
+ function getEIP712Domain(network, tokenAddress, chainId) {
431
+ const token = getTokenByAddress(network, tokenAddress);
432
+ if (!token) return void 0;
433
+ return {
434
+ name: token.name,
435
+ version: token.version,
436
+ chainId,
437
+ verifyingContract: token.address
438
+ };
439
+ }
440
+
441
+ // src/utils.ts
442
+ function getEvmChainId(network) {
443
+ const networkMap = {
444
+ base: 8453,
445
+ "base-sepolia": 84532,
446
+ ethereum: 1,
447
+ sepolia: 11155111,
448
+ polygon: 137,
449
+ "polygon-amoy": 80002
450
+ };
451
+ return networkMap[network] || 1;
452
+ }
453
+ function createNonce() {
454
+ const cryptoObj = globalThis.crypto;
455
+ if (!cryptoObj || !cryptoObj.getRandomValues) {
456
+ throw new Error("Crypto API not available");
457
+ }
458
+ return bytesToHex(cryptoObj.getRandomValues(new Uint8Array(32)));
459
+ }
460
+ // Annotate the CommonJS export names for ESM import in node:
461
+ 0 && (module.exports = {
462
+ TOKEN_PRIORITY,
463
+ TOKEN_REGISTRY,
464
+ USDC_ADDRESSES,
465
+ USDT0_ADDRESSES,
466
+ USDT_LEGACY_ADDRESSES,
467
+ authorizationTypes,
468
+ bytesToHex,
469
+ createNonce,
470
+ eip3009ABI,
471
+ erc20LegacyABI,
472
+ getDefaultToken,
473
+ getEIP712Domain,
474
+ getEvmChainId,
475
+ getNetworkTokens,
476
+ getNetworksForToken,
477
+ getTokenByAddress,
478
+ getTokenConfig,
479
+ getUsdt0Networks,
480
+ hexToBytes,
481
+ isUptoEIP2612Payload,
482
+ legacyAuthorizationTypes,
483
+ permitTypes,
484
+ supportsEIP3009,
485
+ toClientEvmSigner,
486
+ toFacilitatorEvmSigner
487
+ });
488
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/primitives.ts","../../src/types.ts","../../src/constants.ts","../../src/signer.ts","../../src/tokens.ts","../../src/utils.ts"],"sourcesContent":["/**\n * @t402/evm-core\n *\n * T402 EVM Core Types and Utilities\n *\n * This package provides EVM types, constants, and utilities with zero external dependencies\n * (except for @t402/core). Use this package when you want to work with T402 EVM types\n * without bundling viem.\n *\n * For full EVM functionality with viem integration, use @t402/evm instead.\n *\n * @packageDocumentation\n */\n\n// Primitive types (Address, Hex, conversion functions)\nexport * from \"./primitives\";\n\n// Payment types (ExactEIP3009Payload, UptoEIP2612Payload, etc.)\nexport * from \"./types\";\n\n// EIP-712 and ABI constants\nexport * from \"./constants\";\n\n// Signer interfaces\nexport * from \"./signer\";\n\n// Token registry and configuration\nexport * from \"./tokens\";\n\n// Utility functions\nexport * from \"./utils\";\n","/**\n * EVM Primitive Types\n *\n * These type aliases are compatible with viem's types but don't require viem as a dependency.\n * When used with viem, these types are structurally identical and fully interoperable.\n */\n\n/**\n * Ethereum address (20 bytes, checksummed or lowercase)\n * Compatible with viem's Address type\n */\nexport type Address = `0x${string}`;\n\n/**\n * Hexadecimal string\n * Compatible with viem's Hex type\n */\nexport type Hex = `0x${string}`;\n\n/**\n * Bytes32 value (32 bytes as hex)\n */\nexport type Bytes32 = `0x${string}`;\n\n/**\n * Convert a Uint8Array to a hex string\n * Standalone implementation - no viem dependency\n */\nexport function bytesToHex(bytes: Uint8Array): Hex {\n let hex = \"0x\";\n for (let i = 0; i < bytes.length; i++) {\n hex += bytes[i].toString(16).padStart(2, \"0\");\n }\n return hex as Hex;\n}\n\n/**\n * Convert a hex string to Uint8Array\n * Standalone implementation - no viem dependency\n */\nexport function hexToBytes(hex: Hex): Uint8Array {\n const stripped = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n const bytes = new Uint8Array(stripped.length / 2);\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = parseInt(stripped.slice(i * 2, i * 2 + 2), 16);\n }\n return bytes;\n}\n","/**\n * EVM Payment Types\n *\n * Type definitions for T402 EVM payment schemes.\n * These types have no external dependencies and can be used independently.\n */\n\nimport type { Address, Hex } from \"./primitives\";\n\n// ============================================================================\n// Exact Scheme Types (EIP-3009 TransferWithAuthorization)\n// ============================================================================\n\n/**\n * EIP-3009 TransferWithAuthorization payload\n */\nexport type ExactEIP3009Payload = {\n signature?: Hex;\n authorization: {\n from: Address;\n to: Address;\n value: string;\n validAfter: string;\n validBefore: string;\n nonce: Hex;\n };\n};\n\nexport type ExactEvmPayloadV1 = ExactEIP3009Payload;\nexport type ExactEvmPayloadV2 = ExactEIP3009Payload;\n\n/**\n * Payload for exact-legacy scheme (approve + transferFrom pattern)\n * Used for legacy USDT and other tokens without EIP-3009 support\n */\nexport type ExactLegacyPayload = {\n signature?: Hex;\n authorization: {\n /** Payer address */\n from: Address;\n /** Recipient address */\n to: Address;\n /** Payment amount in token units */\n value: string;\n /** Unix timestamp after which the authorization is valid */\n validAfter: string;\n /** Unix timestamp before which the authorization is valid */\n validBefore: string;\n /** Unique nonce to prevent replay attacks */\n nonce: Hex;\n /** Facilitator address that will call transferFrom */\n spender: Address;\n };\n};\n\n// ============================================================================\n// Up-To Scheme Types (EIP-2612 Permit)\n// ============================================================================\n\n/**\n * EIP-2612 Permit signature components\n */\nexport type PermitSignature = {\n v: number;\n r: Hex;\n s: Hex;\n};\n\n/**\n * EIP-2612 Permit authorization parameters\n */\nexport type PermitAuthorization = {\n /** Token owner address */\n owner: Address;\n /** Spender address (router contract or facilitator) */\n spender: Address;\n /** Maximum authorized value */\n value: string;\n /** Permit deadline (unix timestamp) */\n deadline: string;\n /** Permit nonce from token contract */\n nonce: number;\n};\n\n/**\n * Payload for upto scheme using EIP-2612 Permit\n */\nexport type UptoEIP2612Payload = {\n /** EIP-2612 permit signature */\n signature: PermitSignature;\n /** Permit authorization parameters */\n authorization: PermitAuthorization;\n /** Unique payment nonce (separate from permit nonce) */\n paymentNonce: Hex;\n};\n\n/**\n * Compact payload with combined signature bytes\n */\nexport type UptoEIP2612PayloadCompact = {\n /** Combined permit signature (65 bytes) */\n signature: Hex;\n /** Permit authorization parameters */\n authorization: PermitAuthorization;\n /** Unique payment nonce */\n paymentNonce: Hex;\n};\n\nexport type UptoEvmPayloadV2 = UptoEIP2612Payload | UptoEIP2612PayloadCompact;\n\n/**\n * Extra fields for upto scheme requirements on EVM\n */\nexport type UptoEvmExtra = {\n /** EIP-712 domain name (from token contract) */\n name: string;\n /** EIP-712 domain version */\n version: string;\n /** Router contract address for settlement */\n routerAddress?: Address;\n /** Billing unit */\n unit?: string;\n /** Price per unit */\n unitPrice?: string;\n};\n\n/**\n * Settlement data for upto scheme\n */\nexport type UptoEvmSettlement = {\n /** Actual amount to settle (must be <= maxAmount) */\n settleAmount: string;\n /** Usage details for auditing */\n usageDetails?: {\n unitsConsumed?: number;\n unitPrice?: string;\n unitType?: string;\n startTime?: number;\n endTime?: number;\n };\n};\n\n/**\n * EIP-712 typed data for EIP-2612 Permit\n */\nexport const permitTypes = {\n Permit: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n} as const;\n\n/**\n * Type guard for UptoEIP2612Payload\n */\nexport function isUptoEIP2612Payload(payload: unknown): payload is UptoEIP2612Payload {\n if (typeof payload !== \"object\" || payload === null) return false;\n const p = payload as Record<string, unknown>;\n return (\n \"signature\" in p &&\n \"authorization\" in p &&\n \"paymentNonce\" in p &&\n typeof p.authorization === \"object\" &&\n p.authorization !== null &&\n \"owner\" in (p.authorization as Record<string, unknown>) &&\n \"spender\" in (p.authorization as Record<string, unknown>) &&\n \"value\" in (p.authorization as Record<string, unknown>) &&\n \"deadline\" in (p.authorization as Record<string, unknown>) &&\n \"nonce\" in (p.authorization as Record<string, unknown>)\n );\n}\n","/**\n * EVM Constants\n *\n * EIP-712 type definitions and ABI constants for T402 EVM payments.\n * No external dependencies.\n */\n\n// EIP-3009 TransferWithAuthorization types for EIP-712 signing\nexport const authorizationTypes = {\n TransferWithAuthorization: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n ],\n} as const;\n\n// Legacy transfer authorization types for EIP-712 signing\n// Used for tokens without EIP-3009 support (approve + transferFrom pattern)\nexport const legacyAuthorizationTypes = {\n LegacyTransferAuthorization: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n { name: \"spender\", type: \"address\" },\n ],\n} as const;\n\n// EIP3009 ABI for transferWithAuthorization function\nexport const eip3009ABI = [\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n { name: \"v\", type: \"uint8\" },\n { name: \"r\", type: \"bytes32\" },\n { name: \"s\", type: \"bytes32\" },\n ],\n name: \"transferWithAuthorization\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"validAfter\", type: \"uint256\" },\n { name: \"validBefore\", type: \"uint256\" },\n { name: \"nonce\", type: \"bytes32\" },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"transferWithAuthorization\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"version\",\n outputs: [{ name: \"\", type: \"string\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\n// Standard ERC20 ABI for legacy token operations (approve + transferFrom pattern)\nexport const erc20LegacyABI = [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n","/**\n * EVM Signer Types\n *\n * Type definitions for T402 EVM signers (clients and facilitators).\n * These interfaces are compatible with viem but don't require it.\n */\n\nimport type { Address, Hex } from \"./primitives\";\n\n/**\n * ClientEvmSigner - Used by T402 clients to sign payment authorizations\n *\n * This is typically a LocalAccount or wallet that holds private keys\n * and can sign EIP-712 typed data for payment authorizations.\n * Compatible with viem's LocalAccount interface.\n */\nexport type ClientEvmSigner = {\n readonly address: Address;\n signTypedData(message: {\n domain: Record<string, unknown>;\n types: Record<string, unknown>;\n primaryType: string;\n message: Record<string, unknown>;\n }): Promise<Hex>;\n};\n\n/**\n * FacilitatorEvmSigner - Used by T402 facilitators to verify and settle payments\n *\n * This is typically a viem PublicClient + WalletClient combination that can\n * read contract state, verify signatures, write transactions, and wait for receipts.\n * Compatible with viem's client interface.\n *\n * Supports multiple addresses for load balancing, key rotation, and high availability.\n */\nexport type FacilitatorEvmSigner = {\n /**\n * Get all addresses this facilitator can use for signing\n * Enables dynamic address selection for load balancing and key rotation\n */\n getAddresses(): readonly Address[];\n\n readContract(args: {\n address: Address;\n abi: readonly unknown[];\n functionName: string;\n args?: readonly unknown[];\n }): Promise<unknown>;\n\n verifyTypedData(args: {\n address: Address;\n domain: Record<string, unknown>;\n types: Record<string, unknown>;\n primaryType: string;\n message: Record<string, unknown>;\n signature: Hex;\n }): Promise<boolean>;\n\n writeContract(args: {\n address: Address;\n abi: readonly unknown[];\n functionName: string;\n args: readonly unknown[];\n }): Promise<Hex>;\n\n sendTransaction(args: { to: Address; data: Hex }): Promise<Hex>;\n\n waitForTransactionReceipt(args: { hash: Hex }): Promise<{ status: string }>;\n\n getCode(args: { address: Address }): Promise<Hex | undefined>;\n};\n\n/**\n * Converts a signer to a ClientEvmSigner\n *\n * @param signer - The signer to convert to a ClientEvmSigner\n * @returns The converted signer\n */\nexport function toClientEvmSigner(signer: ClientEvmSigner): ClientEvmSigner {\n return signer;\n}\n\n/**\n * Converts a viem client with single address to a FacilitatorEvmSigner\n * Wraps the single address in a getAddresses() function for compatibility\n *\n * @param client - The client to convert (must have 'address' property)\n * @returns FacilitatorEvmSigner with getAddresses() support\n */\nexport function toFacilitatorEvmSigner(\n client: Omit<FacilitatorEvmSigner, \"getAddresses\"> & { address: Address },\n): FacilitatorEvmSigner {\n return {\n ...client,\n getAddresses: () => [client.address],\n };\n}\n","/**\n * Token Configuration for T402 EVM Payments\n *\n * This module provides comprehensive token definitions including:\n * - USDT0 (Tether's new omnichain token with EIP-3009 support)\n * - USDC (USD Coin with EIP-3009 support)\n * - Legacy tokens configuration\n *\n * No external dependencies - uses local Address type.\n */\n\nimport type { Address } from \"./primitives\";\n\n/**\n * Token type classification for payment scheme selection\n */\nexport type TokenType = \"eip3009\" | \"legacy\";\n\n/**\n * Token configuration with EIP-712 domain parameters\n */\nexport interface TokenConfig {\n /** Token contract address */\n address: Address;\n /** Token symbol (e.g., \"USDT0\", \"USDC\") */\n symbol: string;\n /** EIP-712 domain name for signing */\n name: string;\n /** EIP-712 domain version for signing */\n version: string;\n /** Number of decimal places */\n decimals: number;\n /** Token type for scheme selection */\n tokenType: TokenType;\n /** Payment priority (lower = higher priority) */\n priority: number;\n}\n\n/**\n * Network token registry mapping network -> symbol -> config\n */\nexport type NetworkTokenRegistry = Record<string, Record<string, TokenConfig>>;\n\n/**\n * USDT0 Contract Addresses by Network\n * Source: https://docs.tether.io/usdt0/integration-guide/deployed-contracts\n *\n * USDT0 is Tether's new omnichain token using LayerZero OFT standard.\n * Key features:\n * - Supports EIP-3009 transferWithAuthorization (gasless transfers)\n * - Supports EIP-2612 permit\n * - Native cross-chain via LayerZero\n */\nexport const USDT0_ADDRESSES: Record<string, Address> = {\n // Ethereum Mainnet - OFT Adapter (bridge endpoint)\n \"eip155:1\": \"0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee\",\n // Arbitrum One - Native USDT0\n \"eip155:42161\": \"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9\",\n // Ink Mainnet\n \"eip155:57073\": \"0x0200C29006150606B650577BBE7B6248F58470c1\",\n // Berachain Mainnet\n \"eip155:80094\": \"0x779Ded0c9e1022225f8E0630b35a9b54bE713736\",\n // Unichain Mainnet\n \"eip155:130\": \"0x588ce4F028D8e7B53B687865d6A67b3A54C75518\",\n};\n\n/**\n * USDC Contract Addresses by Network\n * Native USDC with EIP-3009 support\n */\nexport const USDC_ADDRESSES: Record<string, Address> = {\n // Ethereum Mainnet\n \"eip155:1\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n // Base Mainnet\n \"eip155:8453\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n // Base Sepolia (testnet)\n \"eip155:84532\": \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n // Sepolia (testnet)\n \"eip155:11155111\": \"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238\",\n // Arbitrum One\n \"eip155:42161\": \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\",\n // Polygon Mainnet\n \"eip155:137\": \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\",\n};\n\n/**\n * Traditional USDT Addresses (Legacy - no EIP-3009 support)\n * These require the approve + transferFrom pattern\n */\nexport const USDT_LEGACY_ADDRESSES: Record<string, Address> = {\n // Ethereum Mainnet\n \"eip155:1\": \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n // Polygon Mainnet\n \"eip155:137\": \"0xc2132D05D31c914a87C6611C10748AEb04B58e8F\",\n};\n\n/**\n * Complete token registry with all supported tokens per network\n */\nexport const TOKEN_REGISTRY: NetworkTokenRegistry = {\n // Ethereum Mainnet\n \"eip155:1\": {\n USDT0: {\n address: USDT0_ADDRESSES[\"eip155:1\"],\n symbol: \"USDT0\",\n name: \"TetherToken\",\n version: \"1\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 1,\n },\n USDC: {\n address: USDC_ADDRESSES[\"eip155:1\"],\n symbol: \"USDC\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 2,\n },\n USDT: {\n address: USDT_LEGACY_ADDRESSES[\"eip155:1\"],\n symbol: \"USDT\",\n name: \"TetherUSD\",\n version: \"1\",\n decimals: 6,\n tokenType: \"legacy\",\n priority: 10, // Lower priority due to legacy flow\n },\n },\n\n // Arbitrum One\n \"eip155:42161\": {\n USDT0: {\n address: USDT0_ADDRESSES[\"eip155:42161\"],\n symbol: \"USDT0\",\n name: \"TetherToken\",\n version: \"1\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 1,\n },\n USDC: {\n address: USDC_ADDRESSES[\"eip155:42161\"],\n symbol: \"USDC\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 2,\n },\n },\n\n // Ink Mainnet\n \"eip155:57073\": {\n USDT0: {\n address: USDT0_ADDRESSES[\"eip155:57073\"],\n symbol: \"USDT0\",\n name: \"TetherToken\",\n version: \"1\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 1,\n },\n },\n\n // Berachain Mainnet\n \"eip155:80094\": {\n USDT0: {\n address: USDT0_ADDRESSES[\"eip155:80094\"],\n symbol: \"USDT0\",\n name: \"TetherToken\",\n version: \"1\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 1,\n },\n },\n\n // Unichain Mainnet\n \"eip155:130\": {\n USDT0: {\n address: USDT0_ADDRESSES[\"eip155:130\"],\n symbol: \"USDT0\",\n name: \"TetherToken\",\n version: \"1\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 1,\n },\n },\n\n // Base Mainnet\n \"eip155:8453\": {\n USDC: {\n address: USDC_ADDRESSES[\"eip155:8453\"],\n symbol: \"USDC\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 2,\n },\n },\n\n // Base Sepolia (testnet)\n \"eip155:84532\": {\n USDC: {\n address: USDC_ADDRESSES[\"eip155:84532\"],\n symbol: \"USDC\",\n name: \"USDC\",\n version: \"2\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 2,\n },\n },\n\n // Sepolia (testnet)\n \"eip155:11155111\": {\n USDC: {\n address: USDC_ADDRESSES[\"eip155:11155111\"],\n symbol: \"USDC\",\n name: \"USDC\",\n version: \"2\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 2,\n },\n },\n\n // Polygon Mainnet\n \"eip155:137\": {\n USDC: {\n address: USDC_ADDRESSES[\"eip155:137\"],\n symbol: \"USDC\",\n name: \"USD Coin\",\n version: \"2\",\n decimals: 6,\n tokenType: \"eip3009\",\n priority: 2,\n },\n USDT: {\n address: USDT_LEGACY_ADDRESSES[\"eip155:137\"],\n symbol: \"USDT\",\n name: \"TetherUSD\",\n version: \"1\",\n decimals: 6,\n tokenType: \"legacy\",\n priority: 10,\n },\n },\n};\n\n/**\n * Token priority for payment method selection\n * Lower number = higher priority\n */\nexport const TOKEN_PRIORITY: Record<string, number> = {\n USDT0: 1, // Highest priority - gasless, cross-chain\n USDC: 2, // Second - wide support, EIP-3009\n USDT: 10, // Lower - requires approval transaction\n DAI: 5, // Medium - good support\n};\n\n/**\n * Get token configuration for a specific token on a network\n */\nexport function getTokenConfig(network: string, symbol: string): TokenConfig | undefined {\n return TOKEN_REGISTRY[network]?.[symbol.toUpperCase()];\n}\n\n/**\n * Get all tokens available on a network\n */\nexport function getNetworkTokens(network: string): TokenConfig[] {\n const tokens = TOKEN_REGISTRY[network];\n if (!tokens) return [];\n return Object.values(tokens).sort((a, b) => a.priority - b.priority);\n}\n\n/**\n * Get the default/preferred token for a network\n * Prefers USDT0 > USDC > others based on priority\n */\nexport function getDefaultToken(network: string): TokenConfig | undefined {\n const tokens = getNetworkTokens(network);\n return tokens[0]; // Already sorted by priority\n}\n\n/**\n * Get token by contract address on a network\n */\nexport function getTokenByAddress(network: string, address: Address): TokenConfig | undefined {\n const tokens = TOKEN_REGISTRY[network];\n if (!tokens) return undefined;\n\n const lowerAddress = address.toLowerCase();\n return Object.values(tokens).find((t) => t.address.toLowerCase() === lowerAddress);\n}\n\n/**\n * Check if a token supports EIP-3009 (gasless transfers)\n */\nexport function supportsEIP3009(network: string, symbol: string): boolean {\n const config = getTokenConfig(network, symbol);\n return config?.tokenType === \"eip3009\";\n}\n\n/**\n * Get all networks that support a specific token\n */\nexport function getNetworksForToken(symbol: string): string[] {\n const networks: string[] = [];\n for (const [network, tokens] of Object.entries(TOKEN_REGISTRY)) {\n if (tokens[symbol.toUpperCase()]) {\n networks.push(network);\n }\n }\n return networks;\n}\n\n/**\n * Get USDT0 networks (primary T402 token)\n */\nexport function getUsdt0Networks(): string[] {\n return getNetworksForToken(\"USDT0\");\n}\n\n/**\n * EIP-712 domain configuration for a token\n */\nexport function getEIP712Domain(\n network: string,\n tokenAddress: Address,\n chainId: number,\n): { name: string; version: string; chainId: number; verifyingContract: Address } | undefined {\n const token = getTokenByAddress(network, tokenAddress);\n if (!token) return undefined;\n\n return {\n name: token.name,\n version: token.version,\n chainId,\n verifyingContract: token.address,\n };\n}\n","/**\n * EVM Utilities\n *\n * Utility functions for T402 EVM payments.\n * No external dependencies - uses local implementations.\n */\n\nimport type { Network } from \"@t402/core/types\";\nimport type { Hex } from \"./primitives\";\nimport { bytesToHex } from \"./primitives\";\n\n/**\n * Extract chain ID from network string (e.g., \"base-sepolia\" -> 84532)\n * Used by v1 implementations\n *\n * @param network - The network identifier\n * @returns The numeric chain ID\n */\nexport function getEvmChainId(network: Network): number {\n const networkMap: Record<string, number> = {\n base: 8453,\n \"base-sepolia\": 84532,\n ethereum: 1,\n sepolia: 11155111,\n polygon: 137,\n \"polygon-amoy\": 80002,\n };\n return networkMap[network] || 1;\n}\n\n/**\n * Create a random 32-byte nonce for authorization\n *\n * @returns A hex-encoded 32-byte nonce\n */\nexport function createNonce(): Hex {\n // Use globalThis.crypto which is available in both browser and Node.js 19+\n const cryptoObj = globalThis.crypto;\n\n if (!cryptoObj || !cryptoObj.getRandomValues) {\n throw new Error(\"Crypto API not available\");\n }\n\n return bytesToHex(cryptoObj.getRandomValues(new Uint8Array(32)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4BO,SAAS,WAAW,OAAwB;AACjD,MAAI,MAAM;AACV,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,WAAO,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EAC9C;AACA,SAAO;AACT;AAMO,SAAS,WAAW,KAAsB;AAC/C,QAAM,WAAW,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AACvD,QAAM,QAAQ,IAAI,WAAW,SAAS,SAAS,CAAC;AAChD,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,CAAC,IAAI,SAAS,SAAS,MAAM,IAAI,GAAG,IAA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