@1llet.xyz/erc4337-gasless-sdk 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +58 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -81,9 +81,11 @@ declare class AccountAbstraction {
|
|
|
81
81
|
*/
|
|
82
82
|
isAccountDeployed(): Promise<boolean>;
|
|
83
83
|
getTokenAddress(token: string | Address): Address;
|
|
84
|
+
getBalance(token: string | Address): Promise<bigint>;
|
|
85
|
+
getEoaBalance(token: string | Address): Promise<bigint>;
|
|
84
86
|
getUsdcBalance(): Promise<bigint>;
|
|
85
87
|
getEoaUsdcBalance(): Promise<bigint>;
|
|
86
|
-
getAllowance(): Promise<bigint>;
|
|
88
|
+
getAllowance(token?: string | Address): Promise<bigint>;
|
|
87
89
|
deployAccount(): Promise<UserOpReceipt>;
|
|
88
90
|
sendTransaction(tx: {
|
|
89
91
|
target: Address;
|
|
@@ -136,6 +138,7 @@ declare class BundlerClient {
|
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
declare const BASE_MAINNET: ChainConfig;
|
|
141
|
+
declare const GNOSIS_MAINNET: ChainConfig;
|
|
139
142
|
declare const BASE_SEPOLIA: ChainConfig;
|
|
140
143
|
declare const CHAIN_CONFIGS: Record<number, ChainConfig>;
|
|
141
144
|
|
|
@@ -272,4 +275,4 @@ declare const erc20Abi: readonly [{
|
|
|
272
275
|
readonly type: "function";
|
|
273
276
|
}];
|
|
274
277
|
|
|
275
|
-
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CHAIN_CONFIGS, type ChainConfig, type GasEstimate, type Token, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
278
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CHAIN_CONFIGS, type ChainConfig, GNOSIS_MAINNET, type GasEstimate, type Token, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
package/dist/index.d.ts
CHANGED
|
@@ -81,9 +81,11 @@ declare class AccountAbstraction {
|
|
|
81
81
|
*/
|
|
82
82
|
isAccountDeployed(): Promise<boolean>;
|
|
83
83
|
getTokenAddress(token: string | Address): Address;
|
|
84
|
+
getBalance(token: string | Address): Promise<bigint>;
|
|
85
|
+
getEoaBalance(token: string | Address): Promise<bigint>;
|
|
84
86
|
getUsdcBalance(): Promise<bigint>;
|
|
85
87
|
getEoaUsdcBalance(): Promise<bigint>;
|
|
86
|
-
getAllowance(): Promise<bigint>;
|
|
88
|
+
getAllowance(token?: string | Address): Promise<bigint>;
|
|
87
89
|
deployAccount(): Promise<UserOpReceipt>;
|
|
88
90
|
sendTransaction(tx: {
|
|
89
91
|
target: Address;
|
|
@@ -136,6 +138,7 @@ declare class BundlerClient {
|
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
declare const BASE_MAINNET: ChainConfig;
|
|
141
|
+
declare const GNOSIS_MAINNET: ChainConfig;
|
|
139
142
|
declare const BASE_SEPOLIA: ChainConfig;
|
|
140
143
|
declare const CHAIN_CONFIGS: Record<number, ChainConfig>;
|
|
141
144
|
|
|
@@ -272,4 +275,4 @@ declare const erc20Abi: readonly [{
|
|
|
272
275
|
readonly type: "function";
|
|
273
276
|
}];
|
|
274
277
|
|
|
275
|
-
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CHAIN_CONFIGS, type ChainConfig, type GasEstimate, type Token, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
278
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CHAIN_CONFIGS, type ChainConfig, GNOSIS_MAINNET, type GasEstimate, type Token, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
BASE_SEPOLIA: () => BASE_SEPOLIA,
|
|
26
26
|
BundlerClient: () => BundlerClient,
|
|
27
27
|
CHAIN_CONFIGS: () => CHAIN_CONFIGS,
|
|
28
|
+
GNOSIS_MAINNET: () => GNOSIS_MAINNET,
|
|
28
29
|
entryPointAbi: () => entryPointAbi,
|
|
29
30
|
erc20Abi: () => erc20Abi,
|
|
30
31
|
smartAccountAbi: () => smartAccountAbi
|
|
@@ -524,17 +525,24 @@ var AccountAbstraction = class {
|
|
|
524
525
|
getTokenAddress(token) {
|
|
525
526
|
return this.tokenService.getTokenAddress(token);
|
|
526
527
|
}
|
|
527
|
-
async
|
|
528
|
+
async getBalance(token) {
|
|
528
529
|
if (!this.smartAccountAddress) throw new Error("Not connected");
|
|
529
|
-
return this.tokenService.getBalance(
|
|
530
|
+
return this.tokenService.getBalance(token, this.smartAccountAddress);
|
|
530
531
|
}
|
|
531
|
-
async
|
|
532
|
+
async getEoaBalance(token) {
|
|
532
533
|
if (!this.owner) throw new Error("Not connected");
|
|
533
|
-
return this.tokenService.getBalance(
|
|
534
|
+
return this.tokenService.getBalance(token, this.owner);
|
|
535
|
+
}
|
|
536
|
+
// Deprecated helpers maintained for compatibility
|
|
537
|
+
async getUsdcBalance() {
|
|
538
|
+
return this.getBalance("USDC");
|
|
534
539
|
}
|
|
535
|
-
async
|
|
540
|
+
async getEoaUsdcBalance() {
|
|
541
|
+
return this.getEoaBalance("USDC");
|
|
542
|
+
}
|
|
543
|
+
async getAllowance(token = "USDC") {
|
|
536
544
|
if (!this.owner || !this.smartAccountAddress) throw new Error("Not connected");
|
|
537
|
-
return this.tokenService.getAllowance(
|
|
545
|
+
return this.tokenService.getAllowance(token, this.owner, this.smartAccountAddress);
|
|
538
546
|
}
|
|
539
547
|
// --- Transactions ---
|
|
540
548
|
async deployAccount() {
|
|
@@ -701,6 +709,47 @@ var BASE_MAINNET = {
|
|
|
701
709
|
}
|
|
702
710
|
]
|
|
703
711
|
};
|
|
712
|
+
var GNOSIS_MAINNET = {
|
|
713
|
+
chain: import_chains.gnosis,
|
|
714
|
+
bundlerUrl: "http://localhost:3000/rpc?chain=gnosis",
|
|
715
|
+
// Default to local bundler pattern
|
|
716
|
+
// Addresses
|
|
717
|
+
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
718
|
+
factoryAddress: "0xC8a2Fb1f2E686417A131E09be3320cb5431CcD90",
|
|
719
|
+
paymasterAddress: "0x4C36C70d68a7c26326711e8268bb163E3784fA96",
|
|
720
|
+
tokens: [
|
|
721
|
+
{
|
|
722
|
+
symbol: "USDC",
|
|
723
|
+
decimals: 6,
|
|
724
|
+
address: "0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0"
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
symbol: "USDT",
|
|
728
|
+
decimals: 6,
|
|
729
|
+
address: "0x4ECaBa5870353805a9F068101A40E0f32ed605C6"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
symbol: "EURe",
|
|
733
|
+
decimals: 18,
|
|
734
|
+
address: "0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430"
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
symbol: "GNO",
|
|
738
|
+
decimals: 18,
|
|
739
|
+
address: "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
symbol: "WETH",
|
|
743
|
+
decimals: 18,
|
|
744
|
+
address: "0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
symbol: "XDAI",
|
|
748
|
+
decimals: 18,
|
|
749
|
+
address: "0x0000000000000000000000000000000000000000"
|
|
750
|
+
}
|
|
751
|
+
]
|
|
752
|
+
};
|
|
704
753
|
var BASE_SEPOLIA = {
|
|
705
754
|
chain: import_chains.baseSepolia,
|
|
706
755
|
bundlerUrl: "http://localhost:3000/rpc?chain=baseSepolia",
|
|
@@ -724,7 +773,8 @@ var BASE_SEPOLIA = {
|
|
|
724
773
|
};
|
|
725
774
|
var CHAIN_CONFIGS = {
|
|
726
775
|
[import_chains.base.id]: BASE_MAINNET,
|
|
727
|
-
[import_chains.baseSepolia.id]: BASE_SEPOLIA
|
|
776
|
+
[import_chains.baseSepolia.id]: BASE_SEPOLIA,
|
|
777
|
+
[import_chains.gnosis.id]: GNOSIS_MAINNET
|
|
728
778
|
};
|
|
729
779
|
// Annotate the CommonJS export names for ESM import in node:
|
|
730
780
|
0 && (module.exports = {
|
|
@@ -733,6 +783,7 @@ var CHAIN_CONFIGS = {
|
|
|
733
783
|
BASE_SEPOLIA,
|
|
734
784
|
BundlerClient,
|
|
735
785
|
CHAIN_CONFIGS,
|
|
786
|
+
GNOSIS_MAINNET,
|
|
736
787
|
entryPointAbi,
|
|
737
788
|
erc20Abi,
|
|
738
789
|
smartAccountAbi
|
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, 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 getUsdcBalance(): Promise<bigint> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(\"USDC\", this.smartAccountAddress);\n }\n\n async getEoaUsdcBalance(): Promise<bigint> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(\"USDC\", this.owner);\n }\n\n async getAllowance(): Promise<bigint> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getAllowance(\"USDC\", 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, type Hex } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\nimport { entryPointAbi } from \"./constants\";\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, type GasEstimate } 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 } from \"viem/chains\";\n\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: \"http://localhost:3000/rpc?chain=base\", // Default to local bundler pattern\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 BASE_SEPOLIA: ChainConfig = {\n chain: baseSepolia,\n bundlerUrl: \"http://localhost:3000/rpc?chain=baseSepolia\", // Default to local bundler pattern\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};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;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,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G,SAAS,GAAG;AAAA,MAAe;AAAA,IAC/B;AAEA,QAAI,IAAI,SAAS,MAAM,EAAG,QAAO,IAAI,MAAM,sDAAsD;AACjG,QAAI,IAAI,SAAS,MAAM,EAAG,QAAO,IAAI,MAAM,sCAAsC;AAEjF,WAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAAA,EACnE;AAAA;AAAA,EAGA,WAAW;AAAE,WAAO,KAAK;AAAA,EAAO;AAAA,EAChC,kBAAkB;AAAE,WAAO,KAAK;AAAA,EAAqB;AACzD;;;AKvVA,oBAAkC;AAE3B,IAAM,eAA4B;AAAA,EACrC,OAAO;AAAA,EACP,YAAY;AAAA;AAAA;AAAA,EAGZ,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAElB,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;AAEO,IAAM,eAA4B;AAAA,EACrC,OAAO;AAAA,EACP,YAAY;AAAA;AAAA;AAAA,EAGZ,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;AACtB;","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 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, type Hex } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\nimport { entryPointAbi } from \"./constants\";\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, type GasEstimate } 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\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: \"http://localhost:3000/rpc?chain=base\", // Default to local bundler pattern\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: \"http://localhost:3000/rpc?chain=gnosis\", // Default to local bundler pattern\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: \"http://localhost:3000/rpc?chain=baseSepolia\", // Default to local bundler pattern\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;AA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AA,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;AAAA;AAAA;AAAA,EAGZ,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
|
@@ -499,17 +499,24 @@ var AccountAbstraction = class {
|
|
|
499
499
|
getTokenAddress(token) {
|
|
500
500
|
return this.tokenService.getTokenAddress(token);
|
|
501
501
|
}
|
|
502
|
-
async
|
|
502
|
+
async getBalance(token) {
|
|
503
503
|
if (!this.smartAccountAddress) throw new Error("Not connected");
|
|
504
|
-
return this.tokenService.getBalance(
|
|
504
|
+
return this.tokenService.getBalance(token, this.smartAccountAddress);
|
|
505
505
|
}
|
|
506
|
-
async
|
|
506
|
+
async getEoaBalance(token) {
|
|
507
507
|
if (!this.owner) throw new Error("Not connected");
|
|
508
|
-
return this.tokenService.getBalance(
|
|
508
|
+
return this.tokenService.getBalance(token, this.owner);
|
|
509
|
+
}
|
|
510
|
+
// Deprecated helpers maintained for compatibility
|
|
511
|
+
async getUsdcBalance() {
|
|
512
|
+
return this.getBalance("USDC");
|
|
509
513
|
}
|
|
510
|
-
async
|
|
514
|
+
async getEoaUsdcBalance() {
|
|
515
|
+
return this.getEoaBalance("USDC");
|
|
516
|
+
}
|
|
517
|
+
async getAllowance(token = "USDC") {
|
|
511
518
|
if (!this.owner || !this.smartAccountAddress) throw new Error("Not connected");
|
|
512
|
-
return this.tokenService.getAllowance(
|
|
519
|
+
return this.tokenService.getAllowance(token, this.owner, this.smartAccountAddress);
|
|
513
520
|
}
|
|
514
521
|
// --- Transactions ---
|
|
515
522
|
async deployAccount() {
|
|
@@ -654,7 +661,7 @@ var AccountAbstraction = class {
|
|
|
654
661
|
};
|
|
655
662
|
|
|
656
663
|
// src/chains.ts
|
|
657
|
-
import { base, baseSepolia } from "viem/chains";
|
|
664
|
+
import { base, baseSepolia, gnosis } from "viem/chains";
|
|
658
665
|
var BASE_MAINNET = {
|
|
659
666
|
chain: base,
|
|
660
667
|
bundlerUrl: "http://localhost:3000/rpc?chain=base",
|
|
@@ -676,6 +683,47 @@ var BASE_MAINNET = {
|
|
|
676
683
|
}
|
|
677
684
|
]
|
|
678
685
|
};
|
|
686
|
+
var GNOSIS_MAINNET = {
|
|
687
|
+
chain: gnosis,
|
|
688
|
+
bundlerUrl: "http://localhost:3000/rpc?chain=gnosis",
|
|
689
|
+
// Default to local bundler pattern
|
|
690
|
+
// Addresses
|
|
691
|
+
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
692
|
+
factoryAddress: "0xC8a2Fb1f2E686417A131E09be3320cb5431CcD90",
|
|
693
|
+
paymasterAddress: "0x4C36C70d68a7c26326711e8268bb163E3784fA96",
|
|
694
|
+
tokens: [
|
|
695
|
+
{
|
|
696
|
+
symbol: "USDC",
|
|
697
|
+
decimals: 6,
|
|
698
|
+
address: "0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0"
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
symbol: "USDT",
|
|
702
|
+
decimals: 6,
|
|
703
|
+
address: "0x4ECaBa5870353805a9F068101A40E0f32ed605C6"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
symbol: "EURe",
|
|
707
|
+
decimals: 18,
|
|
708
|
+
address: "0x420CA0f9B9b604cE0fd9C18EF134C705e5Fa3430"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
symbol: "GNO",
|
|
712
|
+
decimals: 18,
|
|
713
|
+
address: "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
symbol: "WETH",
|
|
717
|
+
decimals: 18,
|
|
718
|
+
address: "0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1"
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
symbol: "XDAI",
|
|
722
|
+
decimals: 18,
|
|
723
|
+
address: "0x0000000000000000000000000000000000000000"
|
|
724
|
+
}
|
|
725
|
+
]
|
|
726
|
+
};
|
|
679
727
|
var BASE_SEPOLIA = {
|
|
680
728
|
chain: baseSepolia,
|
|
681
729
|
bundlerUrl: "http://localhost:3000/rpc?chain=baseSepolia",
|
|
@@ -699,7 +747,8 @@ var BASE_SEPOLIA = {
|
|
|
699
747
|
};
|
|
700
748
|
var CHAIN_CONFIGS = {
|
|
701
749
|
[base.id]: BASE_MAINNET,
|
|
702
|
-
[baseSepolia.id]: BASE_SEPOLIA
|
|
750
|
+
[baseSepolia.id]: BASE_SEPOLIA,
|
|
751
|
+
[gnosis.id]: GNOSIS_MAINNET
|
|
703
752
|
};
|
|
704
753
|
export {
|
|
705
754
|
AccountAbstraction,
|
|
@@ -707,6 +756,7 @@ export {
|
|
|
707
756
|
BASE_SEPOLIA,
|
|
708
757
|
BundlerClient,
|
|
709
758
|
CHAIN_CONFIGS,
|
|
759
|
+
GNOSIS_MAINNET,
|
|
710
760
|
entryPointAbi,
|
|
711
761
|
erc20Abi,
|
|
712
762
|
smartAccountAbi
|
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 getUsdcBalance(): Promise<bigint> {\n if (!this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(\"USDC\", this.smartAccountAddress);\n }\n\n async getEoaUsdcBalance(): Promise<bigint> {\n if (!this.owner) throw new Error(\"Not connected\");\n return this.tokenService.getBalance(\"USDC\", this.owner);\n }\n\n async getAllowance(): Promise<bigint> {\n if (!this.owner || !this.smartAccountAddress) throw new Error(\"Not connected\");\n return this.tokenService.getAllowance(\"USDC\", 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, type Hex } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\nimport { entryPointAbi } from \"./constants\";\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, type GasEstimate } 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 } from \"viem/chains\";\n\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: \"http://localhost:3000/rpc?chain=base\", // Default to local bundler pattern\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 BASE_SEPOLIA: ChainConfig = {\n chain: baseSepolia,\n bundlerUrl: \"http://localhost:3000/rpc?chain=baseSepolia\", // Default to local bundler pattern\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};\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,IAC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,EAAE,GAAG;AAAA,EACX,CAAC,YAAY,EAAE,GAAG;AACtB;","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 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, type Hex } from \"viem\";\nimport { type ChainConfig, type UserOperation, type GasEstimate, type UserOpReceipt, type ApprovalSupportResult } from \"./types\";\nimport { entryPointAbi } from \"./constants\";\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, type GasEstimate } 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\nexport const BASE_MAINNET: ChainConfig = {\n chain: base,\n bundlerUrl: \"http://localhost:3000/rpc?chain=base\", // Default to local bundler pattern\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: \"http://localhost:3000/rpc?chain=gnosis\", // Default to local bundler pattern\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: \"http://localhost:3000/rpc?chain=baseSepolia\", // Default to local bundler pattern\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,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,IAA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