@t402/wdk-gasless 2.0.0-beta.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/cjs/index.d.ts +9 -37
- package/dist/cjs/index.js +31 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +9 -37
- package/dist/esm/index.mjs +31 -5
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -153,7 +153,7 @@ Check if the smart account is deployed on-chain.
|
|
|
153
153
|
| Base | 8453 | ✅ | ✅ |
|
|
154
154
|
| Optimism | 10 | ✅ | ✅ |
|
|
155
155
|
| Ink | 57073 | ✅ | - |
|
|
156
|
-
| Berachain |
|
|
156
|
+
| Berachain | 80094 | ✅ | - |
|
|
157
157
|
| Unichain | 130 | ✅ | - |
|
|
158
158
|
|
|
159
159
|
## Constants
|
|
@@ -227,6 +227,14 @@ const result = await client.pay({
|
|
|
227
227
|
})
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
+
## Related Packages
|
|
231
|
+
|
|
232
|
+
- `@t402/core` - Core protocol types and client
|
|
233
|
+
- `@t402/wdk` - Tether WDK integration
|
|
234
|
+
- `@t402/wdk-bridge` - Cross-chain LayerZero bridging
|
|
235
|
+
- `@t402/wdk-multisig` - Safe multi-sig wallets
|
|
236
|
+
- `@t402/evm` - EVM mechanism implementation
|
|
237
|
+
|
|
230
238
|
## License
|
|
231
239
|
|
|
232
240
|
Apache-2.0
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PublicClient, Address, Hex } from 'viem';
|
|
2
2
|
import { SmartAccountSigner, BundlerConfig, PaymasterConfig } from '@t402/evm';
|
|
3
3
|
export { BundlerConfig, PaymasterConfig, SmartAccountSigner, UserOperationReceipt } from '@t402/evm';
|
|
4
|
+
import { WdkAccount } from '@t402/wdk';
|
|
5
|
+
export { WdkAccount } from '@t402/wdk';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* WDK Gasless Types
|
|
@@ -9,41 +11,7 @@ export { BundlerConfig, PaymasterConfig, SmartAccountSigner, UserOperationReceip
|
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* WDK
|
|
13
|
-
*/
|
|
14
|
-
interface WdkAccount {
|
|
15
|
-
/** Get the account's address */
|
|
16
|
-
getAddress(): Promise<string>;
|
|
17
|
-
/** Get the account's native balance */
|
|
18
|
-
getBalance(): Promise<bigint>;
|
|
19
|
-
/** Get the account's token balance */
|
|
20
|
-
getTokenBalance(tokenAddress: string): Promise<bigint>;
|
|
21
|
-
/** Sign a message */
|
|
22
|
-
signMessage(message: string): Promise<string>;
|
|
23
|
-
/** Sign typed data (EIP-712) */
|
|
24
|
-
signTypedData(params: {
|
|
25
|
-
domain: {
|
|
26
|
-
name?: string;
|
|
27
|
-
version?: string;
|
|
28
|
-
chainId?: number;
|
|
29
|
-
verifyingContract?: string;
|
|
30
|
-
};
|
|
31
|
-
types: Record<string, Array<{
|
|
32
|
-
name: string;
|
|
33
|
-
type: string;
|
|
34
|
-
}>>;
|
|
35
|
-
primaryType: string;
|
|
36
|
-
message: Record<string, unknown>;
|
|
37
|
-
}): Promise<string>;
|
|
38
|
-
/** Send a transaction */
|
|
39
|
-
sendTransaction(params: {
|
|
40
|
-
to: string;
|
|
41
|
-
value?: bigint;
|
|
42
|
-
data?: string;
|
|
43
|
-
}): Promise<string>;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* WDK instance interface
|
|
14
|
+
* WDK instance interface (simplified wrapper for gasless context)
|
|
47
15
|
*/
|
|
48
16
|
interface WdkInstance {
|
|
49
17
|
/** Get accounts */
|
|
@@ -310,7 +278,7 @@ declare const SAFE_4337_ADDRESSES: {
|
|
|
310
278
|
declare class WdkSmartAccount implements SmartAccountSigner {
|
|
311
279
|
private readonly wdkAccount;
|
|
312
280
|
private readonly publicClient;
|
|
313
|
-
private readonly
|
|
281
|
+
private readonly _chainId;
|
|
314
282
|
private readonly owners;
|
|
315
283
|
private readonly threshold;
|
|
316
284
|
private readonly saltNonce;
|
|
@@ -329,6 +297,10 @@ declare class WdkSmartAccount implements SmartAccountSigner {
|
|
|
329
297
|
* Get the WDK account's EOA address
|
|
330
298
|
*/
|
|
331
299
|
getOwnerAddress(): Promise<Address>;
|
|
300
|
+
/**
|
|
301
|
+
* Get the chain ID
|
|
302
|
+
*/
|
|
303
|
+
getChainId(): number;
|
|
332
304
|
/**
|
|
333
305
|
* Get the smart account address (counterfactual)
|
|
334
306
|
*/
|
|
@@ -406,4 +378,4 @@ declare function getTokenAddress(token: 'USDT0' | 'USDC' | Address, chainName: s
|
|
|
406
378
|
*/
|
|
407
379
|
declare function getChainName(chainId: number): string;
|
|
408
380
|
|
|
409
|
-
export { type BatchPaymentParams, CHAIN_IDS, type CreateWdkGaslessClientConfig, DEFAULT_BUNDLER_URLS, type GaslessPaymentParams, type GaslessPaymentReceipt, type GaslessPaymentResult, SAFE_4337_ADDRESSES, type SponsorshipInfo, USDC_ADDRESSES, USDT0_ADDRESSES,
|
|
381
|
+
export { type BatchPaymentParams, CHAIN_IDS, type CreateWdkGaslessClientConfig, DEFAULT_BUNDLER_URLS, type GaslessPaymentParams, type GaslessPaymentReceipt, type GaslessPaymentResult, SAFE_4337_ADDRESSES, type SponsorshipInfo, USDC_ADDRESSES, USDT0_ADDRESSES, WdkGaslessClient, type WdkGaslessClientConfig, type WdkInstance, WdkSmartAccount, type WdkSmartAccountConfig, createWdkGaslessClient, createWdkSmartAccount, getChainName, getTokenAddress };
|
package/dist/cjs/index.js
CHANGED
|
@@ -134,7 +134,7 @@ var SAFE_4337_MODULE_ABI = [
|
|
|
134
134
|
var WdkSmartAccount = class {
|
|
135
135
|
wdkAccount;
|
|
136
136
|
publicClient;
|
|
137
|
-
|
|
137
|
+
_chainId;
|
|
138
138
|
owners;
|
|
139
139
|
threshold;
|
|
140
140
|
saltNonce;
|
|
@@ -146,7 +146,7 @@ var WdkSmartAccount = class {
|
|
|
146
146
|
constructor(config) {
|
|
147
147
|
this.wdkAccount = config.wdkAccount;
|
|
148
148
|
this.publicClient = config.publicClient;
|
|
149
|
-
this.
|
|
149
|
+
this._chainId = config.chainId;
|
|
150
150
|
this.threshold = config.threshold ?? 1;
|
|
151
151
|
this.saltNonce = config.saltNonce ?? 0n;
|
|
152
152
|
this.owners = config.additionalOwners ?? [];
|
|
@@ -171,6 +171,12 @@ var WdkSmartAccount = class {
|
|
|
171
171
|
await this.initialize();
|
|
172
172
|
return this.cachedOwnerAddress;
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Get the chain ID
|
|
176
|
+
*/
|
|
177
|
+
getChainId() {
|
|
178
|
+
return this._chainId;
|
|
179
|
+
}
|
|
174
180
|
/**
|
|
175
181
|
* Get the smart account address (counterfactual)
|
|
176
182
|
*/
|
|
@@ -258,10 +264,10 @@ var WdkSmartAccount = class {
|
|
|
258
264
|
if (this.deploymentChecked) {
|
|
259
265
|
return this.isAccountDeployed;
|
|
260
266
|
}
|
|
267
|
+
this.deploymentChecked = true;
|
|
261
268
|
await this.initialize();
|
|
262
269
|
const address = this.cachedAddress ?? await this.getAddress();
|
|
263
270
|
const code = await this.publicClient.getCode({ address });
|
|
264
|
-
this.deploymentChecked = true;
|
|
265
271
|
this.isAccountDeployed = code !== void 0 && code !== "0x";
|
|
266
272
|
return this.isAccountDeployed;
|
|
267
273
|
}
|
|
@@ -354,7 +360,7 @@ var USDT0_ADDRESSES = {
|
|
|
354
360
|
arbitrum: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
355
361
|
ink: "0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
356
362
|
berachain: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
|
|
357
|
-
unichain: "
|
|
363
|
+
unichain: "0x9151434b16b9763660705744891fA906F660EcC5",
|
|
358
364
|
base: "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee",
|
|
359
365
|
optimism: "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee"
|
|
360
366
|
};
|
|
@@ -372,7 +378,7 @@ var CHAIN_IDS = {
|
|
|
372
378
|
optimism: 10,
|
|
373
379
|
polygon: 137,
|
|
374
380
|
ink: 57073,
|
|
375
|
-
berachain:
|
|
381
|
+
berachain: 80094,
|
|
376
382
|
unichain: 130
|
|
377
383
|
};
|
|
378
384
|
var DEFAULT_BUNDLER_URLS = {
|
|
@@ -447,6 +453,12 @@ var WdkGaslessClient = class {
|
|
|
447
453
|
* Gas is sponsored by a paymaster if configured.
|
|
448
454
|
*/
|
|
449
455
|
async pay(params) {
|
|
456
|
+
if (!params.to || params.to === "0x0000000000000000000000000000000000000000") {
|
|
457
|
+
throw new Error("Recipient address must not be the zero address");
|
|
458
|
+
}
|
|
459
|
+
if (params.amount <= 0n) {
|
|
460
|
+
throw new Error("Payment amount must be greater than zero");
|
|
461
|
+
}
|
|
450
462
|
const token = params.token ?? "USDT0";
|
|
451
463
|
const tokenAddress = getTokenAddress(token, this.chainName);
|
|
452
464
|
const callData = (0, import_viem2.encodeFunctionData)({
|
|
@@ -502,6 +514,20 @@ var WdkGaslessClient = class {
|
|
|
502
514
|
* All payments are executed atomically.
|
|
503
515
|
*/
|
|
504
516
|
async payBatch(params) {
|
|
517
|
+
if (!params.payments || params.payments.length === 0) {
|
|
518
|
+
throw new Error("Batch payments must contain at least one payment");
|
|
519
|
+
}
|
|
520
|
+
if (params.payments.length > 50) {
|
|
521
|
+
throw new Error("Batch payments must not exceed 50 payments");
|
|
522
|
+
}
|
|
523
|
+
for (const payment of params.payments) {
|
|
524
|
+
if (!payment.to || payment.to === "0x0000000000000000000000000000000000000000") {
|
|
525
|
+
throw new Error("Recipient address must not be the zero address");
|
|
526
|
+
}
|
|
527
|
+
if (payment.amount <= 0n) {
|
|
528
|
+
throw new Error("Payment amount must be greater than zero");
|
|
529
|
+
}
|
|
530
|
+
}
|
|
505
531
|
const intents = params.payments.map((payment) => {
|
|
506
532
|
const token = payment.token ?? "USDT0";
|
|
507
533
|
const tokenAddress = getTokenAddress(token, this.chainName);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/client.ts","../../src/account.ts","../../src/constants.ts"],"sourcesContent":["/**\n * @t402/wdk-gasless\n *\n * Gasless USDT0 payments using Tether WDK and ERC-4337 Account Abstraction.\n *\n * This package enables users to send USDT0 payments without holding any ETH\n * for gas fees. It works by:\n *\n * 1. Wrapping a WDK account in a Safe smart account (ERC-4337)\n * 2. Using a paymaster to sponsor gas fees\n * 3. Submitting UserOperations through a bundler\n *\n * @example Basic usage\n * ```typescript\n * import { createWdkGaslessClient } from '@t402/wdk-gasless';\n * import { createPublicClient, http } from 'viem';\n * import { arbitrum } from 'viem/chains';\n *\n * // Create public client\n * const publicClient = createPublicClient({\n * chain: arbitrum,\n * transport: http(),\n * });\n *\n * // Create gasless client\n * const client = await createWdkGaslessClient({\n * wdkAccount: myWdkAccount,\n * publicClient,\n * chainId: 42161,\n * bundler: {\n * bundlerUrl: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * chainId: 42161,\n * },\n * paymaster: {\n * address: '0x...',\n * url: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * type: 'sponsoring',\n * },\n * });\n *\n * // Check balance\n * const balance = await client.getFormattedBalance();\n * console.log(`USDT0 Balance: ${balance}`);\n *\n * // Execute gasless payment\n * const result = await client.pay({\n * to: '0x...',\n * amount: 1000000n, // 1 USDT0 (6 decimals)\n * });\n *\n * console.log('UserOp submitted:', result.userOpHash);\n * console.log('Sponsored (free gas):', result.sponsored);\n *\n * // Wait for confirmation\n * const receipt = await result.wait();\n * console.log('Confirmed in tx:', receipt.txHash);\n * ```\n *\n * @example Batch payments\n * ```typescript\n * // Send to multiple recipients in one transaction\n * const result = await client.payBatch({\n * payments: [\n * { to: '0xAlice...', amount: 1000000n }, // 1 USDT0\n * { to: '0xBob...', amount: 2000000n }, // 2 USDT0\n * { to: '0xCharlie...', amount: 500000n }, // 0.5 USDT0\n * ],\n * });\n * ```\n *\n * @example Check sponsorship eligibility\n * ```typescript\n * const info = await client.canSponsor({\n * to: '0x...',\n * amount: 1000000n,\n * });\n *\n * if (info.canSponsor) {\n * console.log('Payment will be sponsored (free gas)');\n * } else {\n * console.log('Not sponsored:', info.reason);\n * console.log('Estimated gas cost:', info.estimatedGasCost);\n * }\n * ```\n *\n * @packageDocumentation\n */\n\n// Main client\nexport { WdkGaslessClient, createWdkGaslessClient } from './client.js'\nexport type { CreateWdkGaslessClientConfig } from './client.js'\n\n// Smart account\nexport { WdkSmartAccount, createWdkSmartAccount, SAFE_4337_ADDRESSES } from './account.js'\n\n// Types\nexport type {\n WdkAccount,\n WdkInstance,\n WdkSmartAccountConfig,\n WdkGaslessClientConfig,\n GaslessPaymentParams,\n BatchPaymentParams,\n GaslessPaymentResult,\n GaslessPaymentReceipt,\n SponsorshipInfo,\n} from './types.js'\n\n// Constants\nexport {\n USDT0_ADDRESSES,\n USDC_ADDRESSES,\n CHAIN_IDS,\n DEFAULT_BUNDLER_URLS,\n getTokenAddress,\n getChainName,\n} from './constants.js'\n\n// Re-export essential types from @t402/evm for convenience\nexport type {\n SmartAccountSigner,\n BundlerConfig,\n PaymasterConfig,\n UserOperationReceipt,\n} from '@t402/evm'\n","/**\n * WDK Gasless Client\n *\n * High-level client for executing gasless USDT0 payments using\n * Tether WDK accounts and ERC-4337 Account Abstraction.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport { encodeFunctionData, formatUnits } from 'viem'\nimport { BundlerClient, PaymasterClient, UserOpBuilder, ENTRYPOINT_V07_ADDRESS } from '@t402/evm'\nimport type {\n SmartAccountSigner,\n BundlerConfig,\n PaymasterConfig,\n TransactionIntent,\n GasEstimate,\n PaymasterData,\n} from '@t402/evm'\nimport type {\n WdkGaslessClientConfig,\n GaslessPaymentParams,\n BatchPaymentParams,\n GaslessPaymentResult,\n GaslessPaymentReceipt,\n SponsorshipInfo,\n WdkAccount,\n} from './types.js'\nimport { createWdkSmartAccount } from './account.js'\nimport { getTokenAddress, getChainName } from './constants.js'\n\n/**\n * ERC20 transfer ABI\n */\nconst ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * ERC20 balanceOf ABI\n */\nconst ERC20_BALANCE_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Gasless Client\n *\n * Provides a simple API for executing gasless USDT0 payments using\n * WDK accounts and ERC-4337 smart accounts.\n */\nexport class WdkGaslessClient {\n private readonly signer: SmartAccountSigner\n private readonly builder: UserOpBuilder\n private readonly bundler: BundlerClient\n private readonly paymaster?: PaymasterClient\n private readonly chainId: number\n private readonly publicClient: PublicClient\n private readonly chainName: string\n\n constructor(config: WdkGaslessClientConfig) {\n this.signer = config.signer\n this.builder = new UserOpBuilder()\n this.bundler = new BundlerClient(config.bundler)\n this.paymaster = config.paymaster ? new PaymasterClient(config.paymaster) : undefined\n this.chainId = config.chainId\n this.publicClient = config.publicClient\n this.chainName = getChainName(config.chainId)\n }\n\n /**\n * Execute a gasless payment\n *\n * Sends USDT0 (or other tokens) without the user paying gas fees.\n * Gas is sponsored by a paymaster if configured.\n */\n async pay(params: GaslessPaymentParams): Promise<GaslessPaymentResult> {\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n // Build the transfer call data\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n // Create the transaction intent\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n\n // Estimate gas\n const gasEstimate = await this.estimateGas(intent)\n\n // Get paymaster data if configured\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build the UserOperation\n const userOp = await this.builder.buildUserOp(\n this.signer,\n intent,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign the UserOperation\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n // Submit to bundler\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Execute multiple payments in a single transaction\n *\n * More gas efficient than individual payments.\n * All payments are executed atomically.\n */\n async payBatch(params: BatchPaymentParams): Promise<GaslessPaymentResult> {\n // Build transaction intents for all payments\n const intents: TransactionIntent[] = params.payments.map((payment) => {\n const token = payment.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n return {\n to: tokenAddress,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [payment.to, payment.amount],\n }),\n }\n })\n\n // Estimate gas for batch\n const gasEstimate = await this.estimateBatchGas(intents)\n\n // Get paymaster data\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build batch UserOperation\n const userOp = await this.builder.buildBatchUserOp(\n this.signer,\n intents,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign and submit\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Check if a payment can be sponsored (free gas)\n */\n async canSponsor(params: GaslessPaymentParams): Promise<SponsorshipInfo> {\n if (!this.paymaster) {\n return {\n canSponsor: false,\n reason: 'No paymaster configured',\n }\n }\n\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n const sender = await this.signer.getAddress()\n const encodedCallData = this.signer.encodeExecute(tokenAddress, 0n, callData)\n\n try {\n const canSponsor = await this.paymaster.willSponsor(\n { sender, callData: encodedCallData },\n this.chainId,\n ENTRYPOINT_V07_ADDRESS,\n )\n\n if (canSponsor) {\n return { canSponsor: true }\n } else {\n // Estimate gas cost if not sponsored\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n const gasEstimate = await this.estimateGas(intent)\n const gasPrice = await this.publicClient.getGasPrice()\n const estimatedGasCost =\n (gasEstimate.verificationGasLimit +\n gasEstimate.callGasLimit +\n gasEstimate.preVerificationGas) *\n gasPrice\n\n return {\n canSponsor: false,\n reason: 'Payment not eligible for sponsorship',\n estimatedGasCost,\n }\n }\n } catch (error) {\n return {\n canSponsor: false,\n reason: error instanceof Error ? error.message : 'Unknown error',\n }\n }\n }\n\n /**\n * Get the smart account address\n */\n async getAccountAddress(): Promise<Address> {\n return this.signer.getAddress()\n }\n\n /**\n * Check if the smart account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n return this.signer.isDeployed()\n }\n\n /**\n * Get the token balance of the smart account\n */\n async getBalance(token: 'USDT0' | 'USDC' | Address = 'USDT0'): Promise<bigint> {\n const tokenAddress = getTokenAddress(token, this.chainName)\n const accountAddress = await this.signer.getAddress()\n\n const balance = await this.publicClient.readContract({\n address: tokenAddress,\n abi: ERC20_BALANCE_ABI,\n functionName: 'balanceOf',\n args: [accountAddress],\n })\n\n return balance as bigint\n }\n\n /**\n * Get the formatted token balance\n */\n async getFormattedBalance(\n token: 'USDT0' | 'USDC' | Address = 'USDT0',\n decimals = 6,\n ): Promise<string> {\n const balance = await this.getBalance(token)\n return formatUnits(balance, decimals)\n }\n\n /**\n * Estimate gas for a single transaction\n */\n private async estimateGas(intent: TransactionIntent): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecute(intent.to, intent.value ?? 0n, intent.data ?? '0x')\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults if estimation fails\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n,\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Estimate gas for a batch transaction\n */\n private async estimateBatchGas(intents: TransactionIntent[]): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecuteBatch(\n intents.map((i) => i.to),\n intents.map((i) => i.value ?? 0n),\n intents.map((i) => (i.data ?? '0x') as Hex),\n )\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults with multiplier for batch size\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n * BigInt(intents.length),\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Get paymaster data if configured\n */\n private async getPaymasterData(_gasEstimate: GasEstimate): Promise<PaymasterData | undefined> {\n if (!this.paymaster) return undefined\n\n const sender = await this.signer.getAddress()\n\n return this.paymaster.getPaymasterData({ sender }, this.chainId, ENTRYPOINT_V07_ADDRESS)\n }\n}\n\n/**\n * Configuration for creating a WDK gasless client\n */\nexport interface CreateWdkGaslessClientConfig {\n /** WDK account to use as the signer */\n wdkAccount: WdkAccount\n /** Public client for chain interactions */\n publicClient: PublicClient\n /** Chain ID */\n chainId: number\n /** Bundler configuration */\n bundler: BundlerConfig\n /** Optional paymaster for gas sponsorship */\n paymaster?: PaymasterConfig\n /** Salt nonce for address generation (defaults to 0) */\n saltNonce?: bigint\n}\n\n/**\n * Create a WDK gasless client\n *\n * This is the main entry point for using WDK with gasless payments.\n *\n * @example\n * ```typescript\n * import { createWdkGaslessClient } from '@t402/wdk-gasless';\n *\n * const client = await createWdkGaslessClient({\n * wdkAccount: myWdkAccount,\n * publicClient,\n * chainId: 42161, // Arbitrum\n * bundler: {\n * bundlerUrl: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * chainId: 42161,\n * },\n * paymaster: {\n * address: '0x...',\n * url: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * type: 'sponsoring',\n * },\n * });\n *\n * // Execute gasless payment\n * const result = await client.pay({\n * to: '0x...',\n * amount: 1000000n, // 1 USDT0\n * });\n *\n * const receipt = await result.wait();\n * console.log('Payment confirmed:', receipt.txHash);\n * ```\n */\nexport async function createWdkGaslessClient(\n config: CreateWdkGaslessClientConfig,\n): Promise<WdkGaslessClient> {\n // Create the WDK smart account\n const smartAccount = await createWdkSmartAccount({\n wdkAccount: config.wdkAccount,\n publicClient: config.publicClient,\n chainId: config.chainId,\n saltNonce: config.saltNonce,\n })\n\n // Create the gasless client\n return new WdkGaslessClient({\n signer: smartAccount,\n bundler: config.bundler,\n paymaster: config.paymaster,\n chainId: config.chainId,\n publicClient: config.publicClient,\n })\n}\n","/**\n * WDK Smart Account\n *\n * Wraps a Tether WDK account to work with ERC-4337 smart accounts.\n * Creates a Safe smart account with the WDK account as the owner/signer.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport {\n encodeFunctionData,\n encodeAbiParameters,\n concat,\n keccak256,\n getContractAddress,\n} from 'viem'\nimport type { SmartAccountSigner } from '@t402/evm'\nimport type { WdkAccount, WdkSmartAccountConfig } from './types.js'\n\n/**\n * Safe 4337 module addresses (v0.3.0)\n * Deployed on all major EVM chains at the same addresses\n */\nexport const SAFE_4337_ADDRESSES = {\n /** Safe 4337 Module */\n module: '0xa581c4A4DB7175302464fF3C06380BC3270b4037' as Address,\n /** Safe Module Setup */\n moduleSetup: '0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47' as Address,\n /** Safe Singleton */\n singleton: '0x29fcB43b46531BcA003ddC8FCB67FFE91900C762' as Address,\n /** Safe Proxy Factory */\n proxyFactory: '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67' as Address,\n /** Safe Fallback Handler */\n fallbackHandler: '0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99' as Address,\n /** Add Modules Lib */\n addModulesLib: '0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb' as Address,\n} as const\n\n/**\n * Safe Proxy Factory ABI\n */\nconst PROXY_FACTORY_ABI = [\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'createProxyWithNonce',\n outputs: [{ name: 'proxy', type: 'address' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'proxyCreationCode',\n outputs: [{ name: '', type: 'bytes' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * Safe Singleton ABI\n */\nconst SAFE_ABI = [\n {\n inputs: [\n { name: 'owners', type: 'address[]' },\n { name: 'threshold', type: 'uint256' },\n { name: 'to', type: 'address' },\n { name: 'data', type: 'bytes' },\n { name: 'fallbackHandler', type: 'address' },\n { name: 'paymentToken', type: 'address' },\n { name: 'payment', type: 'uint256' },\n { name: 'paymentReceiver', type: 'address' },\n ],\n name: 'setup',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Add Modules Lib ABI\n */\nconst ADD_MODULES_LIB_ABI = [\n {\n inputs: [{ name: 'modules', type: 'address[]' }],\n name: 'enableModules',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Safe 4337 Module ABI\n */\nconst SAFE_4337_MODULE_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'data', type: 'bytes' },\n { name: 'operation', type: 'uint8' },\n ],\n name: 'executeUserOp',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'tos', type: 'address[]' },\n { name: 'values', type: 'uint256[]' },\n { name: 'datas', type: 'bytes[]' },\n { name: 'operations', type: 'uint8[]' },\n ],\n name: 'executeUserOpBatch',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Smart Account\n *\n * Creates a Safe smart account using a WDK account as the owner/signer.\n * Implements SmartAccountSigner for ERC-4337 compatibility.\n */\nexport class WdkSmartAccount implements SmartAccountSigner {\n private readonly wdkAccount: WdkAccount\n private readonly publicClient: PublicClient\n private readonly chainId: number\n private readonly owners: Address[]\n private readonly threshold: number\n private readonly saltNonce: bigint\n\n private cachedAddress?: Address\n private cachedInitCode?: Hex\n private cachedOwnerAddress?: Address\n private deploymentChecked = false\n private isAccountDeployed = false\n\n constructor(config: WdkSmartAccountConfig) {\n this.wdkAccount = config.wdkAccount\n this.publicClient = config.publicClient\n this.chainId = config.chainId\n this.threshold = config.threshold ?? 1\n this.saltNonce = config.saltNonce ?? 0n\n\n // Owners will be set when we get the WDK account address\n this.owners = config.additionalOwners ?? []\n }\n\n /**\n * Initialize the account (fetch WDK address)\n * Call this before using the account\n */\n async initialize(): Promise<void> {\n if (!this.cachedOwnerAddress) {\n const address = await this.wdkAccount.getAddress()\n this.cachedOwnerAddress = address as Address\n\n // Add WDK account as the first owner if not already in owners\n if (!this.owners.includes(this.cachedOwnerAddress)) {\n this.owners.unshift(this.cachedOwnerAddress)\n }\n }\n }\n\n /**\n * Get the WDK account's EOA address\n */\n async getOwnerAddress(): Promise<Address> {\n await this.initialize()\n return this.cachedOwnerAddress!\n }\n\n /**\n * Get the smart account address (counterfactual)\n */\n async getAddress(): Promise<Address> {\n await this.initialize()\n\n if (this.cachedAddress) {\n return this.cachedAddress\n }\n\n const initCode = await this.getInitCode()\n\n // If already deployed, get address from code\n if (initCode === '0x') {\n // Need to compute it anyway for first time\n const initializerData = await this.buildInitializer()\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n } else {\n // Extract initializer from init code\n const initializerData = `0x${initCode.slice(2 + 40 * 2)}` as Hex\n\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n }\n\n return this.cachedAddress\n }\n\n /**\n * Sign a UserOperation hash using the WDK account\n */\n async signUserOpHash(userOpHash: Hex): Promise<Hex> {\n await this.initialize()\n\n // Sign the hash using WDK account's signMessage\n // The hash is signed as raw bytes (personal_sign format)\n const signature = await this.wdkAccount.signMessage(userOpHash)\n\n // Format signature for Safe (add signature type byte)\n // Type 0: EOA signature\n return concat([signature as Hex, '0x00']) as Hex\n }\n\n /**\n * Get the account's init code for deployment\n */\n async getInitCode(): Promise<Hex> {\n await this.initialize()\n\n // Check if already deployed\n if (await this.isDeployed()) {\n return '0x' as Hex\n }\n\n if (this.cachedInitCode) {\n return this.cachedInitCode\n }\n\n const safeSetupData = await this.buildInitializer()\n\n // Build factory call data\n const createProxyData = encodeFunctionData({\n abi: PROXY_FACTORY_ABI,\n functionName: 'createProxyWithNonce',\n args: [SAFE_4337_ADDRESSES.singleton, safeSetupData, this.saltNonce],\n })\n\n // Init code = factory address + factory call data\n this.cachedInitCode = concat([SAFE_4337_ADDRESSES.proxyFactory, createProxyData]) as Hex\n\n return this.cachedInitCode\n }\n\n /**\n * Check if the account is deployed\n */\n async isDeployed(): Promise<boolean> {\n if (this.deploymentChecked) {\n return this.isAccountDeployed\n }\n\n await this.initialize()\n const address = this.cachedAddress ?? (await this.getAddress())\n const code = await this.publicClient.getCode({ address })\n\n this.deploymentChecked = true\n this.isAccountDeployed = code !== undefined && code !== '0x'\n\n return this.isAccountDeployed\n }\n\n /**\n * Encode a call to the account's execute function\n */\n encodeExecute(target: Address, value: bigint, data: Hex): Hex {\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOp',\n args: [target, value, data, 0], // operation: CALL\n })\n }\n\n /**\n * Encode a batch call to the account's executeBatch function\n */\n encodeExecuteBatch(targets: Address[], values: bigint[], datas: Hex[]): Hex {\n if (targets.length !== values.length || targets.length !== datas.length) {\n throw new Error('Array lengths must match')\n }\n\n const operations = targets.map(() => 0) // All CALL operations\n\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOpBatch',\n args: [targets, values, datas, operations],\n })\n }\n\n /**\n * Build the Safe setup initializer data\n */\n private async buildInitializer(): Promise<Hex> {\n await this.initialize()\n\n // Build Safe setup data with 4337 module\n const setupModulesData = encodeFunctionData({\n abi: ADD_MODULES_LIB_ABI,\n functionName: 'enableModules',\n args: [[SAFE_4337_ADDRESSES.module]],\n })\n\n return encodeFunctionData({\n abi: SAFE_ABI,\n functionName: 'setup',\n args: [\n this.owners,\n BigInt(this.threshold),\n SAFE_4337_ADDRESSES.addModulesLib, // to: AddModulesLib\n setupModulesData, // data: enableModules([module])\n SAFE_4337_ADDRESSES.fallbackHandler,\n '0x0000000000000000000000000000000000000000' as Address, // paymentToken\n 0n, // payment\n '0x0000000000000000000000000000000000000000' as Address, // paymentReceiver\n ],\n })\n }\n\n /**\n * Get the Safe's owners\n */\n getOwners(): Address[] {\n return [...this.owners]\n }\n\n /**\n * Get the Safe's threshold\n */\n getThreshold(): number {\n return this.threshold\n }\n\n /**\n * Clear cached values (useful after deployment)\n */\n clearCache(): void {\n this.cachedAddress = undefined\n this.cachedInitCode = undefined\n this.deploymentChecked = false\n this.isAccountDeployed = false\n }\n}\n\n/**\n * Create a WDK smart account\n */\nexport async function createWdkSmartAccount(\n config: WdkSmartAccountConfig,\n): Promise<WdkSmartAccount> {\n const account = new WdkSmartAccount(config)\n await account.initialize()\n return account\n}\n","/**\n * WDK Gasless Constants\n *\n * Addresses and configuration for gasless USDT0 payments.\n */\n\nimport type { Address } from 'viem'\n\n/**\n * USDT0 OFT addresses by chain\n */\nexport const USDT0_ADDRESSES: Record<string, Address> = {\n ethereum: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n arbitrum: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',\n ink: '0x0200C29006150606B650577BBE7B6248F58470c1',\n berachain: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736',\n unichain: '0x588ce4F028D8e7B53B687865d6A67b3A54C75518',\n base: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n optimism: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n} as const\n\n/**\n * USDC addresses by chain\n */\nexport const USDC_ADDRESSES: Record<string, Address> = {\n ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n arbitrum: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',\n base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n optimism: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',\n polygon: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',\n} as const\n\n/**\n * Chain IDs for supported networks\n */\nexport const CHAIN_IDS: Record<string, number> = {\n ethereum: 1,\n arbitrum: 42161,\n base: 8453,\n optimism: 10,\n polygon: 137,\n ink: 57073,\n berachain: 80084,\n unichain: 130,\n} as const\n\n/**\n * Default bundler URLs by chain (using public endpoints)\n */\nexport const DEFAULT_BUNDLER_URLS: Record<number, string> = {\n 1: 'https://api.pimlico.io/v2/ethereum/rpc',\n 42161: 'https://api.pimlico.io/v2/arbitrum/rpc',\n 8453: 'https://api.pimlico.io/v2/base/rpc',\n 10: 'https://api.pimlico.io/v2/optimism/rpc',\n 137: 'https://api.pimlico.io/v2/polygon/rpc',\n} as const\n\n/**\n * Get token address for a chain\n */\nexport function getTokenAddress(token: 'USDT0' | 'USDC' | Address, chainName: string): Address {\n if (token.startsWith('0x')) {\n return token as Address\n }\n\n const addresses = token === 'USDT0' ? USDT0_ADDRESSES : USDC_ADDRESSES\n const address = addresses[chainName.toLowerCase()]\n\n if (!address) {\n throw new Error(`Token ${token} not available on ${chainName}`)\n }\n\n return address\n}\n\n/**\n * Get chain name from chain ID\n */\nexport function getChainName(chainId: number): string {\n const entry = Object.entries(CHAIN_IDS).find(([, id]) => id === chainId)\n if (!entry) {\n thro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A;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AAEN,aAAO;AAAA,QACL,sBAAsB;AAAA,QACtB,cAAc,UAAU,OAAO,QAAQ,MAAM;AAAA,QAC7C,oBAAoB;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,iBAAiB,cAA+D;AAC5F,QAAI,CAAC,KAAK,UAAW,QAAO;AAE5B,UAAM,SAAS,MAAM,KAAK,OAAO,WAAW;AAE5C,WAAO,KAAK,UAAU,iBAAiB,EAAE,OAAO,GAAG,KAAK,SAAS,iCAAsB;AAAA,EACzF;AACF;AAsDA,eAAsB,uBACpB,QAC2B;AAE3B,QAAM,eAAe,MAAM,sBAAsB;AAAA,IAC/C,YAAY,OAAO;AAAA,IACnB,cAAc,OAAO;AAAA,IACrB,SAAS,OAAO;AAAA,IAChB,WAAW,OAAO;AAAA,EACpB,CAAC;AAGD,SAAO,IAAI,iBAAiB;AAAA,IAC1B,QAAQ;AAAA,IACR,SAAS,OAAO;AAAA,IAChB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,cAAc,OAAO;AAAA,EACvB,CAAC;AACH;","names":["import_viem"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/client.ts","../../src/account.ts","../../src/constants.ts"],"sourcesContent":["/**\n * @t402/wdk-gasless\n *\n * Gasless USDT0 payments using Tether WDK and ERC-4337 Account Abstraction.\n *\n * This package enables users to send USDT0 payments without holding any ETH\n * for gas fees. It works by:\n *\n * 1. Wrapping a WDK account in a Safe smart account (ERC-4337)\n * 2. Using a paymaster to sponsor gas fees\n * 3. Submitting UserOperations through a bundler\n *\n * @example Basic usage\n * ```typescript\n * import { createWdkGaslessClient } from '@t402/wdk-gasless';\n * import { createPublicClient, http } from 'viem';\n * import { arbitrum } from 'viem/chains';\n *\n * // Create public client\n * const publicClient = createPublicClient({\n * chain: arbitrum,\n * transport: http(),\n * });\n *\n * // Create gasless client\n * const client = await createWdkGaslessClient({\n * wdkAccount: myWdkAccount,\n * publicClient,\n * chainId: 42161,\n * bundler: {\n * bundlerUrl: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * chainId: 42161,\n * },\n * paymaster: {\n * address: '0x...',\n * url: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * type: 'sponsoring',\n * },\n * });\n *\n * // Check balance\n * const balance = await client.getFormattedBalance();\n * console.log(`USDT0 Balance: ${balance}`);\n *\n * // Execute gasless payment\n * const result = await client.pay({\n * to: '0x...',\n * amount: 1000000n, // 1 USDT0 (6 decimals)\n * });\n *\n * console.log('UserOp submitted:', result.userOpHash);\n * console.log('Sponsored (free gas):', result.sponsored);\n *\n * // Wait for confirmation\n * const receipt = await result.wait();\n * console.log('Confirmed in tx:', receipt.txHash);\n * ```\n *\n * @example Batch payments\n * ```typescript\n * // Send to multiple recipients in one transaction\n * const result = await client.payBatch({\n * payments: [\n * { to: '0xAlice...', amount: 1000000n }, // 1 USDT0\n * { to: '0xBob...', amount: 2000000n }, // 2 USDT0\n * { to: '0xCharlie...', amount: 500000n }, // 0.5 USDT0\n * ],\n * });\n * ```\n *\n * @example Check sponsorship eligibility\n * ```typescript\n * const info = await client.canSponsor({\n * to: '0x...',\n * amount: 1000000n,\n * });\n *\n * if (info.canSponsor) {\n * console.log('Payment will be sponsored (free gas)');\n * } else {\n * console.log('Not sponsored:', info.reason);\n * console.log('Estimated gas cost:', info.estimatedGasCost);\n * }\n * ```\n *\n * @packageDocumentation\n */\n\n// Main client\nexport { WdkGaslessClient, createWdkGaslessClient } from './client.js'\nexport type { CreateWdkGaslessClientConfig } from './client.js'\n\n// Smart account\nexport { WdkSmartAccount, createWdkSmartAccount, SAFE_4337_ADDRESSES } from './account.js'\n\n// Types\nexport type {\n WdkAccount,\n WdkInstance,\n WdkSmartAccountConfig,\n WdkGaslessClientConfig,\n GaslessPaymentParams,\n BatchPaymentParams,\n GaslessPaymentResult,\n GaslessPaymentReceipt,\n SponsorshipInfo,\n} from './types.js'\n\n// Constants\nexport {\n USDT0_ADDRESSES,\n USDC_ADDRESSES,\n CHAIN_IDS,\n DEFAULT_BUNDLER_URLS,\n getTokenAddress,\n getChainName,\n} from './constants.js'\n\n// Re-export essential types from @t402/evm for convenience\nexport type {\n SmartAccountSigner,\n BundlerConfig,\n PaymasterConfig,\n UserOperationReceipt,\n} from '@t402/evm'\n","/**\n * WDK Gasless Client\n *\n * High-level client for executing gasless USDT0 payments using\n * Tether WDK accounts and ERC-4337 Account Abstraction.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport { encodeFunctionData, formatUnits } from 'viem'\nimport { BundlerClient, PaymasterClient, UserOpBuilder, ENTRYPOINT_V07_ADDRESS } from '@t402/evm'\nimport type {\n SmartAccountSigner,\n BundlerConfig,\n PaymasterConfig,\n TransactionIntent,\n GasEstimate,\n PaymasterData,\n} from '@t402/evm'\nimport type {\n WdkGaslessClientConfig,\n GaslessPaymentParams,\n BatchPaymentParams,\n GaslessPaymentResult,\n GaslessPaymentReceipt,\n SponsorshipInfo,\n WdkAccount,\n} from './types.js'\nimport { createWdkSmartAccount } from './account.js'\nimport { getTokenAddress, getChainName } from './constants.js'\n\n/**\n * ERC20 transfer ABI\n */\nconst ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * ERC20 balanceOf ABI\n */\nconst ERC20_BALANCE_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Gasless Client\n *\n * Provides a simple API for executing gasless USDT0 payments using\n * WDK accounts and ERC-4337 smart accounts.\n */\nexport class WdkGaslessClient {\n private readonly signer: SmartAccountSigner\n private readonly builder: UserOpBuilder\n private readonly bundler: BundlerClient\n private readonly paymaster?: PaymasterClient\n private readonly chainId: number\n private readonly publicClient: PublicClient\n private readonly chainName: string\n\n constructor(config: WdkGaslessClientConfig) {\n this.signer = config.signer\n this.builder = new UserOpBuilder()\n this.bundler = new BundlerClient(config.bundler)\n this.paymaster = config.paymaster ? new PaymasterClient(config.paymaster) : undefined\n this.chainId = config.chainId\n this.publicClient = config.publicClient\n this.chainName = getChainName(config.chainId)\n }\n\n /**\n * Execute a gasless payment\n *\n * Sends USDT0 (or other tokens) without the user paying gas fees.\n * Gas is sponsored by a paymaster if configured.\n */\n async pay(params: GaslessPaymentParams): Promise<GaslessPaymentResult> {\n // Validate payment params\n if (!params.to || params.to === '0x0000000000000000000000000000000000000000') {\n throw new Error('Recipient address must not be the zero address')\n }\n\n if (params.amount <= 0n) {\n throw new Error('Payment amount must be greater than zero')\n }\n\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n // Build the transfer call data\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n // Create the transaction intent\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n\n // Estimate gas\n const gasEstimate = await this.estimateGas(intent)\n\n // Get paymaster data if configured\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build the UserOperation\n const userOp = await this.builder.buildUserOp(\n this.signer,\n intent,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign the UserOperation\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n // Submit to bundler\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Execute multiple payments in a single transaction\n *\n * More gas efficient than individual payments.\n * All payments are executed atomically.\n */\n async payBatch(params: BatchPaymentParams): Promise<GaslessPaymentResult> {\n // Validate batch params\n if (!params.payments || params.payments.length === 0) {\n throw new Error('Batch payments must contain at least one payment')\n }\n\n if (params.payments.length > 50) {\n throw new Error('Batch payments must not exceed 50 payments')\n }\n\n for (const payment of params.payments) {\n if (!payment.to || payment.to === '0x0000000000000000000000000000000000000000') {\n throw new Error('Recipient address must not be the zero address')\n }\n if (payment.amount <= 0n) {\n throw new Error('Payment amount must be greater than zero')\n }\n }\n\n // Build transaction intents for all payments\n const intents: TransactionIntent[] = params.payments.map((payment) => {\n const token = payment.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n return {\n to: tokenAddress,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [payment.to, payment.amount],\n }),\n }\n })\n\n // Estimate gas for batch\n const gasEstimate = await this.estimateBatchGas(intents)\n\n // Get paymaster data\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build batch UserOperation\n const userOp = await this.builder.buildBatchUserOp(\n this.signer,\n intents,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign and submit\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Check if a payment can be sponsored (free gas)\n */\n async canSponsor(params: GaslessPaymentParams): Promise<SponsorshipInfo> {\n if (!this.paymaster) {\n return {\n canSponsor: false,\n reason: 'No paymaster configured',\n }\n }\n\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n const sender = await this.signer.getAddress()\n const encodedCallData = this.signer.encodeExecute(tokenAddress, 0n, callData)\n\n try {\n const canSponsor = await this.paymaster.willSponsor(\n { sender, callData: encodedCallData },\n this.chainId,\n ENTRYPOINT_V07_ADDRESS,\n )\n\n if (canSponsor) {\n return { canSponsor: true }\n } else {\n // Estimate gas cost if not sponsored\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n const gasEstimate = await this.estimateGas(intent)\n const gasPrice = await this.publicClient.getGasPrice()\n const estimatedGasCost =\n (gasEstimate.verificationGasLimit +\n gasEstimate.callGasLimit +\n gasEstimate.preVerificationGas) *\n gasPrice\n\n return {\n canSponsor: false,\n reason: 'Payment not eligible for sponsorship',\n estimatedGasCost,\n }\n }\n } catch (error) {\n return {\n canSponsor: false,\n reason: error instanceof Error ? error.message : 'Unknown error',\n }\n }\n }\n\n /**\n * Get the smart account address\n */\n async getAccountAddress(): Promise<Address> {\n return this.signer.getAddress()\n }\n\n /**\n * Check if the smart account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n return this.signer.isDeployed()\n }\n\n /**\n * Get the token balance of the smart account\n */\n async getBalance(token: 'USDT0' | 'USDC' | Address = 'USDT0'): Promise<bigint> {\n const tokenAddress = getTokenAddress(token, this.chainName)\n const accountAddress = await this.signer.getAddress()\n\n const balance = await this.publicClient.readContract({\n address: tokenAddress,\n abi: ERC20_BALANCE_ABI,\n functionName: 'balanceOf',\n args: [accountAddress],\n })\n\n return balance as bigint\n }\n\n /**\n * Get the formatted token balance\n */\n async getFormattedBalance(\n token: 'USDT0' | 'USDC' | Address = 'USDT0',\n decimals = 6,\n ): Promise<string> {\n const balance = await this.getBalance(token)\n return formatUnits(balance, decimals)\n }\n\n /**\n * Estimate gas for a single transaction\n */\n private async estimateGas(intent: TransactionIntent): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecute(intent.to, intent.value ?? 0n, intent.data ?? '0x')\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults if estimation fails\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n,\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Estimate gas for a batch transaction\n */\n private async estimateBatchGas(intents: TransactionIntent[]): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecuteBatch(\n intents.map((i) => i.to),\n intents.map((i) => i.value ?? 0n),\n intents.map((i) => (i.data ?? '0x') as Hex),\n )\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults with multiplier for batch size\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n * BigInt(intents.length),\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Get paymaster data if configured\n */\n private async getPaymasterData(_gasEstimate: GasEstimate): Promise<PaymasterData | undefined> {\n if (!this.paymaster) return undefined\n\n const sender = await this.signer.getAddress()\n\n return this.paymaster.getPaymasterData({ sender }, this.chainId, ENTRYPOINT_V07_ADDRESS)\n }\n}\n\n/**\n * Configuration for creating a WDK gasless client\n */\nexport interface CreateWdkGaslessClientConfig {\n /** WDK account to use as the signer */\n wdkAccount: WdkAccount\n /** Public client for chain interactions */\n publicClient: PublicClient\n /** Chain ID */\n chainId: number\n /** Bundler configuration */\n bundler: BundlerConfig\n /** Optional paymaster for gas sponsorship */\n paymaster?: PaymasterConfig\n /** Salt nonce for address generation (defaults to 0) */\n saltNonce?: bigint\n}\n\n/**\n * Create a WDK gasless client\n *\n * This is the main entry point for using WDK with gasless payments.\n *\n * @example\n * ```typescript\n * import { createWdkGaslessClient } from '@t402/wdk-gasless';\n *\n * const client = await createWdkGaslessClient({\n * wdkAccount: myWdkAccount,\n * publicClient,\n * chainId: 42161, // Arbitrum\n * bundler: {\n * bundlerUrl: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * chainId: 42161,\n * },\n * paymaster: {\n * address: '0x...',\n * url: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * type: 'sponsoring',\n * },\n * });\n *\n * // Execute gasless payment\n * const result = await client.pay({\n * to: '0x...',\n * amount: 1000000n, // 1 USDT0\n * });\n *\n * const receipt = await result.wait();\n * console.log('Payment confirmed:', receipt.txHash);\n * ```\n */\nexport async function createWdkGaslessClient(\n config: CreateWdkGaslessClientConfig,\n): Promise<WdkGaslessClient> {\n // Create the WDK smart account\n const smartAccount = await createWdkSmartAccount({\n wdkAccount: config.wdkAccount,\n publicClient: config.publicClient,\n chainId: config.chainId,\n saltNonce: config.saltNonce,\n })\n\n // Create the gasless client\n return new WdkGaslessClient({\n signer: smartAccount,\n bundler: config.bundler,\n paymaster: config.paymaster,\n chainId: config.chainId,\n publicClient: config.publicClient,\n })\n}\n","/**\n * WDK Smart Account\n *\n * Wraps a Tether WDK account to work with ERC-4337 smart accounts.\n * Creates a Safe smart account with the WDK account as the owner/signer.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport {\n encodeFunctionData,\n encodeAbiParameters,\n concat,\n keccak256,\n getContractAddress,\n} from 'viem'\nimport type { SmartAccountSigner } from '@t402/evm'\nimport type { WdkAccount, WdkSmartAccountConfig } from './types.js'\n\n/**\n * Safe 4337 module addresses (v0.3.0)\n * Deployed on all major EVM chains at the same addresses\n */\nexport const SAFE_4337_ADDRESSES = {\n /** Safe 4337 Module */\n module: '0xa581c4A4DB7175302464fF3C06380BC3270b4037' as Address,\n /** Safe Module Setup */\n moduleSetup: '0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47' as Address,\n /** Safe Singleton */\n singleton: '0x29fcB43b46531BcA003ddC8FCB67FFE91900C762' as Address,\n /** Safe Proxy Factory */\n proxyFactory: '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67' as Address,\n /** Safe Fallback Handler */\n fallbackHandler: '0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99' as Address,\n /** Add Modules Lib */\n addModulesLib: '0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb' as Address,\n} as const\n\n/**\n * Safe Proxy Factory ABI\n */\nconst PROXY_FACTORY_ABI = [\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'createProxyWithNonce',\n outputs: [{ name: 'proxy', type: 'address' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'proxyCreationCode',\n outputs: [{ name: '', type: 'bytes' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * Safe Singleton ABI\n */\nconst SAFE_ABI = [\n {\n inputs: [\n { name: 'owners', type: 'address[]' },\n { name: 'threshold', type: 'uint256' },\n { name: 'to', type: 'address' },\n { name: 'data', type: 'bytes' },\n { name: 'fallbackHandler', type: 'address' },\n { name: 'paymentToken', type: 'address' },\n { name: 'payment', type: 'uint256' },\n { name: 'paymentReceiver', type: 'address' },\n ],\n name: 'setup',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Add Modules Lib ABI\n */\nconst ADD_MODULES_LIB_ABI = [\n {\n inputs: [{ name: 'modules', type: 'address[]' }],\n name: 'enableModules',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Safe 4337 Module ABI\n */\nconst SAFE_4337_MODULE_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'data', type: 'bytes' },\n { name: 'operation', type: 'uint8' },\n ],\n name: 'executeUserOp',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'tos', type: 'address[]' },\n { name: 'values', type: 'uint256[]' },\n { name: 'datas', type: 'bytes[]' },\n { name: 'operations', type: 'uint8[]' },\n ],\n name: 'executeUserOpBatch',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Smart Account\n *\n * Creates a Safe smart account using a WDK account as the owner/signer.\n * Implements SmartAccountSigner for ERC-4337 compatibility.\n */\nexport class WdkSmartAccount implements SmartAccountSigner {\n private readonly wdkAccount: WdkAccount\n private readonly publicClient: PublicClient\n private readonly _chainId: number\n private readonly owners: Address[]\n private readonly threshold: number\n private readonly saltNonce: bigint\n\n private cachedAddress?: Address\n private cachedInitCode?: Hex\n private cachedOwnerAddress?: Address\n private deploymentChecked = false\n private isAccountDeployed = false\n\n constructor(config: WdkSmartAccountConfig) {\n this.wdkAccount = config.wdkAccount\n this.publicClient = config.publicClient\n this._chainId = config.chainId\n this.threshold = config.threshold ?? 1\n this.saltNonce = config.saltNonce ?? 0n\n\n // Owners will be set when we get the WDK account address\n this.owners = config.additionalOwners ?? []\n }\n\n /**\n * Initialize the account (fetch WDK address)\n * Call this before using the account\n */\n async initialize(): Promise<void> {\n if (!this.cachedOwnerAddress) {\n const address = await this.wdkAccount.getAddress()\n this.cachedOwnerAddress = address as Address\n\n // Add WDK account as the first owner if not already in owners\n if (!this.owners.includes(this.cachedOwnerAddress)) {\n this.owners.unshift(this.cachedOwnerAddress)\n }\n }\n }\n\n /**\n * Get the WDK account's EOA address\n */\n async getOwnerAddress(): Promise<Address> {\n await this.initialize()\n return this.cachedOwnerAddress!\n }\n\n /**\n * Get the chain ID\n */\n getChainId(): number {\n return this._chainId\n }\n\n /**\n * Get the smart account address (counterfactual)\n */\n async getAddress(): Promise<Address> {\n await this.initialize()\n\n if (this.cachedAddress) {\n return this.cachedAddress\n }\n\n const initCode = await this.getInitCode()\n\n // If already deployed, get address from code\n if (initCode === '0x') {\n // Need to compute it anyway for first time\n const initializerData = await this.buildInitializer()\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n } else {\n // Extract initializer from init code\n const initializerData = `0x${initCode.slice(2 + 40 * 2)}` as Hex\n\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n }\n\n return this.cachedAddress\n }\n\n /**\n * Sign a UserOperation hash using the WDK account\n */\n async signUserOpHash(userOpHash: Hex): Promise<Hex> {\n await this.initialize()\n\n // Sign the hash using WDK account's signMessage\n // The hash is signed as raw bytes (personal_sign format)\n const signature = await this.wdkAccount.signMessage(userOpHash)\n\n // Format signature for Safe (add signature type byte)\n // Type 0: EOA signature\n return concat([signature as Hex, '0x00']) as Hex\n }\n\n /**\n * Get the account's init code for deployment\n */\n async getInitCode(): Promise<Hex> {\n await this.initialize()\n\n // Check if already deployed\n if (await this.isDeployed()) {\n return '0x' as Hex\n }\n\n if (this.cachedInitCode) {\n return this.cachedInitCode\n }\n\n const safeSetupData = await this.buildInitializer()\n\n // Build factory call data\n const createProxyData = encodeFunctionData({\n abi: PROXY_FACTORY_ABI,\n functionName: 'createProxyWithNonce',\n args: [SAFE_4337_ADDRESSES.singleton, safeSetupData, this.saltNonce],\n })\n\n // Init code = factory address + factory call data\n this.cachedInitCode = concat([SAFE_4337_ADDRESSES.proxyFactory, createProxyData]) as Hex\n\n return this.cachedInitCode\n }\n\n /**\n * Check if the account is deployed\n */\n async isDeployed(): Promise<boolean> {\n if (this.deploymentChecked) {\n return this.isAccountDeployed\n }\n\n // Set flag early to break infinite recursion:\n // getAddress() → getInitCode() → isDeployed() → getAddress() → ...\n // Default assumption (not deployed) is correct for init code computation.\n this.deploymentChecked = true\n\n await this.initialize()\n const address = this.cachedAddress ?? (await this.getAddress())\n const code = await this.publicClient.getCode({ address })\n\n this.isAccountDeployed = code !== undefined && code !== '0x'\n\n return this.isAccountDeployed\n }\n\n /**\n * Encode a call to the account's execute function\n */\n encodeExecute(target: Address, value: bigint, data: Hex): Hex {\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOp',\n args: [target, value, data, 0], // operation: CALL\n })\n }\n\n /**\n * Encode a batch call to the account's executeBatch function\n */\n encodeExecuteBatch(targets: Address[], values: bigint[], datas: Hex[]): Hex {\n if (targets.length !== values.length || targets.length !== datas.length) {\n throw new Error('Array lengths must match')\n }\n\n const operations = targets.map(() => 0) // All CALL operations\n\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOpBatch',\n args: [targets, values, datas, operations],\n })\n }\n\n /**\n * Build the Safe setup initializer data\n */\n private async buildInitializer(): Promise<Hex> {\n await this.initialize()\n\n // Build Safe setup data with 4337 module\n const setupModulesData = encodeFunctionData({\n abi: ADD_MODULES_LIB_ABI,\n functionName: 'enableModules',\n args: [[SAFE_4337_ADDRESSES.module]],\n })\n\n return encodeFunctionData({\n abi: SAFE_ABI,\n functionName: 'setup',\n args: [\n this.owners,\n BigInt(this.threshold),\n SAFE_4337_ADDRESSES.addModulesLib, // to: AddModulesLib\n setupModulesData, // data: enableModules([module])\n SAFE_4337_ADDRESSES.fallbackHandler,\n '0x0000000000000000000000000000000000000000' as Address, // paymentToken\n 0n, // payment\n '0x0000000000000000000000000000000000000000' as Address, // paymentReceiver\n ],\n })\n }\n\n /**\n * Get the Safe's owners\n */\n getOwners(): Address[] {\n return [...this.owners]\n }\n\n /**\n * Get the Safe's threshold\n */\n getThreshold(): number {\n return this.threshold\n }\n\n /**\n * Clear cached values (useful after deployment)\n */\n clearCache(): void {\n this.cachedAddress = undefined\n this.cachedInitCode = undefined\n this.deploymentChecked = false\n this.isAccountDeployed = false\n }\n}\n\n/**\n * Create a WDK smart account\n */\nexport async function createWdkSmartAccount(\n config: WdkSmartAccountConfig,\n): Promise<WdkSmartAccount> {\n const account = new WdkSmartAccount(config)\n await account.initialize()\n return account\n}\n","/**\n * WDK Gasless Constants\n *\n * Addresses and configuration for gasless USDT0 payments.\n */\n\nimport type { Address } from 'viem'\n\n/**\n * USDT0 OFT addresses by chain\n */\nexport const USDT0_ADDRESSES: Record<string, Address> = {\n ethereum: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n arbitrum: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',\n ink: '0x0200C29006150606B650577BBE7B6248F58470c1',\n berachain: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736',\n unichain: '0x9151434b16b9763660705744891fA906F660EcC5',\n base: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n optimism: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n} as const\n\n/**\n * USDC addresses by chain\n */\nexport const USDC_ADDRESSES: Record<string, Address> = {\n ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n arbitrum: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',\n base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n optimism: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',\n polygon: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',\n} as const\n\n/**\n * Chain IDs for supported networks\n */\nexport const CHAIN_IDS: Record<string, number> = {\n ethereum: 1,\n arbitrum: 42161,\n base: 8453,\n optimism: 10,\n polygon: 137,\n ink: 57073,\n berachain: 80094,\n unichain: 130,\n} as const\n\n/**\n * Default bundler URLs by chain (using public endpoints)\n */\nexport const DEFAULT_BUNDLER_URLS: Record<number, string> = {\n 1: 'https://api.pimlico.io/v2/ethereum/rpc',\n 42161: 'https://api.pimlico.io/v2/arbitrum/rpc',\n 8453: 'https://api.pimlico.io/v2/base/rpc',\n 10: 'https://api.pimlico.io/v2/optimism/rpc',\n 137: 'https://api.pimlico.io/v2/polygon/rpc',\n} as const\n\n/**\n * Get token address for a chain\n */\nexport function getTokenAddress(token: 'USDT0' | 'USDC' | Address, chainName: string): Address {\n if (token.startsWith('0x')) {\n return token as Address\n }\n\n const addresses = token === 'USDT0' ? USDT0_ADDRESSES : USDC_ADDRESSES\n const address = addresses[chainName.toLowerCase()]\n\n if (!address) {\n throw new Error(`Token ${token} not available on ${chainName}`)\n }\n\n return address\n}\n\n/**\n * Get chain name from chain ID\n */\nexport function getChainName(chainId: number): string {\n const entry = Object.entries(CHAIN_IDS).find(([, id]) => id === chainId)\n if (!entry) {\n throw new Error(`Unsupported chain ID: ${chainId}`)\n }\n return entry[0]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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","names":["import_viem"]}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PublicClient, Address, Hex } from 'viem';
|
|
2
2
|
import { SmartAccountSigner, BundlerConfig, PaymasterConfig } from '@t402/evm';
|
|
3
3
|
export { BundlerConfig, PaymasterConfig, SmartAccountSigner, UserOperationReceipt } from '@t402/evm';
|
|
4
|
+
import { WdkAccount } from '@t402/wdk';
|
|
5
|
+
export { WdkAccount } from '@t402/wdk';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* WDK Gasless Types
|
|
@@ -9,41 +11,7 @@ export { BundlerConfig, PaymasterConfig, SmartAccountSigner, UserOperationReceip
|
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* WDK
|
|
13
|
-
*/
|
|
14
|
-
interface WdkAccount {
|
|
15
|
-
/** Get the account's address */
|
|
16
|
-
getAddress(): Promise<string>;
|
|
17
|
-
/** Get the account's native balance */
|
|
18
|
-
getBalance(): Promise<bigint>;
|
|
19
|
-
/** Get the account's token balance */
|
|
20
|
-
getTokenBalance(tokenAddress: string): Promise<bigint>;
|
|
21
|
-
/** Sign a message */
|
|
22
|
-
signMessage(message: string): Promise<string>;
|
|
23
|
-
/** Sign typed data (EIP-712) */
|
|
24
|
-
signTypedData(params: {
|
|
25
|
-
domain: {
|
|
26
|
-
name?: string;
|
|
27
|
-
version?: string;
|
|
28
|
-
chainId?: number;
|
|
29
|
-
verifyingContract?: string;
|
|
30
|
-
};
|
|
31
|
-
types: Record<string, Array<{
|
|
32
|
-
name: string;
|
|
33
|
-
type: string;
|
|
34
|
-
}>>;
|
|
35
|
-
primaryType: string;
|
|
36
|
-
message: Record<string, unknown>;
|
|
37
|
-
}): Promise<string>;
|
|
38
|
-
/** Send a transaction */
|
|
39
|
-
sendTransaction(params: {
|
|
40
|
-
to: string;
|
|
41
|
-
value?: bigint;
|
|
42
|
-
data?: string;
|
|
43
|
-
}): Promise<string>;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* WDK instance interface
|
|
14
|
+
* WDK instance interface (simplified wrapper for gasless context)
|
|
47
15
|
*/
|
|
48
16
|
interface WdkInstance {
|
|
49
17
|
/** Get accounts */
|
|
@@ -310,7 +278,7 @@ declare const SAFE_4337_ADDRESSES: {
|
|
|
310
278
|
declare class WdkSmartAccount implements SmartAccountSigner {
|
|
311
279
|
private readonly wdkAccount;
|
|
312
280
|
private readonly publicClient;
|
|
313
|
-
private readonly
|
|
281
|
+
private readonly _chainId;
|
|
314
282
|
private readonly owners;
|
|
315
283
|
private readonly threshold;
|
|
316
284
|
private readonly saltNonce;
|
|
@@ -329,6 +297,10 @@ declare class WdkSmartAccount implements SmartAccountSigner {
|
|
|
329
297
|
* Get the WDK account's EOA address
|
|
330
298
|
*/
|
|
331
299
|
getOwnerAddress(): Promise<Address>;
|
|
300
|
+
/**
|
|
301
|
+
* Get the chain ID
|
|
302
|
+
*/
|
|
303
|
+
getChainId(): number;
|
|
332
304
|
/**
|
|
333
305
|
* Get the smart account address (counterfactual)
|
|
334
306
|
*/
|
|
@@ -406,4 +378,4 @@ declare function getTokenAddress(token: 'USDT0' | 'USDC' | Address, chainName: s
|
|
|
406
378
|
*/
|
|
407
379
|
declare function getChainName(chainId: number): string;
|
|
408
380
|
|
|
409
|
-
export { type BatchPaymentParams, CHAIN_IDS, type CreateWdkGaslessClientConfig, DEFAULT_BUNDLER_URLS, type GaslessPaymentParams, type GaslessPaymentReceipt, type GaslessPaymentResult, SAFE_4337_ADDRESSES, type SponsorshipInfo, USDC_ADDRESSES, USDT0_ADDRESSES,
|
|
381
|
+
export { type BatchPaymentParams, CHAIN_IDS, type CreateWdkGaslessClientConfig, DEFAULT_BUNDLER_URLS, type GaslessPaymentParams, type GaslessPaymentReceipt, type GaslessPaymentResult, SAFE_4337_ADDRESSES, type SponsorshipInfo, USDC_ADDRESSES, USDT0_ADDRESSES, WdkGaslessClient, type WdkGaslessClientConfig, type WdkInstance, WdkSmartAccount, type WdkSmartAccountConfig, createWdkGaslessClient, createWdkSmartAccount, getChainName, getTokenAddress };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -104,7 +104,7 @@ var SAFE_4337_MODULE_ABI = [
|
|
|
104
104
|
var WdkSmartAccount = class {
|
|
105
105
|
wdkAccount;
|
|
106
106
|
publicClient;
|
|
107
|
-
|
|
107
|
+
_chainId;
|
|
108
108
|
owners;
|
|
109
109
|
threshold;
|
|
110
110
|
saltNonce;
|
|
@@ -116,7 +116,7 @@ var WdkSmartAccount = class {
|
|
|
116
116
|
constructor(config) {
|
|
117
117
|
this.wdkAccount = config.wdkAccount;
|
|
118
118
|
this.publicClient = config.publicClient;
|
|
119
|
-
this.
|
|
119
|
+
this._chainId = config.chainId;
|
|
120
120
|
this.threshold = config.threshold ?? 1;
|
|
121
121
|
this.saltNonce = config.saltNonce ?? 0n;
|
|
122
122
|
this.owners = config.additionalOwners ?? [];
|
|
@@ -141,6 +141,12 @@ var WdkSmartAccount = class {
|
|
|
141
141
|
await this.initialize();
|
|
142
142
|
return this.cachedOwnerAddress;
|
|
143
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Get the chain ID
|
|
146
|
+
*/
|
|
147
|
+
getChainId() {
|
|
148
|
+
return this._chainId;
|
|
149
|
+
}
|
|
144
150
|
/**
|
|
145
151
|
* Get the smart account address (counterfactual)
|
|
146
152
|
*/
|
|
@@ -228,10 +234,10 @@ var WdkSmartAccount = class {
|
|
|
228
234
|
if (this.deploymentChecked) {
|
|
229
235
|
return this.isAccountDeployed;
|
|
230
236
|
}
|
|
237
|
+
this.deploymentChecked = true;
|
|
231
238
|
await this.initialize();
|
|
232
239
|
const address = this.cachedAddress ?? await this.getAddress();
|
|
233
240
|
const code = await this.publicClient.getCode({ address });
|
|
234
|
-
this.deploymentChecked = true;
|
|
235
241
|
this.isAccountDeployed = code !== void 0 && code !== "0x";
|
|
236
242
|
return this.isAccountDeployed;
|
|
237
243
|
}
|
|
@@ -324,7 +330,7 @@ var USDT0_ADDRESSES = {
|
|
|
324
330
|
arbitrum: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
325
331
|
ink: "0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
326
332
|
berachain: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
|
|
327
|
-
unichain: "
|
|
333
|
+
unichain: "0x9151434b16b9763660705744891fA906F660EcC5",
|
|
328
334
|
base: "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee",
|
|
329
335
|
optimism: "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee"
|
|
330
336
|
};
|
|
@@ -342,7 +348,7 @@ var CHAIN_IDS = {
|
|
|
342
348
|
optimism: 10,
|
|
343
349
|
polygon: 137,
|
|
344
350
|
ink: 57073,
|
|
345
|
-
berachain:
|
|
351
|
+
berachain: 80094,
|
|
346
352
|
unichain: 130
|
|
347
353
|
};
|
|
348
354
|
var DEFAULT_BUNDLER_URLS = {
|
|
@@ -417,6 +423,12 @@ var WdkGaslessClient = class {
|
|
|
417
423
|
* Gas is sponsored by a paymaster if configured.
|
|
418
424
|
*/
|
|
419
425
|
async pay(params) {
|
|
426
|
+
if (!params.to || params.to === "0x0000000000000000000000000000000000000000") {
|
|
427
|
+
throw new Error("Recipient address must not be the zero address");
|
|
428
|
+
}
|
|
429
|
+
if (params.amount <= 0n) {
|
|
430
|
+
throw new Error("Payment amount must be greater than zero");
|
|
431
|
+
}
|
|
420
432
|
const token = params.token ?? "USDT0";
|
|
421
433
|
const tokenAddress = getTokenAddress(token, this.chainName);
|
|
422
434
|
const callData = encodeFunctionData2({
|
|
@@ -472,6 +484,20 @@ var WdkGaslessClient = class {
|
|
|
472
484
|
* All payments are executed atomically.
|
|
473
485
|
*/
|
|
474
486
|
async payBatch(params) {
|
|
487
|
+
if (!params.payments || params.payments.length === 0) {
|
|
488
|
+
throw new Error("Batch payments must contain at least one payment");
|
|
489
|
+
}
|
|
490
|
+
if (params.payments.length > 50) {
|
|
491
|
+
throw new Error("Batch payments must not exceed 50 payments");
|
|
492
|
+
}
|
|
493
|
+
for (const payment of params.payments) {
|
|
494
|
+
if (!payment.to || payment.to === "0x0000000000000000000000000000000000000000") {
|
|
495
|
+
throw new Error("Recipient address must not be the zero address");
|
|
496
|
+
}
|
|
497
|
+
if (payment.amount <= 0n) {
|
|
498
|
+
throw new Error("Payment amount must be greater than zero");
|
|
499
|
+
}
|
|
500
|
+
}
|
|
475
501
|
const intents = params.payments.map((payment) => {
|
|
476
502
|
const token = payment.token ?? "USDT0";
|
|
477
503
|
const tokenAddress = getTokenAddress(token, this.chainName);
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client.ts","../../src/account.ts","../../src/constants.ts"],"sourcesContent":["/**\n * WDK Gasless Client\n *\n * High-level client for executing gasless USDT0 payments using\n * Tether WDK accounts and ERC-4337 Account Abstraction.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport { encodeFunctionData, formatUnits } from 'viem'\nimport { BundlerClient, PaymasterClient, UserOpBuilder, ENTRYPOINT_V07_ADDRESS } from '@t402/evm'\nimport type {\n SmartAccountSigner,\n BundlerConfig,\n PaymasterConfig,\n TransactionIntent,\n GasEstimate,\n PaymasterData,\n} from '@t402/evm'\nimport type {\n WdkGaslessClientConfig,\n GaslessPaymentParams,\n BatchPaymentParams,\n GaslessPaymentResult,\n GaslessPaymentReceipt,\n SponsorshipInfo,\n WdkAccount,\n} from './types.js'\nimport { createWdkSmartAccount } from './account.js'\nimport { getTokenAddress, getChainName } from './constants.js'\n\n/**\n * ERC20 transfer ABI\n */\nconst ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * ERC20 balanceOf ABI\n */\nconst ERC20_BALANCE_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Gasless Client\n *\n * Provides a simple API for executing gasless USDT0 payments using\n * WDK accounts and ERC-4337 smart accounts.\n */\nexport class WdkGaslessClient {\n private readonly signer: SmartAccountSigner\n private readonly builder: UserOpBuilder\n private readonly bundler: BundlerClient\n private readonly paymaster?: PaymasterClient\n private readonly chainId: number\n private readonly publicClient: PublicClient\n private readonly chainName: string\n\n constructor(config: WdkGaslessClientConfig) {\n this.signer = config.signer\n this.builder = new UserOpBuilder()\n this.bundler = new BundlerClient(config.bundler)\n this.paymaster = config.paymaster ? new PaymasterClient(config.paymaster) : undefined\n this.chainId = config.chainId\n this.publicClient = config.publicClient\n this.chainName = getChainName(config.chainId)\n }\n\n /**\n * Execute a gasless payment\n *\n * Sends USDT0 (or other tokens) without the user paying gas fees.\n * Gas is sponsored by a paymaster if configured.\n */\n async pay(params: GaslessPaymentParams): Promise<GaslessPaymentResult> {\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n // Build the transfer call data\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n // Create the transaction intent\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n\n // Estimate gas\n const gasEstimate = await this.estimateGas(intent)\n\n // Get paymaster data if configured\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build the UserOperation\n const userOp = await this.builder.buildUserOp(\n this.signer,\n intent,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign the UserOperation\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n // Submit to bundler\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Execute multiple payments in a single transaction\n *\n * More gas efficient than individual payments.\n * All payments are executed atomically.\n */\n async payBatch(params: BatchPaymentParams): Promise<GaslessPaymentResult> {\n // Build transaction intents for all payments\n const intents: TransactionIntent[] = params.payments.map((payment) => {\n const token = payment.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n return {\n to: tokenAddress,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [payment.to, payment.amount],\n }),\n }\n })\n\n // Estimate gas for batch\n const gasEstimate = await this.estimateBatchGas(intents)\n\n // Get paymaster data\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build batch UserOperation\n const userOp = await this.builder.buildBatchUserOp(\n this.signer,\n intents,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign and submit\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Check if a payment can be sponsored (free gas)\n */\n async canSponsor(params: GaslessPaymentParams): Promise<SponsorshipInfo> {\n if (!this.paymaster) {\n return {\n canSponsor: false,\n reason: 'No paymaster configured',\n }\n }\n\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n const sender = await this.signer.getAddress()\n const encodedCallData = this.signer.encodeExecute(tokenAddress, 0n, callData)\n\n try {\n const canSponsor = await this.paymaster.willSponsor(\n { sender, callData: encodedCallData },\n this.chainId,\n ENTRYPOINT_V07_ADDRESS,\n )\n\n if (canSponsor) {\n return { canSponsor: true }\n } else {\n // Estimate gas cost if not sponsored\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n const gasEstimate = await this.estimateGas(intent)\n const gasPrice = await this.publicClient.getGasPrice()\n const estimatedGasCost =\n (gasEstimate.verificationGasLimit +\n gasEstimate.callGasLimit +\n gasEstimate.preVerificationGas) *\n gasPrice\n\n return {\n canSponsor: false,\n reason: 'Payment not eligible for sponsorship',\n estimatedGasCost,\n }\n }\n } catch (error) {\n return {\n canSponsor: false,\n reason: error instanceof Error ? error.message : 'Unknown error',\n }\n }\n }\n\n /**\n * Get the smart account address\n */\n async getAccountAddress(): Promise<Address> {\n return this.signer.getAddress()\n }\n\n /**\n * Check if the smart account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n return this.signer.isDeployed()\n }\n\n /**\n * Get the token balance of the smart account\n */\n async getBalance(token: 'USDT0' | 'USDC' | Address = 'USDT0'): Promise<bigint> {\n const tokenAddress = getTokenAddress(token, this.chainName)\n const accountAddress = await this.signer.getAddress()\n\n const balance = await this.publicClient.readContract({\n address: tokenAddress,\n abi: ERC20_BALANCE_ABI,\n functionName: 'balanceOf',\n args: [accountAddress],\n })\n\n return balance as bigint\n }\n\n /**\n * Get the formatted token balance\n */\n async getFormattedBalance(\n token: 'USDT0' | 'USDC' | Address = 'USDT0',\n decimals = 6,\n ): Promise<string> {\n const balance = await this.getBalance(token)\n return formatUnits(balance, decimals)\n }\n\n /**\n * Estimate gas for a single transaction\n */\n private async estimateGas(intent: TransactionIntent): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecute(intent.to, intent.value ?? 0n, intent.data ?? '0x')\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults if estimation fails\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n,\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Estimate gas for a batch transaction\n */\n private async estimateBatchGas(intents: TransactionIntent[]): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecuteBatch(\n intents.map((i) => i.to),\n intents.map((i) => i.value ?? 0n),\n intents.map((i) => (i.data ?? '0x') as Hex),\n )\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults with multiplier for batch size\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n * BigInt(intents.length),\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Get paymaster data if configured\n */\n private async getPaymasterData(_gasEstimate: GasEstimate): Promise<PaymasterData | undefined> {\n if (!this.paymaster) return undefined\n\n const sender = await this.signer.getAddress()\n\n return this.paymaster.getPaymasterData({ sender }, this.chainId, ENTRYPOINT_V07_ADDRESS)\n }\n}\n\n/**\n * Configuration for creating a WDK gasless client\n */\nexport interface CreateWdkGaslessClientConfig {\n /** WDK account to use as the signer */\n wdkAccount: WdkAccount\n /** Public client for chain interactions */\n publicClient: PublicClient\n /** Chain ID */\n chainId: number\n /** Bundler configuration */\n bundler: BundlerConfig\n /** Optional paymaster for gas sponsorship */\n paymaster?: PaymasterConfig\n /** Salt nonce for address generation (defaults to 0) */\n saltNonce?: bigint\n}\n\n/**\n * Create a WDK gasless client\n *\n * This is the main entry point for using WDK with gasless payments.\n *\n * @example\n * ```typescript\n * import { createWdkGaslessClient } from '@t402/wdk-gasless';\n *\n * const client = await createWdkGaslessClient({\n * wdkAccount: myWdkAccount,\n * publicClient,\n * chainId: 42161, // Arbitrum\n * bundler: {\n * bundlerUrl: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * chainId: 42161,\n * },\n * paymaster: {\n * address: '0x...',\n * url: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * type: 'sponsoring',\n * },\n * });\n *\n * // Execute gasless payment\n * const result = await client.pay({\n * to: '0x...',\n * amount: 1000000n, // 1 USDT0\n * });\n *\n * const receipt = await result.wait();\n * console.log('Payment confirmed:', receipt.txHash);\n * ```\n */\nexport async function createWdkGaslessClient(\n config: CreateWdkGaslessClientConfig,\n): Promise<WdkGaslessClient> {\n // Create the WDK smart account\n const smartAccount = await createWdkSmartAccount({\n wdkAccount: config.wdkAccount,\n publicClient: config.publicClient,\n chainId: config.chainId,\n saltNonce: config.saltNonce,\n })\n\n // Create the gasless client\n return new WdkGaslessClient({\n signer: smartAccount,\n bundler: config.bundler,\n paymaster: config.paymaster,\n chainId: config.chainId,\n publicClient: config.publicClient,\n })\n}\n","/**\n * WDK Smart Account\n *\n * Wraps a Tether WDK account to work with ERC-4337 smart accounts.\n * Creates a Safe smart account with the WDK account as the owner/signer.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport {\n encodeFunctionData,\n encodeAbiParameters,\n concat,\n keccak256,\n getContractAddress,\n} from 'viem'\nimport type { SmartAccountSigner } from '@t402/evm'\nimport type { WdkAccount, WdkSmartAccountConfig } from './types.js'\n\n/**\n * Safe 4337 module addresses (v0.3.0)\n * Deployed on all major EVM chains at the same addresses\n */\nexport const SAFE_4337_ADDRESSES = {\n /** Safe 4337 Module */\n module: '0xa581c4A4DB7175302464fF3C06380BC3270b4037' as Address,\n /** Safe Module Setup */\n moduleSetup: '0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47' as Address,\n /** Safe Singleton */\n singleton: '0x29fcB43b46531BcA003ddC8FCB67FFE91900C762' as Address,\n /** Safe Proxy Factory */\n proxyFactory: '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67' as Address,\n /** Safe Fallback Handler */\n fallbackHandler: '0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99' as Address,\n /** Add Modules Lib */\n addModulesLib: '0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb' as Address,\n} as const\n\n/**\n * Safe Proxy Factory ABI\n */\nconst PROXY_FACTORY_ABI = [\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'createProxyWithNonce',\n outputs: [{ name: 'proxy', type: 'address' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'proxyCreationCode',\n outputs: [{ name: '', type: 'bytes' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * Safe Singleton ABI\n */\nconst SAFE_ABI = [\n {\n inputs: [\n { name: 'owners', type: 'address[]' },\n { name: 'threshold', type: 'uint256' },\n { name: 'to', type: 'address' },\n { name: 'data', type: 'bytes' },\n { name: 'fallbackHandler', type: 'address' },\n { name: 'paymentToken', type: 'address' },\n { name: 'payment', type: 'uint256' },\n { name: 'paymentReceiver', type: 'address' },\n ],\n name: 'setup',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Add Modules Lib ABI\n */\nconst ADD_MODULES_LIB_ABI = [\n {\n inputs: [{ name: 'modules', type: 'address[]' }],\n name: 'enableModules',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Safe 4337 Module ABI\n */\nconst SAFE_4337_MODULE_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'data', type: 'bytes' },\n { name: 'operation', type: 'uint8' },\n ],\n name: 'executeUserOp',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'tos', type: 'address[]' },\n { name: 'values', type: 'uint256[]' },\n { name: 'datas', type: 'bytes[]' },\n { name: 'operations', type: 'uint8[]' },\n ],\n name: 'executeUserOpBatch',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Smart Account\n *\n * Creates a Safe smart account using a WDK account as the owner/signer.\n * Implements SmartAccountSigner for ERC-4337 compatibility.\n */\nexport class WdkSmartAccount implements SmartAccountSigner {\n private readonly wdkAccount: WdkAccount\n private readonly publicClient: PublicClient\n private readonly chainId: number\n private readonly owners: Address[]\n private readonly threshold: number\n private readonly saltNonce: bigint\n\n private cachedAddress?: Address\n private cachedInitCode?: Hex\n private cachedOwnerAddress?: Address\n private deploymentChecked = false\n private isAccountDeployed = false\n\n constructor(config: WdkSmartAccountConfig) {\n this.wdkAccount = config.wdkAccount\n this.publicClient = config.publicClient\n this.chainId = config.chainId\n this.threshold = config.threshold ?? 1\n this.saltNonce = config.saltNonce ?? 0n\n\n // Owners will be set when we get the WDK account address\n this.owners = config.additionalOwners ?? []\n }\n\n /**\n * Initialize the account (fetch WDK address)\n * Call this before using the account\n */\n async initialize(): Promise<void> {\n if (!this.cachedOwnerAddress) {\n const address = await this.wdkAccount.getAddress()\n this.cachedOwnerAddress = address as Address\n\n // Add WDK account as the first owner if not already in owners\n if (!this.owners.includes(this.cachedOwnerAddress)) {\n this.owners.unshift(this.cachedOwnerAddress)\n }\n }\n }\n\n /**\n * Get the WDK account's EOA address\n */\n async getOwnerAddress(): Promise<Address> {\n await this.initialize()\n return this.cachedOwnerAddress!\n }\n\n /**\n * Get the smart account address (counterfactual)\n */\n async getAddress(): Promise<Address> {\n await this.initialize()\n\n if (this.cachedAddress) {\n return this.cachedAddress\n }\n\n const initCode = await this.getInitCode()\n\n // If already deployed, get address from code\n if (initCode === '0x') {\n // Need to compute it anyway for first time\n const initializerData = await this.buildInitializer()\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n } else {\n // Extract initializer from init code\n const initializerData = `0x${initCode.slice(2 + 40 * 2)}` as Hex\n\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n }\n\n return this.cachedAddress\n }\n\n /**\n * Sign a UserOperation hash using the WDK account\n */\n async signUserOpHash(userOpHash: Hex): Promise<Hex> {\n await this.initialize()\n\n // Sign the hash using WDK account's signMessage\n // The hash is signed as raw bytes (personal_sign format)\n const signature = await this.wdkAccount.signMessage(userOpHash)\n\n // Format signature for Safe (add signature type byte)\n // Type 0: EOA signature\n return concat([signature as Hex, '0x00']) as Hex\n }\n\n /**\n * Get the account's init code for deployment\n */\n async getInitCode(): Promise<Hex> {\n await this.initialize()\n\n // Check if already deployed\n if (await this.isDeployed()) {\n return '0x' as Hex\n }\n\n if (this.cachedInitCode) {\n return this.cachedInitCode\n }\n\n const safeSetupData = await this.buildInitializer()\n\n // Build factory call data\n const createProxyData = encodeFunctionData({\n abi: PROXY_FACTORY_ABI,\n functionName: 'createProxyWithNonce',\n args: [SAFE_4337_ADDRESSES.singleton, safeSetupData, this.saltNonce],\n })\n\n // Init code = factory address + factory call data\n this.cachedInitCode = concat([SAFE_4337_ADDRESSES.proxyFactory, createProxyData]) as Hex\n\n return this.cachedInitCode\n }\n\n /**\n * Check if the account is deployed\n */\n async isDeployed(): Promise<boolean> {\n if (this.deploymentChecked) {\n return this.isAccountDeployed\n }\n\n await this.initialize()\n const address = this.cachedAddress ?? (await this.getAddress())\n const code = await this.publicClient.getCode({ address })\n\n this.deploymentChecked = true\n this.isAccountDeployed = code !== undefined && code !== '0x'\n\n return this.isAccountDeployed\n }\n\n /**\n * Encode a call to the account's execute function\n */\n encodeExecute(target: Address, value: bigint, data: Hex): Hex {\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOp',\n args: [target, value, data, 0], // operation: CALL\n })\n }\n\n /**\n * Encode a batch call to the account's executeBatch function\n */\n encodeExecuteBatch(targets: Address[], values: bigint[], datas: Hex[]): Hex {\n if (targets.length !== values.length || targets.length !== datas.length) {\n throw new Error('Array lengths must match')\n }\n\n const operations = targets.map(() => 0) // All CALL operations\n\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOpBatch',\n args: [targets, values, datas, operations],\n })\n }\n\n /**\n * Build the Safe setup initializer data\n */\n private async buildInitializer(): Promise<Hex> {\n await this.initialize()\n\n // Build Safe setup data with 4337 module\n const setupModulesData = encodeFunctionData({\n abi: ADD_MODULES_LIB_ABI,\n functionName: 'enableModules',\n args: [[SAFE_4337_ADDRESSES.module]],\n })\n\n return encodeFunctionData({\n abi: SAFE_ABI,\n functionName: 'setup',\n args: [\n this.owners,\n BigInt(this.threshold),\n SAFE_4337_ADDRESSES.addModulesLib, // to: AddModulesLib\n setupModulesData, // data: enableModules([module])\n SAFE_4337_ADDRESSES.fallbackHandler,\n '0x0000000000000000000000000000000000000000' as Address, // paymentToken\n 0n, // payment\n '0x0000000000000000000000000000000000000000' as Address, // paymentReceiver\n ],\n })\n }\n\n /**\n * Get the Safe's owners\n */\n getOwners(): Address[] {\n return [...this.owners]\n }\n\n /**\n * Get the Safe's threshold\n */\n getThreshold(): number {\n return this.threshold\n }\n\n /**\n * Clear cached values (useful after deployment)\n */\n clearCache(): void {\n this.cachedAddress = undefined\n this.cachedInitCode = undefined\n this.deploymentChecked = false\n this.isAccountDeployed = false\n }\n}\n\n/**\n * Create a WDK smart account\n */\nexport async function createWdkSmartAccount(\n config: WdkSmartAccountConfig,\n): Promise<WdkSmartAccount> {\n const account = new WdkSmartAccount(config)\n await account.initialize()\n return account\n}\n","/**\n * WDK Gasless Constants\n *\n * Addresses and configuration for gasless USDT0 payments.\n */\n\nimport type { Address } from 'viem'\n\n/**\n * USDT0 OFT addresses by chain\n */\nexport const USDT0_ADDRESSES: Record<string, Address> = {\n ethereum: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n arbitrum: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',\n ink: '0x0200C29006150606B650577BBE7B6248F58470c1',\n berachain: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736',\n unichain: '0x588ce4F028D8e7B53B687865d6A67b3A54C75518',\n base: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n optimism: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n} as const\n\n/**\n * USDC addresses by chain\n */\nexport const USDC_ADDRESSES: Record<string, Address> = {\n ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n arbitrum: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',\n base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n optimism: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',\n polygon: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',\n} as const\n\n/**\n * Chain IDs for supported networks\n */\nexport const CHAIN_IDS: Record<string, number> = {\n ethereum: 1,\n arbitrum: 42161,\n base: 8453,\n optimism: 10,\n polygon: 137,\n ink: 57073,\n berachain: 80084,\n unichain: 130,\n} as const\n\n/**\n * Default bundler URLs by chain (using public endpoints)\n */\nexport const DEFAULT_BUNDLER_URLS: Record<number, string> = {\n 1: 'https://api.pimlico.io/v2/ethereum/rpc',\n 42161: 'https://api.pimlico.io/v2/arbitrum/rpc',\n 8453: 'https://api.pimlico.io/v2/base/rpc',\n 10: 'https://api.pimlico.io/v2/optimism/rpc',\n 137: 'https://api.pimlico.io/v2/polygon/rpc',\n} as const\n\n/**\n * Get token address for a chain\n */\nexport function getTokenAddress(token: 'USDT0' | 'USDC' | Address, chainName: string): Address {\n if (token.startsWith('0x')) {\n return token as Address\n }\n\n const addresses = token === 'USDT0' ? USDT0_ADDRESSES : USDC_ADDRESSES\n const address = addresses[chainName.toLowerCase()]\n\n if (!address) {\n throw new Error(`Token ${token} not available on ${chainName}`)\n }\n\n return address\n}\n\n/**\n * Get chain name from chain ID\n */\nexport function getChainName(chainId: number): string {\n const entry = Object.entries(CHAIN_IDS).find(([, id]) => id === chainId)\n if (!entry) {\n throw new Error(`Unsupported chain ID: ${chainId}`)\n }\n return entry[0]\n}\n"],"mappings":";AAQA,SAAS,sBAAAA,qBAAoB,mBAAmB;AAChD,SAAS,eAAe,iBAAiB,eAAe,8BAA8B;;;ACDtF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQA,IAAM,sBAAsB;AAAA;AAAA,EAEjC,QAAQ;AAAA;AAAA,EAER,aAAa;AAAA;AAAA,EAEb,WAAW;AAAA;AAAA,EAEX,cAAc;AAAA;AAAA,EAEd,iBAAiB;AAAA;AAAA,EAEjB,eAAe;AACjB;A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pB,QAC2B;AAE3B,QAAM,eAAe,MAAM,sBAAsB;AAAA,IAC/C,YAAY,OAAO;AAAA,IACnB,cAAc,OAAO;AAAA,IACrB,SAAS,OAAO;AAAA,IAChB,WAAW,OAAO;AAAA,EACpB,CAAC;AAGD,SAAO,IAAI,iBAAiB;AAAA,IAC1B,QAAQ;AAAA,IACR,SAAS,OAAO;AAAA,IAChB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,cAAc,OAAO;AAAA,EACvB,CAAC;AACH;","names":["encodeFunctionData","encodeFunctionData"]}
|
|
1
|
+
{"version":3,"sources":["../../src/client.ts","../../src/account.ts","../../src/constants.ts"],"sourcesContent":["/**\n * WDK Gasless Client\n *\n * High-level client for executing gasless USDT0 payments using\n * Tether WDK accounts and ERC-4337 Account Abstraction.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport { encodeFunctionData, formatUnits } from 'viem'\nimport { BundlerClient, PaymasterClient, UserOpBuilder, ENTRYPOINT_V07_ADDRESS } from '@t402/evm'\nimport type {\n SmartAccountSigner,\n BundlerConfig,\n PaymasterConfig,\n TransactionIntent,\n GasEstimate,\n PaymasterData,\n} from '@t402/evm'\nimport type {\n WdkGaslessClientConfig,\n GaslessPaymentParams,\n BatchPaymentParams,\n GaslessPaymentResult,\n GaslessPaymentReceipt,\n SponsorshipInfo,\n WdkAccount,\n} from './types.js'\nimport { createWdkSmartAccount } from './account.js'\nimport { getTokenAddress, getChainName } from './constants.js'\n\n/**\n * ERC20 transfer ABI\n */\nconst ERC20_TRANSFER_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * ERC20 balanceOf ABI\n */\nconst ERC20_BALANCE_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Gasless Client\n *\n * Provides a simple API for executing gasless USDT0 payments using\n * WDK accounts and ERC-4337 smart accounts.\n */\nexport class WdkGaslessClient {\n private readonly signer: SmartAccountSigner\n private readonly builder: UserOpBuilder\n private readonly bundler: BundlerClient\n private readonly paymaster?: PaymasterClient\n private readonly chainId: number\n private readonly publicClient: PublicClient\n private readonly chainName: string\n\n constructor(config: WdkGaslessClientConfig) {\n this.signer = config.signer\n this.builder = new UserOpBuilder()\n this.bundler = new BundlerClient(config.bundler)\n this.paymaster = config.paymaster ? new PaymasterClient(config.paymaster) : undefined\n this.chainId = config.chainId\n this.publicClient = config.publicClient\n this.chainName = getChainName(config.chainId)\n }\n\n /**\n * Execute a gasless payment\n *\n * Sends USDT0 (or other tokens) without the user paying gas fees.\n * Gas is sponsored by a paymaster if configured.\n */\n async pay(params: GaslessPaymentParams): Promise<GaslessPaymentResult> {\n // Validate payment params\n if (!params.to || params.to === '0x0000000000000000000000000000000000000000') {\n throw new Error('Recipient address must not be the zero address')\n }\n\n if (params.amount <= 0n) {\n throw new Error('Payment amount must be greater than zero')\n }\n\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n // Build the transfer call data\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n // Create the transaction intent\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n\n // Estimate gas\n const gasEstimate = await this.estimateGas(intent)\n\n // Get paymaster data if configured\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build the UserOperation\n const userOp = await this.builder.buildUserOp(\n this.signer,\n intent,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign the UserOperation\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n // Submit to bundler\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Execute multiple payments in a single transaction\n *\n * More gas efficient than individual payments.\n * All payments are executed atomically.\n */\n async payBatch(params: BatchPaymentParams): Promise<GaslessPaymentResult> {\n // Validate batch params\n if (!params.payments || params.payments.length === 0) {\n throw new Error('Batch payments must contain at least one payment')\n }\n\n if (params.payments.length > 50) {\n throw new Error('Batch payments must not exceed 50 payments')\n }\n\n for (const payment of params.payments) {\n if (!payment.to || payment.to === '0x0000000000000000000000000000000000000000') {\n throw new Error('Recipient address must not be the zero address')\n }\n if (payment.amount <= 0n) {\n throw new Error('Payment amount must be greater than zero')\n }\n }\n\n // Build transaction intents for all payments\n const intents: TransactionIntent[] = params.payments.map((payment) => {\n const token = payment.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n return {\n to: tokenAddress,\n value: 0n,\n data: encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [payment.to, payment.amount],\n }),\n }\n })\n\n // Estimate gas for batch\n const gasEstimate = await this.estimateBatchGas(intents)\n\n // Get paymaster data\n const paymasterData = await this.getPaymasterData(gasEstimate)\n const sponsored = paymasterData !== undefined\n\n // Build batch UserOperation\n const userOp = await this.builder.buildBatchUserOp(\n this.signer,\n intents,\n this.publicClient,\n gasEstimate,\n paymasterData,\n )\n\n // Sign and submit\n const signedUserOp = await this.builder.signUserOp(\n userOp,\n this.signer,\n this.publicClient,\n this.chainId,\n )\n\n const result = await this.bundler.sendUserOperation(signedUserOp)\n const sender = await this.signer.getAddress()\n\n return {\n userOpHash: result.userOpHash,\n sender,\n sponsored,\n wait: async (): Promise<GaslessPaymentReceipt> => {\n const receipt = await result.wait()\n return {\n userOpHash: receipt.userOpHash,\n txHash: receipt.receipt.transactionHash,\n blockNumber: receipt.receipt.blockNumber,\n success: receipt.success,\n gasUsed: receipt.actualGasUsed,\n gasCost: receipt.actualGasCost,\n reason: receipt.reason,\n }\n },\n }\n }\n\n /**\n * Check if a payment can be sponsored (free gas)\n */\n async canSponsor(params: GaslessPaymentParams): Promise<SponsorshipInfo> {\n if (!this.paymaster) {\n return {\n canSponsor: false,\n reason: 'No paymaster configured',\n }\n }\n\n const token = params.token ?? 'USDT0'\n const tokenAddress = getTokenAddress(token, this.chainName)\n\n const callData = encodeFunctionData({\n abi: ERC20_TRANSFER_ABI,\n functionName: 'transfer',\n args: [params.to, params.amount],\n })\n\n const sender = await this.signer.getAddress()\n const encodedCallData = this.signer.encodeExecute(tokenAddress, 0n, callData)\n\n try {\n const canSponsor = await this.paymaster.willSponsor(\n { sender, callData: encodedCallData },\n this.chainId,\n ENTRYPOINT_V07_ADDRESS,\n )\n\n if (canSponsor) {\n return { canSponsor: true }\n } else {\n // Estimate gas cost if not sponsored\n const intent: TransactionIntent = {\n to: tokenAddress,\n value: 0n,\n data: callData,\n }\n const gasEstimate = await this.estimateGas(intent)\n const gasPrice = await this.publicClient.getGasPrice()\n const estimatedGasCost =\n (gasEstimate.verificationGasLimit +\n gasEstimate.callGasLimit +\n gasEstimate.preVerificationGas) *\n gasPrice\n\n return {\n canSponsor: false,\n reason: 'Payment not eligible for sponsorship',\n estimatedGasCost,\n }\n }\n } catch (error) {\n return {\n canSponsor: false,\n reason: error instanceof Error ? error.message : 'Unknown error',\n }\n }\n }\n\n /**\n * Get the smart account address\n */\n async getAccountAddress(): Promise<Address> {\n return this.signer.getAddress()\n }\n\n /**\n * Check if the smart account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n return this.signer.isDeployed()\n }\n\n /**\n * Get the token balance of the smart account\n */\n async getBalance(token: 'USDT0' | 'USDC' | Address = 'USDT0'): Promise<bigint> {\n const tokenAddress = getTokenAddress(token, this.chainName)\n const accountAddress = await this.signer.getAddress()\n\n const balance = await this.publicClient.readContract({\n address: tokenAddress,\n abi: ERC20_BALANCE_ABI,\n functionName: 'balanceOf',\n args: [accountAddress],\n })\n\n return balance as bigint\n }\n\n /**\n * Get the formatted token balance\n */\n async getFormattedBalance(\n token: 'USDT0' | 'USDC' | Address = 'USDT0',\n decimals = 6,\n ): Promise<string> {\n const balance = await this.getBalance(token)\n return formatUnits(balance, decimals)\n }\n\n /**\n * Estimate gas for a single transaction\n */\n private async estimateGas(intent: TransactionIntent): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecute(intent.to, intent.value ?? 0n, intent.data ?? '0x')\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults if estimation fails\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n,\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Estimate gas for a batch transaction\n */\n private async estimateBatchGas(intents: TransactionIntent[]): Promise<GasEstimate> {\n const sender = await this.signer.getAddress()\n const callData = this.signer.encodeExecuteBatch(\n intents.map((i) => i.to),\n intents.map((i) => i.value ?? 0n),\n intents.map((i) => (i.data ?? '0x') as Hex),\n )\n\n try {\n return await this.bundler.estimateUserOperationGas({\n sender,\n callData,\n })\n } catch {\n // Return defaults with multiplier for batch size\n return {\n verificationGasLimit: 150000n,\n callGasLimit: 100000n * BigInt(intents.length),\n preVerificationGas: 50000n,\n }\n }\n }\n\n /**\n * Get paymaster data if configured\n */\n private async getPaymasterData(_gasEstimate: GasEstimate): Promise<PaymasterData | undefined> {\n if (!this.paymaster) return undefined\n\n const sender = await this.signer.getAddress()\n\n return this.paymaster.getPaymasterData({ sender }, this.chainId, ENTRYPOINT_V07_ADDRESS)\n }\n}\n\n/**\n * Configuration for creating a WDK gasless client\n */\nexport interface CreateWdkGaslessClientConfig {\n /** WDK account to use as the signer */\n wdkAccount: WdkAccount\n /** Public client for chain interactions */\n publicClient: PublicClient\n /** Chain ID */\n chainId: number\n /** Bundler configuration */\n bundler: BundlerConfig\n /** Optional paymaster for gas sponsorship */\n paymaster?: PaymasterConfig\n /** Salt nonce for address generation (defaults to 0) */\n saltNonce?: bigint\n}\n\n/**\n * Create a WDK gasless client\n *\n * This is the main entry point for using WDK with gasless payments.\n *\n * @example\n * ```typescript\n * import { createWdkGaslessClient } from '@t402/wdk-gasless';\n *\n * const client = await createWdkGaslessClient({\n * wdkAccount: myWdkAccount,\n * publicClient,\n * chainId: 42161, // Arbitrum\n * bundler: {\n * bundlerUrl: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * chainId: 42161,\n * },\n * paymaster: {\n * address: '0x...',\n * url: 'https://api.pimlico.io/v2/arbitrum/rpc?apikey=...',\n * type: 'sponsoring',\n * },\n * });\n *\n * // Execute gasless payment\n * const result = await client.pay({\n * to: '0x...',\n * amount: 1000000n, // 1 USDT0\n * });\n *\n * const receipt = await result.wait();\n * console.log('Payment confirmed:', receipt.txHash);\n * ```\n */\nexport async function createWdkGaslessClient(\n config: CreateWdkGaslessClientConfig,\n): Promise<WdkGaslessClient> {\n // Create the WDK smart account\n const smartAccount = await createWdkSmartAccount({\n wdkAccount: config.wdkAccount,\n publicClient: config.publicClient,\n chainId: config.chainId,\n saltNonce: config.saltNonce,\n })\n\n // Create the gasless client\n return new WdkGaslessClient({\n signer: smartAccount,\n bundler: config.bundler,\n paymaster: config.paymaster,\n chainId: config.chainId,\n publicClient: config.publicClient,\n })\n}\n","/**\n * WDK Smart Account\n *\n * Wraps a Tether WDK account to work with ERC-4337 smart accounts.\n * Creates a Safe smart account with the WDK account as the owner/signer.\n */\n\nimport type { Address, Hex, PublicClient } from 'viem'\nimport {\n encodeFunctionData,\n encodeAbiParameters,\n concat,\n keccak256,\n getContractAddress,\n} from 'viem'\nimport type { SmartAccountSigner } from '@t402/evm'\nimport type { WdkAccount, WdkSmartAccountConfig } from './types.js'\n\n/**\n * Safe 4337 module addresses (v0.3.0)\n * Deployed on all major EVM chains at the same addresses\n */\nexport const SAFE_4337_ADDRESSES = {\n /** Safe 4337 Module */\n module: '0xa581c4A4DB7175302464fF3C06380BC3270b4037' as Address,\n /** Safe Module Setup */\n moduleSetup: '0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47' as Address,\n /** Safe Singleton */\n singleton: '0x29fcB43b46531BcA003ddC8FCB67FFE91900C762' as Address,\n /** Safe Proxy Factory */\n proxyFactory: '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67' as Address,\n /** Safe Fallback Handler */\n fallbackHandler: '0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99' as Address,\n /** Add Modules Lib */\n addModulesLib: '0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb' as Address,\n} as const\n\n/**\n * Safe Proxy Factory ABI\n */\nconst PROXY_FACTORY_ABI = [\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'createProxyWithNonce',\n outputs: [{ name: 'proxy', type: 'address' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'singleton', type: 'address' },\n { name: 'initializer', type: 'bytes' },\n { name: 'saltNonce', type: 'uint256' },\n ],\n name: 'proxyCreationCode',\n outputs: [{ name: '', type: 'bytes' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n\n/**\n * Safe Singleton ABI\n */\nconst SAFE_ABI = [\n {\n inputs: [\n { name: 'owners', type: 'address[]' },\n { name: 'threshold', type: 'uint256' },\n { name: 'to', type: 'address' },\n { name: 'data', type: 'bytes' },\n { name: 'fallbackHandler', type: 'address' },\n { name: 'paymentToken', type: 'address' },\n { name: 'payment', type: 'uint256' },\n { name: 'paymentReceiver', type: 'address' },\n ],\n name: 'setup',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Add Modules Lib ABI\n */\nconst ADD_MODULES_LIB_ABI = [\n {\n inputs: [{ name: 'modules', type: 'address[]' }],\n name: 'enableModules',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * Safe 4337 Module ABI\n */\nconst SAFE_4337_MODULE_ABI = [\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'data', type: 'bytes' },\n { name: 'operation', type: 'uint8' },\n ],\n name: 'executeUserOp',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'tos', type: 'address[]' },\n { name: 'values', type: 'uint256[]' },\n { name: 'datas', type: 'bytes[]' },\n { name: 'operations', type: 'uint8[]' },\n ],\n name: 'executeUserOpBatch',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n] as const\n\n/**\n * WDK Smart Account\n *\n * Creates a Safe smart account using a WDK account as the owner/signer.\n * Implements SmartAccountSigner for ERC-4337 compatibility.\n */\nexport class WdkSmartAccount implements SmartAccountSigner {\n private readonly wdkAccount: WdkAccount\n private readonly publicClient: PublicClient\n private readonly _chainId: number\n private readonly owners: Address[]\n private readonly threshold: number\n private readonly saltNonce: bigint\n\n private cachedAddress?: Address\n private cachedInitCode?: Hex\n private cachedOwnerAddress?: Address\n private deploymentChecked = false\n private isAccountDeployed = false\n\n constructor(config: WdkSmartAccountConfig) {\n this.wdkAccount = config.wdkAccount\n this.publicClient = config.publicClient\n this._chainId = config.chainId\n this.threshold = config.threshold ?? 1\n this.saltNonce = config.saltNonce ?? 0n\n\n // Owners will be set when we get the WDK account address\n this.owners = config.additionalOwners ?? []\n }\n\n /**\n * Initialize the account (fetch WDK address)\n * Call this before using the account\n */\n async initialize(): Promise<void> {\n if (!this.cachedOwnerAddress) {\n const address = await this.wdkAccount.getAddress()\n this.cachedOwnerAddress = address as Address\n\n // Add WDK account as the first owner if not already in owners\n if (!this.owners.includes(this.cachedOwnerAddress)) {\n this.owners.unshift(this.cachedOwnerAddress)\n }\n }\n }\n\n /**\n * Get the WDK account's EOA address\n */\n async getOwnerAddress(): Promise<Address> {\n await this.initialize()\n return this.cachedOwnerAddress!\n }\n\n /**\n * Get the chain ID\n */\n getChainId(): number {\n return this._chainId\n }\n\n /**\n * Get the smart account address (counterfactual)\n */\n async getAddress(): Promise<Address> {\n await this.initialize()\n\n if (this.cachedAddress) {\n return this.cachedAddress\n }\n\n const initCode = await this.getInitCode()\n\n // If already deployed, get address from code\n if (initCode === '0x') {\n // Need to compute it anyway for first time\n const initializerData = await this.buildInitializer()\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n } else {\n // Extract initializer from init code\n const initializerData = `0x${initCode.slice(2 + 40 * 2)}` as Hex\n\n const salt = keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'uint256' }],\n [keccak256(initializerData), this.saltNonce],\n ),\n )\n\n const proxyCreationCode = (await this.publicClient.readContract({\n address: SAFE_4337_ADDRESSES.proxyFactory,\n abi: PROXY_FACTORY_ABI,\n functionName: 'proxyCreationCode',\n args: [SAFE_4337_ADDRESSES.singleton, initializerData, this.saltNonce],\n })) as Hex\n\n this.cachedAddress = getContractAddress({\n bytecode: proxyCreationCode,\n from: SAFE_4337_ADDRESSES.proxyFactory,\n opcode: 'CREATE2',\n salt,\n })\n }\n\n return this.cachedAddress\n }\n\n /**\n * Sign a UserOperation hash using the WDK account\n */\n async signUserOpHash(userOpHash: Hex): Promise<Hex> {\n await this.initialize()\n\n // Sign the hash using WDK account's signMessage\n // The hash is signed as raw bytes (personal_sign format)\n const signature = await this.wdkAccount.signMessage(userOpHash)\n\n // Format signature for Safe (add signature type byte)\n // Type 0: EOA signature\n return concat([signature as Hex, '0x00']) as Hex\n }\n\n /**\n * Get the account's init code for deployment\n */\n async getInitCode(): Promise<Hex> {\n await this.initialize()\n\n // Check if already deployed\n if (await this.isDeployed()) {\n return '0x' as Hex\n }\n\n if (this.cachedInitCode) {\n return this.cachedInitCode\n }\n\n const safeSetupData = await this.buildInitializer()\n\n // Build factory call data\n const createProxyData = encodeFunctionData({\n abi: PROXY_FACTORY_ABI,\n functionName: 'createProxyWithNonce',\n args: [SAFE_4337_ADDRESSES.singleton, safeSetupData, this.saltNonce],\n })\n\n // Init code = factory address + factory call data\n this.cachedInitCode = concat([SAFE_4337_ADDRESSES.proxyFactory, createProxyData]) as Hex\n\n return this.cachedInitCode\n }\n\n /**\n * Check if the account is deployed\n */\n async isDeployed(): Promise<boolean> {\n if (this.deploymentChecked) {\n return this.isAccountDeployed\n }\n\n // Set flag early to break infinite recursion:\n // getAddress() → getInitCode() → isDeployed() → getAddress() → ...\n // Default assumption (not deployed) is correct for init code computation.\n this.deploymentChecked = true\n\n await this.initialize()\n const address = this.cachedAddress ?? (await this.getAddress())\n const code = await this.publicClient.getCode({ address })\n\n this.isAccountDeployed = code !== undefined && code !== '0x'\n\n return this.isAccountDeployed\n }\n\n /**\n * Encode a call to the account's execute function\n */\n encodeExecute(target: Address, value: bigint, data: Hex): Hex {\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOp',\n args: [target, value, data, 0], // operation: CALL\n })\n }\n\n /**\n * Encode a batch call to the account's executeBatch function\n */\n encodeExecuteBatch(targets: Address[], values: bigint[], datas: Hex[]): Hex {\n if (targets.length !== values.length || targets.length !== datas.length) {\n throw new Error('Array lengths must match')\n }\n\n const operations = targets.map(() => 0) // All CALL operations\n\n return encodeFunctionData({\n abi: SAFE_4337_MODULE_ABI,\n functionName: 'executeUserOpBatch',\n args: [targets, values, datas, operations],\n })\n }\n\n /**\n * Build the Safe setup initializer data\n */\n private async buildInitializer(): Promise<Hex> {\n await this.initialize()\n\n // Build Safe setup data with 4337 module\n const setupModulesData = encodeFunctionData({\n abi: ADD_MODULES_LIB_ABI,\n functionName: 'enableModules',\n args: [[SAFE_4337_ADDRESSES.module]],\n })\n\n return encodeFunctionData({\n abi: SAFE_ABI,\n functionName: 'setup',\n args: [\n this.owners,\n BigInt(this.threshold),\n SAFE_4337_ADDRESSES.addModulesLib, // to: AddModulesLib\n setupModulesData, // data: enableModules([module])\n SAFE_4337_ADDRESSES.fallbackHandler,\n '0x0000000000000000000000000000000000000000' as Address, // paymentToken\n 0n, // payment\n '0x0000000000000000000000000000000000000000' as Address, // paymentReceiver\n ],\n })\n }\n\n /**\n * Get the Safe's owners\n */\n getOwners(): Address[] {\n return [...this.owners]\n }\n\n /**\n * Get the Safe's threshold\n */\n getThreshold(): number {\n return this.threshold\n }\n\n /**\n * Clear cached values (useful after deployment)\n */\n clearCache(): void {\n this.cachedAddress = undefined\n this.cachedInitCode = undefined\n this.deploymentChecked = false\n this.isAccountDeployed = false\n }\n}\n\n/**\n * Create a WDK smart account\n */\nexport async function createWdkSmartAccount(\n config: WdkSmartAccountConfig,\n): Promise<WdkSmartAccount> {\n const account = new WdkSmartAccount(config)\n await account.initialize()\n return account\n}\n","/**\n * WDK Gasless Constants\n *\n * Addresses and configuration for gasless USDT0 payments.\n */\n\nimport type { Address } from 'viem'\n\n/**\n * USDT0 OFT addresses by chain\n */\nexport const USDT0_ADDRESSES: Record<string, Address> = {\n ethereum: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n arbitrum: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',\n ink: '0x0200C29006150606B650577BBE7B6248F58470c1',\n berachain: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736',\n unichain: '0x9151434b16b9763660705744891fA906F660EcC5',\n base: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n optimism: '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee',\n} as const\n\n/**\n * USDC addresses by chain\n */\nexport const USDC_ADDRESSES: Record<string, Address> = {\n ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n arbitrum: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',\n base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n optimism: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',\n polygon: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',\n} as const\n\n/**\n * Chain IDs for supported networks\n */\nexport const CHAIN_IDS: Record<string, number> = {\n ethereum: 1,\n arbitrum: 42161,\n base: 8453,\n optimism: 10,\n polygon: 137,\n ink: 57073,\n berachain: 80094,\n unichain: 130,\n} as const\n\n/**\n * Default bundler URLs by chain (using public endpoints)\n */\nexport const DEFAULT_BUNDLER_URLS: Record<number, string> = {\n 1: 'https://api.pimlico.io/v2/ethereum/rpc',\n 42161: 'https://api.pimlico.io/v2/arbitrum/rpc',\n 8453: 'https://api.pimlico.io/v2/base/rpc',\n 10: 'https://api.pimlico.io/v2/optimism/rpc',\n 137: 'https://api.pimlico.io/v2/polygon/rpc',\n} as const\n\n/**\n * Get token address for a chain\n */\nexport function getTokenAddress(token: 'USDT0' | 'USDC' | Address, chainName: string): Address {\n if (token.startsWith('0x')) {\n return token as Address\n }\n\n const addresses = token === 'USDT0' ? USDT0_ADDRESSES : USDC_ADDRESSES\n const address = addresses[chainName.toLowerCase()]\n\n if (!address) {\n throw new Error(`Token ${token} not available on ${chainName}`)\n }\n\n return address\n}\n\n/**\n * Get chain name from chain ID\n */\nexport function getChainName(chainId: number): string {\n const entry = Object.entries(CHAI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O,IAAI,iBAAiB;AAAA,IAC1B,QAAQ;AAAA,IACR,SAAS,OAAO;AAAA,IAChB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,cAAc,OAAO;AAAA,EACvB,CAAC;AACH;","names":["encodeFunctionData","encodeFunctionData"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t402/wdk-gasless",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/cjs/index.d.ts",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"description": "Gasless USDT0 payments with Tether WDK and ERC-4337 Account Abstraction",
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@eslint/js": "^9.24.0",
|
|
25
|
-
"@types/node": "^
|
|
25
|
+
"@types/node": "^25.2.0",
|
|
26
26
|
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
|
27
27
|
"@typescript-eslint/parser": "^8.29.1",
|
|
28
28
|
"eslint": "^9.24.0",
|
|
29
29
|
"eslint-plugin-import": "^2.31.0",
|
|
30
|
-
"eslint-plugin-jsdoc": "^
|
|
30
|
+
"eslint-plugin-jsdoc": "^62.5.0",
|
|
31
31
|
"eslint-plugin-prettier": "^5.2.6",
|
|
32
32
|
"glob": "^13.0.0",
|
|
33
33
|
"prettier": "3.5.2",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"vitest": "^3.2.4"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@t402/core": "2.
|
|
43
|
-
"@t402/
|
|
44
|
-
"@t402/
|
|
42
|
+
"@t402/core": "2.4.0",
|
|
43
|
+
"@t402/wdk": "2.4.0",
|
|
44
|
+
"@t402/evm": "2.4.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"viem": "^2.0.0",
|