abstractionkit 0.2.41 → 0.3.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/account/SmartAccount.ts","../src/constants.ts","../src/types.ts","../src/errors.ts","../src/utils.ts","../src/utils7702.ts","../src/Bundler.ts","../src/account/SendUseroperationResponse.ts","../src/account/simple/Simple7702Account.ts","../src/account/simple/Simple7702AccountV09.ts","../src/utilsTenderly.ts","../src/account/Safe/types.ts","../src/account/Safe/multisend.ts","../src/factory/SmartAccountFactory.ts","../src/factory/SafeAccountFactory.ts","../src/account/Safe/safeMessage.ts","../src/account/Safe/SafeAccount.ts","../src/account/Safe/MerkleTree.ts","../src/account/Safe/constants.ts","../src/account/Safe/SafeMultiChainSigAccount.ts","../src/account/Calibur/types.ts","../src/account/Calibur/Calibur7702Account.ts","../src/account/Safe/modules/SafeModule.ts","../src/account/Safe/modules/SocialRecoveryModule.ts","../src/account/Safe/modules/AllowanceModule.ts","../src/account/Safe/SafeAccountV0_3_0.ts","../src/account/Safe/SafeAccountV0_2_0.ts","../src/account/Safe/SafeAccountV1_5_0_M_0_3_0.ts","../src/paymaster/Paymaster.ts","../src/paymaster/CandidePaymaster.ts","../src/paymaster/AllowAllPaymaster.ts","../src/paymaster/WorldIdPermissionlessPaymaster.ts","../src/abstractionkit.ts"],"sourcesContent":["/**\n * Abstract base class for all smart account implementations.\n * Defines common properties shared across account types (Safe, Simple, etc.).\n */\nexport abstract class SmartAccount {\n\t/** The on-chain address of the smart account */\n\treadonly accountAddress: string;\n\t/** Proxy contract creation bytecode */\n\tstatic readonly proxyByteCode: string;\n\t/** 4-byte function selector for the account initializer */\n\tstatic readonly initializerFunctionSelector: string;\n\t/** ABI types for the initializer function parameters */\n\tstatic readonly initializerFunctionInputAbi: string[];\n\t/** 4-byte function selector for the executor function */\n\tstatic readonly executorFunctionSelector: string;\n\t/** ABI types for the executor function parameters */\n\tstatic readonly executorFunctionInputAbi: string[];\n\n\t/**\n\t * @param accountAddress - The on-chain address of the smart account\n\t */\n\tconstructor(accountAddress: string) {\n\t\tthis.accountAddress = accountAddress;\n\t}\n}\n","import { SafeAccountSingleton } from \"./account/Safe/types\";\n\n/** The Ethereum zero address (0x0000...0000), used as a placeholder for empty/null addresses */\nexport const ZeroAddress = \"0x0000000000000000000000000000000000000000\";\n\n/** EntryPoint v0.9 contract address */\nexport const ENTRYPOINT_V9 = \"0x433709009B8330FDa32311DF1C2AFA402eD8D009\";\n/** EntryPoint v0.8 contract address */\nexport const ENTRYPOINT_V8 = \"0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108\";\n/** EntryPoint v0.7 contract address */\nexport const ENTRYPOINT_V7 = \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\";\n/** EntryPoint v0.6 contract address */\nexport const ENTRYPOINT_V6 = \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\n\n/** Safe L2 singleton v1.5.0 address and init hash */\nexport const Safe_L2_V1_5_0: SafeAccountSingleton = {\n\tsingletonAddress: \"0xEdd160fEBBD92E350D4D398fb636302fccd67C7e\",\n\tsingletonInitHash:\n\t\t\"0x1b94aebb5a7df6dff11d93589204a6bbc99b4b8c9014bf1d386d006c2c17a881\",\n};\n\n/** Safe L2 singleton v1.4.1 address and init hash */\nexport const Safe_L2_V1_4_1: SafeAccountSingleton = {\n\tsingletonAddress: \"0x29fcB43b46531BcA003ddC8FCB67FFE91900C762\",\n\tsingletonInitHash:\n\t\t\"0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee\",\n};\n\n/** Default placeholder values for gas estimation before actual values are known */\nexport const BaseUserOperationDummyValues = {\n\tsender: ZeroAddress,\n\tnonce: 0n,\n\tcallData: \"0x\",\n\tcallGasLimit: 0n,\n\tverificationGasLimit: 0n,\n\tpreVerificationGas: 0n,\n\tmaxFeePerGas: 0n,\n\tmaxPriorityFeePerGas: 0n,\n\tsignature: \"0x\",\n};\n\nexport const EIP712_SAFE_OPERATION_PRIMARY_TYPE = \"SafeOp\";\n\n/** EIP-712 type definition for Safe UserOperation signing (EntryPoint v0.6) */\nexport const EIP712_SAFE_OPERATION_V6_TYPE = {\n\tSafeOp: [\n\t\t{ type: \"address\", name: \"safe\" },\n\t\t{ type: \"uint256\", name: \"nonce\" },\n\t\t{ type: \"bytes\", name: \"initCode\" },\n\t\t{ type: \"bytes\", name: \"callData\" },\n\t\t{ type: \"uint256\", name: \"callGasLimit\" },\n\t\t{ type: \"uint256\", name: \"verificationGasLimit\" },\n\t\t{ type: \"uint256\", name: \"preVerificationGas\" },\n\t\t{ type: \"uint256\", name: \"maxFeePerGas\" },\n\t\t{ type: \"uint256\", name: \"maxPriorityFeePerGas\" },\n\t\t{ type: \"bytes\", name: \"paymasterAndData\" },\n\t\t{ type: \"uint48\", name: \"validAfter\" },\n\t\t{ type: \"uint48\", name: \"validUntil\" },\n\t\t{ type: \"address\", name: \"entryPoint\" },\n\t],\n};\n\n/** EIP-712 type definition for Safe UserOperation signing (EntryPoint v0.7) */\nexport const EIP712_SAFE_OPERATION_V7_TYPE = {\n\tSafeOp: [\n\t\t{ type: \"address\", name: \"safe\" },\n\t\t{ type: \"uint256\", name: \"nonce\" },\n\t\t{ type: \"bytes\", name: \"initCode\" },\n\t\t{ type: \"bytes\", name: \"callData\" },\n\t\t{ type: \"uint128\", name: \"verificationGasLimit\" },\n\t\t{ type: \"uint128\", name: \"callGasLimit\" },\n\t\t{ type: \"uint256\", name: \"preVerificationGas\" },\n\t\t{ type: \"uint128\", name: \"maxPriorityFeePerGas\" },\n\t\t{ type: \"uint128\", name: \"maxFeePerGas\" },\n\t\t{ type: \"bytes\", name: \"paymasterAndData\" },\n\t\t{ type: \"uint48\", name: \"validAfter\" },\n\t\t{ type: \"uint48\", name: \"validUntil\" },\n\t\t{ type: \"address\", name: \"entryPoint\" },\n\t],\n};\n\nexport const EIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE = \"MerkleTreeRoot\";\n\n/** EIP-712 type definition for multi-chain Safe operations using Merkle tree roots */\nexport const EIP712_MULTI_CHAIN_OPERATIONS_TYPE = {\n\tMerkleTreeRoot: [\n\t\t{ type: \"bytes32\", name: \"merkleTreeRoot\" },\n\t],\n};\n\n/** Default address for the secp256r1 (P-256) precompile used by WebAuthn verification */\nexport const DEFAULT_SECP256R1_PRECOMPILE_ADDRESS = \"0x0000000000000000000000000000000000000100\";\n\n/** Uniswap Calibur singleton v1.0.0 (EntryPoint v0.8) */\nexport const CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS = \"0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00\";\n\n/** Candide Calibur singleton v0.1.0 (EntryPoint v0.9, unaudited) */\nexport const CALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS = \"0x71032285A847c4311Eb7ec2E7A636aB94A9805Aa\";\n","import { Authorization7702Hex } from \"./utils7702\";\n\n/**\n * Base fields shared by all UserOperation versions.\n * Extended by version-specific interfaces (UserOperationV6, V7, V8).\n */\nexport interface BaseUserOperation {\n\t/** The account making the operation */\n\tsender: string;\n\t/** Anti-replay parameter; also used as the salt for first-time account creation */\n\tnonce: bigint;\n\t/** The calldata to execute on the sender account */\n\tcallData: string;\n\t/** Gas limit for the inner account execution */\n\tcallGasLimit: bigint;\n\t/** Gas limit for the account verification step */\n\tverificationGasLimit: bigint;\n\t/** Extra gas to pay the bundler */\n\tpreVerificationGas: bigint;\n\t/** Maximum fee per gas (EIP-1559 max_fee_per_gas) */\n\tmaxFeePerGas: bigint;\n\t/** Maximum priority fee per gas (EIP-1559 max_priority_fee_per_gas) */\n\tmaxPriorityFeePerGas: bigint;\n\t/** Signature over the UserOperation hash */\n\tsignature: string;\n}\n\n/**\n * UserOperation for EntryPoint v0.6. Uses concatenated initCode and paymasterAndData fields.\n */\nexport interface UserOperationV6 extends BaseUserOperation {\n\t/** Concatenated factory address and factory-specific data (empty '0x' if already deployed) */\n\tinitCode: string;\n\t/** Concatenated paymaster address and paymaster-specific data (empty '0x' for self-funded) */\n\tpaymasterAndData: string;\n}\n\n/**\n * UserOperation for EntryPoint v0.7. Uses separate factory/paymaster fields.\n */\nexport interface UserOperationV7 extends BaseUserOperation {\n\t/** Factory contract address used to deploy the account (null if already deployed) */\n\tfactory: string | null;\n\t/** Factory-specific data for account creation (null if already deployed) */\n\tfactoryData: string | null;\n\t/** Paymaster contract address (null for self-funded operations) */\n\tpaymaster: string | null;\n\t/** Gas limit for the paymaster verification step (null if no paymaster) */\n\tpaymasterVerificationGasLimit: bigint | null;\n\t/** Gas limit for the paymaster post-operation callback (null if no paymaster) */\n\tpaymasterPostOpGasLimit: bigint | null;\n\t/** Paymaster-specific data (null if no paymaster) */\n\tpaymasterData: string | null;\n}\n\n/**\n * UserOperation for EntryPoint v0.8. Adds EIP-7702 authorization support.\n */\nexport interface UserOperationV8 extends BaseUserOperation {\n\t/** Factory contract address used to deploy the account (null if already deployed) */\n\tfactory: string | null;\n\t/** Factory-specific data for account creation (null if already deployed) */\n\tfactoryData: string | null;\n\t/** Paymaster contract address (null for self-funded operations) */\n\tpaymaster: string | null;\n\t/** Gas limit for the paymaster verification step (null if no paymaster) */\n\tpaymasterVerificationGasLimit: bigint | null;\n\t/** Gas limit for the paymaster post-operation callback (null if no paymaster) */\n\tpaymasterPostOpGasLimit: bigint | null;\n\t/** Paymaster-specific data (null if no paymaster) */\n\tpaymasterData: string | null;\n\t/** EIP-7702 delegation authorization (null if not using 7702) */\n eip7702Auth: Authorization7702Hex | null;\n}\n\n/**\n * UserOperation for EntryPoint v0.9. Same structure as v0.8.\n */\nexport interface UserOperationV9 extends UserOperationV8 {\n}\n\n/** Union type for values that can be ABI-encoded as function parameters. */\nexport type AbiInputValue =\n\t| string\n\t| bigint\n\t| number\n\t| boolean\n\t| AbiInputValue[];\n\n/** Union type for JSON-RPC request parameters. */\nexport type JsonRpcParam = string | bigint | boolean | object | JsonRpcParam[];\n\n/** Standard JSON-RPC 2.0 response envelope. */\nexport type JsonRpcResponse = {\n\t/** Request identifier */\n\tid: number | null;\n\t/** JSON-RPC protocol version */\n\tjsonrpc: string;\n\t/** The result payload on success */\n\tresult?: JsonRpcResult;\n\t/** Tenderly simulation results */\n simulation_results?: JsonRpcResult;\n\t/** The error payload on failure */\n\terror?: JsonRpcError;\n};\n\nexport type ChainIdResult = string;\nexport type SupportedEntryPointsResult = string[];\n\nexport type SingleTransactionTenderlySimulationResult = {\n transaction: any\n simulation: any\n}\n\nexport type TenderlySimulationResult = SingleTransactionTenderlySimulationResult[]\n\nexport type JsonRpcResult =\n\t| ChainIdResult\n\t| SupportedEntryPointsResult\n\t| GasEstimationResult\n\t| UserOperationByHashResult\n\t| UserOperationReceipt\n\t| UserOperationReceiptResult\n\t| SupportedERC20TokensAndMetadata\n\t| PmUserOperationV7Result\n\t| PmUserOperationV6Result\n | TenderlySimulationResult;\n\n/** JSON-RPC error object returned when a request fails. */\nexport type JsonRpcError = {\n\t/** Numeric error code */\n\tcode: number;\n\t/** Human-readable error message */\n\tmessage: string;\n\t/** Additional structured error data */\n\tdata: object;\n};\n\n/** Gas estimation result returned by eth_estimateUserOperationGas. */\nexport type GasEstimationResult = {\n\t/** Estimated gas limit for inner execution */\n\tcallGasLimit: bigint;\n\t/** Estimated extra gas to pay the bundler */\n\tpreVerificationGas: bigint;\n\t/** Estimated gas limit for verification step */\n\tverificationGasLimit: bigint;\n};\n\n/** Result of eth_getUserOperationByHash. Null if not found. */\nexport type UserOperationByHashResult = {\n\t/** The UserOperation object */\n\tuserOperation: UserOperationV6 | UserOperationV7;\n\t/** The EntryPoint address */\n\tentryPoint: string;\n\t/** Block number (null if pending) */\n\tblockNumber: bigint | null;\n\t/** Block hash (null if pending) */\n\tblockHash: string | null;\n\t/** Transaction hash of the bundle (null if pending) */\n\ttransactionHash: string | null;\n} | null;\n\n/** On-chain transaction receipt for the bundle that included a UserOperation. */\nexport type UserOperationReceipt = {\n\t/** Hash of the block containing the transaction */\n\tblockHash: string;\n\t/** Number of the block containing the transaction */\n\tblockNumber: bigint;\n\t/** Address of the bundler that submitted the transaction */\n\tfrom: string;\n\t/** Total gas used in the block up to and including this transaction */\n\tcumulativeGasUsed: bigint;\n\t/** Gas used by this specific transaction */\n\tgasUsed: bigint;\n\t/** Encoded logs emitted during execution */\n\tlogs: string;\n\t/** Bloom filter for the transaction logs */\n\tlogsBloom: string;\n\t/** Hash of the bundle transaction */\n\ttransactionHash: string;\n\t/** Index of the transaction within the block */\n\ttransactionIndex: bigint;\n\t/** Effective gas price paid (EIP-1559) */\n\teffectiveGasPrice?: bigint;\n};\n\n/** Full result of eth_getUserOperationReceipt. Null if not found. */\nexport type UserOperationReceiptResult = {\n\t/** Hash of the UserOperation */\n\tuserOpHash: string;\n\t/** EntryPoint contract address that processed the operation */\n\tentryPoint: string;\n\t/** Sender (smart account) address */\n\tsender: string;\n\t/** Nonce used by the UserOperation */\n\tnonce: bigint;\n\t/** Paymaster address (or zero address if self-funded) */\n\tpaymaster: string;\n\t/** Actual gas cost charged (in wei) */\n\tactualGasCost: bigint;\n\t/** Actual gas units consumed */\n\tactualGasUsed: bigint;\n\t/** Whether the inner account execution succeeded */\n\tsuccess: boolean;\n\t/** Encoded logs emitted during execution */\n\tlogs: string;\n\t/** The underlying transaction receipt */\n\treceipt: UserOperationReceipt;\n} | null;\n\n/** Metadata about the sponsor of a UserOperation. */\nexport type SponsorMetadata = {\n\t/** Sponsor display name */\n\tname: string;\n\t/** Sponsor description */\n\tdescription: string;\n\t/** Sponsor website URL */\n\turl: string;\n\t/** Sponsor icon URLs */\n\ticons: string[];\n};\n\n/** Paymaster fields returned by pm_getPaymasterData for EntryPoint v0.7+. */\nexport type PmUserOperationV7Result = {\n\t/** Paymaster contract address */\n\tpaymaster: string;\n\t/** Gas limit for the paymaster verification step */\n\tpaymasterVerificationGasLimit: bigint;\n\t/** Gas limit for the paymaster post-operation callback */\n\tpaymasterPostOpGasLimit: bigint;\n\t/** Paymaster-specific data */\n\tpaymasterData: string;\n\t/** Overridden call gas limit (if provided by paymaster) */\n\tcallGasLimit?: bigint;\n\t/** Overridden verification gas limit (if provided by paymaster) */\n\tverificationGasLimit?: bigint;\n\t/** Overridden pre-verification gas (if provided by paymaster) */\n\tpreVerificationGas?: bigint;\n\t/** Overridden max fee per gas (if provided by paymaster) */\n\tmaxFeePerGas?: bigint;\n\t/** Overridden max priority fee per gas (if provided by paymaster) */\n\tmaxPriorityFeePerGas?: bigint;\n\t/** Metadata about the sponsor */\n\tsponsorMetadata?: SponsorMetadata;\n};\n\nexport type PmUserOperationV8Result = PmUserOperationV7Result;\n\n/** Paymaster fields returned by pm_getPaymasterData for EntryPoint v0.6. */\nexport type PmUserOperationV6Result = {\n\t/** Concatenated paymaster address and paymaster-specific data */\n\tpaymasterAndData: string;\n\t/** Overridden call gas limit (if provided by paymaster) */\n\tcallGasLimit?: bigint;\n\t/** Overridden pre-verification gas (if provided by paymaster) */\n\tpreVerificationGas?: bigint;\n\t/** Overridden verification gas limit (if provided by paymaster) */\n\tverificationGasLimit?: bigint;\n\t/** Overridden max fee per gas (if provided by paymaster) */\n\tmaxFeePerGas?: bigint;\n\t/** Overridden max priority fee per gas (if provided by paymaster) */\n\tmaxPriorityFeePerGas?: bigint;\n\t/** Metadata about the sponsor */\n\tsponsorMetadata?: SponsorMetadata;\n};\n\n/**\n * Specifies whether a transaction is a regular call or a delegatecall.\n */\nexport enum Operation {\n\t/** Standard call to the target address */\n\tCall = 0,\n\t/** Delegatecall (executes target code in caller's context) */\n\tDelegate = 1,\n}\n\n/**\n * A single transaction to be included in a UserOperation.\n * Multiple MetaTransactions can be batched via multi-send.\n */\nexport interface MetaTransaction {\n\t/** Target contract or recipient address */\n\tto: string;\n\t/** Amount of native token (wei) to send */\n\tvalue: bigint;\n\t/** ABI-encoded calldata for the target contract */\n\tdata: string;\n\t/** Call type: Call (0) or Delegate (1). Defaults to Call. */\n\toperation?: Operation;\n}\n\n/**\n * Erc20 token info from the token paymaster\n */\nexport interface ERC20Token {\n\tname: string;\n\t/** Token symbol */\n\tsymbol: string;\n\t/** Token address */\n\taddress: string;\n\t/** Token decimal places */\n\tdecimals: number;\n}\n\n/**\n * Erc20 token info from the token paymaster with exchange rate\n */\nexport interface ERC20TokenWithExchangeRate extends ERC20Token {\n\t/** Token exchange rate*/\n\texchangeRate: bigint;\n}\n\n/**\n * Paymaster metadata returned by the paymaster RPC.\n * V7/V8 paymasters return structured dummyPaymasterAndData; V6 returns a concatenated hex string.\n */\nexport interface PaymasterMetadata {\n\tname: string;\n\tdescription: string;\n\ticons: string[];\n\t/** Paymaster contract address */\n\taddress: string;\n\t/** the event that will be emitted when a useroperation is sponsored */\n\tsponsoredEventTopic: string;\n\t/** dummyPaymasterAndData to use for gas estimation */\n\tdummyPaymasterAndData:\n\t\t| {\n\t\t\t\tpaymaster: string;\n\t\t\t\tpaymasterVerificationGasLimit: bigint;\n\t\t\t\tpaymasterPostOpGasLimit: bigint;\n\t\t\t\tpaymasterData: string;\n\t\t }\n\t\t| string;\n}\n\n/** @deprecated Use PaymasterMetadata instead */\nexport type PaymasterMetadataV7 = PaymasterMetadata;\n/** @deprecated Use PaymasterMetadata instead */\nexport type PaymasterMetadataV8 = PaymasterMetadata;\n/** @deprecated Use PaymasterMetadata instead */\nexport type PaymasterMetadataV6 = PaymasterMetadata;\n\n/**\n * Paymaster metadata and supported erc20 tokens\n */\nexport interface SupportedERC20TokensAndMetadata {\n\tpaymasterMetadata: PaymasterMetadata;\n\ttokens: ERC20Token[];\n}\n\n/** @deprecated Use SupportedERC20TokensAndMetadata instead */\nexport type SupportedERC20TokensAndMetadataV7 = SupportedERC20TokensAndMetadata;\n/** @deprecated Use SupportedERC20TokensAndMetadata instead */\nexport type SupportedERC20TokensAndMetadataV8 = SupportedERC20TokensAndMetadata;\n/** @deprecated Use SupportedERC20TokensAndMetadata instead */\nexport type SupportedERC20TokensAndMetadataV6 = SupportedERC20TokensAndMetadata;\n\n/**\n * Paymaster metadata and supported erc20 tokens with exchange rates\n */\nexport interface SupportedERC20TokensAndMetadataWithExchangeRate {\n\tpaymasterMetadata: PaymasterMetadata;\n\ttokens: ERC20TokenWithExchangeRate[];\n}\n\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV7WithExchangeRate = SupportedERC20TokensAndMetadataWithExchangeRate;\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV8WithExchangeRate = SupportedERC20TokensAndMetadataWithExchangeRate;\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV6WithExchangeRate = SupportedERC20TokensAndMetadataWithExchangeRate;\n\n/**\n * Wrapper for a dictionary type\n */\nexport interface Dictionary<T> {\n\t[Key: string]: T;\n}\n\n/**\n * State overrides for a single address, used during gas estimation.\n */\nexport type AddressToState = {\n\t/** Override the account's ETH balance (in wei) */\n\tbalance?: bigint;\n\t/** Override the account's nonce */\n\tnonce?: bigint;\n\t/** Override the account's deployed bytecode */\n\tcode?: string;\n\t/** Completely replace the account's storage */\n\tstate?: Dictionary<string>;\n\t/** Selectively override individual storage slots */\n\tstateDiff?: Dictionary<string>;\n};\n\n/**\n * Wrapper for state overrides for gas estimation\n */\nexport type StateOverrideSet = {\n\t[key: string]: AddressToState;\n};\n\n/**\n * Multiplier to determine the gas price. Higher values result in faster inclusion but higher cost.\n */\nexport enum GasOption {\n\t/** 1x multiplier -- lowest cost, slowest inclusion */\n\tSlow = 1,\n\t/** 1.2x multiplier -- balanced cost and speed */\n\tMedium = 1.2,\n\t/** 1.5x multiplier -- highest cost, fastest inclusion */\n\tFast = 1.5,\n}\nexport enum PolygonChain {\n\tMainnet = 'v2',\n ZkMainnet = 'zkevm',\n\tAmoy = 'amoy',\n\tCardona = 'cardona',\n}\n\nexport type GasPrice = {\n maxPriorityFee:number; //in Gwei\n maxFee:number; //in Gwei\n}\n\nexport type PolygonGasStationJsonRpcResponse = {\n safeLow: GasPrice;\n standard: GasPrice;\n fast: GasPrice;\n estimatedBaseFee:string;\n blockTime:number;\n blockNumber:number;\n};\n\nexport type OnChainIdentifierParamsType = {\n /** Project name */\n project: string\n /** \"Web\" or \"Mobile\" or \"Safe App\" or \"Widget\", defaults to \"Web\". */\n platform?: \"Web\" | \"Mobile\" | \"Safe App\" | \"Widget\",\n /** tool used, defaults to \"abstractionkit\" */\n tool?: string\n /** tool version, defaults to current abstractionkit version */\n toolVersion?: string\n}\n\nexport interface ParallelPaymasterInitValues {\n\tpaymaster: string;\n\tpaymasterVerificationGasLimit: bigint;\n\tpaymasterPostOpGasLimit: bigint;\n\tpaymasterData: string;\n}\n","//credits:https://medium.com/with-orus/the-5-commandments-of-clean-error-handling-in-typescript-93a9cbdf1af5\n\nimport { Dictionary } from \"./types\";\n\n/**\n * General SDK error codes for non-bundler, non-RPC failures.\n */\nexport type BasicErrorCode =\n\t| \"UNKNOWN_ERROR\"\n\t| \"TIMEOUT\"\n\t| \"BAD_DATA\"\n\t| \"BUNDLER_ERROR\"\n\t| \"PAYMASTER_ERROR\";\n\n/**\n * ERC-4337 bundler-specific error codes, mapped from JSON-RPC error numbers\n * defined in the ERC-4337 specification.\n */\nexport type BundlerErrorCode =\n\t| \"INVALID_FIELDS\"\n\t| \"SIMULATE_VALIDATION\"\n\t| \"SIMULATE_PAYMASTER_VALIDATION\"\n\t| \"OPCODE_VALIDATION\"\n\t| \"EXPIRE_SHORTLY\"\n\t| \"REPUTATION\"\n\t| \"INSUFFICIENT_STAKE\"\n\t| \"UNSUPPORTED_SIGNATURE_AGGREGATOR\"\n\t| \"INVALID_SIGNATURE\"\n\t| \"INVALID_USEROPERATION_HASH\"\n\t| \"EXECUTION_REVERTED\";\n\n/**\n * Standard JSON-RPC 2.0 error codes plus Tenderly simulation errors.\n */\nexport type JsonRpcErrorCode =\n\t| \"PARSE_ERROR\"\n\t| \"INVALID_REQUEST\"\n\t| \"METHOD_NOT_FOUND\"\n\t| \"INVALID_PARAMS\"\n\t| \"INTERNAL_ERROR\"\n\t| \"SERVER_ERROR\"\n | \"TENDERLY_SIMULATION_ERROR\";\n\n/**\n * Maps JSON-RPC numeric error codes to human-readable {@link BundlerErrorCode} values.\n */\nexport const BundlerErrorCodeDict: Dictionary<BundlerErrorCode> = {\n\t\"-32602\": \"INVALID_FIELDS\",\n\t\"-32500\": \"SIMULATE_VALIDATION\",\n\t\"-32501\": \"SIMULATE_PAYMASTER_VALIDATION\",\n\t\"-32502\": \"OPCODE_VALIDATION\",\n\t\"-32503\": \"EXPIRE_SHORTLY\",\n\t\"-32504\": \"REPUTATION\",\n\t\"-32505\": \"INSUFFICIENT_STAKE\",\n\t\"-32506\": \"UNSUPPORTED_SIGNATURE_AGGREGATOR\",\n\t\"-32507\": \"INVALID_SIGNATURE\",\n\t\"-32601\": \"INVALID_USEROPERATION_HASH\",\n\t\"-32521\": \"EXECUTION_REVERTED\",\n};\n\n/**\n * Maps JSON-RPC numeric error codes to human-readable {@link JsonRpcErrorCode} values.\n */\nexport const JsonRpcErrorDict: Dictionary<JsonRpcErrorCode> = {\n\t\"-32700\": \"PARSE_ERROR\",\n\t\"-32600\": \"INVALID_REQUEST\",\n\t\"-32601\": \"METHOD_NOT_FOUND\",\n\t\"-32602\": \"INVALID_PARAMS\",\n\t\"-32603\": \"INTERNAL_ERROR\",\n};\n\ntype Jsonable =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| undefined\n\t| readonly Jsonable[]\n\t| { readonly [key: string]: Jsonable }\n\t| { toJSON(): Jsonable };\n\n/**\n * Custom error class for the AbstractionKit SDK. Wraps bundler, JSON-RPC,\n * and general errors with a structured code, optional numeric errno, and\n * arbitrary JSON-serializable context.\n */\nexport class AbstractionKitError extends Error {\n\tpublic readonly code: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode;\n\tpublic readonly context?: Jsonable;\n\tpublic readonly errno?: number;\n\n\t/**\n\t * @param code - Error code identifying the category of failure\n\t * @param message - Human-readable error description\n\t * @param options - Optional cause, numeric errno, and JSON-serializable context\n\t */\n\tconstructor(\n\t\tcode: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode,\n\t\tmessage: string,\n\t\toptions: { cause?: Error; errno?: number; context?: Jsonable } = {},\n\t) {\n\t\tconst { cause, errno, context } = options;\n\n\t\tsuper(message, { cause });\n\t\tthis.name = this.constructor.name;\n\n\t\tthis.code = code;\n\t\tthis.errno = errno;\n\t\tthis.context = context;\n\t}\n\n\t/**\n\t * Returns a JSON string representation of this error including name, code,\n\t * message, cause, errno, and context. Useful in React Native where the\n\t * Error \"cause\" property is not shown in stack traces.\n\t * @returns JSON string of the error\n\t */\n\tstringify(): string {\n\t\treturn JSON.stringify(this, [\n\t\t\t\"name\",\n\t\t\t\"code\",\n\t\t\t\"message\",\n\t\t\t\"cause\",\n\t\t\t\"errno\",\n\t\t\t\"context\",\n\t\t]);\n\t}\n}\n\n/**\n * Coerces an unknown thrown value into an Error instance.\n * If the value is already an Error it is returned as-is; otherwise it is\n * stringified and wrapped in a new Error.\n * @param value - The caught value to normalize\n * @returns An Error instance\n */\nexport function ensureError(value: unknown): Error {\n\tif (value instanceof Error) return value;\n\n\tlet stringified = \"[Unable to stringify the thrown value]\";\n\ttry {\n\t\tstringified = JSON.stringify(value);\n\t} catch {\n\t\t/* empty */\n\t}\n\n\tconst error = new Error(\n\t\t`This value was thrown as is, not through an Error: ${stringified}`,\n\t);\n\treturn error;\n}\n","import { id, AbiCoder, keccak256, JsonRpcProvider, solidityPacked, getAddress } from \"ethers\";\n\nimport {\n\tAbiInputValue,\n\tUserOperationV6,\n\tJsonRpcResponse,\n\tJsonRpcParam,\n\tJsonRpcError,\n\tGasOption,\n\tJsonRpcResult,\n\tUserOperationV7,\n\tUserOperationV8,\n PolygonChain,\n PolygonGasStationJsonRpcResponse,\n UserOperationV9,\n} from \"./types\";\nimport {\n\tAbstractionKitError,\n\tBundlerErrorCodeDict,\n\tensureError,\n} from \"./errors\";\nimport { ENTRYPOINT_V6, ENTRYPOINT_V7, ENTRYPOINT_V8, ENTRYPOINT_V9 } from \"./constants\";\n\nfunction buildDomainSeparator(chainId: bigint, entrypoint: string): string{\n // DOMAIN_NAME = \"ERC4337\"\n const hashed_name = \"0x364da28a5c92bcc87fe97c8813a6c6b8a3a049b0ea0a328fcb0b4f0e00337586\"; \n\n // DOMAIN_VERSION = \"1\"\n const hashed_version = \"0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6\";\n\n // TYPE_HASH = keccak(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n const type_hash = \"0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f\";\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n const encodedUserOperationHash = abiCoder.encode(\n [\"(bytes32,bytes32,bytes32,uint256,address)\"],\n [[type_hash, hashed_name, hashed_version, chainId, entrypoint]],\n );\n return keccak256(encodedUserOperationHash);\n}\n\n/**\n * Compute the UserOperation hash for any supported EntryPoint version.\n * This hash is what gets signed by the account owner(s).\n * Automatically selects the correct packing format based on the entrypoint address.\n *\n * @param useroperation - UserOperation to hash\n * @param entrypointAddress - EntryPoint contract address (determines hash format)\n * @param chainId - Target chain ID\n * @returns The UserOperation hash as a hex string\n */\nexport function createUserOperationHash(\n\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\tentrypointAddress: string,\n\tchainId: bigint,\n): string {\n\tlet packedUserOperationHash: string;\n const abiCoder = AbiCoder.defaultAbiCoder();\n\tlet userOperationHash;\n\tif (entrypointAddress.toLowerCase() == ENTRYPOINT_V6.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV6(useroperation as UserOperationV6),\n\t\t);\n const encodedUserOperationHash = abiCoder.encode(\n [\"bytes32\", \"address\", \"uint256\"],\n [packedUserOperationHash, entrypointAddress, chainId],\n );\n userOperationHash = keccak256(encodedUserOperationHash);\n }else if (entrypointAddress.toLowerCase() == ENTRYPOINT_V7.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV7(useroperation as UserOperationV7),\n\t\t);\n const encodedUserOperationHash = abiCoder.encode(\n [\"bytes32\", \"address\", \"uint256\"],\n [packedUserOperationHash, entrypointAddress, chainId],\n );\n userOperationHash = keccak256(encodedUserOperationHash);\n }else if (entrypointAddress.toLowerCase() == ENTRYPOINT_V8.toLowerCase()) {\n packedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV8(useroperation as UserOperationV8),\n\t\t);\n const domainSeparator = buildDomainSeparator(chainId, entrypointAddress);\n userOperationHash = keccak256(\n \"0x1901\" + domainSeparator.slice(2) + packedUserOperationHash.slice(2));\n }else if (entrypointAddress.toLowerCase() == ENTRYPOINT_V9.toLowerCase()) {\n packedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV9(useroperation as UserOperationV8),\n\t\t);\n const domainSeparator = buildDomainSeparator(chainId, entrypointAddress);\n userOperationHash = keccak256(\n \"0x1901\" + domainSeparator.slice(2) + packedUserOperationHash.slice(2));\n }else{\n throw new RangeError(\"unsupported entrypoint address: \" + entrypointAddress);\n }\n\n\treturn userOperationHash;\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.6 format).\n * Bytes fields (initCode, callData, paymasterAndData) are keccak256-hashed before packing.\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV6(\n\tuseroperation: UserOperationV6,\n): string {\n\tconst useroperationValuesArrayWithHashedByteValues = [\n\t\tuseroperation.sender,\n\t\tuseroperation.nonce,\n\t\tkeccak256(useroperation.initCode),\n\t\tkeccak256(useroperation.callData),\n\t\tuseroperation.callGasLimit,\n\t\tuseroperation.verificationGasLimit,\n\t\tuseroperation.preVerificationGas,\n\t\tuseroperation.maxFeePerGas,\n\t\tuseroperation.maxPriorityFeePerGas,\n\t\tkeccak256(useroperation.paymasterAndData),\n\t];\n\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\tconst packedUserOperation = abiCoder.encode(\n\t\t[\n\t\t\t\"address\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t],\n\t\tuseroperationValuesArrayWithHashedByteValues,\n\t);\n\treturn packedUserOperation;\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.7 format).\n * Reconstructs initCode, accountGasLimits, gasFees, and paymasterAndData from separate fields.\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV7(\n\tuseroperation: UserOperationV7,\n): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\tlet initCode = \"0x\";\n\tif (useroperation.factory != null) {\n\t\tinitCode = useroperation.factory;\n\t\tif (useroperation.factoryData != null) {\n\t\t\tinitCode += useroperation.factoryData.slice(2);\n\t\t}\n\t}\n\n\tconst accountGasLimits =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.verificationGasLimit])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.callGasLimit]).slice(34);\n\n\tconst gasFees =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.maxPriorityFeePerGas])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.maxFeePerGas]).slice(34);\n\n\tlet paymasterAndData = \"0x\";\n\tif (useroperation.paymaster != null) {\n\t\tpaymasterAndData = useroperation.paymaster;\n\t\tif (useroperation.paymasterVerificationGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterVerificationGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterPostOpGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterData != null) {\n\t\t\tpaymasterAndData += useroperation.paymasterData.slice(2);\n\t\t}\n\t}\n\n\tconst useroperationValuesArrayWithHashedByteValues = [\n\t\tuseroperation.sender,\n\t\tuseroperation.nonce,\n\t\tkeccak256(initCode),\n\t\tkeccak256(useroperation.callData),\n\t\taccountGasLimits,\n\t\tuseroperation.preVerificationGas,\n\t\tgasFees,\n\t\tkeccak256(paymasterAndData),\n\t];\n\n\tconst packedUserOperation = abiCoder.encode(\n\t\t[\n\t\t\t\"address\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t],\n\t\tuseroperationValuesArrayWithHashedByteValues,\n\t);\n\treturn packedUserOperation;\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.9 format).\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV9(\n\tuseroperation: UserOperationV8,\n): string {\n return baseCreatePackedUserOperationV8V9(useroperation, true);\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.8 format).\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV8(\n\tuseroperation: UserOperationV8,\n): string {\n return baseCreatePackedUserOperationV8V9(useroperation, false);\n}\n\n/**\n * createPackedUserOperation for the standard entrypointv0.8 hash\n * @param useroperation -useroperation to pack\n * @returns packed UserOperation\n */\nfunction baseCreatePackedUserOperationV8V9(\n\tuseroperation: UserOperationV8 | UserOperationV9, is_v9: boolean\n): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\tlet initCode = \"0x\";\n\tif (useroperation.factory != null) {\n const eip7702Auth = useroperation.eip7702Auth;\n if (eip7702Auth != null && eip7702Auth.address != null){\n initCode = eip7702Auth.address; \n }else{\n initCode = useroperation.factory;\n }\n if (useroperation.factoryData != null) {\n initCode += useroperation.factoryData.slice(2);\n }\n\t}\n\n\tconst accountGasLimits =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.verificationGasLimit])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.callGasLimit]).slice(34);\n\n\tconst gasFees =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.maxPriorityFeePerGas])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.maxFeePerGas]).slice(34);\n\n\tlet paymasterAndData = \"0x\";\n\tif (useroperation.paymaster != null) {\n\t\tpaymasterAndData = useroperation.paymaster;\n\t\tif (useroperation.paymasterVerificationGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterVerificationGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterPostOpGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterData != null) {\n\t\t\tconst PAYMASTER_SIG_MAGIC = '22e325a297439656';\n\t\t\tif(\n\t\t\t\tis_v9 &&\n\t\t\t\tuseroperation.paymasterData.toLowerCase().endsWith(PAYMASTER_SIG_MAGIC)\n\t\t\t){\n\t\t\t\tconst sigLenHex = useroperation.paymasterData.slice(\n\t\t\t\t\tuseroperation.paymasterData.length - 16 - 4,\n\t\t\t\t\tuseroperation.paymasterData.length - 16\n\t\t\t\t);\n\t\t\t\tconst sigLen = parseInt(sigLenHex, 16);\n\t\t\t\tconst prefixEnd = useroperation.paymasterData.length - 16 - 4 - sigLen * 2;\n\t\t\t\tpaymasterAndData += useroperation.paymasterData.slice(0, prefixEnd).replaceAll(\"0x\", \"\") + PAYMASTER_SIG_MAGIC;\n\t\t\t}else{\n\t\t\t\tpaymasterAndData += useroperation.paymasterData.slice(2);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst useroperationValuesArrayWithHashedByteValues = [\n // PACKED_USEROP_TYPEHASH\n \"0x29a0bca4af4be3421398da00295e58e6d7de38cb492214754cb6a47507dd6f8e\",\n\t\tuseroperation.sender,\n\t\tuseroperation.nonce,\n\t\tkeccak256(initCode),\n\t\tkeccak256(useroperation.callData),\n\t\taccountGasLimits,\n\t\tuseroperation.preVerificationGas,\n\t\tgasFees,\n\t\tkeccak256(paymasterAndData),\n\t];\n\n\tconst packedUserOperation = abiCoder.encode(\n\t\t[\n\t\t\t\"bytes32\",\n\t\t\t\"address\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t],\n\t\tuseroperationValuesArrayWithHashedByteValues,\n\t);\n\treturn packedUserOperation;\n}\n\n/**\n * Encode a function call into ABI-encoded calldata.\n *\n * @param functionSelector - 4-byte hex function selector (e.g., \"0xa9059cbb\" for ERC-20 transfer)\n * @param functionInputAbi - Array of ABI type strings (e.g., [\"address\", \"uint256\"])\n * @param functionInputParameters - Array of parameter values matching the ABI types\n * @returns ABI-encoded calldata as a hex string (selector + encoded parameters)\n *\n * @example\n * const transferCallData = createCallData(\n * \"0xa9059cbb\",\n * [\"address\", \"uint256\"],\n * [\"0xRecipientAddress\", 1000000n],\n * );\n */\nexport function createCallData(\n\tfunctionSelector: string,\n\tfunctionInputAbi: string[],\n\tfunctionInputParameters: AbiInputValue[],\n): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n const params: string = abiCoder.encode(\n\t\tfunctionInputAbi,\n\t\tfunctionInputParameters,\n\t);\n\tconst callData = functionSelector + params.slice(2);\n\n\treturn callData;\n}\n\n/**\n * Send a JSON-RPC request to the specified endpoint.\n * Automatically converts bigint values to hex strings in the request body.\n *\n * @param rpcUrl - The JSON-RPC endpoint URL (bundler, node, or paymaster)\n * @param method - The JSON-RPC method name (e.g., \"eth_call\", \"eth_sendUserOperation\")\n * @param params - The JSON-RPC parameters\n * @param headers - Custom HTTP headers (defaults to Content-Type: application/json)\n * @param paramsKeyName - Key name for the params field (defaults to \"params\")\n * @returns The result field from the JSON-RPC response\n * @throws AbstractionKitError if the RPC returns an error\n */\nexport async function sendJsonRpcRequest(\n\trpcUrl: string,\n\tmethod: string,\n\tparams: JsonRpcParam,\n headers: Record<string, string> = { \"Content-Type\": \"application/json\" },\n paramsKeyName: string = \"params\",\n): Promise<JsonRpcResult> {\n\tconst raw = JSON.stringify(\n\t\t{\n\t\t\tmethod: method,\n\t\t\t[paramsKeyName]: params,\n\t\t\tid: new Date().getTime(), //semi unique id\n\t\t\tjsonrpc: \"2.0\",\n\t\t},\n\t\t(key, value) =>\n\t\t\t// change all bigint values to \"0x\" prefixed hex strings\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\ttypeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n\t);\n\tconst requestOptions: RequestInit = {\n\t\tmethod: \"POST\",\n\t\theaders, \n\t\tbody: raw,\n\t\tredirect: \"follow\",\n\t};\n\tconst fetchResult = await fetch(rpcUrl, requestOptions);\n\tconst response = (await fetchResult.json()) as JsonRpcResponse;\n\n\tif (\"result\" in response) {\n\t\treturn response.result as JsonRpcResult;\n\t} else if (\"simulation_results\" in response) {\n\t\treturn response.simulation_results as JsonRpcResult;\n\t} else {\n\t\tconst err = response.error as JsonRpcError;\n\t\tconst codeString = String(err.code);\n\n\t\tif (codeString in BundlerErrorCodeDict) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\tBundlerErrorCodeDict[codeString],\n\t\t\t\terr.message,\n\t\t\t\t{\n\t\t\t\t\terrno: err.code,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\turl: rpcUrl,\n\t\t\t\t\t\trequestOptions: JSON.stringify(requestOptions),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\"UNKNOWN_ERROR\", err.message, {\n\t\t\t\terrno: err.code,\n\t\t\t\tcontext: {\n\t\t\t\t\turl: rpcUrl,\n\t\t\t\t\trequestOptions: JSON.stringify(requestOptions),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * get function selector from the function signature\n * @param functionSignature - example of a function signature \"mint(address)\"\n * @returns fucntion selector - hexstring representation of the first four bytes of the hash of the signature of the function\n *\n * @example\n * const getNonceFunctionSignature = 'getNonce(address,uint192)';\n * const getNonceFunctionSelector = getFunctionSelector(getNonceFunctionSignature);\n */\nexport function getFunctionSelector(functionSignature: string): string {\n\treturn id(functionSignature).slice(0, 10);\n}\n\n/**\n * Fetch the account's nonce from the EntryPoint contract.\n *\n * @param rpcUrl - Ethereum JSON-RPC node URL\n * @param entryPoint - EntryPoint contract address\n * @param account - Smart account address to query\n * @param key - Nonce key (default 0). Different keys allow parallel nonce channels.\n * @returns The current nonce as a bigint\n * @throws AbstractionKitError with code \"BAD_DATA\" if the nonce call fails\n */\nexport async function fetchAccountNonce(\n\trpcUrl: string,\n\tentryPoint: string,\n\taccount: string,\n\tkey: number = 0,\n): Promise<bigint> {\n\tconst getNonceFunctionSignature = \"getNonce(address,uint192)\";\n\tconst getNonceFunctionSelector = getFunctionSelector(\n\t\tgetNonceFunctionSignature,\n\t);\n\tconst getNonceTransactionCallData = createCallData(\n\t\tgetNonceFunctionSelector,\n\t\t[\"address\", \"uint192\"],\n\t\t[account, key],\n\t);\n\n\tconst params = [\n\t\t{\n\t\t\tfrom: \"0x0000000000000000000000000000000000000000\",\n\t\t\tto: entryPoint,\n\t\t\tdata: getNonceTransactionCallData,\n\t\t},\n\t\t\"latest\",\n\t];\n\n\ttry {\n\t\tconst nonce = await sendJsonRpcRequest(rpcUrl, \"eth_call\", params);\n\n\t\tif (typeof nonce === \"string\") {\n\t\t\ttry {\n\t\t\t\treturn BigInt(nonce);\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"getNonce returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"getNonce returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(nonce),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getNonce failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\n/**\n * Fetch current gas prices from a JSON-RPC node.\n * Applies a gas level multiplier to adjust for faster or cheaper inclusion.\n *\n * @param provideRpc - Ethereum JSON-RPC node URL\n * @param gasLevel - Gas price multiplier (default: GasOption.Medium = 1.2x)\n * @returns A tuple of [maxFeePerGas, maxPriorityFeePerGas] as bigints\n */\nexport async function fetchGasPrice(\n\tprovideRpc: string,\n\tgasLevel: GasOption = GasOption.Medium,\n): Promise<[bigint, bigint]> {\n try{\n const jsonRpcProvider = new JsonRpcProvider(provideRpc);\n const feeData = await jsonRpcProvider.getFeeData();\n let maxFeePerGas:bigint;\n let maxPriorityFeePerGas:bigint;\n\n if(feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null){\n maxFeePerGas = BigInt(\n Math.ceil(Number(feeData.maxFeePerGas) * gasLevel),\n );\n maxPriorityFeePerGas = BigInt(\n Math.ceil(Number(feeData.maxPriorityFeePerGas) * gasLevel),\n );\n }else if(feeData.gasPrice != null){\n maxFeePerGas = BigInt(\n Math.ceil(Number(feeData.gasPrice) * gasLevel),\n );\n maxPriorityFeePerGas = maxFeePerGas;\n }\n else{\n maxFeePerGas = BigInt(Math.ceil(1000000000 * gasLevel));\n maxPriorityFeePerGas = maxFeePerGas;\n }\n\n if (maxFeePerGas == 0n) {\n maxFeePerGas = 1n;\n }\n if (maxPriorityFeePerGas == 0n) {\n maxPriorityFeePerGas = 1n;\n }\n\n return [maxFeePerGas, maxPriorityFeePerGas];\n }catch (err) {\n const error = ensureError(err);\n\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"fetching gas prices from node failed.\", {\n cause: error,\n });\n }\n}\n\n/**\n * Fetch current gas prices from the Polygon Gas Station API.\n *\n * @param polygonChain - Target Polygon chain (Mainnet, Amoy, etc.)\n * @param gasLevel - Gas price level (Slow, Medium, Fast)\n * @returns A tuple of [maxFeePerGas, maxPriorityFeePerGas] as bigints\n */\nexport async function fetchGasPricePolygon(\n\tpolygonChain: PolygonChain,\n\tgasLevel: GasOption = GasOption.Medium,\n): Promise<[bigint, bigint]> {\n const gasStationUrl = 'https://gasstation.polygon.technology/' + polygonChain;\n try{\n const fetchResult = await fetch(gasStationUrl);\n const response = (await fetchResult.json()) as PolygonGasStationJsonRpcResponse;\n let gasPrice;\n if(gasLevel == GasOption.Slow){\n gasPrice = response.safeLow; \n }else if(gasLevel == GasOption.Medium){\n gasPrice = response.standard; \n }else{\n gasPrice = response.fast; \n }\n let maxFeePerGas = BigInt(\n Math.ceil(Number(gasPrice.maxFee) * 1000000000),\n );\n let maxPriorityFeePerGas = BigInt(\n Math.ceil(Number(gasPrice.maxPriorityFee) * 1000000000),\n );\n\n if (maxFeePerGas == 0n) {\n maxFeePerGas = 1n;\n }\n if (maxPriorityFeePerGas == 0n) {\n maxPriorityFeePerGas = 1n;\n }\n\n return [maxFeePerGas, maxPriorityFeePerGas];\n }catch (err) {\n const error = ensureError(err);\n\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"fetching gas prices from \" + gasStationUrl + \" failed.\", {\n cause: error,\n });\n }\n}\n\n/**\n * Calculate the maximum gas cost (in wei) that a UserOperation could consume.\n * Uses different formulas for v0.6 (with paymaster multiplier) and v0.7+ UserOperations.\n *\n * @param useroperation - The UserOperation to calculate the max gas cost for\n * @returns Maximum possible gas cost in wei as a bigint\n */\nexport function calculateUserOperationMaxGasCost(\n\tuseroperation: UserOperationV6 | UserOperationV7,\n): bigint {\n\tif (\"initCode\" in useroperation) {\n\t\tconst isPaymasterAndData =\n\t\t\tuseroperation.paymasterAndData != \"0x\" &&\n\t\t\tuseroperation.paymasterAndData != null;\n\t\tconst mul = isPaymasterAndData ? 3n : 0n;\n\t\tconst requiredGas =\n\t\t\tuseroperation.callGasLimit +\n\t\t\tuseroperation.verificationGasLimit * mul +\n\t\t\tuseroperation.preVerificationGas;\n\t\treturn requiredGas * useroperation.maxFeePerGas;\n\t} else {\n\t\tconst requiredGas =\n\t\t\tuseroperation.verificationGasLimit +\n\t\t\tuseroperation.callGasLimit +\n\t\t\t(useroperation.paymasterVerificationGasLimit ?? 0n) +\n\t\t\t(useroperation.paymasterPostOpGasLimit ?? 0n) +\n\t\t\tuseroperation.preVerificationGas;\n\n\t\treturn requiredGas * useroperation.maxFeePerGas;\n\t}\n}\n\n/**\n * Deposit information for an address in the EntryPoint contract.\n */\nexport type DepositInfo = {\n deposit: bigint;\n staked: boolean;\n stake:bigint;\n unstakeDelaySec: bigint;\n withdrawTime: bigint;\n};\n\n/**\n * Get the deposit balance of an address in the EntryPoint contract.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param address - Address to query the deposit for\n * @param entrypointAddress - EntryPoint contract address\n * @returns The deposit balance as a bigint\n */\nexport async function getBalanceOf(\n\tnodeRpcUrl: string,\n\taddress: string,\n\tentrypointAddress: string,\n): Promise<bigint> {\n const depositInfo = await getDepositInfo(\n nodeRpcUrl, address, entrypointAddress\n )\n return depositInfo.deposit;\n}\n\n/**\n * Get the full deposit info of an address from the EntryPoint contract.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param address - Address to query\n * @param entrypointAddress - EntryPoint contract address\n * @returns DepositInfo with deposit, staked, stake, unstakeDelaySec, withdrawTime\n */\nexport async function getDepositInfo(\n\tnodeRpcUrl: string,\n\taddress: string,\n\tentrypointAddress: string,\n): Promise<DepositInfo> {\n\tconst getDepositInfoSelector = \"0x5287ce12\"; //\"getDepositInfo(address)\"\n\tconst getDepositInfoCallData = createCallData(\n\t\tgetDepositInfoSelector,\n\t\t[\"address\"],\n\t\t[address],\n\t);\n\n\tconst params = {\n from: \"0x0000000000000000000000000000000000000000\",\n to: entrypointAddress,\n data: getDepositInfoCallData,\n };\n\n\ttry {\n const depositInfoRequestResult = await sendEthCallRequest(\n nodeRpcUrl, params, \"latest\");\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n\t const decodedCalldata = abiCoder.decode(\n [\"uint256\", \"bool\", \"uint112\", \"uint32\", \"uint48\"],\n depositInfoRequestResult\n );\n\n\n\t\tif (decodedCalldata.length === 5) {\n\t\t\ttry {\n\t\t\t\treturn {\n deposit:BigInt(decodedCalldata[0]),\n staked:Boolean(decodedCalldata[1]),\n stake:BigInt(decodedCalldata[2]),\n unstakeDelaySec:BigInt(decodedCalldata[3]),\n withdrawTime:BigInt(decodedCalldata[4]),\n };\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"getDepositInfo returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"getDepositInfo returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(decodedCalldata),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getDepositInfo failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\ntype EthCallTransaction = {\n\tfrom?: string;\n\tto: string;\n\tgas?: bigint;\n\tgasPrice?: bigint;\n\tvalue?: bigint;\n\tdata?: string;\n};\n\n/**\n * Send an eth_call JSON-RPC request with optional state overrides.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param ethCallTransaction - The call transaction parameters\n * @param blockNumber - Block number or \"latest\"\n * @param stateOverrides - Optional state overrides for the call\n * @returns The call result as a hex string\n */\nexport async function sendEthCallRequest(\n\tnodeRpcUrl: string,\n\tethCallTransaction: EthCallTransaction,\n\tblockNumber: string | bigint,\n stateOverrides?:object\n): Promise<string> {\n let params = [];\n if(stateOverrides == null){\n\t params = [ethCallTransaction, blockNumber];\n }else{\n\t params = [ethCallTransaction, blockNumber, stateOverrides];\n }\n\n\ttry {\n\t\tconst data = await sendJsonRpcRequest(nodeRpcUrl, \"eth_call\", params);\n\n\t\tif (typeof data === \"string\") {\n\t\t\ttry {\n\t\t\t\treturn data;\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"eth_call returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"eth_call returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(data),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_call failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\n/**\n * Send an eth_getCode JSON-RPC request to check deployed bytecode.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param contractAddress - Contract address to query\n * @param blockNumber - Block number or \"latest\"\n * @returns The deployed bytecode as a hex string\n */\nexport async function sendEthGetCodeRequest(\n\tnodeRpcUrl: string,\n\tcontractAddress: string,\n\tblockNumber: string | bigint,\n): Promise<string> {\n\tconst params = [contractAddress, blockNumber];\n\n\ttry {\n\t\tconst data = await sendJsonRpcRequest(nodeRpcUrl, \"eth_getCode\", params);\n\n\t\tif (typeof data === \"string\") {\n\t\t\ttry {\n\t\t\t\treturn data;\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"eth_getCode returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"eth_getCode returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(data),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_getCode failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\n/**\n * Check if an address is delegated via EIP-7702 and return the delegatee address.\n * EIP-7702 delegated accounts have bytecode in the format `0xef0100` + 20-byte address.\n *\n * @param accountAddress - The address to check\n * @param providerRpc - Ethereum JSON-RPC node URL\n * @returns The checksummed delegatee address, or `null` if not delegated\n */\nexport async function getDelegatedAddress(\n accountAddress: string,\n providerRpc: string,\n): Promise<string | null> {\n const code = (await sendEthGetCodeRequest(providerRpc, accountAddress, \"latest\")).toLowerCase();\n if (code.length === 48 && code.startsWith(\"0xef0100\")) {\n return getAddress(\"0x\" + code.slice(8));\n }\n return null;\n}\n\n/**\n * Fetch gas prices using either the Polygon Gas Station or a standard JSON-RPC node.\n *\n * @param providerRpc - Ethereum JSON-RPC node URL (used if polygonGasStation is null)\n * @param polygonGasStation - Polygon chain to use for gas station (takes priority)\n * @param gasLevel - Gas price multiplier (default: GasOption.Medium)\n * @returns A tuple of [maxFeePerGas, maxPriorityFeePerGas] as bigints\n */\nexport async function handlefetchGasPrice(\n providerRpc: string | undefined,\n polygonGasStation: PolygonChain | undefined,\n gasLevel: GasOption = GasOption.Medium,\n): Promise<[bigint, bigint]> {\n let maxFeePerGas:bigint;\n let maxPriorityFeePerGas:bigint;\n\n if (polygonGasStation != null) {\n [maxFeePerGas, maxPriorityFeePerGas] = await fetchGasPricePolygon(\n polygonGasStation, gasLevel);\n }\n else if (providerRpc != null) {\n [maxFeePerGas, maxPriorityFeePerGas] =\n await fetchGasPrice(providerRpc, gasLevel);\n } else {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"providerRpc can't be null if maxFeePerGas and \" +\n \"maxPriorityFeePerGas are not overriden\",\n );\n }\n return [maxFeePerGas, maxPriorityFeePerGas];\n}\n","//https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md\n//rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, value, data, access_list, authorization_list, yParity, r, s])\n//authorization_list = [[chain_id, address, nonce, yParity, r, s], ...]\nimport {\n encodeRlp, Wallet, getBytes, toBeArray, keccak256,\n} from \"ethers\";\n\nconst SET_CODE_TX_TYPE = \"0x04\";\n\n/**\n * An EIP-7702 delegation authorization with bigint values.\n * Represents a signed authorization that delegates an EOA's code to a contract.\n */\nexport type Authorization7702 = {\n /** The chain ID the authorization is valid for. */\n chainId: bigint,\n /** The contract address to delegate code from. */\n address: string,\n /** The EOA's nonce at the time of signing. */\n nonce: bigint,\n /** The parity of the signature's y-coordinate (0 or 1). */\n yParity: 0 | 1,\n /** The r component of the ECDSA signature. */\n r: bigint,\n /** The s component of the ECDSA signature. */\n s: bigint\n};\n\n/**\n * An EIP-7702 delegation authorization with hex-encoded string values.\n * Same as {@link Authorization7702} but with all numeric fields as hex strings.\n */\nexport type Authorization7702Hex = {\n /** The chain ID as a hex string. */\n chainId: string,\n /** The contract address to delegate code from. */\n address: string,\n /** The EOA's nonce as a hex string. */\n nonce: string,\n /** The parity of the signature's y-coordinate as a hex string. */\n yParity: string,\n /** The r component of the ECDSA signature as a hex string. */\n r: string,\n /** The s component of the ECDSA signature as a hex string. */\n s: string\n};\n\n/**\n * Creates and signs a legacy (pre-EIP-1559) raw transaction using RLP encoding.\n * @param chainId - The chain ID for replay protection.\n * @param nonce - The sender's transaction nonce.\n * @param gas_price - The gas price in wei.\n * @param gas_limit - The maximum gas units for the transaction.\n * @param destination - The recipient address (42-character hex string).\n * @param value - The amount of ETH to send in wei.\n * @param data - The transaction input data.\n * @param eoaPrivateKey - The sender's private key for signing.\n * @returns The RLP-encoded signed transaction as a hex string.\n */\nexport function createAndSignLegacyRawTransaction(\n chainId: bigint,\n nonce: bigint,\n gas_price: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n eoaPrivateKey: string\n): string {\n if (chainId >= 2**64){\n\t\tthrow new RangeError(\"Invalid chainId.\");\n }\n\n if (nonce >= 2**64){\n\t\tthrow new RangeError(\"Invalid nonce.\");\n }\n\n if (destination.length != 42){\n\t\tthrow new RangeError(\"Invalid destination.\");\n }\n\n let payload = [\n bigintToBytes(nonce),\n bigintToBytes(gas_price),\n bigintToBytes(gas_limit),\n destination,\n bigintToBytes(value),\n data,\n bigintToBytes(chainId),\n bigintToBytes(0n),\n bigintToBytes(0n)\n ]\n \n const txHash = keccak256(encodeRlp(payload));\n \n const eoa = new Wallet(eoaPrivateKey);\n const signature = eoa.signingKey.sign(\n txHash,\n );\n\n payload = [\n bigintToBytes(nonce),\n bigintToBytes(gas_price),\n bigintToBytes(gas_limit),\n destination,\n bigintToBytes(value),\n data,\n bigintToBytes(\n BigInt(signature.yParity + (Number(chainId) * 2) + 35)),\n getBytes(signature.r),\n getBytes(signature.s)\n ]\n const transactionPayload = encodeRlp(payload);\n return transactionPayload;\n}\n\n/**\n * Creates and signs an EIP-7702 delegation authorization.\n * The authorization allows an EOA to delegate its code to a specified contract address.\n *\n * Accepts either a hex-encoded private key string or a signer callback\n * `(hash: string) => Promise<string>` for use with viem, ethers Signers,\n * hardware wallets, or MPC signers.\n *\n * @param chainId - The chain ID the authorization is valid for.\n * @param address - The contract address to delegate code from.\n * @param nonce - The EOA's nonce at the time of signing.\n * @param signer - The EOA's private key or a signing function that returns a 65-byte signature.\n * @returns The signed authorization with all numeric values as hex strings.\n */\nexport function createAndSignEip7702DelegationAuthorization(\n chainId: bigint,\n address: string,\n nonce: bigint,\n signer: string,\n): Authorization7702Hex;\nexport function createAndSignEip7702DelegationAuthorization(\n chainId: bigint,\n address: string,\n nonce: bigint,\n signer: (hash: string) => Promise<string>,\n): Promise<Authorization7702Hex>;\nexport function createAndSignEip7702DelegationAuthorization(\n chainId: bigint,\n address: string,\n nonce: bigint,\n signer: string | ((hash: string) => Promise<string>),\n): Authorization7702Hex | Promise<Authorization7702Hex> {\n const authHash = createEip7702DelegationAuthorizationHash(\n chainId, address, nonce);\n\n if (typeof signer === \"string\") {\n const signature = signHash(authHash, signer);\n return {\n chainId: bigintToHex(chainId),\n address,\n nonce: bigintToHex(nonce),\n yParity: bigintToHex(BigInt(signature.yParity)),\n r: bigintToHex(signature.r),\n s: bigintToHex(signature.s),\n };\n }\n\n return signer(authHash).then((rawSig) => {\n const sig = parseRawSignature(rawSig);\n return {\n chainId: bigintToHex(chainId),\n address,\n nonce: bigintToHex(nonce),\n yParity: bigintToHex(BigInt(sig.yParity)),\n r: bigintToHex(sig.r),\n s: bigintToHex(sig.s),\n };\n });\n}\n\n/**\n * Creates and signs an EIP-7702 delegation revocation authorization.\n * Sets the delegatee address to the zero address, which revokes the delegation\n * and restores the EOA to a normal account.\n *\n * @param chainId - The chain ID the authorization is valid for.\n * @param nonce - The EOA's authorization nonce at the time of signing.\n * @param eoaPrivateKey - The EOA's private key for signing.\n * @returns The signed delegation revocation authorization with hex-encoded values.\n */\nexport function createRevokeDelegationAuthorization(\n chainId: bigint,\n nonce: bigint,\n eoaPrivateKey: string,\n): Authorization7702Hex {\n const ZeroAddress = \"0x0000000000000000000000000000000000000000\";\n return createAndSignEip7702DelegationAuthorization(\n chainId, ZeroAddress, nonce, eoaPrivateKey\n );\n}\n\n/**\n * Computes the keccak256 hash of an EIP-7702 delegation authorization.\n * Uses the MAGIC prefix (0x05) as defined in the EIP-7702 spec.\n * @param chainId - The chain ID the authorization is valid for.\n * @param address - The contract address to delegate code from.\n * @param nonce - The EOA's nonce at the time of signing.\n * @returns The authorization hash as a hex string.\n */\nexport function createEip7702DelegationAuthorizationHash(\n chainId: bigint,\n address: string,\n nonce: bigint\n):string {\n const auth_arr = [\n bigintToBytes(chainId),\n address,\n bigintToBytes(nonce),\n ]\n const encoded_auth = encodeRlp(auth_arr);\n const MAGIC = \"0x05\";\n return keccak256(MAGIC + encoded_auth.slice(2));\n}\n\n/**\n * Signs a hash using an EOA's private key.\n * @param authHash - The hash to sign.\n * @param eoaPrivateKey - The EOA's private key for signing.\n * @returns An object containing the signature components: yParity, r, and s.\n */\nexport function signHash(\n authHash: string,\n eoaPrivateKey: string\n): {yParity: 0 | 1, r:bigint, s: bigint}{\n const eoa = new Wallet(eoaPrivateKey);\n const signature = eoa.signingKey.sign(\n authHash,\n );\n return {\n yParity: signature.yParity,\n r: BigInt(signature.r),\n s: BigInt(signature.s)\n };\n}\n\n/**\n * Creates and signs an EIP-7702 (set-code) raw transaction.\n * Encodes the transaction with a type 0x04 prefix and includes the authorization list.\n * @param chainId - The chain ID for replay protection.\n * @param nonce - The sender's transaction nonce.\n * @param max_priority_fee_per_gas - The maximum priority fee per gas (tip) in wei.\n * @param max_fee_per_gas - The maximum total fee per gas in wei.\n * @param gas_limit - The maximum gas units for the transaction.\n * @param destination - The recipient address (42-character hex string).\n * @param value - The amount of ETH to send in wei.\n * @param data - The transaction input data.\n * @param access_list - The EIP-2930 access list as [address, storageKeys] tuples.\n * @param authorization_list - The list of signed EIP-7702 delegation authorizations.\n * @param eoaPrivateKey - The sender's private key for signing.\n * @returns The signed, RLP-encoded transaction with 0x04 type prefix.\n */\nexport function createAndSignEip7702RawTransaction(\n chainId: bigint,\n nonce: bigint,\n max_priority_fee_per_gas: bigint,\n max_fee_per_gas: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n access_list: [string, string[]][],\n authorization_list: Authorization7702[],\n eoaPrivateKey: string\n): string {\n const txHash = createEip7702TransactionHash(\n chainId,\n nonce,\n max_priority_fee_per_gas,\n max_fee_per_gas,\n gas_limit,\n destination,\n value,\n data,\n access_list,\n authorization_list,\n )\n\n const basePayload = encodeEip7702TransactionBaseList(\n chainId,\n nonce,\n max_priority_fee_per_gas,\n max_fee_per_gas,\n gas_limit,\n destination,\n value,\n data,\n access_list,\n authorization_list,\n );\n\n const signature = signHash(txHash, eoaPrivateKey);\n const payload = basePayload.concat([\n bigintToBytes(BigInt(signature.yParity)),\n bigintToBytes(signature.r),\n bigintToBytes(signature.s)\n ]);\n const transactionPayload = encodeRlp(payload);\n\n return SET_CODE_TX_TYPE + transactionPayload.slice(2);\n}\n\n\n/**\n * Computes the keccak256 hash of an EIP-7702 transaction for signing.\n * @param chainId - The chain ID for replay protection.\n * @param nonce - The sender's transaction nonce.\n * @param max_priority_fee_per_gas - The maximum priority fee per gas (tip) in wei.\n * @param max_fee_per_gas - The maximum total fee per gas in wei.\n * @param gas_limit - The maximum gas units for the transaction.\n * @param destination - The recipient address (42-character hex string).\n * @param value - The amount of ETH to send in wei.\n * @param data - The transaction input data.\n * @param access_list - The EIP-2930 access list as [address, storageKeys] tuples.\n * @param authorization_list - The list of signed EIP-7702 delegation authorizations.\n * @returns The transaction hash as a hex string.\n */\nexport function createEip7702TransactionHash(\n chainId: bigint,\n nonce: bigint,\n max_priority_fee_per_gas: bigint,\n max_fee_per_gas: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n access_list: [string, string[]][],\n authorization_list: Authorization7702[],\n):string {\n const payload = encodeEip7702TransactionBaseList(\n chainId,\n nonce,\n max_priority_fee_per_gas,\n max_fee_per_gas,\n gas_limit,\n destination,\n value,\n data,\n access_list,\n authorization_list,\n );\n\n return keccak256(SET_CODE_TX_TYPE + encodeRlp(payload).slice(2));\n}\n\n/**\n * Encodes the base RLP list for an EIP-7702 transaction (without signature fields).\n * Used internally to build the payload that gets hashed and signed.\n */\nfunction encodeEip7702TransactionBaseList(\n chainId: bigint,\n nonce: bigint,\n max_priority_fee_per_gas: bigint,\n max_fee_per_gas: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n access_list: [string, string[]][],\n authorization_list: Authorization7702[],\n){\n if (chainId >= 2**64){\n\t\tthrow new RangeError(\"Invalid chainId.\");\n }\n\n if (nonce >= 2**64){\n\t\tthrow new RangeError(\"Invalid nonce.\");\n }\n\n if (destination.length != 42){\n\t\tthrow new RangeError(\"Invalid destination.\");\n }\n\n const encoded_auth_list = encodeAuthList(authorization_list); \n const encoded_access_list = encodeAccessList(access_list);\n\n const payload = [\n bigintToBytes(chainId),\n bigintToBytes(nonce),\n bigintToBytes(max_priority_fee_per_gas),\n bigintToBytes(max_fee_per_gas),\n bigintToBytes(gas_limit),\n destination,\n bigintToBytes(value),\n data,\n encoded_access_list,\n encoded_auth_list,\n ]\n return payload;\n}\n\n/** Encodes an array of EIP-7702 authorizations into RLP-compatible nested arrays. */\nfunction encodeAuthList(authorization_list: Authorization7702[]){\n let encoded_auth_list = [];\n for (const auth of authorization_list){\n if (auth.address.length != 42){\n\t\t\tthrow new RangeError(\"Invalid authorization list address: \" + auth);\n }\n const encoded_auth = [\n bigintToBytes(auth.chainId),\n auth.address,\n bigintToBytes(auth.nonce),\n bigintToBytes(BigInt(auth.yParity)),\n bigintToBytes(auth.r),\n bigintToBytes(auth.s)\n ]\n encoded_auth_list.push(encoded_auth);\n }\n return encoded_auth_list;\n}\n\n/** Encodes an EIP-2930 access list into RLP-compatible nested arrays. */\nfunction encodeAccessList(access_list: [string, string[]][]){\n let encoded_access_list = [];\n for (const [access_add, storage_arr] of access_list){\n if (access_add.length != 42){\n\t\t\tthrow new RangeError(\"Invalid access list address: \" + access_add);\n }\n let encoded_storage_list = [];\n for (const storage of storage_arr){\n if (storage.length != 66){\n\t\t\t throw new RangeError(\"Invalid access list storage: \" + storage);\n }\n encoded_storage_list.push(getBytes(storage));\n }\n encoded_access_list.push(\n [getBytes(access_add), encoded_storage_list]\n );\n }\n return encoded_access_list;\n}\n\n/** Converts a bigint to a Uint8Array of its big-endian byte representation. */\nfunction bigintToBytes(bi: bigint){\n return getBytes(toBeArray(bi))\n}\n\n\n/**\n * Parse a raw ECDSA signature into its components.\n * Supports standard 65-byte (r + s + v) and EIP-2098 64-byte compact formats.\n * @param rawSig - Hex string: 128 chars (EIP-2098 compact), or 130/132 chars (standard with 0x prefix)\n * @returns An object with yParity (0 or 1), r, and s components\n */\nfunction parseRawSignature(rawSig: string): { yParity: 0 | 1; r: bigint; s: bigint } {\n const sig = rawSig.startsWith(\"0x\") ? rawSig.slice(2) : rawSig;\n if (sig.length !== 128 && sig.length !== 130) {\n throw new RangeError(\n `invalid signature length: expected 128 (EIP-2098 compact) or 130 (standard) hex chars, got ${sig.length}`\n );\n }\n const r = BigInt(\"0x\" + sig.slice(0, 64));\n\n if (sig.length === 128) {\n // EIP-2098 compact signature (64 bytes): r (32) + yParity||s (32)\n const yParityAndS = BigInt(\"0x\" + sig.slice(64, 128));\n const yParity = Number((yParityAndS >> 255n) & 1n) as 0 | 1;\n const s = yParityAndS & ((1n << 255n) - 1n);\n return { yParity, r, s };\n }\n\n // Standard 65-byte signature: r (32) + s (32) + v (1)\n const s = BigInt(\"0x\" + sig.slice(64, 128));\n const v = parseInt(sig.slice(128, 130), 16);\n if (v !== 0 && v !== 1 && v !== 27 && v !== 28) {\n throw new RangeError(`invalid signature v value: ${v}`);\n }\n const yParity = (v >= 27 ? v - 27 : v) as 0 | 1;\n return { yParity, r, s };\n}\n\n/**\n * Converts a bigint to a 0x-prefixed hex string with even-length padding.\n * @param value - The bigint value to convert.\n * @returns The hex string representation (e.g., \"0x01\", \"0xff\").\n */\nexport function bigintToHex(value: bigint): string {\n let hex = value.toString(16);\n return hex.length % 2 ? \"0x0\" + hex : \"0x\" + hex;\n}\n","import type {\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n\tUserOperationV9,\n\tGasEstimationResult,\n\tUserOperationByHashResult,\n\tUserOperationReceipt,\n\tUserOperationReceiptResult,\n\tStateOverrideSet,\n\tJsonRpcResult,\n} from \"./types\";\nimport { sendJsonRpcRequest } from \"./utils\";\nimport { AbstractionKitError, ensureError } from \"./errors\";\n\n/**\n * Client for communicating with an ERC-4337 bundler via JSON-RPC.\n * Provides methods for gas estimation, UserOperation submission, and receipt retrieval.\n *\n * Candide's bundler endpoint follows the format:\n * - `https://api.candide.dev/api/v3/{chainId}/{apiKey}` (authenticated)\n * - `https://api.candide.dev/public/v3/{chainId}` (public, no key required)\n *\n * @example\n * const bundler = new Bundler(\"https://api.candide.dev/public/v3/11155111\");\n * const receipt = await bundler.getUserOperationReceipt(userOpHash);\n */\nexport class Bundler {\n\t/** The bundler JSON-RPC endpoint URL */\n\treadonly rpcUrl: string;\n\n\t/** @param rpcUrl - The bundler JSON-RPC endpoint URL */\n\tconstructor(rpcUrl: string) {\n\t\tthis.rpcUrl = rpcUrl;\n\t}\n\n\t/**\n\t * Get the chain ID from the bundler.\n\t * @returns The chain ID as a hex-encoded string\n\t */\n\tasync chainId(): Promise<string> {\n\t\ttry {\n\t\t\tconst chainId = (await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_chainId\",\n\t\t\t\t[],\n\t\t\t)) as string;\n\t\t\tif (typeof chainId === \"string\") {\n\t\t\t\treturn chainId;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundler eth_chainId rpc call failed\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_chainId rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the list of EntryPoint addresses supported by this bundler.\n\t * @returns An array of supported EntryPoint contract addresses\n\t */\n\tasync supportedEntryPoints(): Promise<string[]> {\n\t\ttry {\n\t\t\tconst supportedEntryPoints = (await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_supportedEntryPoints\",\n\t\t\t\t[],\n\t\t\t)) as string[];\n\t\t\treturn supportedEntryPoints;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_supportedEntryPoints rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Estimate gas limits for a UserOperation.\n\t * @param useroperation - UserOperation to estimate gas for\n\t * @param entrypointAddress - Target EntryPoint address\n\t * @param state_override_set - Optional state overrides for estimation\n\t * @returns Gas estimation with callGasLimit, preVerificationGas, and verificationGasLimit\n\t */\n\tasync estimateUserOperationGas(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\t\tentrypointAddress: string,\n\t\tstate_override_set?: StateOverrideSet,\n\t): Promise<GasEstimationResult> {\n\t\ttry {\n\t\t\tlet jsonRpcResult = {} as JsonRpcResult;\n\t\t\tif (typeof state_override_set === \"undefined\") {\n\t\t\t\tjsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\t\tthis.rpcUrl,\n\t\t\t\t\t\"eth_estimateUserOperationGas\",\n\t\t\t\t\t[useroperation, entrypointAddress],\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tjsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\t\tthis.rpcUrl,\n\t\t\t\t\t\"eth_estimateUserOperationGas\",\n\t\t\t\t\t[useroperation, entrypointAddress, state_override_set],\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst res = jsonRpcResult as GasEstimationResult;\n\t\t\tconst gasEstimationResult: GasEstimationResult = {\n\t\t\t\tcallGasLimit: BigInt(res.callGasLimit),\n\t\t\t\tpreVerificationGas: BigInt(res.preVerificationGas),\n\t\t\t\tverificationGasLimit: BigInt(res.verificationGasLimit),\n\t\t\t};\n\n\t\t\treturn gasEstimationResult;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_estimateUserOperationGas rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Submit a signed UserOperation to the bundler for on-chain inclusion.\n\t * @param useroperation - The signed UserOperation to submit\n\t * @param entrypointAddress - Target EntryPoint address\n\t * @returns The UserOperation hash\n\t */\n\tasync sendUserOperation(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\t\tentrypointAddress: string,\n\t): Promise<string> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = (await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_sendUserOperation\",\n\t\t\t\t[useroperation, entrypointAddress],\n\t\t\t)) as string;\n\t\t\treturn jsonRpcResult;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_sendUserOperation rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the receipt for a previously submitted UserOperation.\n\t * @param useroperationhash - The hash of the UserOperation to look up\n\t * @returns The receipt, or null if not yet included\n\t */\n\tasync getUserOperationReceipt(\n\t\tuseroperationhash: string,\n\t): Promise<UserOperationReceiptResult> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_getUserOperationReceipt\",\n\t\t\t\t[useroperationhash],\n\t\t\t);\n\t\t\tconst res = jsonRpcResult as UserOperationReceiptResult;\n\n\t\t\tif (res != null) {\n\t\t\t\tconst userOperationReceipt: UserOperationReceipt = {\n\t\t\t\t\t...res.receipt,\n\t\t\t\t\tblockNumber: BigInt(res.receipt.blockNumber),\n\t\t\t\t\tcumulativeGasUsed: BigInt(res.receipt.cumulativeGasUsed),\n\t\t\t\t\tgasUsed: BigInt(res.receipt.gasUsed),\n\t\t\t\t\ttransactionIndex: BigInt(res.receipt.transactionIndex),\n\t\t\t\t\teffectiveGasPrice:\n\t\t\t\t\t\tres.receipt.effectiveGasPrice == undefined\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: BigInt(res.receipt.effectiveGasPrice),\n\t\t\t\t\tlogs: JSON.stringify(res.receipt.logs),\n\t\t\t\t};\n\n\t\t\t\tconst bundlerGetUserOperationReceiptResult: UserOperationReceiptResult =\n\t\t\t\t\t{\n\t\t\t\t\t\t...res,\n\t\t\t\t\t\tnonce: BigInt(res.nonce),\n\t\t\t\t\t\tactualGasCost: BigInt(res.actualGasCost),\n\t\t\t\t\t\tactualGasUsed: BigInt(res.actualGasUsed),\n\t\t\t\t\t\tlogs: JSON.stringify(res.logs),\n\t\t\t\t\t\treceipt: userOperationReceipt,\n\t\t\t\t\t};\n\t\t\t\treturn bundlerGetUserOperationReceiptResult;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_getUserOperationReceipt rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tuseroperationhash: useroperationhash,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Look up a UserOperation by its hash.\n\t * @param useroperationhash - The hash of the UserOperation to look up\n\t * @returns The UserOperation with metadata, or null if not found\n\t */\n\tasync getUserOperationByHash(\n\t\tuseroperationhash: string,\n\t): Promise<UserOperationByHashResult> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_getUserOperationByHash\",\n\t\t\t\t[useroperationhash],\n\t\t\t);\n\t\t\tconst res = jsonRpcResult as UserOperationByHashResult;\n\t\t\tif (res != null) {\n\t\t\t\treturn {\n\t\t\t\t\t...res,\n\t\t\t\t\tblockNumber: res.blockNumber == null ? null : BigInt(res.blockNumber),\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_getUserOperationByHash rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tuseroperationhash: useroperationhash,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n}\n","import { Bundler } from \"src/Bundler\";\nimport { AbstractionKitError } from \"src/errors\";\nimport { UserOperationReceiptResult } from \"src/types\";\n\n/**\n * Response object returned after submitting a UserOperation to a bundler.\n * Provides the `included()` method to poll for on-chain inclusion.\n *\n * @example\n * const response = await smartAccount.sendUserOperation(userOp, bundlerRpc);\n * const receipt = await response.included();\n */\nexport class SendUseroperationResponse {\n\t/** The hash of the submitted UserOperation */\n\treadonly userOperationHash: string;\n\t/** The bundler client used for polling */\n\treadonly bundler: Bundler;\n\t/** The EntryPoint address the operation was submitted to */\n\treadonly entrypointAddress: string;\n\n\t/**\n\t * @param userOperationHash - The hash of the submitted UserOperation\n\t * @param bundler - The bundler client to use for polling\n\t * @param entrypointAddress - The EntryPoint address\n\t */\n\tconstructor(\n\t\tuserOperationHash: string,\n\t\tbundler: Bundler,\n\t\tentrypointAddress: string,\n\t) {\n\t\tthis.bundler = bundler;\n\t\tthis.userOperationHash = userOperationHash;\n\t\tthis.entrypointAddress = entrypointAddress;\n\t}\n\n\tprivate delay(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\t/**\n\t * Poll the bundler for the UserOperation receipt until it is included on-chain or times out.\n\t *\n\t * @param timeoutInSeconds - Maximum time to wait for inclusion (default: 180s)\n\t * @param requestIntervalInSeconds - Time between polling requests (default: 2s)\n\t * @returns The UserOperation receipt once included\n\t * @throws RangeError if timeout or interval are <= 0, or timeout < interval\n\t * @throws AbstractionKitError with code \"TIMEOUT\" if the operation is not found within the timeout\n\t */\n\tasync included(\n\t\ttimeoutInSeconds: number = 180,\n\t\trequestIntervalInSeconds: number = 2,\n\t): Promise<UserOperationReceiptResult> {\n\t\tif (timeoutInSeconds <= 0 || requestIntervalInSeconds <= 0) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"timeoutInSeconds and requestIntervalInSeconds should be bigger than zero\",\n\t\t\t);\n\t\t}\n\t\tif (timeoutInSeconds < requestIntervalInSeconds) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"timeoutInSeconds can't be less than requestIntervalInSeconds\",\n\t\t\t);\n\t\t}\n\t\tlet count = 0;\n\t\twhile (count <= timeoutInSeconds) {\n\t\t\tawait this.delay(requestIntervalInSeconds * 1000);\n\t\t\tconst res = await this.bundler.getUserOperationReceipt(\n\t\t\t\tthis.userOperationHash,\n\t\t\t);\n\t\t\tif (res == null) {\n\t\t\t\tcount += requestIntervalInSeconds;\n\t\t\t} else {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\t\tthrow new AbstractionKitError(\"TIMEOUT\", \"can't find useroperation\", {\n\t\t\tcontext: this.userOperationHash,\n\t\t});\n\t}\n}\n","import { SmartAccount } from \"../SmartAccount\";\nimport { BaseUserOperationDummyValues, ENTRYPOINT_V8, ENTRYPOINT_V9 } from \"src/constants\";\nimport { \n createCallData, createUserOperationHash, fetchAccountNonce,\n getDelegatedAddress, getFunctionSelector, handlefetchGasPrice,\n sendJsonRpcRequest\n} from \"../../utils\";\nimport { GasOption, PolygonChain, StateOverrideSet, UserOperationV8, UserOperationV9 } from \"src/types\";\nimport { AbstractionKitError } from \"src/errors\";\nimport {\n Authorization7702Hex, bigintToHex,\n createAndSignEip7702RawTransaction,\n createRevokeDelegationAuthorization,\n} from \"src/utils7702\";\nimport { Bundler } from \"src/Bundler\";\nimport { Wallet, AbiCoder } from \"ethers\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\n\n/**\n * A minimal transaction object for EIP-7702 simple accounts.\n * Represents a single call with a target address, ETH value, and calldata.\n */\nexport interface SimpleMetaTransaction {\n\t/** Target contract or EOA address */\n\tto: string;\n\t/** Amount of native token (in wei) to send with the call */\n\tvalue: bigint;\n\t/** ABI-encoded calldata, or \"0x\" for plain ETH transfers */\n\tdata: string;\n}\n\n/**\n * Optional overrides for UserOperation fields when calling\n * {@link BaseSimple7702Account.baseCreateUserOperation}.\n * Any field left undefined will be auto-determined (nonce fetched from RPC,\n * gas limits estimated via bundler, gas prices fetched from the network).\n */\nexport interface CreateUserOperationOverrides {\n\t/** set the nonce instead of quering the current nonce from the rpc node */\n\tnonce?: bigint;\n\t/** set the callData instead of using the encoding of the provided Metatransactions*/\n\tcallData?: string;\n\t/** set the callGasLimit instead of estimating gas using the bundler*/\n\tcallGasLimit?: bigint;\n\t/** set the verificationGasLimit instead of estimating gas using the bundler*/\n\tverificationGasLimit?: bigint;\n\t/** set the preVerificationGas instead of estimating gas using the bundler*/\n\tpreVerificationGas?: bigint;\n\t/** set the maxFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxFeePerGas?: bigint;\n\t/** set the maxPriorityFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGas?: bigint;\n\n\t/** set the callGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tcallGasLimitPercentageMultiplier?: number;\n\t/** set the verificationGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tverificationGasLimitPercentageMultiplier?: number;\n\t/** set the preVerificationGasPercentageMultiplier instead of estimating gas using the bundler*/\n\tpreVerificationGasPercentageMultiplier?: number;\n\t/** set the maxFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** set the maxPriorityFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGasPercentageMultiplier?: number;\n\n\t/** pass some state overrides for gas estimation\"*/\n\tstate_override_set?: StateOverrideSet;\n\n\t/** Override the dummy signature used during gas estimation */\n\tdummySignature?: string;\n\n\t/** Gas price level preference (e.g., slow, medium, fast) */\n\tgasLevel?: GasOption;\n\t/** Polygon chain identifier for fetching gas prices from Polygon Gas Station */\n\tpolygonGasStation?: PolygonChain;\n\n\t/**\n\t * EIP-7702 authorization fields. When provided, the UserOperation\n\t * will include an authorization tuple that delegates the EOA to\n\t * the account's delegatee contract. If address/nonce are omitted,\n\t * defaults are used (delegateeAddress and fetched from RPC respectively).\n\t */\n eip7702Auth?:{\n chainId: bigint;\n address?: string;\n nonce?: bigint;\n yParity?: string;\n r?: string;\n s?: string;\n };\n\n\tparallelPaymasterInitValues?: {\n\t\t/** set the paymaster contract address */\n\t\tpaymaster: string;\n\t\t/** set the paymaster verification gas limit */\n\t\tpaymasterVerificationGasLimit: bigint;\n\t\t/** set the paymaster post-operation gas limit */\n\t\tpaymasterPostOpGasLimit: bigint;\n\t\t/** set the paymaster data, only valid value is 0x22e325a297439656 */\n\t\tpaymasterData: string;\n\t}\n}\n\n/**\n * Abstract base class for EIP-7702 simple smart accounts.\n * Provides shared logic for creating, signing, and sending UserOperations\n * using the SimpleAccount execute/executeBatch interface. Subclasses\n * (e.g., {@link Simple7702Account}, {@link Simple7702AccountV09}) bind\n * a specific EntryPoint version and delegatee address.\n */\nexport class BaseSimple7702Account extends SmartAccount {\n\t/** Function selector for `execute(address,uint256,bytes)` */\n\tstatic readonly executorFunctionSelector = \"0xb61d27f6\"; //execute\n\t/** ABI parameter types for the single-call `execute` function */\n\tstatic readonly executorFunctionInputAbi: string[] = [\n \"address\", //dest\n \"uint256\", //value\n \"bytes\", //func\n ];\n /** Function selector for `executeBatch((address,uint256,bytes)[])` */\n static readonly batchExecutorFunctionSelector = \"0x34fcd5be\"; //executeBatch\n\t/** ABI parameter types for the batch `executeBatch` function */\n\tstatic readonly batchExecutorFunctionInputAbi = [\"(address,uint256,bytes)[]\"];\n /** Dummy ECDSA signature used during gas estimation */\n static readonly dummySignature =\n \"0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c\";\n\n\t/** The EntryPoint contract address this account targets */\n\treadonly entrypointAddress: string;\n\t/** The EIP-7702 delegatee (implementation) contract address */\n\treadonly delegateeAddress: string;\n\n\t/**\n\t * @param accountAddress - The EOA address that will be delegated via EIP-7702\n\t * @param entrypointAddress - The EntryPoint contract address\n\t * @param delegateeAddress - The EIP-7702 delegatee (implementation) contract address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n entrypointAddress: string,\n delegateeAddress:string,\n\t) {\n\t\tsuper(accountAddress);\n this.entrypointAddress = entrypointAddress;\n this.delegateeAddress = delegateeAddress;\n\t}\n\n /**\n * Check if this EOA is delegated to the expected delegatee address via EIP-7702.\n * Returns `true` only when delegated to `this.delegateeAddress`.\n * Use `getDelegatedAddress()` directly to get the raw delegatee address.\n *\n * @param providerRpc - Ethereum JSON-RPC node URL\n * @returns `true` if delegated to the expected address, `false` otherwise\n */\n public async isDelegatedToThisAccount(providerRpc: string): Promise<boolean> {\n const address = await getDelegatedAddress(this.accountAddress, providerRpc);\n if (address === null) return false;\n return address.toLowerCase() === this.delegateeAddress.toLowerCase();\n }\n\n /**\n * Create a signed raw EIP-7702 transaction that revokes the delegation,\n * restoring the EOA to a normal account. The transaction is type 0x04\n * with a zero-address authorization.\n *\n * Cannot be done via UserOp — the authorization_list is processed before\n * execution, removing the account's code mid-transaction.\n *\n * Authorization nonce defaults to txNonce + 1 because EIP-7702 increments\n * the sender's transaction nonce before processing the authorization list.\n *\n * @param eoaPrivateKey - The EOA's private key (signs both auth and tx)\n * @param providerRpc - JSON-RPC endpoint for nonce, gas price, chain ID\n * @param overrides - Optional overrides for transaction fields\n * @returns Signed raw transaction hex, ready for `eth_sendRawTransaction`\n */\n public async createRevokeDelegationTransaction(\n eoaPrivateKey: string,\n providerRpc: string,\n overrides: {\n nonce?: bigint;\n authorizationNonce?: bigint;\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n gasLimit?: bigint;\n chainId?: bigint;\n } = {},\n ): Promise<string> {\n // Verify delegation state before revoking\n const delegatedTo = await getDelegatedAddress(this.accountAddress, providerRpc);\n if (delegatedTo === null) {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"Account is not delegated — nothing to revoke\",\n );\n }\n if (delegatedTo.toLowerCase() !== this.delegateeAddress.toLowerCase()) {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"Account is delegated to a different address (\" +\n delegatedTo + \"), not \" + this.delegateeAddress +\n \" — use the correct account class to revoke\",\n );\n }\n\n const results: {\n nonce?: bigint;\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n chainId?: bigint;\n } = {};\n\n // Build parallel fetch list\n const ops: Promise<void>[] = [];\n\n if (overrides.nonce == null) {\n ops.push(\n sendJsonRpcRequest(\n providerRpc, \"eth_getTransactionCount\",\n [this.accountAddress, \"latest\"]\n ).then((v) => { results.nonce = BigInt(v as string); })\n );\n }\n\n if (overrides.maxFeePerGas == null || overrides.maxPriorityFeePerGas == null) {\n ops.push(\n handlefetchGasPrice(providerRpc, undefined)\n .then(([fee, tip]) => {\n results.maxFeePerGas = fee;\n results.maxPriorityFeePerGas = tip;\n })\n );\n }\n\n if (overrides.chainId == null) {\n ops.push(\n sendJsonRpcRequest(providerRpc, \"eth_chainId\", [])\n .then((v) => { results.chainId = BigInt(v as string); })\n );\n }\n\n if (ops.length > 0) await Promise.all(ops);\n\n const txNonce = overrides.nonce ?? results.nonce ?? 0n;\n const maxFeePerGas = overrides.maxFeePerGas ?? results.maxFeePerGas ?? 0n;\n const maxPriorityFeePerGas = overrides.maxPriorityFeePerGas ?? results.maxPriorityFeePerGas ?? 0n;\n const chainId = overrides.chainId ?? results.chainId ?? 0n;\n\n // Authorization nonce = txNonce + 1 by default\n // (tx nonce is incremented before authorization processing in EIP-7702)\n const authNonce = overrides.authorizationNonce ?? (txNonce + 1n);\n\n // Create undelegation authorization (returns Authorization7702Hex)\n const authHex = createRevokeDelegationAuthorization(\n chainId, authNonce, eoaPrivateKey\n );\n\n // Convert Authorization7702Hex -> Authorization7702 for raw tx builder\n const auth = {\n chainId: BigInt(authHex.chainId),\n address: authHex.address,\n nonce: BigInt(authHex.nonce),\n yParity: (BigInt(authHex.yParity) === 0n ? 0 : 1) as 0 | 1,\n r: BigInt(authHex.r),\n s: BigInt(authHex.s),\n };\n\n const gasLimit = overrides.gasLimit ?? 60_000n;\n\n return createAndSignEip7702RawTransaction(\n chainId,\n txNonce,\n maxPriorityFeePerGas,\n maxFeePerGas,\n gasLimit,\n this.accountAddress,\n 0n,\n \"0x\",\n [],\n [auth],\n eoaPrivateKey,\n );\n }\n\n /**\n\t * Encode calldata for a single `execute(address,uint256,bytes)` call.\n\t * @param to - Target contract or EOA address\n\t * @param value - Amount of native token (in wei) to transfer\n\t * @param data - ABI-encoded calldata for the target\n\t * @returns Encoded calldata for the execute function\n\t */\n public static createAccountCallData(\n\t\tto: string,\n\t\tvalue: bigint,\n\t\tdata: string,\n\t): string {\n\t\tconst executorFunctionInputParameters = [to, value, data];\n\t\tconst callData = createCallData(\n\t\t\tBaseSimple7702Account.executorFunctionSelector,\n\t\t\tBaseSimple7702Account.executorFunctionInputAbi,\n\t\t\texecutorFunctionInputParameters,\n\t\t);\n\t\treturn callData;\n }\n \n /**\n\t * Encode calldata for a single {@link SimpleMetaTransaction} using `execute`.\n\t * @param metaTransaction - The transaction to encode\n\t * @returns Encoded calldata for the execute function\n\t */\n public static createAccountCallDataSingleTransaction(\n\t\tmetaTransaction: SimpleMetaTransaction,\n\t): string {\n\t\tconst value = metaTransaction.value ?? 0;\n\t\tconst data = metaTransaction.data ?? \"0x\";\n\t\tconst executorFunctionCallData = BaseSimple7702Account.createAccountCallData(\n\t\t\tmetaTransaction.to,\n\t\t\tvalue,\n\t\t\tdata,\n\t\t);\n\t\treturn executorFunctionCallData;\n\t}\n\n /**\n\t * Encode calldata for a batch of {@link SimpleMetaTransaction}s using `executeBatch`.\n\t * @param transactions - Array of transactions to batch\n\t * @returns Encoded calldata for the executeBatch function\n\t */\n\tpublic static createAccountCallDataBatchTransactions(\n transactions: SimpleMetaTransaction[]\n ): string {\n const encodedTransactions = [transactions.map(\n transaction => [transaction.to, transaction.value, transaction.data]\n )];\n const callData = createCallData(\n\t\t\tBaseSimple7702Account.batchExecutorFunctionSelector,\n\t\t\tBaseSimple7702Account.batchExecutorFunctionInputAbi,\n\t\t\tencodedTransactions,\n\t\t);\n\t\treturn callData;\n\t}\n \n /**\n\t * Build an unsigned UserOperation from one or more transactions.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and\n\t * optionally includes EIP-7702 authorization. All auto-determined\n\t * values can be overridden.\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned UserOperation (v8 or v9)\n\t */\n protected async baseCreateUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8 | UserOperationV9> {\n if (transactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one transaction\");\n\t\t}\n let nonce:bigint | null = null;\n\t\tlet nonceOp:Promise<bigint> | null = null;\n\n if (overrides.nonce == null) {\n\t\t\tif (providerRpc != null) {\n\t\t\t\tnonceOp = fetchAccountNonce(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc cant't be null if nonce is not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnonce = overrides.nonce;\n\t\t}\n\n if (\n\t\t\ttypeof overrides.maxFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxFeePerGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxPriorityFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxPriorityFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas override can't be negative\");\n\t\t}\n let maxFeePerGas = BaseUserOperationDummyValues.maxFeePerGas;\n\t\tlet maxPriorityFeePerGas =\n\t\t\tBaseUserOperationDummyValues.maxPriorityFeePerGas;\n\n let gasPriceOp:Promise<[bigint, bigint]> | null = null;\n if (\n\t\t\toverrides.maxFeePerGas == null ||\n\t\t\toverrides.maxPriorityFeePerGas == null\n\t\t) {\n gasPriceOp = handlefetchGasPrice(\n providerRpc, overrides.polygonGasStation, overrides.gasLevel\n )\n }\n \n let eip7702AuthChainId:bigint|null = null;\n let eip7702AuthAddress:string|null = null;\n let eip7702AuthNonce:bigint|null = null;\n let skipEip7702Auth = false;\n\n if(overrides.eip7702Auth != null){\n eip7702AuthChainId = overrides.eip7702Auth.chainId;\n eip7702AuthAddress = overrides.eip7702Auth.address??\n this.delegateeAddress;\n eip7702AuthNonce = overrides.eip7702Auth.nonce??null;\n }\n\n // When eip7702Auth is provided, check delegation status in parallel.\n // Best-effort: if the check fails, proceed as if not delegated.\n let delegationCheckOp:Promise<string|null>|null = null;\n if(overrides.eip7702Auth != null && providerRpc != null){\n delegationCheckOp = getDelegatedAddress(this.accountAddress, providerRpc)\n .catch(() => null);\n }\n\n if(overrides.eip7702Auth != null && eip7702AuthNonce == null){\n //check for eip7702AuthNonce\n let eip7702AuthNonceOp;\n if (providerRpc != null) {\n eip7702AuthNonceOp = sendJsonRpcRequest(\n providerRpc,\n \"eth_getTransactionCount\",\n [this.accountAddress, \"latest\"]\n );\n } else {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"providerRpc cant't be null if eoaDelegatorNonce \" +\n \"is not overriden\",\n );\n }\n\n // Build array of all parallel operations\n const ops:Promise<any>[] = [eip7702AuthNonceOp];\n if(nonceOp != null) ops.push(nonceOp);\n if(gasPriceOp != null) ops.push(gasPriceOp);\n if(delegationCheckOp != null) ops.push(delegationCheckOp);\n\n const values = await Promise.all(ops);\n let idx = 0;\n eip7702AuthNonce = BigInt(values[idx++] as string);\n if(nonceOp != null) nonce = values[idx++];\n if(gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++];\n if(delegationCheckOp != null){\n const delegatedTo = values[idx++] as string|null;\n if(delegatedTo != null &&\n delegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()){\n skipEip7702Auth = true;\n }\n }\n }else if(overrides.eip7702Auth != null){\n // eip7702AuthNonce was provided, but still need delegation check + other ops\n const ops:Promise<any>[] = [];\n if(nonceOp != null) ops.push(nonceOp);\n if(gasPriceOp != null) ops.push(gasPriceOp);\n if(delegationCheckOp != null) ops.push(delegationCheckOp);\n\n if(ops.length > 0){\n const values = await Promise.all(ops);\n let idx = 0;\n if(nonceOp != null) nonce = values[idx++];\n if(gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++];\n if(delegationCheckOp != null){\n const delegatedTo = values[idx++] as string|null;\n if(delegatedTo != null &&\n delegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()){\n skipEip7702Auth = true;\n }\n }\n }\n }else{\n //don't check for eip7702AuthNonce\n if(gasPriceOp != null && nonceOp != null){\n await Promise.all([nonceOp, gasPriceOp]).then((values) => {\n nonce = values[0];\n [maxFeePerGas, maxPriorityFeePerGas] = values[1];\n });\n }else if(gasPriceOp != null){\n [maxFeePerGas, maxPriorityFeePerGas] = await gasPriceOp;\n }else if(nonceOp != null){\n nonce = await nonceOp;\n }\n }\n\t\tmaxFeePerGas = overrides.maxFeePerGas ??\n BigInt(\n Math.floor(\n Number(maxFeePerGas) *\n (((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n );\n\t\tmaxPriorityFeePerGas = overrides.maxPriorityFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxPriorityFeePerGas) *\n\t\t\t\t\t(((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n\t\t\t);\n if(nonce == null){\n\t\t\tthrow new RangeError(\"failed to determine nonce\");\n }\n else if (nonce < 0n) {\n\t\t\tthrow new RangeError(\"nonce can't be negative\");\n\t\t}\n \n let callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tif (transactions.length == 1) {\n\t\t\t\tcallData = BaseSimple7702Account.createAccountCallDataSingleTransaction(\n\t\t\t\t\ttransactions[0],\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcallData = BaseSimple7702Account.createAccountCallDataBatchTransactions(\n\t\t\t\t\ttransactions,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n \n\t\tlet userOperation:UserOperationV8 | UserOperationV9;\n if(overrides.eip7702Auth != null && !skipEip7702Auth){\n const yParity = overrides.eip7702Auth.yParity?? \"0x0\";\n if(\n yParity != \"0x0\" && yParity != \"0x00\" &&\n yParity != \"0x1\" && yParity != \"0x01\"\n ){\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"invalide yParity value for eoaDelegatorSignature. \" +\n \"must be '0x0' or '0x1'\"\n );\n }\n\n const authorization:Authorization7702Hex= {\n chainId: bigintToHex(eip7702AuthChainId as bigint),\n address: eip7702AuthAddress as string,\n nonce: bigintToHex(eip7702AuthNonce as bigint),\n yParity: yParity,\n r: overrides.eip7702Auth.r??\n \"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2\",\n s: overrides.eip7702Auth.s??\n \"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd\",\n } \n userOperation = {\n ...BaseUserOperationDummyValues,\n sender: this.accountAddress,\n nonce: nonce,\n callData: callData,\n maxFeePerGas: maxFeePerGas,\n maxPriorityFeePerGas: maxPriorityFeePerGas,\n factory: \"0x7702\",\n factoryData: null,\n paymaster: null,\n paymasterVerificationGasLimit: null,\n paymasterPostOpGasLimit: null,\n paymasterData: null,\n eip7702Auth: authorization,\n };\n }else{\n userOperation = {\n ...BaseUserOperationDummyValues,\n sender: this.accountAddress,\n nonce: nonce,\n callData: callData,\n maxFeePerGas: maxFeePerGas,\n maxPriorityFeePerGas: maxPriorityFeePerGas,\n factory: null,\n factoryData: null,\n paymaster: null,\n paymasterVerificationGasLimit: null,\n paymasterPostOpGasLimit: null,\n paymasterData: null,\n eip7702Auth: null,\n };\n }\n let preVerificationGas = BaseUserOperationDummyValues.preVerificationGas;\n\t\tlet verificationGasLimit =\n\t\t\tBaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n const parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n if(parallelPaymasterInitValues != null){\n if(this.entrypointAddress != ENTRYPOINT_V9){\n throw new RangeError(\n \"parallelPaymasterInitValues only works with ep v0.9\"\n );\n }\n userOperation.paymaster = parallelPaymasterInitValues.paymaster;\n userOperation.paymasterVerificationGasLimit =\n parallelPaymasterInitValues.paymasterVerificationGasLimit;\n userOperation.paymasterPostOpGasLimit =\n parallelPaymasterInitValues.paymasterPostOpGasLimit;\n userOperation.paymasterData =\n parallelPaymasterInitValues.paymasterData;\n }\n\n\t\t\tif (bundlerRpc != null) {\n\t\t\t\tuserOperation.callGasLimit = 0n;\n\t\t\t\tuserOperation.verificationGasLimit = 0n;\n\t\t\t\tuserOperation.preVerificationGas = 0n;\n\t\t\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\t\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\t\t\tuserOperation.maxFeePerGas = 0n;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\n\t\t\t\tlet userOperationToEstimate: UserOperationV8 | UserOperationV9;\n userOperationToEstimate = { ...userOperation };\n\n\t\t\t\tuserOperation.signature = overrides.dummySignature??\n BaseSimple7702Account.dummySignature;;\n\t\t\t\t[preVerificationGas, verificationGasLimit, callGasLimit] =\n\t\t\t\t\tawait this.baseEstimateUserOperationGas(\n\t\t\t\t\t\tuserOperationToEstimate,\n\t\t\t\t\t\tbundlerRpc,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstateOverrideSet: overrides.state_override_set,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\tverificationGasLimit += 55_000n;\n\n\t\t\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc cant't be null if preVerificationGas,\" +\n\t\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\ttypeof overrides.preVerificationGas === \"bigint\" &&\n\t\t\toverrides.preVerificationGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"preVerificationGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.verificationGasLimit === \"bigint\" &&\n\t\t\toverrides.verificationGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"verificationGasLimit override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.callGasLimit === \"bigint\" &&\n\t\t\toverrides.callGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"callGasLimit override can't be negative\");\n\t\t}\n\n\t\tuserOperation.preVerificationGas = overrides.preVerificationGas ??\n BigInt(\n Math.floor(\n Number(preVerificationGas) *\n (((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100)\n ),\n );\n\n\t\tuserOperation.verificationGasLimit = overrides.verificationGasLimit ??\n BigInt(\n Math.floor(\n Number(verificationGasLimit) *\n (((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n ),\n );\n\n\t\tuserOperation.callGasLimit = overrides.callGasLimit ??\n BigInt(\n Math.floor(\n Number(callGasLimit) *\n (((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n ),\n );\n\n\t\treturn userOperation;\n }\n \n /**\n\t * Estimate gas limits for a UserOperation via the bundler.\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides\n\t * @param overrides.stateOverrideSet - State overrides to apply during estimation\n\t * @param overrides.dummySignature - Custom dummy ECDSA signature for estimation\n\t * @returns A promise resolving to `[preVerificationGas, verificationGasLimit, callGasLimit]`\n\t */\n protected async baseEstimateUserOperationGas(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t dummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\tuserOperation.signature = overrides.dummySignature??\n BaseSimple7702Account.dummySignature;\n\t\t \n\t\tconst bundler = new Bundler(bundlerRpc);\n\n\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\tuserOperation.maxFeePerGas = 0n;\n\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\toverrides.stateOverrideSet,\n\t\t);\n\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\n\t\tconst preVerificationGas = BigInt(estimation.preVerificationGas);\n\n\t\tconst verificationGasLimit = BigInt(estimation.verificationGasLimit);\n\n\t\tconst callGasLimit = BigInt(estimation.callGasLimit);\n\n\t\treturn [preVerificationGas, verificationGasLimit, callGasLimit];\n\t}\n \n /**\n\t * Sign a UserOperation with an EOA private key.\n\t * Computes the UserOperation hash and produces an ECDSA signature.\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key of the EOA signer\n\t * @param chainId - Target chain ID\n\t * @returns Hex-encoded ECDSA signature\n\t */\n protected baseSignUserOperation(\n\t\tuseroperation: UserOperationV8 | UserOperationV9,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n ): string {\n\t\tconst userOperationHash = createUserOperationHash(\n\t\t\tuseroperation,\n this.entrypointAddress,\n\t\t\tchainId,\n );\n\n\t\tconst wallet = new Wallet(privateKey);\n return wallet.signingKey.sign(userOperationHash).serialized;\n\t}\n \n /**\n\t * Submit a signed UserOperation to a bundler for on-chain inclusion.\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tprotected async baseSendUserOperation(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = new Bundler(bundlerRpc);\n\t\tconst sendUserOperationRes = await bundler.sendUserOperation(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\n\t\treturn new SendUseroperationResponse(\n\t\t\tsendUserOperationRes,\n\t\t\tbundler,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\t}\n\n /**\n\t * Prepend a token `approve` call to existing calldata for a token paymaster.\n\t * Instance wrapper for {@link BaseSimple7702Account.prependTokenPaymasterApproveToCallDataStatic}.\n\t * @param callData - Existing encoded calldata (execute or executeBatch)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended as a batch\n\t */\n\tpublic prependTokenPaymasterApproveToCallData(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\treturn BaseSimple7702Account.prependTokenPaymasterApproveToCallDataStatic(\n\t\t\tcallData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tapproveAmount,\n\t\t);\n\t}\n\n /**\n\t * Prepend a token `approve` call to existing calldata for a token paymaster.\n\t * Decodes the existing calldata, prepends an ERC-20 approve transaction,\n\t * and re-encodes as a batch via `executeBatch`.\n\t * @param callData - Existing encoded calldata (execute or executeBatch)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended as a batch\n\t */\n\tpublic static prependTokenPaymasterApproveToCallDataStatic(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\tconst approveFunctionSignature = \"approve(address,uint256)\";\n\t\tconst approveFunctionSelector = getFunctionSelector(\n\t\t\tapproveFunctionSignature,\n\t\t);\n\t\tconst approveCallData = createCallData(\n\t\t\tapproveFunctionSelector,\n\t\t\t[\"address\", \"uint256\"],\n\t\t\t[paymasterAddress, approveAmount],\n\t\t);\n\t\tconst approveMetatransaction: SimpleMetaTransaction = {\n\t\t\tto: tokenAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: approveCallData,\n\t\t};\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n let decodedMetaTransactions:SimpleMetaTransaction[];\n\t\tif (callData.startsWith(BaseSimple7702Account.batchExecutorFunctionSelector)) {\n const decodedParamsArray = abiCoder.decode(\n BaseSimple7702Account.batchExecutorFunctionInputAbi,\n \"0x\" + callData.slice(10)\n )[0] as [];\n decodedMetaTransactions = decodedParamsArray.map(decodedParams =>({\n to: decodedParams[0] as string,\n value: BigInt(decodedParams[1] as string),\n data: typeof decodedParams[2] !== \"string\"?\n new TextDecoder().decode(decodedParams[2]):decodedParams[2]\n }));\n } else if(callData.startsWith(BaseSimple7702Account.executorFunctionSelector)) {\n const decodedParams = abiCoder.decode(\n BaseSimple7702Account.executorFunctionInputAbi,\n \"0x\" + callData.slice(10)\n );\n decodedMetaTransactions = [{\n to: decodedParams[0] as string,\n value: BigInt(decodedParams[1] as string),\n data: typeof decodedParams[2] !== \"string\"?\n new TextDecoder().decode(decodedParams[2]):decodedParams[2]\n }];\n }else{\n throw new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Invalid calldata, should start with \" +\n\t\t\t\t\tBaseSimple7702Account.batchExecutorFunctionSelector +\n\t\t\t\t\t\" or \" +\n\t\t\t\t\tBaseSimple7702Account.executorFunctionSelector,\n\t\t\t\t{\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tcallData: callData,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n }\n decodedMetaTransactions.unshift(approveMetatransaction);\n return BaseSimple7702Account.createAccountCallDataBatchTransactions(\n decodedMetaTransactions\n )\n }\n}\n\n/**\n * EIP-7702 simple smart account targeting EntryPoint v0.8\n * (`0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108`).\n * Wraps {@link BaseSimple7702Account} with concrete types for\n * {@link UserOperationV8} and sensible defaults for the delegatee address.\n */\nexport class Simple7702Account extends BaseSimple7702Account {\n\tstatic readonly DEFAULT_DELEGATEE_ADDRESS = \"0xe6Cae83BdE06E4c305530e199D7217f42808555B\";\n\n\t/**\n\t * @param accountAddress - The EOA address that will be delegated via EIP-7702\n\t * @param overrides - Optional overrides for entrypoint and delegatee addresses\n\t * @param overrides.entrypointAddress - Custom EntryPoint address (defaults to EntryPoint v0.8)\n\t * @param overrides.delegateeAddress - Custom delegatee contract address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n overrides: {\n\t\t\tentrypointAddress?: string;\n delegateeAddress?:string;\n\t\t} = {},\n\t) {\n\t\tsuper(\n accountAddress,\n overrides.entrypointAddress ?? ENTRYPOINT_V8,\n overrides.delegateeAddress ?? Simple7702Account.DEFAULT_DELEGATEE_ADDRESS\n );\n\t}\n\n /**\n\t * Create a {@link UserOperationV8} for EntryPoint v0.8.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and returns\n\t * an unsigned UserOperation. All auto-determined values can be overridden.\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned {@link UserOperationV8}\n\t */\n public async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8> {\n return this.baseCreateUserOperation(\n transactions,\n providerRpc,\n bundlerRpc,\n overrides,\n );\n }\n\n /**\n\t * Estimate gas limits for a {@link UserOperationV8}.\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides\n\t * @param overrides.stateOverrideSet - State overrides to apply during estimation\n\t * @param overrides.dummySignature - Custom dummy signature for estimation\n\t * @returns A promise resolving to `[preVerificationGas, verificationGasLimit, callGasLimit]`\n\t */\n public async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV8,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t dummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n return this.baseEstimateUserOperationGas(\n userOperation,\n bundlerRpc,\n overrides\n );\n }\n\n /**\n\t * Sign a {@link UserOperationV8} with an EOA private key.\n\t * Computes the UserOperation hash and produces an ECDSA signature.\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key of the EOA signer\n\t * @param chainId - Target chain ID\n\t * @returns Hex-encoded ECDSA signature\n\t */\n public signUserOperation(\n\t\tuseroperation: UserOperationV8,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n ): string {\n return this.baseSignUserOperation(useroperation, privateKey, chainId);\n }\n\n /**\n\t * Send a signed {@link UserOperationV8} to a bundler for on-chain inclusion.\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV8,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n return this.baseSendUserOperation(userOperation, bundlerRpc);\n }\n}\n","import { StateOverrideSet, UserOperationV9 } from \"src/types\";\nimport { BaseSimple7702Account, CreateUserOperationOverrides, SimpleMetaTransaction } from \"./Simple7702Account\";\nimport { ENTRYPOINT_V9 } from \"src/constants\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\n\n/**\n * EIP-7702 simple smart account targeting EntryPoint v0.9\n * (`0x433709009B8330FDa32311DF1C2AFA402eD8D009`).\n * Extends {@link BaseSimple7702Account} with concrete types for\n * {@link UserOperationV9} and sensible defaults for the delegatee address.\n */\nexport class Simple7702AccountV09 extends BaseSimple7702Account {\n\tstatic readonly DEFAULT_DELEGATEE_ADDRESS = \"0xa46cc63eBF4Bd77888AA327837d20b23A63a56B5\";\n\n\t/**\n\t * @param accountAddress - The EOA address that will be delegated via EIP-7702\n\t * @param overrides - Optional overrides for entrypoint and delegatee addresses\n\t * @param overrides.entrypointAddress - Custom EntryPoint address (defaults to EntryPoint v0.9)\n\t * @param overrides.delegateeAddress - Custom delegatee contract address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n overrides: {\n\t\t\tentrypointAddress?: string;\n delegateeAddress?:string;\n\t\t} = {},\n\t) {\n\t\tsuper(\n accountAddress,\n overrides.entrypointAddress ?? ENTRYPOINT_V9,\n overrides.delegateeAddress ?? Simple7702AccountV09.DEFAULT_DELEGATEE_ADDRESS\n );\n\t}\n\n /**\n\t * Create a {@link UserOperationV9} for EntryPoint v0.9.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and returns\n\t * an unsigned UserOperation. All auto-determined values can be overridden.\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned {@link UserOperationV9}\n\t */\n public async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV9> {\n return this.baseCreateUserOperation(\n transactions,\n providerRpc,\n bundlerRpc,\n overrides,\n );\n }\n\n /**\n\t * Estimate gas limits for a {@link UserOperationV9}.\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides\n\t * @param overrides.stateOverrideSet - State overrides to apply during estimation\n\t * @param overrides.dummySignature - Custom dummy signature for estimation\n\t * @returns A promise resolving to `[preVerificationGas, verificationGasLimit, callGasLimit]`\n\t */\n public async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV9,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t dummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n return this.baseEstimateUserOperationGas(\n userOperation,\n bundlerRpc,\n overrides\n );\n }\n\n /**\n\t * Sign a {@link UserOperationV9} with an EOA private key.\n\t * Computes the UserOperation hash and produces an ECDSA signature.\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key of the EOA signer\n\t * @param chainId - Target chain ID\n\t * @returns Hex-encoded ECDSA signature\n\t */\n public signUserOperation(\n\t\tuseroperation: UserOperationV9,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n ): string {\n return this.baseSignUserOperation(useroperation, privateKey, chainId);\n }\n\n /**\n\t * Send a signed {@link UserOperationV9} to a bundler for on-chain inclusion.\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV9,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n return this.baseSendUserOperation(userOperation, bundlerRpc);\n }\n}\n","import { AbiCoder } from \"ethers\";\n\nimport {\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n UserOperationV9,\n TenderlySimulationResult,\n SingleTransactionTenderlySimulationResult,\n} from \"./types\";\nimport {\n\tAbstractionKitError\n} from \"./errors\";\nimport { sendJsonRpcRequest, createUserOperationHash } from \"./utils\";\n\n/**\n * State override mapping for Tenderly simulations.\n * Maps contract addresses to their overridden state (balance, storage, or stateDiff).\n */\nexport type OverrideType = Record<\n string,\n Record<\n string,\n string | Record<string,string>\n >\n>;\n\n/**\n * Shares an existing Tenderly simulation so it can be viewed via a public link.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param tenderlySimulationId - The ID of the simulation to share.\n */\nexport async function shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n tenderlySimulationId: string,\n){\n const tenderlyUrl = \n 'https://api.tenderly.co/api/v1/account/' + tenderlyAccountSlug +\n '/project/' + tenderlyProjectSlug +\n '/simulations/' + tenderlySimulationId +\n '/share';\n \n const headers = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n 'X-Access-Key': tenderlyAccessKey\n };\n \n\tconst requestOptions: RequestInit = {\n\t\tmethod: \"POST\",\n\t\theaders, \n\t\tredirect: \"follow\",\n\t};\n\tconst fetchResult = await fetch(tenderlyUrl, requestOptions);\n\tconst status = fetchResult.status;\n\n\tif (status != 204) {\n\t throw new AbstractionKitError(\n \"BAD_DATA\", \"tenderly share simulation failed.\", {\n context: {\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n tenderlySimulationId,\n status\n },\n });\n\t}\n}\n\n/**\n * Simulates a full UserOperation via Tenderly's handleOps/handleUserOps entry\n * and creates a shareable link.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation result and a shareable dashboard link.\n */\nexport async function simulateUserOperationWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<{\n simulation:SingleTransactionTenderlySimulationResult,\n simulationShareLink: string,\n}> {\n const simulation = await simulateUserOperationWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n userOperation,\n blockNumber,\n stateOverrides\n );\n\n await shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n simulation.simulation.id,\n )\n const simulationShareLink =\n 'https://dashboard.tenderly.co/shared/simulation/' + simulation.simulation.id;\n return {\n simulation,\n simulationShareLink\n }\n}\n\n/**\n * Simulates a full UserOperation via the EntryPoint's handleOps/handleUserOps\n * function on Tenderly. Encodes the UserOperation into the appropriate calldata\n * based on the EntryPoint version.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation result from Tenderly.\n */\nexport async function simulateUserOperationWithTenderly(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<SingleTransactionTenderlySimulationResult> {\n const entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n let callData: string | null = null;\n const abiCoder = AbiCoder.defaultAbiCoder();\n const isV6UserOperation = \"initCode\" in userOperation;\n const isV6Entrypoint =\n entrypointAddressLowerCase == \"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789\";\n\n if (isV6UserOperation !== isV6Entrypoint) {\n throw new RangeError(\"UserOperation version does not match entrypoint.\");\n }\n\n if (isV6UserOperation) {\n userOperation = userOperation as UserOperationV6;\n const useroperationValuesArray = [\n userOperation.sender,\n userOperation.nonce,\n userOperation.initCode,\n userOperation.callData,\n userOperation.callGasLimit,\n userOperation.verificationGasLimit,\n userOperation.preVerificationGas,\n userOperation.maxFeePerGas,\n userOperation.maxPriorityFeePerGas,\n userOperation.paymasterAndData,\n userOperation.signature\n ];\n\n const encodedUserOperation = abiCoder.encode(\n [\n \"(address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[]\",\n \"address\",\n ],\n [\n [useroperationValuesArray],\n \"0x1000000000000000000000000000000000000000\"\n ],\n );\n callData = '0x1fad948c' + encodedUserOperation.slice(2);\n\n }else{\n userOperation = userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9;\n let initCode = \"0x\";\n if (userOperation.factory != null) {\n initCode = userOperation.factory;\n if (userOperation.factoryData != null) {\n initCode += userOperation.factoryData.slice(2);\n }\n }\n\n const accountGasLimits =\n \"0x\" +\n abiCoder\n .encode([\"uint128\"], [userOperation.verificationGasLimit])\n .slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.callGasLimit]).slice(34);\n\n const gasFees =\n \"0x\" +\n abiCoder\n .encode([\"uint128\"], [userOperation.maxPriorityFeePerGas])\n .slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.maxFeePerGas]).slice(34);\n\n let paymasterAndData = \"0x\";\n if (userOperation.paymaster != null) {\n paymasterAndData = userOperation.paymaster;\n if (userOperation.paymasterVerificationGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterVerificationGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterPostOpGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterPostOpGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterData != null) {\n paymasterAndData += userOperation.paymasterData.slice(2);\n }\n }\n\n const useroperationValuesArray = [\n userOperation.sender,\n userOperation.nonce,\n initCode,\n userOperation.callData,\n accountGasLimits,\n userOperation.preVerificationGas,\n gasFees,\n paymasterAndData,\n userOperation.signature\n ];\n\n const encodedUserOperation = abiCoder.encode(\n [\n \"(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)[]\",\n \"address\",\n ],\n [\n [useroperationValuesArray],\n \"0x1000000000000000000000000000000000000000\"\n ],\n );\n\n if(\n entrypointAddressLowerCase == '0x0000000071727de22e5e9d8baf0edac6f37da032' ||\n entrypointAddressLowerCase == '0x4337084d9e255ff0702461cf8895ce9e3b5ff108' ||\n entrypointAddressLowerCase == '0x433709009b8330fda32311df1c2afa402ed8d009'\n ){\n callData = '0x765e827f' + encodedUserOperation.slice(2);\n }else{\n throw new RangeError(\"Invalid entrypoint.\");\n }\n }\n\n // For EIP-7702 userOps (factory == \"0x7702\"), the EntryPoint checks\n // that the sender's code starts with the EIP-7702 delegation prefix\n // (0xef0100). Inject a code state override so the check passes in\n // simulation.\n if (\n !isV6UserOperation &&\n (userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9)\n .factory === \"0x7702\"\n ) {\n const eip7702Auth = (userOperation as UserOperationV8 | UserOperationV9).eip7702Auth;\n if (eip7702Auth != null && eip7702Auth.address != null) {\n const delegationCode =\n \"0xef0100\" + eip7702Auth.address.toLowerCase().replace(\"0x\", \"\");\n const senderLower = userOperation.sender.toLowerCase();\n stateOverrides = stateOverrides\n ? { ...stateOverrides }\n : {};\n stateOverrides[senderLower] = {\n ...(stateOverrides[senderLower] || {}),\n code: delegationCode,\n };\n }\n }\n\n const simulation = await callTenderlySimulateBundle(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n [{\n chainId,\n blockNumber,\n from: \"0x1000000000000000000000000000000000000000\",\n to: entrypointAddress,\n data: callData,\n stateOverrides\n }]\n );\n return simulation[0];\n}\n\n/**\n * Base fields shared by all UserOperation versions for Tenderly simulation.\n * Contains the common fields present in every EntryPoint version.\n */\nexport interface BaseUserOperationToSimulate {\n\t/** The smart account address that sends the UserOperation. */\n\tsender: string;\n\t/** The encoded call data to execute on the account. */\n\tcallData: string;\n\t/** The account nonce. */\n\tnonce: any;\n\t/** The gas limit for the main execution call. */\n\tcallGasLimit: any;\n\t/** The gas limit for the verification step. */\n\tverificationGasLimit: any;\n\t/** The gas overhead to compensate the bundler. */\n\tpreVerificationGas: any;\n\t/** The maximum fee per gas (EIP-1559). */\n\tmaxFeePerGas: any;\n\t/** The maximum priority fee per gas (EIP-1559). */\n\tmaxPriorityFeePerGas: any;\n\t/** The UserOperation signature. */\n\tsignature: any;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.6.\n * Uses the combined `initCode` and `paymasterAndData` fields.\n */\nexport interface UserOperationV6ToSimulate extends BaseUserOperationToSimulate {\n\t/** The concatenated factory address and factory data, or null if already deployed. */\n\tinitCode: string | null;\n\t/** The concatenated paymaster address and paymaster-specific data. */\n\tpaymasterAndData: any;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.7.\n * Uses separate factory/paymaster fields instead of combined byte arrays.\n */\nexport interface UserOperationV7ToSimulate extends BaseUserOperationToSimulate {\n\t/** The factory contract address, or null if already deployed. */\n\tfactory: string | null;\n\t/** The factory-specific initialization data, or null if already deployed. */\n\tfactoryData: string | null;\n\t/** The paymaster contract address. */\n\tpaymaster: any;\n\t/** The gas limit for paymaster verification. */\n\tpaymasterVerificationGasLimit: any;\n\t/** The gas limit for paymaster postOp execution. */\n\tpaymasterPostOpGasLimit: any;\n\t/** The paymaster-specific data. */\n\tpaymasterData: any;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.8.\n * Extends the v0.7 structure with an additional `eip7702Auth` field for\n * EIP-7702 delegation support.\n */\nexport interface UserOperationV8ToSimulate extends BaseUserOperationToSimulate {\n\t/** The factory contract address, or null if already deployed. */\n\tfactory: string | null;\n\t/** The factory-specific initialization data, or null if already deployed. */\n\tfactoryData: string | null;\n\t/** The paymaster contract address. */\n\tpaymaster: any;\n\t/** The gas limit for paymaster verification. */\n\tpaymasterVerificationGasLimit: any;\n\t/** The gas limit for paymaster postOp execution. */\n\tpaymasterPostOpGasLimit: any;\n\t/** The paymaster-specific data. */\n\tpaymasterData: any;\n\t/** The EIP-7702 delegation authorization data. */\n eip7702Auth: any;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.9.\n */\nexport interface UserOperationV9ToSimulate extends UserOperationV8ToSimulate {}\n\n/**\n * Simulates a UserOperation's callData (and optional account deployment) on\n * Tenderly, then creates shareable links for each simulation.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8 format).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation results and shareable dashboard links.\n */\nexport async function simulateUserOperationCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6ToSimulate | UserOperationV7ToSimulate | UserOperationV8ToSimulate | UserOperationV9ToSimulate,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null,\n): Promise<{\n simulation:TenderlySimulationResult,\n callDataSimulationShareLink: string,\n accountDeploymentSimulationShareLink?: string,\n}> {\n const simulation = await simulateUserOperationCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n userOperation,\n blockNumber,\n stateOverrides\n );\n const simulationIds = simulation.map(s => s.simulation.id) as string[];\n await Promise.all(simulationIds.map(simulationId =>\n shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n simulationId,\n )\n ));\n \n const simulationLinks = simulationIds.map(\n s => 'https://dashboard.tenderly.co/shared/simulation/' + s );\n if (simulationLinks.length == 1){\n return {\n simulation,\n callDataSimulationShareLink: simulationLinks[0]\n };\n }else if (simulationLinks.length == 2){\n return {\n simulation,\n accountDeploymentSimulationShareLink: simulationLinks[0],\n callDataSimulationShareLink: simulationLinks[1]\n };\n }else{\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"invalid number of simulations retuned\",\n {\n context: JSON.stringify(\n simulation,\n (_key, value) =>\n typeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n ),\n },\n );\n } \n}\n\n/**\n * Simulates a UserOperation's callData on Tenderly by extracting the sender,\n * callData, and factory info, then delegating to {@link simulateSenderCallDataWithTenderly}.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8 format).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The Tenderly simulation results.\n */\nexport async function simulateUserOperationCallDataWithTenderly(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6ToSimulate | UserOperationV7ToSimulate | UserOperationV8ToSimulate | UserOperationV9ToSimulate,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null,\n) : Promise<TenderlySimulationResult> {\n let factory = null;\n let factoryData = null;\n const entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n const isV6UserOperation = \"initCode\" in userOperation;\n const isV6Entrypoint =\n entrypointAddressLowerCase == \"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789\";\n\n if (isV6UserOperation !== isV6Entrypoint) {\n throw new RangeError(\"UserOperation version does not match entrypoint.\");\n }\n\n let callData = userOperation.callData;\n\tif (\"initCode\" in userOperation) {\n if(userOperation.initCode != null && userOperation.initCode.length > 2){\n factory = userOperation.initCode.slice(0,22);\n factoryData = userOperation.initCode.slice(22);\n }\n }else{\n factory = userOperation.factory;\n factoryData = userOperation.factoryData;\n\n // EIP-7702 userOps use factory:\"0x7702\" as a sentinel with\n // factoryData:null. This doesn't represent an actual factory\n // deployment, so normalize to null.\n if (factory === \"0x7702\") {\n factory = null;\n factoryData = null;\n }\n\n // Handle IAccountExecute.executeUserOp callData rewriting.\n // When callData starts with the executeUserOp selector (0x8dd7712f),\n // the EntryPoint rewrites the call to\n // sender.executeUserOp(packedUserOp, userOpHash) instead of\n // sender.call(callData). Replicate that behavior here.\n const EXECUTE_USEROP_SELECTOR = \"0x8dd7712f\";\n if (callData.toLowerCase().startsWith(EXECUTE_USEROP_SELECTOR)) {\n const abiCoder = AbiCoder.defaultAbiCoder();\n\n let initCode = \"0x\";\n if (userOperation.factory != null) {\n initCode = userOperation.factory;\n if (userOperation.factoryData != null) {\n initCode += userOperation.factoryData.slice(2);\n }\n }\n\n const accountGasLimits =\n \"0x\" +\n abiCoder.encode([\"uint128\"], [userOperation.verificationGasLimit]).slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.callGasLimit]).slice(34);\n\n const gasFees =\n \"0x\" +\n abiCoder.encode([\"uint128\"], [userOperation.maxPriorityFeePerGas]).slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.maxFeePerGas]).slice(34);\n\n let paymasterAndData = \"0x\";\n if (userOperation.paymaster != null) {\n paymasterAndData = userOperation.paymaster;\n if (userOperation.paymasterVerificationGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterVerificationGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterPostOpGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterPostOpGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterData != null) {\n paymasterAndData += userOperation.paymasterData.slice(2);\n }\n }\n\n const userOpHash = createUserOperationHash(\n userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9,\n entrypointAddress,\n chainId,\n );\n\n const packedUserOp = [\n userOperation.sender,\n userOperation.nonce,\n initCode,\n userOperation.callData,\n accountGasLimits,\n userOperation.preVerificationGas,\n gasFees,\n paymasterAndData,\n userOperation.signature,\n ];\n\n const encodedParams = abiCoder.encode(\n [\"(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)\", \"bytes32\"],\n [packedUserOp, userOpHash],\n );\n callData = EXECUTE_USEROP_SELECTOR + encodedParams.slice(2);\n }\n }\n\n return await simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n userOperation.sender,\n callData,\n factory,\n factoryData,\n blockNumber,\n stateOverrides\n )\n}\n\n/**\n * Simulates the sender's callData (and optional account deployment) on Tenderly,\n * then creates shareable links for each simulation.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param sender - The smart account address.\n * @param callData - The encoded call data to simulate.\n * @param factory - The factory contract address, or null if already deployed.\n * @param factoryData - The factory initialization data, or null if already deployed.\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation results and shareable dashboard links.\n */\nexport async function simulateSenderCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n sender: string,\n callData: string,\n factory: string | null = null,\n\tfactoryData: string | null = null,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<{\n simulation:TenderlySimulationResult,\n callDataSimulationShareLink: string,\n accountDeploymentSimulationShareLink?: string,\n}> {\n const simulation = await simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n sender,\n callData,\n factory,\n factoryData,\n blockNumber,\n stateOverrides\n );\n const simulationIds = simulation.map(s => s.simulation.id) as string[];\n await Promise.all(simulationIds.map(simulationId =>\n shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n simulationId,\n )\n ));\n \n const simulationLinks = simulationIds.map(\n s => 'https://dashboard.tenderly.co/shared/simulation/' + s );\n if (simulationLinks.length == 1){\n return {\n simulation,\n callDataSimulationShareLink: simulationLinks[0]\n };\n }else if (simulationLinks.length == 2){\n return {\n simulation,\n accountDeploymentSimulationShareLink: simulationLinks[0],\n callDataSimulationShareLink: simulationLinks[1]\n };\n }else{\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"invalid number of simulations retuned\",\n {\n context: JSON.stringify(\n simulation,\n (_key, value) =>\n typeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n ),\n },\n );\n } \n}\n\n/**\n * Simulates the sender's callData on Tenderly. If factory and factoryData are\n * provided, simulates account deployment first, then the callData execution.\n * Uses the appropriate SenderCreator address based on the EntryPoint version.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param sender - The smart account address.\n * @param callData - The encoded call data to simulate.\n * @param factory - The factory contract address, or null if already deployed.\n * @param factoryData - The factory initialization data, or null if already deployed.\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The Tenderly simulation results (one or two entries depending on deployment).\n */\nexport async function simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n sender: string,\n callData: string,\n factory: string | null = null,\n\tfactoryData: string | null = null,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<TenderlySimulationResult> {\n const transactions = [];\n const entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n let senderCreator:string;\n if(\n entrypointAddressLowerCase == '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789'\n ){\n senderCreator = \"0x7fc98430eaedbb6070b35b39d798725049088348\";\n }else if(\n entrypointAddressLowerCase == '0x0000000071727de22e5e9d8baf0edac6f37da032'\n ){\n senderCreator = \"0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c\";\n }else if(\n entrypointAddressLowerCase == '0x4337084d9e255ff0702461cf8895ce9e3b5ff108'\n ){\n senderCreator = \"0x449ed7c3e6fee6a97311d4b55475df59c44add33\";\n }else if(\n entrypointAddressLowerCase == '0x433709009b8330fda32311df1c2afa402ed8d009'\n ){\n senderCreator = \"0x0A630a99Df908A81115A3022927Be82f9299987e\";\n }else{\n throw new RangeError(`Invalid entrypoint: ${entrypointAddress}`);\n }\n \n if(\n (factory == null && factoryData != null) ||\n (factory != null && factoryData == null)\n ){\n throw new RangeError(`Invalid factory and factoryData`);\n }\n if(factory != null && factoryData != null){ \n transactions.push({\n chainId,\n blockNumber,\n from: senderCreator,\n to: factory,\n data: factoryData,\n stateOverrides\n })\n }\n transactions.push({\n chainId,\n blockNumber,\n from: entrypointAddress,\n to: sender,\n data: callData,\n stateOverrides\n })\n const simulationsResult = await callTenderlySimulateBundle(\n tenderlyAccountSlug, tenderlyProjectSlug, tenderlyAccessKey, transactions);\n \n for (const simulationResult of simulationsResult) {\n if(simulationResult.simulation.id == \"\"){\n throw new AbstractionKitError(\n \"TENDERLY_SIMULATION_ERROR\",\n \"tenderly simulation failed\",\n {\n context: JSON.stringify(\n simulationsResult,\n (_key, value) =>\n typeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n ),\n },\n );\n }\n }\n return simulationsResult;\n}\n\n\n/**\n * Sends a bundle of transactions to Tenderly's simulate-bundle API endpoint.\n * This is the low-level function that all other Tenderly simulation functions delegate to.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param transactions - Array of transaction objects to simulate as a bundle.\n * @returns The simulation results from Tenderly.\n */\nexport async function callTenderlySimulateBundle(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n transactions:{\n chainId: bigint,\n from: string,\n to: string,\n data: string,\n gas?: number | null,\n gasPrice?: number | null,\n value?: number | null,\n blockNumber?: number | null,\n simulationType?: 'full' | 'quick' | 'abi'\n stateOverrides?: OverrideType | null,\n transactionIndex?: number,\n save?: boolean,\n saveIfFails?: boolean,\n estimateGas?: boolean,\n generateAccessList?: boolean,\n accessList?: {address: string}[]\n }[], \n): Promise<TenderlySimulationResult> {\n const tenderlyUrl = \n 'https://api.tenderly.co/api/v1/account/' + tenderlyAccountSlug +\n '/project/' + tenderlyProjectSlug + '/simulate-bundle';\n const simulations =\n transactions.map(transaction=>{\n const transactionObject: Record<string,\n string | number | boolean |\n OverrideType |\n {address: string}[]\n > = {\n network_id: transaction.chainId.toString(),\n save: transaction.save?? true,\n save_if_fails:transaction.saveIfFails?? true,\n from: transaction.from,\n to: transaction.to,\n input: transaction.data,\n simulation_type: transaction.simulationType??'full',\n }\n if (transaction.blockNumber != null){\n transactionObject[\"block_number\"] = transaction.blockNumber;\n }\n\n if (transaction.gas != null){\n transactionObject[\"gas\"] = transaction.gas;\n }\n if (transaction.gasPrice != null){\n transactionObject[\"gas_price\"] = transaction.gasPrice;\n }\n if (transaction.value != null){\n transactionObject[\"value\"] = transaction.value;\n }\n if (transaction.stateOverrides != null){\n const stateOverrides = transaction.stateOverrides;\n for (const address in stateOverrides) {\n for (const key in stateOverrides[address]) {\n if(key != 'balance' && key != 'code' && key != 'storage' && key != 'stateDiff'){\n throw new RangeError(\n `Invalide stateOverrides key: ${key}.`\n );\n }else if(\n 'storage' in stateOverrides[address] &&\n 'stateDiff' in stateOverrides[address]\n ){\n throw new RangeError(\n \"can't set both storage and stateDiff for stateOverrides\"\n );\n }else if('stateDiff' in stateOverrides[address]){\n stateOverrides[address][\"storage\"] = stateOverrides[address][\"stateDiff\"];\n delete stateOverrides[address][\"stateDiff\"];\n }\n }\n }\n transactionObject[\"state_objects\"] = stateOverrides;\n }\n \n if (transaction.transactionIndex != null){\n transactionObject[\"transaction_index\"] = transaction.transactionIndex;\n }\n if (transaction.estimateGas != null){\n transactionObject[\"estimate_gas\"] = transaction.estimateGas;\n }\n if (transaction.generateAccessList != null){\n transactionObject[\"generate_access_list\"] =\n transaction.generateAccessList;\n }\n if (transaction.accessList != null){\n transactionObject[\"access_list\"] = transaction.accessList;\n }\n return transactionObject;\n }\n ) \n \n const headers = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n 'X-Access-Key': tenderlyAccessKey\n };\n return await sendJsonRpcRequest(\n tenderlyUrl,\n \"tenderly_simulateBundle\",\n simulations,\n headers,\n \"simulations\"\n ) as TenderlySimulationResult;\n}\n","import type { GasOption, StateOverrideSet, PolygonChain, OnChainIdentifierParamsType, MetaTransaction, UserOperationV9, ParallelPaymasterInitValues } from \"../../types\";\n\n/**\n * Overrides for the \"createBaseUserOperationAndFactoryAddressAndFactoryData\" function\n */\nexport interface CreateBaseUserOperationOverrides {\n\t/** set the nonce instead of quering the current nonce from the rpc node */\n\tnonce?: bigint;\n\t/** set the callData instead of using the encoding of the provided Metatransactions*/\n\tcallData?: string;\n\t/** set the callGasLimit instead of estimating gas using the bundler*/\n\tcallGasLimit?: bigint;\n\t/** set the verificationGasLimit instead of estimating gas using the bundler*/\n\tverificationGasLimit?: bigint;\n\t/** set the preVerificationGas instead of estimating gas using the bundler*/\n\tpreVerificationGas?: bigint;\n\t/** set the maxFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxFeePerGas?: bigint;\n\t/** set the maxPriorityFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGas?: bigint;\n\n\t/** set the callGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tcallGasLimitPercentageMultiplier?: number;\n\t/** set the verificationGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tverificationGasLimitPercentageMultiplier?: number;\n\t/** set the preVerificationGasPercentageMultiplier instead of estimating gas using the bundler*/\n\tpreVerificationGasPercentageMultiplier?: number;\n\t/** set the maxFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** set the maxPriorityFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGasPercentageMultiplier?: number;\n\n\t/** pass some state overrides for gas estimation\"*/\n\tstate_override_set?: StateOverrideSet;\n\n\tdummySignerSignaturePairs?: SignerSignaturePair[];\n\n\twebAuthnSharedSigner?: string;\n\twebAuthnSignerFactory?: string;\n\twebAuthnSignerSingleton?: string;\n\twebAuthnSignerProxyCreationCode?: string;\n\n\teip7212WebAuthnPrecompileVerifier?: string;\n\teip7212WebAuthnContractVerifier?: string;\n\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\tmultisendContractAddress?: string;\n\n\tgasLevel?: GasOption;\n\tpolygonGasStation?: PolygonChain;\n\n expectedSigners?: Signer[];\n\tisMultiChainSignature?: boolean;\n\n\tparallelPaymasterInitValues?: {\n\t\t/** set the paymaster contract address */\n\t\tpaymaster: string;\n\t\t/** set the paymaster verification gas limit */\n\t\tpaymasterVerificationGasLimit: bigint;\n\t\t/** set the paymaster post-operation gas limit */\n\t\tpaymasterPostOpGasLimit: bigint;\n\t\t/** set the paymaster data, only valid value is 0x22e325a297439656 */\n\t\tpaymasterData: string;\n\t}\n}\n\n/**\n * Overrides for the \"createUserOperation\" function\n */\nexport interface CreateUserOperationV6Overrides\n\textends CreateBaseUserOperationOverrides {\n\t/** set the initCode instead of using the calculated value */\n\tinitCode?: string;\n}\n\n/**\n * Overrides for the \"createUserOperation\" function\n */\nexport interface CreateUserOperationV7Overrides\n\textends CreateBaseUserOperationOverrides {\n\t/** set the factory address instead of using the calculated value */\n\tfactory?: string;\n\t/** set the factory data instead of using the calculated value */\n\tfactoryData?: string;\n}\n\nexport interface CreateUserOperationV9Overrides extends CreateUserOperationV7Overrides{}\n\n/** Safe singleton contract address and init hash for deterministic deployment. */\nexport interface SafeAccountSingleton {\n\t/** The address of the Safe singleton contract */\n\tsingletonAddress: string;\n\t/** The init code hash used for CREATE2 address computation */\n\tsingletonInitHash: string;\n}\n\n/**\n * Overrides for initilizing a new Safe account\n */\nexport interface InitCodeOverrides {\n\t/** signature threshold\n\t * @defaultValue 1\n\t */\n\tthreshold?: number;\n\t/** create2 nonce - to generate different sender addresses from the same owners\n\t * @defaultValue 0\n\t */\n\tc2Nonce?: bigint;\n\tsafe4337ModuleAddress?: string;\n\tsafeModuleSetupAddress?: string;\n\n\tentrypointAddress?: string;\n\t/** Safe contract singleton address\n\t */\n\tsafeAccountSingleton?: SafeAccountSingleton;\n\t/** Safe Factory address\n\t */\n\tsafeAccountFactoryAddress?: string;\n\t/** Safe 4337 module address\n\t */\n\tmultisendContractAddress?: string;\n\twebAuthnSharedSigner?: string;\n\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string;\n}\n\nexport interface BaseInitOverrides {\n\t/** signature threshold\n\t * @defaultValue 1\n\t */\n\tthreshold?: number;\n\t/** create2 nonce - to generate different sender addresses from the same owners\n\t * @defaultValue 0\n\t */\n\tc2Nonce?: bigint;\n\n\tsafeAccountSingleton?: SafeAccountSingleton;\n\t/** Safe Factory address\n\t */\n\tsafeAccountFactoryAddress?: string;\n\t/** Safe 4337 module address\n\t */\n\tmultisendContractAddress?: string;\n\twebAuthnSharedSigner?: string;\n\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n}\n\n/** Overrides for WebAuthn signature creation and verification. */\nexport interface WebAuthnSignatureOverrides {\n\tisInit?: boolean;\n\twebAuthnSharedSigner?: string;\n\teip7212WebAuthnPrecompileVerifier?: string;\n\teip7212WebAuthnContractVerifier?: string;\n\twebAuthnSignerFactory?: string;\n\twebAuthnSignerSingleton?: string;\n\twebAuthnSignerProxyCreationCode?: string;\n\tvalidAfter?: bigint;\n\tvalidUntil?: bigint;\n\tisMultiChainSignature?: boolean;\n\tmultiChainMerkleProof?: string;\n\tsafe4337ModuleAddress?: string;\n}\n\n/**\n * Safe has two executor functions \"executeUserOpWithErrorString\" and \"executeUserOp\"\n */\nexport enum SafeModuleExecutorFunctionSelector {\n\texecuteUserOpWithErrorString = \"0x541d63c8\",\n\texecuteUserOp = \"0x7bb37428\",\n}\n\n/** EIP-712 domain for Safe UserOperation signing. */\nexport interface SafeUserOperationTypedDataDomain {\n\t/** Target chain ID to prevent cross-chain replay */\n\tchainId: number;\n\t/** Address of the Safe 4337 module contract */\n\tverifyingContract: string;\n}\n\n/** EIP-712 typed data values for a Safe UserOperation (EntryPoint v0.6). */\nexport interface SafeUserOperationV6TypedMessageValue {\n\t/** The Safe account address */\n\tsafe: string;\n\t/** The UserOperation nonce */\n\tnonce: bigint;\n\t/** Packed factory address and init data for account deployment */\n\tinitCode: string;\n\t/** Encoded call data for the account to execute */\n\tcallData: string;\n\t/** Gas limit for the main execution call */\n\tcallGasLimit: bigint;\n\t/** Gas limit for the verification step */\n\tverificationGasLimit: bigint;\n\t/** Gas overhead to compensate for pre-verification execution */\n\tpreVerificationGas: bigint;\n\t/** Maximum fee per gas unit */\n\tmaxFeePerGas: bigint;\n\t/** Maximum priority fee (tip) per gas unit */\n\tmaxPriorityFeePerGas: bigint;\n\t/** Packed paymaster address and data */\n\tpaymasterAndData: string;\n\t/** Unix timestamp after which the signature becomes valid */\n\tvalidAfter: bigint;\n\t/** Unix timestamp after which the signature expires */\n\tvalidUntil: bigint;\n\t/** EntryPoint contract address */\n\tentryPoint: string;\n}\n\n/** EIP-712 typed data values for a Safe UserOperation (EntryPoint v0.7). Note: field order differs from v0.6. */\nexport interface SafeUserOperationV7TypedMessageValue {\n\t/** The Safe account address */\n\tsafe: string;\n\t/** The UserOperation nonce */\n\tnonce: bigint;\n\t/** Packed factory address and init data for account deployment */\n\tinitCode: string;\n\t/** Encoded call data for the account to execute */\n\tcallData: string;\n\t/** Gas limit for the verification step */\n\tverificationGasLimit: bigint;\n\t/** Gas limit for the main execution call */\n\tcallGasLimit: bigint;\n\t/** Gas overhead to compensate for pre-verification execution */\n\tpreVerificationGas: bigint;\n\t/** Maximum priority fee (tip) per gas unit */\n\tmaxPriorityFeePerGas: bigint;\n\t/** Maximum fee per gas unit */\n\tmaxFeePerGas: bigint;\n\t/** Packed paymaster address and data */\n\tpaymasterAndData: string;\n\t/** Unix timestamp after which the signature becomes valid */\n\tvalidAfter: bigint;\n\t/** Unix timestamp after which the signature expires */\n\tvalidUntil: bigint;\n\t/** EntryPoint contract address */\n\tentryPoint: string;\n}\n\n/** EIP-712 typed data values for a Safe UserOperation (EntryPoint v0.9). */\nexport interface SafeUserOperationV9TypedMessageValue extends SafeUserOperationV7TypedMessageValue{\n}\n\n/** An Ethereum address string representing an ECDSA signer. */\nexport type ECDSAPublicAddress = string;\n\n/** WebAuthn/Passkey public key with x,y coordinates on the P-256 curve. */\nexport interface WebauthnPublicKey {\n\t/** X coordinate of the public key */\n\tx: bigint;\n\t/** Y coordinate of the public key */\n\ty: bigint;\n}\n\n/** A signer can be either an ECDSA address or a WebAuthn public key. */\nexport type Signer = ECDSAPublicAddress | WebauthnPublicKey;\n\nexport type ECDSASignature = string;\n\nexport interface WebauthnSignatureData {\n\tauthenticatorData: ArrayBuffer;\n\tclientDataFields: string;\n\trs: [bigint, bigint];\n}\n\n/** A pair of signer identity and their signature. */\nexport interface SignerSignaturePair {\n\t/** The signer (ECDSA address or WebAuthn key) */\n\tsigner: Signer;\n\t/** The signature hex string */\n\tsignature: string;\n\t/** Whether this is a contract signature (EIP-1271) */\n\tisContractSignature?: boolean;\n}\n\n/** Dummy signer-signature pair for gas estimation with EOA signers. */\nexport const EOADummySignerSignaturePair: SignerSignaturePair = {\n\tsigner: \"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9\",\n\tsignature:\n \"0x47003599ffa7e9198f321afa774e34a12a959844efd6363b88896e9c24ed33cf4e1be876ef123a3c4467e7d451511434039539699f2baa2f44955fa3d1c1c6d81c\",\n\tisContractSignature: false,\n};\n\n/** Dummy signer-signature pair for gas estimation with WebAuthn signers. */\nexport const WebauthnDummySignerSignaturePair: SignerSignaturePair = {\n\tsigner: \"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9\",\n\tsignature:\n\t\t\"0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e06c92f0ac5c4ef9e74721c23d80a9fc12f259ca84afb160f0890483539b9e6080d824c0e6c795157ad5d1ee5eff1ceeb3031009a595f9360919b83dd411c5a78d0000000000000000000000000000000000000000000000000000000000000025a24f744b28d73f066bf3203d145765a7bc735e6328168c8b03e476da3ad0d8fe0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e226f726967696e223a2268747470733a2f2f736166652e676c6f62616c220000\",\n\tisContractSignature: true,\n};\n\n/** A UserOperation with chain context ready for signing. */\nexport interface UserOperationToSign {\n chainId: bigint,\n userOperation: UserOperationV9,\n validAfter?: bigint;\n validUntil?: bigint;\n}\n\n/** EIP-712 domain for multi-chain signature Merkle tree root. */\nexport interface MultiChainSignatureMerkleTreeRootTypedDataDomain {\n\tverifyingContract: string;\n}\n\n/** EIP-712 typed message value containing a Merkle tree root for multi-chain signatures. */\nexport interface MultiChainSignatureMerkleTreeRootTypedMessageValue {\n\tmerkleTreeRoot: string;\n}\n","import { AbiCoder, getBytes, solidityPacked } from \"ethers\";\nimport { MetaTransaction, Operation } from \"src/types\";\n\n/**\n * Encodes a Metatransaction to be executed by Safe contract\n * @param metaTransaction - metatransaction to be encoded\n * @returns The encoded metatransaction\n */\nfunction encodeMultiSendTransaction(metaTransaction: MetaTransaction): string {\n\tconst operation = metaTransaction.operation ?? Operation.Call;\n\n\tconst data = getBytes(metaTransaction.data);\n\tconst encoded = solidityPacked(\n\t\t[\"uint8\", \"address\", \"uint256\", \"uint256\", \"bytes\"],\n\t\t[operation, metaTransaction.to, metaTransaction.value, data.length, data],\n\t);\n\treturn encoded.slice(2);\n}\n\n/**\n * Encodes a Metatransaction list to be batch executed by Safe contract\n * @param metaTransactions - metatransaction list to be encoded\n * @returns The encoded metatransaction\n */\nexport function encodeMultiSendCallData(\n\tmetaTransactions: MetaTransaction[],\n): string {\n\treturn (\n\t\t\"0x\" + metaTransactions.map((tx) => encodeMultiSendTransaction(tx)).join(\"\")\n\t);\n}\n\n/**\n * Decodes a MultiSend callData back into its packed transaction bytes.\n * Strips the function selector and ABI-decodes the inner bytes payload.\n * @param callData - The full MultiSend callData (with 0x prefix and function selector).\n * @returns The decoded packed transaction bytes as a hex string.\n */\nexport function decodeMultiSendCallData(callData: string): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\tconst decodedCalldata = abiCoder.decode([\"bytes\"], \"0x\" + callData.slice(10));\n\treturn decodedCalldata[0] as string;\n}\n","import type { AbiInputValue } from \"../types\";\nimport { createCallData } from \"../utils\";\n\n/**\n * Generic factory for deploying smart account proxy contracts.\n * Encodes the factory address and createProxyWithNonce calldata into\n * the `initCode` field of a UserOperation.\n */\nexport class SmartAccountFactory {\n\t/** On-chain address of the factory contract */\n\treadonly address: string;\n\t/** 4-byte function selector for the factory's proxy creation method */\n\treadonly generatorFunctionSelector: string;\n\t/** ABI types for the proxy creation function parameters */\n\treadonly generatorFunctionInputAbi: string[];\n\n\t/**\n\t * @param address - On-chain address of the factory contract\n\t * @param generatorFunctionSelector - 4-byte hex selector for the proxy creation function\n\t * @param generatorFunctionInputAbi - ABI type strings for the proxy creation function parameters\n\t */\n\tconstructor(\n\t\taddress: string,\n\t\tgeneratorFunctionSelector: string,\n\t\tgeneratorFunctionInputAbi: string[],\n\t) {\n\t\tthis.address = address;\n\t\tthis.generatorFunctionSelector = generatorFunctionSelector;\n\t\tthis.generatorFunctionInputAbi = generatorFunctionInputAbi;\n\t}\n\n\t/**\n\t * Encode the factory function calldata for deploying a new account proxy.\n\t *\n\t * @param generatorFunctionInputParameters - Values to ABI-encode as the factory function parameters\n\t * @returns ABI-encoded calldata as a hex string\n\t */\n\tgetFactoryGeneratorFunctionCallData(\n\t\tgeneratorFunctionInputParameters: AbiInputValue[],\n\t): string {\n\t\tconst callData = createCallData(\n\t\t\tthis.generatorFunctionSelector,\n\t\t\tthis.generatorFunctionInputAbi,\n\t\t\tgeneratorFunctionInputParameters,\n\t\t);\n\t\t//const res: string = this.address + callData.slice(2);\n\n\t\treturn callData;\n\t}\n}\n","import { SmartAccountFactory } from \"./SmartAccountFactory\";\n/**\n * Factory for deploying Safe proxy contracts via `createProxyWithNonce`.\n * Pre-configured with the Safe proxy factory's function selector and ABI.\n */\nexport class SafeAccountFactory extends SmartAccountFactory {\n\t/** Default Safe proxy factory contract address */\n\tstatic readonly DEFAULT_FACTORY_ADDRESS =\n\t\t\"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67\";\n\t/**\n\t * @param address - Safe proxy factory contract address\n\t * @defaultValue \"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67\"\n\t */\n\tconstructor(address: string = SafeAccountFactory.DEFAULT_FACTORY_ADDRESS) {\n\t\tconst generatorFunctionSelector = \"0x1688f0b9\"; //createProxyWithNonce\n\t\tconst generatorFunctionInputAbi = [\n\t\t\t\"address\", //_singleton\n\t\t\t\"bytes\", //initializer\n\t\t\t\"uint256\", //saltNonce\n\t\t];\n\t\tsuper(address, generatorFunctionSelector, generatorFunctionInputAbi);\n\t}\n}\n","import { hashMessage } from \"ethers\";\n\n/** The primary EIP-712 type name used for Safe message signing. */\nexport const SAFE_MESSAGE_PRIMARY_TYPE = \"SafeMessage\";\n\n/** EIP-712 type definition for SafeMessage, containing a single bytes field. */\nexport const SAFE_MESSAGE_MODULE_TYPE = {\n SafeMessage: [\n { type: \"bytes\", name: \"message\" },\n ],\n};\n\n/** EIP-712 domain for Safe message signing, scoped to a chain and account. */\nexport type SafeMessageTypedDataDomain = {\n\t/** Target chain ID to prevent cross-chain replay */\n\tchainId: number;\n\t/** The Safe account address that will verify the signature */\n\tverifyingContract: string;\n}\n\n/** EIP-712 typed message value containing the hashed message bytes. */\nexport type SafeMessageTypedMessageValue = {\n\t/** The EIP-191 hash of the original message */\n\tmessage: string;\n}\n\n/**\n * Create EIP-712 signing data for a Safe message.\n * @param accountAddress - the Safe account address\n * @param chainId - target chain id\n * @param message - the message string to sign\n * @returns an object with domain, types, and messageValue for EIP-712 signing\n */\nexport function getSafeMessageEip712Data(\n accountAddress: string,\n chainId: bigint,\n message: string\n): {\n domain: SafeMessageTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeMessageTypedMessageValue\n} {\n const messageValue: SafeMessageTypedMessageValue = {\n message: hashMessage(message)\n };\n const domain: SafeMessageTypedDataDomain = {\n chainId: Number(chainId),\n verifyingContract: accountAddress\n };\n\n return {\n domain,\n types: SAFE_MESSAGE_MODULE_TYPE,\n messageValue,\n };\n}\n","import {\n\tWallet,\n\tAbiCoder,\n\tTypedDataEncoder,\n\tkeccak256,\n\tsolidityPacked,\n\tsolidityPackedKeccak256,\n\tethers,\n getAddress\n} from \"ethers\";\nimport { SmartAccount } from \"../SmartAccount\";\nimport {\n\tBaseUserOperationDummyValues,\n\tZeroAddress,\n\tSafe_L2_V1_4_1,\n\tENTRYPOINT_V6,\n\tENTRYPOINT_V7,\n\tEIP712_SAFE_OPERATION_V7_TYPE,\n\tEIP712_SAFE_OPERATION_V6_TYPE,\n ENTRYPOINT_V9,\n} from \"../../constants\";\nimport {\n\tMetaTransaction,\n\tOperation,\n\tStateOverrideSet,\n\tBaseUserOperation,\n\tUserOperationV6,\n\tUserOperationV7,\n GasOption,\n PolygonChain,\n OnChainIdentifierParamsType,\n TenderlySimulationResult,\n UserOperationV9,\n} from \"../../types\";\nimport {\n\tcreateCallData,\n\tgetFunctionSelector,\n\tfetchAccountNonce,\n\tsendEthCallRequest,\n\tsendEthGetCodeRequest,\n handlefetchGasPrice,\n} from \"../../utils\";\n\nimport {\n simulateSenderCallDataWithTenderly,\n simulateSenderCallDataWithTenderlyAndCreateShareLink\n} from \"../../utilsTenderly\";\n\nimport {\n\tCreateBaseUserOperationOverrides,\n\tSigner,\n\tSafeUserOperationTypedDataDomain,\n\tSafeUserOperationV6TypedMessageValue,\n\tSafeUserOperationV7TypedMessageValue,\n\tSignerSignaturePair,\n\tWebauthnSignatureData,\n\tSafeModuleExecutorFunctionSelector,\n\tEOADummySignerSignaturePair,\n\tWebAuthnSignatureOverrides,\n\tBaseInitOverrides,\n WebauthnDummySignerSignaturePair,\n WebauthnPublicKey,\n SafeAccountSingleton,\n} from \"./types\";\nimport { decodeMultiSendCallData, encodeMultiSendCallData } from \"./multisend\";\nimport { AbstractionKitError, ensureError } from \"src/errors\";\nimport { Bundler } from \"src/Bundler\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\nimport { SafeAccountFactory } from \"src/factory/SafeAccountFactory\";\nimport { getSafeMessageEip712Data, SafeMessageTypedDataDomain, SafeMessageTypedMessageValue } from \"./safeMessage\";\n\nexport class SafeAccount extends SmartAccount {\n\tstatic readonly DEFAULT_WEB_AUTHN_SHARED_SIGNER: string =\n\t\t\"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9\";\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_SINGLETON: string =\n\t\t\"0x270D7E4a57E6322f336261f3EaE2BADe72E68d72\";\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_FACTORY: string =\n\t\t\"0xF7488fFbe67327ac9f37D5F722d83Fc900852Fbf\";\n\tstatic readonly DEFAULT_WEB_AUTHN_FCLP256_VERIFIER: string =\n\t\t\"0x445a0683e494ea0c5AF3E83c5159fBE47Cf9e765\";\n\tstatic readonly DEFAULT_WEB_AUTHN_PRECOMPILE: string =\n\t\t\"0x0000000000000000000000000000000000000000\"; //zero address means no precompile\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE: string =\n\t\t\"0x61010060405234801561001157600080fd5b506040516101ee3803806101ee83398101604081905261003091610058565b6001600160a01b0390931660805260a09190915260c0526001600160b01b031660e0526100bc565b6000806000806080858703121561006e57600080fd5b84516001600160a01b038116811461008557600080fd5b60208601516040870151606088015192965090945092506001600160b01b03811681146100b157600080fd5b939692955090935050565b60805160a05160c05160e05160ff6100ef60003960006008015260006031015260006059015260006080015260ff6000f3fe608060408190527f00000000000000000000000000000000000000000000000000000000000000003660b681018290527f000000000000000000000000000000000000000000000000000000000000000060a082018190527f00000000000000000000000000000000000000000000000000000000000000008285018190527f00000000000000000000000000000000000000000000000000000000000000009490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033\";\n\n\tstatic readonly DEFAULT_MULTISEND_CONTRACT_ADDRESS =\n\t\t\"0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526\";\n\n\tstatic readonly initializerFunctionSelector: string = \"0xb63e800d\";\n\tstatic readonly initializerFunctionInputAbi: string[] = [\n\t\t\"address[]\",\n\t\t\"uint256\",\n\t\t\"address\",\n\t\t\"bytes\",\n\t\t\"address\",\n\t\t\"address\",\n\t\t\"uint256\",\n\t\t\"address\",\n\t];\n\n\tstatic readonly DEFAULT_EXECUTOR_FUCNTION_SELECTOR =\n\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString;\n\tstatic readonly executorFunctionInputAbi: string[] = [\n\t\t\"address\", //to\n\t\t\"uint256\", //value\n\t\t\"bytes\", //data\n\t\t\"uint8\", //operation\n\t];\n\n\tprotected isInitWebAuthn: boolean;\n\tprotected x: bigint | null = null;\n\tprotected y: bigint | null = null;\n\n\treadonly safeAccountSingleton:SafeAccountSingleton;\n\treadonly entrypointAddress: string;\n\treadonly safe4337ModuleAddress: string;\n\tprotected factoryAddress: string | null;\n\tprotected factoryData: string | null;\n\n readonly onChainIdentifier: string | null;\n\n\tconstructor(\n\t\taccountAddress: string,\n\t\tsafe4337ModuleAddress: string,\n\t\tentrypointAddress: string,\n overrides: {\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string;\n safeAccountSingleton?: SafeAccountSingleton;\n } = {}\n\t) {\n\t\tsuper(accountAddress);\n\t\tthis.entrypointAddress = entrypointAddress;\n\t\tthis.safe4337ModuleAddress = safe4337ModuleAddress;\n\t\tthis.factoryAddress = null;\n\t\tthis.factoryData = null;\n\n\t\tthis.isInitWebAuthn = false;\n \n if(\n overrides.onChainIdentifierParams != null &&\n overrides.onChainIdentifier != null\n ){\n\t\t\tthrow new RangeError(\n \"can't override both onChainIdentifier and onChainIdentifierParams\"\n );\n }else if(overrides.onChainIdentifierParams != null){\n this.onChainIdentifier = generateOnChainIdentifier(\n overrides.onChainIdentifierParams.project,\n overrides.onChainIdentifierParams.platform,\n overrides.onChainIdentifierParams.tool,\n overrides.onChainIdentifierParams.toolVersion,\n );\n }else if(overrides.onChainIdentifier != null){\n let onChainIdentifier = overrides.onChainIdentifier;\n if (onChainIdentifier.startsWith(\"0x\")){\n onChainIdentifier = onChainIdentifier.slice(2);\n }\n if(onChainIdentifier.length != 64){\n throw new RangeError(\"onChainIdentifier length must be 64.\");\n }\n this.onChainIdentifier = onChainIdentifier;\n }else{\n this.onChainIdentifier = null;\n }\n this.safeAccountSingleton = overrides.safeAccountSingleton?? Safe_L2_V1_4_1;\n\t}\n\n\t/**\n\t * calculate proxy/account address using initilizer call data\n\t * @param initializerCallData from createBaseInitializerCallData\n\t * @param overrides - overrides for the default values\n\t * @param overrides.c2Nonce - create2 nonce to generate different sender addresses from the same owners\n\t * defaults to zero\n\t * @param overrides.safeFactoryAddress - safeFactoryAddress, defaults to\n\t * SafeAccountFactory.DEFAULT_FACTORY_ADDRESS\n\t * @param overrides.singletonInitHash - a hash that includes the singleton address and thr proxy bytecode\n\t * keccak256(solidityPacked([\"bytes\", \"bytes\"], [proxyByteCode, abiCoder.encode([\"uint256\"], [singletonAddress])]))\n\t * defaults to SafeAccount.safeAccountSingleton.singletonInitHash\n\t * @returns proxy/account address\n\t */\n\tpublic static createProxyAddress(\n\t\tinitializerCallData: string,\n\t\toverrides: {\n\t\t\tc2Nonce?: bigint;\n\t\t\tsafeFactoryAddress?: string;\n\t\t\tsingletonInitHash?: string;\n\t\t} = {},\n\t): string {\n\t\tconst c2Nonce = overrides.c2Nonce ?? 0n;\n\t\tif (c2Nonce < 0n) {\n\t\t\tthrow new RangeError(\"c2Nonce can't be negative\");\n\t\t}\n\t\tconst safeFactoryAddress =\n\t\t\toverrides.safeFactoryAddress ??\n\t\t\tSafeAccountFactory.DEFAULT_FACTORY_ADDRESS;\n\t\tconst singletonInitHash =\n\t\t\toverrides.singletonInitHash ?? Safe_L2_V1_4_1.singletonInitHash;\n\t\tconst salt = keccak256(\n\t\t\tsolidityPacked(\n\t\t\t\t[\"bytes32\", \"uint256\"],\n\t\t\t\t[keccak256(initializerCallData), c2Nonce],\n\t\t\t),\n\t\t);\n\n\t\tconst proxyAdd = solidityPackedKeccak256(\n\t\t\t[\"bytes1\", \"address\", \"bytes32\", \"bytes32\"],\n\t\t\t[\"0xff\", safeFactoryAddress, salt, singletonInitHash],\n\t\t).slice(-40);\n\n\t\treturn getAddress(\"0x\" + proxyAdd);//to checksummed\n\t}\n\n\t/**\n\t * encode calldata for a single MetaTransaction to be executed by Safe account\n\t * @param metaTransaction - metaTransaction to create calldata for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.safeModuleExecutorFunctionSelector - select the\n\t * executor function, either \"executeUserOpWithErrorString\" or \"executeUserOp\"\n\t * defaults to \"executeUserOpWithErrorString\"\n\t * @returns calldata\n\t */\n\tpublic static createAccountCallDataSingleTransaction(\n\t\tmetaTransaction: MetaTransaction,\n\t\toverrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t} = {},\n\t): string {\n\t\tconst value = metaTransaction.value ?? 0;\n\t\tconst data = metaTransaction.data ?? \"0x\";\n\t\tconst operation = metaTransaction.operation ?? Operation.Call;\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst executorFunctionCallData = SafeAccount.createAccountCallData(\n\t\t\tmetaTransaction.to,\n\t\t\tvalue,\n\t\t\tdata,\n\t\t\toperation,\n\t\t\t{\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t},\n\t\t);\n\t\treturn executorFunctionCallData;\n\t}\n\n\t/**\n\t * encode calldata for a list of MetaTransactions to be executed by Safe account\n\t * @param metaTransaction - metaTransaction to create calldata for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.safeModuleExecutorFunctionSelector - select the\n\t * executor function, either \"executeUserOpWithErrorString\" or \"executeUserOp\"\n\t * defaults to \"executeUserOpWithErrorString\"\n\t * @param overrides.multisendContractAddress - defaults to\n\t * SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS\n\t * @returns calldata\n\t */\n\tpublic static createAccountCallDataBatchTransactions(\n\t\tmetaTransactions: MetaTransaction[],\n\t\toverrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t\tmultisendContractAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tif (metaTransactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one metaTransaction\");\n\t\t}\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\n\t\tconst multiData = encodeMultiSendCallData(metaTransactions);\n\n\t\tconst mutisendSelector = \"0x8d80ff0a\";\n\t\tconst multiSendCallData = createCallData(\n\t\t\tmutisendSelector,\n\t\t\t[\"bytes\"],\n\t\t\t[multiData],\n\t\t);\n\n\t\tconst executorFunctionCallData = SafeAccount.createAccountCallData(\n\t\t\tmultisendContractAddress,\n\t\t\t0n,\n\t\t\tmultiSendCallData,\n\t\t\tOperation.Delegate,\n\t\t\t{\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t},\n\t\t);\n\n\t\treturn executorFunctionCallData;\n\t}\n\n\t/**\n\t * encode calldata to be executed by Safe account\n\t * @param to - target address\n\t * @param value - amount of natic token to transafer to target address\n\t * @param data - calldata\n\t * @param operation - either call or delegate call\n\t * @param overrides - overrides for the default values\n\t * @param overrides.safeModuleExecutorFunctionSelector - select the\n\t * executor function, either \"executeUserOpWithErrorString\" or \"executeUserOp\"\n\t * defaults to \"executeUserOpWithErrorString\"\n\t * @returns callData\n\t */\n\tpublic static createAccountCallData(\n\t\tto: string,\n\t\tvalue: bigint,\n\t\tdata: string,\n\t\toperation: Operation,\n\t\toverrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t} = {},\n\t): string {\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst executorFunctionInputParameters = [to, value, data, operation];\n\t\tconst callData = createCallData(\n\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\tSafeAccount.executorFunctionInputAbi,\n\t\t\texecutorFunctionInputParameters,\n\t\t);\n\t\treturn callData;\n\t}\n\n\t/**\n\t * decode calldata to a Metatransaction\n\t * @param callData - calldata to decode\n\t * @returns [MetaTransaction, SafeModuleExecutorFunctionSelector]\n\t */\n\tpublic static decodeAccountCallData(\n\t\tcallData: string,\n\t): [MetaTransaction, SafeModuleExecutorFunctionSelector] {\n\t\tlet safeModuleExecutorFunctionSelector: SafeModuleExecutorFunctionSelector | null =\n\t\t\tnull;\n\t\tif (\n\t\t\tcallData.startsWith(\n\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString,\n\t\t\t)\n\t\t) {\n\t\t\tsafeModuleExecutorFunctionSelector =\n\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString;\n\t\t} else if (\n\t\t\tcallData.startsWith(SafeModuleExecutorFunctionSelector.executeUserOp)\n\t\t) {\n\t\t\tsafeModuleExecutorFunctionSelector =\n\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOp;\n\t\t}\n\t\tif (safeModuleExecutorFunctionSelector != null) {\n\t\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\t\tconst params = \"0x\" + callData.slice(10);\n\t\t\tconst decodedParams = abiCoder.decode(\n\t\t\t\t[\n\t\t\t\t\t\"address\", //to\n\t\t\t\t\t\"uint256\", //value\n\t\t\t\t\t\"bytes\", //data\n\t\t\t\t\t\"uint8\", //operation\"\n\t\t\t\t],\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tlet accountCallDataString;\n\t\t\tif (typeof decodedParams[2] !== \"string\") {\n\t\t\t\taccountCallDataString = new TextDecoder().decode(decodedParams[2]);\n\t\t\t} else {\n\t\t\t\taccountCallDataString = decodedParams[2];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tto: decodedParams[0] as string,\n\t\t\t\t\tvalue: BigInt(decodedParams[1] as string),\n\t\t\t\t\tdata: accountCallDataString,\n\t\t\t\t\toperation: Number(decodedParams[3]),\n\t\t\t\t},\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t];\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Invalid calldata, should start with \" +\n\t\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString +\n\t\t\t\t\t\" or \" +\n\t\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOp,\n\t\t\t\t{\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tcallData: callData,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * adds a token approve call to the call data for a token paymaster\n\t * @param callData - calldata to be added to, if after decoding it is not\n\t * a multisend transaction, it will be encoded as a multisend transaction\n\t * @param tokenAddress - token to add approve for\n\t * @param paymasterAddress - paymaster to add approve for\n\t * @param approveAmount - amount to add approve for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.multisendContractAddress - defaults to\n\t * SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS\n\t * @returns callData\n\t */\n\tpublic static prependTokenPaymasterApproveToCallDataStatic(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t\toverrides: {\n\t\t\tmultisendContractAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\t\tconst [metaTransaction, safeModuleExecutorFunctionSelector] =\n\t\t\tSafeAccount.decodeAccountCallData(callData);\n\n\t\tconst approveFunctionSignature = \"approve(address,uint256)\";\n\t\tconst approveFunctionSelector = getFunctionSelector(\n\t\t\tapproveFunctionSignature,\n\t\t);\n\t\tconst approveCallData = createCallData(\n\t\t\tapproveFunctionSelector,\n\t\t\t[\"address\", \"uint256\"],\n\t\t\t[paymasterAddress, approveAmount],\n\t\t);\n\t\tconst approveMetatransaction: MetaTransaction = {\n\t\t\tto: tokenAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: approveCallData,\n\t\t\toperation: Operation.Call,\n\t\t};\n\t\tconst encodedApproveMetatransaction = encodeMultiSendCallData([\n\t\t\tapproveMetatransaction,\n\t\t]);\n\n\t\tlet multiSendCallDataParams = \"\";\n\t\tconst mutisendSelector = \"0x8d80ff0a\";\n\t\tif (metaTransaction.data.startsWith(mutisendSelector)) {\n\t\t\t//multisend\n\t\t\tconst decodedCalldata = decodeMultiSendCallData(metaTransaction.data);\n\t\t\tmultiSendCallDataParams =\n\t\t\t\tencodedApproveMetatransaction + decodedCalldata.slice(2);\n\t\t} else {\n\t\t\tconst encodedCallDataMetaTransaction = encodeMultiSendCallData([\n\t\t\t\tmetaTransaction,\n\t\t\t]);\n\t\t\tmultiSendCallDataParams =\n\t\t\t\tencodedApproveMetatransaction + encodedCallDataMetaTransaction.slice(2);\n\t\t}\n\t\tconst multiSendCallData = createCallData(\n\t\t\tmutisendSelector,\n\t\t\t[\"bytes\"],\n\t\t\t[multiSendCallDataParams],\n\t\t);\n\n\t\tconst executorFunctionCallData = SafeAccount.createAccountCallData(\n\t\t\tmultisendContractAddress,\n\t\t\t0n,\n\t\t\tmultiSendCallData,\n\t\t\tOperation.Delegate,\n\t\t\t{\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t},\n\t\t);\n\n\t\treturn executorFunctionCallData;\n\t}\n\n\t/**\n * @deprecated \n\t * formate a list of eip712 signatures to a useroperation signature\n\t * @param signersAddresses - signers public addresses\n\t * @param signatures - list of eip712 signatures\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic static formatEip712SignaturesToUseroperationSignature(\n\t\tsignersAddresses: string[],\n\t\tsignatures: string[],\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n isMultiChainSignature?: boolean;\n\t\t\tmerkleProof?: string;\n\t\t} = {},\n\t): string {\n\t\tif (signersAddresses.length != signatures.length) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"signersAddresses and signatures arrays should be the same length\",\n\t\t\t);\n\t\t}\n\n\t\tconst signersSignatures: SignerSignaturePair[] = [];\n\n\t\tsignersAddresses.forEach((signer, index) => {\n\t\t\tsignersSignatures.push(\n\t\t\t\t{\n\t\t\t\t\tsigner: signer.toLowerCase(),\n\t\t\t\t\tsignature: signatures[index]\n\t\t\t\t}\n\t\t\t);\n\t\t});\n\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\tsignersSignatures, {\n\t\t\t\tvalidAfter: overrides.validAfter,\n\t\t\t\tvalidUntil: overrides.validUntil,\n\t\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\t\tmultiChainMerkleProof: overrides.merkleProof,\n\t\t\t},\n\t\t);\n\t}\n \n /**\n\t * create a v0.07 or v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * @param overrides.safe4337ModuleAddress - target module address \n\t * @returns useroperation hash\n\t */\n\tprotected static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tif (\"initCode\" in useroperation) {\n\t\t\treturn SafeAccount.getUserOperationEip712Hash_V6(\n\t\t\t\tuseroperation,\n\t\t\t\tchainId,\n\t\t\t\toverrides,\n\t\t\t);\n\t\t} else {\n if(overrides.entrypointAddress){\n if(overrides.entrypointAddress.toLowerCase() === ENTRYPOINT_V9.toLowerCase()){\n return SafeAccount.getUserOperationEip712Hash_V9(\n useroperation as UserOperationV9,\n chainId,\n overrides,\n );\n }else{\n return SafeAccount.getUserOperationEip712Hash_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n }else{\n return SafeAccount.getUserOperationEip712Hash_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n\t\t}\n\t}\n \n /**\n\t * create a v0.07 or v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * @param overrides.safe4337ModuleAddress - target module address \n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n protected static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides?: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue | SafeUserOperationV6TypedMessageValue\n } {\n\t\tif (\"initCode\" in useroperation) {\n\t\t\tconst data = SafeAccount.getUserOperationEip712Data_V6(\n\t\t\t\tuseroperation,\n\t\t\t\tchainId,\n\t\t\t\toverrides,\n\t\t\t);\n return {\n domain: data.domain,\n types: data.types,\n messageValue: data.messageValue\n }\n\t\t} else {\n let data;\n if(overrides?.entrypointAddress){\n if(overrides.entrypointAddress.toLowerCase() === ENTRYPOINT_V9.toLowerCase()){\n data = SafeAccount.getUserOperationEip712Data_V9(\n useroperation as UserOperationV9,\n chainId,\n overrides,\n );\n }else{\n data = SafeAccount.getUserOperationEip712Data_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n }else{\n data = SafeAccount.getUserOperationEip712Data_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n return {\n domain: data.domain,\n types: data.types,\n messageValue: data.messageValue\n }\n\t\t}\n\t}\n\n /**\n\t * create a v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V6\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xa581c4A4DB7175302464fF3C06380BC3270b4037\"\n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data_V6(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tconst entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V6;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\"0xa581c4A4DB7175302464fF3C06380BC3270b4037\";\n\n\t\tconst messageValue: SafeUserOperationV6TypedMessageValue = {\n\t\t\tsafe: useroperation.sender,\n\t\t\tnonce: useroperation.nonce,\n\t\t\tinitCode: useroperation.initCode,\n\t\t\tcallData: useroperation.callData,\n\t\t\tcallGasLimit: useroperation.callGasLimit,\n\t\t\tverificationGasLimit: useroperation.verificationGasLimit,\n\t\t\tpreVerificationGas: useroperation.preVerificationGas,\n\t\t\tmaxFeePerGas: useroperation.maxFeePerGas,\n\t\t\tmaxPriorityFeePerGas: useroperation.maxPriorityFeePerGas,\n\t\t\tpaymasterAndData: useroperation.paymasterAndData,\n\t\t\tvalidAfter: validAfter,\n\t\t\tvalidUntil: validUntil,\n\t\t\tentryPoint: entrypointAddress,\n\t\t};\n\n\t\tconst domain: SafeUserOperationTypedDataDomain = {\n\t\t\tchainId: Number(chainId),\n\t\t\tverifyingContract: safe4337ModuleAddress,\n\t\t};\n\n\t\treturn {\n\t\t\tdomain,\n\t\t\ttypes: EIP712_SAFE_OPERATION_V6_TYPE,\n\t\t\tmessageValue,\n };\n\t}\n\n\n\t/**\n\t * create a v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V6\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xa581c4A4DB7175302464fF3C06380BC3270b4037\"\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash_V6(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t const data = SafeAccount.getUserOperationEip712Data_V6(\n useroperation, chainId, overrides)\t\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n\t}\n\n private static baseGetUserOperationEip712DataV7V8V9(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\tentrypointAddress: string,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tsafe4337ModuleAddress?: string;\n is_v9?: boolean\n\t\t} = {},\n ): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\";\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\t\tlet initCode = \"0x\";\n\t\tif (useroperation.factory != null) {\n\t\t\tinitCode = useroperation.factory;\n\t\t\tif (useroperation.factoryData != null) {\n\t\t\t\tinitCode += useroperation.factoryData.slice(2);\n\t\t\t}\n\t\t}\n\n\t\tlet paymasterAndData = \"0x\";\n\t\tif (useroperation.paymaster != null) {\n\t\t\tpaymasterAndData = useroperation.paymaster;\n\t\t\tif (useroperation.paymasterVerificationGasLimit != null) {\n\t\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterVerificationGasLimit])\n\t\t\t\t\t.slice(34);\n\t\t\t}\n\t\t\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterPostOpGasLimit])\n\t\t\t\t\t.slice(34);\n\t\t\t}\n\t\t\tif (useroperation.paymasterData != null) {\n\t const PAYMASTER_SIG_MAGIC = '22e325a297439656';\n\t if(\n\t overrides.is_v9 &&\n\t useroperation.paymasterData.toLowerCase().endsWith(PAYMASTER_SIG_MAGIC)\n\t ){\n\t const sigLenHex = useroperation.paymasterData.slice(\n\t useroperation.paymasterData.length - 16 - 4,\n\t useroperation.paymasterData.length - 16\n\t );\n\t const sigLen = parseInt(sigLenHex, 16);\n\t const prefixEnd = useroperation.paymasterData.length - 16 - 4 - sigLen * 2;\n\t paymasterAndData += useroperation.paymasterData.slice(0, prefixEnd).replaceAll(\"0x\", \"\") + PAYMASTER_SIG_MAGIC;\n\t }else{\n\t paymasterAndData += useroperation.paymasterData.slice(2);\n\t }\n\t\t\t}\n\t\t}\n\t\tconst messageValue: SafeUserOperationV7TypedMessageValue = {\n\t\t\tsafe: useroperation.sender,\n\t\t\tnonce: useroperation.nonce,\n\t\t\tinitCode: initCode,\n\t\t\tcallData: useroperation.callData,\n\t\t\tverificationGasLimit: useroperation.verificationGasLimit,\n\t\t\tcallGasLimit: useroperation.callGasLimit,\n\t\t\tpreVerificationGas: useroperation.preVerificationGas,\n\t\t\tmaxPriorityFeePerGas: useroperation.maxPriorityFeePerGas,\n\t\t\tmaxFeePerGas: useroperation.maxFeePerGas,\n\t\t\tpaymasterAndData, \n\t\t\tvalidAfter: validAfter,\n\t\t\tvalidUntil: validUntil,\n\t\t\tentryPoint: entrypointAddress,\n\t\t};\n\t\tconst domain: SafeUserOperationTypedDataDomain = {\n\t\t\tchainId: Number(chainId),\n\t\t\tverifyingContract: safe4337ModuleAddress,\n\t\t};\n return {\n\t\t\tdomain,\n\t\t\ttypes: EIP712_SAFE_OPERATION_V7_TYPE,\n\t\t\tmessageValue,\n };\n }\n\n /**\n\t * create a v0.07 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V7\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\"\n * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data_V7(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n ): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n return SafeAccount.baseGetUserOperationEip712DataV7V8V9(\n useroperation,\n chainId,\n overrides.entrypointAddress??ENTRYPOINT_V7,\n overrides\n );\n }\n\n\t/**\n\t * create a v0.07 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V7\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\"\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash_V7(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n const data = SafeAccount.getUserOperationEip712Data_V7(\n useroperation, chainId, overrides)\t\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n\t}\n\n /**\n\t * create a v0.09 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V9\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42\"\n * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data_V9(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n ): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42\";\n\n return SafeAccount.baseGetUserOperationEip712DataV7V8V9(\n useroperation,\n chainId,\n overrides.entrypointAddress??ENTRYPOINT_V9,\n {\n ...overrides,\n safe4337ModuleAddress,\n is_v9: true\n }\n );\n }\n\n\t/**\n\t * create a v0.09 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V9\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xE0049883864b20728b76B5cf265765B45162516D\"\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash_V9(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n const data = SafeAccount.getUserOperationEip712Data_V9(\n useroperation, chainId, overrides)\t\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n\t}\n\n\t/**\n * @deprecated\n\t * formate an eip712 signature to a useroperation signature\n\t * @param signature - an eip712 signature\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns formated signature\n\t */\n\tpublic static formatEip712SingleSignatureToUseroperationSignature(\n\t\tsignature: string,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n isMultiChainSignature?: boolean;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t[{\n\t\t\t\tsigner: \"0x0000000000000000000000000000000000000000\", // any random address\n\t\t\t\tsignature\n\t\t\t}],\n\t\t\toverrides\n\t\t);\n\t}\n\n\t/**\n\t * sends a useroperation to a bundler rpc\n\t * @param userOperation - useroperation to send\n\t * @param bundlerRpc - bundler rpc to send useroperation\n\t * @returns promise with SendUseroperationResponse\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = new Bundler(bundlerRpc);\n\t\tconst sendUserOperationRes = await bundler.sendUserOperation(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\n\t\treturn new SendUseroperationResponse(\n\t\t\tsendUserOperationRes,\n\t\t\tbundler,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\t}\n\n\t/**\n\t * calculate account address and initcode from owners\n\t * @param owners - list of account owners addresses\n\t * @param overrides - override values to change the initialization default values\n\t * @returns account address ,factory address and factorydata\n\t */\n\tprotected static createAccountAddressAndFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: BaseInitOverrides,\n\t\tsafe4337ModuleAddress: string,\n\t\tsafeModuleSetupAddress: string,\n\t): [string, string, string] {\n\t\tif (owners.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one owner\");\n\t\t}\n\t\tconst initializerCallData = SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\toverrides.threshold ?? 1,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress ??\n\t\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,\n\t\t);\n\n\t\tlet safeAccountFactory;\n\t\tif (overrides.safeAccountFactoryAddress != null) {\n\t\t\tsafeAccountFactory = new SafeAccountFactory(\n\t\t\t\toverrides.safeAccountFactoryAddress,\n\t\t\t);\n\t\t} else {\n\t\t\tsafeAccountFactory = new SafeAccountFactory();\n\t\t}\n\t\tconst safeSingleton =\n\t\t\toverrides.safeAccountSingleton ?? Safe_L2_V1_4_1;\n\t\tconst sender = this.createProxyAddress(initializerCallData, {\n\t\t\tc2Nonce: overrides.c2Nonce ?? 0n,\n\t\t\tsafeFactoryAddress: safeAccountFactory.address,\n\t\t\tsingletonInitHash: safeSingleton.singletonInitHash,\n\t\t});\n\n\t\tconst generatorFunctionInputParameters = [\n\t\t\tsafeSingleton.singletonAddress,\n\t\t\tinitializerCallData,\n\t\t\toverrides.c2Nonce ?? 0n,\n\t\t];\n\n\t\tconst factoryGeneratorFunctionCallData =\n\t\t\tsafeAccountFactory.getFactoryGeneratorFunctionCallData(\n\t\t\t\tgeneratorFunctionInputParameters,\n\t\t\t);\n\n\t\treturn [\n\t\t\tsender,\n\t\t\tsafeAccountFactory.address,\n\t\t\tfactoryGeneratorFunctionCallData,\n\t\t];\n\t}\n\n\tprotected static createBaseInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\tsafe4337ModuleAddress: string,\n\t\tsafeModuleSetupAddress: string,\n\t\tmultisendContractAddress: string = SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\twebAuthnSharedSigner = SafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: string = SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\teip7212WebAuthnContractVerifierForSharedSigner: string = SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,\n\t): string {\n\t\tif (owners.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one owner\");\n\t\t}\n\n\t\tif (threshold < 1) {\n\t\t\tthrow new RangeError(\"threshold should be at least one\");\n\t\t}\n\n\t\tif (threshold > owners.length) {\n\t\t\tthrow new RangeError(\"threshold can't be larger than number of owners\");\n\t\t}\n\n\t\tconst enable4337ModuleCallData = createCallData(\n\t\t\t\"0x8d0dc49f\", //enableModules\n\t\t\t[\"address[]\"],\n\t\t\t[[safe4337ModuleAddress]],\n\t\t);\n\t\tlet isInitWebAuthn = false;\n\t\tlet initializerFunctionInputParameters;\n\n\t\tconst owners_str: string[] = [];\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t} else {\n\t\t\t\towners_str.push(owner);\n\t\t\t}\n\t\t}\n\n\t\tif (isInitWebAuthn) {\n\t\t\tconst safeModuleSetupCallData: MetaTransaction = {\n\t\t\t\tto: safeModuleSetupAddress,\n\t\t\t\tvalue: 0n,\n\t\t\t\tdata: enable4337ModuleCallData,\n\t\t\t\toperation: Operation.Delegate,\n\t\t\t};\n\t\t\tconst txs = [];\n\t\t\ttxs.push(safeModuleSetupCallData);\n\t\t\tconst modOwners = [];\n\n\t\t\tlet numOfWebAuthnOwners = 0;\n\t\t\tfor (const owner of owners) {\n\t\t\t\tif (typeof owner != \"string\") {\n\t\t\t\t\tif (numOfWebAuthnOwners > 0) {\n\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t\"Only one WebAuthn owner can be set during initialization\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst addWebauthnSigner = createCallData(\n\t\t\t\t\t\t\"0x0dd9692f\", //configure\n\t\t\t\t\t\t[\"uint256\", \"uint256\", \"uint176\"],\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\towner.x,\n\t\t\t\t\t\t\towner.y,\n\t\t\t\t\t\t\t\"0x\" +\n\t\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner.slice(-4) +\n\t\t\t\t\t\t\t\teip7212WebAuthnContractVerifierForSharedSigner.slice(2),\n\t\t\t\t\t\t],\n\t\t\t\t\t);\n\n\t\t\t\t\tconst setSignerCallData: MetaTransaction = {\n\t\t\t\t\t\tto: webAuthnSharedSigner,\n\t\t\t\t\t\tvalue: 0n,\n\t\t\t\t\t\tdata: addWebauthnSigner,\n\t\t\t\t\t\toperation: Operation.Delegate,\n\t\t\t\t\t};\n\t\t\t\t\ttxs.push(setSignerCallData);\n\t\t\t\t\tmodOwners.push(webAuthnSharedSigner);\n\t\t\t\t\tnumOfWebAuthnOwners++;\n\t\t\t\t} else {\n\t\t\t\t\tmodOwners.push(owner);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst encodedInit = encodeMultiSendCallData(txs);\n\n\t\t\tconst mutisendSelector = \"0x8d80ff0a\";\n\t\t\tconst multiSendCallData = createCallData(\n\t\t\t\tmutisendSelector,\n\t\t\t\t[\"bytes\"],\n\t\t\t\t[encodedInit],\n\t\t\t);\n\n\t\t\tinitializerFunctionInputParameters = [\n\t\t\t\tmodOwners,\n\t\t\t\tthreshold,\n\t\t\t\tmultisendContractAddress, //to Contract address for optional delegate call during initialization\n\t\t\t\tmultiSendCallData, //Data payload for optional delegate call during initialization\n\t\t\t\tsafe4337ModuleAddress, //fallbackHandler Handler for fallback calls to this contract\n\t\t\t\tZeroAddress, //paymentToken (Safe specific, can be ignored)\n\t\t\t\t0, //payment (Safe specific, can be ignored)\n\t\t\t\tZeroAddress, //paymentReceiver (Safe specific, can be ignored)\n\t\t\t];\n\t\t} else {\n\t\t\tinitializerFunctionInputParameters = [\n\t\t\t\towners_str, //_owners\n\t\t\t\tthreshold, //_threshold\n\t\t\t\tsafeModuleSetupAddress, //to Contract address for optional delegate call during initialization\n\t\t\t\tenable4337ModuleCallData, //Data payload for optional delegate call during initialization\n\t\t\t\tsafe4337ModuleAddress, //fallbackHandler Handler for fallback calls to this contract\n\t\t\t\tZeroAddress, //paymentToken (Safe specific, can be ignored)\n\t\t\t\t0, //payment (Safe specific, can be ignored)\n\t\t\t\tZeroAddress, //paymentReceiver (Safe specific, can be ignored)\n\t\t\t];\n\t\t}\n\n\t\treturn createCallData(\n\t\t\tSafeAccount.initializerFunctionSelector,\n\t\t\tSafeAccount.initializerFunctionInputAbi,\n\t\t\tinitializerFunctionInputParameters,\n\t\t);\n\t}\n\n\t/**\n\t * create factory address and factoryData (initcode)\n\t * @param owners - list of account owners signers\n\t * @param overrides - overrides for the default values\n\t * @returns factoryAddress and factoryData\n\t */\n\tprotected static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: BaseInitOverrides = {},\n\t\tsafe4337ModuleAddress: string,\n\t\tsafeModuleSetupAddress: string,\n\t): [string, string] {\n\t\tif (owners.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one owner\");\n\t\t}\n\t\tconst threshold = overrides.threshold ?? 1;\n\t\tconst c2Nonce = overrides.c2Nonce ?? 0;\n\t\tif (threshold < 1) {\n\t\t\tthrow new RangeError(\"threshold should be at least one\");\n\t\t}\n\n\t\tif (threshold > owners.length) {\n\t\t\tthrow new RangeError(\"threshold can't be larger than number of owners\");\n\t\t}\n\n\t\tif (c2Nonce < 0n) {\n\t\t\tthrow new RangeError(\"c2Nonce can't be negative\");\n\t\t}\n\n\t\tconst initializerCallData = SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\toverrides.threshold ?? 1,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress ??\n\t\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,\n\t\t);\n\n\t\tlet safeAccountFactory;\n\t\tif (overrides.safeAccountFactoryAddress != null) {\n\t\t\tsafeAccountFactory = new SafeAccountFactory(\n\t\t\t\toverrides.safeAccountFactoryAddress,\n\t\t\t);\n\t\t} else {\n\t\t\tsafeAccountFactory = new SafeAccountFactory();\n\t\t}\n\n\t\tconst safeSingleton =\n\t\t\toverrides.safeAccountSingleton ?? Safe_L2_V1_4_1;\n\n\t\tconst generatorFunctionInputParameters = [\n\t\t\tsafeSingleton.singletonAddress,\n\t\t\tinitializerCallData,\n\t\t\tc2Nonce,\n\t\t];\n\n\t\tconst factoryGeneratorFunctionCallData =\n\t\t\tsafeAccountFactory.getFactoryGeneratorFunctionCallData(\n\t\t\t\tgeneratorFunctionInputParameters,\n\t\t\t);\n\n\t\treturn [safeAccountFactory.address, factoryGeneratorFunctionCallData];\n\t}\n\n\t/**\n\t * a non static wrapper function for prependTokenPaymasterApproveToCallDataStatic\n\t * which adds a token approve call to the call data for a token paymaster\n\t * @param callData - calldata to be added to, if after decoding it is not\n\t * a multisend transaction, it will be encoded as a multisend transaction\n\t * @param tokenAddress - token to add approve for\n\t * @param paymasterAddress - paymaster to add approve for\n\t * @param approveAmount - amount to add approve for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.multisendContractAddress - defaults to\n\t * SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS\n\t * @returns callData\n\t */\n\tpublic prependTokenPaymasterApproveToCallData(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t\toverrides: {\n\t\t\tmultisendContractAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\t\treturn SafeAccount.prependTokenPaymasterApproveToCallDataStatic(\n\t\t\tcallData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tapproveAmount,\n\t\t\t{\n\t\t\t\tmultisendContractAddress,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * estimate gas limits for a useroperation\n\t * @param userOperation - useroperation to estimate gas for\n\t * @param bundlerRpc - bundler rpc for gas estimation\n\t * @param overrides - overrides for the default values\n\t * @param overrides.stateOverrideSet - state override values to set during gs estimation\n\t * @param overrides.dummySignerSignaturePairs - list of dummy signers signature pairs\n\t * defaults to a single eoa signature\n\t * @returns promise with [preVerificationGas, verificationGasLimit, callGasLimit]\n\t */\n\tpublic async baseEstimateUserOperationGas(\n\t\tuserOperation: UserOperationV6 | UserOperationV7,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n expectedSigners?: Signer[];\n webAuthnSharedSigner?: string;\n webAuthnSignerFactory?: string;\n webAuthnSignerSingleton?: string;\n webAuthnSignerProxyCreationCode?: string;\n eip7212WebAuthnPrecompileVerifier?: string;\n eip7212WebAuthnContractVerifier?: string;\n isMultiChainSignature?: boolean;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n const validAfter = 0xffffffffffffn;\n\t\tconst validUntil = 0xffffffffffffn;\n\n\t\tif (overrides.dummySignerSignaturePairs != null) {\n if(overrides.expectedSigners != null){\n throw new RangeError(\n \"Can't use both dummySignerSignaturePairs and expectedSigners overrides.\",\n );\n }\n\t\t\tif (overrides.dummySignerSignaturePairs.length < 1) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\"Number of dummy signers signature pairs can't be less than 1\",\n\t\t\t\t);\n\t\t\t}\n\t\t userOperation.signature =\n\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\t\toverrides.dummySignerSignaturePairs,\n\t\t\t\t\t{\n\t\t\t\t\t\tvalidAfter,\n\t\t\t\t\t\tvalidUntil,\n isMultiChainSignature: overrides.isMultiChainSignature\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t} else if (overrides.expectedSigners != null) {\n let initCode;\n\n if (\"initCode\" in userOperation) {\n initCode = userOperation.initCode;\n }else{\n initCode = userOperation.factory;\n }\n const isInit = initCode != null && initCode != \"0x\";\n \n const dummySignerSignaturePairs = SafeAccount.createDummySignerSignaturePairForExpectedSigners(\n overrides.expectedSigners,\n {\n isInit,\n webAuthnSharedSigner:overrides.webAuthnSharedSigner,\n eip7212WebAuthnPrecompileVerifier:overrides.eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier:overrides.eip7212WebAuthnContractVerifier,\n webAuthnSignerFactory:overrides.webAuthnSignerFactory,\n webAuthnSignerSingleton:overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode:overrides.webAuthnSignerProxyCreationCode,\n validAfter,\n validUntil,\n }\n )\n userOperation.signature =\n SafeAccount.formatSignaturesToUseroperationSignature(\n dummySignerSignaturePairs,\n {\n validAfter,\n validUntil,\n isMultiChainSignature: overrides.isMultiChainSignature\n },\n );\n\t\t} else if (userOperation.signature.length < 3) {\n userOperation.signature =\n SafeAccount.formatSignaturesToUseroperationSignature(\n [EOADummySignerSignaturePair],\n {\n validAfter,\n validUntil,\n isMultiChainSignature: overrides.isMultiChainSignature\n },\n );\n }\n \n\t\tconst bundler = new Bundler(bundlerRpc);\n\n\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\tuserOperation.maxFeePerGas = 0n;\n\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\toverrides.stateOverrideSet,\n\t\t);\n\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\n\t\tconst preVerificationGas = BigInt(estimation.preVerificationGas);\n\n\t\tlet verificationGasLimit: bigint;\n\t\tif (overrides.dummySignerSignaturePairs != null) {\n\t\t\tverificationGasLimit =\n\t\t\t\tBigInt(estimation.verificationGasLimit) +\n\t\t\t\tBigInt(overrides.dummySignerSignaturePairs.length) * 55_000n;\n\t\t} else {\n\t\t\tverificationGasLimit = BigInt(estimation.verificationGasLimit);\n\t\t}\n\n\t\tconst callGasLimit = BigInt(estimation.callGasLimit);\n\n\t\treturn [preVerificationGas, verificationGasLimit, callGasLimit];\n\t}\n\n\t/**\n\t * createBaseUserOperationAndFactoryAddressAndFactoryData will\n\t * determine the nonce, fetch the gas prices,\n\t * estimate gas limits and return a useroperation to be signed.\n\t * you can override all these values using the overrides parameter.\n\t * @param transactions - metatransaction list to be encoded\n\t * @param providerRpc - node rpc to fetch account nonce and gas prices\n\t * @param bundlerRpc - bundler rpc for gas estimation\n\t * @param overrides - overrides for the default values\n\t * @returns a promise with (base useroperation, factoryAddress, factoryData)\n\t */\n\tprotected async createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\ttransactions: MetaTransaction[],\n\t\tisV06: boolean,\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateBaseUserOperationOverrides = {},\n\t): Promise<[BaseUserOperation, string | null, string | null]> {\n\t\tif (transactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one transaction\");\n\t\t}\n\t\tconst webAuthnSharedSigner =\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\n\t\tlet nonce:bigint | null = null;\n\t\tlet nonceOp:Promise<bigint> | null = null;\n\n\t\tif (overrides.nonce == null) {\n\t\t\tif (providerRpc != null) {\n\t\t\t\tnonceOp = fetchAccountNonce(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc cant't be null if nonce is not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnonce = overrides.nonce;\n\t\t}\n\n if (\n\t\t\ttypeof overrides.maxFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxFeePerGas overrid can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxPriorityFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxPriorityFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas overrid can't be negative\");\n\t\t}\n let maxFeePerGas = BaseUserOperationDummyValues.maxFeePerGas;\n\t\tlet maxPriorityFeePerGas =\n\t\t\tBaseUserOperationDummyValues.maxPriorityFeePerGas;\n\n let gasPriceOp:Promise<[bigint, bigint]> | null = null;\n if (\n\t\t\toverrides.maxFeePerGas == null ||\n\t\t\toverrides.maxPriorityFeePerGas == null\n\t\t) {\n gasPriceOp = handlefetchGasPrice(\n providerRpc, overrides.polygonGasStation, overrides.gasLevel\n )\n }\n \n if(gasPriceOp != null && nonceOp != null){\n await Promise.all([nonceOp, gasPriceOp]).then((values) => {\n nonce = values[0];\n [maxFeePerGas, maxPriorityFeePerGas] = values[1]; \n });\n }else if(gasPriceOp != null){\n [maxFeePerGas, maxPriorityFeePerGas] = await gasPriceOp; \n }else if(nonceOp != null){\n nonce = await nonceOp;\n }\n \n\t\tmaxFeePerGas = overrides.maxFeePerGas ??\n maxFeePerGas * BigInt((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100n;\n\t\tmaxPriorityFeePerGas = overrides.maxPriorityFeePerGas ??\n maxPriorityFeePerGas * BigInt((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / 100n;\n\n const eip7212WebAuthnPrecompileVerifier =\n overrides.eip7212WebAuthnPrecompileVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n const eip7212WebAuthnContractVerifier =\n overrides.eip7212WebAuthnContractVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n const webAuthnSignerFactory =\n overrides.webAuthnSignerFactory ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n const webAuthnSignerSingleton =\n overrides.webAuthnSignerSingleton ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\tlet factoryAddress: string | null = this.factoryAddress;\n\t\tlet factoryData: string | null = this.factoryData;\n \n if(nonce == null){\n\t\t\tthrow new RangeError(\"failed to determine nonce\");\n }\n else if (nonce < 0n) {\n\t\t\tthrow new RangeError(\"nonce can't be negative\");\n\t\t}\n else if (nonce > 0n) {\n\t\t\tfactoryAddress = null;\n\t\t\tfactoryData = null;\n\t\t} \n else if (this.isInitWebAuthn) { //nonce = 0\n\t\t\tif (this.x == null || this.y == null) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\"Invalide account initialization with Webauthnn signer.\" +\n\t\t\t\t\t\t\"Webauthnn signer publickey can be null!!\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst createDeterministicWebAuthnVerifierOwner: MetaTransaction =\n\t\t\t\tSafeAccount.createDeployWebAuthnVerifierMetaTransaction(\n\t\t\t\t\tthis.x,\n\t\t\t\t\tthis.y,\n\t\t\t\t\t{\n\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\tconst deterministicWebAuthnVerifierAddress =\n\t\t\t\tSafeAccount.createWebAuthnSignerVerifierAddress(this.x, this.y, {\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t});\n\n\t\t\tconst swapSingletonWithDeterministicWebAuthnVerifierOwnerCallData =\n\t\t\t\tcreateCallData(\n\t\t\t\t\t\"0xe318b52b\", //swapOwner\n\t\t\t\t\t[\n\t\t\t\t\t\t\"address\", //prevOwner\n\t\t\t\t\t\t\"address\", //oldOwner\n\t\t\t\t\t\t\"address\", //newOwner\n\t\t\t\t\t],\n\t\t\t\t\t[\n\t\t\t\t\t\t\"0x0000000000000000000000000000000000000001\", //SENTINEL_OWNERS\n\t\t\t\t\t\twebAuthnSharedSigner,\n\t\t\t\t\t\tdeterministicWebAuthnVerifierAddress,\n\t\t\t\t\t],\n\t\t\t\t);\n\n\t\t\tconst swapSingletonWithDeterministicWebAuthnVerifierOwner: MetaTransaction =\n\t\t\t\t{\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tvalue: 0n,\n\t\t\t\t\tdata: swapSingletonWithDeterministicWebAuthnVerifierOwnerCallData,\n\t\t\t\t};\n\n\t\t\t/*const clearWebauthnSharedSignerCallData = createCallData(\n\t\t\t\t\"0x0dd9692f\", //configure\n\t\t\t\t[\"uint256\", \"uint256\", \"uint176\"],\n\t\t\t\t[0, 0, 0],\n\t\t\t);\n \n\t\t\tconst clearWebauthnSharedSigner: MetaTransaction = {\n\t\t\t\tto: webAuthnSharedSigner,\n\t\t\t\tvalue: 0n,\n\t\t\t\tdata: clearWebauthnSharedSignerCallData,\n\t\t\t\toperation: Operation.Delegate,\n\t\t\t};*/\n\n\t\t\ttransactions = [\n\t\t\t\tcreateDeterministicWebAuthnVerifierOwner,\n\t\t\t\tswapSingletonWithDeterministicWebAuthnVerifierOwner,\n\t\t\t\t//clearWebauthnSharedSigner,\n\t\t\t].concat(transactions);\n\t\t}\n\n\n\t\tlet callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tif (transactions.length == 1) {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataSingleTransaction(\n\t\t\t\t\ttransactions[0],\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataBatchTransactions(\n\t\t\t\t\ttransactions,\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector:\n\t\t\t\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t\t\t\tmultisendContractAddress: multisendContractAddress,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n\n if(this.onChainIdentifier != null){\n callData = callData + this.onChainIdentifier;\n }\n\n\t\tconst userOperation = {\n\t\t\t...BaseUserOperationDummyValues,\n\t\t\tsender: this.accountAddress,\n\t\t\tnonce: nonce,\n\t\t\tcallData: callData,\n\t\t\tmaxFeePerGas: maxFeePerGas,\n\t\t\tmaxPriorityFeePerGas: maxPriorityFeePerGas,\n\t\t};\n\n\t\tlet preVerificationGas = BaseUserOperationDummyValues.preVerificationGas;\n\t\tlet verificationGasLimit =\n\t\t\tBaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n\t\t\tif (bundlerRpc != null) {\n\t\t\t\tuserOperation.callGasLimit = 0n;\n\t\t\t\tuserOperation.verificationGasLimit = 0n;\n\t\t\t\tuserOperation.preVerificationGas = 0n;\n\t\t\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\t\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\t\t\tuserOperation.maxFeePerGas = 0n;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\n\t\t\t\tlet userOperationToEstimate: UserOperationV6 | UserOperationV7;\n\t\t\t\tif (isV06) {\n\t\t\t\t\tlet initCode = \"0x\";\n\t\t\t\t\tif (factoryAddress != null) {\n\t\t\t\t\t\tinitCode = factoryAddress;\n\n\t\t\t\t\t\tif (factoryData != null) {\n\t\t\t\t\t\t\tinitCode += factoryData.slice(2);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tuserOperationToEstimate = {\n\t\t\t\t\t\t...userOperation,\n\t\t\t\t\t\tinitCode: initCode,\n\t\t\t\t\t\tpaymasterAndData: \"0x\",\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tuserOperationToEstimate = {\n\t\t\t\t\t\t...userOperation,\n\t\t\t\t\t\tfactory: factoryAddress,\n\t\t\t\t\t\tfactoryData: factoryData,\n\t\t\t\t\t\tpaymaster: null,\n\t\t\t\t\t\tpaymasterVerificationGasLimit: null,\n\t\t\t\t\t\tpaymasterPostOpGasLimit: null,\n\t\t\t\t\t\tpaymasterData: null,\n\t\t\t\t\t};\n\n const parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n if(parallelPaymasterInitValues != null){\n if(\n !parallelPaymasterInitValues.paymasterData.endsWith(\"22e325a297439656\")\n ){\n throw new RangeError(\n \"Invalid paymasterData override, it must end with the PAYMASTER_SIG_MAGIC '22e325a297439656'.\"\n );\n }\n if(this.entrypointAddress != ENTRYPOINT_V9){\n throw new RangeError(\n \"parallelPaymasterInitValues only works with ep v0.9\"\n );\n }\n userOperationToEstimate.paymaster = parallelPaymasterInitValues.paymaster;\n userOperationToEstimate.paymasterVerificationGasLimit =\n parallelPaymasterInitValues.paymasterVerificationGasLimit;\n userOperationToEstimate.paymasterPostOpGasLimit =\n parallelPaymasterInitValues.paymasterPostOpGasLimit;\n userOperationToEstimate.paymasterData =\n parallelPaymasterInitValues.paymasterData;\n }\n\t\t\t\t}\n const validAfter = 0xffffffffffffn;\n const validUntil = 0xffffffffffffn;\n\n\t\t\t\tlet dummySignerSignaturePairs;\n\t\t\t\tif (overrides.dummySignerSignaturePairs != null) {\n if(overrides.expectedSigners != null){\n throw new RangeError(\n\t\t\t\t\t\t\t\"Can't use both dummySignerSignaturePairs and expectedSigners overrides.\",\n\t\t\t\t\t\t);\n }\n\t\t\t\t\tif (overrides.dummySignerSignaturePairs.length < 1) {\n\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t\"Number of dummySignerSignaturePairs can't be less than 1\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tdummySignerSignaturePairs = overrides.dummySignerSignaturePairs;\n\t\t\t\t} else {\n if(overrides.expectedSigners == null){\n dummySignerSignaturePairs = [EOADummySignerSignaturePair];\n }else{\n const isInit = factoryAddress != null && factoryAddress != \"0x\";\n dummySignerSignaturePairs = SafeAccount.createDummySignerSignaturePairForExpectedSigners(\n overrides.expectedSigners,\n {\n isInit,\n webAuthnSharedSigner,\n eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier,\n webAuthnSignerFactory,\n webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode,\n validAfter,\n validUntil,\n }\n )\n }\n\t\t\t\t}\n\t\t\t\tuserOperation.signature =\n\t\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\t\t\tdummySignerSignaturePairs,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalidAfter,\n\t\t\t\t\t\t\tvalidUntil,\n\t\t\t\t\t\t\twebAuthnSharedSigner,\n isMultiChainSignature: overrides.isMultiChainSignature\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t[preVerificationGas, verificationGasLimit, callGasLimit] =\n\t\t\t\t\tawait this.baseEstimateUserOperationGas(\n\t\t\t\t\t\tuserOperationToEstimate,\n\t\t\t\t\t\tbundlerRpc,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstateOverrideSet: overrides.state_override_set,\n\t\t\t\t\t\t\tisMultiChainSignature:overrides.isMultiChainSignature\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\tverificationGasLimit +=\n\t\t\t\t\tBigInt(dummySignerSignaturePairs.length) * 55_000n;\n\n\t\t\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc cant't be null if preVerificationGas,\" +\n\t\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\ttypeof overrides.preVerificationGas === \"bigint\" &&\n\t\t\toverrides.preVerificationGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"preVerificationGas overrid can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.verificationGasLimit === \"bigint\" &&\n\t\t\toverrides.verificationGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"verificationGasLimit overrid can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.callGasLimit === \"bigint\" &&\n\t\t\toverrides.callGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"callGasLimit overrid can't be negative\");\n\t\t}\n\n\t\tuserOperation.preVerificationGas = overrides.preVerificationGas ??\n preVerificationGas * BigInt((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100n;\n\n\t\tuserOperation.verificationGasLimit = overrides.verificationGasLimit ??\n verificationGasLimit * BigInt((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100n;\n\n\t\tuserOperation.callGasLimit = overrides.callGasLimit ??\n callGasLimit * BigInt((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) / 100n;\n\n\t\treturn [userOperation, factoryAddress, factoryData];\n\t}\n \n\t/**\n\t * create a useroperation signature\n\t * @param useroperation - useroperation to sign\n\t * @param privateKeys - for the signers\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic static baseSignSingleUserOperation(\n\t\tuseroperation: UserOperationV6 | UserOperationV7,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\tentrypointAddress: string,\n\t\tsafe4337ModuleAddress: string,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tisMultiChainSignature?: boolean;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tif (privateKeys.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one privateKey\");\n\t\t}\n\t\tif (chainId < 0n) {\n\t\t\tthrow new RangeError(\"chainId can't be negative\");\n\t\t}\n\t\tif (validAfter < 0n) {\n\t\t\tthrow new RangeError(\"validAfter can't be negative\");\n\t\t}\n\t\tif (validUntil < 0n) {\n\t\t\tthrow new RangeError(\"validUntil can't be negative\");\n\t\t}\n\n\t\tconst userOperationEip712Hash = SafeAccount.getUserOperationEip712Hash(\n\t\t\tuseroperation,\n\t\t\tchainId,\n\t\t\t{\n\t\t\t\tvalidAfter,\n\t\t\t\tvalidUntil,\n\t\t\t\tentrypointAddress,\n\t\t\t\tsafe4337ModuleAddress,\n\t\t\t},\n\t\t);\n\n const signerSignaturePairs: SignerSignaturePair[] = [];\n\t\tfor (const privateKey of privateKeys) {\n\t\t\tconst wallet = new Wallet(privateKey);\n\t\t\tconst signature = wallet.signingKey.sign(\n\t\t\t\tuserOperationEip712Hash,\n\t\t\t).serialized;\n signerSignaturePairs.push({\n signer: wallet.address,\n signature\n });\n\t\t}\n\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n signerSignaturePairs,\n\t\t\t{\n\t\t\t\tvalidAfter,\n\t\t\t\tvalidUntil,\n isMultiChainSignature:overrides.isMultiChainSignature\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * compute the deterministic address for a webauthn proxy verifier based on a\n\t * webauthn public key(x, y)\n\t * @param x - webauthn public key x parameter\n\t * @param y - webauthn public key y parameter\n\t * @param overrides - overrides for the default values\n\t * @returns webauthn verifier address\n\t */\n\tpublic static createWebAuthnSignerVerifierAddress(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): string {\n\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\tconst webAuthnSignerFactory =\n\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\tconst webAuthnSignerSingleton =\n\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n\n\t\tif (\n\t\t\teip7212WebAuthnPrecompileVerifier.length != 42 ||\n\t\t\teip7212WebAuthnPrecompileVerifier.slice(0, 38) != ZeroAddress.slice(0, 38)\n\t\t) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"Invalide precompile address. \" +\n\t\t\t\t\t\"It should have the format 0x000000000000000000000000000000000000____\",\n\t\t\t);\n\t\t}\n\t\tconst codeHash = keccak256(\n\t\t\tsolidityPacked(\n\t\t\t\t[\"bytes\", \"uint256\", \"uint256\", \"uint256\", \"uint256\"],\n\t\t\t\t[\n\t\t\t\t\toverrides.webAuthnSignerProxyCreationCode??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\t\t\twebAuthnSignerSingleton,\n\t\t\t\t\tx,\n\t\t\t\t\ty,\n\t\t\t\t\t\"0x\" +\n\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier.slice(-4) +\n\t\t\t\t\t\teip7212WebAuthnContractVerifier.slice(2),\n\t\t\t\t],\n\t\t\t),\n\t\t);\n\n\t\tconst proxyAdd = solidityPackedKeccak256(\n\t\t\t[\"bytes1\", \"address\", \"bytes32\", \"bytes32\"],\n\t\t\t[\n\t\t\t\t\"0xff\",\n\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000000\",\n\t\t\t\tcodeHash,\n\t\t\t],\n\t\t).slice(-40);\n\n\t\treturn \"0x\" + proxyAdd;\n\t}\n\n\t/**\n\t * formate a list of eip712 signatures to a useroperation signature\n\t * @param signerSignaturePairs - a list of a pair of a signer and it's signature\n\t * @param overrides - overrides for the default values\n\t * @returns signature\n\t */\n\tpublic static formatSignaturesToUseroperationSignature(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toverrides: WebAuthnSignatureOverrides = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tconst signature = this.buildSignaturesFromSingerSignaturePairs(\n\t\t\tsignerSignaturePairs,\n\t\t\toverrides,\n\t\t);\n\n\t\tif(overrides.isMultiChainSignature){\n\t\t\tif(overrides.multiChainMerkleProof != null){\n const merkleProofLength =\n overrides.multiChainMerkleProof.slice(2).length; // wihout 0x prefix\n\t\t\t\tif(\n // 1 byte has a length of 2 hex chars\n // minimum proof consist of at least two hashes, 2 * 2 * 32 = 128\n\t\t\t\t\tmerkleProofLength < 128 ||\n // a valid proof length should be a multiple of 2 * 32 = 64\n\t\t\t\t\tmerkleProofLength % 64 != 0\n\t\t\t\t){\n\t\t\t\t\tthrow new RangeError(\"invalid multiChainMerkleProof length.\");\n\t\t\t\t}\n\t\t\t\tconst merkleTreeDepth = (merkleProofLength / 64) - 1;\n\t\t\t\tlet merkleTreeDepthHex = merkleTreeDepth.toString(16);\n\n // create a 0x prefixed hex with an even length of chars\n if(merkleTreeDepthHex.length % 2 == 0){\n merkleTreeDepthHex = \"0x\" + merkleTreeDepthHex;\n }else{\n merkleTreeDepthHex = \"0x0\" + merkleTreeDepthHex;\n }\n\n\t\t\t\treturn solidityPacked(\n\t\t\t\t\t[\"bytes1\", \"uint48\", \"uint48\", \"bytes\"],\n\t\t\t\t\t[\n merkleTreeDepthHex,\n validAfter,\n validUntil,\n overrides.multiChainMerkleProof + signature.slice(2)\n ],\n\t\t\t\t);\n\t\t\t}else{\n //no proof means a single useroperation\n\t\t\t\treturn solidityPacked(\n\t\t\t\t\t[\"bytes1\", \"uint48\", \"uint48\", \"bytes\"],\n\t\t\t\t\t[\n \"0x00\", // single useroperation - merkle depth is 0\n validAfter,\n validUntil,\n signature\n ],\n\t\t\t\t);\n\t\t\t}\n\t\t}else{\n\t\t\treturn solidityPacked(\n\t\t\t\t[\"uint48\", \"uint48\", \"bytes\"],\n\t\t\t\t[validAfter, validUntil, signature],\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * calculate a signer public address lowercase\n\t * @param signer - a signer to compute address for\n\t * @param overrides - overrides for the default values\n\t * @returns signer address\n\t */\n\tpublic static getSignerLowerCaseAddress(\n\t\tsigner: Signer,\n\t\toverrides: WebAuthnSignatureOverrides = {},\n\t): string {\n\t\tif (typeof signer == \"string\") {\n\t\t\treturn signer.toLowerCase();\n\t\t} else {\n\t\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\t\tconst webAuthnSignerFactory =\n\t\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\t\tconst webAuthnSignerSingleton =\n\t\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\treturn SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\tsigner.x,\n\t\t\t\tsigner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t).toLowerCase();\n\t\t}\n\t}\n\n\t/**\n\t * sorts a list of signerSginaturesPairs in place based on the signer\n\t * public address, as the signatures needs to be sorted to be validated\n\t * by a safe account\n\t * @param signer - a signer to compute address for\n\t * @param overrides - overrides for the default values\n\t */\n\tpublic static sortSignatures(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toverrides: WebAuthnSignatureOverrides = {},\n\t) {\n\t\tsignerSignaturePairs.sort((left, right) =>\n\t\t\tSafeAccount.getSignerLowerCaseAddress(\n\t\t\t\tleft.signer,\n\t\t\t\toverrides,\n\t\t\t).localeCompare(\n\t\t\t\tSafeAccount.getSignerLowerCaseAddress(right.signer, overrides),\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * formate a list of eip712 signatures to a safe signature(without the time range)\n\t * @param signerSignaturePairs - a list of a pair of a signer and it's signature\n\t * @param overrides - overrides for the default values\n\t * @returns signature\n\t */\n\tpublic static buildSignaturesFromSingerSignaturePairs(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): string {\n\t\tSafeAccount.sortSignatures(\n\t\t\tsignerSignaturePairs,\n\t\t\twebAuthnSignatureOverrides,\n\t\t);\n\t\tconst start = 65 * signerSignaturePairs.length;\n\t\tconst { segments } = signerSignaturePairs.reduce(\n\t\t\t({ segments, offset }, { signer, signature, isContractSignature }) => {\n\t\t\t\tisContractSignature = isContractSignature || typeof signer != \"string\";\n\t\t\t\tif (isContractSignature) {\n\t\t\t\t\tif (typeof signer != \"string\") { //webauthn signature\n //check if this is a webAuthn signature to replace \n //the signer address with the shared signer address\n //if init\n\t\t\t\t\t\tif (webAuthnSignatureOverrides.isInit == null) {\n\t\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t\t\"Must define isInit parameter when using WebAuthn\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (webAuthnSignatureOverrides.isInit) {\n\t\t\t\t\t\t\tconst webauthnsharedsigner =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSharedSigner ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n\t\t\t\t\t\t\tsigner = webauthnsharedsigner;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\t\t\t\t\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\t\t\t\t\t\tconst webAuthnSignerFactory =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerFactory ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\t\t\t\t\t\tconst webAuthnSignerSingleton =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerSingleton ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n webAuthnSignatureOverrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\t\t\t\t\tsigner = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\t\t\t\t\tsigner.x,\n\t\t\t\t\t\t\t\tsigner.y,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\t\t\t\t\twebAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n }\n return {\n segments: [\n ...segments,\n ethers.solidityPacked(\n [\"uint256\", \"uint256\", \"uint8\"],\n [signer, start + offset, 0],\n ),\n ],\n offset: offset + 32 + ethers.dataLength(signature),\n };\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t...segments,\n\t\t\t\t\t\t\tethers.solidityPacked([\"bytes\"], [signature]),\n\t\t\t\t\t\t],\n\t\t\t\t\t\toffset: offset,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ segments: [] as string[], offset: 0 },\n\t\t);\n\t\treturn ethers.concat([\n\t\t\t...segments,\n\t\t\t...signerSignaturePairs.map(({ signer, signature, isContractSignature }) => {\n isContractSignature = isContractSignature || typeof signer != \"string\";\n if (isContractSignature) {\n return ethers.solidityPacked(\n [\"uint256\", \"bytes\"],\n [ethers.dataLength(signature), signature],\n )\n }else{\n //only append signatures if a contract signature\n return \"0x\";\n }\n },\n\t\t\t),\n\t\t]);\n\t}\n\n\t/**\n\t * encode webauthn signature from WebauthnSignatureData\n\t * @param signatureData - signature data to format\n\t * @returns formatted signature\n\t */\n\tpublic static createWebAuthnSignature(\n\t\tsignatureData: WebauthnSignatureData,\n\t): string {\n\t\treturn ethers.AbiCoder.defaultAbiCoder().encode(\n\t\t\t[\"bytes\", \"bytes\", \"uint256[2]\"],\n\t\t\t[\n\t\t\t\tnew Uint8Array(signatureData.authenticatorData),\n\t\t\t\tsignatureData.clientDataFields,\n\t\t\t\tsignatureData.rs,\n\t\t\t],\n\t\t);\n\t}\n\n\t/**\n\t * create a swapOwner metatransaction and create a metatransaction to\n\t * deploy a webauthn verifier owner if not deployed and it will automatically\n\t * fetch the prevowner needed for the swap\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * (to get the prevOwner paramter) and to check if a webauthn newowner verifier \n * is already deployed.\n\t * @param newOwner - newOwner public address\n\t * @param oldOwner - oldOwner to replace public address\n\t * @param overrides - overrides for the default values\n\t * @param overrides.prevOwner - if set, it will be used as the previous owner and\n\t * nideRpcUrl won't be used to fetch it\n\t * @returns a promise of a list of metaTransactions\n\t */\n\tpublic async createSwapOwnerMetaTransactions(\n\t\tnodeRpcUrl: string,\n\t\tnewOwner: Signer,\n\t\toldOwner: Signer,\n\t\toverrides: {\n\t\t\tprevOwner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t webAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction[]> {\n\t\tlet deployNewOwnerSignerMetaTransaction: MetaTransaction | null = null;\n\t\tlet newOwnerT: string;\n\t\tlet oldOwnerT: string;\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\tif (typeof newOwner != \"string\") {\n\t\t\tnewOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\tnewOwner.x,\n\t\t\t\tnewOwner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst newOwnerCode = await sendEthGetCodeRequest(\n\t\t\t\tnodeRpcUrl,\n\t\t\t\tnewOwnerT,\n\t\t\t\t\"latest\",\n\t\t\t);\n\t\t\tconst newOwnerNotDeployed = newOwnerCode.length < 3;\n\t\t\tif (newOwnerNotDeployed) {\n\t\t\t\tdeployNewOwnerSignerMetaTransaction =\n\t\t\t\t\tSafeAccount.createDeployWebAuthnVerifierMetaTransaction(\n\t\t\t\t\t\tnewOwner.x,\n\t\t\t\t\t\tnewOwner.y,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnewOwnerT = newOwner;\n\t\t}\n\t\tif (typeof oldOwner != \"string\") {\n\t\t\toldOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\toldOwner.x,\n\t\t\t\toldOwner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\toldOwnerT = oldOwner;\n\t\t}\n\n\t\tlet prevOwnerT = overrides.prevOwner;\n\t\tif (prevOwnerT == null) {\n\t\t\tconst owners = await this.getOwners(nodeRpcUrl);\n\t\t\tconst oldOwnerIndex = owners.indexOf(oldOwnerT);\n\t\t\tif (oldOwnerIndex == -1) {\n\t\t\t\tthrow new RangeError(\"oldOwner is not a current owner.\");\n\t\t\t} else if (oldOwnerIndex == 0) {\n\t\t\t\tprevOwnerT = \"0x0000000000000000000000000000000000000001\";\n\t\t\t} else {\n\t\t\t\tprevOwnerT = owners[oldOwnerIndex - 1];\n\t\t\t}\n\t\t}\n\t\tconst swapMetaTransaction = this.createStandardSwapOwnerMetaTransaction(\n\t\t\tnewOwnerT,\n\t\t\toldOwnerT,\n\t\t\tprevOwnerT,\n\t\t);\n\t\tif (deployNewOwnerSignerMetaTransaction == null) {\n\t\t\treturn [swapMetaTransaction];\n\t\t} else {\n\t\t\treturn [deployNewOwnerSignerMetaTransaction, swapMetaTransaction];\n\t\t}\n\t}\n\n\t/**\n\t * create a removeOwner metatransaction, and fetch the prevowner\n\t * needed for the remove\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * (to get the prevOwner paramter).\n\t * @param ownerToDelete - owner to delete public address\n\t * @param threshold - new threshold\n\t * @param overrides - overrides for the default values\n\t * @param overrides.prevOwner - if set, it will be used as the previous owner and\n\t * nideRpcUrl won't be used to fetch it\n\t * @returns a promise of a metaTransaction\n\t */\n\tpublic async createRemoveOwnerMetaTransaction(\n\t\tnodeRpcUrl: string,\n\t\townerToDelete: Signer,\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tprevOwner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t webAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction> {\n\t\tlet ownerToDeleteT: string;\n\n\t\tif (typeof ownerToDelete != \"string\") {\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\townerToDeleteT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\townerToDelete.x,\n\t\t\t\townerToDelete.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\townerToDeleteT = ownerToDelete;\n\t\t}\n\n\t\tlet prevOwnerT = overrides.prevOwner;\n\t\tif (prevOwnerT == null) {\n\t\t\tconst owners = await this.getOwners(nodeRpcUrl);\n\t\t\tconst ownerToDeleteIndex = owners.indexOf(ownerToDeleteT);\n\t\t\tif (ownerToDeleteIndex == -1) {\n\t\t\t\tthrow new RangeError(\"ownerToDelete is not a current owner.\");\n\t\t\t} else if (ownerToDeleteIndex == 0) {\n\t\t\t\tprevOwnerT = \"0x0000000000000000000000000000000000000001\";\n\t\t\t} else {\n\t\t\t\tprevOwnerT = owners[ownerToDeleteIndex - 1];\n\t\t\t}\n\t\t}\n\t\treturn this.createStandardRemoveOwnerMetaTransaction(\n\t\t\townerToDeleteT,\n\t\t\tthreshold,\n\t\t\tprevOwnerT,\n\t\t);\n\t}\n\n /**\n\t * create an addOwner metatransaction and create a metatransaction to\n\t * deploy a webauthn verifier owner if it is not deployed\n\t * @param newOwner - newOwner public address\n\t * @param threshold - new threshold\n\t * @param overrides - overrides for the default values\n * @param overrides.nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * (to check if the new webauthn owner is deployed or not).\n\t * @returns a promise of a list of metaTransactions\n\t */\n\tpublic async createAddOwnerWithThresholdMetaTransactions(\n\t\tnewOwner: Signer,\n\t\tthreshold: number,\n\t\toverrides: {\n nodeRpcUrl?: string,\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t webAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction[]> {\n\t\tlet deployNewOwnerSignerMetaTransaction: MetaTransaction | null = null;\n\t\tlet newOwnerT: string;\n\n\t\tif (typeof newOwner != \"string\") {\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\tnewOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\tnewOwner.x,\n\t\t\t\tnewOwner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n if(overrides.nodeRpcUrl == null){\n\t\t\t\tthrow new RangeError(\n \"overrides.nodeRpcUrl can't be null if adding a webauthn owner\");\n }\n\t\t\tconst newOwnerCode = await sendEthGetCodeRequest(\n\t\t\t\toverrides.nodeRpcUrl,\n\t\t\t\tnewOwnerT,\n\t\t\t\t\"latest\",\n\t\t\t);\n\t\t\tconst newOwnerNotDeployed = newOwnerCode.length < 3;\n\t\t\tif (newOwnerNotDeployed) {\n\t\t\t\tdeployNewOwnerSignerMetaTransaction =\n\t\t\t\t\tSafeAccount.createDeployWebAuthnVerifierMetaTransaction(\n\t\t\t\t\t\tnewOwner.x,\n\t\t\t\t\t\tnewOwner.y,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnewOwnerT = newOwner;\n\t\t}\n\t\t\n const addMetaTransaction = this.createStandardAddOwnerWithThresholdMetaTransaction(\n\t\t\tnewOwnerT,\n threshold\n\t\t);\n\t\tif (deployNewOwnerSignerMetaTransaction == null) {\n\t\t\treturn [addMetaTransaction];\n\t\t} else {\n\t\t\treturn [deployNewOwnerSignerMetaTransaction, addMetaTransaction];\n\t\t}\n\t}\n\n\t/**\n\t * create a standard addOwner metatransaction\n\t * @param newOwner - newOwner public address\n\t * @param threshold - new threshold\n\t * @returns a metaTransaction\n\t */\n\tpublic createStandardAddOwnerWithThresholdMetaTransaction(\n\t\tnewOwner: string,\n\t\tthreshold: number,\n\t): MetaTransaction {\n\t\tconst functionSelector = \"0x0d582f13\"; //addOwnerWithThreshold\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\n\t\t\t\t\"address\", //owner\n\t\t\t\t\"uint256\", //_threshold\n\t\t\t],\n\t\t\t[newOwner, threshold],\n\t\t);\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a standard swapOwner metatransaction\n\t * @param newOwner - newOwner public address\n\t * @param oldOwner - oldOwner public address\n\t * @param prevOwner - prevOwner public address in the owners linked list\n\t * @returns a metaTransaction\n\t */\n\tpublic createStandardSwapOwnerMetaTransaction(\n\t\tnewOwner: string,\n\t\toldOwner: string,\n\t\tprevOwner: string,\n\t): MetaTransaction {\n\t\tconst functionSelector = \"0xe318b52b\"; //swapOwner\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\n\t\t\t\t\"address\", //prevOwner\n\t\t\t\t\"address\", //oldOwner\n\t\t\t\t\"address\", //newOwner\n\t\t\t],\n\t\t\t[\n\t\t\t\tprevOwner, //SENTINEL_OWNERS\n\t\t\t\toldOwner,\n\t\t\t\tnewOwner,\n\t\t\t],\n\t\t);\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a standard removeOwner metatransaction\n\t * @param ownerToDelete - owner to delete public address\n\t * @param threshold - new threshold\n\t * @param prevOwner - prevOwner public address in the owners linked list\n\t * @returns a metaTransaction\n\t */\n\tpublic createStandardRemoveOwnerMetaTransaction(\n\t\townerToDelete: string,\n\t\tthreshold: number,\n\t\tprevOwner: string,\n\t): MetaTransaction {\n\t\tconst functionSelector = \"0xf8dc5dd9\"; //removeOwner\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\n\t\t\t\t\"address\", //prevOwner\n\t\t\t\t\"address\", //owner\n\t\t\t\t\"uint256\", //_threshold\n\t\t\t],\n\t\t\t[\n\t\t\t\tprevOwner, //SENTINEL_OWNERS\n\t\t\t\townerToDelete,\n\t\t\t\tthreshold,\n\t\t\t],\n\t\t);\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n /**\n\t * create a change threshold metatransaction \n\t * @param threshold - new threshold\n\t * @returns a metaTransactions\n\t */\n\tpublic createChangeThresholdMetaTransaction(threshold: number): MetaTransaction {\n if(threshold < 1){\n throw new RangeError(\"threshold can't be less than 1.\");\n }\n\n\t\tconst changeThresholdCallData = createCallData(\n\t\t\t\"0x694e80c3\", //changeThreshold\n\t\t\t[\"uint256\"],\n\t\t\t[threshold],\n\t\t);\n\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: changeThresholdCallData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n /**\n\t * create an approve hash metatransaction \n\t * @param hashToApprove - hash to approve\n\t * @returns a metaTransactions\n\t */\n\tpublic createApproveHashMetaTransaction(hashToApprove: string): MetaTransaction {\n\t\tconst approveHashCallData = createCallData(\n\t\t\t\"0xd4d9bdcd\", //approveHash\n\t\t\t[\"bytes32\"],\n\t\t\t[hashToApprove],\n\t\t);\n\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: approveHashCallData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a deploy webauthn verifier metatransaction\n\t * @param x - webauthn public key x parameter\n\t * @param y - webauthn public key y parameter\n\t * @param overrides - overrides for the default values\n\t * @returns a metaTransaction\n\t */\n\tpublic static createDeployWebAuthnVerifierMetaTransaction(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t} = {},\n\t): MetaTransaction {\n\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\tconst webAuthnSignerFactory =\n\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\n\t\tconst createDeterministicWebAuthnVerifierOwnerCallData = createCallData(\n\t\t\t\"0x0d2f0489\", //createSigner\n\t\t\t[\"uint256\", \"uint256\", \"uint176\"],\n\t\t\t[\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\t\"0x\" +\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier.slice(-4) +\n\t\t\t\t\teip7212WebAuthnContractVerifier.slice(2),\n\t\t\t],\n\t\t);\n\n\t\treturn {\n\t\t\tto: webAuthnSignerFactory,\n\t\t\tvalue: 0n,\n\t\t\tdata: createDeterministicWebAuthnVerifierOwnerCallData,\n\t\t};\n\t}\n\n\t/**\n\t * fetches a list of the account owners public addresses\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise of a list of owners public addresses\n\t */\n\tpublic async getOwners(nodeRpcUrl: string): Promise<string[]> {\n\t\tconst functionSignature = \"getOwners()\";\n\t\tconst functionSelector = getFunctionSelector(functionSignature);\n\t\tconst callData = createCallData(functionSelector, [], []);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst getOwnersResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n\t\t);\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst decodedCalldata = abiCoder.decode(\n\t\t\t[\"address[]\"],\n\t\t\tgetOwnersResult,\n\t\t);\n\n\t\treturn decodedCalldata[0];\n\t}\n\n\t/**\n\t * fetches the current threshold\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise with the current threshold\n\t */\n\tpublic async getThreshold(nodeRpcUrl: string): Promise<number> {\n\t\tconst functionSelector = \"0xe75235b8\"; //getThreshold\n\t\tconst callData = createCallData(functionSelector, [], []);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst getThresholdResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n\t\t);\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst decodedCalldata = abiCoder.decode(\n\t\t\t[\"uint256\"],\n\t\t\tgetThresholdResult,\n\t\t);\n\n\t\treturn Number(decodedCalldata[0]);\n\t}\n \n /**\n\t * fetches a list of the account owners public addresses\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise of a list of owners public addresses and\n * next Start of the next page\n\t */\n\tpublic async getModules(\n nodeRpcUrl: string, \n overrides: {\n\t\t\tstart?: string;\n pageSize?: bigint\n\t\t} = {}\n ): Promise<[string[], string]> {\n try{\n let start = overrides.start;\n if(start == null){\n start = \"0x0000000000000000000000000000000000000001\";\n }\n let pageSize = overrides.pageSize;\n if(pageSize == null){\n pageSize = 10n;\n }\n\n const callData = createCallData(\n \"0xcc2f8452\", //getModulesPaginated(address,uint256)\n [\"address\", \"uint256\"],\n [start, pageSize]\n );\n\n const ethCallParams = {\n to: this.accountAddress,\n data: callData,\n };\n const getModulesResult = await sendEthCallRequest(\n nodeRpcUrl,\n ethCallParams,\n \"latest\",\n );\n if (getModulesResult == \"0x\"){\n throw new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"getModules retuned an empty result, the target account is \" + \n \"probably not deployed yet.\",\n\t\t\t\t);\n }\n const abiCoder = AbiCoder.defaultAbiCoder();\n const decodedCalldata = abiCoder.decode(\n [\"address[]\", \"address\"],\n getModulesResult,\n );\n return [decodedCalldata[0], decodedCalldata[1]];\n }catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"getModules failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n /**\n\t * check if a module is enabled \n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @param moduleAddress - the module address to check if enabled \n\t * @returns a promise of boolean \n\t */\n\tpublic async isModuleEnabled(\n nodeRpcUrl: string, moduleAddress: string\n ): Promise<boolean> {\n\t\tconst functionSignature = \"isModuleEnabled(address)\";\n\t\tconst functionSelector = getFunctionSelector(functionSignature);\n\t\tconst callData = createCallData(\n functionSelector, [\"address\"], [moduleAddress]);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst isModuleEnabledResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n\t\t);\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst decodedCalldata = abiCoder.decode(\n\t\t\t[\"bool\"],\n\t\t\tisModuleEnabledResult,\n\t\t);\n\n\t\treturn decodedCalldata[0];\n\t}\n \n /**\n\t * create a list of dummy signer signature pair list based on the expected signers\n\t * @param expectedSigners - webauthn public key x parameter\n\t * @param webAuthnSignatureOverrides - overrides for the default values\n\t * @returns a list of dummy SignerSignaturePair\n\t */\n\tpublic static createDummySignerSignaturePairForExpectedSigners(\n\t\texpectedSigners: Signer[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n ): SignerSignaturePair[] {\n const signers = [...expectedSigners]; \n const dummySignerSignatures: SignerSignaturePair[] = [];\n for (let signer of signers){\n let signerSignaturePair: SignerSignaturePair;\n if (typeof signer == \"string\") {\n signerSignaturePair = EOADummySignerSignaturePair;\n }else{\n if (webAuthnSignatureOverrides.isInit == null) {\n throw new RangeError(\n \"Must define isInit parameter when using WebAuthn\",\n );\n }\n signerSignaturePair = { ...WebauthnDummySignerSignaturePair };\n if (webAuthnSignatureOverrides.isInit) {\n const webauthnsharedsigner =\n webAuthnSignatureOverrides.webAuthnSharedSigner ??\n SafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n signerSignaturePair.signer = webauthnsharedsigner;\n } else {\n const eip7212WebAuthnPrecompileVerifier =\n webAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n const eip7212WebAuthnContractVerifier =\n webAuthnSignatureOverrides.eip7212WebAuthnContractVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n const webAuthnSignerFactory =\n webAuthnSignatureOverrides.webAuthnSignerFactory ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n const webAuthnSignerSingleton =\n webAuthnSignatureOverrides.webAuthnSignerSingleton ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n webAuthnSignatureOverrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n signerSignaturePair.signer = SafeAccount.createWebAuthnSignerVerifierAddress(\n signer.x,\n signer.y,\n {\n eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier,\n webAuthnSignerFactory,\n webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n },\n );\n }\n }\n dummySignerSignatures.push(signerSignaturePair);\n }\n return dummySignerSignatures;\n }\n \n /**\n\t * verify a webauthn signature against a signer and a message hash \n * @note: this function works by constructing the bytecode of a webatuhn\n * verifying contract proxy that represent the input signer, then overriding\n * an arbitrary address code and caling \"isValidSignature\" using eth_call \n * this way we can check a signature even if the verifying contract is not\n * deployed\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @param signer - a signer to check the signature against \n\t * @param messageHash - a messageHash to check the signature against \n\t * @param signature - a webauthn signature to check\n\t * @param overrides - overrides for the default values\n\t * @returns a promise of boolean - True if a valid signature\n\t */\n public static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string,\n signer: WebauthnPublicKey,\n messageHash: string, \n signature: string,\n overrides:{\n eip7212WebAuthnPrecompileVerifier?: string,\n eip7212WebAuthnContractVerifier?: string,\n webAuthnSignerSingleton?: string,\n } = {}\n ):Promise<boolean> {\n if (messageHash.length != 66 || messageHash.slice(0, 2) != \"0x\") {\n\t\t\tthrow new RangeError(\n\t\t\t \"Invalide messageHash ,must be a 0x prefixed keccak256 hash.\",\n\t\t\t);\n\t\t}\n\n const eip7212WebAuthnPrecompileVerifier =\n overrides.eip7212WebAuthnPrecompileVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n const eip7212WebAuthnContractVerifier =\n overrides.eip7212WebAuthnContractVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n const webAuthnSignerSingleton =\n overrides.webAuthnSignerSingleton ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n \n if (\n\t\t\teip7212WebAuthnPrecompileVerifier.length != 42 ||\n\t\t\teip7212WebAuthnPrecompileVerifier.slice(0, 38) != ZeroAddress.slice(0, 38)\n\t\t) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"Invalide precompile address. \" +\n \"It should have the format 0x000000000000000000000000000000000000____\",\n\t\t\t);\n\t\t}\n\t\tconst functionSelector = \"0x1626ba7e\"; //isValidSignature(bytes32,bytes)\n\t\tconst callData = createCallData(\n functionSelector,\n [\"bytes32\", \"bytes\"],\n [messageHash, signature]\n );\n \n const arbitraryAddress = \"0x1111111111111111111111111111111111111111\";\n\t\tconst ethCallParams = {\n\t\t\tto: arbitraryAddress,\n\t\t\tdata: callData,\n\t\t};\n const deployedByteCode = SafeAccount.createSafeWebAuthnSignerProxyDeployedByteCode(\n signer,\n eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier,\n webAuthnSignerSingleton\n )\n\n\t\tconst isModuleEnabledResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n {[arbitraryAddress]: {\"code\": deployedByteCode}}\n\t\t);\n\n\t\tconst decodedCalldata = AbiCoder.defaultAbiCoder().decode(\n\t\t\t[\"bool\"],\n\t\t\tisModuleEnabledResult,\n\t\t);\n\n\t\treturn decodedCalldata[0];\n }\n\n private static createSafeWebAuthnSignerProxyDeployedByteCode(\n signer: WebauthnPublicKey, \n eip7212WebAuthnPrecompileVerifier: string,\n eip7212WebAuthnContractVerifier: string,\n webAuthnSignerSingleton: string,\n ):string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n const x = abiCoder.encode([\"uint256\"], [signer.x])\n const y = abiCoder.encode([\"uint256\"], [signer.y])\n const verifiers = abiCoder.encode(\n [\"uint176\"],\n [\n \"0x\" +\n\t\t\t\teip7212WebAuthnPrecompileVerifier.slice(-4) +\n\t\t\t\teip7212WebAuthnContractVerifier.slice(2),\n ]\n )\n const byteCode = \n \"0x608060408190527f\" + verifiers.slice(2) +\n \"3660b681018290527f\" + y.slice(2) +\n \"60a082018190527f\" + x.slice(2) + \n \"8285018190527f000000000000000000000000\" +\n webAuthnSignerSingleton.slice(2) +\n \"9490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033\";\n return byteCode;\n }\n\n /**\n * create MetaTransaction to enable a module\n * @param accountAddress - Safe account to enable the module for\n * @returns a MetaTransaction\n */\n public static createEnableModuleMetaTransaction(\n moduleAddress: string,\n accountAddress: string,\n ):MetaTransaction{\n const callData = createCallData(\n \"0x610b5925\", //\"enableModule(address)\"\n [\"address\"],\n [moduleAddress],\n );\n return {\n to:accountAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create a standard disable a module MetaTransaction\n * @param moduleAddress - Module to disable\n * @param prevModuleAddress - previous module to moudle to disable \n * @param accountAddress - Safe account to enable the module for\n * @returns a MetaTransaction\n */\n public async createDisableModuleMetaTransaction(\n\t\tnodeRpcUrl: string,\n moduleToDisableAddress: string,\n accountAddress: string,\n\t\toverrides: {\n\t\t\tprevModuleAddress?: string;\n\t\t\tmodulesStart?: string;\n modulesPageSize?: bigint\n\t\t} = {},\n ):Promise<MetaTransaction>{\n try{\n let prevModuleAddressT = overrides.prevModuleAddress;\n if (prevModuleAddressT == null) {\n const [modules, _] = await this.getModules(\n nodeRpcUrl,\n {\n start:overrides.modulesStart,\n pageSize:overrides.modulesPageSize\n }\n );\n \n const moduleToDisableIndex = modules.indexOf(moduleToDisableAddress);\n if (moduleToDisableIndex == -1) {\n throw new RangeError(\n \"moduleToDisable \" + moduleToDisableAddress +\n \" is not an enabled module.\"\n );\n } else if (moduleToDisableIndex == 0) {\n prevModuleAddressT = \"0x0000000000000000000000000000000000000001\";\n } else if (moduleToDisableIndex > 0) {\n prevModuleAddressT = modules[moduleToDisableIndex - 1];\n } else {\n throw new RangeError(\n \"Invalid module index for \" + moduleToDisableAddress);\n }\n }\n return SafeAccount.createStandardDisableModuleMetaTransaction(\n moduleToDisableAddress, prevModuleAddressT, accountAddress\n );\n } catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"createDisableModuleMetaTransaction failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n }\n\n /**\n * create a standard disable a module MetaTransaction\n * @param moduleAddress - Module to disable\n * @param prevModuleAddress - previous module to moudle to disable \n * @param accountAddress - Safe account to enable the module for\n * @returns a MetaTransaction\n */\n public static createStandardDisableModuleMetaTransaction(\n moduleAddress: string,\n prevModuleAddress: string,\n accountAddress: string,\n ):MetaTransaction{\n const callData = createCallData(\n \"0xe009cfde\", //\"disableModule(address)\"\n [\"address\", \"address\"],\n [prevModuleAddress, moduleAddress],\n );\n return {\n to:accountAddress,\n data: callData,\n value: 0n\n }\n }\n\n async simulateCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n\t\tnodeRpcUrl: string | null = null,\n chainId: bigint,\n\t\tmetaTransactions: MetaTransaction[],\n blockNumber: number | null = null,\n overrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t\tmultisendContractAddress?: string;\n callData?: string;\n createShareLink?: boolean;\n isInit?: boolean,\n\t\t} = {},\n ): Promise<{\n simulation:TenderlySimulationResult,\n callDataSimulationShareLink?: string,\n accountDeploymentSimulationShareLink?: string,\n }> {\n let isInit:boolean = false;\n if(nodeRpcUrl == null && overrides.isInit == null){\n throw new RangeError(\n \"nodeRpcUrl and overrides.isInit can't both be null\"\n );\n }else if(overrides.isInit == null){\n const accountNonce =\n await fetchAccountNonce(\n nodeRpcUrl as string,\n this.entrypointAddress,\n this.accountAddress,\n )\n isInit = accountNonce == 0n;\n }else{\n isInit = overrides.isInit;\n }\n\n let callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tif (metaTransactions.length == 1) {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataSingleTransaction(\n\t\t\t\t\tmetaTransactions[0],\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector:overrides.safeModuleExecutorFunctionSelector,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataBatchTransactions(\n\t\t\t\t\tmetaTransactions,\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector:\n\t\t\t\t\t\t\toverrides.safeModuleExecutorFunctionSelector,\n\t\t\t\t\t\tmultisendContractAddress: overrides.multisendContractAddress,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n\n const createShareLink = overrides.createShareLink?? true;\n if(createShareLink){\n return await simulateSenderCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n this.entrypointAddress,\n this.accountAddress,\n callData,\n isInit?this.factoryAddress:null,\n isInit?this.factoryData:null,\n blockNumber\n )\n }else{\n const simulation = await simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n this.entrypointAddress,\n this.accountAddress,\n callData,\n isInit?this.factoryAddress:null,\n isInit?this.factoryData:null,\n blockNumber\n )\n return {simulation};\n }\n }\n\n /**\n\t * create eip712 signing data for a safe message\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param message - message to hash\n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing a sae message\n\t */\n getSafeMessageEip712Data(\n chainId: bigint,\n message: string\n ): {\n domain: SafeMessageTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeMessageTypedMessageValue\n } {\n return getSafeMessageEip712Data(\n this.accountAddress,\n chainId,\n message\n );\n }\n}\n\n/**\n * generate Safe on-chain identifier as per https://docs.safe.global/sdk/onchain-tracking\n * @param project - project name\n * @param platform - \"Web\" or \"Mobile\" or \"Safe App\" or \"Widget\", defaults to \"Web\".\n * @param tool - tool used, defaults to \"abstractionkit\"\n * @param toolVersion - tool version, defaults to current abstractionkit version\n * @returns the onchain idenetifier as a hex string (not 0x prefixed)\n */\nfunction generateOnChainIdentifier(\n project: string,\n platform: \"Web\" | \"Mobile\" | \"Safe App\" | \"Widget\" = \"Web\",\n tool: string = \"abstractionkit\",\n toolVersion: string = \"0.2.41\"\n): string {\n const identifierPrefix = '5afe'; // Safe identifier prefix\n const identifierVersion = '00'; // First version\n const projectHash = keccak256(\"0x\" + Buffer.from(project, 'utf8').toString('hex')).slice(-20);\n const platformHash = keccak256(\"0x\" + Buffer.from(platform, 'utf8').toString('hex')).slice(-3);\n const toolHash = keccak256(\"0x\" + Buffer.from(tool, 'utf8').toString('hex')).slice(-3);\n const toolVersionHash = keccak256(\"0x\" + Buffer.from(toolVersion, 'utf8').toString('hex')).slice(-3);\n \n const projectHashEncoded = Buffer.from(projectHash, 'utf8').toString('hex');\n const platformHashEncoded = Buffer.from(platformHash, 'utf8').toString('hex');\n const toolHashEncoded = Buffer.from(toolHash, 'utf8').toString('hex');\n const toolVersionHashEncoded = Buffer.from(toolVersionHash, 'utf8').toString('hex');\n\n const res = `${identifierPrefix}${identifierVersion}${projectHashEncoded}${platformHashEncoded}${toolHashEncoded}${toolVersionHashEncoded}`;\n return res;\n}\n","import { keccak256 } from \"ethers\";\n\n/**\n * Hashes two values together using keccak256, sorting them so the smaller\n * value is always first to ensure consistent ordering.\n * @param left - The first hash value.\n * @param right - The second hash value.\n * @returns The keccak256 hash of the sorted pair.\n */\nfunction hashPair(left: string, right: string): string {\n if(left < right){\n return keccak256(left + right.slice(2));\n }else{\n return keccak256(right + left.slice(2));\n }\n}\n\n/**\n * Builds a Merkle tree and returns proofs for each input hash\n * @param hashes - Array of hash strings to include in the Merkle tree\n * @returns Array of MerkleProof objects containing the original hash, its proof path, and the root\n */\nexport function generateMerkleProofs(hashes: string[]): [string, string[]] {\n if (hashes.length === 0) {\n throw new Error('Cannot create Merkle tree with empty hash list');\n }\n\n // Store the original hashes and their indices\n const originalHashes = [...hashes];\n \n // Build the tree level by level\n let currentLevel = [...hashes];\n const tree: string[][] = [currentLevel];\n \n // Build tree from bottom to top\n while (currentLevel.length > 1) {\n const nextLevel: string[] = [];\n \n for (let i = 0; i < currentLevel.length; i += 2) {\n if (i + 1 < currentLevel.length) {\n // Hash pair of nodes\n nextLevel.push(hashPair(currentLevel[i], currentLevel[i + 1]));\n } else {\n // Odd number of nodes - duplicate the last one\n nextLevel.push(hashPair(currentLevel[i], currentLevel[i]));\n }\n }\n \n tree.push(nextLevel);\n currentLevel = nextLevel;\n }\n const root = tree[tree.length - 1][0];\n \n // Generate proof for each original hash\n const proofs: string[] = originalHashes.map((hash, index) => {\n const proofArr: string[] = [];\n let currentIndex = index;\n \n // Traverse from leaf to root, collecting sibling hashes\n for (let level = 0; level < tree.length - 1; level++) {\n const currentLevelNodes = tree[level];\n const isRightNode = currentIndex % 2 === 1;\n \n if (isRightNode) {\n // If we're the right node, sibling is on the left\n proofArr.push(currentLevelNodes[currentIndex - 1]);\n } else {\n // If we're the left node, sibling is on the right\n if (currentIndex + 1 < currentLevelNodes.length) {\n proofArr.push(currentLevelNodes[currentIndex + 1]);\n } else {\n // Odd number of nodes - we're paired with ourselves\n proofArr.push(currentLevelNodes[currentIndex]);\n }\n }\n \n // Move to parent index in next level\n currentIndex = Math.floor(currentIndex / 2);\n }\n let proof = root;\n proofArr.reverse().forEach((proofElement) =>{\n proof += proofElement.slice(2);\n });\n return proof;\n });\n return [root, proofs];\n}\n\n/**\n * Verifies a Merkle proof\n * @param hash - The original hash\n * @param proof - Array of sibling hashes from leaf to root\n * @param root - The expected Merkle root\n * @returns true if the proof is valid, false otherwise\n */\nexport function verifyMerkleProof(hash: string, proof: string[], root: string): boolean {\n let currentHash = hash;\n \n for (const siblingHash of proof) {\n // Determine order (smaller hash goes first for consistency)\n if (currentHash <= siblingHash) {\n currentHash = hashPair(currentHash, siblingHash);\n } else {\n currentHash = hashPair(siblingHash, currentHash);\n }\n }\n \n return currentHash === root;\n}\n","// Version 0.2.1\n// https://github.com/safe-fndn/safe-modules/blob/04e65efbce634e776cc8c1fbe90061f09e09a71b/modules/passkey/CHANGELOG.md?plain=1#L23\n//\nexport const DEFAULT_WEB_AUTHN_SHARED_SIGNER_V_0_2_1 =\n \"0x94a4F6affBd8975951142c3999aEAB7ecee555c2\";\nexport const DEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1=\n\t\t\"0x4E27b51350e6c2083EE19011120F50DAfEc5CA50\";\nexport const DEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1=\n\t\t\"0x1d31F259eE307358a26dFb23EB365939E8641195\";\nexport const DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1 =\n\t\t\"0x610100346100ad57601f6101b538819003918201601f19168301916001600160401b038311848410176100b2578084926080946040528339810103126100ad578051906001600160a01b03821682036100ad5760208101516040820151606090920151926001600160b01b03841684036100ad5760805260a05260c05260e05260405160ec90816100c98239608051816082015260a05181604d015260c051816027015260e0518160010152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe7f000000000000000000000000000000000000000000000000000000000000000060b63601527f000000000000000000000000000000000000000000000000000000000000000060a03601527f000000000000000000000000000000000000000000000000000000000000000036608001523660006080376000806056360160807f00000000000000000000000000000000000000000000000000000000000000005af43d600060803e60b1573d6080fd5b3d6080f3fea26469706673582212201660515548d15702d720bbc046b457ca85e941a4559ab9f9518488e4c82e5ee964736f6c634300081a0033\";\nexport const DEFAULT_WEB_AUTHN_PRECOMPILE_RIP_7951=\n\t\t\"0x0000000000000000000000000000000000000100\"; // EIP-7951\nexport const DEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1=\n\t\t\"0xc2b78104907F722DABAc4C69f826a522B2754De4\";\n","import { SafeAccount } from \"./SafeAccount\";\nimport {\n\tInitCodeOverrides,\n\tSigner,\n\tCreateUserOperationV9Overrides,\n SafeUserOperationTypedDataDomain,\n SafeUserOperationV9TypedMessageValue,\n SafeAccountSingleton,\n UserOperationToSign,\n MultiChainSignatureMerkleTreeRootTypedDataDomain,\n MultiChainSignatureMerkleTreeRootTypedMessageValue,\n SignerSignaturePair,\n WebAuthnSignatureOverrides,\n WebauthnPublicKey,\n} from \"./types\";\n\nimport { UserOperationV9, MetaTransaction, OnChainIdentifierParamsType } from \"../../types\";\nimport { EIP712_MULTI_CHAIN_OPERATIONS_TYPE, ENTRYPOINT_V9 } from \"src/constants\";\nimport { generateMerkleProofs } from \"./MerkleTree\";\nimport { TypedDataEncoder, Wallet } from \"ethers\";\nimport {\n\tDEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_PRECOMPILE_RIP_7951,\n\tDEFAULT_WEB_AUTHN_SHARED_SIGNER_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1,\n} from \"./constants\";\n\n/**\n * @class\n * Safe account variant that supports multi-chain signatures via Merkle trees.\n * Allows signing UserOperations for multiple chains with a single signature,\n * using EntryPoint v0.9 and EIP-712 typed data with Merkle proofs.\n *\n * Uses Safe Passkey module v0.2.1 WebAuthn verifiers by default,\n * with the Daimo P256 verifier instead of the FCL P256 verifier\n * used by the base SafeAccount class.\n * @see {@link https://github.com/safe-fndn/safe-modules/blob/04e65efbce634e776cc8c1fbe90061f09e09a71b/modules/passkey/CHANGELOG.md?plain=1#L23}\n */\nexport class SafeMultiChainSigAccountV1 extends SafeAccount {\n\tstatic readonly DEFAULT_ENTRYPOINT_ADDRESS = ENTRYPOINT_V9;\n\tstatic readonly DEFAULT_SAFE_4337_MODULE_ADDRESS =\n \"0x22939E839e3c0F479B713eAF95e0df128554AEAd\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS =\n\t\t\"0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47\";\n\n\t// Safe Passkey module v0.2.1 WebAuthn verifier defaults\n\tstatic readonly DEFAULT_WEB_AUTHN_SHARED_SIGNER: string = DEFAULT_WEB_AUTHN_SHARED_SIGNER_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_SINGLETON: string = DEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_FACTORY: string = DEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE = DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_PRECOMPILE: string = DEFAULT_WEB_AUTHN_PRECOMPILE_RIP_7951;\n\tstatic readonly DEFAULT_WEB_AUTHN_DAIMO_VERIFIER: string = DEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1;\n\n\t/**\n\t * Create a SafeMultiChainSigAccount instance for an existing or new account.\n\t * @param accountAddress - the Safe account address\n\t * @param overrides - optional overrides for module, entrypoint, and singleton addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string\n safeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_ENTRYPOINT_ADDRESS;\n \n super(\n accountAddress, safe4337ModuleAddress, entrypointAddress,\n {\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n safeAccountSingleton: overrides.safeAccountSingleton,\n }\n );\n\t}\n\n\t/**\n\t * calculate account address from initial owners signers\n\t * @param owners - list of account owners addresses\n\t * @param overrides - override values to change the initialization default values\n\t * @returns account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n // webAuthnSignerFactory, webAuthnSignerSingleton, and webAuthnSignerProxyCreationCode\n // are not defaulted here — the init code path only configures the shared signer\n // and its verifier. Deploying the deterministic verifier proxy and swapping it\n // for the shared signer happens later in createUserOperation (nonce == 0),\n // which defaults those fields.\n const modOverrides = { ...overrides,\n\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n\t\tconst [accountAddress, ,] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\tmodOverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\treturn accountAddress;\n\t}\n\n\t/**\n\t * To create and initialize a SafeAccount object from its\n\t * initial owners\n\t * @remarks\n\t * initializeNewAccount only needed when the smart account\n\t * have not been deployed yet and the account address is unknown.\n\t * @param owners - list of account owners signers\n\t * @param overrides - override values to change the initialization default values\n\t * @returns a SafeAccount object\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeMultiChainSigAccountV1 {\n\t\tlet isInitWebAuthn = false;\n\t\tlet x = 0n;\n\t\tlet y = 0n;\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tif (isInitWebAuthn) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\"Only one Webauthn signer is allowed during initialization\",\n\t\t\t\t\t);\n\t\t\t\t}\n if(owners.indexOf(owner) != 0){\n throw new RangeError(\n\t\t\t\t\t\t\"Webauthn owner has to be the first owner for an init transaction.\",\n\t\t\t\t\t);\n }\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t\tx = owner.x;\n\t\t\t\ty = owner.y;\n\t\t\t}\n\t\t}\n // webAuthnSignerFactory, webAuthnSignerSingleton, and webAuthnSignerProxyCreationCode\n // are not defaulted here — the init code path only configures the shared signer\n // and its verifier. Deploying the deterministic verifier proxy and swapping it\n // for the shared signer happens later in createUserOperation (nonce == 0),\n // which defaults those fields.\n const modOverrides = { ...overrides,\n\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n\t\tconst [accountAddress, factoryAddress, factoryData] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\tmodOverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst safe = new SafeMultiChainSigAccountV1(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton,\n\t\t});\n\t\tsafe.factoryAddress = factoryAddress;\n\t\tsafe.factoryData = factoryData;\n\t\tif (isInitWebAuthn) {\n\t\t\tsafe.isInitWebAuthn = true;\n\t\t\tsafe.x = x;\n\t\t\tsafe.y = y;\n\t\t}\n\n\t\treturn safe;\n\t}\n\n\t/**\n\t * create a useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V9\n\t * @param overrides.safe4337ModuleAddress - defaults to DEFAULT_SAFE_4337_MODULE_ADDRESS\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Hash(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n \n /**\n\t * create a useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * @param overrides.safe4337ModuleAddress - target module address \n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV9TypedMessageValue\n } \n {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Create the initializer callData for setting up a new Safe account.\n\t * @param owners - list of account owner signers\n\t * @param threshold - number of required signatures for execution\n\t * @param overrides - optional overrides for module and contract addresses\n\t * @returns hex-encoded initializer callData\n\t */\n\tpublic static createInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;\n\n\t\treturn SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\tthreshold,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress,\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t);\n\t}\n\n\t/**\n\t * create account factory address and factory data\n\t * @param owners - list of account owners signers\n\t * @param overrides - override values to change the initialization default values\n\t * @returns factoryAddress and factoryData\n\t */\n\tpublic static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n \t// webAuthnSignerFactory, webAuthnSignerSingleton, and webAuthnSignerProxyCreationCode\n\t\t// are not defaulted here — the init code path only configures the shared signer\n\t\t// and its verifier. Deploying the deterministic verifier proxy and swapping it\n\t\t// for the shared signer happens later in createUserOperation (nonce == 0),\n\t\t// which defaults those fields.\n\t\tconst modOverrides = { ...overrides,\n\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n\t\treturn SafeAccount.createFactoryAddressAndData(\n\t\t\towners,\n\t\t\tmodOverrides,\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t);\n\t}\n\n\t/**\n\t * createUserOperation will determine the nonce, fetch the gas prices,\n\t * estimate gas limits and return a useroperation to be signed.\n\t * you can override all these values using the overrides parameter.\n\t * @param transactions - metatransaction list to be encoded\n\t * @param providerRpc - node rpc to fetch account nonce and gas prices\n\t * @param bundlerRpc - bundler rpc for gas estimation\n\t * @param overrides - overrides for the default values\n\t * @returns promise with useroperation\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV9Overrides = {},\n\t): Promise<UserOperationV9> {\n\t\tconst parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n\t\tif(\n parallelPaymasterInitValues != null &&\n\t\t\t!parallelPaymasterInitValues.paymasterData.toLowerCase().endsWith(\"22e325a297439656\")\n ){\n throw new RangeError(\n \"Invalid paymasterData override, it must end with the PAYMASTER_SIG_MAGIC '22e325a297439656'\"\n );\n\t\t}\t\t\n const [userOperation, factoryAddress, factoryData] =\n\t\t\tawait this.createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\t\t\ttransactions,\n\t\t\t\tfalse,\n\t\t\t\tproviderRpc,\n\t\t\t\tbundlerRpc,\n\t\t\t\t{\n\t\t\t\t\t...overrides,\n\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\t\t\twebAuthnSignerProxyCreationCode: overrides.webAuthnSignerProxyCreationCode??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\t\t}\n\t\t\t);\n\t\tif(parallelPaymasterInitValues != null){\n\t\t\treturn {\n\t\t\t\t...userOperation,\n\t\t\t\tfactory: factoryAddress,\n\t\t\t\tfactoryData,\n ...parallelPaymasterInitValues,\n\t\t\t\teip7702Auth: null\n\t\t\t};\n\t\t}else{\n\t\t\treturn {\n\t\t\t\t...userOperation,\n\t\t\t\tfactory: factoryAddress,\n\t\t\t\tfactoryData,\n\t\t\t\tpaymaster: null,\n\t\t\t\tpaymasterVerificationGasLimit: null,\n\t\t\t\tpaymasterPostOpGasLimit: null,\n\t\t\t\tpaymasterData: null,\n\t\t\t\teip7702Auth: null\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * create a useroperation signature\n\t * @param useroperation - useroperation to sign\n\t * @param privateKeys - for the signers\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic signUserOperation(\n\t\tuserOperation: UserOperationV9,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.baseSignSingleUserOperation(\n\t\t\tuserOperation,\n\t\t\tprivateKeys,\n\t\t\tchainId,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.safe4337ModuleAddress,\n\t\t\t{\n\t\t\t\t...overrides,\n\t\t\t\tisMultiChainSignature: true\n\t\t\t}\n\t\t)\n\t}\n\n\t/**\n\t * sign a list of useroperations - multi chain signature\n\t * @param useroperation - useroperation to sign\n\t * @param privateKeys - for the signers\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic signUserOperations(\n\t\tuserOperationsToSign: UserOperationToSign[],\n\t\tprivateKeys: string[],\n\t): string[] {\n\t\tif (userOperationsToSign.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one userOperationsToSign\");\n\t\t}\n\t\tif (privateKeys.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one privateKey\");\n\t\t}\n if(userOperationsToSign.length > 1){\n const userOperationsHashes: string[] = [];\n userOperationsToSign.forEach(\n (userOperationsToSign, _index) => {\n const userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n userOperationsToSign.userOperation,\n userOperationsToSign.chainId,\n {\n validAfter: userOperationsToSign.validAfter,\n validUntil: userOperationsToSign.validUntil,\n safe4337ModuleAddress: this.safe4337ModuleAddress,\n entrypointAddress: this.entrypointAddress,\n },\n );\n userOperationsHashes.push(userOperationHash);\n });\n const [root, proofs] = generateMerkleProofs(userOperationsHashes);\n\n const merkleTreeRootHash = TypedDataEncoder.hash(\n {verifyingContract: this.safe4337ModuleAddress},\n\t\t\t EIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n {merkleTreeRoot: root},\n )\n\n const signerSignaturePairs: SignerSignaturePair[] = [];\n for (const privateKey of privateKeys) {\n const wallet = new Wallet(privateKey);\n const signature = wallet.signingKey.sign(\n merkleTreeRootHash\n ).serialized;\n signerSignaturePairs.push({\n signer: wallet.address,\n signature\n });\n }\n\n const userOpSignatures: string[] = [];\n userOperationsToSign.forEach(\n (userOperationsToSign, index) => {\n userOpSignatures.push(\n SafeAccount.formatSignaturesToUseroperationSignature(\n signerSignaturePairs,\n {\n validAfter: userOperationsToSign.validAfter,\n validUntil: userOperationsToSign.validUntil,\n isMultiChainSignature:true,\n multiChainMerkleProof: proofs[index]\n },\n )\n );\n });\n return userOpSignatures;\n }else{\n return [this.signUserOperation(\n userOperationsToSign[0].userOperation,\n privateKeys,\n userOperationsToSign[0].chainId,\n {\n validUntil: userOperationsToSign[0].validUntil,\n validAfter: userOperationsToSign[0].validAfter\n }\n )];\n }\n\t}\n\n\t/**\n\t * Compute the EIP-712 hash of a multi-chain Merkle tree root for a set of UserOperations.\n\t * This hash is what signers sign to approve multiple cross-chain operations at once.\n\t * @param userOperationsToSignsToSign - list of UserOperations with their target chain IDs\n\t * @param overrides - optional overrides for the Safe 4337 module address\n\t * @returns the EIP-712 hash as a hex string\n\t */\n\tpublic static getMultiChainSingleSignatureUserOperationsEip712Hash(\n\t\tuserOperationsToSignsToSign: UserOperationToSign[],\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n ): string{\n const data = SafeMultiChainSigAccountV1.getMultiChainSingleSignatureUserOperationsEip712Data(\n userOperationsToSignsToSign, overrides)\t;\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n }\n\n\t/**\n\t * Get the EIP-712 typed data components for a multi-chain Merkle tree root.\n\t * Returns the domain, types, and message value needed for signing or hashing.\n\t * @param userOperationsToSignsToSign - list of UserOperations with their target chain IDs\n\t * @param overrides - optional overrides for the Safe 4337 module address\n\t * @returns an object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic static getMultiChainSingleSignatureUserOperationsEip712Data(\n\t\tuserOperationsToSign: UserOperationToSign[],\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n\t\t} = {},\n ): {\n domain: MultiChainSignatureMerkleTreeRootTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: MultiChainSignatureMerkleTreeRootTypedMessageValue\n } {\n\t\tif (userOperationsToSign.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one userOperationsToSign\");\n\t\t}\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n SafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\t\n\n const userOperationsHashes: string[] = [];\n\n userOperationsToSign.forEach(\n (userOperationsToSign, _index) => {\n const userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n userOperationsToSign.userOperation,\n userOperationsToSign.chainId,\n {\n validAfter: userOperationsToSign.validAfter,\n validUntil: userOperationsToSign.validUntil,\n safe4337ModuleAddress,\n entrypointAddress: overrides.entrypointAddress,\n },\n );\n userOperationsHashes.push(userOperationHash);\n });\n const [root, _proofs] = generateMerkleProofs(userOperationsHashes);\n\t\treturn {\n domain: {verifyingContract: safe4337ModuleAddress},\n\t\t\ttypes: EIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\t\t\tmessageValue: {merkleTreeRoot: root},\n };\n }\n\n\t/**\n\t * formate a list of eip712 signatures to a list of multi chain useroperations signatures\n\t * @param signerSignaturePairs - a list of a pair of a signer and it's signature\n\t * @param overrides - overrides for the default values\n\t * @returns signature\n\t */\n\tpublic static formatSignaturesToUseroperationsSignatures(\n\t\tuserOperationsToSign: UserOperationToSign[],\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toverrides: WebAuthnSignatureOverrides = {},\n\t): string[] {\n\t\tif (userOperationsToSign.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one userOperationsToSign\");\n\t\t}\n\t\tconst resolvedOverrides: WebAuthnSignatureOverrides = {\n\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\tsafe4337ModuleAddress:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\twebAuthnSharedSigner:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\t...overrides,\n\t\t};\n if (userOperationsToSign.length === 1) {\n return [\n SafeAccount.formatSignaturesToUseroperationSignature(\n signerSignaturePairs,\n {\n ...resolvedOverrides,\n isMultiChainSignature: true,\n },\n ),\n ];\n }\n const userOperationsHashes: string[] = [];\n userOperationsToSign.forEach(\n (userOperationsToSign, _index) => {\n const userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n userOperationsToSign.userOperation,\n userOperationsToSign.chainId,\n {\n validAfter: userOperationsToSign.validAfter,\n validUntil: userOperationsToSign.validUntil,\n safe4337ModuleAddress: resolvedOverrides.safe4337ModuleAddress,\n },\n );\n userOperationsHashes.push(userOperationHash);\n });\n const [_root, proofs] = generateMerkleProofs(userOperationsHashes);\n const userOpSignatures: string[] = [];\n userOperationsToSign.forEach(\n (_userOperationsToSign, index) => {\n userOpSignatures.push(\n SafeAccount.formatSignaturesToUseroperationSignature(\n signerSignaturePairs,\n {\n ...resolvedOverrides,\n isMultiChainSignature:true,\n multiChainMerkleProof: proofs[index],\n },\n )\n );\n });\n return userOpSignatures;\n }\n\n\tpublic static createWebAuthnSignerVerifierAddress(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.createWebAuthnSignerVerifierAddress(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode: overrides.webAuthnSignerProxyCreationCode??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t});\n\t}\n\n\tpublic static createDeployWebAuthnVerifierMetaTransaction(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t} = {},\n\t): MetaTransaction {\n\t\treturn SafeAccount.createDeployWebAuthnVerifierMetaTransaction(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t});\n\t}\n\n\tpublic static createDummySignerSignaturePairForExpectedSigners(\n\t\texpectedSigners: Signer[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): SignerSignaturePair[] {\n\t\treturn SafeAccount.createDummySignerSignaturePairForExpectedSigners(expectedSigners, {\n\t\t\t...webAuthnSignatureOverrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: webAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: webAuthnSignatureOverrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory: webAuthnSignatureOverrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton: webAuthnSignatureOverrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode: webAuthnSignatureOverrides.webAuthnSignerProxyCreationCode??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\twebAuthnSharedSigner: webAuthnSignatureOverrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t});\n\t}\n\n\tpublic static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string,\n\t\tsigner: WebauthnPublicKey,\n\t\tmessageHash: string,\n\t\tsignature: string,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t} = {},\n\t): Promise<boolean> {\n\t\treturn SafeAccount.verifyWebAuthnSignatureForMessageHash(nodeRpcUrl, signer, messageHash, signature, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t});\n\t}\n}\n","import { GasOption, ParallelPaymasterInitValues, PolygonChain, StateOverrideSet } from \"src/types\";\n\n/**\n * Key types supported by the Calibur smart account.\n */\nexport enum CaliburKeyType {\n\t/** Raw P-256 (secp256r1) key */\n\tP256 = 0,\n\t/** WebAuthn-wrapped P-256 key (passkey) */\n\tWebAuthnP256 = 1,\n\t/** secp256k1 key (standard Ethereum EOA) */\n\tSecp256k1 = 2,\n}\n\n/**\n * A key registered on a Calibur account.\n */\nexport interface CaliburKey {\n\t/** The type of cryptographic key */\n\tkeyType: CaliburKeyType;\n\t/** ABI-encoded public key bytes (hex string) */\n\tpublicKey: string;\n}\n\n/**\n * Settings for a key registered on a Calibur account.\n * All fields are optional — used as input when registering or updating keys.\n */\nexport interface CaliburKeySettings {\n\t/** Hook contract address called during validation (zero address = no hook) */\n\thook?: string;\n\t/** Unix timestamp after which the key expires (0 = never) */\n\texpiration?: number;\n\t/** Whether the key has admin privileges */\n\tisAdmin?: boolean;\n}\n\n/**\n * Concrete key settings returned from on-chain reads.\n * Unlike {@link CaliburKeySettings}, all fields are required since\n * the contract always returns concrete values.\n */\nexport interface CaliburKeySettingsResult {\n\t/** Hook contract address called during validation (zero address = no hook) */\n\thook: string;\n\t/** Unix timestamp after which the key expires (0 = never) */\n\texpiration: number;\n\t/** Whether the key has admin privileges */\n\tisAdmin: boolean;\n}\n\n/**\n * WebAuthn assertion data matching the on-chain `WebAuthn.WebAuthnAuth` struct.\n * Used when signing UserOperations with a passkey.\n */\nexport interface WebAuthnSignatureData {\n\t/** Authenticator data bytes (hex string) */\n\tauthenticatorData: string;\n\t/** Client data JSON string (UTF-8) */\n\tclientDataJSON: string;\n\t/** Index of the challenge in clientDataJSON */\n\tchallengeIndex: bigint;\n\t/** Index of the type field in clientDataJSON */\n\ttypeIndex: bigint;\n\t/** ECDSA signature r component */\n\tr: bigint;\n\t/** ECDSA signature s component */\n\ts: bigint;\n}\n\n/**\n * Optional overrides for UserOperation fields when calling\n * {@link Calibur7702Account.createUserOperation}.\n * Any field left undefined will be auto-determined.\n */\nexport interface CaliburCreateUserOperationOverrides {\n\t/** Set the nonce instead of querying from the RPC node */\n\tnonce?: bigint;\n\t/** Set the callData instead of encoding the provided MetaTransactions */\n\tcallData?: string;\n\t/** Set the callGasLimit instead of estimating via the bundler */\n\tcallGasLimit?: bigint;\n\t/** Set the verificationGasLimit instead of estimating via the bundler */\n\tverificationGasLimit?: bigint;\n\t/** Set the preVerificationGas instead of estimating via the bundler */\n\tpreVerificationGas?: bigint;\n\t/** Set the maxFeePerGas instead of querying current gas price */\n\tmaxFeePerGas?: bigint;\n\t/** Set the maxPriorityFeePerGas instead of querying current gas price */\n\tmaxPriorityFeePerGas?: bigint;\n\n\t/** Percentage multiplier applied to estimated callGasLimit */\n\tcallGasLimitPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to estimated verificationGasLimit */\n\tverificationGasLimitPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to estimated preVerificationGas */\n\tpreVerificationGasPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to fetched maxFeePerGas */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to fetched maxPriorityFeePerGas */\n\tmaxPriorityFeePerGasPercentageMultiplier?: number;\n\n\t/** State overrides for gas estimation */\n\tstate_override_set?: StateOverrideSet;\n\n\t/** Override the dummy signature used during gas estimation */\n\tdummySignature?: string;\n\n\t/** Gas price level preference */\n\tgasLevel?: GasOption;\n\t/** Polygon chain identifier for fetching gas prices from Polygon Gas Station */\n\tpolygonGasStation?: PolygonChain;\n\n\t/** Whether BatchedCall should revert on individual call failure (default: true) */\n\trevertOnFailure?: boolean;\n\n\t/**\n\t * Paymaster init values for gas estimation. Set these to include\n\t * paymaster data during gas estimation so preVerificationGas is accurate.\n\t * Use {@link ExperimentalAllowAllPaymaster.getPaymasterFieldsInitValues} or similar\n\t * to obtain these values.\n\t */\n\tpaymasterFields?: ParallelPaymasterInitValues;\n\n\t/**\n\t * EIP-7702 authorization fields. Required for the first UserOperation\n\t * to delegate the EOA to the Calibur singleton.\n\t */\n\teip7702Auth?: {\n\t\tchainId: bigint;\n\t\taddress?: string;\n\t\tnonce?: bigint;\n\t\tyParity?: string;\n\t\tr?: string;\n\t\ts?: string;\n\t};\n}\n\n/**\n * Optional overrides for signature wrapping.\n */\nexport interface CaliburSignatureOverrides {\n\t/** Hook data to append to the signature (default: \"0x\" = empty) */\n\thookData?: string;\n\t/** Key hash of a registered secondary key. If omitted, the root key hash is used. */\n\tkeyHash?: string;\n}\n\n/**\n * A signing function that takes a hash and returns a raw signature.\n * Use this to integrate viem, ethers Signers, hardware wallets, or MPC signers\n * without passing raw private keys.\n */\nexport type SignerFunction = (hash: string) => Promise<string>;\n","import { SmartAccount } from \"../SmartAccount\";\nimport { BaseUserOperationDummyValues, CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS, ENTRYPOINT_V8, ZeroAddress } from \"src/constants\";\nimport {\n\tcreateCallData, createUserOperationHash, fetchAccountNonce,\n\tgetDelegatedAddress, getFunctionSelector, handlefetchGasPrice, sendJsonRpcRequest\n} from \"../../utils\";\nimport { UserOperationV8 } from \"src/types\";\nimport { AbstractionKitError } from \"src/errors\";\nimport {\n\tAuthorization7702Hex, bigintToHex,\n\tcreateAndSignEip7702RawTransaction,\n\tcreateRevokeDelegationAuthorization,\n} from \"src/utils7702\";\nimport { Bundler } from \"src/Bundler\";\nimport { Wallet, AbiCoder, keccak256 } from \"ethers\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\nimport { SimpleMetaTransaction } from \"../simple/Simple7702Account\";\nimport { PrependTokenPaymasterApproveAccount } from \"src/paymaster/types\";\nimport {\n\tCaliburKeyType, CaliburKey, CaliburKeySettings, CaliburKeySettingsResult,\n\tWebAuthnSignatureData, CaliburCreateUserOperationOverrides,\n\tCaliburSignatureOverrides, SignerFunction,\n} from \"./types\";\n\n\nconst DEFAULT_SINGLETON_ADDRESS = CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS;\n\n/** Root key hash (bytes32 zero) — used for the EOA's own secp256k1 key */\nconst ROOT_KEY_HASH = \"0x0000000000000000000000000000000000000000000000000000000000000000\";\n\n// Function selectors — computed from Calibur's actual Solidity interfaces:\n// - executeUserOp is IAccountExecute.executeUserOp(PackedUserOperation,bytes32)\n// The EntryPoint calls this; userOp.callData = selector + abi.encode(BatchedCall)\n// - register takes Key struct: register((uint8,bytes))\n// - update/revoke/invalidateNonce match standard signatures\n\n/** executeUserOp selector — `executeUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)` from IAccountExecute */\nconst EXECUTE_USER_OP_SELECTOR = \"0x8dd7712f\";\n/** register((uint8,bytes)) — registers a Key struct */\nconst REGISTER_SELECTOR = \"0x30b1fa3b\";\n/** update(bytes32,uint256) — updates key settings */\nconst UPDATE_SELECTOR = \"0xa58bb84a\";\n/** revoke(bytes32) — revokes a key by hash */\nconst REVOKE_SELECTOR = \"0xb75c7dc6\";\n/** invalidateNonce(uint256) — invalidates nonces */\nconst INVALIDATE_NONCE_SELECTOR = \"0xb70e36f0\";\n\n// Read function selectors\n/** isRegistered(bytes32) */\nconst IS_REGISTERED_SELECTOR = \"0x27258b22\";\n/** getKeySettings(bytes32) — returns packed Settings (uint256) */\nconst GET_KEY_SETTINGS_SELECTOR = \"0x0f3ebf6e\";\n/** getKey(bytes32) — returns Key struct (uint8,bytes) */\nconst GET_KEY_SELECTOR = \"0x12aaac70\";\n/** keyCount() */\nconst KEY_COUNT_SELECTOR = \"0xfac750e0\";\n/** keyAt(uint256) — returns Key struct */\nconst KEY_AT_SELECTOR = \"0x4223b5c2\";\n\n/**\n * EIP-7702 smart account implementation for the Calibur (Uniswap) singleton.\n * Calibur turns an EOA into a smart account via EIP-7702 delegation, providing\n * batched transactions, passkey signing, ERC-4337 support, and per-key hooks.\n *\n * Unlike Safe accounts, there is no factory or proxy — the EOA IS the account.\n * All transactions go through `executeUserOp(bytes)` with `BatchedCall` encoding.\n *\n * @example\n * ```typescript\n * const account = new Calibur7702Account(\"0xMyEOA\");\n * const userOp = await account.createUserOperation(\n * [{ to: \"0xRecipient\", value: 1000000000000000n, data: \"0x\" }],\n * nodeRpc, bundlerRpc,\n * { eip7702Auth: { chainId: 11155111n } }\n * );\n * userOp.signature = account.signUserOperation(userOp, privateKey, 11155111n);\n * const response = await account.sendUserOperation(userOp, bundlerRpc);\n * ```\n */\nexport class Calibur7702Account extends SmartAccount\n\timplements PrependTokenPaymasterApproveAccount {\n\n\t/** Function selector for `executeUserOp(bytes)` */\n\tstatic readonly executorFunctionSelector = EXECUTE_USER_OP_SELECTOR;\n\n\t/**\n\t * Dummy ECDSA signature for gas estimation with root key signing.\n\t * Format: `abi.encode(bytes32 keyHash, bytes sig, bytes hookData)`\n\t */\n\tstatic readonly dummySignature: string = AbiCoder.defaultAbiCoder().encode(\n\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t[\n\t\t\tROOT_KEY_HASH,\n\t\t\t\"0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c\",\n\t\t\t\"0x\",\n\t\t],\n\t);\n\n\t/**\n\t * Create a dummy WebAuthn signature for gas estimation with passkey signing.\n\t * The key hash must correspond to an actually registered key on the account,\n\t * otherwise the contract's `validateUserOp` will revert with `KeyDoesNotExist`.\n\t *\n\t * @param keyHash - The key hash of a registered passkey (from {@link getKeyHash})\n\t * @returns A dummy signature suitable for passing as `dummySignature` override\n\t */\n\tpublic static createDummyWebAuthnSignature(keyHash: string): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst dummyClientDataJSON = '{\"type\":\"webauthn.get\",\"challenge\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\",\"origin\":\"https://example.com\",\"crossOrigin\":false}';\n\t\tconst challengeIndex = BigInt(dummyClientDataJSON.indexOf('\"challenge\":\"'));\n\t\tconst typeIndex = BigInt(dummyClientDataJSON.indexOf('\"type\":\"webauthn.get\"'));\n\t\treturn abiCoder.encode(\n\t\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t\t[\n\t\t\t\tkeyHash,\n\t\t\t\tabiCoder.encode(\n\t\t\t\t\t[\"(bytes,string,uint256,uint256,uint256,uint256)\"],\n\t\t\t\t\t[[\n\t\t\t\t\t\t\"0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000\",\n\t\t\t\t\t\tdummyClientDataJSON,\n\t\t\t\t\t\tchallengeIndex,\n\t\t\t\t\t\ttypeIndex,\n\t\t\t\t\t\tBigInt(\"0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\"),\n\t\t\t\t\t\tBigInt(\"0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\"),\n\t\t\t\t\t]],\n\t\t\t\t),\n\t\t\t\t\"0x\",\n\t\t\t],\n\t\t);\n\t}\n\n\t/**\n\t * Wrap a raw ECDSA signature in Calibur's signature format:\n\t * `abi.encode(bytes32 keyHash, bytes signature, bytes hookData)`.\n\t *\n\t * Use this when signing externally (e.g., with viem, hardware wallet, MPC)\n\t * to avoid manually ABI-encoding the wrapped signature.\n\t *\n\t * @param keyHash - The key hash (use ROOT_KEY_HASH `0x00...00` for the EOA's root key)\n\t * @param rawSignature - The raw ECDSA signature (65 bytes, hex-encoded)\n\t * @param hookData - Optional hook data (default: \"0x\")\n\t * @returns Hex-encoded wrapped signature ready for `userOp.signature`\n\t */\n\tpublic static wrapSignature(\n\t\tkeyHash: string,\n\t\trawSignature: string,\n\t\thookData = \"0x\",\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn abiCoder.encode(\n\t\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t\t[keyHash, rawSignature, hookData],\n\t\t);\n\t}\n\n\t/** The EntryPoint contract address this account targets */\n\treadonly entrypointAddress: string;\n\t/** The Calibur singleton (delegatee) contract address */\n\treadonly delegateeAddress: string;\n\n\t/**\n\t * Create a new Calibur7702Account instance for an existing EOA.\n\t * @param accountAddress - The EOA address that will be (or already is) delegated via EIP-7702\n\t * @param overrides - Optional overrides for entrypoint and delegatee addresses\n\t * @param overrides.entrypointAddress - Custom EntryPoint address (defaults to EntryPoint v0.8)\n\t * @param overrides.delegateeAddress - Custom Calibur singleton address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tentrypointAddress?: string;\n\t\t\tdelegateeAddress?: string;\n\t\t} = {},\n\t) {\n\t\tsuper(accountAddress);\n\t\tthis.entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V8;\n\t\tthis.delegateeAddress = overrides.delegateeAddress ?? DEFAULT_SINGLETON_ADDRESS;\n\t}\n\n\t/**\n\t * Compute the UserOperation hash for this account's EntryPoint.\n\t * Convenience wrapper around the standalone `createUserOperationHash` that\n\t * automatically uses this account's EntryPoint address.\n\t *\n\t * @param userOperation - The UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @returns The UserOperation hash as a hex string\n\t */\n\tpublic getUserOperationHash(\n\t\tuserOperation: UserOperationV8,\n\t\tchainId: bigint,\n\t): string {\n\t\treturn createUserOperationHash(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t);\n\t}\n\n\t// ─── CallData Encoding ───────────────────────────────────────────────\n\n\t/**\n\t * Encode calldata for `executeUserOp(bytes)` with BatchedCall format.\n\t * All transactions (even single ones) go through the same BatchedCall path.\n\t *\n\t * @param transactions - One or more transactions to encode\n\t * @param revertOnFailure - Whether to revert the entire batch if any call fails (default: true)\n\t * @returns Encoded calldata for the executeUserOp function\n\t */\n\tpublic static createAccountCallData(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\trevertOnFailure = true,\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst calls = transactions.map(tx => [tx.to, tx.value, tx.data]);\n\t\t// BatchedCall struct { Call[] calls; bool revertOnFailure; }\n\t\t// Solidity's abi.decode(data, (BatchedCall)) expects a single struct/tuple\n\t\t// parameter, which has an extra offset layer compared to two separate args.\n\t\tconst batchedCallEncoded = abiCoder.encode(\n\t\t\t[\"((address,uint256,bytes)[],bool)\"],\n\t\t\t[[calls, revertOnFailure]],\n\t\t);\n\t\treturn EXECUTE_USER_OP_SELECTOR + batchedCallEncoded.slice(2);\n\t}\n\n\t// ─── UserOperation Lifecycle ─────────────────────────────────────────\n\n\t/**\n\t * Build an unsigned {@link UserOperationV8} from one or more transactions.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and\n\t * optionally includes EIP-7702 authorization. All auto-determined\n\t * values can be overridden.\n\t *\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned {@link UserOperationV8}\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CaliburCreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8> {\n\t\tif (transactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one transaction\");\n\t\t}\n\n\t\tlet nonce: bigint | null = null;\n\t\tlet nonceOp: Promise<bigint> | null = null;\n\n\t\tif (overrides.nonce == null) {\n\t\t\tif (providerRpc != null) {\n\t\t\t\tnonceOp = fetchAccountNonce(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc can't be null if nonce is not overridden\",\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnonce = overrides.nonce;\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxFeePerGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxPriorityFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxPriorityFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas override can't be negative\");\n\t\t}\n\n\t\tlet maxFeePerGas = BaseUserOperationDummyValues.maxFeePerGas;\n\t\tlet maxPriorityFeePerGas = BaseUserOperationDummyValues.maxPriorityFeePerGas;\n\n\t\tlet gasPriceOp: Promise<[bigint, bigint]> | null = null;\n\t\tif (\n\t\t\toverrides.maxFeePerGas == null ||\n\t\t\toverrides.maxPriorityFeePerGas == null\n\t\t) {\n\t\t\tgasPriceOp = handlefetchGasPrice(\n\t\t\t\tproviderRpc, overrides.polygonGasStation, overrides.gasLevel\n\t\t\t);\n\t\t}\n\n\t\tlet eip7702AuthChainId: bigint | null = null;\n\t\tlet eip7702AuthAddress: string | null = null;\n\t\tlet eip7702AuthNonce: bigint | null = null;\n\n\t\tif (overrides.eip7702Auth != null) {\n\t\t\teip7702AuthChainId = overrides.eip7702Auth.chainId;\n\t\t\teip7702AuthAddress = overrides.eip7702Auth.address ??\n\t\t\t\tthis.delegateeAddress;\n\t\t\teip7702AuthNonce = overrides.eip7702Auth.nonce ?? null;\n\t\t}\n\n\t\t// When eip7702Auth is provided, check if already delegated in parallel.\n\t\t// If already delegated to the target, skip the authorization.\n\t\tlet skipEip7702Auth = false;\n\t\tlet delegationCheckOp: Promise<string | null> | null = null;\n\t\tif (overrides.eip7702Auth != null && providerRpc != null) {\n\t\t\tdelegationCheckOp = getDelegatedAddress(this.accountAddress, providerRpc)\n\t\t\t\t.catch(() => null);\n\t\t}\n\n\t\tif (overrides.eip7702Auth != null && eip7702AuthNonce == null) {\n\t\t\tlet eip7702AuthNonceOp;\n\t\t\tif (providerRpc != null) {\n\t\t\t\teip7702AuthNonceOp = sendJsonRpcRequest(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\t\"eth_getTransactionCount\",\n\t\t\t\t\t[this.accountAddress, \"latest\"]\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc can't be null if eoaDelegatorNonce \" +\n\t\t\t\t\t\"is not overriden\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst ops: Promise<any>[] = [eip7702AuthNonceOp];\n\t\t\tif (nonceOp != null) ops.push(nonceOp);\n\t\t\tif (gasPriceOp != null) ops.push(gasPriceOp);\n\t\t\tif (delegationCheckOp != null) ops.push(delegationCheckOp);\n\n\t\t\tconst values = await Promise.all(ops);\n\t\t\tlet idx = 0;\n\t\t\teip7702AuthNonce = BigInt(values[idx++] as string);\n\t\t\tif (nonceOp != null) nonce = values[idx++];\n\t\t\tif (gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++];\n\t\t\tif (delegationCheckOp != null) {\n\t\t\t\tconst delegatedTo = values[idx++] as string | null;\n\t\t\t\tif (delegatedTo != null &&\n\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()) {\n\t\t\t\t\tskipEip7702Auth = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (overrides.eip7702Auth != null) {\n\t\t\tconst ops: Promise<any>[] = [];\n\t\t\tif (nonceOp != null) ops.push(nonceOp);\n\t\t\tif (gasPriceOp != null) ops.push(gasPriceOp);\n\t\t\tif (delegationCheckOp != null) ops.push(delegationCheckOp);\n\n\t\t\tif (ops.length > 0) {\n\t\t\t\tconst values = await Promise.all(ops);\n\t\t\t\tlet idx = 0;\n\t\t\t\tif (nonceOp != null) nonce = values[idx++];\n\t\t\t\tif (gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++];\n\t\t\t\tif (delegationCheckOp != null) {\n\t\t\t\t\tconst delegatedTo = values[idx++] as string | null;\n\t\t\t\t\tif (delegatedTo != null &&\n\t\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()) {\n\t\t\t\t\t\tskipEip7702Auth = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (gasPriceOp != null && nonceOp != null) {\n\t\t\t\tawait Promise.all([nonceOp, gasPriceOp]).then((values) => {\n\t\t\t\t\tnonce = values[0];\n\t\t\t\t\t[maxFeePerGas, maxPriorityFeePerGas] = values[1];\n\t\t\t\t});\n\t\t\t} else if (gasPriceOp != null) {\n\t\t\t\t[maxFeePerGas, maxPriorityFeePerGas] = await gasPriceOp;\n\t\t\t} else if (nonceOp != null) {\n\t\t\t\tnonce = await nonceOp;\n\t\t\t}\n\t\t}\n\n\t\tmaxFeePerGas = overrides.maxFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxFeePerGas) *\n\t\t\t\t\t(((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n\t\t\t);\n\t\tmaxPriorityFeePerGas = overrides.maxPriorityFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxPriorityFeePerGas) *\n\t\t\t\t\t(((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n\t\t\t);\n\n\t\tif (nonce == null) {\n\t\t\tthrow new RangeError(\"failed to determine nonce\");\n\t\t} else if (nonce < 0n) {\n\t\t\tthrow new RangeError(\"nonce can't be negative\");\n\t\t}\n\n\t\tlet callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tcallData = Calibur7702Account.createAccountCallData(\n\t\t\t\ttransactions,\n\t\t\t\toverrides.revertOnFailure ?? true,\n\t\t\t);\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n\n\t\tconst pmFields = overrides.paymasterFields;\n\t\tlet userOperation: UserOperationV8;\n\t\tif (overrides.eip7702Auth != null && !skipEip7702Auth) {\n\t\t\tconst yParity = overrides.eip7702Auth.yParity ?? \"0x0\";\n\t\t\tif (\n\t\t\t\tyParity != \"0x0\" && yParity != \"0x00\" &&\n\t\t\t\tyParity != \"0x1\" && yParity != \"0x01\"\n\t\t\t) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"invalid yParity value for eoaDelegatorSignature. \" +\n\t\t\t\t\t\"must be '0x0' or '0x1'\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst authorization: Authorization7702Hex = {\n\t\t\t\tchainId: bigintToHex(eip7702AuthChainId as bigint),\n\t\t\t\taddress: eip7702AuthAddress as string,\n\t\t\t\tnonce: bigintToHex(eip7702AuthNonce as bigint),\n\t\t\t\tyParity: yParity,\n\t\t\t\tr: overrides.eip7702Auth.r ??\n\t\t\t\t\t\"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2\",\n\t\t\t\ts: overrides.eip7702Auth.s ??\n\t\t\t\t\t\"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd\",\n\t\t\t};\n\t\t\tuserOperation = {\n\t\t\t\t...BaseUserOperationDummyValues,\n\t\t\t\tsender: this.accountAddress,\n\t\t\t\tnonce: nonce,\n\t\t\t\tcallData: callData,\n\t\t\t\tmaxFeePerGas: maxFeePerGas,\n\t\t\t\tmaxPriorityFeePerGas: maxPriorityFeePerGas,\n\t\t\t\tfactory: \"0x7702\",\n\t\t\t\tfactoryData: null,\n\t\t\t\tpaymaster: pmFields?.paymaster ?? null,\n\t\t\t\tpaymasterVerificationGasLimit: pmFields?.paymasterVerificationGasLimit ?? null,\n\t\t\t\tpaymasterPostOpGasLimit: pmFields?.paymasterPostOpGasLimit ?? null,\n\t\t\t\tpaymasterData: pmFields?.paymasterData ?? null,\n\t\t\t\teip7702Auth: authorization,\n\t\t\t};\n\t\t} else {\n\t\t\tuserOperation = {\n\t\t\t\t...BaseUserOperationDummyValues,\n\t\t\t\tsender: this.accountAddress,\n\t\t\t\tnonce: nonce,\n\t\t\t\tcallData: callData,\n\t\t\t\tmaxFeePerGas: maxFeePerGas,\n\t\t\t\tmaxPriorityFeePerGas: maxPriorityFeePerGas,\n\t\t\t\tfactory: null,\n\t\t\t\tfactoryData: null,\n\t\t\t\tpaymaster: pmFields?.paymaster ?? null,\n\t\t\t\tpaymasterVerificationGasLimit: pmFields?.paymasterVerificationGasLimit ?? null,\n\t\t\t\tpaymasterPostOpGasLimit: pmFields?.paymasterPostOpGasLimit ?? null,\n\t\t\t\tpaymasterData: pmFields?.paymasterData ?? null,\n\t\t\t\teip7702Auth: null,\n\t\t\t};\n\t\t}\n\n\t\tlet preVerificationGas = BaseUserOperationDummyValues.preVerificationGas;\n\t\tlet verificationGasLimit = BaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n\t\t\tif (bundlerRpc != null) {\n\t\t\t\tuserOperation.callGasLimit = 0n;\n\t\t\t\tuserOperation.verificationGasLimit = 0n;\n\t\t\t\tuserOperation.preVerificationGas = 0n;\n\t\t\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\t\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\t\t\tuserOperation.maxFeePerGas = 0n;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\n\t\t\t\tconst userOperationToEstimate: UserOperationV8 = { ...userOperation };\n\t\t\t\tuserOperationToEstimate.signature = overrides.dummySignature ??\n\t\t\t\t\tCalibur7702Account.dummySignature;\n\n\t\t\t\tconst bundler = new Bundler(bundlerRpc);\n\t\t\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\t\t\tuserOperationToEstimate,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\toverrides.state_override_set,\n\t\t\t\t);\n\n\t\t\t\tpreVerificationGas = BigInt(estimation.preVerificationGas);\n\t\t\t\tverificationGasLimit = BigInt(estimation.verificationGasLimit);\n\t\t\t\tcallGasLimit = BigInt(estimation.callGasLimit);\n\t\t\t\t// Safety margin for P-256/WebAuthn signature verification overhead\n\t\t\t// that the bundler's simulation may underestimate.\n\t\t\tverificationGasLimit += 55_000n;\n\n\t\t\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc can't be null if preVerificationGas,\" +\n\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.preVerificationGas === \"bigint\" &&\n\t\t\toverrides.preVerificationGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"preVerificationGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.verificationGasLimit === \"bigint\" &&\n\t\t\toverrides.verificationGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"verificationGasLimit override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.callGasLimit === \"bigint\" &&\n\t\t\toverrides.callGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"callGasLimit override can't be negative\");\n\t\t}\n\n\t\tuserOperation.preVerificationGas = overrides.preVerificationGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(preVerificationGas) *\n\t\t\t\t\t(((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.verificationGasLimit = overrides.verificationGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(verificationGasLimit) *\n\t\t\t\t\t(((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.callGasLimit = overrides.callGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(callGasLimit) *\n\t\t\t\t\t(((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t),\n\t\t\t);\n\n\t\t// Set the dummy signature so paymaster sponsorship calls can simulate\n\t\t// validateUserOp (Calibur's signature decoder rejects empty signatures).\n\t\tuserOperation.signature = overrides.dummySignature ??\n\t\t\tCalibur7702Account.dummySignature;\n\n\t\treturn userOperation;\n\t}\n\n\t/**\n\t * Sign a UserOperation with a private key.\n\t * Computes the UserOperation hash and wraps the ECDSA signature in\n\t * Calibur's format: `abi.encode(keyHash, ecdsaSig, hookData)`.\n\t *\n\t * By default signs with the root key. To sign with a registered\n\t * secondary key, pass its key hash via `overrides.keyHash`.\n\t *\n\t * @param userOperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key\n\t * @param chainId - Target chain ID\n\t * @param overrides - Optional overrides (keyHash for secondary keys, hookData)\n\t * @returns Hex-encoded wrapped signature\n\t *\n\t * @example\n\t * // Sign with root key\n\t * userOp.signature = account.signUserOperation(userOp, privateKey, chainId);\n\t *\n\t * // Sign with a registered secondary key\n\t * userOp.signature = account.signUserOperation(userOp, privateKey, chainId, { keyHash });\n\t */\n\tpublic signUserOperation(\n\t\tuserOperation: UserOperationV8,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): string {\n\t\tconst userOperationHash = createUserOperationHash(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t);\n\t\tconst keyHash = overrides.keyHash ?? ROOT_KEY_HASH;\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\t\tconst wallet = new Wallet(privateKey);\n\t\tconst ecdsaSig = wallet.signingKey.sign(userOperationHash).serialized;\n\t\treturn Calibur7702Account.wrapSignature(keyHash, ecdsaSig, hookData);\n\t}\n\n\t/**\n\t * Sign a UserOperation with an external signer (viem, ethers Signer,\n\t * hardware wallet, MPC signer, etc.).\n\t * Computes the UserOperation hash and wraps the returned signature in\n\t * Calibur's format: `abi.encode(keyHash, ecdsaSig, hookData)`.\n\t *\n\t * By default signs with the root key. To sign with a registered\n\t * secondary key, pass its key hash via `overrides.keyHash`.\n\t *\n\t * @param userOperation - The UserOperation to sign\n\t * @param signer - Async signing function: `(hash: string) => Promise<string>`\n\t * @param chainId - Target chain ID\n\t * @param overrides - Optional overrides (keyHash for secondary keys, hookData)\n\t * @returns Promise resolving to the hex-encoded wrapped signature\n\t *\n\t * @example\n\t * // Sign with a viem wallet client\n\t * userOp.signature = await account.signUserOperationWithSigner(\n\t * userOp,\n\t * (hash) => walletClient.signMessage({ message: { raw: hash } }),\n\t * chainId,\n\t * );\n\t */\n\tpublic async signUserOperationWithSigner(\n\t\tuserOperation: UserOperationV8,\n\t\tsigner: SignerFunction,\n\t\tchainId: bigint,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): Promise<string> {\n\t\tconst userOperationHash = createUserOperationHash(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t);\n\t\tconst keyHash = overrides.keyHash ?? ROOT_KEY_HASH;\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\t\tconst ecdsaSig = await signer(userOperationHash);\n\t\treturn Calibur7702Account.wrapSignature(keyHash, ecdsaSig, hookData);\n\t}\n\n\t/**\n\t * Format a WebAuthn (passkey) assertion into Calibur's signature format.\n\t * The challenge for the WebAuthn assertion should be `abi.encode(userOpHash)`.\n\t *\n\t * @param keyHash - The key hash of the registered passkey (from {@link getKeyHash})\n\t * @param webAuthnAuth - WebAuthn assertion data from the browser\n\t * @param overrides - Optional signature overrides (e.g., hookData)\n\t * @returns Hex-encoded wrapped signature\n\t */\n\tpublic formatWebAuthnSignature(\n\t\tkeyHash: string,\n\t\twebAuthnAuth: WebAuthnSignatureData,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\n\t\t// Encode as a struct/tuple — Calibur decodes with:\n\t\t// abi.decode(signature, (WebAuthn.WebAuthnAuth))\n\t\t// which expects struct-wrapped encoding (extra offset for dynamic tuple).\n\t\tconst webAuthnEncoded = abiCoder.encode(\n\t\t\t[\"(bytes,string,uint256,uint256,uint256,uint256)\"],\n\t\t\t[[\n\t\t\t\twebAuthnAuth.authenticatorData,\n\t\t\t\twebAuthnAuth.clientDataJSON,\n\t\t\t\twebAuthnAuth.challengeIndex,\n\t\t\t\twebAuthnAuth.typeIndex,\n\t\t\t\twebAuthnAuth.r,\n\t\t\t\twebAuthnAuth.s,\n\t\t\t]],\n\t\t);\n\n\t\treturn abiCoder.encode(\n\t\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t\t[keyHash, webAuthnEncoded, hookData],\n\t\t);\n\t}\n\n\t/**\n\t * Submit a signed UserOperation to a bundler for on-chain inclusion.\n\t *\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV8,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = new Bundler(bundlerRpc);\n\t\tconst sendUserOperationRes = await bundler.sendUserOperation(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\n\t\treturn new SendUseroperationResponse(\n\t\t\tsendUserOperationRes,\n\t\t\tbundler,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\t}\n\n\t// ─── Key Helpers (static) ────────────────────────────────────────────\n\n\t/**\n\t * Create a secp256k1 key descriptor from an Ethereum address.\n\t * @param address - The Ethereum address (EOA public address)\n\t * @returns A {@link CaliburKey} with type Secp256k1\n\t */\n\tpublic static createSecp256k1Key(address: string): CaliburKey {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn {\n\t\t\tkeyType: CaliburKeyType.Secp256k1,\n\t\t\tpublicKey: abiCoder.encode([\"address\"], [address]),\n\t\t};\n\t}\n\n\t/**\n\t * Create a WebAuthn P-256 key descriptor from public key coordinates.\n\t * @param x - The x coordinate of the P-256 public key\n\t * @param y - The y coordinate of the P-256 public key\n\t * @returns A {@link CaliburKey} with type WebAuthnP256\n\t */\n\tpublic static createWebAuthnP256Key(x: bigint, y: bigint): CaliburKey {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn {\n\t\t\tkeyType: CaliburKeyType.WebAuthnP256,\n\t\t\tpublicKey: abiCoder.encode([\"uint256\", \"uint256\"], [x, y]),\n\t\t};\n\t}\n\n\t/**\n\t * Create a raw P-256 key descriptor from public key coordinates.\n\t * @param x - The x coordinate of the P-256 public key\n\t * @param y - The y coordinate of the P-256 public key\n\t * @returns A {@link CaliburKey} with type P256\n\t */\n\tpublic static createP256Key(x: bigint, y: bigint): CaliburKey {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn {\n\t\t\tkeyType: CaliburKeyType.P256,\n\t\t\tpublicKey: abiCoder.encode([\"uint256\", \"uint256\"], [x, y]),\n\t\t};\n\t}\n\n\t/**\n\t * Compute the key hash for a Calibur key.\n\t * Uses double hashing: `keccak256(abi.encode(uint8 keyType, bytes32 keccak256(publicKey)))`.\n\t *\n\t * @param key - The key to hash\n\t * @returns The key hash as a bytes32 hex string\n\t */\n\tpublic static getKeyHash(key: CaliburKey): string {\n\t\tconst innerHash = keccak256(key.publicKey);\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst encoded = abiCoder.encode(\n\t\t\t[\"uint8\", \"bytes32\"],\n\t\t\t[key.keyType, innerHash],\n\t\t);\n\t\treturn keccak256(encoded);\n\t}\n\n\t/**\n\t * Pack key settings into a single uint256 value.\n\t * Layout: `(isAdmin << 200) | (expiration << 160) | hook`\n\t *\n\t * @param settings - The key settings to pack\n\t * @returns The packed settings as a bigint\n\t */\n\tpublic static packKeySettings(settings: CaliburKeySettings): bigint {\n\t\tconst hook = BigInt(settings.hook ?? ZeroAddress);\n\t\tconst expiration = BigInt(settings.expiration ?? 0);\n\t\tconst isAdmin = settings.isAdmin ? 1n : 0n;\n\t\treturn (isAdmin << 200n) | (expiration << 160n) | hook;\n\t}\n\n\t/**\n\t * Unpack a uint256 settings value into a {@link CaliburKeySettingsResult} object.\n\t *\n\t * @param packed - The packed settings value\n\t * @returns Parsed key settings with all fields populated\n\t */\n\tpublic static unpackKeySettings(packed: bigint): CaliburKeySettingsResult {\n\t\tconst hook = \"0x\" + (packed & ((1n << 160n) - 1n)).toString(16).padStart(40, \"0\");\n\t\tconst expiration = Number((packed >> 160n) & ((1n << 40n) - 1n));\n\t\tconst isAdmin = ((packed >> 200n) & 1n) === 1n;\n\t\treturn { hook, expiration, isAdmin };\n\t}\n\n\t// ─── Key Management (static, return SimpleMetaTransaction) ───────────\n\n\t/**\n\t * Create meta-transactions to register a new key on the Calibur account.\n\t * Returns **two transactions**: `[register, update]`. Both must be included\n\t * in the same UserOperation.\n\t *\n\t * **Safety guardrail:** This method never sets `isAdmin: true` regardless\n\t * of input settings. Developers who need admin keys must encode calldata themselves.\n\t *\n\t * @param key - The key to register\n\t * @param settings - Optional key settings (isAdmin is always forced to false)\n\t * @returns A tuple of exactly two {@link SimpleMetaTransaction}s: [registerTx, updateTx].\n\t * Both must be included in the same UserOperation.\n\t */\n\tpublic static createRegisterKeyMetaTransactions(\n\t\tkey: CaliburKey,\n\t\tsettings: CaliburKeySettings = {},\n\t): [SimpleMetaTransaction, SimpleMetaTransaction] {\n\t\tif (settings.isAdmin === true) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"createRegisterKeyMetaTransactions does not allow setting \" +\n\t\t\t\t\"isAdmin to true. Encode the calldata manually for admin keys.\",\n\t\t\t);\n\t\t}\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\t\t// Register: register((uint8 keyType, bytes publicKey))\n\t\tconst registerCallData = REGISTER_SELECTOR + abiCoder.encode(\n\t\t\t[\"(uint8,bytes)\"],\n\t\t\t[[key.keyType, key.publicKey]],\n\t\t).slice(2);\n\n\t\t// Update: update(bytes32 keyHash, uint256 packedSettings)\n\t\tconst safeSettings: CaliburKeySettings = {\n\t\t\t...settings,\n\t\t\tisAdmin: false,\n\t\t};\n\t\tconst keyHash = Calibur7702Account.getKeyHash(key);\n\t\tconst packedSettings = Calibur7702Account.packKeySettings(safeSettings);\n\t\tconst updateCallData = UPDATE_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\", \"uint256\"],\n\t\t\t[keyHash, packedSettings],\n\t\t).slice(2);\n\n\t\treturn [\n\t\t\t{ to: ZeroAddress, value: 0n, data: registerCallData },\n\t\t\t{ to: ZeroAddress, value: 0n, data: updateCallData },\n\t\t] as [SimpleMetaTransaction, SimpleMetaTransaction];\n\t}\n\n\t/**\n\t * Create a meta-transaction to revoke a key from the Calibur account.\n\t *\n\t * @param keyHash - The key hash to revoke\n\t * @returns A {@link SimpleMetaTransaction} that calls `revoke(bytes32)`\n\t */\n\tpublic static createRevokeKeyMetaTransaction(\n\t\tkeyHash: string,\n\t): SimpleMetaTransaction {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = REVOKE_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\treturn { to: ZeroAddress, value: 0n, data: callData };\n\t}\n\n\t/**\n\t * Create meta-transactions to revoke ALL registered keys on this account.\n\t * Queries the on-chain key list and returns one `revoke(bytes32)` call per key.\n\t *\n\t * **Recommended before revoking EIP-7702 delegation** to prevent stale keys\n\t * from becoming active again if the EOA re-delegates later.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint to query registered keys\n\t * @returns Array of {@link SimpleMetaTransaction}s — one revoke call per key.\n\t * Empty array if no keys are registered.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Step 1: Revoke all keys (send as UserOp)\n\t * const revokeTxs = await account.createRevokeAllKeysMetaTransactions(providerRpc);\n\t * if (revokeTxs.length > 0) {\n\t * const userOp = await account.createUserOperation(revokeTxs, providerRpc, bundlerRpc);\n\t * userOp.signature = account.signUserOperation(userOp, privateKey, chainId);\n\t * const response = await account.sendUserOperation(userOp, bundlerRpc);\n\t * await response.included();\n\t * }\n\t *\n\t * // Step 2: Revoke delegation\n\t * const rawTx = await account.createRevokeDelegationRawTransaction(chainId, privateKey, providerRpc);\n\t * ```\n\t */\n\tpublic async createRevokeAllKeysMetaTransactions(\n\t\tproviderRpc: string,\n\t): Promise<SimpleMetaTransaction[]> {\n\t\tconst keys = await this.getKeys(providerRpc);\n\t\treturn keys.map((key) => {\n\t\t\tconst keyHash = Calibur7702Account.getKeyHash(key);\n\t\t\treturn Calibur7702Account.createRevokeKeyMetaTransaction(keyHash);\n\t\t});\n\t}\n\n\t/**\n\t * Create a signed raw transaction that revokes EIP-7702 delegation,\n\t * restoring this account to a plain EOA.\n\t *\n\t * **Recommended flow:** Call {@link createRevokeAllKeysMetaTransactions} first\n\t * and send the cleanup UserOp, then call this method to revoke delegation.\n\t * This prevents stale keys from reactivating if the EOA re-delegates later.\n\t *\n\t * @param chainId - Target chain ID\n\t * @param eoaPrivateKey - The EOA's private key for signing\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param overrides - Optional overrides for transaction parameters\n\t * @param overrides.nonce - Transaction nonce (fetched from provider if omitted)\n\t * @param overrides.authorizationNonce - EIP-7702 authorization nonce (defaults to txNonce + 1)\n\t * @param overrides.maxFeePerGas - Max fee per gas (fetched from provider if omitted)\n\t * @param overrides.maxPriorityFeePerGas - Max priority fee per gas (fetched if omitted)\n\t * @param overrides.gasLimit - Gas limit (defaults to 60,000)\n\t * @returns Hex-encoded signed EIP-7702 type-4 transaction ready for `eth_sendRawTransaction`\n\t * @throws {AbstractionKitError} If the account is not delegated or is delegated to a different address\n\t *\n\t * @example\n\t * ```typescript\n\t * const rawTx = await account.createRevokeDelegationRawTransaction(\n\t * 11155111n, privateKey, providerRpc,\n\t * );\n\t * await sendJsonRpcRequest(providerRpc, \"eth_sendRawTransaction\", [rawTx]);\n\t * ```\n\t */\n\tpublic async createRevokeDelegationRawTransaction(\n\t\tchainId: bigint,\n\t\teoaPrivateKey: string,\n\t\tproviderRpc: string,\n\t\toverrides: {\n\t\t\tnonce?: bigint;\n\t\t\tauthorizationNonce?: bigint;\n\t\t\tmaxFeePerGas?: bigint;\n\t\t\tmaxPriorityFeePerGas?: bigint;\n\t\t\tgasLimit?: bigint;\n\t\t} = {},\n\t): Promise<string> {\n\t\t// Verify the private key matches this account\n\t\tconst signerAddress = new Wallet(eoaPrivateKey).address;\n\t\tif (signerAddress.toLowerCase() !== this.accountAddress.toLowerCase()) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"eoaPrivateKey does not match accountAddress (\" +\n\t\t\t\t\tthis.accountAddress + \")\",\n\t\t\t);\n\t\t}\n\n\t\t// Verify delegation state before revoking\n\t\tconst delegatedTo = await getDelegatedAddress(this.accountAddress, providerRpc);\n\t\tif (delegatedTo === null) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Account is not delegated — nothing to revoke\",\n\t\t\t);\n\t\t}\n\t\tif (delegatedTo.toLowerCase() !== this.delegateeAddress.toLowerCase()) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Account is delegated to a different address (\" +\n\t\t\t\t\tdelegatedTo + \"), not \" + this.delegateeAddress +\n\t\t\t\t\t\" — use the correct account class to revoke\",\n\t\t\t);\n\t\t}\n\n\t\tconst results: {\n\t\t\tnonce?: bigint;\n\t\t\tmaxFeePerGas?: bigint;\n\t\t\tmaxPriorityFeePerGas?: bigint;\n\t\t} = {};\n\n\t\t// Build parallel fetch list\n\t\tconst ops: Promise<void>[] = [];\n\n\t\tif (overrides.nonce == null) {\n\t\t\tops.push(\n\t\t\t\tsendJsonRpcRequest(\n\t\t\t\t\tproviderRpc, \"eth_getTransactionCount\",\n\t\t\t\t\t[this.accountAddress, \"latest\"]\n\t\t\t\t).then((v) => { results.nonce = BigInt(v as string); })\n\t\t\t);\n\t\t}\n\n\t\tif (overrides.maxFeePerGas == null || overrides.maxPriorityFeePerGas == null) {\n\t\t\tops.push(\n\t\t\t\thandlefetchGasPrice(providerRpc, undefined)\n\t\t\t\t\t.then(([fee, tip]) => {\n\t\t\t\t\t\tresults.maxFeePerGas = fee;\n\t\t\t\t\t\tresults.maxPriorityFeePerGas = tip;\n\t\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (ops.length > 0) await Promise.all(ops);\n\n\t\tconst txNonce = overrides.nonce ?? results.nonce ?? 0n;\n\t\tconst maxFeePerGas = overrides.maxFeePerGas ?? results.maxFeePerGas ?? 0n;\n\t\tconst maxPriorityFeePerGas = overrides.maxPriorityFeePerGas ?? results.maxPriorityFeePerGas ?? 0n;\n\n\t\t// Authorization nonce = txNonce + 1 by default\n\t\t// (tx nonce is incremented before authorization processing in EIP-7702)\n\t\tconst authNonce = overrides.authorizationNonce ?? (txNonce + 1n);\n\n\t\t// Create undelegation authorization (delegates to address(0))\n\t\tconst authHex = createRevokeDelegationAuthorization(\n\t\t\tchainId, authNonce, eoaPrivateKey\n\t\t);\n\n\t\t// Convert Authorization7702Hex -> Authorization7702 for raw tx builder\n\t\tconst auth = {\n\t\t\tchainId: BigInt(authHex.chainId),\n\t\t\taddress: authHex.address,\n\t\t\tnonce: BigInt(authHex.nonce),\n\t\t\tyParity: (BigInt(authHex.yParity) === 0n ? 0 : 1) as 0 | 1,\n\t\t\tr: BigInt(authHex.r),\n\t\t\ts: BigInt(authHex.s),\n\t\t};\n\n\t\tconst gasLimit = overrides.gasLimit ?? 60_000n;\n\n\t\treturn createAndSignEip7702RawTransaction(\n\t\t\tchainId,\n\t\t\ttxNonce,\n\t\t\tmaxPriorityFeePerGas,\n\t\t\tmaxFeePerGas,\n\t\t\tgasLimit,\n\t\t\tthis.accountAddress,\n\t\t\t0n,\n\t\t\t\"0x\",\n\t\t\t[],\n\t\t\t[auth],\n\t\t\teoaPrivateKey,\n\t\t);\n\t}\n\n\t/**\n\t * Create a meta-transaction to update settings for a registered key.\n\t *\n\t * **Safety guardrail:** Throws if `settings.isAdmin` is `true`.\n\t * Developers who need admin keys must encode calldata themselves.\n\t *\n\t * @param keyHash - The key hash to update\n\t * @param settings - New settings for the key\n\t * @returns A {@link SimpleMetaTransaction} that calls `update(bytes32, uint256)`\n\t * @throws {AbstractionKitError} If settings.isAdmin is true\n\t */\n\tpublic static createUpdateKeySettingsMetaTransaction(\n\t\tkeyHash: string,\n\t\tsettings: CaliburKeySettings,\n\t): SimpleMetaTransaction {\n\t\tif (settings.isAdmin === true) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"createUpdateKeySettingsMetaTransaction does not allow setting \" +\n\t\t\t\t\"isAdmin to true. Encode the calldata manually for admin keys.\",\n\t\t\t);\n\t\t}\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst packedSettings = Calibur7702Account.packKeySettings(settings);\n\t\tconst callData = UPDATE_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\", \"uint256\"],\n\t\t\t[keyHash, packedSettings],\n\t\t).slice(2);\n\n\t\treturn { to: ZeroAddress, value: 0n, data: callData };\n\t}\n\n\t/**\n\t * Create a meta-transaction to invalidate nonces up to a given value.\n\t *\n\t * @param newNonce - The new nonce value (all nonces below this are invalidated)\n\t * @returns A {@link SimpleMetaTransaction} that calls `invalidateNonce(uint256)`\n\t */\n\tpublic static createInvalidateNonceMetaTransaction(\n\t\tnewNonce: bigint,\n\t): SimpleMetaTransaction {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = INVALIDATE_NONCE_SELECTOR + abiCoder.encode(\n\t\t\t[\"uint256\"],\n\t\t\t[newNonce],\n\t\t).slice(2);\n\n\t\treturn { to: ZeroAddress, value: 0n, data: callData };\n\t}\n\n\t// ─── Read Functions (instance, RPC calls) ────────────────────────────\n\n\t/**\n\t * Check if this EOA is delegated to this account's singleton (delegatee).\n\t * Returns `false` if not delegated at all or delegated to a different\n\t * singleton. Use the standalone {@link getDelegatedAddress} utility to\n\t * get the raw delegatee address regardless of which singleton it is.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @returns True if the account is delegated to `this.delegateeAddress`\n\t */\n\tpublic async isDelegatedToThisAccount(providerRpc: string): Promise<boolean> {\n\t\tconst address = await getDelegatedAddress(this.accountAddress, providerRpc);\n\t\tif (address === null) return false;\n\t\treturn address.toLowerCase() === this.delegateeAddress.toLowerCase();\n\t}\n\n\t/**\n\t * Get the account nonce from the EntryPoint.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param sequenceKey - Optional sequence key for parallel nonce channels (default: 0)\n\t * @returns The fully constructed nonce `(sequenceKey << 64) | seq`\n\t */\n\tpublic async getNonce(\n\t\tproviderRpc: string,\n\t\tsequenceKey = 0,\n\t): Promise<bigint> {\n\t\treturn fetchAccountNonce(\n\t\t\tproviderRpc,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.accountAddress,\n\t\t\tsequenceKey,\n\t\t);\n\t}\n\n\t/**\n\t * Check if a key is registered on this account.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param keyHash - The key hash to check\n\t * @returns True if the key is registered\n\t */\n\tpublic async isKeyRegistered(\n\t\tproviderRpc: string,\n\t\tkeyHash: string,\n\t): Promise<boolean> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = IS_REGISTERED_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: callData,\n\t\t\t\t},\n\t\t\t\t\"latest\",\n\t\t\t],\n\t\t);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = abiCoder.decode([\"bool\"], result);\n\t\t\treturn decoded[0] as boolean;\n\t\t}\n\t\tthrow new AbstractionKitError(\n\t\t\t\"BAD_DATA\",\n\t\t\t\"Unexpected response from isRegistered call\",\n\t\t);\n\t}\n\n\t/**\n\t * Get the settings for a registered key.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param keyHash - The key hash to query\n\t * @returns Parsed {@link CaliburKeySettingsResult} with all fields populated\n\t */\n\tpublic async getKeySettings(\n\t\tproviderRpc: string,\n\t\tkeyHash: string,\n\t): Promise<CaliburKeySettingsResult> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = GET_KEY_SETTINGS_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: callData,\n\t\t\t\t},\n\t\t\t\t\"latest\",\n\t\t\t],\n\t\t);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = abiCoder.decode([\"uint256\"], result);\n\t\t\treturn Calibur7702Account.unpackKeySettings(BigInt(decoded[0]));\n\t\t}\n\t\tthrow new AbstractionKitError(\n\t\t\t\"BAD_DATA\",\n\t\t\t\"Unexpected response from getKeySettings call\",\n\t\t);\n\t}\n\n\t/**\n\t * Get the full key data for a registered key.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param keyHash - The key hash to query\n\t * @returns Parsed {@link CaliburKey}\n\t */\n\tpublic async getKey(\n\t\tproviderRpc: string,\n\t\tkeyHash: string,\n\t): Promise<CaliburKey> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = GET_KEY_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: callData,\n\t\t\t\t},\n\t\t\t\t\"latest\",\n\t\t\t],\n\t\t);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = abiCoder.decode([\"(uint8,bytes)\"], result);\n\t\t\tconst keyTuple = decoded[0] as [number, string];\n\t\t\treturn {\n\t\t\t\tkeyType: Number(keyTuple[0]) as CaliburKeyType,\n\t\t\t\tpublicKey: keyTuple[1] as string,\n\t\t\t};\n\t\t}\n\t\tthrow new AbstractionKitError(\n\t\t\t\"BAD_DATA\",\n\t\t\t\"Unexpected response from getKey call\",\n\t\t);\n\t}\n\n\t/**\n\t * Get all keys registered on this account.\n\t * Iterates `keyCount()` + `keyAt(i)` to enumerate all keys.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param overrides - Optional overrides\n\t * @param overrides.blockNumber - Block number to query at. If omitted,\n\t * fetches the current block number once and uses it for all reads.\n\t * @returns Array of registered {@link CaliburKey}s\n\t */\n\tpublic async getKeys(\n\t\tproviderRpc: string,\n\t\toverrides: { blockNumber?: bigint } = {},\n\t): Promise<CaliburKey[]> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tlet blockTag: string;\n\t\tif (overrides.blockNumber != null) {\n\t\t\tblockTag = \"0x\" + overrides.blockNumber.toString(16);\n\t\t} else {\n\t\t\tconst blockHex = await sendJsonRpcRequest(\n\t\t\t\tproviderRpc, \"eth_blockNumber\", [],\n\t\t\t) as string;\n\t\t\tblockTag = blockHex;\n\t\t}\n\n\t\t// Get key count\n\t\tconst countResult = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: KEY_COUNT_SELECTOR,\n\t\t\t\t},\n\t\t\t\tblockTag,\n\t\t\t],\n\t\t);\n\n\t\tif (typeof countResult !== \"string\") {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Unexpected response from keyCount call\",\n\t\t\t);\n\t\t}\n\n\t\t// Non-delegated accounts return \"0x\" which can't be converted to BigInt.\n\t\tif (countResult === \"0x\" || countResult === \"0x0\") {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst count = Number(BigInt(countResult));\n\t\tif (count === 0) return [];\n\n\t\t// Batch all keyAt calls in parallel\n\t\tconst keyAtPromises: Promise<any>[] = [];\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst keyAtCallData = KEY_AT_SELECTOR + abiCoder.encode(\n\t\t\t\t[\"uint256\"],\n\t\t\t\t[i],\n\t\t\t).slice(2);\n\n\t\t\tkeyAtPromises.push(\n\t\t\t\tsendJsonRpcRequest(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\t\"eth_call\",\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\t\t\tdata: keyAtCallData,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tblockTag,\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst keyResults = await Promise.all(keyAtPromises);\n\t\tconst keys: CaliburKey[] = [];\n\n\t\tfor (let i = 0; i < keyResults.length; i++) {\n\t\t\tconst keyResult = keyResults[i];\n\t\t\tif (typeof keyResult !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t`Unexpected response from keyAt(${i}) call on ${this.accountAddress}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst decoded = abiCoder.decode([\"(uint8,bytes)\"], keyResult);\n\t\t\tconst keyTuple = decoded[0] as [number, string];\n\t\t\tkeys.push({\n\t\t\t\tkeyType: Number(keyTuple[0]) as CaliburKeyType,\n\t\t\t\tpublicKey: keyTuple[1] as string,\n\t\t\t});\n\t\t}\n\n\t\treturn keys;\n\t}\n\n\t// ─── Token Paymaster Support ─────────────────────────────────────────\n\n\t/**\n\t * Prepend a token `approve` call to existing calldata for a token paymaster.\n\t * Decodes the existing BatchedCall, prepends an ERC-20 approve transaction,\n\t * and re-encodes.\n\t *\n\t * @param callData - Existing encoded calldata (executeUserOp format)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended\n\t */\n\tpublic prependTokenPaymasterApproveToCallData(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\treturn Calibur7702Account.prependTokenPaymasterApproveToCallDataStatic(\n\t\t\tcallData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tapproveAmount,\n\t\t);\n\t}\n\n\t/**\n\t * Static version of {@link prependTokenPaymasterApproveToCallData}.\n\t * Decodes existing executeUserOp calldata, prepends an ERC-20 approve call,\n\t * and re-encodes the BatchedCall.\n\t *\n\t * @param callData - Existing encoded calldata (executeUserOp format)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended\n\t */\n\tpublic static prependTokenPaymasterApproveToCallDataStatic(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\t\t// Build approve transaction\n\t\tconst approveFunctionSelector = getFunctionSelector(\"approve(address,uint256)\");\n\t\tconst approveCallData = createCallData(\n\t\t\tapproveFunctionSelector,\n\t\t\t[\"address\", \"uint256\"],\n\t\t\t[paymasterAddress, approveAmount],\n\t\t);\n\n\t\tif (!callData.startsWith(EXECUTE_USER_OP_SELECTOR)) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Invalid calldata, should start with \" + EXECUTE_USER_OP_SELECTOR +\n\t\t\t\t\" (executeUserOp selector)\",\n\t\t\t\t{ context: { callData } },\n\t\t\t);\n\t\t}\n\n\t\t// Decode: strip selector -> decode BatchedCall struct\n\t\tconst batchedCallDecoded = abiCoder.decode(\n\t\t\t[\"((address,uint256,bytes)[],bool)\"],\n\t\t\t\"0x\" + callData.slice(10),\n\t\t);\n\t\tconst existingCalls = batchedCallDecoded[0][0] as [];\n\t\tconst revertOnFailure = batchedCallDecoded[0][1] as boolean;\n\n\t\tconst decodedTransactions: SimpleMetaTransaction[] = existingCalls.map(\n\t\t\t(call: [string, bigint, string]) => ({\n\t\t\t\tto: call[0],\n\t\t\t\tvalue: BigInt(call[1]),\n\t\t\t\tdata: typeof call[2] !== \"string\"\n\t\t\t\t\t? new TextDecoder().decode(call[2])\n\t\t\t\t\t: call[2],\n\t\t\t}),\n\t\t);\n\n\t\t// Prepend approve\n\t\tdecodedTransactions.unshift({\n\t\t\tto: tokenAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: approveCallData,\n\t\t});\n\n\t\t// Re-encode as BatchedCall struct\n\t\tconst calls = decodedTransactions.map(tx => [tx.to, tx.value, tx.data]);\n\t\tconst batchedCallEncoded = abiCoder.encode(\n\t\t\t[\"((address,uint256,bytes)[],bool)\"],\n\t\t\t[[calls, revertOnFailure]],\n\t\t);\n\t\treturn EXECUTE_USER_OP_SELECTOR + batchedCallEncoded.slice(2);\n\t}\n}\n","import { AbstractionKitError } from \"src/errors\";\nimport { MetaTransaction } from \"../../../types\";\nimport { SafeAccount } from \"../SafeAccount\";\nimport { AbiCoder } from \"ethers\";\n\n/**\n * Abstract base class for Safe modules. Provides shared utilities for\n * encoding calldata, enabling the module, and validating on-chain results.\n */\nexport abstract class SafeModule {\n\treadonly moduleAddress: string;\n protected readonly abiCoder:AbiCoder;\n\n\t/**\n\t * @param moduleAddress - The deployed address of the Safe module contract.\n\t */\n\tconstructor(moduleAddress: string) {\n\t\tthis.moduleAddress = moduleAddress;\n this.abiCoder = AbiCoder.defaultAbiCoder();\n\t}\n\n /**\n\t * create MetaTransaction to enable this module\n\t * @param accountAddress - Safe account to enable the module for\n\t * @returns a MetaTransaction\n\t */\n public createEnableModuleMetaTransaction(\n accountAddress: string,\n ):MetaTransaction{\n return SafeAccount.createEnableModuleMetaTransaction(\n this.moduleAddress,\n accountAddress\n );\n }\n\n /**\n * Throws if the RPC call returned empty data (`0x`), which typically\n * indicates the module contract is not deployed at the expected address.\n * @param result - The raw hex result from an `eth_call`.\n * @param requestName - Name of the calling method, used in the error message.\n */\n public checkForEmptyResultAndRevert(\n result: string, requestName: string\n ): void {\n if(result == \"0x\"){\n throw new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\trequestName + \" returned 0x, \" +\n \"module contract \" + this.moduleAddress + \n \" is probably not deployed\"\n );\n } \n }\n}\n","import { SafeModule } from \"./SafeModule\";\nimport { createCallData, sendEthCallRequest } from \"../../../utils\";\nimport { MetaTransaction } from \"../../../types\";\n\n/**\n * Pre-deployed Social Recovery Module addresses, each with a different\n * grace period before a confirmed recovery can be finalized.\n */\nexport enum SocialRecoveryModuleGracePeriodSelector {\n\t/** 3-minute grace period (useful for testing). */\n\tAfter3Minutes = \"0x949d01d424bE050D09C16025dd007CB59b3A8c66\",\n\t/** 3-day grace period. */\n\tAfter3Days = \"0x38275826E1933303E508433dD5f289315Da2541c\",\n\t/** 7-day grace period. */\n\tAfter7Days = \"0x088f6cfD8BB1dDb1BB069CCb3fc1A98927D233f2\",\n\t/** 14-day grace period. */\n\tAfter14Days = \"0x9BacD92F4687Db306D7ded5d4513a51EA05df25b\",\n}\n\n/**\n * Safe module for social recovery with guardians. Allows designated guardians\n * to replace the owners of a Safe account when the original keys are lost.\n * Guardians must reach a configurable approval threshold before recovery\n * can be executed, and a grace period must elapse before finalization.\n */\nexport class SocialRecoveryModule extends SafeModule{\n static readonly DEFAULT_SOCIAL_RECOVERY_ADDRESS =\n SocialRecoveryModuleGracePeriodSelector.After3Days;\n\n /**\n * @param moduleAddress - Deployed address of the Social Recovery Module.\n * Defaults to the 3-day grace period deployment.\n */\n constructor(\n\t\tmoduleAddress: string = SocialRecoveryModule.DEFAULT_SOCIAL_RECOVERY_ADDRESS,\n\t) {\n\t\tsuper(moduleAddress);\n\t}\n\n /**\n\t * create MetaTransaction that lets single guardian confirm the execution of the recovery request.\n * Can also trigger the start of the execution by passing true to 'execute' parameter.\n * Once triggered the recovery is pending for the recovery period before it can be finalised.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @param execute - Whether to auto-start execution of recovery.\n\t * @returns a MetaTransaction\n\t */\n public createConfirmRecoveryMetaTransaction(\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n execute: boolean\n ):MetaTransaction{\n //\"confirmRecovery(address,address[],uint256,bool)\"\n const functionSelector = \"0x064e2d0e\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\", \"bool\"],\n [accountAddress, newOwners, newThreshold, execute],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that lets multiple guardians confirm the execution of the recovery request.\n * Can also trigger the start of the execution by passing true to 'execute' parameter.\n * Once triggered the recovery is pending for the recovery period before it can be finalised.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @param signatureData - The guardians signers and signatures pair list.\n * @param execute - true to auto-start execution of recovery or false for not.\n\t * @returns a MetaTransaction\n */\n public createMultiConfirmRecoveryMetaTransaction(\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n signaturePairList: RecoverySignaturePair[],\n execute: boolean\n ):MetaTransaction{\n //\"multiConfirmRecovery(address,address[],uint256,SignatureData[],bool)\"\n const functionSelector = \"0x0728e1e7\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\", \"(address,bytes)\", \"bool\"],\n [\n accountAddress,\n newOwners,\n newThreshold,\n signaturePairList.map(\n signaturePair=> [signaturePair.signer, signaturePair.signature]),\n execute\n ],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * @notice create MetaTransaction that lets the guardians start the execution of the recovery request.\n * Once triggered the recovery is pending for the recovery period before it can be finalised.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n\t * @returns a MetaTransaction\n */\n public createExecuteRecoveryMetaTransaction(\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n ):MetaTransaction{\n //\"executeRecovery(address,address[],uint256)\"\n const functionSelector = \"0xb1f85f69\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\"],\n [accountAddress, newOwners, newThreshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransaction that finalizes an ongoing recovery request if the recovery period is over.\n * The method is public and callable by anyone to enable orchestration.\n * @param accountAddress - The target account.\n\t * @returns a MetaTransaction\n */\n public createFinalizeRecoveryMetaTransaction(\n accountAddress: string,\n ):MetaTransaction{\n //\"finalizeRecovery(address)\"\n const functionSelector = \"0x315a7af3\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransction that lets the account cancel an ongoing recovery request.\n\t * @returns a MetaTransaction\n */\n public createCancelRecoveryMetaTransaction():MetaTransaction{\n //\"cancelRecovery()\";\n const functionSelector = \"0x0ba234d6\";\n const callData = functionSelector;\n\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransaction that lets the owner add a guardian for its account.\n * @param guardianAddress - The guardian to add.\n * @param threshold - The new threshold that will be set after addition.\n\t * @returns a MetaTransaction\n */\n public createAddGuardianWithThresholdMetaTransaction(\n guardianAddress: string,\n threshold: bigint,\n ):MetaTransaction{\n //\"addGuardianWithThreshold(address,uint256)\"\n const functionSelector = \"0xbe0e54d7\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"uint256\"],\n [guardianAddress, threshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that lets the owner revoke a guardian from its account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n * (to get the prevGuardian paramter).\n * @param accountAddress - The target account.\n * @param guardianAddress - The guardian to revoke.\n * @param threshold - The new threshold that will be set after execution of revokation.\n * @param prevGuardian - (if not provided, will be detected using the nodeRpcUrl)\n * The previous guardian linking to the guardian in the linked list.\n\t * @returns promise of a MetaTransaction\n */\n public async createRevokeGuardianWithThresholdMetaTransaction(\n nodeRpcUrl: string,\n accountAddress: string,\n guardianAddress: string,\n threshold: bigint,\n\t\toverrides: {\n prevGuardianAddress?: string,\n\t\t} = {},\n ):Promise<MetaTransaction>{\n let prevGuardianAddressT = overrides.prevGuardianAddress;\n\t\tif (prevGuardianAddressT == null) {\n\t\t\tconst guardians = await this.getGuardians(nodeRpcUrl, accountAddress);\n\t\t\tconst guardianToDeleteIndex = guardians.indexOf(guardianAddress);\n\t\t\tif (guardianToDeleteIndex == -1) {\n\t\t\t\tthrow new RangeError(\n guardianAddress + \n \" is not a current guardian for account : \" +\n accountAddress\n );\n\t\t\t} else if (guardianToDeleteIndex == 0) {\n //SENTINEL_ADDRESS\n\t\t\t\tprevGuardianAddressT = \"0x0000000000000000000000000000000000000001\";\n\t\t\t} else if (guardianToDeleteIndex > 0) {\n\t\t\t\tprevGuardianAddressT = guardians[guardianToDeleteIndex - 1];\n\t\t\t} else {\n\t\t\t\tthrow new RangeError(\"Invalid guardian index\");\n\t\t\t}\n\t\t}\n\t\treturn this.createStandardRevokeGuardianWithThresholdMetaTransaction(\n\t\t\tprevGuardianAddressT,\n guardianAddress,\n\t\t\tthreshold,\n\t\t);\n }\n\n /**\n * create MetaTransaction that lets the owner revoke a guardian from its account.\n * @param prevGuardian - The previous guardian linking to the guardian in the linked list.\n * @param guardian - The guardian to revoke.\n * @param threshold - The new threshold that will be set after execution of revokation.\n\t * @returns a MetaTransaction\n */\n public createStandardRevokeGuardianWithThresholdMetaTransaction(\n prevGuardianAddress: string,\n guardianAddress: string,\n threshold: bigint,\n ):MetaTransaction{\n //\"revokeGuardianWithThreshold(address,address,uint256)\"\n const functionSelector = \"0x936f7d86\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"uint256\"],\n [prevGuardianAddress, guardianAddress, threshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create MetaTransaction that lets the owner change the guardian threshold required to initiate a recovery.\n * @param threshold - The new threshold that will be set after execution of revokation.\n\t * @returns a MetaTransaction\n */\n public createChangeThresholdMetaTransaction(\n threshold: bigint,\n ):MetaTransaction{\n //\"changeThreshold(address,uint256)\"\n const functionSelector = \"0x694e80c3\";\n const callData = createCallData(\n functionSelector,\n [\"uint256\"],\n [threshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * Generates the recovery hash that should be signed by the guardian to authorize a recovery\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @param nonce - recovery nonce\n\t * @returns promise of a recovery hash\n */\n public async getRecoveryHash(\n nodeRpcUrl: string,\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n nonce: bigint,\n ):Promise<string>{\n //\"getRecoveryHash(address,address[],uint256,uint256)\"\n const functionSelector = \"0x5f19df08\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\", \"uint256\"],\n [accountAddress, newOwners, newThreshold, nonce],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const recoveryHashResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n \n this.checkForEmptyResultAndRevert(recoveryHashResult, \"getRecoveryHash\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"bytes32\"], recoveryHashResult);\n return decodedCalldata[0];\n }\n\n /**\n * Retrieves the account's current ongoing recovery request.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of the account's current recovery request\n */\n public async getRecoveryRequest(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<RecoveryRequest>{\n //\"getRecoveryRequest(address)\"\n const functionSelector = \"0x4f9a28b9\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const recoveryRequestResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(recoveryRequestResult, \"getRecoveryRequest\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"(uint256,uint256,uint64,address[])\"], recoveryRequestResult);\n\n return {\n guardiansApprovalCount: BigInt(decodedCalldata[0][0]),\n newThreshold: BigInt(decodedCalldata[0][1]),\n executeAfter: BigInt(decodedCalldata[0][2]),\n newOwners: decodedCalldata[0][3],\n }\n }\n\n /**\n * Retrieves the guardian approval count for this particular recovery request at current nonce.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @return promise of the account's current recovery approvals count\n */\n public async getRecoveryApprovals(\n nodeRpcUrl: string,\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n ):Promise<bigint>{\n //\"getRecoveryApprovals(address,address[],uint256)\"\n const functionSelector = \"0x6c6595ca\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\"],\n [accountAddress, newOwners, newThreshold],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const recoveryApprovalResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(recoveryApprovalResult, \"getRecoveryApprovals\");\n\t const decodedCalldata = this.abiCoder.decode([\"uint256\"], recoveryApprovalResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n * Retrieves specific guardian approval status a particular recovery request at current nonce.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param guardian - The guardian.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @return promise of guardian approval status\n */\n public async hasGuardianApproved(\n nodeRpcUrl: string,\n accountAddress: string,\n guardian: string,\n newOwners: string[],\n newThreshold: number,\n ):Promise<boolean>{\n //\"hasGuardianApproved(address,address,address[],uint256)\"\n const functionSelector = \"0x37d82c36\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"address[]\", \"uint256\"],\n [accountAddress, guardian, newOwners, newThreshold],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const hasGuardianApprovedResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(\n hasGuardianApprovedResult, \"hasGuardianApproved\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"bool\"], hasGuardianApprovedResult);\n\n return Boolean(decodedCalldata[0]);\n }\n\n /**\n * Checks if an address is a guardian for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param guardian - The address to check.\n * @return promise of `true` if the address is a guardian for\n * the account otherwise `false`.\n */\n public async isGuardian(\n nodeRpcUrl: string,\n accountAddress: string,\n guardian: string,\n ):Promise<boolean>{\n //\"isGuardian(address,address)\"\n const functionSelector = \"0xd4ee9734\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [accountAddress, guardian],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const isGuardianResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(isGuardianResult, \"isGuardian\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"bool\"], isGuardianResult);\n\n return Boolean(decodedCalldata[0]);\n }\n\n /**\n * Counts the number of active guardians for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of The number of active guardians for an account.\n */\n public async guardiansCount(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<bigint>{\n //\"guardiansCount(address)\"\n const functionSelector = \"0xc026e7ee\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const guardiansCountResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(guardiansCountResult, \"guardiansCount\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"uint256\"], guardiansCountResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n * Retrieves the account threshold.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of Threshold.\n */\n public async threshold(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<bigint>{\n //\"threshold(address)\"\n const functionSelector = \"0xc86ec2bf\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const thresholdResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(thresholdResult, \"threshold\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"uint256\"], thresholdResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n * Get the active guardians for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of a list of the active guardians for an account.\n */\n public async getGuardians(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<string[]>{\n //\"getGuardians(address)\"\n const functionSelector = \"0xf18858ab\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const getGuardiansResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(getGuardiansResult, \"threshold\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"address[]\"], getGuardiansResult);\n\n return decodedCalldata[0];\n }\n\n /**\n * Get the module nonce for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of the nonce for this account.\n */\n public async nonce(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<bigint>{\n //\"nonce(address)\"\n const functionSelector = \"0x70ae92d2\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const nonceResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(nonceResult, \"threshold\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"uint256\"], nonceResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n\t * create recovery request eip712 data\n\t * @param rpcNode - node to fetch the recovery nonce\n\t * @param accountAddress - address of account to recover\n\t * @param newOwners - new owners to recover to\n\t * @param newThreshold - new threshold\n\t * @param overrides.recoveryNonce - manually set the recovery nonce\n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tasync getRecoveryRequestEip712Data(\n rpcNode: string,\n chainId: bigint,\n accountAddress: string,\n newOwners: string[],\n newThreshold: bigint,\n overrides: {\n recoveryNonce?: bigint,\n } = {}\n\t): Promise<{\n domain: RecoveryRequestTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: RecoveryRequestTypedMessageValue\n }> {\n let recoveryNonce;\n if(overrides.recoveryNonce == null){\n const socialRecoveryModule = new SocialRecoveryModule(\n this.moduleAddress\n );\n recoveryNonce = await socialRecoveryModule.nonce(rpcNode, accountAddress);\n }else{\n recoveryNonce = overrides.recoveryNonce;\n }\n\n const messageValue: RecoveryRequestTypedMessageValue = {\n wallet: accountAddress,\n newOwners,\n newThreshold,\n nonce: recoveryNonce\n };\n const domain: RecoveryRequestTypedDataDomain = {\n name: \"Social Recovery Module\",\n version: \"0.0.1\",\n chainId: Number(chainId),\n verifyingContract: this.moduleAddress\n };\n\n return {\n domain,\n types: EIP712_RECOVERY_MODULE_TYPE,\n messageValue,\n };\n\t}\n}\n\n/**\n * Represents an ongoing recovery request for a Safe account.\n */\nexport type RecoveryRequest = {\n /** Number of guardians that have approved this recovery request. */\n guardiansApprovalCount:bigint;\n /** The new owner threshold that will be set after recovery. */\n newThreshold:bigint;\n /** Unix timestamp (seconds) after which the recovery can be finalized. 0 if not yet executed. */\n executeAfter:bigint;\n /** The list of new owner addresses that will replace the current owners. */\n newOwners:string[];\n}\n\n/**\n * A guardian address paired with its EIP-712 signature authorizing a recovery.\n */\nexport type RecoverySignaturePair = {\n /** Guardian address that produced the signature. */\n signer:string;\n /** Hex-encoded signature bytes. */\n signature:string;\n}\n\n/** EIP-712 primary type string used when signing recovery requests. */\nexport const EXECUTE_RECOVERY_PRIMARY_TYPE = \"ExecuteRecovery\";\n\n/**\n * EIP-712 domain separator fields for signing recovery requests.\n */\nexport type RecoveryRequestTypedDataDomain = {\n /** Domain name, always \"Social Recovery Module\". */\n name: string;\n /** Domain version, e.g. \"0.0.1\". */\n version: string;\n /** Chain ID of the target network. */\n\tchainId: number;\n /** Address of the Social Recovery Module contract. */\n\tverifyingContract: string;\n}\n\n/**\n * EIP-712 structured message values for a recovery request signature.\n */\nexport type RecoveryRequestTypedMessageValue = {\n /** Address of the Safe account being recovered. */\n\twallet: string;\n /** New owner addresses to set after recovery. */\n\tnewOwners: string[];\n /** New Safe threshold to set after recovery. */\n\tnewThreshold: bigint;\n /** Recovery nonce for replay protection. */\n\tnonce: bigint;\n}\n\n/** EIP-712 type definitions for the `ExecuteRecovery` primary type. */\nexport const EIP712_RECOVERY_MODULE_TYPE = {\n ExecuteRecovery: [\n { type: \"address\", name: \"wallet\" },\n { type: \"address[]\", name: \"newOwners\" },\n { type: \"uint256\", name: \"newThreshold\" },\n { type: \"uint256\", name: \"nonce\" },\n ],\n};\n","import { SafeModule } from \"./SafeModule\";\nimport { createCallData, sendEthCallRequest } from \"../../../utils\";\nimport { MetaTransaction } from \"../../../types\";\n\n/**\n * Address of the legacy Allowance Module v0.1.0 contract.\n * Replaced by v1.0.0 due to a bug in the v0.1.0 contract.\n * Use this to interact with existing allowances set on the old module.\n * @deprecated Prefer `AllowanceModule.DEFAULT_ALLOWANCE_MODULE_ADDRESS` (v1.0.0) for new allowances.\n */\nexport const ALLOWANCE_MODULE_V0_1_0_ADDRESS =\n \"0xAA46724893dedD72658219405185Fb0Fc91e091C\";\n\n/**\n * Safe module for managing token spending allowances (v1.0.0). Enables Safe owners\n * to grant delegates recurring or one-time permission to transfer ERC-20\n * tokens from the Safe, subject to configurable limits and reset periods.\n *\n * Requires Safe v1.1.1 or later.\n *\n * Each delegate is limited to 65534 transfers per token allowance (uint16 nonce).\n * Once exhausted, a new delegate must be used.\n *\n * **Breaking change (v1.0.0):** The default module address changed from\n * {@link ALLOWANCE_MODULE_V0_1_0_ADDRESS} (`0xAA46…091C`) due to a bug in the\n * v0.1.0 contract. If you have active allowances on the old module, use\n * `new AllowanceModule(ALLOWANCE_MODULE_V0_1_0_ADDRESS)` to interact with them.\n */\nexport class AllowanceModule extends SafeModule{\n static readonly DEFAULT_ALLOWANCE_MODULE_ADDRESS =\n \"0x691f59471Bfd2B7d639DCF74671a2d648ED1E331\";\n\n /**\n * @param moduleAddress - Deployed address of the Allowance Module contract.\n * Defaults to {@link DEFAULT_ALLOWANCE_MODULE_ADDRESS}.\n */\n constructor(\n\t\tmoduleAddress: string = AllowanceModule.DEFAULT_ALLOWANCE_MODULE_ADDRESS,\n\t) {\n\t\tsuper(moduleAddress);\n\t}\n \n /**\n * Creates a MetaTransaction that sets a one-time (non-recurring) token allowance\n * for a delegate. The allowance is consumed once and never resets.\n * @param delegate - Address of the delegate to grant the allowance to.\n * @param token - ERC-20 token contract address (use zero address for native token).\n * @param allowanceAmount - Maximum amount the delegate can spend, in the token's smallest unit.\n * @param startAfterInMinutes - Delay in minutes before the allowance becomes active.\n * @returns A MetaTransaction to be executed by the Safe.\n */\n public createOneTimeAllowanceMetaTransaction(\n delegate: string,\n token: string,\n allowanceAmount: bigint,\n startAfterInMinutes:bigint\n ):MetaTransaction{\n return this.createBaseSetAllowanceMetaTransaction(\n delegate,\n token,\n allowanceAmount,\n 0n,\n startAfterInMinutes\n )\n }\n \n /**\n * Creates a MetaTransaction that sets a recurring token allowance for a delegate.\n * The allowance resets to the full amount after each validity period elapses.\n * @param delegate - Address of the delegate to grant the allowance to.\n * @param token - ERC-20 token contract address (use zero address for native token).\n * @param allowanceAmount - Maximum amount per period, in the token's smallest unit.\n * @param recurringAllowanceValidityPeriodInMinutes - Duration of each allowance period in minutes.\n * @param startAfterInMinutes - Delay in minutes before the first allowance period begins.\n * @returns A MetaTransaction to be executed by the Safe.\n */\n public createRecurringAllowanceMetaTransaction(\n delegate: string,\n token: string,\n allowanceAmount: bigint,\n recurringAllowanceValidityPeriodInMinutes: bigint,\n startAfterInMinutes:bigint\n ):MetaTransaction{\n return this.createBaseSetAllowanceMetaTransaction(\n delegate,\n token,\n allowanceAmount,\n recurringAllowanceValidityPeriodInMinutes,\n startAfterInMinutes\n )\n }\n\n /**\n\t * create MetaTransaction that allows to update the allowance for \n * a specified token. This can only be done via a Safe transaction.\n * @param delegate - Delegate whose allowance should be updated.\n * @param token - Token contract address.\n * @param allowanceAmount - allowance in smallest token unit.\n * @param resetTimeMin - Time after which the allowance should reset\n * @param resetBaseMin - Time based on which the reset time should be increased\n * @returns a MetaTransaction\n\t */\n public createBaseSetAllowanceMetaTransaction(\n delegate: string,\n token: string,\n allowanceAmount: bigint,\n resetTimeMin: bigint,\n resetBaseMin:bigint\n ):MetaTransaction{\n //setAllowance(address delegate, address token, uint96 allowanceAmount, uint16 resetTimeMin, uint32 resetBaseMin)\n const functionSelector = \"0xbeaeb388\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"uint96\", \"uint16\", \"uint32\"],\n [delegate, token, allowanceAmount, resetTimeMin, resetBaseMin],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that allows to renew(reset) the allowance for a specific\n * delegate and token.\n * @param delegate - Delegate whose allowance should be updated.\n * @param token - Token contract address.\n\t * @returns a MetaTransaction\n */\n public createRenewAllowanceMetaTransaction(\n delegate: string, token: string\n ):MetaTransaction{\n //resetAllowance(address delegate, address token)\n const functionSelector = \"0xc19bf50e\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [delegate, token],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that allows to remove the allowance for a specific\n * delegate and token. This will set all values except the `nonce` to 0.\n * @param delegate - Delegate whose allowance should be updated.\n * @param token - Token contract address.\n\t * @returns a MetaTransaction\n */\n public createDeleteAllowanceMetaTransaction(\n delegate: string, token: string\n ):MetaTransaction{\n //deleteAllowance(address delegate, address token)\n const functionSelector = \"0x885133e3\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [delegate, token],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * Creates a MetaTransaction that executes a token transfer using an existing allowance.\n * Can be called by the delegate or by anyone with a valid delegate signature.\n * @param allowanceSourceSafeAddress - Safe address whose allowance is being spent.\n * @param token - ERC-20 token contract address to transfer.\n * @param to - Recipient address for the token transfer.\n * @param amount - Amount to transfer, in the token's smallest unit.\n * @param delegate - Delegate address whose allowance is being used.\n * @param overrides.delegateSignature - Optional signature from the delegate. Defaults to a\n * sentinel value indicating the caller is the delegate themselves.\n * @param overrides.paymentToken - Optional token address used to pay for execution.\n * @param overrides.paymentAmount - Amount to pay for execution (required if paymentToken is set).\n * @returns A MetaTransaction to be executed by the Safe.\n * @throws Will revert on-chain if the delegate's nonce has reached 65534 for this token.\n */\n public createAllowanceTransferMetaTransaction(\n allowanceSourceSafeAddress: string,\n token: string,\n to: string,\n amount: bigint,\n delegate:string,\n overrides:{\n delegateSignature?:string,\n paymentToken?: string,\n paymentAmount?: bigint,\n } = {}\n ):MetaTransaction{\n let paymentToken = \"0x0000000000000000000000000000000000000000\"\n let paymentAmount = 0n;\n if(overrides.paymentToken != null){\n paymentToken = overrides.paymentToken;\n if(overrides.paymentAmount == null){\n throw new RangeError(\"must specify paymentAmount if paymentToken is set\")\n }\n paymentAmount = overrides.paymentAmount;\n }\n \n let delegateSignature = \n overrides.delegateSignature??\n\t\t \"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\"\n\n return this.createBaseExecuteAllowanceTransferMetaTransaction(\n allowanceSourceSafeAddress,\n token,\n to,\n amount,\n paymentToken,\n paymentAmount,\n delegate,\n delegateSignature\n )\n }\n\n /**\n * \n * create MetaTransaction that allows to use the allowance to perform a transfer.\n * @param safeAddress - The Safe whose funds should be used.\n * @param token - Token contract address.\n * @param to - Address that should receive the tokens.\n * @param amount - Amount that should be transferred.\n * @param paymentToken - Token that should be used to pay for the execution of the transfer.\n * @param payment - Amount to should be paid for executing the transfer.\n * @param delegate - Delegate whose allowance should be updated.\n * @param signature - Signature generated by the delegate to authorize the transfer.\n\t * @returns a MetaTransaction\n */\n public createBaseExecuteAllowanceTransferMetaTransaction(\n safeAddress: string,\n token: string,\n to: string,\n amount: bigint,\n paymentToken: string,\n payment: bigint,\n delegate:string,\n delegateSignature:string\n ):MetaTransaction{\n //executeAllowanceTransfer(address,address,address,uint96,address,uint96,address,bytes)\n const functionSelector = \"0x4515641a\";\n const callData = createCallData(\n functionSelector,\n [\n \"address\",\n \"address\",\n \"address\",\n \"uint96\",\n \"address\",\n \"uint96\",\n \"address\",\n \"bytes\",\n ],\n [\n safeAddress,\n token,\n to,\n amount,\n paymentToken,\n payment,\n delegate,\n delegateSignature\n ]\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransaction that allows to add a delegate.\n * @param delegate - Delegate that should be added.\n\t * @returns a MetaTransaction\n */\n public createAddDelegateMetaTransaction(\n delegate: string,\n ):MetaTransaction{\n //\"addDelegate(address)\"\n const functionSelector = \"0xe71bdf41\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [delegate],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create a MetaTransaction that allows to remove a delegate.\n * @param delegate - Delegate that should be removed.\n * @param removeAllowances - Indicator if allowances should also be removed.\n * This should be set to `true` unless this causes an out of gas,\n * in this case the allowances should be \"manually\" deleted via `deleteAllowance`.\n\t * @returns a MetaTransaction\n */\n public createRemoveDelegateMetaTransaction(\n delegate: string,\n removeAllowances: boolean\n ):MetaTransaction{\n //\"removeDelegate(address,bool)\"\n const functionSelector = \"0xdd43a79f\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"bool\"],\n [delegate, removeAllowances],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n \n /**\n * Get delegated tokens\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param safeAddress - The target account.\n * @param delegate - The target delegate.\n\t * @returns promise of a list of tokens\n */\n public async getTokens(\n nodeRpcUrl: string,\n safeAddress: string,\n delegate: string,\n ):Promise<string[]>{\n //\"getTokens(address,address)\"\n const functionSelector = \"0x8d0e8e1d\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [safeAddress, delegate],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const tokens = await sendEthCallRequest(nodeRpcUrl, ethCallParams, \"latest\");\n this.checkForEmptyResultAndRevert(tokens, \"getTokens\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"address[]\"], tokens);\n return decodedCalldata[0];\n }\n\n /**\n * Get allowance\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param safeAddress - The target account.\n * @param delegate - The target delegate.\n * @param token - The target delegate.\n\t * @returns promise of Allowance\n */\n public async getTokensAllowance(\n nodeRpcUrl: string,\n safeAddress: string,\n delegate: string,\n token: string,\n ):Promise<Allowance>{\n //\"getTokenAllowance(address,address,address)\"\n const functionSelector = \"0x94b31fbd\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"address\"],\n [safeAddress, delegate, token],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const tokenAllowance = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n this.checkForEmptyResultAndRevert(tokenAllowance, \"getTokenAllowance\");\n\t const decodedCalldata = this.abiCoder.decode([\"uint256[5]\"], tokenAllowance);\n const allowance = decodedCalldata[0]\n return {\n amount: BigInt(allowance[0]),\n spent: BigInt(allowance[1]),\n resetTimeMin: BigInt(allowance[2]),\n lastResetMin: BigInt(allowance[3]),\n nonce: BigInt(allowance[4]),\n };\n }\n\n /**\n * Fetches all delegate addresses for a Safe. Automatically paginates through\n * all results unless `maxNumberOfResults` is specified.\n * @param nodeRpcUrl - JSON-RPC endpoint URL for the target chain.\n * @param safeAddress - The Safe account address to query delegates for.\n * @param overrides.start - Starting index for pagination (default 0).\n * @param overrides.maxNumberOfResults - Maximum number of delegates to return.\n * If omitted, all delegates are fetched via automatic pagination.\n * @returns Array of delegate addresses.\n */\n public async getDelegates(\n nodeRpcUrl: string,\n safeAddress: string,\n overrides:{\n start?: bigint,\n maxNumberOfResults?: bigint,\n } = {}\n ):Promise<string[]>{\n let start = overrides.start??0n\n if(overrides.maxNumberOfResults != null){\n return (await this.baseGetDelegates(\n nodeRpcUrl,\n safeAddress,\n start,\n overrides.maxNumberOfResults\n )).results\n }\n const pageSize = 20n;\n const delegates:string[] = [];\n while(true){\n const getDelegatesResult = await this.baseGetDelegates(\n nodeRpcUrl,\n safeAddress,\n start,\n pageSize\n )\n delegates.push.apply(delegates, getDelegatesResult.results)\n if(getDelegatesResult.next == 0n){\n break;\n }else{\n start = getDelegatesResult.next;\n }\n }\n return delegates;\n }\n\n /**\n * Get delegates \n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param safeAddress - The target account.\n * @return promise of the account's current recovery request\n */\n public async baseGetDelegates(\n nodeRpcUrl: string,\n safeAddress: string,\n start: bigint,\n pageSize: bigint,\n ):Promise<{results:string[], next:bigint}>{\n //\"getDelegates(address,uint48,uint8)\"\n const functionSelector = \"0xeb37abe0\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"uint48\", \"uint8\"],\n [safeAddress, start, pageSize],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const delegates = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n this.checkForEmptyResultAndRevert(delegates, \"getDelegates\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"address[]\", \"uint48\"], delegates);\n\n return {\n results: decodedCalldata[0],\n next: BigInt(decodedCalldata[1]),\n }\n }\n}\n\n/**\n * On-chain allowance state for a delegate/token pair on a Safe account.\n */\nexport type Allowance = {\n /** Total allowance amount per period, in the token's smallest unit. */\n amount: bigint,\n /** Amount already spent in the current period. */\n spent: bigint,\n /** Reset period duration in minutes. 0 means one-time (non-recurring). */\n resetTimeMin: bigint,\n /** Timestamp (in minutes since epoch) of the last allowance reset. */\n lastResetMin: bigint,\n /**\n * Monotonically increasing nonce, incremented on each allowance transfer.\n * Capped at 65534 (uint16 max - 1); once exhausted, a new delegate is required.\n */\n nonce: bigint,\n}\n","import { SafeAccount } from \"./SafeAccount\";\nimport {\n\tInitCodeOverrides,\n\tSigner,\n\tCreateUserOperationV7Overrides,\n SafeUserOperationTypedDataDomain,\n SafeUserOperationV7TypedMessageValue,\n SafeAccountSingleton,\n\tSignerSignaturePair,\n} from \"./types\";\n\nimport { UserOperationV7, MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet } from \"../../types\";\nimport { ENTRYPOINT_V7, Safe_L2_V1_4_1 } from \"src/constants\";\n\n/**\n * Safe smart account implementation for EntryPoint v0.7.\n * Provides methods to create, sign, and send ERC-4337 UserOperations\n * using Safe's modular smart account architecture with the v0.7 EntryPoint.\n *\n * @example\n * // Create a new account (not yet deployed on-chain)\n * const smartAccount = SafeAccountV0_3_0.initializeNewAccount([ownerAddress]);\n *\n * // Or connect to an existing deployed account\n * const smartAccount = new SafeAccountV0_3_0(existingAccountAddress);\n */\nexport class SafeAccountV0_3_0 extends SafeAccount {\n\tstatic readonly DEFAULT_ENTRYPOINT_ADDRESS = ENTRYPOINT_V7;\n\tstatic readonly DEFAULT_SAFE_4337_MODULE_ADDRESS =\n\t\t\"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS =\n\t\t\"0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47\";\n\n\t/**\n\t * Create a SafeAccountV0_3_0 instance for an existing deployed account.\n\t * For new (undeployed) accounts, use the static `initializeNewAccount` method instead.\n\t *\n\t * @param accountAddress - The on-chain address of the Safe account\n\t * @param overrides - Override default module, EntryPoint, and singleton addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string\n safeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n \n super(\n accountAddress, safe4337ModuleAddress, entrypointAddress,\n {\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n safeAccountSingleton: overrides.safeAccountSingleton\n }\n );\n\t}\n\n\t/**\n\t * Calculate the counterfactual account address from the initial owner signers.\n\t * Does not deploy the account.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns The deterministic account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n\t\tconst [accountAddress, ,] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\treturn accountAddress;\n\t}\n\n\t/**\n\t * Create and initialize a new SafeAccountV0_3_0 from its initial owners.\n\t * The account address is deterministically computed but not yet deployed on-chain.\n\t * The first UserOperation sent will deploy it automatically via factory data.\n\t *\n\t * @param owners - Array of owner signers (at least one required)\n\t * @param overrides - Override default initialization values\n\t * @returns A SafeAccountV0_3_0 instance with factory data set for deployment\n\t *\n\t * @example\n\t * const smartAccount = SafeAccountV0_3_0.initializeNewAccount([\"0xOwnerAddress\"]);\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeAccountV0_3_0 {\n\t\tlet isInitWebAuthn = false;\n\t\tlet x = 0n;\n\t\tlet y = 0n;\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tif (isInitWebAuthn) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\"Only one Webauthn signer is allowed during initialization\",\n\t\t\t\t\t);\n\t\t\t\t}\n if(owners.indexOf(owner) != 0){\n throw new RangeError(\n\t\t\t\t\t\t\"Webauthn owner has to be the first owner for an init transaction.\",\n\t\t\t\t\t);\n }\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t\tx = owner.x;\n\t\t\t\ty = owner.y;\n\t\t\t}\n\t\t}\n\t\tconst [accountAddress, factoryAddress, factoryData] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst safe = new SafeAccountV0_3_0(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton,\n\t\t});\n\t\tsafe.factoryAddress = factoryAddress;\n\t\tsafe.factoryData = factoryData;\n\t\tif (isInitWebAuthn) {\n\t\t\tsafe.isInitWebAuthn = true;\n\t\t\tsafe.x = x;\n\t\t\tsafe.y = y;\n\t\t}\n\n\t\treturn safe;\n\t}\n\n\t/**\n\t * Compute the EIP-712 hash of a UserOperation for Safe signature verification.\n\t *\n\t * @param useroperation - UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns The EIP-712 hash as a hex string\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Hash(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n \n /**\n\t * Get the EIP-712 typed data components for a UserOperation.\n\t * Useful for signing with external signers that need domain, types, and message separately.\n\t *\n\t * @param useroperation - UserOperation to get typed data for\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns Object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV7TypedMessageValue\n } \n {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Build the Safe initializer calldata for the account setup transaction.\n\t * Encodes the owners, threshold, module setup, and optional WebAuthn configuration.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param threshold - Number of required signatures for transaction approval\n\t * @param overrides - Override default module, multisend, and WebAuthn addresses\n\t * @returns The encoded initializer calldata hex string\n\t */\n\tpublic static createInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;\n\n\t\treturn SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\tthreshold,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress,\n\t\t\toverrides.webAuthnSharedSigner,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner,\n\t\t);\n\t}\n\n\t/**\n\t * Create the factory address and encoded factory data for deploying a new Safe account.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns A tuple of [factoryAddress, factoryData]\n\t */\n\tpublic static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n\t\treturn SafeAccount.createFactoryAddressAndData(\n\t\t\towners,\n\t\t\toverrides,\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t);\n\t}\n\n\t/**\n\t * Create a complete UserOperation ready for signing.\n\t * Automatically determines the nonce, fetches gas prices, estimates gas limits,\n\t * and encodes the transactions into calldata. All values can be overridden.\n\t *\n\t * @param transactions - Array of MetaTransactions to execute\n\t * @param providerRpc - Ethereum JSON-RPC node URL (for nonce and gas prices)\n\t * @param bundlerRpc - Bundler RPC URL (for gas estimation)\n\t * @param overrides - Override any auto-determined values\n\t * @returns The unsigned UserOperation (UserOperationV7) ready to be signed\n\t *\n\t * @example\n\t * const userOp = await smartAccount.createUserOperation(\n\t * [{ to: recipientAddress, value: 1000000000000000n, data: \"0x\" }],\n\t * nodeRpcUrl,\n\t * bundlerRpcUrl,\n\t * );\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV7Overrides = {},\n\t): Promise<UserOperationV7> {\n\t\tconst [userOperation, factoryAddress, factoryData] =\n\t\t\tawait this.createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\t\t\ttransactions,\n\t\t\t\tfalse,\n\t\t\t\tproviderRpc,\n\t\t\t\tbundlerRpc,\n\t\t\t\toverrides,\n\t\t\t);\n\n\t\tconst userOperationV7: UserOperationV7 = {\n\t\t\t...userOperation,\n\t\t\tfactory: factoryAddress,\n\t\t\tfactoryData,\n\t\t\tpaymaster: null,\n\t\t\tpaymasterVerificationGasLimit: null,\n\t\t\tpaymasterPostOpGasLimit: null,\n\t\t\tpaymasterData: null,\n\t\t};\n\n\t\treturn userOperationV7;\n\t}\n\n\t/**\n\t * Estimate gas limits for a UserOperation using the bundler.\n\t *\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC URL\n\t * @param overrides - State overrides, dummy signatures, and WebAuthn configuration\n\t * @returns A tuple of [preVerificationGas, verificationGasLimit, callGasLimit]\n\t */\n\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV7,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n\t\t\texpectedSigners?: Signer[];\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn this.baseEstimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tbundlerRpc,\n\t\t\toverrides\n\t\t);\n\t}\n\n\t/**\n\t * Sign a UserOperation using one or more private keys via EIP-712 typed data signing.\n\t *\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKeys - Array of private keys for the signers\n\t * @param chainId - The target chain ID\n\t * @param overrides - Override validAfter and validUntil timestamps\n\t * @returns The formatted signature string ready to set on the UserOperation\n\t *\n\t * @example\n\t * const signature = smartAccount.signUserOperation(userOp, [privateKey], 1n);\n\t * userOp.signature = signature;\n\t */\n\tpublic signUserOperation(\n\t\tuseroperation: UserOperationV7,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.baseSignSingleUserOperation(\n\t\t\tuseroperation,\n\t\t\tprivateKeys,\n\t\t\tchainId,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.safe4337ModuleAddress,\n\t\t\toverrides\n\t\t)\n\t}\n}\n\n/**\n * Alias for {@link SafeAccountV0_3_0} representing Safe v1.4.1 singleton with module v0.3.0.\n * Uses the same defaults and behavior as SafeAccountV0_3_0.\n */\nexport class SafeAccountV1_4_1_M_0_3_0 extends SafeAccountV0_3_0 {\n}\n","import { SafeAccount } from \"./SafeAccount\";\nimport {\n\tInitCodeOverrides,\n\tSigner,\n\tCreateUserOperationV6Overrides,\n\tSafeAccountSingleton,\n SafeUserOperationTypedDataDomain,\n SafeUserOperationV6TypedMessageValue,\n\tSignerSignaturePair,\n} from \"./types\";\n\nimport { UserOperationV6, MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet } from \"../../types\";\nimport { ENTRYPOINT_V6 } from \"src/constants\";\nimport { createCallData } from \"src/utils\";\nimport { SafeAccountV0_3_0 } from \"./SafeAccountV0_3_0\";\n\n/**\n * Safe smart account implementation for EntryPoint v0.6.\n * Provides methods to create, sign, and send ERC-4337 UserOperations\n * using Safe's modular smart account architecture.\n *\n * @example\n * // Create a new account (not yet deployed on-chain)\n * const smartAccount = SafeAccountV0_2_0.initializeNewAccount([ownerAddress]);\n *\n * // Or connect to an existing deployed account\n * const smartAccount = new SafeAccountV0_2_0(existingAccountAddress);\n */\nexport class SafeAccountV0_2_0 extends SafeAccount {\n\tstatic readonly DEFAULT_ENTRYPOINT_ADDRESS = ENTRYPOINT_V6;\n\tstatic readonly DEFAULT_SAFE_4337_MODULE_ADDRESS =\n\t\t\"0xa581c4A4DB7175302464fF3C06380BC3270b4037\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS =\n\t\t\"0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb\";\n\n\t/**\n\t * Create a SafeAccountV0_2_0 instance for an existing deployed account.\n\t * For new (undeployed) accounts, use the static `initializeNewAccount` method instead.\n\t *\n\t * @param accountAddress - The on-chain address of the Safe account\n\t * @param overrides - Override default module and EntryPoint addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\n\t\tsuper(\n accountAddress, safe4337ModuleAddress, entrypointAddress,\n {\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier\n }\n );\n\t}\n\n\t/**\n\t * Calculate the counterfactual account address from the initial owner signers.\n\t * Does not deploy the account.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns The deterministic account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: {\n\t\t\tthreshold?: number;\n\t\t\tc2Nonce?: bigint;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tsafeAccountSingleton?: SafeAccountSingleton;\n\t\t\tsafeAccountFactoryAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst [accountAddress, ,] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\treturn accountAddress;\n\t}\n\n\t/**\n\t * Create and initialize a new SafeAccountV0_2_0 from its initial owners.\n\t * The account address is deterministically computed but not yet deployed on-chain.\n\t * The first UserOperation sent will deploy it automatically via initCode.\n\t *\n\t * @param owners - Array of owner signers (at least one required)\n\t * @param overrides - Override default initialization values\n\t * @returns A SafeAccountV0_2_0 instance with factory data set for deployment\n\t *\n\t * @example\n\t * const smartAccount = SafeAccountV0_2_0.initializeNewAccount([\"0xOwnerAddress\"]);\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeAccountV0_2_0 {\n\t\tlet isInitWebAuthn = false;\n\t\tlet x = 0n;\n\t\tlet y = 0n;\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tif (isInitWebAuthn) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\"Only one Webauthn signer is allowed during initialization\",\n\t\t\t\t\t);\n\t\t\t\t}\n if(owners.indexOf(owner) != 0){\n throw new RangeError(\n\t\t\t\t\t\t\"Webauthn owner has to be the first owner for an init transaction.\",\n\t\t\t\t\t);\n }\n\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t\tx = owner.x;\n\t\t\t\ty = owner.y;\n\t\t\t}\n\t\t}\n\t\tconst [accountAddress, factoryAddress, factoryData] =\n\t\t\tSafeAccountV0_2_0.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst safe = new SafeAccountV0_2_0(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier\n\t\t});\n\t\tsafe.factoryAddress = factoryAddress;\n\t\tsafe.factoryData = factoryData;\n\t\tif (isInitWebAuthn) {\n\t\t\tsafe.isInitWebAuthn = true;\n\t\t\tsafe.x = x;\n\t\t\tsafe.y = y;\n\t\t}\n\n\t\treturn safe;\n\t}\n\n\t/**\n\t * Compute the EIP-712 hash of a UserOperation for Safe signature verification.\n\t *\n\t * @param useroperation - UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns The EIP-712 hash as a hex string\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Hash(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n /**\n\t * Get the EIP-712 typed data components for a UserOperation.\n\t * Useful for signing with external signers that need domain, types, and message separately.\n\t *\n\t * @param useroperation - UserOperation to get typed data for\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns Object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } \n {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Calculate both the counterfactual account address and the initCode from owner signers.\n\t *\n\t * @param owners - Array of owner signers\n\t * @param overrides - Override default initialization values\n\t * @returns A tuple of [accountAddress, initCode]\n\t */\n\tpublic static createAccountAddressAndInitCode(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n\t\tconst [sender, safeAccountFactoryAddress, factoryData] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst initCode = safeAccountFactoryAddress + factoryData.slice(2);\n\t\treturn [sender, initCode];\n\t}\n\n\tpublic static createInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;\n\n\t\treturn SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\tthreshold,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress,\n\t\t\toverrides.webAuthnSharedSigner,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner,\n\t\t);\n\t}\n\n\t/**\n\t * Create the initCode for deploying a new Safe account via the factory.\n\t *\n\t * @param owners - Array of owner signers\n\t * @param overrides - Override default initialization values\n\t * @returns The initCode string (factory address + encoded calldata)\n\t */\n\tpublic static createInitCode(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n\t\tconst [safeAccountFactoryAddress, factoryData] =\n\t\t\tSafeAccount.createFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\t\treturn safeAccountFactoryAddress + factoryData.slice(2);\n\t}\n\n\t/**\n\t * Create a complete UserOperation ready for signing.\n\t * Automatically determines the nonce, fetches gas prices, estimates gas limits,\n\t * and encodes the transactions into calldata. All values can be overridden.\n\t *\n\t * @param transactions - Array of MetaTransactions to execute\n\t * @param providerRpc - Ethereum JSON-RPC node URL (for nonce and gas prices)\n\t * @param bundlerRpc - Bundler RPC URL (for gas estimation)\n\t * @param overrides - Override any auto-determined values\n\t * @returns The unsigned UserOperation (UserOperationV6) ready to be signed\n\t *\n\t * @example\n\t * const userOp = await smartAccount.createUserOperation(\n\t * [{ to: recipientAddress, value: 1000000000000000n, data: \"0x\" }],\n\t * nodeRpcUrl,\n\t * bundlerRpcUrl,\n\t * );\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV6Overrides = {},\n\t): Promise<UserOperationV6> {\n\t\tconst [userOperation, factoryAddress, factoryData] =\n\t\t\tawait this.createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\t\t\ttransactions,\n\t\t\t\ttrue,\n\t\t\t\tproviderRpc,\n\t\t\t\tbundlerRpc,\n\t\t\t\toverrides,\n\t\t\t);\n\n\t\tlet initCode = \"0x\";\n\n\t\tif (overrides.initCode == null) {\n\t\t\tif (factoryAddress != null) {\n\t\t\t\tlet factoryDataStr = \"0x\";\n\t\t\t\tif (factoryData != null) {\n\t\t\t\t\tfactoryDataStr = factoryData;\n\t\t\t\t}\n\t\t\t\tinitCode = factoryAddress + factoryDataStr.slice(2);\n\t\t\t}\n\t\t} else {\n\t\t\tinitCode = overrides.initCode;\n\t\t}\n\n\t\tconst userOperationV6: UserOperationV6 = {\n\t\t\t...userOperation,\n\t\t\tinitCode,\n\t\t\tpaymasterAndData: \"0x\",\n\t\t};\n\n\t\treturn userOperationV6;\n\t}\n \n /**\n\t * Create MetaTransactions to migrate this account from EntryPoint v0.6 (module v0.2.0)\n\t * to EntryPoint v0.7 (module v0.3.0).\n\t *\n\t * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n\t * @param overrides - Override module addresses and pagination\n\t * @returns Array of MetaTransactions for the migration\n\t */\n public async createMigrateToSafeAccountV0_3_0MetaTransactions(\n\t\tnodeRpcUrl: string,\n overrides:{\n\t\t\tsafeV06ModuleAddress?: string;\n\t\t\tsafeV07ModuleAddress?: string;\n pageSize?: bigint;\n\t\t\tmodulesStart?: string;\n } = {}\n ):Promise<MetaTransaction[]> {\n\t\tconst moduleV06Address =\n\t\t\toverrides.safeV06ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\tconst moduleV07Address =\n\t\t\toverrides.safeV07ModuleAddress ??\n SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n \n const disableModuleMetaTransaction = \n await this.createDisableModuleMetaTransaction(\n nodeRpcUrl, moduleV06Address, this.accountAddress,\n {\n prevModuleAddress:overrides.safeV06ModuleAddress,\n modulesPageSize: overrides.pageSize,\n modulesStart: overrides.modulesStart\n }\n );\n \n const enableModuleMetaTransaction = \n SafeAccount.createEnableModuleMetaTransaction(\n moduleV07Address, this.accountAddress);\n\n const setFallbackHandlerCallData = createCallData(\n\t\t\t\"0xf08a0323\", //setFallbackHandler(address)\n\t\t\t[\"address\"],\n\t\t\t[moduleV07Address],\n\t\t);\n\t\tconst setFallbackHandlerMetaTransaction: MetaTransaction = {\n\t\t\tto: this.accountAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: setFallbackHandlerCallData,\n\t\t};\n \n return [\n disableModuleMetaTransaction,\n enableModuleMetaTransaction,\n setFallbackHandlerMetaTransaction\n ];\n }\n\n\t/**\n\t * Estimate gas limits for a UserOperation using the bundler.\n\t *\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC URL\n\t * @param overrides - State overrides, dummy signatures, and WebAuthn configuration\n\t * @returns A tuple of [preVerificationGas, verificationGasLimit, callGasLimit]\n\t */\n\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV6,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n expectedSigners?: Signer[];\n webAuthnSharedSigner?: string;\n webAuthnSignerFactory?: string;\n webAuthnSignerSingleton?: string;\n webAuthnSignerProxyCreationCode?: string;\n eip7212WebAuthnPrecompileVerifier?: string;\n eip7212WebAuthnContractVerifier?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn this.baseEstimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tbundlerRpc,\n\t\t\toverrides\n\t\t);\n\t}\n\n\t/**\n\t * Sign a UserOperation using one or more private keys via EIP-712 typed data signing.\n\t *\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKeys - Array of private keys for the signers\n\t * @param chainId - The target chain ID\n\t * @param overrides - Override validAfter and validUntil timestamps\n\t * @returns The formatted signature string ready to set on the UserOperation\n\t *\n\t * @example\n\t * const signature = smartAccount.signUserOperation(userOp, [privateKey], 1n);\n\t * userOp.signature = signature;\n\t */\n\tpublic signUserOperation(\n\t\tuseroperation: UserOperationV6,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.baseSignSingleUserOperation(\n\t\t\tuseroperation,\n\t\t\tprivateKeys,\n\t\t\tchainId,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.safe4337ModuleAddress,\n\t\t\toverrides\n\t\t)\n\t}\n}\n","import { OnChainIdentifierParamsType, MetaTransaction, UserOperationV7 } from \"src/types\";\nimport { SafeAccount } from \"./SafeAccount\";\nimport { SafeAccountV0_3_0 } from \"./SafeAccountV0_3_0\";\nimport {\n\tSigner,\n\tInitCodeOverrides,\n\tSafeAccountSingleton,\n\tCreateUserOperationV7Overrides,\n\tSignerSignaturePair,\n\tWebAuthnSignatureOverrides,\n\tWebauthnPublicKey,\n} from \"./types\";\nimport { Safe_L2_V1_5_0 } from \"src/constants\";\nimport { StateOverrideSet } from \"src/types\";\n\n/**\n * Safe v1.5.0 smart account implementation with module v0.3.0 for EntryPoint v0.7.\n * Extends {@link SafeAccountV0_3_0} using the Safe L2 v1.5.0 singleton instead of v1.4.1.\n *\n * @example\n * // Create a new account using Safe v1.5.0 singleton\n * const smartAccount = SafeAccountV1_5_0_M_0_3_0.initializeNewAccount([ownerAddress]);\n *\n * // Or connect to an existing deployed account\n * const smartAccount = new SafeAccountV1_5_0_M_0_3_0(existingAccountAddress);\n */\nexport class SafeAccountV1_5_0_M_0_3_0 extends SafeAccountV0_3_0 {\n\tstatic readonly DEFAULT_WEB_AUTHN_PRECOMPILE: string =\n\t\t\"0x0000000000000000000000000000000000000100\"; // EIP-7951\n\tstatic readonly DEFAULT_WEB_AUTHN_DAIMO_VERIFIER: string =\n\t\t\"0xc2b78104907F722DABAc4C69f826a522B2754De4\";\n\n\t/**\n\t * Create a SafeAccountV1_5_0_M_0_3_0 instance for an existing deployed account.\n\t * For new (undeployed) accounts, use the static `initializeNewAccount` method instead.\n\t *\n\t * @param accountAddress - The on-chain address of the Safe account\n\t * @param overrides - Override default module and EntryPoint addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string;\n\t\t\tsafeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n super(\n accountAddress,\n {\n safe4337ModuleAddress: overrides.safe4337ModuleAddress,\n entrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0\n }\n );\n\t}\n\n\t/**\n\t * Calculate the deterministic proxy address from the initializer calldata.\n\t * Uses the Safe v1.5.0 singleton init hash by default.\n\t *\n\t * @param initializerCallData - The encoded initializer calldata for the proxy\n\t * @param overrides - Override default nonce, factory address, and singleton init hash\n\t * @returns The deterministic proxy address\n\t */\n\tpublic static createProxyAddress(\n\t\tinitializerCallData: string,\n\t\toverrides: {\n\t\t\tc2Nonce?: bigint;\n\t\t\tsafeFactoryAddress?: string;\n\t\t\tsingletonInitHash?: string;\n\t\t} = {},\n\t): string {\n const modOverrides = { ...overrides,\n singletonInitHash: overrides.singletonInitHash??Safe_L2_V1_5_0.singletonInitHash,\n };\n return SafeAccountV0_3_0.createProxyAddress(\n initializerCallData,\n modOverrides\n );\n }\n\n\t/**\n\t * Create and initialize a new SafeAccountV1_5_0_M_0_3_0 from its initial owners.\n\t * The account address is deterministically computed but not yet deployed on-chain.\n\t * The first UserOperation sent will deploy it automatically via factory data.\n\t *\n\t * @param owners - Array of owner signers (at least one required)\n\t * @param overrides - Override default initialization values\n\t * @returns A SafeAccountV1_5_0_M_0_3_0 instance with factory data set for deployment\n\t *\n\t * @example\n\t * const smartAccount = SafeAccountV1_5_0_M_0_3_0.initializeNewAccount([\"0xOwnerAddress\"]);\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeAccountV1_5_0_M_0_3_0 {\n const modOverrides = { ...overrides,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n return SafeAccountV0_3_0.initializeNewAccount(\n owners,\n modOverrides\n );\n }\n\n\t/**\n\t * Calculate the counterfactual account address from the initial owner signers.\n\t * Does not deploy the account. Uses the Safe v1.5.0 singleton by default.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns The deterministic account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n const modOverrides = { ...overrides,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n return SafeAccountV0_3_0.createAccountAddress(\n owners,\n modOverrides\n );\n }\n\n\t/**\n\t * Create the factory address and encoded factory data for deploying a new Safe account.\n\t * Uses the Safe v1.5.0 singleton by default.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns A tuple of [factoryAddress, factoryData]\n\t */\n\tpublic static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n const modOverrides = { ...overrides,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n return SafeAccountV0_3_0.createFactoryAddressAndData(\n owners,\n modOverrides\n );\n }\n\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV7Overrides = {},\n\t): Promise<UserOperationV7> {\n\t\treturn super.createUserOperation(transactions, providerRpc, bundlerRpc, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV7,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n\t\t\texpectedSigners?: Signer[];\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn super.estimateUserOperationGas(userOperation, bundlerRpc, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static createWebAuthnSignerVerifierAddress(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.createWebAuthnSignerVerifierAddress(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static createDeployWebAuthnVerifierMetaTransaction(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t} = {},\n\t): MetaTransaction {\n\t\treturn SafeAccount.createDeployWebAuthnVerifierMetaTransaction(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static createDummySignerSignaturePairForExpectedSigners(\n\t\texpectedSigners: Signer[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): SignerSignaturePair[] {\n\t\treturn SafeAccount.createDummySignerSignaturePairForExpectedSigners(expectedSigners, {\n\t\t\t...webAuthnSignatureOverrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: webAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: webAuthnSignatureOverrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string,\n\t\tsigner: WebauthnPublicKey,\n\t\tmessageHash: string,\n\t\tsignature: string,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t} = {},\n\t): Promise<boolean> {\n\t\treturn SafeAccount.verifyWebAuthnSignatureForMessageHash(nodeRpcUrl, signer, messageHash, signature, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n}\n","/**\n * Abstract base class for all paymaster implementations.\n * Subclasses provide specific logic for gas sponsorship or ERC-20 token gas payment.\n */\nexport abstract class Paymaster {}\n","import { Paymaster } from \"./Paymaster\";\nimport { calculateUserOperationMaxGasCost, sendJsonRpcRequest } from \"../utils\";\nimport {\n\tSupportedERC20TokensAndMetadata,\n\tSupportedERC20TokensAndMetadataWithExchangeRate,\n\tPmUserOperationV8Result,\n\tPmUserOperationV7Result,\n\tPmUserOperationV6Result,\n\tPaymasterMetadata,\n\tERC20Token,\n\tERC20TokenWithExchangeRate,\n\tSponsorMetadata,\n} from \"../types\";\nimport {\n\tCandidePaymasterContext,\n\tPrependTokenPaymasterApproveAccount,\n\tGasPaymasterUserOperationOverrides,\n\tAnyUserOperation,\n\tSameUserOp, SmartAccountWithEntrypoint,\n} from \"./types\";\nimport { Bundler } from \"src/Bundler\";\nimport { AbstractionKitError, ensureError } from \"src/errors\";\nimport {ENTRYPOINT_V8, ENTRYPOINT_V7, ENTRYPOINT_V6, ENTRYPOINT_V9} from \"src/constants\";\n\n/** Buffer added to verificationGasLimit for paymasterAndData verification overhead */\nconst PAYMASTER_V06_VERIFICATION_OVERHEAD = 40000n;\n/** Max value for uint256 */\nconst UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;\n/** Multiplier for token approve amount to cover paymasterAndData cost variance */\nconst TOKEN_APPROVE_AMOUNT_MULTIPLIER = 2n;\n\n/**\n * ERC-20 tokens that require resetting their allowance to 0 before setting a\n * new approval amount (e.g. USDT on mainnet).\n * Addresses are stored lowercase for case-insensitive comparison.\n *\n * If you encounter a token with this behavior that is not listed here,\n * please open an issue at https://github.com/candidelabs/abstractionkit/issues\n * or use the `resetApproval` override as a workaround.\n */\nconst TOKENS_REQUIRING_ALLOWANCE_RESET: string[] = [\n\t\"0xdac17f958d2ee523a2206206994597c13d831ec7\", // USDT (Ethereum mainnet)\n];\n\n/**\n * Client for the Candide Paymaster service.\n * Supports both gas sponsorship (sponsor paymaster) and ERC-20 token payment for gas (token paymaster).\n * Auto-initializes on first use by fetching supported tokens and metadata from the paymaster RPC.\n *\n * Candide's paymaster endpoint follows the format:\n * - `https://api.candide.dev/api/v3/{chainId}/{apiKey}` (authenticated)\n * - `https://api.candide.dev/public/v3/{chainId}` (public, no key required)\n *\n * @example\n * const paymaster = new CandidePaymaster(\"https://api.candide.dev/public/v3/11155111\");\n * const [sponsoredOp] = await paymaster.createSponsorPaymasterUserOperation(userOp, bundlerRpcUrl);\n */\nexport class CandidePaymaster extends Paymaster {\n\t/** The paymaster JSON-RPC endpoint URL */\n\treadonly rpcUrl: string;\n\t/** Cached token/metadata per EntryPoint address (lowercase keys) */\n\tprivate entrypointData = new Map<\n\t\tstring,\n\t\tSupportedERC20TokensAndMetadata\n\t>();\n\t/** Per-entrypoint initialization promises (lowercase keys) */\n\tprivate initPromises = new Map<string, Promise<void>>();\n\t/** Cached chain ID (hex string), resolved from URL or pm_chainId RPC */\n\tprivate chainId: string | null = null;\n\tprivate chainIdPromise: Promise<string> | null = null;\n\n\t/** @param rpcUrl - The Candide paymaster JSON-RPC endpoint URL */\n\tconstructor(rpcUrl: string) {\n\t\tsuper();\n\t\tthis.rpcUrl = rpcUrl;\n\t\tthis.chainId = CandidePaymaster.extractChainIdFromUrl(rpcUrl);\n\t}\n\n\t/**\n\t * Extract chain ID from a Candide paymaster URL.\n\t * Matches: https://api.candide.dev/(api|public)/v{N}/{chainId}(/{apiKey})?\n\t */\n\tprivate static extractChainIdFromUrl(url: string): string | null {\n\t\tconst match = url.match(\n\t\t\t/api\\.candide\\.dev\\/(?:api|public)\\/v\\d+\\/(\\d+)(?:\\/|$)/,\n\t\t);\n\t\tif (match) {\n\t\t\treturn \"0x\" + BigInt(match[1]).toString(16);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Get the chain ID, resolving it from the URL or via pm_chainId RPC.\n\t * Deduplicates concurrent calls.\n\t */\n\tprivate async getChainId(): Promise<string> {\n\t\tif (this.chainId != null) {\n\t\t\treturn this.chainId;\n\t\t}\n\t\tif (this.chainIdPromise == null) {\n\t\t\tthis.chainIdPromise = this.fetchChainId().then((id) => {\n\t\t\t\tthis.chainId = id;\n\t\t\t\treturn id;\n\t\t\t}).catch((err) => {\n\t\t\t\tthis.chainIdPromise = null;\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t}\n\t\treturn this.chainIdPromise;\n\t}\n\n\tprivate async fetchChainId(): Promise<string> {\n\t\ttry {\n\t\t\tconst result = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_chainId\",\n\t\t\t\t[],\n\t\t\t);\n\t\t\treturn result as string;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_chainId failed\",\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Determine the EntryPoint address from the UserOperation's shape.\n\t * V6 ops have `initCode`, V8 ops have `eip7702Auth`, V7 is the default.\n\t */\n\tprivate resolveEntrypoint(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: AnyUserOperation,\n\t): string {\n\t\tif (smartAccount.entrypointAddress != null && smartAccount.entrypointAddress.trim() !== \"\") {\n\t\t\treturn smartAccount.entrypointAddress;\n\t\t}\n\t\tif (\"initCode\" in userOperation) return ENTRYPOINT_V6;\n\t\telse if (\"eip7702Auth\" in userOperation) return ENTRYPOINT_V8;\n\t\telse return ENTRYPOINT_V7;\n\t}\n\n\t/**\n\t * Get the cached entrypoint data for a given entrypoint address.\n\t */\n\tprivate getEntrypointData(\n\t\tentrypoint: string,\n\t): SupportedERC20TokensAndMetadata | undefined {\n\t\treturn this.entrypointData.get(entrypoint.toLowerCase());\n\t}\n\n\tprivate static mapTokens(\n\t\ttokens: { name: string; symbol: string; address: string; decimals: number | string }[],\n\t): ERC20Token[] {\n\t\treturn tokens.map((t) => ({\n\t\t\tname: t.name,\n\t\t\tsymbol: t.symbol,\n\t\t\taddress: t.address,\n\t\t\tdecimals: Number(t.decimals),\n\t\t}));\n\t}\n\n\tprivate static mapTokensWithExchangeRate(\n\t\ttokens: { name: string; symbol: string; address: string; decimals: number | string; exchangeRate: string | bigint }[],\n\t): ERC20TokenWithExchangeRate[] {\n\t\treturn tokens.map((t) => ({\n\t\t\tname: t.name,\n\t\t\tsymbol: t.symbol,\n\t\t\taddress: t.address,\n\t\t\tdecimals: Number(t.decimals),\n\t\t\texchangeRate: BigInt(t.exchangeRate),\n\t\t}));\n\t}\n\n\t/**\n\t * Convert dummyPaymasterAndData gas fields from hex strings to bigint.\n\t * RPC returns these as hex strings, but our types expect bigint.\n\t */\n\tprivate static normalizePaymasterMetadata(\n\t\tmetadata: PaymasterMetadata,\n\t): PaymasterMetadata {\n\t\tif (typeof metadata.dummyPaymasterAndData !== \"string\") {\n\t\t\treturn {\n\t\t\t\t...metadata,\n\t\t\t\tdummyPaymasterAndData: {\n\t\t\t\t\t...metadata.dummyPaymasterAndData,\n\t\t\t\t\tpaymasterVerificationGasLimit: BigInt(metadata.dummyPaymasterAndData.paymasterVerificationGasLimit),\n\t\t\t\t\tpaymasterPostOpGasLimit: BigInt(metadata.dummyPaymasterAndData.paymasterPostOpGasLimit),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn metadata;\n\t}\n\n\t/**\n\t * Ensure the paymaster data for a specific entrypoint is initialized.\n\t * Deduplicates concurrent calls for the same entrypoint.\n\t * On failure, resets so the next call retries.\n\t */\n\tprivate ensureInitialized(entrypoint: string): Promise<void> {\n\t\tconst key = entrypoint.toLowerCase();\n\t\tlet promise = this.initPromises.get(key);\n\t\tif (promise == null) {\n\t\t\tpromise = this.doInitialize(entrypoint).catch((err) => {\n\t\t\t\tthis.initPromises.delete(key);\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t\tthis.initPromises.set(key, promise);\n\t\t}\n\t\treturn promise;\n\t}\n\n\t/**\n\t * Fetch and cache the paymaster's supported tokens and metadata for a specific entrypoint.\n\t *\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if initialization fails\n\t */\n\tprivate async doInitialize(entrypoint: string): Promise<void> {\n\t\ttry {\n\t\t\tconst data = await this.fetchAndTransformTokenData(entrypoint);\n\t\t\tif (data == null) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t`Invalid data received during initialization for entrypoint ${entrypoint}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.entrypointData.set(entrypoint.toLowerCase(), data);\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"failed initializing the paymaster\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch supported tokens and metadata for a specific entrypoint from the RPC\n\t * and transform the result into a normalized format. Used during initialization.\n\t */\n\tprivate async fetchAndTransformTokenData(\n\t\tentrypoint: string,\n\t): Promise<SupportedERC20TokensAndMetadata | null> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await this.fetchSupportedTokensRpc(entrypoint);\n\n\t\t\tconst result = jsonRpcResult as SupportedERC20TokensAndMetadata;\n\t\t\treturn {\n\t\t\t\ttokens: CandidePaymaster.mapTokens(result.tokens),\n\t\t\t\tpaymasterMetadata: CandidePaymaster.normalizePaymasterMetadata(result.paymasterMetadata),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"fetchAndTransformTokenData failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async fetchSupportedTokensRpc(\n\t\tentrypoint: string,\n\t): Promise<unknown> {\n\t\treturn await sendJsonRpcRequest(\n\t\t\tthis.rpcUrl,\n\t\t\t\"pm_supportedERC20Tokens\",\n\t\t\t[entrypoint],\n\t\t);\n\t}\n\n\t/**\n\t * Get the EntryPoint addresses supported by this paymaster.\n\t *\n\t * @returns Array of supported EntryPoint contract addresses\n\t */\n\tasync getSupportedEntrypoints(): Promise<string[]> {\n\t\ttry {\n\t\t\tconst result = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_supportedEntryPoints\",\n\t\t\t\t[],\n\t\t\t);\n\t\t\treturn result as string[];\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_supportedEntryPoints failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the paymaster contract metadata for a specific EntryPoint.\n\t * Auto-initializes if not yet initialized.\n\t *\n\t * @param entrypoint - Target EntryPoint address\n\t * @returns The paymaster metadata (name, address, icons, dummyPaymasterAndData, etc.)\n\t * @throws RangeError if the entrypoint is not supported\n\t */\n\tasync getPaymasterMetaData(\n\t\tentrypoint: string,\n\t): Promise<PaymasterMetadata | null> {\n\t\tawait this.ensureInitialized(entrypoint);\n\n\t\tconst data = this.getEntrypointData(entrypoint);\n\t\tif (data == null) {\n\t\t\tthrow new RangeError(\"unsupported entrypoint.\");\n\t\t}\n\t\treturn data.paymasterMetadata;\n\t}\n\n\t/**\n\t * Check if the token paymaster supports a given ERC-20 token for gas payment.\n\t *\n\t * @param erc20TokenAddress - The ERC-20 token contract address to check\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns true if the token is supported, false otherwise\n\t */\n\tasync isSupportedERC20Token(\n\t\terc20TokenAddress: string,\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<boolean> {\n\t\tconst gasToken = await this.getSupportedERC20TokenData(\n\t\t\terc20TokenAddress,\n\t\t\tentrypoint,\n\t\t);\n\t\treturn gasToken != null;\n\t}\n\n\t/**\n\t * Get the paymaster's data for a specific ERC-20 token.\n\t *\n\t * @param erc20TokenAddress - The ERC-20 token contract address\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns The token data (name, symbol, address, decimals), or null if not supported\n\t * @throws RangeError if the entrypoint is not supported\n\t */\n\tasync getSupportedERC20TokenData(\n\t\terc20TokenAddress: string,\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<ERC20Token | null> {\n\t\tawait this.ensureInitialized(entrypoint);\n\n\t\tconst data = this.getEntrypointData(entrypoint);\n\t\tif (data == null) {\n\t\t\tthrow new RangeError(\"unsupported entrypoint.\");\n\t\t}\n\n\t\tconst gasToken = data.tokens.find(\n\t\t\t(token) =>\n\t\t\t\ttoken.address.toLowerCase() === erc20TokenAddress.toLowerCase(),\n\t\t);\n\n\t\tif (!gasToken) {\n\t\t\treturn null;\n\t\t}\n\t\treturn {\n\t\t\tname: gasToken.name,\n\t\t\tsymbol: gasToken.symbol,\n\t\t\taddress: gasToken.address,\n\t\t\tdecimals: Number(gasToken.decimals),\n\t\t};\n\t}\n\n\t// ── Private helpers for createPaymasterUserOperation ─────────────\n\n\tprivate setDummyPaymasterFields(\n\t\tuserOp: AnyUserOperation,\n\t\tepData: SupportedERC20TokensAndMetadata,\n\t): void {\n\t\tconst dummyPaymasterAndData = epData.paymasterMetadata.dummyPaymasterAndData;\n\t\tif (\"initCode\" in userOp) {\n\t\t\tuserOp.paymasterAndData = dummyPaymasterAndData as string;\n\t\t} else {\n\t\t\tconst structured = dummyPaymasterAndData as Exclude<\n\t\t\t\ttypeof dummyPaymasterAndData, string\n\t\t\t>;\n\t\t\tuserOp.paymaster = structured.paymaster;\n\t\t\tuserOp.paymasterVerificationGasLimit =\n\t\t\t\tstructured.paymasterVerificationGasLimit;\n\t\t\tuserOp.paymasterPostOpGasLimit =\n\t\t\t\tstructured.paymasterPostOpGasLimit;\n\t\t\tuserOp.paymasterData = structured.paymasterData;\n\t\t}\n\t}\n\n\tprivate async estimateAndApplyGasLimits(\n\t\tuserOp: AnyUserOperation,\n\t\tbundlerRpc: string,\n\t\tentrypoint: string,\n\t\toverrides: GasPaymasterUserOperationOverrides,\n\t): Promise<void> {\n\t\tlet preVerificationGas = userOp.preVerificationGas;\n\t\tlet verificationGasLimit = userOp.verificationGasLimit;\n\t\tlet callGasLimit = userOp.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n\t\t\tif (bundlerRpc == null) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc can't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overridden\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst bundler = new Bundler(bundlerRpc);\n\n\t\t\tuserOp.callGasLimit = 0n;\n\t\t\tuserOp.verificationGasLimit = 0n;\n\t\t\tuserOp.preVerificationGas = 0n;\n\t\t\tconst inputMaxFeePerGas = userOp.maxFeePerGas;\n\t\t\tconst inputMaxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\n\t\t\tuserOp.maxFeePerGas = 0n;\n\t\t\tuserOp.maxPriorityFeePerGas = 0n;\n\n\t\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\t\tuserOp,\n\t\t\t\tentrypoint,\n\t\t\t\toverrides.state_override_set,\n\t\t\t);\n\n\t\t\tif (preVerificationGas < estimation.preVerificationGas) {\n\t\t\t\tpreVerificationGas = estimation.preVerificationGas;\n\t\t\t}\n\t\t\tif (verificationGasLimit < estimation.verificationGasLimit) {\n\t\t\t\tverificationGasLimit = estimation.verificationGasLimit;\n\t\t\t}\n\t\t\tif (callGasLimit < estimation.callGasLimit) {\n\t\t\t\tcallGasLimit = estimation.callGasLimit;\n\t\t\t}\n\n\t\t\tuserOp.maxFeePerGas = inputMaxFeePerGas;\n\t\t\tuserOp.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t}\n\n\t\tif (typeof overrides.preVerificationGas === \"bigint\" && overrides.preVerificationGas < 0n) {\n\t\t\tthrow new RangeError(\"preVerificationGas override can't be negative\");\n\t\t}\n\t\tif (typeof overrides.verificationGasLimit === \"bigint\" && overrides.verificationGasLimit < 0n) {\n\t\t\tthrow new RangeError(\"verificationGasLimit override can't be negative\");\n\t\t}\n\t\tif (typeof overrides.callGasLimit === \"bigint\" && overrides.callGasLimit < 0n) {\n\t\t\tthrow new RangeError(\"callGasLimit override can't be negative\");\n\t\t}\n\n\t\tconst applyMultiplier = (value: bigint, multiplier?: number): bigint =>\n\t\t\tvalue + (value * BigInt(Math.round((multiplier ?? 0) * 100))) / 10000n;\n\n\t\tuserOp.preVerificationGas = overrides.preVerificationGas\n\t\t\t?? applyMultiplier(preVerificationGas, overrides.preVerificationGasPercentageMultiplier ?? 5);\n\t\tuserOp.verificationGasLimit = overrides.verificationGasLimit\n\t\t\t?? applyMultiplier(verificationGasLimit, overrides.verificationGasLimitPercentageMultiplier ?? 10);\n\t\tuserOp.callGasLimit = overrides.callGasLimit\n\t\t\t?? applyMultiplier(callGasLimit, overrides.callGasLimitPercentageMultiplier ?? 10);\n\n\t\tif (entrypoint == ENTRYPOINT_V6){\n\t\t\tuserOp.verificationGasLimit += PAYMASTER_V06_VERIFICATION_OVERHEAD;\n\t\t}\n\t}\n\n\tprivate applyPaymasterResult(\n\t\tuserOp: AnyUserOperation,\n\t\tjsonRpcResult: unknown,\n\t): SponsorMetadata | undefined {\n\t\tconst result = jsonRpcResult as\n\t\t\t| PmUserOperationV8Result\n\t\t\t| PmUserOperationV7Result\n\t\t\t| PmUserOperationV6Result;\n\n\t\t// Set version-specific paymaster fields (gas limits/prices are not overridden)\n\t\tif (\"initCode\" in userOp) {\n\t\t\tconst v6Result = jsonRpcResult as PmUserOperationV6Result;\n\t\t\tuserOp.paymasterAndData = v6Result.paymasterAndData;\n\t\t} else {\n\t\t\tconst v7Result = jsonRpcResult as PmUserOperationV7Result;\n\t\t\tuserOp.paymaster = v7Result.paymaster;\n\t\t\tuserOp.paymasterVerificationGasLimit = BigInt(v7Result.paymasterVerificationGasLimit);\n\t\t\tuserOp.paymasterPostOpGasLimit = BigInt(v7Result.paymasterPostOpGasLimit);\n\t\t\tuserOp.paymasterData = v7Result.paymasterData;\n\t\t}\n\n\t\treturn result.sponsorMetadata ?? undefined;\n\t}\n\n\t// ── Core paymaster method (private) ──────────────────────────────\n\n\tprivate async createPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: T,\n\t\tcontext: CandidePaymasterContext = {},\n\t\toverrides: GasPaymasterUserOperationOverrides = {},\n\t): Promise<[SameUserOp<T>, SponsorMetadata | undefined]> {\n\t\ttry {\n\t\t\tconst entrypoint = overrides.entrypoint ?? this.resolveEntrypoint(smartAccount, userOperation);\n\t\t\tconst chainId = await this.getChainId();\n\t\t\tconst jsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_getPaymasterData\",\n\t\t\t\t[userOperation, entrypoint, chainId, context],\n\t\t\t);\n\t\t\tconst sponsorMetadata = this.applyPaymasterResult(userOperation, jsonRpcResult);\n\t\t\treturn [userOperation as unknown as SameUserOp<T>, sponsorMetadata];\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_getPaymasterData failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t// ── Public convenience methods ───────────────────────────────────\n\n\t/**\n\t * Create a gas-sponsored UserOperation (no token payment required).\n\t *\n\t * @param smartAccount - The smart account instance\n\t * @param userOperation - The UserOperation to sponsor\n\t * @param bundlerRpc - Bundler RPC URL for gas estimation\n\t * @param sponsorshipPolicyId - Optional sponsorship policy ID\n\t * @param overrides - Override gas limits, multipliers, and optional context\n\t * @returns A tuple of [UserOperation, SponsorMetadata | undefined]\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if sponsorship fails\n\t */\n\tasync createSponsorPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: T,\n\t\tbundlerRpc: string,\n\t\tsponsorshipPolicyId?: string,\n\t\toverrides?: GasPaymasterUserOperationOverrides,\n\t): Promise<[SameUserOp<T>, SponsorMetadata | undefined]> {\n\t\tconst userOp = { ...userOperation } as T;\n\t\tconst context: CandidePaymasterContext = {sponsorshipPolicyId, ...(overrides?.context || {}) };\n\t\tconst entrypoint = overrides?.entrypoint ?? this.resolveEntrypoint(smartAccount, userOp);\n\t\tawait this.ensureInitialized(entrypoint);\n\t\tconst epData = this.getEntrypointData(entrypoint);\n\t\tif (epData == null) {\n\t\t\tthrow new RangeError(\n\t\t\t\t`UserOperation for entrypoint ${entrypoint} is not supported`,\n\t\t\t);\n\t\t}\n\t\tif (context.signingPhase !== \"finalize\"){\n\t\t\tthis.setDummyPaymasterFields(userOp, epData);\n\t\t\tawait this.estimateAndApplyGasLimits(userOp, bundlerRpc, entrypoint, overrides ?? {});\n\t\t}\n\t\tconst _overrides = { ...(overrides || {}),\n\t\t\tentrypoint: entrypoint,\n\t\t};\n\t\treturn await this.createPaymasterUserOperation(\n\t\t\tsmartAccount,\n\t\t\tuserOp,\n\t\t\tcontext,\n\t\t\t_overrides,\n\t\t);\n\t}\n\n\t/**\n\t * Create a UserOperation that pays for gas with an ERC-20 token.\n\t * Automatically prepends a token approval to the calldata and sets paymaster fields.\n\t *\n\t * @param smartAccount - The smart account instance (must implement prependTokenPaymasterApproveToCallData)\n\t * @param userOperation - The UserOperation to modify for token payment\n\t * @param tokenAddress - The ERC-20 token contract address to pay gas with\n\t * @param bundlerRpc - Bundler RPC URL for gas estimation\n\t * @param overrides - Override gas limits, multipliers, and optional context\n\t * @returns The UserOperation with token approval prepended and paymaster fields set\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the token is not supported\n\t */\n\tasync createTokenPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: PrependTokenPaymasterApproveAccount,\n\t\tuserOperation: T,\n\t\ttokenAddress: string,\n\t\tbundlerRpc: string,\n\t\toverrides?: GasPaymasterUserOperationOverrides,\n\t): Promise<SameUserOp<T>> {\n\t\ttry {\n\t\t\tconst userOp = { ...userOperation } as T;\n\t\t\tconst context: CandidePaymasterContext = { token: tokenAddress, ...(overrides?.context || {}) };\n\t\t\tconst entrypoint = overrides?.entrypoint ?? this.resolveEntrypoint(smartAccount, userOp);\n\t\t\tawait this.ensureInitialized(entrypoint);\n\t\t\tif (context.signingPhase !== \"finalize\"){\n\t\t\t\tconst epData = this.getEntrypointData(entrypoint);\n\t\t\t\tif (epData == null) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t`UserOperation for entrypoint ${entrypoint} is not supported`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.setDummyPaymasterFields(userOp, epData);\n\t\t\t\t// Prepend an infinite approval and re-estimate UserOperation gas limits (a later rational allowance will be calculated and replace the infinite one)\n\t\t\t\tconst oldCallData = userOp.callData;\n\t\t\t\tconst requiresAllowanceReset = overrides?.resetApproval\n\t\t\t\t\t?? TOKENS_REQUIRING_ALLOWANCE_RESET.includes(\n\t\t\t\t\t\tcontext.token!.toLowerCase(),\n\t\t\t\t\t);\n\t\t\t\tlet callDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\tuserOp.callData,\n\t\t\t\t\tcontext.token!,\n\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\tUINT256_MAX,\n\t\t\t\t);\n\t\t\t\tif (requiresAllowanceReset) {\n\t\t\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\t\tcallDataWithApprove,\n\t\t\t\t\t\tcontext.token!,\n\t\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\t\t0n,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tuserOp.callData = callDataWithApprove;\n\n\t\t\t\tawait this.estimateAndApplyGasLimits(userOp, bundlerRpc, entrypoint, overrides ?? {});\n\n\t\t\t\tconst maxErc20Cost = await this.calculateUserOperationErc20TokenMaxGasCost(\n\t\t\t\t\tsmartAccount,\n\t\t\t\t\tuserOp,\n\t\t\t\t\tcontext.token!,\n\t\t\t\t);\n\t\t\t\tconst approveAmount = maxErc20Cost * TOKEN_APPROVE_AMOUNT_MULTIPLIER;\n\t\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\toldCallData,\n\t\t\t\t\tcontext.token!,\n\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\tapproveAmount,\n\t\t\t\t);\n\t\t\t\tif (requiresAllowanceReset) {\n\t\t\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\t\tcallDataWithApprove,\n\t\t\t\t\t\tcontext.token!,\n\t\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\t\t0n,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tuserOp.callData = callDataWithApprove;\n\t\t\t}\n\t\t\tconst _overrides = { ...(overrides || {}),\n\t\t\t\tentrypoint: entrypoint,\n\t\t\t};\n\t\t\tconst [resultUserOp] = await this.createPaymasterUserOperation(\n\t\t\t\tsmartAccount,\n\t\t\t\tuserOp,\n\t\t\t\tcontext,\n\t\t\t\t_overrides,\n\t\t\t);\n\t\t\treturn resultUserOp;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"createTokenPaymasterUserOperation failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Calculate the maximum ERC-20 token cost for a UserOperation's gas.\n\t * Uses the token's exchange rate from the paymaster to convert from wei.\n\t *\n\t * @param smartAccount - The smart account instance\n\t * @param userOperation - The UserOperation to calculate the cost for\n\t * @param erc20TokenAddress - The ERC-20 token contract address\n\t * @param overrides - Optional entrypoint override\n\t * @returns Maximum token cost as a bigint (in token's smallest unit)\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the token is not supported\n\t */\n\tasync calculateUserOperationErc20TokenMaxGasCost(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: AnyUserOperation,\n\t\terc20TokenAddress: string,\n\t\toverrides: { entrypoint?: string | null } = {},\n\t): Promise<bigint> {\n\t\ttry {\n\t\t\tconst entrypoint = overrides.entrypoint ?? this.resolveEntrypoint(smartAccount, userOperation);\n\t\t\tawait this.ensureInitialized(entrypoint);\n\t\t\tconst exchangeRate = await this.fetchTokenPaymasterExchangeRate(\n\t\t\t\terc20TokenAddress,\n\t\t\t\tentrypoint,\n\t\t\t);\n\t\t\tconst cost = calculateUserOperationMaxGasCost(userOperation);\n\t\t\treturn (exchangeRate * cost) / BigInt(10 ** 18);\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"calculateUserOperationErc20TokenMaxGasCost failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch the current exchange rate for an ERC-20 token from the paymaster.\n\t *\n\t * @param erc20TokenAddress - The ERC-20 token contract address\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns The exchange rate as a bigint\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the token is not supported\n\t */\n\tasync fetchTokenPaymasterExchangeRate(\n\t\terc20TokenAddress: string,\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<bigint> {\n\t\ttry {\n\t\t\tawait this.ensureInitialized(entrypoint);\n\n\t\t\tconst jsonRpcResult = await this.fetchSupportedTokensRpc(entrypoint) as SupportedERC20TokensAndMetadataWithExchangeRate;\n\n\t\t\tconst gasToken = jsonRpcResult.tokens.find(\n\t\t\t\t(token) =>\n\t\t\t\t\ttoken.address.toLowerCase() === erc20TokenAddress.toLowerCase(),\n\t\t\t);\n\n\t\t\tif (!gasToken) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\terc20TokenAddress + \" token is not supported by the paymaster.\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tentrypoint,\n\t\t\t\t\t\t\tsupportedTokens: jsonRpcResult.tokens.map((t) => t.address),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn BigInt(gasToken.exchangeRate);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"fetchTokenPaymasterExchangeRate failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch fresh supported ERC-20 tokens with exchange rates and paymaster metadata.\n\t * Unlike the cached version, this always makes an RPC call.\n\t *\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns Supported tokens with exchange rates and paymaster metadata\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the call fails\n\t */\n\tasync fetchSupportedERC20TokensAndPaymasterMetadata(\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<SupportedERC20TokensAndMetadataWithExchangeRate> {\n\t\ttry {\n\t\t\tawait this.ensureInitialized(entrypoint);\n\n\t\t\tif (this.getEntrypointData(entrypoint) == null) {\n\t\t\t\tthrow new RangeError(\"unsupported entrypoint.\");\n\t\t\t}\n\n\t\t\tconst result = await this.fetchSupportedTokensRpc(entrypoint) as\n\t\t\t\tSupportedERC20TokensAndMetadataWithExchangeRate;\n\t\t\treturn {\n\t\t\t\ttokens: CandidePaymaster.mapTokensWithExchangeRate(result.tokens),\n\t\t\t\tpaymasterMetadata: CandidePaymaster.normalizePaymasterMetadata(result.paymasterMetadata),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"fetchSupportedERC20TokensAndPaymasterMetadata failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n}\n","import { Paymaster } from \"./Paymaster\";\nimport { ParallelPaymasterInitValues, UserOperationV9 } from \"../types\";\n\n/**\n * A paymaster that sponsors all UserOperations unconditionally.\n * Uses a fixed magic signature that the on-chain paymaster contract accepts\n * without additional validation.\n * Supports ep v0.9 paymaster parallel signing.\n *\n * **WARNING: FOR DEVELOPMENT AND TESTING ONLY.**\n * This paymaster accepts all operations without validation and should\n * not be used in production environments. Use CandidePaymaster for prod.\n */\nexport class ExperimentalAllowAllParallelPaymaster extends Paymaster {\n\t/** The on-chain paymaster contract address. */\n\treadonly address: string;\n\n\t/**\n\t * @param address - Paymaster contract address. Defaults to the canonical AllowAll deployment.\n\t */\n\tconstructor(address: string = \"0x36A337b8b4cE5CF6ca1dDaeef73Da4928d714DF2\") {\n\t\tsuper();\n\t\tthis.address = address;\n\t}\n\n\t/**\n\t * Returns initial paymaster fields (address, gas limits, and data) for\n\t * UserOperation construction before gas estimation.\n\t * @param chainId - The chain ID (unused, kept for interface compatibility)\n\t * @returns Paymaster fields with the magic signature as paymasterData\n\t */\n\tasync getPaymasterFieldsInitValues(\n chainId: bigint\n ):Promise<ParallelPaymasterInitValues>{\n return {\n paymaster: this.address,\n paymasterVerificationGasLimit: 45_000n,\n paymasterPostOpGasLimit: 45_000n,\n paymasterData:\"0x010101010101010101010101010101010101010101010101010101010101011c\"+\"0020\"+\"22e325a297439656\" // DUMMY SIG + PAYMASTER_SIG_LEN + PAYMASTER_SIG_MAGIC\n };\n }\n\n\t/**\n\t * getApprovedPaymasterData will return a valid paymasterData\n * This function is async to simulate a paymaster service\n * that require an http call to fetch approved data.\n\t * @param userOperation - User operation to be sponsored\n\t * @returns a promise of string\n\t */\n\tasync getApprovedPaymasterData(userOperation: UserOperationV9):Promise<string>{\n // the allow all paymaster only checks for this fixed signature\n return \"0x7603fbcd3c6cebdb7193b716f62fe7e9d4afd859df4bf7fcdb2e9d486f57a1ca\"\n + \"0020\" // signature length\n + \"22e325a297439656\"; // PAYMASTER_SIG_MAGIC\n }\n}\n","import { Paymaster } from \"./Paymaster\";\nimport { StateOverrideSet, UserOperationV7, UserOperationV8 } from \"../types\";\nimport { AbiCoder, keccak256, solidityPacked } from \"ethers\";\nimport { ENTRYPOINT_V7, ENTRYPOINT_V8 } from \"src/constants\";\nimport { Bundler } from \"src/Bundler\";\n\n/**\n * A paymaster that sponsors UserOperations for accounts verified through\n * World ID proof-of-personhood. Encodes the World ID Merkle root,\n * nullifier hash, and zero-knowledge proof into the paymasterData field\n * and re-estimates gas limits via the bundler.\n */\nexport class WorldIdPermissionlessPaymaster extends Paymaster {\n\t/** The on-chain paymaster contract address. */\n\treadonly address: string;\n\n\t/**\n\t * @param address - The deployed WorldIdPermissionlessPaymaster contract address\n\t */\n\tconstructor(address: string) {\n\t\tsuper();\n\t\tthis.address = address;\n\t}\n\n\t/**\n\t * createPaymasterUserOperation will estimate gas and set the paymaster fields.\n\t * @param userOperation - User operation to be sponsored\n\t * @param bundlerRpc - Bundler endpoint rpc url\n * @param nullifierHash - nullifier hash\n\t * @param root - Worldid Merkle tree root\n\t * @param proof - Worldid zk proof\n\t * @param overrides - Overrides for the default values\n\t * @returns a promise of UserOperationV8 | UserOperationV7\n\t */\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV8,\n bundlerRpc: string,\n nullifierHash: bigint,\n root:bigint,\n proof: string,\n\t\toverrides?:{\n /** set the entrypoint address intead of determining it from the useroperation structure.*/\n entrypoint?: string;\n\n /** pass some state overrides for gas estimation\"*/\n state_override_set?: StateOverrideSet;\n }\n\t):Promise<UserOperationV8>;\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV7,\n bundlerRpc: string,\n nullifierHash: bigint,\n root:bigint,\n proof: string,\n\t\toverrides?:{\n /** set the entrypoint address intead of determining it from the useroperation structure.*/\n entrypoint?: string;\n\n /** pass some state overrides for gas estimation\"*/\n state_override_set?: StateOverrideSet;\n }\n\t):Promise<UserOperationV7>;\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV8 | UserOperationV7,\n bundlerRpc: string,\n nullifierHash: bigint,\n root:bigint,\n proof: string,\n\t\toverrides?:{\n /** set the entrypoint address intead of determining it from the useroperation structure.*/\n entrypoint?: string;\n /** pass some state overrides for gas estimation\"*/\n state_override_set?: StateOverrideSet;\n }\n\t):Promise<UserOperationV8 | UserOperationV7> {\n //256 bytes for proof\n if(proof.slice(0,2) != \"0x\" || proof.length != 514){\n throw new RangeError(\"Invalid proof.\");\n }\n\n proof = proof.slice(2);\n const proofArr = [\n \"0x\" + proof.slice(0,64),\n \"0x\" + proof.slice(64,128),\n \"0x\" + proof.slice(128,192),\n \"0x\" + proof.slice(192,256),\n \"0x\" + proof.slice(256,320),\n \"0x\" + proof.slice(320,384),\n \"0x\" + proof.slice(384,448),\n \"0x\" + proof.slice(448,512),\n ];\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n const paymasterData =\n abiCoder.encode(['uint256'],[root]) + \n abiCoder.encode(['uint256'],[nullifierHash]).slice(2) + \n abiCoder.encode(['uint256[8]'],[proofArr]).slice(2);\n\n userOperation.paymaster = this.address;\n userOperation.paymasterData = paymasterData;\n userOperation.paymasterPostOpGasLimit = 45_000n;\n userOperation.paymasterVerificationGasLimit = 350_000n;\n \n if(overrides == null){\n overrides = {}\n }\n let entrypointAddress = overrides.entrypoint;\n\n\t\tif (entrypointAddress == null) {\n\t\t if (\"eip7702Auth\" in userOperation) {\n entrypointAddress = ENTRYPOINT_V8;\n }else{\n entrypointAddress = ENTRYPOINT_V7;\n }\n }\n \n let preVerificationGas = userOperation.preVerificationGas;\n let verificationGasLimit = userOperation.verificationGasLimit;\n let callGasLimit = userOperation.callGasLimit;\n\n // set preVerificationGas to zero to force restimation\n userOperation.preVerificationGas = 0n;\n\n const bundler = new Bundler(bundlerRpc);\n const estimation = await bundler.estimateUserOperationGas(\n userOperation,\n entrypointAddress as string,\n overrides.state_override_set,\n );\n\n // only change gas limits if the estimated limits is higher than\n // the supplied\n if (preVerificationGas < estimation.preVerificationGas) {\n preVerificationGas = estimation.preVerificationGas;\n }\n if (verificationGasLimit < estimation.verificationGasLimit) {\n verificationGasLimit = estimation.verificationGasLimit;\n }\n if (callGasLimit < estimation.callGasLimit) {\n callGasLimit = estimation.callGasLimit;\n }\n\n userOperation.preVerificationGas = preVerificationGas;\n userOperation.verificationGasLimit = verificationGasLimit;\n userOperation.callGasLimit = callGasLimit;\n\n return userOperation;\n\t}\n}\n\n\n/**\n * createWorldIdSignal is a helper function to work with \"@worldcoin/idkit\n * @param accountAddress - account address\n * @param accountNonce - account nonce\n * @param chainId - chain id\n * @returns idkit IDKitWidget signal\n */\nexport function createWorldIdSignal(\n accountAddress: string,\n accountNonce: bigint,\n chainId: bigint,\n):string {\n return keccak256(\n solidityPacked(\n [\"address\", \"uint256\", \"uint256\"],\n [accountAddress, accountNonce, chainId]\n )\n )\n}\n","export { SmartAccount } from \"./account/SmartAccount\";\nexport { Simple7702Account } from \"./account/simple/Simple7702Account\";\nexport { Simple7702AccountV09 } from \"./account/simple/Simple7702AccountV09\";\nexport { SafeMultiChainSigAccountV1 } from \"./account/Safe/SafeMultiChainSigAccount\";\nexport { Calibur7702Account } from \"./account/Calibur/Calibur7702Account\";\nexport { CaliburKeyType } from \"./account/Calibur/types\";\nexport type {\n\tCaliburKey, CaliburKeySettings, CaliburKeySettingsResult,\n\tWebAuthnSignatureData, CaliburCreateUserOperationOverrides,\n\tCaliburSignatureOverrides, SignerFunction,\n} from \"./account/Calibur/types\";\nexport {\n\tSocialRecoveryModule,\n\tSocialRecoveryModuleGracePeriodSelector,\n EXECUTE_RECOVERY_PRIMARY_TYPE,\n EIP712_RECOVERY_MODULE_TYPE\n} from \"./account/Safe/modules/SocialRecoveryModule\";\nexport type {\n\tRecoveryRequest,\n\tRecoverySignaturePair,\n RecoveryRequestTypedDataDomain,\n RecoveryRequestTypedMessageValue,\n} from \"./account/Safe/modules/SocialRecoveryModule\";\nexport {\n\tAllowanceModule,\n\tALLOWANCE_MODULE_V0_1_0_ADDRESS,\n} from \"./account/Safe/modules/AllowanceModule\";\nexport type { Allowance } from \"./account/Safe/modules/AllowanceModule\";\nexport { SafeAccountV0_2_0 } from \"./account/Safe/SafeAccountV0_2_0\";\nexport { SafeAccountV0_3_0 } from \"./account/Safe/SafeAccountV0_3_0\";\nexport { SafeAccountV1_5_0_M_0_3_0 } from \"./account/Safe/SafeAccountV1_5_0_M_0_3_0\";\n\nexport { SendUseroperationResponse } from \"./account/SendUseroperationResponse\";\n\nexport { SmartAccountFactory } from \"./factory/SmartAccountFactory\";\nexport { SafeAccountFactory } from \"./factory/SafeAccountFactory\";\n\nexport { Bundler } from \"./Bundler\";\n\nexport { CandidePaymaster } from \"./paymaster/CandidePaymaster\";\nexport { ExperimentalAllowAllParallelPaymaster } from \"./paymaster/AllowAllPaymaster\";\n\nexport { \n WorldIdPermissionlessPaymaster, createWorldIdSignal \n} from \"./paymaster/WorldIdPermissionlessPaymaster\";\n\nexport {\n\tcreateUserOperationHash,\n\tcreateCallData,\n\tgetFunctionSelector,\n\tfetchAccountNonce,\n\tcalculateUserOperationMaxGasCost,\n\tsendJsonRpcRequest,\n fetchGasPrice,\n getDepositInfo,\n getBalanceOf,\n getDelegatedAddress,\n} from \"./utils\";\nexport type { DepositInfo } from \"./utils\";\n\nexport {\n shareTenderlySimulationAndCreateLink,\n simulateUserOperationWithTenderlyAndCreateShareLink,\n simulateUserOperationWithTenderly,\n simulateUserOperationCallDataWithTenderly,\n simulateSenderCallDataWithTenderlyAndCreateShareLink,\n simulateUserOperationCallDataWithTenderlyAndCreateShareLink,\n simulateSenderCallDataWithTenderly,\n callTenderlySimulateBundle\n} from \"./utilsTenderly\";\n\n\nexport {\n createAndSignLegacyRawTransaction,\n createAndSignEip7702RawTransaction,\n createEip7702TransactionHash,\n createAndSignEip7702DelegationAuthorization,\n createEip7702DelegationAuthorizationHash,\n signHash,\n} from \"./utils7702\";\nexport type { Authorization7702Hex, Authorization7702 } from \"./utils7702\";\n\nexport {\n\tSafeModuleExecutorFunctionSelector,\n\tEOADummySignerSignaturePair,\n\tWebauthnDummySignerSignaturePair,\n} from \"./account/Safe/types\";\nexport type {\n\tCreateUserOperationV6Overrides,\n\tCreateUserOperationV7Overrides,\n\tCreateUserOperationV9Overrides,\n\tECDSAPublicAddress,\n\tInitCodeOverrides,\n\tSafeUserOperationTypedDataDomain,\n\tWebauthnPublicKey,\n\tWebauthnSignatureData,\n\tSignerSignaturePair,\n\tSigner,\n} from \"./account/Safe/types\";\n\nexport type {\n\tCandidePaymasterContext,\n\tPrependTokenPaymasterApproveAccount,\n\tAnyUserOperation,\n\tSameUserOp,\n} from \"./paymaster/types\";\n\nexport { Operation, GasOption, PolygonChain } from \"./types\";\nexport type {\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n\tUserOperationV9,\n\tAbiInputValue,\n\tJsonRpcParam,\n\tJsonRpcResponse,\n\tJsonRpcResult,\n\tGasEstimationResult,\n\tUserOperationByHashResult,\n\tUserOperationReceipt,\n\tUserOperationReceiptResult,\n\tJsonRpcError,\n\tStateOverrideSet,\n\tMetaTransaction,\n SponsorMetadata,\n ParallelPaymasterInitValues,\n} from \"./types\";\n\nexport {\n\tZeroAddress,\n\tBaseUserOperationDummyValues,\n\tEIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\tEIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE,\n\tEIP712_SAFE_OPERATION_V7_TYPE,\n\tEIP712_SAFE_OPERATION_V6_TYPE,\n\tEIP712_SAFE_OPERATION_PRIMARY_TYPE,\n DEFAULT_SECP256R1_PRECOMPILE_ADDRESS,\n CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS,\n CALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS,\n ENTRYPOINT_V6,\n ENTRYPOINT_V7,\n ENTRYPOINT_V8,\n ENTRYPOINT_V9,\n} from \"./constants\";\n\nexport {\n SAFE_MESSAGE_PRIMARY_TYPE,\n SAFE_MESSAGE_MODULE_TYPE,\n getSafeMessageEip712Data,\n} from \"./account/Safe/safeMessage\";\nexport type {\n SafeMessageTypedDataDomain,\n SafeMessageTypedMessageValue,\n} from \"./account/Safe/safeMessage\";\n\nexport { AbstractionKitError } from \"./errors\";\n"],"mappings":";;;;;;;AAIA,IAAsB,eAAtB,MAAmC;;CAElC;;CAEA,OAAgB;;CAEhB,OAAgB;;CAEhB,OAAgB;;CAEhB,OAAgB;;CAEhB,OAAgB;;;;CAKhB,YAAY,gBAAwB;AACnC,OAAK,iBAAiB;;;;;;ACnBxB,MAAa,cAAc;;AAG3B,MAAa,gBAAgB;;AAE7B,MAAa,gBAAgB;;AAE7B,MAAa,gBAAgB;;AAE7B,MAAa,gBAAgB;;AAG7B,MAAa,iBAAuC;CACnD,kBAAkB;CAClB,mBACC;CACD;;AAGD,MAAa,iBAAuC;CACnD,kBAAkB;CAClB,mBACC;CACD;;AAGD,MAAa,+BAA+B;CAC3C,QAAQ;CACR,OAAO;CACP,UAAU;CACV,cAAc;CACd,sBAAsB;CACtB,oBAAoB;CACpB,cAAc;CACd,sBAAsB;CACtB,WAAW;CACX;AAED,MAAa,qCAAqC;;AAGlD,MAAa,gCAAgC,EAC5C,QAAQ;CACP;EAAE,MAAM;EAAW,MAAM;EAAQ;CACjC;EAAE,MAAM;EAAW,MAAM;EAAS;CAClC;EAAE,MAAM;EAAS,MAAM;EAAY;CACnC;EAAE,MAAM;EAAS,MAAM;EAAY;CACnC;EAAE,MAAM;EAAW,MAAM;EAAgB;CACzC;EAAE,MAAM;EAAW,MAAM;EAAwB;CACjD;EAAE,MAAM;EAAW,MAAM;EAAsB;CAC/C;EAAE,MAAM;EAAW,MAAM;EAAgB;CACzC;EAAE,MAAM;EAAW,MAAM;EAAwB;C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":["../src/account/SmartAccount.ts","../src/constants.ts","../src/types.ts","../src/errors.ts","../src/utils.ts","../src/utils7702.ts","../src/Bundler.ts","../src/account/SendUseroperationResponse.ts","../src/account/simple/Simple7702Account.ts","../src/account/simple/Simple7702AccountV09.ts","../src/utilsTenderly.ts","../src/account/Safe/types.ts","../src/account/Safe/multisend.ts","../src/factory/SmartAccountFactory.ts","../src/factory/SafeAccountFactory.ts","../src/account/Safe/safeMessage.ts","../src/account/Safe/SafeAccount.ts","../src/account/Safe/MerkleTree.ts","../src/account/Safe/constants.ts","../src/account/Safe/SafeMultiChainSigAccount.ts","../src/account/Calibur/types.ts","../src/account/Calibur/Calibur7702Account.ts","../src/account/Safe/modules/SafeModule.ts","../src/account/Safe/modules/SocialRecoveryModule.ts","../src/account/Safe/modules/AllowanceModule.ts","../src/account/Safe/SafeAccountV0_3_0.ts","../src/account/Safe/SafeAccountV0_2_0.ts","../src/account/Safe/SafeAccountV1_5_0_M_0_3_0.ts","../src/paymaster/Paymaster.ts","../src/paymaster/CandidePaymaster.ts","../src/paymaster/Erc7677Paymaster.ts","../src/paymaster/AllowAllPaymaster.ts","../src/paymaster/WorldIdPermissionlessPaymaster.ts","../src/abstractionkit.ts"],"sourcesContent":["/**\n * Abstract base class for all smart account implementations.\n * Defines common properties shared across account types (Safe, Simple, etc.).\n */\nexport abstract class SmartAccount {\n\t/** The on-chain address of the smart account */\n\treadonly accountAddress: string;\n\t/** Proxy contract creation bytecode */\n\tstatic readonly proxyByteCode: string;\n\t/** 4-byte function selector for the account initializer */\n\tstatic readonly initializerFunctionSelector: string;\n\t/** ABI types for the initializer function parameters */\n\tstatic readonly initializerFunctionInputAbi: string[];\n\t/** 4-byte function selector for the executor function */\n\tstatic readonly executorFunctionSelector: string;\n\t/** ABI types for the executor function parameters */\n\tstatic readonly executorFunctionInputAbi: string[];\n\n\t/**\n\t * @param accountAddress - The on-chain address of the smart account\n\t */\n\tconstructor(accountAddress: string) {\n\t\tthis.accountAddress = accountAddress;\n\t}\n}\n","import { SafeAccountSingleton } from \"./account/Safe/types\";\n\n/** The Ethereum zero address (0x0000...0000), used as a placeholder for empty/null addresses */\nexport const ZeroAddress = \"0x0000000000000000000000000000000000000000\";\n\n/** EntryPoint v0.9 contract address */\nexport const ENTRYPOINT_V9 = \"0x433709009B8330FDa32311DF1C2AFA402eD8D009\";\n/** EntryPoint v0.8 contract address */\nexport const ENTRYPOINT_V8 = \"0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108\";\n/** EntryPoint v0.7 contract address */\nexport const ENTRYPOINT_V7 = \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\";\n/** EntryPoint v0.6 contract address */\nexport const ENTRYPOINT_V6 = \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\";\n\n/** Safe L2 singleton v1.5.0 address and init hash */\nexport const Safe_L2_V1_5_0: SafeAccountSingleton = {\n\tsingletonAddress: \"0xEdd160fEBBD92E350D4D398fb636302fccd67C7e\",\n\tsingletonInitHash:\n\t\t\"0x1b94aebb5a7df6dff11d93589204a6bbc99b4b8c9014bf1d386d006c2c17a881\",\n};\n\n/** Safe L2 singleton v1.4.1 address and init hash */\nexport const Safe_L2_V1_4_1: SafeAccountSingleton = {\n\tsingletonAddress: \"0x29fcB43b46531BcA003ddC8FCB67FFE91900C762\",\n\tsingletonInitHash:\n\t\t\"0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee\",\n};\n\n/** Default placeholder values for gas estimation before actual values are known */\nexport const BaseUserOperationDummyValues = {\n\tsender: ZeroAddress,\n\tnonce: 0n,\n\tcallData: \"0x\",\n\tcallGasLimit: 0n,\n\tverificationGasLimit: 0n,\n\tpreVerificationGas: 0n,\n\tmaxFeePerGas: 0n,\n\tmaxPriorityFeePerGas: 0n,\n\tsignature: \"0x\",\n};\n\nexport const EIP712_SAFE_OPERATION_PRIMARY_TYPE = \"SafeOp\";\n\n/** EIP-712 type definition for Safe UserOperation signing (EntryPoint v0.6) */\nexport const EIP712_SAFE_OPERATION_V6_TYPE = {\n\tSafeOp: [\n\t\t{ type: \"address\", name: \"safe\" },\n\t\t{ type: \"uint256\", name: \"nonce\" },\n\t\t{ type: \"bytes\", name: \"initCode\" },\n\t\t{ type: \"bytes\", name: \"callData\" },\n\t\t{ type: \"uint256\", name: \"callGasLimit\" },\n\t\t{ type: \"uint256\", name: \"verificationGasLimit\" },\n\t\t{ type: \"uint256\", name: \"preVerificationGas\" },\n\t\t{ type: \"uint256\", name: \"maxFeePerGas\" },\n\t\t{ type: \"uint256\", name: \"maxPriorityFeePerGas\" },\n\t\t{ type: \"bytes\", name: \"paymasterAndData\" },\n\t\t{ type: \"uint48\", name: \"validAfter\" },\n\t\t{ type: \"uint48\", name: \"validUntil\" },\n\t\t{ type: \"address\", name: \"entryPoint\" },\n\t],\n};\n\n/** EIP-712 type definition for Safe UserOperation signing (EntryPoint v0.7) */\nexport const EIP712_SAFE_OPERATION_V7_TYPE = {\n\tSafeOp: [\n\t\t{ type: \"address\", name: \"safe\" },\n\t\t{ type: \"uint256\", name: \"nonce\" },\n\t\t{ type: \"bytes\", name: \"initCode\" },\n\t\t{ type: \"bytes\", name: \"callData\" },\n\t\t{ type: \"uint128\", name: \"verificationGasLimit\" },\n\t\t{ type: \"uint128\", name: \"callGasLimit\" },\n\t\t{ type: \"uint256\", name: \"preVerificationGas\" },\n\t\t{ type: \"uint128\", name: \"maxPriorityFeePerGas\" },\n\t\t{ type: \"uint128\", name: \"maxFeePerGas\" },\n\t\t{ type: \"bytes\", name: \"paymasterAndData\" },\n\t\t{ type: \"uint48\", name: \"validAfter\" },\n\t\t{ type: \"uint48\", name: \"validUntil\" },\n\t\t{ type: \"address\", name: \"entryPoint\" },\n\t],\n};\n\nexport const EIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE = \"MerkleTreeRoot\";\n\n/** EIP-712 type definition for multi-chain Safe operations using Merkle tree roots */\nexport const EIP712_MULTI_CHAIN_OPERATIONS_TYPE = {\n\tMerkleTreeRoot: [\n\t\t{ type: \"bytes32\", name: \"merkleTreeRoot\" },\n\t],\n};\n\n/** Default address for the secp256r1 (P-256) precompile used by WebAuthn verification */\nexport const DEFAULT_SECP256R1_PRECOMPILE_ADDRESS = \"0x0000000000000000000000000000000000000100\";\n\n/** Uniswap Calibur singleton v1.0.0 (EntryPoint v0.8) */\nexport const CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS = \"0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00\";\n\n/** Candide Calibur singleton v0.1.0 (EntryPoint v0.9, unaudited) */\nexport const CALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS = \"0x71032285A847c4311Eb7ec2E7A636aB94A9805Aa\";\n","import { Authorization7702Hex } from \"./utils7702\";\n\n/**\n * Base fields shared by all UserOperation versions.\n * Extended by version-specific interfaces (UserOperationV6, V7, V8).\n */\nexport interface BaseUserOperation {\n\t/** The account making the operation */\n\tsender: string;\n\t/** Anti-replay parameter; also used as the salt for first-time account creation */\n\tnonce: bigint;\n\t/** The calldata to execute on the sender account */\n\tcallData: string;\n\t/** Gas limit for the inner account execution */\n\tcallGasLimit: bigint;\n\t/** Gas limit for the account verification step */\n\tverificationGasLimit: bigint;\n\t/** Extra gas to pay the bundler */\n\tpreVerificationGas: bigint;\n\t/** Maximum fee per gas (EIP-1559 max_fee_per_gas) */\n\tmaxFeePerGas: bigint;\n\t/** Maximum priority fee per gas (EIP-1559 max_priority_fee_per_gas) */\n\tmaxPriorityFeePerGas: bigint;\n\t/** Signature over the UserOperation hash */\n\tsignature: string;\n}\n\n/**\n * UserOperation for EntryPoint v0.6. Uses concatenated initCode and paymasterAndData fields.\n */\nexport interface UserOperationV6 extends BaseUserOperation {\n\t/** Concatenated factory address and factory-specific data (empty '0x' if already deployed) */\n\tinitCode: string;\n\t/** Concatenated paymaster address and paymaster-specific data (empty '0x' for self-funded) */\n\tpaymasterAndData: string;\n}\n\n/**\n * UserOperation for EntryPoint v0.7. Uses separate factory/paymaster fields.\n */\nexport interface UserOperationV7 extends BaseUserOperation {\n\t/** Factory contract address used to deploy the account (null if already deployed) */\n\tfactory: string | null;\n\t/** Factory-specific data for account creation (null if already deployed) */\n\tfactoryData: string | null;\n\t/** Paymaster contract address (null for self-funded operations) */\n\tpaymaster: string | null;\n\t/** Gas limit for the paymaster verification step (null if no paymaster) */\n\tpaymasterVerificationGasLimit: bigint | null;\n\t/** Gas limit for the paymaster post-operation callback (null if no paymaster) */\n\tpaymasterPostOpGasLimit: bigint | null;\n\t/** Paymaster-specific data (null if no paymaster) */\n\tpaymasterData: string | null;\n}\n\n/**\n * UserOperation for EntryPoint v0.8. Adds EIP-7702 authorization support.\n */\nexport interface UserOperationV8 extends BaseUserOperation {\n\t/** Factory contract address used to deploy the account (null if already deployed) */\n\tfactory: string | null;\n\t/** Factory-specific data for account creation (null if already deployed) */\n\tfactoryData: string | null;\n\t/** Paymaster contract address (null for self-funded operations) */\n\tpaymaster: string | null;\n\t/** Gas limit for the paymaster verification step (null if no paymaster) */\n\tpaymasterVerificationGasLimit: bigint | null;\n\t/** Gas limit for the paymaster post-operation callback (null if no paymaster) */\n\tpaymasterPostOpGasLimit: bigint | null;\n\t/** Paymaster-specific data (null if no paymaster) */\n\tpaymasterData: string | null;\n\t/** EIP-7702 delegation authorization (null if not using 7702) */\n eip7702Auth: Authorization7702Hex | null;\n}\n\n/**\n * UserOperation for EntryPoint v0.9. Same structure as v0.8.\n */\nexport interface UserOperationV9 extends UserOperationV8 {\n}\n\n/** Union type for values that can be ABI-encoded as function parameters. */\nexport type AbiInputValue =\n\t| string\n\t| bigint\n\t| number\n\t| boolean\n\t| AbiInputValue[];\n\n/** Union type for JSON-RPC request parameters. */\nexport type JsonRpcParam = string | bigint | boolean | object | JsonRpcParam[];\n\n/** Standard JSON-RPC 2.0 response envelope. */\nexport type JsonRpcResponse = {\n\t/** Request identifier */\n\tid: number | null;\n\t/** JSON-RPC protocol version */\n\tjsonrpc: string;\n\t/** The result payload on success */\n\tresult?: JsonRpcResult;\n\t/** Tenderly simulation results */\n simulation_results?: JsonRpcResult;\n\t/** The error payload on failure */\n\terror?: JsonRpcError;\n};\n\nexport type ChainIdResult = string;\nexport type SupportedEntryPointsResult = string[];\n\nexport type SingleTransactionTenderlySimulationResult = {\n transaction: Record<string, unknown>;\n simulation: { id: string } & Record<string, unknown>;\n}\n\nexport type TenderlySimulationResult = SingleTransactionTenderlySimulationResult[]\n\nexport type JsonRpcResult =\n\t| ChainIdResult\n\t| SupportedEntryPointsResult\n\t| GasEstimationResult\n\t| UserOperationByHashResult\n\t| UserOperationReceipt\n\t| UserOperationReceiptResult\n\t| SupportedERC20TokensAndMetadata\n\t| PmUserOperationV7Result\n\t| PmUserOperationV6Result\n | TenderlySimulationResult;\n\n/** JSON-RPC error object returned when a request fails. */\nexport type JsonRpcError = {\n\t/** Numeric error code */\n\tcode: number;\n\t/** Human-readable error message */\n\tmessage: string;\n\t/** Additional structured error data */\n\tdata: object;\n};\n\n/** Gas estimation result returned by eth_estimateUserOperationGas. */\nexport type GasEstimationResult = {\n\t/** Estimated gas limit for inner execution */\n\tcallGasLimit: bigint;\n\t/** Estimated extra gas to pay the bundler */\n\tpreVerificationGas: bigint;\n\t/** Estimated gas limit for verification step */\n\tverificationGasLimit: bigint;\n\t/** Paymaster verification gas limit. Non-standard bundler extension; see `Bundler.estimateUserOperationGas`. */\n\tpaymasterVerificationGasLimit?: bigint;\n\t/** Paymaster post-op gas limit. Non-standard bundler extension; see `Bundler.estimateUserOperationGas`. */\n\tpaymasterPostOpGasLimit?: bigint;\n};\n\n/** Result of eth_getUserOperationByHash. Null if not found. */\nexport type UserOperationByHashResult = {\n\t/** The UserOperation object */\n\tuserOperation: UserOperationV6 | UserOperationV7;\n\t/** The EntryPoint address */\n\tentryPoint: string;\n\t/** Block number (null if pending) */\n\tblockNumber: bigint | null;\n\t/** Block hash (null if pending) */\n\tblockHash: string | null;\n\t/** Transaction hash of the bundle (null if pending) */\n\ttransactionHash: string | null;\n} | null;\n\n/** On-chain transaction receipt for the bundle that included a UserOperation. */\nexport type UserOperationReceipt = {\n\t/** Hash of the block containing the transaction */\n\tblockHash: string;\n\t/** Number of the block containing the transaction */\n\tblockNumber: bigint;\n\t/** Address of the bundler that submitted the transaction */\n\tfrom: string;\n\t/** Total gas used in the block up to and including this transaction */\n\tcumulativeGasUsed: bigint;\n\t/** Gas used by this specific transaction */\n\tgasUsed: bigint;\n\t/** Encoded logs emitted during execution */\n\tlogs: string;\n\t/** Bloom filter for the transaction logs */\n\tlogsBloom: string;\n\t/** Hash of the bundle transaction */\n\ttransactionHash: string;\n\t/** Index of the transaction within the block */\n\ttransactionIndex: bigint;\n\t/** Effective gas price paid (EIP-1559) */\n\teffectiveGasPrice?: bigint;\n};\n\n/** Full result of eth_getUserOperationReceipt. Null if not found. */\nexport type UserOperationReceiptResult = {\n\t/** Hash of the UserOperation */\n\tuserOpHash: string;\n\t/** EntryPoint contract address that processed the operation */\n\tentryPoint: string;\n\t/** Sender (smart account) address */\n\tsender: string;\n\t/** Nonce used by the UserOperation */\n\tnonce: bigint;\n\t/** Paymaster address (or zero address if self-funded) */\n\tpaymaster: string;\n\t/** Actual gas cost charged (in wei) */\n\tactualGasCost: bigint;\n\t/** Actual gas units consumed */\n\tactualGasUsed: bigint;\n\t/** Whether the inner account execution succeeded */\n\tsuccess: boolean;\n\t/** Encoded logs emitted during execution */\n\tlogs: string;\n\t/** The underlying transaction receipt */\n\treceipt: UserOperationReceipt;\n} | null;\n\n/** Metadata about the sponsor of a UserOperation. */\nexport type SponsorMetadata = {\n\t/** Sponsor display name */\n\tname: string;\n\t/** Sponsor description */\n\tdescription: string;\n\t/** Sponsor website URL */\n\turl: string;\n\t/** Sponsor icon URLs */\n\ticons: string[];\n};\n\n/** Paymaster fields returned by pm_getPaymasterData for EntryPoint v0.7+. */\nexport type PmUserOperationV7Result = {\n\t/** Paymaster contract address */\n\tpaymaster: string;\n\t/** Gas limit for the paymaster verification step */\n\tpaymasterVerificationGasLimit: bigint;\n\t/** Gas limit for the paymaster post-operation callback */\n\tpaymasterPostOpGasLimit: bigint;\n\t/** Paymaster-specific data */\n\tpaymasterData: string;\n\t/** Overridden call gas limit (if provided by paymaster) */\n\tcallGasLimit?: bigint;\n\t/** Overridden verification gas limit (if provided by paymaster) */\n\tverificationGasLimit?: bigint;\n\t/** Overridden pre-verification gas (if provided by paymaster) */\n\tpreVerificationGas?: bigint;\n\t/** Overridden max fee per gas (if provided by paymaster) */\n\tmaxFeePerGas?: bigint;\n\t/** Overridden max priority fee per gas (if provided by paymaster) */\n\tmaxPriorityFeePerGas?: bigint;\n\t/** Metadata about the sponsor */\n\tsponsorMetadata?: SponsorMetadata;\n};\n\nexport type PmUserOperationV8Result = PmUserOperationV7Result;\n\n/** Paymaster fields returned by pm_getPaymasterData for EntryPoint v0.6. */\nexport type PmUserOperationV6Result = {\n\t/** Concatenated paymaster address and paymaster-specific data */\n\tpaymasterAndData: string;\n\t/** Overridden call gas limit (if provided by paymaster) */\n\tcallGasLimit?: bigint;\n\t/** Overridden pre-verification gas (if provided by paymaster) */\n\tpreVerificationGas?: bigint;\n\t/** Overridden verification gas limit (if provided by paymaster) */\n\tverificationGasLimit?: bigint;\n\t/** Overridden max fee per gas (if provided by paymaster) */\n\tmaxFeePerGas?: bigint;\n\t/** Overridden max priority fee per gas (if provided by paymaster) */\n\tmaxPriorityFeePerGas?: bigint;\n\t/** Metadata about the sponsor */\n\tsponsorMetadata?: SponsorMetadata;\n};\n\n/**\n * Specifies whether a transaction is a regular call or a delegatecall.\n */\nexport enum Operation {\n\t/** Standard call to the target address */\n\tCall = 0,\n\t/** Delegatecall (executes target code in caller's context) */\n\tDelegate = 1,\n}\n\n/**\n * A single transaction to be included in a UserOperation.\n * Multiple MetaTransactions can be batched via multi-send.\n */\nexport interface MetaTransaction {\n\t/** Target contract or recipient address */\n\tto: string;\n\t/** Amount of native token (wei) to send */\n\tvalue: bigint;\n\t/** ABI-encoded calldata for the target contract */\n\tdata: string;\n\t/** Call type: Call (0) or Delegate (1). Defaults to Call. */\n\toperation?: Operation;\n}\n\n/**\n * Erc20 token info from the token paymaster\n */\nexport interface ERC20Token {\n\tname: string;\n\t/** Token symbol */\n\tsymbol: string;\n\t/** Token address */\n\taddress: string;\n\t/** Token decimal places */\n\tdecimals: number;\n}\n\n/**\n * Erc20 token info from the token paymaster with exchange rate\n */\nexport interface ERC20TokenWithExchangeRate extends ERC20Token {\n\t/** Token exchange rate*/\n\texchangeRate: bigint;\n}\n\n/**\n * Paymaster metadata returned by the paymaster RPC.\n * V7/V8 paymasters return structured dummyPaymasterAndData; V6 returns a concatenated hex string.\n */\nexport interface PaymasterMetadata {\n\tname: string;\n\tdescription: string;\n\ticons: string[];\n\t/** Paymaster contract address */\n\taddress: string;\n\t/** the event that will be emitted when a useroperation is sponsored */\n\tsponsoredEventTopic: string;\n\t/** dummyPaymasterAndData to use for gas estimation */\n\tdummyPaymasterAndData:\n\t\t| {\n\t\t\t\tpaymaster: string;\n\t\t\t\tpaymasterVerificationGasLimit: bigint;\n\t\t\t\tpaymasterPostOpGasLimit: bigint;\n\t\t\t\tpaymasterData: string;\n\t\t }\n\t\t| string;\n}\n\n/** @deprecated Use PaymasterMetadata instead */\nexport type PaymasterMetadataV7 = PaymasterMetadata;\n/** @deprecated Use PaymasterMetadata instead */\nexport type PaymasterMetadataV8 = PaymasterMetadata;\n/** @deprecated Use PaymasterMetadata instead */\nexport type PaymasterMetadataV6 = PaymasterMetadata;\n\n/**\n * Paymaster metadata and supported erc20 tokens\n */\nexport interface SupportedERC20TokensAndMetadata {\n\tpaymasterMetadata: PaymasterMetadata;\n\ttokens: ERC20Token[];\n}\n\n/** @deprecated Use SupportedERC20TokensAndMetadata instead */\nexport type SupportedERC20TokensAndMetadataV7 = SupportedERC20TokensAndMetadata;\n/** @deprecated Use SupportedERC20TokensAndMetadata instead */\nexport type SupportedERC20TokensAndMetadataV8 = SupportedERC20TokensAndMetadata;\n/** @deprecated Use SupportedERC20TokensAndMetadata instead */\nexport type SupportedERC20TokensAndMetadataV6 = SupportedERC20TokensAndMetadata;\n\n/**\n * Paymaster metadata and supported erc20 tokens with exchange rates\n */\nexport interface SupportedERC20TokensAndMetadataWithExchangeRate {\n\tpaymasterMetadata: PaymasterMetadata;\n\ttokens: ERC20TokenWithExchangeRate[];\n}\n\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV7WithExchangeRate = SupportedERC20TokensAndMetadataWithExchangeRate;\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV8WithExchangeRate = SupportedERC20TokensAndMetadataWithExchangeRate;\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV6WithExchangeRate = SupportedERC20TokensAndMetadataWithExchangeRate;\n\n/**\n * Wrapper for a dictionary type\n */\nexport interface Dictionary<T> {\n\t[Key: string]: T;\n}\n\n/**\n * State overrides for a single address, used during gas estimation.\n */\nexport type AddressToState = {\n\t/** Override the account's ETH balance (in wei) */\n\tbalance?: bigint;\n\t/** Override the account's nonce */\n\tnonce?: bigint;\n\t/** Override the account's deployed bytecode */\n\tcode?: string;\n\t/** Completely replace the account's storage */\n\tstate?: Dictionary<string>;\n\t/** Selectively override individual storage slots */\n\tstateDiff?: Dictionary<string>;\n};\n\n/**\n * Wrapper for state overrides for gas estimation\n */\nexport type StateOverrideSet = {\n\t[key: string]: AddressToState;\n};\n\n/**\n * Multiplier to determine the gas price. Higher values result in faster inclusion but higher cost.\n */\nexport enum GasOption {\n\t/** 1x multiplier -- lowest cost, slowest inclusion */\n\tSlow = 1,\n\t/** 1.2x multiplier -- balanced cost and speed */\n\tMedium = 1.2,\n\t/** 1.5x multiplier -- highest cost, fastest inclusion */\n\tFast = 1.5,\n}\nexport enum PolygonChain {\n\tMainnet = 'v2',\n ZkMainnet = 'zkevm',\n\tAmoy = 'amoy',\n\tCardona = 'cardona',\n}\n\nexport type GasPrice = {\n maxPriorityFee:number; //in Gwei\n maxFee:number; //in Gwei\n}\n\nexport type PolygonGasStationJsonRpcResponse = {\n safeLow: GasPrice;\n standard: GasPrice;\n fast: GasPrice;\n estimatedBaseFee:string;\n blockTime:number;\n blockNumber:number;\n};\n\nexport type OnChainIdentifierParamsType = {\n /** Project name */\n project: string\n /** \"Web\" or \"Mobile\" or \"Safe App\" or \"Widget\", defaults to \"Web\". */\n platform?: \"Web\" | \"Mobile\" | \"Safe App\" | \"Widget\",\n /** tool used, defaults to \"abstractionkit\" */\n tool?: string\n /** tool version, defaults to current abstractionkit version */\n toolVersion?: string\n}\n\nexport interface ParallelPaymasterInitValues {\n\tpaymaster: string;\n\tpaymasterVerificationGasLimit: bigint;\n\tpaymasterPostOpGasLimit: bigint;\n\tpaymasterData: string;\n}\n","//credits:https://medium.com/with-orus/the-5-commandments-of-clean-error-handling-in-typescript-93a9cbdf1af5\n\nimport { Dictionary } from \"./types\";\n\n/**\n * General SDK error codes for non-bundler, non-RPC failures.\n */\nexport type BasicErrorCode =\n\t| \"UNKNOWN_ERROR\"\n\t| \"TIMEOUT\"\n\t| \"BAD_DATA\"\n\t| \"BUNDLER_ERROR\"\n\t| \"PAYMASTER_ERROR\";\n\n/**\n * ERC-4337 bundler-specific error codes, mapped from JSON-RPC error numbers\n * defined in the ERC-4337 specification.\n */\nexport type BundlerErrorCode =\n\t| \"INVALID_FIELDS\"\n\t| \"SIMULATE_VALIDATION\"\n\t| \"SIMULATE_PAYMASTER_VALIDATION\"\n\t| \"OPCODE_VALIDATION\"\n\t| \"EXPIRE_SHORTLY\"\n\t| \"REPUTATION\"\n\t| \"INSUFFICIENT_STAKE\"\n\t| \"UNSUPPORTED_SIGNATURE_AGGREGATOR\"\n\t| \"INVALID_SIGNATURE\"\n\t| \"INVALID_USEROPERATION_HASH\"\n\t| \"EXECUTION_REVERTED\";\n\n/**\n * Standard JSON-RPC 2.0 error codes plus Tenderly simulation errors.\n */\nexport type JsonRpcErrorCode =\n\t| \"PARSE_ERROR\"\n\t| \"INVALID_REQUEST\"\n\t| \"METHOD_NOT_FOUND\"\n\t| \"INVALID_PARAMS\"\n\t| \"INTERNAL_ERROR\"\n\t| \"SERVER_ERROR\"\n | \"TENDERLY_SIMULATION_ERROR\";\n\n/**\n * Maps JSON-RPC numeric error codes to human-readable {@link BundlerErrorCode} values.\n */\nexport const BundlerErrorCodeDict: Dictionary<BundlerErrorCode> = {\n\t\"-32602\": \"INVALID_FIELDS\",\n\t\"-32500\": \"SIMULATE_VALIDATION\",\n\t\"-32501\": \"SIMULATE_PAYMASTER_VALIDATION\",\n\t\"-32502\": \"OPCODE_VALIDATION\",\n\t\"-32503\": \"EXPIRE_SHORTLY\",\n\t\"-32504\": \"REPUTATION\",\n\t\"-32505\": \"INSUFFICIENT_STAKE\",\n\t\"-32506\": \"UNSUPPORTED_SIGNATURE_AGGREGATOR\",\n\t\"-32507\": \"INVALID_SIGNATURE\",\n\t\"-32601\": \"INVALID_USEROPERATION_HASH\",\n\t\"-32521\": \"EXECUTION_REVERTED\",\n};\n\n/**\n * Maps JSON-RPC numeric error codes to human-readable {@link JsonRpcErrorCode} values.\n */\nexport const JsonRpcErrorDict: Dictionary<JsonRpcErrorCode> = {\n\t\"-32700\": \"PARSE_ERROR\",\n\t\"-32600\": \"INVALID_REQUEST\",\n\t\"-32601\": \"METHOD_NOT_FOUND\",\n\t\"-32602\": \"INVALID_PARAMS\",\n\t\"-32603\": \"INTERNAL_ERROR\",\n};\n\ntype Jsonable =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| undefined\n\t| readonly Jsonable[]\n\t| { readonly [key: string]: Jsonable }\n\t| { toJSON(): Jsonable };\n\n/**\n * Custom error class for the AbstractionKit SDK. Wraps bundler, JSON-RPC,\n * and general errors with a structured code, optional numeric errno, and\n * arbitrary JSON-serializable context.\n */\nexport class AbstractionKitError extends Error {\n\tpublic readonly code: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode;\n\tpublic readonly context?: Jsonable;\n\tpublic readonly errno?: number;\n\n\t/**\n\t * @param code - Error code identifying the category of failure\n\t * @param message - Human-readable error description\n\t * @param options - Optional cause, numeric errno, and JSON-serializable context\n\t */\n\tconstructor(\n\t\tcode: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode,\n\t\tmessage: string,\n\t\toptions: { cause?: Error; errno?: number; context?: Jsonable } = {},\n\t) {\n\t\tconst { cause, errno, context } = options;\n\n\t\tsuper(message, { cause });\n\t\tthis.name = this.constructor.name;\n\n\t\tthis.code = code;\n\t\tthis.errno = errno;\n\t\tthis.context = context;\n\t}\n\n\t/**\n\t * Returns a JSON string representation of this error including name, code,\n\t * message, cause, errno, and context. Useful in React Native where the\n\t * Error \"cause\" property is not shown in stack traces.\n\t * @returns JSON string of the error\n\t */\n\tstringify(): string {\n\t\treturn JSON.stringify(this, [\n\t\t\t\"name\",\n\t\t\t\"code\",\n\t\t\t\"message\",\n\t\t\t\"cause\",\n\t\t\t\"errno\",\n\t\t\t\"context\",\n\t\t]);\n\t}\n}\n\n/**\n * Coerces an unknown thrown value into an Error instance.\n * If the value is already an Error it is returned as-is; otherwise it is\n * stringified and wrapped in a new Error.\n * @param value - The caught value to normalize\n * @returns An Error instance\n */\nexport function ensureError(value: unknown): Error {\n\tif (value instanceof Error) return value;\n\n\tlet stringified = \"[Unable to stringify the thrown value]\";\n\ttry {\n\t\tstringified = JSON.stringify(value);\n\t} catch {\n\t\t/* empty */\n\t}\n\n\tconst error = new Error(\n\t\t`This value was thrown as is, not through an Error: ${stringified}`,\n\t);\n\treturn error;\n}\n","import { id, AbiCoder, keccak256, JsonRpcProvider, solidityPacked, getAddress } from \"ethers\";\n\nimport {\n\tAbiInputValue,\n\tUserOperationV6,\n\tJsonRpcResponse,\n\tJsonRpcParam,\n\tJsonRpcError,\n\tGasOption,\n\tJsonRpcResult,\n\tUserOperationV7,\n\tUserOperationV8,\n PolygonChain,\n PolygonGasStationJsonRpcResponse,\n UserOperationV9,\n} from \"./types\";\nimport {\n\tAbstractionKitError,\n\tBundlerErrorCodeDict,\n\tensureError,\n} from \"./errors\";\nimport { ENTRYPOINT_V6, ENTRYPOINT_V7, ENTRYPOINT_V8, ENTRYPOINT_V9 } from \"./constants\";\n\nfunction buildDomainSeparator(chainId: bigint, entrypoint: string): string{\n // DOMAIN_NAME = \"ERC4337\"\n const hashed_name = \"0x364da28a5c92bcc87fe97c8813a6c6b8a3a049b0ea0a328fcb0b4f0e00337586\"; \n\n // DOMAIN_VERSION = \"1\"\n const hashed_version = \"0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6\";\n\n // TYPE_HASH = keccak(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n const type_hash = \"0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f\";\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n const encodedUserOperationHash = abiCoder.encode(\n [\"(bytes32,bytes32,bytes32,uint256,address)\"],\n [[type_hash, hashed_name, hashed_version, chainId, entrypoint]],\n );\n return keccak256(encodedUserOperationHash);\n}\n\n/**\n * Compute the UserOperation hash for any supported EntryPoint version.\n * This hash is what gets signed by the account owner(s).\n * Automatically selects the correct packing format based on the entrypoint address.\n *\n * @param useroperation - UserOperation to hash\n * @param entrypointAddress - EntryPoint contract address (determines hash format)\n * @param chainId - Target chain ID\n * @returns The UserOperation hash as a hex string\n */\nexport function createUserOperationHash(\n\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\tentrypointAddress: string,\n\tchainId: bigint,\n): string {\n\tlet packedUserOperationHash: string;\n const abiCoder = AbiCoder.defaultAbiCoder();\n\tlet userOperationHash;\n\tif (entrypointAddress.toLowerCase() == ENTRYPOINT_V6.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV6(useroperation as UserOperationV6),\n\t\t);\n const encodedUserOperationHash = abiCoder.encode(\n [\"bytes32\", \"address\", \"uint256\"],\n [packedUserOperationHash, entrypointAddress, chainId],\n );\n userOperationHash = keccak256(encodedUserOperationHash);\n }else if (entrypointAddress.toLowerCase() == ENTRYPOINT_V7.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV7(useroperation as UserOperationV7),\n\t\t);\n const encodedUserOperationHash = abiCoder.encode(\n [\"bytes32\", \"address\", \"uint256\"],\n [packedUserOperationHash, entrypointAddress, chainId],\n );\n userOperationHash = keccak256(encodedUserOperationHash);\n }else if (entrypointAddress.toLowerCase() == ENTRYPOINT_V8.toLowerCase()) {\n packedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV8(useroperation as UserOperationV8),\n\t\t);\n const domainSeparator = buildDomainSeparator(chainId, entrypointAddress);\n userOperationHash = keccak256(\n \"0x1901\" + domainSeparator.slice(2) + packedUserOperationHash.slice(2));\n }else if (entrypointAddress.toLowerCase() == ENTRYPOINT_V9.toLowerCase()) {\n packedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV9(useroperation as UserOperationV8),\n\t\t);\n const domainSeparator = buildDomainSeparator(chainId, entrypointAddress);\n userOperationHash = keccak256(\n \"0x1901\" + domainSeparator.slice(2) + packedUserOperationHash.slice(2));\n }else{\n throw new RangeError(\"unsupported entrypoint address: \" + entrypointAddress);\n }\n\n\treturn userOperationHash;\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.6 format).\n * Bytes fields (initCode, callData, paymasterAndData) are keccak256-hashed before packing.\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV6(\n\tuseroperation: UserOperationV6,\n): string {\n\tconst useroperationValuesArrayWithHashedByteValues = [\n\t\tuseroperation.sender,\n\t\tuseroperation.nonce,\n\t\tkeccak256(useroperation.initCode),\n\t\tkeccak256(useroperation.callData),\n\t\tuseroperation.callGasLimit,\n\t\tuseroperation.verificationGasLimit,\n\t\tuseroperation.preVerificationGas,\n\t\tuseroperation.maxFeePerGas,\n\t\tuseroperation.maxPriorityFeePerGas,\n\t\tkeccak256(useroperation.paymasterAndData),\n\t];\n\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\tconst packedUserOperation = abiCoder.encode(\n\t\t[\n\t\t\t\"address\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t],\n\t\tuseroperationValuesArrayWithHashedByteValues,\n\t);\n\treturn packedUserOperation;\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.7 format).\n * Reconstructs initCode, accountGasLimits, gasFees, and paymasterAndData from separate fields.\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV7(\n\tuseroperation: UserOperationV7,\n): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\tlet initCode = \"0x\";\n\tif (useroperation.factory != null) {\n\t\tinitCode = useroperation.factory;\n\t\tif (useroperation.factoryData != null) {\n\t\t\tinitCode += useroperation.factoryData.slice(2);\n\t\t}\n\t}\n\n\tconst accountGasLimits =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.verificationGasLimit])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.callGasLimit]).slice(34);\n\n\tconst gasFees =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.maxPriorityFeePerGas])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.maxFeePerGas]).slice(34);\n\n\tlet paymasterAndData = \"0x\";\n\tif (useroperation.paymaster != null) {\n\t\tpaymasterAndData = useroperation.paymaster;\n\t\tif (useroperation.paymasterVerificationGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterVerificationGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterPostOpGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterData != null) {\n\t\t\tpaymasterAndData += useroperation.paymasterData.slice(2);\n\t\t}\n\t}\n\n\tconst useroperationValuesArrayWithHashedByteValues = [\n\t\tuseroperation.sender,\n\t\tuseroperation.nonce,\n\t\tkeccak256(initCode),\n\t\tkeccak256(useroperation.callData),\n\t\taccountGasLimits,\n\t\tuseroperation.preVerificationGas,\n\t\tgasFees,\n\t\tkeccak256(paymasterAndData),\n\t];\n\n\tconst packedUserOperation = abiCoder.encode(\n\t\t[\n\t\t\t\"address\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t],\n\t\tuseroperationValuesArrayWithHashedByteValues,\n\t);\n\treturn packedUserOperation;\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.9 format).\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV9(\n\tuseroperation: UserOperationV8,\n): string {\n return baseCreatePackedUserOperationV8V9(useroperation, true);\n}\n\n/**\n * ABI-encode and pack a UserOperation for hashing (EntryPoint v0.8 format).\n *\n * @param useroperation - UserOperation to pack\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nexport function createPackedUserOperationV8(\n\tuseroperation: UserOperationV8,\n): string {\n return baseCreatePackedUserOperationV8V9(useroperation, false);\n}\n\n/**\n * createPackedUserOperation for the standard entrypointv0.8 hash\n * @param useroperation -useroperation to pack\n * @returns packed UserOperation\n */\nfunction baseCreatePackedUserOperationV8V9(\n\tuseroperation: UserOperationV8 | UserOperationV9, is_v9: boolean\n): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\tlet initCode = \"0x\";\n\tif (useroperation.factory != null) {\n const eip7702Auth = useroperation.eip7702Auth;\n if (eip7702Auth != null && eip7702Auth.address != null){\n initCode = eip7702Auth.address; \n }else{\n initCode = useroperation.factory;\n }\n if (useroperation.factoryData != null) {\n initCode += useroperation.factoryData.slice(2);\n }\n\t}\n\n\tconst accountGasLimits =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.verificationGasLimit])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.callGasLimit]).slice(34);\n\n\tconst gasFees =\n\t\t\"0x\" +\n\t\tabiCoder\n\t\t\t.encode([\"uint128\"], [useroperation.maxPriorityFeePerGas])\n\t\t\t.slice(34) +\n\t\tabiCoder.encode([\"uint128\"], [useroperation.maxFeePerGas]).slice(34);\n\n\tlet paymasterAndData = \"0x\";\n\tif (useroperation.paymaster != null) {\n\t\tpaymasterAndData = useroperation.paymaster;\n\t\tif (useroperation.paymasterVerificationGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterVerificationGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterPostOpGasLimit])\n\t\t\t\t.slice(34);\n\t\t}\n\t\tif (useroperation.paymasterData != null) {\n\t\t\tconst PAYMASTER_SIG_MAGIC = '22e325a297439656';\n\t\t\tif(\n\t\t\t\tis_v9 &&\n\t\t\t\tuseroperation.paymasterData.toLowerCase().endsWith(PAYMASTER_SIG_MAGIC)\n\t\t\t){\n\t\t\t\tconst sigLenHex = useroperation.paymasterData.slice(\n\t\t\t\t\tuseroperation.paymasterData.length - 16 - 4,\n\t\t\t\t\tuseroperation.paymasterData.length - 16\n\t\t\t\t);\n\t\t\t\tconst sigLen = parseInt(sigLenHex, 16);\n\t\t\t\tconst prefixEnd = useroperation.paymasterData.length - 16 - 4 - sigLen * 2;\n\t\t\t\tpaymasterAndData += useroperation.paymasterData.slice(0, prefixEnd).replaceAll(\"0x\", \"\") + PAYMASTER_SIG_MAGIC;\n\t\t\t}else{\n\t\t\t\tpaymasterAndData += useroperation.paymasterData.slice(2);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst useroperationValuesArrayWithHashedByteValues = [\n // PACKED_USEROP_TYPEHASH\n \"0x29a0bca4af4be3421398da00295e58e6d7de38cb492214754cb6a47507dd6f8e\",\n\t\tuseroperation.sender,\n\t\tuseroperation.nonce,\n\t\tkeccak256(initCode),\n\t\tkeccak256(useroperation.callData),\n\t\taccountGasLimits,\n\t\tuseroperation.preVerificationGas,\n\t\tgasFees,\n\t\tkeccak256(paymasterAndData),\n\t];\n\n\tconst packedUserOperation = abiCoder.encode(\n\t\t[\n\t\t\t\"bytes32\",\n\t\t\t\"address\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t\t\"uint256\",\n\t\t\t\"bytes32\",\n\t\t\t\"bytes32\",\n\t\t],\n\t\tuseroperationValuesArrayWithHashedByteValues,\n\t);\n\treturn packedUserOperation;\n}\n\n/**\n * Encode a function call into ABI-encoded calldata.\n *\n * @param functionSelector - 4-byte hex function selector (e.g., \"0xa9059cbb\" for ERC-20 transfer)\n * @param functionInputAbi - Array of ABI type strings (e.g., [\"address\", \"uint256\"])\n * @param functionInputParameters - Array of parameter values matching the ABI types\n * @returns ABI-encoded calldata as a hex string (selector + encoded parameters)\n *\n * @example\n * const transferCallData = createCallData(\n * \"0xa9059cbb\",\n * [\"address\", \"uint256\"],\n * [\"0xRecipientAddress\", 1000000n],\n * );\n */\nexport function createCallData(\n\tfunctionSelector: string,\n\tfunctionInputAbi: string[],\n\tfunctionInputParameters: AbiInputValue[],\n): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n const params: string = abiCoder.encode(\n\t\tfunctionInputAbi,\n\t\tfunctionInputParameters,\n\t);\n\tconst callData = functionSelector + params.slice(2);\n\n\treturn callData;\n}\n\n/**\n * Send a JSON-RPC request to the specified endpoint.\n * Automatically converts bigint values to hex strings in the request body.\n *\n * @param rpcUrl - The JSON-RPC endpoint URL (bundler, node, or paymaster)\n * @param method - The JSON-RPC method name (e.g., \"eth_call\", \"eth_sendUserOperation\")\n * @param params - The JSON-RPC parameters\n * @param headers - Custom HTTP headers (defaults to Content-Type: application/json)\n * @param paramsKeyName - Key name for the params field (defaults to \"params\")\n * @returns The result field from the JSON-RPC response\n * @throws AbstractionKitError if the RPC returns an error\n */\nexport async function sendJsonRpcRequest(\n\trpcUrl: string,\n\tmethod: string,\n\tparams: JsonRpcParam,\n headers: Record<string, string> = { \"Content-Type\": \"application/json\" },\n paramsKeyName: string = \"params\",\n): Promise<JsonRpcResult> {\n\tconst raw = JSON.stringify(\n\t\t{\n\t\t\tmethod: method,\n\t\t\t[paramsKeyName]: params,\n\t\t\tid: new Date().getTime(), //semi unique id\n\t\t\tjsonrpc: \"2.0\",\n\t\t},\n\t\t(key, value) =>\n\t\t\t// change all bigint values to \"0x\" prefixed hex strings\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\ttypeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n\t);\n\tconst requestOptions: RequestInit = {\n\t\tmethod: \"POST\",\n\t\theaders, \n\t\tbody: raw,\n\t\tredirect: \"follow\",\n\t};\n\tconst fetchResult = await fetch(rpcUrl, requestOptions);\n\tconst response = (await fetchResult.json()) as JsonRpcResponse;\n\n\tif (\"result\" in response) {\n\t\treturn response.result as JsonRpcResult;\n\t} else if (\"simulation_results\" in response) {\n\t\treturn response.simulation_results as JsonRpcResult;\n\t} else {\n\t\tconst err = response.error as JsonRpcError;\n\t\tconst codeString = String(err.code);\n\n\t\tif (codeString in BundlerErrorCodeDict) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\tBundlerErrorCodeDict[codeString],\n\t\t\t\terr.message,\n\t\t\t\t{\n\t\t\t\t\terrno: err.code,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\turl: rpcUrl,\n\t\t\t\t\t\trequestOptions: JSON.stringify(requestOptions),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\"UNKNOWN_ERROR\", err.message, {\n\t\t\t\terrno: err.code,\n\t\t\t\tcontext: {\n\t\t\t\t\turl: rpcUrl,\n\t\t\t\t\trequestOptions: JSON.stringify(requestOptions),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * get function selector from the function signature\n * @param functionSignature - example of a function signature \"mint(address)\"\n * @returns fucntion selector - hexstring representation of the first four bytes of the hash of the signature of the function\n *\n * @example\n * const getNonceFunctionSignature = 'getNonce(address,uint192)';\n * const getNonceFunctionSelector = getFunctionSelector(getNonceFunctionSignature);\n */\nexport function getFunctionSelector(functionSignature: string): string {\n\treturn id(functionSignature).slice(0, 10);\n}\n\n/**\n * Fetch the account's nonce from the EntryPoint contract.\n *\n * @param rpcUrl - Ethereum JSON-RPC node URL\n * @param entryPoint - EntryPoint contract address\n * @param account - Smart account address to query\n * @param key - Nonce key (default 0). Different keys allow parallel nonce channels.\n * @returns The current nonce as a bigint\n * @throws AbstractionKitError with code \"BAD_DATA\" if the nonce call fails\n */\nexport async function fetchAccountNonce(\n\trpcUrl: string,\n\tentryPoint: string,\n\taccount: string,\n\tkey: number = 0,\n): Promise<bigint> {\n\tconst getNonceFunctionSignature = \"getNonce(address,uint192)\";\n\tconst getNonceFunctionSelector = getFunctionSelector(\n\t\tgetNonceFunctionSignature,\n\t);\n\tconst getNonceTransactionCallData = createCallData(\n\t\tgetNonceFunctionSelector,\n\t\t[\"address\", \"uint192\"],\n\t\t[account, key],\n\t);\n\n\tconst params = [\n\t\t{\n\t\t\tfrom: \"0x0000000000000000000000000000000000000000\",\n\t\t\tto: entryPoint,\n\t\t\tdata: getNonceTransactionCallData,\n\t\t},\n\t\t\"latest\",\n\t];\n\n\ttry {\n\t\tconst nonce = await sendJsonRpcRequest(rpcUrl, \"eth_call\", params);\n\n\t\tif (typeof nonce === \"string\") {\n\t\t\ttry {\n\t\t\t\treturn BigInt(nonce);\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"getNonce returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"getNonce returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(nonce),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getNonce failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\n/**\n * Fetch current gas prices from a JSON-RPC node.\n * Applies a gas level multiplier to adjust for faster or cheaper inclusion.\n *\n * @param provideRpc - Ethereum JSON-RPC node URL\n * @param gasLevel - Gas price multiplier (default: GasOption.Medium = 1.2x)\n * @returns A tuple of [maxFeePerGas, maxPriorityFeePerGas] as bigints\n */\nexport async function fetchGasPrice(\n\tprovideRpc: string,\n\tgasLevel: GasOption = GasOption.Medium,\n): Promise<[bigint, bigint]> {\n try{\n const jsonRpcProvider = new JsonRpcProvider(provideRpc);\n const feeData = await jsonRpcProvider.getFeeData();\n let maxFeePerGas:bigint;\n let maxPriorityFeePerGas:bigint;\n\n if(feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null){\n maxFeePerGas = BigInt(\n Math.ceil(Number(feeData.maxFeePerGas) * gasLevel),\n );\n maxPriorityFeePerGas = BigInt(\n Math.ceil(Number(feeData.maxPriorityFeePerGas) * gasLevel),\n );\n }else if(feeData.gasPrice != null){\n maxFeePerGas = BigInt(\n Math.ceil(Number(feeData.gasPrice) * gasLevel),\n );\n maxPriorityFeePerGas = maxFeePerGas;\n }\n else{\n maxFeePerGas = BigInt(Math.ceil(1000000000 * gasLevel));\n maxPriorityFeePerGas = maxFeePerGas;\n }\n\n if (maxFeePerGas == 0n) {\n maxFeePerGas = 1n;\n }\n if (maxPriorityFeePerGas == 0n) {\n maxPriorityFeePerGas = 1n;\n }\n\n return [maxFeePerGas, maxPriorityFeePerGas];\n }catch (err) {\n const error = ensureError(err);\n\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"fetching gas prices from node failed.\", {\n cause: error,\n });\n }\n}\n\n/**\n * Fetch current gas prices from the Polygon Gas Station API.\n *\n * @param polygonChain - Target Polygon chain (Mainnet, Amoy, etc.)\n * @param gasLevel - Gas price level (Slow, Medium, Fast)\n * @returns A tuple of [maxFeePerGas, maxPriorityFeePerGas] as bigints\n */\nexport async function fetchGasPricePolygon(\n\tpolygonChain: PolygonChain,\n\tgasLevel: GasOption = GasOption.Medium,\n): Promise<[bigint, bigint]> {\n const gasStationUrl = 'https://gasstation.polygon.technology/' + polygonChain;\n try{\n const fetchResult = await fetch(gasStationUrl);\n const response = (await fetchResult.json()) as PolygonGasStationJsonRpcResponse;\n let gasPrice;\n if(gasLevel == GasOption.Slow){\n gasPrice = response.safeLow; \n }else if(gasLevel == GasOption.Medium){\n gasPrice = response.standard; \n }else{\n gasPrice = response.fast; \n }\n let maxFeePerGas = BigInt(\n Math.ceil(Number(gasPrice.maxFee) * 1000000000),\n );\n let maxPriorityFeePerGas = BigInt(\n Math.ceil(Number(gasPrice.maxPriorityFee) * 1000000000),\n );\n\n if (maxFeePerGas == 0n) {\n maxFeePerGas = 1n;\n }\n if (maxPriorityFeePerGas == 0n) {\n maxPriorityFeePerGas = 1n;\n }\n\n return [maxFeePerGas, maxPriorityFeePerGas];\n }catch (err) {\n const error = ensureError(err);\n\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"fetching gas prices from \" + gasStationUrl + \" failed.\", {\n cause: error,\n });\n }\n}\n\n/**\n * Calculate the maximum gas cost (in wei) that a UserOperation could consume.\n * Uses different formulas for v0.6 (with paymaster multiplier) and v0.7+ UserOperations.\n *\n * @param useroperation - The UserOperation to calculate the max gas cost for\n * @returns Maximum possible gas cost in wei as a bigint\n */\nexport function calculateUserOperationMaxGasCost(\n\tuseroperation: UserOperationV6 | UserOperationV7,\n): bigint {\n\tif (\"initCode\" in useroperation) {\n\t\tconst isPaymasterAndData =\n\t\t\tuseroperation.paymasterAndData != \"0x\" &&\n\t\t\tuseroperation.paymasterAndData != null;\n\t\tconst mul = isPaymasterAndData ? 3n : 0n;\n\t\tconst requiredGas =\n\t\t\tuseroperation.callGasLimit +\n\t\t\tuseroperation.verificationGasLimit * mul +\n\t\t\tuseroperation.preVerificationGas;\n\t\treturn requiredGas * useroperation.maxFeePerGas;\n\t} else {\n\t\tconst requiredGas =\n\t\t\tuseroperation.verificationGasLimit +\n\t\t\tuseroperation.callGasLimit +\n\t\t\t(useroperation.paymasterVerificationGasLimit ?? 0n) +\n\t\t\t(useroperation.paymasterPostOpGasLimit ?? 0n) +\n\t\t\tuseroperation.preVerificationGas;\n\n\t\treturn requiredGas * useroperation.maxFeePerGas;\n\t}\n}\n\n/**\n * Deposit information for an address in the EntryPoint contract.\n */\nexport type DepositInfo = {\n deposit: bigint;\n staked: boolean;\n stake:bigint;\n unstakeDelaySec: bigint;\n withdrawTime: bigint;\n};\n\n/**\n * Get the deposit balance of an address in the EntryPoint contract.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param address - Address to query the deposit for\n * @param entrypointAddress - EntryPoint contract address\n * @returns The deposit balance as a bigint\n */\nexport async function getBalanceOf(\n\tnodeRpcUrl: string,\n\taddress: string,\n\tentrypointAddress: string,\n): Promise<bigint> {\n const depositInfo = await getDepositInfo(\n nodeRpcUrl, address, entrypointAddress\n )\n return depositInfo.deposit;\n}\n\n/**\n * Get the full deposit info of an address from the EntryPoint contract.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param address - Address to query\n * @param entrypointAddress - EntryPoint contract address\n * @returns DepositInfo with deposit, staked, stake, unstakeDelaySec, withdrawTime\n */\nexport async function getDepositInfo(\n\tnodeRpcUrl: string,\n\taddress: string,\n\tentrypointAddress: string,\n): Promise<DepositInfo> {\n\tconst getDepositInfoSelector = \"0x5287ce12\"; //\"getDepositInfo(address)\"\n\tconst getDepositInfoCallData = createCallData(\n\t\tgetDepositInfoSelector,\n\t\t[\"address\"],\n\t\t[address],\n\t);\n\n\tconst params = {\n from: \"0x0000000000000000000000000000000000000000\",\n to: entrypointAddress,\n data: getDepositInfoCallData,\n };\n\n\ttry {\n const depositInfoRequestResult = await sendEthCallRequest(\n nodeRpcUrl, params, \"latest\");\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n\t const decodedCalldata = abiCoder.decode(\n [\"uint256\", \"bool\", \"uint112\", \"uint32\", \"uint48\"],\n depositInfoRequestResult\n );\n\n\n\t\tif (decodedCalldata.length === 5) {\n\t\t\ttry {\n\t\t\t\treturn {\n deposit:BigInt(decodedCalldata[0]),\n staked:Boolean(decodedCalldata[1]),\n stake:BigInt(decodedCalldata[2]),\n unstakeDelaySec:BigInt(decodedCalldata[3]),\n withdrawTime:BigInt(decodedCalldata[4]),\n };\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"getDepositInfo returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"getDepositInfo returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(decodedCalldata),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getDepositInfo failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\ntype EthCallTransaction = {\n\tfrom?: string;\n\tto: string;\n\tgas?: bigint;\n\tgasPrice?: bigint;\n\tvalue?: bigint;\n\tdata?: string;\n};\n\n/**\n * Send an eth_call JSON-RPC request with optional state overrides.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param ethCallTransaction - The call transaction parameters\n * @param blockNumber - Block number or \"latest\"\n * @param stateOverrides - Optional state overrides for the call\n * @returns The call result as a hex string\n */\nexport async function sendEthCallRequest(\n\tnodeRpcUrl: string,\n\tethCallTransaction: EthCallTransaction,\n\tblockNumber: string | bigint,\n stateOverrides?:object\n): Promise<string> {\n let params = [];\n if(stateOverrides == null){\n\t params = [ethCallTransaction, blockNumber];\n }else{\n\t params = [ethCallTransaction, blockNumber, stateOverrides];\n }\n\n\ttry {\n\t\tconst data = await sendJsonRpcRequest(nodeRpcUrl, \"eth_call\", params);\n\n\t\tif (typeof data === \"string\") {\n\t\t\ttry {\n\t\t\t\treturn data;\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"eth_call returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"eth_call returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(data),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_call failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\n/**\n * Send an eth_getCode JSON-RPC request to check deployed bytecode.\n *\n * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n * @param contractAddress - Contract address to query\n * @param blockNumber - Block number or \"latest\"\n * @returns The deployed bytecode as a hex string\n */\nexport async function sendEthGetCodeRequest(\n\tnodeRpcUrl: string,\n\tcontractAddress: string,\n\tblockNumber: string | bigint,\n): Promise<string> {\n\tconst params = [contractAddress, blockNumber];\n\n\ttry {\n\t\tconst data = await sendJsonRpcRequest(nodeRpcUrl, \"eth_getCode\", params);\n\n\t\tif (typeof data === \"string\") {\n\t\t\ttry {\n\t\t\t\treturn data;\n\t\t\t} catch (err) {\n\t\t\t\tconst error = ensureError(err);\n\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"eth_getCode returned ill formed data\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"eth_getCode returned ill formed data\",\n\t\t\t\t{\n\t\t\t\t\tcontext: JSON.stringify(data),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_getCode failed\", {\n\t\t\tcause: error,\n\t\t});\n\t}\n}\n\n/**\n * Check if an address is delegated via EIP-7702 and return the delegatee address.\n * EIP-7702 delegated accounts have bytecode in the format `0xef0100` + 20-byte address.\n *\n * @param accountAddress - The address to check\n * @param providerRpc - Ethereum JSON-RPC node URL\n * @returns The checksummed delegatee address, or `null` if not delegated\n */\nexport async function getDelegatedAddress(\n accountAddress: string,\n providerRpc: string,\n): Promise<string | null> {\n const code = (await sendEthGetCodeRequest(providerRpc, accountAddress, \"latest\")).toLowerCase();\n if (code.length === 48 && code.startsWith(\"0xef0100\")) {\n return getAddress(\"0x\" + code.slice(8));\n }\n return null;\n}\n\n/**\n * Fetch gas prices using either the Polygon Gas Station or a standard JSON-RPC node.\n *\n * @param providerRpc - Ethereum JSON-RPC node URL (used if polygonGasStation is null)\n * @param polygonGasStation - Polygon chain to use for gas station (takes priority)\n * @param gasLevel - Gas price multiplier (default: GasOption.Medium)\n * @returns A tuple of [maxFeePerGas, maxPriorityFeePerGas] as bigints\n */\nexport async function handlefetchGasPrice(\n providerRpc: string | undefined,\n polygonGasStation: PolygonChain | undefined,\n gasLevel: GasOption = GasOption.Medium,\n): Promise<[bigint, bigint]> {\n let maxFeePerGas:bigint;\n let maxPriorityFeePerGas:bigint;\n\n if (polygonGasStation != null) {\n [maxFeePerGas, maxPriorityFeePerGas] = await fetchGasPricePolygon(\n polygonGasStation, gasLevel);\n }\n else if (providerRpc != null) {\n [maxFeePerGas, maxPriorityFeePerGas] =\n await fetchGasPrice(providerRpc, gasLevel);\n } else {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"providerRpc can't be null if maxFeePerGas and \" +\n \"maxPriorityFeePerGas are not overriden\",\n );\n }\n return [maxFeePerGas, maxPriorityFeePerGas];\n}\n","//https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md\n//rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, value, data, access_list, authorization_list, yParity, r, s])\n//authorization_list = [[chain_id, address, nonce, yParity, r, s], ...]\nimport {\n encodeRlp, Wallet, getBytes, toBeArray, keccak256,\n} from \"ethers\";\n\nconst SET_CODE_TX_TYPE = \"0x04\";\n\n/**\n * An EIP-7702 delegation authorization with bigint values.\n * Represents a signed authorization that delegates an EOA's code to a contract.\n */\nexport type Authorization7702 = {\n /** The chain ID the authorization is valid for. */\n chainId: bigint,\n /** The contract address to delegate code from. */\n address: string,\n /** The EOA's nonce at the time of signing. */\n nonce: bigint,\n /** The parity of the signature's y-coordinate (0 or 1). */\n yParity: 0 | 1,\n /** The r component of the ECDSA signature. */\n r: bigint,\n /** The s component of the ECDSA signature. */\n s: bigint\n};\n\n/**\n * An EIP-7702 delegation authorization with hex-encoded string values.\n * Same as {@link Authorization7702} but with all numeric fields as hex strings.\n */\nexport type Authorization7702Hex = {\n /** The chain ID as a hex string. */\n chainId: string,\n /** The contract address to delegate code from. */\n address: string,\n /** The EOA's nonce as a hex string. */\n nonce: string,\n /** The parity of the signature's y-coordinate as a hex string. */\n yParity: string,\n /** The r component of the ECDSA signature as a hex string. */\n r: string,\n /** The s component of the ECDSA signature as a hex string. */\n s: string\n};\n\n/**\n * Creates and signs a legacy (pre-EIP-1559) raw transaction using RLP encoding.\n * @param chainId - The chain ID for replay protection.\n * @param nonce - The sender's transaction nonce.\n * @param gas_price - The gas price in wei.\n * @param gas_limit - The maximum gas units for the transaction.\n * @param destination - The recipient address (42-character hex string).\n * @param value - The amount of ETH to send in wei.\n * @param data - The transaction input data.\n * @param eoaPrivateKey - The sender's private key for signing.\n * @returns The RLP-encoded signed transaction as a hex string.\n */\nexport function createAndSignLegacyRawTransaction(\n chainId: bigint,\n nonce: bigint,\n gas_price: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n eoaPrivateKey: string\n): string {\n if (chainId >= 2**64){\n\t\tthrow new RangeError(\"Invalid chainId.\");\n }\n\n if (nonce >= 2**64){\n\t\tthrow new RangeError(\"Invalid nonce.\");\n }\n\n if (destination.length != 42){\n\t\tthrow new RangeError(\"Invalid destination.\");\n }\n\n let payload = [\n bigintToBytes(nonce),\n bigintToBytes(gas_price),\n bigintToBytes(gas_limit),\n destination,\n bigintToBytes(value),\n data,\n bigintToBytes(chainId),\n bigintToBytes(0n),\n bigintToBytes(0n)\n ]\n \n const txHash = keccak256(encodeRlp(payload));\n \n const eoa = new Wallet(eoaPrivateKey);\n const signature = eoa.signingKey.sign(\n txHash,\n );\n\n payload = [\n bigintToBytes(nonce),\n bigintToBytes(gas_price),\n bigintToBytes(gas_limit),\n destination,\n bigintToBytes(value),\n data,\n bigintToBytes(\n BigInt(signature.yParity + (Number(chainId) * 2) + 35)),\n getBytes(signature.r),\n getBytes(signature.s)\n ]\n const transactionPayload = encodeRlp(payload);\n return transactionPayload;\n}\n\n/**\n * Creates and signs an EIP-7702 delegation authorization.\n * The authorization allows an EOA to delegate its code to a specified contract address.\n *\n * Accepts either a hex-encoded private key string or a signer callback\n * `(hash: string) => Promise<string>` for use with viem, ethers Signers,\n * hardware wallets, or MPC signers.\n *\n * @param chainId - The chain ID the authorization is valid for.\n * @param address - The contract address to delegate code from.\n * @param nonce - The EOA's nonce at the time of signing.\n * @param signer - The EOA's private key or a signing function that returns a 65-byte signature.\n * @returns The signed authorization with all numeric values as hex strings.\n */\nexport function createAndSignEip7702DelegationAuthorization(\n chainId: bigint,\n address: string,\n nonce: bigint,\n signer: string,\n): Authorization7702Hex;\nexport function createAndSignEip7702DelegationAuthorization(\n chainId: bigint,\n address: string,\n nonce: bigint,\n signer: (hash: string) => Promise<string>,\n): Promise<Authorization7702Hex>;\nexport function createAndSignEip7702DelegationAuthorization(\n chainId: bigint,\n address: string,\n nonce: bigint,\n signer: string | ((hash: string) => Promise<string>),\n): Authorization7702Hex | Promise<Authorization7702Hex> {\n const authHash = createEip7702DelegationAuthorizationHash(\n chainId, address, nonce);\n\n if (typeof signer === \"string\") {\n const signature = signHash(authHash, signer);\n return {\n chainId: bigintToHex(chainId),\n address,\n nonce: bigintToHex(nonce),\n yParity: bigintToHex(BigInt(signature.yParity)),\n r: bigintToHex(signature.r),\n s: bigintToHex(signature.s),\n };\n }\n\n return signer(authHash).then((rawSig) => {\n const sig = parseRawSignature(rawSig);\n return {\n chainId: bigintToHex(chainId),\n address,\n nonce: bigintToHex(nonce),\n yParity: bigintToHex(BigInt(sig.yParity)),\n r: bigintToHex(sig.r),\n s: bigintToHex(sig.s),\n };\n });\n}\n\n/**\n * Creates and signs an EIP-7702 delegation revocation authorization.\n * Sets the delegatee address to the zero address, which revokes the delegation\n * and restores the EOA to a normal account.\n *\n * @param chainId - The chain ID the authorization is valid for.\n * @param nonce - The EOA's authorization nonce at the time of signing.\n * @param eoaPrivateKey - The EOA's private key for signing.\n * @returns The signed delegation revocation authorization with hex-encoded values.\n */\nexport function createRevokeDelegationAuthorization(\n chainId: bigint,\n nonce: bigint,\n eoaPrivateKey: string,\n): Authorization7702Hex {\n const ZeroAddress = \"0x0000000000000000000000000000000000000000\";\n return createAndSignEip7702DelegationAuthorization(\n chainId, ZeroAddress, nonce, eoaPrivateKey\n );\n}\n\n/**\n * Computes the keccak256 hash of an EIP-7702 delegation authorization.\n * Uses the MAGIC prefix (0x05) as defined in the EIP-7702 spec.\n * @param chainId - The chain ID the authorization is valid for.\n * @param address - The contract address to delegate code from.\n * @param nonce - The EOA's nonce at the time of signing.\n * @returns The authorization hash as a hex string.\n */\nexport function createEip7702DelegationAuthorizationHash(\n chainId: bigint,\n address: string,\n nonce: bigint\n):string {\n const auth_arr = [\n bigintToBytes(chainId),\n address,\n bigintToBytes(nonce),\n ]\n const encoded_auth = encodeRlp(auth_arr);\n const MAGIC = \"0x05\";\n return keccak256(MAGIC + encoded_auth.slice(2));\n}\n\n/**\n * Signs a hash using an EOA's private key.\n * @param authHash - The hash to sign.\n * @param eoaPrivateKey - The EOA's private key for signing.\n * @returns An object containing the signature components: yParity, r, and s.\n */\nexport function signHash(\n authHash: string,\n eoaPrivateKey: string\n): {yParity: 0 | 1, r:bigint, s: bigint}{\n const eoa = new Wallet(eoaPrivateKey);\n const signature = eoa.signingKey.sign(\n authHash,\n );\n return {\n yParity: signature.yParity,\n r: BigInt(signature.r),\n s: BigInt(signature.s)\n };\n}\n\n/**\n * Creates and signs an EIP-7702 (set-code) raw transaction.\n * Encodes the transaction with a type 0x04 prefix and includes the authorization list.\n * @param chainId - The chain ID for replay protection.\n * @param nonce - The sender's transaction nonce.\n * @param max_priority_fee_per_gas - The maximum priority fee per gas (tip) in wei.\n * @param max_fee_per_gas - The maximum total fee per gas in wei.\n * @param gas_limit - The maximum gas units for the transaction.\n * @param destination - The recipient address (42-character hex string).\n * @param value - The amount of ETH to send in wei.\n * @param data - The transaction input data.\n * @param access_list - The EIP-2930 access list as [address, storageKeys] tuples.\n * @param authorization_list - The list of signed EIP-7702 delegation authorizations.\n * @param eoaPrivateKey - The sender's private key for signing.\n * @returns The signed, RLP-encoded transaction with 0x04 type prefix.\n */\nexport function createAndSignEip7702RawTransaction(\n chainId: bigint,\n nonce: bigint,\n max_priority_fee_per_gas: bigint,\n max_fee_per_gas: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n access_list: [string, string[]][],\n authorization_list: Authorization7702[],\n eoaPrivateKey: string\n): string {\n const txHash = createEip7702TransactionHash(\n chainId,\n nonce,\n max_priority_fee_per_gas,\n max_fee_per_gas,\n gas_limit,\n destination,\n value,\n data,\n access_list,\n authorization_list,\n )\n\n const basePayload = encodeEip7702TransactionBaseList(\n chainId,\n nonce,\n max_priority_fee_per_gas,\n max_fee_per_gas,\n gas_limit,\n destination,\n value,\n data,\n access_list,\n authorization_list,\n );\n\n const signature = signHash(txHash, eoaPrivateKey);\n const payload = basePayload.concat([\n bigintToBytes(BigInt(signature.yParity)),\n bigintToBytes(signature.r),\n bigintToBytes(signature.s)\n ]);\n const transactionPayload = encodeRlp(payload);\n\n return SET_CODE_TX_TYPE + transactionPayload.slice(2);\n}\n\n\n/**\n * Computes the keccak256 hash of an EIP-7702 transaction for signing.\n * @param chainId - The chain ID for replay protection.\n * @param nonce - The sender's transaction nonce.\n * @param max_priority_fee_per_gas - The maximum priority fee per gas (tip) in wei.\n * @param max_fee_per_gas - The maximum total fee per gas in wei.\n * @param gas_limit - The maximum gas units for the transaction.\n * @param destination - The recipient address (42-character hex string).\n * @param value - The amount of ETH to send in wei.\n * @param data - The transaction input data.\n * @param access_list - The EIP-2930 access list as [address, storageKeys] tuples.\n * @param authorization_list - The list of signed EIP-7702 delegation authorizations.\n * @returns The transaction hash as a hex string.\n */\nexport function createEip7702TransactionHash(\n chainId: bigint,\n nonce: bigint,\n max_priority_fee_per_gas: bigint,\n max_fee_per_gas: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n access_list: [string, string[]][],\n authorization_list: Authorization7702[],\n):string {\n const payload = encodeEip7702TransactionBaseList(\n chainId,\n nonce,\n max_priority_fee_per_gas,\n max_fee_per_gas,\n gas_limit,\n destination,\n value,\n data,\n access_list,\n authorization_list,\n );\n\n return keccak256(SET_CODE_TX_TYPE + encodeRlp(payload).slice(2));\n}\n\n/**\n * Encodes the base RLP list for an EIP-7702 transaction (without signature fields).\n * Used internally to build the payload that gets hashed and signed.\n */\nfunction encodeEip7702TransactionBaseList(\n chainId: bigint,\n nonce: bigint,\n max_priority_fee_per_gas: bigint,\n max_fee_per_gas: bigint,\n gas_limit: bigint,\n destination: string,\n value: bigint,\n data: string,\n access_list: [string, string[]][],\n authorization_list: Authorization7702[],\n){\n if (chainId >= 2**64){\n\t\tthrow new RangeError(\"Invalid chainId.\");\n }\n\n if (nonce >= 2**64){\n\t\tthrow new RangeError(\"Invalid nonce.\");\n }\n\n if (destination.length != 42){\n\t\tthrow new RangeError(\"Invalid destination.\");\n }\n\n const encoded_auth_list = encodeAuthList(authorization_list); \n const encoded_access_list = encodeAccessList(access_list);\n\n const payload = [\n bigintToBytes(chainId),\n bigintToBytes(nonce),\n bigintToBytes(max_priority_fee_per_gas),\n bigintToBytes(max_fee_per_gas),\n bigintToBytes(gas_limit),\n destination,\n bigintToBytes(value),\n data,\n encoded_access_list,\n encoded_auth_list,\n ]\n return payload;\n}\n\n/** Encodes an array of EIP-7702 authorizations into RLP-compatible nested arrays. */\nfunction encodeAuthList(authorization_list: Authorization7702[]){\n let encoded_auth_list = [];\n for (const auth of authorization_list){\n if (auth.address.length != 42){\n\t\t\tthrow new RangeError(\"Invalid authorization list address: \" + auth);\n }\n const encoded_auth = [\n bigintToBytes(auth.chainId),\n auth.address,\n bigintToBytes(auth.nonce),\n bigintToBytes(BigInt(auth.yParity)),\n bigintToBytes(auth.r),\n bigintToBytes(auth.s)\n ]\n encoded_auth_list.push(encoded_auth);\n }\n return encoded_auth_list;\n}\n\n/** Encodes an EIP-2930 access list into RLP-compatible nested arrays. */\nfunction encodeAccessList(access_list: [string, string[]][]){\n let encoded_access_list = [];\n for (const [access_add, storage_arr] of access_list){\n if (access_add.length != 42){\n\t\t\tthrow new RangeError(\"Invalid access list address: \" + access_add);\n }\n let encoded_storage_list = [];\n for (const storage of storage_arr){\n if (storage.length != 66){\n\t\t\t throw new RangeError(\"Invalid access list storage: \" + storage);\n }\n encoded_storage_list.push(getBytes(storage));\n }\n encoded_access_list.push(\n [getBytes(access_add), encoded_storage_list]\n );\n }\n return encoded_access_list;\n}\n\n/** Converts a bigint to a Uint8Array of its big-endian byte representation. */\nfunction bigintToBytes(bi: bigint){\n return getBytes(toBeArray(bi))\n}\n\n\n/**\n * Parse a raw ECDSA signature into its components.\n * Supports standard 65-byte (r + s + v) and EIP-2098 64-byte compact formats.\n * @param rawSig - Hex string: 128 chars (EIP-2098 compact), or 130/132 chars (standard with 0x prefix)\n * @returns An object with yParity (0 or 1), r, and s components\n */\nfunction parseRawSignature(rawSig: string): { yParity: 0 | 1; r: bigint; s: bigint } {\n const sig = rawSig.startsWith(\"0x\") ? rawSig.slice(2) : rawSig;\n if (sig.length !== 128 && sig.length !== 130) {\n throw new RangeError(\n `invalid signature length: expected 128 (EIP-2098 compact) or 130 (standard) hex chars, got ${sig.length}`\n );\n }\n const r = BigInt(\"0x\" + sig.slice(0, 64));\n\n if (sig.length === 128) {\n // EIP-2098 compact signature (64 bytes): r (32) + yParity||s (32)\n const yParityAndS = BigInt(\"0x\" + sig.slice(64, 128));\n const yParity = Number((yParityAndS >> 255n) & 1n) as 0 | 1;\n const s = yParityAndS & ((1n << 255n) - 1n);\n return { yParity, r, s };\n }\n\n // Standard 65-byte signature: r (32) + s (32) + v (1)\n const s = BigInt(\"0x\" + sig.slice(64, 128));\n const v = parseInt(sig.slice(128, 130), 16);\n if (v !== 0 && v !== 1 && v !== 27 && v !== 28) {\n throw new RangeError(`invalid signature v value: ${v}`);\n }\n const yParity = (v >= 27 ? v - 27 : v) as 0 | 1;\n return { yParity, r, s };\n}\n\n/**\n * Converts a bigint to a 0x-prefixed hex string with even-length padding.\n * @param value - The bigint value to convert.\n * @returns The hex string representation (e.g., \"0x01\", \"0xff\").\n */\nexport function bigintToHex(value: bigint): string {\n let hex = value.toString(16);\n return hex.length % 2 ? \"0x0\" + hex : \"0x\" + hex;\n}\n","import type {\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n\tUserOperationV9,\n\tGasEstimationResult,\n\tUserOperationByHashResult,\n\tUserOperationReceipt,\n\tUserOperationReceiptResult,\n\tStateOverrideSet,\n\tJsonRpcResult,\n} from \"./types\";\nimport { sendJsonRpcRequest } from \"./utils\";\nimport { AbstractionKitError, ensureError } from \"./errors\";\n\n/**\n * Client for communicating with an ERC-4337 bundler via JSON-RPC.\n * Provides methods for gas estimation, UserOperation submission, and receipt retrieval.\n *\n * Candide's bundler endpoint follows the format:\n * - `https://api.candide.dev/api/v3/{chainId}/{apiKey}` (authenticated)\n * - `https://api.candide.dev/public/v3/{chainId}` (public, no key required)\n *\n * @example\n * const bundler = new Bundler(\"https://api.candide.dev/public/v3/11155111\");\n * const receipt = await bundler.getUserOperationReceipt(userOpHash);\n */\nexport class Bundler {\n\t/** The bundler JSON-RPC endpoint URL */\n\treadonly rpcUrl: string;\n\n\t/** @param rpcUrl - The bundler JSON-RPC endpoint URL */\n\tconstructor(rpcUrl: string) {\n\t\tthis.rpcUrl = rpcUrl;\n\t}\n\n\t/**\n\t * Get the chain ID from the bundler.\n\t * @returns The chain ID as a hex-encoded string\n\t */\n\tasync chainId(): Promise<string> {\n\t\ttry {\n\t\t\tconst chainId = (await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_chainId\",\n\t\t\t\t[],\n\t\t\t)) as string;\n\t\t\tif (typeof chainId === \"string\") {\n\t\t\t\treturn chainId;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundler eth_chainId rpc call failed\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_chainId rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the list of EntryPoint addresses supported by this bundler.\n\t * @returns An array of supported EntryPoint contract addresses\n\t */\n\tasync supportedEntryPoints(): Promise<string[]> {\n\t\ttry {\n\t\t\tconst supportedEntryPoints = (await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_supportedEntryPoints\",\n\t\t\t\t[],\n\t\t\t)) as string[];\n\t\t\treturn supportedEntryPoints;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_supportedEntryPoints rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Estimate gas limits for a UserOperation.\n\t * @param useroperation - UserOperation to estimate gas for\n\t * @param entrypointAddress - Target EntryPoint address\n\t * @param state_override_set - Optional state overrides for estimation\n\t * @returns Gas estimation with callGasLimit, preVerificationGas, and verificationGasLimit\n\t */\n\tasync estimateUserOperationGas(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\t\tentrypointAddress: string,\n\t\tstate_override_set?: StateOverrideSet,\n\t): Promise<GasEstimationResult> {\n\t\ttry {\n\t\t\tlet jsonRpcResult = {} as JsonRpcResult;\n\t\t\tif (typeof state_override_set === \"undefined\") {\n\t\t\t\tjsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\t\tthis.rpcUrl,\n\t\t\t\t\t\"eth_estimateUserOperationGas\",\n\t\t\t\t\t[useroperation, entrypointAddress],\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tjsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\t\tthis.rpcUrl,\n\t\t\t\t\t\"eth_estimateUserOperationGas\",\n\t\t\t\t\t[useroperation, entrypointAddress, state_override_set],\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst res = jsonRpcResult as GasEstimationResult;\n\t\t\tconst gasEstimationResult: GasEstimationResult = {\n\t\t\t\tcallGasLimit: BigInt(res.callGasLimit),\n\t\t\t\tpreVerificationGas: BigInt(res.preVerificationGas),\n\t\t\t\tverificationGasLimit: BigInt(res.verificationGasLimit),\n\t\t\t};\n\t\t\t// `paymasterVerificationGasLimit` and `paymasterPostOpGasLimit`\n\t\t\t// are standard ERC-4337 UserOperation fields but NOT part of the\n\t\t\t// bundler-spec `GasInfo`. Some bundlers return them as a\n\t\t\t// non-standard extension when a paymaster is attached; forwarded\n\t\t\t// here for compatibility. Guarded with `!= null` so spec-compliant\n\t\t\t// bundlers still work.\n\t\t\tif (res.paymasterVerificationGasLimit != null) {\n\t\t\t\tgasEstimationResult.paymasterVerificationGasLimit = BigInt(\n\t\t\t\t\tres.paymasterVerificationGasLimit,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (res.paymasterPostOpGasLimit != null) {\n\t\t\t\tgasEstimationResult.paymasterPostOpGasLimit = BigInt(\n\t\t\t\t\tres.paymasterPostOpGasLimit,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn gasEstimationResult;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_estimateUserOperationGas rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Submit a signed UserOperation to the bundler for on-chain inclusion.\n\t * @param useroperation - The signed UserOperation to submit\n\t * @param entrypointAddress - Target EntryPoint address\n\t * @returns The UserOperation hash\n\t */\n\tasync sendUserOperation(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\t\tentrypointAddress: string,\n\t): Promise<string> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = (await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_sendUserOperation\",\n\t\t\t\t[useroperation, entrypointAddress],\n\t\t\t)) as string;\n\t\t\treturn jsonRpcResult;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_sendUserOperation rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the receipt for a previously submitted UserOperation.\n\t * @param useroperationhash - The hash of the UserOperation to look up\n\t * @returns The receipt, or null if not yet included\n\t */\n\tasync getUserOperationReceipt(\n\t\tuseroperationhash: string,\n\t): Promise<UserOperationReceiptResult> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_getUserOperationReceipt\",\n\t\t\t\t[useroperationhash],\n\t\t\t);\n\t\t\tconst res = jsonRpcResult as UserOperationReceiptResult;\n\n\t\t\tif (res != null) {\n\t\t\t\tconst userOperationReceipt: UserOperationReceipt = {\n\t\t\t\t\t...res.receipt,\n\t\t\t\t\tblockNumber: BigInt(res.receipt.blockNumber),\n\t\t\t\t\tcumulativeGasUsed: BigInt(res.receipt.cumulativeGasUsed),\n\t\t\t\t\tgasUsed: BigInt(res.receipt.gasUsed),\n\t\t\t\t\ttransactionIndex: BigInt(res.receipt.transactionIndex),\n\t\t\t\t\teffectiveGasPrice:\n\t\t\t\t\t\tres.receipt.effectiveGasPrice == undefined\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: BigInt(res.receipt.effectiveGasPrice),\n\t\t\t\t\tlogs: JSON.stringify(res.receipt.logs),\n\t\t\t\t};\n\n\t\t\t\tconst bundlerGetUserOperationReceiptResult: UserOperationReceiptResult =\n\t\t\t\t\t{\n\t\t\t\t\t\t...res,\n\t\t\t\t\t\tnonce: BigInt(res.nonce),\n\t\t\t\t\t\tactualGasCost: BigInt(res.actualGasCost),\n\t\t\t\t\t\tactualGasUsed: BigInt(res.actualGasUsed),\n\t\t\t\t\t\tlogs: JSON.stringify(res.logs),\n\t\t\t\t\t\treceipt: userOperationReceipt,\n\t\t\t\t\t};\n\t\t\t\treturn bundlerGetUserOperationReceiptResult;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_getUserOperationReceipt rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tuseroperationhash: useroperationhash,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Look up a UserOperation by its hash.\n\t * @param useroperationhash - The hash of the UserOperation to look up\n\t * @returns The UserOperation with metadata, or null if not found\n\t */\n\tasync getUserOperationByHash(\n\t\tuseroperationhash: string,\n\t): Promise<UserOperationByHashResult> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"eth_getUserOperationByHash\",\n\t\t\t\t[useroperationhash],\n\t\t\t);\n\t\t\tconst res = jsonRpcResult as UserOperationByHashResult;\n\t\t\tif (res != null) {\n\t\t\t\treturn {\n\t\t\t\t\t...res,\n\t\t\t\t\tblockNumber: res.blockNumber == null ? null : BigInt(res.blockNumber),\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BUNDLER_ERROR\",\n\t\t\t\t\"bundler eth_getUserOperationByHash rpc call failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tuseroperationhash: useroperationhash,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n}\n","import { Bundler } from \"src/Bundler\";\nimport { AbstractionKitError } from \"src/errors\";\nimport { UserOperationReceiptResult } from \"src/types\";\n\n/**\n * Response object returned after submitting a UserOperation to a bundler.\n * Provides the `included()` method to poll for on-chain inclusion.\n *\n * @example\n * const response = await smartAccount.sendUserOperation(userOp, bundlerRpc);\n * const receipt = await response.included();\n */\nexport class SendUseroperationResponse {\n\t/** The hash of the submitted UserOperation */\n\treadonly userOperationHash: string;\n\t/** The bundler client used for polling */\n\treadonly bundler: Bundler;\n\t/** The EntryPoint address the operation was submitted to */\n\treadonly entrypointAddress: string;\n\n\t/**\n\t * @param userOperationHash - The hash of the submitted UserOperation\n\t * @param bundler - The bundler client to use for polling\n\t * @param entrypointAddress - The EntryPoint address\n\t */\n\tconstructor(\n\t\tuserOperationHash: string,\n\t\tbundler: Bundler,\n\t\tentrypointAddress: string,\n\t) {\n\t\tthis.bundler = bundler;\n\t\tthis.userOperationHash = userOperationHash;\n\t\tthis.entrypointAddress = entrypointAddress;\n\t}\n\n\tprivate delay(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\t/**\n\t * Poll the bundler for the UserOperation receipt until it is included on-chain or times out.\n\t *\n\t * @param timeoutInSeconds - Maximum time to wait for inclusion (default: 180s)\n\t * @param requestIntervalInSeconds - Time between polling requests (default: 2s)\n\t * @returns The UserOperation receipt once included\n\t * @throws RangeError if timeout or interval are <= 0, or timeout < interval\n\t * @throws AbstractionKitError with code \"TIMEOUT\" if the operation is not found within the timeout\n\t */\n\tasync included(\n\t\ttimeoutInSeconds: number = 180,\n\t\trequestIntervalInSeconds: number = 2,\n\t): Promise<UserOperationReceiptResult> {\n\t\tif (timeoutInSeconds <= 0 || requestIntervalInSeconds <= 0) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"timeoutInSeconds and requestIntervalInSeconds should be bigger than zero\",\n\t\t\t);\n\t\t}\n\t\tif (timeoutInSeconds < requestIntervalInSeconds) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"timeoutInSeconds can't be less than requestIntervalInSeconds\",\n\t\t\t);\n\t\t}\n\t\tlet count = 0;\n\t\twhile (count <= timeoutInSeconds) {\n\t\t\tawait this.delay(requestIntervalInSeconds * 1000);\n\t\t\tconst res = await this.bundler.getUserOperationReceipt(\n\t\t\t\tthis.userOperationHash,\n\t\t\t);\n\t\t\tif (res == null) {\n\t\t\t\tcount += requestIntervalInSeconds;\n\t\t\t} else {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t}\n\t\tthrow new AbstractionKitError(\"TIMEOUT\", \"can't find useroperation\", {\n\t\t\tcontext: this.userOperationHash,\n\t\t});\n\t}\n}\n","import { SmartAccount } from \"../SmartAccount\";\nimport { BaseUserOperationDummyValues, ENTRYPOINT_V8, ENTRYPOINT_V9 } from \"src/constants\";\nimport { \n createCallData, createUserOperationHash, fetchAccountNonce,\n getDelegatedAddress, getFunctionSelector, handlefetchGasPrice,\n sendJsonRpcRequest\n} from \"../../utils\";\nimport { GasOption, PolygonChain, StateOverrideSet, UserOperationV8, UserOperationV9 } from \"src/types\";\nimport { AbstractionKitError } from \"src/errors\";\nimport {\n Authorization7702Hex, bigintToHex,\n createAndSignEip7702RawTransaction,\n createRevokeDelegationAuthorization,\n} from \"src/utils7702\";\nimport { Bundler } from \"src/Bundler\";\nimport { Wallet, AbiCoder } from \"ethers\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\n\n/**\n * A minimal transaction object for EIP-7702 simple accounts.\n * Represents a single call with a target address, ETH value, and calldata.\n */\nexport interface SimpleMetaTransaction {\n\t/** Target contract or EOA address */\n\tto: string;\n\t/** Amount of native token (in wei) to send with the call */\n\tvalue: bigint;\n\t/** ABI-encoded calldata, or \"0x\" for plain ETH transfers */\n\tdata: string;\n}\n\n/**\n * Optional overrides for UserOperation fields when calling\n * {@link BaseSimple7702Account.baseCreateUserOperation}.\n * Any field left undefined will be auto-determined (nonce fetched from RPC,\n * gas limits estimated via bundler, gas prices fetched from the network).\n */\nexport interface CreateUserOperationOverrides {\n\t/** set the nonce instead of quering the current nonce from the rpc node */\n\tnonce?: bigint;\n\t/** set the callData instead of using the encoding of the provided Metatransactions*/\n\tcallData?: string;\n\t/** set the callGasLimit instead of estimating gas using the bundler*/\n\tcallGasLimit?: bigint;\n\t/** set the verificationGasLimit instead of estimating gas using the bundler*/\n\tverificationGasLimit?: bigint;\n\t/** set the preVerificationGas instead of estimating gas using the bundler*/\n\tpreVerificationGas?: bigint;\n\t/** set the maxFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxFeePerGas?: bigint;\n\t/** set the maxPriorityFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGas?: bigint;\n\n\t/** set the callGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tcallGasLimitPercentageMultiplier?: number;\n\t/** set the verificationGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tverificationGasLimitPercentageMultiplier?: number;\n\t/** set the preVerificationGasPercentageMultiplier instead of estimating gas using the bundler*/\n\tpreVerificationGasPercentageMultiplier?: number;\n\t/** set the maxFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** set the maxPriorityFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGasPercentageMultiplier?: number;\n\n\t/** pass some state overrides for gas estimation\"*/\n\tstate_override_set?: StateOverrideSet;\n\n\t/** Override the dummy signature used during gas estimation */\n\tdummySignature?: string;\n\n\t/** Gas price level preference (e.g., slow, medium, fast) */\n\tgasLevel?: GasOption;\n\t/** Polygon chain identifier for fetching gas prices from Polygon Gas Station */\n\tpolygonGasStation?: PolygonChain;\n\n\t/**\n\t * EIP-7702 authorization fields. When provided, the UserOperation\n\t * will include an authorization tuple that delegates the EOA to\n\t * the account's delegatee contract. If address/nonce are omitted,\n\t * defaults are used (delegateeAddress and fetched from RPC respectively).\n\t */\n eip7702Auth?:{\n chainId: bigint;\n address?: string;\n nonce?: bigint;\n yParity?: string;\n r?: string;\n s?: string;\n };\n\n\tparallelPaymasterInitValues?: {\n\t\t/** set the paymaster contract address */\n\t\tpaymaster: string;\n\t\t/** set the paymaster verification gas limit */\n\t\tpaymasterVerificationGasLimit: bigint;\n\t\t/** set the paymaster post-operation gas limit */\n\t\tpaymasterPostOpGasLimit: bigint;\n\t\t/** set the paymaster data, only valid value is 0x22e325a297439656 */\n\t\tpaymasterData: string;\n\t}\n}\n\n/**\n * Abstract base class for EIP-7702 simple smart accounts.\n * Provides shared logic for creating, signing, and sending UserOperations\n * using the SimpleAccount execute/executeBatch interface. Subclasses\n * (e.g., {@link Simple7702Account}, {@link Simple7702AccountV09}) bind\n * a specific EntryPoint version and delegatee address.\n */\nexport class BaseSimple7702Account extends SmartAccount {\n\t/** Function selector for `execute(address,uint256,bytes)` */\n\tstatic readonly executorFunctionSelector = \"0xb61d27f6\"; //execute\n\t/** ABI parameter types for the single-call `execute` function */\n\tstatic readonly executorFunctionInputAbi: string[] = [\n \"address\", //dest\n \"uint256\", //value\n \"bytes\", //func\n ];\n /** Function selector for `executeBatch((address,uint256,bytes)[])` */\n static readonly batchExecutorFunctionSelector = \"0x34fcd5be\"; //executeBatch\n\t/** ABI parameter types for the batch `executeBatch` function */\n\tstatic readonly batchExecutorFunctionInputAbi = [\"(address,uint256,bytes)[]\"];\n /** Dummy ECDSA signature used during gas estimation */\n static readonly dummySignature =\n \"0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c\";\n\n\t/** The EntryPoint contract address this account targets */\n\treadonly entrypointAddress: string;\n\t/** The EIP-7702 delegatee (implementation) contract address */\n\treadonly delegateeAddress: string;\n\n\t/**\n\t * @param accountAddress - The EOA address that will be delegated via EIP-7702\n\t * @param entrypointAddress - The EntryPoint contract address\n\t * @param delegateeAddress - The EIP-7702 delegatee (implementation) contract address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n entrypointAddress: string,\n delegateeAddress:string,\n\t) {\n\t\tsuper(accountAddress);\n this.entrypointAddress = entrypointAddress;\n this.delegateeAddress = delegateeAddress;\n\t}\n\n /**\n * Check if this EOA is delegated to the expected delegatee address via EIP-7702.\n * Returns `true` only when delegated to `this.delegateeAddress`.\n * Use `getDelegatedAddress()` directly to get the raw delegatee address.\n *\n * @param providerRpc - Ethereum JSON-RPC node URL\n * @returns `true` if delegated to the expected address, `false` otherwise\n */\n public async isDelegatedToThisAccount(providerRpc: string): Promise<boolean> {\n const address = await getDelegatedAddress(this.accountAddress, providerRpc);\n if (address === null) return false;\n return address.toLowerCase() === this.delegateeAddress.toLowerCase();\n }\n\n /**\n * Create a signed raw EIP-7702 transaction that revokes the delegation,\n * restoring the EOA to a normal account. The transaction is type 0x04\n * with a zero-address authorization.\n *\n * Cannot be done via UserOp — the authorization_list is processed before\n * execution, removing the account's code mid-transaction.\n *\n * Authorization nonce defaults to txNonce + 1 because EIP-7702 increments\n * the sender's transaction nonce before processing the authorization list.\n *\n * @param eoaPrivateKey - The EOA's private key (signs both auth and tx)\n * @param providerRpc - JSON-RPC endpoint for nonce, gas price, chain ID\n * @param overrides - Optional overrides for transaction fields\n * @returns Signed raw transaction hex, ready for `eth_sendRawTransaction`\n */\n public async createRevokeDelegationTransaction(\n eoaPrivateKey: string,\n providerRpc: string,\n overrides: {\n nonce?: bigint;\n authorizationNonce?: bigint;\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n gasLimit?: bigint;\n chainId?: bigint;\n } = {},\n ): Promise<string> {\n // Verify delegation state before revoking\n const delegatedTo = await getDelegatedAddress(this.accountAddress, providerRpc);\n if (delegatedTo === null) {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"Account is not delegated — nothing to revoke\",\n );\n }\n if (delegatedTo.toLowerCase() !== this.delegateeAddress.toLowerCase()) {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"Account is delegated to a different address (\" +\n delegatedTo + \"), not \" + this.delegateeAddress +\n \" — use the correct account class to revoke\",\n );\n }\n\n const results: {\n nonce?: bigint;\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n chainId?: bigint;\n } = {};\n\n // Build parallel fetch list\n const ops: Promise<void>[] = [];\n\n if (overrides.nonce == null) {\n ops.push(\n sendJsonRpcRequest(\n providerRpc, \"eth_getTransactionCount\",\n [this.accountAddress, \"latest\"]\n ).then((v) => { results.nonce = BigInt(v as string); })\n );\n }\n\n if (overrides.maxFeePerGas == null || overrides.maxPriorityFeePerGas == null) {\n ops.push(\n handlefetchGasPrice(providerRpc, undefined)\n .then(([fee, tip]) => {\n results.maxFeePerGas = fee;\n results.maxPriorityFeePerGas = tip;\n })\n );\n }\n\n if (overrides.chainId == null) {\n ops.push(\n sendJsonRpcRequest(providerRpc, \"eth_chainId\", [])\n .then((v) => { results.chainId = BigInt(v as string); })\n );\n }\n\n if (ops.length > 0) await Promise.all(ops);\n\n const txNonce = overrides.nonce ?? results.nonce ?? 0n;\n const maxFeePerGas = overrides.maxFeePerGas ?? results.maxFeePerGas ?? 0n;\n const maxPriorityFeePerGas = overrides.maxPriorityFeePerGas ?? results.maxPriorityFeePerGas ?? 0n;\n const chainId = overrides.chainId ?? results.chainId ?? 0n;\n\n // Authorization nonce = txNonce + 1 by default\n // (tx nonce is incremented before authorization processing in EIP-7702)\n const authNonce = overrides.authorizationNonce ?? (txNonce + 1n);\n\n // Create undelegation authorization (returns Authorization7702Hex)\n const authHex = createRevokeDelegationAuthorization(\n chainId, authNonce, eoaPrivateKey\n );\n\n // Convert Authorization7702Hex -> Authorization7702 for raw tx builder\n const auth = {\n chainId: BigInt(authHex.chainId),\n address: authHex.address,\n nonce: BigInt(authHex.nonce),\n yParity: (BigInt(authHex.yParity) === 0n ? 0 : 1) as 0 | 1,\n r: BigInt(authHex.r),\n s: BigInt(authHex.s),\n };\n\n const gasLimit = overrides.gasLimit ?? 60_000n;\n\n return createAndSignEip7702RawTransaction(\n chainId,\n txNonce,\n maxPriorityFeePerGas,\n maxFeePerGas,\n gasLimit,\n this.accountAddress,\n 0n,\n \"0x\",\n [],\n [auth],\n eoaPrivateKey,\n );\n }\n\n /**\n\t * Encode calldata for a single `execute(address,uint256,bytes)` call.\n\t * @param to - Target contract or EOA address\n\t * @param value - Amount of native token (in wei) to transfer\n\t * @param data - ABI-encoded calldata for the target\n\t * @returns Encoded calldata for the execute function\n\t */\n public static createAccountCallData(\n\t\tto: string,\n\t\tvalue: bigint,\n\t\tdata: string,\n\t): string {\n\t\tconst executorFunctionInputParameters = [to, value, data];\n\t\tconst callData = createCallData(\n\t\t\tBaseSimple7702Account.executorFunctionSelector,\n\t\t\tBaseSimple7702Account.executorFunctionInputAbi,\n\t\t\texecutorFunctionInputParameters,\n\t\t);\n\t\treturn callData;\n }\n \n /**\n\t * Encode calldata for a single {@link SimpleMetaTransaction} using `execute`.\n\t * @param metaTransaction - The transaction to encode\n\t * @returns Encoded calldata for the execute function\n\t */\n public static createAccountCallDataSingleTransaction(\n\t\tmetaTransaction: SimpleMetaTransaction,\n\t): string {\n\t\tconst value = metaTransaction.value ?? 0;\n\t\tconst data = metaTransaction.data ?? \"0x\";\n\t\tconst executorFunctionCallData = BaseSimple7702Account.createAccountCallData(\n\t\t\tmetaTransaction.to,\n\t\t\tvalue,\n\t\t\tdata,\n\t\t);\n\t\treturn executorFunctionCallData;\n\t}\n\n /**\n\t * Encode calldata for a batch of {@link SimpleMetaTransaction}s using `executeBatch`.\n\t * @param transactions - Array of transactions to batch\n\t * @returns Encoded calldata for the executeBatch function\n\t */\n\tpublic static createAccountCallDataBatchTransactions(\n transactions: SimpleMetaTransaction[]\n ): string {\n const encodedTransactions = [transactions.map(\n transaction => [transaction.to, transaction.value, transaction.data]\n )];\n const callData = createCallData(\n\t\t\tBaseSimple7702Account.batchExecutorFunctionSelector,\n\t\t\tBaseSimple7702Account.batchExecutorFunctionInputAbi,\n\t\t\tencodedTransactions,\n\t\t);\n\t\treturn callData;\n\t}\n \n /**\n\t * Build an unsigned UserOperation from one or more transactions.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and\n\t * optionally includes EIP-7702 authorization. All auto-determined\n\t * values can be overridden.\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned UserOperation (v8 or v9)\n\t */\n protected async baseCreateUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8 | UserOperationV9> {\n if (transactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one transaction\");\n\t\t}\n let nonce:bigint | null = null;\n\t\tlet nonceOp:Promise<bigint> | null = null;\n\n if (overrides.nonce == null) {\n\t\t\tif (providerRpc != null) {\n\t\t\t\tnonceOp = fetchAccountNonce(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc cant't be null if nonce is not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnonce = overrides.nonce;\n\t\t}\n\n if (\n\t\t\ttypeof overrides.maxFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxFeePerGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxPriorityFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxPriorityFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas override can't be negative\");\n\t\t}\n let maxFeePerGas = BaseUserOperationDummyValues.maxFeePerGas;\n\t\tlet maxPriorityFeePerGas =\n\t\t\tBaseUserOperationDummyValues.maxPriorityFeePerGas;\n\n let gasPriceOp:Promise<[bigint, bigint]> | null = null;\n if (\n\t\t\toverrides.maxFeePerGas == null ||\n\t\t\toverrides.maxPriorityFeePerGas == null\n\t\t) {\n gasPriceOp = handlefetchGasPrice(\n providerRpc, overrides.polygonGasStation, overrides.gasLevel\n )\n }\n \n let eip7702AuthChainId:bigint|null = null;\n let eip7702AuthAddress:string|null = null;\n let eip7702AuthNonce:bigint|null = null;\n let skipEip7702Auth = false;\n\n if(overrides.eip7702Auth != null){\n eip7702AuthChainId = overrides.eip7702Auth.chainId;\n eip7702AuthAddress = overrides.eip7702Auth.address??\n this.delegateeAddress;\n eip7702AuthNonce = overrides.eip7702Auth.nonce??null;\n }\n\n // When eip7702Auth is provided, check delegation status in parallel.\n // Best-effort: if the check fails, proceed as if not delegated.\n let delegationCheckOp:Promise<string|null>|null = null;\n if(overrides.eip7702Auth != null && providerRpc != null){\n delegationCheckOp = getDelegatedAddress(this.accountAddress, providerRpc)\n .catch(() => null);\n }\n\n if(overrides.eip7702Auth != null && eip7702AuthNonce == null){\n //check for eip7702AuthNonce\n let eip7702AuthNonceOp;\n if (providerRpc != null) {\n eip7702AuthNonceOp = sendJsonRpcRequest(\n providerRpc,\n \"eth_getTransactionCount\",\n [this.accountAddress, \"latest\"]\n );\n } else {\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"providerRpc cant't be null if eoaDelegatorNonce \" +\n \"is not overriden\",\n );\n }\n\n // Build array of all parallel operations\n const ops: Promise<unknown>[] = [eip7702AuthNonceOp];\n if(nonceOp != null) ops.push(nonceOp);\n if(gasPriceOp != null) ops.push(gasPriceOp);\n if(delegationCheckOp != null) ops.push(delegationCheckOp);\n\n const values = await Promise.all(ops);\n let idx = 0;\n eip7702AuthNonce = BigInt(values[idx++] as string);\n if(nonceOp != null) nonce = values[idx++] as bigint;\n if(gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++] as [bigint, bigint];\n if(delegationCheckOp != null){\n const delegatedTo = values[idx++] as string|null;\n if(delegatedTo != null &&\n delegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()){\n skipEip7702Auth = true;\n }\n }\n }else if(overrides.eip7702Auth != null){\n // eip7702AuthNonce was provided, but still need delegation check + other ops\n const ops: Promise<unknown>[] = [];\n if(nonceOp != null) ops.push(nonceOp);\n if(gasPriceOp != null) ops.push(gasPriceOp);\n if(delegationCheckOp != null) ops.push(delegationCheckOp);\n\n if(ops.length > 0){\n const values = await Promise.all(ops);\n let idx = 0;\n if(nonceOp != null) nonce = values[idx++] as bigint;\n if(gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++] as [bigint, bigint];\n if(delegationCheckOp != null){\n const delegatedTo = values[idx++] as string|null;\n if(delegatedTo != null &&\n delegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()){\n skipEip7702Auth = true;\n }\n }\n }\n }else{\n //don't check for eip7702AuthNonce\n if(gasPriceOp != null && nonceOp != null){\n await Promise.all([nonceOp, gasPriceOp]).then((values) => {\n nonce = values[0];\n [maxFeePerGas, maxPriorityFeePerGas] = values[1];\n });\n }else if(gasPriceOp != null){\n [maxFeePerGas, maxPriorityFeePerGas] = await gasPriceOp;\n }else if(nonceOp != null){\n nonce = await nonceOp;\n }\n }\n\t\tmaxFeePerGas = overrides.maxFeePerGas ??\n BigInt(\n Math.floor(\n Number(maxFeePerGas) *\n (((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n );\n\t\tmaxPriorityFeePerGas = overrides.maxPriorityFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxPriorityFeePerGas) *\n\t\t\t\t\t(((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n\t\t\t);\n if(nonce == null){\n\t\t\tthrow new RangeError(\"failed to determine nonce\");\n }\n else if (nonce < 0n) {\n\t\t\tthrow new RangeError(\"nonce can't be negative\");\n\t\t}\n \n let callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tif (transactions.length == 1) {\n\t\t\t\tcallData = BaseSimple7702Account.createAccountCallDataSingleTransaction(\n\t\t\t\t\ttransactions[0],\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcallData = BaseSimple7702Account.createAccountCallDataBatchTransactions(\n\t\t\t\t\ttransactions,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n \n\t\tlet userOperation:UserOperationV8 | UserOperationV9;\n if(overrides.eip7702Auth != null && !skipEip7702Auth){\n const yParity = overrides.eip7702Auth.yParity?? \"0x0\";\n if(\n yParity != \"0x0\" && yParity != \"0x00\" &&\n yParity != \"0x1\" && yParity != \"0x01\"\n ){\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"invalide yParity value for eoaDelegatorSignature. \" +\n \"must be '0x0' or '0x1'\"\n );\n }\n\n const authorization:Authorization7702Hex= {\n chainId: bigintToHex(eip7702AuthChainId as bigint),\n address: eip7702AuthAddress as string,\n nonce: bigintToHex(eip7702AuthNonce as bigint),\n yParity: yParity,\n r: overrides.eip7702Auth.r??\n \"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2\",\n s: overrides.eip7702Auth.s??\n \"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd\",\n } \n userOperation = {\n ...BaseUserOperationDummyValues,\n sender: this.accountAddress,\n nonce: nonce,\n callData: callData,\n maxFeePerGas: maxFeePerGas,\n maxPriorityFeePerGas: maxPriorityFeePerGas,\n factory: \"0x7702\",\n factoryData: null,\n paymaster: null,\n paymasterVerificationGasLimit: null,\n paymasterPostOpGasLimit: null,\n paymasterData: null,\n eip7702Auth: authorization,\n };\n }else{\n userOperation = {\n ...BaseUserOperationDummyValues,\n sender: this.accountAddress,\n nonce: nonce,\n callData: callData,\n maxFeePerGas: maxFeePerGas,\n maxPriorityFeePerGas: maxPriorityFeePerGas,\n factory: null,\n factoryData: null,\n paymaster: null,\n paymasterVerificationGasLimit: null,\n paymasterPostOpGasLimit: null,\n paymasterData: null,\n eip7702Auth: null,\n };\n }\n let preVerificationGas = BaseUserOperationDummyValues.preVerificationGas;\n\t\tlet verificationGasLimit =\n\t\t\tBaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n const parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n if(parallelPaymasterInitValues != null){\n if(this.entrypointAddress != ENTRYPOINT_V9){\n throw new RangeError(\n \"parallelPaymasterInitValues only works with ep v0.9\"\n );\n }\n userOperation.paymaster = parallelPaymasterInitValues.paymaster;\n userOperation.paymasterVerificationGasLimit =\n parallelPaymasterInitValues.paymasterVerificationGasLimit;\n userOperation.paymasterPostOpGasLimit =\n parallelPaymasterInitValues.paymasterPostOpGasLimit;\n userOperation.paymasterData =\n parallelPaymasterInitValues.paymasterData;\n }\n\n\t\t\tif (bundlerRpc != null) {\n\t\t\t\tuserOperation.callGasLimit = 0n;\n\t\t\t\tuserOperation.verificationGasLimit = 0n;\n\t\t\t\tuserOperation.preVerificationGas = 0n;\n\t\t\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\t\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\t\t\tuserOperation.maxFeePerGas = 0n;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\n\t\t\t\tlet userOperationToEstimate: UserOperationV8 | UserOperationV9;\n userOperationToEstimate = { ...userOperation };\n\n\t\t\t\tuserOperation.signature = overrides.dummySignature??\n BaseSimple7702Account.dummySignature;;\n\t\t\t\t[preVerificationGas, verificationGasLimit, callGasLimit] =\n\t\t\t\t\tawait this.baseEstimateUserOperationGas(\n\t\t\t\t\t\tuserOperationToEstimate,\n\t\t\t\t\t\tbundlerRpc,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstateOverrideSet: overrides.state_override_set,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\tverificationGasLimit += 55_000n;\n\n\t\t\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc cant't be null if preVerificationGas,\" +\n\t\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\ttypeof overrides.preVerificationGas === \"bigint\" &&\n\t\t\toverrides.preVerificationGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"preVerificationGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.verificationGasLimit === \"bigint\" &&\n\t\t\toverrides.verificationGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"verificationGasLimit override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.callGasLimit === \"bigint\" &&\n\t\t\toverrides.callGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"callGasLimit override can't be negative\");\n\t\t}\n\n\t\tuserOperation.preVerificationGas = overrides.preVerificationGas ??\n BigInt(\n Math.floor(\n Number(preVerificationGas) *\n (((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100)\n ),\n );\n\n\t\tuserOperation.verificationGasLimit = overrides.verificationGasLimit ??\n BigInt(\n Math.floor(\n Number(verificationGasLimit) *\n (((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n ),\n );\n\n\t\tuserOperation.callGasLimit = overrides.callGasLimit ??\n BigInt(\n Math.floor(\n Number(callGasLimit) *\n (((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n ),\n );\n\n\t\treturn userOperation;\n }\n \n /**\n\t * Estimate gas limits for a UserOperation via the bundler.\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides\n\t * @param overrides.stateOverrideSet - State overrides to apply during estimation\n\t * @param overrides.dummySignature - Custom dummy ECDSA signature for estimation\n\t * @returns A promise resolving to `[preVerificationGas, verificationGasLimit, callGasLimit]`\n\t */\n protected async baseEstimateUserOperationGas(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t dummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\tuserOperation.signature = overrides.dummySignature??\n BaseSimple7702Account.dummySignature;\n\t\t \n\t\tconst bundler = new Bundler(bundlerRpc);\n\n\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\tuserOperation.maxFeePerGas = 0n;\n\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\toverrides.stateOverrideSet,\n\t\t);\n\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\n\t\tconst preVerificationGas = BigInt(estimation.preVerificationGas);\n\n\t\tconst verificationGasLimit = BigInt(estimation.verificationGasLimit);\n\n\t\tconst callGasLimit = BigInt(estimation.callGasLimit);\n\n\t\treturn [preVerificationGas, verificationGasLimit, callGasLimit];\n\t}\n \n /**\n\t * Sign a UserOperation with an EOA private key.\n\t * Computes the UserOperation hash and produces an ECDSA signature.\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key of the EOA signer\n\t * @param chainId - Target chain ID\n\t * @returns Hex-encoded ECDSA signature\n\t */\n protected baseSignUserOperation(\n\t\tuseroperation: UserOperationV8 | UserOperationV9,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n ): string {\n\t\tconst userOperationHash = createUserOperationHash(\n\t\t\tuseroperation,\n this.entrypointAddress,\n\t\t\tchainId,\n );\n\n\t\tconst wallet = new Wallet(privateKey);\n return wallet.signingKey.sign(userOperationHash).serialized;\n\t}\n \n /**\n\t * Submit a signed UserOperation to a bundler for on-chain inclusion.\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tprotected async baseSendUserOperation(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = new Bundler(bundlerRpc);\n\t\tconst sendUserOperationRes = await bundler.sendUserOperation(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\n\t\treturn new SendUseroperationResponse(\n\t\t\tsendUserOperationRes,\n\t\t\tbundler,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\t}\n\n /**\n\t * Prepend a token `approve` call to existing calldata for a token paymaster.\n\t * Instance wrapper for {@link BaseSimple7702Account.prependTokenPaymasterApproveToCallDataStatic}.\n\t * @param callData - Existing encoded calldata (execute or executeBatch)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended as a batch\n\t */\n\tpublic prependTokenPaymasterApproveToCallData(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\treturn BaseSimple7702Account.prependTokenPaymasterApproveToCallDataStatic(\n\t\t\tcallData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tapproveAmount,\n\t\t);\n\t}\n\n /**\n\t * Prepend a token `approve` call to existing calldata for a token paymaster.\n\t * Decodes the existing calldata, prepends an ERC-20 approve transaction,\n\t * and re-encodes as a batch via `executeBatch`.\n\t * @param callData - Existing encoded calldata (execute or executeBatch)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended as a batch\n\t */\n\tpublic static prependTokenPaymasterApproveToCallDataStatic(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\tconst approveFunctionSignature = \"approve(address,uint256)\";\n\t\tconst approveFunctionSelector = getFunctionSelector(\n\t\t\tapproveFunctionSignature,\n\t\t);\n\t\tconst approveCallData = createCallData(\n\t\t\tapproveFunctionSelector,\n\t\t\t[\"address\", \"uint256\"],\n\t\t\t[paymasterAddress, approveAmount],\n\t\t);\n\t\tconst approveMetatransaction: SimpleMetaTransaction = {\n\t\t\tto: tokenAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: approveCallData,\n\t\t};\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n let decodedMetaTransactions:SimpleMetaTransaction[];\n\t\tif (callData.startsWith(BaseSimple7702Account.batchExecutorFunctionSelector)) {\n const decodedParamsArray = abiCoder.decode(\n BaseSimple7702Account.batchExecutorFunctionInputAbi,\n \"0x\" + callData.slice(10)\n )[0] as [];\n decodedMetaTransactions = decodedParamsArray.map(decodedParams =>({\n to: decodedParams[0] as string,\n value: BigInt(decodedParams[1] as string),\n data: typeof decodedParams[2] !== \"string\"?\n new TextDecoder().decode(decodedParams[2]):decodedParams[2]\n }));\n } else if(callData.startsWith(BaseSimple7702Account.executorFunctionSelector)) {\n const decodedParams = abiCoder.decode(\n BaseSimple7702Account.executorFunctionInputAbi,\n \"0x\" + callData.slice(10)\n );\n decodedMetaTransactions = [{\n to: decodedParams[0] as string,\n value: BigInt(decodedParams[1] as string),\n data: typeof decodedParams[2] !== \"string\"?\n new TextDecoder().decode(decodedParams[2]):decodedParams[2]\n }];\n }else{\n throw new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Invalid calldata, should start with \" +\n\t\t\t\t\tBaseSimple7702Account.batchExecutorFunctionSelector +\n\t\t\t\t\t\" or \" +\n\t\t\t\t\tBaseSimple7702Account.executorFunctionSelector,\n\t\t\t\t{\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tcallData: callData,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n }\n decodedMetaTransactions.unshift(approveMetatransaction);\n return BaseSimple7702Account.createAccountCallDataBatchTransactions(\n decodedMetaTransactions\n )\n }\n}\n\n/**\n * EIP-7702 simple smart account targeting EntryPoint v0.8\n * (`0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108`).\n * Wraps {@link BaseSimple7702Account} with concrete types for\n * {@link UserOperationV8} and sensible defaults for the delegatee address.\n */\nexport class Simple7702Account extends BaseSimple7702Account {\n\tstatic readonly DEFAULT_DELEGATEE_ADDRESS = \"0xe6Cae83BdE06E4c305530e199D7217f42808555B\";\n\n\t/**\n\t * @param accountAddress - The EOA address that will be delegated via EIP-7702\n\t * @param overrides - Optional overrides for entrypoint and delegatee addresses\n\t * @param overrides.entrypointAddress - Custom EntryPoint address (defaults to EntryPoint v0.8)\n\t * @param overrides.delegateeAddress - Custom delegatee contract address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n overrides: {\n\t\t\tentrypointAddress?: string;\n delegateeAddress?:string;\n\t\t} = {},\n\t) {\n\t\tsuper(\n accountAddress,\n overrides.entrypointAddress ?? ENTRYPOINT_V8,\n overrides.delegateeAddress ?? Simple7702Account.DEFAULT_DELEGATEE_ADDRESS\n );\n\t}\n\n /**\n\t * Create a {@link UserOperationV8} for EntryPoint v0.8.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and returns\n\t * an unsigned UserOperation. All auto-determined values can be overridden.\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned {@link UserOperationV8}\n\t */\n public async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8> {\n return this.baseCreateUserOperation(\n transactions,\n providerRpc,\n bundlerRpc,\n overrides,\n );\n }\n\n /**\n\t * Estimate gas limits for a {@link UserOperationV8}.\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides\n\t * @param overrides.stateOverrideSet - State overrides to apply during estimation\n\t * @param overrides.dummySignature - Custom dummy signature for estimation\n\t * @returns A promise resolving to `[preVerificationGas, verificationGasLimit, callGasLimit]`\n\t */\n public async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV8,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t dummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n return this.baseEstimateUserOperationGas(\n userOperation,\n bundlerRpc,\n overrides\n );\n }\n\n /**\n\t * Sign a {@link UserOperationV8} with an EOA private key.\n\t * Computes the UserOperation hash and produces an ECDSA signature.\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key of the EOA signer\n\t * @param chainId - Target chain ID\n\t * @returns Hex-encoded ECDSA signature\n\t */\n public signUserOperation(\n\t\tuseroperation: UserOperationV8,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n ): string {\n return this.baseSignUserOperation(useroperation, privateKey, chainId);\n }\n\n /**\n\t * Send a signed {@link UserOperationV8} to a bundler for on-chain inclusion.\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV8,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n return this.baseSendUserOperation(userOperation, bundlerRpc);\n }\n}\n","import { StateOverrideSet, UserOperationV9 } from \"src/types\";\nimport { BaseSimple7702Account, CreateUserOperationOverrides, SimpleMetaTransaction } from \"./Simple7702Account\";\nimport { ENTRYPOINT_V9 } from \"src/constants\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\n\n/**\n * EIP-7702 simple smart account targeting EntryPoint v0.9\n * (`0x433709009B8330FDa32311DF1C2AFA402eD8D009`).\n * Extends {@link BaseSimple7702Account} with concrete types for\n * {@link UserOperationV9} and sensible defaults for the delegatee address.\n */\nexport class Simple7702AccountV09 extends BaseSimple7702Account {\n\tstatic readonly DEFAULT_DELEGATEE_ADDRESS = \"0xa46cc63eBF4Bd77888AA327837d20b23A63a56B5\";\n\n\t/**\n\t * @param accountAddress - The EOA address that will be delegated via EIP-7702\n\t * @param overrides - Optional overrides for entrypoint and delegatee addresses\n\t * @param overrides.entrypointAddress - Custom EntryPoint address (defaults to EntryPoint v0.9)\n\t * @param overrides.delegateeAddress - Custom delegatee contract address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n overrides: {\n\t\t\tentrypointAddress?: string;\n delegateeAddress?:string;\n\t\t} = {},\n\t) {\n\t\tsuper(\n accountAddress,\n overrides.entrypointAddress ?? ENTRYPOINT_V9,\n overrides.delegateeAddress ?? Simple7702AccountV09.DEFAULT_DELEGATEE_ADDRESS\n );\n\t}\n\n /**\n\t * Create a {@link UserOperationV9} for EntryPoint v0.9.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and returns\n\t * an unsigned UserOperation. All auto-determined values can be overridden.\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned {@link UserOperationV9}\n\t */\n public async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV9> {\n return this.baseCreateUserOperation(\n transactions,\n providerRpc,\n bundlerRpc,\n overrides,\n );\n }\n\n /**\n\t * Estimate gas limits for a {@link UserOperationV9}.\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides\n\t * @param overrides.stateOverrideSet - State overrides to apply during estimation\n\t * @param overrides.dummySignature - Custom dummy signature for estimation\n\t * @returns A promise resolving to `[preVerificationGas, verificationGasLimit, callGasLimit]`\n\t */\n public async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV9,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t dummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n return this.baseEstimateUserOperationGas(\n userOperation,\n bundlerRpc,\n overrides\n );\n }\n\n /**\n\t * Sign a {@link UserOperationV9} with an EOA private key.\n\t * Computes the UserOperation hash and produces an ECDSA signature.\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key of the EOA signer\n\t * @param chainId - Target chain ID\n\t * @returns Hex-encoded ECDSA signature\n\t */\n public signUserOperation(\n\t\tuseroperation: UserOperationV9,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n ): string {\n return this.baseSignUserOperation(useroperation, privateKey, chainId);\n }\n\n /**\n\t * Send a signed {@link UserOperationV9} to a bundler for on-chain inclusion.\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV9,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n return this.baseSendUserOperation(userOperation, bundlerRpc);\n }\n}\n","import { AbiCoder } from \"ethers\";\n\nimport {\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n UserOperationV9,\n TenderlySimulationResult,\n SingleTransactionTenderlySimulationResult,\n} from \"./types\";\nimport {\n\tAbstractionKitError\n} from \"./errors\";\nimport { sendJsonRpcRequest, createUserOperationHash } from \"./utils\";\nimport { Authorization7702Hex } from \"./utils7702\";\n\n/**\n * State override mapping for Tenderly simulations.\n * Maps contract addresses to their overridden state (balance, storage, or stateDiff).\n */\nexport type OverrideType = Record<\n string,\n Record<\n string,\n string | Record<string,string>\n >\n>;\n\n/**\n * Shares an existing Tenderly simulation so it can be viewed via a public link.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param tenderlySimulationId - The ID of the simulation to share.\n */\nexport async function shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n tenderlySimulationId: string,\n){\n const tenderlyUrl = \n 'https://api.tenderly.co/api/v1/account/' + tenderlyAccountSlug +\n '/project/' + tenderlyProjectSlug +\n '/simulations/' + tenderlySimulationId +\n '/share';\n \n const headers = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n 'X-Access-Key': tenderlyAccessKey\n };\n \n\tconst requestOptions: RequestInit = {\n\t\tmethod: \"POST\",\n\t\theaders, \n\t\tredirect: \"follow\",\n\t};\n\tconst fetchResult = await fetch(tenderlyUrl, requestOptions);\n\tconst status = fetchResult.status;\n\n\tif (status != 204) {\n\t throw new AbstractionKitError(\n \"BAD_DATA\", \"tenderly share simulation failed.\", {\n context: {\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n tenderlySimulationId,\n status\n },\n });\n\t}\n}\n\n/**\n * Simulates a full UserOperation via Tenderly's handleOps/handleUserOps entry\n * and creates a shareable link.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation result and a shareable dashboard link.\n */\nexport async function simulateUserOperationWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<{\n simulation:SingleTransactionTenderlySimulationResult,\n simulationShareLink: string,\n}> {\n const simulation = await simulateUserOperationWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n userOperation,\n blockNumber,\n stateOverrides\n );\n\n await shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n simulation.simulation.id,\n )\n const simulationShareLink =\n 'https://dashboard.tenderly.co/shared/simulation/' + simulation.simulation.id;\n return {\n simulation,\n simulationShareLink\n }\n}\n\n/**\n * Simulates a full UserOperation via the EntryPoint's handleOps/handleUserOps\n * function on Tenderly. Encodes the UserOperation into the appropriate calldata\n * based on the EntryPoint version.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation result from Tenderly.\n */\nexport async function simulateUserOperationWithTenderly(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<SingleTransactionTenderlySimulationResult> {\n const entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n let callData: string | null = null;\n const abiCoder = AbiCoder.defaultAbiCoder();\n const isV6UserOperation = \"initCode\" in userOperation;\n const isV6Entrypoint =\n entrypointAddressLowerCase == \"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789\";\n\n if (isV6UserOperation !== isV6Entrypoint) {\n throw new RangeError(\"UserOperation version does not match entrypoint.\");\n }\n\n if (isV6UserOperation) {\n userOperation = userOperation as UserOperationV6;\n const useroperationValuesArray = [\n userOperation.sender,\n userOperation.nonce,\n userOperation.initCode,\n userOperation.callData,\n userOperation.callGasLimit,\n userOperation.verificationGasLimit,\n userOperation.preVerificationGas,\n userOperation.maxFeePerGas,\n userOperation.maxPriorityFeePerGas,\n userOperation.paymasterAndData,\n userOperation.signature\n ];\n\n const encodedUserOperation = abiCoder.encode(\n [\n \"(address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[]\",\n \"address\",\n ],\n [\n [useroperationValuesArray],\n \"0x1000000000000000000000000000000000000000\"\n ],\n );\n callData = '0x1fad948c' + encodedUserOperation.slice(2);\n\n }else{\n userOperation = userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9;\n let initCode = \"0x\";\n if (userOperation.factory != null) {\n initCode = userOperation.factory;\n if (userOperation.factoryData != null) {\n initCode += userOperation.factoryData.slice(2);\n }\n }\n\n const accountGasLimits =\n \"0x\" +\n abiCoder\n .encode([\"uint128\"], [userOperation.verificationGasLimit])\n .slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.callGasLimit]).slice(34);\n\n const gasFees =\n \"0x\" +\n abiCoder\n .encode([\"uint128\"], [userOperation.maxPriorityFeePerGas])\n .slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.maxFeePerGas]).slice(34);\n\n let paymasterAndData = \"0x\";\n if (userOperation.paymaster != null) {\n paymasterAndData = userOperation.paymaster;\n if (userOperation.paymasterVerificationGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterVerificationGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterPostOpGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterPostOpGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterData != null) {\n paymasterAndData += userOperation.paymasterData.slice(2);\n }\n }\n\n const useroperationValuesArray = [\n userOperation.sender,\n userOperation.nonce,\n initCode,\n userOperation.callData,\n accountGasLimits,\n userOperation.preVerificationGas,\n gasFees,\n paymasterAndData,\n userOperation.signature\n ];\n\n const encodedUserOperation = abiCoder.encode(\n [\n \"(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)[]\",\n \"address\",\n ],\n [\n [useroperationValuesArray],\n \"0x1000000000000000000000000000000000000000\"\n ],\n );\n\n if(\n entrypointAddressLowerCase == '0x0000000071727de22e5e9d8baf0edac6f37da032' ||\n entrypointAddressLowerCase == '0x4337084d9e255ff0702461cf8895ce9e3b5ff108' ||\n entrypointAddressLowerCase == '0x433709009b8330fda32311df1c2afa402ed8d009'\n ){\n callData = '0x765e827f' + encodedUserOperation.slice(2);\n }else{\n throw new RangeError(\"Invalid entrypoint.\");\n }\n }\n\n // For EIP-7702 userOps (factory == \"0x7702\"), the EntryPoint checks\n // that the sender's code starts with the EIP-7702 delegation prefix\n // (0xef0100). Inject a code state override so the check passes in\n // simulation.\n if (\n !isV6UserOperation &&\n (userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9)\n .factory === \"0x7702\"\n ) {\n const eip7702Auth = (userOperation as UserOperationV8 | UserOperationV9).eip7702Auth;\n if (eip7702Auth != null && eip7702Auth.address != null) {\n const delegationCode =\n \"0xef0100\" + eip7702Auth.address.toLowerCase().replace(\"0x\", \"\");\n const senderLower = userOperation.sender.toLowerCase();\n stateOverrides = stateOverrides\n ? { ...stateOverrides }\n : {};\n stateOverrides[senderLower] = {\n ...(stateOverrides[senderLower] || {}),\n code: delegationCode,\n };\n }\n }\n\n const simulation = await callTenderlySimulateBundle(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n [{\n chainId,\n blockNumber,\n from: \"0x1000000000000000000000000000000000000000\",\n to: entrypointAddress,\n data: callData,\n stateOverrides\n }]\n );\n return simulation[0];\n}\n\n/**\n * Base fields shared by all UserOperation versions for Tenderly simulation.\n * Contains the common fields present in every EntryPoint version.\n */\nexport interface BaseUserOperationToSimulate {\n\t/** The smart account address that sends the UserOperation. */\n\tsender: string;\n\t/** The encoded call data to execute on the account. */\n\tcallData: string;\n\t/** The account nonce. */\n\tnonce: bigint;\n\t/** The gas limit for the main execution call. */\n\tcallGasLimit: bigint;\n\t/** The gas limit for the verification step. */\n\tverificationGasLimit: bigint;\n\t/** The gas overhead to compensate the bundler. */\n\tpreVerificationGas: bigint;\n\t/** The maximum fee per gas (EIP-1559). */\n\tmaxFeePerGas: bigint;\n\t/** The maximum priority fee per gas (EIP-1559). */\n\tmaxPriorityFeePerGas: bigint;\n\t/** The UserOperation signature. */\n\tsignature: string;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.6.\n * Uses the combined `initCode` and `paymasterAndData` fields.\n */\nexport interface UserOperationV6ToSimulate extends BaseUserOperationToSimulate {\n\t/** The concatenated factory address and factory data, or null if already deployed. */\n\tinitCode: string | null;\n\t/** The concatenated paymaster address and paymaster-specific data. */\n\tpaymasterAndData: string;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.7.\n * Uses separate factory/paymaster fields instead of combined byte arrays.\n */\nexport interface UserOperationV7ToSimulate extends BaseUserOperationToSimulate {\n\t/** The factory contract address, or null if already deployed. */\n\tfactory: string | null;\n\t/** The factory-specific initialization data, or null if already deployed. */\n\tfactoryData: string | null;\n\t/** The paymaster contract address. */\n\tpaymaster: string | null;\n\t/** The gas limit for paymaster verification. */\n\tpaymasterVerificationGasLimit: bigint | null;\n\t/** The gas limit for paymaster postOp execution. */\n\tpaymasterPostOpGasLimit: bigint | null;\n\t/** The paymaster-specific data. */\n\tpaymasterData: string | null;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.8.\n * Extends the v0.7 structure with an additional `eip7702Auth` field for\n * EIP-7702 delegation support.\n */\nexport interface UserOperationV8ToSimulate extends BaseUserOperationToSimulate {\n\t/** The factory contract address, or null if already deployed. */\n\tfactory: string | null;\n\t/** The factory-specific initialization data, or null if already deployed. */\n\tfactoryData: string | null;\n\t/** The paymaster contract address. */\n\tpaymaster: string | null;\n\t/** The gas limit for paymaster verification. */\n\tpaymasterVerificationGasLimit: bigint | null;\n\t/** The gas limit for paymaster postOp execution. */\n\tpaymasterPostOpGasLimit: bigint | null;\n\t/** The paymaster-specific data. */\n\tpaymasterData: string | null;\n\t/** The EIP-7702 delegation authorization data. */\n\teip7702Auth: Authorization7702Hex | null;\n}\n\n/**\n * UserOperation fields for Tenderly simulation targeting EntryPoint v0.9.\n */\nexport interface UserOperationV9ToSimulate extends UserOperationV8ToSimulate {}\n\n/**\n * Simulates a UserOperation's callData (and optional account deployment) on\n * Tenderly, then creates shareable links for each simulation.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8 format).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation results and shareable dashboard links.\n */\nexport async function simulateUserOperationCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6ToSimulate | UserOperationV7ToSimulate | UserOperationV8ToSimulate | UserOperationV9ToSimulate,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null,\n): Promise<{\n simulation:TenderlySimulationResult,\n callDataSimulationShareLink: string,\n accountDeploymentSimulationShareLink?: string,\n}> {\n const simulation = await simulateUserOperationCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n userOperation,\n blockNumber,\n stateOverrides\n );\n const simulationIds = simulation.map(s => s.simulation.id);\n await Promise.all(simulationIds.map(simulationId =>\n shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n simulationId,\n )\n ));\n \n const simulationLinks = simulationIds.map(\n s => 'https://dashboard.tenderly.co/shared/simulation/' + s );\n if (simulationLinks.length == 1){\n return {\n simulation,\n callDataSimulationShareLink: simulationLinks[0]\n };\n }else if (simulationLinks.length == 2){\n return {\n simulation,\n accountDeploymentSimulationShareLink: simulationLinks[0],\n callDataSimulationShareLink: simulationLinks[1]\n };\n }else{\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"invalid number of simulations retuned\",\n {\n context: JSON.stringify(\n simulation,\n (_key, value) =>\n typeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n ),\n },\n );\n } \n}\n\n/**\n * Simulates a UserOperation's callData on Tenderly by extracting the sender,\n * callData, and factory info, then delegating to {@link simulateSenderCallDataWithTenderly}.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param userOperation - The UserOperation to simulate (v0.6, v0.7, or v0.8 format).\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The Tenderly simulation results.\n */\nexport async function simulateUserOperationCallDataWithTenderly(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6ToSimulate | UserOperationV7ToSimulate | UserOperationV8ToSimulate | UserOperationV9ToSimulate,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null,\n) : Promise<TenderlySimulationResult> {\n let factory = null;\n let factoryData = null;\n const entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n const isV6UserOperation = \"initCode\" in userOperation;\n const isV6Entrypoint =\n entrypointAddressLowerCase == \"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789\";\n\n if (isV6UserOperation !== isV6Entrypoint) {\n throw new RangeError(\"UserOperation version does not match entrypoint.\");\n }\n\n let callData = userOperation.callData;\n\tif (\"initCode\" in userOperation) {\n if(userOperation.initCode != null && userOperation.initCode.length > 2){\n factory = userOperation.initCode.slice(0,22);\n factoryData = userOperation.initCode.slice(22);\n }\n }else{\n factory = userOperation.factory;\n factoryData = userOperation.factoryData;\n\n // EIP-7702 userOps use factory:\"0x7702\" as a sentinel with\n // factoryData:null. This doesn't represent an actual factory\n // deployment, so normalize to null.\n if (factory === \"0x7702\") {\n factory = null;\n factoryData = null;\n }\n\n // Handle IAccountExecute.executeUserOp callData rewriting.\n // When callData starts with the executeUserOp selector (0x8dd7712f),\n // the EntryPoint rewrites the call to\n // sender.executeUserOp(packedUserOp, userOpHash) instead of\n // sender.call(callData). Replicate that behavior here.\n const EXECUTE_USEROP_SELECTOR = \"0x8dd7712f\";\n if (callData.toLowerCase().startsWith(EXECUTE_USEROP_SELECTOR)) {\n const abiCoder = AbiCoder.defaultAbiCoder();\n\n let initCode = \"0x\";\n if (userOperation.factory != null) {\n initCode = userOperation.factory;\n if (userOperation.factoryData != null) {\n initCode += userOperation.factoryData.slice(2);\n }\n }\n\n const accountGasLimits =\n \"0x\" +\n abiCoder.encode([\"uint128\"], [userOperation.verificationGasLimit]).slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.callGasLimit]).slice(34);\n\n const gasFees =\n \"0x\" +\n abiCoder.encode([\"uint128\"], [userOperation.maxPriorityFeePerGas]).slice(34) +\n abiCoder.encode([\"uint128\"], [userOperation.maxFeePerGas]).slice(34);\n\n let paymasterAndData = \"0x\";\n if (userOperation.paymaster != null) {\n paymasterAndData = userOperation.paymaster;\n if (userOperation.paymasterVerificationGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterVerificationGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterPostOpGasLimit != null) {\n paymasterAndData += abiCoder\n .encode([\"uint128\"], [userOperation.paymasterPostOpGasLimit])\n .slice(34);\n }\n if (userOperation.paymasterData != null) {\n paymasterAndData += userOperation.paymasterData.slice(2);\n }\n }\n\n const userOpHash = createUserOperationHash(\n userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9,\n entrypointAddress,\n chainId,\n );\n\n const packedUserOp = [\n userOperation.sender,\n userOperation.nonce,\n initCode,\n userOperation.callData,\n accountGasLimits,\n userOperation.preVerificationGas,\n gasFees,\n paymasterAndData,\n userOperation.signature,\n ];\n\n const encodedParams = abiCoder.encode(\n [\"(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)\", \"bytes32\"],\n [packedUserOp, userOpHash],\n );\n callData = EXECUTE_USEROP_SELECTOR + encodedParams.slice(2);\n }\n }\n\n return await simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n userOperation.sender,\n callData,\n factory,\n factoryData,\n blockNumber,\n stateOverrides\n )\n}\n\n/**\n * Simulates the sender's callData (and optional account deployment) on Tenderly,\n * then creates shareable links for each simulation.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param sender - The smart account address.\n * @param callData - The encoded call data to simulate.\n * @param factory - The factory contract address, or null if already deployed.\n * @param factoryData - The factory initialization data, or null if already deployed.\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The simulation results and shareable dashboard links.\n */\nexport async function simulateSenderCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n sender: string,\n callData: string,\n factory: string | null = null,\n\tfactoryData: string | null = null,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<{\n simulation:TenderlySimulationResult,\n callDataSimulationShareLink: string,\n accountDeploymentSimulationShareLink?: string,\n}> {\n const simulation = await simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n entrypointAddress,\n sender,\n callData,\n factory,\n factoryData,\n blockNumber,\n stateOverrides\n );\n const simulationIds = simulation.map(s => s.simulation.id);\n await Promise.all(simulationIds.map(simulationId =>\n shareTenderlySimulationAndCreateLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n simulationId,\n )\n ));\n \n const simulationLinks = simulationIds.map(\n s => 'https://dashboard.tenderly.co/shared/simulation/' + s );\n if (simulationLinks.length == 1){\n return {\n simulation,\n callDataSimulationShareLink: simulationLinks[0]\n };\n }else if (simulationLinks.length == 2){\n return {\n simulation,\n accountDeploymentSimulationShareLink: simulationLinks[0],\n callDataSimulationShareLink: simulationLinks[1]\n };\n }else{\n throw new AbstractionKitError(\n \"BAD_DATA\",\n \"invalid number of simulations retuned\",\n {\n context: JSON.stringify(\n simulation,\n (_key, value) =>\n typeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n ),\n },\n );\n } \n}\n\n/**\n * Simulates the sender's callData on Tenderly. If factory and factoryData are\n * provided, simulates account deployment first, then the callData execution.\n * Uses the appropriate SenderCreator address based on the EntryPoint version.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param chainId - The chain ID to simulate on.\n * @param entrypointAddress - The EntryPoint contract address.\n * @param sender - The smart account address.\n * @param callData - The encoded call data to simulate.\n * @param factory - The factory contract address, or null if already deployed.\n * @param factoryData - The factory initialization data, or null if already deployed.\n * @param blockNumber - Optional block number for the simulation.\n * @param stateOverrides - Optional state overrides for the simulation.\n * @returns The Tenderly simulation results (one or two entries depending on deployment).\n */\nexport async function simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n chainId: bigint,\n\tentrypointAddress: string,\n sender: string,\n callData: string,\n factory: string | null = null,\n\tfactoryData: string | null = null,\n blockNumber: number | null = null,\n stateOverrides?: OverrideType | null\n): Promise<TenderlySimulationResult> {\n const transactions = [];\n const entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n let senderCreator:string;\n if(\n entrypointAddressLowerCase == '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789'\n ){\n senderCreator = \"0x7fc98430eaedbb6070b35b39d798725049088348\";\n }else if(\n entrypointAddressLowerCase == '0x0000000071727de22e5e9d8baf0edac6f37da032'\n ){\n senderCreator = \"0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c\";\n }else if(\n entrypointAddressLowerCase == '0x4337084d9e255ff0702461cf8895ce9e3b5ff108'\n ){\n senderCreator = \"0x449ed7c3e6fee6a97311d4b55475df59c44add33\";\n }else if(\n entrypointAddressLowerCase == '0x433709009b8330fda32311df1c2afa402ed8d009'\n ){\n senderCreator = \"0x0A630a99Df908A81115A3022927Be82f9299987e\";\n }else{\n throw new RangeError(`Invalid entrypoint: ${entrypointAddress}`);\n }\n \n if(\n (factory == null && factoryData != null) ||\n (factory != null && factoryData == null)\n ){\n throw new RangeError(`Invalid factory and factoryData`);\n }\n if(factory != null && factoryData != null){ \n transactions.push({\n chainId,\n blockNumber,\n from: senderCreator,\n to: factory,\n data: factoryData,\n stateOverrides\n })\n }\n transactions.push({\n chainId,\n blockNumber,\n from: entrypointAddress,\n to: sender,\n data: callData,\n stateOverrides\n })\n const simulationsResult = await callTenderlySimulateBundle(\n tenderlyAccountSlug, tenderlyProjectSlug, tenderlyAccessKey, transactions);\n \n for (const simulationResult of simulationsResult) {\n if(simulationResult.simulation.id == \"\"){\n throw new AbstractionKitError(\n \"TENDERLY_SIMULATION_ERROR\",\n \"tenderly simulation failed\",\n {\n context: JSON.stringify(\n simulationsResult,\n (_key, value) =>\n typeof value === \"bigint\" ? \"0x\" + value.toString(16) : value,\n ),\n },\n );\n }\n }\n return simulationsResult;\n}\n\n\n/**\n * Sends a bundle of transactions to Tenderly's simulate-bundle API endpoint.\n * This is the low-level function that all other Tenderly simulation functions delegate to.\n * @param tenderlyAccountSlug - The Tenderly account slug.\n * @param tenderlyProjectSlug - The Tenderly project slug.\n * @param tenderlyAccessKey - The Tenderly API access key.\n * @param transactions - Array of transaction objects to simulate as a bundle.\n * @returns The simulation results from Tenderly.\n */\nexport async function callTenderlySimulateBundle(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n transactions:{\n chainId: bigint,\n from: string,\n to: string,\n data: string,\n gas?: number | null,\n gasPrice?: number | null,\n value?: number | null,\n blockNumber?: number | null,\n simulationType?: 'full' | 'quick' | 'abi'\n stateOverrides?: OverrideType | null,\n transactionIndex?: number,\n save?: boolean,\n saveIfFails?: boolean,\n estimateGas?: boolean,\n generateAccessList?: boolean,\n accessList?: {address: string}[]\n }[], \n): Promise<TenderlySimulationResult> {\n const tenderlyUrl = \n 'https://api.tenderly.co/api/v1/account/' + tenderlyAccountSlug +\n '/project/' + tenderlyProjectSlug + '/simulate-bundle';\n const simulations =\n transactions.map(transaction=>{\n const transactionObject: Record<string,\n string | number | boolean |\n OverrideType |\n {address: string}[]\n > = {\n network_id: transaction.chainId.toString(),\n save: transaction.save?? true,\n save_if_fails:transaction.saveIfFails?? true,\n from: transaction.from,\n to: transaction.to,\n input: transaction.data,\n simulation_type: transaction.simulationType??'full',\n }\n if (transaction.blockNumber != null){\n transactionObject[\"block_number\"] = transaction.blockNumber;\n }\n\n if (transaction.gas != null){\n transactionObject[\"gas\"] = transaction.gas;\n }\n if (transaction.gasPrice != null){\n transactionObject[\"gas_price\"] = transaction.gasPrice;\n }\n if (transaction.value != null){\n transactionObject[\"value\"] = transaction.value;\n }\n if (transaction.stateOverrides != null){\n const stateOverrides = transaction.stateOverrides;\n for (const address in stateOverrides) {\n for (const key in stateOverrides[address]) {\n if(key != 'balance' && key != 'code' && key != 'storage' && key != 'stateDiff'){\n throw new RangeError(\n `Invalide stateOverrides key: ${key}.`\n );\n }else if(\n 'storage' in stateOverrides[address] &&\n 'stateDiff' in stateOverrides[address]\n ){\n throw new RangeError(\n \"can't set both storage and stateDiff for stateOverrides\"\n );\n }else if('stateDiff' in stateOverrides[address]){\n stateOverrides[address][\"storage\"] = stateOverrides[address][\"stateDiff\"];\n delete stateOverrides[address][\"stateDiff\"];\n }\n }\n }\n transactionObject[\"state_objects\"] = stateOverrides;\n }\n \n if (transaction.transactionIndex != null){\n transactionObject[\"transaction_index\"] = transaction.transactionIndex;\n }\n if (transaction.estimateGas != null){\n transactionObject[\"estimate_gas\"] = transaction.estimateGas;\n }\n if (transaction.generateAccessList != null){\n transactionObject[\"generate_access_list\"] =\n transaction.generateAccessList;\n }\n if (transaction.accessList != null){\n transactionObject[\"access_list\"] = transaction.accessList;\n }\n return transactionObject;\n }\n ) \n \n const headers = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n 'X-Access-Key': tenderlyAccessKey\n };\n return await sendJsonRpcRequest(\n tenderlyUrl,\n \"tenderly_simulateBundle\",\n simulations,\n headers,\n \"simulations\"\n ) as TenderlySimulationResult;\n}\n","import type { GasOption, StateOverrideSet, PolygonChain, OnChainIdentifierParamsType, MetaTransaction, UserOperationV9, ParallelPaymasterInitValues } from \"../../types\";\n\n/**\n * Overrides for the \"createBaseUserOperationAndFactoryAddressAndFactoryData\" function\n */\nexport interface CreateBaseUserOperationOverrides {\n\t/** set the nonce instead of quering the current nonce from the rpc node */\n\tnonce?: bigint;\n\t/** set the callData instead of using the encoding of the provided Metatransactions*/\n\tcallData?: string;\n\t/** set the callGasLimit instead of estimating gas using the bundler*/\n\tcallGasLimit?: bigint;\n\t/** set the verificationGasLimit instead of estimating gas using the bundler*/\n\tverificationGasLimit?: bigint;\n\t/** set the preVerificationGas instead of estimating gas using the bundler*/\n\tpreVerificationGas?: bigint;\n\t/** set the maxFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxFeePerGas?: bigint;\n\t/** set the maxPriorityFeePerGas instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGas?: bigint;\n\n\t/** set the callGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tcallGasLimitPercentageMultiplier?: number;\n\t/** set the verificationGasLimitPercentageMultiplier instead of estimating gas using the bundler*/\n\tverificationGasLimitPercentageMultiplier?: number;\n\t/** set the preVerificationGasPercentageMultiplier instead of estimating gas using the bundler*/\n\tpreVerificationGasPercentageMultiplier?: number;\n\t/** set the maxFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** set the maxPriorityFeePerGasPercentageMultiplier instead of quering the current gas price from the rpc node */\n\tmaxPriorityFeePerGasPercentageMultiplier?: number;\n\n\t/** pass some state overrides for gas estimation\"*/\n\tstate_override_set?: StateOverrideSet;\n\n\tdummySignerSignaturePairs?: SignerSignaturePair[];\n\n\twebAuthnSharedSigner?: string;\n\twebAuthnSignerFactory?: string;\n\twebAuthnSignerSingleton?: string;\n\twebAuthnSignerProxyCreationCode?: string;\n\n\teip7212WebAuthnPrecompileVerifier?: string;\n\teip7212WebAuthnContractVerifier?: string;\n\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\tmultisendContractAddress?: string;\n\n\tgasLevel?: GasOption;\n\tpolygonGasStation?: PolygonChain;\n\n expectedSigners?: Signer[];\n\tisMultiChainSignature?: boolean;\n\n\tparallelPaymasterInitValues?: {\n\t\t/** set the paymaster contract address */\n\t\tpaymaster: string;\n\t\t/** set the paymaster verification gas limit */\n\t\tpaymasterVerificationGasLimit: bigint;\n\t\t/** set the paymaster post-operation gas limit */\n\t\tpaymasterPostOpGasLimit: bigint;\n\t\t/** set the paymaster data, only valid value is 0x22e325a297439656 */\n\t\tpaymasterData: string;\n\t}\n}\n\n/**\n * Overrides for the \"createUserOperation\" function\n */\nexport interface CreateUserOperationV6Overrides\n\textends CreateBaseUserOperationOverrides {\n\t/** set the initCode instead of using the calculated value */\n\tinitCode?: string;\n}\n\n/**\n * Overrides for the \"createUserOperation\" function\n */\nexport interface CreateUserOperationV7Overrides\n\textends CreateBaseUserOperationOverrides {\n\t/** set the factory address instead of using the calculated value */\n\tfactory?: string;\n\t/** set the factory data instead of using the calculated value */\n\tfactoryData?: string;\n}\n\nexport interface CreateUserOperationV9Overrides extends CreateUserOperationV7Overrides{}\n\n/** Safe singleton contract address and init hash for deterministic deployment. */\nexport interface SafeAccountSingleton {\n\t/** The address of the Safe singleton contract */\n\tsingletonAddress: string;\n\t/** The init code hash used for CREATE2 address computation */\n\tsingletonInitHash: string;\n}\n\n/**\n * Overrides for initilizing a new Safe account\n */\nexport interface InitCodeOverrides {\n\t/** signature threshold\n\t * @defaultValue 1\n\t */\n\tthreshold?: number;\n\t/** create2 nonce - to generate different sender addresses from the same owners\n\t * @defaultValue 0\n\t */\n\tc2Nonce?: bigint;\n\tsafe4337ModuleAddress?: string;\n\tsafeModuleSetupAddress?: string;\n\n\tentrypointAddress?: string;\n\t/** Safe contract singleton address\n\t */\n\tsafeAccountSingleton?: SafeAccountSingleton;\n\t/** Safe Factory address\n\t */\n\tsafeAccountFactoryAddress?: string;\n\t/** Safe 4337 module address\n\t */\n\tmultisendContractAddress?: string;\n\twebAuthnSharedSigner?: string;\n\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string;\n}\n\nexport interface BaseInitOverrides {\n\t/** signature threshold\n\t * @defaultValue 1\n\t */\n\tthreshold?: number;\n\t/** create2 nonce - to generate different sender addresses from the same owners\n\t * @defaultValue 0\n\t */\n\tc2Nonce?: bigint;\n\n\tsafeAccountSingleton?: SafeAccountSingleton;\n\t/** Safe Factory address\n\t */\n\tsafeAccountFactoryAddress?: string;\n\t/** Safe 4337 module address\n\t */\n\tmultisendContractAddress?: string;\n\twebAuthnSharedSigner?: string;\n\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n}\n\n/** Overrides for WebAuthn signature creation and verification. */\nexport interface WebAuthnSignatureOverrides {\n\tisInit?: boolean;\n\twebAuthnSharedSigner?: string;\n\teip7212WebAuthnPrecompileVerifier?: string;\n\teip7212WebAuthnContractVerifier?: string;\n\twebAuthnSignerFactory?: string;\n\twebAuthnSignerSingleton?: string;\n\twebAuthnSignerProxyCreationCode?: string;\n\tvalidAfter?: bigint;\n\tvalidUntil?: bigint;\n\tisMultiChainSignature?: boolean;\n\tmultiChainMerkleProof?: string;\n\tsafe4337ModuleAddress?: string;\n}\n\n/**\n * Safe has two executor functions \"executeUserOpWithErrorString\" and \"executeUserOp\"\n */\nexport enum SafeModuleExecutorFunctionSelector {\n\texecuteUserOpWithErrorString = \"0x541d63c8\",\n\texecuteUserOp = \"0x7bb37428\",\n}\n\n/** EIP-712 domain for Safe UserOperation signing. */\nexport interface SafeUserOperationTypedDataDomain {\n\t/** Target chain ID to prevent cross-chain replay */\n\tchainId: number;\n\t/** Address of the Safe 4337 module contract */\n\tverifyingContract: string;\n}\n\n/** EIP-712 typed data values for a Safe UserOperation (EntryPoint v0.6). */\nexport interface SafeUserOperationV6TypedMessageValue {\n\t/** The Safe account address */\n\tsafe: string;\n\t/** The UserOperation nonce */\n\tnonce: bigint;\n\t/** Packed factory address and init data for account deployment */\n\tinitCode: string;\n\t/** Encoded call data for the account to execute */\n\tcallData: string;\n\t/** Gas limit for the main execution call */\n\tcallGasLimit: bigint;\n\t/** Gas limit for the verification step */\n\tverificationGasLimit: bigint;\n\t/** Gas overhead to compensate for pre-verification execution */\n\tpreVerificationGas: bigint;\n\t/** Maximum fee per gas unit */\n\tmaxFeePerGas: bigint;\n\t/** Maximum priority fee (tip) per gas unit */\n\tmaxPriorityFeePerGas: bigint;\n\t/** Packed paymaster address and data */\n\tpaymasterAndData: string;\n\t/** Unix timestamp after which the signature becomes valid */\n\tvalidAfter: bigint;\n\t/** Unix timestamp after which the signature expires */\n\tvalidUntil: bigint;\n\t/** EntryPoint contract address */\n\tentryPoint: string;\n}\n\n/** EIP-712 typed data values for a Safe UserOperation (EntryPoint v0.7). Note: field order differs from v0.6. */\nexport interface SafeUserOperationV7TypedMessageValue {\n\t/** The Safe account address */\n\tsafe: string;\n\t/** The UserOperation nonce */\n\tnonce: bigint;\n\t/** Packed factory address and init data for account deployment */\n\tinitCode: string;\n\t/** Encoded call data for the account to execute */\n\tcallData: string;\n\t/** Gas limit for the verification step */\n\tverificationGasLimit: bigint;\n\t/** Gas limit for the main execution call */\n\tcallGasLimit: bigint;\n\t/** Gas overhead to compensate for pre-verification execution */\n\tpreVerificationGas: bigint;\n\t/** Maximum priority fee (tip) per gas unit */\n\tmaxPriorityFeePerGas: bigint;\n\t/** Maximum fee per gas unit */\n\tmaxFeePerGas: bigint;\n\t/** Packed paymaster address and data */\n\tpaymasterAndData: string;\n\t/** Unix timestamp after which the signature becomes valid */\n\tvalidAfter: bigint;\n\t/** Unix timestamp after which the signature expires */\n\tvalidUntil: bigint;\n\t/** EntryPoint contract address */\n\tentryPoint: string;\n}\n\n/** EIP-712 typed data values for a Safe UserOperation (EntryPoint v0.9). */\nexport interface SafeUserOperationV9TypedMessageValue extends SafeUserOperationV7TypedMessageValue{\n}\n\n/** An Ethereum address string representing an ECDSA signer. */\nexport type ECDSAPublicAddress = string;\n\n/** WebAuthn/Passkey public key with x,y coordinates on the P-256 curve. */\nexport interface WebauthnPublicKey {\n\t/** X coordinate of the public key */\n\tx: bigint;\n\t/** Y coordinate of the public key */\n\ty: bigint;\n}\n\n/** A signer can be either an ECDSA address or a WebAuthn public key. */\nexport type Signer = ECDSAPublicAddress | WebauthnPublicKey;\n\nexport type ECDSASignature = string;\n\nexport interface WebauthnSignatureData {\n\tauthenticatorData: ArrayBuffer;\n\tclientDataFields: string;\n\trs: [bigint, bigint];\n}\n\n/** A pair of signer identity and their signature. */\nexport interface SignerSignaturePair {\n\t/** The signer (ECDSA address or WebAuthn key) */\n\tsigner: Signer;\n\t/** The signature hex string */\n\tsignature: string;\n\t/** Whether this is a contract signature (EIP-1271) */\n\tisContractSignature?: boolean;\n}\n\n/** Dummy signer-signature pair for gas estimation with EOA signers. */\nexport const EOADummySignerSignaturePair: SignerSignaturePair = {\n\tsigner: \"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9\",\n\tsignature:\n \"0x47003599ffa7e9198f321afa774e34a12a959844efd6363b88896e9c24ed33cf4e1be876ef123a3c4467e7d451511434039539699f2baa2f44955fa3d1c1c6d81c\",\n\tisContractSignature: false,\n};\n\n/** Dummy signer-signature pair for gas estimation with WebAuthn signers. */\nexport const WebauthnDummySignerSignaturePair: SignerSignaturePair = {\n\tsigner: \"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9\",\n\tsignature:\n\t\t\"0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e06c92f0ac5c4ef9e74721c23d80a9fc12f259ca84afb160f0890483539b9e6080d824c0e6c795157ad5d1ee5eff1ceeb3031009a595f9360919b83dd411c5a78d0000000000000000000000000000000000000000000000000000000000000025a24f744b28d73f066bf3203d145765a7bc735e6328168c8b03e476da3ad0d8fe0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e226f726967696e223a2268747470733a2f2f736166652e676c6f62616c220000\",\n\tisContractSignature: true,\n};\n\n/** A UserOperation with chain context ready for signing. */\nexport interface UserOperationToSign {\n chainId: bigint,\n userOperation: UserOperationV9,\n validAfter?: bigint;\n validUntil?: bigint;\n}\n\n/** Extends UserOperationToSign with per-operation WebAuthn/module overrides. */\nexport interface UserOperationToSignWithOverrides extends UserOperationToSign {\n\toverrides?: {\n\t\tisInit?: boolean;\n\t\twebAuthnSharedSigner?: string;\n\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\teip7212WebAuthnContractVerifier?: string;\n\t\twebAuthnSignerFactory?: string;\n\t\twebAuthnSignerSingleton?: string;\n\t\twebAuthnSignerProxyCreationCode?: string;\n\t\tsafe4337ModuleAddress?: string;\n\t};\n}\n\n/** EIP-712 domain for multi-chain signature Merkle tree root. */\nexport interface MultiChainSignatureMerkleTreeRootTypedDataDomain {\n\tverifyingContract: string;\n}\n\n/** EIP-712 typed message value containing a Merkle tree root for multi-chain signatures. */\nexport interface MultiChainSignatureMerkleTreeRootTypedMessageValue {\n\tmerkleTreeRoot: string;\n}\n","import { AbiCoder, getBytes, solidityPacked } from \"ethers\";\nimport { MetaTransaction, Operation } from \"src/types\";\n\n/**\n * Encodes a Metatransaction to be executed by Safe contract\n * @param metaTransaction - metatransaction to be encoded\n * @returns The encoded metatransaction\n */\nfunction encodeMultiSendTransaction(metaTransaction: MetaTransaction): string {\n\tconst operation = metaTransaction.operation ?? Operation.Call;\n\n\tconst data = getBytes(metaTransaction.data);\n\tconst encoded = solidityPacked(\n\t\t[\"uint8\", \"address\", \"uint256\", \"uint256\", \"bytes\"],\n\t\t[operation, metaTransaction.to, metaTransaction.value, data.length, data],\n\t);\n\treturn encoded.slice(2);\n}\n\n/**\n * Encodes a Metatransaction list to be batch executed by Safe contract\n * @param metaTransactions - metatransaction list to be encoded\n * @returns The encoded metatransaction\n */\nexport function encodeMultiSendCallData(\n\tmetaTransactions: MetaTransaction[],\n): string {\n\treturn (\n\t\t\"0x\" + metaTransactions.map((tx) => encodeMultiSendTransaction(tx)).join(\"\")\n\t);\n}\n\n/**\n * Decodes a MultiSend callData back into its packed transaction bytes.\n * Strips the function selector and ABI-decodes the inner bytes payload.\n * @param callData - The full MultiSend callData (with 0x prefix and function selector).\n * @returns The decoded packed transaction bytes as a hex string.\n */\nexport function decodeMultiSendCallData(callData: string): string {\n\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\tconst decodedCalldata = abiCoder.decode([\"bytes\"], \"0x\" + callData.slice(10));\n\treturn decodedCalldata[0] as string;\n}\n","import type { AbiInputValue } from \"../types\";\nimport { createCallData } from \"../utils\";\n\n/**\n * Generic factory for deploying smart account proxy contracts.\n * Encodes the factory address and createProxyWithNonce calldata into\n * the `initCode` field of a UserOperation.\n */\nexport class SmartAccountFactory {\n\t/** On-chain address of the factory contract */\n\treadonly address: string;\n\t/** 4-byte function selector for the factory's proxy creation method */\n\treadonly generatorFunctionSelector: string;\n\t/** ABI types for the proxy creation function parameters */\n\treadonly generatorFunctionInputAbi: string[];\n\n\t/**\n\t * @param address - On-chain address of the factory contract\n\t * @param generatorFunctionSelector - 4-byte hex selector for the proxy creation function\n\t * @param generatorFunctionInputAbi - ABI type strings for the proxy creation function parameters\n\t */\n\tconstructor(\n\t\taddress: string,\n\t\tgeneratorFunctionSelector: string,\n\t\tgeneratorFunctionInputAbi: string[],\n\t) {\n\t\tthis.address = address;\n\t\tthis.generatorFunctionSelector = generatorFunctionSelector;\n\t\tthis.generatorFunctionInputAbi = generatorFunctionInputAbi;\n\t}\n\n\t/**\n\t * Encode the factory function calldata for deploying a new account proxy.\n\t *\n\t * @param generatorFunctionInputParameters - Values to ABI-encode as the factory function parameters\n\t * @returns ABI-encoded calldata as a hex string\n\t */\n\tgetFactoryGeneratorFunctionCallData(\n\t\tgeneratorFunctionInputParameters: AbiInputValue[],\n\t): string {\n\t\tconst callData = createCallData(\n\t\t\tthis.generatorFunctionSelector,\n\t\t\tthis.generatorFunctionInputAbi,\n\t\t\tgeneratorFunctionInputParameters,\n\t\t);\n\t\t//const res: string = this.address + callData.slice(2);\n\n\t\treturn callData;\n\t}\n}\n","import { SmartAccountFactory } from \"./SmartAccountFactory\";\n/**\n * Factory for deploying Safe proxy contracts via `createProxyWithNonce`.\n * Pre-configured with the Safe proxy factory's function selector and ABI.\n */\nexport class SafeAccountFactory extends SmartAccountFactory {\n\t/** Default Safe proxy factory contract address */\n\tstatic readonly DEFAULT_FACTORY_ADDRESS =\n\t\t\"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67\";\n\t/**\n\t * @param address - Safe proxy factory contract address\n\t * @defaultValue \"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67\"\n\t */\n\tconstructor(address: string = SafeAccountFactory.DEFAULT_FACTORY_ADDRESS) {\n\t\tconst generatorFunctionSelector = \"0x1688f0b9\"; //createProxyWithNonce\n\t\tconst generatorFunctionInputAbi = [\n\t\t\t\"address\", //_singleton\n\t\t\t\"bytes\", //initializer\n\t\t\t\"uint256\", //saltNonce\n\t\t];\n\t\tsuper(address, generatorFunctionSelector, generatorFunctionInputAbi);\n\t}\n}\n","import { hashMessage } from \"ethers\";\n\n/** The primary EIP-712 type name used for Safe message signing. */\nexport const SAFE_MESSAGE_PRIMARY_TYPE = \"SafeMessage\";\n\n/** EIP-712 type definition for SafeMessage, containing a single bytes field. */\nexport const SAFE_MESSAGE_MODULE_TYPE = {\n SafeMessage: [\n { type: \"bytes\", name: \"message\" },\n ],\n};\n\n/** EIP-712 domain for Safe message signing, scoped to a chain and account. */\nexport type SafeMessageTypedDataDomain = {\n\t/** Target chain ID to prevent cross-chain replay */\n\tchainId: number;\n\t/** The Safe account address that will verify the signature */\n\tverifyingContract: string;\n}\n\n/** EIP-712 typed message value containing the hashed message bytes. */\nexport type SafeMessageTypedMessageValue = {\n\t/** The EIP-191 hash of the original message */\n\tmessage: string;\n}\n\n/**\n * Create EIP-712 signing data for a Safe message.\n * @param accountAddress - the Safe account address\n * @param chainId - target chain id\n * @param message - the message string to sign\n * @returns an object with domain, types, and messageValue for EIP-712 signing\n */\nexport function getSafeMessageEip712Data(\n accountAddress: string,\n chainId: bigint,\n message: string\n): {\n domain: SafeMessageTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeMessageTypedMessageValue\n} {\n const messageValue: SafeMessageTypedMessageValue = {\n message: hashMessage(message)\n };\n const domain: SafeMessageTypedDataDomain = {\n chainId: Number(chainId),\n verifyingContract: accountAddress\n };\n\n return {\n domain,\n types: SAFE_MESSAGE_MODULE_TYPE,\n messageValue,\n };\n}\n","import {\n\tWallet,\n\tAbiCoder,\n\tTypedDataEncoder,\n\tkeccak256,\n\tsolidityPacked,\n\tsolidityPackedKeccak256,\n\tethers,\n getAddress\n} from \"ethers\";\nimport { SmartAccount } from \"../SmartAccount\";\nimport {\n\tBaseUserOperationDummyValues,\n\tZeroAddress,\n\tSafe_L2_V1_4_1,\n\tENTRYPOINT_V6,\n\tENTRYPOINT_V7,\n\tEIP712_SAFE_OPERATION_V7_TYPE,\n\tEIP712_SAFE_OPERATION_V6_TYPE,\n ENTRYPOINT_V9,\n} from \"../../constants\";\nimport {\n\tMetaTransaction,\n\tOperation,\n\tStateOverrideSet,\n\tBaseUserOperation,\n\tUserOperationV6,\n\tUserOperationV7,\n GasOption,\n PolygonChain,\n OnChainIdentifierParamsType,\n TenderlySimulationResult,\n UserOperationV9,\n} from \"../../types\";\nimport {\n\tcreateCallData,\n\tgetFunctionSelector,\n\tfetchAccountNonce,\n\tsendEthCallRequest,\n\tsendEthGetCodeRequest,\n handlefetchGasPrice,\n} from \"../../utils\";\n\nimport {\n simulateSenderCallDataWithTenderly,\n simulateSenderCallDataWithTenderlyAndCreateShareLink\n} from \"../../utilsTenderly\";\n\nimport {\n\tCreateBaseUserOperationOverrides,\n\tSigner,\n\tSafeUserOperationTypedDataDomain,\n\tSafeUserOperationV6TypedMessageValue,\n\tSafeUserOperationV7TypedMessageValue,\n\tSignerSignaturePair,\n\tWebauthnSignatureData,\n\tSafeModuleExecutorFunctionSelector,\n\tEOADummySignerSignaturePair,\n\tWebAuthnSignatureOverrides,\n\tBaseInitOverrides,\n WebauthnDummySignerSignaturePair,\n WebauthnPublicKey,\n SafeAccountSingleton,\n} from \"./types\";\nimport { decodeMultiSendCallData, encodeMultiSendCallData } from \"./multisend\";\nimport { AbstractionKitError, ensureError } from \"src/errors\";\nimport { Bundler } from \"src/Bundler\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\nimport { SafeAccountFactory } from \"src/factory/SafeAccountFactory\";\nimport { getSafeMessageEip712Data, SafeMessageTypedDataDomain, SafeMessageTypedMessageValue } from \"./safeMessage\";\n\nexport class SafeAccount extends SmartAccount {\n\tstatic readonly DEFAULT_WEB_AUTHN_SHARED_SIGNER: string =\n\t\t\"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9\";\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_SINGLETON: string =\n\t\t\"0x270D7E4a57E6322f336261f3EaE2BADe72E68d72\";\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_FACTORY: string =\n\t\t\"0xF7488fFbe67327ac9f37D5F722d83Fc900852Fbf\";\n\tstatic readonly DEFAULT_WEB_AUTHN_FCLP256_VERIFIER: string =\n\t\t\"0x445a0683e494ea0c5AF3E83c5159fBE47Cf9e765\";\n\tstatic readonly DEFAULT_WEB_AUTHN_PRECOMPILE: string =\n\t\t\"0x0000000000000000000000000000000000000000\"; //zero address means no precompile\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE: string =\n\t\t\"0x61010060405234801561001157600080fd5b506040516101ee3803806101ee83398101604081905261003091610058565b6001600160a01b0390931660805260a09190915260c0526001600160b01b031660e0526100bc565b6000806000806080858703121561006e57600080fd5b84516001600160a01b038116811461008557600080fd5b60208601516040870151606088015192965090945092506001600160b01b03811681146100b157600080fd5b939692955090935050565b60805160a05160c05160e05160ff6100ef60003960006008015260006031015260006059015260006080015260ff6000f3fe608060408190527f00000000000000000000000000000000000000000000000000000000000000003660b681018290527f000000000000000000000000000000000000000000000000000000000000000060a082018190527f00000000000000000000000000000000000000000000000000000000000000008285018190527f00000000000000000000000000000000000000000000000000000000000000009490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033\";\n\n\tstatic readonly DEFAULT_MULTISEND_CONTRACT_ADDRESS =\n\t\t\"0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526\";\n\n\tstatic readonly initializerFunctionSelector: string = \"0xb63e800d\";\n\tstatic readonly initializerFunctionInputAbi: string[] = [\n\t\t\"address[]\",\n\t\t\"uint256\",\n\t\t\"address\",\n\t\t\"bytes\",\n\t\t\"address\",\n\t\t\"address\",\n\t\t\"uint256\",\n\t\t\"address\",\n\t];\n\n\tstatic readonly DEFAULT_EXECUTOR_FUCNTION_SELECTOR =\n\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString;\n\tstatic readonly executorFunctionInputAbi: string[] = [\n\t\t\"address\", //to\n\t\t\"uint256\", //value\n\t\t\"bytes\", //data\n\t\t\"uint8\", //operation\n\t];\n\n\tprotected isInitWebAuthn: boolean;\n\tprotected x: bigint | null = null;\n\tprotected y: bigint | null = null;\n\n\treadonly safeAccountSingleton:SafeAccountSingleton;\n\treadonly entrypointAddress: string;\n\treadonly safe4337ModuleAddress: string;\n\tprotected factoryAddress: string | null;\n\tprotected factoryData: string | null;\n\n readonly onChainIdentifier: string | null;\n\n\tconstructor(\n\t\taccountAddress: string,\n\t\tsafe4337ModuleAddress: string,\n\t\tentrypointAddress: string,\n overrides: {\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string;\n safeAccountSingleton?: SafeAccountSingleton;\n } = {}\n\t) {\n\t\tsuper(accountAddress);\n\t\tthis.entrypointAddress = entrypointAddress;\n\t\tthis.safe4337ModuleAddress = safe4337ModuleAddress;\n\t\tthis.factoryAddress = null;\n\t\tthis.factoryData = null;\n\n\t\tthis.isInitWebAuthn = false;\n \n if(\n overrides.onChainIdentifierParams != null &&\n overrides.onChainIdentifier != null\n ){\n\t\t\tthrow new RangeError(\n \"can't override both onChainIdentifier and onChainIdentifierParams\"\n );\n }else if(overrides.onChainIdentifierParams != null){\n this.onChainIdentifier = generateOnChainIdentifier(\n overrides.onChainIdentifierParams.project,\n overrides.onChainIdentifierParams.platform,\n overrides.onChainIdentifierParams.tool,\n overrides.onChainIdentifierParams.toolVersion,\n );\n }else if(overrides.onChainIdentifier != null){\n let onChainIdentifier = overrides.onChainIdentifier;\n if (onChainIdentifier.startsWith(\"0x\")){\n onChainIdentifier = onChainIdentifier.slice(2);\n }\n if(onChainIdentifier.length != 64){\n throw new RangeError(\"onChainIdentifier length must be 64.\");\n }\n this.onChainIdentifier = onChainIdentifier;\n }else{\n this.onChainIdentifier = null;\n }\n this.safeAccountSingleton = overrides.safeAccountSingleton?? Safe_L2_V1_4_1;\n\t}\n\n\t/**\n\t * calculate proxy/account address using initilizer call data\n\t * @param initializerCallData from createBaseInitializerCallData\n\t * @param overrides - overrides for the default values\n\t * @param overrides.c2Nonce - create2 nonce to generate different sender addresses from the same owners\n\t * defaults to zero\n\t * @param overrides.safeFactoryAddress - safeFactoryAddress, defaults to\n\t * SafeAccountFactory.DEFAULT_FACTORY_ADDRESS\n\t * @param overrides.singletonInitHash - a hash that includes the singleton address and thr proxy bytecode\n\t * keccak256(solidityPacked([\"bytes\", \"bytes\"], [proxyByteCode, abiCoder.encode([\"uint256\"], [singletonAddress])]))\n\t * defaults to SafeAccount.safeAccountSingleton.singletonInitHash\n\t * @returns proxy/account address\n\t */\n\tpublic static createProxyAddress(\n\t\tinitializerCallData: string,\n\t\toverrides: {\n\t\t\tc2Nonce?: bigint;\n\t\t\tsafeFactoryAddress?: string;\n\t\t\tsingletonInitHash?: string;\n\t\t} = {},\n\t): string {\n\t\tconst c2Nonce = overrides.c2Nonce ?? 0n;\n\t\tif (c2Nonce < 0n) {\n\t\t\tthrow new RangeError(\"c2Nonce can't be negative\");\n\t\t}\n\t\tconst safeFactoryAddress =\n\t\t\toverrides.safeFactoryAddress ??\n\t\t\tSafeAccountFactory.DEFAULT_FACTORY_ADDRESS;\n\t\tconst singletonInitHash =\n\t\t\toverrides.singletonInitHash ?? Safe_L2_V1_4_1.singletonInitHash;\n\t\tconst salt = keccak256(\n\t\t\tsolidityPacked(\n\t\t\t\t[\"bytes32\", \"uint256\"],\n\t\t\t\t[keccak256(initializerCallData), c2Nonce],\n\t\t\t),\n\t\t);\n\n\t\tconst proxyAdd = solidityPackedKeccak256(\n\t\t\t[\"bytes1\", \"address\", \"bytes32\", \"bytes32\"],\n\t\t\t[\"0xff\", safeFactoryAddress, salt, singletonInitHash],\n\t\t).slice(-40);\n\n\t\treturn getAddress(\"0x\" + proxyAdd);//to checksummed\n\t}\n\n\t/**\n\t * encode calldata for a single MetaTransaction to be executed by Safe account\n\t * @param metaTransaction - metaTransaction to create calldata for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.safeModuleExecutorFunctionSelector - select the\n\t * executor function, either \"executeUserOpWithErrorString\" or \"executeUserOp\"\n\t * defaults to \"executeUserOpWithErrorString\"\n\t * @returns calldata\n\t */\n\tpublic static createAccountCallDataSingleTransaction(\n\t\tmetaTransaction: MetaTransaction,\n\t\toverrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t} = {},\n\t): string {\n\t\tconst value = metaTransaction.value ?? 0;\n\t\tconst data = metaTransaction.data ?? \"0x\";\n\t\tconst operation = metaTransaction.operation ?? Operation.Call;\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst executorFunctionCallData = SafeAccount.createAccountCallData(\n\t\t\tmetaTransaction.to,\n\t\t\tvalue,\n\t\t\tdata,\n\t\t\toperation,\n\t\t\t{\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t},\n\t\t);\n\t\treturn executorFunctionCallData;\n\t}\n\n\t/**\n\t * encode calldata for a list of MetaTransactions to be executed by Safe account\n\t * @param metaTransaction - metaTransaction to create calldata for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.safeModuleExecutorFunctionSelector - select the\n\t * executor function, either \"executeUserOpWithErrorString\" or \"executeUserOp\"\n\t * defaults to \"executeUserOpWithErrorString\"\n\t * @param overrides.multisendContractAddress - defaults to\n\t * SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS\n\t * @returns calldata\n\t */\n\tpublic static createAccountCallDataBatchTransactions(\n\t\tmetaTransactions: MetaTransaction[],\n\t\toverrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t\tmultisendContractAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tif (metaTransactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one metaTransaction\");\n\t\t}\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\n\t\tconst multiData = encodeMultiSendCallData(metaTransactions);\n\n\t\tconst mutisendSelector = \"0x8d80ff0a\";\n\t\tconst multiSendCallData = createCallData(\n\t\t\tmutisendSelector,\n\t\t\t[\"bytes\"],\n\t\t\t[multiData],\n\t\t);\n\n\t\tconst executorFunctionCallData = SafeAccount.createAccountCallData(\n\t\t\tmultisendContractAddress,\n\t\t\t0n,\n\t\t\tmultiSendCallData,\n\t\t\tOperation.Delegate,\n\t\t\t{\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t},\n\t\t);\n\n\t\treturn executorFunctionCallData;\n\t}\n\n\t/**\n\t * encode calldata to be executed by Safe account\n\t * @param to - target address\n\t * @param value - amount of natic token to transafer to target address\n\t * @param data - calldata\n\t * @param operation - either call or delegate call\n\t * @param overrides - overrides for the default values\n\t * @param overrides.safeModuleExecutorFunctionSelector - select the\n\t * executor function, either \"executeUserOpWithErrorString\" or \"executeUserOp\"\n\t * defaults to \"executeUserOpWithErrorString\"\n\t * @returns callData\n\t */\n\tpublic static createAccountCallData(\n\t\tto: string,\n\t\tvalue: bigint,\n\t\tdata: string,\n\t\toperation: Operation,\n\t\toverrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t} = {},\n\t): string {\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst executorFunctionInputParameters = [to, value, data, operation];\n\t\tconst callData = createCallData(\n\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\tSafeAccount.executorFunctionInputAbi,\n\t\t\texecutorFunctionInputParameters,\n\t\t);\n\t\treturn callData;\n\t}\n\n\t/**\n\t * decode calldata to a Metatransaction\n\t * @param callData - calldata to decode\n\t * @returns [MetaTransaction, SafeModuleExecutorFunctionSelector]\n\t */\n\tpublic static decodeAccountCallData(\n\t\tcallData: string,\n\t): [MetaTransaction, SafeModuleExecutorFunctionSelector] {\n\t\tlet safeModuleExecutorFunctionSelector: SafeModuleExecutorFunctionSelector | null =\n\t\t\tnull;\n\t\tif (\n\t\t\tcallData.startsWith(\n\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString,\n\t\t\t)\n\t\t) {\n\t\t\tsafeModuleExecutorFunctionSelector =\n\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString;\n\t\t} else if (\n\t\t\tcallData.startsWith(SafeModuleExecutorFunctionSelector.executeUserOp)\n\t\t) {\n\t\t\tsafeModuleExecutorFunctionSelector =\n\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOp;\n\t\t}\n\t\tif (safeModuleExecutorFunctionSelector != null) {\n\t\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\t\tconst params = \"0x\" + callData.slice(10);\n\t\t\tconst decodedParams = abiCoder.decode(\n\t\t\t\t[\n\t\t\t\t\t\"address\", //to\n\t\t\t\t\t\"uint256\", //value\n\t\t\t\t\t\"bytes\", //data\n\t\t\t\t\t\"uint8\", //operation\"\n\t\t\t\t],\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tlet accountCallDataString;\n\t\t\tif (typeof decodedParams[2] !== \"string\") {\n\t\t\t\taccountCallDataString = new TextDecoder().decode(decodedParams[2]);\n\t\t\t} else {\n\t\t\t\taccountCallDataString = decodedParams[2];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tto: decodedParams[0] as string,\n\t\t\t\t\tvalue: BigInt(decodedParams[1] as string),\n\t\t\t\t\tdata: accountCallDataString,\n\t\t\t\t\toperation: Number(decodedParams[3]),\n\t\t\t\t},\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t];\n\t\t} else {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Invalid calldata, should start with \" +\n\t\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString +\n\t\t\t\t\t\" or \" +\n\t\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOp,\n\t\t\t\t{\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tcallData: callData,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * adds a token approve call to the call data for a token paymaster\n\t * @param callData - calldata to be added to, if after decoding it is not\n\t * a multisend transaction, it will be encoded as a multisend transaction\n\t * @param tokenAddress - token to add approve for\n\t * @param paymasterAddress - paymaster to add approve for\n\t * @param approveAmount - amount to add approve for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.multisendContractAddress - defaults to\n\t * SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS\n\t * @returns callData\n\t */\n\tpublic static prependTokenPaymasterApproveToCallDataStatic(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t\toverrides: {\n\t\t\tmultisendContractAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\t\tconst [metaTransaction, safeModuleExecutorFunctionSelector] =\n\t\t\tSafeAccount.decodeAccountCallData(callData);\n\n\t\tconst approveFunctionSignature = \"approve(address,uint256)\";\n\t\tconst approveFunctionSelector = getFunctionSelector(\n\t\t\tapproveFunctionSignature,\n\t\t);\n\t\tconst approveCallData = createCallData(\n\t\t\tapproveFunctionSelector,\n\t\t\t[\"address\", \"uint256\"],\n\t\t\t[paymasterAddress, approveAmount],\n\t\t);\n\t\tconst approveMetatransaction: MetaTransaction = {\n\t\t\tto: tokenAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: approveCallData,\n\t\t\toperation: Operation.Call,\n\t\t};\n\t\tconst encodedApproveMetatransaction = encodeMultiSendCallData([\n\t\t\tapproveMetatransaction,\n\t\t]);\n\n\t\tlet multiSendCallDataParams = \"\";\n\t\tconst mutisendSelector = \"0x8d80ff0a\";\n\t\tif (metaTransaction.data.startsWith(mutisendSelector)) {\n\t\t\t//multisend\n\t\t\tconst decodedCalldata = decodeMultiSendCallData(metaTransaction.data);\n\t\t\tmultiSendCallDataParams =\n\t\t\t\tencodedApproveMetatransaction + decodedCalldata.slice(2);\n\t\t} else {\n\t\t\tconst encodedCallDataMetaTransaction = encodeMultiSendCallData([\n\t\t\t\tmetaTransaction,\n\t\t\t]);\n\t\t\tmultiSendCallDataParams =\n\t\t\t\tencodedApproveMetatransaction + encodedCallDataMetaTransaction.slice(2);\n\t\t}\n\t\tconst multiSendCallData = createCallData(\n\t\t\tmutisendSelector,\n\t\t\t[\"bytes\"],\n\t\t\t[multiSendCallDataParams],\n\t\t);\n\n\t\tconst executorFunctionCallData = SafeAccount.createAccountCallData(\n\t\t\tmultisendContractAddress,\n\t\t\t0n,\n\t\t\tmultiSendCallData,\n\t\t\tOperation.Delegate,\n\t\t\t{\n\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t},\n\t\t);\n\n\t\treturn executorFunctionCallData;\n\t}\n\n\t/**\n * @deprecated \n\t * formate a list of eip712 signatures to a useroperation signature\n\t * @param signersAddresses - signers public addresses\n\t * @param signatures - list of eip712 signatures\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic static formatEip712SignaturesToUseroperationSignature(\n\t\tsignersAddresses: string[],\n\t\tsignatures: string[],\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n isMultiChainSignature?: boolean;\n\t\t\tmerkleProof?: string;\n\t\t} = {},\n\t): string {\n\t\tif (signersAddresses.length != signatures.length) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"signersAddresses and signatures arrays should be the same length\",\n\t\t\t);\n\t\t}\n\n\t\tconst signersSignatures: SignerSignaturePair[] = [];\n\n\t\tsignersAddresses.forEach((signer, index) => {\n\t\t\tsignersSignatures.push(\n\t\t\t\t{\n\t\t\t\t\tsigner: signer.toLowerCase(),\n\t\t\t\t\tsignature: signatures[index]\n\t\t\t\t}\n\t\t\t);\n\t\t});\n\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\tsignersSignatures, {\n\t\t\t\tvalidAfter: overrides.validAfter,\n\t\t\t\tvalidUntil: overrides.validUntil,\n\t\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\t\tmultiChainMerkleProof: overrides.merkleProof,\n\t\t\t},\n\t\t);\n\t}\n \n /**\n\t * create a v0.07 or v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * @param overrides.safe4337ModuleAddress - target module address \n\t * @returns useroperation hash\n\t */\n\tprotected static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tif (\"initCode\" in useroperation) {\n\t\t\treturn SafeAccount.getUserOperationEip712Hash_V6(\n\t\t\t\tuseroperation,\n\t\t\t\tchainId,\n\t\t\t\toverrides,\n\t\t\t);\n\t\t} else {\n if(overrides.entrypointAddress){\n if(overrides.entrypointAddress.toLowerCase() === ENTRYPOINT_V9.toLowerCase()){\n return SafeAccount.getUserOperationEip712Hash_V9(\n useroperation as UserOperationV9,\n chainId,\n overrides,\n );\n }else{\n return SafeAccount.getUserOperationEip712Hash_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n }else{\n return SafeAccount.getUserOperationEip712Hash_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n\t\t}\n\t}\n \n /**\n\t * create a v0.07 or v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * @param overrides.safe4337ModuleAddress - target module address \n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n protected static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides?: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue | SafeUserOperationV6TypedMessageValue\n } {\n\t\tif (\"initCode\" in useroperation) {\n\t\t\tconst data = SafeAccount.getUserOperationEip712Data_V6(\n\t\t\t\tuseroperation,\n\t\t\t\tchainId,\n\t\t\t\toverrides,\n\t\t\t);\n return {\n domain: data.domain,\n types: data.types,\n messageValue: data.messageValue\n }\n\t\t} else {\n let data;\n if(overrides?.entrypointAddress){\n if(overrides.entrypointAddress.toLowerCase() === ENTRYPOINT_V9.toLowerCase()){\n data = SafeAccount.getUserOperationEip712Data_V9(\n useroperation as UserOperationV9,\n chainId,\n overrides,\n );\n }else{\n data = SafeAccount.getUserOperationEip712Data_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n }else{\n data = SafeAccount.getUserOperationEip712Data_V7(\n useroperation,\n chainId,\n overrides,\n );\n }\n return {\n domain: data.domain,\n types: data.types,\n messageValue: data.messageValue\n }\n\t\t}\n\t}\n\n /**\n\t * create a v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V6\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xa581c4A4DB7175302464fF3C06380BC3270b4037\"\n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data_V6(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tconst entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V6;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\"0xa581c4A4DB7175302464fF3C06380BC3270b4037\";\n\n\t\tconst messageValue: SafeUserOperationV6TypedMessageValue = {\n\t\t\tsafe: useroperation.sender,\n\t\t\tnonce: useroperation.nonce,\n\t\t\tinitCode: useroperation.initCode,\n\t\t\tcallData: useroperation.callData,\n\t\t\tcallGasLimit: useroperation.callGasLimit,\n\t\t\tverificationGasLimit: useroperation.verificationGasLimit,\n\t\t\tpreVerificationGas: useroperation.preVerificationGas,\n\t\t\tmaxFeePerGas: useroperation.maxFeePerGas,\n\t\t\tmaxPriorityFeePerGas: useroperation.maxPriorityFeePerGas,\n\t\t\tpaymasterAndData: useroperation.paymasterAndData,\n\t\t\tvalidAfter: validAfter,\n\t\t\tvalidUntil: validUntil,\n\t\t\tentryPoint: entrypointAddress,\n\t\t};\n\n\t\tconst domain: SafeUserOperationTypedDataDomain = {\n\t\t\tchainId: Number(chainId),\n\t\t\tverifyingContract: safe4337ModuleAddress,\n\t\t};\n\n\t\treturn {\n\t\t\tdomain,\n\t\t\ttypes: EIP712_SAFE_OPERATION_V6_TYPE,\n\t\t\tmessageValue,\n };\n\t}\n\n\n\t/**\n\t * create a v0.06 useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V6\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xa581c4A4DB7175302464fF3C06380BC3270b4037\"\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash_V6(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t const data = SafeAccount.getUserOperationEip712Data_V6(\n useroperation, chainId, overrides)\t\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n\t}\n\n private static baseGetUserOperationEip712DataV7V8V9(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\tentrypointAddress: string,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tsafe4337ModuleAddress?: string;\n is_v9?: boolean\n\t\t} = {},\n ): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\";\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\t\tlet initCode = \"0x\";\n\t\tif (useroperation.factory != null) {\n\t\t\tinitCode = useroperation.factory;\n\t\t\tif (useroperation.factoryData != null) {\n\t\t\t\tinitCode += useroperation.factoryData.slice(2);\n\t\t\t}\n\t\t}\n\n\t\tlet paymasterAndData = \"0x\";\n\t\tif (useroperation.paymaster != null) {\n\t\t\tpaymasterAndData = useroperation.paymaster;\n\t\t\tif (useroperation.paymasterVerificationGasLimit != null) {\n\t\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterVerificationGasLimit])\n\t\t\t\t\t.slice(34);\n\t\t\t}\n\t\t\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\t\t\tpaymasterAndData += abiCoder\n\t\t\t\t\t.encode([\"uint128\"], [useroperation.paymasterPostOpGasLimit])\n\t\t\t\t\t.slice(34);\n\t\t\t}\n\t\t\tif (useroperation.paymasterData != null) {\n\t const PAYMASTER_SIG_MAGIC = '22e325a297439656';\n\t if(\n\t overrides.is_v9 &&\n\t useroperation.paymasterData.toLowerCase().endsWith(PAYMASTER_SIG_MAGIC)\n\t ){\n\t const sigLenHex = useroperation.paymasterData.slice(\n\t useroperation.paymasterData.length - 16 - 4,\n\t useroperation.paymasterData.length - 16\n\t );\n\t const sigLen = parseInt(sigLenHex, 16);\n\t const prefixEnd = useroperation.paymasterData.length - 16 - 4 - sigLen * 2;\n\t paymasterAndData += useroperation.paymasterData.slice(0, prefixEnd).replaceAll(\"0x\", \"\") + PAYMASTER_SIG_MAGIC;\n\t }else{\n\t paymasterAndData += useroperation.paymasterData.slice(2);\n\t }\n\t\t\t}\n\t\t}\n\t\tconst messageValue: SafeUserOperationV7TypedMessageValue = {\n\t\t\tsafe: useroperation.sender,\n\t\t\tnonce: useroperation.nonce,\n\t\t\tinitCode: initCode,\n\t\t\tcallData: useroperation.callData,\n\t\t\tverificationGasLimit: useroperation.verificationGasLimit,\n\t\t\tcallGasLimit: useroperation.callGasLimit,\n\t\t\tpreVerificationGas: useroperation.preVerificationGas,\n\t\t\tmaxPriorityFeePerGas: useroperation.maxPriorityFeePerGas,\n\t\t\tmaxFeePerGas: useroperation.maxFeePerGas,\n\t\t\tpaymasterAndData, \n\t\t\tvalidAfter: validAfter,\n\t\t\tvalidUntil: validUntil,\n\t\t\tentryPoint: entrypointAddress,\n\t\t};\n\t\tconst domain: SafeUserOperationTypedDataDomain = {\n\t\t\tchainId: Number(chainId),\n\t\t\tverifyingContract: safe4337ModuleAddress,\n\t\t};\n return {\n\t\t\tdomain,\n\t\t\ttypes: EIP712_SAFE_OPERATION_V7_TYPE,\n\t\t\tmessageValue,\n };\n }\n\n /**\n\t * create a v0.07 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V7\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\"\n * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data_V7(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n ): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n return SafeAccount.baseGetUserOperationEip712DataV7V8V9(\n useroperation,\n chainId,\n overrides.entrypointAddress??ENTRYPOINT_V7,\n overrides\n );\n }\n\n\t/**\n\t * create a v0.07 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V7\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\"\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash_V7(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n const data = SafeAccount.getUserOperationEip712Data_V7(\n useroperation, chainId, overrides)\t\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n\t}\n\n /**\n\t * create a v0.09 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V9\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42\"\n * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data_V9(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n ): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42\";\n\n return SafeAccount.baseGetUserOperationEip712DataV7V8V9(\n useroperation,\n chainId,\n overrides.entrypointAddress??ENTRYPOINT_V9,\n {\n ...overrides,\n safe4337ModuleAddress,\n is_v9: true\n }\n );\n }\n\n\t/**\n\t * create a v0.09 useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V9\n\t * @param overrides.safe4337ModuleAddress - defaults to \"0xE0049883864b20728b76B5cf265765B45162516D\"\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash_V9(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n const data = SafeAccount.getUserOperationEip712Data_V9(\n useroperation, chainId, overrides)\t\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n\t}\n\n\t/**\n * @deprecated\n\t * formate an eip712 signature to a useroperation signature\n\t * @param signature - an eip712 signature\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns formated signature\n\t */\n\tpublic static formatEip712SingleSignatureToUseroperationSignature(\n\t\tsignature: string,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n isMultiChainSignature?: boolean;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t[{\n\t\t\t\tsigner: \"0x0000000000000000000000000000000000000000\", // any random address\n\t\t\t\tsignature\n\t\t\t}],\n\t\t\toverrides\n\t\t);\n\t}\n\n\t/**\n\t * sends a useroperation to a bundler rpc\n\t * @param userOperation - useroperation to send\n\t * @param bundlerRpc - bundler rpc to send useroperation\n\t * @returns promise with SendUseroperationResponse\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = new Bundler(bundlerRpc);\n\t\tconst sendUserOperationRes = await bundler.sendUserOperation(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\n\t\treturn new SendUseroperationResponse(\n\t\t\tsendUserOperationRes,\n\t\t\tbundler,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\t}\n\n\t/**\n\t * calculate account address and initcode from owners\n\t * @param owners - list of account owners addresses\n\t * @param overrides - override values to change the initialization default values\n\t * @returns account address ,factory address and factorydata\n\t */\n\tprotected static createAccountAddressAndFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: BaseInitOverrides,\n\t\tsafe4337ModuleAddress: string,\n\t\tsafeModuleSetupAddress: string,\n\t): [string, string, string] {\n\t\tif (owners.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one owner\");\n\t\t}\n\t\tconst initializerCallData = SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\toverrides.threshold ?? 1,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress ??\n\t\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,\n\t\t);\n\n\t\tlet safeAccountFactory;\n\t\tif (overrides.safeAccountFactoryAddress != null) {\n\t\t\tsafeAccountFactory = new SafeAccountFactory(\n\t\t\t\toverrides.safeAccountFactoryAddress,\n\t\t\t);\n\t\t} else {\n\t\t\tsafeAccountFactory = new SafeAccountFactory();\n\t\t}\n\t\tconst safeSingleton =\n\t\t\toverrides.safeAccountSingleton ?? Safe_L2_V1_4_1;\n\t\tconst sender = this.createProxyAddress(initializerCallData, {\n\t\t\tc2Nonce: overrides.c2Nonce ?? 0n,\n\t\t\tsafeFactoryAddress: safeAccountFactory.address,\n\t\t\tsingletonInitHash: safeSingleton.singletonInitHash,\n\t\t});\n\n\t\tconst generatorFunctionInputParameters = [\n\t\t\tsafeSingleton.singletonAddress,\n\t\t\tinitializerCallData,\n\t\t\toverrides.c2Nonce ?? 0n,\n\t\t];\n\n\t\tconst factoryGeneratorFunctionCallData =\n\t\t\tsafeAccountFactory.getFactoryGeneratorFunctionCallData(\n\t\t\t\tgeneratorFunctionInputParameters,\n\t\t\t);\n\n\t\treturn [\n\t\t\tsender,\n\t\t\tsafeAccountFactory.address,\n\t\t\tfactoryGeneratorFunctionCallData,\n\t\t];\n\t}\n\n\tprotected static createBaseInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\tsafe4337ModuleAddress: string,\n\t\tsafeModuleSetupAddress: string,\n\t\tmultisendContractAddress: string = SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\twebAuthnSharedSigner = SafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: string = SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\teip7212WebAuthnContractVerifierForSharedSigner: string = SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,\n\t): string {\n\t\tif (owners.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one owner\");\n\t\t}\n\n\t\tif (threshold < 1) {\n\t\t\tthrow new RangeError(\"threshold should be at least one\");\n\t\t}\n\n\t\tif (threshold > owners.length) {\n\t\t\tthrow new RangeError(\"threshold can't be larger than number of owners\");\n\t\t}\n\n\t\tconst enable4337ModuleCallData = createCallData(\n\t\t\t\"0x8d0dc49f\", //enableModules\n\t\t\t[\"address[]\"],\n\t\t\t[[safe4337ModuleAddress]],\n\t\t);\n\t\tlet isInitWebAuthn = false;\n\t\tlet initializerFunctionInputParameters;\n\n\t\tconst owners_str: string[] = [];\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t} else {\n\t\t\t\towners_str.push(owner);\n\t\t\t}\n\t\t}\n\n\t\tif (isInitWebAuthn) {\n\t\t\tconst safeModuleSetupCallData: MetaTransaction = {\n\t\t\t\tto: safeModuleSetupAddress,\n\t\t\t\tvalue: 0n,\n\t\t\t\tdata: enable4337ModuleCallData,\n\t\t\t\toperation: Operation.Delegate,\n\t\t\t};\n\t\t\tconst txs = [];\n\t\t\ttxs.push(safeModuleSetupCallData);\n\t\t\tconst modOwners = [];\n\n\t\t\tlet numOfWebAuthnOwners = 0;\n\t\t\tfor (const owner of owners) {\n\t\t\t\tif (typeof owner != \"string\") {\n\t\t\t\t\tif (numOfWebAuthnOwners > 0) {\n\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t\"Only one WebAuthn owner can be set during initialization\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst addWebauthnSigner = createCallData(\n\t\t\t\t\t\t\"0x0dd9692f\", //configure\n\t\t\t\t\t\t[\"uint256\", \"uint256\", \"uint176\"],\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\towner.x,\n\t\t\t\t\t\t\towner.y,\n\t\t\t\t\t\t\t\"0x\" +\n\t\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner.slice(-4) +\n\t\t\t\t\t\t\t\teip7212WebAuthnContractVerifierForSharedSigner.slice(2),\n\t\t\t\t\t\t],\n\t\t\t\t\t);\n\n\t\t\t\t\tconst setSignerCallData: MetaTransaction = {\n\t\t\t\t\t\tto: webAuthnSharedSigner,\n\t\t\t\t\t\tvalue: 0n,\n\t\t\t\t\t\tdata: addWebauthnSigner,\n\t\t\t\t\t\toperation: Operation.Delegate,\n\t\t\t\t\t};\n\t\t\t\t\ttxs.push(setSignerCallData);\n\t\t\t\t\tmodOwners.push(webAuthnSharedSigner);\n\t\t\t\t\tnumOfWebAuthnOwners++;\n\t\t\t\t} else {\n\t\t\t\t\tmodOwners.push(owner);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst encodedInit = encodeMultiSendCallData(txs);\n\n\t\t\tconst mutisendSelector = \"0x8d80ff0a\";\n\t\t\tconst multiSendCallData = createCallData(\n\t\t\t\tmutisendSelector,\n\t\t\t\t[\"bytes\"],\n\t\t\t\t[encodedInit],\n\t\t\t);\n\n\t\t\tinitializerFunctionInputParameters = [\n\t\t\t\tmodOwners,\n\t\t\t\tthreshold,\n\t\t\t\tmultisendContractAddress, //to Contract address for optional delegate call during initialization\n\t\t\t\tmultiSendCallData, //Data payload for optional delegate call during initialization\n\t\t\t\tsafe4337ModuleAddress, //fallbackHandler Handler for fallback calls to this contract\n\t\t\t\tZeroAddress, //paymentToken (Safe specific, can be ignored)\n\t\t\t\t0, //payment (Safe specific, can be ignored)\n\t\t\t\tZeroAddress, //paymentReceiver (Safe specific, can be ignored)\n\t\t\t];\n\t\t} else {\n\t\t\tinitializerFunctionInputParameters = [\n\t\t\t\towners_str, //_owners\n\t\t\t\tthreshold, //_threshold\n\t\t\t\tsafeModuleSetupAddress, //to Contract address for optional delegate call during initialization\n\t\t\t\tenable4337ModuleCallData, //Data payload for optional delegate call during initialization\n\t\t\t\tsafe4337ModuleAddress, //fallbackHandler Handler for fallback calls to this contract\n\t\t\t\tZeroAddress, //paymentToken (Safe specific, can be ignored)\n\t\t\t\t0, //payment (Safe specific, can be ignored)\n\t\t\t\tZeroAddress, //paymentReceiver (Safe specific, can be ignored)\n\t\t\t];\n\t\t}\n\n\t\treturn createCallData(\n\t\t\tSafeAccount.initializerFunctionSelector,\n\t\t\tSafeAccount.initializerFunctionInputAbi,\n\t\t\tinitializerFunctionInputParameters,\n\t\t);\n\t}\n\n\t/**\n\t * create factory address and factoryData (initcode)\n\t * @param owners - list of account owners signers\n\t * @param overrides - overrides for the default values\n\t * @returns factoryAddress and factoryData\n\t */\n\tprotected static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: BaseInitOverrides = {},\n\t\tsafe4337ModuleAddress: string,\n\t\tsafeModuleSetupAddress: string,\n\t): [string, string] {\n\t\tif (owners.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one owner\");\n\t\t}\n\t\tconst threshold = overrides.threshold ?? 1;\n\t\tconst c2Nonce = overrides.c2Nonce ?? 0;\n\t\tif (threshold < 1) {\n\t\t\tthrow new RangeError(\"threshold should be at least one\");\n\t\t}\n\n\t\tif (threshold > owners.length) {\n\t\t\tthrow new RangeError(\"threshold can't be larger than number of owners\");\n\t\t}\n\n\t\tif (c2Nonce < 0n) {\n\t\t\tthrow new RangeError(\"c2Nonce can't be negative\");\n\t\t}\n\n\t\tconst initializerCallData = SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\toverrides.threshold ?? 1,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress ??\n\t\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,\n\t\t);\n\n\t\tlet safeAccountFactory;\n\t\tif (overrides.safeAccountFactoryAddress != null) {\n\t\t\tsafeAccountFactory = new SafeAccountFactory(\n\t\t\t\toverrides.safeAccountFactoryAddress,\n\t\t\t);\n\t\t} else {\n\t\t\tsafeAccountFactory = new SafeAccountFactory();\n\t\t}\n\n\t\tconst safeSingleton =\n\t\t\toverrides.safeAccountSingleton ?? Safe_L2_V1_4_1;\n\n\t\tconst generatorFunctionInputParameters = [\n\t\t\tsafeSingleton.singletonAddress,\n\t\t\tinitializerCallData,\n\t\t\tc2Nonce,\n\t\t];\n\n\t\tconst factoryGeneratorFunctionCallData =\n\t\t\tsafeAccountFactory.getFactoryGeneratorFunctionCallData(\n\t\t\t\tgeneratorFunctionInputParameters,\n\t\t\t);\n\n\t\treturn [safeAccountFactory.address, factoryGeneratorFunctionCallData];\n\t}\n\n\t/**\n\t * a non static wrapper function for prependTokenPaymasterApproveToCallDataStatic\n\t * which adds a token approve call to the call data for a token paymaster\n\t * @param callData - calldata to be added to, if after decoding it is not\n\t * a multisend transaction, it will be encoded as a multisend transaction\n\t * @param tokenAddress - token to add approve for\n\t * @param paymasterAddress - paymaster to add approve for\n\t * @param approveAmount - amount to add approve for\n\t * @param overrides - overrides for the default values\n\t * @param overrides.multisendContractAddress - defaults to\n\t * SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS\n\t * @returns callData\n\t */\n\tpublic prependTokenPaymasterApproveToCallData(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t\toverrides: {\n\t\t\tmultisendContractAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\t\treturn SafeAccount.prependTokenPaymasterApproveToCallDataStatic(\n\t\t\tcallData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tapproveAmount,\n\t\t\t{\n\t\t\t\tmultisendContractAddress,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * estimate gas limits for a useroperation\n\t * @param userOperation - useroperation to estimate gas for\n\t * @param bundlerRpc - bundler rpc for gas estimation\n\t * @param overrides - overrides for the default values\n\t * @param overrides.stateOverrideSet - state override values to set during gs estimation\n\t * @param overrides.dummySignerSignaturePairs - list of dummy signers signature pairs\n\t * defaults to a single eoa signature\n\t * @returns promise with [preVerificationGas, verificationGasLimit, callGasLimit]\n\t */\n\tpublic async baseEstimateUserOperationGas(\n\t\tuserOperation: UserOperationV6 | UserOperationV7,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n expectedSigners?: Signer[];\n webAuthnSharedSigner?: string;\n webAuthnSignerFactory?: string;\n webAuthnSignerSingleton?: string;\n webAuthnSignerProxyCreationCode?: string;\n eip7212WebAuthnPrecompileVerifier?: string;\n eip7212WebAuthnContractVerifier?: string;\n isMultiChainSignature?: boolean;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n const validAfter = 0xffffffffffffn;\n\t\tconst validUntil = 0xffffffffffffn;\n\n\t\tif (overrides.dummySignerSignaturePairs != null) {\n if(overrides.expectedSigners != null){\n throw new RangeError(\n \"Can't use both dummySignerSignaturePairs and expectedSigners overrides.\",\n );\n }\n\t\t\tif (overrides.dummySignerSignaturePairs.length < 1) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\"Number of dummy signers signature pairs can't be less than 1\",\n\t\t\t\t);\n\t\t\t}\n\t\t userOperation.signature =\n\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\t\toverrides.dummySignerSignaturePairs,\n\t\t\t\t\t{\n\t\t\t\t\t\tvalidAfter,\n\t\t\t\t\t\tvalidUntil,\n isMultiChainSignature: overrides.isMultiChainSignature\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t} else if (overrides.expectedSigners != null) {\n let initCode;\n\n if (\"initCode\" in userOperation) {\n initCode = userOperation.initCode;\n }else{\n initCode = userOperation.factory;\n }\n const isInit = initCode != null && initCode != \"0x\";\n \n const dummySignerSignaturePairs = SafeAccount.createDummySignerSignaturePairForExpectedSigners(\n overrides.expectedSigners,\n {\n isInit,\n webAuthnSharedSigner:overrides.webAuthnSharedSigner,\n eip7212WebAuthnPrecompileVerifier:overrides.eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier:overrides.eip7212WebAuthnContractVerifier,\n webAuthnSignerFactory:overrides.webAuthnSignerFactory,\n webAuthnSignerSingleton:overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode:overrides.webAuthnSignerProxyCreationCode,\n validAfter,\n validUntil,\n }\n )\n userOperation.signature =\n SafeAccount.formatSignaturesToUseroperationSignature(\n dummySignerSignaturePairs,\n {\n validAfter,\n validUntil,\n isMultiChainSignature: overrides.isMultiChainSignature\n },\n );\n\t\t} else if (userOperation.signature.length < 3) {\n userOperation.signature =\n SafeAccount.formatSignaturesToUseroperationSignature(\n [EOADummySignerSignaturePair],\n {\n validAfter,\n validUntil,\n isMultiChainSignature: overrides.isMultiChainSignature\n },\n );\n }\n \n\t\tconst bundler = new Bundler(bundlerRpc);\n\n\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\tuserOperation.maxFeePerGas = 0n;\n\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\toverrides.stateOverrideSet,\n\t\t);\n\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\n\t\tconst preVerificationGas = BigInt(estimation.preVerificationGas);\n\n\t\tlet verificationGasLimit: bigint;\n\t\tif (overrides.dummySignerSignaturePairs != null) {\n\t\t\tverificationGasLimit =\n\t\t\t\tBigInt(estimation.verificationGasLimit) +\n\t\t\t\tBigInt(overrides.dummySignerSignaturePairs.length) * 55_000n;\n\t\t} else {\n\t\t\tverificationGasLimit = BigInt(estimation.verificationGasLimit);\n\t\t}\n\n\t\tconst callGasLimit = BigInt(estimation.callGasLimit);\n\n\t\treturn [preVerificationGas, verificationGasLimit, callGasLimit];\n\t}\n\n\t/**\n\t * createBaseUserOperationAndFactoryAddressAndFactoryData will\n\t * determine the nonce, fetch the gas prices,\n\t * estimate gas limits and return a useroperation to be signed.\n\t * you can override all these values using the overrides parameter.\n\t * @param transactions - metatransaction list to be encoded\n\t * @param providerRpc - node rpc to fetch account nonce and gas prices\n\t * @param bundlerRpc - bundler rpc for gas estimation\n\t * @param overrides - overrides for the default values\n\t * @returns a promise with (base useroperation, factoryAddress, factoryData)\n\t */\n\tprotected async createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\ttransactions: MetaTransaction[],\n\t\tisV06: boolean,\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateBaseUserOperationOverrides = {},\n\t): Promise<[BaseUserOperation, string | null, string | null]> {\n\t\tif (transactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one transaction\");\n\t\t}\n\t\tconst webAuthnSharedSigner =\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n\t\tconst safeModuleExecutorFunctionSelector =\n\t\t\toverrides.safeModuleExecutorFunctionSelector ??\n\t\t\tSafeAccount.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;\n\t\tconst multisendContractAddress =\n\t\t\toverrides.multisendContractAddress ??\n\t\t\tSafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\n\t\tlet nonce:bigint | null = null;\n\t\tlet nonceOp:Promise<bigint> | null = null;\n\n\t\tif (overrides.nonce == null) {\n\t\t\tif (providerRpc != null) {\n\t\t\t\tnonceOp = fetchAccountNonce(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc cant't be null if nonce is not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnonce = overrides.nonce;\n\t\t}\n\n if (\n\t\t\ttypeof overrides.maxFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxFeePerGas overrid can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxPriorityFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxPriorityFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas overrid can't be negative\");\n\t\t}\n let maxFeePerGas = BaseUserOperationDummyValues.maxFeePerGas;\n\t\tlet maxPriorityFeePerGas =\n\t\t\tBaseUserOperationDummyValues.maxPriorityFeePerGas;\n\n let gasPriceOp:Promise<[bigint, bigint]> | null = null;\n if (\n\t\t\toverrides.maxFeePerGas == null ||\n\t\t\toverrides.maxPriorityFeePerGas == null\n\t\t) {\n gasPriceOp = handlefetchGasPrice(\n providerRpc, overrides.polygonGasStation, overrides.gasLevel\n )\n }\n \n if(gasPriceOp != null && nonceOp != null){\n await Promise.all([nonceOp, gasPriceOp]).then((values) => {\n nonce = values[0];\n [maxFeePerGas, maxPriorityFeePerGas] = values[1]; \n });\n }else if(gasPriceOp != null){\n [maxFeePerGas, maxPriorityFeePerGas] = await gasPriceOp; \n }else if(nonceOp != null){\n nonce = await nonceOp;\n }\n \n\t\tmaxFeePerGas = overrides.maxFeePerGas ??\n maxFeePerGas * BigInt((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100n;\n\t\tmaxPriorityFeePerGas = overrides.maxPriorityFeePerGas ??\n maxPriorityFeePerGas * BigInt((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / 100n;\n\n const eip7212WebAuthnPrecompileVerifier =\n overrides.eip7212WebAuthnPrecompileVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n const eip7212WebAuthnContractVerifier =\n overrides.eip7212WebAuthnContractVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n const webAuthnSignerFactory =\n overrides.webAuthnSignerFactory ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n const webAuthnSignerSingleton =\n overrides.webAuthnSignerSingleton ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\tlet factoryAddress: string | null = this.factoryAddress;\n\t\tlet factoryData: string | null = this.factoryData;\n \n if(nonce == null){\n\t\t\tthrow new RangeError(\"failed to determine nonce\");\n }\n else if (nonce < 0n) {\n\t\t\tthrow new RangeError(\"nonce can't be negative\");\n\t\t}\n else if (nonce > 0n) {\n\t\t\tfactoryAddress = null;\n\t\t\tfactoryData = null;\n\t\t} \n else if (this.isInitWebAuthn) { //nonce = 0\n\t\t\tif (this.x == null || this.y == null) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\"Invalide account initialization with Webauthnn signer.\" +\n\t\t\t\t\t\t\"Webauthnn signer publickey can be null!!\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst createDeterministicWebAuthnVerifierOwner: MetaTransaction =\n\t\t\t\tSafeAccount.createDeployWebAuthnVerifierMetaTransaction(\n\t\t\t\t\tthis.x,\n\t\t\t\t\tthis.y,\n\t\t\t\t\t{\n\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\tconst deterministicWebAuthnVerifierAddress =\n\t\t\t\tSafeAccount.createWebAuthnSignerVerifierAddress(this.x, this.y, {\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t});\n\n\t\t\tconst swapSingletonWithDeterministicWebAuthnVerifierOwnerCallData =\n\t\t\t\tcreateCallData(\n\t\t\t\t\t\"0xe318b52b\", //swapOwner\n\t\t\t\t\t[\n\t\t\t\t\t\t\"address\", //prevOwner\n\t\t\t\t\t\t\"address\", //oldOwner\n\t\t\t\t\t\t\"address\", //newOwner\n\t\t\t\t\t],\n\t\t\t\t\t[\n\t\t\t\t\t\t\"0x0000000000000000000000000000000000000001\", //SENTINEL_OWNERS\n\t\t\t\t\t\twebAuthnSharedSigner,\n\t\t\t\t\t\tdeterministicWebAuthnVerifierAddress,\n\t\t\t\t\t],\n\t\t\t\t);\n\n\t\t\tconst swapSingletonWithDeterministicWebAuthnVerifierOwner: MetaTransaction =\n\t\t\t\t{\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tvalue: 0n,\n\t\t\t\t\tdata: swapSingletonWithDeterministicWebAuthnVerifierOwnerCallData,\n\t\t\t\t};\n\n\t\t\t/*const clearWebauthnSharedSignerCallData = createCallData(\n\t\t\t\t\"0x0dd9692f\", //configure\n\t\t\t\t[\"uint256\", \"uint256\", \"uint176\"],\n\t\t\t\t[0, 0, 0],\n\t\t\t);\n \n\t\t\tconst clearWebauthnSharedSigner: MetaTransaction = {\n\t\t\t\tto: webAuthnSharedSigner,\n\t\t\t\tvalue: 0n,\n\t\t\t\tdata: clearWebauthnSharedSignerCallData,\n\t\t\t\toperation: Operation.Delegate,\n\t\t\t};*/\n\n\t\t\ttransactions = [\n\t\t\t\tcreateDeterministicWebAuthnVerifierOwner,\n\t\t\t\tswapSingletonWithDeterministicWebAuthnVerifierOwner,\n\t\t\t\t//clearWebauthnSharedSigner,\n\t\t\t].concat(transactions);\n\t\t}\n\n\n\t\tlet callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tif (transactions.length == 1) {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataSingleTransaction(\n\t\t\t\t\ttransactions[0],\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataBatchTransactions(\n\t\t\t\t\ttransactions,\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector:\n\t\t\t\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t\t\t\tmultisendContractAddress: multisendContractAddress,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n\n if(this.onChainIdentifier != null){\n callData = callData + this.onChainIdentifier;\n }\n\n\t\tconst userOperation = {\n\t\t\t...BaseUserOperationDummyValues,\n\t\t\tsender: this.accountAddress,\n\t\t\tnonce: nonce,\n\t\t\tcallData: callData,\n\t\t\tmaxFeePerGas: maxFeePerGas,\n\t\t\tmaxPriorityFeePerGas: maxPriorityFeePerGas,\n\t\t};\n\n\t\tlet preVerificationGas = BaseUserOperationDummyValues.preVerificationGas;\n\t\tlet verificationGasLimit =\n\t\t\tBaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n\t\t\tif (bundlerRpc != null) {\n\t\t\t\tuserOperation.callGasLimit = 0n;\n\t\t\t\tuserOperation.verificationGasLimit = 0n;\n\t\t\t\tuserOperation.preVerificationGas = 0n;\n\t\t\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\t\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\t\t\tuserOperation.maxFeePerGas = 0n;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\n\t\t\t\tlet userOperationToEstimate: UserOperationV6 | UserOperationV7;\n\t\t\t\tif (isV06) {\n\t\t\t\t\tlet initCode = \"0x\";\n\t\t\t\t\tif (factoryAddress != null) {\n\t\t\t\t\t\tinitCode = factoryAddress;\n\n\t\t\t\t\t\tif (factoryData != null) {\n\t\t\t\t\t\t\tinitCode += factoryData.slice(2);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tuserOperationToEstimate = {\n\t\t\t\t\t\t...userOperation,\n\t\t\t\t\t\tinitCode: initCode,\n\t\t\t\t\t\tpaymasterAndData: \"0x\",\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tuserOperationToEstimate = {\n\t\t\t\t\t\t...userOperation,\n\t\t\t\t\t\tfactory: factoryAddress,\n\t\t\t\t\t\tfactoryData: factoryData,\n\t\t\t\t\t\tpaymaster: null,\n\t\t\t\t\t\tpaymasterVerificationGasLimit: null,\n\t\t\t\t\t\tpaymasterPostOpGasLimit: null,\n\t\t\t\t\t\tpaymasterData: null,\n\t\t\t\t\t};\n\n const parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n if(parallelPaymasterInitValues != null){\n if(\n !parallelPaymasterInitValues.paymasterData.endsWith(\"22e325a297439656\")\n ){\n throw new RangeError(\n \"Invalid paymasterData override, it must end with the PAYMASTER_SIG_MAGIC '22e325a297439656'.\"\n );\n }\n if(this.entrypointAddress != ENTRYPOINT_V9){\n throw new RangeError(\n \"parallelPaymasterInitValues only works with ep v0.9\"\n );\n }\n userOperationToEstimate.paymaster = parallelPaymasterInitValues.paymaster;\n userOperationToEstimate.paymasterVerificationGasLimit =\n parallelPaymasterInitValues.paymasterVerificationGasLimit;\n userOperationToEstimate.paymasterPostOpGasLimit =\n parallelPaymasterInitValues.paymasterPostOpGasLimit;\n userOperationToEstimate.paymasterData =\n parallelPaymasterInitValues.paymasterData;\n }\n\t\t\t\t}\n const validAfter = 0xffffffffffffn;\n const validUntil = 0xffffffffffffn;\n\n\t\t\t\tlet dummySignerSignaturePairs;\n\t\t\t\tif (overrides.dummySignerSignaturePairs != null) {\n if(overrides.expectedSigners != null){\n throw new RangeError(\n\t\t\t\t\t\t\t\"Can't use both dummySignerSignaturePairs and expectedSigners overrides.\",\n\t\t\t\t\t\t);\n }\n\t\t\t\t\tif (overrides.dummySignerSignaturePairs.length < 1) {\n\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t\"Number of dummySignerSignaturePairs can't be less than 1\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tdummySignerSignaturePairs = overrides.dummySignerSignaturePairs;\n\t\t\t\t} else {\n if(overrides.expectedSigners == null){\n dummySignerSignaturePairs = [EOADummySignerSignaturePair];\n }else{\n const isInit = factoryAddress != null && factoryAddress != \"0x\";\n dummySignerSignaturePairs = SafeAccount.createDummySignerSignaturePairForExpectedSigners(\n overrides.expectedSigners,\n {\n isInit,\n webAuthnSharedSigner,\n eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier,\n webAuthnSignerFactory,\n webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode,\n validAfter,\n validUntil,\n }\n )\n }\n\t\t\t\t}\n\t\t\t\tuserOperation.signature =\n\t\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\t\t\tdummySignerSignaturePairs,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalidAfter,\n\t\t\t\t\t\t\tvalidUntil,\n\t\t\t\t\t\t\twebAuthnSharedSigner,\n isMultiChainSignature: overrides.isMultiChainSignature\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t[preVerificationGas, verificationGasLimit, callGasLimit] =\n\t\t\t\t\tawait this.baseEstimateUserOperationGas(\n\t\t\t\t\t\tuserOperationToEstimate,\n\t\t\t\t\t\tbundlerRpc,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstateOverrideSet: overrides.state_override_set,\n\t\t\t\t\t\t\tisMultiChainSignature:overrides.isMultiChainSignature\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\tverificationGasLimit +=\n\t\t\t\t\tBigInt(dummySignerSignaturePairs.length) * 55_000n;\n\n\t\t\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc cant't be null if preVerificationGas,\" +\n\t\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\ttypeof overrides.preVerificationGas === \"bigint\" &&\n\t\t\toverrides.preVerificationGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"preVerificationGas overrid can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.verificationGasLimit === \"bigint\" &&\n\t\t\toverrides.verificationGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"verificationGasLimit overrid can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.callGasLimit === \"bigint\" &&\n\t\t\toverrides.callGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"callGasLimit overrid can't be negative\");\n\t\t}\n\n\t\tuserOperation.preVerificationGas = overrides.preVerificationGas ??\n preVerificationGas * BigInt((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100n;\n\n\t\tuserOperation.verificationGasLimit = overrides.verificationGasLimit ??\n verificationGasLimit * BigInt((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100n;\n\n\t\tuserOperation.callGasLimit = overrides.callGasLimit ??\n callGasLimit * BigInt((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) / 100n;\n\n\t\treturn [userOperation, factoryAddress, factoryData];\n\t}\n \n\t/**\n\t * create a useroperation signature\n\t * @param useroperation - useroperation to sign\n\t * @param privateKeys - for the signers\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic static baseSignSingleUserOperation(\n\t\tuseroperation: UserOperationV6 | UserOperationV7,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\tentrypointAddress: string,\n\t\tsafe4337ModuleAddress: string,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tisMultiChainSignature?: boolean;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tif (privateKeys.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one privateKey\");\n\t\t}\n\t\tif (chainId < 0n) {\n\t\t\tthrow new RangeError(\"chainId can't be negative\");\n\t\t}\n\t\tif (validAfter < 0n) {\n\t\t\tthrow new RangeError(\"validAfter can't be negative\");\n\t\t}\n\t\tif (validUntil < 0n) {\n\t\t\tthrow new RangeError(\"validUntil can't be negative\");\n\t\t}\n\n\t\tconst userOperationEip712Hash = SafeAccount.getUserOperationEip712Hash(\n\t\t\tuseroperation,\n\t\t\tchainId,\n\t\t\t{\n\t\t\t\tvalidAfter,\n\t\t\t\tvalidUntil,\n\t\t\t\tentrypointAddress,\n\t\t\t\tsafe4337ModuleAddress,\n\t\t\t},\n\t\t);\n\n const signerSignaturePairs: SignerSignaturePair[] = [];\n\t\tfor (const privateKey of privateKeys) {\n\t\t\tconst wallet = new Wallet(privateKey);\n\t\t\tconst signature = wallet.signingKey.sign(\n\t\t\t\tuserOperationEip712Hash,\n\t\t\t).serialized;\n signerSignaturePairs.push({\n signer: wallet.address,\n signature\n });\n\t\t}\n\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n signerSignaturePairs,\n\t\t\t{\n\t\t\t\tvalidAfter,\n\t\t\t\tvalidUntil,\n isMultiChainSignature:overrides.isMultiChainSignature\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * compute the deterministic address for a webauthn proxy verifier based on a\n\t * webauthn public key(x, y)\n\t * @param x - webauthn public key x parameter\n\t * @param y - webauthn public key y parameter\n\t * @param overrides - overrides for the default values\n\t * @returns webauthn verifier address\n\t */\n\tpublic static createWebAuthnSignerVerifierAddress(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): string {\n\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\tconst webAuthnSignerFactory =\n\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\tconst webAuthnSignerSingleton =\n\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n\n\t\tif (\n\t\t\teip7212WebAuthnPrecompileVerifier.length != 42 ||\n\t\t\teip7212WebAuthnPrecompileVerifier.slice(0, 38) != ZeroAddress.slice(0, 38)\n\t\t) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"Invalide precompile address. \" +\n\t\t\t\t\t\"It should have the format 0x000000000000000000000000000000000000____\",\n\t\t\t);\n\t\t}\n\t\tconst codeHash = keccak256(\n\t\t\tsolidityPacked(\n\t\t\t\t[\"bytes\", \"uint256\", \"uint256\", \"uint256\", \"uint256\"],\n\t\t\t\t[\n\t\t\t\t\toverrides.webAuthnSignerProxyCreationCode??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\t\t\twebAuthnSignerSingleton,\n\t\t\t\t\tx,\n\t\t\t\t\ty,\n\t\t\t\t\t\"0x\" +\n\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier.slice(-4) +\n\t\t\t\t\t\teip7212WebAuthnContractVerifier.slice(2),\n\t\t\t\t],\n\t\t\t),\n\t\t);\n\n\t\tconst proxyAdd = solidityPackedKeccak256(\n\t\t\t[\"bytes1\", \"address\", \"bytes32\", \"bytes32\"],\n\t\t\t[\n\t\t\t\t\"0xff\",\n\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000000\",\n\t\t\t\tcodeHash,\n\t\t\t],\n\t\t).slice(-40);\n\n\t\treturn \"0x\" + proxyAdd;\n\t}\n\n\t/**\n\t * formate a list of eip712 signatures to a useroperation signature\n\t * @param signerSignaturePairs - a list of a pair of a signer and it's signature\n\t * @param overrides - overrides for the default values\n\t * @returns signature\n\t */\n\tpublic static formatSignaturesToUseroperationSignature(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toverrides: WebAuthnSignatureOverrides = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tconst signature = this.buildSignaturesFromSingerSignaturePairs(\n\t\t\tsignerSignaturePairs,\n\t\t\toverrides,\n\t\t);\n\n\t\tif(overrides.isMultiChainSignature){\n\t\t\tif(overrides.multiChainMerkleProof != null){\n const merkleProofLength =\n overrides.multiChainMerkleProof.slice(2).length; // wihout 0x prefix\n\t\t\t\tif(\n // 1 byte has a length of 2 hex chars\n // minimum proof consist of at least two hashes, 2 * 2 * 32 = 128\n\t\t\t\t\tmerkleProofLength < 128 ||\n // a valid proof length should be a multiple of 2 * 32 = 64\n\t\t\t\t\tmerkleProofLength % 64 != 0\n\t\t\t\t){\n\t\t\t\t\tthrow new RangeError(\"invalid multiChainMerkleProof length.\");\n\t\t\t\t}\n\t\t\t\tconst merkleTreeDepth = (merkleProofLength / 64) - 1;\n\t\t\t\tlet merkleTreeDepthHex = merkleTreeDepth.toString(16);\n\n // create a 0x prefixed hex with an even length of chars\n if(merkleTreeDepthHex.length % 2 == 0){\n merkleTreeDepthHex = \"0x\" + merkleTreeDepthHex;\n }else{\n merkleTreeDepthHex = \"0x0\" + merkleTreeDepthHex;\n }\n\n\t\t\t\treturn solidityPacked(\n\t\t\t\t\t[\"bytes1\", \"uint48\", \"uint48\", \"bytes\"],\n\t\t\t\t\t[\n merkleTreeDepthHex,\n validAfter,\n validUntil,\n overrides.multiChainMerkleProof + signature.slice(2)\n ],\n\t\t\t\t);\n\t\t\t}else{\n //no proof means a single useroperation\n\t\t\t\treturn solidityPacked(\n\t\t\t\t\t[\"bytes1\", \"uint48\", \"uint48\", \"bytes\"],\n\t\t\t\t\t[\n \"0x00\", // single useroperation - merkle depth is 0\n validAfter,\n validUntil,\n signature\n ],\n\t\t\t\t);\n\t\t\t}\n\t\t}else{\n\t\t\treturn solidityPacked(\n\t\t\t\t[\"uint48\", \"uint48\", \"bytes\"],\n\t\t\t\t[validAfter, validUntil, signature],\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * calculate a signer public address lowercase\n\t * @param signer - a signer to compute address for\n\t * @param overrides - overrides for the default values\n\t * @returns signer address\n\t */\n\tpublic static getSignerLowerCaseAddress(\n\t\tsigner: Signer,\n\t\toverrides: WebAuthnSignatureOverrides = {},\n\t): string {\n\t\tif (typeof signer == \"string\") {\n\t\t\treturn signer.toLowerCase();\n\t\t} else {\n\t\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\t\tconst webAuthnSignerFactory =\n\t\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\t\tconst webAuthnSignerSingleton =\n\t\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\treturn SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\tsigner.x,\n\t\t\t\tsigner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t).toLowerCase();\n\t\t}\n\t}\n\n\t/**\n\t * sorts a list of signerSginaturesPairs in place based on the signer\n\t * public address, as the signatures needs to be sorted to be validated\n\t * by a safe account\n\t * @param signer - a signer to compute address for\n\t * @param overrides - overrides for the default values\n\t */\n\tpublic static sortSignatures(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toverrides: WebAuthnSignatureOverrides = {},\n\t) {\n\t\tsignerSignaturePairs.sort((left, right) =>\n\t\t\tSafeAccount.getSignerLowerCaseAddress(\n\t\t\t\tleft.signer,\n\t\t\t\toverrides,\n\t\t\t).localeCompare(\n\t\t\t\tSafeAccount.getSignerLowerCaseAddress(right.signer, overrides),\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * formate a list of eip712 signatures to a safe signature(without the time range)\n\t * @param signerSignaturePairs - a list of a pair of a signer and it's signature\n\t * @param overrides - overrides for the default values\n\t * @returns signature\n\t */\n\tpublic static buildSignaturesFromSingerSignaturePairs(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): string {\n\t\tSafeAccount.sortSignatures(\n\t\t\tsignerSignaturePairs,\n\t\t\twebAuthnSignatureOverrides,\n\t\t);\n\t\tconst start = 65 * signerSignaturePairs.length;\n\t\tconst { segments } = signerSignaturePairs.reduce(\n\t\t\t({ segments, offset }, { signer, signature, isContractSignature }) => {\n\t\t\t\tisContractSignature = isContractSignature || typeof signer != \"string\";\n\t\t\t\tif (isContractSignature) {\n\t\t\t\t\tif (typeof signer != \"string\") { //webauthn signature\n //check if this is a webAuthn signature to replace \n //the signer address with the shared signer address\n //if init\n\t\t\t\t\t\tif (webAuthnSignatureOverrides.isInit == null) {\n\t\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t\t\"Must define isInit parameter when using WebAuthn\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (webAuthnSignatureOverrides.isInit) {\n\t\t\t\t\t\t\tconst webauthnsharedsigner =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSharedSigner ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n\t\t\t\t\t\t\tsigner = webauthnsharedsigner;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\t\t\t\t\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\t\t\t\t\t\tconst webAuthnSignerFactory =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerFactory ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\t\t\t\t\t\tconst webAuthnSignerSingleton =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerSingleton ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n webAuthnSignatureOverrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\t\t\t\t\tsigner = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\t\t\t\t\tsigner.x,\n\t\t\t\t\t\t\t\tsigner.y,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\t\t\t\t\twebAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n }\n return {\n segments: [\n ...segments,\n ethers.solidityPacked(\n [\"uint256\", \"uint256\", \"uint8\"],\n [signer, start + offset, 0],\n ),\n ],\n offset: offset + 32 + ethers.dataLength(signature),\n };\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t...segments,\n\t\t\t\t\t\t\tethers.solidityPacked([\"bytes\"], [signature]),\n\t\t\t\t\t\t],\n\t\t\t\t\t\toffset: offset,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ segments: [] as string[], offset: 0 },\n\t\t);\n\t\treturn ethers.concat([\n\t\t\t...segments,\n\t\t\t...signerSignaturePairs.map(({ signer, signature, isContractSignature }) => {\n isContractSignature = isContractSignature || typeof signer != \"string\";\n if (isContractSignature) {\n return ethers.solidityPacked(\n [\"uint256\", \"bytes\"],\n [ethers.dataLength(signature), signature],\n )\n }else{\n //only append signatures if a contract signature\n return \"0x\";\n }\n },\n\t\t\t),\n\t\t]);\n\t}\n\n\t/**\n\t * encode webauthn signature from WebauthnSignatureData\n\t * @param signatureData - signature data to format\n\t * @returns formatted signature\n\t */\n\tpublic static createWebAuthnSignature(\n\t\tsignatureData: WebauthnSignatureData,\n\t): string {\n\t\treturn ethers.AbiCoder.defaultAbiCoder().encode(\n\t\t\t[\"bytes\", \"bytes\", \"uint256[2]\"],\n\t\t\t[\n\t\t\t\tnew Uint8Array(signatureData.authenticatorData),\n\t\t\t\tsignatureData.clientDataFields,\n\t\t\t\tsignatureData.rs,\n\t\t\t],\n\t\t);\n\t}\n\n\t/**\n\t * create a swapOwner metatransaction and create a metatransaction to\n\t * deploy a webauthn verifier owner if not deployed and it will automatically\n\t * fetch the prevowner needed for the swap\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * (to get the prevOwner paramter) and to check if a webauthn newowner verifier \n * is already deployed.\n\t * @param newOwner - newOwner public address\n\t * @param oldOwner - oldOwner to replace public address\n\t * @param overrides - overrides for the default values\n\t * @param overrides.prevOwner - if set, it will be used as the previous owner and\n\t * nideRpcUrl won't be used to fetch it\n\t * @returns a promise of a list of metaTransactions\n\t */\n\tpublic async createSwapOwnerMetaTransactions(\n\t\tnodeRpcUrl: string,\n\t\tnewOwner: Signer,\n\t\toldOwner: Signer,\n\t\toverrides: {\n\t\t\tprevOwner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t webAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction[]> {\n\t\tlet deployNewOwnerSignerMetaTransaction: MetaTransaction | null = null;\n\t\tlet newOwnerT: string;\n\t\tlet oldOwnerT: string;\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\tif (typeof newOwner != \"string\") {\n\t\t\tnewOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\tnewOwner.x,\n\t\t\t\tnewOwner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst newOwnerCode = await sendEthGetCodeRequest(\n\t\t\t\tnodeRpcUrl,\n\t\t\t\tnewOwnerT,\n\t\t\t\t\"latest\",\n\t\t\t);\n\t\t\tconst newOwnerNotDeployed = newOwnerCode.length < 3;\n\t\t\tif (newOwnerNotDeployed) {\n\t\t\t\tdeployNewOwnerSignerMetaTransaction =\n\t\t\t\t\tSafeAccount.createDeployWebAuthnVerifierMetaTransaction(\n\t\t\t\t\t\tnewOwner.x,\n\t\t\t\t\t\tnewOwner.y,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnewOwnerT = newOwner;\n\t\t}\n\t\tif (typeof oldOwner != \"string\") {\n\t\t\toldOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\toldOwner.x,\n\t\t\t\toldOwner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\toldOwnerT = oldOwner;\n\t\t}\n\n\t\tlet prevOwnerT = overrides.prevOwner;\n\t\tif (prevOwnerT == null) {\n\t\t\tconst owners = await this.getOwners(nodeRpcUrl);\n\t\t\tconst oldOwnerIndex = owners.indexOf(oldOwnerT);\n\t\t\tif (oldOwnerIndex == -1) {\n\t\t\t\tthrow new RangeError(\"oldOwner is not a current owner.\");\n\t\t\t} else if (oldOwnerIndex == 0) {\n\t\t\t\tprevOwnerT = \"0x0000000000000000000000000000000000000001\";\n\t\t\t} else {\n\t\t\t\tprevOwnerT = owners[oldOwnerIndex - 1];\n\t\t\t}\n\t\t}\n\t\tconst swapMetaTransaction = this.createStandardSwapOwnerMetaTransaction(\n\t\t\tnewOwnerT,\n\t\t\toldOwnerT,\n\t\t\tprevOwnerT,\n\t\t);\n\t\tif (deployNewOwnerSignerMetaTransaction == null) {\n\t\t\treturn [swapMetaTransaction];\n\t\t} else {\n\t\t\treturn [deployNewOwnerSignerMetaTransaction, swapMetaTransaction];\n\t\t}\n\t}\n\n\t/**\n\t * create a removeOwner metatransaction, and fetch the prevowner\n\t * needed for the remove\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * (to get the prevOwner paramter).\n\t * @param ownerToDelete - owner to delete public address\n\t * @param threshold - new threshold\n\t * @param overrides - overrides for the default values\n\t * @param overrides.prevOwner - if set, it will be used as the previous owner and\n\t * nideRpcUrl won't be used to fetch it\n\t * @returns a promise of a metaTransaction\n\t */\n\tpublic async createRemoveOwnerMetaTransaction(\n\t\tnodeRpcUrl: string,\n\t\townerToDelete: Signer,\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tprevOwner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t webAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction> {\n\t\tlet ownerToDeleteT: string;\n\n\t\tif (typeof ownerToDelete != \"string\") {\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\townerToDeleteT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\townerToDelete.x,\n\t\t\t\townerToDelete.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\townerToDeleteT = ownerToDelete;\n\t\t}\n\n\t\tlet prevOwnerT = overrides.prevOwner;\n\t\tif (prevOwnerT == null) {\n\t\t\tconst owners = await this.getOwners(nodeRpcUrl);\n\t\t\tconst ownerToDeleteIndex = owners.indexOf(ownerToDeleteT);\n\t\t\tif (ownerToDeleteIndex == -1) {\n\t\t\t\tthrow new RangeError(\"ownerToDelete is not a current owner.\");\n\t\t\t} else if (ownerToDeleteIndex == 0) {\n\t\t\t\tprevOwnerT = \"0x0000000000000000000000000000000000000001\";\n\t\t\t} else {\n\t\t\t\tprevOwnerT = owners[ownerToDeleteIndex - 1];\n\t\t\t}\n\t\t}\n\t\treturn this.createStandardRemoveOwnerMetaTransaction(\n\t\t\townerToDeleteT,\n\t\t\tthreshold,\n\t\t\tprevOwnerT,\n\t\t);\n\t}\n\n /**\n\t * create an addOwner metatransaction and create a metatransaction to\n\t * deploy a webauthn verifier owner if it is not deployed\n\t * @param newOwner - newOwner public address\n\t * @param threshold - new threshold\n\t * @param overrides - overrides for the default values\n * @param overrides.nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * (to check if the new webauthn owner is deployed or not).\n\t * @returns a promise of a list of metaTransactions\n\t */\n\tpublic async createAddOwnerWithThresholdMetaTransactions(\n\t\tnewOwner: Signer,\n\t\tthreshold: number,\n\t\toverrides: {\n nodeRpcUrl?: string,\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t webAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction[]> {\n\t\tlet deployNewOwnerSignerMetaTransaction: MetaTransaction | null = null;\n\t\tlet newOwnerT: string;\n\n\t\tif (typeof newOwner != \"string\") {\n const webAuthnSignerProxyCreationCode =\n overrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\tnewOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\tnewOwner.x,\n\t\t\t\tnewOwner.y,\n\t\t\t\t{\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n\t\t\t\t},\n\t\t\t);\n if(overrides.nodeRpcUrl == null){\n\t\t\t\tthrow new RangeError(\n \"overrides.nodeRpcUrl can't be null if adding a webauthn owner\");\n }\n\t\t\tconst newOwnerCode = await sendEthGetCodeRequest(\n\t\t\t\toverrides.nodeRpcUrl,\n\t\t\t\tnewOwnerT,\n\t\t\t\t\"latest\",\n\t\t\t);\n\t\t\tconst newOwnerNotDeployed = newOwnerCode.length < 3;\n\t\t\tif (newOwnerNotDeployed) {\n\t\t\t\tdeployNewOwnerSignerMetaTransaction =\n\t\t\t\t\tSafeAccount.createDeployWebAuthnVerifierMetaTransaction(\n\t\t\t\t\t\tnewOwner.x,\n\t\t\t\t\t\tnewOwner.y,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnewOwnerT = newOwner;\n\t\t}\n\t\t\n const addMetaTransaction = this.createStandardAddOwnerWithThresholdMetaTransaction(\n\t\t\tnewOwnerT,\n threshold\n\t\t);\n\t\tif (deployNewOwnerSignerMetaTransaction == null) {\n\t\t\treturn [addMetaTransaction];\n\t\t} else {\n\t\t\treturn [deployNewOwnerSignerMetaTransaction, addMetaTransaction];\n\t\t}\n\t}\n\n\t/**\n\t * create a standard addOwner metatransaction\n\t * @param newOwner - newOwner public address\n\t * @param threshold - new threshold\n\t * @returns a metaTransaction\n\t */\n\tpublic createStandardAddOwnerWithThresholdMetaTransaction(\n\t\tnewOwner: string,\n\t\tthreshold: number,\n\t): MetaTransaction {\n\t\tconst functionSelector = \"0x0d582f13\"; //addOwnerWithThreshold\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\n\t\t\t\t\"address\", //owner\n\t\t\t\t\"uint256\", //_threshold\n\t\t\t],\n\t\t\t[newOwner, threshold],\n\t\t);\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a standard swapOwner metatransaction\n\t * @param newOwner - newOwner public address\n\t * @param oldOwner - oldOwner public address\n\t * @param prevOwner - prevOwner public address in the owners linked list\n\t * @returns a metaTransaction\n\t */\n\tpublic createStandardSwapOwnerMetaTransaction(\n\t\tnewOwner: string,\n\t\toldOwner: string,\n\t\tprevOwner: string,\n\t): MetaTransaction {\n\t\tconst functionSelector = \"0xe318b52b\"; //swapOwner\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\n\t\t\t\t\"address\", //prevOwner\n\t\t\t\t\"address\", //oldOwner\n\t\t\t\t\"address\", //newOwner\n\t\t\t],\n\t\t\t[\n\t\t\t\tprevOwner, //SENTINEL_OWNERS\n\t\t\t\toldOwner,\n\t\t\t\tnewOwner,\n\t\t\t],\n\t\t);\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a standard removeOwner metatransaction\n\t * @param ownerToDelete - owner to delete public address\n\t * @param threshold - new threshold\n\t * @param prevOwner - prevOwner public address in the owners linked list\n\t * @returns a metaTransaction\n\t */\n\tpublic createStandardRemoveOwnerMetaTransaction(\n\t\townerToDelete: string,\n\t\tthreshold: number,\n\t\tprevOwner: string,\n\t): MetaTransaction {\n\t\tconst functionSelector = \"0xf8dc5dd9\"; //removeOwner\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\n\t\t\t\t\"address\", //prevOwner\n\t\t\t\t\"address\", //owner\n\t\t\t\t\"uint256\", //_threshold\n\t\t\t],\n\t\t\t[\n\t\t\t\tprevOwner, //SENTINEL_OWNERS\n\t\t\t\townerToDelete,\n\t\t\t\tthreshold,\n\t\t\t],\n\t\t);\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n /**\n\t * create a change threshold metatransaction \n\t * @param threshold - new threshold\n\t * @returns a metaTransactions\n\t */\n\tpublic createChangeThresholdMetaTransaction(threshold: number): MetaTransaction {\n if(threshold < 1){\n throw new RangeError(\"threshold can't be less than 1.\");\n }\n\n\t\tconst changeThresholdCallData = createCallData(\n\t\t\t\"0x694e80c3\", //changeThreshold\n\t\t\t[\"uint256\"],\n\t\t\t[threshold],\n\t\t);\n\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: changeThresholdCallData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n /**\n\t * create an approve hash metatransaction \n\t * @param hashToApprove - hash to approve\n\t * @returns a metaTransactions\n\t */\n\tpublic createApproveHashMetaTransaction(hashToApprove: string): MetaTransaction {\n\t\tconst approveHashCallData = createCallData(\n\t\t\t\"0xd4d9bdcd\", //approveHash\n\t\t\t[\"bytes32\"],\n\t\t\t[hashToApprove],\n\t\t);\n\n\t\treturn {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: approveHashCallData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a deploy webauthn verifier metatransaction\n\t * @param x - webauthn public key x parameter\n\t * @param y - webauthn public key y parameter\n\t * @param overrides - overrides for the default values\n\t * @returns a metaTransaction\n\t */\n\tpublic static createDeployWebAuthnVerifierMetaTransaction(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t} = {},\n\t): MetaTransaction {\n\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n\t\tconst webAuthnSignerFactory =\n\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\n\t\tconst createDeterministicWebAuthnVerifierOwnerCallData = createCallData(\n\t\t\t\"0x0d2f0489\", //createSigner\n\t\t\t[\"uint256\", \"uint256\", \"uint176\"],\n\t\t\t[\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\t\"0x\" +\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier.slice(-4) +\n\t\t\t\t\teip7212WebAuthnContractVerifier.slice(2),\n\t\t\t],\n\t\t);\n\n\t\treturn {\n\t\t\tto: webAuthnSignerFactory,\n\t\t\tvalue: 0n,\n\t\t\tdata: createDeterministicWebAuthnVerifierOwnerCallData,\n\t\t};\n\t}\n\n\t/**\n\t * fetches a list of the account owners public addresses\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise of a list of owners public addresses\n\t */\n\tpublic async getOwners(nodeRpcUrl: string): Promise<string[]> {\n\t\tconst functionSignature = \"getOwners()\";\n\t\tconst functionSelector = getFunctionSelector(functionSignature);\n\t\tconst callData = createCallData(functionSelector, [], []);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst getOwnersResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n\t\t);\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst decodedCalldata = abiCoder.decode(\n\t\t\t[\"address[]\"],\n\t\t\tgetOwnersResult,\n\t\t);\n\n\t\treturn decodedCalldata[0];\n\t}\n\n\t/**\n\t * fetches the current threshold\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise with the current threshold\n\t */\n\tpublic async getThreshold(nodeRpcUrl: string): Promise<number> {\n\t\tconst functionSelector = \"0xe75235b8\"; //getThreshold\n\t\tconst callData = createCallData(functionSelector, [], []);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst getThresholdResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n\t\t);\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst decodedCalldata = abiCoder.decode(\n\t\t\t[\"uint256\"],\n\t\t\tgetThresholdResult,\n\t\t);\n\n\t\treturn Number(decodedCalldata[0]);\n\t}\n \n /**\n\t * fetches a list of the account owners public addresses\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise of a list of owners public addresses and\n * next Start of the next page\n\t */\n\tpublic async getModules(\n nodeRpcUrl: string, \n overrides: {\n\t\t\tstart?: string;\n pageSize?: bigint\n\t\t} = {}\n ): Promise<[string[], string]> {\n try{\n let start = overrides.start;\n if(start == null){\n start = \"0x0000000000000000000000000000000000000001\";\n }\n let pageSize = overrides.pageSize;\n if(pageSize == null){\n pageSize = 10n;\n }\n\n const callData = createCallData(\n \"0xcc2f8452\", //getModulesPaginated(address,uint256)\n [\"address\", \"uint256\"],\n [start, pageSize]\n );\n\n const ethCallParams = {\n to: this.accountAddress,\n data: callData,\n };\n const getModulesResult = await sendEthCallRequest(\n nodeRpcUrl,\n ethCallParams,\n \"latest\",\n );\n if (getModulesResult == \"0x\"){\n throw new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"getModules retuned an empty result, the target account is \" + \n \"probably not deployed yet.\",\n\t\t\t\t);\n }\n const abiCoder = AbiCoder.defaultAbiCoder();\n const decodedCalldata = abiCoder.decode(\n [\"address[]\", \"address\"],\n getModulesResult,\n );\n return [decodedCalldata[0], decodedCalldata[1]];\n }catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"getModules failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n /**\n\t * check if a module is enabled \n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @param moduleAddress - the module address to check if enabled \n\t * @returns a promise of boolean \n\t */\n\tpublic async isModuleEnabled(\n nodeRpcUrl: string, moduleAddress: string\n ): Promise<boolean> {\n\t\tconst functionSignature = \"isModuleEnabled(address)\";\n\t\tconst functionSelector = getFunctionSelector(functionSignature);\n\t\tconst callData = createCallData(\n functionSelector, [\"address\"], [moduleAddress]);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.accountAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst isModuleEnabledResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n\t\t);\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst decodedCalldata = abiCoder.decode(\n\t\t\t[\"bool\"],\n\t\t\tisModuleEnabledResult,\n\t\t);\n\n\t\treturn decodedCalldata[0];\n\t}\n \n /**\n\t * create a list of dummy signer signature pair list based on the expected signers\n\t * @param expectedSigners - webauthn public key x parameter\n\t * @param webAuthnSignatureOverrides - overrides for the default values\n\t * @returns a list of dummy SignerSignaturePair\n\t */\n\tpublic static createDummySignerSignaturePairForExpectedSigners(\n\t\texpectedSigners: Signer[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n ): SignerSignaturePair[] {\n const signers = [...expectedSigners]; \n const dummySignerSignatures: SignerSignaturePair[] = [];\n for (let signer of signers){\n let signerSignaturePair: SignerSignaturePair;\n if (typeof signer == \"string\") {\n signerSignaturePair = EOADummySignerSignaturePair;\n }else{\n if (webAuthnSignatureOverrides.isInit == null) {\n throw new RangeError(\n \"Must define isInit parameter when using WebAuthn\",\n );\n }\n signerSignaturePair = { ...WebauthnDummySignerSignaturePair };\n if (webAuthnSignatureOverrides.isInit) {\n const webauthnsharedsigner =\n webAuthnSignatureOverrides.webAuthnSharedSigner ??\n SafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n signerSignaturePair.signer = webauthnsharedsigner;\n } else {\n const eip7212WebAuthnPrecompileVerifier =\n webAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n const eip7212WebAuthnContractVerifier =\n webAuthnSignatureOverrides.eip7212WebAuthnContractVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n const webAuthnSignerFactory =\n webAuthnSignatureOverrides.webAuthnSignerFactory ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n const webAuthnSignerSingleton =\n webAuthnSignatureOverrides.webAuthnSignerSingleton ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n const webAuthnSignerProxyCreationCode =\n webAuthnSignatureOverrides.webAuthnSignerProxyCreationCode ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n signerSignaturePair.signer = SafeAccount.createWebAuthnSignerVerifierAddress(\n signer.x,\n signer.y,\n {\n eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier,\n webAuthnSignerFactory,\n webAuthnSignerSingleton,\n webAuthnSignerProxyCreationCode\n },\n );\n }\n }\n dummySignerSignatures.push(signerSignaturePair);\n }\n return dummySignerSignatures;\n }\n \n /**\n\t * verify a webauthn signature against a signer and a message hash \n * @note: this function works by constructing the bytecode of a webatuhn\n * verifying contract proxy that represent the input signer, then overriding\n * an arbitrary address code and caling \"isValidSignature\" using eth_call \n * this way we can check a signature even if the verifying contract is not\n * deployed\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @param signer - a signer to check the signature against \n\t * @param messageHash - a messageHash to check the signature against \n\t * @param signature - a webauthn signature to check\n\t * @param overrides - overrides for the default values\n\t * @returns a promise of boolean - True if a valid signature\n\t */\n public static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string,\n signer: WebauthnPublicKey,\n messageHash: string, \n signature: string,\n overrides:{\n eip7212WebAuthnPrecompileVerifier?: string,\n eip7212WebAuthnContractVerifier?: string,\n webAuthnSignerSingleton?: string,\n } = {}\n ):Promise<boolean> {\n if (messageHash.length != 66 || messageHash.slice(0, 2) != \"0x\") {\n\t\t\tthrow new RangeError(\n\t\t\t \"Invalide messageHash ,must be a 0x prefixed keccak256 hash.\",\n\t\t\t);\n\t\t}\n\n const eip7212WebAuthnPrecompileVerifier =\n overrides.eip7212WebAuthnPrecompileVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n const eip7212WebAuthnContractVerifier =\n overrides.eip7212WebAuthnContractVerifier ??\n SafeAccount.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;\n const webAuthnSignerSingleton =\n overrides.webAuthnSignerSingleton ??\n SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n \n if (\n\t\t\teip7212WebAuthnPrecompileVerifier.length != 42 ||\n\t\t\teip7212WebAuthnPrecompileVerifier.slice(0, 38) != ZeroAddress.slice(0, 38)\n\t\t) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"Invalide precompile address. \" +\n \"It should have the format 0x000000000000000000000000000000000000____\",\n\t\t\t);\n\t\t}\n\t\tconst functionSelector = \"0x1626ba7e\"; //isValidSignature(bytes32,bytes)\n\t\tconst callData = createCallData(\n functionSelector,\n [\"bytes32\", \"bytes\"],\n [messageHash, signature]\n );\n \n const arbitraryAddress = \"0x1111111111111111111111111111111111111111\";\n\t\tconst ethCallParams = {\n\t\t\tto: arbitraryAddress,\n\t\t\tdata: callData,\n\t\t};\n const deployedByteCode = SafeAccount.createSafeWebAuthnSignerProxyDeployedByteCode(\n signer,\n eip7212WebAuthnPrecompileVerifier,\n eip7212WebAuthnContractVerifier,\n webAuthnSignerSingleton\n )\n\n\t\tconst isModuleEnabledResult = await sendEthCallRequest(\n\t\t\tnodeRpcUrl,\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n {[arbitraryAddress]: {\"code\": deployedByteCode}}\n\t\t);\n\n\t\tconst decodedCalldata = AbiCoder.defaultAbiCoder().decode(\n\t\t\t[\"bool\"],\n\t\t\tisModuleEnabledResult,\n\t\t);\n\n\t\treturn decodedCalldata[0];\n }\n\n private static createSafeWebAuthnSignerProxyDeployedByteCode(\n signer: WebauthnPublicKey, \n eip7212WebAuthnPrecompileVerifier: string,\n eip7212WebAuthnContractVerifier: string,\n webAuthnSignerSingleton: string,\n ):string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n const x = abiCoder.encode([\"uint256\"], [signer.x])\n const y = abiCoder.encode([\"uint256\"], [signer.y])\n const verifiers = abiCoder.encode(\n [\"uint176\"],\n [\n \"0x\" +\n\t\t\t\teip7212WebAuthnPrecompileVerifier.slice(-4) +\n\t\t\t\teip7212WebAuthnContractVerifier.slice(2),\n ]\n )\n const byteCode = \n \"0x608060408190527f\" + verifiers.slice(2) +\n \"3660b681018290527f\" + y.slice(2) +\n \"60a082018190527f\" + x.slice(2) + \n \"8285018190527f000000000000000000000000\" +\n webAuthnSignerSingleton.slice(2) +\n \"9490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033\";\n return byteCode;\n }\n\n /**\n * create MetaTransaction to enable a module\n * @param accountAddress - Safe account to enable the module for\n * @returns a MetaTransaction\n */\n public static createEnableModuleMetaTransaction(\n moduleAddress: string,\n accountAddress: string,\n ):MetaTransaction{\n const callData = createCallData(\n \"0x610b5925\", //\"enableModule(address)\"\n [\"address\"],\n [moduleAddress],\n );\n return {\n to:accountAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create a standard disable a module MetaTransaction\n * @param moduleAddress - Module to disable\n * @param prevModuleAddress - previous module to moudle to disable \n * @param accountAddress - Safe account to enable the module for\n * @returns a MetaTransaction\n */\n public async createDisableModuleMetaTransaction(\n\t\tnodeRpcUrl: string,\n moduleToDisableAddress: string,\n accountAddress: string,\n\t\toverrides: {\n\t\t\tprevModuleAddress?: string;\n\t\t\tmodulesStart?: string;\n modulesPageSize?: bigint\n\t\t} = {},\n ):Promise<MetaTransaction>{\n try{\n let prevModuleAddressT = overrides.prevModuleAddress;\n if (prevModuleAddressT == null) {\n const [modules, _] = await this.getModules(\n nodeRpcUrl,\n {\n start:overrides.modulesStart,\n pageSize:overrides.modulesPageSize\n }\n );\n \n const moduleToDisableIndex = modules.indexOf(moduleToDisableAddress);\n if (moduleToDisableIndex == -1) {\n throw new RangeError(\n \"moduleToDisable \" + moduleToDisableAddress +\n \" is not an enabled module.\"\n );\n } else if (moduleToDisableIndex == 0) {\n prevModuleAddressT = \"0x0000000000000000000000000000000000000001\";\n } else if (moduleToDisableIndex > 0) {\n prevModuleAddressT = modules[moduleToDisableIndex - 1];\n } else {\n throw new RangeError(\n \"Invalid module index for \" + moduleToDisableAddress);\n }\n }\n return SafeAccount.createStandardDisableModuleMetaTransaction(\n moduleToDisableAddress, prevModuleAddressT, accountAddress\n );\n } catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"createDisableModuleMetaTransaction failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n }\n\n /**\n * create a standard disable a module MetaTransaction\n * @param moduleAddress - Module to disable\n * @param prevModuleAddress - previous module to moudle to disable \n * @param accountAddress - Safe account to enable the module for\n * @returns a MetaTransaction\n */\n public static createStandardDisableModuleMetaTransaction(\n moduleAddress: string,\n prevModuleAddress: string,\n accountAddress: string,\n ):MetaTransaction{\n const callData = createCallData(\n \"0xe009cfde\", //\"disableModule(address)\"\n [\"address\", \"address\"],\n [prevModuleAddress, moduleAddress],\n );\n return {\n to:accountAddress,\n data: callData,\n value: 0n\n }\n }\n\n async simulateCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug:string,\n tenderlyProjectSlug:string,\n tenderlyAccessKey: string,\n\t\tnodeRpcUrl: string | null = null,\n chainId: bigint,\n\t\tmetaTransactions: MetaTransaction[],\n blockNumber: number | null = null,\n overrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t\tmultisendContractAddress?: string;\n callData?: string;\n createShareLink?: boolean;\n isInit?: boolean,\n\t\t} = {},\n ): Promise<{\n simulation:TenderlySimulationResult,\n callDataSimulationShareLink?: string,\n accountDeploymentSimulationShareLink?: string,\n }> {\n let isInit:boolean = false;\n if(nodeRpcUrl == null && overrides.isInit == null){\n throw new RangeError(\n \"nodeRpcUrl and overrides.isInit can't both be null\"\n );\n }else if(overrides.isInit == null){\n const accountNonce =\n await fetchAccountNonce(\n nodeRpcUrl as string,\n this.entrypointAddress,\n this.accountAddress,\n )\n isInit = accountNonce == 0n;\n }else{\n isInit = overrides.isInit;\n }\n\n let callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tif (metaTransactions.length == 1) {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataSingleTransaction(\n\t\t\t\t\tmetaTransactions[0],\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector:overrides.safeModuleExecutorFunctionSelector,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataBatchTransactions(\n\t\t\t\t\tmetaTransactions,\n\t\t\t\t\t{\n\t\t\t\t\t\tsafeModuleExecutorFunctionSelector:\n\t\t\t\t\t\t\toverrides.safeModuleExecutorFunctionSelector,\n\t\t\t\t\t\tmultisendContractAddress: overrides.multisendContractAddress,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n\n const createShareLink = overrides.createShareLink?? true;\n if(createShareLink){\n return await simulateSenderCallDataWithTenderlyAndCreateShareLink(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n this.entrypointAddress,\n this.accountAddress,\n callData,\n isInit?this.factoryAddress:null,\n isInit?this.factoryData:null,\n blockNumber\n )\n }else{\n const simulation = await simulateSenderCallDataWithTenderly(\n tenderlyAccountSlug,\n tenderlyProjectSlug,\n tenderlyAccessKey,\n chainId,\n this.entrypointAddress,\n this.accountAddress,\n callData,\n isInit?this.factoryAddress:null,\n isInit?this.factoryData:null,\n blockNumber\n )\n return {simulation};\n }\n }\n\n /**\n\t * create eip712 signing data for a safe message\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param message - message to hash\n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing a sae message\n\t */\n getSafeMessageEip712Data(\n chainId: bigint,\n message: string\n ): {\n domain: SafeMessageTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeMessageTypedMessageValue\n } {\n return getSafeMessageEip712Data(\n this.accountAddress,\n chainId,\n message\n );\n }\n}\n\n/**\n * generate Safe on-chain identifier as per https://docs.safe.global/sdk/onchain-tracking\n * @param project - project name\n * @param platform - \"Web\" or \"Mobile\" or \"Safe App\" or \"Widget\", defaults to \"Web\".\n * @param tool - tool used, defaults to \"abstractionkit\"\n * @param toolVersion - tool version, defaults to current abstractionkit version\n * @returns the onchain idenetifier as a hex string (not 0x prefixed)\n */\nfunction generateOnChainIdentifier(\n project: string,\n platform: \"Web\" | \"Mobile\" | \"Safe App\" | \"Widget\" = \"Web\",\n tool: string = \"abstractionkit\",\n toolVersion: string = \"0.3.1\"\n): string {\n const identifierPrefix = '5afe'; // Safe identifier prefix\n const identifierVersion = '00'; // First version\n const projectHash = keccak256(\"0x\" + Buffer.from(project, 'utf8').toString('hex')).slice(-20);\n const platformHash = keccak256(\"0x\" + Buffer.from(platform, 'utf8').toString('hex')).slice(-3);\n const toolHash = keccak256(\"0x\" + Buffer.from(tool, 'utf8').toString('hex')).slice(-3);\n const toolVersionHash = keccak256(\"0x\" + Buffer.from(toolVersion, 'utf8').toString('hex')).slice(-3);\n \n const projectHashEncoded = Buffer.from(projectHash, 'utf8').toString('hex');\n const platformHashEncoded = Buffer.from(platformHash, 'utf8').toString('hex');\n const toolHashEncoded = Buffer.from(toolHash, 'utf8').toString('hex');\n const toolVersionHashEncoded = Buffer.from(toolVersionHash, 'utf8').toString('hex');\n\n const res = `${identifierPrefix}${identifierVersion}${projectHashEncoded}${platformHashEncoded}${toolHashEncoded}${toolVersionHashEncoded}`;\n return res;\n}\n","import { keccak256 } from \"ethers\";\n\n/**\n * Hashes two values together using keccak256, sorting them so the smaller\n * value is always first to ensure consistent ordering.\n * @param left - The first hash value.\n * @param right - The second hash value.\n * @returns The keccak256 hash of the sorted pair.\n */\nfunction hashPair(left: string, right: string): string {\n if(left < right){\n return keccak256(left + right.slice(2));\n }else{\n return keccak256(right + left.slice(2));\n }\n}\n\n/**\n * Builds a Merkle tree and returns proofs for each input hash\n * @param hashes - Array of hash strings to include in the Merkle tree\n * @returns Array of MerkleProof objects containing the original hash, its proof path, and the root\n */\nexport function generateMerkleProofs(hashes: string[]): [string, string[]] {\n if (hashes.length === 0) {\n throw new Error('Cannot create Merkle tree with empty hash list');\n }\n\n // Store the original hashes and their indices\n const originalHashes = [...hashes];\n \n // Build the tree level by level\n let currentLevel = [...hashes];\n const tree: string[][] = [currentLevel];\n \n // Build tree from bottom to top\n while (currentLevel.length > 1) {\n const nextLevel: string[] = [];\n \n for (let i = 0; i < currentLevel.length; i += 2) {\n if (i + 1 < currentLevel.length) {\n // Hash pair of nodes\n nextLevel.push(hashPair(currentLevel[i], currentLevel[i + 1]));\n } else {\n // Odd number of nodes - duplicate the last one\n nextLevel.push(hashPair(currentLevel[i], currentLevel[i]));\n }\n }\n \n tree.push(nextLevel);\n currentLevel = nextLevel;\n }\n const root = tree[tree.length - 1][0];\n \n // Generate proof for each original hash\n const proofs: string[] = originalHashes.map((hash, index) => {\n const proofArr: string[] = [];\n let currentIndex = index;\n \n // Traverse from leaf to root, collecting sibling hashes\n for (let level = 0; level < tree.length - 1; level++) {\n const currentLevelNodes = tree[level];\n const isRightNode = currentIndex % 2 === 1;\n \n if (isRightNode) {\n // If we're the right node, sibling is on the left\n proofArr.push(currentLevelNodes[currentIndex - 1]);\n } else {\n // If we're the left node, sibling is on the right\n if (currentIndex + 1 < currentLevelNodes.length) {\n proofArr.push(currentLevelNodes[currentIndex + 1]);\n } else {\n // Odd number of nodes - we're paired with ourselves\n proofArr.push(currentLevelNodes[currentIndex]);\n }\n }\n \n // Move to parent index in next level\n currentIndex = Math.floor(currentIndex / 2);\n }\n let proof = root;\n proofArr.reverse().forEach((proofElement) =>{\n proof += proofElement.slice(2);\n });\n return proof;\n });\n return [root, proofs];\n}\n\n/**\n * Verifies a Merkle proof\n * @param hash - The original hash\n * @param proof - Array of sibling hashes from leaf to root\n * @param root - The expected Merkle root\n * @returns true if the proof is valid, false otherwise\n */\nexport function verifyMerkleProof(hash: string, proof: string[], root: string): boolean {\n let currentHash = hash;\n \n for (const siblingHash of proof) {\n // Determine order (smaller hash goes first for consistency)\n if (currentHash <= siblingHash) {\n currentHash = hashPair(currentHash, siblingHash);\n } else {\n currentHash = hashPair(siblingHash, currentHash);\n }\n }\n \n return currentHash === root;\n}\n","// Version 0.2.1\n// https://github.com/safe-fndn/safe-modules/blob/04e65efbce634e776cc8c1fbe90061f09e09a71b/modules/passkey/CHANGELOG.md?plain=1#L23\n//\nexport const DEFAULT_WEB_AUTHN_SHARED_SIGNER_V_0_2_1 =\n \"0x94a4F6affBd8975951142c3999aEAB7ecee555c2\";\nexport const DEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1=\n\t\t\"0x4E27b51350e6c2083EE19011120F50DAfEc5CA50\";\nexport const DEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1=\n\t\t\"0x1d31F259eE307358a26dFb23EB365939E8641195\";\nexport const DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1 =\n\t\t\"0x610100346100ad57601f6101b538819003918201601f19168301916001600160401b038311848410176100b2578084926080946040528339810103126100ad578051906001600160a01b03821682036100ad5760208101516040820151606090920151926001600160b01b03841684036100ad5760805260a05260c05260e05260405160ec90816100c98239608051816082015260a05181604d015260c051816027015260e0518160010152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe7f000000000000000000000000000000000000000000000000000000000000000060b63601527f000000000000000000000000000000000000000000000000000000000000000060a03601527f000000000000000000000000000000000000000000000000000000000000000036608001523660006080376000806056360160807f00000000000000000000000000000000000000000000000000000000000000005af43d600060803e60b1573d6080fd5b3d6080f3fea26469706673582212201660515548d15702d720bbc046b457ca85e941a4559ab9f9518488e4c82e5ee964736f6c634300081a0033\";\nexport const DEFAULT_WEB_AUTHN_PRECOMPILE_RIP_7951=\n\t\t\"0x0000000000000000000000000000000000000100\"; // EIP-7951\nexport const DEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1=\n\t\t\"0xc2b78104907F722DABAc4C69f826a522B2754De4\";\n","import { SafeAccount } from \"./SafeAccount\";\nimport {\n\tInitCodeOverrides,\n\tSigner,\n\tCreateUserOperationV9Overrides,\n SafeUserOperationTypedDataDomain,\n SafeUserOperationV9TypedMessageValue,\n SafeAccountSingleton,\n UserOperationToSign,\n MultiChainSignatureMerkleTreeRootTypedDataDomain,\n MultiChainSignatureMerkleTreeRootTypedMessageValue,\n SignerSignaturePair,\n WebAuthnSignatureOverrides,\n WebauthnPublicKey,\n UserOperationToSignWithOverrides,\n} from \"./types\";\n\nimport { UserOperationV9, MetaTransaction, OnChainIdentifierParamsType } from \"../../types\";\nimport { EIP712_MULTI_CHAIN_OPERATIONS_TYPE, ENTRYPOINT_V9 } from \"src/constants\";\nimport { generateMerkleProofs } from \"./MerkleTree\";\nimport { TypedDataEncoder, Wallet } from \"ethers\";\nimport {\n\tDEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_PRECOMPILE_RIP_7951,\n\tDEFAULT_WEB_AUTHN_SHARED_SIGNER_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1,\n} from \"./constants\";\n\n/**\n * @class\n * Safe account variant that supports multi-chain signatures via Merkle trees.\n * Allows signing UserOperations for multiple chains with a single signature,\n * using EntryPoint v0.9 and EIP-712 typed data with Merkle proofs.\n *\n * Uses Safe Passkey module v0.2.1 WebAuthn verifiers by default,\n * with the Daimo P256 verifier instead of the FCL P256 verifier\n * used by the base SafeAccount class.\n * @see {@link https://github.com/safe-fndn/safe-modules/blob/04e65efbce634e776cc8c1fbe90061f09e09a71b/modules/passkey/CHANGELOG.md?plain=1#L23}\n */\nexport class SafeMultiChainSigAccountV1 extends SafeAccount {\n\tstatic readonly DEFAULT_ENTRYPOINT_ADDRESS = ENTRYPOINT_V9;\n\tstatic readonly DEFAULT_SAFE_4337_MODULE_ADDRESS =\n \"0x22939E839e3c0F479B713eAF95e0df128554AEAd\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS =\n\t\t\"0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47\";\n\n\t// Safe Passkey module v0.2.1 WebAuthn verifier defaults\n\tstatic readonly DEFAULT_WEB_AUTHN_SHARED_SIGNER: string = DEFAULT_WEB_AUTHN_SHARED_SIGNER_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_SINGLETON: string = DEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_FACTORY: string = DEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE = DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_PRECOMPILE: string = DEFAULT_WEB_AUTHN_PRECOMPILE_RIP_7951;\n\tstatic readonly DEFAULT_WEB_AUTHN_DAIMO_VERIFIER: string = DEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1;\n\n\t/**\n\t * Create a SafeMultiChainSigAccount instance for an existing or new account.\n\t * @param accountAddress - the Safe account address\n\t * @param overrides - optional overrides for module, entrypoint, and singleton addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string\n safeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_ENTRYPOINT_ADDRESS;\n \n super(\n accountAddress, safe4337ModuleAddress, entrypointAddress,\n {\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n safeAccountSingleton: overrides.safeAccountSingleton,\n }\n );\n\t}\n\n\t/**\n\t * calculate account address from initial owners signers\n\t * @param owners - list of account owners addresses\n\t * @param overrides - override values to change the initialization default values\n\t * @returns account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n // webAuthnSignerFactory, webAuthnSignerSingleton, and webAuthnSignerProxyCreationCode\n // are not defaulted here — the init code path only configures the shared signer\n // and its verifier. Deploying the deterministic verifier proxy and swapping it\n // for the shared signer happens later in createUserOperation (nonce == 0),\n // which defaults those fields.\n const modOverrides = { ...overrides,\n\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n\t\tconst [accountAddress, ,] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\tmodOverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\treturn accountAddress;\n\t}\n\n\t/**\n\t * To create and initialize a SafeAccount object from its\n\t * initial owners\n\t * @remarks\n\t * initializeNewAccount only needed when the smart account\n\t * have not been deployed yet and the account address is unknown.\n\t * @param owners - list of account owners signers\n\t * @param overrides - override values to change the initialization default values\n\t * @returns a SafeAccount object\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeMultiChainSigAccountV1 {\n\t\tlet isInitWebAuthn = false;\n\t\tlet x = 0n;\n\t\tlet y = 0n;\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tif (isInitWebAuthn) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\"Only one Webauthn signer is allowed during initialization\",\n\t\t\t\t\t);\n\t\t\t\t}\n if(owners.indexOf(owner) != 0){\n throw new RangeError(\n\t\t\t\t\t\t\"Webauthn owner has to be the first owner for an init transaction.\",\n\t\t\t\t\t);\n }\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t\tx = owner.x;\n\t\t\t\ty = owner.y;\n\t\t\t}\n\t\t}\n // webAuthnSignerFactory, webAuthnSignerSingleton, and webAuthnSignerProxyCreationCode\n // are not defaulted here — the init code path only configures the shared signer\n // and its verifier. Deploying the deterministic verifier proxy and swapping it\n // for the shared signer happens later in createUserOperation (nonce == 0),\n // which defaults those fields.\n const modOverrides = { ...overrides,\n\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n\t\tconst [accountAddress, factoryAddress, factoryData] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\tmodOverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst safe = new SafeMultiChainSigAccountV1(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton,\n\t\t});\n\t\tsafe.factoryAddress = factoryAddress;\n\t\tsafe.factoryData = factoryData;\n\t\tif (isInitWebAuthn) {\n\t\t\tsafe.isInitWebAuthn = true;\n\t\t\tsafe.x = x;\n\t\t\tsafe.y = y;\n\t\t}\n\n\t\treturn safe;\n\t}\n\n\t/**\n\t * create a useroperation eip712 hash\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * defaults to ENTRYPOINT_V9\n\t * @param overrides.safe4337ModuleAddress - defaults to DEFAULT_SAFE_4337_MODULE_ADDRESS\n\t * @returns useroperation hash\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Hash(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n \n /**\n\t * create a useroperation eip712 data\n\t * @param useroperation - useroperation to hash\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @param overrides.entrypoint - target entrypoint\n\t * @param overrides.safe4337ModuleAddress - target module address \n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV9TypedMessageValue\n } \n {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Create the initializer callData for setting up a new Safe account.\n\t * @param owners - list of account owner signers\n\t * @param threshold - number of required signatures for execution\n\t * @param overrides - optional overrides for module and contract addresses\n\t * @returns hex-encoded initializer callData\n\t */\n\tpublic static createInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;\n\n\t\treturn SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\tthreshold,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress,\n\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t);\n\t}\n\n\t/**\n\t * create account factory address and factory data\n\t * @param owners - list of account owners signers\n\t * @param overrides - override values to change the initialization default values\n\t * @returns factoryAddress and factoryData\n\t */\n\tpublic static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n \t// webAuthnSignerFactory, webAuthnSignerSingleton, and webAuthnSignerProxyCreationCode\n\t\t// are not defaulted here — the init code path only configures the shared signer\n\t\t// and its verifier. Deploying the deterministic verifier proxy and swapping it\n\t\t// for the shared signer happens later in createUserOperation (nonce == 0),\n\t\t// which defaults those fields.\n\t\tconst modOverrides = { ...overrides,\n\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n\t\treturn SafeAccount.createFactoryAddressAndData(\n\t\t\towners,\n\t\t\tmodOverrides,\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t);\n\t}\n\n\t/**\n\t * createUserOperation will determine the nonce, fetch the gas prices,\n\t * estimate gas limits and return a useroperation to be signed.\n\t * you can override all these values using the overrides parameter.\n\t * @param transactions - metatransaction list to be encoded\n\t * @param providerRpc - node rpc to fetch account nonce and gas prices\n\t * @param bundlerRpc - bundler rpc for gas estimation\n\t * @param overrides - overrides for the default values\n\t * @returns promise with useroperation\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV9Overrides = {},\n\t): Promise<UserOperationV9> {\n\t\tconst parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n\t\tif(\n parallelPaymasterInitValues != null &&\n\t\t\t!parallelPaymasterInitValues.paymasterData.toLowerCase().endsWith(\"22e325a297439656\")\n ){\n throw new RangeError(\n \"Invalid paymasterData override, it must end with the PAYMASTER_SIG_MAGIC '22e325a297439656'\"\n );\n\t\t}\t\t\n const [userOperation, factoryAddress, factoryData] =\n\t\t\tawait this.createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\t\t\ttransactions,\n\t\t\t\tfalse,\n\t\t\t\tproviderRpc,\n\t\t\t\tbundlerRpc,\n\t\t\t\t{\n\t\t\t\t\t...overrides,\n\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\t\t\twebAuthnSignerProxyCreationCode: overrides.webAuthnSignerProxyCreationCode??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\t\t}\n\t\t\t);\n\t\tif(parallelPaymasterInitValues != null){\n\t\t\treturn {\n\t\t\t\t...userOperation,\n\t\t\t\tfactory: factoryAddress,\n\t\t\t\tfactoryData,\n ...parallelPaymasterInitValues,\n\t\t\t\teip7702Auth: null\n\t\t\t};\n\t\t}else{\n\t\t\treturn {\n\t\t\t\t...userOperation,\n\t\t\t\tfactory: factoryAddress,\n\t\t\t\tfactoryData,\n\t\t\t\tpaymaster: null,\n\t\t\t\tpaymasterVerificationGasLimit: null,\n\t\t\t\tpaymasterPostOpGasLimit: null,\n\t\t\t\tpaymasterData: null,\n\t\t\t\teip7702Auth: null\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * create a useroperation signature\n\t * @param useroperation - useroperation to sign\n\t * @param privateKeys - for the signers\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic signUserOperation(\n\t\tuserOperation: UserOperationV9,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.baseSignSingleUserOperation(\n\t\t\tuserOperation,\n\t\t\tprivateKeys,\n\t\t\tchainId,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.safe4337ModuleAddress,\n\t\t\t{\n\t\t\t\t...overrides,\n\t\t\t\tisMultiChainSignature: true\n\t\t\t}\n\t\t)\n\t}\n\n\t/**\n\t * sign a list of useroperations - multi chain signature\n\t * @param useroperation - useroperation to sign\n\t * @param privateKeys - for the signers\n\t * @param chainId - target chain id\n\t * @param overrides - overrides for the default values\n\t * @param overrides.validAfter - timestamp the signature will be valid after\n\t * @param overrides.validUntil - timestamp the signature will be valid until\n\t * @returns signature\n\t */\n\tpublic signUserOperations(\n\t\tuserOperationsToSign: UserOperationToSign[],\n\t\tprivateKeys: string[],\n\t): string[] {\n\t\tif (userOperationsToSign.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one userOperationsToSign\");\n\t\t}\n\t\tif (privateKeys.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one privateKey\");\n\t\t}\n if(userOperationsToSign.length > 1){\n const userOperationsHashes: string[] = [];\n userOperationsToSign.forEach(\n (userOperationsToSign, _index) => {\n const userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n userOperationsToSign.userOperation,\n userOperationsToSign.chainId,\n {\n validAfter: userOperationsToSign.validAfter,\n validUntil: userOperationsToSign.validUntil,\n safe4337ModuleAddress: this.safe4337ModuleAddress,\n entrypointAddress: this.entrypointAddress,\n },\n );\n userOperationsHashes.push(userOperationHash);\n });\n const [root, proofs] = generateMerkleProofs(userOperationsHashes);\n\n const merkleTreeRootHash = TypedDataEncoder.hash(\n {verifyingContract: this.safe4337ModuleAddress},\n\t\t\t EIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n {merkleTreeRoot: root},\n )\n\n const signerSignaturePairs: SignerSignaturePair[] = [];\n for (const privateKey of privateKeys) {\n const wallet = new Wallet(privateKey);\n const signature = wallet.signingKey.sign(\n merkleTreeRootHash\n ).serialized;\n signerSignaturePairs.push({\n signer: wallet.address,\n signature\n });\n }\n\n const userOpSignatures: string[] = [];\n userOperationsToSign.forEach(\n (userOperationsToSign, index) => {\n userOpSignatures.push(\n SafeAccount.formatSignaturesToUseroperationSignature(\n signerSignaturePairs,\n {\n validAfter: userOperationsToSign.validAfter,\n validUntil: userOperationsToSign.validUntil,\n isMultiChainSignature:true,\n multiChainMerkleProof: proofs[index]\n },\n )\n );\n });\n return userOpSignatures;\n }else{\n return [this.signUserOperation(\n userOperationsToSign[0].userOperation,\n privateKeys,\n userOperationsToSign[0].chainId,\n {\n validUntil: userOperationsToSign[0].validUntil,\n validAfter: userOperationsToSign[0].validAfter\n }\n )];\n }\n\t}\n\n\t/**\n\t * Compute the EIP-712 hash of a multi-chain Merkle tree root for a set of UserOperations.\n\t * This hash is what signers sign to approve multiple cross-chain operations at once.\n\t * @param userOperationsToSignsToSign - list of UserOperations with their target chain IDs\n\t * @param overrides - optional overrides for the Safe 4337 module address\n\t * @returns the EIP-712 hash as a hex string\n\t */\n\tpublic static getMultiChainSingleSignatureUserOperationsEip712Hash(\n\t\tuserOperationsToSignsToSign: UserOperationToSign[],\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n ): string{\n const data = SafeMultiChainSigAccountV1.getMultiChainSingleSignatureUserOperationsEip712Data(\n userOperationsToSignsToSign, overrides)\t;\n\t\treturn TypedDataEncoder.hash(\n\t\t\tdata.domain,\n\t\t\tdata.types,\n\t\t\tdata.messageValue,\n\t\t);\n }\n\n\t/**\n\t * Get the EIP-712 typed data components for a multi-chain Merkle tree root.\n\t * Returns the domain, types, and message value needed for signing or hashing.\n\t * @param userOperationsToSignsToSign - list of UserOperations with their target chain IDs\n\t * @param overrides - optional overrides for the Safe 4337 module address\n\t * @returns an object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic static getMultiChainSingleSignatureUserOperationsEip712Data(\n\t\tuserOperationsToSign: UserOperationToSign[],\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n\t\t} = {},\n ): {\n domain: MultiChainSignatureMerkleTreeRootTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: MultiChainSignatureMerkleTreeRootTypedMessageValue\n } {\n\t\tif (userOperationsToSign.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one userOperationsToSign\");\n\t\t}\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n SafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\t\n\n const userOperationsHashes: string[] = [];\n\n userOperationsToSign.forEach(\n (userOperationsToSign, _index) => {\n const userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n userOperationsToSign.userOperation,\n userOperationsToSign.chainId,\n {\n validAfter: userOperationsToSign.validAfter,\n validUntil: userOperationsToSign.validUntil,\n safe4337ModuleAddress,\n entrypointAddress: overrides.entrypointAddress,\n },\n );\n userOperationsHashes.push(userOperationHash);\n });\n const [root, _proofs] = generateMerkleProofs(userOperationsHashes);\n\t\treturn {\n domain: {verifyingContract: safe4337ModuleAddress},\n\t\t\ttypes: EIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\t\t\tmessageValue: {merkleTreeRoot: root},\n };\n }\n\n\t/**\n\t * formate a list of eip712 signatures to a list of multi chain useroperations signatures\n\t * @param signerSignaturePairs - a list of a pair of a signer and it's signature\n\t * @param overrides - overrides for the default values\n\t * @returns signature\n\t */\n\tpublic static formatSignaturesToUseroperationsSignatures(\n\t\tuserOperationsToSign: UserOperationToSignWithOverrides[],\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t): string[] {\n\t\tif (userOperationsToSign.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one userOperationsToSign\");\n\t\t}\n\t\tconst defaultOverrides: WebAuthnSignatureOverrides = {\n\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\tsafe4337ModuleAddress:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\twebAuthnSharedSigner:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t};\n\t\tif (userOperationsToSign.length === 1) {\n\t\t\treturn [\n\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\t\tsignerSignaturePairs,\n\t\t\t\t\t{\n\t\t\t\t\t\t...defaultOverrides,\n\t\t\t\t\t\t...userOperationsToSign[0].overrides,\n\t\t\t\t\t\tvalidAfter: userOperationsToSign[0].validAfter,\n\t\t\t\t\t\tvalidUntil: userOperationsToSign[0].validUntil,\n\t\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t\tconst userOperationsHashes: string[] = [];\n\t\tuserOperationsToSign.forEach(\n\t\t\t(userOperationToSign, _index) => {\n\t\t\t\tconst userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n\t\t\t\t\tuserOperationToSign.userOperation,\n\t\t\t\t\tuserOperationToSign.chainId,\n\t\t\t\t\t{\n\t\t\t\t\t\tvalidAfter: userOperationToSign.validAfter,\n\t\t\t\t\t\tvalidUntil: userOperationToSign.validUntil,\n\t\t\t\t\t\tsafe4337ModuleAddress:\n\t\t\t\t\t\t\tuserOperationToSign.overrides?.safe4337ModuleAddress ??\n\t\t\t\t\t\t\tdefaultOverrides.safe4337ModuleAddress,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tuserOperationsHashes.push(userOperationHash);\n\t\t\t},\n\t\t);\n\t\tconst [_root, proofs] = generateMerkleProofs(userOperationsHashes);\n\t\tconst userOpSignatures: string[] = [];\n\t\tuserOperationsToSign.forEach(\n\t\t\t(userOperationToSign, index) => {\n\t\t\t\tuserOpSignatures.push(\n\t\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\t\t\tsignerSignaturePairs,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...defaultOverrides,\n\t\t\t\t\t\t\t...userOperationToSign.overrides,\n\t\t\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\t\t\tmultiChainMerkleProof: proofs[index],\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn userOpSignatures;\n\t}\n\n\tpublic static createWebAuthnSignerVerifierAddress(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.createWebAuthnSignerVerifierAddress(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode: overrides.webAuthnSignerProxyCreationCode??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t});\n\t}\n\n\tpublic static createDeployWebAuthnVerifierMetaTransaction(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t} = {},\n\t): MetaTransaction {\n\t\treturn SafeAccount.createDeployWebAuthnVerifierMetaTransaction(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t});\n\t}\n\n\tpublic static createDummySignerSignaturePairForExpectedSigners(\n\t\texpectedSigners: Signer[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): SignerSignaturePair[] {\n\t\treturn SafeAccount.createDummySignerSignaturePairForExpectedSigners(expectedSigners, {\n\t\t\t...webAuthnSignatureOverrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: webAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: webAuthnSignatureOverrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerFactory: webAuthnSignatureOverrides.webAuthnSignerFactory??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton: webAuthnSignatureOverrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode: webAuthnSignatureOverrides.webAuthnSignerProxyCreationCode??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\twebAuthnSharedSigner: webAuthnSignatureOverrides.webAuthnSharedSigner??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t});\n\t}\n\n\tpublic static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string,\n\t\tsigner: WebauthnPublicKey,\n\t\tmessageHash: string,\n\t\tsignature: string,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t} = {},\n\t): Promise<boolean> {\n\t\treturn SafeAccount.verifyWebAuthnSignatureForMessageHash(nodeRpcUrl, signer, messageHash, signature, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton??SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t});\n\t}\n}\n","import { GasOption, ParallelPaymasterInitValues, PolygonChain, StateOverrideSet } from \"src/types\";\n\n/**\n * Key types supported by the Calibur smart account.\n */\nexport enum CaliburKeyType {\n\t/** Raw P-256 (secp256r1) key */\n\tP256 = 0,\n\t/** WebAuthn-wrapped P-256 key (passkey) */\n\tWebAuthnP256 = 1,\n\t/** secp256k1 key (standard Ethereum EOA) */\n\tSecp256k1 = 2,\n}\n\n/**\n * A key registered on a Calibur account.\n */\nexport interface CaliburKey {\n\t/** The type of cryptographic key */\n\tkeyType: CaliburKeyType;\n\t/** ABI-encoded public key bytes (hex string) */\n\tpublicKey: string;\n}\n\n/**\n * Settings for a key registered on a Calibur account.\n * All fields are optional — used as input when registering or updating keys.\n */\nexport interface CaliburKeySettings {\n\t/** Hook contract address called during validation (zero address = no hook) */\n\thook?: string;\n\t/** Unix timestamp after which the key expires (0 = never) */\n\texpiration?: number;\n\t/** Whether the key has admin privileges */\n\tisAdmin?: boolean;\n}\n\n/**\n * Concrete key settings returned from on-chain reads.\n * Unlike {@link CaliburKeySettings}, all fields are required since\n * the contract always returns concrete values.\n */\nexport interface CaliburKeySettingsResult {\n\t/** Hook contract address called during validation (zero address = no hook) */\n\thook: string;\n\t/** Unix timestamp after which the key expires (0 = never) */\n\texpiration: number;\n\t/** Whether the key has admin privileges */\n\tisAdmin: boolean;\n}\n\n/**\n * WebAuthn assertion data matching the on-chain `WebAuthn.WebAuthnAuth` struct.\n * Used when signing UserOperations with a passkey.\n */\nexport interface WebAuthnSignatureData {\n\t/** Authenticator data bytes (hex string) */\n\tauthenticatorData: string;\n\t/** Client data JSON string (UTF-8) */\n\tclientDataJSON: string;\n\t/** Index of the challenge in clientDataJSON */\n\tchallengeIndex: bigint;\n\t/** Index of the type field in clientDataJSON */\n\ttypeIndex: bigint;\n\t/** ECDSA signature r component */\n\tr: bigint;\n\t/** ECDSA signature s component */\n\ts: bigint;\n}\n\n/**\n * Optional overrides for UserOperation fields when calling\n * {@link Calibur7702Account.createUserOperation}.\n * Any field left undefined will be auto-determined.\n */\nexport interface CaliburCreateUserOperationOverrides {\n\t/** Set the nonce instead of querying from the RPC node */\n\tnonce?: bigint;\n\t/** Set the callData instead of encoding the provided MetaTransactions */\n\tcallData?: string;\n\t/** Set the callGasLimit instead of estimating via the bundler */\n\tcallGasLimit?: bigint;\n\t/** Set the verificationGasLimit instead of estimating via the bundler */\n\tverificationGasLimit?: bigint;\n\t/** Set the preVerificationGas instead of estimating via the bundler */\n\tpreVerificationGas?: bigint;\n\t/** Set the maxFeePerGas instead of querying current gas price */\n\tmaxFeePerGas?: bigint;\n\t/** Set the maxPriorityFeePerGas instead of querying current gas price */\n\tmaxPriorityFeePerGas?: bigint;\n\n\t/** Percentage multiplier applied to estimated callGasLimit */\n\tcallGasLimitPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to estimated verificationGasLimit */\n\tverificationGasLimitPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to estimated preVerificationGas */\n\tpreVerificationGasPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to fetched maxFeePerGas */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** Percentage multiplier applied to fetched maxPriorityFeePerGas */\n\tmaxPriorityFeePerGasPercentageMultiplier?: number;\n\n\t/** State overrides for gas estimation */\n\tstate_override_set?: StateOverrideSet;\n\n\t/** Override the dummy signature used during gas estimation */\n\tdummySignature?: string;\n\n\t/** Gas price level preference */\n\tgasLevel?: GasOption;\n\t/** Polygon chain identifier for fetching gas prices from Polygon Gas Station */\n\tpolygonGasStation?: PolygonChain;\n\n\t/** Whether BatchedCall should revert on individual call failure (default: true) */\n\trevertOnFailure?: boolean;\n\n\t/**\n\t * Paymaster init values for gas estimation. Set these to include\n\t * paymaster data during gas estimation so preVerificationGas is accurate.\n\t * Use {@link ExperimentalAllowAllPaymaster.getPaymasterFieldsInitValues} or similar\n\t * to obtain these values.\n\t */\n\tpaymasterFields?: ParallelPaymasterInitValues;\n\n\t/**\n\t * EIP-7702 authorization fields. Required for the first UserOperation\n\t * to delegate the EOA to the Calibur singleton.\n\t */\n\teip7702Auth?: {\n\t\tchainId: bigint;\n\t\taddress?: string;\n\t\tnonce?: bigint;\n\t\tyParity?: string;\n\t\tr?: string;\n\t\ts?: string;\n\t};\n}\n\n/**\n * Optional overrides for signature wrapping.\n */\nexport interface CaliburSignatureOverrides {\n\t/** Hook data to append to the signature (default: \"0x\" = empty) */\n\thookData?: string;\n\t/** Key hash of a registered secondary key. If omitted, the root key hash is used. */\n\tkeyHash?: string;\n}\n\n/**\n * A signing function that takes a hash and returns a raw signature.\n * Use this to integrate viem, ethers Signers, hardware wallets, or MPC signers\n * without passing raw private keys.\n */\nexport type SignerFunction = (hash: string) => Promise<string>;\n","import { SmartAccount } from \"../SmartAccount\";\nimport { BaseUserOperationDummyValues, CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS, ENTRYPOINT_V8, ZeroAddress } from \"src/constants\";\nimport {\n\tcreateCallData, createUserOperationHash, fetchAccountNonce,\n\tgetDelegatedAddress, getFunctionSelector, handlefetchGasPrice, sendJsonRpcRequest\n} from \"../../utils\";\nimport { UserOperationV8 } from \"src/types\";\nimport { AbstractionKitError } from \"src/errors\";\nimport {\n\tAuthorization7702Hex, bigintToHex,\n\tcreateAndSignEip7702RawTransaction,\n\tcreateRevokeDelegationAuthorization,\n} from \"src/utils7702\";\nimport { Bundler } from \"src/Bundler\";\nimport { Wallet, AbiCoder, keccak256 } from \"ethers\";\nimport { SendUseroperationResponse } from \"../SendUseroperationResponse\";\nimport { SimpleMetaTransaction } from \"../simple/Simple7702Account\";\nimport { PrependTokenPaymasterApproveAccount } from \"src/paymaster/types\";\nimport {\n\tCaliburKeyType, CaliburKey, CaliburKeySettings, CaliburKeySettingsResult,\n\tWebAuthnSignatureData, CaliburCreateUserOperationOverrides,\n\tCaliburSignatureOverrides, SignerFunction,\n} from \"./types\";\n\n\nconst DEFAULT_SINGLETON_ADDRESS = CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS;\n\n/** Root key hash (bytes32 zero) — used for the EOA's own secp256k1 key */\nconst ROOT_KEY_HASH = \"0x0000000000000000000000000000000000000000000000000000000000000000\";\n\n// Function selectors — computed from Calibur's actual Solidity interfaces:\n// - executeUserOp is IAccountExecute.executeUserOp(PackedUserOperation,bytes32)\n// The EntryPoint calls this; userOp.callData = selector + abi.encode(BatchedCall)\n// - register takes Key struct: register((uint8,bytes))\n// - update/revoke/invalidateNonce match standard signatures\n\n/** executeUserOp selector — `executeUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)` from IAccountExecute */\nconst EXECUTE_USER_OP_SELECTOR = \"0x8dd7712f\";\n/** register((uint8,bytes)) — registers a Key struct */\nconst REGISTER_SELECTOR = \"0x30b1fa3b\";\n/** update(bytes32,uint256) — updates key settings */\nconst UPDATE_SELECTOR = \"0xa58bb84a\";\n/** revoke(bytes32) — revokes a key by hash */\nconst REVOKE_SELECTOR = \"0xb75c7dc6\";\n/** invalidateNonce(uint256) — invalidates nonces */\nconst INVALIDATE_NONCE_SELECTOR = \"0xb70e36f0\";\n\n// Read function selectors\n/** isRegistered(bytes32) */\nconst IS_REGISTERED_SELECTOR = \"0x27258b22\";\n/** getKeySettings(bytes32) — returns packed Settings (uint256) */\nconst GET_KEY_SETTINGS_SELECTOR = \"0x0f3ebf6e\";\n/** getKey(bytes32) — returns Key struct (uint8,bytes) */\nconst GET_KEY_SELECTOR = \"0x12aaac70\";\n/** keyCount() */\nconst KEY_COUNT_SELECTOR = \"0xfac750e0\";\n/** keyAt(uint256) — returns Key struct */\nconst KEY_AT_SELECTOR = \"0x4223b5c2\";\n\n/**\n * EIP-7702 smart account implementation for the Calibur (Uniswap) singleton.\n * Calibur turns an EOA into a smart account via EIP-7702 delegation, providing\n * batched transactions, passkey signing, ERC-4337 support, and per-key hooks.\n *\n * Unlike Safe accounts, there is no factory or proxy — the EOA IS the account.\n * All transactions go through `executeUserOp(bytes)` with `BatchedCall` encoding.\n *\n * @example\n * ```typescript\n * const account = new Calibur7702Account(\"0xMyEOA\");\n * const userOp = await account.createUserOperation(\n * [{ to: \"0xRecipient\", value: 1000000000000000n, data: \"0x\" }],\n * nodeRpc, bundlerRpc,\n * { eip7702Auth: { chainId: 11155111n } }\n * );\n * userOp.signature = account.signUserOperation(userOp, privateKey, 11155111n);\n * const response = await account.sendUserOperation(userOp, bundlerRpc);\n * ```\n */\nexport class Calibur7702Account extends SmartAccount\n\timplements PrependTokenPaymasterApproveAccount {\n\n\t/** Function selector for `executeUserOp(bytes)` */\n\tstatic readonly executorFunctionSelector = EXECUTE_USER_OP_SELECTOR;\n\n\t/**\n\t * Dummy ECDSA signature for gas estimation with root key signing.\n\t * Format: `abi.encode(bytes32 keyHash, bytes sig, bytes hookData)`\n\t */\n\tstatic readonly dummySignature: string = AbiCoder.defaultAbiCoder().encode(\n\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t[\n\t\t\tROOT_KEY_HASH,\n\t\t\t\"0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c\",\n\t\t\t\"0x\",\n\t\t],\n\t);\n\n\t/**\n\t * Create a dummy WebAuthn signature for gas estimation with passkey signing.\n\t * The key hash must correspond to an actually registered key on the account,\n\t * otherwise the contract's `validateUserOp` will revert with `KeyDoesNotExist`.\n\t *\n\t * @param keyHash - The key hash of a registered passkey (from {@link getKeyHash})\n\t * @returns A dummy signature suitable for passing as `dummySignature` override\n\t */\n\tpublic static createDummyWebAuthnSignature(keyHash: string): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst dummyClientDataJSON = '{\"type\":\"webauthn.get\",\"challenge\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\",\"origin\":\"https://example.com\",\"crossOrigin\":false}';\n\t\tconst challengeIndex = BigInt(dummyClientDataJSON.indexOf('\"challenge\":\"'));\n\t\tconst typeIndex = BigInt(dummyClientDataJSON.indexOf('\"type\":\"webauthn.get\"'));\n\t\treturn abiCoder.encode(\n\t\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t\t[\n\t\t\t\tkeyHash,\n\t\t\t\tabiCoder.encode(\n\t\t\t\t\t[\"(bytes,string,uint256,uint256,uint256,uint256)\"],\n\t\t\t\t\t[[\n\t\t\t\t\t\t\"0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000\",\n\t\t\t\t\t\tdummyClientDataJSON,\n\t\t\t\t\t\tchallengeIndex,\n\t\t\t\t\t\ttypeIndex,\n\t\t\t\t\t\tBigInt(\"0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\"),\n\t\t\t\t\t\tBigInt(\"0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\"),\n\t\t\t\t\t]],\n\t\t\t\t),\n\t\t\t\t\"0x\",\n\t\t\t],\n\t\t);\n\t}\n\n\t/**\n\t * Wrap a raw ECDSA signature in Calibur's signature format:\n\t * `abi.encode(bytes32 keyHash, bytes signature, bytes hookData)`.\n\t *\n\t * Use this when signing externally (e.g., with viem, hardware wallet, MPC)\n\t * to avoid manually ABI-encoding the wrapped signature.\n\t *\n\t * @param keyHash - The key hash (use ROOT_KEY_HASH `0x00...00` for the EOA's root key)\n\t * @param rawSignature - The raw ECDSA signature (65 bytes, hex-encoded)\n\t * @param hookData - Optional hook data (default: \"0x\")\n\t * @returns Hex-encoded wrapped signature ready for `userOp.signature`\n\t */\n\tpublic static wrapSignature(\n\t\tkeyHash: string,\n\t\trawSignature: string,\n\t\thookData = \"0x\",\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn abiCoder.encode(\n\t\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t\t[keyHash, rawSignature, hookData],\n\t\t);\n\t}\n\n\t/** The EntryPoint contract address this account targets */\n\treadonly entrypointAddress: string;\n\t/** The Calibur singleton (delegatee) contract address */\n\treadonly delegateeAddress: string;\n\n\t/**\n\t * Create a new Calibur7702Account instance for an existing EOA.\n\t * @param accountAddress - The EOA address that will be (or already is) delegated via EIP-7702\n\t * @param overrides - Optional overrides for entrypoint and delegatee addresses\n\t * @param overrides.entrypointAddress - Custom EntryPoint address (defaults to EntryPoint v0.8)\n\t * @param overrides.delegateeAddress - Custom Calibur singleton address\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tentrypointAddress?: string;\n\t\t\tdelegateeAddress?: string;\n\t\t} = {},\n\t) {\n\t\tsuper(accountAddress);\n\t\tthis.entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V8;\n\t\tthis.delegateeAddress = overrides.delegateeAddress ?? DEFAULT_SINGLETON_ADDRESS;\n\t}\n\n\t/**\n\t * Compute the UserOperation hash for this account's EntryPoint.\n\t * Convenience wrapper around the standalone `createUserOperationHash` that\n\t * automatically uses this account's EntryPoint address.\n\t *\n\t * @param userOperation - The UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @returns The UserOperation hash as a hex string\n\t */\n\tpublic getUserOperationHash(\n\t\tuserOperation: UserOperationV8,\n\t\tchainId: bigint,\n\t): string {\n\t\treturn createUserOperationHash(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t);\n\t}\n\n\t// ─── CallData Encoding ───────────────────────────────────────────────\n\n\t/**\n\t * Encode calldata for `executeUserOp(bytes)` with BatchedCall format.\n\t * All transactions (even single ones) go through the same BatchedCall path.\n\t *\n\t * @param transactions - One or more transactions to encode\n\t * @param revertOnFailure - Whether to revert the entire batch if any call fails (default: true)\n\t * @returns Encoded calldata for the executeUserOp function\n\t */\n\tpublic static createAccountCallData(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\trevertOnFailure = true,\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst calls = transactions.map(tx => [tx.to, tx.value, tx.data]);\n\t\t// BatchedCall struct { Call[] calls; bool revertOnFailure; }\n\t\t// Solidity's abi.decode(data, (BatchedCall)) expects a single struct/tuple\n\t\t// parameter, which has an extra offset layer compared to two separate args.\n\t\tconst batchedCallEncoded = abiCoder.encode(\n\t\t\t[\"((address,uint256,bytes)[],bool)\"],\n\t\t\t[[calls, revertOnFailure]],\n\t\t);\n\t\treturn EXECUTE_USER_OP_SELECTOR + batchedCallEncoded.slice(2);\n\t}\n\n\t// ─── UserOperation Lifecycle ─────────────────────────────────────────\n\n\t/**\n\t * Build an unsigned {@link UserOperationV8} from one or more transactions.\n\t * Determines nonce, fetches gas prices, estimates gas limits, and\n\t * optionally includes EIP-7702 authorization. All auto-determined\n\t * values can be overridden.\n\t *\n\t * @param transactions - One or more transactions to encode into callData\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param bundlerRpc - Bundler RPC endpoint for gas estimation\n\t * @param overrides - Optional overrides for gas, nonce, and EIP-7702 auth fields\n\t * @returns A promise resolving to an unsigned {@link UserOperationV8}\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CaliburCreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8> {\n\t\tif (transactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one transaction\");\n\t\t}\n\n\t\tlet nonce: bigint | null = null;\n\t\tlet nonceOp: Promise<bigint> | null = null;\n\n\t\tif (overrides.nonce == null) {\n\t\t\tif (providerRpc != null) {\n\t\t\t\tnonceOp = fetchAccountNonce(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc can't be null if nonce is not overridden\",\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tnonce = overrides.nonce;\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxFeePerGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.maxPriorityFeePerGas === \"bigint\" &&\n\t\t\toverrides.maxPriorityFeePerGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas override can't be negative\");\n\t\t}\n\n\t\tlet maxFeePerGas = BaseUserOperationDummyValues.maxFeePerGas;\n\t\tlet maxPriorityFeePerGas = BaseUserOperationDummyValues.maxPriorityFeePerGas;\n\n\t\tlet gasPriceOp: Promise<[bigint, bigint]> | null = null;\n\t\tif (\n\t\t\toverrides.maxFeePerGas == null ||\n\t\t\toverrides.maxPriorityFeePerGas == null\n\t\t) {\n\t\t\tgasPriceOp = handlefetchGasPrice(\n\t\t\t\tproviderRpc, overrides.polygonGasStation, overrides.gasLevel\n\t\t\t);\n\t\t}\n\n\t\tlet eip7702AuthChainId: bigint | null = null;\n\t\tlet eip7702AuthAddress: string | null = null;\n\t\tlet eip7702AuthNonce: bigint | null = null;\n\n\t\tif (overrides.eip7702Auth != null) {\n\t\t\teip7702AuthChainId = overrides.eip7702Auth.chainId;\n\t\t\teip7702AuthAddress = overrides.eip7702Auth.address ??\n\t\t\t\tthis.delegateeAddress;\n\t\t\teip7702AuthNonce = overrides.eip7702Auth.nonce ?? null;\n\t\t}\n\n\t\t// When eip7702Auth is provided, check if already delegated in parallel.\n\t\t// If already delegated to the target, skip the authorization.\n\t\tlet skipEip7702Auth = false;\n\t\tlet delegationCheckOp: Promise<string | null> | null = null;\n\t\tif (overrides.eip7702Auth != null && providerRpc != null) {\n\t\t\tdelegationCheckOp = getDelegatedAddress(this.accountAddress, providerRpc)\n\t\t\t\t.catch(() => null);\n\t\t}\n\n\t\tif (overrides.eip7702Auth != null && eip7702AuthNonce == null) {\n\t\t\tlet eip7702AuthNonceOp;\n\t\t\tif (providerRpc != null) {\n\t\t\t\teip7702AuthNonceOp = sendJsonRpcRequest(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\t\"eth_getTransactionCount\",\n\t\t\t\t\t[this.accountAddress, \"latest\"]\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"providerRpc can't be null if eoaDelegatorNonce \" +\n\t\t\t\t\t\"is not overriden\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst ops: Promise<unknown>[] = [eip7702AuthNonceOp];\n\t\t\tif (nonceOp != null) ops.push(nonceOp);\n\t\t\tif (gasPriceOp != null) ops.push(gasPriceOp);\n\t\t\tif (delegationCheckOp != null) ops.push(delegationCheckOp);\n\n\t\t\tconst values = await Promise.all(ops);\n\t\t\tlet idx = 0;\n\t\t\teip7702AuthNonce = BigInt(values[idx++] as string);\n\t\t\tif (nonceOp != null) nonce = values[idx++] as bigint;\n\t\t\tif (gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++] as [bigint, bigint];\n\t\t\tif (delegationCheckOp != null) {\n\t\t\t\tconst delegatedTo = values[idx++] as string | null;\n\t\t\t\tif (delegatedTo != null &&\n\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()) {\n\t\t\t\t\tskipEip7702Auth = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (overrides.eip7702Auth != null) {\n\t\t\tconst ops: Promise<unknown>[] = [];\n\t\t\tif (nonceOp != null) ops.push(nonceOp);\n\t\t\tif (gasPriceOp != null) ops.push(gasPriceOp);\n\t\t\tif (delegationCheckOp != null) ops.push(delegationCheckOp);\n\n\t\t\tif (ops.length > 0) {\n\t\t\t\tconst values = await Promise.all(ops);\n\t\t\t\tlet idx = 0;\n\t\t\t\tif (nonceOp != null) nonce = values[idx++] as bigint;\n\t\t\t\tif (gasPriceOp != null) [maxFeePerGas, maxPriorityFeePerGas] = values[idx++] as [bigint, bigint];\n\t\t\t\tif (delegationCheckOp != null) {\n\t\t\t\t\tconst delegatedTo = values[idx++] as string | null;\n\t\t\t\t\tif (delegatedTo != null &&\n\t\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()) {\n\t\t\t\t\t\tskipEip7702Auth = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (gasPriceOp != null && nonceOp != null) {\n\t\t\t\tawait Promise.all([nonceOp, gasPriceOp]).then((values) => {\n\t\t\t\t\tnonce = values[0];\n\t\t\t\t\t[maxFeePerGas, maxPriorityFeePerGas] = values[1];\n\t\t\t\t});\n\t\t\t} else if (gasPriceOp != null) {\n\t\t\t\t[maxFeePerGas, maxPriorityFeePerGas] = await gasPriceOp;\n\t\t\t} else if (nonceOp != null) {\n\t\t\t\tnonce = await nonceOp;\n\t\t\t}\n\t\t}\n\n\t\tmaxFeePerGas = overrides.maxFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxFeePerGas) *\n\t\t\t\t\t(((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n\t\t\t);\n\t\tmaxPriorityFeePerGas = overrides.maxPriorityFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxPriorityFeePerGas) *\n\t\t\t\t\t(((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t)\n\t\t\t);\n\n\t\tif (nonce == null) {\n\t\t\tthrow new RangeError(\"failed to determine nonce\");\n\t\t} else if (nonce < 0n) {\n\t\t\tthrow new RangeError(\"nonce can't be negative\");\n\t\t}\n\n\t\tlet callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tcallData = Calibur7702Account.createAccountCallData(\n\t\t\t\ttransactions,\n\t\t\t\toverrides.revertOnFailure ?? true,\n\t\t\t);\n\t\t} else {\n\t\t\tcallData = overrides.callData;\n\t\t}\n\n\t\tconst pmFields = overrides.paymasterFields;\n\t\tlet userOperation: UserOperationV8;\n\t\tif (overrides.eip7702Auth != null && !skipEip7702Auth) {\n\t\t\tconst yParity = overrides.eip7702Auth.yParity ?? \"0x0\";\n\t\t\tif (\n\t\t\t\tyParity != \"0x0\" && yParity != \"0x00\" &&\n\t\t\t\tyParity != \"0x1\" && yParity != \"0x01\"\n\t\t\t) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"invalid yParity value for eoaDelegatorSignature. \" +\n\t\t\t\t\t\"must be '0x0' or '0x1'\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst authorization: Authorization7702Hex = {\n\t\t\t\tchainId: bigintToHex(eip7702AuthChainId as bigint),\n\t\t\t\taddress: eip7702AuthAddress as string,\n\t\t\t\tnonce: bigintToHex(eip7702AuthNonce as bigint),\n\t\t\t\tyParity: yParity,\n\t\t\t\tr: overrides.eip7702Auth.r ??\n\t\t\t\t\t\"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2\",\n\t\t\t\ts: overrides.eip7702Auth.s ??\n\t\t\t\t\t\"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd\",\n\t\t\t};\n\t\t\tuserOperation = {\n\t\t\t\t...BaseUserOperationDummyValues,\n\t\t\t\tsender: this.accountAddress,\n\t\t\t\tnonce: nonce,\n\t\t\t\tcallData: callData,\n\t\t\t\tmaxFeePerGas: maxFeePerGas,\n\t\t\t\tmaxPriorityFeePerGas: maxPriorityFeePerGas,\n\t\t\t\tfactory: \"0x7702\",\n\t\t\t\tfactoryData: null,\n\t\t\t\tpaymaster: pmFields?.paymaster ?? null,\n\t\t\t\tpaymasterVerificationGasLimit: pmFields?.paymasterVerificationGasLimit ?? null,\n\t\t\t\tpaymasterPostOpGasLimit: pmFields?.paymasterPostOpGasLimit ?? null,\n\t\t\t\tpaymasterData: pmFields?.paymasterData ?? null,\n\t\t\t\teip7702Auth: authorization,\n\t\t\t};\n\t\t} else {\n\t\t\tuserOperation = {\n\t\t\t\t...BaseUserOperationDummyValues,\n\t\t\t\tsender: this.accountAddress,\n\t\t\t\tnonce: nonce,\n\t\t\t\tcallData: callData,\n\t\t\t\tmaxFeePerGas: maxFeePerGas,\n\t\t\t\tmaxPriorityFeePerGas: maxPriorityFeePerGas,\n\t\t\t\tfactory: null,\n\t\t\t\tfactoryData: null,\n\t\t\t\tpaymaster: pmFields?.paymaster ?? null,\n\t\t\t\tpaymasterVerificationGasLimit: pmFields?.paymasterVerificationGasLimit ?? null,\n\t\t\t\tpaymasterPostOpGasLimit: pmFields?.paymasterPostOpGasLimit ?? null,\n\t\t\t\tpaymasterData: pmFields?.paymasterData ?? null,\n\t\t\t\teip7702Auth: null,\n\t\t\t};\n\t\t}\n\n\t\tlet preVerificationGas = BaseUserOperationDummyValues.preVerificationGas;\n\t\tlet verificationGasLimit = BaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n\t\t\tif (bundlerRpc != null) {\n\t\t\t\tuserOperation.callGasLimit = 0n;\n\t\t\t\tuserOperation.verificationGasLimit = 0n;\n\t\t\t\tuserOperation.preVerificationGas = 0n;\n\t\t\t\tconst inputMaxFeePerGas = userOperation.maxFeePerGas;\n\t\t\t\tconst inputMaxPriorityFeePerGas = userOperation.maxPriorityFeePerGas;\n\t\t\t\tuserOperation.maxFeePerGas = 0n;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = 0n;\n\n\t\t\t\tconst userOperationToEstimate: UserOperationV8 = { ...userOperation };\n\t\t\t\tuserOperationToEstimate.signature = overrides.dummySignature ??\n\t\t\t\t\tCalibur7702Account.dummySignature;\n\n\t\t\t\tconst bundler = new Bundler(bundlerRpc);\n\t\t\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\t\t\tuserOperationToEstimate,\n\t\t\t\t\tthis.entrypointAddress,\n\t\t\t\t\toverrides.state_override_set,\n\t\t\t\t);\n\n\t\t\t\tpreVerificationGas = BigInt(estimation.preVerificationGas);\n\t\t\t\tverificationGasLimit = BigInt(estimation.verificationGasLimit);\n\t\t\t\tcallGasLimit = BigInt(estimation.callGasLimit);\n\t\t\t\t// Safety margin for P-256/WebAuthn signature verification overhead\n\t\t\t// that the bundler's simulation may underestimate.\n\t\t\tverificationGasLimit += 55_000n;\n\n\t\t\t\tuserOperation.maxFeePerGas = inputMaxFeePerGas;\n\t\t\t\tuserOperation.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc can't be null if preVerificationGas,\" +\n\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overriden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.preVerificationGas === \"bigint\" &&\n\t\t\toverrides.preVerificationGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"preVerificationGas override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.verificationGasLimit === \"bigint\" &&\n\t\t\toverrides.verificationGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"verificationGasLimit override can't be negative\");\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.callGasLimit === \"bigint\" &&\n\t\t\toverrides.callGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"callGasLimit override can't be negative\");\n\t\t}\n\n\t\tuserOperation.preVerificationGas = overrides.preVerificationGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(preVerificationGas) *\n\t\t\t\t\t(((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.verificationGasLimit = overrides.verificationGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(verificationGasLimit) *\n\t\t\t\t\t(((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.callGasLimit = overrides.callGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(callGasLimit) *\n\t\t\t\t\t(((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) / 100)\n\t\t\t\t),\n\t\t\t);\n\n\t\t// Set the dummy signature so paymaster sponsorship calls can simulate\n\t\t// validateUserOp (Calibur's signature decoder rejects empty signatures).\n\t\tuserOperation.signature = overrides.dummySignature ??\n\t\t\tCalibur7702Account.dummySignature;\n\n\t\treturn userOperation;\n\t}\n\n\t/**\n\t * Sign a UserOperation with a private key.\n\t * Computes the UserOperation hash and wraps the ECDSA signature in\n\t * Calibur's format: `abi.encode(keyHash, ecdsaSig, hookData)`.\n\t *\n\t * By default signs with the root key. To sign with a registered\n\t * secondary key, pass its key hash via `overrides.keyHash`.\n\t *\n\t * @param userOperation - The UserOperation to sign\n\t * @param privateKey - Hex-encoded private key\n\t * @param chainId - Target chain ID\n\t * @param overrides - Optional overrides (keyHash for secondary keys, hookData)\n\t * @returns Hex-encoded wrapped signature\n\t *\n\t * @example\n\t * // Sign with root key\n\t * userOp.signature = account.signUserOperation(userOp, privateKey, chainId);\n\t *\n\t * // Sign with a registered secondary key\n\t * userOp.signature = account.signUserOperation(userOp, privateKey, chainId, { keyHash });\n\t */\n\tpublic signUserOperation(\n\t\tuserOperation: UserOperationV8,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): string {\n\t\tconst userOperationHash = createUserOperationHash(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t);\n\t\tconst keyHash = overrides.keyHash ?? ROOT_KEY_HASH;\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\t\tconst wallet = new Wallet(privateKey);\n\t\tconst ecdsaSig = wallet.signingKey.sign(userOperationHash).serialized;\n\t\treturn Calibur7702Account.wrapSignature(keyHash, ecdsaSig, hookData);\n\t}\n\n\t/**\n\t * Sign a UserOperation with an external signer (viem, ethers Signer,\n\t * hardware wallet, MPC signer, etc.).\n\t * Computes the UserOperation hash and wraps the returned signature in\n\t * Calibur's format: `abi.encode(keyHash, ecdsaSig, hookData)`.\n\t *\n\t * By default signs with the root key. To sign with a registered\n\t * secondary key, pass its key hash via `overrides.keyHash`.\n\t *\n\t * @param userOperation - The UserOperation to sign\n\t * @param signer - Async signing function: `(hash: string) => Promise<string>`\n\t * @param chainId - Target chain ID\n\t * @param overrides - Optional overrides (keyHash for secondary keys, hookData)\n\t * @returns Promise resolving to the hex-encoded wrapped signature\n\t *\n\t * @example\n\t * // Sign with a viem wallet client\n\t * userOp.signature = await account.signUserOperationWithSigner(\n\t * userOp,\n\t * (hash) => walletClient.signMessage({ message: { raw: hash } }),\n\t * chainId,\n\t * );\n\t */\n\tpublic async signUserOperationWithSigner(\n\t\tuserOperation: UserOperationV8,\n\t\tsigner: SignerFunction,\n\t\tchainId: bigint,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): Promise<string> {\n\t\tconst userOperationHash = createUserOperationHash(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t);\n\t\tconst keyHash = overrides.keyHash ?? ROOT_KEY_HASH;\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\t\tconst ecdsaSig = await signer(userOperationHash);\n\t\treturn Calibur7702Account.wrapSignature(keyHash, ecdsaSig, hookData);\n\t}\n\n\t/**\n\t * Format a WebAuthn (passkey) assertion into Calibur's signature format.\n\t * The challenge for the WebAuthn assertion should be `abi.encode(userOpHash)`.\n\t *\n\t * @param keyHash - The key hash of the registered passkey (from {@link getKeyHash})\n\t * @param webAuthnAuth - WebAuthn assertion data from the browser\n\t * @param overrides - Optional signature overrides (e.g., hookData)\n\t * @returns Hex-encoded wrapped signature\n\t */\n\tpublic formatWebAuthnSignature(\n\t\tkeyHash: string,\n\t\twebAuthnAuth: WebAuthnSignatureData,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\n\t\t// Encode as a struct/tuple — Calibur decodes with:\n\t\t// abi.decode(signature, (WebAuthn.WebAuthnAuth))\n\t\t// which expects struct-wrapped encoding (extra offset for dynamic tuple).\n\t\tconst webAuthnEncoded = abiCoder.encode(\n\t\t\t[\"(bytes,string,uint256,uint256,uint256,uint256)\"],\n\t\t\t[[\n\t\t\t\twebAuthnAuth.authenticatorData,\n\t\t\t\twebAuthnAuth.clientDataJSON,\n\t\t\t\twebAuthnAuth.challengeIndex,\n\t\t\t\twebAuthnAuth.typeIndex,\n\t\t\t\twebAuthnAuth.r,\n\t\t\t\twebAuthnAuth.s,\n\t\t\t]],\n\t\t);\n\n\t\treturn abiCoder.encode(\n\t\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t\t[keyHash, webAuthnEncoded, hookData],\n\t\t);\n\t}\n\n\t/**\n\t * Submit a signed UserOperation to a bundler for on-chain inclusion.\n\t *\n\t * @param userOperation - The signed UserOperation to submit\n\t * @param bundlerRpc - Bundler RPC endpoint\n\t * @returns A {@link SendUseroperationResponse} that can be used to wait for inclusion\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV8,\n\t\tbundlerRpc: string,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = new Bundler(bundlerRpc);\n\t\tconst sendUserOperationRes = await bundler.sendUserOperation(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\n\t\treturn new SendUseroperationResponse(\n\t\t\tsendUserOperationRes,\n\t\t\tbundler,\n\t\t\tthis.entrypointAddress,\n\t\t);\n\t}\n\n\t// ─── Key Helpers (static) ────────────────────────────────────────────\n\n\t/**\n\t * Create a secp256k1 key descriptor from an Ethereum address.\n\t * @param address - The Ethereum address (EOA public address)\n\t * @returns A {@link CaliburKey} with type Secp256k1\n\t */\n\tpublic static createSecp256k1Key(address: string): CaliburKey {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn {\n\t\t\tkeyType: CaliburKeyType.Secp256k1,\n\t\t\tpublicKey: abiCoder.encode([\"address\"], [address]),\n\t\t};\n\t}\n\n\t/**\n\t * Create a WebAuthn P-256 key descriptor from public key coordinates.\n\t * @param x - The x coordinate of the P-256 public key\n\t * @param y - The y coordinate of the P-256 public key\n\t * @returns A {@link CaliburKey} with type WebAuthnP256\n\t */\n\tpublic static createWebAuthnP256Key(x: bigint, y: bigint): CaliburKey {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn {\n\t\t\tkeyType: CaliburKeyType.WebAuthnP256,\n\t\t\tpublicKey: abiCoder.encode([\"uint256\", \"uint256\"], [x, y]),\n\t\t};\n\t}\n\n\t/**\n\t * Create a raw P-256 key descriptor from public key coordinates.\n\t * @param x - The x coordinate of the P-256 public key\n\t * @param y - The y coordinate of the P-256 public key\n\t * @returns A {@link CaliburKey} with type P256\n\t */\n\tpublic static createP256Key(x: bigint, y: bigint): CaliburKey {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\treturn {\n\t\t\tkeyType: CaliburKeyType.P256,\n\t\t\tpublicKey: abiCoder.encode([\"uint256\", \"uint256\"], [x, y]),\n\t\t};\n\t}\n\n\t/**\n\t * Compute the key hash for a Calibur key.\n\t * Uses double hashing: `keccak256(abi.encode(uint8 keyType, bytes32 keccak256(publicKey)))`.\n\t *\n\t * @param key - The key to hash\n\t * @returns The key hash as a bytes32 hex string\n\t */\n\tpublic static getKeyHash(key: CaliburKey): string {\n\t\tconst innerHash = keccak256(key.publicKey);\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst encoded = abiCoder.encode(\n\t\t\t[\"uint8\", \"bytes32\"],\n\t\t\t[key.keyType, innerHash],\n\t\t);\n\t\treturn keccak256(encoded);\n\t}\n\n\t/**\n\t * Pack key settings into a single uint256 value.\n\t * Layout: `(isAdmin << 200) | (expiration << 160) | hook`\n\t *\n\t * @param settings - The key settings to pack\n\t * @returns The packed settings as a bigint\n\t */\n\tpublic static packKeySettings(settings: CaliburKeySettings): bigint {\n\t\tconst hook = BigInt(settings.hook ?? ZeroAddress);\n\t\tconst expiration = BigInt(settings.expiration ?? 0);\n\t\tconst isAdmin = settings.isAdmin ? 1n : 0n;\n\t\treturn (isAdmin << 200n) | (expiration << 160n) | hook;\n\t}\n\n\t/**\n\t * Unpack a uint256 settings value into a {@link CaliburKeySettingsResult} object.\n\t *\n\t * @param packed - The packed settings value\n\t * @returns Parsed key settings with all fields populated\n\t */\n\tpublic static unpackKeySettings(packed: bigint): CaliburKeySettingsResult {\n\t\tconst hook = \"0x\" + (packed & ((1n << 160n) - 1n)).toString(16).padStart(40, \"0\");\n\t\tconst expiration = Number((packed >> 160n) & ((1n << 40n) - 1n));\n\t\tconst isAdmin = ((packed >> 200n) & 1n) === 1n;\n\t\treturn { hook, expiration, isAdmin };\n\t}\n\n\t// ─── Key Management (static, return SimpleMetaTransaction) ───────────\n\n\t/**\n\t * Create meta-transactions to register a new key on the Calibur account.\n\t * Returns **two transactions**: `[register, update]`. Both must be included\n\t * in the same UserOperation.\n\t *\n\t * **Safety guardrail:** This method never sets `isAdmin: true` regardless\n\t * of input settings. Developers who need admin keys must encode calldata themselves.\n\t *\n\t * @param key - The key to register\n\t * @param settings - Optional key settings (isAdmin is always forced to false)\n\t * @returns A tuple of exactly two {@link SimpleMetaTransaction}s: [registerTx, updateTx].\n\t * Both must be included in the same UserOperation.\n\t */\n\tpublic static createRegisterKeyMetaTransactions(\n\t\tkey: CaliburKey,\n\t\tsettings: CaliburKeySettings = {},\n\t): [SimpleMetaTransaction, SimpleMetaTransaction] {\n\t\tif (settings.isAdmin === true) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"createRegisterKeyMetaTransactions does not allow setting \" +\n\t\t\t\t\"isAdmin to true. Encode the calldata manually for admin keys.\",\n\t\t\t);\n\t\t}\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\t\t// Register: register((uint8 keyType, bytes publicKey))\n\t\tconst registerCallData = REGISTER_SELECTOR + abiCoder.encode(\n\t\t\t[\"(uint8,bytes)\"],\n\t\t\t[[key.keyType, key.publicKey]],\n\t\t).slice(2);\n\n\t\t// Update: update(bytes32 keyHash, uint256 packedSettings)\n\t\tconst safeSettings: CaliburKeySettings = {\n\t\t\t...settings,\n\t\t\tisAdmin: false,\n\t\t};\n\t\tconst keyHash = Calibur7702Account.getKeyHash(key);\n\t\tconst packedSettings = Calibur7702Account.packKeySettings(safeSettings);\n\t\tconst updateCallData = UPDATE_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\", \"uint256\"],\n\t\t\t[keyHash, packedSettings],\n\t\t).slice(2);\n\n\t\treturn [\n\t\t\t{ to: ZeroAddress, value: 0n, data: registerCallData },\n\t\t\t{ to: ZeroAddress, value: 0n, data: updateCallData },\n\t\t] as [SimpleMetaTransaction, SimpleMetaTransaction];\n\t}\n\n\t/**\n\t * Create a meta-transaction to revoke a key from the Calibur account.\n\t *\n\t * @param keyHash - The key hash to revoke\n\t * @returns A {@link SimpleMetaTransaction} that calls `revoke(bytes32)`\n\t */\n\tpublic static createRevokeKeyMetaTransaction(\n\t\tkeyHash: string,\n\t): SimpleMetaTransaction {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = REVOKE_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\treturn { to: ZeroAddress, value: 0n, data: callData };\n\t}\n\n\t/**\n\t * Create meta-transactions to revoke ALL registered keys on this account.\n\t * Queries the on-chain key list and returns one `revoke(bytes32)` call per key.\n\t *\n\t * **Recommended before revoking EIP-7702 delegation** to prevent stale keys\n\t * from becoming active again if the EOA re-delegates later.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint to query registered keys\n\t * @returns Array of {@link SimpleMetaTransaction}s — one revoke call per key.\n\t * Empty array if no keys are registered.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Step 1: Revoke all keys (send as UserOp)\n\t * const revokeTxs = await account.createRevokeAllKeysMetaTransactions(providerRpc);\n\t * if (revokeTxs.length > 0) {\n\t * const userOp = await account.createUserOperation(revokeTxs, providerRpc, bundlerRpc);\n\t * userOp.signature = account.signUserOperation(userOp, privateKey, chainId);\n\t * const response = await account.sendUserOperation(userOp, bundlerRpc);\n\t * await response.included();\n\t * }\n\t *\n\t * // Step 2: Revoke delegation\n\t * const rawTx = await account.createRevokeDelegationRawTransaction(chainId, privateKey, providerRpc);\n\t * ```\n\t */\n\tpublic async createRevokeAllKeysMetaTransactions(\n\t\tproviderRpc: string,\n\t): Promise<SimpleMetaTransaction[]> {\n\t\tconst keys = await this.getKeys(providerRpc);\n\t\treturn keys.map((key) => {\n\t\t\tconst keyHash = Calibur7702Account.getKeyHash(key);\n\t\t\treturn Calibur7702Account.createRevokeKeyMetaTransaction(keyHash);\n\t\t});\n\t}\n\n\t/**\n\t * Create a signed raw transaction that revokes EIP-7702 delegation,\n\t * restoring this account to a plain EOA.\n\t *\n\t * **Recommended flow:** Call {@link createRevokeAllKeysMetaTransactions} first\n\t * and send the cleanup UserOp, then call this method to revoke delegation.\n\t * This prevents stale keys from reactivating if the EOA re-delegates later.\n\t *\n\t * @param chainId - Target chain ID\n\t * @param eoaPrivateKey - The EOA's private key for signing\n\t * @param providerRpc - JSON-RPC endpoint for nonce and gas price queries\n\t * @param overrides - Optional overrides for transaction parameters\n\t * @param overrides.nonce - Transaction nonce (fetched from provider if omitted)\n\t * @param overrides.authorizationNonce - EIP-7702 authorization nonce (defaults to txNonce + 1)\n\t * @param overrides.maxFeePerGas - Max fee per gas (fetched from provider if omitted)\n\t * @param overrides.maxPriorityFeePerGas - Max priority fee per gas (fetched if omitted)\n\t * @param overrides.gasLimit - Gas limit (defaults to 60,000)\n\t * @returns Hex-encoded signed EIP-7702 type-4 transaction ready for `eth_sendRawTransaction`\n\t * @throws {AbstractionKitError} If the account is not delegated or is delegated to a different address\n\t *\n\t * @example\n\t * ```typescript\n\t * const rawTx = await account.createRevokeDelegationRawTransaction(\n\t * 11155111n, privateKey, providerRpc,\n\t * );\n\t * await sendJsonRpcRequest(providerRpc, \"eth_sendRawTransaction\", [rawTx]);\n\t * ```\n\t */\n\tpublic async createRevokeDelegationRawTransaction(\n\t\tchainId: bigint,\n\t\teoaPrivateKey: string,\n\t\tproviderRpc: string,\n\t\toverrides: {\n\t\t\tnonce?: bigint;\n\t\t\tauthorizationNonce?: bigint;\n\t\t\tmaxFeePerGas?: bigint;\n\t\t\tmaxPriorityFeePerGas?: bigint;\n\t\t\tgasLimit?: bigint;\n\t\t} = {},\n\t): Promise<string> {\n\t\t// Verify the private key matches this account\n\t\tconst signerAddress = new Wallet(eoaPrivateKey).address;\n\t\tif (signerAddress.toLowerCase() !== this.accountAddress.toLowerCase()) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"eoaPrivateKey does not match accountAddress (\" +\n\t\t\t\t\tthis.accountAddress + \")\",\n\t\t\t);\n\t\t}\n\n\t\t// Verify delegation state before revoking\n\t\tconst delegatedTo = await getDelegatedAddress(this.accountAddress, providerRpc);\n\t\tif (delegatedTo === null) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Account is not delegated — nothing to revoke\",\n\t\t\t);\n\t\t}\n\t\tif (delegatedTo.toLowerCase() !== this.delegateeAddress.toLowerCase()) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Account is delegated to a different address (\" +\n\t\t\t\t\tdelegatedTo + \"), not \" + this.delegateeAddress +\n\t\t\t\t\t\" — use the correct account class to revoke\",\n\t\t\t);\n\t\t}\n\n\t\tconst results: {\n\t\t\tnonce?: bigint;\n\t\t\tmaxFeePerGas?: bigint;\n\t\t\tmaxPriorityFeePerGas?: bigint;\n\t\t} = {};\n\n\t\t// Build parallel fetch list\n\t\tconst ops: Promise<void>[] = [];\n\n\t\tif (overrides.nonce == null) {\n\t\t\tops.push(\n\t\t\t\tsendJsonRpcRequest(\n\t\t\t\t\tproviderRpc, \"eth_getTransactionCount\",\n\t\t\t\t\t[this.accountAddress, \"latest\"]\n\t\t\t\t).then((v) => { results.nonce = BigInt(v as string); })\n\t\t\t);\n\t\t}\n\n\t\tif (overrides.maxFeePerGas == null || overrides.maxPriorityFeePerGas == null) {\n\t\t\tops.push(\n\t\t\t\thandlefetchGasPrice(providerRpc, undefined)\n\t\t\t\t\t.then(([fee, tip]) => {\n\t\t\t\t\t\tresults.maxFeePerGas = fee;\n\t\t\t\t\t\tresults.maxPriorityFeePerGas = tip;\n\t\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (ops.length > 0) await Promise.all(ops);\n\n\t\tconst txNonce = overrides.nonce ?? results.nonce ?? 0n;\n\t\tconst maxFeePerGas = overrides.maxFeePerGas ?? results.maxFeePerGas ?? 0n;\n\t\tconst maxPriorityFeePerGas = overrides.maxPriorityFeePerGas ?? results.maxPriorityFeePerGas ?? 0n;\n\n\t\t// Authorization nonce = txNonce + 1 by default\n\t\t// (tx nonce is incremented before authorization processing in EIP-7702)\n\t\tconst authNonce = overrides.authorizationNonce ?? (txNonce + 1n);\n\n\t\t// Create undelegation authorization (delegates to address(0))\n\t\tconst authHex = createRevokeDelegationAuthorization(\n\t\t\tchainId, authNonce, eoaPrivateKey\n\t\t);\n\n\t\t// Convert Authorization7702Hex -> Authorization7702 for raw tx builder\n\t\tconst auth = {\n\t\t\tchainId: BigInt(authHex.chainId),\n\t\t\taddress: authHex.address,\n\t\t\tnonce: BigInt(authHex.nonce),\n\t\t\tyParity: (BigInt(authHex.yParity) === 0n ? 0 : 1) as 0 | 1,\n\t\t\tr: BigInt(authHex.r),\n\t\t\ts: BigInt(authHex.s),\n\t\t};\n\n\t\tconst gasLimit = overrides.gasLimit ?? 60_000n;\n\n\t\treturn createAndSignEip7702RawTransaction(\n\t\t\tchainId,\n\t\t\ttxNonce,\n\t\t\tmaxPriorityFeePerGas,\n\t\t\tmaxFeePerGas,\n\t\t\tgasLimit,\n\t\t\tthis.accountAddress,\n\t\t\t0n,\n\t\t\t\"0x\",\n\t\t\t[],\n\t\t\t[auth],\n\t\t\teoaPrivateKey,\n\t\t);\n\t}\n\n\t/**\n\t * Create a meta-transaction to update settings for a registered key.\n\t *\n\t * **Safety guardrail:** Throws if `settings.isAdmin` is `true`.\n\t * Developers who need admin keys must encode calldata themselves.\n\t *\n\t * @param keyHash - The key hash to update\n\t * @param settings - New settings for the key\n\t * @returns A {@link SimpleMetaTransaction} that calls `update(bytes32, uint256)`\n\t * @throws {AbstractionKitError} If settings.isAdmin is true\n\t */\n\tpublic static createUpdateKeySettingsMetaTransaction(\n\t\tkeyHash: string,\n\t\tsettings: CaliburKeySettings,\n\t): SimpleMetaTransaction {\n\t\tif (settings.isAdmin === true) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"createUpdateKeySettingsMetaTransaction does not allow setting \" +\n\t\t\t\t\"isAdmin to true. Encode the calldata manually for admin keys.\",\n\t\t\t);\n\t\t}\n\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst packedSettings = Calibur7702Account.packKeySettings(settings);\n\t\tconst callData = UPDATE_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\", \"uint256\"],\n\t\t\t[keyHash, packedSettings],\n\t\t).slice(2);\n\n\t\treturn { to: ZeroAddress, value: 0n, data: callData };\n\t}\n\n\t/**\n\t * Create a meta-transaction to invalidate nonces up to a given value.\n\t *\n\t * @param newNonce - The new nonce value (all nonces below this are invalidated)\n\t * @returns A {@link SimpleMetaTransaction} that calls `invalidateNonce(uint256)`\n\t */\n\tpublic static createInvalidateNonceMetaTransaction(\n\t\tnewNonce: bigint,\n\t): SimpleMetaTransaction {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = INVALIDATE_NONCE_SELECTOR + abiCoder.encode(\n\t\t\t[\"uint256\"],\n\t\t\t[newNonce],\n\t\t).slice(2);\n\n\t\treturn { to: ZeroAddress, value: 0n, data: callData };\n\t}\n\n\t// ─── Read Functions (instance, RPC calls) ────────────────────────────\n\n\t/**\n\t * Check if this EOA is delegated to this account's singleton (delegatee).\n\t * Returns `false` if not delegated at all or delegated to a different\n\t * singleton. Use the standalone {@link getDelegatedAddress} utility to\n\t * get the raw delegatee address regardless of which singleton it is.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @returns True if the account is delegated to `this.delegateeAddress`\n\t */\n\tpublic async isDelegatedToThisAccount(providerRpc: string): Promise<boolean> {\n\t\tconst address = await getDelegatedAddress(this.accountAddress, providerRpc);\n\t\tif (address === null) return false;\n\t\treturn address.toLowerCase() === this.delegateeAddress.toLowerCase();\n\t}\n\n\t/**\n\t * Get the account nonce from the EntryPoint.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param sequenceKey - Optional sequence key for parallel nonce channels (default: 0)\n\t * @returns The fully constructed nonce `(sequenceKey << 64) | seq`\n\t */\n\tpublic async getNonce(\n\t\tproviderRpc: string,\n\t\tsequenceKey = 0,\n\t): Promise<bigint> {\n\t\treturn fetchAccountNonce(\n\t\t\tproviderRpc,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.accountAddress,\n\t\t\tsequenceKey,\n\t\t);\n\t}\n\n\t/**\n\t * Check if a key is registered on this account.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param keyHash - The key hash to check\n\t * @returns True if the key is registered\n\t */\n\tpublic async isKeyRegistered(\n\t\tproviderRpc: string,\n\t\tkeyHash: string,\n\t): Promise<boolean> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = IS_REGISTERED_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: callData,\n\t\t\t\t},\n\t\t\t\t\"latest\",\n\t\t\t],\n\t\t);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = abiCoder.decode([\"bool\"], result);\n\t\t\treturn decoded[0] as boolean;\n\t\t}\n\t\tthrow new AbstractionKitError(\n\t\t\t\"BAD_DATA\",\n\t\t\t\"Unexpected response from isRegistered call\",\n\t\t);\n\t}\n\n\t/**\n\t * Get the settings for a registered key.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param keyHash - The key hash to query\n\t * @returns Parsed {@link CaliburKeySettingsResult} with all fields populated\n\t */\n\tpublic async getKeySettings(\n\t\tproviderRpc: string,\n\t\tkeyHash: string,\n\t): Promise<CaliburKeySettingsResult> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = GET_KEY_SETTINGS_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: callData,\n\t\t\t\t},\n\t\t\t\t\"latest\",\n\t\t\t],\n\t\t);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = abiCoder.decode([\"uint256\"], result);\n\t\t\treturn Calibur7702Account.unpackKeySettings(BigInt(decoded[0]));\n\t\t}\n\t\tthrow new AbstractionKitError(\n\t\t\t\"BAD_DATA\",\n\t\t\t\"Unexpected response from getKeySettings call\",\n\t\t);\n\t}\n\n\t/**\n\t * Get the full key data for a registered key.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param keyHash - The key hash to query\n\t * @returns Parsed {@link CaliburKey}\n\t */\n\tpublic async getKey(\n\t\tproviderRpc: string,\n\t\tkeyHash: string,\n\t): Promise<CaliburKey> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tconst callData = GET_KEY_SELECTOR + abiCoder.encode(\n\t\t\t[\"bytes32\"],\n\t\t\t[keyHash],\n\t\t).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: callData,\n\t\t\t\t},\n\t\t\t\t\"latest\",\n\t\t\t],\n\t\t);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = abiCoder.decode([\"(uint8,bytes)\"], result);\n\t\t\tconst keyTuple = decoded[0] as [number, string];\n\t\t\treturn {\n\t\t\t\tkeyType: Number(keyTuple[0]) as CaliburKeyType,\n\t\t\t\tpublicKey: keyTuple[1] as string,\n\t\t\t};\n\t\t}\n\t\tthrow new AbstractionKitError(\n\t\t\t\"BAD_DATA\",\n\t\t\t\"Unexpected response from getKey call\",\n\t\t);\n\t}\n\n\t/**\n\t * Get all keys registered on this account.\n\t * Iterates `keyCount()` + `keyAt(i)` to enumerate all keys.\n\t *\n\t * @param providerRpc - JSON-RPC endpoint\n\t * @param overrides - Optional overrides\n\t * @param overrides.blockNumber - Block number to query at. If omitted,\n\t * fetches the current block number once and uses it for all reads.\n\t * @returns Array of registered {@link CaliburKey}s\n\t */\n\tpublic async getKeys(\n\t\tproviderRpc: string,\n\t\toverrides: { blockNumber?: bigint } = {},\n\t): Promise<CaliburKey[]> {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\t\tlet blockTag: string;\n\t\tif (overrides.blockNumber != null) {\n\t\t\tblockTag = \"0x\" + overrides.blockNumber.toString(16);\n\t\t} else {\n\t\t\tconst blockHex = await sendJsonRpcRequest(\n\t\t\t\tproviderRpc, \"eth_blockNumber\", [],\n\t\t\t) as string;\n\t\t\tblockTag = blockHex;\n\t\t}\n\n\t\t// Get key count\n\t\tconst countResult = await sendJsonRpcRequest(\n\t\t\tproviderRpc,\n\t\t\t\"eth_call\",\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\tdata: KEY_COUNT_SELECTOR,\n\t\t\t\t},\n\t\t\t\tblockTag,\n\t\t\t],\n\t\t);\n\n\t\tif (typeof countResult !== \"string\") {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Unexpected response from keyCount call\",\n\t\t\t);\n\t\t}\n\n\t\t// Non-delegated accounts return \"0x\" which can't be converted to BigInt.\n\t\tif (countResult === \"0x\" || countResult === \"0x0\") {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst count = Number(BigInt(countResult));\n\t\tif (count === 0) return [];\n\n\t\t// Batch all keyAt calls in parallel\n\t\tconst keyAtPromises: Promise<unknown>[] = [];\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst keyAtCallData = KEY_AT_SELECTOR + abiCoder.encode(\n\t\t\t\t[\"uint256\"],\n\t\t\t\t[i],\n\t\t\t).slice(2);\n\n\t\t\tkeyAtPromises.push(\n\t\t\t\tsendJsonRpcRequest(\n\t\t\t\t\tproviderRpc,\n\t\t\t\t\t\"eth_call\",\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\t\t\tdata: keyAtCallData,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tblockTag,\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst keyResults = await Promise.all(keyAtPromises);\n\t\tconst keys: CaliburKey[] = [];\n\n\t\tfor (let i = 0; i < keyResults.length; i++) {\n\t\t\tconst keyResult = keyResults[i];\n\t\t\tif (typeof keyResult !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t`Unexpected response from keyAt(${i}) call on ${this.accountAddress}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst decoded = abiCoder.decode([\"(uint8,bytes)\"], keyResult);\n\t\t\tconst keyTuple = decoded[0] as [number, string];\n\t\t\tkeys.push({\n\t\t\t\tkeyType: Number(keyTuple[0]) as CaliburKeyType,\n\t\t\t\tpublicKey: keyTuple[1] as string,\n\t\t\t});\n\t\t}\n\n\t\treturn keys;\n\t}\n\n\t// ─── Token Paymaster Support ─────────────────────────────────────────\n\n\t/**\n\t * Prepend a token `approve` call to existing calldata for a token paymaster.\n\t * Decodes the existing BatchedCall, prepends an ERC-20 approve transaction,\n\t * and re-encodes.\n\t *\n\t * @param callData - Existing encoded calldata (executeUserOp format)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended\n\t */\n\tpublic prependTokenPaymasterApproveToCallData(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\treturn Calibur7702Account.prependTokenPaymasterApproveToCallDataStatic(\n\t\t\tcallData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tapproveAmount,\n\t\t);\n\t}\n\n\t/**\n\t * Static version of {@link prependTokenPaymasterApproveToCallData}.\n\t * Decodes existing executeUserOp calldata, prepends an ERC-20 approve call,\n\t * and re-encodes the BatchedCall.\n\t *\n\t * @param callData - Existing encoded calldata (executeUserOp format)\n\t * @param tokenAddress - ERC-20 token contract to approve\n\t * @param paymasterAddress - Paymaster address to approve as spender\n\t * @param approveAmount - Token amount to approve\n\t * @returns Re-encoded calldata with the approve transaction prepended\n\t */\n\tpublic static prependTokenPaymasterApproveToCallDataStatic(\n\t\tcallData: string,\n\t\ttokenAddress: string,\n\t\tpaymasterAddress: string,\n\t\tapproveAmount: bigint,\n\t): string {\n\t\tconst abiCoder = AbiCoder.defaultAbiCoder();\n\n\t\t// Build approve transaction\n\t\tconst approveFunctionSelector = getFunctionSelector(\"approve(address,uint256)\");\n\t\tconst approveCallData = createCallData(\n\t\t\tapproveFunctionSelector,\n\t\t\t[\"address\", \"uint256\"],\n\t\t\t[paymasterAddress, approveAmount],\n\t\t);\n\n\t\tif (!callData.startsWith(EXECUTE_USER_OP_SELECTOR)) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\"Invalid calldata, should start with \" + EXECUTE_USER_OP_SELECTOR +\n\t\t\t\t\" (executeUserOp selector)\",\n\t\t\t\t{ context: { callData } },\n\t\t\t);\n\t\t}\n\n\t\t// Decode: strip selector -> decode BatchedCall struct\n\t\tconst batchedCallDecoded = abiCoder.decode(\n\t\t\t[\"((address,uint256,bytes)[],bool)\"],\n\t\t\t\"0x\" + callData.slice(10),\n\t\t);\n\t\tconst existingCalls = batchedCallDecoded[0][0] as [];\n\t\tconst revertOnFailure = batchedCallDecoded[0][1] as boolean;\n\n\t\tconst decodedTransactions: SimpleMetaTransaction[] = existingCalls.map(\n\t\t\t(call: [string, bigint, string]) => ({\n\t\t\t\tto: call[0],\n\t\t\t\tvalue: BigInt(call[1]),\n\t\t\t\tdata: typeof call[2] !== \"string\"\n\t\t\t\t\t? new TextDecoder().decode(call[2])\n\t\t\t\t\t: call[2],\n\t\t\t}),\n\t\t);\n\n\t\t// Prepend approve\n\t\tdecodedTransactions.unshift({\n\t\t\tto: tokenAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: approveCallData,\n\t\t});\n\n\t\t// Re-encode as BatchedCall struct\n\t\tconst calls = decodedTransactions.map(tx => [tx.to, tx.value, tx.data]);\n\t\tconst batchedCallEncoded = abiCoder.encode(\n\t\t\t[\"((address,uint256,bytes)[],bool)\"],\n\t\t\t[[calls, revertOnFailure]],\n\t\t);\n\t\treturn EXECUTE_USER_OP_SELECTOR + batchedCallEncoded.slice(2);\n\t}\n}\n","import { AbstractionKitError } from \"src/errors\";\nimport { MetaTransaction } from \"../../../types\";\nimport { SafeAccount } from \"../SafeAccount\";\nimport { AbiCoder } from \"ethers\";\n\n/**\n * Abstract base class for Safe modules. Provides shared utilities for\n * encoding calldata, enabling the module, and validating on-chain results.\n */\nexport abstract class SafeModule {\n\treadonly moduleAddress: string;\n protected readonly abiCoder:AbiCoder;\n\n\t/**\n\t * @param moduleAddress - The deployed address of the Safe module contract.\n\t */\n\tconstructor(moduleAddress: string) {\n\t\tthis.moduleAddress = moduleAddress;\n this.abiCoder = AbiCoder.defaultAbiCoder();\n\t}\n\n /**\n\t * create MetaTransaction to enable this module\n\t * @param accountAddress - Safe account to enable the module for\n\t * @returns a MetaTransaction\n\t */\n public createEnableModuleMetaTransaction(\n accountAddress: string,\n ):MetaTransaction{\n return SafeAccount.createEnableModuleMetaTransaction(\n this.moduleAddress,\n accountAddress\n );\n }\n\n /**\n * Throws if the RPC call returned empty data (`0x`), which typically\n * indicates the module contract is not deployed at the expected address.\n * @param result - The raw hex result from an `eth_call`.\n * @param requestName - Name of the calling method, used in the error message.\n */\n public checkForEmptyResultAndRevert(\n result: string, requestName: string\n ): void {\n if(result == \"0x\"){\n throw new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\trequestName + \" returned 0x, \" +\n \"module contract \" + this.moduleAddress + \n \" is probably not deployed\"\n );\n } \n }\n}\n","import { SafeModule } from \"./SafeModule\";\nimport { createCallData, sendEthCallRequest } from \"../../../utils\";\nimport { MetaTransaction } from \"../../../types\";\n\n/**\n * Pre-deployed Social Recovery Module addresses, each with a different\n * grace period before a confirmed recovery can be finalized.\n */\nexport enum SocialRecoveryModuleGracePeriodSelector {\n\t/** 3-minute grace period (useful for testing). */\n\tAfter3Minutes = \"0x949d01d424bE050D09C16025dd007CB59b3A8c66\",\n\t/** 3-day grace period. */\n\tAfter3Days = \"0x38275826E1933303E508433dD5f289315Da2541c\",\n\t/** 7-day grace period. */\n\tAfter7Days = \"0x088f6cfD8BB1dDb1BB069CCb3fc1A98927D233f2\",\n\t/** 14-day grace period. */\n\tAfter14Days = \"0x9BacD92F4687Db306D7ded5d4513a51EA05df25b\",\n}\n\n/**\n * Safe module for social recovery with guardians. Allows designated guardians\n * to replace the owners of a Safe account when the original keys are lost.\n * Guardians must reach a configurable approval threshold before recovery\n * can be executed, and a grace period must elapse before finalization.\n */\nexport class SocialRecoveryModule extends SafeModule{\n static readonly DEFAULT_SOCIAL_RECOVERY_ADDRESS =\n SocialRecoveryModuleGracePeriodSelector.After3Days;\n\n /**\n * @param moduleAddress - Deployed address of the Social Recovery Module.\n * Defaults to the 3-day grace period deployment.\n */\n constructor(\n\t\tmoduleAddress: string = SocialRecoveryModule.DEFAULT_SOCIAL_RECOVERY_ADDRESS,\n\t) {\n\t\tsuper(moduleAddress);\n\t}\n\n /**\n\t * create MetaTransaction that lets single guardian confirm the execution of the recovery request.\n * Can also trigger the start of the execution by passing true to 'execute' parameter.\n * Once triggered the recovery is pending for the recovery period before it can be finalised.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @param execute - Whether to auto-start execution of recovery.\n\t * @returns a MetaTransaction\n\t */\n public createConfirmRecoveryMetaTransaction(\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n execute: boolean\n ):MetaTransaction{\n //\"confirmRecovery(address,address[],uint256,bool)\"\n const functionSelector = \"0x064e2d0e\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\", \"bool\"],\n [accountAddress, newOwners, newThreshold, execute],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that lets multiple guardians confirm the execution of the recovery request.\n * Can also trigger the start of the execution by passing true to 'execute' parameter.\n * Once triggered the recovery is pending for the recovery period before it can be finalised.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @param signatureData - The guardians signers and signatures pair list.\n * @param execute - true to auto-start execution of recovery or false for not.\n\t * @returns a MetaTransaction\n */\n public createMultiConfirmRecoveryMetaTransaction(\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n signaturePairList: RecoverySignaturePair[],\n execute: boolean\n ):MetaTransaction{\n //\"multiConfirmRecovery(address,address[],uint256,SignatureData[],bool)\"\n const functionSelector = \"0x0728e1e7\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\", \"(address,bytes)\", \"bool\"],\n [\n accountAddress,\n newOwners,\n newThreshold,\n signaturePairList.map(\n signaturePair=> [signaturePair.signer, signaturePair.signature]),\n execute\n ],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * @notice create MetaTransaction that lets the guardians start the execution of the recovery request.\n * Once triggered the recovery is pending for the recovery period before it can be finalised.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n\t * @returns a MetaTransaction\n */\n public createExecuteRecoveryMetaTransaction(\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n ):MetaTransaction{\n //\"executeRecovery(address,address[],uint256)\"\n const functionSelector = \"0xb1f85f69\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\"],\n [accountAddress, newOwners, newThreshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransaction that finalizes an ongoing recovery request if the recovery period is over.\n * The method is public and callable by anyone to enable orchestration.\n * @param accountAddress - The target account.\n\t * @returns a MetaTransaction\n */\n public createFinalizeRecoveryMetaTransaction(\n accountAddress: string,\n ):MetaTransaction{\n //\"finalizeRecovery(address)\"\n const functionSelector = \"0x315a7af3\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransction that lets the account cancel an ongoing recovery request.\n\t * @returns a MetaTransaction\n */\n public createCancelRecoveryMetaTransaction():MetaTransaction{\n //\"cancelRecovery()\";\n const functionSelector = \"0x0ba234d6\";\n const callData = functionSelector;\n\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransaction that lets the owner add a guardian for its account.\n * @param guardianAddress - The guardian to add.\n * @param threshold - The new threshold that will be set after addition.\n\t * @returns a MetaTransaction\n */\n public createAddGuardianWithThresholdMetaTransaction(\n guardianAddress: string,\n threshold: bigint,\n ):MetaTransaction{\n //\"addGuardianWithThreshold(address,uint256)\"\n const functionSelector = \"0xbe0e54d7\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"uint256\"],\n [guardianAddress, threshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that lets the owner revoke a guardian from its account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n * (to get the prevGuardian paramter).\n * @param accountAddress - The target account.\n * @param guardianAddress - The guardian to revoke.\n * @param threshold - The new threshold that will be set after execution of revokation.\n * @param prevGuardian - (if not provided, will be detected using the nodeRpcUrl)\n * The previous guardian linking to the guardian in the linked list.\n\t * @returns promise of a MetaTransaction\n */\n public async createRevokeGuardianWithThresholdMetaTransaction(\n nodeRpcUrl: string,\n accountAddress: string,\n guardianAddress: string,\n threshold: bigint,\n\t\toverrides: {\n prevGuardianAddress?: string,\n\t\t} = {},\n ):Promise<MetaTransaction>{\n let prevGuardianAddressT = overrides.prevGuardianAddress;\n\t\tif (prevGuardianAddressT == null) {\n\t\t\tconst guardians = await this.getGuardians(nodeRpcUrl, accountAddress);\n\t\t\tconst guardianToDeleteIndex = guardians.indexOf(guardianAddress);\n\t\t\tif (guardianToDeleteIndex == -1) {\n\t\t\t\tthrow new RangeError(\n guardianAddress + \n \" is not a current guardian for account : \" +\n accountAddress\n );\n\t\t\t} else if (guardianToDeleteIndex == 0) {\n //SENTINEL_ADDRESS\n\t\t\t\tprevGuardianAddressT = \"0x0000000000000000000000000000000000000001\";\n\t\t\t} else if (guardianToDeleteIndex > 0) {\n\t\t\t\tprevGuardianAddressT = guardians[guardianToDeleteIndex - 1];\n\t\t\t} else {\n\t\t\t\tthrow new RangeError(\"Invalid guardian index\");\n\t\t\t}\n\t\t}\n\t\treturn this.createStandardRevokeGuardianWithThresholdMetaTransaction(\n\t\t\tprevGuardianAddressT,\n guardianAddress,\n\t\t\tthreshold,\n\t\t);\n }\n\n /**\n * create MetaTransaction that lets the owner revoke a guardian from its account.\n * @param prevGuardian - The previous guardian linking to the guardian in the linked list.\n * @param guardian - The guardian to revoke.\n * @param threshold - The new threshold that will be set after execution of revokation.\n\t * @returns a MetaTransaction\n */\n public createStandardRevokeGuardianWithThresholdMetaTransaction(\n prevGuardianAddress: string,\n guardianAddress: string,\n threshold: bigint,\n ):MetaTransaction{\n //\"revokeGuardianWithThreshold(address,address,uint256)\"\n const functionSelector = \"0x936f7d86\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"uint256\"],\n [prevGuardianAddress, guardianAddress, threshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create MetaTransaction that lets the owner change the guardian threshold required to initiate a recovery.\n * @param threshold - The new threshold that will be set after execution of revokation.\n\t * @returns a MetaTransaction\n */\n public createChangeThresholdMetaTransaction(\n threshold: bigint,\n ):MetaTransaction{\n //\"changeThreshold(address,uint256)\"\n const functionSelector = \"0x694e80c3\";\n const callData = createCallData(\n functionSelector,\n [\"uint256\"],\n [threshold],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * Generates the recovery hash that should be signed by the guardian to authorize a recovery\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @param nonce - recovery nonce\n\t * @returns promise of a recovery hash\n */\n public async getRecoveryHash(\n nodeRpcUrl: string,\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n nonce: bigint,\n ):Promise<string>{\n //\"getRecoveryHash(address,address[],uint256,uint256)\"\n const functionSelector = \"0x5f19df08\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\", \"uint256\"],\n [accountAddress, newOwners, newThreshold, nonce],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const recoveryHashResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n \n this.checkForEmptyResultAndRevert(recoveryHashResult, \"getRecoveryHash\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"bytes32\"], recoveryHashResult);\n return decodedCalldata[0];\n }\n\n /**\n * Retrieves the account's current ongoing recovery request.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of the account's current recovery request\n */\n public async getRecoveryRequest(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<RecoveryRequest>{\n //\"getRecoveryRequest(address)\"\n const functionSelector = \"0x4f9a28b9\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const recoveryRequestResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(recoveryRequestResult, \"getRecoveryRequest\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"(uint256,uint256,uint64,address[])\"], recoveryRequestResult);\n\n return {\n guardiansApprovalCount: BigInt(decodedCalldata[0][0]),\n newThreshold: BigInt(decodedCalldata[0][1]),\n executeAfter: BigInt(decodedCalldata[0][2]),\n newOwners: decodedCalldata[0][3],\n }\n }\n\n /**\n * Retrieves the guardian approval count for this particular recovery request at current nonce.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @return promise of the account's current recovery approvals count\n */\n public async getRecoveryApprovals(\n nodeRpcUrl: string,\n accountAddress: string,\n newOwners: string[],\n newThreshold: number,\n ):Promise<bigint>{\n //\"getRecoveryApprovals(address,address[],uint256)\"\n const functionSelector = \"0x6c6595ca\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address[]\", \"uint256\"],\n [accountAddress, newOwners, newThreshold],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const recoveryApprovalResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(recoveryApprovalResult, \"getRecoveryApprovals\");\n\t const decodedCalldata = this.abiCoder.decode([\"uint256\"], recoveryApprovalResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n * Retrieves specific guardian approval status a particular recovery request at current nonce.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param guardian - The guardian.\n * @param newOwners - The new owners' addressess.\n * @param newThreshold - The new threshold for the safe.\n * @return promise of guardian approval status\n */\n public async hasGuardianApproved(\n nodeRpcUrl: string,\n accountAddress: string,\n guardian: string,\n newOwners: string[],\n newThreshold: number,\n ):Promise<boolean>{\n //\"hasGuardianApproved(address,address,address[],uint256)\"\n const functionSelector = \"0x37d82c36\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"address[]\", \"uint256\"],\n [accountAddress, guardian, newOwners, newThreshold],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const hasGuardianApprovedResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(\n hasGuardianApprovedResult, \"hasGuardianApproved\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"bool\"], hasGuardianApprovedResult);\n\n return Boolean(decodedCalldata[0]);\n }\n\n /**\n * Checks if an address is a guardian for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @param guardian - The address to check.\n * @return promise of `true` if the address is a guardian for\n * the account otherwise `false`.\n */\n public async isGuardian(\n nodeRpcUrl: string,\n accountAddress: string,\n guardian: string,\n ):Promise<boolean>{\n //\"isGuardian(address,address)\"\n const functionSelector = \"0xd4ee9734\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [accountAddress, guardian],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const isGuardianResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(isGuardianResult, \"isGuardian\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"bool\"], isGuardianResult);\n\n return Boolean(decodedCalldata[0]);\n }\n\n /**\n * Counts the number of active guardians for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of The number of active guardians for an account.\n */\n public async guardiansCount(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<bigint>{\n //\"guardiansCount(address)\"\n const functionSelector = \"0xc026e7ee\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const guardiansCountResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(guardiansCountResult, \"guardiansCount\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"uint256\"], guardiansCountResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n * Retrieves the account threshold.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of Threshold.\n */\n public async threshold(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<bigint>{\n //\"threshold(address)\"\n const functionSelector = \"0xc86ec2bf\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const thresholdResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(thresholdResult, \"threshold\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"uint256\"], thresholdResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n * Get the active guardians for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of a list of the active guardians for an account.\n */\n public async getGuardians(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<string[]>{\n //\"getGuardians(address)\"\n const functionSelector = \"0xf18858ab\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const getGuardiansResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(getGuardiansResult, \"threshold\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"address[]\"], getGuardiansResult);\n\n return decodedCalldata[0];\n }\n\n /**\n * Get the module nonce for an account.\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param accountAddress - The target account.\n * @return promise of the nonce for this account.\n */\n public async nonce(\n nodeRpcUrl: string,\n accountAddress: string,\n ):Promise<bigint>{\n //\"nonce(address)\"\n const functionSelector = \"0x70ae92d2\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [accountAddress],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n const nonceResult = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n\n this.checkForEmptyResultAndRevert(nonceResult, \"threshold\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"uint256\"], nonceResult);\n\n return BigInt(decodedCalldata[0]);\n }\n\n /**\n\t * create recovery request eip712 data\n\t * @param rpcNode - node to fetch the recovery nonce\n\t * @param accountAddress - address of account to recover\n\t * @param newOwners - new owners to recover to\n\t * @param newThreshold - new threshold\n\t * @param overrides.recoveryNonce - manually set the recovery nonce\n\t * @returns an object containing the typed data domain, type and typed data vales\n * object needed for hashing and signing\n\t */\n\tasync getRecoveryRequestEip712Data(\n rpcNode: string,\n chainId: bigint,\n accountAddress: string,\n newOwners: string[],\n newThreshold: bigint,\n overrides: {\n recoveryNonce?: bigint,\n } = {}\n\t): Promise<{\n domain: RecoveryRequestTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: RecoveryRequestTypedMessageValue\n }> {\n let recoveryNonce;\n if(overrides.recoveryNonce == null){\n const socialRecoveryModule = new SocialRecoveryModule(\n this.moduleAddress\n );\n recoveryNonce = await socialRecoveryModule.nonce(rpcNode, accountAddress);\n }else{\n recoveryNonce = overrides.recoveryNonce;\n }\n\n const messageValue: RecoveryRequestTypedMessageValue = {\n wallet: accountAddress,\n newOwners,\n newThreshold,\n nonce: recoveryNonce\n };\n const domain: RecoveryRequestTypedDataDomain = {\n name: \"Social Recovery Module\",\n version: \"0.0.1\",\n chainId: Number(chainId),\n verifyingContract: this.moduleAddress\n };\n\n return {\n domain,\n types: EIP712_RECOVERY_MODULE_TYPE,\n messageValue,\n };\n\t}\n}\n\n/**\n * Represents an ongoing recovery request for a Safe account.\n */\nexport type RecoveryRequest = {\n /** Number of guardians that have approved this recovery request. */\n guardiansApprovalCount:bigint;\n /** The new owner threshold that will be set after recovery. */\n newThreshold:bigint;\n /** Unix timestamp (seconds) after which the recovery can be finalized. 0 if not yet executed. */\n executeAfter:bigint;\n /** The list of new owner addresses that will replace the current owners. */\n newOwners:string[];\n}\n\n/**\n * A guardian address paired with its EIP-712 signature authorizing a recovery.\n */\nexport type RecoverySignaturePair = {\n /** Guardian address that produced the signature. */\n signer:string;\n /** Hex-encoded signature bytes. */\n signature:string;\n}\n\n/** EIP-712 primary type string used when signing recovery requests. */\nexport const EXECUTE_RECOVERY_PRIMARY_TYPE = \"ExecuteRecovery\";\n\n/**\n * EIP-712 domain separator fields for signing recovery requests.\n */\nexport type RecoveryRequestTypedDataDomain = {\n /** Domain name, always \"Social Recovery Module\". */\n name: string;\n /** Domain version, e.g. \"0.0.1\". */\n version: string;\n /** Chain ID of the target network. */\n\tchainId: number;\n /** Address of the Social Recovery Module contract. */\n\tverifyingContract: string;\n}\n\n/**\n * EIP-712 structured message values for a recovery request signature.\n */\nexport type RecoveryRequestTypedMessageValue = {\n /** Address of the Safe account being recovered. */\n\twallet: string;\n /** New owner addresses to set after recovery. */\n\tnewOwners: string[];\n /** New Safe threshold to set after recovery. */\n\tnewThreshold: bigint;\n /** Recovery nonce for replay protection. */\n\tnonce: bigint;\n}\n\n/** EIP-712 type definitions for the `ExecuteRecovery` primary type. */\nexport const EIP712_RECOVERY_MODULE_TYPE = {\n ExecuteRecovery: [\n { type: \"address\", name: \"wallet\" },\n { type: \"address[]\", name: \"newOwners\" },\n { type: \"uint256\", name: \"newThreshold\" },\n { type: \"uint256\", name: \"nonce\" },\n ],\n};\n","import { SafeModule } from \"./SafeModule\";\nimport { createCallData, sendEthCallRequest } from \"../../../utils\";\nimport { MetaTransaction } from \"../../../types\";\n\n/**\n * Address of the legacy Allowance Module v0.1.0 contract.\n * Replaced by v1.0.0 due to a bug in the v0.1.0 contract.\n * Use this to interact with existing allowances set on the old module.\n * @deprecated Prefer `AllowanceModule.DEFAULT_ALLOWANCE_MODULE_ADDRESS` (v1.0.0) for new allowances.\n */\nexport const ALLOWANCE_MODULE_V0_1_0_ADDRESS =\n \"0xAA46724893dedD72658219405185Fb0Fc91e091C\";\n\n/**\n * Safe module for managing token spending allowances (v1.0.0). Enables Safe owners\n * to grant delegates recurring or one-time permission to transfer ERC-20\n * tokens from the Safe, subject to configurable limits and reset periods.\n *\n * Requires Safe v1.1.1 or later.\n *\n * Each delegate is limited to 65534 transfers per token allowance (uint16 nonce).\n * Once exhausted, a new delegate must be used.\n *\n * **Breaking change (v1.0.0):** The default module address changed from\n * {@link ALLOWANCE_MODULE_V0_1_0_ADDRESS} (`0xAA46…091C`) due to a bug in the\n * v0.1.0 contract. If you have active allowances on the old module, use\n * `new AllowanceModule(ALLOWANCE_MODULE_V0_1_0_ADDRESS)` to interact with them.\n */\nexport class AllowanceModule extends SafeModule{\n static readonly DEFAULT_ALLOWANCE_MODULE_ADDRESS =\n \"0x691f59471Bfd2B7d639DCF74671a2d648ED1E331\";\n\n /**\n * @param moduleAddress - Deployed address of the Allowance Module contract.\n * Defaults to {@link DEFAULT_ALLOWANCE_MODULE_ADDRESS}.\n */\n constructor(\n\t\tmoduleAddress: string = AllowanceModule.DEFAULT_ALLOWANCE_MODULE_ADDRESS,\n\t) {\n\t\tsuper(moduleAddress);\n\t}\n \n /**\n * Creates a MetaTransaction that sets a one-time (non-recurring) token allowance\n * for a delegate. The allowance is consumed once and never resets.\n * @param delegate - Address of the delegate to grant the allowance to.\n * @param token - ERC-20 token contract address (use zero address for native token).\n * @param allowanceAmount - Maximum amount the delegate can spend, in the token's smallest unit.\n * @param startAfterInMinutes - Delay in minutes before the allowance becomes active.\n * @returns A MetaTransaction to be executed by the Safe.\n */\n public createOneTimeAllowanceMetaTransaction(\n delegate: string,\n token: string,\n allowanceAmount: bigint,\n startAfterInMinutes:bigint\n ):MetaTransaction{\n return this.createBaseSetAllowanceMetaTransaction(\n delegate,\n token,\n allowanceAmount,\n 0n,\n startAfterInMinutes\n )\n }\n \n /**\n * Creates a MetaTransaction that sets a recurring token allowance for a delegate.\n * The allowance resets to the full amount after each validity period elapses.\n * @param delegate - Address of the delegate to grant the allowance to.\n * @param token - ERC-20 token contract address (use zero address for native token).\n * @param allowanceAmount - Maximum amount per period, in the token's smallest unit.\n * @param recurringAllowanceValidityPeriodInMinutes - Duration of each allowance period in minutes.\n * @param startAfterInMinutes - Delay in minutes before the first allowance period begins.\n * @returns A MetaTransaction to be executed by the Safe.\n */\n public createRecurringAllowanceMetaTransaction(\n delegate: string,\n token: string,\n allowanceAmount: bigint,\n recurringAllowanceValidityPeriodInMinutes: bigint,\n startAfterInMinutes:bigint\n ):MetaTransaction{\n return this.createBaseSetAllowanceMetaTransaction(\n delegate,\n token,\n allowanceAmount,\n recurringAllowanceValidityPeriodInMinutes,\n startAfterInMinutes\n )\n }\n\n /**\n\t * create MetaTransaction that allows to update the allowance for \n * a specified token. This can only be done via a Safe transaction.\n * @param delegate - Delegate whose allowance should be updated.\n * @param token - Token contract address.\n * @param allowanceAmount - allowance in smallest token unit.\n * @param resetTimeMin - Time after which the allowance should reset\n * @param resetBaseMin - Time based on which the reset time should be increased\n * @returns a MetaTransaction\n\t */\n public createBaseSetAllowanceMetaTransaction(\n delegate: string,\n token: string,\n allowanceAmount: bigint,\n resetTimeMin: bigint,\n resetBaseMin:bigint\n ):MetaTransaction{\n //setAllowance(address delegate, address token, uint96 allowanceAmount, uint16 resetTimeMin, uint32 resetBaseMin)\n const functionSelector = \"0xbeaeb388\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"uint96\", \"uint16\", \"uint32\"],\n [delegate, token, allowanceAmount, resetTimeMin, resetBaseMin],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that allows to renew(reset) the allowance for a specific\n * delegate and token.\n * @param delegate - Delegate whose allowance should be updated.\n * @param token - Token contract address.\n\t * @returns a MetaTransaction\n */\n public createRenewAllowanceMetaTransaction(\n delegate: string, token: string\n ):MetaTransaction{\n //resetAllowance(address delegate, address token)\n const functionSelector = \"0xc19bf50e\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [delegate, token],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create MetaTransaction that allows to remove the allowance for a specific\n * delegate and token. This will set all values except the `nonce` to 0.\n * @param delegate - Delegate whose allowance should be updated.\n * @param token - Token contract address.\n\t * @returns a MetaTransaction\n */\n public createDeleteAllowanceMetaTransaction(\n delegate: string, token: string\n ):MetaTransaction{\n //deleteAllowance(address delegate, address token)\n const functionSelector = \"0x885133e3\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [delegate, token],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * Creates a MetaTransaction that executes a token transfer using an existing allowance.\n * Can be called by the delegate or by anyone with a valid delegate signature.\n * @param allowanceSourceSafeAddress - Safe address whose allowance is being spent.\n * @param token - ERC-20 token contract address to transfer.\n * @param to - Recipient address for the token transfer.\n * @param amount - Amount to transfer, in the token's smallest unit.\n * @param delegate - Delegate address whose allowance is being used.\n * @param overrides.delegateSignature - Optional signature from the delegate. Defaults to a\n * sentinel value indicating the caller is the delegate themselves.\n * @param overrides.paymentToken - Optional token address used to pay for execution.\n * @param overrides.paymentAmount - Amount to pay for execution (required if paymentToken is set).\n * @returns A MetaTransaction to be executed by the Safe.\n * @throws Will revert on-chain if the delegate's nonce has reached 65534 for this token.\n */\n public createAllowanceTransferMetaTransaction(\n allowanceSourceSafeAddress: string,\n token: string,\n to: string,\n amount: bigint,\n delegate:string,\n overrides:{\n delegateSignature?:string,\n paymentToken?: string,\n paymentAmount?: bigint,\n } = {}\n ):MetaTransaction{\n let paymentToken = \"0x0000000000000000000000000000000000000000\"\n let paymentAmount = 0n;\n if(overrides.paymentToken != null){\n paymentToken = overrides.paymentToken;\n if(overrides.paymentAmount == null){\n throw new RangeError(\"must specify paymentAmount if paymentToken is set\")\n }\n paymentAmount = overrides.paymentAmount;\n }\n \n let delegateSignature = \n overrides.delegateSignature??\n\t\t \"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\"\n\n return this.createBaseExecuteAllowanceTransferMetaTransaction(\n allowanceSourceSafeAddress,\n token,\n to,\n amount,\n paymentToken,\n paymentAmount,\n delegate,\n delegateSignature\n )\n }\n\n /**\n * \n * create MetaTransaction that allows to use the allowance to perform a transfer.\n * @param safeAddress - The Safe whose funds should be used.\n * @param token - Token contract address.\n * @param to - Address that should receive the tokens.\n * @param amount - Amount that should be transferred.\n * @param paymentToken - Token that should be used to pay for the execution of the transfer.\n * @param payment - Amount to should be paid for executing the transfer.\n * @param delegate - Delegate whose allowance should be updated.\n * @param signature - Signature generated by the delegate to authorize the transfer.\n\t * @returns a MetaTransaction\n */\n public createBaseExecuteAllowanceTransferMetaTransaction(\n safeAddress: string,\n token: string,\n to: string,\n amount: bigint,\n paymentToken: string,\n payment: bigint,\n delegate:string,\n delegateSignature:string\n ):MetaTransaction{\n //executeAllowanceTransfer(address,address,address,uint96,address,uint96,address,bytes)\n const functionSelector = \"0x4515641a\";\n const callData = createCallData(\n functionSelector,\n [\n \"address\",\n \"address\",\n \"address\",\n \"uint96\",\n \"address\",\n \"uint96\",\n \"address\",\n \"bytes\",\n ],\n [\n safeAddress,\n token,\n to,\n amount,\n paymentToken,\n payment,\n delegate,\n delegateSignature\n ]\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n /**\n * create a MetaTransaction that allows to add a delegate.\n * @param delegate - Delegate that should be added.\n\t * @returns a MetaTransaction\n */\n public createAddDelegateMetaTransaction(\n delegate: string,\n ):MetaTransaction{\n //\"addDelegate(address)\"\n const functionSelector = \"0xe71bdf41\";\n const callData = createCallData(\n functionSelector,\n [\"address\"],\n [delegate],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n \n /**\n * create a MetaTransaction that allows to remove a delegate.\n * @param delegate - Delegate that should be removed.\n * @param removeAllowances - Indicator if allowances should also be removed.\n * This should be set to `true` unless this causes an out of gas,\n * in this case the allowances should be \"manually\" deleted via `deleteAllowance`.\n\t * @returns a MetaTransaction\n */\n public createRemoveDelegateMetaTransaction(\n delegate: string,\n removeAllowances: boolean\n ):MetaTransaction{\n //\"removeDelegate(address,bool)\"\n const functionSelector = \"0xdd43a79f\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"bool\"],\n [delegate, removeAllowances],\n );\n return {\n to:this.moduleAddress,\n data: callData,\n value: 0n\n }\n }\n\n \n /**\n * Get delegated tokens\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param safeAddress - The target account.\n * @param delegate - The target delegate.\n\t * @returns promise of a list of tokens\n */\n public async getTokens(\n nodeRpcUrl: string,\n safeAddress: string,\n delegate: string,\n ):Promise<string[]>{\n //\"getTokens(address,address)\"\n const functionSelector = \"0x8d0e8e1d\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\"],\n [safeAddress, delegate],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const tokens = await sendEthCallRequest(nodeRpcUrl, ethCallParams, \"latest\");\n this.checkForEmptyResultAndRevert(tokens, \"getTokens\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"address[]\"], tokens);\n return decodedCalldata[0];\n }\n\n /**\n * Get allowance\n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param safeAddress - The target account.\n * @param delegate - The target delegate.\n * @param token - The target delegate.\n\t * @returns promise of Allowance\n */\n public async getTokensAllowance(\n nodeRpcUrl: string,\n safeAddress: string,\n delegate: string,\n token: string,\n ):Promise<Allowance>{\n //\"getTokenAllowance(address,address,address)\"\n const functionSelector = \"0x94b31fbd\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"address\", \"address\"],\n [safeAddress, delegate, token],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const tokenAllowance = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n this.checkForEmptyResultAndRevert(tokenAllowance, \"getTokenAllowance\");\n\t const decodedCalldata = this.abiCoder.decode([\"uint256[5]\"], tokenAllowance);\n const allowance = decodedCalldata[0]\n return {\n amount: BigInt(allowance[0]),\n spent: BigInt(allowance[1]),\n resetTimeMin: BigInt(allowance[2]),\n lastResetMin: BigInt(allowance[3]),\n nonce: BigInt(allowance[4]),\n };\n }\n\n /**\n * Fetches all delegate addresses for a Safe. Automatically paginates through\n * all results unless `maxNumberOfResults` is specified.\n * @param nodeRpcUrl - JSON-RPC endpoint URL for the target chain.\n * @param safeAddress - The Safe account address to query delegates for.\n * @param overrides.start - Starting index for pagination (default 0).\n * @param overrides.maxNumberOfResults - Maximum number of delegates to return.\n * If omitted, all delegates are fetched via automatic pagination.\n * @returns Array of delegate addresses.\n */\n public async getDelegates(\n nodeRpcUrl: string,\n safeAddress: string,\n overrides:{\n start?: bigint,\n maxNumberOfResults?: bigint,\n } = {}\n ):Promise<string[]>{\n let start = overrides.start??0n\n if(overrides.maxNumberOfResults != null){\n return (await this.baseGetDelegates(\n nodeRpcUrl,\n safeAddress,\n start,\n overrides.maxNumberOfResults\n )).results\n }\n const pageSize = 20n;\n const delegates:string[] = [];\n while(true){\n const getDelegatesResult = await this.baseGetDelegates(\n nodeRpcUrl,\n safeAddress,\n start,\n pageSize\n )\n delegates.push.apply(delegates, getDelegatesResult.results)\n if(getDelegatesResult.next == 0n){\n break;\n }else{\n start = getDelegatesResult.next;\n }\n }\n return delegates;\n }\n\n /**\n * Get delegates \n * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n * @param safeAddress - The target account.\n * @return promise of the account's current recovery request\n */\n public async baseGetDelegates(\n nodeRpcUrl: string,\n safeAddress: string,\n start: bigint,\n pageSize: bigint,\n ):Promise<{results:string[], next:bigint}>{\n //\"getDelegates(address,uint48,uint8)\"\n const functionSelector = \"0xeb37abe0\";\n const callData = createCallData(\n functionSelector,\n [\"address\", \"uint48\", \"uint8\"],\n [safeAddress, start, pageSize],\n );\n\n const ethCallParams ={\n to: this.moduleAddress,\n data: callData,\n };\n\n const delegates = await sendEthCallRequest(\n nodeRpcUrl, ethCallParams, \"latest\");\n this.checkForEmptyResultAndRevert(delegates, \"getDelegates\");\n\t const decodedCalldata = this.abiCoder.decode(\n [\"address[]\", \"uint48\"], delegates);\n\n return {\n results: decodedCalldata[0],\n next: BigInt(decodedCalldata[1]),\n }\n }\n}\n\n/**\n * On-chain allowance state for a delegate/token pair on a Safe account.\n */\nexport type Allowance = {\n /** Total allowance amount per period, in the token's smallest unit. */\n amount: bigint,\n /** Amount already spent in the current period. */\n spent: bigint,\n /** Reset period duration in minutes. 0 means one-time (non-recurring). */\n resetTimeMin: bigint,\n /** Timestamp (in minutes since epoch) of the last allowance reset. */\n lastResetMin: bigint,\n /**\n * Monotonically increasing nonce, incremented on each allowance transfer.\n * Capped at 65534 (uint16 max - 1); once exhausted, a new delegate is required.\n */\n nonce: bigint,\n}\n","import { SafeAccount } from \"./SafeAccount\";\nimport {\n\tInitCodeOverrides,\n\tSigner,\n\tCreateUserOperationV7Overrides,\n SafeUserOperationTypedDataDomain,\n SafeUserOperationV7TypedMessageValue,\n SafeAccountSingleton,\n\tSignerSignaturePair,\n} from \"./types\";\n\nimport { UserOperationV7, MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet } from \"../../types\";\nimport { ENTRYPOINT_V7, Safe_L2_V1_4_1 } from \"src/constants\";\n\n/**\n * Safe smart account implementation for EntryPoint v0.7.\n * Provides methods to create, sign, and send ERC-4337 UserOperations\n * using Safe's modular smart account architecture with the v0.7 EntryPoint.\n *\n * @example\n * // Create a new account (not yet deployed on-chain)\n * const smartAccount = SafeAccountV0_3_0.initializeNewAccount([ownerAddress]);\n *\n * // Or connect to an existing deployed account\n * const smartAccount = new SafeAccountV0_3_0(existingAccountAddress);\n */\nexport class SafeAccountV0_3_0 extends SafeAccount {\n\tstatic readonly DEFAULT_ENTRYPOINT_ADDRESS = ENTRYPOINT_V7;\n\tstatic readonly DEFAULT_SAFE_4337_MODULE_ADDRESS =\n\t\t\"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS =\n\t\t\"0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47\";\n\n\t/**\n\t * Create a SafeAccountV0_3_0 instance for an existing deployed account.\n\t * For new (undeployed) accounts, use the static `initializeNewAccount` method instead.\n\t *\n\t * @param accountAddress - The on-chain address of the Safe account\n\t * @param overrides - Override default module, EntryPoint, and singleton addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string\n safeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n \n super(\n accountAddress, safe4337ModuleAddress, entrypointAddress,\n {\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n safeAccountSingleton: overrides.safeAccountSingleton\n }\n );\n\t}\n\n\t/**\n\t * Calculate the counterfactual account address from the initial owner signers.\n\t * Does not deploy the account.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns The deterministic account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n\t\tconst [accountAddress, ,] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\treturn accountAddress;\n\t}\n\n\t/**\n\t * Create and initialize a new SafeAccountV0_3_0 from its initial owners.\n\t * The account address is deterministically computed but not yet deployed on-chain.\n\t * The first UserOperation sent will deploy it automatically via factory data.\n\t *\n\t * @param owners - Array of owner signers (at least one required)\n\t * @param overrides - Override default initialization values\n\t * @returns A SafeAccountV0_3_0 instance with factory data set for deployment\n\t *\n\t * @example\n\t * const smartAccount = SafeAccountV0_3_0.initializeNewAccount([\"0xOwnerAddress\"]);\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeAccountV0_3_0 {\n\t\tlet isInitWebAuthn = false;\n\t\tlet x = 0n;\n\t\tlet y = 0n;\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tif (isInitWebAuthn) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\"Only one Webauthn signer is allowed during initialization\",\n\t\t\t\t\t);\n\t\t\t\t}\n if(owners.indexOf(owner) != 0){\n throw new RangeError(\n\t\t\t\t\t\t\"Webauthn owner has to be the first owner for an init transaction.\",\n\t\t\t\t\t);\n }\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t\tx = owner.x;\n\t\t\t\ty = owner.y;\n\t\t\t}\n\t\t}\n\t\tconst [accountAddress, factoryAddress, factoryData] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst safe = new SafeAccountV0_3_0(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton,\n\t\t});\n\t\tsafe.factoryAddress = factoryAddress;\n\t\tsafe.factoryData = factoryData;\n\t\tif (isInitWebAuthn) {\n\t\t\tsafe.isInitWebAuthn = true;\n\t\t\tsafe.x = x;\n\t\t\tsafe.y = y;\n\t\t}\n\n\t\treturn safe;\n\t}\n\n\t/**\n\t * Compute the EIP-712 hash of a UserOperation for Safe signature verification.\n\t *\n\t * @param useroperation - UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns The EIP-712 hash as a hex string\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Hash(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n \n /**\n\t * Get the EIP-712 typed data components for a UserOperation.\n\t * Useful for signing with external signers that need domain, types, and message separately.\n\t *\n\t * @param useroperation - UserOperation to get typed data for\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns Object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV7,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV7TypedMessageValue\n } \n {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Build the Safe initializer calldata for the account setup transaction.\n\t * Encodes the owners, threshold, module setup, and optional WebAuthn configuration.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param threshold - Number of required signatures for transaction approval\n\t * @param overrides - Override default module, multisend, and WebAuthn addresses\n\t * @returns The encoded initializer calldata hex string\n\t */\n\tpublic static createInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;\n\n\t\treturn SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\tthreshold,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress,\n\t\t\toverrides.webAuthnSharedSigner,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner,\n\t\t);\n\t}\n\n\t/**\n\t * Create the factory address and encoded factory data for deploying a new Safe account.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns A tuple of [factoryAddress, factoryData]\n\t */\n\tpublic static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n\t\treturn SafeAccount.createFactoryAddressAndData(\n\t\t\towners,\n\t\t\toverrides,\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\tSafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t);\n\t}\n\n\t/**\n\t * Create a complete UserOperation ready for signing.\n\t * Automatically determines the nonce, fetches gas prices, estimates gas limits,\n\t * and encodes the transactions into calldata. All values can be overridden.\n\t *\n\t * @param transactions - Array of MetaTransactions to execute\n\t * @param providerRpc - Ethereum JSON-RPC node URL (for nonce and gas prices)\n\t * @param bundlerRpc - Bundler RPC URL (for gas estimation)\n\t * @param overrides - Override any auto-determined values\n\t * @returns The unsigned UserOperation (UserOperationV7) ready to be signed\n\t *\n\t * @example\n\t * const userOp = await smartAccount.createUserOperation(\n\t * [{ to: recipientAddress, value: 1000000000000000n, data: \"0x\" }],\n\t * nodeRpcUrl,\n\t * bundlerRpcUrl,\n\t * );\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV7Overrides = {},\n\t): Promise<UserOperationV7> {\n\t\tconst [userOperation, factoryAddress, factoryData] =\n\t\t\tawait this.createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\t\t\ttransactions,\n\t\t\t\tfalse,\n\t\t\t\tproviderRpc,\n\t\t\t\tbundlerRpc,\n\t\t\t\toverrides,\n\t\t\t);\n\n\t\tconst userOperationV7: UserOperationV7 = {\n\t\t\t...userOperation,\n\t\t\tfactory: factoryAddress,\n\t\t\tfactoryData,\n\t\t\tpaymaster: null,\n\t\t\tpaymasterVerificationGasLimit: null,\n\t\t\tpaymasterPostOpGasLimit: null,\n\t\t\tpaymasterData: null,\n\t\t};\n\n\t\treturn userOperationV7;\n\t}\n\n\t/**\n\t * Estimate gas limits for a UserOperation using the bundler.\n\t *\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC URL\n\t * @param overrides - State overrides, dummy signatures, and WebAuthn configuration\n\t * @returns A tuple of [preVerificationGas, verificationGasLimit, callGasLimit]\n\t */\n\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV7,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n\t\t\texpectedSigners?: Signer[];\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn this.baseEstimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tbundlerRpc,\n\t\t\toverrides\n\t\t);\n\t}\n\n\t/**\n\t * Sign a UserOperation using one or more private keys via EIP-712 typed data signing.\n\t *\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKeys - Array of private keys for the signers\n\t * @param chainId - The target chain ID\n\t * @param overrides - Override validAfter and validUntil timestamps\n\t * @returns The formatted signature string ready to set on the UserOperation\n\t *\n\t * @example\n\t * const signature = smartAccount.signUserOperation(userOp, [privateKey], 1n);\n\t * userOp.signature = signature;\n\t */\n\tpublic signUserOperation(\n\t\tuseroperation: UserOperationV7,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.baseSignSingleUserOperation(\n\t\t\tuseroperation,\n\t\t\tprivateKeys,\n\t\t\tchainId,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.safe4337ModuleAddress,\n\t\t\toverrides\n\t\t)\n\t}\n}\n\n/**\n * Alias for {@link SafeAccountV0_3_0} representing Safe v1.4.1 singleton with module v0.3.0.\n * Uses the same defaults and behavior as SafeAccountV0_3_0.\n */\nexport class SafeAccountV1_4_1_M_0_3_0 extends SafeAccountV0_3_0 {\n}\n","import { SafeAccount } from \"./SafeAccount\";\nimport {\n\tInitCodeOverrides,\n\tSigner,\n\tCreateUserOperationV6Overrides,\n\tSafeAccountSingleton,\n SafeUserOperationTypedDataDomain,\n SafeUserOperationV6TypedMessageValue,\n\tSignerSignaturePair,\n} from \"./types\";\n\nimport { UserOperationV6, MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet } from \"../../types\";\nimport { ENTRYPOINT_V6 } from \"src/constants\";\nimport { createCallData } from \"src/utils\";\nimport { SafeAccountV0_3_0 } from \"./SafeAccountV0_3_0\";\n\n/**\n * Safe smart account implementation for EntryPoint v0.6.\n * Provides methods to create, sign, and send ERC-4337 UserOperations\n * using Safe's modular smart account architecture.\n *\n * @example\n * // Create a new account (not yet deployed on-chain)\n * const smartAccount = SafeAccountV0_2_0.initializeNewAccount([ownerAddress]);\n *\n * // Or connect to an existing deployed account\n * const smartAccount = new SafeAccountV0_2_0(existingAccountAddress);\n */\nexport class SafeAccountV0_2_0 extends SafeAccount {\n\tstatic readonly DEFAULT_ENTRYPOINT_ADDRESS = ENTRYPOINT_V6;\n\tstatic readonly DEFAULT_SAFE_4337_MODULE_ADDRESS =\n\t\t\"0xa581c4A4DB7175302464fF3C06380BC3270b4037\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS =\n\t\t\"0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb\";\n\n\t/**\n\t * Create a SafeAccountV0_2_0 instance for an existing deployed account.\n\t * For new (undeployed) accounts, use the static `initializeNewAccount` method instead.\n\t *\n\t * @param accountAddress - The on-chain address of the Safe account\n\t * @param overrides - Override default module and EntryPoint addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\n\t\tsuper(\n accountAddress, safe4337ModuleAddress, entrypointAddress,\n {\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier\n }\n );\n\t}\n\n\t/**\n\t * Calculate the counterfactual account address from the initial owner signers.\n\t * Does not deploy the account.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns The deterministic account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: {\n\t\t\tthreshold?: number;\n\t\t\tc2Nonce?: bigint;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tsafeAccountSingleton?: SafeAccountSingleton;\n\t\t\tsafeAccountFactoryAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst [accountAddress, ,] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\treturn accountAddress;\n\t}\n\n\t/**\n\t * Create and initialize a new SafeAccountV0_2_0 from its initial owners.\n\t * The account address is deterministically computed but not yet deployed on-chain.\n\t * The first UserOperation sent will deploy it automatically via initCode.\n\t *\n\t * @param owners - Array of owner signers (at least one required)\n\t * @param overrides - Override default initialization values\n\t * @returns A SafeAccountV0_2_0 instance with factory data set for deployment\n\t *\n\t * @example\n\t * const smartAccount = SafeAccountV0_2_0.initializeNewAccount([\"0xOwnerAddress\"]);\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeAccountV0_2_0 {\n\t\tlet isInitWebAuthn = false;\n\t\tlet x = 0n;\n\t\tlet y = 0n;\n\t\tfor (const owner of owners) {\n\t\t\tif (typeof owner != \"string\") {\n\t\t\t\tif (isInitWebAuthn) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\"Only one Webauthn signer is allowed during initialization\",\n\t\t\t\t\t);\n\t\t\t\t}\n if(owners.indexOf(owner) != 0){\n throw new RangeError(\n\t\t\t\t\t\t\"Webauthn owner has to be the first owner for an init transaction.\",\n\t\t\t\t\t);\n }\n\n\t\t\t\tisInitWebAuthn = true;\n\t\t\t\tx = owner.x;\n\t\t\t\ty = owner.y;\n\t\t\t}\n\t\t}\n\t\tconst [accountAddress, factoryAddress, factoryData] =\n\t\t\tSafeAccountV0_2_0.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst safe = new SafeAccountV0_2_0(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier\n\t\t});\n\t\tsafe.factoryAddress = factoryAddress;\n\t\tsafe.factoryData = factoryData;\n\t\tif (isInitWebAuthn) {\n\t\t\tsafe.isInitWebAuthn = true;\n\t\t\tsafe.x = x;\n\t\t\tsafe.y = y;\n\t\t}\n\n\t\treturn safe;\n\t}\n\n\t/**\n\t * Compute the EIP-712 hash of a UserOperation for Safe signature verification.\n\t *\n\t * @param useroperation - UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns The EIP-712 hash as a hex string\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Hash(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n /**\n\t * Get the EIP-712 typed data components for a UserOperation.\n\t * Useful for signing with external signers that need domain, types, and message separately.\n\t *\n\t * @param useroperation - UserOperation to get typed data for\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override validAfter, validUntil, entrypoint, and module addresses\n\t * @returns Object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuseroperation: UserOperationV6,\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t\tentrypointAddress?: string;\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t} = {},\n\t): {\n domain: SafeUserOperationTypedDataDomain,\n types:Record<string, {name: string;type: string;}[]>,\n messageValue: SafeUserOperationV6TypedMessageValue\n } \n {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Calculate both the counterfactual account address and the initCode from owner signers.\n\t *\n\t * @param owners - Array of owner signers\n\t * @param overrides - Override default initialization values\n\t * @returns A tuple of [accountAddress, initCode]\n\t */\n\tpublic static createAccountAddressAndInitCode(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n\t\tconst [sender, safeAccountFactoryAddress, factoryData] =\n\t\t\tSafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\tconst initCode = safeAccountFactoryAddress + factoryData.slice(2);\n\t\treturn [sender, initCode];\n\t}\n\n\tpublic static createInitializerCallData(\n\t\towners: Signer[],\n\t\tthreshold: number,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tsafeModuleSetupAddress?: string;\n\t\t\tmultisendContractAddress?: string;\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner?: string;\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner?: string;\n\t\t} = {},\n\t): string {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;\n\n\t\treturn SafeAccount.createBaseInitializerCallData(\n\t\t\towners,\n\t\t\tthreshold,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tsafeModuleSetupAddress,\n\t\t\toverrides.multisendContractAddress,\n\t\t\toverrides.webAuthnSharedSigner,\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner,\n\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner,\n\t\t);\n\t}\n\n\t/**\n\t * Create the initCode for deploying a new Safe account via the factory.\n\t *\n\t * @param owners - Array of owner signers\n\t * @param overrides - Override default initialization values\n\t * @returns The initCode string (factory address + encoded calldata)\n\t */\n\tpublic static createInitCode(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n\t\tconst [safeAccountFactoryAddress, factoryData] =\n\t\t\tSafeAccount.createFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ??\n\t\t\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\t\treturn safeAccountFactoryAddress + factoryData.slice(2);\n\t}\n\n\t/**\n\t * Create a complete UserOperation ready for signing.\n\t * Automatically determines the nonce, fetches gas prices, estimates gas limits,\n\t * and encodes the transactions into calldata. All values can be overridden.\n\t *\n\t * @param transactions - Array of MetaTransactions to execute\n\t * @param providerRpc - Ethereum JSON-RPC node URL (for nonce and gas prices)\n\t * @param bundlerRpc - Bundler RPC URL (for gas estimation)\n\t * @param overrides - Override any auto-determined values\n\t * @returns The unsigned UserOperation (UserOperationV6) ready to be signed\n\t *\n\t * @example\n\t * const userOp = await smartAccount.createUserOperation(\n\t * [{ to: recipientAddress, value: 1000000000000000n, data: \"0x\" }],\n\t * nodeRpcUrl,\n\t * bundlerRpcUrl,\n\t * );\n\t */\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV6Overrides = {},\n\t): Promise<UserOperationV6> {\n\t\tconst [userOperation, factoryAddress, factoryData] =\n\t\t\tawait this.createBaseUserOperationAndFactoryAddressAndFactoryData(\n\t\t\t\ttransactions,\n\t\t\t\ttrue,\n\t\t\t\tproviderRpc,\n\t\t\t\tbundlerRpc,\n\t\t\t\toverrides,\n\t\t\t);\n\n\t\tlet initCode = \"0x\";\n\n\t\tif (overrides.initCode == null) {\n\t\t\tif (factoryAddress != null) {\n\t\t\t\tlet factoryDataStr = \"0x\";\n\t\t\t\tif (factoryData != null) {\n\t\t\t\t\tfactoryDataStr = factoryData;\n\t\t\t\t}\n\t\t\t\tinitCode = factoryAddress + factoryDataStr.slice(2);\n\t\t\t}\n\t\t} else {\n\t\t\tinitCode = overrides.initCode;\n\t\t}\n\n\t\tconst userOperationV6: UserOperationV6 = {\n\t\t\t...userOperation,\n\t\t\tinitCode,\n\t\t\tpaymasterAndData: \"0x\",\n\t\t};\n\n\t\treturn userOperationV6;\n\t}\n \n /**\n\t * Create MetaTransactions to migrate this account from EntryPoint v0.6 (module v0.2.0)\n\t * to EntryPoint v0.7 (module v0.3.0).\n\t *\n\t * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n\t * @param overrides - Override module addresses and pagination\n\t * @returns Array of MetaTransactions for the migration\n\t */\n public async createMigrateToSafeAccountV0_3_0MetaTransactions(\n\t\tnodeRpcUrl: string,\n overrides:{\n\t\t\tsafeV06ModuleAddress?: string;\n\t\t\tsafeV07ModuleAddress?: string;\n pageSize?: bigint;\n\t\t\tmodulesStart?: string;\n } = {}\n ):Promise<MetaTransaction[]> {\n\t\tconst moduleV06Address =\n\t\t\toverrides.safeV06ModuleAddress ??\n\t\t\tSafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\tconst moduleV07Address =\n\t\t\toverrides.safeV07ModuleAddress ??\n SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n \n const disableModuleMetaTransaction = \n await this.createDisableModuleMetaTransaction(\n nodeRpcUrl, moduleV06Address, this.accountAddress,\n {\n prevModuleAddress:overrides.safeV06ModuleAddress,\n modulesPageSize: overrides.pageSize,\n modulesStart: overrides.modulesStart\n }\n );\n \n const enableModuleMetaTransaction = \n SafeAccount.createEnableModuleMetaTransaction(\n moduleV07Address, this.accountAddress);\n\n const setFallbackHandlerCallData = createCallData(\n\t\t\t\"0xf08a0323\", //setFallbackHandler(address)\n\t\t\t[\"address\"],\n\t\t\t[moduleV07Address],\n\t\t);\n\t\tconst setFallbackHandlerMetaTransaction: MetaTransaction = {\n\t\t\tto: this.accountAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: setFallbackHandlerCallData,\n\t\t};\n \n return [\n disableModuleMetaTransaction,\n enableModuleMetaTransaction,\n setFallbackHandlerMetaTransaction\n ];\n }\n\n\t/**\n\t * Estimate gas limits for a UserOperation using the bundler.\n\t *\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC URL\n\t * @param overrides - State overrides, dummy signatures, and WebAuthn configuration\n\t * @returns A tuple of [preVerificationGas, verificationGasLimit, callGasLimit]\n\t */\n\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV6,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n expectedSigners?: Signer[];\n webAuthnSharedSigner?: string;\n webAuthnSignerFactory?: string;\n webAuthnSignerSingleton?: string;\n webAuthnSignerProxyCreationCode?: string;\n eip7212WebAuthnPrecompileVerifier?: string;\n eip7212WebAuthnContractVerifier?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn this.baseEstimateUserOperationGas(\n\t\t\tuserOperation,\n\t\t\tbundlerRpc,\n\t\t\toverrides\n\t\t);\n\t}\n\n\t/**\n\t * Sign a UserOperation using one or more private keys via EIP-712 typed data signing.\n\t *\n\t * @param useroperation - The UserOperation to sign\n\t * @param privateKeys - Array of private keys for the signers\n\t * @param chainId - The target chain ID\n\t * @param overrides - Override validAfter and validUntil timestamps\n\t * @returns The formatted signature string ready to set on the UserOperation\n\t *\n\t * @example\n\t * const signature = smartAccount.signUserOperation(userOp, [privateKey], 1n);\n\t * userOp.signature = signature;\n\t */\n\tpublic signUserOperation(\n\t\tuseroperation: UserOperationV6,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\toverrides: {\n\t\t\tvalidAfter?: bigint;\n\t\t\tvalidUntil?: bigint;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.baseSignSingleUserOperation(\n\t\t\tuseroperation,\n\t\t\tprivateKeys,\n\t\t\tchainId,\n\t\t\tthis.entrypointAddress,\n\t\t\tthis.safe4337ModuleAddress,\n\t\t\toverrides\n\t\t)\n\t}\n}\n","import { OnChainIdentifierParamsType, MetaTransaction, UserOperationV7 } from \"src/types\";\nimport { SafeAccount } from \"./SafeAccount\";\nimport { SafeAccountV0_3_0 } from \"./SafeAccountV0_3_0\";\nimport {\n\tSigner,\n\tInitCodeOverrides,\n\tSafeAccountSingleton,\n\tCreateUserOperationV7Overrides,\n\tSignerSignaturePair,\n\tWebAuthnSignatureOverrides,\n\tWebauthnPublicKey,\n} from \"./types\";\nimport { Safe_L2_V1_5_0 } from \"src/constants\";\nimport { StateOverrideSet } from \"src/types\";\n\n/**\n * Safe v1.5.0 smart account implementation with module v0.3.0 for EntryPoint v0.7.\n * Extends {@link SafeAccountV0_3_0} using the Safe L2 v1.5.0 singleton instead of v1.4.1.\n *\n * @example\n * // Create a new account using Safe v1.5.0 singleton\n * const smartAccount = SafeAccountV1_5_0_M_0_3_0.initializeNewAccount([ownerAddress]);\n *\n * // Or connect to an existing deployed account\n * const smartAccount = new SafeAccountV1_5_0_M_0_3_0(existingAccountAddress);\n */\nexport class SafeAccountV1_5_0_M_0_3_0 extends SafeAccountV0_3_0 {\n\tstatic readonly DEFAULT_WEB_AUTHN_PRECOMPILE: string =\n\t\t\"0x0000000000000000000000000000000000000100\"; // EIP-7951\n\tstatic readonly DEFAULT_WEB_AUTHN_DAIMO_VERIFIER: string =\n\t\t\"0xc2b78104907F722DABAc4C69f826a522B2754De4\";\n\n\t/**\n\t * Create a SafeAccountV1_5_0_M_0_3_0 instance for an existing deployed account.\n\t * For new (undeployed) accounts, use the static `initializeNewAccount` method instead.\n\t *\n\t * @param accountAddress - The on-chain address of the Safe account\n\t * @param overrides - Override default module and EntryPoint addresses\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tsafe4337ModuleAddress?: string;\n\t\t\tentrypointAddress?: string;\n onChainIdentifierParams?: OnChainIdentifierParamsType;\n onChainIdentifier?: string;\n\t\t\tsafeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n super(\n accountAddress,\n {\n safe4337ModuleAddress: overrides.safe4337ModuleAddress,\n entrypointAddress: overrides.entrypointAddress,\n onChainIdentifierParams: overrides.onChainIdentifierParams,\n onChainIdentifier: overrides.onChainIdentifier,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0\n }\n );\n\t}\n\n\t/**\n\t * Calculate the deterministic proxy address from the initializer calldata.\n\t * Uses the Safe v1.5.0 singleton init hash by default.\n\t *\n\t * @param initializerCallData - The encoded initializer calldata for the proxy\n\t * @param overrides - Override default nonce, factory address, and singleton init hash\n\t * @returns The deterministic proxy address\n\t */\n\tpublic static createProxyAddress(\n\t\tinitializerCallData: string,\n\t\toverrides: {\n\t\t\tc2Nonce?: bigint;\n\t\t\tsafeFactoryAddress?: string;\n\t\t\tsingletonInitHash?: string;\n\t\t} = {},\n\t): string {\n const modOverrides = { ...overrides,\n singletonInitHash: overrides.singletonInitHash??Safe_L2_V1_5_0.singletonInitHash,\n };\n return SafeAccountV0_3_0.createProxyAddress(\n initializerCallData,\n modOverrides\n );\n }\n\n\t/**\n\t * Create and initialize a new SafeAccountV1_5_0_M_0_3_0 from its initial owners.\n\t * The account address is deterministically computed but not yet deployed on-chain.\n\t * The first UserOperation sent will deploy it automatically via factory data.\n\t *\n\t * @param owners - Array of owner signers (at least one required)\n\t * @param overrides - Override default initialization values\n\t * @returns A SafeAccountV1_5_0_M_0_3_0 instance with factory data set for deployment\n\t *\n\t * @example\n\t * const smartAccount = SafeAccountV1_5_0_M_0_3_0.initializeNewAccount([\"0xOwnerAddress\"]);\n\t */\n\tpublic static initializeNewAccount(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): SafeAccountV1_5_0_M_0_3_0 {\n const modOverrides = { ...overrides,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n return SafeAccountV0_3_0.initializeNewAccount(\n owners,\n modOverrides\n );\n }\n\n\t/**\n\t * Calculate the counterfactual account address from the initial owner signers.\n\t * Does not deploy the account. Uses the Safe v1.5.0 singleton by default.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns The deterministic account address\n\t */\n\tpublic static createAccountAddress(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): string {\n const modOverrides = { ...overrides,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n return SafeAccountV0_3_0.createAccountAddress(\n owners,\n modOverrides\n );\n }\n\n\t/**\n\t * Create the factory address and encoded factory data for deploying a new Safe account.\n\t * Uses the Safe v1.5.0 singleton by default.\n\t *\n\t * @param owners - Array of owner signers (ECDSA addresses or WebAuthn public keys)\n\t * @param overrides - Override default initialization values\n\t * @returns A tuple of [factoryAddress, factoryData]\n\t */\n\tpublic static createFactoryAddressAndData(\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): [string, string] {\n const modOverrides = { ...overrides,\n safeAccountSingleton: overrides.safeAccountSingleton??Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner: overrides.eip7212WebAuthnPrecompileVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner: overrides.eip7212WebAuthnContractVerifierForSharedSigner??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n };\n return SafeAccountV0_3_0.createFactoryAddressAndData(\n owners,\n modOverrides\n );\n }\n\n\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string,\n\t\tbundlerRpc?: string,\n\t\toverrides: CreateUserOperationV7Overrides = {},\n\t): Promise<UserOperationV7> {\n\t\treturn super.createUserOperation(transactions, providerRpc, bundlerRpc, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV7,\n\t\tbundlerRpc: string,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignerSignaturePairs?: SignerSignaturePair[];\n\t\t\texpectedSigners?: Signer[];\n\t\t\twebAuthnSharedSigner?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn super.estimateUserOperationGas(userOperation, bundlerRpc, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static createWebAuthnSignerVerifierAddress(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.createWebAuthnSignerVerifierAddress(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static createDeployWebAuthnVerifierMetaTransaction(\n\t\tx: bigint,\n\t\ty: bigint,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerFactory?: string;\n\t\t} = {},\n\t): MetaTransaction {\n\t\treturn SafeAccount.createDeployWebAuthnVerifierMetaTransaction(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static createDummySignerSignaturePairForExpectedSigners(\n\t\texpectedSigners: Signer[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): SignerSignaturePair[] {\n\t\treturn SafeAccount.createDummySignerSignaturePairForExpectedSigners(expectedSigners, {\n\t\t\t...webAuthnSignatureOverrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: webAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: webAuthnSignatureOverrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n\n\tpublic static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string,\n\t\tsigner: WebauthnPublicKey,\n\t\tmessageHash: string,\n\t\tsignature: string,\n\t\toverrides: {\n\t\t\teip7212WebAuthnPrecompileVerifier?: string;\n\t\t\teip7212WebAuthnContractVerifier?: string;\n\t\t\twebAuthnSignerSingleton?: string;\n\t\t} = {},\n\t): Promise<boolean> {\n\t\treturn SafeAccount.verifyWebAuthnSignatureForMessageHash(nodeRpcUrl, signer, messageHash, signature, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier??SafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,\n\t\t});\n\t}\n}\n","/**\n * Abstract base class for all paymaster implementations.\n * Subclasses provide specific logic for gas sponsorship or ERC-20 token gas payment.\n */\nexport abstract class Paymaster {}\n","import { Paymaster } from \"./Paymaster\";\nimport { calculateUserOperationMaxGasCost, sendJsonRpcRequest } from \"../utils\";\nimport {\n\tSupportedERC20TokensAndMetadata,\n\tSupportedERC20TokensAndMetadataWithExchangeRate,\n\tPmUserOperationV8Result,\n\tPmUserOperationV7Result,\n\tPmUserOperationV6Result,\n\tPaymasterMetadata,\n\tERC20Token,\n\tERC20TokenWithExchangeRate,\n\tSponsorMetadata,\n} from \"../types\";\nimport {\n\tCandidePaymasterContext,\n\tPrependTokenPaymasterApproveAccount,\n\tGasPaymasterUserOperationOverrides,\n\tAnyUserOperation,\n\tSameUserOp, SmartAccountWithEntrypoint,\n} from \"./types\";\nimport { Bundler } from \"src/Bundler\";\nimport { AbstractionKitError, ensureError } from \"src/errors\";\nimport {ENTRYPOINT_V8, ENTRYPOINT_V7, ENTRYPOINT_V6, ENTRYPOINT_V9} from \"src/constants\";\n\n/** Buffer added to verificationGasLimit for paymasterAndData verification overhead */\nconst PAYMASTER_V06_VERIFICATION_OVERHEAD = 40000n;\n/** Max value for uint256 */\nconst UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;\n/** Multiplier for token approve amount to cover paymasterAndData cost variance */\nconst TOKEN_APPROVE_AMOUNT_MULTIPLIER = 2n;\n\n/**\n * ERC-20 tokens that require resetting their allowance to 0 before setting a\n * new approval amount (e.g. USDT on mainnet).\n * Addresses are stored lowercase for case-insensitive comparison.\n *\n * If you encounter a token with this behavior that is not listed here,\n * please open an issue at https://github.com/candidelabs/abstractionkit/issues\n * or use the `resetApproval` override as a workaround.\n */\nconst TOKENS_REQUIRING_ALLOWANCE_RESET: string[] = [\n\t\"0xdac17f958d2ee523a2206206994597c13d831ec7\", // USDT (Ethereum mainnet)\n];\n\n/**\n * Client for the Candide Paymaster service.\n * Supports both gas sponsorship (sponsor paymaster) and ERC-20 token payment for gas (token paymaster).\n * Auto-initializes on first use by fetching supported tokens and metadata from the paymaster RPC.\n *\n * Candide's paymaster endpoint follows the format:\n * - `https://api.candide.dev/api/v3/{chainId}/{apiKey}` (authenticated)\n * - `https://api.candide.dev/public/v3/{chainId}` (public, no key required)\n *\n * @example\n * const paymaster = new CandidePaymaster(\"https://api.candide.dev/public/v3/11155111\");\n * const [sponsoredOp] = await paymaster.createSponsorPaymasterUserOperation(userOp, bundlerRpcUrl);\n */\nexport class CandidePaymaster extends Paymaster {\n\t/** The paymaster JSON-RPC endpoint URL */\n\treadonly rpcUrl: string;\n\t/** Cached token/metadata per EntryPoint address (lowercase keys) */\n\tprivate entrypointData = new Map<\n\t\tstring,\n\t\tSupportedERC20TokensAndMetadata\n\t>();\n\t/** Per-entrypoint initialization promises (lowercase keys) */\n\tprivate initPromises = new Map<string, Promise<void>>();\n\t/** Cached chain ID (hex string), resolved from URL or pm_chainId RPC */\n\tprivate chainId: string | null = null;\n\tprivate chainIdPromise: Promise<string> | null = null;\n\n\t/** @param rpcUrl - The Candide paymaster JSON-RPC endpoint URL */\n\tconstructor(rpcUrl: string) {\n\t\tsuper();\n\t\tthis.rpcUrl = rpcUrl;\n\t\tthis.chainId = CandidePaymaster.extractChainIdFromUrl(rpcUrl);\n\t}\n\n\t/**\n\t * Extract chain ID from a Candide paymaster URL.\n\t * Matches: https://api.candide.dev/(api|public)/v{N}/{chainId}(/{apiKey})?\n\t */\n\tprivate static extractChainIdFromUrl(url: string): string | null {\n\t\tconst match = url.match(\n\t\t\t/api\\.candide\\.dev\\/(?:api|public)\\/v\\d+\\/(\\d+)(?:\\/|$)/,\n\t\t);\n\t\tif (match) {\n\t\t\treturn \"0x\" + BigInt(match[1]).toString(16);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Get the chain ID, resolving it from the URL or via pm_chainId RPC.\n\t * Deduplicates concurrent calls.\n\t */\n\tprivate async getChainId(): Promise<string> {\n\t\tif (this.chainId != null) {\n\t\t\treturn this.chainId;\n\t\t}\n\t\tif (this.chainIdPromise == null) {\n\t\t\tthis.chainIdPromise = this.fetchChainId().then((id) => {\n\t\t\t\tthis.chainId = id;\n\t\t\t\treturn id;\n\t\t\t}).catch((err) => {\n\t\t\t\tthis.chainIdPromise = null;\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t}\n\t\treturn this.chainIdPromise;\n\t}\n\n\tprivate async fetchChainId(): Promise<string> {\n\t\ttry {\n\t\t\tconst result = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_chainId\",\n\t\t\t\t[],\n\t\t\t);\n\t\t\treturn result as string;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_chainId failed\",\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Determine the EntryPoint address from the UserOperation's shape.\n\t * V6 ops have `initCode`, V8 ops have `eip7702Auth`, V7 is the default.\n\t */\n\tprivate resolveEntrypoint(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: AnyUserOperation,\n\t): string {\n\t\tif (smartAccount.entrypointAddress != null && smartAccount.entrypointAddress.trim() !== \"\") {\n\t\t\treturn smartAccount.entrypointAddress;\n\t\t}\n\t\tif (\"initCode\" in userOperation) return ENTRYPOINT_V6;\n\t\telse if (\"eip7702Auth\" in userOperation) return ENTRYPOINT_V8;\n\t\telse return ENTRYPOINT_V7;\n\t}\n\n\t/**\n\t * Get the cached entrypoint data for a given entrypoint address.\n\t */\n\tprivate getEntrypointData(\n\t\tentrypoint: string,\n\t): SupportedERC20TokensAndMetadata | undefined {\n\t\treturn this.entrypointData.get(entrypoint.toLowerCase());\n\t}\n\n\tprivate static mapTokens(\n\t\ttokens: { name: string; symbol: string; address: string; decimals: number | string }[],\n\t): ERC20Token[] {\n\t\treturn tokens.map((t) => ({\n\t\t\tname: t.name,\n\t\t\tsymbol: t.symbol,\n\t\t\taddress: t.address,\n\t\t\tdecimals: Number(t.decimals),\n\t\t}));\n\t}\n\n\tprivate static mapTokensWithExchangeRate(\n\t\ttokens: { name: string; symbol: string; address: string; decimals: number | string; exchangeRate: string | bigint }[],\n\t): ERC20TokenWithExchangeRate[] {\n\t\treturn tokens.map((t) => ({\n\t\t\tname: t.name,\n\t\t\tsymbol: t.symbol,\n\t\t\taddress: t.address,\n\t\t\tdecimals: Number(t.decimals),\n\t\t\texchangeRate: BigInt(t.exchangeRate),\n\t\t}));\n\t}\n\n\t/**\n\t * Convert dummyPaymasterAndData gas fields from hex strings to bigint.\n\t * RPC returns these as hex strings, but our types expect bigint.\n\t */\n\tprivate static normalizePaymasterMetadata(\n\t\tmetadata: PaymasterMetadata,\n\t): PaymasterMetadata {\n\t\tif (typeof metadata.dummyPaymasterAndData !== \"string\") {\n\t\t\treturn {\n\t\t\t\t...metadata,\n\t\t\t\tdummyPaymasterAndData: {\n\t\t\t\t\t...metadata.dummyPaymasterAndData,\n\t\t\t\t\tpaymasterVerificationGasLimit: BigInt(metadata.dummyPaymasterAndData.paymasterVerificationGasLimit),\n\t\t\t\t\tpaymasterPostOpGasLimit: BigInt(metadata.dummyPaymasterAndData.paymasterPostOpGasLimit),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\treturn metadata;\n\t}\n\n\t/**\n\t * Ensure the paymaster data for a specific entrypoint is initialized.\n\t * Deduplicates concurrent calls for the same entrypoint.\n\t * On failure, resets so the next call retries.\n\t */\n\tprivate ensureInitialized(entrypoint: string): Promise<void> {\n\t\tconst key = entrypoint.toLowerCase();\n\t\tlet promise = this.initPromises.get(key);\n\t\tif (promise == null) {\n\t\t\tpromise = this.doInitialize(entrypoint).catch((err) => {\n\t\t\t\tthis.initPromises.delete(key);\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t\tthis.initPromises.set(key, promise);\n\t\t}\n\t\treturn promise;\n\t}\n\n\t/**\n\t * Fetch and cache the paymaster's supported tokens and metadata for a specific entrypoint.\n\t *\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if initialization fails\n\t */\n\tprivate async doInitialize(entrypoint: string): Promise<void> {\n\t\ttry {\n\t\t\tconst data = await this.fetchAndTransformTokenData(entrypoint);\n\t\t\tif (data == null) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t`Invalid data received during initialization for entrypoint ${entrypoint}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.entrypointData.set(entrypoint.toLowerCase(), data);\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"failed initializing the paymaster\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch supported tokens and metadata for a specific entrypoint from the RPC\n\t * and transform the result into a normalized format. Used during initialization.\n\t */\n\tprivate async fetchAndTransformTokenData(\n\t\tentrypoint: string,\n\t): Promise<SupportedERC20TokensAndMetadata | null> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await this.fetchSupportedTokensRpc(entrypoint);\n\n\t\t\tconst result = jsonRpcResult as SupportedERC20TokensAndMetadata;\n\t\t\treturn {\n\t\t\t\ttokens: CandidePaymaster.mapTokens(result.tokens),\n\t\t\t\tpaymasterMetadata: CandidePaymaster.normalizePaymasterMetadata(result.paymasterMetadata),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"fetchAndTransformTokenData failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async fetchSupportedTokensRpc(\n\t\tentrypoint: string,\n\t): Promise<unknown> {\n\t\treturn await sendJsonRpcRequest(\n\t\t\tthis.rpcUrl,\n\t\t\t\"pm_supportedERC20Tokens\",\n\t\t\t[entrypoint],\n\t\t);\n\t}\n\n\t/**\n\t * Get the EntryPoint addresses supported by this paymaster.\n\t *\n\t * @returns Array of supported EntryPoint contract addresses\n\t */\n\tasync getSupportedEntrypoints(): Promise<string[]> {\n\t\ttry {\n\t\t\tconst result = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_supportedEntryPoints\",\n\t\t\t\t[],\n\t\t\t);\n\t\t\treturn result as string[];\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_supportedEntryPoints failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the paymaster contract metadata for a specific EntryPoint.\n\t * Auto-initializes if not yet initialized.\n\t *\n\t * @param entrypoint - Target EntryPoint address\n\t * @returns The paymaster metadata (name, address, icons, dummyPaymasterAndData, etc.)\n\t * @throws RangeError if the entrypoint is not supported\n\t */\n\tasync getPaymasterMetaData(\n\t\tentrypoint: string,\n\t): Promise<PaymasterMetadata | null> {\n\t\tawait this.ensureInitialized(entrypoint);\n\n\t\tconst data = this.getEntrypointData(entrypoint);\n\t\tif (data == null) {\n\t\t\tthrow new RangeError(\"unsupported entrypoint.\");\n\t\t}\n\t\treturn data.paymasterMetadata;\n\t}\n\n\t/**\n\t * Check if the token paymaster supports a given ERC-20 token for gas payment.\n\t *\n\t * @param erc20TokenAddress - The ERC-20 token contract address to check\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns true if the token is supported, false otherwise\n\t */\n\tasync isSupportedERC20Token(\n\t\terc20TokenAddress: string,\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<boolean> {\n\t\tconst gasToken = await this.getSupportedERC20TokenData(\n\t\t\terc20TokenAddress,\n\t\t\tentrypoint,\n\t\t);\n\t\treturn gasToken != null;\n\t}\n\n\t/**\n\t * Get the paymaster's data for a specific ERC-20 token.\n\t *\n\t * @param erc20TokenAddress - The ERC-20 token contract address\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns The token data (name, symbol, address, decimals), or null if not supported\n\t * @throws RangeError if the entrypoint is not supported\n\t */\n\tasync getSupportedERC20TokenData(\n\t\terc20TokenAddress: string,\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<ERC20Token | null> {\n\t\tawait this.ensureInitialized(entrypoint);\n\n\t\tconst data = this.getEntrypointData(entrypoint);\n\t\tif (data == null) {\n\t\t\tthrow new RangeError(\"unsupported entrypoint.\");\n\t\t}\n\n\t\tconst gasToken = data.tokens.find(\n\t\t\t(token) =>\n\t\t\t\ttoken.address.toLowerCase() === erc20TokenAddress.toLowerCase(),\n\t\t);\n\n\t\tif (!gasToken) {\n\t\t\treturn null;\n\t\t}\n\t\treturn {\n\t\t\tname: gasToken.name,\n\t\t\tsymbol: gasToken.symbol,\n\t\t\taddress: gasToken.address,\n\t\t\tdecimals: Number(gasToken.decimals),\n\t\t};\n\t}\n\n\t// ── Private helpers for createPaymasterUserOperation ─────────────\n\n\tprivate setDummyPaymasterFields(\n\t\tuserOp: AnyUserOperation,\n\t\tepData: SupportedERC20TokensAndMetadata,\n\t): void {\n\t\tconst dummyPaymasterAndData = epData.paymasterMetadata.dummyPaymasterAndData;\n\t\tif (\"initCode\" in userOp) {\n\t\t\tuserOp.paymasterAndData = dummyPaymasterAndData as string;\n\t\t} else {\n\t\t\tconst structured = dummyPaymasterAndData as Exclude<\n\t\t\t\ttypeof dummyPaymasterAndData, string\n\t\t\t>;\n\t\t\tuserOp.paymaster = structured.paymaster;\n\t\t\tuserOp.paymasterVerificationGasLimit =\n\t\t\t\tstructured.paymasterVerificationGasLimit;\n\t\t\tuserOp.paymasterPostOpGasLimit =\n\t\t\t\tstructured.paymasterPostOpGasLimit;\n\t\t\tuserOp.paymasterData = structured.paymasterData;\n\t\t}\n\t}\n\n\tprivate async estimateAndApplyGasLimits(\n\t\tuserOp: AnyUserOperation,\n\t\tbundlerRpc: string,\n\t\tentrypoint: string,\n\t\toverrides: GasPaymasterUserOperationOverrides,\n\t): Promise<void> {\n\t\tlet preVerificationGas = userOp.preVerificationGas;\n\t\tlet verificationGasLimit = userOp.verificationGasLimit;\n\t\tlet callGasLimit = userOp.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n\t\t\tif (bundlerRpc == null) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc can't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overridden\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst bundler = new Bundler(bundlerRpc);\n\n\t\t\tuserOp.callGasLimit = 0n;\n\t\t\tuserOp.verificationGasLimit = 0n;\n\t\t\tuserOp.preVerificationGas = 0n;\n\t\t\tconst inputMaxFeePerGas = userOp.maxFeePerGas;\n\t\t\tconst inputMaxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\n\t\t\tuserOp.maxFeePerGas = 0n;\n\t\t\tuserOp.maxPriorityFeePerGas = 0n;\n\n\t\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\t\tuserOp,\n\t\t\t\tentrypoint,\n\t\t\t\toverrides.state_override_set,\n\t\t\t);\n\n\t\t\tif (preVerificationGas < estimation.preVerificationGas) {\n\t\t\t\tpreVerificationGas = estimation.preVerificationGas;\n\t\t\t}\n\t\t\tif (verificationGasLimit < estimation.verificationGasLimit) {\n\t\t\t\tverificationGasLimit = estimation.verificationGasLimit;\n\t\t\t}\n\t\t\tif (callGasLimit < estimation.callGasLimit) {\n\t\t\t\tcallGasLimit = estimation.callGasLimit;\n\t\t\t}\n\n\t\t\tuserOp.maxFeePerGas = inputMaxFeePerGas;\n\t\t\tuserOp.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t}\n\n\t\tif (typeof overrides.preVerificationGas === \"bigint\" && overrides.preVerificationGas < 0n) {\n\t\t\tthrow new RangeError(\"preVerificationGas override can't be negative\");\n\t\t}\n\t\tif (typeof overrides.verificationGasLimit === \"bigint\" && overrides.verificationGasLimit < 0n) {\n\t\t\tthrow new RangeError(\"verificationGasLimit override can't be negative\");\n\t\t}\n\t\tif (typeof overrides.callGasLimit === \"bigint\" && overrides.callGasLimit < 0n) {\n\t\t\tthrow new RangeError(\"callGasLimit override can't be negative\");\n\t\t}\n\n\t\tconst applyMultiplier = (value: bigint, multiplier?: number): bigint =>\n\t\t\tvalue + (value * BigInt(Math.round((multiplier ?? 0) * 100))) / 10000n;\n\n\t\tuserOp.preVerificationGas = overrides.preVerificationGas\n\t\t\t?? applyMultiplier(preVerificationGas, overrides.preVerificationGasPercentageMultiplier ?? 5);\n\t\tuserOp.verificationGasLimit = overrides.verificationGasLimit\n\t\t\t?? applyMultiplier(verificationGasLimit, overrides.verificationGasLimitPercentageMultiplier ?? 10);\n\t\tuserOp.callGasLimit = overrides.callGasLimit\n\t\t\t?? applyMultiplier(callGasLimit, overrides.callGasLimitPercentageMultiplier ?? 10);\n\n\t\tif (entrypoint == ENTRYPOINT_V6){\n\t\t\tuserOp.verificationGasLimit += PAYMASTER_V06_VERIFICATION_OVERHEAD;\n\t\t}\n\t}\n\n\tprivate applyPaymasterResult(\n\t\tuserOp: AnyUserOperation,\n\t\tjsonRpcResult: unknown,\n\t): SponsorMetadata | undefined {\n\t\tconst result = jsonRpcResult as\n\t\t\t| PmUserOperationV8Result\n\t\t\t| PmUserOperationV7Result\n\t\t\t| PmUserOperationV6Result;\n\n\t\t// Set version-specific paymaster fields (gas limits/prices are not overridden)\n\t\tif (\"initCode\" in userOp) {\n\t\t\tconst v6Result = jsonRpcResult as PmUserOperationV6Result;\n\t\t\tuserOp.paymasterAndData = v6Result.paymasterAndData;\n\t\t} else {\n\t\t\tconst v7Result = jsonRpcResult as PmUserOperationV7Result;\n\t\t\tuserOp.paymaster = v7Result.paymaster;\n\t\t\tuserOp.paymasterVerificationGasLimit = BigInt(v7Result.paymasterVerificationGasLimit);\n\t\t\tuserOp.paymasterPostOpGasLimit = BigInt(v7Result.paymasterPostOpGasLimit);\n\t\t\tuserOp.paymasterData = v7Result.paymasterData;\n\t\t}\n\n\t\treturn result.sponsorMetadata ?? undefined;\n\t}\n\n\t// ── Core paymaster method (private) ──────────────────────────────\n\n\tprivate async createPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: T,\n\t\tcontext: CandidePaymasterContext = {},\n\t\toverrides: GasPaymasterUserOperationOverrides = {},\n\t): Promise<[SameUserOp<T>, SponsorMetadata | undefined]> {\n\t\ttry {\n\t\t\tconst entrypoint = overrides.entrypoint ?? this.resolveEntrypoint(smartAccount, userOperation);\n\t\t\tconst chainId = await this.getChainId();\n\t\t\tconst jsonRpcResult = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_getPaymasterData\",\n\t\t\t\t[userOperation, entrypoint, chainId, context],\n\t\t\t);\n\t\t\tconst sponsorMetadata = this.applyPaymasterResult(userOperation, jsonRpcResult);\n\t\t\treturn [userOperation as unknown as SameUserOp<T>, sponsorMetadata];\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_getPaymasterData failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t// ── Public convenience methods ───────────────────────────────────\n\n\t/**\n\t * Create a gas-sponsored UserOperation (no token payment required).\n\t *\n\t * @param smartAccount - The smart account instance\n\t * @param userOperation - The UserOperation to sponsor\n\t * @param bundlerRpc - Bundler RPC URL for gas estimation\n\t * @param sponsorshipPolicyId - Optional sponsorship policy ID\n\t * @param overrides - Override gas limits, multipliers, and optional context\n\t * @returns A tuple of [UserOperation, SponsorMetadata | undefined]\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if sponsorship fails\n\t */\n\tasync createSponsorPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: T,\n\t\tbundlerRpc: string,\n\t\tsponsorshipPolicyId?: string,\n\t\toverrides?: GasPaymasterUserOperationOverrides,\n\t): Promise<[SameUserOp<T>, SponsorMetadata | undefined]> {\n\t\tconst userOp = { ...userOperation } as T;\n\t\tconst context: CandidePaymasterContext = {sponsorshipPolicyId, ...(overrides?.context || {}) };\n\t\tconst entrypoint = overrides?.entrypoint ?? this.resolveEntrypoint(smartAccount, userOp);\n\t\tawait this.ensureInitialized(entrypoint);\n\t\tconst epData = this.getEntrypointData(entrypoint);\n\t\tif (epData == null) {\n\t\t\tthrow new RangeError(\n\t\t\t\t`UserOperation for entrypoint ${entrypoint} is not supported`,\n\t\t\t);\n\t\t}\n\t\tif (context.signingPhase !== \"finalize\"){\n\t\t\tthis.setDummyPaymasterFields(userOp, epData);\n\t\t\tawait this.estimateAndApplyGasLimits(userOp, bundlerRpc, entrypoint, overrides ?? {});\n\t\t}\n\t\tconst _overrides = { ...(overrides || {}),\n\t\t\tentrypoint: entrypoint,\n\t\t};\n\t\treturn await this.createPaymasterUserOperation(\n\t\t\tsmartAccount,\n\t\t\tuserOp,\n\t\t\tcontext,\n\t\t\t_overrides,\n\t\t);\n\t}\n\n\t/**\n\t * Create a UserOperation that pays for gas with an ERC-20 token.\n\t * Automatically prepends a token approval to the calldata and sets paymaster fields.\n\t *\n\t * @param smartAccount - The smart account instance (must implement prependTokenPaymasterApproveToCallData)\n\t * @param userOperation - The UserOperation to modify for token payment\n\t * @param tokenAddress - The ERC-20 token contract address to pay gas with\n\t * @param bundlerRpc - Bundler RPC URL for gas estimation\n\t * @param overrides - Override gas limits, multipliers, and optional context\n\t * @returns The UserOperation with token approval prepended and paymaster fields set\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the token is not supported\n\t */\n\tasync createTokenPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: PrependTokenPaymasterApproveAccount,\n\t\tuserOperation: T,\n\t\ttokenAddress: string,\n\t\tbundlerRpc: string,\n\t\toverrides?: GasPaymasterUserOperationOverrides,\n\t): Promise<SameUserOp<T>> {\n\t\ttry {\n\t\t\tconst userOp = { ...userOperation } as T;\n\t\t\tconst context: CandidePaymasterContext = { token: tokenAddress, ...(overrides?.context || {}) };\n\t\t\tconst entrypoint = overrides?.entrypoint ?? this.resolveEntrypoint(smartAccount, userOp);\n\t\t\tawait this.ensureInitialized(entrypoint);\n\t\t\tif (context.signingPhase !== \"finalize\"){\n\t\t\t\tconst epData = this.getEntrypointData(entrypoint);\n\t\t\t\tif (epData == null) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t`UserOperation for entrypoint ${entrypoint} is not supported`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.setDummyPaymasterFields(userOp, epData);\n\t\t\t\t// Prepend an infinite approval and re-estimate UserOperation gas limits (a later rational allowance will be calculated and replace the infinite one)\n\t\t\t\tconst oldCallData = userOp.callData;\n\t\t\t\tconst requiresAllowanceReset = overrides?.resetApproval\n\t\t\t\t\t?? TOKENS_REQUIRING_ALLOWANCE_RESET.includes(\n\t\t\t\t\t\tcontext.token!.toLowerCase(),\n\t\t\t\t\t);\n\t\t\t\tlet callDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\tuserOp.callData,\n\t\t\t\t\tcontext.token!,\n\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\tUINT256_MAX,\n\t\t\t\t);\n\t\t\t\tif (requiresAllowanceReset) {\n\t\t\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\t\tcallDataWithApprove,\n\t\t\t\t\t\tcontext.token!,\n\t\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\t\t0n,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tuserOp.callData = callDataWithApprove;\n\n\t\t\t\tawait this.estimateAndApplyGasLimits(userOp, bundlerRpc, entrypoint, overrides ?? {});\n\n\t\t\t\tconst maxErc20Cost = await this.calculateUserOperationErc20TokenMaxGasCost(\n\t\t\t\t\tsmartAccount,\n\t\t\t\t\tuserOp,\n\t\t\t\t\tcontext.token!,\n\t\t\t\t);\n\t\t\t\tconst approveAmount = maxErc20Cost * TOKEN_APPROVE_AMOUNT_MULTIPLIER;\n\t\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\toldCallData,\n\t\t\t\t\tcontext.token!,\n\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\tapproveAmount,\n\t\t\t\t);\n\t\t\t\tif (requiresAllowanceReset) {\n\t\t\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\t\t\tcallDataWithApprove,\n\t\t\t\t\t\tcontext.token!,\n\t\t\t\t\t\tepData.paymasterMetadata.address,\n\t\t\t\t\t\t0n,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tuserOp.callData = callDataWithApprove;\n\t\t\t}\n\t\t\tconst _overrides = { ...(overrides || {}),\n\t\t\t\tentrypoint: entrypoint,\n\t\t\t};\n\t\t\tconst [resultUserOp] = await this.createPaymasterUserOperation(\n\t\t\t\tsmartAccount,\n\t\t\t\tuserOp,\n\t\t\t\tcontext,\n\t\t\t\t_overrides,\n\t\t\t);\n\t\t\treturn resultUserOp;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"createTokenPaymasterUserOperation failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Calculate the maximum ERC-20 token cost for a UserOperation's gas.\n\t * Uses the token's exchange rate from the paymaster to convert from wei.\n\t *\n\t * @param smartAccount - The smart account instance\n\t * @param userOperation - The UserOperation to calculate the cost for\n\t * @param erc20TokenAddress - The ERC-20 token contract address\n\t * @param overrides - Optional entrypoint override\n\t * @returns Maximum token cost as a bigint (in token's smallest unit)\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the token is not supported\n\t */\n\tasync calculateUserOperationErc20TokenMaxGasCost(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: AnyUserOperation,\n\t\terc20TokenAddress: string,\n\t\toverrides: { entrypoint?: string | null } = {},\n\t): Promise<bigint> {\n\t\ttry {\n\t\t\tconst entrypoint = overrides.entrypoint ?? this.resolveEntrypoint(smartAccount, userOperation);\n\t\t\tawait this.ensureInitialized(entrypoint);\n\t\t\tconst exchangeRate = await this.fetchTokenPaymasterExchangeRate(\n\t\t\t\terc20TokenAddress,\n\t\t\t\tentrypoint,\n\t\t\t);\n\t\t\tconst cost = calculateUserOperationMaxGasCost(userOperation);\n\t\t\treturn (exchangeRate * cost) / BigInt(10 ** 18);\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"calculateUserOperationErc20TokenMaxGasCost failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch the current exchange rate for an ERC-20 token from the paymaster.\n\t *\n\t * @param erc20TokenAddress - The ERC-20 token contract address\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns The exchange rate as a bigint\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the token is not supported\n\t */\n\tasync fetchTokenPaymasterExchangeRate(\n\t\terc20TokenAddress: string,\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<bigint> {\n\t\ttry {\n\t\t\tawait this.ensureInitialized(entrypoint);\n\n\t\t\tconst jsonRpcResult = await this.fetchSupportedTokensRpc(entrypoint) as SupportedERC20TokensAndMetadataWithExchangeRate;\n\n\t\t\tconst gasToken = jsonRpcResult.tokens.find(\n\t\t\t\t(token) =>\n\t\t\t\t\ttoken.address.toLowerCase() === erc20TokenAddress.toLowerCase(),\n\t\t\t);\n\n\t\t\tif (!gasToken) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\terc20TokenAddress + \" token is not supported by the paymaster.\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tentrypoint,\n\t\t\t\t\t\t\tsupportedTokens: jsonRpcResult.tokens.map((t) => t.address),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn BigInt(gasToken.exchangeRate);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"fetchTokenPaymasterExchangeRate failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch fresh supported ERC-20 tokens with exchange rates and paymaster metadata.\n\t * Unlike the cached version, this always makes an RPC call.\n\t *\n\t * @param entrypoint - Target EntryPoint address (default: ENTRYPOINT_V7)\n\t * @returns Supported tokens with exchange rates and paymaster metadata\n\t * @throws AbstractionKitError with code \"PAYMASTER_ERROR\" if the call fails\n\t */\n\tasync fetchSupportedERC20TokensAndPaymasterMetadata(\n\t\tentrypoint: string = ENTRYPOINT_V7,\n\t): Promise<SupportedERC20TokensAndMetadataWithExchangeRate> {\n\t\ttry {\n\t\t\tawait this.ensureInitialized(entrypoint);\n\n\t\t\tif (this.getEntrypointData(entrypoint) == null) {\n\t\t\t\tthrow new RangeError(\"unsupported entrypoint.\");\n\t\t\t}\n\n\t\t\tconst result = await this.fetchSupportedTokensRpc(entrypoint) as\n\t\t\t\tSupportedERC20TokensAndMetadataWithExchangeRate;\n\t\t\treturn {\n\t\t\t\ttokens: CandidePaymaster.mapTokensWithExchangeRate(result.tokens),\n\t\t\t\tpaymasterMetadata: CandidePaymaster.normalizePaymasterMetadata(result.paymasterMetadata),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"fetchSupportedERC20TokensAndPaymasterMetadata failed\",\n\t\t\t\t{\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n}\n","import { Paymaster } from \"./Paymaster\";\nimport { Bundler } from \"../Bundler\";\nimport { calculateUserOperationMaxGasCost, sendJsonRpcRequest } from \"../utils\";\nimport { AbstractionKitError, ensureError } from \"../errors\";\nimport {\n\tENTRYPOINT_V6,\n\tENTRYPOINT_V7,\n\tENTRYPOINT_V8,\n\tENTRYPOINT_V9,\n} from \"../constants\";\nimport type { StateOverrideSet } from \"../types\";\nimport {\n\tAnyUserOperation,\n\tSameUserOp,\n\tSmartAccountWithEntrypoint,\n\tPrependTokenPaymasterApproveAccount,\n\tGasPaymasterUserOperationOverrides,\n\tErc7677Provider,\n\tErc7677PaymasterConstructorOptions,\n} from \"./types\";\n\n/** Max value for uint256 */\nconst UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;\n/** Multiplier for token approve amount to cover paymasterAndData cost variance */\nconst TOKEN_APPROVE_AMOUNT_MULTIPLIER = 2n;\n/**\n * ERC-20 tokens that require resetting their allowance to 0 before setting a\n * new approval amount (e.g. USDT on mainnet).\n */\nconst TOKENS_REQUIRING_ALLOWANCE_RESET: string[] = [\n\t\"0xdac17f958d2ee523a2206206994597c13d831ec7\", // USDT (Ethereum mainnet)\n];\n/**\n * Time-to-live for cached Candide `pm_supportedERC20Tokens` responses, applied\n * only when the fetch is initiated for an exchange-rate lookup. Stub-data\n * lookups (paymaster address + dummyPaymasterAndData) reuse the cache\n * indefinitely since those fields are effectively static per EP.\n */\nconst CANDIDE_TOKEN_QUOTE_TTL_MS = 45_000;\n\n/**\n * Opaque context object forwarded to the paymaster RPC as the fourth argument\n * of `pm_getPaymasterStubData` / `pm_getPaymasterData`.\n *\n * The shape is provider-specific: Candide uses `{ token }` for token paymaster\n * and `{ sponsorshipPolicyId }` for sponsored operations; other providers\n * (Pimlico, Alchemy, …) have their own conventions. Refer to the\n * paymaster provider's documentation for the exact fields.\n *\n * ## Reserved fields consumed by this class (not forwarded to the RPC)\n *\n * - `exchangeRate` - token-to-ETH exchange rate as a bigint or hex/decimal\n * string, scaled by 10^18 (i.e. the value of 1 ETH expressed in the token's\n * smallest unit). Used to calculate the ERC-20 approval amount when no\n * provider is auto-detected. Not needed when `provider` is `\"pimlico\"` or\n * `\"candide\"`; the class fetches the rate from the provider's RPC.\n */\nexport type Erc7677Context = Record<string, unknown>;\n\n/**\n * Paymaster gas/data fields returned by `pm_getPaymasterStubData` and\n * `pm_getPaymasterData` for EntryPoint v0.7+ UserOperations.\n */\nexport interface Erc7677PaymasterFields {\n\tpaymaster?: string;\n\tpaymasterData?: string;\n\tpaymasterVerificationGasLimit?: bigint | string;\n\tpaymasterPostOpGasLimit?: bigint | string;\n\t/** Present on v0.6 responses; mutually exclusive with the split fields above. */\n\tpaymasterAndData?: string;\n}\n\n/**\n * Response from `pm_getPaymasterStubData`. Includes `isFinal` when the paymaster\n * signs immediately and does not require a follow-up `pm_getPaymasterData` call.\n */\nexport interface Erc7677StubDataResult extends Erc7677PaymasterFields {\n\t/** When true, skip pm_getPaymasterData and use these fields as the final signature. */\n\tisFinal?: boolean;\n\t[key: string]: unknown;\n}\n\n/**\n * Generic ERC-7677 paymaster client.\n *\n * Speaks the [ERC-7677](https://eips.ethereum.org/EIPS/eip-7677) JSON-RPC\n * protocol: `pm_getPaymasterStubData` for gas-estimation stubs and\n * `pm_getPaymasterData` for the final signed paymaster fields. Works with any\n * paymaster provider that implements the standard (Candide, Pimlico, Alchemy, …).\n *\n * For Candide-hosted paymasters, {@link CandidePaymaster} is the dedicated\n * client and offers extra features (parallel signing phases, etc.). This\n * generic class is provided so consumers retain the freedom to switch\n * providers without changing the SDK.\n *\n * ## Flow\n *\n * {@link Erc7677Paymaster.createPaymasterUserOperation} runs the full pipeline:\n *\n * 1. `pm_getPaymasterStubData(userOp, entrypoint, chainId, context)` — stub\n * paymaster fields for gas estimation.\n * 2. Apply stub fields to the UserOperation.\n * 3. `eth_estimateUserOperationGas` via the bundler, reading back the bundler's\n * paymaster gas limits (v0.7+).\n * 4. Apply gas limits to the UserOperation.\n * 5. If the stub response includes `isFinal: true`, skip to step 7.\n * 6. `pm_getPaymasterData(userOp, entrypoint, chainId, context)` — final\n * paymaster signature.\n * 7. Return the UserOperation with paymaster fields populated, ready to sign.\n *\n * Owner signing is intentionally out of scope — call the smart account's\n * `signUserOperation` (or your external signer) after this method returns.\n *\n * ## Token paymaster flows\n *\n * When `context.token` is set and the smart account implements\n * `prependTokenPaymasterApproveToCallData`, the class automatically runs the\n * token paymaster pipeline:\n *\n * - **Provider detected** (Candide, Pimlico): fetches exchange rate and\n * paymaster address via provider-specific RPC, then handles approval\n * prepending, gas estimation, and final paymaster data automatically.\n * - **No provider, `context.exchangeRate` set**: uses the provided rate;\n * paymaster address comes from `pm_getPaymasterStubData`.\n * - **No provider, no `exchangeRate`**: falls through to the regular\n * sponsored flow — the developer is responsible for prepending the\n * approval and calculating the amount.\n *\n * @example Sponsored UserOperation (Candide)\n * ```ts\n * const paymaster = new Erc7677Paymaster(candideUrl);\n * const sponsoredOp = await paymaster.createPaymasterUserOperation(\n * smartAccount,\n * userOp,\n * bundlerRpc,\n * { sponsorshipPolicyId: \"sp_melted_jackpot\" },\n * );\n * sponsoredOp.signature = smartAccount.signUserOperation(sponsoredOp, [pk], chainId);\n * await new Bundler(bundlerRpc).sendUserOperation(sponsoredOp, smartAccount.entrypointAddress);\n * ```\n *\n * @example Token paymaster (Candide — automatic, provider auto-detected)\n * ```ts\n * const paymaster = new Erc7677Paymaster(candideUrl);\n * const tokenOp = await paymaster.createPaymasterUserOperation(\n * smartAccount,\n * userOp,\n * bundlerRpc,\n * { token: usdtAddress },\n * );\n * ```\n *\n * @example Token paymaster (unknown provider, exchangeRate supplied)\n * ```ts\n * const paymaster = new Erc7677Paymaster(customUrl);\n * const tokenOp = await paymaster.createPaymasterUserOperation(\n * smartAccount,\n * userOp,\n * bundlerRpc,\n * { token: usdtAddress, exchangeRate: \"1000000000000000000\" },\n * );\n * ```\n */\n/**\n * Raw shape of Candide's `pm_supportedERC20Tokens` response.\n * `dummyPaymasterAndData` is a concatenated hex string for EntryPoint v0.6 and\n * a structured object for v0.7+.\n */\ninterface CandideSupportedResponse {\n\ttokens: Array<{ address: string; exchangeRate: string }>;\n\tpaymasterMetadata: {\n\t\taddress: string;\n\t\tdummyPaymasterAndData:\n\t\t\t| string\n\t\t\t| {\n\t\t\t\tpaymaster: string;\n\t\t\t\tpaymasterVerificationGasLimit: string;\n\t\t\t\tpaymasterPostOpGasLimit: string;\n\t\t\t\tpaymasterData: string;\n\t\t\t};\n\t};\n}\n\nexport class Erc7677Paymaster extends Paymaster {\n\t/** The paymaster JSON-RPC endpoint URL */\n\treadonly rpcUrl: string;\n\t/** Cached chain ID (hex string). Passed via constructor or resolved from the bundler at first use. */\n\tprivate chainId: string | null;\n\t/** Detected or explicitly set paymaster provider. `null` means no provider-specific features. */\n\treadonly provider: Erc7677Provider;\n\t/**\n\t * Cached Candide `pm_supportedERC20Tokens` response, keyed by lowercase\n\t * entrypoint. Used for both token quotes and stub data to avoid a second\n\t * round-trip (`pm_getPaymasterStubData`) for Candide-hosted paymasters.\n\t *\n\t * The cache is indefinite for stub-data lookups but has a TTL for\n\t * exchange-rate lookups — see {@link CANDIDE_TOKEN_QUOTE_TTL_MS}.\n\t */\n\tprivate candideCache = new Map<string, { data: CandideSupportedResponse; fetchedAt: number }>();\n\n\t/**\n\t * Detect the paymaster provider from the RPC URL hostname.\n\t * Returns `null` for unknown hosts or malformed URLs.\n\t *\n\t * Hostname-based (not substring) so that proxies or paths containing a\n\t * provider name (e.g. `https://my-proxy.com/pimlico-compat/...`) are not\n\t * misidentified.\n\t */\n\tstatic detectProvider(rpcUrl: string): Erc7677Provider {\n\t\tlet host: string;\n\t\ttry {\n\t\t\thost = new URL(rpcUrl).hostname.toLowerCase();\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t\tif (host === \"pimlico.io\" || host.endsWith(\".pimlico.io\")) return \"pimlico\";\n\t\tif (host === \"candide.dev\" || host.endsWith(\".candide.dev\")) return \"candide\";\n\t\treturn null;\n\t}\n\n\t/**\n\t * @param rpcUrl - Paymaster JSON-RPC endpoint. Can be the same URL as the\n\t * bundler when the provider bundles both (Candide, Pimlico, Alchemy);\n\t * can also be a separate paymaster-only endpoint.\n\t * @param options\n\t * @param options.chainId - Optional chain id as a bigint (e.g. `1n` for\n\t * mainnet). When provided, avoids a lookup at first use. Otherwise,\n\t * resolved from the bundler via `eth_chainId` on the first call.\n\t * @param options.provider - Paymaster provider. `\"auto\"` (default) detects\n\t * from the RPC URL. Set explicitly to override, or `null` to disable.\n\t */\n\tconstructor(rpcUrl: string, options: Erc7677PaymasterConstructorOptions = {}) {\n\t\tsuper();\n\t\tthis.rpcUrl = rpcUrl;\n\t\tthis.chainId = options.chainId != null ? \"0x\" + options.chainId.toString(16) : null;\n\t\tif (options.provider === undefined || options.provider === \"auto\") {\n\t\t\tthis.provider = Erc7677Paymaster.detectProvider(rpcUrl);\n\t\t} else {\n\t\t\tthis.provider = options.provider;\n\t\t}\n\t}\n\n\t/**\n\t * Resolve the chain id, querying the bundler if not provided at construction.\n\t */\n\tprivate async getChainId(bundlerRpc: string): Promise<string> {\n\t\tif (this.chainId != null) return this.chainId;\n\t\tconst id = await new Bundler(bundlerRpc).chainId();\n\t\tthis.chainId = id;\n\t\treturn id;\n\t}\n\n\t/**\n\t * Determine the EntryPoint address from the UserOperation shape.\n\t * V6 ops have `initCode`, V8+ ops have `eip7702Auth`, V7 is the default.\n\t */\n\tprivate resolveEntrypoint(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: AnyUserOperation,\n\t): string {\n\t\tif (\n\t\t\tsmartAccount.entrypointAddress != null &&\n\t\t\tsmartAccount.entrypointAddress.trim() !== \"\"\n\t\t) {\n\t\t\treturn smartAccount.entrypointAddress;\n\t\t}\n\t\tif (\"initCode\" in userOperation) return ENTRYPOINT_V6;\n\t\tif (\"eip7702Auth\" in userOperation) return ENTRYPOINT_V8;\n\t\treturn ENTRYPOINT_V7;\n\t}\n\n\t/**\n\t * Low-level ERC-7677 `pm_getPaymasterStubData` call.\n\t * Returns dummy paymaster fields intended for gas estimation.\n\t *\n\t * Most consumers should prefer {@link createPaymasterUserOperation}, which\n\t * runs the full stub → estimate → final pipeline. Use this directly if you\n\t * need to drive the flow manually.\n\t */\n\tasync getPaymasterStubData(\n\t\tuserOperation: AnyUserOperation,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t\tcontext: Erc7677Context = {},\n\t): Promise<Erc7677StubDataResult> {\n\t\ttry {\n\t\t\tconst result = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_getPaymasterStubData\",\n\t\t\t\t[userOperation, entrypoint, chainIdHex, context],\n\t\t\t);\n\t\t\treturn result as Erc7677StubDataResult;\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_getPaymasterStubData failed\",\n\t\t\t\t{ cause: ensureError(err) },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Low-level ERC-7677 `pm_getPaymasterData` call.\n\t * Returns the final signed paymaster fields.\n\t */\n\tasync getPaymasterData(\n\t\tuserOperation: AnyUserOperation,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t\tcontext: Erc7677Context = {},\n\t): Promise<Erc7677PaymasterFields> {\n\t\ttry {\n\t\t\tconst result = await sendJsonRpcRequest(\n\t\t\t\tthis.rpcUrl,\n\t\t\t\t\"pm_getPaymasterData\",\n\t\t\t\t[userOperation, entrypoint, chainIdHex, context],\n\t\t\t);\n\t\t\treturn result as Erc7677PaymasterFields;\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"pm_getPaymasterData failed\",\n\t\t\t\t{ cause: ensureError(err) },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Send an arbitrary JSON-RPC request through the paymaster endpoint.\n\t * Useful for provider-specific methods that fall outside the ERC-7677 spec.\n\t *\n\t * @param method - The JSON-RPC method name\n\t * @param params - The JSON-RPC params array\n\t * @returns The `result` field from the JSON-RPC response\n\t */\n\tasync sendRPCRequest(\n\t\tmethod: string,\n\t\tparams: unknown[] = [],\n\t): Promise<unknown> {\n\t\ttry {\n\t\t\treturn await sendJsonRpcRequest(this.rpcUrl, method, params);\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t`sendRPCRequest(${method}) failed`,\n\t\t\t\t{ cause: ensureError(err) },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Runs the full ERC-7677 pipeline and returns a UserOperation with paymaster\n\t * fields populated. The caller is responsible for signing and sending.\n\t *\n\t * @param smartAccount - Provides the target EntryPoint; not mutated.\n\t * @param userOperation - Starting UserOperation. Not mutated — a shallow copy is returned.\n\t * @param bundlerRpc - Bundler URL used for gas estimation and, if\n\t * `options.chainId` was not provided to the constructor, chain-id lookup.\n\t * @param context - Provider-specific paymaster context\n\t * (e.g. `{ sponsorshipPolicyId }` or `{ token }`).\n\t * @param overrides - Gas estimation overrides and state-override set.\n\t *\n\t * @returns The UserOperation with paymaster + gas fields populated.\n\t */\n\tasync createPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: T,\n\t\tbundlerRpc: string,\n\t\tcontext: Erc7677Context = {},\n\t\toverrides: GasPaymasterUserOperationOverrides = {},\n\t): Promise<SameUserOp<T>> {\n\t\ttry {\n\t\t\tconst userOp = { ...userOperation } as T;\n\t\t\tconst entrypoint =\n\t\t\t\toverrides.entrypoint ?? this.resolveEntrypoint(smartAccount, userOp);\n\t\t\tconst chainIdHex = await this.getChainId(bundlerRpc);\n\n\t\t\t// Token paymaster flow: triggered when context.token is set\n\t\t\tif (\n\t\t\t\tcontext.token != null &&\n\t\t\t\ttypeof context.token === \"string\"\n\t\t\t) {\n\t\t\t\treturn this.tokenPaymasterFlow(\n\t\t\t\t\tsmartAccount as unknown as PrependTokenPaymasterApproveAccount,\n\t\t\t\t\tuserOp,\n\t\t\t\t\tcontext.token as string,\n\t\t\t\t\tbundlerRpc,\n\t\t\t\t\tentrypoint,\n\t\t\t\t\tchainIdHex,\n\t\t\t\t\tcontext,\n\t\t\t\t\toverrides,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Delegate to the sponsored flow (stub → estimate → final).\n\t\t\treturn this.sponsoredFlow(\n\t\t\t\tuserOp,\n\t\t\t\tbundlerRpc,\n\t\t\t\tentrypoint,\n\t\t\t\tchainIdHex,\n\t\t\t\tcontext,\n\t\t\t\toverrides,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\t\t\tif (error instanceof AbstractionKitError) throw error;\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"createPaymasterUserOperation failed\",\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Merge paymaster fields into a UserOperation. Handles both v0.6\n\t * (`paymasterAndData`) and v0.7+ split fields.\n\t */\n\tprivate applyPaymasterFields(\n\t\tuserOp: AnyUserOperation,\n\t\tfields: Erc7677PaymasterFields,\n\t): void {\n\t\tif (\"initCode\" in userOp) {\n\t\t\tif (fields.paymasterAndData != null) {\n\t\t\t\tuserOp.paymasterAndData = fields.paymasterAndData;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (fields.paymaster != null) userOp.paymaster = fields.paymaster;\n\t\tif (fields.paymasterData != null) userOp.paymasterData = fields.paymasterData;\n\t\tif (fields.paymasterVerificationGasLimit != null) {\n\t\t\tuserOp.paymasterVerificationGasLimit = BigInt(\n\t\t\t\tfields.paymasterVerificationGasLimit,\n\t\t\t);\n\t\t}\n\t\tif (fields.paymasterPostOpGasLimit != null) {\n\t\t\tuserOp.paymasterPostOpGasLimit = BigInt(fields.paymasterPostOpGasLimit);\n\t\t}\n\t}\n\n\t/**\n\t * Estimate gas limits via the bundler and apply them (with multipliers).\n\t * Reads paymaster gas fields back from the bundler when present — some\n\t * providers' `pm_getPaymasterStubData` returns `paymasterPostOpGasLimit: 0x1`\n\t * as a placeholder, relying on the bundler's estimate for the real value.\n\t *\n\t * Mirrors CandidePaymaster.estimateAndApplyGasLimits default multipliers\n\t * (5%/10%/10% on preVerification/verification/call) for consistent UX.\n\t */\n\tprivate async estimateAndApplyGasLimits(\n\t\tuserOp: AnyUserOperation,\n\t\tbundlerRpc: string,\n\t\tentrypoint: string,\n\t\toverrides: GasPaymasterUserOperationOverrides,\n\t): Promise<void> {\n\t\tlet preVerificationGas = userOp.preVerificationGas;\n\t\tlet verificationGasLimit = userOp.verificationGasLimit;\n\t\tlet callGasLimit = userOp.callGasLimit;\n\n\t\tif (\n\t\t\toverrides.preVerificationGas == null ||\n\t\t\toverrides.verificationGasLimit == null ||\n\t\t\toverrides.callGasLimit == null\n\t\t) {\n\t\t\tif (bundlerRpc == null) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"bundlerRpc can't be null if preVerificationGas, verificationGasLimit and callGasLimit are not overridden\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst bundler = new Bundler(bundlerRpc);\n\t\t\tuserOp.callGasLimit = 0n;\n\t\t\tuserOp.verificationGasLimit = 0n;\n\t\t\tuserOp.preVerificationGas = 0n;\n\t\t\t// Some bundlers reject estimation when fees are set and the sender\n\t\t\t// has insufficient balance to pay them. Zero them during the\n\t\t\t// estimate and restore after — same pattern as CandidePaymaster.\n\t\t\t//\n\t\t\t// Pimlico is an exception: estimating with maxFeePerGas = 0 makes\n\t\t\t// its paymaster postOp divide by the fee and revert with\n\t\t\t// \"AA50 postOp reverted: divide by zero\". Skip the zeroing for\n\t\t\t// Pimlico and pass the user-supplied fees through unchanged.\n\t\t\tconst skipFeeZeroing = this.provider === \"pimlico\";\n\t\t\tconst inputMaxFeePerGas = userOp.maxFeePerGas;\n\t\t\tconst inputMaxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\n\t\t\tif (!skipFeeZeroing) {\n\t\t\t\tuserOp.maxFeePerGas = 0n;\n\t\t\t\tuserOp.maxPriorityFeePerGas = 0n;\n\t\t\t}\n\n\t\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\t\tuserOp,\n\t\t\t\tentrypoint,\n\t\t\t\toverrides.state_override_set as StateOverrideSet | undefined,\n\t\t\t);\n\n\t\t\tif (!skipFeeZeroing) {\n\t\t\t\tuserOp.maxFeePerGas = inputMaxFeePerGas;\n\t\t\t\tuserOp.maxPriorityFeePerGas = inputMaxPriorityFeePerGas;\n\t\t\t}\n\n\t\t\tif (estimation.preVerificationGas > preVerificationGas) {\n\t\t\t\tpreVerificationGas = estimation.preVerificationGas;\n\t\t\t}\n\t\t\tif (estimation.verificationGasLimit > verificationGasLimit) {\n\t\t\t\tverificationGasLimit = estimation.verificationGasLimit;\n\t\t\t}\n\t\t\tif (estimation.callGasLimit > callGasLimit) {\n\t\t\t\tcallGasLimit = estimation.callGasLimit;\n\t\t\t}\n\n\t\t\t// Overwrite paymaster gas fields with bundler-reported values when\n\t\t\t// available. Stub responses often leave these as placeholders.\n\t\t\tif (\n\t\t\t\t\"paymaster\" in userOp &&\n\t\t\t\testimation.paymasterVerificationGasLimit != null\n\t\t\t) {\n\t\t\t\tuserOp.paymasterVerificationGasLimit =\n\t\t\t\t\testimation.paymasterVerificationGasLimit;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t\"paymaster\" in userOp &&\n\t\t\t\testimation.paymasterPostOpGasLimit != null\n\t\t\t) {\n\t\t\t\tuserOp.paymasterPostOpGasLimit = estimation.paymasterPostOpGasLimit;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\ttypeof overrides.preVerificationGas === \"bigint\" &&\n\t\t\toverrides.preVerificationGas < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"preVerificationGas override can't be negative\");\n\t\t}\n\t\tif (\n\t\t\ttypeof overrides.verificationGasLimit === \"bigint\" &&\n\t\t\toverrides.verificationGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"verificationGasLimit override can't be negative\");\n\t\t}\n\t\tif (\n\t\t\ttypeof overrides.callGasLimit === \"bigint\" &&\n\t\t\toverrides.callGasLimit < 0n\n\t\t) {\n\t\t\tthrow new RangeError(\"callGasLimit override can't be negative\");\n\t\t}\n\n\t\tconst applyMultiplier = (value: bigint, multiplier?: number): bigint =>\n\t\t\tvalue +\n\t\t\t(value * BigInt(Math.round((multiplier ?? 0) * 100))) / 10000n;\n\n\t\tuserOp.preVerificationGas =\n\t\t\toverrides.preVerificationGas ??\n\t\t\tapplyMultiplier(\n\t\t\t\tpreVerificationGas,\n\t\t\t\toverrides.preVerificationGasPercentageMultiplier ?? 5,\n\t\t\t);\n\t\tuserOp.verificationGasLimit =\n\t\t\toverrides.verificationGasLimit ??\n\t\t\tapplyMultiplier(\n\t\t\t\tverificationGasLimit,\n\t\t\t\toverrides.verificationGasLimitPercentageMultiplier ?? 10,\n\t\t\t);\n\t\tuserOp.callGasLimit =\n\t\t\toverrides.callGasLimit ??\n\t\t\tapplyMultiplier(\n\t\t\t\tcallGasLimit,\n\t\t\t\toverrides.callGasLimitPercentageMultiplier ?? 10,\n\t\t\t);\n\n\t\tif (entrypoint.toLowerCase() === ENTRYPOINT_V6.toLowerCase()) {\n\t\t\t// Align with CandidePaymaster: add paymaster verification overhead for v0.6.\n\t\t\t// Lowercase compare — overrides.entrypoint is arbitrary user input\n\t\t\t// and ENTRYPOINT_V6 is checksummed.\n\t\t\tuserOp.verificationGasLimit += 40_000n;\n\t\t}\n\t\t// entrypoint v9 has no special handling here; kept for future use.\n\t\tvoid ENTRYPOINT_V9;\n\t}\n\n\t// ── Provider-specific exchange-rate helpers ──────────────────────────\n\n\t/**\n\t * Fetch token exchange rate and paymaster address via Pimlico's\n\t * `pimlico_getTokenQuotes` RPC.\n\t *\n\t * @returns `exchangeRate` as a bigint scaled by 10^18 (the value of 1 ETH\n\t * expressed in the token's smallest unit). Used to compute the token\n\t * approval amount via `(exchangeRate * gasCostWei) / 10^18`.\n\t */\n\tprivate async fetchPimlicoTokenQuote(\n\t\ttokenAddress: string,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t): Promise<{ exchangeRate: bigint; paymasterAddress: string }> {\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tthis.rpcUrl,\n\t\t\t\"pimlico_getTokenQuotes\",\n\t\t\t[{ tokens: [tokenAddress] }, entrypoint, chainIdHex],\n\t\t) as { quotes?: Array<{ paymaster: string; token: string; exchangeRate: string }> };\n\n\t\tconst quotes = result?.quotes;\n\t\tif (!Array.isArray(quotes) || quotes.length === 0) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t`pimlico_getTokenQuotes returned no quotes for token ${tokenAddress}`,\n\t\t\t);\n\t\t}\n\t\tconst quote = quotes.find(\n\t\t\t(q) => q.token.toLowerCase() === tokenAddress.toLowerCase(),\n\t\t);\n\t\tif (quote == null) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t`pimlico_getTokenQuotes did not include token ${tokenAddress}`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\texchangeRate: BigInt(quote.exchangeRate),\n\t\t\tpaymasterAddress: quote.paymaster,\n\t\t};\n\t}\n\n\t/**\n\t * Fetch (and cache) Candide's `pm_supportedERC20Tokens` response for the\n\t * given entrypoint. The response carries both exchange rates and the\n\t * `dummyPaymasterAndData` used for gas estimation, so one round-trip\n\t * suffices for the entire paymaster flow.\n\t *\n\t * @param options.enforceTTL - When true, re-fetches if the cached entry is\n\t * older than {@link CANDIDE_TOKEN_QUOTE_TTL_MS}. Set by exchange-rate\n\t * lookups (where staleness matters). Stub-data lookups leave this false\n\t * and reuse the cache indefinitely — the paymaster address and\n\t * `dummyPaymasterAndData` are effectively static per paymaster version.\n\t */\n\tprivate async fetchCandideSupportedTokens(\n\t\tentrypoint: string,\n\t\toptions: { enforceTTL?: boolean } = {},\n\t): Promise<CandideSupportedResponse> {\n\t\tconst key = entrypoint.toLowerCase();\n\t\tconst cached = this.candideCache.get(key);\n\t\tconst isStale = cached != null\n\t\t\t&& options.enforceTTL === true\n\t\t\t&& Date.now() - cached.fetchedAt > CANDIDE_TOKEN_QUOTE_TTL_MS;\n\t\tif (cached != null && !isStale) return cached.data;\n\t\tconst result = await sendJsonRpcRequest(\n\t\t\tthis.rpcUrl,\n\t\t\t\"pm_supportedERC20Tokens\",\n\t\t\t[entrypoint],\n\t\t) as unknown as CandideSupportedResponse;\n\t\tthis.candideCache.set(key, { data: result, fetchedAt: Date.now() });\n\t\treturn result;\n\t}\n\n\t/**\n\t * Fetch token exchange rate and paymaster address via Candide's\n\t * `pm_supportedERC20Tokens` RPC.\n\t *\n\t * @returns `exchangeRate` as a bigint scaled by 10^18 (the value of 1 ETH\n\t * expressed in the token's smallest unit). Used to compute the token\n\t * approval amount via `(exchangeRate * gasCostWei) / 10^18`.\n\t */\n\tprivate async fetchCandideTokenQuote(\n\t\ttokenAddress: string,\n\t\tentrypoint: string,\n\t): Promise<{ exchangeRate: bigint; paymasterAddress: string }> {\n\t\tconst result = await this.fetchCandideSupportedTokens(entrypoint, { enforceTTL: true });\n\n\t\tconst token = result.tokens?.find(\n\t\t\t(t) => t.address.toLowerCase() === tokenAddress.toLowerCase(),\n\t\t);\n\t\tif (token == null) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t`${tokenAddress} token is not supported by the Candide paymaster`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\texchangeRate: BigInt(token.exchangeRate),\n\t\t\tpaymasterAddress: result.paymasterMetadata.address,\n\t\t};\n\t}\n\n\t/**\n\t * Convert Candide's `dummyPaymasterAndData` metadata into a stub result\n\t * compatible with {@link applyPaymasterFields}. Handles both v0.6\n\t * (concatenated hex string) and v0.7+ (structured) shapes.\n\t */\n\tprivate candideStubFromMetadata(\n\t\tmetadata: CandideSupportedResponse[\"paymasterMetadata\"],\n\t): Erc7677StubDataResult {\n\t\tconst dummy = metadata.dummyPaymasterAndData;\n\t\tif (typeof dummy === \"string\") {\n\t\t\treturn { paymasterAndData: dummy };\n\t\t}\n\t\treturn {\n\t\t\tpaymaster: dummy.paymaster,\n\t\t\tpaymasterData: dummy.paymasterData,\n\t\t\tpaymasterVerificationGasLimit: dummy.paymasterVerificationGasLimit,\n\t\t\tpaymasterPostOpGasLimit: dummy.paymasterPostOpGasLimit,\n\t\t};\n\t}\n\n\t/**\n\t * Get stub paymaster data. For Candide-hosted paymasters this derives the\n\t * stub from the cached `pm_supportedERC20Tokens` response (no extra\n\t * round-trip). For other providers, falls back to `pm_getPaymasterStubData`.\n\t */\n\tprivate async getStubData(\n\t\tuserOperation: AnyUserOperation,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t\tcontext: Erc7677Context,\n\t): Promise<Erc7677StubDataResult> {\n\t\tif (this.provider === \"candide\") {\n\t\t\tconst response = await this.fetchCandideSupportedTokens(entrypoint);\n\t\t\treturn this.candideStubFromMetadata(response.paymasterMetadata);\n\t\t}\n\t\treturn this.getPaymasterStubData(userOperation, entrypoint, chainIdHex, context);\n\t}\n\n\t/**\n\t * Route to the correct provider-specific token quote fetcher.\n\t * Returns `null` when no provider is configured.\n\t */\n\tprivate async fetchProviderTokenQuote(\n\t\ttokenAddress: string,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t): Promise<{ exchangeRate: bigint; paymasterAddress: string } | null> {\n\t\tswitch (this.provider) {\n\t\t\tcase \"pimlico\":\n\t\t\t\treturn this.fetchPimlicoTokenQuote(tokenAddress, entrypoint, chainIdHex);\n\t\t\tcase \"candide\":\n\t\t\t\treturn this.fetchCandideTokenQuote(tokenAddress, entrypoint);\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\t// ── Token paymaster flow ────────────────────────────────────────────\n\n\t/**\n\t * Internal token paymaster pipeline. Called from `createPaymasterUserOperation`\n\t * when `context.token` is set and the smart account supports approval prepending.\n\t *\n\t * Three cases:\n\t * - **Provider detected**: exchange rate + paymaster address from provider RPC.\n\t * - **No provider, `context.exchangeRate` set**: uses provided rate, paymaster\n\t * address from stub.\n\t * - **No provider, no rate**: falls through to the regular sponsored flow\n\t * (developer already handled approval).\n\t */\n\tprivate async tokenPaymasterFlow<T extends AnyUserOperation>(\n\t\tsmartAccount: PrependTokenPaymasterApproveAccount,\n\t\tuserOp: T,\n\t\ttokenAddress: string,\n\t\tbundlerRpc: string,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t\tcontext: Erc7677Context,\n\t\toverrides: GasPaymasterUserOperationOverrides,\n\t): Promise<SameUserOp<T>> {\n\t\t// Step 1 — resolve exchange rate + paymaster address.\n\t\tlet exchangeRate: bigint;\n\t\tlet paymasterAddress: string | null = null;\n\n\t\tconst providerQuote = await this.fetchProviderTokenQuote(\n\t\t\ttokenAddress,\n\t\t\tentrypoint,\n\t\t\tchainIdHex,\n\t\t);\n\n\t\tif (providerQuote != null) {\n\t\t\t// Case A: provider detected.\n\t\t\texchangeRate = providerQuote.exchangeRate;\n\t\t\tpaymasterAddress = providerQuote.paymasterAddress;\n\t\t} else if (context.exchangeRate != null) {\n\t\t\t// Case B: no provider, but exchangeRate in context.\n\t\t\t// paymasterAddress is resolved from the stub response below.\n\t\t\ttry {\n\t\t\t\texchangeRate = BigInt(context.exchangeRate as string | bigint);\n\t\t\t} catch (err) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\t`context.exchangeRate could not be parsed as a bigint: ${String(context.exchangeRate)}`,\n\t\t\t\t\t{ cause: ensureError(err) },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (exchangeRate <= 0n) {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\t`context.exchangeRate must be > 0, got ${exchangeRate}`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// Case C: no provider, no exchangeRate — fall through to regular flow.\n\t\t\treturn this.sponsoredFlow(\n\t\t\t\tuserOp,\n\t\t\t\tbundlerRpc,\n\t\t\t\tentrypoint,\n\t\t\t\tchainIdHex,\n\t\t\t\tcontext,\n\t\t\t\toverrides,\n\t\t\t);\n\t\t}\n\n\t\t// Step 2 — stub paymaster data for gas estimation.\n\t\t// For Candide, this is derived from the cached `pm_supportedERC20Tokens`\n\t\t// response (same RPC call used for the exchange rate above) — no extra\n\t\t// `pm_getPaymasterStubData` round-trip.\n\t\tconst stub = await this.getStubData(\n\t\t\tuserOp,\n\t\t\tentrypoint,\n\t\t\tchainIdHex,\n\t\t\tcontext,\n\t\t);\n\t\tthis.applyPaymasterFields(userOp, stub);\n\n\t\t// For Case B, resolve paymasterAddress from stub or context override.\n\t\tif (paymasterAddress == null) {\n\t\t\tif (context.paymasterAddress != null) {\n\t\t\t\tpaymasterAddress = context.paymasterAddress as string;\n\t\t\t} else if (\"initCode\" in userOp && stub.paymasterAndData != null) {\n\t\t\t\t// v0.6: extract address from first 20 bytes of paymasterAndData.\n\t\t\t\tpaymasterAddress = \"0x\" + stub.paymasterAndData.slice(2, 42);\n\t\t\t} else if (stub.paymaster != null) {\n\t\t\t\tpaymasterAddress = stub.paymaster;\n\t\t\t} else {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\t\"pm_getPaymasterStubData did not return a paymaster address. \" +\n\t\t\t\t\t\"Pass paymasterAddress in the context or set a provider.\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Step 3 — save original callData, prepend approve(paymaster, UINT256_MAX).\n\t\tconst originalCallData = userOp.callData;\n\t\tconst requiresAllowanceReset = overrides.resetApproval\n\t\t\t?? TOKENS_REQUIRING_ALLOWANCE_RESET.includes(tokenAddress.toLowerCase());\n\n\t\tlet callDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\tuserOp.callData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tUINT256_MAX,\n\t\t);\n\t\tif (requiresAllowanceReset) {\n\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\tcallDataWithApprove,\n\t\t\t\ttokenAddress,\n\t\t\t\tpaymasterAddress,\n\t\t\t\t0n,\n\t\t\t);\n\t\t}\n\t\tuserOp.callData = callDataWithApprove;\n\n\t\t// Step 4 — estimate gas limits.\n\t\tawait this.estimateAndApplyGasLimits(userOp, bundlerRpc, entrypoint, overrides);\n\n\t\t// Step 5 — calculate real token cost.\n\t\tconst maxGasCostWei = calculateUserOperationMaxGasCost(userOp);\n\t\tconst tokenCost = (exchangeRate * maxGasCostWei) / (10n ** 18n);\n\t\tconst approveAmount = tokenCost * TOKEN_APPROVE_AMOUNT_MULTIPLIER;\n\n\t\t// Step 6 — replace dummy approval with calculated amount on original callData.\n\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\toriginalCallData,\n\t\t\ttokenAddress,\n\t\t\tpaymasterAddress,\n\t\t\tapproveAmount,\n\t\t);\n\t\tif (requiresAllowanceReset) {\n\t\t\tcallDataWithApprove = smartAccount.prependTokenPaymasterApproveToCallData(\n\t\t\t\tcallDataWithApprove,\n\t\t\t\ttokenAddress,\n\t\t\t\tpaymasterAddress,\n\t\t\t\t0n,\n\t\t\t);\n\t\t}\n\t\tuserOp.callData = callDataWithApprove;\n\n\t\t// Step 7 — final paymaster data (signature over the fully-populated\n\t\t// userOp). The token flow always fetches fresh paymaster data: the\n\t\t// stub's `isFinal` cannot be honored here because callData was mutated\n\t\t// after the stub was generated, so any stub signature is over a\n\t\t// different UserOp hash than the one we're about to return.\n\t\tconst final = await this.getPaymasterData(\n\t\t\tuserOp,\n\t\t\tentrypoint,\n\t\t\tchainIdHex,\n\t\t\tcontext,\n\t\t);\n\t\tthis.applyPaymasterFields(userOp, final);\n\n\t\treturn userOp as unknown as SameUserOp<T>;\n\t}\n\n\t/**\n\t * The regular (non-token) sponsored flow: stub → estimate → final.\n\t * Extracted to allow `tokenPaymasterFlow` to fall through to it for Case C.\n\t */\n\tprivate async sponsoredFlow<T extends AnyUserOperation>(\n\t\tuserOp: T,\n\t\tbundlerRpc: string,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t\tcontext: Erc7677Context,\n\t\toverrides: GasPaymasterUserOperationOverrides,\n\t): Promise<SameUserOp<T>> {\n\t\t// Step 1 — stub paymaster data for gas estimation.\n\t\t// Candide-hosted paymasters skip `pm_getPaymasterStubData` and use the\n\t\t// cached `pm_supportedERC20Tokens` response instead.\n\t\tconst stub = await this.getStubData(\n\t\t\tuserOp,\n\t\t\tentrypoint,\n\t\t\tchainIdHex,\n\t\t\tcontext,\n\t\t);\n\t\tthis.applyPaymasterFields(userOp, stub);\n\n\t\t// Step 2 — gas estimation with the stub paymaster applied.\n\t\tawait this.estimateAndApplyGasLimits(\n\t\t\tuserOp,\n\t\t\tbundlerRpc,\n\t\t\tentrypoint,\n\t\t\toverrides,\n\t\t);\n\n\t\t// Step 3 — if the stub was already final, we're done.\n\t\tif (stub.isFinal === true) {\n\t\t\treturn userOp as unknown as SameUserOp<T>;\n\t\t}\n\n\t\t// Step 4 — final paymaster data (signature over the fully-populated userOp).\n\t\tconst final = await this.getPaymasterData(\n\t\t\tuserOp,\n\t\t\tentrypoint,\n\t\t\tchainIdHex,\n\t\t\tcontext,\n\t\t);\n\t\tthis.applyPaymasterFields(userOp, final);\n\n\t\treturn userOp as unknown as SameUserOp<T>;\n\t}\n}\n","import { Paymaster } from \"./Paymaster\";\nimport { ParallelPaymasterInitValues, UserOperationV9 } from \"../types\";\n\n/**\n * A paymaster that sponsors all UserOperations unconditionally.\n * Uses a fixed magic signature that the on-chain paymaster contract accepts\n * without additional validation.\n * Supports ep v0.9 paymaster parallel signing.\n *\n * **WARNING: FOR DEVELOPMENT AND TESTING ONLY.**\n * This paymaster accepts all operations without validation and should\n * not be used in production environments. Use CandidePaymaster for prod.\n */\nexport class ExperimentalAllowAllParallelPaymaster extends Paymaster {\n\t/** The on-chain paymaster contract address. */\n\treadonly address: string;\n\n\t/**\n\t * @param address - Paymaster contract address. Defaults to the canonical AllowAll deployment.\n\t */\n\tconstructor(address: string = \"0x36A337b8b4cE5CF6ca1dDaeef73Da4928d714DF2\") {\n\t\tsuper();\n\t\tthis.address = address;\n\t}\n\n\t/**\n\t * Returns initial paymaster fields (address, gas limits, and data) for\n\t * UserOperation construction before gas estimation.\n\t * @param chainId - The chain ID (unused, kept for interface compatibility)\n\t * @returns Paymaster fields with the magic signature as paymasterData\n\t */\n\tasync getPaymasterFieldsInitValues(\n chainId: bigint\n ):Promise<ParallelPaymasterInitValues>{\n return {\n paymaster: this.address,\n paymasterVerificationGasLimit: 45_000n,\n paymasterPostOpGasLimit: 45_000n,\n paymasterData:\"0x010101010101010101010101010101010101010101010101010101010101011c\"+\"0020\"+\"22e325a297439656\" // DUMMY SIG + PAYMASTER_SIG_LEN + PAYMASTER_SIG_MAGIC\n };\n }\n\n\t/**\n\t * getApprovedPaymasterData will return a valid paymasterData\n * This function is async to simulate a paymaster service\n * that require an http call to fetch approved data.\n\t * @param userOperation - User operation to be sponsored\n\t * @returns a promise of string\n\t */\n\tasync getApprovedPaymasterData(userOperation: UserOperationV9):Promise<string>{\n // the allow all paymaster only checks for this fixed signature\n return \"0x7603fbcd3c6cebdb7193b716f62fe7e9d4afd859df4bf7fcdb2e9d486f57a1ca\"\n + \"0020\" // signature length\n + \"22e325a297439656\"; // PAYMASTER_SIG_MAGIC\n }\n}\n","import { Paymaster } from \"./Paymaster\";\nimport { StateOverrideSet, UserOperationV7, UserOperationV8 } from \"../types\";\nimport { AbiCoder, keccak256, solidityPacked } from \"ethers\";\nimport { ENTRYPOINT_V7, ENTRYPOINT_V8 } from \"src/constants\";\nimport { Bundler } from \"src/Bundler\";\n\n/**\n * A paymaster that sponsors UserOperations for accounts verified through\n * World ID proof-of-personhood. Encodes the World ID Merkle root,\n * nullifier hash, and zero-knowledge proof into the paymasterData field\n * and re-estimates gas limits via the bundler.\n */\nexport class WorldIdPermissionlessPaymaster extends Paymaster {\n\t/** The on-chain paymaster contract address. */\n\treadonly address: string;\n\n\t/**\n\t * @param address - The deployed WorldIdPermissionlessPaymaster contract address\n\t */\n\tconstructor(address: string) {\n\t\tsuper();\n\t\tthis.address = address;\n\t}\n\n\t/**\n\t * createPaymasterUserOperation will estimate gas and set the paymaster fields.\n\t * @param userOperation - User operation to be sponsored\n\t * @param bundlerRpc - Bundler endpoint rpc url\n * @param nullifierHash - nullifier hash\n\t * @param root - Worldid Merkle tree root\n\t * @param proof - Worldid zk proof\n\t * @param overrides - Overrides for the default values\n\t * @returns a promise of UserOperationV8 | UserOperationV7\n\t */\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV8,\n bundlerRpc: string,\n nullifierHash: bigint,\n root:bigint,\n proof: string,\n\t\toverrides?:{\n /** set the entrypoint address intead of determining it from the useroperation structure.*/\n entrypoint?: string;\n\n /** pass some state overrides for gas estimation\"*/\n state_override_set?: StateOverrideSet;\n }\n\t):Promise<UserOperationV8>;\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV7,\n bundlerRpc: string,\n nullifierHash: bigint,\n root:bigint,\n proof: string,\n\t\toverrides?:{\n /** set the entrypoint address intead of determining it from the useroperation structure.*/\n entrypoint?: string;\n\n /** pass some state overrides for gas estimation\"*/\n state_override_set?: StateOverrideSet;\n }\n\t):Promise<UserOperationV7>;\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV8 | UserOperationV7,\n bundlerRpc: string,\n nullifierHash: bigint,\n root:bigint,\n proof: string,\n\t\toverrides?:{\n /** set the entrypoint address intead of determining it from the useroperation structure.*/\n entrypoint?: string;\n /** pass some state overrides for gas estimation\"*/\n state_override_set?: StateOverrideSet;\n }\n\t):Promise<UserOperationV8 | UserOperationV7> {\n //256 bytes for proof\n if(proof.slice(0,2) != \"0x\" || proof.length != 514){\n throw new RangeError(\"Invalid proof.\");\n }\n\n proof = proof.slice(2);\n const proofArr = [\n \"0x\" + proof.slice(0,64),\n \"0x\" + proof.slice(64,128),\n \"0x\" + proof.slice(128,192),\n \"0x\" + proof.slice(192,256),\n \"0x\" + proof.slice(256,320),\n \"0x\" + proof.slice(320,384),\n \"0x\" + proof.slice(384,448),\n \"0x\" + proof.slice(448,512),\n ];\n\n const abiCoder = AbiCoder.defaultAbiCoder();\n const paymasterData =\n abiCoder.encode(['uint256'],[root]) + \n abiCoder.encode(['uint256'],[nullifierHash]).slice(2) + \n abiCoder.encode(['uint256[8]'],[proofArr]).slice(2);\n\n userOperation.paymaster = this.address;\n userOperation.paymasterData = paymasterData;\n userOperation.paymasterPostOpGasLimit = 45_000n;\n userOperation.paymasterVerificationGasLimit = 350_000n;\n \n if(overrides == null){\n overrides = {}\n }\n let entrypointAddress = overrides.entrypoint;\n\n\t\tif (entrypointAddress == null) {\n\t\t if (\"eip7702Auth\" in userOperation) {\n entrypointAddress = ENTRYPOINT_V8;\n }else{\n entrypointAddress = ENTRYPOINT_V7;\n }\n }\n \n let preVerificationGas = userOperation.preVerificationGas;\n let verificationGasLimit = userOperation.verificationGasLimit;\n let callGasLimit = userOperation.callGasLimit;\n\n // set preVerificationGas to zero to force restimation\n userOperation.preVerificationGas = 0n;\n\n const bundler = new Bundler(bundlerRpc);\n const estimation = await bundler.estimateUserOperationGas(\n userOperation,\n entrypointAddress as string,\n overrides.state_override_set,\n );\n\n // only change gas limits if the estimated limits is higher than\n // the supplied\n if (preVerificationGas < estimation.preVerificationGas) {\n preVerificationGas = estimation.preVerificationGas;\n }\n if (verificationGasLimit < estimation.verificationGasLimit) {\n verificationGasLimit = estimation.verificationGasLimit;\n }\n if (callGasLimit < estimation.callGasLimit) {\n callGasLimit = estimation.callGasLimit;\n }\n\n userOperation.preVerificationGas = preVerificationGas;\n userOperation.verificationGasLimit = verificationGasLimit;\n userOperation.callGasLimit = callGasLimit;\n\n return userOperation;\n\t}\n}\n\n\n/**\n * createWorldIdSignal is a helper function to work with \"@worldcoin/idkit\n * @param accountAddress - account address\n * @param accountNonce - account nonce\n * @param chainId - chain id\n * @returns idkit IDKitWidget signal\n */\nexport function createWorldIdSignal(\n accountAddress: string,\n accountNonce: bigint,\n chainId: bigint,\n):string {\n return keccak256(\n solidityPacked(\n [\"address\", \"uint256\", \"uint256\"],\n [accountAddress, accountNonce, chainId]\n )\n )\n}\n","export { SmartAccount } from \"./account/SmartAccount\";\nexport { Simple7702Account } from \"./account/simple/Simple7702Account\";\nexport { Simple7702AccountV09 } from \"./account/simple/Simple7702AccountV09\";\nexport { SafeMultiChainSigAccountV1 } from \"./account/Safe/SafeMultiChainSigAccount\";\nexport { Calibur7702Account } from \"./account/Calibur/Calibur7702Account\";\nexport { CaliburKeyType } from \"./account/Calibur/types\";\nexport type {\n\tCaliburKey, CaliburKeySettings, CaliburKeySettingsResult,\n\tWebAuthnSignatureData, CaliburCreateUserOperationOverrides,\n\tCaliburSignatureOverrides, SignerFunction,\n} from \"./account/Calibur/types\";\nexport {\n\tSocialRecoveryModule,\n\tSocialRecoveryModuleGracePeriodSelector,\n EXECUTE_RECOVERY_PRIMARY_TYPE,\n EIP712_RECOVERY_MODULE_TYPE\n} from \"./account/Safe/modules/SocialRecoveryModule\";\nexport type {\n\tRecoveryRequest,\n\tRecoverySignaturePair,\n RecoveryRequestTypedDataDomain,\n RecoveryRequestTypedMessageValue,\n} from \"./account/Safe/modules/SocialRecoveryModule\";\nexport {\n\tAllowanceModule,\n\tALLOWANCE_MODULE_V0_1_0_ADDRESS,\n} from \"./account/Safe/modules/AllowanceModule\";\nexport type { Allowance } from \"./account/Safe/modules/AllowanceModule\";\nexport { SafeAccountV0_2_0 } from \"./account/Safe/SafeAccountV0_2_0\";\nexport { SafeAccountV0_3_0 } from \"./account/Safe/SafeAccountV0_3_0\";\nexport { SafeAccountV1_5_0_M_0_3_0 } from \"./account/Safe/SafeAccountV1_5_0_M_0_3_0\";\n\nexport { SendUseroperationResponse } from \"./account/SendUseroperationResponse\";\n\nexport { SmartAccountFactory } from \"./factory/SmartAccountFactory\";\nexport { SafeAccountFactory } from \"./factory/SafeAccountFactory\";\n\nexport { Bundler } from \"./Bundler\";\n\nexport { CandidePaymaster } from \"./paymaster/CandidePaymaster\";\nexport { Erc7677Paymaster } from \"./paymaster/Erc7677Paymaster\";\nexport type {\n\tErc7677Context,\n\tErc7677PaymasterFields,\n\tErc7677StubDataResult,\n} from \"./paymaster/Erc7677Paymaster\";\nexport type {\n\tErc7677Provider,\n\tErc7677PaymasterConstructorOptions,\n\tGasPaymasterUserOperationOverrides,\n} from \"./paymaster/types\";\nexport { ExperimentalAllowAllParallelPaymaster } from \"./paymaster/AllowAllPaymaster\";\n\nexport { \n WorldIdPermissionlessPaymaster, createWorldIdSignal \n} from \"./paymaster/WorldIdPermissionlessPaymaster\";\n\nexport {\n\tcreateUserOperationHash,\n\tcreateCallData,\n\tgetFunctionSelector,\n\tfetchAccountNonce,\n\tcalculateUserOperationMaxGasCost,\n\tsendJsonRpcRequest,\n fetchGasPrice,\n getDepositInfo,\n getBalanceOf,\n getDelegatedAddress,\n} from \"./utils\";\nexport type { DepositInfo } from \"./utils\";\n\nexport {\n shareTenderlySimulationAndCreateLink,\n simulateUserOperationWithTenderlyAndCreateShareLink,\n simulateUserOperationWithTenderly,\n simulateUserOperationCallDataWithTenderly,\n simulateSenderCallDataWithTenderlyAndCreateShareLink,\n simulateUserOperationCallDataWithTenderlyAndCreateShareLink,\n simulateSenderCallDataWithTenderly,\n callTenderlySimulateBundle\n} from \"./utilsTenderly\";\n\n\nexport {\n createAndSignLegacyRawTransaction,\n createAndSignEip7702RawTransaction,\n createEip7702TransactionHash,\n createAndSignEip7702DelegationAuthorization,\n createEip7702DelegationAuthorizationHash,\n signHash,\n} from \"./utils7702\";\nexport type { Authorization7702Hex, Authorization7702 } from \"./utils7702\";\n\nexport {\n\tSafeModuleExecutorFunctionSelector,\n\tEOADummySignerSignaturePair,\n\tWebauthnDummySignerSignaturePair,\n} from \"./account/Safe/types\";\nexport type {\n\tCreateUserOperationV6Overrides,\n\tCreateUserOperationV7Overrides,\n\tCreateUserOperationV9Overrides,\n\tECDSAPublicAddress,\n\tInitCodeOverrides,\n\tSafeUserOperationTypedDataDomain,\n\tWebauthnPublicKey,\n\tWebauthnSignatureData,\n\tSignerSignaturePair,\n\tSigner,\n} from \"./account/Safe/types\";\n\nexport type {\n\tCandidePaymasterContext,\n\tPrependTokenPaymasterApproveAccount,\n\tAnyUserOperation,\n\tSameUserOp,\n} from \"./paymaster/types\";\n\nexport { Operation, GasOption, PolygonChain } from \"./types\";\nexport type {\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n\tUserOperationV9,\n\tAbiInputValue,\n\tJsonRpcParam,\n\tJsonRpcResponse,\n\tJsonRpcResult,\n\tGasEstimationResult,\n\tUserOperationByHashResult,\n\tUserOperationReceipt,\n\tUserOperationReceiptResult,\n\tJsonRpcError,\n\tStateOverrideSet,\n\tMetaTransaction,\n SponsorMetadata,\n ParallelPaymasterInitValues,\n} from \"./types\";\n\nexport {\n\tZeroAddress,\n\tBaseUserOperationDummyValues,\n\tEIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\tEIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE,\n\tEIP712_SAFE_OPERATION_V7_TYPE,\n\tEIP712_SAFE_OPERATION_V6_TYPE,\n\tEIP712_SAFE_OPERATION_PRIMARY_TYPE,\n DEFAULT_SECP256R1_PRECOMPILE_ADDRESS,\n CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS,\n CALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS,\n ENTRYPOINT_V6,\n ENTRYPOINT_V7,\n ENTRYPOINT_V8,\n ENTRYPOINT_V9,\n} from \"./constants\";\n\nexport {\n SAFE_MESSAGE_PRIMARY_TYPE,\n SAFE_MESSAGE_MODULE_TYPE,\n getSafeMessageEip712Data,\n} from \"./account/Safe/safeMessage\";\nexport type {\n SafeMessageTypedDataDomain,\n SafeMessageTypedMessageValue,\n} from \"./account/Safe/safeMessage\";\n\nexport { AbstractionKitError } from \"./errors\";\n"],"mappings":";;;;;;;AAIA,IAAsB,eAAtB,MAAmC;;CAElC;;CAEA,OAAgB;;CAEhB,OAAgB;;CAEhB,OAAgB;;CAEhB,OAAgB;;CAEhB,OAAgB;;;;CAKhB,YAAY,gBAAwB;AACnC,OAAK,iBAAiB;;;;;;ACnBxB,MAAa,cAAc;;AAG3B,MAAa,gBAAgB;;AAE7B,MAAa,gBAAgB;;AAE7B,MAAa,gBAAgB;;AAE7B,MAAa,gBAAgB;;AAG7B,MAAa,iBAAuC;CACnD,kBAAkB;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