@1llet.xyz/erc4337-gasless-sdk 0.4.5 → 0.4.6
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 +19 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +79 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,10 @@ await aa.connect();
|
|
|
29
29
|
|
|
30
30
|
### 2. Initialize & Connect
|
|
31
31
|
|
|
32
|
+
Two modes are supported: **Browser (MetaMask)** and **Server/Script (Private Key)**.
|
|
33
|
+
|
|
34
|
+
#### Option A: Browser (MetaMask)
|
|
35
|
+
|
|
32
36
|
```typescript
|
|
33
37
|
import { AccountAbstraction } from "@1llet.xyz/erc4337-gasless-sdk";
|
|
34
38
|
|
|
@@ -42,6 +46,21 @@ console.log("EOA Owner:", owner);
|
|
|
42
46
|
console.log("Smart Account:", smartAccount);
|
|
43
47
|
```
|
|
44
48
|
|
|
49
|
+
#### Option B: Server / Backend (Private Key)
|
|
50
|
+
|
|
51
|
+
Initialize with a private key to sign transactions locally (no popup). Useful for bots or backends.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const PRIVATE_KEY = "0x..."; // Your EOA Private Key
|
|
55
|
+
|
|
56
|
+
// Connect using the private key
|
|
57
|
+
const { owner, smartAccount } = await aa.connect(PRIVATE_KEY);
|
|
58
|
+
|
|
59
|
+
console.log("Local Signer:", owner);
|
|
60
|
+
// seamless transaction execution...
|
|
61
|
+
await aa.transfer("USDC", recipient, amount);
|
|
62
|
+
```
|
|
63
|
+
|
|
45
64
|
### 3. Send a Gasless Transaction
|
|
46
65
|
|
|
47
66
|
Send a transaction where the Gas is paid by the Paymaster (sponsored).
|
package/dist/index.d.mts
CHANGED
|
@@ -60,15 +60,17 @@ declare class AccountAbstraction {
|
|
|
60
60
|
private chainConfig;
|
|
61
61
|
private publicClient;
|
|
62
62
|
private bundlerClient;
|
|
63
|
+
private walletClient;
|
|
63
64
|
private tokenService;
|
|
64
65
|
private userOpBuilder;
|
|
65
66
|
private entryPointAddress;
|
|
66
67
|
private factoryAddress;
|
|
67
68
|
constructor(chainConfig: ChainConfig);
|
|
68
69
|
/**
|
|
69
|
-
* Connect to MetaMask
|
|
70
|
+
* Connect to MetaMask OR use Private Key
|
|
71
|
+
* @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
|
|
70
72
|
*/
|
|
71
|
-
connect(): Promise<{
|
|
73
|
+
connect(privateKey?: Hex): Promise<{
|
|
72
74
|
owner: Address;
|
|
73
75
|
smartAccount: Address;
|
|
74
76
|
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -60,15 +60,17 @@ declare class AccountAbstraction {
|
|
|
60
60
|
private chainConfig;
|
|
61
61
|
private publicClient;
|
|
62
62
|
private bundlerClient;
|
|
63
|
+
private walletClient;
|
|
63
64
|
private tokenService;
|
|
64
65
|
private userOpBuilder;
|
|
65
66
|
private entryPointAddress;
|
|
66
67
|
private factoryAddress;
|
|
67
68
|
constructor(chainConfig: ChainConfig);
|
|
68
69
|
/**
|
|
69
|
-
* Connect to MetaMask
|
|
70
|
+
* Connect to MetaMask OR use Private Key
|
|
71
|
+
* @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
|
|
70
72
|
*/
|
|
71
|
-
connect(): Promise<{
|
|
73
|
+
connect(privateKey?: Hex): Promise<{
|
|
72
74
|
owner: Address;
|
|
73
75
|
smartAccount: Address;
|
|
74
76
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
34
34
|
|
|
35
35
|
// src/AccountAbstraction.ts
|
|
36
36
|
var import_viem3 = require("viem");
|
|
37
|
+
var import_accounts = require("viem/accounts");
|
|
37
38
|
|
|
38
39
|
// src/constants.ts
|
|
39
40
|
var factoryAbi = [
|
|
@@ -440,6 +441,7 @@ var AccountAbstraction = class {
|
|
|
440
441
|
constructor(chainConfig) {
|
|
441
442
|
this.owner = null;
|
|
442
443
|
this.smartAccountAddress = null;
|
|
444
|
+
this.walletClient = null;
|
|
443
445
|
this.chainConfig = chainConfig;
|
|
444
446
|
if (!chainConfig.entryPointAddress) throw new Error("EntryPoint address required");
|
|
445
447
|
this.entryPointAddress = chainConfig.entryPointAddress;
|
|
@@ -455,47 +457,59 @@ var AccountAbstraction = class {
|
|
|
455
457
|
this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);
|
|
456
458
|
}
|
|
457
459
|
/**
|
|
458
|
-
* Connect to MetaMask
|
|
460
|
+
* Connect to MetaMask OR use Private Key
|
|
461
|
+
* @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
|
|
459
462
|
*/
|
|
460
|
-
async connect() {
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
463
|
+
async connect(privateKey) {
|
|
464
|
+
if (privateKey) {
|
|
465
|
+
const account = (0, import_accounts.privateKeyToAccount)(privateKey);
|
|
466
|
+
this.owner = account.address;
|
|
467
|
+
const rpcUrl = this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0];
|
|
468
|
+
this.walletClient = (0, import_viem3.createWalletClient)({
|
|
469
|
+
account,
|
|
470
|
+
chain: this.chainConfig.chain,
|
|
471
|
+
transport: (0, import_viem3.http)(rpcUrl)
|
|
472
|
+
});
|
|
473
|
+
} else {
|
|
474
|
+
if (typeof window === "undefined" || !window.ethereum) {
|
|
475
|
+
throw new Error("MetaMask is not installed and no private key provided");
|
|
476
|
+
}
|
|
477
|
+
const accounts = await window.ethereum.request({
|
|
478
|
+
method: "eth_requestAccounts"
|
|
479
|
+
});
|
|
480
|
+
if (!accounts || accounts.length === 0) throw new Error("No accounts found");
|
|
481
|
+
const chainId = await window.ethereum.request({
|
|
482
|
+
method: "eth_chainId"
|
|
483
|
+
});
|
|
484
|
+
const targetChainId = this.chainConfig.chain.id;
|
|
485
|
+
if (parseInt(chainId, 16) !== targetChainId) {
|
|
486
|
+
try {
|
|
481
487
|
await window.ethereum.request({
|
|
482
|
-
method: "
|
|
483
|
-
params: [
|
|
484
|
-
{
|
|
485
|
-
chainId: "0x" + targetChainId.toString(16),
|
|
486
|
-
chainName: this.chainConfig.chain.name,
|
|
487
|
-
nativeCurrency: this.chainConfig.chain.nativeCurrency,
|
|
488
|
-
rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],
|
|
489
|
-
blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url ? [this.chainConfig.chain.blockExplorers.default.url] : []
|
|
490
|
-
}
|
|
491
|
-
]
|
|
488
|
+
method: "wallet_switchEthereumChain",
|
|
489
|
+
params: [{ chainId: "0x" + targetChainId.toString(16) }]
|
|
492
490
|
});
|
|
493
|
-
}
|
|
494
|
-
|
|
491
|
+
} catch (switchError) {
|
|
492
|
+
const error = switchError;
|
|
493
|
+
if (error.code === 4902) {
|
|
494
|
+
await window.ethereum.request({
|
|
495
|
+
method: "wallet_addEthereumChain",
|
|
496
|
+
params: [
|
|
497
|
+
{
|
|
498
|
+
chainId: "0x" + targetChainId.toString(16),
|
|
499
|
+
chainName: this.chainConfig.chain.name,
|
|
500
|
+
nativeCurrency: this.chainConfig.chain.nativeCurrency,
|
|
501
|
+
rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],
|
|
502
|
+
blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url ? [this.chainConfig.chain.blockExplorers.default.url] : []
|
|
503
|
+
}
|
|
504
|
+
]
|
|
505
|
+
});
|
|
506
|
+
} else {
|
|
507
|
+
throw switchError;
|
|
508
|
+
}
|
|
495
509
|
}
|
|
496
510
|
}
|
|
511
|
+
this.owner = accounts[0];
|
|
497
512
|
}
|
|
498
|
-
this.owner = accounts[0];
|
|
499
513
|
this.smartAccountAddress = await this.getSmartAccountAddress(this.owner);
|
|
500
514
|
return {
|
|
501
515
|
owner: this.owner,
|
|
@@ -581,6 +595,15 @@ var AccountAbstraction = class {
|
|
|
581
595
|
}
|
|
582
596
|
async deposit(amount) {
|
|
583
597
|
if (!this.owner || !this.smartAccountAddress) throw new Error("Not connected");
|
|
598
|
+
if (this.walletClient) {
|
|
599
|
+
return await this.walletClient.sendTransaction({
|
|
600
|
+
account: this.walletClient.account,
|
|
601
|
+
to: this.smartAccountAddress,
|
|
602
|
+
value: amount,
|
|
603
|
+
chain: this.chainConfig.chain
|
|
604
|
+
// Explicit chain
|
|
605
|
+
});
|
|
606
|
+
}
|
|
584
607
|
const txHash = await window.ethereum.request({
|
|
585
608
|
method: "eth_sendTransaction",
|
|
586
609
|
params: [{
|
|
@@ -615,6 +638,14 @@ var AccountAbstraction = class {
|
|
|
615
638
|
const support = await this.requestApprovalSupport(token, spender, amount);
|
|
616
639
|
if (support.type === "approve") {
|
|
617
640
|
const data = this.tokenService.encodeApprove(spender, amount);
|
|
641
|
+
if (this.walletClient) {
|
|
642
|
+
return await this.walletClient.sendTransaction({
|
|
643
|
+
account: this.walletClient.account,
|
|
644
|
+
to: token,
|
|
645
|
+
data,
|
|
646
|
+
chain: this.chainConfig.chain
|
|
647
|
+
});
|
|
648
|
+
}
|
|
618
649
|
const txHash = await window.ethereum.request({
|
|
619
650
|
method: "eth_sendTransaction",
|
|
620
651
|
params: [{
|
|
@@ -642,10 +673,19 @@ var AccountAbstraction = class {
|
|
|
642
673
|
async signUserOperation(userOp) {
|
|
643
674
|
if (!this.owner) throw new Error("Not connected");
|
|
644
675
|
const userOpHash = this.userOpBuilder.getUserOpHash(userOp);
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
676
|
+
let signature;
|
|
677
|
+
if (this.walletClient) {
|
|
678
|
+
signature = await this.walletClient.signMessage({
|
|
679
|
+
account: this.walletClient.account,
|
|
680
|
+
message: { raw: userOpHash }
|
|
681
|
+
// Sign hash directly
|
|
682
|
+
});
|
|
683
|
+
} else {
|
|
684
|
+
signature = await window.ethereum.request({
|
|
685
|
+
method: "personal_sign",
|
|
686
|
+
params: [userOpHash, this.owner]
|
|
687
|
+
});
|
|
688
|
+
}
|
|
649
689
|
return { ...userOp, signature };
|
|
650
690
|
}
|
|
651
691
|
async sendUserOperation(userOp) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/AccountAbstraction.ts","../src/constants.ts","../src/BundlerClient.ts","../src/TokenService.ts","../src/UserOpBuilder.ts","../src/chains.ts"],"sourcesContent":["// Core\nexport { AccountAbstraction } from \"./AccountAbstraction\";\nexport { BundlerClient } from \"./BundlerClient\";\n\n// Config & Registry\nexport { BASE_MAINNET, BASE_SEPOLIA, GNOSIS_MAINNET, CHAIN_CONFIGS } from \"./chains\";\n\n// Types\nexport type { ChainConfig, Token, UserOperation, UserOpReceipt, GasEstimate, ApprovalSupportResult } from \"./types\";\n\n// Constants (ABIs)\nexport { erc20Abi, smartAccountAbi, entryPointAbi } from \"./constants\";\n","import {\n createPublicClient,\n http,\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n decodeErrorResult\n} from \"viem\";\nimport {\n factoryAbi,\n} from \"./constants\";\nimport {\n type ChainConfig,\n type UserOperation,\n type UserOpReceipt,\n type ApprovalSupportResult,\n type Token\n} from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { TokenService } from \"./TokenService\";\nimport { UserOpBuilder } from \"./UserOpBuilder\";\n\n/**\n * ERC-4337 Account Abstraction Client\n */\nexport class AccountAbstraction {\n private owner: Address | null = null;\n private smartAccountAddress: Address | null = null;\n private chainConfig: ChainConfig;\n private publicClient: PublicClient;\n private bundlerClient: BundlerClient;\n\n // Services\n private tokenService: TokenService;\n private userOpBuilder: UserOpBuilder;\n\n // Resolved addresses\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(chainConfig: ChainConfig) {\n this.chainConfig = chainConfig;\n\n // Validation\n if (!chainConfig.entryPointAddress) throw new Error(\"EntryPoint address required\");\n this.entryPointAddress = chainConfig.entryPointAddress;\n if (!chainConfig.factoryAddress) throw new Error(\"Factory address required\");\n this.factoryAddress = chainConfig.factoryAddress;\n\n // Setup Clients\n const rpcUrl = chainConfig.rpcUrl || chainConfig.chain.rpcUrls.default.http[0];\n this.publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n });\n\n this.bundlerClient = new BundlerClient(chainConfig, this.entryPointAddress);\n\n // Setup Services\n this.tokenService = new TokenService(chainConfig, this.publicClient);\n this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);\n }\n\n /**\n * Connect to MetaMask and get the owner address\n */\n async connect(): Promise<{ owner: Address; smartAccount: Address }> {\n if (typeof window === \"undefined\" || !window.ethereum) {\n throw new Error(\"MetaMask is not installed\");\n }\n\n // Request account access\n const accounts = (await window.ethereum.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n\n if (!accounts || accounts.length === 0) throw new Error(\"No accounts found\");\n\n // Check network\n const chainId = (await window.ethereum.request({\n method: \"eth_chainId\",\n })) as string;\n const targetChainId = this.chainConfig.chain.id;\n\n if (parseInt(chainId, 16) !== targetChainId) {\n try {\n await window.ethereum.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: \"0x\" + targetChainId.toString(16) }],\n });\n } catch (switchError: unknown) {\n const error = switchError as { code?: number };\n if (error.code === 4902) {\n await window.ethereum.request({\n method: \"wallet_addEthereumChain\",\n params: [\n {\n chainId: \"0x\" + targetChainId.toString(16),\n chainName: this.chainConfig.chain.name,\n nativeCurrency: this.chainConfig.chain.nativeCurrency,\n rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],\n blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url\n ? [this.chainConfig.chain.blockExplorers.default.url]\n : [],\n },\n ],\n });\n } else {\n throw switchError;\n }\n }\n }\n\n this.owner = accounts[0] as Address;\n this.smartAccountAddress = await this.getSmartAccountAddress(this.owner);\n\n return {\n owner: this.owner,\n smartAccount: this.smartAccountAddress,\n };\n }\n\n /**\n * Get the Smart Account address for an owner\n */\n async getSmartAccountAddress(owner: Address): Promise<Address> {\n const address = await this.publicClient.readContract({\n address: this.factoryAddress,\n abi: factoryAbi,\n functionName: \"getAccountAddress\",\n args: [owner, 0n],\n }) as Address;\n return address;\n }\n\n /**\n * Check if the Smart Account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.isAccountDeployed(this.smartAccountAddress);\n }\n\n // --- Token Methods (Delegated) ---\n\n getTokenAddress(token: string | Address): Address {\n return this.tokenService.getTokenAddress(token);\n }\n\n async getBalance(token: string | Address): Promise<bigint> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.smartAccountAddress);\n }\n\n async getEoaBalance(token: string | Address): Promise<bigint> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.owner);\n }\n\n // Deprecated helpers maintained for compatibility\n async getUsdcBalance(): Promise<bigint> { return this.getBalance(\"USDC\"); }\n async getEoaUsdcBalance(): Promise<bigint> { return this.getEoaBalance(\"USDC\"); }\n\n async getAllowance(token: string | Address = \"USDC\"): Promise<bigint> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getAllowance(token, this.owner, this.smartAccountAddress);\n }\n\n // --- Transactions ---\n\n async deployAccount(): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n try {\n const userOp = await this.userOpBuilder.buildDeployUserOp(this.owner, this.smartAccountAddress);\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async sendTransaction(\n tx: { target: Address; value?: bigint; data?: Hex }\n ): Promise<UserOpReceipt> {\n return this.sendBatchTransaction([tx]);\n }\n\n async sendBatchTransaction(\n txs: { target: Address; value?: bigint; data?: Hex }[]\n ): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n // Normalize\n const transactions = txs.map(tx => ({\n target: tx.target,\n value: tx.value ?? 0n,\n data: tx.data ?? \"0x\"\n }));\n\n try {\n const userOp = await this.userOpBuilder.buildUserOperationBatch(\n this.owner,\n this.smartAccountAddress,\n transactions\n );\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async deposit(amount: bigint): Promise<Hash> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: this.smartAccountAddress,\n value: \"0x\" + amount.toString(16)\n }]\n }) as Hash;\n return txHash;\n }\n\n async transfer(\n token: Address | string,\n recipient: Address,\n amount: bigint\n ): Promise<UserOpReceipt> {\n const tokenAddress = this.getTokenAddress(token);\n\n // Native Transfer check\n if (tokenAddress === \"0x0000000000000000000000000000000000000000\") {\n return this.sendTransaction({\n target: recipient,\n value: amount,\n data: \"0x\"\n });\n }\n\n // ERC-20\n const data = this.tokenService.encodeTransfer(recipient, amount);\n return this.sendTransaction({\n target: tokenAddress,\n value: 0n,\n data\n });\n }\n\n /**\n * Approve a token for the Smart Account\n */\n async approveToken(\n token: Address,\n spender: Address,\n amount: bigint = 115792089237316195423570985008687907853269984665640564039457584007913129639935n // maxUint256\n ): Promise<Hash | \"NOT_NEEDED\"> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const support = await this.requestApprovalSupport(token, spender, amount);\n\n if (support.type === \"approve\") {\n const data = this.tokenService.encodeApprove(spender, amount);\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: token,\n data,\n }]\n }) as Hash;\n return txHash;\n }\n\n if (support.type === \"permit\") throw new Error(\"Permit not yet supported\");\n return \"NOT_NEEDED\";\n }\n\n // --- Core Bridge to Bundler/UserOp ---\n\n // Deprecated/Legacy but kept for compatibility or advanced usage?\n // buildUserOperationBatch moved to internal usage mostly, but maybe exposed?\n // If I remove them from public API, that is a BREAKING change if user used them.\n // User requested \"modularize\", but usually expects same public API.\n // I will expose them as simple delegates if needed, or assume they primarily use sendBatchTransaction.\n // The previous implementation exposed `buildUserOperationBatch`.\n async buildUserOperationBatch(transactions: any[]) {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.buildUserOperationBatch(this.owner, this.smartAccountAddress, transactions);\n }\n\n async signUserOperation(userOp: UserOperation): Promise<UserOperation> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const userOpHash = this.userOpBuilder.getUserOpHash(userOp);\n\n const signature = (await window.ethereum!.request({\n method: \"personal_sign\",\n params: [userOpHash, this.owner],\n })) as Hex;\n\n return { ...userOp, signature };\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return this.bundlerClient.sendUserOperation(userOp);\n }\n\n async waitForUserOperation(hash: Hash, timeout = 60000) {\n return this.bundlerClient.waitForUserOperation(hash, timeout);\n }\n\n // Internal but exposed via BundlerClient originally\n async requestApprovalSupport(token: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.bundlerClient.requestApprovalSupport(token, this.owner, spender, amount);\n }\n\n // Error Decoding (Private)\n private decodeError(error: any): Error {\n const msg = error?.message || \"\";\n const hexMatch = msg.match(/(0x[0-9a-fA-F]+)/);\n\n if (hexMatch) {\n try {\n const decoded = decodeErrorResult({\n abi: [{ inputs: [{ name: \"message\", type: \"string\" }], name: \"Error\", type: \"error\" }],\n data: hexMatch[0] as Hex\n });\n if (decoded.errorName === \"Error\") return new Error(`Smart Account Error: ${decoded.args[0]}`);\n } catch (e) { /* ignore */ }\n }\n\n if (msg.includes(\"AA21\")) return new Error(\"Smart Account: Native transfer failed (ETH missing?)\");\n if (msg.includes(\"AA25\")) return new Error(\"Smart Account: Invalid account nonce\");\n\n return error instanceof Error ? error : new Error(String(error));\n }\n\n // Getters\n getOwner() { return this.owner; }\n getSmartAccount() { return this.smartAccountAddress; }\n}\n\n// Global window types for MetaMask\ndeclare global {\n interface Window {\n ethereum?: {\n request: (args: { method: string; params?: unknown[] }) => Promise<unknown>;\n on: (event: string, callback: (args: unknown) => void) => void;\n removeListener: (event: string, callback: (args: unknown) => void) => void;\n };\n }\n}\n","export const DEFAULT_ENTRYPOINT = \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\nexport const DEFAULT_FACTORY = \"0x9406Cc6185a346906296840746125a0E44976454\"; // SimpleAccountFactory v0.6\n\nexport const factoryAbi = [\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"getAccountAddress\",\n outputs: [{ name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"isAccountDeployed\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"createAccount\",\n outputs: [{ name: \"account\", type: \"address\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const entryPointAbi = [\n {\n inputs: [\n { name: \"sender\", type: \"address\" },\n { name: \"key\", type: \"uint192\" },\n ],\n name: \"getNonce\",\n outputs: [{ name: \"nonce\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\nexport const smartAccountAbi = [\n {\n inputs: [\n { name: \"target\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"data\", type: \"bytes\" },\n ],\n name: \"execute\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"targets\", type: \"address[]\" },\n { name: \"values\", type: \"uint256[]\" },\n { name: \"datas\", type: \"bytes[]\" },\n ],\n name: \"executeBatch\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const erc20Abi = [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"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 {\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"decimals\",\n outputs: [{ name: \"\", type: \"uint8\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n","import { type Address, type Hash } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\n\nexport class BundlerClient {\n private bundlerUrl: string;\n private chainId: number;\n private entryPointAddress: Address;\n\n constructor(config: ChainConfig, entryPointAddress: Address) {\n this.bundlerUrl = config.bundlerUrl;\n this.chainId = config.chain.id;\n this.entryPointAddress = entryPointAddress;\n }\n\n private async call(method: string, params: any[]): Promise<any> {\n const response = await fetch(this.bundlerUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method,\n params,\n }),\n });\n\n const result = await response.json();\n if (result.error) {\n throw new Error(result.error.message);\n }\n return result.result;\n }\n\n async estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate> {\n return await this.call(\"eth_estimateUserOperationGas\", [\n {\n sender: userOp.sender,\n nonce: userOp.nonce ? \"0x\" + userOp.nonce.toString(16) : \"0x0\",\n initCode: userOp.initCode || \"0x\",\n callData: userOp.callData || \"0x\",\n paymasterAndData: userOp.paymasterAndData || \"0x\",\n signature: \"0x\",\n },\n this.entryPointAddress,\n ]);\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return await this.call(\"eth_sendUserOperation\", [\n {\n sender: userOp.sender,\n nonce: \"0x\" + userOp.nonce.toString(16),\n initCode: userOp.initCode,\n callData: userOp.callData,\n callGasLimit: \"0x\" + userOp.callGasLimit.toString(16),\n verificationGasLimit: \"0x\" + userOp.verificationGasLimit.toString(16),\n preVerificationGas: \"0x\" + userOp.preVerificationGas.toString(16),\n maxFeePerGas: \"0x\" + userOp.maxFeePerGas.toString(16),\n maxPriorityFeePerGas: \"0x\" + userOp.maxPriorityFeePerGas.toString(16),\n paymasterAndData: userOp.paymasterAndData,\n signature: userOp.signature,\n },\n this.entryPointAddress,\n ]);\n }\n\n async waitForUserOperation(userOpHash: Hash, timeout = 60000): Promise<UserOpReceipt> {\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n const result = await this.call(\"eth_getUserOperationReceipt\", [userOpHash]);\n\n if (result) {\n return result as UserOpReceipt;\n }\n\n // Wait 2 seconds before polling again\n await new Promise((resolve) => setTimeout(resolve, 2000));\n }\n\n throw new Error(\"Timeout waiting for UserOperation\");\n }\n\n async requestApprovalSupport(token: Address, owner: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n return await this.call(\"pm_requestApprovalSupport\", [\n token,\n owner,\n spender,\n amount.toString()\n ]);\n }\n}\n","import { type Address, type PublicClient, encodeFunctionData } from \"viem\";\nimport { type ChainConfig, type Token } from \"./types\";\nimport { erc20Abi } from \"./constants\";\n\nexport class TokenService {\n private tokens: Map<string, Token> = new Map();\n private publicClient: PublicClient;\n\n constructor(chainConfig: ChainConfig, publicClient: PublicClient) {\n this.publicClient = publicClient;\n\n // Initialize Tokens\n chainConfig.tokens.forEach(token => {\n this.tokens.set(token.symbol.toUpperCase(), token);\n });\n }\n\n /**\n * Resolve token address from symbol or return address if provided\n */\n getTokenAddress(token: string | Address): Address {\n // Native Token (ETH)\n if (token === \"ETH\") {\n return \"0x0000000000000000000000000000000000000000\";\n }\n\n if (token.startsWith(\"0x\")) return token as Address;\n const info = this.tokens.get(token.toUpperCase());\n if (!info) throw new Error(`Token ${token} not found in chain config`);\n return info.address;\n }\n\n /**\n * Get balance of a token for an account\n */\n async getBalance(token: string | Address, account: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n // Native Balance\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return await this.publicClient.getBalance({ address: account });\n }\n\n // ERC-20 Balance\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [account],\n }) as bigint;\n }\n\n /**\n * Get allowance (ERC-20 only)\n */\n async getAllowance(token: string | Address, owner: Address, spender: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return 0n; // Native token has no allowance\n }\n\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n }) as bigint;\n }\n\n /**\n * Encode transfer data\n */\n encodeTransfer(recipient: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [recipient, amount]\n });\n }\n\n /**\n * Encode approve data\n */\n encodeApprove(spender: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount]\n });\n }\n}\n","import {\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n encodeFunctionData,\n encodeAbiParameters,\n keccak256\n} from \"viem\";\nimport { type ChainConfig, type UserOperation } from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { factoryAbi, smartAccountAbi, entryPointAbi } from \"./constants\";\n\nexport class UserOpBuilder {\n private chainConfig: ChainConfig;\n private bundlerClient: BundlerClient;\n private publicClient: PublicClient;\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(\n chainConfig: ChainConfig,\n bundlerClient: BundlerClient,\n publicClient: PublicClient\n ) {\n this.chainConfig = chainConfig;\n this.bundlerClient = bundlerClient;\n this.publicClient = publicClient;\n\n // Resolved in AA or here? Let's assume passed valid config or resolve again\n // Ideally we shouldn't duplicate logic. AA resolves them.\n // Let's rely on config having them or resolving valid ones.\n // For now take from config or defaults.\n this.entryPointAddress = chainConfig.entryPointAddress!; // Assumed validated by AA\n this.factoryAddress = chainConfig.factoryAddress!;\n }\n\n async getNonce(smartAccountAddress: Address): Promise<bigint> {\n return await this.publicClient.readContract({\n address: this.entryPointAddress,\n abi: entryPointAbi,\n functionName: \"getNonce\",\n args: [smartAccountAddress, 0n],\n }) as bigint;\n }\n\n buildInitCode(owner: Address): Hex {\n const createAccountData = encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [owner, 0n],\n });\n return `${this.factoryAddress}${createAccountData.slice(2)}` as Hex;\n }\n\n async isAccountDeployed(smartAccountAddress: Address): Promise<boolean> {\n const code = await this.publicClient.getCode({\n address: smartAccountAddress,\n });\n return code !== undefined && code !== \"0x\";\n }\n\n async buildUserOperationBatch(\n owner: Address,\n smartAccountAddress: Address,\n transactions: { target: Address; value: bigint; data: Hex }[]\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n const initCode = isDeployed ? \"0x\" : this.buildInitCode(owner);\n\n const targets = transactions.map((tx) => tx.target);\n const values = transactions.map((tx) => tx.value);\n const datas = transactions.map((tx) => tx.data);\n\n const callData = encodeFunctionData({\n abi: smartAccountAbi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n async buildDeployUserOp(\n owner: Address,\n smartAccountAddress: Address\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n if (isDeployed) throw new Error(\"Account already deployed\");\n\n const initCode = this.buildInitCode(owner);\n const callData = \"0x\";\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData: callData as Hex,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n getUserOpHash(userOp: UserOperation): Hex {\n const packed = encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n ],\n [\n userOp.sender,\n userOp.nonce,\n keccak256(userOp.initCode),\n keccak256(userOp.callData),\n userOp.callGasLimit,\n userOp.verificationGasLimit,\n userOp.preVerificationGas,\n userOp.maxFeePerGas,\n userOp.maxPriorityFeePerGas,\n keccak256(userOp.paymasterAndData),\n ]\n );\n\n const packedHash = keccak256(packed);\n\n return keccak256(\n encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }, { type: \"uint256\" }],\n [packedHash, this.entryPointAddress, BigInt(this.chainConfig.chain.id)]\n )\n );\n }\n}\n","import { type ChainConfig } from \"./types\";\nimport { base, baseSepolia, gnosis } from \"viem/chains\";\n\nconst DEFAULT_BUNDLER_URL = \"https://bundler-erc-4337.vercel.app\";\nconst BUNDLER_URL = process.env.NEXT_PUBLIC_BUNDLER_URL || process.env.BUNDLER_URL || DEFAULT_BUNDLER_URL;\n\n\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=base`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xe2584152891E4769025807DEa0cD611F135aDC68\",\n paymasterAddress: \"0x1e13Eb16C565E3f3FDe49A011755e50410bb1F95\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const GNOSIS_MAINNET: ChainConfig = {\n chain: gnosis,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=gnosis`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xC8a2Fb1f2E686417A131E09be3320cb5431CcD90\",\n paymasterAddress: \"0x4C36C70d68a7c26326711e8268bb163E3784fA96\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0\"\n },\n {\n symbol: \"USDT\",\n decimals: 6,\n address: \"0x4ECaBa5870353805a9F068101A40E0f32ed605C6\"\n },\n {\n symbol: \"EURe\",\n decimals: 18,\n address: \"0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430\"\n },\n {\n symbol: \"GNO\",\n decimals: 18,\n address: \"0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb\"\n },\n {\n symbol: \"WETH\",\n decimals: 18,\n address: \"0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1\"\n },\n {\n symbol: \"XDAI\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const BASE_SEPOLIA: ChainConfig = {\n chain: baseSepolia,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=baseSepolia`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0x9406Cc6185a346906296840746125a0E44976454\",\n // Paymaster not configured in deployments.ts for Sepolia?\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\n// Map accessible by ChainID\nexport const CHAIN_CONFIGS: Record<number, ChainConfig> = {\n [base.id]: BASE_MAINNET,\n [baseSepolia.id]: BASE_SEPOLIA,\n [gnosis.id]: GNOSIS_MAINNET\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAQO;;;ACLA,IAAM,aAAa;AAAA,EACtB;AAAA,IACI,QAAQ;AAAA,MACJ,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IACpC;AAAA,IACA,MAAM;AAAA,IACN,SAAS,CAAC,EAAE,MAAM,IAAI,MAAM,UAAU,CAAC;AAAA,IACvC,iBAAiB;AAAA,IACjB,MAAM;AAAA,EACV;AAAA,EACA;AAAA,IACI,QAAQ;AAAA,MACJ,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IACpC;AAAA,IACA,MAAM;AAAA,IACN,SAAS,CAAC,EAAE,MAAM,IAAI,MAAM,OAAO,CAAC;AAAA,IACpC,iBAAiB;AAAA,IACjB,MAAM;AAAA,EACV;AAAA,EACA;AAAA,IACI,QAAQ;AAAA,MACJ,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IACpC;AAAA,IACA,MAAM;AAAA,IACN,SAAS,CAAC,EAAE,MAAM,WAAW,MAAM,UAAU,CAAC;AAAA,IAC9C,iBAAiB;AAAA,IACjB,MAAM;AAAA,EACV;AACJ;AAEO,IAAM,gBAAgB;AAAA,EACzB;AAA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,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAGO,IAAM,gBAA6C;AAAA,EACtD,CAAC,mBAAK,EAAE,GAAG;AAAA,EACX,CAAC,0BAAY,EAAE,GAAG;AAAA,EAClB,CAAC,qBAAO,EAAE,GAAG;AACjB;","names":["import_viem","import_viem"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/AccountAbstraction.ts","../src/constants.ts","../src/BundlerClient.ts","../src/TokenService.ts","../src/UserOpBuilder.ts","../src/chains.ts"],"sourcesContent":["// Core\nexport { AccountAbstraction } from \"./AccountAbstraction\";\nexport { BundlerClient } from \"./BundlerClient\";\n\n// Config & Registry\nexport { BASE_MAINNET, BASE_SEPOLIA, GNOSIS_MAINNET, CHAIN_CONFIGS } from \"./chains\";\n\n// Types\nexport type { ChainConfig, Token, UserOperation, UserOpReceipt, GasEstimate, ApprovalSupportResult } from \"./types\";\n\n// Constants (ABIs)\nexport { erc20Abi, smartAccountAbi, entryPointAbi } from \"./constants\";\n","import {\n createPublicClient,\n createWalletClient,\n http,\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n type WalletClient,\n type LocalAccount,\n decodeErrorResult\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport {\n factoryAbi,\n} from \"./constants\";\nimport {\n type ChainConfig,\n type UserOperation,\n type UserOpReceipt,\n type ApprovalSupportResult,\n type Token\n} from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { TokenService } from \"./TokenService\";\nimport { UserOpBuilder } from \"./UserOpBuilder\";\n\n/**\n * ERC-4337 Account Abstraction Client\n */\nexport class AccountAbstraction {\n private owner: Address | null = null;\n private smartAccountAddress: Address | null = null;\n private chainConfig: ChainConfig;\n private publicClient: PublicClient;\n private bundlerClient: BundlerClient;\n private walletClient: WalletClient | null = null; // Local signer (optional)\n\n // Services\n private tokenService: TokenService;\n private userOpBuilder: UserOpBuilder;\n\n // Resolved addresses\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(chainConfig: ChainConfig) {\n this.chainConfig = chainConfig;\n\n // Validation\n if (!chainConfig.entryPointAddress) throw new Error(\"EntryPoint address required\");\n this.entryPointAddress = chainConfig.entryPointAddress;\n if (!chainConfig.factoryAddress) throw new Error(\"Factory address required\");\n this.factoryAddress = chainConfig.factoryAddress;\n\n // Setup Clients\n const rpcUrl = chainConfig.rpcUrl || chainConfig.chain.rpcUrls.default.http[0];\n this.publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n });\n\n this.bundlerClient = new BundlerClient(chainConfig, this.entryPointAddress);\n\n // Setup Services\n this.tokenService = new TokenService(chainConfig, this.publicClient);\n this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);\n }\n\n /**\n * Connect to MetaMask OR use Private Key\n * @param privateKey (Optional) Hex string of private key. If provided, uses local signing.\n */\n async connect(privateKey?: Hex): Promise<{ owner: Address; smartAccount: Address }> {\n // Mode 1: Private Key (Local Signer)\n if (privateKey) {\n const account: LocalAccount = privateKeyToAccount(privateKey);\n this.owner = account.address;\n\n const rpcUrl = this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0];\n this.walletClient = createWalletClient({\n account,\n chain: this.chainConfig.chain,\n transport: http(rpcUrl)\n });\n\n // We don't need to switch chain for local signer, we just use the correct RPC/Chain object\n\n } else {\n // Mode 2: External Provider (MetaMask)\n if (typeof window === \"undefined\" || !window.ethereum) {\n throw new Error(\"MetaMask is not installed and no private key provided\");\n }\n\n // Request account access\n const accounts = (await window.ethereum.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n\n if (!accounts || accounts.length === 0) throw new Error(\"No accounts found\");\n\n // Check network\n const chainId = (await window.ethereum.request({\n method: \"eth_chainId\",\n })) as string;\n const targetChainId = this.chainConfig.chain.id;\n\n if (parseInt(chainId, 16) !== targetChainId) {\n try {\n await window.ethereum.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: \"0x\" + targetChainId.toString(16) }],\n });\n } catch (switchError: unknown) {\n const error = switchError as { code?: number };\n if (error.code === 4902) {\n await window.ethereum.request({\n method: \"wallet_addEthereumChain\",\n params: [\n {\n chainId: \"0x\" + targetChainId.toString(16),\n chainName: this.chainConfig.chain.name,\n nativeCurrency: this.chainConfig.chain.nativeCurrency,\n rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],\n blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url\n ? [this.chainConfig.chain.blockExplorers.default.url]\n : [],\n },\n ],\n });\n } else {\n throw switchError;\n }\n }\n }\n\n this.owner = accounts[0] as Address;\n // No walletClient needed, we use window.ethereum directly\n }\n\n this.smartAccountAddress = await this.getSmartAccountAddress(this.owner!);\n\n return {\n owner: this.owner!,\n smartAccount: this.smartAccountAddress,\n };\n }\n\n /**\n * Get the Smart Account address for an owner\n */\n async getSmartAccountAddress(owner: Address): Promise<Address> {\n const address = await this.publicClient.readContract({\n address: this.factoryAddress,\n abi: factoryAbi,\n functionName: \"getAccountAddress\",\n args: [owner, 0n],\n }) as Address;\n return address;\n }\n\n /**\n * Check if the Smart Account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.isAccountDeployed(this.smartAccountAddress);\n }\n\n // --- Token Methods (Delegated) ---\n\n getTokenAddress(token: string | Address): Address {\n return this.tokenService.getTokenAddress(token);\n }\n\n async getBalance(token: string | Address): Promise<bigint> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.smartAccountAddress);\n }\n\n async getEoaBalance(token: string | Address): Promise<bigint> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.owner);\n }\n\n // Deprecated helpers maintained for compatibility\n async getUsdcBalance(): Promise<bigint> { return this.getBalance(\"USDC\"); }\n async getEoaUsdcBalance(): Promise<bigint> { return this.getEoaBalance(\"USDC\"); }\n\n async getAllowance(token: string | Address = \"USDC\"): Promise<bigint> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getAllowance(token, this.owner, this.smartAccountAddress);\n }\n\n // --- Transactions ---\n\n async deployAccount(): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n try {\n const userOp = await this.userOpBuilder.buildDeployUserOp(this.owner, this.smartAccountAddress);\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async sendTransaction(\n tx: { target: Address; value?: bigint; data?: Hex }\n ): Promise<UserOpReceipt> {\n return this.sendBatchTransaction([tx]);\n }\n\n async sendBatchTransaction(\n txs: { target: Address; value?: bigint; data?: Hex }[]\n ): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n // Normalize\n const transactions = txs.map(tx => ({\n target: tx.target,\n value: tx.value ?? 0n,\n data: tx.data ?? \"0x\"\n }));\n\n try {\n const userOp = await this.userOpBuilder.buildUserOperationBatch(\n this.owner,\n this.smartAccountAddress,\n transactions\n );\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async deposit(amount: bigint): Promise<Hash> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n if (this.walletClient) {\n return await this.walletClient.sendTransaction({\n account: this.walletClient.account!,\n to: this.smartAccountAddress,\n value: amount,\n chain: this.chainConfig.chain // Explicit chain\n });\n }\n\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: this.smartAccountAddress,\n value: \"0x\" + amount.toString(16)\n }]\n }) as Hash;\n return txHash;\n }\n\n async transfer(\n token: Address | string,\n recipient: Address,\n amount: bigint\n ): Promise<UserOpReceipt> {\n const tokenAddress = this.getTokenAddress(token);\n\n // Native Transfer check\n if (tokenAddress === \"0x0000000000000000000000000000000000000000\") {\n return this.sendTransaction({\n target: recipient,\n value: amount,\n data: \"0x\"\n });\n }\n\n // ERC-20\n const data = this.tokenService.encodeTransfer(recipient, amount);\n return this.sendTransaction({\n target: tokenAddress,\n value: 0n,\n data\n });\n }\n\n /**\n * Approve a token for the Smart Account\n */\n async approveToken(\n token: Address,\n spender: Address,\n amount: bigint = 115792089237316195423570985008687907853269984665640564039457584007913129639935n // maxUint256\n ): Promise<Hash | \"NOT_NEEDED\"> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const support = await this.requestApprovalSupport(token, spender, amount);\n\n if (support.type === \"approve\") {\n const data = this.tokenService.encodeApprove(spender, amount);\n\n if (this.walletClient) {\n return await this.walletClient.sendTransaction({\n account: this.walletClient.account!,\n to: token,\n data,\n chain: this.chainConfig.chain\n });\n }\n\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: token,\n data,\n }]\n }) as Hash;\n return txHash;\n }\n\n if (support.type === \"permit\") throw new Error(\"Permit not yet supported\");\n return \"NOT_NEEDED\";\n }\n\n // --- Core Bridge to Bundler/UserOp ---\n\n // Deprecated/Legacy but kept for compatibility or advanced usage?\n // buildUserOperationBatch moved to internal usage mostly, but maybe exposed?\n // If I remove them from public API, that is a BREAKING change if user used them.\n // User requested \"modularize\", but usually expects same public API.\n // I will expose them as simple delegates if needed, or assume they primarily use sendBatchTransaction.\n // The previous implementation exposed `buildUserOperationBatch`.\n async buildUserOperationBatch(transactions: any[]) {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.buildUserOperationBatch(this.owner, this.smartAccountAddress, transactions);\n }\n\n async signUserOperation(userOp: UserOperation): Promise<UserOperation> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const userOpHash = this.userOpBuilder.getUserOpHash(userOp);\n let signature: Hex;\n\n if (this.walletClient) {\n signature = await this.walletClient.signMessage({\n account: this.walletClient.account!,\n message: { raw: userOpHash } // Sign hash directly\n });\n } else {\n signature = (await window.ethereum!.request({\n method: \"personal_sign\",\n params: [userOpHash, this.owner],\n })) as Hex;\n }\n\n return { ...userOp, signature };\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return this.bundlerClient.sendUserOperation(userOp);\n }\n\n async waitForUserOperation(hash: Hash, timeout = 60000) {\n return this.bundlerClient.waitForUserOperation(hash, timeout);\n }\n\n // Internal but exposed via BundlerClient originally\n async requestApprovalSupport(token: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.bundlerClient.requestApprovalSupport(token, this.owner, spender, amount);\n }\n\n // Error Decoding (Private)\n private decodeError(error: any): Error {\n const msg = error?.message || \"\";\n const hexMatch = msg.match(/(0x[0-9a-fA-F]+)/);\n\n if (hexMatch) {\n try {\n const decoded = decodeErrorResult({\n abi: [{ inputs: [{ name: \"message\", type: \"string\" }], name: \"Error\", type: \"error\" }],\n data: hexMatch[0] as Hex\n });\n if (decoded.errorName === \"Error\") return new Error(`Smart Account Error: ${decoded.args[0]}`);\n } catch (e) { /* ignore */ }\n }\n\n if (msg.includes(\"AA21\")) return new Error(\"Smart Account: Native transfer failed (ETH missing?)\");\n if (msg.includes(\"AA25\")) return new Error(\"Smart Account: Invalid account nonce\");\n\n return error instanceof Error ? error : new Error(String(error));\n }\n\n // Getters\n getOwner() { return this.owner; }\n getSmartAccount() { return this.smartAccountAddress; }\n}\n\n// Global window types for MetaMask\ndeclare global {\n interface Window {\n ethereum?: {\n request: (args: { method: string; params?: unknown[] }) => Promise<unknown>;\n on: (event: string, callback: (args: unknown) => void) => void;\n removeListener: (event: string, callback: (args: unknown) => void) => void;\n };\n }\n}\n","export const DEFAULT_ENTRYPOINT = \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\nexport const DEFAULT_FACTORY = \"0x9406Cc6185a346906296840746125a0E44976454\"; // SimpleAccountFactory v0.6\n\nexport const factoryAbi = [\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"getAccountAddress\",\n outputs: [{ name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"isAccountDeployed\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"createAccount\",\n outputs: [{ name: \"account\", type: \"address\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const entryPointAbi = [\n {\n inputs: [\n { name: \"sender\", type: \"address\" },\n { name: \"key\", type: \"uint192\" },\n ],\n name: \"getNonce\",\n outputs: [{ name: \"nonce\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\nexport const smartAccountAbi = [\n {\n inputs: [\n { name: \"target\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"data\", type: \"bytes\" },\n ],\n name: \"execute\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"targets\", type: \"address[]\" },\n { name: \"values\", type: \"uint256[]\" },\n { name: \"datas\", type: \"bytes[]\" },\n ],\n name: \"executeBatch\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const erc20Abi = [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"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 {\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"decimals\",\n outputs: [{ name: \"\", type: \"uint8\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n","import { type Address, type Hash } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\n\nexport class BundlerClient {\n private bundlerUrl: string;\n private chainId: number;\n private entryPointAddress: Address;\n\n constructor(config: ChainConfig, entryPointAddress: Address) {\n this.bundlerUrl = config.bundlerUrl;\n this.chainId = config.chain.id;\n this.entryPointAddress = entryPointAddress;\n }\n\n private async call(method: string, params: any[]): Promise<any> {\n const response = await fetch(this.bundlerUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method,\n params,\n }),\n });\n\n const result = await response.json();\n if (result.error) {\n throw new Error(result.error.message);\n }\n return result.result;\n }\n\n async estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate> {\n return await this.call(\"eth_estimateUserOperationGas\", [\n {\n sender: userOp.sender,\n nonce: userOp.nonce ? \"0x\" + userOp.nonce.toString(16) : \"0x0\",\n initCode: userOp.initCode || \"0x\",\n callData: userOp.callData || \"0x\",\n paymasterAndData: userOp.paymasterAndData || \"0x\",\n signature: \"0x\",\n },\n this.entryPointAddress,\n ]);\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return await this.call(\"eth_sendUserOperation\", [\n {\n sender: userOp.sender,\n nonce: \"0x\" + userOp.nonce.toString(16),\n initCode: userOp.initCode,\n callData: userOp.callData,\n callGasLimit: \"0x\" + userOp.callGasLimit.toString(16),\n verificationGasLimit: \"0x\" + userOp.verificationGasLimit.toString(16),\n preVerificationGas: \"0x\" + userOp.preVerificationGas.toString(16),\n maxFeePerGas: \"0x\" + userOp.maxFeePerGas.toString(16),\n maxPriorityFeePerGas: \"0x\" + userOp.maxPriorityFeePerGas.toString(16),\n paymasterAndData: userOp.paymasterAndData,\n signature: userOp.signature,\n },\n this.entryPointAddress,\n ]);\n }\n\n async waitForUserOperation(userOpHash: Hash, timeout = 60000): Promise<UserOpReceipt> {\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n const result = await this.call(\"eth_getUserOperationReceipt\", [userOpHash]);\n\n if (result) {\n return result as UserOpReceipt;\n }\n\n // Wait 2 seconds before polling again\n await new Promise((resolve) => setTimeout(resolve, 2000));\n }\n\n throw new Error(\"Timeout waiting for UserOperation\");\n }\n\n async requestApprovalSupport(token: Address, owner: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n return await this.call(\"pm_requestApprovalSupport\", [\n token,\n owner,\n spender,\n amount.toString()\n ]);\n }\n}\n","import { type Address, type PublicClient, encodeFunctionData } from \"viem\";\nimport { type ChainConfig, type Token } from \"./types\";\nimport { erc20Abi } from \"./constants\";\n\nexport class TokenService {\n private tokens: Map<string, Token> = new Map();\n private publicClient: PublicClient;\n\n constructor(chainConfig: ChainConfig, publicClient: PublicClient) {\n this.publicClient = publicClient;\n\n // Initialize Tokens\n chainConfig.tokens.forEach(token => {\n this.tokens.set(token.symbol.toUpperCase(), token);\n });\n }\n\n /**\n * Resolve token address from symbol or return address if provided\n */\n getTokenAddress(token: string | Address): Address {\n // Native Token (ETH)\n if (token === \"ETH\") {\n return \"0x0000000000000000000000000000000000000000\";\n }\n\n if (token.startsWith(\"0x\")) return token as Address;\n const info = this.tokens.get(token.toUpperCase());\n if (!info) throw new Error(`Token ${token} not found in chain config`);\n return info.address;\n }\n\n /**\n * Get balance of a token for an account\n */\n async getBalance(token: string | Address, account: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n // Native Balance\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return await this.publicClient.getBalance({ address: account });\n }\n\n // ERC-20 Balance\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [account],\n }) as bigint;\n }\n\n /**\n * Get allowance (ERC-20 only)\n */\n async getAllowance(token: string | Address, owner: Address, spender: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return 0n; // Native token has no allowance\n }\n\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n }) as bigint;\n }\n\n /**\n * Encode transfer data\n */\n encodeTransfer(recipient: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [recipient, amount]\n });\n }\n\n /**\n * Encode approve data\n */\n encodeApprove(spender: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount]\n });\n }\n}\n","import {\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n encodeFunctionData,\n encodeAbiParameters,\n keccak256\n} from \"viem\";\nimport { type ChainConfig, type UserOperation } from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { factoryAbi, smartAccountAbi, entryPointAbi } from \"./constants\";\n\nexport class UserOpBuilder {\n private chainConfig: ChainConfig;\n private bundlerClient: BundlerClient;\n private publicClient: PublicClient;\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(\n chainConfig: ChainConfig,\n bundlerClient: BundlerClient,\n publicClient: PublicClient\n ) {\n this.chainConfig = chainConfig;\n this.bundlerClient = bundlerClient;\n this.publicClient = publicClient;\n\n // Resolved in AA or here? Let's assume passed valid config or resolve again\n // Ideally we shouldn't duplicate logic. AA resolves them.\n // Let's rely on config having them or resolving valid ones.\n // For now take from config or defaults.\n this.entryPointAddress = chainConfig.entryPointAddress!; // Assumed validated by AA\n this.factoryAddress = chainConfig.factoryAddress!;\n }\n\n async getNonce(smartAccountAddress: Address): Promise<bigint> {\n return await this.publicClient.readContract({\n address: this.entryPointAddress,\n abi: entryPointAbi,\n functionName: \"getNonce\",\n args: [smartAccountAddress, 0n],\n }) as bigint;\n }\n\n buildInitCode(owner: Address): Hex {\n const createAccountData = encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [owner, 0n],\n });\n return `${this.factoryAddress}${createAccountData.slice(2)}` as Hex;\n }\n\n async isAccountDeployed(smartAccountAddress: Address): Promise<boolean> {\n const code = await this.publicClient.getCode({\n address: smartAccountAddress,\n });\n return code !== undefined && code !== \"0x\";\n }\n\n async buildUserOperationBatch(\n owner: Address,\n smartAccountAddress: Address,\n transactions: { target: Address; value: bigint; data: Hex }[]\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n const initCode = isDeployed ? \"0x\" : this.buildInitCode(owner);\n\n const targets = transactions.map((tx) => tx.target);\n const values = transactions.map((tx) => tx.value);\n const datas = transactions.map((tx) => tx.data);\n\n const callData = encodeFunctionData({\n abi: smartAccountAbi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n async buildDeployUserOp(\n owner: Address,\n smartAccountAddress: Address\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n if (isDeployed) throw new Error(\"Account already deployed\");\n\n const initCode = this.buildInitCode(owner);\n const callData = \"0x\";\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData: callData as Hex,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n getUserOpHash(userOp: UserOperation): Hex {\n const packed = encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n ],\n [\n userOp.sender,\n userOp.nonce,\n keccak256(userOp.initCode),\n keccak256(userOp.callData),\n userOp.callGasLimit,\n userOp.verificationGasLimit,\n userOp.preVerificationGas,\n userOp.maxFeePerGas,\n userOp.maxPriorityFeePerGas,\n keccak256(userOp.paymasterAndData),\n ]\n );\n\n const packedHash = keccak256(packed);\n\n return keccak256(\n encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }, { type: \"uint256\" }],\n [packedHash, this.entryPointAddress, BigInt(this.chainConfig.chain.id)]\n )\n );\n }\n}\n","import { type ChainConfig } from \"./types\";\nimport { base, baseSepolia, gnosis } from \"viem/chains\";\n\nconst DEFAULT_BUNDLER_URL = \"https://bundler-erc-4337.vercel.app\";\nconst BUNDLER_URL = process.env.NEXT_PUBLIC_BUNDLER_URL || process.env.BUNDLER_URL || DEFAULT_BUNDLER_URL;\n\n\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=base`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xe2584152891E4769025807DEa0cD611F135aDC68\",\n paymasterAddress: \"0x1e13Eb16C565E3f3FDe49A011755e50410bb1F95\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const GNOSIS_MAINNET: ChainConfig = {\n chain: gnosis,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=gnosis`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xC8a2Fb1f2E686417A131E09be3320cb5431CcD90\",\n paymasterAddress: \"0x4C36C70d68a7c26326711e8268bb163E3784fA96\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0\"\n },\n {\n symbol: \"USDT\",\n decimals: 6,\n address: \"0x4ECaBa5870353805a9F068101A40E0f32ed605C6\"\n },\n {\n symbol: \"EURe\",\n decimals: 18,\n address: \"0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430\"\n },\n {\n symbol: \"GNO\",\n decimals: 18,\n address: \"0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb\"\n },\n {\n symbol: \"WETH\",\n decimals: 18,\n address: \"0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1\"\n },\n {\n symbol: \"XDAI\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const BASE_SEPOLIA: ChainConfig = {\n chain: baseSepolia,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=baseSepolia`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0x9406Cc6185a346906296840746125a0E44976454\",\n // Paymaster not configured in deployments.ts for Sepolia?\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\n// Map accessible by ChainID\nexport const CHAIN_CONFIGS: Record<number, ChainConfig> = {\n [base.id]: BASE_MAINNET,\n [baseSepolia.id]: BASE_SEPOLIA,\n [gnosis.id]: GNOSIS_MAINNET\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAWO;AACP,sBAAoC;;;ACT7B,IAAM,aAAa;AAAA,EACtB;AAAA,IACI,QAAQ;AAAA,MACJ,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IACpC;AAAA,IACA,MAAM;AAAA,IACN,SAAS,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ACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAEO,IAAM,eAA4B;AAAA,EACrC,OAAO;AAAA,EACP,YAAY,GAAG,WAAW;AAAA;AAAA;AAAA,EAG1B,mBAAmB;AAAA,EACnB,gBAAgB;AAAA;AAAA,EAGhB,QAAQ;AAAA,IACJ;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAGO,IAAM,gBAA6C;AAAA,EACtD,CAAC,mBAAK,EAAE,GAAG;AAAA,EACX,CAAC,0BAAY,EAAE,GAAG;AAAA,EAClB,CAAC,qBAAO,EAAE,GAAG;AACjB;","names":["import_viem","import_viem"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/AccountAbstraction.ts
|
|
2
2
|
import {
|
|
3
3
|
createPublicClient,
|
|
4
|
+
createWalletClient,
|
|
4
5
|
http,
|
|
5
6
|
decodeErrorResult
|
|
6
7
|
} from "viem";
|
|
8
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
7
9
|
|
|
8
10
|
// src/constants.ts
|
|
9
11
|
var factoryAbi = [
|
|
@@ -414,6 +416,7 @@ var AccountAbstraction = class {
|
|
|
414
416
|
constructor(chainConfig) {
|
|
415
417
|
this.owner = null;
|
|
416
418
|
this.smartAccountAddress = null;
|
|
419
|
+
this.walletClient = null;
|
|
417
420
|
this.chainConfig = chainConfig;
|
|
418
421
|
if (!chainConfig.entryPointAddress) throw new Error("EntryPoint address required");
|
|
419
422
|
this.entryPointAddress = chainConfig.entryPointAddress;
|
|
@@ -429,47 +432,59 @@ var AccountAbstraction = class {
|
|
|
429
432
|
this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);
|
|
430
433
|
}
|
|
431
434
|
/**
|
|
432
|
-
* Connect to MetaMask
|
|
435
|
+
* Connect to MetaMask OR use Private Key
|
|
436
|
+
* @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
|
|
433
437
|
*/
|
|
434
|
-
async connect() {
|
|
435
|
-
if (
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
438
|
+
async connect(privateKey) {
|
|
439
|
+
if (privateKey) {
|
|
440
|
+
const account = privateKeyToAccount(privateKey);
|
|
441
|
+
this.owner = account.address;
|
|
442
|
+
const rpcUrl = this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0];
|
|
443
|
+
this.walletClient = createWalletClient({
|
|
444
|
+
account,
|
|
445
|
+
chain: this.chainConfig.chain,
|
|
446
|
+
transport: http(rpcUrl)
|
|
447
|
+
});
|
|
448
|
+
} else {
|
|
449
|
+
if (typeof window === "undefined" || !window.ethereum) {
|
|
450
|
+
throw new Error("MetaMask is not installed and no private key provided");
|
|
451
|
+
}
|
|
452
|
+
const accounts = await window.ethereum.request({
|
|
453
|
+
method: "eth_requestAccounts"
|
|
454
|
+
});
|
|
455
|
+
if (!accounts || accounts.length === 0) throw new Error("No accounts found");
|
|
456
|
+
const chainId = await window.ethereum.request({
|
|
457
|
+
method: "eth_chainId"
|
|
458
|
+
});
|
|
459
|
+
const targetChainId = this.chainConfig.chain.id;
|
|
460
|
+
if (parseInt(chainId, 16) !== targetChainId) {
|
|
461
|
+
try {
|
|
455
462
|
await window.ethereum.request({
|
|
456
|
-
method: "
|
|
457
|
-
params: [
|
|
458
|
-
{
|
|
459
|
-
chainId: "0x" + targetChainId.toString(16),
|
|
460
|
-
chainName: this.chainConfig.chain.name,
|
|
461
|
-
nativeCurrency: this.chainConfig.chain.nativeCurrency,
|
|
462
|
-
rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],
|
|
463
|
-
blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url ? [this.chainConfig.chain.blockExplorers.default.url] : []
|
|
464
|
-
}
|
|
465
|
-
]
|
|
463
|
+
method: "wallet_switchEthereumChain",
|
|
464
|
+
params: [{ chainId: "0x" + targetChainId.toString(16) }]
|
|
466
465
|
});
|
|
467
|
-
}
|
|
468
|
-
|
|
466
|
+
} catch (switchError) {
|
|
467
|
+
const error = switchError;
|
|
468
|
+
if (error.code === 4902) {
|
|
469
|
+
await window.ethereum.request({
|
|
470
|
+
method: "wallet_addEthereumChain",
|
|
471
|
+
params: [
|
|
472
|
+
{
|
|
473
|
+
chainId: "0x" + targetChainId.toString(16),
|
|
474
|
+
chainName: this.chainConfig.chain.name,
|
|
475
|
+
nativeCurrency: this.chainConfig.chain.nativeCurrency,
|
|
476
|
+
rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],
|
|
477
|
+
blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url ? [this.chainConfig.chain.blockExplorers.default.url] : []
|
|
478
|
+
}
|
|
479
|
+
]
|
|
480
|
+
});
|
|
481
|
+
} else {
|
|
482
|
+
throw switchError;
|
|
483
|
+
}
|
|
469
484
|
}
|
|
470
485
|
}
|
|
486
|
+
this.owner = accounts[0];
|
|
471
487
|
}
|
|
472
|
-
this.owner = accounts[0];
|
|
473
488
|
this.smartAccountAddress = await this.getSmartAccountAddress(this.owner);
|
|
474
489
|
return {
|
|
475
490
|
owner: this.owner,
|
|
@@ -555,6 +570,15 @@ var AccountAbstraction = class {
|
|
|
555
570
|
}
|
|
556
571
|
async deposit(amount) {
|
|
557
572
|
if (!this.owner || !this.smartAccountAddress) throw new Error("Not connected");
|
|
573
|
+
if (this.walletClient) {
|
|
574
|
+
return await this.walletClient.sendTransaction({
|
|
575
|
+
account: this.walletClient.account,
|
|
576
|
+
to: this.smartAccountAddress,
|
|
577
|
+
value: amount,
|
|
578
|
+
chain: this.chainConfig.chain
|
|
579
|
+
// Explicit chain
|
|
580
|
+
});
|
|
581
|
+
}
|
|
558
582
|
const txHash = await window.ethereum.request({
|
|
559
583
|
method: "eth_sendTransaction",
|
|
560
584
|
params: [{
|
|
@@ -589,6 +613,14 @@ var AccountAbstraction = class {
|
|
|
589
613
|
const support = await this.requestApprovalSupport(token, spender, amount);
|
|
590
614
|
if (support.type === "approve") {
|
|
591
615
|
const data = this.tokenService.encodeApprove(spender, amount);
|
|
616
|
+
if (this.walletClient) {
|
|
617
|
+
return await this.walletClient.sendTransaction({
|
|
618
|
+
account: this.walletClient.account,
|
|
619
|
+
to: token,
|
|
620
|
+
data,
|
|
621
|
+
chain: this.chainConfig.chain
|
|
622
|
+
});
|
|
623
|
+
}
|
|
592
624
|
const txHash = await window.ethereum.request({
|
|
593
625
|
method: "eth_sendTransaction",
|
|
594
626
|
params: [{
|
|
@@ -616,10 +648,19 @@ var AccountAbstraction = class {
|
|
|
616
648
|
async signUserOperation(userOp) {
|
|
617
649
|
if (!this.owner) throw new Error("Not connected");
|
|
618
650
|
const userOpHash = this.userOpBuilder.getUserOpHash(userOp);
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
651
|
+
let signature;
|
|
652
|
+
if (this.walletClient) {
|
|
653
|
+
signature = await this.walletClient.signMessage({
|
|
654
|
+
account: this.walletClient.account,
|
|
655
|
+
message: { raw: userOpHash }
|
|
656
|
+
// Sign hash directly
|
|
657
|
+
});
|
|
658
|
+
} else {
|
|
659
|
+
signature = await window.ethereum.request({
|
|
660
|
+
method: "personal_sign",
|
|
661
|
+
params: [userOpHash, this.owner]
|
|
662
|
+
});
|
|
663
|
+
}
|
|
623
664
|
return { ...userOp, signature };
|
|
624
665
|
}
|
|
625
666
|
async sendUserOperation(userOp) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/AccountAbstraction.ts","../src/constants.ts","../src/BundlerClient.ts","../src/TokenService.ts","../src/UserOpBuilder.ts","../src/chains.ts"],"sourcesContent":["import {\n createPublicClient,\n http,\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n decodeErrorResult\n} from \"viem\";\nimport {\n factoryAbi,\n} from \"./constants\";\nimport {\n type ChainConfig,\n type UserOperation,\n type UserOpReceipt,\n type ApprovalSupportResult,\n type Token\n} from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { TokenService } from \"./TokenService\";\nimport { UserOpBuilder } from \"./UserOpBuilder\";\n\n/**\n * ERC-4337 Account Abstraction Client\n */\nexport class AccountAbstraction {\n private owner: Address | null = null;\n private smartAccountAddress: Address | null = null;\n private chainConfig: ChainConfig;\n private publicClient: PublicClient;\n private bundlerClient: BundlerClient;\n\n // Services\n private tokenService: TokenService;\n private userOpBuilder: UserOpBuilder;\n\n // Resolved addresses\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(chainConfig: ChainConfig) {\n this.chainConfig = chainConfig;\n\n // Validation\n if (!chainConfig.entryPointAddress) throw new Error(\"EntryPoint address required\");\n this.entryPointAddress = chainConfig.entryPointAddress;\n if (!chainConfig.factoryAddress) throw new Error(\"Factory address required\");\n this.factoryAddress = chainConfig.factoryAddress;\n\n // Setup Clients\n const rpcUrl = chainConfig.rpcUrl || chainConfig.chain.rpcUrls.default.http[0];\n this.publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n });\n\n this.bundlerClient = new BundlerClient(chainConfig, this.entryPointAddress);\n\n // Setup Services\n this.tokenService = new TokenService(chainConfig, this.publicClient);\n this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);\n }\n\n /**\n * Connect to MetaMask and get the owner address\n */\n async connect(): Promise<{ owner: Address; smartAccount: Address }> {\n if (typeof window === \"undefined\" || !window.ethereum) {\n throw new Error(\"MetaMask is not installed\");\n }\n\n // Request account access\n const accounts = (await window.ethereum.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n\n if (!accounts || accounts.length === 0) throw new Error(\"No accounts found\");\n\n // Check network\n const chainId = (await window.ethereum.request({\n method: \"eth_chainId\",\n })) as string;\n const targetChainId = this.chainConfig.chain.id;\n\n if (parseInt(chainId, 16) !== targetChainId) {\n try {\n await window.ethereum.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: \"0x\" + targetChainId.toString(16) }],\n });\n } catch (switchError: unknown) {\n const error = switchError as { code?: number };\n if (error.code === 4902) {\n await window.ethereum.request({\n method: \"wallet_addEthereumChain\",\n params: [\n {\n chainId: \"0x\" + targetChainId.toString(16),\n chainName: this.chainConfig.chain.name,\n nativeCurrency: this.chainConfig.chain.nativeCurrency,\n rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],\n blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url\n ? [this.chainConfig.chain.blockExplorers.default.url]\n : [],\n },\n ],\n });\n } else {\n throw switchError;\n }\n }\n }\n\n this.owner = accounts[0] as Address;\n this.smartAccountAddress = await this.getSmartAccountAddress(this.owner);\n\n return {\n owner: this.owner,\n smartAccount: this.smartAccountAddress,\n };\n }\n\n /**\n * Get the Smart Account address for an owner\n */\n async getSmartAccountAddress(owner: Address): Promise<Address> {\n const address = await this.publicClient.readContract({\n address: this.factoryAddress,\n abi: factoryAbi,\n functionName: \"getAccountAddress\",\n args: [owner, 0n],\n }) as Address;\n return address;\n }\n\n /**\n * Check if the Smart Account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.isAccountDeployed(this.smartAccountAddress);\n }\n\n // --- Token Methods (Delegated) ---\n\n getTokenAddress(token: string | Address): Address {\n return this.tokenService.getTokenAddress(token);\n }\n\n async getBalance(token: string | Address): Promise<bigint> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.smartAccountAddress);\n }\n\n async getEoaBalance(token: string | Address): Promise<bigint> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.owner);\n }\n\n // Deprecated helpers maintained for compatibility\n async getUsdcBalance(): Promise<bigint> { return this.getBalance(\"USDC\"); }\n async getEoaUsdcBalance(): Promise<bigint> { return this.getEoaBalance(\"USDC\"); }\n\n async getAllowance(token: string | Address = \"USDC\"): Promise<bigint> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getAllowance(token, this.owner, this.smartAccountAddress);\n }\n\n // --- Transactions ---\n\n async deployAccount(): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n try {\n const userOp = await this.userOpBuilder.buildDeployUserOp(this.owner, this.smartAccountAddress);\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async sendTransaction(\n tx: { target: Address; value?: bigint; data?: Hex }\n ): Promise<UserOpReceipt> {\n return this.sendBatchTransaction([tx]);\n }\n\n async sendBatchTransaction(\n txs: { target: Address; value?: bigint; data?: Hex }[]\n ): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n // Normalize\n const transactions = txs.map(tx => ({\n target: tx.target,\n value: tx.value ?? 0n,\n data: tx.data ?? \"0x\"\n }));\n\n try {\n const userOp = await this.userOpBuilder.buildUserOperationBatch(\n this.owner,\n this.smartAccountAddress,\n transactions\n );\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async deposit(amount: bigint): Promise<Hash> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: this.smartAccountAddress,\n value: \"0x\" + amount.toString(16)\n }]\n }) as Hash;\n return txHash;\n }\n\n async transfer(\n token: Address | string,\n recipient: Address,\n amount: bigint\n ): Promise<UserOpReceipt> {\n const tokenAddress = this.getTokenAddress(token);\n\n // Native Transfer check\n if (tokenAddress === \"0x0000000000000000000000000000000000000000\") {\n return this.sendTransaction({\n target: recipient,\n value: amount,\n data: \"0x\"\n });\n }\n\n // ERC-20\n const data = this.tokenService.encodeTransfer(recipient, amount);\n return this.sendTransaction({\n target: tokenAddress,\n value: 0n,\n data\n });\n }\n\n /**\n * Approve a token for the Smart Account\n */\n async approveToken(\n token: Address,\n spender: Address,\n amount: bigint = 115792089237316195423570985008687907853269984665640564039457584007913129639935n // maxUint256\n ): Promise<Hash | \"NOT_NEEDED\"> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const support = await this.requestApprovalSupport(token, spender, amount);\n\n if (support.type === \"approve\") {\n const data = this.tokenService.encodeApprove(spender, amount);\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: token,\n data,\n }]\n }) as Hash;\n return txHash;\n }\n\n if (support.type === \"permit\") throw new Error(\"Permit not yet supported\");\n return \"NOT_NEEDED\";\n }\n\n // --- Core Bridge to Bundler/UserOp ---\n\n // Deprecated/Legacy but kept for compatibility or advanced usage?\n // buildUserOperationBatch moved to internal usage mostly, but maybe exposed?\n // If I remove them from public API, that is a BREAKING change if user used them.\n // User requested \"modularize\", but usually expects same public API.\n // I will expose them as simple delegates if needed, or assume they primarily use sendBatchTransaction.\n // The previous implementation exposed `buildUserOperationBatch`.\n async buildUserOperationBatch(transactions: any[]) {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.buildUserOperationBatch(this.owner, this.smartAccountAddress, transactions);\n }\n\n async signUserOperation(userOp: UserOperation): Promise<UserOperation> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const userOpHash = this.userOpBuilder.getUserOpHash(userOp);\n\n const signature = (await window.ethereum!.request({\n method: \"personal_sign\",\n params: [userOpHash, this.owner],\n })) as Hex;\n\n return { ...userOp, signature };\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return this.bundlerClient.sendUserOperation(userOp);\n }\n\n async waitForUserOperation(hash: Hash, timeout = 60000) {\n return this.bundlerClient.waitForUserOperation(hash, timeout);\n }\n\n // Internal but exposed via BundlerClient originally\n async requestApprovalSupport(token: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.bundlerClient.requestApprovalSupport(token, this.owner, spender, amount);\n }\n\n // Error Decoding (Private)\n private decodeError(error: any): Error {\n const msg = error?.message || \"\";\n const hexMatch = msg.match(/(0x[0-9a-fA-F]+)/);\n\n if (hexMatch) {\n try {\n const decoded = decodeErrorResult({\n abi: [{ inputs: [{ name: \"message\", type: \"string\" }], name: \"Error\", type: \"error\" }],\n data: hexMatch[0] as Hex\n });\n if (decoded.errorName === \"Error\") return new Error(`Smart Account Error: ${decoded.args[0]}`);\n } catch (e) { /* ignore */ }\n }\n\n if (msg.includes(\"AA21\")) return new Error(\"Smart Account: Native transfer failed (ETH missing?)\");\n if (msg.includes(\"AA25\")) return new Error(\"Smart Account: Invalid account nonce\");\n\n return error instanceof Error ? error : new Error(String(error));\n }\n\n // Getters\n getOwner() { return this.owner; }\n getSmartAccount() { return this.smartAccountAddress; }\n}\n\n// Global window types for MetaMask\ndeclare global {\n interface Window {\n ethereum?: {\n request: (args: { method: string; params?: unknown[] }) => Promise<unknown>;\n on: (event: string, callback: (args: unknown) => void) => void;\n removeListener: (event: string, callback: (args: unknown) => void) => void;\n };\n }\n}\n","export const DEFAULT_ENTRYPOINT = \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\nexport const DEFAULT_FACTORY = \"0x9406Cc6185a346906296840746125a0E44976454\"; // SimpleAccountFactory v0.6\n\nexport const factoryAbi = [\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"getAccountAddress\",\n outputs: [{ name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"isAccountDeployed\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"createAccount\",\n outputs: [{ name: \"account\", type: \"address\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const entryPointAbi = [\n {\n inputs: [\n { name: \"sender\", type: \"address\" },\n { name: \"key\", type: \"uint192\" },\n ],\n name: \"getNonce\",\n outputs: [{ name: \"nonce\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\nexport const smartAccountAbi = [\n {\n inputs: [\n { name: \"target\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"data\", type: \"bytes\" },\n ],\n name: \"execute\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"targets\", type: \"address[]\" },\n { name: \"values\", type: \"uint256[]\" },\n { name: \"datas\", type: \"bytes[]\" },\n ],\n name: \"executeBatch\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const erc20Abi = [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"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 {\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"decimals\",\n outputs: [{ name: \"\", type: \"uint8\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n","import { type Address, type Hash } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\n\nexport class BundlerClient {\n private bundlerUrl: string;\n private chainId: number;\n private entryPointAddress: Address;\n\n constructor(config: ChainConfig, entryPointAddress: Address) {\n this.bundlerUrl = config.bundlerUrl;\n this.chainId = config.chain.id;\n this.entryPointAddress = entryPointAddress;\n }\n\n private async call(method: string, params: any[]): Promise<any> {\n const response = await fetch(this.bundlerUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method,\n params,\n }),\n });\n\n const result = await response.json();\n if (result.error) {\n throw new Error(result.error.message);\n }\n return result.result;\n }\n\n async estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate> {\n return await this.call(\"eth_estimateUserOperationGas\", [\n {\n sender: userOp.sender,\n nonce: userOp.nonce ? \"0x\" + userOp.nonce.toString(16) : \"0x0\",\n initCode: userOp.initCode || \"0x\",\n callData: userOp.callData || \"0x\",\n paymasterAndData: userOp.paymasterAndData || \"0x\",\n signature: \"0x\",\n },\n this.entryPointAddress,\n ]);\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return await this.call(\"eth_sendUserOperation\", [\n {\n sender: userOp.sender,\n nonce: \"0x\" + userOp.nonce.toString(16),\n initCode: userOp.initCode,\n callData: userOp.callData,\n callGasLimit: \"0x\" + userOp.callGasLimit.toString(16),\n verificationGasLimit: \"0x\" + userOp.verificationGasLimit.toString(16),\n preVerificationGas: \"0x\" + userOp.preVerificationGas.toString(16),\n maxFeePerGas: \"0x\" + userOp.maxFeePerGas.toString(16),\n maxPriorityFeePerGas: \"0x\" + userOp.maxPriorityFeePerGas.toString(16),\n paymasterAndData: userOp.paymasterAndData,\n signature: userOp.signature,\n },\n this.entryPointAddress,\n ]);\n }\n\n async waitForUserOperation(userOpHash: Hash, timeout = 60000): Promise<UserOpReceipt> {\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n const result = await this.call(\"eth_getUserOperationReceipt\", [userOpHash]);\n\n if (result) {\n return result as UserOpReceipt;\n }\n\n // Wait 2 seconds before polling again\n await new Promise((resolve) => setTimeout(resolve, 2000));\n }\n\n throw new Error(\"Timeout waiting for UserOperation\");\n }\n\n async requestApprovalSupport(token: Address, owner: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n return await this.call(\"pm_requestApprovalSupport\", [\n token,\n owner,\n spender,\n amount.toString()\n ]);\n }\n}\n","import { type Address, type PublicClient, encodeFunctionData } from \"viem\";\nimport { type ChainConfig, type Token } from \"./types\";\nimport { erc20Abi } from \"./constants\";\n\nexport class TokenService {\n private tokens: Map<string, Token> = new Map();\n private publicClient: PublicClient;\n\n constructor(chainConfig: ChainConfig, publicClient: PublicClient) {\n this.publicClient = publicClient;\n\n // Initialize Tokens\n chainConfig.tokens.forEach(token => {\n this.tokens.set(token.symbol.toUpperCase(), token);\n });\n }\n\n /**\n * Resolve token address from symbol or return address if provided\n */\n getTokenAddress(token: string | Address): Address {\n // Native Token (ETH)\n if (token === \"ETH\") {\n return \"0x0000000000000000000000000000000000000000\";\n }\n\n if (token.startsWith(\"0x\")) return token as Address;\n const info = this.tokens.get(token.toUpperCase());\n if (!info) throw new Error(`Token ${token} not found in chain config`);\n return info.address;\n }\n\n /**\n * Get balance of a token for an account\n */\n async getBalance(token: string | Address, account: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n // Native Balance\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return await this.publicClient.getBalance({ address: account });\n }\n\n // ERC-20 Balance\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [account],\n }) as bigint;\n }\n\n /**\n * Get allowance (ERC-20 only)\n */\n async getAllowance(token: string | Address, owner: Address, spender: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return 0n; // Native token has no allowance\n }\n\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n }) as bigint;\n }\n\n /**\n * Encode transfer data\n */\n encodeTransfer(recipient: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [recipient, amount]\n });\n }\n\n /**\n * Encode approve data\n */\n encodeApprove(spender: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount]\n });\n }\n}\n","import {\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n encodeFunctionData,\n encodeAbiParameters,\n keccak256\n} from \"viem\";\nimport { type ChainConfig, type UserOperation } from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { factoryAbi, smartAccountAbi, entryPointAbi } from \"./constants\";\n\nexport class UserOpBuilder {\n private chainConfig: ChainConfig;\n private bundlerClient: BundlerClient;\n private publicClient: PublicClient;\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(\n chainConfig: ChainConfig,\n bundlerClient: BundlerClient,\n publicClient: PublicClient\n ) {\n this.chainConfig = chainConfig;\n this.bundlerClient = bundlerClient;\n this.publicClient = publicClient;\n\n // Resolved in AA or here? Let's assume passed valid config or resolve again\n // Ideally we shouldn't duplicate logic. AA resolves them.\n // Let's rely on config having them or resolving valid ones.\n // For now take from config or defaults.\n this.entryPointAddress = chainConfig.entryPointAddress!; // Assumed validated by AA\n this.factoryAddress = chainConfig.factoryAddress!;\n }\n\n async getNonce(smartAccountAddress: Address): Promise<bigint> {\n return await this.publicClient.readContract({\n address: this.entryPointAddress,\n abi: entryPointAbi,\n functionName: \"getNonce\",\n args: [smartAccountAddress, 0n],\n }) as bigint;\n }\n\n buildInitCode(owner: Address): Hex {\n const createAccountData = encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [owner, 0n],\n });\n return `${this.factoryAddress}${createAccountData.slice(2)}` as Hex;\n }\n\n async isAccountDeployed(smartAccountAddress: Address): Promise<boolean> {\n const code = await this.publicClient.getCode({\n address: smartAccountAddress,\n });\n return code !== undefined && code !== \"0x\";\n }\n\n async buildUserOperationBatch(\n owner: Address,\n smartAccountAddress: Address,\n transactions: { target: Address; value: bigint; data: Hex }[]\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n const initCode = isDeployed ? \"0x\" : this.buildInitCode(owner);\n\n const targets = transactions.map((tx) => tx.target);\n const values = transactions.map((tx) => tx.value);\n const datas = transactions.map((tx) => tx.data);\n\n const callData = encodeFunctionData({\n abi: smartAccountAbi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n async buildDeployUserOp(\n owner: Address,\n smartAccountAddress: Address\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n if (isDeployed) throw new Error(\"Account already deployed\");\n\n const initCode = this.buildInitCode(owner);\n const callData = \"0x\";\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData: callData as Hex,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n getUserOpHash(userOp: UserOperation): Hex {\n const packed = encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n ],\n [\n userOp.sender,\n userOp.nonce,\n keccak256(userOp.initCode),\n keccak256(userOp.callData),\n userOp.callGasLimit,\n userOp.verificationGasLimit,\n userOp.preVerificationGas,\n userOp.maxFeePerGas,\n userOp.maxPriorityFeePerGas,\n keccak256(userOp.paymasterAndData),\n ]\n );\n\n const packedHash = keccak256(packed);\n\n return keccak256(\n encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }, { type: \"uint256\" }],\n [packedHash, this.entryPointAddress, BigInt(this.chainConfig.chain.id)]\n )\n );\n }\n}\n","import { type ChainConfig } from \"./types\";\nimport { base, baseSepolia, gnosis } from \"viem/chains\";\n\nconst DEFAULT_BUNDLER_URL = \"https://bundler-erc-4337.vercel.app\";\nconst BUNDLER_URL = process.env.NEXT_PUBLIC_BUNDLER_URL || process.env.BUNDLER_URL || DEFAULT_BUNDLER_URL;\n\n\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=base`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xe2584152891E4769025807DEa0cD611F135aDC68\",\n paymasterAddress: \"0x1e13Eb16C565E3f3FDe49A011755e50410bb1F95\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const GNOSIS_MAINNET: ChainConfig = {\n chain: gnosis,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=gnosis`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xC8a2Fb1f2E686417A131E09be3320cb5431CcD90\",\n paymasterAddress: \"0x4C36C70d68a7c26326711e8268bb163E3784fA96\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0\"\n },\n {\n symbol: \"USDT\",\n decimals: 6,\n address: \"0x4ECaBa5870353805a9F068101A40E0f32ed605C6\"\n },\n {\n symbol: \"EURe\",\n decimals: 18,\n address: \"0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430\"\n },\n {\n symbol: \"GNO\",\n decimals: 18,\n address: \"0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb\"\n },\n {\n symbol: \"WETH\",\n decimals: 18,\n address: \"0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1\"\n },\n {\n symbol: \"XDAI\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const BASE_SEPOLIA: ChainConfig = {\n chain: baseSepolia,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=baseSepolia`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0x9406Cc6185a346906296840746125a0E44976454\",\n // Paymaster not configured in deployments.ts for Sepolia?\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\n// Map accessible by ChainID\nexport const CHAIN_CONFIGS: Record<number, ChainConfig> = {\n [base.id]: BASE_MAINNET,\n [baseSepolia.id]: BASE_SEPOLIA,\n [gnosis.id]: GNOSIS_MAINNET\n};\n"],"mappings":";AAAA;AAAA,EACI;AAAA,EACA;AAAA,EAKA;AAAA,OACG;;;ACLA,IAAM,aAAa;AAAA,EACtB;AAAA,IACI,QAAQ;AAAA,MACJ,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IACpC;AAAA,IACA,MAAM;AAAA,IACN,SAAS,CAAC,EAAE,MAAM,IAAI,MAAM,UAAU,CAAC;AAAA,IACvC,iBAAiB;AAAA,IACjB,MAAM;AAAA,EACV;AAAA,EACA;AAAA,IAC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,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAEO,IAAM,eAA4B;AAAA,EACrC,OAAO;AAAA,EACP,YAAY,GAAG,WAAW;AAAA;AAAA;AAAA,EAG1B,mBAAmB;AAAA,EACnB,gBAAgB;AAAA;AAAA,EAGhB,QAAQ;AAAA,IACJ;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAGO,IAAM,gBAA6C;AAAA,EACtD,CAAC,KAAK,EAAE,GAAG;AAAA,EACX,CAAC,YAAY,EAAE,GAAG;AAAA,EAClB,CAAC,OAAO,EAAE,GAAG;AACjB;","names":["encodeFunctionData","encodeFunctionData"]}
|
|
1
|
+
{"version":3,"sources":["../src/AccountAbstraction.ts","../src/constants.ts","../src/BundlerClient.ts","../src/TokenService.ts","../src/UserOpBuilder.ts","../src/chains.ts"],"sourcesContent":["import {\n createPublicClient,\n createWalletClient,\n http,\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n type WalletClient,\n type LocalAccount,\n decodeErrorResult\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport {\n factoryAbi,\n} from \"./constants\";\nimport {\n type ChainConfig,\n type UserOperation,\n type UserOpReceipt,\n type ApprovalSupportResult,\n type Token\n} from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { TokenService } from \"./TokenService\";\nimport { UserOpBuilder } from \"./UserOpBuilder\";\n\n/**\n * ERC-4337 Account Abstraction Client\n */\nexport class AccountAbstraction {\n private owner: Address | null = null;\n private smartAccountAddress: Address | null = null;\n private chainConfig: ChainConfig;\n private publicClient: PublicClient;\n private bundlerClient: BundlerClient;\n private walletClient: WalletClient | null = null; // Local signer (optional)\n\n // Services\n private tokenService: TokenService;\n private userOpBuilder: UserOpBuilder;\n\n // Resolved addresses\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(chainConfig: ChainConfig) {\n this.chainConfig = chainConfig;\n\n // Validation\n if (!chainConfig.entryPointAddress) throw new Error(\"EntryPoint address required\");\n this.entryPointAddress = chainConfig.entryPointAddress;\n if (!chainConfig.factoryAddress) throw new Error(\"Factory address required\");\n this.factoryAddress = chainConfig.factoryAddress;\n\n // Setup Clients\n const rpcUrl = chainConfig.rpcUrl || chainConfig.chain.rpcUrls.default.http[0];\n this.publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n });\n\n this.bundlerClient = new BundlerClient(chainConfig, this.entryPointAddress);\n\n // Setup Services\n this.tokenService = new TokenService(chainConfig, this.publicClient);\n this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);\n }\n\n /**\n * Connect to MetaMask OR use Private Key\n * @param privateKey (Optional) Hex string of private key. If provided, uses local signing.\n */\n async connect(privateKey?: Hex): Promise<{ owner: Address; smartAccount: Address }> {\n // Mode 1: Private Key (Local Signer)\n if (privateKey) {\n const account: LocalAccount = privateKeyToAccount(privateKey);\n this.owner = account.address;\n\n const rpcUrl = this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0];\n this.walletClient = createWalletClient({\n account,\n chain: this.chainConfig.chain,\n transport: http(rpcUrl)\n });\n\n // We don't need to switch chain for local signer, we just use the correct RPC/Chain object\n\n } else {\n // Mode 2: External Provider (MetaMask)\n if (typeof window === \"undefined\" || !window.ethereum) {\n throw new Error(\"MetaMask is not installed and no private key provided\");\n }\n\n // Request account access\n const accounts = (await window.ethereum.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n\n if (!accounts || accounts.length === 0) throw new Error(\"No accounts found\");\n\n // Check network\n const chainId = (await window.ethereum.request({\n method: \"eth_chainId\",\n })) as string;\n const targetChainId = this.chainConfig.chain.id;\n\n if (parseInt(chainId, 16) !== targetChainId) {\n try {\n await window.ethereum.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: \"0x\" + targetChainId.toString(16) }],\n });\n } catch (switchError: unknown) {\n const error = switchError as { code?: number };\n if (error.code === 4902) {\n await window.ethereum.request({\n method: \"wallet_addEthereumChain\",\n params: [\n {\n chainId: \"0x\" + targetChainId.toString(16),\n chainName: this.chainConfig.chain.name,\n nativeCurrency: this.chainConfig.chain.nativeCurrency,\n rpcUrls: [this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0]],\n blockExplorerUrls: this.chainConfig.chain.blockExplorers?.default?.url\n ? [this.chainConfig.chain.blockExplorers.default.url]\n : [],\n },\n ],\n });\n } else {\n throw switchError;\n }\n }\n }\n\n this.owner = accounts[0] as Address;\n // No walletClient needed, we use window.ethereum directly\n }\n\n this.smartAccountAddress = await this.getSmartAccountAddress(this.owner!);\n\n return {\n owner: this.owner!,\n smartAccount: this.smartAccountAddress,\n };\n }\n\n /**\n * Get the Smart Account address for an owner\n */\n async getSmartAccountAddress(owner: Address): Promise<Address> {\n const address = await this.publicClient.readContract({\n address: this.factoryAddress,\n abi: factoryAbi,\n functionName: \"getAccountAddress\",\n args: [owner, 0n],\n }) as Address;\n return address;\n }\n\n /**\n * Check if the Smart Account is deployed\n */\n async isAccountDeployed(): Promise<boolean> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.isAccountDeployed(this.smartAccountAddress);\n }\n\n // --- Token Methods (Delegated) ---\n\n getTokenAddress(token: string | Address): Address {\n return this.tokenService.getTokenAddress(token);\n }\n\n async getBalance(token: string | Address): Promise<bigint> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.smartAccountAddress);\n }\n\n async getEoaBalance(token: string | Address): Promise<bigint> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(token, this.owner);\n }\n\n // Deprecated helpers maintained for compatibility\n async getUsdcBalance(): Promise<bigint> { return this.getBalance(\"USDC\"); }\n async getEoaUsdcBalance(): Promise<bigint> { return this.getEoaBalance(\"USDC\"); }\n\n async getAllowance(token: string | Address = \"USDC\"): Promise<bigint> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getAllowance(token, this.owner, this.smartAccountAddress);\n }\n\n // --- Transactions ---\n\n async deployAccount(): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n try {\n const userOp = await this.userOpBuilder.buildDeployUserOp(this.owner, this.smartAccountAddress);\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async sendTransaction(\n tx: { target: Address; value?: bigint; data?: Hex }\n ): Promise<UserOpReceipt> {\n return this.sendBatchTransaction([tx]);\n }\n\n async sendBatchTransaction(\n txs: { target: Address; value?: bigint; data?: Hex }[]\n ): Promise<UserOpReceipt> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n // Normalize\n const transactions = txs.map(tx => ({\n target: tx.target,\n value: tx.value ?? 0n,\n data: tx.data ?? \"0x\"\n }));\n\n try {\n const userOp = await this.userOpBuilder.buildUserOperationBatch(\n this.owner,\n this.smartAccountAddress,\n transactions\n );\n const signed = await this.signUserOperation(userOp);\n const hash = await this.sendUserOperation(signed);\n return await this.waitForUserOperation(hash);\n } catch (error) {\n throw this.decodeError(error);\n }\n }\n\n async deposit(amount: bigint): Promise<Hash> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n\n if (this.walletClient) {\n return await this.walletClient.sendTransaction({\n account: this.walletClient.account!,\n to: this.smartAccountAddress,\n value: amount,\n chain: this.chainConfig.chain // Explicit chain\n });\n }\n\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: this.smartAccountAddress,\n value: \"0x\" + amount.toString(16)\n }]\n }) as Hash;\n return txHash;\n }\n\n async transfer(\n token: Address | string,\n recipient: Address,\n amount: bigint\n ): Promise<UserOpReceipt> {\n const tokenAddress = this.getTokenAddress(token);\n\n // Native Transfer check\n if (tokenAddress === \"0x0000000000000000000000000000000000000000\") {\n return this.sendTransaction({\n target: recipient,\n value: amount,\n data: \"0x\"\n });\n }\n\n // ERC-20\n const data = this.tokenService.encodeTransfer(recipient, amount);\n return this.sendTransaction({\n target: tokenAddress,\n value: 0n,\n data\n });\n }\n\n /**\n * Approve a token for the Smart Account\n */\n async approveToken(\n token: Address,\n spender: Address,\n amount: bigint = 115792089237316195423570985008687907853269984665640564039457584007913129639935n // maxUint256\n ): Promise<Hash | \"NOT_NEEDED\"> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const support = await this.requestApprovalSupport(token, spender, amount);\n\n if (support.type === \"approve\") {\n const data = this.tokenService.encodeApprove(spender, amount);\n\n if (this.walletClient) {\n return await this.walletClient.sendTransaction({\n account: this.walletClient.account!,\n to: token,\n data,\n chain: this.chainConfig.chain\n });\n }\n\n const txHash = await window.ethereum!.request({\n method: \"eth_sendTransaction\",\n params: [{\n from: this.owner,\n to: token,\n data,\n }]\n }) as Hash;\n return txHash;\n }\n\n if (support.type === \"permit\") throw new Error(\"Permit not yet supported\");\n return \"NOT_NEEDED\";\n }\n\n // --- Core Bridge to Bundler/UserOp ---\n\n // Deprecated/Legacy but kept for compatibility or advanced usage?\n // buildUserOperationBatch moved to internal usage mostly, but maybe exposed?\n // If I remove them from public API, that is a BREAKING change if user used them.\n // User requested \"modularize\", but usually expects same public API.\n // I will expose them as simple delegates if needed, or assume they primarily use sendBatchTransaction.\n // The previous implementation exposed `buildUserOperationBatch`.\n async buildUserOperationBatch(transactions: any[]) {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.userOpBuilder.buildUserOperationBatch(this.owner, this.smartAccountAddress, transactions);\n }\n\n async signUserOperation(userOp: UserOperation): Promise<UserOperation> {\n if (!this.owner) throw new Error(\"Not connected\");\n\n const userOpHash = this.userOpBuilder.getUserOpHash(userOp);\n let signature: Hex;\n\n if (this.walletClient) {\n signature = await this.walletClient.signMessage({\n account: this.walletClient.account!,\n message: { raw: userOpHash } // Sign hash directly\n });\n } else {\n signature = (await window.ethereum!.request({\n method: \"personal_sign\",\n params: [userOpHash, this.owner],\n })) as Hex;\n }\n\n return { ...userOp, signature };\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return this.bundlerClient.sendUserOperation(userOp);\n }\n\n async waitForUserOperation(hash: Hash, timeout = 60000) {\n return this.bundlerClient.waitForUserOperation(hash, timeout);\n }\n\n // Internal but exposed via BundlerClient originally\n async requestApprovalSupport(token: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.bundlerClient.requestApprovalSupport(token, this.owner, spender, amount);\n }\n\n // Error Decoding (Private)\n private decodeError(error: any): Error {\n const msg = error?.message || \"\";\n const hexMatch = msg.match(/(0x[0-9a-fA-F]+)/);\n\n if (hexMatch) {\n try {\n const decoded = decodeErrorResult({\n abi: [{ inputs: [{ name: \"message\", type: \"string\" }], name: \"Error\", type: \"error\" }],\n data: hexMatch[0] as Hex\n });\n if (decoded.errorName === \"Error\") return new Error(`Smart Account Error: ${decoded.args[0]}`);\n } catch (e) { /* ignore */ }\n }\n\n if (msg.includes(\"AA21\")) return new Error(\"Smart Account: Native transfer failed (ETH missing?)\");\n if (msg.includes(\"AA25\")) return new Error(\"Smart Account: Invalid account nonce\");\n\n return error instanceof Error ? error : new Error(String(error));\n }\n\n // Getters\n getOwner() { return this.owner; }\n getSmartAccount() { return this.smartAccountAddress; }\n}\n\n// Global window types for MetaMask\ndeclare global {\n interface Window {\n ethereum?: {\n request: (args: { method: string; params?: unknown[] }) => Promise<unknown>;\n on: (event: string, callback: (args: unknown) => void) => void;\n removeListener: (event: string, callback: (args: unknown) => void) => void;\n };\n }\n}\n","export const DEFAULT_ENTRYPOINT = \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\nexport const DEFAULT_FACTORY = \"0x9406Cc6185a346906296840746125a0E44976454\"; // SimpleAccountFactory v0.6\n\nexport const factoryAbi = [\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"getAccountAddress\",\n outputs: [{ name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"isAccountDeployed\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"salt\", type: \"uint256\" },\n ],\n name: \"createAccount\",\n outputs: [{ name: \"account\", type: \"address\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const entryPointAbi = [\n {\n inputs: [\n { name: \"sender\", type: \"address\" },\n { name: \"key\", type: \"uint192\" },\n ],\n name: \"getNonce\",\n outputs: [{ name: \"nonce\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\nexport const smartAccountAbi = [\n {\n inputs: [\n { name: \"target\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"data\", type: \"bytes\" },\n ],\n name: \"execute\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"targets\", type: \"address[]\" },\n { name: \"values\", type: \"uint256[]\" },\n { name: \"datas\", type: \"bytes[]\" },\n ],\n name: \"executeBatch\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const erc20Abi = [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"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 {\n inputs: [\n { name: \"spender\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { name: \"from\", type: \"address\" },\n { name: \"to\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"decimals\",\n outputs: [{ name: \"\", type: \"uint8\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n","import { type Address, type Hash } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\n\nexport class BundlerClient {\n private bundlerUrl: string;\n private chainId: number;\n private entryPointAddress: Address;\n\n constructor(config: ChainConfig, entryPointAddress: Address) {\n this.bundlerUrl = config.bundlerUrl;\n this.chainId = config.chain.id;\n this.entryPointAddress = entryPointAddress;\n }\n\n private async call(method: string, params: any[]): Promise<any> {\n const response = await fetch(this.bundlerUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method,\n params,\n }),\n });\n\n const result = await response.json();\n if (result.error) {\n throw new Error(result.error.message);\n }\n return result.result;\n }\n\n async estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate> {\n return await this.call(\"eth_estimateUserOperationGas\", [\n {\n sender: userOp.sender,\n nonce: userOp.nonce ? \"0x\" + userOp.nonce.toString(16) : \"0x0\",\n initCode: userOp.initCode || \"0x\",\n callData: userOp.callData || \"0x\",\n paymasterAndData: userOp.paymasterAndData || \"0x\",\n signature: \"0x\",\n },\n this.entryPointAddress,\n ]);\n }\n\n async sendUserOperation(userOp: UserOperation): Promise<Hash> {\n return await this.call(\"eth_sendUserOperation\", [\n {\n sender: userOp.sender,\n nonce: \"0x\" + userOp.nonce.toString(16),\n initCode: userOp.initCode,\n callData: userOp.callData,\n callGasLimit: \"0x\" + userOp.callGasLimit.toString(16),\n verificationGasLimit: \"0x\" + userOp.verificationGasLimit.toString(16),\n preVerificationGas: \"0x\" + userOp.preVerificationGas.toString(16),\n maxFeePerGas: \"0x\" + userOp.maxFeePerGas.toString(16),\n maxPriorityFeePerGas: \"0x\" + userOp.maxPriorityFeePerGas.toString(16),\n paymasterAndData: userOp.paymasterAndData,\n signature: userOp.signature,\n },\n this.entryPointAddress,\n ]);\n }\n\n async waitForUserOperation(userOpHash: Hash, timeout = 60000): Promise<UserOpReceipt> {\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n const result = await this.call(\"eth_getUserOperationReceipt\", [userOpHash]);\n\n if (result) {\n return result as UserOpReceipt;\n }\n\n // Wait 2 seconds before polling again\n await new Promise((resolve) => setTimeout(resolve, 2000));\n }\n\n throw new Error(\"Timeout waiting for UserOperation\");\n }\n\n async requestApprovalSupport(token: Address, owner: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult> {\n return await this.call(\"pm_requestApprovalSupport\", [\n token,\n owner,\n spender,\n amount.toString()\n ]);\n }\n}\n","import { type Address, type PublicClient, encodeFunctionData } from \"viem\";\nimport { type ChainConfig, type Token } from \"./types\";\nimport { erc20Abi } from \"./constants\";\n\nexport class TokenService {\n private tokens: Map<string, Token> = new Map();\n private publicClient: PublicClient;\n\n constructor(chainConfig: ChainConfig, publicClient: PublicClient) {\n this.publicClient = publicClient;\n\n // Initialize Tokens\n chainConfig.tokens.forEach(token => {\n this.tokens.set(token.symbol.toUpperCase(), token);\n });\n }\n\n /**\n * Resolve token address from symbol or return address if provided\n */\n getTokenAddress(token: string | Address): Address {\n // Native Token (ETH)\n if (token === \"ETH\") {\n return \"0x0000000000000000000000000000000000000000\";\n }\n\n if (token.startsWith(\"0x\")) return token as Address;\n const info = this.tokens.get(token.toUpperCase());\n if (!info) throw new Error(`Token ${token} not found in chain config`);\n return info.address;\n }\n\n /**\n * Get balance of a token for an account\n */\n async getBalance(token: string | Address, account: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n // Native Balance\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return await this.publicClient.getBalance({ address: account });\n }\n\n // ERC-20 Balance\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [account],\n }) as bigint;\n }\n\n /**\n * Get allowance (ERC-20 only)\n */\n async getAllowance(token: string | Address, owner: Address, spender: Address): Promise<bigint> {\n const address = this.getTokenAddress(token);\n\n if (address === \"0x0000000000000000000000000000000000000000\") {\n return 0n; // Native token has no allowance\n }\n\n return await this.publicClient.readContract({\n address,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n }) as bigint;\n }\n\n /**\n * Encode transfer data\n */\n encodeTransfer(recipient: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [recipient, amount]\n });\n }\n\n /**\n * Encode approve data\n */\n encodeApprove(spender: Address, amount: bigint): `0x${string}` {\n return encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, amount]\n });\n }\n}\n","import {\n type Address,\n type Hash,\n type Hex,\n type PublicClient,\n encodeFunctionData,\n encodeAbiParameters,\n keccak256\n} from \"viem\";\nimport { type ChainConfig, type UserOperation } from \"./types\";\nimport { BundlerClient } from \"./BundlerClient\";\nimport { factoryAbi, smartAccountAbi, entryPointAbi } from \"./constants\";\n\nexport class UserOpBuilder {\n private chainConfig: ChainConfig;\n private bundlerClient: BundlerClient;\n private publicClient: PublicClient;\n private entryPointAddress: Address;\n private factoryAddress: Address;\n\n constructor(\n chainConfig: ChainConfig,\n bundlerClient: BundlerClient,\n publicClient: PublicClient\n ) {\n this.chainConfig = chainConfig;\n this.bundlerClient = bundlerClient;\n this.publicClient = publicClient;\n\n // Resolved in AA or here? Let's assume passed valid config or resolve again\n // Ideally we shouldn't duplicate logic. AA resolves them.\n // Let's rely on config having them or resolving valid ones.\n // For now take from config or defaults.\n this.entryPointAddress = chainConfig.entryPointAddress!; // Assumed validated by AA\n this.factoryAddress = chainConfig.factoryAddress!;\n }\n\n async getNonce(smartAccountAddress: Address): Promise<bigint> {\n return await this.publicClient.readContract({\n address: this.entryPointAddress,\n abi: entryPointAbi,\n functionName: \"getNonce\",\n args: [smartAccountAddress, 0n],\n }) as bigint;\n }\n\n buildInitCode(owner: Address): Hex {\n const createAccountData = encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [owner, 0n],\n });\n return `${this.factoryAddress}${createAccountData.slice(2)}` as Hex;\n }\n\n async isAccountDeployed(smartAccountAddress: Address): Promise<boolean> {\n const code = await this.publicClient.getCode({\n address: smartAccountAddress,\n });\n return code !== undefined && code !== \"0x\";\n }\n\n async buildUserOperationBatch(\n owner: Address,\n smartAccountAddress: Address,\n transactions: { target: Address; value: bigint; data: Hex }[]\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n const initCode = isDeployed ? \"0x\" : this.buildInitCode(owner);\n\n const targets = transactions.map((tx) => tx.target);\n const values = transactions.map((tx) => tx.value);\n const datas = transactions.map((tx) => tx.data);\n\n const callData = encodeFunctionData({\n abi: smartAccountAbi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n async buildDeployUserOp(\n owner: Address,\n smartAccountAddress: Address\n ): Promise<UserOperation> {\n const isDeployed = await this.isAccountDeployed(smartAccountAddress);\n if (isDeployed) throw new Error(\"Account already deployed\");\n\n const initCode = this.buildInitCode(owner);\n const callData = \"0x\";\n const nonce = await this.getNonce(smartAccountAddress);\n\n const partialOp = {\n sender: smartAccountAddress,\n nonce,\n initCode: initCode as Hex,\n callData: callData as Hex,\n paymasterAndData: (this.chainConfig.paymasterAddress || \"0x\") as Hex,\n };\n\n const gasEstimate = await this.bundlerClient.estimateGas(partialOp);\n\n return {\n ...partialOp,\n callGasLimit: BigInt(gasEstimate.callGasLimit),\n verificationGasLimit: BigInt(gasEstimate.verificationGasLimit),\n preVerificationGas: BigInt(gasEstimate.preVerificationGas),\n maxFeePerGas: BigInt(gasEstimate.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasEstimate.maxPriorityFeePerGas),\n signature: \"0x\",\n };\n }\n\n getUserOpHash(userOp: UserOperation): Hex {\n const packed = encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n ],\n [\n userOp.sender,\n userOp.nonce,\n keccak256(userOp.initCode),\n keccak256(userOp.callData),\n userOp.callGasLimit,\n userOp.verificationGasLimit,\n userOp.preVerificationGas,\n userOp.maxFeePerGas,\n userOp.maxPriorityFeePerGas,\n keccak256(userOp.paymasterAndData),\n ]\n );\n\n const packedHash = keccak256(packed);\n\n return keccak256(\n encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }, { type: \"uint256\" }],\n [packedHash, this.entryPointAddress, BigInt(this.chainConfig.chain.id)]\n )\n );\n }\n}\n","import { type ChainConfig } from \"./types\";\nimport { base, baseSepolia, gnosis } from \"viem/chains\";\n\nconst DEFAULT_BUNDLER_URL = \"https://bundler-erc-4337.vercel.app\";\nconst BUNDLER_URL = process.env.NEXT_PUBLIC_BUNDLER_URL || process.env.BUNDLER_URL || DEFAULT_BUNDLER_URL;\n\n\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=base`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xe2584152891E4769025807DEa0cD611F135aDC68\",\n paymasterAddress: \"0x1e13Eb16C565E3f3FDe49A011755e50410bb1F95\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const GNOSIS_MAINNET: ChainConfig = {\n chain: gnosis,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=gnosis`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0xC8a2Fb1f2E686417A131E09be3320cb5431CcD90\",\n paymasterAddress: \"0x4C36C70d68a7c26326711e8268bb163E3784fA96\",\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0\"\n },\n {\n symbol: \"USDT\",\n decimals: 6,\n address: \"0x4ECaBa5870353805a9F068101A40E0f32ed605C6\"\n },\n {\n symbol: \"EURe\",\n decimals: 18,\n address: \"0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430\"\n },\n {\n symbol: \"GNO\",\n decimals: 18,\n address: \"0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb\"\n },\n {\n symbol: \"WETH\",\n decimals: 18,\n address: \"0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1\"\n },\n {\n symbol: \"XDAI\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\nexport const BASE_SEPOLIA: ChainConfig = {\n chain: baseSepolia,\n bundlerUrl: `${BUNDLER_URL}/rpc?chain=baseSepolia`, // Dynamic Bundler URL\n\n // Addresses\n entryPointAddress: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n factoryAddress: \"0x9406Cc6185a346906296840746125a0E44976454\",\n // Paymaster not configured in deployments.ts for Sepolia?\n\n tokens: [\n {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"\n },\n {\n symbol: \"ETH\",\n decimals: 18,\n address: \"0x0000000000000000000000000000000000000000\"\n }\n ]\n};\n\n// Map accessible by ChainID\nexport const CHAIN_CONFIGS: Record<number, ChainConfig> = {\n [base.id]: BASE_MAINNET,\n [baseSepolia.id]: BASE_SEPOLIA,\n [gnosis.id]: GNOSIS_MAINNET\n};\n"],"mappings":";AAAA;AAAA,EACI;AAAA,EACA;AAAA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