{"version":3,"file":"index.mjs","names":["signHash","ecdsaSignHash","signHash","signHash","signHash","signHash","UINT256_MAX","TOKEN_APPROVE_AMOUNT_MULTIPLIER","TOKENS_REQUIRING_ALLOWANCE_RESET","signHash"],"sources":["../src/ethereUtils.ts","../src/errors.ts","../src/transport/Transport.ts","../src/transport/BaseRpcTransport.ts","../src/transport/HttpTransport.ts","../src/types.ts","../src/transport/normalize.ts","../src/transport/JsonRpcNode.ts","../src/Bundler.ts","../src/constants.ts","../src/signer/negotiate.ts","../src/utils7702.ts","../src/utils.ts","../src/account/SendUseroperationResponse.ts","../src/account/SmartAccount.ts","../src/account/Calibur/types.ts","../src/account/Calibur/Calibur7702Account.ts","../src/factory/SmartAccountFactory.ts","../src/factory/SafeAccountFactory.ts","../src/utilsTenderly.ts","../src/account/Safe/multisend.ts","../src/account/Safe/safeMessage.ts","../src/account/Safe/types.ts","../src/account/Safe/SafeAccount.ts","../src/account/Safe/modules/SafeModule.ts","../src/account/Safe/modules/AllowanceModule.ts","../src/account/Safe/modules/SocialRecoveryModule.ts","../src/account/Safe/constants.ts","../src/account/Safe/MerkleTree.ts","../src/account/Safe/SafeMultiChainSigAccount.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/account/simple/Simple7702Account.ts","../src/account/simple/Simple7702AccountV09.ts","../src/paymaster/Paymaster.ts","../src/paymaster/AllowAllPaymaster.ts","../src/paymaster/CandidePaymaster.ts","../src/paymaster/Erc7677Paymaster.ts","../src/paymaster/WorldIdPermissionlessPaymaster.ts","../src/account/Safe/adapters.ts","../src/signer/adapters.ts","../src/userOperationRevert.ts","../src/abstractionkit.ts"],"sourcesContent":["/**\n * ethereUtils — copying related code from ethers v6 with some modification,\n * covering exactly the surface area used by `abstractionkit`.\n *\n * Sources (ethers v6.13.x):\n *   src.ts/utils/{data,maths,utf8,rlp-encode}.ts\n *   src.ts/crypto/{keccak,signing-key,signature}.ts\n *   src.ts/hash/{id,message,solidity,typed-data}.ts\n *   src.ts/address/{address,checks}.ts\n *   src.ts/abi/{abi-coder, coders/*}.ts\n *   src.ts/transaction/address.ts\n */\n\nimport { keccak_256 } from \"@noble/hashes/sha3\";\nimport { secp256k1 } from \"@noble/curves/secp256k1\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Types\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type Hex = `0x${string}`;\nexport type BytesLike = string | Uint8Array;\nexport type Numeric = number | bigint;\nexport type BigNumberish = string | Numeric;\nexport type RlpStructuredDataish = BytesLike | ReadonlyArray<RlpStructuredDataish>;\n\nexport interface TypedDataDomain {\n    name?: null | string;\n    version?: null | string;\n    chainId?: null | BigNumberish;\n    verifyingContract?: null | string;\n    salt?: null | BytesLike;\n}\n\nexport interface TypedDataField {\n    name: string;\n    type: string;\n}\n\nexport interface Signature {\n    r: Hex;\n    s: Hex;\n    v: 27 | 28;\n    yParity: 0 | 1;\n    /** 65-byte hex: `r (32) || s (32) || v (1)`. */\n    serialized: Hex;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Errors (simplified)\n//   ethers ships a rich error system; we keep the assertion shape and message\n//   formatting but drop the typed-error machinery (CALL_EXCEPTION,\n//   BUFFER_OVERRUN, NUMERIC_FAULT, …) since none of abstractionkit's call\n//   sites discriminate on them.\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Format an argument value for inclusion in an error message without leaking\n// secrets. Private keys, digests, and calldata flow through `getBytes` and\n// can land here on malformed input, so:\n//   1. If the parameter name hints at a secret, fully redact.\n//   2. Hex strings get a prefix/suffix preview (callers can recognize the\n//      value in logs without copying the whole thing into a bug report).\n//   3. Any string long enough to be a key but missed by (1) and (2) is\n//      redacted by length, as defense-in-depth.\n//   4. Uint8Array is never echoed (a raw private key can flow this way too).\nfunction redactArgumentValue(name: string, value: unknown): string {\n    if (value === null || value === undefined) return String(value);\n    if (typeof value === \"string\") {\n        const n = name.toLowerCase();\n        if (\n            n.includes(\"key\") ||\n            n.includes(\"secret\") ||\n            n.includes(\"token\") ||\n            n.includes(\"password\") ||\n            n.includes(\"mnemonic\")\n        ) {\n            return \"[REDACTED]\";\n        }\n        if (/^0x[0-9a-f]+$/i.test(value) && value.length > 18) {\n            return `${value.slice(0, 10)}…${value.slice(-6)}`;\n        }\n        if (value.length > 64) return `[REDACTED string length=${value.length}]`;\n        return value;\n    }\n    if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") {\n        return String(value);\n    }\n    if (value instanceof Uint8Array) return `[REDACTED Uint8Array length=${value.length}]`;\n    return `[REDACTED ${typeof value}]`;\n}\n\nfunction assertArgument(check: unknown, message: string, name: string, value: unknown): asserts check {\n    if (!check) throw new Error(`invalid argument (${name}=${redactArgumentValue(name, value)}, message=${message})`);\n}\nfunction assertCheck(check: unknown, message: string): asserts check {\n    if (!check) throw new Error(message);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Data helpers (src.ts/utils/data.ts)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst HexCharacters = \"0123456789abcdef\";\n\nfunction _getBytes(value: BytesLike, name?: string, copy?: boolean): Uint8Array {\n    if (value instanceof Uint8Array) {\n        return copy ? new Uint8Array(value) : value;\n    }\n    if (typeof value === \"string\" && value.length % 2 === 0 && value.match(/^0x[0-9a-f]*$/i)) {\n        const result = new Uint8Array((value.length - 2) / 2);\n        let offset = 2;\n        for (let i = 0; i < result.length; i++) {\n            result[i] = parseInt(value.substring(offset, offset + 2), 16);\n            offset += 2;\n        }\n        return result;\n    }\n    assertArgument(false, \"invalid BytesLike value\", name || \"value\", value);\n}\n\nexport function getBytes(value: BytesLike, name?: string): Uint8Array {\n    return _getBytes(value, name, false);\n}\n\nfunction getBytesCopy(value: BytesLike, name?: string): Uint8Array {\n    return _getBytes(value, name, true);\n}\n\nexport function isHexString(value: unknown, length?: number | boolean): value is `0x${string}` {\n    if (typeof value !== \"string\" || !value.match(/^0x[0-9A-Fa-f]*$/)) return false;\n    if (typeof length === \"number\" && value.length !== 2 + 2 * length) return false;\n    if (length === true && value.length % 2 !== 0) return false;\n    return true;\n}\n\nexport function hexlify(data: BytesLike): Hex {\n    const bytes = getBytes(data);\n    let result = \"0x\";\n    for (let i = 0; i < bytes.length; i++) {\n        const v = bytes[i];\n        result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];\n    }\n    return result as Hex;\n}\n\nexport function concat(datas: ReadonlyArray<BytesLike>): Hex {\n    return (\"0x\" + datas.map((d) => hexlify(d).substring(2)).join(\"\")) as Hex;\n}\n\nexport function dataLength(data: BytesLike): number {\n    if (isHexString(data, true)) return (data.length - 2) / 2;\n    return getBytes(data).length;\n}\n\nfunction zeroPad(data: BytesLike, length: number, left: boolean): Hex {\n    const bytes = getBytes(data);\n    assertCheck(length >= bytes.length, \"padding exceeds data length\");\n    const result = new Uint8Array(length);\n    result.fill(0);\n    if (left) result.set(bytes, length - bytes.length);\n    else result.set(bytes, 0);\n    return hexlify(result);\n}\n\nfunction zeroPadValue(data: BytesLike, length: number): Hex {\n    return zeroPad(data, length, true);\n}\n\nfunction zeroPadBytes(data: BytesLike, length: number): Hex {\n    return zeroPad(data, length, false);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Math helpers (src.ts/utils/maths.ts)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst BN_0 = 0n;\nconst BN_1 = 1n;\nconst maxValue = 0x1fffffffffffff; // 2^53 - 1 (IEEE 754 mantissa)\n\nfunction getBigInt(value: BigNumberish, name?: string): bigint {\n    switch (typeof value) {\n        case \"bigint\": return value;\n        case \"number\":\n            assertArgument(Number.isInteger(value), \"underflow\", name || \"value\", value);\n            assertArgument(value >= -maxValue && value <= maxValue, \"overflow\", name || \"value\", value);\n            return BigInt(value);\n        case \"string\":\n            try {\n                if (value === \"\") throw new Error(\"empty string\");\n                if (value[0] === \"-\" && value[1] !== \"-\") return -BigInt(value.substring(1));\n                return BigInt(value);\n            } catch (e) {\n                assertArgument(false, `invalid BigNumberish string: ${(e as Error).message}`, name || \"value\", value);\n            }\n    }\n    assertArgument(false, \"invalid BigNumberish value\", name || \"value\", value);\n}\n\nfunction getUint(value: BigNumberish, name?: string): bigint {\n    const result = getBigInt(value, name);\n    assertCheck(result >= BN_0, \"unsigned value cannot be negative\");\n    return result;\n}\n\nfunction getNumber(value: BigNumberish, name?: string): number {\n    switch (typeof value) {\n        case \"bigint\":\n            assertArgument(value >= -maxValue && value <= maxValue, \"overflow\", name || \"value\", value);\n            return Number(value);\n        case \"number\":\n            assertArgument(Number.isInteger(value), \"underflow\", name || \"value\", value);\n            assertArgument(value >= -maxValue && value <= maxValue, \"overflow\", name || \"value\", value);\n            return value;\n        case \"string\":\n            try {\n                if (value === \"\") throw new Error(\"empty string\");\n                return getNumber(BigInt(value), name);\n            } catch (e) {\n                assertArgument(false, `invalid numeric string: ${(e as Error).message}`, name || \"value\", value);\n            }\n    }\n    assertArgument(false, \"invalid numeric value\", name || \"value\", value);\n}\n\nconst Nibbles = \"0123456789abcdef\";\n\nfunction toBigInt(value: BigNumberish | Uint8Array): bigint {\n    if (value instanceof Uint8Array) {\n        let result = \"0x0\";\n        for (const v of value) {\n            result += Nibbles[v >> 4];\n            result += Nibbles[v & 0x0f];\n        }\n        return BigInt(result);\n    }\n    return getBigInt(value);\n}\n\nfunction toNumber(value: BigNumberish | Uint8Array): number {\n    return getNumber(toBigInt(value));\n}\n\nfunction mask(_value: BigNumberish, _bits: Numeric): bigint {\n    const value = getUint(_value, \"value\");\n    const bits = BigInt(getNumber(_bits, \"bits\"));\n    return value & ((BN_1 << bits) - BN_1);\n}\n\nfunction toTwos(_value: BigNumberish, _width: Numeric): bigint {\n    let value = getBigInt(_value, \"value\");\n    const width = BigInt(getNumber(_width, \"width\"));\n    const limit = BN_1 << (width - BN_1);\n    if (value < BN_0) {\n        value = -value;\n        assertCheck(value <= limit, \"toTwos: too low\");\n        const m = (BN_1 << width) - BN_1;\n        return ((~value) & m) + BN_1;\n    }\n    assertCheck(value < limit, \"toTwos: too high\");\n    return value;\n}\n\nfunction fromTwos(_value: BigNumberish, _width: Numeric): bigint {\n    const value = getUint(_value, \"value\");\n    const width = BigInt(getNumber(_width, \"width\"));\n    assertCheck((value >> width) === BN_0, \"fromTwos: overflow\");\n    if (value >> (width - BN_1)) {\n        const m = (BN_1 << width) - BN_1;\n        return -(((~value) & m) + BN_1);\n    }\n    return value;\n}\n\nfunction toBeHex(_value: BigNumberish, _width?: Numeric): Hex {\n    const value = getUint(_value, \"value\");\n    let result = value.toString(16);\n    if (_width == null) {\n        if (result.length % 2) result = \"0\" + result;\n    } else {\n        const width = getNumber(_width, \"width\");\n        if (width === 0 && value === BN_0) return \"0x\" as Hex;\n        assertCheck(width * 2 >= result.length, `value exceeds width (${width} bytes)`);\n        while (result.length < width * 2) result = \"0\" + result;\n    }\n    return (\"0x\" + result) as Hex;\n}\n\nexport function toBeArray(_value: BigNumberish, _width?: Numeric): Uint8Array {\n    const value = getUint(_value, \"value\");\n    if (value === BN_0) {\n        const width = _width != null ? getNumber(_width, \"width\") : 0;\n        return new Uint8Array(width);\n    }\n    let hex = value.toString(16);\n    if (hex.length % 2) hex = \"0\" + hex;\n    if (_width != null) {\n        const width = getNumber(_width, \"width\");\n        while (hex.length < width * 2) hex = \"00\" + hex;\n        assertCheck(width * 2 === hex.length, `value exceeds width (${width} bytes)`);\n    }\n    const result = new Uint8Array(hex.length / 2);\n    for (let i = 0; i < result.length; i++) {\n        const offset = i * 2;\n        result[i] = parseInt(hex.substring(offset, offset + 2), 16);\n    }\n    return result;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// UTF-8 (src.ts/utils/utf8.ts — encoding + decoding)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport function toUtf8Bytes(str: string): Uint8Array {\n    assertArgument(typeof str === \"string\", \"invalid string value\", \"str\", str);\n    const result: number[] = [];\n    for (let i = 0; i < str.length; i++) {\n        const c = str.charCodeAt(i);\n        if (c < 0x80) {\n            result.push(c);\n        } else if (c < 0x800) {\n            result.push((c >> 6) | 0xc0);\n            result.push((c & 0x3f) | 0x80);\n        } else if ((c & 0xfc00) === 0xd800) {\n            i++;\n            const c2 = str.charCodeAt(i);\n            assertArgument(i < str.length && (c2 & 0xfc00) === 0xdc00, \"invalid surrogate pair\", \"str\", str);\n            const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);\n            result.push((pair >> 18) | 0xf0);\n            result.push(((pair >> 12) & 0x3f) | 0x80);\n            result.push(((pair >> 6) & 0x3f) | 0x80);\n            result.push((pair & 0x3f) | 0x80);\n        } else {\n            result.push((c >> 12) | 0xe0);\n            result.push(((c >> 6) & 0x3f) | 0x80);\n            result.push((c & 0x3f) | 0x80);\n        }\n    }\n    return new Uint8Array(result);\n}\n\n/**\n * Decode UTF-8 bytes to a string. Pure JS so it works in every runtime,\n * including React Native / Hermes where `TextDecoder` is not defined by default.\n *\n * Throws on bad prefix, truncated sequences, missing or unexpected continuation bytes,\n * overlong encodings, surrogate code points (U+D800..U+DFFF), and code\n * points above U+10FFFF. For ABI string payloads this is the right policy —\n * well-formed contracts never emit broken UTF-8, so an error signals a\n * real problem rather than silently corrupting the decoded value.\n *\n * @throws Error when `bytes` is not a valid UTF-8 sequence.\n */\nexport function fromUtf8Bytes(bytes: Uint8Array): string {\n    const codepoints: number[] = [];\n    let i = 0;\n    while (i < bytes.length) {\n        const c = bytes[i++];\n\n        // 1-byte ASCII.\n        if ((c & 0x80) === 0) {\n            codepoints.push(c);\n            continue;\n        }\n\n        // Lead-byte classification per RFC 3629. Bytes 0xf8..0xff are not\n        // valid UTF-8 lead bytes and fall through to the error branch.\n        let extraLength: number;\n        let overlongMask: number;\n        if ((c & 0xe0) === 0xc0) {\n            extraLength = 1;\n            overlongMask = 0x7f;\n        } else if ((c & 0xf0) === 0xe0) {\n            extraLength = 2;\n            overlongMask = 0x7ff;\n        } else if ((c & 0xf8) === 0xf0) {\n            extraLength = 3;\n            overlongMask = 0xffff;\n        } else {\n            const kind = (c & 0xc0) === 0x80 ? \"unexpected continuation\" : \"bad prefix\";\n            throw new Error(`invalid UTF-8: ${kind} byte 0x${c.toString(16)} at index ${i - 1}`);\n        }\n\n        if (i + extraLength > bytes.length) {\n            throw new Error(`invalid UTF-8: truncated sequence at index ${i - 1}`);\n        }\n\n        let res = c & ((1 << (8 - extraLength - 1)) - 1);\n        for (let j = 0; j < extraLength; j++) {\n            const next = bytes[i++];\n            if ((next & 0xc0) !== 0x80) {\n                throw new Error(\n                    `invalid UTF-8: missing continuation byte 0x${next.toString(16)} at index ${i - 1}`,\n                );\n            }\n            res = (res << 6) | (next & 0x3f);\n        }\n\n        if (res <= overlongMask) {\n            throw new Error(`invalid UTF-8: overlong encoding of U+${res.toString(16).toUpperCase()}`);\n        }\n        if (res >= 0xd800 && res <= 0xdfff) {\n            throw new Error(`invalid UTF-8: surrogate code point U+${res.toString(16).toUpperCase()}`);\n        }\n        if (res > 0x10ffff) {\n            throw new Error(`invalid UTF-8: code point U+${res.toString(16).toUpperCase()} out of range`);\n        }\n\n        codepoints.push(res);\n    }\n\n    let result = \"\";\n    for (const cp of codepoints) result += String.fromCodePoint(cp);\n    return result;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Crypto: keccak256 (src.ts/crypto/keccak.ts)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport function keccak256(_data: BytesLike): Hex {\n    const data = getBytes(_data, \"data\");\n    return hexlify(keccak_256(data));\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Hash: id, hashMessage (src.ts/hash/{id,message}.ts)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport function id(value: string): Hex {\n    return keccak256(toUtf8Bytes(value));\n}\n\nconst MessagePrefix = \"\\x19Ethereum Signed Message:\\n\";\n\nexport function hashMessage(message: Uint8Array | string): Hex {\n    if (typeof message === \"string\") message = toUtf8Bytes(message);\n    return keccak256(concat([\n        toUtf8Bytes(MessagePrefix),\n        toUtf8Bytes(String(message.length)),\n        message,\n    ]));\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Address: getAddress, isAddress (src.ts/address/{address,checks}.ts)\n//   ICAP/Base36 dropped — abstractionkit never passes ICAP addresses.\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction getChecksumAddress(address: string): Hex {\n    address = address.toLowerCase();\n    const chars = address.substring(2).split(\"\");\n    const expanded = new Uint8Array(40);\n    for (let i = 0; i < 40; i++) expanded[i] = chars[i].charCodeAt(0);\n    const hashed = getBytes(keccak256(expanded));\n    for (let i = 0; i < 40; i += 2) {\n        if ((hashed[i >> 1] >> 4) >= 8) chars[i] = chars[i].toUpperCase();\n        if ((hashed[i >> 1] & 0x0f) >= 8) chars[i + 1] = chars[i + 1].toUpperCase();\n    }\n    return (\"0x\" + chars.join(\"\")) as Hex;\n}\n\nexport function getAddress(address: string): Hex {\n    assertArgument(typeof address === \"string\", \"invalid address\", \"address\", address);\n    if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {\n        if (!address.startsWith(\"0x\")) address = \"0x\" + address;\n        const result = getChecksumAddress(address);\n        assertArgument(\n            !address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address,\n            \"bad address checksum\", \"address\", address,\n        );\n        return result;\n    }\n    assertArgument(false, \"invalid address\", \"address\", address);\n}\n\nexport function isAddress(value: unknown): value is string {\n    try {\n        getAddress(value as string);\n        return true;\n    } catch {\n        return false;\n    }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Solidity packed (src.ts/hash/solidity.ts)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst regexBytes = /^bytes([0-9]+)$/;\nconst regexNumber = /^(u?int)([0-9]*)$/;\nconst regexArray = /^(.*)\\[([0-9]*)\\]$/;\n\nfunction _pack(type: string, value: unknown, isArray?: boolean): Uint8Array {\n    switch (type) {\n        case \"address\":\n            if (isArray) return getBytes(zeroPadValue(value as string, 32));\n            return getBytes(getAddress(value as string));\n        case \"string\":\n            return toUtf8Bytes(value as string);\n        case \"bytes\":\n            return getBytes(value as BytesLike);\n        case \"bool\": {\n            const v: Hex = value ? \"0x01\" : \"0x00\";\n            if (isArray) return getBytes(zeroPadValue(v, 32));\n            return getBytes(v);\n        }\n    }\n\n    let match = type.match(regexNumber);\n    if (match) {\n        const signed = match[1] === \"int\";\n        let size = parseInt(match[2] || \"256\");\n        assertArgument(\n            (!match[2] || match[2] === String(size)) && size % 8 === 0 && size !== 0 && size <= 256,\n            \"invalid number type\", \"type\", type,\n        );\n        if (isArray) size = 256;\n        const v = signed ? toTwos(value as BigNumberish, size) : (value as BigNumberish);\n        return getBytes(zeroPadValue(toBeArray(v), size / 8));\n    }\n\n    match = type.match(regexBytes);\n    if (match) {\n        const size = parseInt(match[1]);\n        assertArgument(String(size) === match[1] && size !== 0 && size <= 32, \"invalid bytes type\", \"type\", type);\n        assertArgument(dataLength(value as BytesLike) === size, `invalid value for ${type}`, \"value\", value);\n        if (isArray) return getBytes(zeroPadBytes(value as BytesLike, 32));\n        return getBytes(value as BytesLike);\n    }\n\n    match = type.match(regexArray);\n    if (match && Array.isArray(value)) {\n        const baseType = match[1];\n        const count = parseInt(match[2] || String(value.length));\n        assertArgument(count === value.length, `invalid array length for ${type}`, \"value\", value);\n        const result: Uint8Array[] = [];\n        for (const v of value) result.push(_pack(baseType, v, true));\n        return getBytes(concat(result));\n    }\n\n    assertArgument(false, \"invalid type\", \"type\", type);\n}\n\nexport function solidityPacked(types: ReadonlyArray<string>, values: ReadonlyArray<unknown>): Hex {\n    assertArgument(types.length === values.length, \"wrong number of values\", \"values\", values);\n    const tight: Uint8Array[] = [];\n    for (let i = 0; i < types.length; i++) {\n        tight.push(_pack(types[i], values[i]));\n    }\n    return hexlify(concat(tight));\n}\n\nexport function solidityPackedKeccak256(types: ReadonlyArray<string>, values: ReadonlyArray<unknown>): Hex {\n    return keccak256(solidityPacked(types, values));\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// RLP encode (src.ts/utils/rlp-encode.ts)\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction arrayifyInteger(value: number): number[] {\n    const result: number[] = [];\n    while (value) {\n        result.unshift(value & 0xff);\n        value >>= 8;\n    }\n    return result;\n}\n\nfunction _rlpEncode(object: RlpStructuredDataish): number[] {\n    if (Array.isArray(object)) {\n        let payload: number[] = [];\n        object.forEach((child) => {\n            payload = payload.concat(_rlpEncode(child));\n        });\n        if (payload.length <= 55) {\n            payload.unshift(0xc0 + payload.length);\n            return payload;\n        }\n        const length = arrayifyInteger(payload.length);\n        length.unshift(0xf7 + length.length);\n        return length.concat(payload);\n    }\n    const data: number[] = Array.prototype.slice.call(getBytes(object as BytesLike, \"object\"));\n    if (data.length === 1 && data[0] <= 0x7f) return data;\n    if (data.length <= 55) {\n        data.unshift(0x80 + data.length);\n        return data;\n    }\n    const length = arrayifyInteger(data.length);\n    length.unshift(0xb7 + length.length);\n    return length.concat(data);\n}\n\nexport function encodeRlp(object: RlpStructuredDataish): Hex {\n    let result = \"0x\";\n    for (const v of _rlpEncode(object)) {\n        result += Nibbles[v >> 4];\n        result += Nibbles[v & 0xf];\n    }\n    return result as Hex;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// ABI codec (src.ts/abi/* — class hierarchy collapsed into recursive functions)\n//\n// Type grammar (subset used by abstractionkit):\n//   address | bool | string | bytes | bytes<1..32> | uint<8..256> | int<8..256>\n//   T[] | T[<n>] | (T1,T2,...) (tuples)\n// ─────────────────────────────────────────────────────────────────────────────\n\ntype AbiType =\n    | { kind: \"uint\"; bits: number; signed: boolean }\n    | { kind: \"address\" }\n    | { kind: \"bool\" }\n    | { kind: \"bytesN\"; size: number }\n    | { kind: \"bytes\" }\n    | { kind: \"string\" }\n    | { kind: \"array\"; child: AbiType; size: number /* -1 = dynamic */ }\n    | { kind: \"tuple\"; components: AbiType[] };\n\nfunction splitTopLevel(s: string): string[] {\n    const out: string[] = [];\n    let depth = 0, start = 0;\n    for (let i = 0; i < s.length; i++) {\n        const c = s[i];\n        if (c === \"(\" || c === \"[\") depth++;\n        else if (c === \")\" || c === \"]\") depth--;\n        else if (c === \",\" && depth === 0) { out.push(s.slice(start, i)); start = i + 1; }\n    }\n    if (start < s.length) out.push(s.slice(start));\n    return out.map((x) => x.trim()).filter((x) => x.length > 0);\n}\n\nfunction parseType(s: string): AbiType {\n    s = s.trim();\n    const m = s.match(/^(.+?)((?:\\[\\d*\\])*)$/);\n    assertArgument(!!m, `invalid type`, \"type\", s);\n    const base = m![1], suffix = m![2];\n\n    let t: AbiType;\n    if (base.startsWith(\"(\")) {\n        assertArgument(base.endsWith(\")\"), `unbalanced tuple`, \"type\", s);\n        t = { kind: \"tuple\", components: splitTopLevel(base.slice(1, -1)).map(parseType) };\n    } else if (base === \"address\") t = { kind: \"address\" };\n    else if (base === \"bool\") t = { kind: \"bool\" };\n    else if (base === \"string\") t = { kind: \"string\" };\n    else if (base === \"bytes\") t = { kind: \"bytes\" };\n    else if (base === \"uint\" || base === \"int\") t = { kind: \"uint\", bits: 256, signed: base === \"int\" };\n    else {\n        const um = base.match(regexNumber);\n        if (um) {\n            const bits = parseInt(um[2] || \"256\");\n            assertArgument(bits !== 0 && bits <= 256 && bits % 8 === 0, \"invalid number type\", \"type\", base);\n            t = { kind: \"uint\", bits, signed: um[1] === \"int\" };\n        } else {\n            const bm = base.match(regexBytes);\n            assertArgument(!!bm, `unknown type ${base}`, \"type\", base);\n            const size = parseInt(bm![1]);\n            assertArgument(size !== 0 && size <= 32, \"invalid bytes type\", \"type\", base);\n            t = { kind: \"bytesN\", size };\n        }\n    }\n\n    for (const ap of suffix.matchAll(/\\[(\\d*)\\]/g)) {\n        t = { kind: \"array\", child: t, size: ap[1] ? parseInt(ap[1]) : -1 };\n    }\n    return t;\n}\n\nfunction isDynamic(t: AbiType): boolean {\n    switch (t.kind) {\n        case \"bytes\": case \"string\": return true;\n        case \"array\": return t.size === -1 || isDynamic(t.child);\n        case \"tuple\": return t.components.some(isDynamic);\n        default: return false;\n    }\n}\n\nfunction staticSize(t: AbiType): number {\n    switch (t.kind) {\n        case \"uint\": case \"address\": case \"bool\": case \"bytesN\": return 32;\n        case \"array\": return t.size * staticSize(t.child);\n        case \"tuple\": return t.components.reduce((s, c) => s + staticSize(c), 0);\n        default: throw new Error(`staticSize: dynamic type ${t.kind}`);\n    }\n}\n\nconst WordSize = 32;\nconst Padding = new Uint8Array(WordSize);\n// Allocation cap for dynamic arrays whose element type has zero head footprint\n// (e.g. empty tuples), where the payload carries no per-element bytes to bound\n// the length against. Far above any realistic decode, low enough to stay safe.\nconst MaxZeroFootprintArrayLen = 1 << 20;\n\nfunction padLeft(b: Uint8Array, size: number): Uint8Array {\n    assertCheck(b.length <= size, \"padLeft: overflow\");\n    const out = new Uint8Array(size);\n    out.set(b, size - b.length);\n    return out;\n}\n\nfunction padRight(b: Uint8Array, size: number): Uint8Array {\n    assertCheck(b.length <= size, \"padRight: overflow\");\n    const out = new Uint8Array(size);\n    out.set(b, 0);\n    return out;\n}\n\nfunction padTo32(len: number): number {\n    return Math.ceil(len / WordSize) * WordSize;\n}\n\nconst BN_MAX_UINT256 = (1n << 256n) - 1n;\n\nfunction encodeValue(t: AbiType, v: unknown): Uint8Array {\n    switch (t.kind) {\n        case \"uint\": {\n            let value = getBigInt(v as BigNumberish, \"value\");\n            const maxUintValue = mask(BN_MAX_UINT256, WordSize * 8);\n            if (t.signed) {\n                const bounds = mask(maxUintValue, t.bits - 1);\n                assertCheck(value <= bounds && value >= -(bounds + 1n), `int${t.bits}: value out-of-bounds`);\n                value = toTwos(value, 8 * WordSize);\n            } else {\n                assertCheck(value >= 0n && value <= mask(maxUintValue, t.bits), `uint${t.bits}: out-of-bounds`);\n            }\n            return padLeft(toBeArray(value), WordSize);\n        }\n        case \"address\": {\n            const bytes = getBytes(getAddress(v as string));\n            return padLeft(bytes, WordSize);\n        }\n        case \"bool\":\n            return padLeft(new Uint8Array([v ? 1 : 0]), WordSize);\n        case \"bytesN\": {\n            const bytes = getBytes(v as BytesLike);\n            assertCheck(bytes.length === t.size, `bytes${t.size}: wrong length`);\n            return padRight(bytes, WordSize);\n        }\n        case \"bytes\": {\n            const bytes = getBytes(v as BytesLike);\n            return concatBytes([padLeft(toBeArray(bytes.length), WordSize), padRight(bytes, padTo32(bytes.length))]);\n        }\n        case \"string\": {\n            const bytes = toUtf8Bytes(v as string);\n            return concatBytes([padLeft(toBeArray(bytes.length), WordSize), padRight(bytes, padTo32(bytes.length))]);\n        }\n        case \"array\": {\n            const arr = v as unknown[];\n            assertCheck(t.size === -1 || arr.length === t.size, \"array: length mismatch\");\n            const types = Array<AbiType>(arr.length).fill(t.child);\n            const inner = encodeTuple(types, arr);\n            return t.size === -1\n                ? concatBytes([padLeft(toBeArray(arr.length), WordSize), inner])\n                : inner;\n        }\n        case \"tuple\":\n            return encodeTuple(t.components, v as unknown[]);\n    }\n}\n\nfunction concatBytes(parts: Uint8Array[]): Uint8Array {\n    const total = parts.reduce((s, p) => s + p.length, 0);\n    const out = new Uint8Array(total);\n    let off = 0;\n    for (const p of parts) { out.set(p, off); off += p.length; }\n    return out;\n}\n\nfunction encodeTuple(types: AbiType[], values: unknown[]): Uint8Array {\n    assertCheck(types.length === values.length, \"tuple: length mismatch\");\n    const heads: Uint8Array[] = [];\n    const tails: Uint8Array[] = [];\n    const headSize = types.reduce((s, t) => s + (isDynamic(t) ? WordSize : staticSize(t)), 0);\n    let tailOff = headSize;\n    for (let i = 0; i < types.length; i++) {\n        const enc = encodeValue(types[i], values[i]);\n        if (isDynamic(types[i])) {\n            heads.push(padLeft(toBeArray(tailOff), WordSize));\n            tails.push(enc);\n            tailOff += enc.length;\n        } else {\n            heads.push(enc);\n        }\n    }\n    return concatBytes([...heads, ...tails]);\n}\n\nfunction ensureRange(data: Uint8Array, offset: number, len: number, what: string): void {\n    if (offset < 0 || len < 0 || offset + len > data.length) {\n        throw new Error(\n            `ABI decode: out-of-bounds read for ${what} ` +\n            `(offset=${offset}, length=${len}, data.length=${data.length})`,\n        );\n    }\n}\n\nfunction decodeValue(t: AbiType, data: Uint8Array, base: number): unknown {\n    switch (t.kind) {\n        case \"uint\": {\n            ensureRange(data, base, WordSize, `${t.signed ? \"int\" : \"uint\"}${t.bits}`);\n            const raw = toBigInt(data.slice(base, base + WordSize));\n            const masked = mask(raw, t.bits);\n            return t.signed ? fromTwos(masked, t.bits) : masked;\n        }\n        case \"address\":\n            ensureRange(data, base, WordSize, \"address\");\n            return getAddress(hexlify(data.slice(base + 12, base + WordSize)));\n        case \"bool\":\n            ensureRange(data, base, WordSize, \"bool\");\n            return data[base + 31] !== 0;\n        case \"bytesN\":\n            ensureRange(data, base, WordSize, `bytes${t.size}`);\n            return hexlify(data.slice(base, base + t.size));\n        case \"bytes\": {\n            ensureRange(data, base, WordSize, \"bytes length\");\n            const len = toNumber(data.slice(base, base + WordSize));\n            ensureRange(data, base + WordSize, len, \"bytes payload\");\n            return hexlify(data.slice(base + WordSize, base + WordSize + len));\n        }\n        case \"string\": {\n            ensureRange(data, base, WordSize, \"string length\");\n            const len = toNumber(data.slice(base, base + WordSize));\n            ensureRange(data, base + WordSize, len, \"string payload\");\n            return fromUtf8Bytes(data.slice(base + WordSize, base + WordSize + len));\n        }\n        case \"array\": {\n            if (t.size === -1) {\n                ensureRange(data, base, WordSize, \"array length\");\n                const len = toNumber(data.slice(base, base + WordSize));\n                // Bound the element count before allocating, so a hostile length\n                // word can't trigger an out-of-memory allocation. Each element\n                // occupies a fixed head footprint in the array body: a 32-byte\n                // offset slot for a dynamic element, its static size for a static\n                // one. Zero-footprint elements (e.g. empty tuples) consume no\n                // body bytes, so there is nothing to bound the length against;\n                // cap those by an absolute length instead.\n                const elementHeadSize = isDynamic(t.child)\n                    ? WordSize\n                    : staticSize(t.child);\n                const bodyBytes = data.length - (base + WordSize);\n                const maxElements =\n                    elementHeadSize > 0\n                        ? Math.floor(bodyBytes / elementHeadSize)\n                        : MaxZeroFootprintArrayLen;\n                if (len > maxElements) {\n                    throw new Error(\n                        `ABI decode: array length ${len} exceeds payload capacity ` +\n                        `(maxElements=${maxElements}, data.length=${data.length})`,\n                    );\n                }\n                return decodeTupleAt(Array<AbiType>(len).fill(t.child), data, base + WordSize);\n            }\n            return decodeTupleAt(Array<AbiType>(t.size).fill(t.child), data, base);\n        }\n        case \"tuple\":\n            return decodeTupleAt(t.components, data, base);\n    }\n}\n\nfunction decodeTupleAt(types: AbiType[], data: Uint8Array, base: number): unknown[] {\n    const out: unknown[] = [];\n    let head = 0;\n    for (const t of types) {\n        if (isDynamic(t)) {\n            ensureRange(data, base + head, WordSize, \"tuple offset slot\");\n            const off = toNumber(data.slice(base + head, base + head + WordSize));\n            if (off < 0 || base + off > data.length) {\n                throw new Error(\n                    `ABI decode: tuple dynamic offset out-of-bounds ` +\n                    `(offset=${off}, base=${base}, data.length=${data.length})`,\n                );\n            }\n            out.push(decodeValue(t, data, base + off));\n            head += WordSize;\n        } else {\n            const size = staticSize(t);\n            ensureRange(data, base + head, size, `tuple static slot (${t.kind})`);\n            out.push(decodeValue(t, data, base + head));\n            head += size;\n        }\n    }\n    return out;\n}\n\nexport function encodeAbiParameters(\n    types: ReadonlyArray<string>,\n    values: ReadonlyArray<unknown>,\n): Hex {\n    assertCheck(types.length === values.length, \"encodeAbiParameters: length mismatch\");\n    return hexlify(encodeTuple(types.map(parseType), values as unknown[]));\n}\n\n// Caller-asserted return shape: the generic T is not validated against `types`\n// at compile time or runtime. Mismatched (types, T) pairs will mistype values.\nexport function decodeAbiParameters<T extends readonly unknown[] = unknown[]>(\n    types: ReadonlyArray<string>,\n    data: BytesLike,\n): T {\n    return decodeTupleAt(types.map(parseType), getBytes(data), 0) as unknown as T;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// EIP-712 typed data (src.ts/hash/typed-data.ts — TypedDataEncoder collapsed)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst hexTrue = toBeHex(BN_1, 32);\nconst hexFalse = toBeHex(BN_0, 32);\n\nfunction hexPadRight(value: BytesLike): Hex {\n    const bytes = getBytes(value);\n    const padOffset = bytes.length % WordSize;\n    if (padOffset) return concat([bytes, Padding.slice(padOffset)]);\n    return hexlify(bytes);\n}\n\nfunction getBaseEncoder(type: string): null | ((value: unknown) => Hex) {\n    {\n        const match = type.match(/^(u?)int(\\d+)$/);\n        if (match) {\n            const signed = match[1] === \"\";\n            const width = parseInt(match[2]);\n            assertArgument(\n                width % 8 === 0 && width !== 0 && width <= 256 && match[2] === String(width),\n                \"invalid numeric width\", \"type\", type,\n            );\n            const boundsUpper = mask(BN_MAX_UINT256, signed ? width - 1 : width);\n            const boundsLower = signed ? (boundsUpper + BN_1) * -1n : BN_0;\n            return (v: unknown) => {\n                const value = getBigInt(v as BigNumberish, \"value\");\n                assertCheck(value >= boundsLower && value <= boundsUpper, `value out-of-bounds for ${type}`);\n                return toBeHex(signed ? toTwos(value, 256) : value, 32);\n            };\n        }\n    }\n    {\n        const match = type.match(/^bytes(\\d+)$/);\n        if (match) {\n            const width = parseInt(match[1]);\n            assertArgument(width !== 0 && width <= 32 && match[1] === String(width), \"invalid bytes width\", \"type\", type);\n            return (v: unknown) => {\n                const bytes = getBytes(v as BytesLike);\n                assertCheck(bytes.length === width, `invalid length for ${type}`);\n                return hexPadRight(v as BytesLike);\n            };\n        }\n    }\n    switch (type) {\n        case \"address\": return (v: unknown) => zeroPadValue(getAddress(v as string), 32);\n        case \"bool\":    return (v: unknown) => (!v ? hexFalse : hexTrue);\n        case \"bytes\":   return (v: unknown) => keccak256(v as BytesLike);\n        case \"string\":  return (v: unknown) => id(v as string);\n    }\n    return null;\n}\n\ntype ArrayResult = { base: string; index?: string; array?: { base: string; prefix: string; count: number } };\n\nfunction splitArray(type: string): ArrayResult {\n    //const match = type.match(/^([^\\[]*)((\\[\\d*\\])*)(\\[(\\d*)\\])$/);\n    const match = type.match(/^([^\\x5b]*)((\\x5b\\d*\\x5d)*)(\\x5b(\\d*)\\x5d)$/);    \n    if (match) {\n        return {\n            base: match[1],\n            index: match[2] + match[4],\n            array: { base: match[1], prefix: match[1] + match[2], count: match[5] ? parseInt(match[5]) : -1 },\n        };\n    }\n    return { base: type };\n}\n\nfunction encodeType(name: string, fields: ReadonlyArray<TypedDataField>): string {\n    return `${name}(${fields.map(({ name, type }) => type + \" \" + name).join(\",\")})`;\n}\n\n/**\n * Build a recursive encoder for `primaryType` that produces the EIP-712\n * `encodeData` for a struct value. Internal `fullTypes` map captures the\n * fully-described type string for each struct (`MyStruct(...)NestedStruct(...)`).\n */\nfunction buildTypedDataState(_types: Record<string, ReadonlyArray<TypedDataField>>) {\n    const fullTypes = new Map<string, string>();\n    const links = new Map<string, Set<string>>();\n    const parents = new Map<string, string[]>();\n    const subtypes = new Map<string, Set<string>>();\n\n    const types: Record<string, TypedDataField[]> = {};\n    for (const type of Object.keys(_types)) {\n        types[type] = _types[type].map(({ name, type }) => {\n            let { base, index } = splitArray(type);\n            if (base === \"int\" && !_types[\"int\"]) base = \"int256\";\n            if (base === \"uint\" && !_types[\"uint\"]) base = \"uint256\";\n            return { name, type: base + (index || \"\") };\n        });\n        links.set(type, new Set());\n        parents.set(type, []);\n        subtypes.set(type, new Set());\n    }\n\n    for (const name in types) {\n        const uniqueNames = new Set<string>();\n        for (const field of types[name]) {\n            assertArgument(!uniqueNames.has(field.name), `duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, \"types\", _types);\n            uniqueNames.add(field.name);\n            const baseType = splitArray(field.type).base;\n            assertArgument(baseType !== name, `circular type reference to ${JSON.stringify(baseType)}`, \"types\", _types);\n            if (getBaseEncoder(baseType)) continue;\n            assertArgument(parents.has(baseType), `unknown type ${JSON.stringify(baseType)}`, \"types\", _types);\n            parents.get(baseType)!.push(name);\n            links.get(name)!.add(baseType);\n        }\n    }\n\n    const primaryTypes = Array.from(parents.keys()).filter((n) => parents.get(n)!.length === 0);\n    assertArgument(primaryTypes.length !== 0, \"missing primary type\", \"types\", _types);\n    assertArgument(primaryTypes.length === 1, `ambiguous primary types or unused types: ${primaryTypes.map((t) => JSON.stringify(t)).join(\", \")}`, \"types\", _types);\n    const primaryType = primaryTypes[0];\n\n    function checkCircular(type: string, found: Set<string>): void {\n        assertArgument(!found.has(type), `circular type reference to ${JSON.stringify(type)}`, \"types\", _types);\n        found.add(type);\n        for (const child of links.get(type)!) {\n            if (!parents.has(child)) continue;\n            checkCircular(child, found);\n            for (const subtype of found) subtypes.get(subtype)!.add(child);\n        }\n        found.delete(type);\n    }\n    checkCircular(primaryType, new Set());\n\n    for (const [name, set] of subtypes) {\n        const st = Array.from(set);\n        st.sort();\n        fullTypes.set(name, encodeType(name, types[name]) + st.map((t) => encodeType(t, types[t])).join(\"\"));\n    }\n\n    const encoderCache = new Map<string, (value: unknown) => Hex>();\n    function getEncoder(type: string): (value: unknown) => Hex {\n        const cached = encoderCache.get(type);\n        if (cached) return cached;\n        const built = buildEncoder(type);\n        encoderCache.set(type, built);\n        return built;\n    }\n    function buildEncoder(type: string): (value: unknown) => Hex {\n        const base = getBaseEncoder(type);\n        if (base) return base;\n        const arr = splitArray(type).array;\n        if (arr) {\n            const subtype = arr.prefix;\n            const subEncoder = getEncoder(subtype);\n            return (value: unknown) => {\n                const arrVal = value as unknown[];\n                assertCheck(arr.count === -1 || arr.count === arrVal.length, `array length mismatch; expected ${arr.count}`);\n                let result = arrVal.map(subEncoder) as Hex[];\n                if (fullTypes.has(subtype)) result = result.map(keccak256);\n                return keccak256(concat(result));\n            };\n        }\n        const fields = types[type];\n        if (fields) {\n            const encodedType = id(fullTypes.get(type)!);\n            return (value: unknown) => {\n                const obj = value as Record<string, unknown>;\n                const values = fields.map(({ name, type }) => {\n                    const r = getEncoder(type)(obj[name]);\n                    return fullTypes.has(type) ? keccak256(r) : r;\n                });\n                values.unshift(encodedType);\n                return concat(values);\n            };\n        }\n        assertArgument(false, `unknown type: ${type}`, \"type\", type);\n    }\n\n    function hashStruct(name: string, value: Record<string, unknown>): Hex {\n        return keccak256(getEncoder(name)(value));\n    }\n\n    return { primaryType, hashStruct };\n}\n\nconst domainFieldTypes: Record<string, string> = {\n    name: \"string\",\n    version: \"string\",\n    chainId: \"uint256\",\n    verifyingContract: \"address\",\n    salt: \"bytes32\",\n};\nconst domainFieldNames = [\"name\", \"version\", \"chainId\", \"verifyingContract\", \"salt\"];\n\nfunction hashDomain(domain: TypedDataDomain): Hex {\n    const domainFields: TypedDataField[] = [];\n    for (const name in domain) {\n        const v = (domain as Record<string, unknown>)[name];\n        if (v == null) continue;\n        const type = domainFieldTypes[name];\n        assertArgument(!!type, `invalid typed-data domain key: ${JSON.stringify(name)}`, \"domain\", domain);\n        domainFields.push({ name, type });\n    }\n    domainFields.sort((a, b) => domainFieldNames.indexOf(a.name) - domainFieldNames.indexOf(b.name));\n    const { hashStruct } = buildTypedDataState({ EIP712Domain: domainFields });\n    return hashStruct(\"EIP712Domain\", domain as Record<string, unknown>);\n}\n\nexport function hashTypedData(\n    domain: TypedDataDomain,\n    types: Record<string, ReadonlyArray<TypedDataField>>,\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    value: Record<string, any>,\n): Hex {\n    // Strip EIP712Domain from user types (ethers does this implicitly).\n    const userTypes: Record<string, ReadonlyArray<TypedDataField>> = {};\n    for (const [k, v] of Object.entries(types)) if (k !== \"EIP712Domain\") userTypes[k] = v;\n    const { primaryType, hashStruct } = buildTypedDataState(userTypes);\n    return keccak256(concat([\"0x1901\", hashDomain(domain), hashStruct(primaryType, value)]));\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Signing (src.ts/crypto/{signing-key,signature}.ts + transaction/address.ts)\n//   Class-free: privateKeyToAddress + signHash + signTypedData functions only.\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction computePublicKey(privateKey: BytesLike): Hex {\n    const bytes = getBytes(privateKey, \"key\");\n    assertCheck(bytes.length === 32, \"invalid private key\");\n    return hexlify(secp256k1.getPublicKey(bytes, false));\n}\n\n// Mirrors `Wallet` constructor (src.ts/wallet/wallet.ts:42-44): accept\n// unprefixed hex at the public signing API while keeping internal `getBytes`\n// strict.\nfunction normalizePrivateKey(key: string): string {\n    return key.startsWith(\"0x\") ? key : \"0x\" + key;\n}\n\nexport function privateKeyToAddress(privateKey: string): Hex {\n    const pub = computePublicKey(normalizePrivateKey(privateKey));\n    return getAddress(keccak256((\"0x\" + pub.substring(4)) as Hex).substring(26));\n}\n\nexport function signHash(privateKey: string, hash: BytesLike): Signature {\n    assertCheck(dataLength(hash) === 32, \"invalid digest length\");\n    const sig = secp256k1.sign(getBytesCopy(hash), getBytesCopy(normalizePrivateKey(privateKey)), { lowS: true });\n    const r = toBeHex(sig.r, 32);\n    const s = toBeHex(sig.s, 32);\n    const yParity = (sig.recovery & 1) as 0 | 1;\n    const v = (27 + yParity) as 27 | 28;\n    return {\n        r,\n        s,\n        v,\n        yParity,\n        serialized: concat([r, s, new Uint8Array([v])]),\n    };\n}\n\nexport function signTypedData(\n    privateKey: string,\n    domain: TypedDataDomain,\n    types: Record<string, ReadonlyArray<TypedDataField>>,\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    message: Record<string, any>,\n): Hex {\n    return signHash(privateKey, hashTypedData(domain, types, message)).serialized;\n}\n","//credits:https://medium.com/with-orus/the-5-commandments-of-clean-error-handling-in-typescript-93a9cbdf1af5\n\nimport type {Dictionary} from \"./types\";\n\n/**\n * General SDK error codes for non-bundler, non-RPC failures.\n *\n * - `NODE_ERROR` — outer code thrown by {@link JsonRpcNode} when an underlying\n *   RPC call fails. The specific JSON-RPC code (when known) appears in\n *   `.cause` as a nested {@link AbstractionKitError} carrying a\n *   {@link JsonRpcErrorCode}.\n * - `BAD_DATA` — reserved for malformed responses (the RPC call returned, but\n *   the data shape was wrong). Not used for RPC failures themselves.\n */\nexport type BasicErrorCode =\n\t| \"UNKNOWN_ERROR\"\n\t| \"TIMEOUT\"\n\t| \"BAD_DATA\"\n\t| \"BUNDLER_ERROR\"\n\t| \"PAYMASTER_ERROR\"\n\t| \"NODE_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| \"PAYMASTER_DEPOSIT_TOO_LOW\"\n\t/** @deprecated no longer produced: -32601 was mismapped to this code; an\n\t * invalid hash surfaces as INVALID_FIELDS (-32602) per the bundler spec\n\t * tests and Voltaire, while -32601 is the standard METHOD_NOT_FOUND. */\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\t| \"TENDERLY_SIMULATION_ERROR\"\n\t| \"TENDERLY_HTTP_ERROR\"\n\t| \"TENDERLY_INVALID_JSON\"\n\t| \"TENDERLY_NETWORK_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\"-32508\": \"PAYMASTER_DEPOSIT_TOO_LOW\",\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\t/**\n\t * The EntryPoint FailedOp revert code parsed from the message (e.g. \"AA21\"),\n\t * when present. EntryPoint codes are contract-defined and stable across\n\t * bundlers, so they are a reliable signal for classifying a failure without\n\t * matching the human-readable message text.\n\t */\n\tpublic readonly aaCode?: string;\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, JSON-serializable context, and AAxx code\n\t */\n\tconstructor(\n\t\tcode: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode,\n\t\tmessage: string,\n\t\toptions: { cause?: Error; errno?: number; context?: Jsonable; aaCode?: string } = {},\n\t) {\n\t\tconst { cause, errno, context, aaCode } = 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\tthis.aaCode = aaCode;\n\t}\n\n\t/**\n\t * Returns a JSON string representation of this error including name, code,\n\t * message, cause, errno, context, and aaCode. Useful in React Native where\n\t * the 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, [\"name\", \"code\", \"message\", \"cause\", \"errno\", \"context\", \"aaCode\"]);\n\t}\n}\n\n/**\n * Parse the EntryPoint FailedOp revert code (e.g. \"AA21\") from a bundler error\n * message, if one is present. Returns the uppercased code or undefined.\n */\nexport function parseAaCode(message: string): string | undefined {\n\t// Word boundaries keep the code from matching digit pairs embedded in hex\n\t// blobs (revert data, hashes, addresses, chain ids) that bundler messages\n\t// routinely carry, e.g. \"0x3aa21f\" or chainId \"0xaa36a7\".\n\treturn message.match(/\\bAA\\d{2}\\b/i)?.[0].toUpperCase();\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(`This value was thrown as is, not through an Error: ${stringified}`);\n\treturn error;\n}\n","/**\n * Core transport abstractions for abstractionkit.\n *\n * The transport layer is the SDK's single, swappable seam for talking to\n * external services (bundler, paymaster, JSON-RPC node). It is intentionally\n * shaped after [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) so that\n * browser wallet providers, WalletConnect, viem clients, and ethers'\n * `Eip1193Provider`-shaped objects can be passed in directly with no wrapper\n * code.\n *\n * The SDK ships exactly one concrete transport ({@link HttpTransport}). All\n * other behaviors — fallback, retry, hedging, logging, circuit breakers — are\n * intentionally left to the user to compose. See `FEATURE_TRANSPORT.md` for\n * the design rationale.\n */\n\n/**\n * EIP-1193-shaped request arguments. Matches the 1193 `provider.request()`\n * args verbatim so 1193 providers drop in as a Transport with zero wrappers.\n */\nexport interface RequestArgs {\n\treadonly method: string;\n\treadonly params?: readonly unknown[] | object;\n}\n\n/**\n * Per-request options. Intentionally narrow at v1; the options-bag shape leaves\n * room to add `timeoutMs`, `headers`, `retryHint`, etc. in future minor\n * releases without further widening of {@link Transport.request}.\n *\n * Cancellation is best-effort: the awaited promise rejects on abort, but the\n * underlying network request may complete. This matches how viem and ethers\n * handle abort propagation.\n */\nexport interface RequestOptions {\n\treadonly signal?: AbortSignal;\n}\n\n/**\n * EIP-1193-shaped error. Throw an object matching this shape from a custom\n * {@link Transport} so the SDK's service classes (Bundler, JsonRpcNode,\n * paymaster) can introspect `code` and translate it into their own domain\n * error vocabulary.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport interface ProviderRpcError extends Error {\n\treadonly code: number;\n\treadonly data?: unknown;\n}\n\n/**\n * Default {@link ProviderRpcError} implementation. {@link BaseRpcTransport}\n * throws this automatically when a JSON-RPC envelope returns\n * `{ error: { code, message, data } }`.\n */\nexport class TransportRpcError extends Error implements ProviderRpcError {\n\treadonly code: number;\n\treadonly data?: unknown;\n\n\t/**\n\t * @param code - Numeric JSON-RPC error code (e.g. -32601 for METHOD_NOT_FOUND)\n\t * @param message - Human-readable error description\n\t * @param data - Optional additional data returned by the RPC server\n\t */\n\tconstructor(code: number, message: string, data?: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"TransportRpcError\";\n\t\tthis.code = code;\n\t\tthis.data = data;\n\t}\n}\n\n/**\n * Minimum capability shared by every backend the SDK can talk to.\n *\n * The single `request` method takes an EIP-1193-shaped `{ method, params }`\n * argument object and returns a `Promise` resolving to the JSON-RPC `result`\n * field. The optional `options` bag carries per-request concerns like\n * cancellation.\n *\n * Implementations should:\n * - Throw a {@link ProviderRpcError}-shaped object on JSON-RPC error responses\n *   so high-level services can translate codes into their domain vocabulary.\n * - Forward `options.signal` to their underlying I/O when supported.\n *\n * @example Implementing a custom transport\n * ```ts\n * const myTransport: Transport = {\n *   async request({ method, params }, options) {\n *     // ... your I/O here, honoring options?.signal if possible\n *     return result;\n *   },\n * };\n * new Bundler(myTransport);\n * ```\n */\nexport interface Transport {\n\trequest<T = unknown>(args: RequestArgs, options?: RequestOptions): Promise<T>;\n}\n\n/**\n * Optional subtype consumers narrow to when they need pub/sub subscriptions\n * (block headers, pending transactions, etc.). The SDK itself never narrows\n * to this — it's provided for downstream code that wants to write\n * `if (isEventfulTransport(t))` without monkey-patching the base contract.\n */\nexport interface EventfulTransport extends Transport {\n\ton(event: string, listener: (...args: unknown[]) => void): void;\n\tremoveListener(event: string, listener: (...args: unknown[]) => void): void;\n}\n\n/**\n * Narrowing helper for {@link EventfulTransport}.\n *\n * @param transport - Any transport to test\n * @returns `true` when both `on` and `removeListener` methods are present\n */\nexport function isEventfulTransport(transport: Transport): transport is EventfulTransport {\n\tconst t = transport as Partial<EventfulTransport>;\n\treturn typeof t.on === \"function\" && typeof t.removeListener === \"function\";\n}\n","import {type RequestArgs, type RequestOptions, type Transport, TransportRpcError,} from \"./Transport\";\n\n/**\n * JSON-RPC 2.0 envelope. The shape sent by {@link BaseRpcTransport.request} to\n * its subclass `send` implementation.\n */\nexport interface JsonRpcEnvelope {\n\treadonly jsonrpc: \"2.0\";\n\treadonly id: number;\n\treadonly method: string;\n\treadonly params?: unknown;\n}\n\n/**\n * JSON-RPC 2.0 response. Either `result` or `error` is set.\n */\ntype JsonRpcResponseEnvelope = {\n\tjsonrpc?: string;\n\tid: number | string | null;\n\tresult?: unknown;\n\t// null is tolerated: some non-strict servers send \"error\": null on success\n\terror?: { code: number; message: string; data?: unknown } | null;\n};\n\n/**\n * Optional convenience base class for users writing new wire-level\n * {@link Transport} backends (WebSocket, IPC, custom HTTP, in-process mock,\n * etc.). Handles JSON-RPC framing, id assignment, bigint serialization, and\n * standard error parsing so subclasses implement only the byte-level\n * `send(envelope, options)` hook.\n *\n * Users who already have a {@link Transport} in hand (window.ethereum, viem\n * `WalletClient`, ethers `Eip1193Provider`-shaped object, etc.) do NOT need\n * this class — they pass their object directly.\n *\n * @example\n * ```ts\n * class WebSocketTransport extends BaseRpcTransport {\n *   protected async send(envelope) {\n *     // serialize envelope to JSON, send over the socket, await response\n *     return JSON.parse(await this.socket.sendAndAwait(JSON.stringify(envelope)));\n *   }\n * }\n * ```\n */\nexport abstract class BaseRpcTransport implements Transport {\n\tprivate nextId = 1;\n\n\t/**\n\t * Build a JSON-RPC envelope, delegate the wire I/O to the subclass's\n\t * {@link BaseRpcTransport.send} method, and parse the response.\n\t *\n\t * @throws {@link TransportRpcError} when the response contains an `error` field\n\t * @throws {@link TransportRpcError} (code -32603) when the response is malformed\n\t */\n\tasync request<T = unknown>(args: RequestArgs, options?: RequestOptions): Promise<T> {\n\t\tconst envelope: JsonRpcEnvelope = {\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tid: this.nextId++,\n\t\t\tmethod: args.method,\n\t\t\tparams: args.params,\n\t\t};\n\t\tconst raw = await this.send(envelope, options);\n\t\treturn BaseRpcTransport.parseResponse<T>(raw);\n\t}\n\n\t/**\n\t * Subclass hook. Send a JSON-RPC envelope and return the parsed response.\n\t *\n\t * Subclasses are responsible for JSON-encoding the envelope (using\n\t * {@link BaseRpcTransport.serializeEnvelope} for correct bigint handling)\n\t * and JSON-decoding the response. They should forward `options.signal` to\n\t * their underlying I/O when supported.\n\t *\n\t * @param envelope - JSON-RPC 2.0 envelope to send\n\t * @param options - Per-request options (cancellation, etc.)\n\t * @returns The decoded JSON-RPC response object\n\t */\n\tprotected abstract send(envelope: JsonRpcEnvelope, options?: RequestOptions): Promise<unknown>;\n\n\t/**\n\t * Serialize a JSON-RPC envelope to a string, converting bigint values to\n\t * `0x`-prefixed hex strings (preserving the historical SDK behavior).\n\t */\n\tprotected static serializeEnvelope(envelope: JsonRpcEnvelope): string {\n\t\treturn JSON.stringify(envelope, (_key, value) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: JSON.stringify replacer signature\n\t\t\ttypeof value === \"bigint\" ? `0x${(value as bigint).toString(16)}` : (value as any),\n\t\t);\n\t}\n\n\t/**\n\t * Parse a decoded JSON-RPC response. Returns the `result` field on success\n\t * or throws a {@link TransportRpcError} on error / malformed response.\n\t */\n\tprivate static parseResponse<T>(raw: unknown): T {\n\t\tif (raw == null || typeof raw !== \"object\") {\n\t\t\tthrow new TransportRpcError(-32603, \"malformed JSON-RPC response\", raw);\n\t\t}\n\t\tconst response = raw as JsonRpcResponseEnvelope;\n\t\t// null check, not key presence — some servers include \"error\": null\n\t\t// on successful responses\n\t\tif (response.error != null) {\n\t\t\t// non-object error payloads (e.g. a bare string) fall through to the\n\t\t\t// malformed-response error below, which carries the raw response\n\t\t\tif (typeof response.error === \"object\") {\n\t\t\t\tconst { code, message, data } = response.error;\n\t\t\t\tthrow new TransportRpcError(code, message, data);\n\t\t\t}\n\t\t\tthrow new TransportRpcError(-32603, \"malformed JSON-RPC response\", raw);\n\t\t}\n\t\tif (\"result\" in response) {\n\t\t\treturn response.result as T;\n\t\t}\n\t\tthrow new TransportRpcError(-32603, \"malformed JSON-RPC response\", raw);\n\t}\n}\n","import {BaseRpcTransport, type JsonRpcEnvelope} from \"./BaseRpcTransport\";\nimport {type RequestOptions, type Transport, TransportRpcError} from \"./Transport\";\n\n/**\n * Construction options for {@link HttpTransport}.\n */\nexport interface HttpTransportOptions {\n\t/**\n\t * Override the global `fetch`. Useful in environments without a global\n\t * fetch (older Node, React Native edge cases) or to inject a polyfill,\n\t * mock (msw, jest), or auth-aware wrapper (`undici`, `node-fetch`).\n\t */\n\tfetch?: typeof globalThis.fetch;\n\t/**\n\t * Static headers added to every request. Merged with the default\n\t * `Content-Type: application/json` (which always wins for the body type).\n\t */\n\theaders?: Record<string, string>;\n}\n\n/**\n * Default concrete {@link Transport}: POSTs JSON-RPC envelopes to an HTTP\n * endpoint. Used by every URL-string call site once a string is normalized\n * into a transport.\n *\n * @example\n * ```ts\n * const t = new HttpTransport(\"https://api.candide.dev/public/v3/11155111\");\n * const chainId = await t.request<string>({ method: \"eth_chainId\" });\n *\n * // With auth headers and a custom fetch:\n * const t2 = new HttpTransport(\"https://...\", {\n *   headers: { Authorization: `Bearer ${token}` },\n *   fetch: myFetchWithRetry,\n * });\n * ```\n */\nexport class HttpTransport extends BaseRpcTransport {\n\t/** Endpoint URL this transport POSTs to. */\n\treadonly url: string;\n\t/** Options passed at construction time. */\n\treadonly options: HttpTransportOptions;\n\n\t/**\n\t * @param url - JSON-RPC endpoint URL (bundler, paymaster, or node)\n\t * @param options - Optional fetch override and static headers\n\t */\n\tconstructor(url: string, options: HttpTransportOptions = {}) {\n\t\tsuper();\n\t\tthis.url = url;\n\t\tthis.options = options;\n\t}\n\n\tprotected async send(envelope: JsonRpcEnvelope, options?: RequestOptions): Promise<unknown> {\n\t\t// Content-Type is fixed by this class (body is always a JSON-RPC\n\t\t// envelope), so it wins against any user-supplied header.\n\t\tconst headers: Record<string, string> = {\n\t\t\t...(this.options.headers ?? {}),\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t};\n\t\tconst body = HttpTransport.serializeEnvelope(envelope);\n\t\tconst fetchImpl = this.options.fetch ?? globalThis.fetch;\n\t\tconst response = await fetchImpl(this.url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders,\n\t\t\tbody,\n\t\t\tredirect: \"follow\",\n\t\t\tsignal: options?.signal,\n\t\t});\n\t\tconst responseText = await response.text();\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(responseText);\n\t\t} catch {\n\t\t\t// non-JSON body (HTML error page, plain text) — the HTTP status is\n\t\t\t// the real diagnostic, so surface it instead of a JSON parse error\n\t\t\tthrow new TransportRpcError(\n\t\t\t\t-32603,\n\t\t\t\t`HTTP ${response.status} ${response.statusText}: response body is not JSON`.trim(),\n\t\t\t\tresponseText.slice(0, 1000),\n\t\t\t);\n\t\t}\n\t\t// Only a properly shaped JSON-RPC error object counts. A non-RPC JSON\n\t\t// error body (e.g. `{\"error\": \"rate limited\"}` from a gateway) must not\n\t\t// mask the HTTP status below.\n\t\tconst rpcError =\n\t\t\ttypeof parsed === \"object\" && parsed != null && \"error\" in parsed\n\t\t\t\t? (parsed as {error: unknown}).error\n\t\t\t\t: null;\n\t\tconst hasRpcError =\n\t\t\ttypeof rpcError === \"object\" &&\n\t\t\trpcError != null &&\n\t\t\ttypeof (rpcError as {code: unknown}).code === \"number\" &&\n\t\t\ttypeof (rpcError as {message: unknown}).message === \"string\";\n\t\tif (!response.ok && !hasRpcError) {\n\t\t\t// On HTTP failure, only a JSON-RPC *error* envelope falls through\n\t\t\t// (parseResponse reports the server's error, e.g. a 429 rate\n\t\t\t// limit). Anything else — including a contradictory \"result\" — is\n\t\t\t// not trusted; the status is the real diagnostic.\n\t\t\tthrow new TransportRpcError(\n\t\t\t\t-32603,\n\t\t\t\t`HTTP ${response.status} ${response.statusText}`.trim(),\n\t\t\t\tparsed,\n\t\t\t);\n\t\t}\n\t\treturn parsed;\n\t}\n}\n\n/**\n * Narrowing helper for {@link HttpTransport}. Useful for code that wants to\n * read the underlying URL — e.g. when serializing a configured Bundler for\n * logging or diagnostics.\n *\n * @example\n * ```ts\n * if (isHttpTransport(bundler.transport)) {\n *   console.log(\"Bundler URL:\", bundler.transport.url);\n * }\n * ```\n */\nexport function isHttpTransport(transport: Transport): transport is HttpTransport {\n\treturn transport instanceof HttpTransport;\n}\n","import type { 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\teip7702Auth: Authorization7702Hex | null;\n}\n\n/**\n * UserOperation for EntryPoint v0.9. Same structure as v0.8.\n */\nexport interface UserOperationV9 extends UserOperationV8 {}\n\n/** Union type for values that can be ABI-encoded as function parameters. */\nexport type AbiInputValue = string | bigint | number | boolean | 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\tsimulation_results?: JsonRpcResult;\n\t/** The error payload on failure */\n\terror?: JsonRpcError;\n};\n\n/** Hex-encoded chain ID returned by eth_chainId. */\nexport type ChainIdResult = string;\n/** Array of EntryPoint addresses returned by eth_supportedEntryPoints. */\nexport type SupportedEntryPointsResult = string[];\n\n/** Result for a single transaction from a Tenderly bundle simulation. */\nexport type SingleTransactionTenderlySimulationResult = {\n\ttransaction: Record<string, unknown>;\n\tsimulation: { id: string } & Record<string, unknown>;\n};\n\n/** Result array from a Tenderly bundle simulation (one entry per transaction). */\nexport type TenderlySimulationResult = SingleTransactionTenderlySimulationResult[];\n\n/** Union of all possible `result` payloads returned by SDK-level JSON-RPC calls. */\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\t| 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 | UserOperationV8 | UserOperationV9;\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/** A single EVM event log, as returned by the node and bundler. */\nexport type Log = {\n\t/** Address of the contract that emitted the log */\n\taddress: string;\n\t/** Indexed topics; topics[0] is the event signature hash */\n\ttopics: string[];\n\t/** Non-indexed event data, ABI-encoded */\n\tdata: string;\n\t/** Block number (hex), when present */\n\tblockNumber?: string;\n\t/** Hash of the block containing the log, when present */\n\tblockHash?: string;\n\t/** Hash of the transaction that produced the log, when present */\n\ttransactionHash?: string;\n\t/** Transaction index in the block (hex), when present */\n\ttransactionIndex?: string;\n\t/** Log index in the block (hex), when present */\n\tlogIndex?: string;\n\t/** Whether the log was removed due to a chain reorg */\n\tremoved?: boolean;\n};\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/** Logs emitted during the bundle transaction */\n\tlogs: Log[];\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/** Logs emitted during this UserOperation's execution */\n\tlogs: Log[];\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/**\n * Quote describing the ERC-20 token payment for a gas-sponsored UserOperation.\n * Populated when a paymaster successfully applies a token-payment flow.\n */\nexport type TokenQuote = {\n\t/** ERC-20 token contract address used to pay gas */\n\ttoken: string;\n\t/**\n\t * Count of token smallest-units equivalent to 1 ETH (10^18 wei). E.g. for\n\t * USDC ($1, 6 decimals) at $3000/ETH this is `3000 * 10^6 = 3e9`.\n\t */\n\texchangeRate: bigint;\n\t/**\n\t * Maximum token cost charged for this UserOperation, in the token's\n\t * smallest unit. Computed as `(exchangeRate * maxGasCostWei) / 10^18` and\n\t * floored to a minimum of `1n` so cheap-gas chains never quote `0n`.\n\t */\n\ttokenCost: bigint;\n};\n\n/**\n * Raw sponsor info shape returned by `pm_getPaymasterData` per ERC-7677\n * (singular `icon`). Normalized into {@link SponsorMetadata} by\n * `applyPaymasterResult`.\n *\n * @see https://eips.ethereum.org/EIPS/eip-7677\n */\nexport type SponsorInfo = {\n\tname: string;\n\ticon?: 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/** Raw sponsor info per ERC-7677 (normalized into {@link SponsorMetadata}) */\n\tsponsor?: SponsorInfo;\n};\n\n/** Paymaster fields returned by pm_getPaymasterData for EntryPoint v0.8 (identical shape to v0.7). */\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/** Raw sponsor info per ERC-7677 (normalized into {@link SponsorMetadata}) */\n\tsponsor?: SponsorInfo;\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\t/** Token name */\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\t/** Sponsor display name */\n\tname: string;\n\t/** Sponsor description */\n\tdescription: string;\n\t/** Sponsor icon URLs */\n\ticons: string[];\n\t/** Paymaster contract address */\n\taddress: string;\n\t/** The event topic emitted on-chain when a UserOperation is sponsored */\n\tsponsoredEventTopic: string;\n\t/** Dummy paymaster data used 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 =\n\tSupportedERC20TokensAndMetadataWithExchangeRate;\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV8WithExchangeRate =\n\tSupportedERC20TokensAndMetadataWithExchangeRate;\n/** @deprecated Use SupportedERC20TokensAndMetadataWithExchangeRate instead */\nexport type SupportedERC20TokensAndMetadataV6WithExchangeRate =\n\tSupportedERC20TokensAndMetadataWithExchangeRate;\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}\n/** Polygon network identifier used to select the correct Polygon Gas Station endpoint. */\nexport enum PolygonChain {\n\tMainnet = \"v2\",\n\tZkMainnet = \"zkevm\",\n\tAmoy = \"amoy\",\n\tCardona = \"cardona\",\n}\n\n/** EIP-1559 gas price pair in Gwei, as returned by Polygon Gas Station. */\nexport type GasPrice = {\n\t/** Priority fee (tip) in Gwei */\n\tmaxPriorityFee: number;\n\t/** Max fee per gas in Gwei */\n\tmaxFee: number;\n};\n\n/** Response shape returned by the Polygon Gas Station API. */\nexport type PolygonGasStationJsonRpcResponse = {\n\tsafeLow: GasPrice;\n\tstandard: GasPrice;\n\tfast: GasPrice;\n\testimatedBaseFee: string;\n\tblockTime: number;\n\tblockNumber: number;\n};\n\n/** Attribution parameters appended to calldata as an on-chain identifier for analytics. */\nexport type OnChainIdentifierParamsType = {\n\t/** Project name */\n\tproject: string;\n\t/** Client platform; defaults to \"Web\" */\n\tplatform?: \"Web\" | \"Mobile\" | \"Safe App\" | \"Widget\";\n\t/** Tool name; defaults to \"abstractionkit\" */\n\ttool?: string;\n\t/** Tool version; defaults to the current abstractionkit version */\n\ttoolVersion?: string;\n};\n\n/** Paymaster fields pre-populated during UserOperation construction for parallel paymaster flows. */\nexport interface ParallelPaymasterInitValues {\n\t/** Paymaster contract address */\n\tpaymaster: string;\n\t/** Paymaster verification gas limit */\n\tpaymasterVerificationGasLimit: bigint;\n\t/** Paymaster post-operation gas limit */\n\tpaymasterPostOpGasLimit: bigint;\n\t/** Paymaster-specific data */\n\tpaymasterData: string;\n}\n","import type {RequestArgs, RequestOptions, Transport} from \"./Transport\";\n\n/**\n * Recursively convert any `bigint` values inside an RPC param to `0x`-prefixed\n * hex strings, descending into arrays and plain objects. Other values pass\n * through unchanged.\n *\n * Required for user-supplied {@link Transport} implementations that don't go\n * through {@link BaseRpcTransport.serializeEnvelope} (EIP-1193 providers, viem\n * clients, etc.) and would otherwise see raw `bigint`s in `params`. Mirrors the\n * normalization done in {@link sendJsonRpcRequest}.\n *\n * @internal\n */\nexport function normalizeRpcValue(value: unknown): unknown {\n\tif (typeof value === \"bigint\") return `0x${value.toString(16)}`;\n\tif (Array.isArray(value)) return value.map(normalizeRpcValue);\n\tif (value !== null && typeof value === \"object\") {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [k, v] of Object.entries(value)) out[k] = normalizeRpcValue(v);\n\t\treturn out;\n\t}\n\treturn value;\n}\n\n/**\n * Wrap a {@link Transport} so every outbound `request` has its `params`\n * normalized (bigints → 0x-hex) before delegation. Idempotent: wrapping an\n * already-normalizing transport is harmless because the second pass sees only\n * strings.\n *\n * Applied once at each service boundary (Bundler, CandidePaymaster,\n * Erc7677Paymaster, JsonRpcNode, …) so normalization is impossible to forget\n * per-method. Required for user-supplied transports (EIP-1193 providers, viem\n * clients, etc.) that don't route through {@link BaseRpcTransport.serializeEnvelope}.\n *\n * @internal\n */\nexport function normalizingTransport(inner: Transport): Transport {\n\treturn {\n\t\trequest<T = unknown>(args: RequestArgs, options?: RequestOptions) {\n\t\t\tconst params =\n\t\t\t\targs.params == null\n\t\t\t\t\t? args.params\n\t\t\t\t\t: (normalizeRpcValue(args.params) as readonly unknown[] | object);\n\t\t\treturn inner.request<T>({method: args.method, params}, options);\n\t\t},\n\t};\n}\n","import {decodeAbiParameters, encodeAbiParameters, getAddress} from \"../ethereUtils\";\nimport {\n\tAbstractionKitError,\n\ttype BasicErrorCode,\n\tensureError,\n\ttype JsonRpcErrorCode,\n\tJsonRpcErrorDict,\n} from \"../errors\";\nimport {GasOption} from \"../types\";\nimport type {DepositInfo} from \"../utils\";\nimport {HttpTransport} from \"./HttpTransport\";\nimport {normalizingTransport} from \"./normalize\";\nimport type {ProviderRpcError, RequestArgs, RequestOptions, Transport} from \"./Transport\";\n\n/**\n * Transaction shape accepted by {@link JsonRpcNode.call}.\n */\nexport type EthCallTransaction = {\n\tfrom?: string;\n\tto: string;\n\tgas?: bigint;\n\tgasPrice?: bigint;\n\tvalue?: bigint;\n\tdata?: string;\n};\n\nconst ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\n/**\n * High-level service class for the JSON-RPC node methods abstractionkit reads\n * from. Intentionally NOT a general Ethereum client — only exposes the\n * methods the SDK actually uses. For broader functionality, drop down to\n * `.transport` and call `request({ method, params })` directly, or use a\n * dedicated library like viem / ethers.\n *\n * Like {@link Bundler} and the paymaster classes, `JsonRpcNode` itself\n * implements {@link Transport} so it can be passed back into any Transport\n * position.\n *\n * @example\n * ```ts\n * const node = new JsonRpcNode(\"https://ethereum-sepolia.publicnode.com\");\n * const id = await node.chainId();\n * const code = await node.getCode(\"0x...\");\n *\n * // Also a Transport — can be slotted in:\n * const bundler = new Bundler(node);  // bundler will speak through this node\n * ```\n */\nexport class JsonRpcNode implements Transport {\n\t/**\n\t * The raw transport the user passed in (or {@link HttpTransport} when a URL\n\t * string was passed). Exposed for introspection — reading `.url`,\n\t * `isHttpTransport(...)` checks, passing it back into another service.\n\t *\n\t * Calls made directly on this field (`node.transport.request(...)`) go\n\t * to the raw transport and skip SDK-level behavior like bigint param\n\t * normalization. For SDK-pipeline behavior, use {@link JsonRpcNode.request}\n\t * or the typed methods.\n\t */\n\treadonly transport: Transport;\n\t/** Normalizing wrapper around {@link transport}, used for every SDK-outbound call. */\n\tprivate readonly outbound: Transport;\n\n\t/**\n\t * @param rpc - Node JSON-RPC endpoint URL, or any {@link Transport}\n\t */\n\tconstructor(rpc: string | Transport) {\n\t\tthis.transport = typeof rpc === \"string\" ? new HttpTransport(rpc) : rpc;\n\t\tthis.outbound = normalizingTransport(this.transport);\n\t}\n\n\t/**\n\t * Normalize any acceptable input into a {@link JsonRpcNode}. Used at every\n\t * public-API widening site (in account / paymaster classes). When the\n\t * input is already a `JsonRpcNode`, the same instance is returned by\n\t * reference, so a user's preconstructed `JsonRpcNode` is never re-wrapped.\n\t *\n\t * @param input - URL string, Transport, or existing JsonRpcNode\n\t */\n\tstatic from(input: string | Transport | JsonRpcNode): JsonRpcNode {\n\t\treturn input instanceof JsonRpcNode ? input : new JsonRpcNode(input);\n\t}\n\n\t/**\n\t * Transport delegate. Routes through the normalizing wrapper so `bigint`\n\t * values in `params` are converted to `0x`-hex before reaching\n\t * user-supplied transports that don't go through\n\t * {@link BaseRpcTransport.serializeEnvelope}. Lets a `JsonRpcNode` itself\n\t * slot into any other transport position.\n\t */\n\trequest<T = unknown>(args: RequestArgs, options?: RequestOptions): Promise<T> {\n\t\treturn this.outbound.request<T>(args, options);\n\t}\n\n\t// ─── Standard JSON-RPC methods ───────────────────────────────────────\n\n\t/**\n\t * `eth_chainId`. Returns the hex-encoded chain id (e.g. `\"0xaa36a7\"` for\n\t * Sepolia).\n\t */\n\tasync chainId(options?: RequestOptions): Promise<string> {\n\t\ttry {\n\t\t\tconst result = await this.outbound.request<unknown>({method: \"eth_chainId\"}, options);\n\t\t\tif (typeof result !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_chainId returned ill formed data\", {\n\t\t\t\t\tcontext: JSON.stringify(result),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthrow translateNodeError(err, \"eth_chainId\");\n\t\t}\n\t}\n\n\t/**\n\t * `eth_blockNumber`. Returns the latest block number as a bigint.\n\t */\n\tasync blockNumber(options?: RequestOptions): Promise<bigint> {\n\t\ttry {\n\t\t\tconst result = await this.outbound.request<unknown>({method: \"eth_blockNumber\"}, options);\n\t\t\tif (typeof result !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_blockNumber returned ill formed data\", {\n\t\t\t\t\tcontext: JSON.stringify(result),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn BigInt(result);\n\t\t} catch (err) {\n\t\t\tthrow translateNodeError(err, \"eth_blockNumber\");\n\t\t}\n\t}\n\n\t/**\n\t * `eth_getCode`. Returns the deployed bytecode at `address` at the given\n\t * block tag (default `\"latest\"`).\n\t */\n\tasync getCode(\n\t\taddress: string,\n\t\tblockTag: string | bigint = \"latest\",\n\t\toptions?: RequestOptions,\n\t): Promise<string> {\n\t\ttry {\n\t\t\tconst result = await this.outbound.request<unknown>(\n\t\t\t\t{method: \"eth_getCode\", params: [address, blockTag]},\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tif (typeof result !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_getCode returned ill formed data\", {\n\t\t\t\t\tcontext: JSON.stringify(result),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthrow translateNodeError(err, \"eth_getCode\");\n\t\t}\n\t}\n\n\t/**\n\t * `eth_getStorageAt`. Returns the 32-byte storage word at `slot` for\n\t * `address` at the given block tag (default `\"latest\"`), as a hex string.\n\t */\n\tasync getStorageAt(\n\t\taddress: string,\n\t\tslot: string,\n\t\tblockTag: string | bigint = \"latest\",\n\t\toptions?: RequestOptions,\n\t): Promise<string> {\n\t\ttry {\n\t\t\tconst result = await this.outbound.request<unknown>(\n\t\t\t\t{method: \"eth_getStorageAt\", params: [address, slot, blockTag]},\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tif (typeof result !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_getStorageAt returned ill formed data\", {\n\t\t\t\t\tcontext: JSON.stringify(result),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthrow translateNodeError(err, \"eth_getStorageAt\");\n\t\t}\n\t}\n\n\t/**\n\t * `eth_call`. Executes a read-only call against `to` and returns the raw\n\t * return data as a hex string. Supports state overrides via the optional\n\t * third parameter.\n\t */\n\tasync call(\n\t\ttx: EthCallTransaction,\n\t\tblockTag: string | bigint = \"latest\",\n\t\tstateOverrides?: object,\n\t\toptions?: RequestOptions,\n\t): Promise<string> {\n\t\tconst params: unknown[] =\n\t\t\tstateOverrides == null ? [tx, blockTag] : [tx, blockTag, stateOverrides];\n\t\ttry {\n\t\t\tconst result = await this.outbound.request<unknown>({method: \"eth_call\", params}, options);\n\t\t\tif (typeof result !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"eth_call returned ill formed data\", {\n\t\t\t\t\tcontext: JSON.stringify(result),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthrow translateNodeError(err, \"eth_call\");\n\t\t}\n\t}\n\n\t/**\n\t * `eth_getTransactionCount`. Returns the transaction count (account nonce\n\t * at the EOA level — not the EntryPoint nonce; see\n\t * {@link JsonRpcNode.getEntryPointNonce}) as a bigint.\n\t */\n\tasync getTransactionCount(\n\t\taddress: string,\n\t\tblockTag: string | bigint = \"latest\",\n\t\toptions?: RequestOptions,\n\t): Promise<bigint> {\n\t\ttry {\n\t\t\tconst result = await this.outbound.request<unknown>(\n\t\t\t\t{method: \"eth_getTransactionCount\", params: [address, blockTag]},\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tif (typeof result !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"eth_getTransactionCount returned ill formed data\",\n\t\t\t\t\t{ context: JSON.stringify(result) },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn BigInt(result);\n\t\t} catch (err) {\n\t\t\tthrow translateNodeError(err, \"eth_getTransactionCount\");\n\t\t}\n\t}\n\n\t// ─── Higher-level helpers ────────────────────────────────────────────\n\n\t/**\n\t * Fetch current gas prices and apply a level multiplier.\n\t *\n\t * Tries `eth_maxPriorityFeePerGas` + `eth_gasPrice` first (EIP-1559),\n\t * falling back to `eth_gasPrice` alone if the priority-fee method is\n\t * unsupported, and finally to a 1 gwei floor multiplied by `gasLevel`.\n\t *\n\t * @param gasLevel - {@link GasOption} multiplier (default: Medium = 1.2x)\n\t * @returns `[maxFeePerGas, maxPriorityFeePerGas]` as bigints\n\t */\n\tasync getFeeData(\n\t\tgasLevel: GasOption = GasOption.Medium,\n\t\toptions?: RequestOptions,\n\t): Promise<[bigint, bigint]> {\n\t\ttry {\n\t\t\tlet gasPrice: bigint | null = null;\n\t\t\tlet maxPriorityFeePerGas: bigint | null = null;\n\n\t\t\ttry {\n\t\t\t\tconst result = await this.outbound.request<unknown>({method: \"eth_gasPrice\"}, options);\n\t\t\t\tif (typeof result !== \"string\") {\n\t\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\t\"eth_gasPrice returned ill formed data\",\n\t\t\t\t\t\t{ context: JSON.stringify(result) },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tgasPrice = BigInt(result);\n\t\t\t} catch (err) {\n\t\t\t\tif (!isMethodNotSupportedError(err)) throw err;\n\t\t\t\t// method unsupported on this node; fall through to gas-price-less branch\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst result = await this.outbound.request<unknown>(\n\t\t\t\t\t{method: \"eth_maxPriorityFeePerGas\"},\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t\tif (typeof result !== \"string\") {\n\t\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\t\"eth_maxPriorityFeePerGas returned ill formed data\",\n\t\t\t\t\t\t{ context: JSON.stringify(result) },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tmaxPriorityFeePerGas = BigInt(result);\n\t\t\t} catch (err) {\n\t\t\t\tif (!isMethodNotSupportedError(err)) throw err;\n\t\t\t\t// older chains don't support this; fall through\n\t\t\t}\n\n\t\t\tlet maxFeePerGas: bigint;\n\t\t\tlet priorityFee: bigint;\n\t\t\tif (gasPrice != null && maxPriorityFeePerGas != null) {\n\t\t\t\tmaxFeePerGas = scaleBigIntByGasLevel(gasPrice, gasLevel);\n\t\t\t\tpriorityFee = scaleBigIntByGasLevel(maxPriorityFeePerGas, gasLevel);\n\t\t\t} else if (gasPrice != null) {\n\t\t\t\tmaxFeePerGas = scaleBigIntByGasLevel(gasPrice, gasLevel);\n\t\t\t\tpriorityFee = maxFeePerGas;\n\t\t\t} else if (maxPriorityFeePerGas != null) {\n\t\t\t\t// eth_gasPrice unsupported but the node served a priority fee —\n\t\t\t\t// use it rather than discarding it for the 1-gwei floor\n\t\t\t\t// (the clamp below raises maxFeePerGas to at least priorityFee)\n\t\t\t\tpriorityFee = scaleBigIntByGasLevel(maxPriorityFeePerGas, gasLevel);\n\t\t\t\tmaxFeePerGas = scaleBigIntByGasLevel(1_000_000_000n, gasLevel);\n\t\t\t} else {\n\t\t\t\tmaxFeePerGas = scaleBigIntByGasLevel(1_000_000_000n, gasLevel);\n\t\t\t\tpriorityFee = maxFeePerGas;\n\t\t\t}\n\n\t\t\tif (maxFeePerGas === 0n) maxFeePerGas = 1n;\n\t\t\tif (priorityFee === 0n) priorityFee = 1n;\n\t\t\tif (priorityFee > maxFeePerGas) maxFeePerGas = priorityFee;\n\n\t\t\treturn [maxFeePerGas, priorityFee];\n\t\t} catch (err) {\n\t\t\tthrow translateNodeError(err, \"getFeeData\");\n\t\t}\n\t}\n\n\t/**\n\t * Check whether an address is EIP-7702-delegated and return the delegatee\n\t * address. EIP-7702-delegated accounts have bytecode of the form\n\t * `0xef0100<20-byte-delegatee>` per the spec.\n\t *\n\t * @returns The checksummed delegatee address, or `null` if not delegated\n\t */\n\tasync getDelegatedAddress(\n\t\taccountAddress: string,\n\t\toptions?: RequestOptions,\n\t): Promise<string | null> {\n\t\tconst code = (await this.getCode(accountAddress, \"latest\", options)).toLowerCase();\n\t\tif (code.length === 48 && code.startsWith(\"0xef0100\")) {\n\t\t\treturn getAddress(`0x${code.slice(8)}`);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Fetch the smart account's nonce from the EntryPoint contract via\n\t * `eth_call`. This is the 4337 nonce (an EntryPoint-managed counter with\n\t * 192-bit parallel keys), not the EOA `eth_getTransactionCount`.\n\t *\n\t * @param entryPoint - EntryPoint contract address\n\t * @param account - Smart account address\n\t * @param key - Nonce key as a `bigint` (default `0n`). Different keys allow\n\t *   parallel nonce channels. `bigint` so the full `uint192` range is\n\t *   representable (a JS `number` would cap at 2^53−1).\n\t */\n\tasync getEntryPointNonce(\n\t\tentryPoint: string,\n\t\taccount: string,\n\t\tkey: bigint = 0n,\n\t\toptions?: RequestOptions,\n\t): Promise<bigint> {\n\t\t// getNonce(address,uint192) selector\n\t\tconst getNonceSelector = \"0x35567e1a\";\n\t\tconst params = encodeAbiParameters([\"address\", \"uint192\"], [account, key]);\n\t\tconst data = getNonceSelector + params.slice(2);\n\n\t\tconst callResult = await this.call(\n\t\t\t{ from: ZERO_ADDRESS, to: entryPoint, data },\n\t\t\t\"latest\",\n\t\t\tundefined,\n\t\t\toptions,\n\t\t);\n\t\ttry {\n\t\t\treturn BigInt(callResult);\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getNonce returned ill formed data\", {\n\t\t\t\tcause: ensureError(err),\n\t\t\t\tcontext: callResult,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the EntryPoint deposit balance for an address.\n\t *\n\t * @returns The deposit balance in wei as a bigint\n\t */\n\tasync getEntryPointDeposit(\n\t\taddress: string,\n\t\tentryPoint: string,\n\t\toptions?: RequestOptions,\n\t): Promise<bigint> {\n\t\tconst info = await this.getEntryPointDepositInfo(address, entryPoint, options);\n\t\treturn info.deposit;\n\t}\n\n\t/**\n\t * Get the full {@link DepositInfo} for an address from the EntryPoint\n\t * contract.\n\t */\n\tasync getEntryPointDepositInfo(\n\t\taddress: string,\n\t\tentryPoint: string,\n\t\toptions?: RequestOptions,\n\t): Promise<DepositInfo> {\n\t\t// getDepositInfo(address) selector\n\t\tconst getDepositInfoSelector = \"0x5287ce12\";\n\t\tconst params = encodeAbiParameters([\"address\"], [address]);\n\t\tconst data = getDepositInfoSelector + params.slice(2);\n\n\t\tconst callResult = await this.call(\n\t\t\t{ from: ZERO_ADDRESS, to: entryPoint, data },\n\t\t\t\"latest\",\n\t\t\tundefined,\n\t\t\toptions,\n\t\t);\n\t\ttry {\n\t\t\tconst decoded = decodeAbiParameters<[bigint, boolean, bigint, bigint, bigint]>(\n\t\t\t\t[\"uint256\", \"bool\", \"uint112\", \"uint32\", \"uint48\"],\n\t\t\t\tcallResult,\n\t\t\t);\n\t\t\tif (decoded.length !== 5) {\n\t\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getDepositInfo returned ill formed data\", {\n\t\t\t\t\tcontext: JSON.stringify(decoded),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdeposit: BigInt(decoded[0]),\n\t\t\t\tstaked: Boolean(decoded[1]),\n\t\t\t\tstake: BigInt(decoded[2]),\n\t\t\t\tunstakeDelaySec: BigInt(decoded[3]),\n\t\t\t\twithdrawTime: BigInt(decoded[4]),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tif (err instanceof AbstractionKitError) throw err;\n\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getDepositInfo returned ill formed data\", {\n\t\t\t\tcause: ensureError(err),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Apply a fractional `gasLevel` multiplier (e.g. 1.2 = 120%) to a `bigint`\n * gas price without going through JS number precision.\n *\n * The naive `BigInt(Math.ceil(Number(value) * gasLevel))` truncates any\n * `value` above `Number.MAX_SAFE_INTEGER` (2^53 − 1 ≈ 9.0 × 10^15 wei),\n * which is well within the range a chain can legitimately report\n * (especially on testnets, fork networks, or anomalous mainnet spikes).\n *\n * Approach: scale the multiplier into integer space (three-decimal precision\n * — sufficient for `GasOption` and any reasonable custom value), do the\n * multiplication in `BigInt`, then ceiling-divide back down. Preserves the\n * original `Math.ceil(...)` rounding behavior bit-for-bit on small values.\n *\n * @internal\n */\nfunction scaleBigIntByGasLevel(value: bigint, gasLevel: number): bigint {\n\tconst scale = 1000n;\n\tconst scaledLevel = BigInt(Math.round(gasLevel * Number(scale)));\n\treturn (value * scaledLevel + scale - 1n) / scale;\n}\n\n/**\n * Detect whether an error indicates the JSON-RPC method itself is not\n * implemented by the node. Used by {@link JsonRpcNode.getFeeData} to fall\n * back gracefully on chains that don't expose EIP-1559 fee methods, while\n * still surfacing transport, auth, and parse errors to the caller.\n *\n * @internal\n */\nfunction isMethodNotSupportedError(err: unknown): boolean {\n\tconst code = (err as ProviderRpcError | undefined)?.code;\n\tif (code === -32601) return true;\n\tconst message = (err as Error | undefined)?.message?.toLowerCase() ?? \"\";\n\treturn (\n\t\tmessage.includes(\"method not found\") ||\n\t\tmessage.includes(\"not supported\") ||\n\t\tmessage.includes(\"unsupported\")\n\t);\n}\n\n/**\n * Translate a transport-level error (or already-wrapped {@link AbstractionKitError})\n * into the `NODE_ERROR` outer / specific inner shape used by {@link JsonRpcNode}.\n *\n * - `AbstractionKitError` passes through unchanged (already domain-translated).\n * - {@link ProviderRpcError} with a known JSON-RPC code → inner code from\n *   {@link JsonRpcErrorDict}.\n * - Anything else → inner `UNKNOWN_ERROR`.\n *\n * @internal\n */\nfunction translateNodeError(err: unknown, method: string): AbstractionKitError {\n\tif (err instanceof AbstractionKitError) return err;\n\tconst code = (err as ProviderRpcError | undefined)?.code;\n\tconst codeString = code != null ? String(code) : \"\";\n\tconst innerCode: JsonRpcErrorCode | BasicErrorCode =\n\t\tcodeString in JsonRpcErrorDict ? JsonRpcErrorDict[codeString] : \"UNKNOWN_ERROR\";\n\tconst error = ensureError(err);\n\treturn new AbstractionKitError(\"NODE_ERROR\", `node ${method} rpc call failed`, {\n\t\tcause: new AbstractionKitError(innerCode, error.message, {\n\t\t\terrno: code,\n\t\t}),\n\t\terrno: code,\n\t});\n}\n","import {\n\tAbstractionKitError,\n\ttype BasicErrorCode,\n\ttype BundlerErrorCode,\n\tBundlerErrorCodeDict,\n\tensureError,\n\ttype JsonRpcErrorCode,\n\tparseAaCode,\n} from \"./errors\";\nimport {\n\tHttpTransport,\n\tnormalizingTransport,\n\ttype ProviderRpcError,\n\ttype RequestArgs,\n\ttype RequestOptions,\n\ttype Transport,\n} from \"./transport\";\nimport type {\n\tGasEstimationResult,\n\tJsonRpcResult,\n\tStateOverrideSet,\n\tUserOperationByHashResult,\n\tUserOperationReceipt,\n\tUserOperationReceiptResult,\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n\tUserOperationV9,\n} from \"./types\";\n\n/**\n * JSON-RPC client for an ERC-4337 bundler.\n *\n * Accepts either a URL string (wrapped automatically in {@link HttpTransport})\n * or any {@link Transport} — including a viem client, an EIP-1193 wallet\n * provider, an in-process mock, or a user-composed fallback/retry transport.\n *\n * The class itself implements {@link Transport}, so a `Bundler` can be passed\n * back into any other Transport position.\n *\n * Candide bundler endpoints:\n * - `https://api.candide.dev/api/v3/{chainId}/{apiKey}` (authenticated)\n * - `https://api.candide.dev/public/v3/{chainId}` (public)\n *\n * @example URL string (most common)\n * ```ts\n * const bundler = new Bundler(\"https://api.candide.dev/public/v3/11155111\");\n * const receipt = await bundler.getUserOperationReceipt(userOpHash);\n * ```\n *\n * @example Custom transport (composed retry behavior)\n * ```ts\n * const retryingTransport: Transport = {\n *   async request(args, options) {\n *     for (let i = 0; i < 3; i++) {\n *       try { return await inner.request(args, options); }\n *       catch (e) { if (i === 2) throw e; await sleep(2 ** i * 100); }\n *     }\n *   },\n * };\n * const bundler = new Bundler(retryingTransport);\n * ```\n */\nexport class Bundler implements Transport {\n\t/**\n\t * The raw transport the user passed in (or {@link HttpTransport} when a URL\n\t * string was passed). Exposed for introspection — reading `.url`,\n\t * `isHttpTransport(...)` checks, passing it back into another service.\n\t *\n\t * Calls made directly on this field (`bundler.transport.request(...)`) go\n\t * to the raw transport and skip SDK-level behavior like bigint param\n\t * normalization. For SDK-pipeline behavior, use {@link Bundler.request} or\n\t * the typed methods.\n\t */\n\treadonly transport: Transport;\n\t/** Normalizing wrapper around {@link transport}, used for every SDK-outbound call. */\n\tprivate readonly outbound: Transport;\n\n\t/**\n\t * @param rpc - Bundler JSON-RPC endpoint URL, or any {@link Transport}.\n\t */\n\tconstructor(rpc: string | Transport) {\n\t\tthis.transport = typeof rpc === \"string\" ? new HttpTransport(rpc) : rpc;\n\t\tthis.outbound = normalizingTransport(this.transport);\n\t}\n\n\t/**\n\t * Normalize any acceptable input into a `Bundler`. When the input is\n\t * already a `Bundler` instance, it is returned by reference (so a user's\n\t * pre-constructed Bundler is never re-wrapped and its transport is\n\t * reused for follow-up calls like {@link SendUseroperationResponse.included}).\n\t *\n\t * @param input - URL string, Transport, or existing Bundler\n\t */\n\tstatic from(input: string | Transport | Bundler): Bundler {\n\t\treturn input instanceof Bundler ? input : new Bundler(input);\n\t}\n\n\t/**\n\t * Transport delegate. Forwards directly to the underlying\n\t * {@link Transport.request}. Lets a `Bundler` itself slot into any other\n\t * transport position.\n\t */\n\trequest<T = unknown>(args: RequestArgs, options?: RequestOptions): Promise<T> {\n\t\treturn this.outbound.request<T>(args, options);\n\t}\n\n\t/**\n\t * Get the bundler's chain ID.\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 this.outbound.request<unknown>({ method: \"eth_chainId\" });\n\t\t\tif (typeof chainId !== \"string\") {\n\t\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"bundler eth_chainId rpc call failed\");\n\t\t\t}\n\t\t\treturn chainId;\n\t\t} catch (err) {\n\t\t\tthrow translateBundlerError(err, \"eth_chainId\");\n\t\t}\n\t}\n\n\t/**\n\t * Get 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 result = await this.outbound.request<string[]>({\n\t\t\t\tmethod: \"eth_supportedEntryPoints\",\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthrow translateBundlerError(err, \"eth_supportedEntryPoints\");\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\tconst params: unknown[] =\n\t\t\t\tstate_override_set == null\n\t\t\t\t\t? [useroperation, entrypointAddress]\n\t\t\t\t\t: [useroperation, entrypointAddress, state_override_set];\n\t\t\tconst jsonRpcResult = await this.outbound.request<JsonRpcResult>({\n\t\t\t\tmethod: \"eth_estimateUserOperationGas\",\n\t\t\t\tparams,\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// Non-spec extension: some bundlers return paymaster gas fields\n\t\t\t// alongside the standard ones. Forward them when present.\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(res.paymasterPostOpGasLimit);\n\t\t\t}\n\n\t\t\treturn gasEstimationResult;\n\t\t} catch (err) {\n\t\t\tthrow translateBundlerError(err, \"eth_estimateUserOperationGas\");\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 this.outbound.request<string>({\n\t\t\t\tmethod: \"eth_sendUserOperation\",\n\t\t\t\tparams: [useroperation, entrypointAddress],\n\t\t\t});\n\t\t\treturn jsonRpcResult;\n\t\t} catch (err) {\n\t\t\tthrow translateBundlerError(err, \"eth_sendUserOperation\");\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 on-chain\n\t */\n\tasync getUserOperationReceipt(useroperationhash: string): Promise<UserOperationReceiptResult> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await this.outbound.request<UserOperationReceiptResult | null>({\n\t\t\t\tmethod: \"eth_getUserOperationReceipt\",\n\t\t\t\tparams: [useroperationhash],\n\t\t\t});\n\t\t\tif (jsonRpcResult == null) return null;\n\t\t\tconst res = jsonRpcResult;\n\n\t\t\tconst userOperationReceipt: UserOperationReceipt = {\n\t\t\t\t...res.receipt,\n\t\t\t\tblockNumber: BigInt(res.receipt.blockNumber),\n\t\t\t\tcumulativeGasUsed: BigInt(res.receipt.cumulativeGasUsed),\n\t\t\t\tgasUsed: BigInt(res.receipt.gasUsed),\n\t\t\t\ttransactionIndex: BigInt(res.receipt.transactionIndex),\n\t\t\t\teffectiveGasPrice:\n\t\t\t\t\tres.receipt.effectiveGasPrice == null\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: BigInt(res.receipt.effectiveGasPrice),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\t...res,\n\t\t\t\tnonce: BigInt(res.nonce),\n\t\t\t\tactualGasCost: BigInt(res.actualGasCost),\n\t\t\t\tactualGasUsed: BigInt(res.actualGasUsed),\n\t\t\t\treceipt: userOperationReceipt,\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tthrow translateBundlerError(err, \"eth_getUserOperationReceipt\", { useroperationhash });\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(useroperationhash: string): Promise<UserOperationByHashResult> {\n\t\ttry {\n\t\t\tconst jsonRpcResult = await this.outbound.request<UserOperationByHashResult | null>({\n\t\t\t\tmethod: \"eth_getUserOperationByHash\",\n\t\t\t\tparams: [useroperationhash],\n\t\t\t});\n\t\t\tif (jsonRpcResult == null) return null;\n\t\t\t// the wire format carries hex strings; convert the numeric fields\n\t\t\t// to the bigints the declared type promises\n\t\t\tconst wireOp = jsonRpcResult.userOperation as unknown as Record<string, unknown>;\n\t\t\tconst userOperation = { ...wireOp };\n\t\t\tfor (const field of [\n\t\t\t\t\"nonce\",\n\t\t\t\t\"callGasLimit\",\n\t\t\t\t\"verificationGasLimit\",\n\t\t\t\t\"preVerificationGas\",\n\t\t\t\t\"maxFeePerGas\",\n\t\t\t\t\"maxPriorityFeePerGas\",\n\t\t\t\t\"paymasterVerificationGasLimit\",\n\t\t\t\t\"paymasterPostOpGasLimit\",\n\t\t\t]) {\n\t\t\t\tif (wireOp[field] != null) {\n\t\t\t\t\tuserOperation[field] = BigInt(wireOp[field] as string | bigint);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...jsonRpcResult,\n\t\t\t\tuserOperation: userOperation as unknown as\n\t\t\t\t\t| UserOperationV6\n\t\t\t\t\t| UserOperationV7\n\t\t\t\t\t| UserOperationV8\n\t\t\t\t\t| UserOperationV9,\n\t\t\t\tblockNumber: jsonRpcResult.blockNumber == null ? null : BigInt(jsonRpcResult.blockNumber),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tthrow translateBundlerError(err, \"eth_getUserOperationByHash\", { useroperationhash });\n\t\t}\n\t}\n}\n\n/**\n * Translate a transport-level error (or already-wrapped\n * {@link AbstractionKitError}) into the `BUNDLER_ERROR` outer / specific\n * 4337-code inner shape used by {@link Bundler}.\n *\n * - `AbstractionKitError` passes through unchanged (already domain-translated).\n * - {@link ProviderRpcError} with a known 4337 code → inner code from\n *   {@link BundlerErrorCodeDict}; -32601 is the standard JSON-RPC\n *   METHOD_NOT_FOUND (neither ERC-7769 nor bundler implementations assign\n *   it any 4337-specific meaning — an invalid hash arrives as -32602).\n * - Anything else → inner `UNKNOWN_ERROR`.\n *\n * @internal\n */\nfunction translateBundlerError(\n\terr: unknown,\n\tmethod: string,\n\tcontext?: { readonly useroperationhash?: string },\n): AbstractionKitError {\n\tif (err instanceof AbstractionKitError) {\n\t\t// BC: existing callers see outer BUNDLER_ERROR even when the inner\n\t\t// translation has already happened (e.g. via JsonRpcNode reuse, future\n\t\t// proofing). Re-wrap if not already a BUNDLER_ERROR.\n\t\tif (err.code === \"BUNDLER_ERROR\") return err;\n\t\t// Upstream wrappers (JsonRpcNode, transport layers) may have set the\n\t\t// message but not the aaCode. Fall back to parsing it out of the\n\t\t// message so the AAxx code survives the re-wrap.\n\t\tconst aaCode = err.aaCode ?? parseAaCode(err.message);\n\t\treturn new AbstractionKitError(\"BUNDLER_ERROR\", `bundler ${method} rpc call failed`, {\n\t\t\tcause: err,\n\t\t\terrno: err.errno,\n\t\t\tcontext,\n\t\t\taaCode,\n\t\t});\n\t}\n\tconst code = (err as ProviderRpcError | undefined)?.code;\n\tconst codeString = code != null ? String(code) : \"\";\n\tlet innerCode: BundlerErrorCode | BasicErrorCode | JsonRpcErrorCode =\n\t\tcodeString in BundlerErrorCodeDict ? BundlerErrorCodeDict[codeString] : \"UNKNOWN_ERROR\";\n\t// Standard JSON-RPC codes without 4337 semantics keep their standard names.\n\tif (codeString === \"-32601\") {\n\t\tinnerCode = \"METHOD_NOT_FOUND\";\n\t} else if (codeString === \"-32603\") {\n\t\tinnerCode = \"INTERNAL_ERROR\";\n\t}\n\tconst error = ensureError(err);\n\t// The EntryPoint AAxx code lives only inside the message text. Parse it once\n\t// here so callers can branch on a stable code instead of matching the message.\n\tconst aaCode = parseAaCode(error.message);\n\treturn new AbstractionKitError(\"BUNDLER_ERROR\", `bundler ${method} rpc call failed`, {\n\t\tcause: new AbstractionKitError(innerCode, error.message, { errno: code, aaCode }),\n\t\terrno: code,\n\t\tcontext,\n\t\taaCode,\n\t});\n}\n","import type { 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/**\n * Safe fallback-handler storage slot: keccak256(\"fallback_manager.handler.address\").\n * The address of a Safe's fallback handler (which is the 4337 module) is stored\n * in the lower 20 bytes of the word at this slot.\n */\nexport const SAFE_FALLBACK_HANDLER_STORAGE_SLOT =\n\t\"0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5\";\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: \"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: \"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\n/** EIP-712 primary type string used when signing Safe UserOperations. */\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\n/** EIP-712 primary type string used when signing multi-chain Safe operations. */\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: [{ type: \"bytes32\", name: \"merkleTreeRoot\" }],\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 =\n\t\"0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00\";\n\n/** Candide Calibur singleton v0.1.0 (EntryPoint v0.9, unaudited) */\nexport const CALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS =\n\t\"0x71032285A847c4311Eb7ec2E7A636aB94A9805Aa\";\n","import { AbstractionKitError } from \"../errors\";\nimport type { ExternalSigner, SigningScheme, TypedData } from \"./types\";\n\n/**\n * Pick the best mutually-supported signing scheme for one signer against an\n * account's accepted schemes. Later in the `accepted` array = lower preference;\n * the account ranks by preference.\n *\n * Throws a detailed {@link AbstractionKitError} if no scheme overlaps,\n * citing the signer's address, what the account accepts, and what the\n * signer can do.\n */\nexport function pickScheme<C>(\n\tsigner: ExternalSigner<C>,\n\taccepted: readonly SigningScheme[],\n\tcontext: { accountName: string; signerIndex: number },\n): SigningScheme {\n\t// Typeof-check (not truthiness) so malformed signers like\n\t// `{ signHash: true }` from JS callers bypassing types get a clear\n\t// AbstractionKitError here instead of a raw TypeError at the call site.\n\tconst signerCan: SigningScheme[] = [];\n\tif (typeof signer.signTypedData === \"function\") signerCan.push(\"typedData\");\n\tif (typeof signer.signHash === \"function\") signerCan.push(\"hash\");\n\n\tfor (const scheme of accepted) {\n\t\tif (signerCan.includes(scheme)) return scheme;\n\t}\n\n\tthrow new AbstractionKitError(\n\t\t\"BAD_DATA\",\n\t\tbuildMismatchMessage({\n\t\t\taccountName: context.accountName,\n\t\t\tsignerIndex: context.signerIndex,\n\t\t\tsignerAddress: signer.address,\n\t\t\taccepted,\n\t\t\tsignerCan,\n\t\t}),\n\t);\n}\n\nfunction buildMismatchMessage(params: {\n\taccountName: string;\n\tsignerIndex: number;\n\tsignerAddress: string;\n\taccepted: readonly SigningScheme[];\n\tsignerCan: SigningScheme[];\n}): string {\n\tconst { accountName, signerIndex, signerAddress, accepted, signerCan } = params;\n\tconst canStr = signerCan.length > 0 ? signerCan.join(\", \") : \"none\";\n\treturn (\n\t\t`No compatible signing scheme for signer[${signerIndex}] ${signerAddress}. ` +\n\t\t`${accountName} accepts: [${accepted.join(\", \")}]; signer provides: [${canStr}]. ` +\n\t\t(signerCan.length === 0\n\t\t\t? \"ExternalSigner must implement at least one of `signHash` or `signTypedData`. \"\n\t\t\t: \"\") +\n\t\t\"Hint: `fromViem` / `fromEthersWallet` give both; \" +\n\t\t\"`fromViemWalletClient` gives only `typedData` (use Safe for JSON-RPC wallets).\"\n\t);\n}\n\n/**\n * Invoke a signer for one scheme. Keeps the dispatch in one place so the\n * account-side code stays linear. `typedData` is optional: accounts that\n * only accept the `\"hash\"` scheme can pass just `hash`.\n *\n * `context` is always forwarded to the signer so power-user implementations\n * can inspect the userOp.\n */\nexport async function invokeSigner<C>(\n\tsigner: ExternalSigner<C>,\n\tscheme: SigningScheme,\n\tpayload: {\n\t\thash: `0x${string}`;\n\t\ttypedData?: TypedData;\n\t\tcontext: C;\n\t},\n): Promise<`0x${string}`> {\n\tif (scheme === \"typedData\") {\n\t\tif (typeof signer.signTypedData !== \"function\") {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`signer ${signer.address} is missing signTypedData`,\n\t\t\t);\n\t\t}\n\t\tif (!payload.typedData) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`scheme \"typedData\" selected but no typedData payload provided`,\n\t\t\t);\n\t\t}\n\t\treturn signer.signTypedData(payload.typedData, payload.context);\n\t}\n\tif (typeof signer.signHash !== \"function\") {\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", `signer ${signer.address} is missing signHash`);\n\t}\n\treturn signer.signHash(payload.hash, payload.context);\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\tencodeRlp,\n\tgetBytes,\n\tkeccak256,\n\tsignHash as ecdsaSignHash,\n\ttoBeArray,\n} from \"./ethereUtils\";\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\t/** The chain ID the authorization is valid for. */\n\tchainId: bigint;\n\t/** The contract address to delegate code from. */\n\taddress: string;\n\t/** The EOA's nonce at the time of signing. */\n\tnonce: bigint;\n\t/** The parity of the signature's y-coordinate (0 or 1). */\n\tyParity: 0 | 1;\n\t/** The r component of the ECDSA signature. */\n\tr: bigint;\n\t/** The s component of the ECDSA signature. */\n\ts: 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\t/** The chain ID as a hex string. */\n\tchainId: string;\n\t/** The contract address to delegate code from. */\n\taddress: string;\n\t/** The EOA's nonce as a hex string. */\n\tnonce: string;\n\t/** The parity of the signature's y-coordinate as a hex string. */\n\tyParity: string;\n\t/** The r component of the ECDSA signature as a hex string. */\n\tr: string;\n\t/** The s component of the ECDSA signature as a hex string. */\n\ts: 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\tchainId: bigint,\n\tnonce: bigint,\n\tgas_price: bigint,\n\tgas_limit: bigint,\n\tdestination: string,\n\tvalue: bigint,\n\tdata: string,\n\teoaPrivateKey: string,\n): string {\n\tif (chainId >= 2 ** 64) {\n\t\tthrow new RangeError(\"Invalid chainId.\");\n\t}\n\n\tif (nonce >= 2 ** 64) {\n\t\tthrow new RangeError(\"Invalid nonce.\");\n\t}\n\n\tif (destination.length !== 42) {\n\t\tthrow new RangeError(\"Invalid destination.\");\n\t}\n\n\tlet payload = [\n\t\tbigintToBytes(nonce),\n\t\tbigintToBytes(gas_price),\n\t\tbigintToBytes(gas_limit),\n\t\tdestination,\n\t\tbigintToBytes(value),\n\t\tdata,\n\t\tbigintToBytes(chainId),\n\t\tbigintToBytes(0n),\n\t\tbigintToBytes(0n),\n\t];\n\n\tconst txHash = keccak256(encodeRlp(payload));\n\n\tconst signature = ecdsaSignHash(eoaPrivateKey, txHash);\n\n\tpayload = [\n\t\tbigintToBytes(nonce),\n\t\tbigintToBytes(gas_price),\n\t\tbigintToBytes(gas_limit),\n\t\tdestination,\n\t\tbigintToBytes(value),\n\t\tdata,\n\t\tbigintToBytes(BigInt(signature.yParity) + chainId * 2n + 35n),\n\t\t// r and s must be minimal big-endian integers — nodes reject RLP\n\t\t// scalars with leading zero bytes as non-canonical\n\t\tbigintToBytes(BigInt(signature.r)),\n\t\tbigintToBytes(BigInt(signature.s)),\n\t];\n\tconst transactionPayload = encodeRlp(payload);\n\treturn 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 * The callback signs the auth hash directly — no EIP-191 / EIP-712 / message\n * prefix. The returned hex string must be one of:\n *   - **Standard 65-byte signature** (130 hex chars after `0x`): `r (32) || s (32) || v (1)`,\n *     where `v` is `0`, `1`, `27`, or `28`. This is the shape every common\n *     library produces (e.g., ethers v6: `Signature.from(wallet.signingKey.sign(hash)).serialized`;\n *     viem `LocalAccount.sign({ hash })`).\n *   - **EIP-2098 compact 64-byte signature** (128 hex chars after `0x`): `r (32) || yParityAndS (32)`,\n *     where the high bit of the second 32-byte word encodes `yParity`.\n *\n * The `0x` prefix is optional. Other lengths or out-of-range `v` values throw.\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 returning a 65-byte standard or 64-byte EIP-2098 hex signature.\n * @returns The signed authorization with all numeric values as hex strings.\n */\nexport function createAndSignEip7702DelegationAuthorization(\n\tchainId: bigint,\n\taddress: string,\n\tnonce: bigint,\n\tsigner: string,\n): Authorization7702Hex;\nexport function createAndSignEip7702DelegationAuthorization(\n\tchainId: bigint,\n\taddress: string,\n\tnonce: bigint,\n\tsigner: (hash: string) => Promise<string>,\n): Promise<Authorization7702Hex>;\nexport function createAndSignEip7702DelegationAuthorization(\n\tchainId: bigint,\n\taddress: string,\n\tnonce: bigint,\n\tsigner: string | ((hash: string) => Promise<string>),\n): Authorization7702Hex | Promise<Authorization7702Hex> {\n\tconst authHash = createEip7702DelegationAuthorizationHash(chainId, address, nonce);\n\n\tif (typeof signer === \"string\") {\n\t\tconst signature = signHash(authHash, signer);\n\t\treturn {\n\t\t\tchainId: bigintToHex(chainId),\n\t\t\taddress,\n\t\t\tnonce: bigintToHex(nonce),\n\t\t\tyParity: bigintToHex(BigInt(signature.yParity)),\n\t\t\tr: bigintToHex(signature.r),\n\t\t\ts: bigintToHex(signature.s),\n\t\t};\n\t}\n\n\treturn signer(authHash).then((rawSig) => {\n\t\tconst sig = parseRawSignature(rawSig);\n\t\treturn {\n\t\t\tchainId: bigintToHex(chainId),\n\t\t\taddress,\n\t\t\tnonce: bigintToHex(nonce),\n\t\t\tyParity: bigintToHex(BigInt(sig.yParity)),\n\t\t\tr: bigintToHex(sig.r),\n\t\t\ts: bigintToHex(sig.s),\n\t\t};\n\t});\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\tchainId: bigint,\n\tnonce: bigint,\n\teoaPrivateKey: string,\n): Authorization7702Hex {\n\tconst ZeroAddress = \"0x0000000000000000000000000000000000000000\";\n\treturn createAndSignEip7702DelegationAuthorization(chainId, ZeroAddress, nonce, eoaPrivateKey);\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\tchainId: bigint,\n\taddress: string,\n\tnonce: bigint,\n): string {\n\tconst auth_arr = [bigintToBytes(chainId), address, bigintToBytes(nonce)];\n\tconst encoded_auth = encodeRlp(auth_arr);\n\tconst MAGIC = \"0x05\";\n\treturn 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\tauthHash: string,\n\teoaPrivateKey: string,\n): { yParity: 0 | 1; r: bigint; s: bigint } {\n\tconst signature = ecdsaSignHash(eoaPrivateKey, authHash);\n\treturn {\n\t\tyParity: signature.yParity,\n\t\tr: BigInt(signature.r),\n\t\ts: BigInt(signature.s),\n\t};\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\tchainId: bigint,\n\tnonce: bigint,\n\tmax_priority_fee_per_gas: bigint,\n\tmax_fee_per_gas: bigint,\n\tgas_limit: bigint,\n\tdestination: string,\n\tvalue: bigint,\n\tdata: string,\n\taccess_list: [string, string[]][],\n\tauthorization_list: Authorization7702[],\n\teoaPrivateKey: string,\n): string {\n\tconst txHash = createEip7702TransactionHash(\n\t\tchainId,\n\t\tnonce,\n\t\tmax_priority_fee_per_gas,\n\t\tmax_fee_per_gas,\n\t\tgas_limit,\n\t\tdestination,\n\t\tvalue,\n\t\tdata,\n\t\taccess_list,\n\t\tauthorization_list,\n\t);\n\n\tconst basePayload = encodeEip7702TransactionBaseList(\n\t\tchainId,\n\t\tnonce,\n\t\tmax_priority_fee_per_gas,\n\t\tmax_fee_per_gas,\n\t\tgas_limit,\n\t\tdestination,\n\t\tvalue,\n\t\tdata,\n\t\taccess_list,\n\t\tauthorization_list,\n\t);\n\n\tconst signature = signHash(txHash, eoaPrivateKey);\n\tconst payload = basePayload.concat([\n\t\tbigintToBytes(BigInt(signature.yParity)),\n\t\tbigintToBytes(signature.r),\n\t\tbigintToBytes(signature.s),\n\t]);\n\tconst transactionPayload = encodeRlp(payload);\n\n\treturn SET_CODE_TX_TYPE + transactionPayload.slice(2);\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\tchainId: bigint,\n\tnonce: bigint,\n\tmax_priority_fee_per_gas: bigint,\n\tmax_fee_per_gas: bigint,\n\tgas_limit: bigint,\n\tdestination: string,\n\tvalue: bigint,\n\tdata: string,\n\taccess_list: [string, string[]][],\n\tauthorization_list: Authorization7702[],\n): string {\n\tconst payload = encodeEip7702TransactionBaseList(\n\t\tchainId,\n\t\tnonce,\n\t\tmax_priority_fee_per_gas,\n\t\tmax_fee_per_gas,\n\t\tgas_limit,\n\t\tdestination,\n\t\tvalue,\n\t\tdata,\n\t\taccess_list,\n\t\tauthorization_list,\n\t);\n\n\treturn 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\tchainId: bigint,\n\tnonce: bigint,\n\tmax_priority_fee_per_gas: bigint,\n\tmax_fee_per_gas: bigint,\n\tgas_limit: bigint,\n\tdestination: string,\n\tvalue: bigint,\n\tdata: string,\n\taccess_list: [string, string[]][],\n\tauthorization_list: Authorization7702[],\n) {\n\tif (chainId >= 2 ** 64) {\n\t\tthrow new RangeError(\"Invalid chainId.\");\n\t}\n\n\tif (nonce >= 2 ** 64) {\n\t\tthrow new RangeError(\"Invalid nonce.\");\n\t}\n\n\tif (destination.length !== 42) {\n\t\tthrow new RangeError(\"Invalid destination.\");\n\t}\n\n\tconst encoded_auth_list = encodeAuthList(authorization_list);\n\tconst encoded_access_list = encodeAccessList(access_list);\n\n\tconst payload = [\n\t\tbigintToBytes(chainId),\n\t\tbigintToBytes(nonce),\n\t\tbigintToBytes(max_priority_fee_per_gas),\n\t\tbigintToBytes(max_fee_per_gas),\n\t\tbigintToBytes(gas_limit),\n\t\tdestination,\n\t\tbigintToBytes(value),\n\t\tdata,\n\t\tencoded_access_list,\n\t\tencoded_auth_list,\n\t];\n\treturn payload;\n}\n\n/** Encodes an array of EIP-7702 authorizations into RLP-compatible nested arrays. */\nfunction encodeAuthList(authorization_list: Authorization7702[]) {\n\tconst encoded_auth_list = [];\n\tfor (const auth of authorization_list) {\n\t\tif (auth.address.length !== 42) {\n\t\t\tthrow new RangeError(`Invalid authorization list address: ${auth}`);\n\t\t}\n\t\tconst encoded_auth = [\n\t\t\tbigintToBytes(auth.chainId),\n\t\t\tauth.address,\n\t\t\tbigintToBytes(auth.nonce),\n\t\t\tbigintToBytes(BigInt(auth.yParity)),\n\t\t\tbigintToBytes(auth.r),\n\t\t\tbigintToBytes(auth.s),\n\t\t];\n\t\tencoded_auth_list.push(encoded_auth);\n\t}\n\treturn encoded_auth_list;\n}\n\n/** Encodes an EIP-2930 access list into RLP-compatible nested arrays. */\nfunction encodeAccessList(access_list: [string, string[]][]) {\n\tconst encoded_access_list = [];\n\tfor (const [access_add, storage_arr] of access_list) {\n\t\tif (access_add.length !== 42) {\n\t\t\tthrow new RangeError(`Invalid access list address: ${access_add}`);\n\t\t}\n\t\tconst encoded_storage_list = [];\n\t\tfor (const storage of storage_arr) {\n\t\t\tif (storage.length !== 66) {\n\t\t\t\tthrow new RangeError(`Invalid access list storage: ${storage}`);\n\t\t\t}\n\t\t\tencoded_storage_list.push(getBytes(storage));\n\t\t}\n\t\tencoded_access_list.push([getBytes(access_add), encoded_storage_list]);\n\t}\n\treturn encoded_access_list;\n}\n\n/** Converts a bigint to a Uint8Array of its big-endian byte representation. */\nfunction bigintToBytes(bi: bigint) {\n\treturn getBytes(toBeArray(bi));\n}\n\nconst SECP256K1_N = BigInt(\n\t\"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141\",\n);\nconst SECP256K1_HALF_N = SECP256K1_N / 2n;\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 *\n * High-s signatures are normalized to the complementary low-s form\n * (s' = n - s, flipped yParity) rather than rejected. A high-s value is not\n * a signer defect: plain ECDSA produces s uniformly across the range, so\n * generic signers (AWS KMS, HSMs, WebCrypto) return high-s for ~half of all\n * signatures — the low-s rule is an Ethereum canonicalization convention\n * (EIP-2), not part of ECDSA. Per the EIP-2 rationale, the complementary\n * signature is equally valid for the same signer and payload, so the\n * conversion changes the encoding, not the authorization. Rejecting instead\n * would fail nondeterministically on ~half of all signatures from such\n * signers, and EIP-7702 makes the unnormalized failure mode silent: nodes\n * validate s <= secp256k1n/2 per tuple and skip invalid tuples without\n * error, so a high-s authorization would \"succeed\" without ever applying\n * the delegation.\n *\n * @see https://eips.ethereum.org/EIPS/eip-2 - s-value bound and the\n * malleability rationale (flipping s to secp256k1n - s with the v flip\n * \"would still be valid\")\n * @see https://eips.ethereum.org/EIPS/eip-7702 - Behavior steps: \"Verify s\n * is less than or equal to secp256k1n/2\" and \"If any step above fails,\n * immediately stop processing the tuple and continue to the next tuple\"\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 (low-s normalized)\n */\nfunction parseRawSignature(rawSig: string): { yParity: 0 | 1; r: bigint; s: bigint } {\n\tconst sig = rawSig.startsWith(\"0x\") ? rawSig.slice(2) : rawSig;\n\tif (sig.length !== 128 && sig.length !== 130) {\n\t\tthrow new RangeError(\n\t\t\t`invalid signature length: expected 128 (EIP-2098 compact) or 130 (standard) hex chars, got ${sig.length}`,\n\t\t);\n\t}\n\tconst r = BigInt(`0x${sig.slice(0, 64)}`);\n\tlet yParity: 0 | 1;\n\tlet s: bigint;\n\n\tif (sig.length === 128) {\n\t\t// EIP-2098 compact signature (64 bytes): r (32) + yParity||s (32)\n\t\tconst yParityAndS = BigInt(`0x${sig.slice(64, 128)}`);\n\t\tyParity = Number((yParityAndS >> 255n) & 1n) as 0 | 1;\n\t\ts = yParityAndS & ((1n << 255n) - 1n);\n\t} else {\n\t\t// Standard 65-byte signature: r (32) + s (32) + v (1)\n\t\ts = BigInt(`0x${sig.slice(64, 128)}`);\n\t\tconst v = parseInt(sig.slice(128, 130), 16);\n\t\tif (v !== 0 && v !== 1 && v !== 27 && v !== 28) {\n\t\t\tthrow new RangeError(`invalid signature v value: ${v}`);\n\t\t}\n\t\tyParity = (v >= 27 ? v - 27 : v) as 0 | 1;\n\t}\n\n\t// EIP-7702 requires s <= n/2; nodes silently skip high-s authorization\n\t// tuples. Normalize to the complementary low-s signature.\n\tif (s > SECP256K1_HALF_N) {\n\t\ts = SECP256K1_N - s;\n\t\tyParity = (1 - yParity) as 0 | 1;\n\t}\n\treturn { 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\tconst hex = value.toString(16);\n\treturn hex.length % 2 ? `0x0${hex}` : `0x${hex}`;\n}\n","import {encodeAbiParameters, hashTypedData, id, keccak256} from \"./ethereUtils\";\nimport {ENTRYPOINT_V6, ENTRYPOINT_V7, ENTRYPOINT_V8, ENTRYPOINT_V9} from \"./constants\";\nimport {AbstractionKitError, ensureError} from \"./errors\";\nimport type {TypedData} from \"./signer/types\";\nimport {JsonRpcNode, type Transport, TransportRpcError} from \"./transport\";\nimport {\n\ttype AbiInputValue,\n\tGasOption,\n\ttype GasPrice,\n\ttype JsonRpcError,\n\ttype JsonRpcParam,\n\ttype JsonRpcResponse,\n\ttype JsonRpcResult,\n\ttype PolygonChain,\n\ttype PolygonGasStationJsonRpcResponse,\n\ttype UserOperationV6,\n\ttype UserOperationV7,\n\ttype UserOperationV8,\n\ttype UserOperationV9,\n} from \"./types\";\n\nfunction buildDomainSeparator(chainId: bigint, entrypoint: string): string {\n\t// DOMAIN_NAME = \"ERC4337\"\n\tconst hashed_name = \"0x364da28a5c92bcc87fe97c8813a6c6b8a3a049b0ea0a328fcb0b4f0e00337586\";\n\n\t// DOMAIN_VERSION = \"1\"\n\tconst hashed_version = \"0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6\";\n\n\t// TYPE_HASH = keccak(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\tconst type_hash = \"0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f\";\n\n\tconst encodedUserOperationHash = encodeAbiParameters(\n\t\t[\"(bytes32,bytes32,bytes32,uint256,address)\"],\n\t\t[[type_hash, hashed_name, hashed_version, chainId, entrypoint]],\n\t);\n\treturn 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\tlet userOperationHash: string;\n\tif (entrypointAddress.toLowerCase() === ENTRYPOINT_V6.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV6(useroperation as UserOperationV6),\n\t\t);\n\t\tconst encodedUserOperationHash = encodeAbiParameters(\n\t\t\t[\"bytes32\", \"address\", \"uint256\"],\n\t\t\t[packedUserOperationHash, entrypointAddress, chainId],\n\t\t);\n\t\tuserOperationHash = keccak256(encodedUserOperationHash);\n\t} else if (entrypointAddress.toLowerCase() === ENTRYPOINT_V7.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV7(useroperation as UserOperationV7),\n\t\t);\n\t\tconst encodedUserOperationHash = encodeAbiParameters(\n\t\t\t[\"bytes32\", \"address\", \"uint256\"],\n\t\t\t[packedUserOperationHash, entrypointAddress, chainId],\n\t\t);\n\t\tuserOperationHash = keccak256(encodedUserOperationHash);\n\t} else if (entrypointAddress.toLowerCase() === ENTRYPOINT_V8.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV8(useroperation as UserOperationV8),\n\t\t);\n\t\tconst domainSeparator = buildDomainSeparator(chainId, entrypointAddress);\n\t\tuserOperationHash = keccak256(\n\t\t\t`0x1901${domainSeparator.slice(2)}${packedUserOperationHash.slice(2)}`,\n\t\t);\n\t} else if (entrypointAddress.toLowerCase() === ENTRYPOINT_V9.toLowerCase()) {\n\t\tpackedUserOperationHash = keccak256(\n\t\t\tcreatePackedUserOperationV9(useroperation as UserOperationV8),\n\t\t);\n\t\tconst domainSeparator = buildDomainSeparator(chainId, entrypointAddress);\n\t\tuserOperationHash = keccak256(\n\t\t\t`0x1901${domainSeparator.slice(2)}${packedUserOperationHash.slice(2)}`,\n\t\t);\n\t} else {\n\t\tthrow new RangeError(`unsupported entrypoint address: ${entrypointAddress}`);\n\t}\n\n\treturn userOperationHash;\n}\n\n/**\n * @internal\n * Reconstruct the packed `initCode` field for an EntryPoint v0.8/v0.9\n * UserOperation. When `eip7702Auth.address` is set, the EIP-7702 delegatee\n * address replaces the factory address in initCode (only `factoryData` is\n * concatenated). Otherwise, behaves like v0.7 (`factory + factoryData`).\n *\n * Shared by {@link createPackedUserOperationV8} /\n * {@link createPackedUserOperationV9} and Simple7702Account's typed-data\n * builder. Not part of the public API; only `export`ed for cross-module\n * use within the package and not re-exported from `src/abstractionkit.ts`.\n *\n * @param useroperation - V8 or V9 UserOperation to read fields from\n * @returns Hex-encoded initCode\n */\nexport function buildPackedInitCodeV8V9(useroperation: UserOperationV8 | UserOperationV9): string {\n\tif (useroperation.factory == null) return \"0x\";\n\tconst eip7702Auth = useroperation.eip7702Auth;\n\tconst head =\n\t\teip7702Auth != null && eip7702Auth.address != null\n\t\t\t? eip7702Auth.address\n\t\t\t: useroperation.factory;\n\tconst factoryData = useroperation.factoryData != null ? useroperation.factoryData.slice(2) : \"\";\n\treturn head + factoryData;\n}\n\n/**\n * @internal\n * Pack `(verificationGasLimit, callGasLimit)` into a single `bytes32`\n * (two uint128 values, big-endian). Matches the on-chain\n * `PackedUserOperation.accountGasLimits` layout used by EntryPoint v0.7+.\n */\nfunction packAccountGasLimits(verificationGasLimit: bigint, callGasLimit: bigint): string {\n\treturn (\n\t\t\"0x\" +\n\t\tencodeAbiParameters([\"uint128\"], [verificationGasLimit]).slice(34) +\n\t\tencodeAbiParameters([\"uint128\"], [callGasLimit]).slice(34)\n\t);\n}\n\n/**\n * @internal\n * Pack `(maxPriorityFeePerGas, maxFeePerGas)` into a single `bytes32`\n * (two uint128 values, big-endian). Matches the on-chain\n * `PackedUserOperation.gasFees` layout used by EntryPoint v0.7+.\n */\nfunction packGasFees(maxPriorityFeePerGas: bigint, maxFeePerGas: bigint): string {\n\treturn (\n\t\t\"0x\" +\n\t\tencodeAbiParameters([\"uint128\"], [maxPriorityFeePerGas]).slice(34) +\n\t\tencodeAbiParameters([\"uint128\"], [maxFeePerGas]).slice(34)\n\t);\n}\n\n/**\n * @internal\n * Reconstruct the packed `paymasterAndData` field from a UserOperation's\n * separate paymaster fields. Returns `0x` when no paymaster is set.\n *\n * For EntryPoint v0.9, when `paymasterData` ends with the parallel-paymaster\n * signature magic suffix (`0x22e325a297439656`), the embedded signature is\n * stripped so the userOpHash does not commit to the paymaster's signature\n * over itself. Pass `stripV9PaymasterSig=false` to preserve the wire format.\n *\n * Shared by v7/v8/v9 packers and Simple7702Account's typed-data builder.\n * Not part of the public API; only `export`ed for cross-module use within\n * the package and not re-exported from `src/abstractionkit.ts`.\n *\n * @param useroperation - V7/V8/V9 UserOperation to read fields from\n * @param stripV9PaymasterSig - Whether to strip the v0.9 paymaster signature suffix\n * @returns Hex-encoded paymasterAndData\n */\nexport function buildPaymasterAndData(\n\tuseroperation: UserOperationV7 | UserOperationV8 | UserOperationV9,\n\tstripV9PaymasterSig: boolean = false,\n): string {\n\tif (useroperation.paymaster == null) return \"0x\";\n\tlet paymasterAndData = useroperation.paymaster;\n\tif (useroperation.paymasterVerificationGasLimit != null) {\n\t\tpaymasterAndData += encodeAbiParameters(\n\t\t\t[\"uint128\"],\n\t\t\t[useroperation.paymasterVerificationGasLimit],\n\t\t).slice(34);\n\t}\n\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\tpaymasterAndData += encodeAbiParameters(\n\t\t\t[\"uint128\"],\n\t\t\t[useroperation.paymasterPostOpGasLimit],\n\t\t).slice(34);\n\t}\n\tif (useroperation.paymasterData != null) {\n\t\tconst PAYMASTER_SIG_MAGIC = \"22e325a297439656\";\n\t\tif (\n\t\t\tstripV9PaymasterSig &&\n\t\t\tuseroperation.paymasterData.toLowerCase().endsWith(PAYMASTER_SIG_MAGIC)\n\t\t) {\n\t\t\tconst sigLenHex = useroperation.paymasterData.slice(\n\t\t\t\tuseroperation.paymasterData.length - 16 - 4,\n\t\t\t\tuseroperation.paymasterData.length - 16,\n\t\t\t);\n\t\t\tconst sigLen = parseInt(sigLenHex, 16);\n\t\t\tconst prefixEnd = useroperation.paymasterData.length - 16 - 4 - sigLen * 2;\n\t\t\tpaymasterAndData +=\n\t\t\t\tuseroperation.paymasterData.slice(0, prefixEnd).replaceAll(\"0x\", \"\") + PAYMASTER_SIG_MAGIC;\n\t\t} else {\n\t\t\tpaymasterAndData += useroperation.paymasterData.slice(2);\n\t\t}\n\t}\n\treturn paymasterAndData;\n}\n\n/**\n * Build the EIP-712 typed data payload for a UserOperation under the\n * EntryPoint v0.8 / v0.9 domain. The digest of the returned payload equals\n * the `userOpHash` from {@link createUserOperationHash}, so signing it via\n * `signTypedData` produces a signature that validates against the same hash\n * as raw ECDSA over the `userOpHash`.\n *\n * Shared by EIP-7702 accounts (Simple7702, Calibur). Earlier EntryPoints\n * define the userOpHash differently and don't fit this typed-data shape.\n *\n * @param userOperation - Unsigned UserOperation to wrap\n * @param entrypointAddress - The EntryPoint contract address (must be v0.8 or v0.9)\n * @param chainId - Target chain ID (must match the chain that will validate the signature)\n * @returns EIP-712 {@link TypedData} payload ready for `signTypedData`\n * @throws {AbstractionKitError} if `entrypointAddress` is not v0.8 / v0.9\n */\nexport function getUserOperationEip712DataV8V9(\n\tuserOperation: UserOperationV8 | UserOperationV9,\n\tentrypointAddress: string,\n\tchainId: bigint,\n): TypedData {\n\tconst ep = entrypointAddress.toLowerCase();\n\tconst isV9 = ep === ENTRYPOINT_V9.toLowerCase();\n\tif (ep !== ENTRYPOINT_V8.toLowerCase() && !isV9) {\n\t\tthrow new AbstractionKitError(\n\t\t\t\"BAD_DATA\",\n\t\t\t`getUserOperationEip712Data supports EntryPoint v0.8 / v0.9 only; ` +\n\t\t\t\t`got ${entrypointAddress}. Earlier EntryPoints define the userOpHash ` +\n\t\t\t\t`differently and require raw-hash signing.`,\n\t\t);\n\t}\n\n\tconst initCode = buildPackedInitCodeV8V9(userOperation);\n\tconst accountGasLimits = packAccountGasLimits(\n\t\tuserOperation.verificationGasLimit,\n\t\tuserOperation.callGasLimit,\n\t);\n\tconst gasFees = packGasFees(userOperation.maxPriorityFeePerGas, userOperation.maxFeePerGas);\n\tconst paymasterAndData = buildPaymasterAndData(userOperation, isV9);\n\n\tconst types = {\n\t\tPackedUserOperation: [\n\t\t\t{ name: \"sender\", type: \"address\" },\n\t\t\t{ name: \"nonce\", type: \"uint256\" },\n\t\t\t{ name: \"initCode\", type: \"bytes\" },\n\t\t\t{ name: \"callData\", type: \"bytes\" },\n\t\t\t{ name: \"accountGasLimits\", type: \"bytes32\" },\n\t\t\t{ name: \"preVerificationGas\", type: \"uint256\" },\n\t\t\t{ name: \"gasFees\", type: \"bytes32\" },\n\t\t\t{ name: \"paymasterAndData\", type: \"bytes\" },\n\t\t],\n\t};\n\n\treturn {\n\t\tdomain: {\n\t\t\tname: \"ERC4337\",\n\t\t\tversion: \"1\",\n\t\t\tchainId,\n\t\t\tverifyingContract: entrypointAddress as `0x${string}`,\n\t\t},\n\t\ttypes,\n\t\tprimaryType: \"PackedUserOperation\",\n\t\tmessage: {\n\t\t\tsender: userOperation.sender,\n\t\t\tnonce: userOperation.nonce,\n\t\t\tinitCode,\n\t\t\tcallData: userOperation.callData,\n\t\t\taccountGasLimits,\n\t\t\tpreVerificationGas: userOperation.preVerificationGas,\n\t\t\tgasFees,\n\t\t\tpaymasterAndData,\n\t\t},\n\t};\n}\n\n/**\n * Compute the EIP-712 digest of a UserOperation under the EntryPoint\n * v0.8 / v0.9 domain. For these EntryPoints this digest IS the\n * `userOpHash` ({@link createUserOperationHash}).\n *\n * @param userOperation - Unsigned UserOperation to hash\n * @param entrypointAddress - The EntryPoint contract address (must be v0.8 or v0.9)\n * @param chainId - Target chain ID\n * @returns The EIP-712 digest as a hex string\n * @throws {AbstractionKitError} if `entrypointAddress` is not v0.8 / v0.9\n */\nexport function getUserOperationEip712HashV8V9(\n\tuserOperation: UserOperationV8 | UserOperationV9,\n\tentrypointAddress: string,\n\tchainId: bigint,\n): string {\n\tconst data = getUserOperationEip712DataV8V9(userOperation, entrypointAddress, chainId);\n\treturn hashTypedData(data.domain, data.types, data.message);\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(useroperation: UserOperationV6): 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 packedUserOperation = encodeAbiParameters(\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(useroperation: UserOperationV7): string {\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 = packAccountGasLimits(\n\t\tuseroperation.verificationGasLimit,\n\t\tuseroperation.callGasLimit,\n\t);\n\tconst gasFees = packGasFees(useroperation.maxPriorityFeePerGas, useroperation.maxFeePerGas);\n\tconst paymasterAndData = buildPaymasterAndData(useroperation);\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 = encodeAbiParameters(\n\t\t[\"address\", \"uint256\", \"bytes32\", \"bytes32\", \"bytes32\", \"uint256\", \"bytes32\", \"bytes32\"],\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(useroperation: UserOperationV8): string {\n\treturn 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(useroperation: UserOperationV8): string {\n\treturn baseCreatePackedUserOperationV8V9(useroperation, false);\n}\n\n/**\n * Shared packer for EntryPoint v0.8 and v0.9 UserOperations.\n * @param useroperation - UserOperation to pack\n * @param is_v9 - If true, strips the paymaster signature suffix (v0.9-specific)\n * @returns ABI-encoded packed UserOperation as a hex string\n */\nfunction baseCreatePackedUserOperationV8V9(\n\tuseroperation: UserOperationV8 | UserOperationV9,\n\tis_v9: boolean,\n): string {\n\tconst initCode = buildPackedInitCodeV8V9(useroperation);\n\tconst accountGasLimits = packAccountGasLimits(\n\t\tuseroperation.verificationGasLimit,\n\t\tuseroperation.callGasLimit,\n\t);\n\tconst gasFees = packGasFees(useroperation.maxPriorityFeePerGas, useroperation.maxFeePerGas);\n\tconst paymasterAndData = buildPaymasterAndData(useroperation, is_v9);\n\n\tconst useroperationValuesArrayWithHashedByteValues = [\n\t\t// PACKED_USEROP_TYPEHASH\n\t\t\"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 = encodeAbiParameters(\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 params: string = encodeAbiParameters(functionInputAbi, functionInputParameters);\n\tconst callData = functionSelector + params.slice(2);\n\n\treturn callData;\n}\n\n/**\n * Send a JSON-RPC 2.0 request to the specified endpoint.\n *\n * **External escape hatch.** Most SDK consumers should use one of the\n * high-level service classes ({@link Bundler}, {@link CandidePaymaster},\n * {@link Erc7677Paymaster}, {@link JsonRpcNode}) which translate errors into\n * the SDK's domain vocabulary. This function is intentionally low-level: it\n * speaks plain JSON-RPC and throws {@link TransportRpcError}\n * (an EIP-1193-shaped `ProviderRpcError`) on RPC errors.\n *\n * Two execution modes:\n * - **URL string:** issues a `fetch` POST directly. Supports custom `headers`\n *   and a custom `paramsKeyName` for non-standard servers (e.g. APIs that\n *   expect `\"simulations\"` instead of `\"params\"`).\n * - **Transport / JsonRpcNode:** delegates to `.request({ method, params })`.\n *   `headers` and `paramsKeyName` are ignored (those concerns belong to the\n *   transport implementation).\n *\n * Automatically serializes `bigint` values in `params` as `0x`-prefixed hex.\n *\n * @param rpc - JSON-RPC endpoint URL, {@link Transport}, or {@link JsonRpcNode}\n * @param method - The JSON-RPC method name (e.g., `\"eth_call\"`)\n * @param params - The JSON-RPC parameters\n * @param headers - Custom HTTP headers (URL inputs only; default Content-Type: application/json)\n * @param paramsKeyName - Override the params key in the envelope (URL inputs only; default `\"params\"`)\n * @returns The `result` (or non-standard equivalent) field from the JSON-RPC response\n * @throws {@link TransportRpcError} when the response contains an `error` field\n */\nexport async function sendJsonRpcRequest(\n\trpc: string | Transport | JsonRpcNode,\n\tmethod: string,\n\tparams: JsonRpcParam,\n\theaders: Record<string, string> = { \"Content-Type\": \"application/json\" },\n\tparamsKeyName: string = \"params\",\n): Promise<JsonRpcResult> {\n\t// Normalize bigints to 0x-hex so user-supplied transports\n\t// and the fetch body both receive\n\t// JSON-RPC-safe values.\n\tconst normalizedParams = JSON.parse(\n\t\tJSON.stringify(params, (_key, value) =>\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\t),\n\t) as JsonRpcParam;\n\tif (typeof rpc !== \"string\") {\n\t\treturn JsonRpcNode.from(rpc).request<JsonRpcResult>({\n\t\t\tmethod,\n\t\t\tparams: normalizedParams as readonly unknown[] | object,\n\t\t});\n\t}\n\t// URL path — preserve the historical fetch-based implementation so callers\n\t// passing custom headers or a custom paramsKeyName continue to work.\n\tconst raw = JSON.stringify({\n\t\tmethod,\n\t\t[paramsKeyName]: normalizedParams,\n\t\tid: Date.now(),\n\t\tjsonrpc: \"2.0\",\n\t});\n\tconst fetchResult = await fetch(rpc, {\n\t\tmethod: \"POST\",\n\t\theaders,\n\t\tbody: raw,\n\t\tredirect: \"follow\",\n\t});\n\tconst responseText = await fetchResult.text();\n\tlet response: JsonRpcResponse;\n\ttry {\n\t\tresponse = JSON.parse(responseText) as JsonRpcResponse;\n\t} catch {\n\t\t// non-JSON body (HTML error page, plain text) — the HTTP status is the\n\t\t// real diagnostic, so surface it instead of a JSON parse error\n\t\tthrow new TransportRpcError(\n\t\t\t-32603,\n\t\t\t`HTTP ${fetchResult.status} ${fetchResult.statusText}: response body is not JSON`.trim(),\n\t\t\tresponseText.slice(0, 1000),\n\t\t);\n\t}\n\tif (typeof response !== \"object\" || response === null) {\n\t\t// scalar or null payload — the `in` checks below would throw a\n\t\t// TypeError; report it as a malformed response with the HTTP status\n\t\tthrow new TransportRpcError(\n\t\t\t-32603,\n\t\t\t`HTTP ${fetchResult.status} ${fetchResult.statusText}: malformed JSON-RPC response`.trim(),\n\t\t\tresponse,\n\t\t);\n\t}\n\tif (!fetchResult.ok) {\n\t\t// An HTTP failure status wins over any \"result\" in the body — a\n\t\t// success payload delivered with a failure status is contradictory\n\t\t// and not trusted. A JSON-RPC error envelope still reports the\n\t\t// server's own error (e.g. a 429 rate limit).\n\t\tconst err = response.error as JsonRpcError | undefined;\n\t\tif (err != null && typeof err === \"object\") {\n\t\t\tthrow new TransportRpcError(err.code, err.message);\n\t\t}\n\t\tthrow new TransportRpcError(\n\t\t\t-32603,\n\t\t\t`HTTP ${fetchResult.status} ${fetchResult.statusText}`.trim(),\n\t\t\tresponse,\n\t\t);\n\t}\n\tif (\"result\" in response) {\n\t\treturn response.result as JsonRpcResult;\n\t}\n\t// Non-standard servers (e.g. Tenderly's simulate-bundle API) return the\n\t// payload under `simulation_results` instead of `result`.\n\tif (\"simulation_results\" in response) {\n\t\treturn response.simulation_results as JsonRpcResult;\n\t}\n\tconst err = response.error as JsonRpcError;\n\tif (err == null || typeof err !== \"object\") {\n\t\t// no result and no error object — report the HTTP status rather than\n\t\t// crashing on err.code\n\t\tthrow new TransportRpcError(\n\t\t\t-32603,\n\t\t\t`HTTP ${fetchResult.status} ${fetchResult.statusText}: malformed JSON-RPC response`.trim(),\n\t\t\tresponse,\n\t\t);\n\t}\n\tthrow new TransportRpcError(err.code, err.message);\n}\n\n/**\n * Get a 4-byte function selector from a Solidity-style function signature.\n * Computed as the first 4 bytes of keccak256(signature).\n * @param functionSignature - Solidity-style function signature, e.g. \"mint(address)\"\n * @returns Function selector as a 0x-prefixed 10-character hex string\n *\n * @example\n * getFunctionSelector(\"getNonce(address,uint192)\"); // \"0x35567e1a\"\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 * Equivalent to `JsonRpcNode.from(rpc).getEntryPointNonce(entryPoint, account, key)`.\n * Kept as a top-level export for backward compatibility with existing call\n * sites; the first parameter widens from `string` to\n * `string | Transport | JsonRpcNode` so users can pass a configured transport\n * (with custom headers, retries, etc.) without restructuring their code.\n *\n * @param rpc - Ethereum JSON-RPC node URL, {@link Transport}, or {@link JsonRpcNode}\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\n *   channels. Prefer a `bigint` — keys can be as large as `uint192`, beyond\n *   what a JS `number` can represent; `number` is kept for backward\n *   compatibility.\n * @returns The current nonce as a bigint\n */\nexport async function fetchAccountNonce(\n\trpc: string | Transport | JsonRpcNode,\n\tentryPoint: string,\n\taccount: string,\n\tkey: number | bigint = 0,\n): Promise<bigint> {\n\treturn JsonRpcNode.from(rpc).getEntryPointNonce(entryPoint, account, BigInt(key));\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\tconst gasStationUrl = `https://gasstation.polygon.technology/${polygonChain}`;\n\ttry {\n\t\tconst fetchResult = await fetch(gasStationUrl);\n\t\tconst response = (await fetchResult.json()) as PolygonGasStationJsonRpcResponse;\n\t\tlet gasPrice: GasPrice;\n\t\tif (gasLevel === GasOption.Slow) {\n\t\t\tgasPrice = response.safeLow;\n\t\t} else if (gasLevel === GasOption.Medium) {\n\t\t\tgasPrice = response.standard;\n\t\t} else {\n\t\t\tgasPrice = response.fast;\n\t\t}\n\t\tlet maxFeePerGas = BigInt(Math.ceil(Number(gasPrice.maxFee) * 1000000000));\n\t\tlet maxPriorityFeePerGas = BigInt(Math.ceil(Number(gasPrice.maxPriorityFee) * 1000000000));\n\n\t\tif (maxFeePerGas === 0n) {\n\t\t\tmaxFeePerGas = 1n;\n\t\t}\n\t\tif (maxPriorityFeePerGas === 0n) {\n\t\t\tmaxPriorityFeePerGas = 1n;\n\t\t}\n\n\t\treturn [maxFeePerGas, maxPriorityFeePerGas];\n\t} catch (err) {\n\t\tconst error = ensureError(err);\n\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", `fetching gas prices from ${gasStationUrl} failed.`, {\n\t\t\tcause: error,\n\t\t});\n\t}\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\" && useroperation.paymasterAndData != null;\n\t\tconst mul = isPaymasterAndData ? 3n : 1n;\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\tdeposit: bigint;\n\tstaked: boolean;\n\tstake: bigint;\n\tunstakeDelaySec: bigint;\n\twithdrawTime: bigint;\n};\n\n/**\n * @internal\n * Internal dispatcher: routes to the Polygon Gas Station when a chain is\n * provided, otherwise delegates to {@link JsonRpcNode.getFeeData}. Used by\n * the account classes when assembling base UserOperation gas fields.\n */\nexport async function handlefetchGasPrice(\n\tproviderRpc: string | Transport | JsonRpcNode | undefined,\n\tpolygonGasStation: PolygonChain | undefined,\n\tgasLevel: GasOption = GasOption.Medium,\n): Promise<[bigint, bigint]> {\n\tif (polygonGasStation != null) {\n\t\treturn fetchGasPricePolygon(polygonGasStation, gasLevel);\n\t}\n\tif (providerRpc != null) {\n\t\treturn JsonRpcNode.from(providerRpc).getFeeData(gasLevel);\n\t}\n\tthrow new AbstractionKitError(\n\t\t\"BAD_DATA\",\n\t\t\"providerRpc can't be null if maxFeePerGas and maxPriorityFeePerGas are not overridden\",\n\t);\n}\n","import type { Bundler } from \"src/Bundler\";\nimport { AbstractionKitError } from \"src/errors\";\nimport type { 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(userOperationHash: string, bundler: Bundler, entrypointAddress: string) {\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(\"timeoutInSeconds can't be less than requestIntervalInSeconds\");\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(this.userOperationHash);\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","/**\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 type {\n\tGasOption,\n\tParallelPaymasterInitValues,\n\tPolygonChain,\n\tStateOverrideSet,\n} 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/**\n\t * Skip calling the bundler's gas estimation entirely. When true, the returned\n\t * UserOperation still gets a dummy signature, but its gas limits come from the\n\t * provided overrides (or stay at 0n). Useful when estimation is run separately\n\t * — for example, by a paymaster sponsorship call that returns its own limits.\n\t */\n\tskipGasEstimation?: boolean;\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","import {\n\tdecodeAbiParameters,\n\tencodeAbiParameters,\n\thexlify,\n\tkeccak256,\n\tprivateKeyToAddress,\n\tsignHash,\n} from \"src/ethereUtils\";\nimport {Bundler} from \"src/Bundler\";\nimport {\n\tBaseUserOperationDummyValues,\n\tCALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS,\n\tENTRYPOINT_V8,\n\tZeroAddress,\n} from \"src/constants\";\nimport {AbstractionKitError} from \"src/errors\";\nimport type {PrependTokenPaymasterApproveAccount} from \"src/paymaster/types\";\nimport {invokeSigner, pickScheme} from \"src/signer/negotiate\";\nimport type {SignContext, ExternalSigner, SigningScheme, TypedData} from \"src/signer/types\";\nimport {JsonRpcNode, type Transport} from \"src/transport\";\nimport type {JsonRpcResult, UserOperationV8, UserOperationV9} from \"src/types\";\nimport {\n\ttype Authorization7702Hex,\n\tbigintToHex,\n\tcreateAndSignEip7702RawTransaction,\n\tcreateRevokeDelegationAuthorization,\n} from \"src/utils7702\";\nimport {\n\tcreateCallData,\n\tcreateUserOperationHash,\n\tfetchAccountNonce,\n\tgetFunctionSelector,\n\tgetUserOperationEip712DataV8V9,\n\tgetUserOperationEip712HashV8V9,\n\thandlefetchGasPrice,\n\tsendJsonRpcRequest,\n} from \"../../utils\";\nimport {SendUseroperationResponse} from \"../SendUseroperationResponse\";\nimport {SmartAccount} from \"../SmartAccount\";\nimport type {SimpleMetaTransaction} from \"../simple/Simple7702Account\";\nimport {\n\ttype CaliburCreateUserOperationOverrides,\n\ttype CaliburKey,\n\ttype CaliburKeySettings,\n\ttype CaliburKeySettingsResult,\n\tCaliburKeyType,\n\ttype CaliburSignatureOverrides,\n\ttype WebAuthnSignatureData,\n} from \"./types\";\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\n\textends 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 = encodeAbiParameters(\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 dummyClientDataJSON =\n\t\t\t'{\"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 encodeAbiParameters(\n\t\t\t[\"bytes32\", \"bytes\", \"bytes\"],\n\t\t\t[\n\t\t\t\tkeyHash,\n\t\t\t\tencodeAbiParameters(\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[\n\t\t\t\t\t\t\t\"0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000\",\n\t\t\t\t\t\t\tdummyClientDataJSON,\n\t\t\t\t\t\t\tchallengeIndex,\n\t\t\t\t\t\t\ttypeIndex,\n\t\t\t\t\t\t\tBigInt(\"0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\"),\n\t\t\t\t\t\t\tBigInt(\"0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\"),\n\t\t\t\t\t\t],\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(keyHash: string, rawSignature: string, hookData = \"0x\"): string {\n\t\treturn encodeAbiParameters([\"bytes32\", \"bytes\", \"bytes\"], [keyHash, rawSignature, hookData]);\n\t}\n\n\t/**\n\t * Format a raw EIP-712 signature (from `signTypedData` over the payload\n\t * returned by {@link getUserOperationEip712Data}) into Calibur's\n\t * `userOp.signature` layout. Provided for API parity with Safe's\n\t * `formatEip712SingleSignatureToUseroperationSignature`.\n\t *\n\t * Under EntryPoint v0.8 / v0.9 the userOpHash IS the EIP-712 digest of\n\t * the PackedUserOperation, so a raw-hash signature and a typed-data\n\t * signature are byte-identical for deterministic-ECDSA signers; this\n\t * method is therefore equivalent to {@link wrapSignature} with the same\n\t * `keyHash` / `hookData`. The default `keyHash` is the root-key hash\n\t * (`bytes32(0)`), which selects the EOA's own secp256k1 key.\n\t *\n\t * @param signature - Raw ECDSA signature (65 bytes, hex-encoded) from\n\t *   `signTypedData` over the payload from {@link getUserOperationEip712Data}\n\t * @param overrides - Optional `keyHash` / `hookData` overrides\n\t * @returns Hex-encoded wrapped signature ready for `userOp.signature`\n\t */\n\tpublic static formatEip712SingleSignatureToUseroperationSignature(\n\t\tsignature: string,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): string {\n\t\tconst keyHash = overrides.keyHash ?? ROOT_KEY_HASH;\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\t\treturn Calibur7702Account.wrapSignature(keyHash, signature, hookData);\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(userOperation: UserOperationV8, chainId: bigint): string {\n\t\treturn createUserOperationHash(userOperation, this.entrypointAddress, chainId);\n\t}\n\n\t/**\n\t * Build the EIP-712 typed data payload for a UserOperation under the\n\t * EntryPoint v0.8 / v0.9 domain. Useful for wallets that can only sign\n\t * typed data (`eth_signTypedData_v4`) — the digest of the returned payload\n\t * equals the `userOpHash`, so a typed-data signature over it produces a\n\t * wrapped Calibur signature that validates against the same hash on-chain.\n\t *\n\t * Intended for the secp256k1 key path (root key or any registered\n\t * secondary secp256k1 key), since `eth_signTypedData_v4` only produces\n\t * secp256k1 signatures. P-256 and WebAuthn-P256 keys sign with their\n\t * own primitives — for those, use {@link getUserOperationEip712Hash}\n\t * (the digest), which is the value-to-be-signed regardless of key type.\n\t *\n\t * @param userOperation - Unsigned UserOperation to wrap\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override the entrypoint address (defaults to EntryPoint v0.8)\n\t * @returns EIP-712 {@link TypedData} payload ready for `signTypedData`\n\t * @throws {AbstractionKitError} if the target EntryPoint is not v0.8 / v0.9.\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: { entrypointAddress?: string } = {},\n\t): TypedData {\n\t\tconst entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V8;\n\t\treturn getUserOperationEip712DataV8V9(userOperation, entrypointAddress, chainId);\n\t}\n\n\t/**\n\t * Compute the EIP-712 digest of a UserOperation under the EntryPoint\n\t * v0.8 / v0.9 domain. For these EntryPoints this digest IS the\n\t * `userOpHash`; the wrapped Calibur signature is verified against this\n\t * hash on-chain.\n\t *\n\t * Universal across Calibur key types: secp256k1 and P-256 keys sign\n\t * this digest directly, each with their own signing primitive.\n\t *\n\t * @param userOperation - Unsigned UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override the entrypoint address (defaults to EntryPoint v0.8)\n\t * @returns The EIP-712 digest as a hex string\n\t * @throws {AbstractionKitError} if the target EntryPoint is not v0.8 / v0.9.\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: { entrypointAddress?: string } = {},\n\t): string {\n\t\tconst entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V8;\n\t\treturn getUserOperationEip712HashV8V9(userOperation, entrypointAddress, chainId);\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 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 = encodeAbiParameters(\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 | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\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(providerRpc, this.entrypointAddress, this.accountAddress);\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 (typeof overrides.maxFeePerGas === \"bigint\" && overrides.maxFeePerGas < 0n) {\n\t\t\tthrow new RangeError(\"maxFeePerGas override can't be negative\");\n\t\t}\n\n\t\tif (typeof overrides.maxPriorityFeePerGas === \"bigint\" && overrides.maxPriorityFeePerGas < 0n) {\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 (overrides.maxFeePerGas == null || overrides.maxPriorityFeePerGas == null) {\n\t\t\tgasPriceOp = handlefetchGasPrice(\n\t\t\t\tproviderRpc,\n\t\t\t\toverrides.polygonGasStation,\n\t\t\t\toverrides.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 ?? this.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 = JsonRpcNode.from(providerRpc)\n\t\t\t\t.getDelegatedAddress(this.accountAddress)\n\t\t\t\t.catch(() => null);\n\t\t}\n\n\t\tif (overrides.eip7702Auth != null && eip7702AuthNonce == null) {\n\t\t\tlet eip7702AuthNonceOp: Promise<JsonRpcResult>;\n\t\t\tif (providerRpc != null) {\n\t\t\t\teip7702AuthNonceOp = sendJsonRpcRequest(providerRpc, \"eth_getTransactionCount\", [\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t\t\"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 \" + \"is not overridden\",\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)\n\t\t\t\t[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 (\n\t\t\t\t\tdelegatedTo != null &&\n\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()\n\t\t\t\t) {\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)\n\t\t\t\t\t[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 (\n\t\t\t\t\t\tdelegatedTo != null &&\n\t\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()\n\t\t\t\t\t) {\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 =\n\t\t\toverrides.maxFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxFeePerGas) * (((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\n\t\tmaxPriorityFeePerGas =\n\t\t\toverrides.maxPriorityFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxPriorityFeePerGas) *\n\t\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 (yParity !== \"0x0\" && yParity !== \"0x00\" && yParity !== \"0x1\" && yParity !== \"0x01\") {\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. \" + \"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:\n\t\t\t\t\toverrides.eip7702Auth.r ??\n\t\t\t\t\t\"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2\",\n\t\t\t\ts:\n\t\t\t\t\toverrides.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\tconst skipGasEstimation = overrides.skipGasEstimation ?? false;\n\n\t\tif (\n\t\t\t!skipGasEstimation &&\n\t\t\t(overrides.preVerificationGas == null ||\n\t\t\t\toverrides.verificationGasLimit == null ||\n\t\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 =\n\t\t\t\t\toverrides.dummySignature ?? Calibur7702Account.dummySignature;\n\n\t\t\t\tconst bundler = Bundler.from(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// Compensate for signature verification cost the bundler skips\n\t\t\t\t// during `eth_estimateUserOperationGas`: estimation runs with a\n\t\t\t\t// dummy signature whose signature path is short-circuited\n\t\t\t\t// (the dummy doesn't recover to a real key, so the bundler\n\t\t\t\t// bypasses signature validation). ~55k gas covers the on-chain\n\t\t\t\t// signature path that simulation never paid for, whether the\n\t\t\t\t// real key is secp256k1 (ECRECOVER), P-256, or WebAuthn-P256.\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 can't be null if preVerificationGas,\" +\n\t\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overridden\",\n\t\t\t\t);\n\t\t\t}\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\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\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\tuserOperation.preVerificationGas =\n\t\t\toverrides.preVerificationGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(preVerificationGas) *\n\t\t\t\t\t\t(((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.verificationGasLimit =\n\t\t\toverrides.verificationGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(verificationGasLimit) *\n\t\t\t\t\t\t(((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.callGasLimit =\n\t\t\toverrides.callGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(callGasLimit) * (((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 ?? Calibur7702Account.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 ecdsaSig = signHash(privateKey, userOperationHash).serialized;\n\t\treturn Calibur7702Account.wrapSignature(keyHash, ecdsaSig, hookData);\n\t}\n\n\t/**\n\t * Schemes Calibur accepts from a Signer. EntryPoint v0.8/v0.9 introduced\n\t * an EIP-712 domain at the EntryPoint contract, and the userOpHash IS the\n\t * EIP-712 digest of the PackedUserOperation under that domain — so signing\n\t * the typed data and signing the raw hash produce signatures that verify\n\t * against the same `userOpHash` (and recover to the same signer address).\n\t * Deterministic-ECDSA signers (ethers, viem, MetaMask) yield byte-identical\n\t * bytes; signers that differ in `s` / `v` normalization still validate the\n\t * same on-chain.\n\t *\n\t * `typedData` is listed first so JSON-RPC wallets that can only sign typed\n\t * data work without a separate code path; `hash` remains a valid fallback\n\t * for local-key signers.\n\t */\n\tpublic static readonly ACCEPTED_SIGNING_SCHEMES: readonly SigningScheme[] = [\"typedData\", \"hash\"];\n\n\t/**\n\t * Sign a UserOperation with an {@link ExternalSigner}. The signer can implement\n\t * either `signTypedData` (preferred — JSON-RPC wallets, viem `WalletClient`)\n\t * or `signHash` (local keys, hardware wallets). Both schemes produce\n\t * signatures that validate against the same `userOpHash` because the\n\t * v0.8 / v0.9 userOpHash IS the EIP-712 digest of the PackedUserOperation\n\t * (deterministic-ECDSA signers yield byte-identical bytes).\n\t *\n\t * Signers that implement neither method fail offline with an actionable\n\t * error.\n\t */\n\tpublic async signUserOperationWithSigner(\n\t\tuserOperation: UserOperationV8,\n\t\tsigner: ExternalSigner,\n\t\tchainId: bigint,\n\t\toverrides: CaliburSignatureOverrides = {},\n\t): Promise<string> {\n\t\tconst scheme = pickScheme(signer, Calibur7702Account.ACCEPTED_SIGNING_SCHEMES, {\n\t\t\taccountName: \"Calibur (raw ECDSA over userOpHash)\",\n\t\t\tsignerIndex: 0,\n\t\t});\n\t\tconst hash = createUserOperationHash(\n\t\t\tuserOperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t) as `0x${string}`;\n\t\tconst context: SignContext<UserOperationV8> = {\n\t\t\tuserOperation,\n\t\t\tchainId,\n\t\t\tentryPoint: this.entrypointAddress,\n\t\t};\n\t\tconst typedData =\n\t\t\tscheme === \"typedData\"\n\t\t\t\t? Calibur7702Account.getUserOperationEip712Data(userOperation, chainId, {\n\t\t\t\t\t\tentrypointAddress: this.entrypointAddress,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\tconst signature = await invokeSigner(signer, scheme, { hash, typedData, context });\n\t\tconst keyHash = overrides.keyHash ?? ROOT_KEY_HASH;\n\t\tconst hookData = overrides.hookData ?? \"0x\";\n\t\treturn Calibur7702Account.wrapSignature(keyHash, signature, 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 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 = encodeAbiParameters(\n\t\t\t[\"(bytes,string,uint256,uint256,uint256,uint256)\"],\n\t\t\t[\n\t\t\t\t[\n\t\t\t\t\twebAuthnAuth.authenticatorData,\n\t\t\t\t\twebAuthnAuth.clientDataJSON,\n\t\t\t\t\twebAuthnAuth.challengeIndex,\n\t\t\t\t\twebAuthnAuth.typeIndex,\n\t\t\t\t\twebAuthnAuth.r,\n\t\t\t\t\twebAuthnAuth.s,\n\t\t\t\t],\n\t\t\t],\n\t\t);\n\n\t\treturn encodeAbiParameters([\"bytes32\", \"bytes\", \"bytes\"], [keyHash, webAuthnEncoded, hookData]);\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 | Transport | Bundler,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = Bundler.from(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(sendUserOperationRes, bundler, this.entrypointAddress);\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\treturn {\n\t\t\tkeyType: CaliburKeyType.Secp256k1,\n\t\t\tpublicKey: encodeAbiParameters([\"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\treturn {\n\t\t\tkeyType: CaliburKeyType.WebAuthnP256,\n\t\t\tpublicKey: encodeAbiParameters([\"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\treturn {\n\t\t\tkeyType: CaliburKeyType.P256,\n\t\t\tpublicKey: encodeAbiParameters([\"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 encoded = encodeAbiParameters([\"uint8\", \"bytes32\"], [key.keyType, innerHash]);\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\tif (expiration < 0n || expiration >= 1n << 40n) {\n\t\t\t// the on-chain field is uint40; an oversized value (e.g. a millisecond\n\t\t\t// timestamp) would bleed into the isAdmin bit at position 200\n\t\t\tthrow new RangeError(\n\t\t\t\t\"expiration must be a unix timestamp in seconds that fits in 40 bits, \" +\n\t\t\t\t\t`got ${expiration}. Did you pass milliseconds instead of seconds?`,\n\t\t\t);\n\t\t}\n\t\tif (hook < 0n || hook >= 1n << 160n) {\n\t\t\tthrow new RangeError(\"hook must be a valid 20-byte address.\");\n\t\t}\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\t\"isAdmin to true. Encode the calldata manually for admin keys.\",\n\t\t\t);\n\t\t}\n\n\n\t\t// Register: register((uint8 keyType, bytes publicKey))\n\t\tconst registerCallData =\n\t\t\tREGISTER_SELECTOR +\n\t\t\tencodeAbiParameters([\"(uint8,bytes)\"], [[key.keyType, key.publicKey]]).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 =\n\t\t\tUPDATE_SELECTOR + encodeAbiParameters([\"bytes32\", \"uint256\"], [keyHash, packedSettings]).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(keyHash: string): SimpleMetaTransaction {\n\t\tconst callData = REVOKE_SELECTOR + encodeAbiParameters([\"bytes32\"], [keyHash]).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 | Transport | JsonRpcNode,\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 | Transport | JsonRpcNode,\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 = privateKeyToAddress(eoaPrivateKey);\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 (${this.accountAddress})`,\n\t\t\t);\n\t\t}\n\n\t\t// Verify delegation state before revoking\n\t\tconst delegatedTo = await JsonRpcNode.from(providerRpc).getDelegatedAddress(this.accountAddress);\n\t\tif (delegatedTo === null) {\n\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"Account is not delegated — nothing to revoke\");\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 +\n\t\t\t\t\t\"), not \" +\n\t\t\t\t\tthis.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(providerRpc, \"eth_getTransactionCount\", [\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t\t\"latest\",\n\t\t\t\t]).then((v) => {\n\t\t\t\t\tresults.nonce = BigInt(v as string);\n\t\t\t\t}),\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).then(([fee, tip]) => {\n\t\t\t\t\tresults.maxFeePerGas = fee;\n\t\t\t\t\tresults.maxPriorityFeePerGas = tip;\n\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 =\n\t\t\toverrides.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(chainId, authNonce, eoaPrivateKey);\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\t\"isAdmin to true. Encode the calldata manually for admin keys.\",\n\t\t\t);\n\t\t}\n\n\t\tconst packedSettings = Calibur7702Account.packKeySettings(settings);\n\t\tconst callData =\n\t\t\tUPDATE_SELECTOR + encodeAbiParameters([\"bytes32\", \"uint256\"], [keyHash, packedSettings]).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(newNonce: bigint): SimpleMetaTransaction {\n\t\tconst callData = INVALIDATE_NONCE_SELECTOR + encodeAbiParameters([\"uint256\"], [newNonce]).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 {@link JsonRpcNode.getDelegatedAddress} to get the raw\n\t * 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 | Transport | JsonRpcNode): Promise<boolean> {\n\t\tconst address = await JsonRpcNode.from(providerRpc).getDelegatedAddress(this.accountAddress);\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(providerRpc: string | Transport | JsonRpcNode, sequenceKey = 0): Promise<bigint> {\n\t\treturn fetchAccountNonce(providerRpc, this.entrypointAddress, this.accountAddress, sequenceKey);\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(providerRpc: string | Transport | JsonRpcNode, keyHash: string): Promise<boolean> {\n\t\tconst callData = IS_REGISTERED_SELECTOR + encodeAbiParameters([\"bytes32\"], [keyHash]).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(providerRpc, \"eth_call\", [\n\t\t\t{\n\t\t\t\tfrom: ZeroAddress,\n\t\t\t\tto: this.accountAddress,\n\t\t\t\tdata: callData,\n\t\t\t},\n\t\t\t\"latest\",\n\t\t]);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = decodeAbiParameters<[boolean]>([\"bool\"], result);\n\t\t\treturn decoded[0];\n\t\t}\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"Unexpected response from isRegistered call\");\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 | Transport | JsonRpcNode,\n\t\tkeyHash: string,\n\t): Promise<CaliburKeySettingsResult> {\n\t\tconst callData = GET_KEY_SETTINGS_SELECTOR + encodeAbiParameters([\"bytes32\"], [keyHash]).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(providerRpc, \"eth_call\", [\n\t\t\t{\n\t\t\t\tfrom: ZeroAddress,\n\t\t\t\tto: this.accountAddress,\n\t\t\t\tdata: callData,\n\t\t\t},\n\t\t\t\"latest\",\n\t\t]);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = decodeAbiParameters<[bigint]>([\"uint256\"], result);\n\t\t\treturn Calibur7702Account.unpackKeySettings(BigInt(decoded[0]));\n\t\t}\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"Unexpected response from getKeySettings call\");\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(providerRpc: string | Transport | JsonRpcNode, keyHash: string): Promise<CaliburKey> {\n\t\tconst callData = GET_KEY_SELECTOR + encodeAbiParameters([\"bytes32\"], [keyHash]).slice(2);\n\n\t\tconst result = await sendJsonRpcRequest(providerRpc, \"eth_call\", [\n\t\t\t{\n\t\t\t\tfrom: ZeroAddress,\n\t\t\t\tto: this.accountAddress,\n\t\t\t\tdata: callData,\n\t\t\t},\n\t\t\t\"latest\",\n\t\t]);\n\n\t\tif (typeof result === \"string\") {\n\t\t\tconst decoded = decodeAbiParameters<[[bigint, string]]>([\"(uint8,bytes)\"], result);\n\t\t\tconst keyTuple = decoded[0];\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(\"BAD_DATA\", \"Unexpected response from getKey call\");\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 | Transport | JsonRpcNode,\n\t\toverrides: { blockNumber?: bigint } = {},\n\t): Promise<CaliburKey[]> {\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(providerRpc, \"eth_blockNumber\", [])) as string;\n\t\t\tblockTag = blockHex;\n\t\t}\n\n\t\t// Get key count\n\t\tconst countResult = await sendJsonRpcRequest(providerRpc, \"eth_call\", [\n\t\t\t{\n\t\t\t\tfrom: ZeroAddress,\n\t\t\t\tto: this.accountAddress,\n\t\t\t\tdata: KEY_COUNT_SELECTOR,\n\t\t\t},\n\t\t\tblockTag,\n\t\t]);\n\n\t\tif (typeof countResult !== \"string\") {\n\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"Unexpected response from keyCount call\");\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 + encodeAbiParameters([\"uint256\"], [i]).slice(2);\n\n\t\t\tkeyAtPromises.push(\n\t\t\t\tsendJsonRpcRequest(providerRpc, \"eth_call\", [\n\t\t\t\t\t{\n\t\t\t\t\t\tfrom: ZeroAddress,\n\t\t\t\t\t\tto: this.accountAddress,\n\t\t\t\t\t\tdata: keyAtCallData,\n\t\t\t\t\t},\n\t\t\t\t\tblockTag,\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 = decodeAbiParameters<[[bigint, string]]>([\"(uint8,bytes)\"], keyResult);\n\t\t\tconst keyTuple = decoded[0];\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\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 \" +\n\t\t\t\t\tEXECUTE_USER_OP_SELECTOR +\n\t\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 = decodeAbiParameters<\n\t\t\t[[Array<[string, bigint, string | Uint8Array]>, boolean]]\n\t\t>([\"((address,uint256,bytes)[],bool)\"], `0x${callData.slice(10)}`);\n\t\tconst existingCalls = batchedCallDecoded[0][0];\n\t\tconst revertOnFailure = batchedCallDecoded[0][1];\n\n\t\tconst decodedTransactions: SimpleMetaTransaction[] = existingCalls.map((call) => ({\n\t\t\tto: call[0],\n\t\t\tvalue: BigInt(call[1]),\n\t\t\t// call[2] is the inner transaction calldata (binary). When the ABI\n\t\t\t// decoder hands it back as bytes, hex-encode it (do NOT UTF-8 decode,\n\t\t\t// which would corrupt the selector/arguments).\n\t\t\tdata: typeof call[2] !== \"string\" ? hexlify(call[2]) : call[2],\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 = encodeAbiParameters(\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 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(generatorFunctionInputParameters: AbiInputValue[]): 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 = \"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 {encodeAbiParameters} from \"./ethereUtils\";\nimport {AbstractionKitError, ensureError} from \"./errors\";\nimport type {\n\tSingleTransactionTenderlySimulationResult,\n\tTenderlySimulationResult,\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n\tUserOperationV9,\n} from \"./types\";\nimport {createUserOperationHash} from \"./utils\";\nimport type {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<string, Record<string, string | Record<string, string>>>;\n\n/**\n * The 20-byte right-padded EIP-7702 marker EntryPoint v0.8+ expects at the\n * head of `initCode` (any trailing bytes are the sender initialization call).\n */\nconst EIP7702_INITCODE_MARKER = \"0x7702000000000000000000000000000000000000\";\n\n/**\n * EIP-7702 userOps mark the factory field with a sentinel instead of a real\n * factory: either the short form \"0x7702\" or the 20-byte right-padded form\n * accepted by EntryPoint v0.8 (initCode starting with bytes 0x7702).\n */\nfunction isEip7702FactorySentinel(factory: string | null | undefined): boolean {\n\tif (factory == null) {\n\t\treturn false;\n\t}\n\tconst factoryLowerCase = factory.toLowerCase();\n\treturn factoryLowerCase === \"0x7702\" || factoryLowerCase === EIP7702_INITCODE_MARKER;\n}\n\n/**\n * Return a copy of `stateOverrides` with the sender's EIP-7702 delegation\n * code merged in. Override keys are EVM addresses, so the sender entry is\n * matched case-insensitively — a caller entry keyed by a checksummed address\n * merges into one lowercase entry instead of duplicating the address.\n * Multiple keys matching the sender (differing only in case) are rejected,\n * matching callTenderlySimulateBundle's duplicate policy — collapsing them\n * here would silently pick one entry's fields over the other's.\n */\nfunction withSenderCodeOverride(\n\tstateOverrides: OverrideType | null | undefined,\n\tsender: string,\n\tdelegationCode: string,\n): OverrideType {\n\tconst senderLower = sender.toLowerCase();\n\tconst merged: OverrideType = {};\n\tlet senderEntry: Record<string, string | Record<string, string>> | null = null;\n\tfor (const [address, entry] of Object.entries(stateOverrides ?? {})) {\n\t\tif (address.toLowerCase() === senderLower) {\n\t\t\tif (senderEntry != null) {\n\t\t\t\tthrow new RangeError(`Duplicate stateOverrides address (case-insensitive): ${address}.`);\n\t\t\t}\n\t\t\tsenderEntry = entry;\n\t\t} else {\n\t\t\tmerged[address] = entry;\n\t\t}\n\t}\n\tmerged[senderLower] = { ...(senderEntry ?? {}), code: delegationCode };\n\treturn merged;\n}\n\n/**\n * Rebuild the packed `initCode` from split factory/factoryData fields,\n * normalizing the short \"0x7702\" sentinel to the 20-byte right-padded marker\n * so non-empty factoryData lands after a well-formed head.\n */\nfunction buildWireInitCode(factory: string | null, factoryData: string | null): string {\n\tif (factory == null) {\n\t\treturn \"0x\";\n\t}\n\tlet initCode = isEip7702FactorySentinel(factory) ? EIP7702_INITCODE_MARKER : factory;\n\tif (factoryData != null) {\n\t\tinitCode += factoryData.slice(2);\n\t}\n\treturn initCode;\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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\ttenderlySimulationId: string,\n) {\n\tconst tenderlyUrl =\n\t\t\"https://api.tenderly.co/api/v1/account/\" +\n\t\ttenderlyAccountSlug +\n\t\t\"/project/\" +\n\t\ttenderlyProjectSlug +\n\t\t\"/simulations/\" +\n\t\ttenderlySimulationId +\n\t\t\"/share\";\n\n\tconst headers = {\n\t\tAccept: \"application/json\",\n\t\t\"Content-Type\": \"application/json\",\n\t\t\"X-Access-Key\": tenderlyAccessKey,\n\t};\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\tthrow new AbstractionKitError(\"BAD_DATA\", \"tenderly share simulation failed.\", {\n\t\t\tcontext: {\n\t\t\t\ttenderlyAccountSlug,\n\t\t\t\ttenderlyProjectSlug,\n\t\t\t\thasTenderlyAccessKey: tenderlyAccessKey.length > 0,\n\t\t\t\ttenderlySimulationId,\n\t\t\t\tstatus,\n\t\t\t},\n\t\t});\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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\tchainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\tblockNumber: number | null = null,\n\tstateOverrides?: OverrideType | null,\n): Promise<{\n\tsimulation: SingleTransactionTenderlySimulationResult;\n\tsimulationShareLink: string;\n}> {\n\tconst simulation = await simulateUserOperationWithTenderly(\n\t\ttenderlyAccountSlug,\n\t\ttenderlyProjectSlug,\n\t\ttenderlyAccessKey,\n\t\tchainId,\n\t\tentrypointAddress,\n\t\tuserOperation,\n\t\tblockNumber,\n\t\tstateOverrides,\n\t);\n\n\tawait shareTenderlySimulationAndCreateLink(\n\t\ttenderlyAccountSlug,\n\t\ttenderlyProjectSlug,\n\t\ttenderlyAccessKey,\n\t\tsimulation.simulation.id,\n\t);\n\tconst simulationShareLink = `https://dashboard.tenderly.co/shared/simulation/${simulation.simulation.id}`;\n\treturn {\n\t\tsimulation,\n\t\tsimulationShareLink,\n\t};\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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\tchainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9,\n\tblockNumber: number | null = null,\n\tstateOverrides?: OverrideType | null,\n): Promise<SingleTransactionTenderlySimulationResult> {\n\tconst entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n\tlet callData: string | null = null;\n\tconst isV6UserOperation = \"initCode\" in userOperation;\n\tconst isV6Entrypoint =\n\t\tentrypointAddressLowerCase === \"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789\";\n\n\tif (isV6UserOperation !== isV6Entrypoint) {\n\t\tthrow new RangeError(\"UserOperation version does not match entrypoint.\");\n\t}\n\n\tif (isV6UserOperation) {\n\t\tuserOperation = userOperation as UserOperationV6;\n\t\tconst useroperationValuesArray = [\n\t\t\tuserOperation.sender,\n\t\t\tuserOperation.nonce,\n\t\t\tuserOperation.initCode,\n\t\t\tuserOperation.callData,\n\t\t\tuserOperation.callGasLimit,\n\t\t\tuserOperation.verificationGasLimit,\n\t\t\tuserOperation.preVerificationGas,\n\t\t\tuserOperation.maxFeePerGas,\n\t\t\tuserOperation.maxPriorityFeePerGas,\n\t\t\tuserOperation.paymasterAndData,\n\t\t\tuserOperation.signature,\n\t\t];\n\n\t\tconst encodedUserOperation = encodeAbiParameters(\n\t\t\t[\n\t\t\t\t\"(address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[]\",\n\t\t\t\t\"address\",\n\t\t\t],\n\t\t\t[[useroperationValuesArray], \"0x1000000000000000000000000000000000000000\"],\n\t\t);\n\t\tcallData = `0x1fad948c${encodedUserOperation.slice(2)}`;\n\t} else {\n\t\tuserOperation = userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9;\n\t\tconst initCode = buildWireInitCode(userOperation.factory, userOperation.factoryData);\n\n\t\tconst accountGasLimits =\n\t\t\t\"0x\" +\n\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.verificationGasLimit]).slice(34) +\n\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.callGasLimit]).slice(34);\n\n\t\tconst gasFees =\n\t\t\t\"0x\" +\n\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.maxPriorityFeePerGas]).slice(34) +\n\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.maxFeePerGas]).slice(34);\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 += encodeAbiParameters(\n\t\t\t\t\t[\"uint128\"],\n\t\t\t\t\t[userOperation.paymasterVerificationGasLimit],\n\t\t\t\t).slice(34);\n\t\t\t}\n\t\t\tif (userOperation.paymasterPostOpGasLimit != null) {\n\t\t\t\tpaymasterAndData += encodeAbiParameters(\n\t\t\t\t\t[\"uint128\"],\n\t\t\t\t\t[userOperation.paymasterPostOpGasLimit],\n\t\t\t\t).slice(34);\n\t\t\t}\n\t\t\tif (userOperation.paymasterData != null) {\n\t\t\t\tpaymasterAndData += userOperation.paymasterData.slice(2);\n\t\t\t}\n\t\t}\n\n\t\tconst useroperationValuesArray = [\n\t\t\tuserOperation.sender,\n\t\t\tuserOperation.nonce,\n\t\t\tinitCode,\n\t\t\tuserOperation.callData,\n\t\t\taccountGasLimits,\n\t\t\tuserOperation.preVerificationGas,\n\t\t\tgasFees,\n\t\t\tpaymasterAndData,\n\t\t\tuserOperation.signature,\n\t\t];\n\n\t\tconst encodedUserOperation = encodeAbiParameters(\n\t\t\t[\"(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)[]\", \"address\"],\n\t\t\t[[useroperationValuesArray], \"0x1000000000000000000000000000000000000000\"],\n\t\t);\n\n\t\tif (\n\t\t\tentrypointAddressLowerCase === \"0x0000000071727de22e5e9d8baf0edac6f37da032\" ||\n\t\t\tentrypointAddressLowerCase === \"0x4337084d9e255ff0702461cf8895ce9e3b5ff108\" ||\n\t\t\tentrypointAddressLowerCase === \"0x433709009b8330fda32311df1c2afa402ed8d009\"\n\t\t) {\n\t\t\tcallData = `0x765e827f${encodedUserOperation.slice(2)}`;\n\t\t} else {\n\t\t\tthrow new RangeError(\"Invalid entrypoint.\");\n\t\t}\n\t}\n\n\t// EIP-7702 userOps (factory == \"0x7702\"): EntryPoint requires the sender's\n\t// code to start with the delegation prefix (0xef0100). Inject a code state\n\t// override so the simulation passes.\n\tif (\n\t\t!isV6UserOperation &&\n\t\tisEip7702FactorySentinel(\n\t\t\t(userOperation as UserOperationV7 | UserOperationV8 | UserOperationV9).factory,\n\t\t)\n\t) {\n\t\tconst eip7702Auth = (userOperation as UserOperationV8 | UserOperationV9).eip7702Auth;\n\t\tif (eip7702Auth != null && eip7702Auth.address != null) {\n\t\t\tconst delegationCode = `0xef0100${eip7702Auth.address.toLowerCase().replace(\"0x\", \"\")}`;\n\t\t\tstateOverrides = withSenderCodeOverride(stateOverrides, userOperation.sender, delegationCode);\n\t\t}\n\t}\n\n\tconst simulation = await callTenderlySimulateBundle(\n\t\ttenderlyAccountSlug,\n\t\ttenderlyProjectSlug,\n\t\ttenderlyAccessKey,\n\t\t[\n\t\t\t{\n\t\t\t\tchainId,\n\t\t\t\tblockNumber,\n\t\t\t\tfrom: \"0x1000000000000000000000000000000000000000\",\n\t\t\t\tto: entrypointAddress,\n\t\t\t\tdata: callData,\n\t\t\t\tstateOverrides,\n\t\t\t},\n\t\t],\n\t);\n\treturn 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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\tchainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation:\n\t\t| UserOperationV6ToSimulate\n\t\t| UserOperationV7ToSimulate\n\t\t| UserOperationV8ToSimulate\n\t\t| UserOperationV9ToSimulate,\n\tblockNumber: number | null = null,\n\tstateOverrides?: OverrideType | null,\n): Promise<{\n\tsimulation: TenderlySimulationResult;\n\tcallDataSimulationShareLink: string;\n\taccountDeploymentSimulationShareLink?: string;\n}> {\n\tconst simulation = await simulateUserOperationCallDataWithTenderly(\n\t\ttenderlyAccountSlug,\n\t\ttenderlyProjectSlug,\n\t\ttenderlyAccessKey,\n\t\tchainId,\n\t\tentrypointAddress,\n\t\tuserOperation,\n\t\tblockNumber,\n\t\tstateOverrides,\n\t);\n\tconst simulationIds = simulation.map((s) => s.simulation.id);\n\tawait Promise.all(\n\t\tsimulationIds.map((simulationId) =>\n\t\t\tshareTenderlySimulationAndCreateLink(\n\t\t\t\ttenderlyAccountSlug,\n\t\t\t\ttenderlyProjectSlug,\n\t\t\t\ttenderlyAccessKey,\n\t\t\t\tsimulationId,\n\t\t\t),\n\t\t),\n\t);\n\n\tconst simulationLinks = simulationIds.map(\n\t\t(s) => `https://dashboard.tenderly.co/shared/simulation/${s}`,\n\t);\n\tif (simulationLinks.length === 1) {\n\t\treturn {\n\t\t\tsimulation,\n\t\t\tcallDataSimulationShareLink: simulationLinks[0],\n\t\t};\n\t} else if (simulationLinks.length === 2) {\n\t\treturn {\n\t\t\tsimulation,\n\t\t\taccountDeploymentSimulationShareLink: simulationLinks[0],\n\t\t\tcallDataSimulationShareLink: simulationLinks[1],\n\t\t};\n\t} else {\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"invalid number of simulations returned\", {\n\t\t\tcontext: JSON.stringify(simulation, (_key, value) =>\n\t\t\t\ttypeof value === \"bigint\" ? `0x${value.toString(16)}` : value,\n\t\t\t),\n\t\t});\n\t}\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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\tchainId: bigint,\n\tentrypointAddress: string,\n\tuserOperation:\n\t\t| UserOperationV6ToSimulate\n\t\t| UserOperationV7ToSimulate\n\t\t| UserOperationV8ToSimulate\n\t\t| UserOperationV9ToSimulate,\n\tblockNumber: number | null = null,\n\tstateOverrides?: OverrideType | null,\n): Promise<TenderlySimulationResult> {\n\tlet factory = null;\n\tlet factoryData = null;\n\tconst entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n\tconst isV6UserOperation = \"initCode\" in userOperation;\n\tconst isV6Entrypoint =\n\t\tentrypointAddressLowerCase === \"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789\";\n\n\tif (isV6UserOperation !== isV6Entrypoint) {\n\t\tthrow new RangeError(\"UserOperation version does not match entrypoint.\");\n\t}\n\n\tlet callData = userOperation.callData;\n\tif (\"initCode\" in userOperation) {\n\t\tif (userOperation.initCode != null && userOperation.initCode.length > 2) {\n\t\t\t// initCode = 20-byte factory address (\"0x\" + 40 hex chars) ‖ factoryData\n\t\t\tfactory = userOperation.initCode.slice(0, 42);\n\t\t\tfactoryData = `0x${userOperation.initCode.slice(42)}`;\n\t\t}\n\t} else {\n\t\tfactory = userOperation.factory;\n\t\tfactoryData = userOperation.factoryData;\n\n\t\t// EIP-7702 userOps use a \"0x7702\" factory sentinel instead of a real\n\t\t// factory. Mirror the full handleOps simulation: install the sender's\n\t\t// delegation code (0xef0100 ‖ delegatee) as a state override, and treat\n\t\t// non-empty factoryData as the sender initialization call — made by the\n\t\t// SenderCreator to the sender itself, not to a factory.\n\t\tif (isEip7702FactorySentinel(factory)) {\n\t\t\tconst eip7702Auth = (userOperation as UserOperationV8ToSimulate | UserOperationV9ToSimulate)\n\t\t\t\t.eip7702Auth;\n\t\t\tif (eip7702Auth != null && eip7702Auth.address != null) {\n\t\t\t\tconst delegationCode = `0xef0100${eip7702Auth.address.toLowerCase().replace(\"0x\", \"\")}`;\n\t\t\t\tstateOverrides = withSenderCodeOverride(\n\t\t\t\t\tstateOverrides,\n\t\t\t\t\tuserOperation.sender,\n\t\t\t\t\tdelegationCode,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (factoryData != null && factoryData !== \"0x\") {\n\t\t\t\tfactory = userOperation.sender;\n\t\t\t} else {\n\t\t\t\tfactory = null;\n\t\t\t\tfactoryData = null;\n\t\t\t}\n\t\t}\n\n\t\t// IAccountExecute.executeUserOp rewrite: when callData starts with the\n\t\t// executeUserOp selector (0x8dd7712f), EntryPoint calls\n\t\t// sender.executeUserOp(packedUserOp, userOpHash) instead of\n\t\t// sender.call(callData). Replicate here.\n\t\tconst EXECUTE_USEROP_SELECTOR = \"0x8dd7712f\";\n\t\tif (callData.toLowerCase().startsWith(EXECUTE_USEROP_SELECTOR)) {\n\t\t\tconst initCode = buildWireInitCode(userOperation.factory, userOperation.factoryData);\n\n\t\t\tconst accountGasLimits =\n\t\t\t\t\"0x\" +\n\t\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.verificationGasLimit]).slice(34) +\n\t\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.callGasLimit]).slice(34);\n\n\t\t\tconst gasFees =\n\t\t\t\t\"0x\" +\n\t\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.maxPriorityFeePerGas]).slice(34) +\n\t\t\t\tencodeAbiParameters([\"uint128\"], [userOperation.maxFeePerGas]).slice(34);\n\n\t\t\tlet paymasterAndData = \"0x\";\n\t\t\tif (userOperation.paymaster != null) {\n\t\t\t\tpaymasterAndData = userOperation.paymaster;\n\t\t\t\tif (userOperation.paymasterVerificationGasLimit != null) {\n\t\t\t\t\tpaymasterAndData += encodeAbiParameters(\n\t\t\t\t\t\t[\"uint128\"],\n\t\t\t\t\t\t[userOperation.paymasterVerificationGasLimit],\n\t\t\t\t\t).slice(34);\n\t\t\t\t}\n\t\t\t\tif (userOperation.paymasterPostOpGasLimit != null) {\n\t\t\t\t\tpaymasterAndData += encodeAbiParameters(\n\t\t\t\t\t\t[\"uint128\"],\n\t\t\t\t\t\t[userOperation.paymasterPostOpGasLimit],\n\t\t\t\t\t).slice(34);\n\t\t\t\t}\n\t\t\t\tif (userOperation.paymasterData != null) {\n\t\t\t\t\tpaymasterAndData += userOperation.paymasterData.slice(2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst userOpHash = createUserOperationHash(\n\t\t\t\tuserOperation as UserOperationV7 | UserOperationV8 | UserOperationV9,\n\t\t\t\tentrypointAddress,\n\t\t\t\tchainId,\n\t\t\t);\n\n\t\t\tconst packedUserOp = [\n\t\t\t\tuserOperation.sender,\n\t\t\t\tuserOperation.nonce,\n\t\t\t\tinitCode,\n\t\t\t\tuserOperation.callData,\n\t\t\t\taccountGasLimits,\n\t\t\t\tuserOperation.preVerificationGas,\n\t\t\t\tgasFees,\n\t\t\t\tpaymasterAndData,\n\t\t\t\tuserOperation.signature,\n\t\t\t];\n\n\t\t\tconst encodedParams = encodeAbiParameters(\n\t\t\t\t[\"(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)\", \"bytes32\"],\n\t\t\t\t[packedUserOp, userOpHash],\n\t\t\t);\n\t\t\tcallData = EXECUTE_USEROP_SELECTOR + encodedParams.slice(2);\n\t\t}\n\t}\n\n\treturn await simulateSenderCallDataWithTenderly(\n\t\ttenderlyAccountSlug,\n\t\ttenderlyProjectSlug,\n\t\ttenderlyAccessKey,\n\t\tchainId,\n\t\tentrypointAddress,\n\t\tuserOperation.sender,\n\t\tcallData,\n\t\tfactory,\n\t\tfactoryData,\n\t\tblockNumber,\n\t\tstateOverrides,\n\t);\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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\tchainId: bigint,\n\tentrypointAddress: string,\n\tsender: string,\n\tcallData: string,\n\tfactory: string | null = null,\n\tfactoryData: string | null = null,\n\tblockNumber: number | null = null,\n\tstateOverrides?: OverrideType | null,\n): Promise<{\n\tsimulation: TenderlySimulationResult;\n\tcallDataSimulationShareLink: string;\n\taccountDeploymentSimulationShareLink?: string;\n}> {\n\tconst simulation = await simulateSenderCallDataWithTenderly(\n\t\ttenderlyAccountSlug,\n\t\ttenderlyProjectSlug,\n\t\ttenderlyAccessKey,\n\t\tchainId,\n\t\tentrypointAddress,\n\t\tsender,\n\t\tcallData,\n\t\tfactory,\n\t\tfactoryData,\n\t\tblockNumber,\n\t\tstateOverrides,\n\t);\n\tconst simulationIds = simulation.map((s) => s.simulation.id);\n\tawait Promise.all(\n\t\tsimulationIds.map((simulationId) =>\n\t\t\tshareTenderlySimulationAndCreateLink(\n\t\t\t\ttenderlyAccountSlug,\n\t\t\t\ttenderlyProjectSlug,\n\t\t\t\ttenderlyAccessKey,\n\t\t\t\tsimulationId,\n\t\t\t),\n\t\t),\n\t);\n\n\tconst simulationLinks = simulationIds.map(\n\t\t(s) => `https://dashboard.tenderly.co/shared/simulation/${s}`,\n\t);\n\tif (simulationLinks.length === 1) {\n\t\treturn {\n\t\t\tsimulation,\n\t\t\tcallDataSimulationShareLink: simulationLinks[0],\n\t\t};\n\t} else if (simulationLinks.length === 2) {\n\t\treturn {\n\t\t\tsimulation,\n\t\t\taccountDeploymentSimulationShareLink: simulationLinks[0],\n\t\t\tcallDataSimulationShareLink: simulationLinks[1],\n\t\t};\n\t} else {\n\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"invalid number of simulations returned\", {\n\t\t\tcontext: JSON.stringify(simulation, (_key, value) =>\n\t\t\t\ttypeof value === \"bigint\" ? `0x${value.toString(16)}` : value,\n\t\t\t),\n\t\t});\n\t}\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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\tchainId: bigint,\n\tentrypointAddress: string,\n\tsender: string,\n\tcallData: string,\n\tfactory: string | null = null,\n\tfactoryData: string | null = null,\n\tblockNumber: number | null = null,\n\tstateOverrides?: OverrideType | null,\n): Promise<TenderlySimulationResult> {\n\tconst transactions = [];\n\tconst entrypointAddressLowerCase = entrypointAddress.toLowerCase();\n\tlet senderCreator: string;\n\tif (entrypointAddressLowerCase === \"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789\") {\n\t\tsenderCreator = \"0x7fc98430eaedbb6070b35b39d798725049088348\";\n\t} else if (entrypointAddressLowerCase === \"0x0000000071727de22e5e9d8baf0edac6f37da032\") {\n\t\tsenderCreator = \"0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c\";\n\t} else if (entrypointAddressLowerCase === \"0x4337084d9e255ff0702461cf8895ce9e3b5ff108\") {\n\t\tsenderCreator = \"0x449ed7c3e6fee6a97311d4b55475df59c44add33\";\n\t} else if (entrypointAddressLowerCase === \"0x433709009b8330fda32311df1c2afa402ed8d009\") {\n\t\tsenderCreator = \"0x0A630a99Df908A81115A3022927Be82f9299987e\";\n\t} else {\n\t\tthrow new RangeError(`Invalid entrypoint: ${entrypointAddress}`);\n\t}\n\n\tif ((factory == null && factoryData != null) || (factory != null && factoryData == null)) {\n\t\tthrow new RangeError(`Invalid factory and factoryData`);\n\t}\n\tif (factory != null && factoryData != null) {\n\t\ttransactions.push({\n\t\t\tchainId,\n\t\t\tblockNumber,\n\t\t\tfrom: senderCreator,\n\t\t\tto: factory,\n\t\t\tdata: factoryData,\n\t\t\tstateOverrides,\n\t\t});\n\t}\n\ttransactions.push({\n\t\tchainId,\n\t\tblockNumber,\n\t\tfrom: entrypointAddress,\n\t\tto: sender,\n\t\tdata: callData,\n\t\tstateOverrides,\n\t});\n\tconst simulationsResult = await callTenderlySimulateBundle(\n\t\ttenderlyAccountSlug,\n\t\ttenderlyProjectSlug,\n\t\ttenderlyAccessKey,\n\t\ttransactions,\n\t);\n\n\tfor (const simulationResult of simulationsResult) {\n\t\tif (simulationResult.simulation.id === \"\") {\n\t\t\tthrow new AbstractionKitError(\"TENDERLY_SIMULATION_ERROR\", \"tenderly simulation failed\", {\n\t\t\t\tcontext: JSON.stringify(simulationsResult, (_key, value) =>\n\t\t\t\t\ttypeof value === \"bigint\" ? `0x${value.toString(16)}` : value,\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t}\n\treturn simulationsResult;\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\ttenderlyAccountSlug: string,\n\ttenderlyProjectSlug: string,\n\ttenderlyAccessKey: string,\n\ttransactions: {\n\t\tchainId: bigint;\n\t\tfrom: string;\n\t\tto: string;\n\t\tdata: string;\n\t\tgas?: number | null;\n\t\tgasPrice?: bigint | number | null;\n\t\tvalue?: bigint | number | null;\n\t\tblockNumber?: number | null;\n\t\tsimulationType?: \"full\" | \"quick\" | \"abi\";\n\t\tstateOverrides?: OverrideType | null;\n\t\ttransactionIndex?: number;\n\t\tsave?: boolean;\n\t\tsaveIfFails?: boolean;\n\t\testimateGas?: boolean;\n\t\tgenerateAccessList?: boolean;\n\t\taccessList?: { address: string }[];\n\t}[],\n): Promise<TenderlySimulationResult> {\n\tconst tenderlyUrl =\n\t\t\"https://api.tenderly.co/api/v1/account/\" +\n\t\ttenderlyAccountSlug +\n\t\t\"/project/\" +\n\t\ttenderlyProjectSlug +\n\t\t\"/simulate-bundle\";\n\tconst simulations = transactions.map((transaction) => {\n\t\tconst transactionObject: Record<\n\t\t\tstring,\n\t\t\tstring | number | boolean | OverrideType | { address: string }[]\n\t\t> = {\n\t\t\tnetwork_id: transaction.chainId.toString(),\n\t\t\tsave: transaction.save ?? true,\n\t\t\tsave_if_fails: transaction.saveIfFails ?? true,\n\t\t\tfrom: transaction.from,\n\t\t\tto: transaction.to,\n\t\t\tinput: transaction.data,\n\t\t\tsimulation_type: transaction.simulationType ?? \"full\",\n\t\t};\n\t\tif (transaction.blockNumber != null) {\n\t\t\ttransactionObject.block_number = transaction.blockNumber;\n\t\t}\n\n\t\tif (transaction.gas != null) {\n\t\t\ttransactionObject.gas = transaction.gas;\n\t\t}\n\t\tif (transaction.gasPrice != null) {\n\t\t\t// serialize bigint as a decimal string so wei amounts above 2^53\n\t\t\t// don't lose precision\n\t\t\ttransactionObject.gas_price =\n\t\t\t\ttypeof transaction.gasPrice === \"bigint\"\n\t\t\t\t\t? transaction.gasPrice.toString()\n\t\t\t\t\t: transaction.gasPrice;\n\t\t}\n\t\tif (transaction.value != null) {\n\t\t\ttransactionObject.value =\n\t\t\t\ttypeof transaction.value === \"bigint\"\n\t\t\t\t\t? transaction.value.toString()\n\t\t\t\t\t: transaction.value;\n\t\t}\n\t\tif (transaction.stateOverrides != null) {\n\t\t\t// build a copy instead of rewriting the caller-owned object in place.\n\t\t\t// Keys are EVM addresses: lowercase them so the payload carries one\n\t\t\t// canonical key per address, and reject same-address keys that differ\n\t\t\t// only in case rather than silently letting one override the other.\n\t\t\tconst stateOverrides: OverrideType = {};\n\t\t\tfor (const address in transaction.stateOverrides) {\n\t\t\t\tconst entry = { ...transaction.stateOverrides[address] };\n\t\t\t\tfor (const key in entry) {\n\t\t\t\t\tif (key !== \"balance\" && key !== \"code\" && key !== \"storage\" && key !== \"stateDiff\") {\n\t\t\t\t\t\tthrow new RangeError(`Invalid stateOverrides key: ${key}.`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (\"storage\" in entry && \"stateDiff\" in entry) {\n\t\t\t\t\tthrow new RangeError(\"can't set both storage and stateDiff for stateOverrides\");\n\t\t\t\t}\n\t\t\t\tif (\"stateDiff\" in entry) {\n\t\t\t\t\tentry.storage = entry.stateDiff;\n\t\t\t\t\tdelete entry.stateDiff;\n\t\t\t\t}\n\t\t\t\tconst addressLower = address.toLowerCase();\n\t\t\t\tif (addressLower in stateOverrides) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t`Duplicate stateOverrides address (case-insensitive): ${address}.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tstateOverrides[addressLower] = entry;\n\t\t\t}\n\t\t\ttransactionObject.state_objects = stateOverrides;\n\t\t}\n\n\t\tif (transaction.transactionIndex != null) {\n\t\t\ttransactionObject.transaction_index = transaction.transactionIndex;\n\t\t}\n\t\tif (transaction.estimateGas != null) {\n\t\t\ttransactionObject.estimate_gas = transaction.estimateGas;\n\t\t}\n\t\tif (transaction.generateAccessList != null) {\n\t\t\ttransactionObject.generate_access_list = transaction.generateAccessList;\n\t\t}\n\t\tif (transaction.accessList != null) {\n\t\t\ttransactionObject.access_list = transaction.accessList;\n\t\t}\n\t\treturn transactionObject;\n\t});\n\n\tconst headers = {\n\t\tAccept: \"application/json\",\n\t\t\"Content-Type\": \"application/json\",\n\t\t\"X-Access-Key\": tenderlyAccessKey,\n\t};\n\tconst body = JSON.stringify(\n\t\t{\n\t\t\tmethod: \"tenderly_simulateBundle\",\n\t\t\tsimulations,\n\t\t\tid: Date.now(),\n\t\t\tjsonrpc: \"2.0\",\n\t\t},\n\t\t(_key, value) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: JSON.stringify replacer\n\t\t\ttypeof value === \"bigint\" ? `0x${(value as bigint).toString(16)}` : (value as any),\n\t);\n\tlet response: Response;\n\ttry {\n\t\tresponse = await fetch(tenderlyUrl, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders,\n\t\t\tbody,\n\t\t\tredirect: \"follow\",\n\t\t});\n\t} catch (err) {\n\t\tconst e = ensureError(err);\n\t\tthrow new AbstractionKitError(\n\t\t\t\"TENDERLY_NETWORK_ERROR\",\n\t\t\t`tenderly_simulateBundle network error: ${e.message}`,\n\t\t\t{ cause: e },\n\t\t);\n\t}\n\n\tif (!response.ok) {\n\t\tthrow new AbstractionKitError(\n\t\t\t\"TENDERLY_HTTP_ERROR\",\n\t\t\t`tenderly_simulateBundle HTTP ${response.status}: ${response.statusText}`,\n\t\t\t{\n\t\t\t\terrno: response.status,\n\t\t\t\tcontext: { status: response.status, statusText: response.statusText },\n\t\t\t},\n\t\t);\n\t}\n\n\tconst responseText = await response.text();\n\tlet json: {\n\t\tsimulation_results?: TenderlySimulationResult;\n\t\terror?: { code: number; message: string };\n\t};\n\ttry {\n\t\tjson = JSON.parse(responseText);\n\t} catch (err) {\n\t\tconst e = ensureError(err);\n\t\tthrow new AbstractionKitError(\n\t\t\t\"TENDERLY_INVALID_JSON\",\n\t\t\t`tenderly_simulateBundle returned invalid JSON: ${e.message}`,\n\t\t\t{ cause: e, context: { responseText } },\n\t\t);\n\t}\n\n\tif (json.simulation_results != null) {\n\t\treturn json.simulation_results;\n\t}\n\tthrow new AbstractionKitError(\"TENDERLY_SIMULATION_ERROR\", \"tenderly_simulateBundle failed\", {\n\t\terrno: json.error?.code,\n\t\tcontext: JSON.stringify(json),\n\t});\n}\n","import { decodeAbiParameters, getBytes, solidityPacked } from \"../../ethereUtils\";\nimport { type MetaTransaction, Operation } from \"src/types\";\n\n/**\n * Pack a single MetaTransaction into the MultiSend byte layout\n * (operation, to, value, dataLength, data).\n * @param metaTransaction - The transaction to encode\n * @returns The encoded transaction bytes (without 0x prefix)\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 * Encode a list of MetaTransactions into the `multiSend` argument for batch execution.\n * @param metaTransactions - The transactions to batch\n * @returns The concatenated encoded transactions as a 0x-prefixed hex string\n */\nexport function encodeMultiSendCallData(metaTransactions: MetaTransaction[]): string {\n\treturn `0x${metaTransactions.map((tx) => encodeMultiSendTransaction(tx)).join(\"\")}`;\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 decodedCalldata = decodeAbiParameters<[string]>([\"bytes\"], `0x${callData.slice(10)}`);\n\treturn decodedCalldata[0];\n}\n","import { hashMessage } from \"../../ethereUtils\";\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\tSafeMessage: [{ type: \"bytes\", name: \"message\" }],\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\taccountAddress: string,\n\tchainId: bigint,\n\tmessage: string,\n): {\n\tdomain: SafeMessageTypedDataDomain;\n\ttypes: Record<string, { name: string; type: string }[]>;\n\tmessageValue: SafeMessageTypedMessageValue;\n} {\n\tconst messageValue: SafeMessageTypedMessageValue = {\n\t\tmessage: hashMessage(message),\n\t};\n\tconst domain: SafeMessageTypedDataDomain = {\n\t\tchainId: Number(chainId),\n\t\tverifyingContract: accountAddress,\n\t};\n\n\treturn {\n\t\tdomain,\n\t\ttypes: SAFE_MESSAGE_MODULE_TYPE,\n\t\tmessageValue,\n\t};\n}\n","import type {\n\tGasOption,\n\tOnChainIdentifierParamsType,\n\tPolygonChain,\n\tStateOverrideSet,\n\tUserOperationV9,\n} from \"../../types\";\n\n/**\n * Overrides for the \"createBaseUserOperationAndFactoryAddressAndFactoryData\" function\n */\nexport interface CreateBaseUserOperationOverrides {\n\t/** set the nonce instead of querying 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 querying the current gas price from the rpc node */\n\tmaxFeePerGas?: bigint;\n\t/** set the maxPriorityFeePerGas instead of querying 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 querying the current gas price from the rpc node */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** set the maxPriorityFeePerGasPercentageMultiplier instead of querying 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/**\n\t * Skip calling the bundler's gas estimation entirely. When true, the returned\n\t * UserOperation still gets a dummy signature, but its gas limits come from the\n\t * provided overrides (or stay at 0n). Useful when estimation is run separately\n\t * — for example, by a paymaster sponsorship call that returns its own limits.\n\t */\n\tskipGasEstimation?: boolean;\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\texpectedSigners?: 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 extends 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 extends 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 initializing 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\tonChainIdentifierParams?: OnChainIdentifierParamsType;\n\tonChainIdentifier?: 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/**\n * WebAuthn-specific overrides for signature encoding: verifier addresses,\n * shared-signer routing, and the init-flag that switches between them.\n * Only fields tied to WebAuthn semantics belong here; per-call signing\n * parameters (timing, multi-chain, target module) live on\n * {@link SafeSignatureOptions}.\n */\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}\n\n/**\n * Per-call options for Safe UserOperation signing/formatting. Carries\n * timing, multi-chain encoding, and module-address routing. Future\n * per-call flags are added here, not on {@link WebAuthnSignatureOverrides}.\n */\nexport interface SafeSignatureOptions {\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/** Encode as a multi-chain signature (single op, or with Merkle proof) */\n\tisMultiChainSignature?: boolean;\n\t/** Merkle proof bytes (with 0x prefix) for multi-chain signatures over multiple ops */\n\tmultiChainMerkleProof?: string;\n\t/** Override the Safe 4337 module address used when constructing the signature */\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\n\textends SafeUserOperationV7TypedMessageValue {}\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\t\t\"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\tchainId: bigint;\n\tuserOperation: UserOperationV9;\n\tvalidAfter?: bigint;\n\tvalidUntil?: bigint;\n}\n\n/** Extends UserOperationToSign with per-operation options + WebAuthn overrides. */\nexport interface UserOperationToSignWithOverrides extends UserOperationToSign {\n\toptions?: SafeSignatureOptions;\n\twebAuthnSignatureOverrides?: WebAuthnSignatureOverrides;\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 {\n\tconcat,\n\tdataLength,\n\tdecodeAbiParameters,\n\tencodeAbiParameters,\n\tgetAddress,\n\thashTypedData,\n\thexlify,\n\tkeccak256,\n\tprivateKeyToAddress,\n\tsignHash,\n\tsolidityPacked,\n\tsolidityPackedKeccak256,\n\ttoUtf8Bytes,\n} from \"src/ethereUtils\";\nimport {Bundler} from \"src/Bundler\";\nimport {AbstractionKitError, ensureError} from \"src/errors\";\nimport {SafeAccountFactory} from \"src/factory/SafeAccountFactory\";\nimport {invokeSigner, pickScheme} from \"src/signer/negotiate\";\nimport type {ExternalSigner, SigningScheme, TypedData} from \"src/signer/types\";\nimport {JsonRpcNode, type Transport} from \"src/transport\";\nimport {\n\tBaseUserOperationDummyValues,\n\tEIP712_SAFE_OPERATION_PRIMARY_TYPE,\n\tEIP712_SAFE_OPERATION_V6_TYPE,\n\tEIP712_SAFE_OPERATION_V7_TYPE,\n\tENTRYPOINT_V6,\n\tENTRYPOINT_V7,\n\tENTRYPOINT_V9,\n\tSAFE_FALLBACK_HANDLER_STORAGE_SLOT,\n\tSafe_L2_V1_4_1,\n\tZeroAddress,\n} from \"../../constants\";\nimport {\n\ttype AbiInputValue,\n\ttype BaseUserOperation,\n\ttype MetaTransaction,\n\ttype OnChainIdentifierParamsType,\n\tOperation,\n\ttype StateOverrideSet,\n\ttype TenderlySimulationResult,\n\ttype UserOperationV6,\n\ttype UserOperationV7,\n\ttype UserOperationV9,\n} from \"../../types\";\nimport {createCallData, fetchAccountNonce, getFunctionSelector, handlefetchGasPrice,} from \"../../utils\";\nimport {\n\tsimulateSenderCallDataWithTenderly,\n\tsimulateSenderCallDataWithTenderlyAndCreateShareLink,\n} from \"../../utilsTenderly\";\nimport {SendUseroperationResponse} from \"../SendUseroperationResponse\";\nimport {SmartAccount} from \"../SmartAccount\";\nimport {decodeMultiSendCallData, encodeMultiSendCallData} from \"./multisend\";\nimport {\n\tgetSafeMessageEip712Data,\n\ttype SafeMessageTypedDataDomain,\n\ttype SafeMessageTypedMessageValue,\n} from \"./safeMessage\";\nimport {\n\ttype BaseInitOverrides,\n\ttype CreateBaseUserOperationOverrides,\n\ttype CreateUserOperationV6Overrides,\n\tEOADummySignerSignaturePair,\n\ttype SafeAccountSingleton,\n\tSafeModuleExecutorFunctionSelector,\n\ttype SafeSignatureOptions,\n\ttype SafeUserOperationTypedDataDomain,\n\ttype SafeUserOperationV6TypedMessageValue,\n\ttype SafeUserOperationV7TypedMessageValue,\n\ttype SafeUserOperationV9TypedMessageValue,\n\ttype Signer,\n\ttype SignerSignaturePair,\n\tWebauthnDummySignerSignaturePair,\n\ttype WebauthnPublicKey,\n\ttype WebauthnSignatureData,\n\ttype WebAuthnSignatureOverrides,\n} from \"./types\";\n\n/**\n * Base implementation shared by all Safe-account variants.\n *\n * Provides the core logic for Safe ERC-4337 accounts: counterfactual address\n * derivation, initializer/factory-data encoding, EIP-712 UserOperation signing,\n * multi-signer aggregation (ECDSA + WebAuthn), module enable/disable helpers,\n * and UserOperation construction. Versioned subclasses\n * ({@link SafeAccountV0_2_0}, {@link SafeAccountV0_3_0},\n * {@link SafeAccountV1_5_0_M_0_3_0}) bind this class to a specific EntryPoint\n * and Safe singleton, and expose version-typed wrappers.\n *\n * Instantiate directly only for an already-deployed account; use a subclass's\n * static `initializeNewAccount` to produce a counterfactual account + factory\n * data for first-time deployment.\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\t// EIP-7212 contract verifier used in the verifier proxy CREATE2 salt and\n\t// installed as the shared signer's contract verifier at init time.\n\t// Defaults to FCL P256 because that's what Safe Passkey module v0.2.0\n\t// shipped — newer modules (v0.2.1+, v1.5.0_M_0.3.0) override with Daimo.\n\t// FCL has known non-security-critical bugs and is being phased out\n\t// upstream now that EIP-7951 (precompile) supersedes it.\n\tstatic readonly DEFAULT_WEB_AUTHN_CONTRACT_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 = \"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\treadonly onChainIdentifier: string | null;\n\n\t/**\n\t * @param accountAddress - On-chain address of the Safe account\n\t * @param safe4337ModuleAddress - Address of the Safe 4337 module the account delegates to\n\t * @param entrypointAddress - Target EntryPoint address (v0.6 / v0.7 / v0.9)\n\t * @param overrides - Optional on-chain-identifier configuration and custom singleton\n\t * @param overrides.onChainIdentifierParams - Attribution params for analytics (mutually exclusive with `onChainIdentifier`)\n\t * @param overrides.onChainIdentifier - Pre-computed 32-byte identifier hex (no 0x prefix or with 0x)\n\t * @param overrides.safeAccountSingleton - Override Safe singleton address + init hash (defaults to Safe L2 v1.4.1)\n\t */\n\tconstructor(\n\t\taccountAddress: string,\n\t\tsafe4337ModuleAddress: string,\n\t\tentrypointAddress: string,\n\t\toverrides: {\n\t\t\tonChainIdentifierParams?: OnChainIdentifierParamsType;\n\t\t\tonChainIdentifier?: string;\n\t\t\tsafeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\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\t\tif (overrides.onChainIdentifierParams != null && overrides.onChainIdentifier != null) {\n\t\t\tthrow new RangeError(\"can't override both onChainIdentifier and onChainIdentifierParams\");\n\t\t} else if (overrides.onChainIdentifierParams != null) {\n\t\t\tthis.onChainIdentifier = generateOnChainIdentifier(\n\t\t\t\toverrides.onChainIdentifierParams.project,\n\t\t\t\toverrides.onChainIdentifierParams.platform,\n\t\t\t\toverrides.onChainIdentifierParams.tool,\n\t\t\t\toverrides.onChainIdentifierParams.toolVersion,\n\t\t\t);\n\t\t} else if (overrides.onChainIdentifier != null) {\n\t\t\tlet onChainIdentifier = overrides.onChainIdentifier;\n\t\t\tif (onChainIdentifier.startsWith(\"0x\")) {\n\t\t\t\tonChainIdentifier = onChainIdentifier.slice(2);\n\t\t\t}\n\t\t\tif (onChainIdentifier.length !== 64) {\n\t\t\t\tthrow new RangeError(\"onChainIdentifier length must be 64.\");\n\t\t\t}\n\t\t\tthis.onChainIdentifier = onChainIdentifier;\n\t\t} else {\n\t\t\tthis.onChainIdentifier = null;\n\t\t}\n\t\tthis.safeAccountSingleton = overrides.safeAccountSingleton ?? Safe_L2_V1_4_1;\n\t}\n\n\t/**\n\t * calculate proxy/account address using initializer 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 the 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 ?? SafeAccountFactory.DEFAULT_FACTORY_ADDRESS;\n\t\tconst singletonInitHash = overrides.singletonInitHash ?? Safe_L2_V1_4_1.singletonInitHash;\n\t\tconst salt = keccak256(\n\t\t\tsolidityPacked([\"bytes32\", \"uint256\"], [keccak256(initializerCallData), c2Nonce]),\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 * Check whether a Safe account is already deployed at the given address.\n\t *\n\t * Use this to decide between connecting to an existing account\n\t * (`new SafeAccountV0_3_0(address)`) and initializing a new one\n\t * (`SafeAccountV0_3_0.initializeNewAccount(owners)`). Once an account is\n\t * deployed, the factory data carried by `initializeNewAccount` is no\n\t * longer needed and including it would waste gas.\n\t *\n\t * Note: this only checks whether bytecode exists at `accountAddress`, not\n\t * whether the deployed code is actually a Safe or whether its on-chain\n\t * configuration matches a given set of owners.\n\t *\n\t * @param accountAddress - the Safe account address to check\n\t * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n\t * @returns `true` if bytecode is deployed at `accountAddress`, `false` otherwise\n\t *\n\t * @example\n\t * ```ts\n\t * const account = (await SafeAccountV0_3_0.isDeployed(addr, rpc))\n\t *   ? new SafeAccountV0_3_0(addr)\n\t *   : SafeAccountV0_3_0.initializeNewAccount(owners);\n\t * ```\n\t */\n\tpublic static async isDeployed(\n\t\taccountAddress: string,\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t): Promise<boolean> {\n\t\tconst code = await JsonRpcNode.from(nodeRpcUrl).getCode(accountAddress, \"latest\");\n\t\treturn code.length > 2;\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 ?? SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS;\n\n\t\tconst multiData = encodeMultiSendCallData(metaTransactions);\n\n\t\tconst mutisendSelector = \"0x8d80ff0a\";\n\t\tconst multiSendCallData = createCallData(mutisendSelector, [\"bytes\"], [multiData]);\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 native token to transfer 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 = null;\n\t\tif (callData.startsWith(SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString)) {\n\t\t\tsafeModuleExecutorFunctionSelector =\n\t\t\t\tSafeModuleExecutorFunctionSelector.executeUserOpWithErrorString;\n\t\t} else if (callData.startsWith(SafeModuleExecutorFunctionSelector.executeUserOp)) {\n\t\t\tsafeModuleExecutorFunctionSelector = SafeModuleExecutorFunctionSelector.executeUserOp;\n\t\t}\n\t\tif (safeModuleExecutorFunctionSelector != null) {\n\t\t\tconst params = `0x${callData.slice(10)}`;\n\t\t\tconst decodedParams = decodeAbiParameters<[string, bigint, string | Uint8Array, bigint]>(\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\t// decodeAbiParameters returns the \"bytes\" field as either a hex\n\t\t\t// string or a Uint8Array. UTF-8 decoding the bytes would corrupt\n\t\t\t// any non-text payload (function selectors, addresses, multisend\n\t\t\t// blobs); hex-encode instead so the calldata round-trips.\n\t\t\tconst accountCallDataString: string =\n\t\t\t\ttypeof decodedParams[2] === \"string\" ? decodedParams[2] : hexlify(decodedParams[2]);\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tto: decodedParams[0],\n\t\t\t\t\tvalue: BigInt(decodedParams[1]),\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 ?? SafeAccount.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(approveFunctionSignature);\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([approveMetatransaction]);\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 = encodedApproveMetatransaction + decodedCalldata.slice(2);\n\t\t} else {\n\t\t\tconst encodedCallDataMetaTransaction = encodeMultiSendCallData([metaTransaction]);\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\t * @deprecated\n\t * format 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\t\t\tisMultiChainSignature?: 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(\"signersAddresses and signatures arrays should be the same length\");\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\tsigner: signer.toLowerCase(),\n\t\t\t\tsignature: signatures[index],\n\t\t\t});\n\t\t});\n\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(signersSignatures, {\n\t\t\tvalidAfter: overrides.validAfter,\n\t\t\tvalidUntil: overrides.validUntil,\n\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\tmultiChainMerkleProof: overrides.merkleProof,\n\t\t});\n\t}\n\n\t/**\n\t * Get the EIP-712 typed data for this account's configured EntryPoint and\n\t * Safe 4337 module. Prefer this instance method for manual signing so\n\t * custom constructor overrides are carried through automatically.\n\t *\n\t * @param useroperation - UserOperation to get typed data for\n\t * @param chainId - target chain ID\n\t * @param overrides - optional validity window and explicit address overrides\n\t * @returns Object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic 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\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue:\n\t\t\t| SafeUserOperationV6TypedMessageValue\n\t\t\t| SafeUserOperationV7TypedMessageValue\n\t\t\t| SafeUserOperationV9TypedMessageValue;\n\t} {\n\t\treturn SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\t...overrides,\n\t\t\tentrypointAddress: overrides.entrypointAddress ?? this.entrypointAddress,\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress ?? this.safe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Hash the EIP-712 typed data for this account's configured EntryPoint and\n\t * Safe 4337 module. Prefer this instance method for manual signing so\n\t * custom constructor overrides are carried through automatically.\n\t *\n\t * @param useroperation - UserOperation to hash\n\t * @param chainId - target chain ID\n\t * @param overrides - optional validity window and explicit address overrides\n\t * @returns EIP-712 digest as a hex string\n\t */\n\tpublic 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\tconst data = this.getUserOperationEip712Data(useroperation, chainId, overrides);\n\t\treturn hashTypedData(data.domain, data.types, data.messageValue);\n\t}\n\n\t/**\n\t * Format signer/signature pairs for this account's signature encoding.\n\t * Prefer this instance method for manual signing so account-level module\n\t * context is applied automatically.\n\t *\n\t * @param signerSignaturePairs - signer/signature pairs to encode\n\t * @param options - optional validity window, multi-chain, module, and WebAuthn encoding overrides\n\t * @returns formatted UserOperation signature\n\t */\n\tpublic formatUserOperationSignature(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toptions: SafeSignatureOptions & WebAuthnSignatureOverrides = {},\n\t): string {\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(signerSignaturePairs, {\n\t\t\t...options,\n\t\t\tsafe4337ModuleAddress: options.safe4337ModuleAddress ?? this.safe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\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(useroperation, chainId, overrides);\n\t\t} else {\n\t\t\tif (overrides.entrypointAddress) {\n\t\t\t\tif (overrides.entrypointAddress.toLowerCase() === ENTRYPOINT_V9.toLowerCase()) {\n\t\t\t\t\treturn SafeAccount.getUserOperationEip712Hash_V9(\n\t\t\t\t\t\tuseroperation as UserOperationV9,\n\t\t\t\t\t\tchainId,\n\t\t\t\t\t\toverrides,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\treturn SafeAccount.getUserOperationEip712Hash_V7(useroperation, chainId, overrides);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn SafeAccount.getUserOperationEip712Hash_V7(useroperation, chainId, overrides);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\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\t * object needed for hashing and signing\n\t */\n\tprotected 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\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue:\n\t\t\t| SafeUserOperationV6TypedMessageValue\n\t\t\t| SafeUserOperationV7TypedMessageValue\n\t\t\t| SafeUserOperationV9TypedMessageValue;\n\t} {\n\t\tif (\"initCode\" in useroperation) {\n\t\t\tconst data = SafeAccount.getUserOperationEip712Data_V6(useroperation, chainId, overrides);\n\t\t\treturn {\n\t\t\t\tdomain: data.domain,\n\t\t\t\ttypes: data.types,\n\t\t\t\tmessageValue: data.messageValue,\n\t\t\t};\n\t\t} else {\n\t\t\tlet data:\n\t\t\t\t| ReturnType<typeof SafeAccount.getUserOperationEip712Data_V7>\n\t\t\t\t| ReturnType<typeof SafeAccount.getUserOperationEip712Data_V9>;\n\t\t\tif (overrides?.entrypointAddress) {\n\t\t\t\tif (overrides.entrypointAddress.toLowerCase() === ENTRYPOINT_V9.toLowerCase()) {\n\t\t\t\t\tdata = SafeAccount.getUserOperationEip712Data_V9(\n\t\t\t\t\t\tuseroperation as UserOperationV9,\n\t\t\t\t\t\tchainId,\n\t\t\t\t\t\toverrides,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tdata = SafeAccount.getUserOperationEip712Data_V7(useroperation, chainId, overrides);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdata = SafeAccount.getUserOperationEip712Data_V7(useroperation, chainId, overrides);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdomain: data.domain,\n\t\t\t\ttypes: data.types,\n\t\t\t\tmessageValue: data.messageValue,\n\t\t\t};\n\t\t}\n\t}\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 an object containing the typed data domain, type and typed data vales\n\t * 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\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV6TypedMessageValue;\n\t} {\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 ?? \"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\t\t};\n\t}\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\tconst data = SafeAccount.getUserOperationEip712Data_V6(useroperation, chainId, overrides);\n\t\treturn hashTypedData(data.domain, data.types, data.messageValue);\n\t}\n\n\tprivate 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\t\t\tis_v9?: boolean;\n\t\t} = {},\n\t): {\n\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV6TypedMessageValue;\n\t} {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? \"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\";\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 += encodeAbiParameters(\n\t\t\t\t\t[\"uint128\"],\n\t\t\t\t\t[useroperation.paymasterVerificationGasLimit],\n\t\t\t\t).slice(34);\n\t\t\t}\n\t\t\tif (useroperation.paymasterPostOpGasLimit != null) {\n\t\t\t\tpaymasterAndData += encodeAbiParameters(\n\t\t\t\t\t[\"uint128\"],\n\t\t\t\t\t[useroperation.paymasterPostOpGasLimit],\n\t\t\t\t).slice(34);\n\t\t\t}\n\t\t\tif (useroperation.paymasterData != null) {\n\t\t\t\tconst PAYMASTER_SIG_MAGIC = \"22e325a297439656\";\n\t\t\t\tif (\n\t\t\t\t\toverrides.is_v9 &&\n\t\t\t\t\tuseroperation.paymasterData.toLowerCase().endsWith(PAYMASTER_SIG_MAGIC)\n\t\t\t\t) {\n\t\t\t\t\tconst sigLenHex = useroperation.paymasterData.slice(\n\t\t\t\t\t\tuseroperation.paymasterData.length - 16 - 4,\n\t\t\t\t\t\tuseroperation.paymasterData.length - 16,\n\t\t\t\t\t);\n\t\t\t\t\tconst sigLen = parseInt(sigLenHex, 16);\n\t\t\t\t\tconst prefixEnd = useroperation.paymasterData.length - 16 - 4 - sigLen * 2;\n\t\t\t\t\tpaymasterAndData +=\n\t\t\t\t\t\tuseroperation.paymasterData.slice(0, prefixEnd).replaceAll(\"0x\", \"\") +\n\t\t\t\t\t\tPAYMASTER_SIG_MAGIC;\n\t\t\t\t} else {\n\t\t\t\t\tpaymasterAndData += useroperation.paymasterData.slice(2);\n\t\t\t\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\t\treturn {\n\t\t\tdomain,\n\t\t\ttypes: EIP712_SAFE_OPERATION_V7_TYPE,\n\t\t\tmessageValue,\n\t\t};\n\t}\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 an object containing the typed data domain, type and typed data vales\n\t * 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\t): {\n\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV6TypedMessageValue;\n\t} {\n\t\treturn SafeAccount.baseGetUserOperationEip712DataV7V8V9(\n\t\t\tuseroperation,\n\t\t\tchainId,\n\t\t\toverrides.entrypointAddress ?? ENTRYPOINT_V7,\n\t\t\toverrides,\n\t\t);\n\t}\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\t\tconst data = SafeAccount.getUserOperationEip712Data_V7(useroperation, chainId, overrides);\n\t\treturn hashTypedData(data.domain, data.types, data.messageValue);\n\t}\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 \"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42\"\n\t * @returns an object containing the typed data domain, type and typed data vales\n\t * 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\t): {\n\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV9TypedMessageValue;\n\t} {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? \"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42\";\n\n\t\treturn SafeAccount.baseGetUserOperationEip712DataV7V8V9(\n\t\t\tuseroperation,\n\t\t\tchainId,\n\t\t\toverrides.entrypointAddress ?? ENTRYPOINT_V9,\n\t\t\t{\n\t\t\t\t...overrides,\n\t\t\t\tsafe4337ModuleAddress,\n\t\t\t\tis_v9: true,\n\t\t\t},\n\t\t);\n\t}\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\t\tconst data = SafeAccount.getUserOperationEip712Data_V9(useroperation, chainId, overrides);\n\t\treturn hashTypedData(data.domain, data.types, data.messageValue);\n\t}\n\n\t/**\n\t * @deprecated Use `account.formatUserOperationSignature([{ signer, signature }], options)`\n\t * when an account instance is available, or\n\t * `SafeAccount.formatSignaturesToUseroperationSignature([{ signer, signature }], options)`\n\t * for static formatting. For `SafeMultiChainSigAccountV1`, prefer the\n\t * instance method so `isMultiChainSignature` is applied automatically; if\n\t * using the lower-level static formatter directly, pass\n\t * `isMultiChainSignature: true`.\n\t *\n\t * format 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 formatted 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\t\t\tisMultiChainSignature?: boolean;\n\t\t} = {},\n\t): string {\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tsigner: \"0x0000000000000000000000000000000000000000\", // any random address\n\t\t\t\t\tsignature,\n\t\t\t\t},\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 URL, {@link Transport}, or pre-constructed {@link Bundler}\n\t * @returns promise with SendUseroperationResponse\n\t */\n\tpublic async sendUserOperation(\n\t\tuserOperation: UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tbundlerRpc: string | Transport | Bundler,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = Bundler.from(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(sendUserOperationRes, bundler, this.entrypointAddress);\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 ?? SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\t\toverrides.webAuthnSharedSigner ?? SafeAccount.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_CONTRACT_VERIFIER,\n\t\t);\n\n\t\tlet safeAccountFactory: SafeAccountFactory;\n\t\tif (overrides.safeAccountFactoryAddress != null) {\n\t\t\tsafeAccountFactory = new SafeAccountFactory(overrides.safeAccountFactoryAddress);\n\t\t} else {\n\t\t\tsafeAccountFactory = new SafeAccountFactory();\n\t\t}\n\t\tconst safeSingleton = overrides.safeAccountSingleton ?? Safe_L2_V1_4_1;\n\t\tconst sender = SafeAccount.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 = safeAccountFactory.getFactoryGeneratorFunctionCallData(\n\t\t\tgeneratorFunctionInputParameters,\n\t\t);\n\n\t\treturn [sender, safeAccountFactory.address, factoryGeneratorFunctionCallData];\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_CONTRACT_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: AbiInputValue[];\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(\"Only one WebAuthn owner can be set during initialization\");\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(mutisendSelector, [\"bytes\"], [encodedInit]);\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 ?? SafeAccount.DEFAULT_MULTISEND_CONTRACT_ADDRESS,\n\t\t\toverrides.webAuthnSharedSigner ?? SafeAccount.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_CONTRACT_VERIFIER,\n\t\t);\n\n\t\tlet safeAccountFactory: SafeAccountFactory;\n\t\tif (overrides.safeAccountFactoryAddress != null) {\n\t\t\tsafeAccountFactory = new SafeAccountFactory(overrides.safeAccountFactoryAddress);\n\t\t} else {\n\t\t\tsafeAccountFactory = new SafeAccountFactory();\n\t\t}\n\n\t\tconst safeSingleton = overrides.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 = safeAccountFactory.getFactoryGeneratorFunctionCallData(\n\t\t\tgeneratorFunctionInputParameters,\n\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 ?? SafeAccount.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 *\n\t * The returned verificationGasLimit includes ~55k gas per dummy signer\n\t * used for estimation (from dummySignerSignaturePairs, expectedSigners,\n\t * or the single-EOA default), compensating for the per-signature\n\t * verification cost bundler simulation skips. If the operation already\n\t * carries a signature, no compensation is added and the caller is\n\t * responsible for it.\n\t *\n\t * The passed userOperation is not mutated; estimation runs on an\n\t * internal copy carrying the dummy signature and zeroed gas fees.\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 | Transport | Bundler,\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\tisMultiChainSignature?: boolean;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\tconst validAfter = 0xffffffffffffn;\n\t\tconst validUntil = 0xffffffffffffn;\n\n\t\t// Derived from the operation's own init fields; the signature encoder\n\t\t// needs the init flag and verifier config whenever a dummy pair\n\t\t// carries a raw WebauthnPublicKey signer.\n\t\tlet initCode: string | null;\n\t\tif (\"initCode\" in userOperation) {\n\t\t\tinitCode = userOperation.initCode;\n\t\t} else {\n\t\t\tinitCode = userOperation.factory;\n\t\t}\n\t\tconst isInit = initCode != null && initCode !== \"0x\";\n\t\tconst webAuthnSignatureOverrides = {\n\t\t\tisInit,\n\t\t\twebAuthnSharedSigner: overrides.webAuthnSharedSigner,\n\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier,\n\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n\t\t\twebAuthnSignerProxyCreationCode: overrides.webAuthnSignerProxyCreationCode,\n\t\t};\n\n\t\t// Number of dummy signatures this method placed on the estimated\n\t\t// operation. Zero when the caller supplied a ready-made signature,\n\t\t// in which case the signer count is unknown here and per-signer gas\n\t\t// compensation is left to the caller.\n\t\tlet dummySignersCount = 0;\n\t\tlet estimationSignature = userOperation.signature;\n\t\tif (overrides.dummySignerSignaturePairs != null) {\n\t\t\tif (overrides.expectedSigners != null) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\"Can't use both dummySignerSignaturePairs and expectedSigners overrides.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (overrides.dummySignerSignaturePairs.length < 1) {\n\t\t\t\tthrow new RangeError(\"Number of dummy signers signature pairs can't be less than 1\");\n\t\t\t}\n\t\t\tdummySignersCount = overrides.dummySignerSignaturePairs.length;\n\t\t\testimationSignature = SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\toverrides.dummySignerSignaturePairs,\n\t\t\t\t{\n\t\t\t\t\tvalidAfter,\n\t\t\t\t\tvalidUntil,\n\t\t\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\t\t\t...webAuthnSignatureOverrides,\n\t\t\t\t},\n\t\t\t);\n\t\t} else if (overrides.expectedSigners != null) {\n\t\t\tconst dummySignerSignaturePairs =\n\t\t\t\tSafeAccount.createDummySignerSignaturePairForExpectedSigners(\n\t\t\t\t\toverrides.expectedSigners,\n\t\t\t\t\twebAuthnSignatureOverrides,\n\t\t\t\t);\n\t\t\tdummySignersCount = dummySignerSignaturePairs.length;\n\t\t\testimationSignature = SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\tdummySignerSignaturePairs,\n\t\t\t\t{\n\t\t\t\t\tvalidAfter,\n\t\t\t\t\tvalidUntil,\n\t\t\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\t\t\t...webAuthnSignatureOverrides,\n\t\t\t\t},\n\t\t\t);\n\t\t} else if (userOperation.signature.length < 3) {\n\t\t\tdummySignersCount = 1;\n\t\t\testimationSignature = SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\t\t[EOADummySignerSignaturePair],\n\t\t\t\t{\n\t\t\t\t\tvalidAfter,\n\t\t\t\t\tvalidUntil,\n\t\t\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst bundler = Bundler.from(bundlerRpc);\n\n\t\t// Estimate on a shallow copy so the caller's operation is never\n\t\t// mutated, even when estimation throws.\n\t\tconst userOperationToEstimate = {\n\t\t\t...userOperation,\n\t\t\tsignature: estimationSignature,\n\t\t\tmaxFeePerGas: 0n,\n\t\t\tmaxPriorityFeePerGas: 0n,\n\t\t};\n\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\tuserOperationToEstimate,\n\t\t\tthis.entrypointAddress,\n\t\t\toverrides.stateOverrideSet,\n\t\t);\n\n\t\tconst preVerificationGas = BigInt(estimation.preVerificationGas);\n\n\t\t// Compensate for per-signer signature verification cost the bundler\n\t\t// skips during estimation: dummy signatures short-circuit validation,\n\t\t// but Safe iterates owner signatures inside `validateUserOp`, so each\n\t\t// real signature pays ~55k gas at inclusion that simulation never\n\t\t// paid for.\n\t\tconst verificationGasLimit =\n\t\t\tBigInt(estimation.verificationGasLimit) + BigInt(dummySignersCount) * 55_000n;\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 | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\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 ?? SafeAccount.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 ?? SafeAccount.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(providerRpc, this.entrypointAddress, this.accountAddress);\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 (typeof overrides.maxFeePerGas === \"bigint\" && overrides.maxFeePerGas < 0n) {\n\t\t\tthrow new RangeError(\"maxFeePerGas overrid can't be negative\");\n\t\t}\n\n\t\tif (typeof overrides.maxPriorityFeePerGas === \"bigint\" && overrides.maxPriorityFeePerGas < 0n) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas overrid can't be negative\");\n\t\t}\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 (overrides.maxFeePerGas == null || overrides.maxPriorityFeePerGas == null) {\n\t\t\tgasPriceOp = handlefetchGasPrice(\n\t\t\t\tproviderRpc,\n\t\t\t\toverrides.polygonGasStation,\n\t\t\t\toverrides.gasLevel,\n\t\t\t);\n\t\t}\n\n\t\tif (gasPriceOp != null && nonceOp != null) {\n\t\t\tawait Promise.all([nonceOp, gasPriceOp]).then((values) => {\n\t\t\t\tnonce = values[0];\n\t\t\t\t[maxFeePerGas, maxPriorityFeePerGas] = values[1];\n\t\t\t});\n\t\t} else if (gasPriceOp != null) {\n\t\t\t[maxFeePerGas, maxPriorityFeePerGas] = await gasPriceOp;\n\t\t} else if (nonceOp != null) {\n\t\t\tnonce = await nonceOp;\n\t\t}\n\n\t\tmaxFeePerGas =\n\t\t\toverrides.maxFeePerGas ??\n\t\t\t(maxFeePerGas * BigInt((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100)) / 100n;\n\t\tmaxPriorityFeePerGas =\n\t\t\toverrides.maxPriorityFeePerGas ??\n\t\t\t(maxPriorityFeePerGas *\n\t\t\t\tBigInt((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100)) /\n\t\t\t\t100n;\n\n\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER;\n\t\tconst webAuthnSignerFactory =\n\t\t\toverrides.webAuthnSignerFactory ?? SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\tconst webAuthnSignerSingleton =\n\t\t\toverrides.webAuthnSignerSingleton ?? SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n\t\tconst webAuthnSignerProxyCreationCode =\n\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\tSafeAccount.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\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} else if (nonce > 0n) {\n\t\t\tfactoryAddress = null;\n\t\t\tfactoryData = null;\n\t\t} else if (this.isInitWebAuthn) {\n\t\t\t//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\"Invalid account initialization with Webauthn signer.\" +\n\t\t\t\t\t\t\"Webauthn 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(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});\n\n\t\t\tconst deterministicWebAuthnVerifierAddress = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\tthis.x,\n\t\t\t\tthis.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\t\t\t\t\twebAuthnSignerProxyCreationCode,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst swapSingletonWithDeterministicWebAuthnVerifierOwnerCallData = createCallData(\n\t\t\t\t\"0xe318b52b\", //swapOwner\n\t\t\t\t[\n\t\t\t\t\t\"address\", //prevOwner\n\t\t\t\t\t\"address\", //oldOwner\n\t\t\t\t\t\"address\", //newOwner\n\t\t\t\t],\n\t\t\t\t[\n\t\t\t\t\t\"0x0000000000000000000000000000000000000001\", //SENTINEL_OWNERS\n\t\t\t\t\twebAuthnSharedSigner,\n\t\t\t\t\tdeterministicWebAuthnVerifierAddress,\n\t\t\t\t],\n\t\t\t);\n\n\t\t\tconst swapSingletonWithDeterministicWebAuthnVerifierOwner: MetaTransaction = {\n\t\t\t\tto: this.accountAddress,\n\t\t\t\tvalue: 0n,\n\t\t\t\tdata: swapSingletonWithDeterministicWebAuthnVerifierOwnerCallData,\n\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\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(transactions[0], {\n\t\t\t\t\tsafeModuleExecutorFunctionSelector,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataBatchTransactions(transactions, {\n\t\t\t\t\tsafeModuleExecutorFunctionSelector: safeModuleExecutorFunctionSelector,\n\t\t\t\t\tmultisendContractAddress: multisendContractAddress,\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\tif (this.onChainIdentifier != null) {\n\t\t\tcallData = callData + this.onChainIdentifier;\n\t\t}\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 = BaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\t// Build the dummy signature up-front and attach it to the user operation\n\t\t// so the returned op always carries a valid placeholder signature\n\t\t// whether gas estimation runs below or is skipped.\n\t\tconst validAfter = 0xffffffffffffn;\n\t\tconst validUntil = 0xffffffffffffn;\n\n\t\t// V0.6 callers can override the final initCode (applied by\n\t\t// createUserOperation after this method returns). Resolve it up front\n\t\t// so the dummy-signature encoding and the estimation op below see the\n\t\t// same deployment state as the returned op — e.g. a caller-supplied\n\t\t// \"0x\" must select the deployed-account WebAuthn owner encoding even\n\t\t// when a factory address is set.\n\t\tlet resolvedV06InitCode: string | null = null;\n\t\tif (isV06) {\n\t\t\tresolvedV06InitCode = (overrides as CreateUserOperationV6Overrides).initCode ?? null;\n\t\t\tif (resolvedV06InitCode == null) {\n\t\t\t\tresolvedV06InitCode = \"0x\";\n\t\t\t\tif (factoryAddress != null) {\n\t\t\t\t\tresolvedV06InitCode = factoryAddress;\n\t\t\t\t\tif (factoryData != null) {\n\t\t\t\t\t\tresolvedV06InitCode += factoryData.slice(2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst isInit = isV06\n\t\t\t? resolvedV06InitCode !== \"0x\"\n\t\t\t: factoryAddress != null && factoryAddress !== \"0x\";\n\t\tlet dummySignerSignaturePairs: SignerSignaturePair[];\n\t\tif (overrides.dummySignerSignaturePairs != null) {\n\t\t\tif (overrides.expectedSigners != null) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\"Can't use both dummySignerSignaturePairs and expectedSigners overrides.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (overrides.dummySignerSignaturePairs.length < 1) {\n\t\t\t\tthrow new RangeError(\"Number of dummySignerSignaturePairs can't be less than 1\");\n\t\t\t}\n\t\t\tdummySignerSignaturePairs = overrides.dummySignerSignaturePairs;\n\t\t} else {\n\t\t\tif (overrides.expectedSigners == null) {\n\t\t\t\tdummySignerSignaturePairs = [EOADummySignerSignaturePair];\n\t\t\t} else {\n\t\t\t\tdummySignerSignaturePairs = SafeAccount.createDummySignerSignaturePairForExpectedSigners(\n\t\t\t\t\toverrides.expectedSigners,\n\t\t\t\t\t{\n\t\t\t\t\t\tisInit,\n\t\t\t\t\t\twebAuthnSharedSigner,\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\twebAuthnSignerSingleton,\n\t\t\t\t\t\twebAuthnSignerProxyCreationCode,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tuserOperation.signature = SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\tdummySignerSignaturePairs,\n\t\t\t{\n\t\t\t\tvalidAfter,\n\t\t\t\tvalidUntil,\n\t\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\t\t// needed when user-supplied dummySignerSignaturePairs contain raw\n\t\t\t\t// WebauthnPublicKey signers — the encoder requires the init flag,\n\t\t\t\t// and for deployed accounts derives the per-owner verifier\n\t\t\t\t// address from the verifier config\n\t\t\t\tisInit,\n\t\t\t\twebAuthnSharedSigner,\n\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\twebAuthnSignerFactory,\n\t\t\t\twebAuthnSignerSingleton,\n\t\t\t\twebAuthnSignerProxyCreationCode,\n\t\t\t},\n\t\t);\n\n\t\tconst skipGasEstimation = overrides.skipGasEstimation ?? false;\n\n\t\tif (\n\t\t\t!skipGasEstimation &&\n\t\t\t(overrides.preVerificationGas == null ||\n\t\t\t\toverrides.verificationGasLimit == null ||\n\t\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\tuserOperationToEstimate = {\n\t\t\t\t\t\t...userOperation,\n\t\t\t\t\t\tinitCode: resolvedV06InitCode as string,\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\t\t\t\t\tconst parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n\t\t\t\t\tif (parallelPaymasterInitValues != null) {\n\t\t\t\t\t\t// lowercase like the EIP-712 trimmer and the MultiChain\n\t\t\t\t\t\t// subclass — uppercase hex is valid input\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!parallelPaymasterInitValues.paymasterData\n\t\t\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t\t\t.endsWith(\"22e325a297439656\")\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t\t\"Invalid paymasterData override, it must end with the PAYMASTER_SIG_MAGIC '22e325a297439656'.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.entrypointAddress.toLowerCase() !== ENTRYPOINT_V9.toLowerCase()) {\n\t\t\t\t\t\t\tthrow new RangeError(\"parallelPaymasterInitValues only works with ep v0.9\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tuserOperationToEstimate.paymaster = parallelPaymasterInitValues.paymaster;\n\t\t\t\t\t\tuserOperationToEstimate.paymasterVerificationGasLimit =\n\t\t\t\t\t\t\tparallelPaymasterInitValues.paymasterVerificationGasLimit;\n\t\t\t\t\t\tuserOperationToEstimate.paymasterPostOpGasLimit =\n\t\t\t\t\t\t\tparallelPaymasterInitValues.paymasterPostOpGasLimit;\n\t\t\t\t\t\tuserOperationToEstimate.paymasterData = parallelPaymasterInitValues.paymasterData;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t[preVerificationGas, verificationGasLimit, callGasLimit] =\n\t\t\t\t\tawait this.baseEstimateUserOperationGas(userOperationToEstimate, bundlerRpc, {\n\t\t\t\t\t\tstateOverrideSet: overrides.state_override_set,\n\t\t\t\t\t\tisMultiChainSignature: overrides.isMultiChainSignature,\n\t\t\t\t\t});\n\t\t\t\t// Compensate for per-signer signature verification cost the\n\t\t\t\t// bundler skips during `eth_estimateUserOperationGas`:\n\t\t\t\t// estimation runs with dummy signatures whose signature paths\n\t\t\t\t// are short-circuited (dummies don't recover to real owners,\n\t\t\t\t// so the bundler bypasses signature validation). Safe iterates\n\t\t\t\t// owner signatures inside `validateUserOp`, so each real\n\t\t\t\t// signature pays ~55k gas at inclusion that simulation never\n\t\t\t\t// paid for. The same pattern (without the per-signer\n\t\t\t\t// multiplier) appears in Simple7702 and Calibur.\n\t\t\t\tverificationGasLimit += BigInt(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 can't be null if preVerificationGas,\" +\n\t\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overridden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (typeof overrides.preVerificationGas === \"bigint\" && overrides.preVerificationGas < 0n) {\n\t\t\tthrow new RangeError(\"preVerificationGas overrid can't be negative\");\n\t\t}\n\n\t\tif (typeof overrides.verificationGasLimit === \"bigint\" && overrides.verificationGasLimit < 0n) {\n\t\t\tthrow new RangeError(\"verificationGasLimit overrid can't be negative\");\n\t\t}\n\n\t\tif (typeof overrides.callGasLimit === \"bigint\" && overrides.callGasLimit < 0n) {\n\t\t\tthrow new RangeError(\"callGasLimit overrid can't be negative\");\n\t\t}\n\n\t\tuserOperation.preVerificationGas =\n\t\t\toverrides.preVerificationGas ??\n\t\t\t(preVerificationGas * BigInt((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100)) /\n\t\t\t\t100n;\n\n\t\tuserOperation.verificationGasLimit =\n\t\t\toverrides.verificationGasLimit ??\n\t\t\t(verificationGasLimit *\n\t\t\t\tBigInt((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100)) /\n\t\t\t\t100n;\n\n\t\tuserOperation.callGasLimit =\n\t\t\toverrides.callGasLimit ??\n\t\t\t(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 entrypointAddress - target EntryPoint\n\t * @param safe4337ModuleAddress - Safe 4337 module\n\t * @param options - per-call signing options (timing, multi-chain encoding, module address) — passed through to {@link formatSignaturesToUseroperationSignature}\n\t * @returns signature\n\t */\n\tprotected 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\toptions: SafeSignatureOptions = {},\n\t): string {\n\t\tconst validAfter = options.validAfter ?? 0n;\n\t\tconst validUntil = options.validUntil ?? 0n;\n\t\tconst moduleAddress = options.safe4337ModuleAddress ?? safe4337ModuleAddress;\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(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress: moduleAddress,\n\t\t});\n\n\t\tconst signerSignaturePairs: SignerSignaturePair[] = [];\n\t\tfor (const privateKey of privateKeys) {\n\t\t\tconst signature = signHash(privateKey, userOperationEip712Hash).serialized;\n\t\t\tsignerSignaturePairs.push({\n\t\t\t\tsigner: privateKeyToAddress(privateKey),\n\t\t\t\tsignature,\n\t\t\t});\n\t\t}\n\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\tsignerSignaturePairs,\n\t\t\t{ ...options, validAfter, validUntil },\n\t\t);\n\t}\n\n\t/**\n\t * Schemes Safe accepts from an {@link ExternalSigner}, in preference order.\n\t * `typedData` is preferred because wallets can display structured fields\n\t * rather than a hex blob; `hash` is accepted as a fallback for signers\n\t * that only support raw ECDSA.\n\t */\n\tpublic static readonly ACCEPTED_SIGNING_SCHEMES: readonly SigningScheme[] = [\"typedData\", \"hash\"];\n\n\t/**\n\t * Sign a UserOperation using one or more {@link ExternalSigner}s. This is the\n\t * capability-oriented signing path: each signer declares what it can do\n\t * (`signHash`, `signTypedData`, both) and the account picks the best\n\t * match per signer. Incompatible signers fail offline with an actionable\n\t * error rather than a silent bundler rejection.\n\t *\n\t * Signers are invoked in parallel. For interactive wallets that share a\n\t * popup session, sequence the prompts inside your ExternalSigner implementation.\n\t *\n\t * @param useroperation - UserOperation to sign\n\t * @param signers - ExternalSigner instances (`fromViem(account)`, `fromEthersWallet(wallet)`, etc.)\n\t * @param chainId - target chain id\n\t * @param params - bag combining required wiring (`entrypointAddress`,\n\t *   `safe4337ModuleAddress`, `context`) with optional `options`\n\t *   ({@link SafeSignatureOptions}: timing, multi-chain encoding,\n\t *   module address).\n\t *   Both flow through to {@link formatSignaturesToUseroperationSignature}.\n\t * @returns formatted signature\n\t */\n\tprotected static async baseSignUserOperationWithSigners<\n\t\tT extends UserOperationV6 | UserOperationV7 | UserOperationV9,\n\t\tC,\n\t>(\n\t\tuseroperation: T,\n\t\tsigners: ReadonlyArray<ExternalSigner<C>>,\n\t\tchainId: bigint,\n\t\tparams: {\n\t\t\tentrypointAddress: string;\n\t\t\tsafe4337ModuleAddress: string;\n\t\t\tcontext: C;\n\t\t\toptions?: SafeSignatureOptions;\n\t\t},\n\t): Promise<string> {\n\t\tconst {\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress,\n\t\t\tcontext,\n\t\t\toptions = {},\n\t\t} = params;\n\t\tconst validAfter = options.validAfter ?? 0n;\n\t\tconst validUntil = options.validUntil ?? 0n;\n\t\tconst moduleAddress = options.safe4337ModuleAddress ?? safe4337ModuleAddress;\n\n\t\tif (signers.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one signer\");\n\t\t}\n\n\t\tconst typedDataRaw = SafeAccount.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\tvalidAfter,\n\t\t\tvalidUntil,\n\t\t\tentrypointAddress,\n\t\t\tsafe4337ModuleAddress: moduleAddress,\n\t\t});\n\t\tconst userOpHash = hashTypedData(\n\t\t\ttypedDataRaw.domain,\n\t\t\ttypedDataRaw.types,\n\t\t\ttypedDataRaw.messageValue,\n\t\t) as `0x${string}`;\n\n\t\t// Strip EIP712Domain; every downstream signTypedData API rejects it\n\t\t// when it appears alongside the primary type.\n\t\tconst { EIP712Domain: _drop, ...primaryTypes } = typedDataRaw.types as Record<\n\t\t\tstring,\n\t\t\t{ name: string; type: string }[]\n\t\t>;\n\t\tconst typedData: TypedData = {\n\t\t\tdomain: typedDataRaw.domain as TypedData[\"domain\"],\n\t\t\ttypes: primaryTypes,\n\t\t\tprimaryType: EIP712_SAFE_OPERATION_PRIMARY_TYPE,\n\t\t\t// SafeUserOperationVxTypedMessageValue has fixed fields, not an\n\t\t\t// index signature, so TS rejects a direct cast to Record. Route\n\t\t\t// through `unknown` to acknowledge the structural conversion.\n\t\t\tmessage: typedDataRaw.messageValue as unknown as Record<string, unknown>,\n\t\t};\n\n\t\t// Preflight: validate + checksum every signer's address before\n\t\t// calling any signer. Catches malformed addresses offline instead\n\t\t// of after an external signer (HSM, hardware wallet) has already\n\t\t// been prompted.\n\t\tconst normalizedAddresses = signers.map((signer) => getAddress(signer.address));\n\n\t\t// Offline capability check: throws with an actionable message if\n\t\t// any signer can't produce what Safe accepts.\n\t\tconst schemes = signers.map((signer, signerIndex) =>\n\t\t\tpickScheme(signer, SafeAccount.ACCEPTED_SIGNING_SCHEMES, {\n\t\t\t\taccountName: \"Safe (EIP-712 or raw hash over SafeOp digest)\",\n\t\t\t\tsignerIndex,\n\t\t\t}),\n\t\t);\n\n\t\tconst signatures = await Promise.all(\n\t\t\tsigners.map((signer, i) =>\n\t\t\t\tinvokeSigner(signer, schemes[i], {\n\t\t\t\t\thash: userOpHash,\n\t\t\t\t\ttypedData,\n\t\t\t\t\tcontext,\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\n\t\tconst signerSignaturePairs = signatures.map((signature, i) => ({\n\t\t\tsigner: normalizedAddresses[i],\n\t\t\tsignature,\n\t\t\tisContractSignature: signers[i].type === \"contract\",\n\t\t}));\n\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(\n\t\t\tsignerSignaturePairs,\n\t\t\t{ ...options, validAfter, validUntil },\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 ?? SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER;\n\t\tconst webAuthnSignerFactory =\n\t\t\toverrides.webAuthnSignerFactory ?? SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\tconst webAuthnSignerSingleton =\n\t\t\toverrides.webAuthnSignerSingleton ?? SafeAccount.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\"Invalid 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\t\t\t\t\t\tSafeAccount.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 getAddress(`0x${proxyAdd}`); //to checksummed\n\t}\n\n\t/**\n\t * format 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 options - merged bag of {@link SafeSignatureOptions} (timing, multi-chain encoding, module address) and {@link WebAuthnSignatureOverrides} (verifier addresses, init flag). Single param for back-compat with the pre-split shape — callers may pass any combination of fields from either type.\n\t * @returns signature\n\t */\n\tpublic static formatSignaturesToUseroperationSignature(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toptions: SafeSignatureOptions & WebAuthnSignatureOverrides = {},\n\t): string {\n\t\tconst validAfter = options.validAfter ?? 0n;\n\t\tconst validUntil = options.validUntil ?? 0n;\n\n\t\tconst signature = SafeAccount.buildSignaturesFromSingerSignaturePairs(\n\t\t\tsignerSignaturePairs,\n\t\t\toptions,\n\t\t);\n\n\t\tif (options.isMultiChainSignature) {\n\t\t\tif (options.multiChainMerkleProof != null) {\n\t\t\t\tconst merkleProofLength = options.multiChainMerkleProof.slice(2).length; // wihout 0x prefix\n\t\t\t\tif (\n\t\t\t\t\t// 1 byte has a length of 2 hex chars\n\t\t\t\t\t// minimum proof consist of at least two hashes, 2 * 2 * 32 = 128\n\t\t\t\t\tmerkleProofLength < 128 ||\n\t\t\t\t\t// 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\t\t\t\t// create a 0x prefixed hex with an even length of chars\n\t\t\t\tif (merkleTreeDepthHex.length % 2 === 0) {\n\t\t\t\t\tmerkleTreeDepthHex = `0x${merkleTreeDepthHex}`;\n\t\t\t\t} else {\n\t\t\t\t\tmerkleTreeDepthHex = `0x0${merkleTreeDepthHex}`;\n\t\t\t\t}\n\n\t\t\t\treturn solidityPacked(\n\t\t\t\t\t[\"bytes1\", \"uint48\", \"uint48\", \"bytes\"],\n\t\t\t\t\t[\n\t\t\t\t\t\tmerkleTreeDepthHex,\n\t\t\t\t\t\tvalidAfter,\n\t\t\t\t\t\tvalidUntil,\n\t\t\t\t\t\toptions.multiChainMerkleProof + signature.slice(2),\n\t\t\t\t\t],\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t//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\t\t\t\t\t\t\"0x00\", // single useroperation - merkle depth is 0\n\t\t\t\t\t\tvalidAfter,\n\t\t\t\t\t\tvalidUntil,\n\t\t\t\t\t\tsignature,\n\t\t\t\t\t],\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\treturn solidityPacked([\"uint48\", \"uint48\", \"bytes\"], [validAfter, validUntil, signature]);\n\t\t}\n\t}\n\n\t/**\n\t * Resolve a {@link Signer} to the lowercase address the Safe contract\n\t * sees as the owner — not merely a case conversion:\n\t *\n\t * - string signer: returned lowercased as-is.\n\t * - WebAuthn public key with `overrides.isInit` set: resolves to the\n\t *   WebAuthn **shared signer** address, since during account init the\n\t *   shared signer is the enabled owner rather than a per-owner verifier.\n\t * - WebAuthn public key otherwise: **derives** the deterministic CREATE2\n\t *   address of the per-owner WebAuthn verifier proxy from the key's x/y\n\t *   coordinates and the verifier/factory configuration.\n\t *\n\t * Used as the sort key in {@link sortSignatures}, so it must always match\n\t * the owner address that signature encoding will emit for the same\n\t * overrides — pass the same overrides bag to both.\n\t * @param signer - a signer to compute the owner address for\n\t * @param overrides - WebAuthn verifier configuration and the init flag\n\t * @returns the owner address, lowercased\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 if (overrides.isInit) {\n\t\t\t// on init the encoded owner is the WebAuthn shared signer, not the\n\t\t\t// per-owner verifier proxy — sort by the same address that gets encoded\n\t\t\tconst webAuthnSharedSigner =\n\t\t\t\toverrides.webAuthnSharedSigner ?? SafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n\t\t\treturn webAuthnSharedSigner.toLowerCase();\n\t\t} else {\n\t\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER;\n\t\t\tconst webAuthnSignerFactory =\n\t\t\t\toverrides.webAuthnSignerFactory ?? SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\t\tconst webAuthnSignerSingleton =\n\t\t\t\toverrides.webAuthnSignerSingleton ?? SafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n\t\t\tconst webAuthnSignerProxyCreationCode =\n\t\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\treturn SafeAccount.createWebAuthnSignerVerifierAddress(signer.x, signer.y, {\n\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\twebAuthnSignerFactory,\n\t\t\t\twebAuthnSignerSingleton,\n\t\t\t\twebAuthnSignerProxyCreationCode,\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(left.signer, overrides).localeCompare(\n\t\t\t\tSafeAccount.getSignerLowerCaseAddress(right.signer, overrides),\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * format 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 webAuthnSignatureOverrides - WebAuthn-only configuration (verifier addresses, init flag)\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(signerSignaturePairs, webAuthnSignatureOverrides);\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\") {\n\t\t\t\t\t\t// webauthn signature — on init, use the shared signer address\n\t\t\t\t\t\t// instead of the per-owner WebAuthn verifier address\n\t\t\t\t\t\tif (webAuthnSignatureOverrides.isInit == null) {\n\t\t\t\t\t\t\tthrow new RangeError(\"Must define isInit parameter when using WebAuthn\");\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_CONTRACT_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\t\t\t\t\t\t\tconst webAuthnSignerProxyCreationCode =\n\t\t\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\t\t\t\t\tsigner = SafeAccount.createWebAuthnSignerVerifierAddress(signer.x, signer.y, {\n\t\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\t\t\t\twebAuthnSignerSingleton,\n\t\t\t\t\t\t\t\twebAuthnSignerProxyCreationCode,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\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\tsolidityPacked([\"uint256\", \"uint256\", \"uint8\"], [signer, start + offset, 0]),\n\t\t\t\t\t\t],\n\t\t\t\t\t\toffset: offset + 32 + dataLength(signature),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsegments: [...segments, solidityPacked([\"bytes\"], [signature])],\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 concat([\n\t\t\t...segments,\n\t\t\t...signerSignaturePairs.map(({ signer, signature, isContractSignature }) => {\n\t\t\t\tisContractSignature = isContractSignature || typeof signer !== \"string\";\n\t\t\t\tif (isContractSignature) {\n\t\t\t\t\treturn solidityPacked(\n\t\t\t\t\t\t[\"uint256\", \"bytes\"],\n\t\t\t\t\t\t[dataLength(signature), signature],\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t//only append signatures if a contract signature\n\t\t\t\t\treturn \"0x\";\n\t\t\t\t}\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(signatureData: WebauthnSignatureData): string {\n\t\treturn encodeAbiParameters(\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 parameter) and to check if a webauthn newowner verifier\n\t * 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 * nodeRpcUrl 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 | Transport | JsonRpcNode,\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\t\twebAuthnSignerProxyCreationCode?: 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\t\tconst webAuthnSignerProxyCreationCode =\n\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\tif (typeof newOwner !== \"string\") {\n\t\t\tnewOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(newOwner.x, newOwner.y, {\n\t\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier,\n\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n\t\t\t\twebAuthnSignerProxyCreationCode,\n\t\t\t});\n\t\t\tconst newOwnerCode = await JsonRpcNode.from(nodeRpcUrl).getCode(newOwnerT, \"latest\");\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(newOwner.x, newOwner.y, {\n\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\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(oldOwner.x, oldOwner.y, {\n\t\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier,\n\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n\t\t\t\twebAuthnSignerProxyCreationCode,\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.findIndex(\n\t\t\t\t(owner) => owner.toLowerCase() === oldOwnerT.toLowerCase(),\n\t\t\t);\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 parameter).\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 * nodeRpcUrl 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 | Transport | JsonRpcNode,\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\t\twebAuthnSignerProxyCreationCode?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction> {\n\t\tlet ownerToDeleteT: string;\n\n\t\tif (typeof ownerToDelete !== \"string\") {\n\t\t\tconst webAuthnSignerProxyCreationCode =\n\t\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\tSafeAccount.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: overrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n\t\t\t\t\twebAuthnSignerProxyCreationCode,\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.findIndex(\n\t\t\t\t(owner) => owner.toLowerCase() === ownerToDeleteT.toLowerCase(),\n\t\t\t);\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(ownerToDeleteT, threshold, prevOwnerT);\n\t}\n\n\t/**\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\t * @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\t\t\tnodeRpcUrl?: string | Transport | JsonRpcNode;\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): Promise<MetaTransaction[]> {\n\t\tlet deployNewOwnerSignerMetaTransaction: MetaTransaction | null = null;\n\t\tlet newOwnerT: string;\n\n\t\tif (typeof newOwner !== \"string\") {\n\t\t\tconst webAuthnSignerProxyCreationCode =\n\t\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\tnewOwnerT = SafeAccount.createWebAuthnSignerVerifierAddress(newOwner.x, newOwner.y, {\n\t\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier,\n\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\twebAuthnSignerSingleton: overrides.webAuthnSignerSingleton,\n\t\t\t\twebAuthnSignerProxyCreationCode,\n\t\t\t});\n\t\t\tif (overrides.nodeRpcUrl == null) {\n\t\t\t\tthrow new RangeError(\"overrides.nodeRpcUrl can't be null if adding a webauthn owner\");\n\t\t\t}\n\t\t\tconst newOwnerCode = await JsonRpcNode.from(overrides.nodeRpcUrl).getCode(newOwnerT, \"latest\");\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(newOwner.x, newOwner.y, {\n\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier: overrides.eip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\teip7212WebAuthnContractVerifier: overrides.eip7212WebAuthnContractVerifier,\n\t\t\t\t\t\twebAuthnSignerFactory: overrides.webAuthnSignerFactory,\n\t\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tnewOwnerT = newOwner;\n\t\t}\n\n\t\tconst addMetaTransaction = this.createStandardAddOwnerWithThresholdMetaTransaction(\n\t\t\tnewOwnerT,\n\t\t\tthreshold,\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\t/**\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\t\tif (threshold < 1) {\n\t\t\tthrow new RangeError(\"threshold can't be less than 1.\");\n\t\t}\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\t/**\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 ?? SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER;\n\t\tconst webAuthnSignerFactory =\n\t\t\toverrides.webAuthnSignerFactory ?? SafeAccount.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 | Transport | JsonRpcNode): 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 JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tconst decodedCalldata = decodeAbiParameters<[string[]]>([\"address[]\"], getOwnersResult);\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 | Transport | JsonRpcNode): 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 JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tconst decodedCalldata = decodeAbiParameters<[bigint]>([\"uint256\"], getThresholdResult);\n\n\t\treturn Number(decodedCalldata[0]);\n\t}\n\n\t/**\n\t * fetches a paginated list of enabled modules for this account.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @param overrides - pagination overrides\n\t * @param overrides.start - module address to start from (defaults to the sentinel 0x...0001)\n\t * @param overrides.pageSize - maximum number of modules to return (default 10)\n\t * @returns a promise of [moduleAddresses, nextPageStart]; pass nextPageStart back in overrides.start to continue\n\t */\n\tpublic async getModules(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\toverrides: {\n\t\t\tstart?: string;\n\t\t\tpageSize?: bigint;\n\t\t} = {},\n\t): Promise<[string[], string]> {\n\t\ttry {\n\t\t\tlet start = overrides.start;\n\t\t\tif (start == null) {\n\t\t\t\tstart = \"0x0000000000000000000000000000000000000001\";\n\t\t\t}\n\t\t\tlet pageSize = overrides.pageSize;\n\t\t\tif (pageSize == null) {\n\t\t\t\tpageSize = 10n;\n\t\t\t}\n\n\t\t\tconst callData = createCallData(\n\t\t\t\t\"0xcc2f8452\", //getModulesPaginated(address,uint256)\n\t\t\t\t[\"address\", \"uint256\"],\n\t\t\t\t[start, pageSize],\n\t\t\t);\n\n\t\t\tconst ethCallParams = {\n\t\t\t\tto: this.accountAddress,\n\t\t\t\tdata: callData,\n\t\t\t};\n\t\t\tconst getModulesResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\t\t\tif (getModulesResult === \"0x\") {\n\t\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\t\"BAD_DATA\",\n\t\t\t\t\t\"getModules returned an empty result, the target account is \" +\n\t\t\t\t\t\t\"probably not deployed yet.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst decodedCalldata = decodeAbiParameters<[string[], string]>(\n\t\t\t\t[\"address[]\", \"address\"],\n\t\t\t\tgetModulesResult,\n\t\t\t);\n\t\t\treturn [decodedCalldata[0], decodedCalldata[1]];\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"getModules failed\", {\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\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\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\tmoduleAddress: string,\n\t): Promise<boolean> {\n\t\tconst functionSignature = \"isModuleEnabled(address)\";\n\t\tconst functionSelector = getFunctionSelector(functionSignature);\n\t\tconst callData = createCallData(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 JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tconst decodedCalldata = decodeAbiParameters<[boolean]>([\"bool\"], isModuleEnabledResult);\n\n\t\treturn decodedCalldata[0];\n\t}\n\n\t/**\n\t * read the Safe's current fallback handler address from storage.\n\t * For Safe ERC-4337 accounts the fallback handler is the 4337 module, so this\n\t * is the canonical way to confirm which module/EntryPoint version an account\n\t * is on (e.g. after a module migration).\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise of the fallback handler address (checksummed)\n\t */\n\tpublic async getFallbackHandler(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t): Promise<string> {\n\t\tconst word = await JsonRpcNode.from(nodeRpcUrl).getStorageAt(\n\t\t\tthis.accountAddress,\n\t\t\tSAFE_FALLBACK_HANDLER_STORAGE_SLOT,\n\t\t\t\"latest\",\n\t\t);\n\t\treturn getAddress(\"0x\" + word.slice(-40));\n\t}\n\n\t/**\n\t * read the Safe's version string via `VERSION()` (e.g. \"1.4.1\").\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @returns a promise of the Safe singleton version string\n\t */\n\tpublic async getSafeVersion(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t): Promise<string> {\n\t\tconst callData = createCallData(getFunctionSelector(\"VERSION()\"), [], []);\n\t\tconst result = await JsonRpcNode.from(nodeRpcUrl).call(\n\t\t\t{ to: this.accountAddress, data: callData },\n\t\t\t\"latest\",\n\t\t);\n\t\tconst [version] = decodeAbiParameters<[string]>([\"string\"], result);\n\t\treturn version;\n\t}\n\n\t/**\n\t * create a list of dummy signer/signature pairs for gas estimation based on the expected signers.\n\t * @param expectedSigners - signers whose signatures will be produced at sign time\n\t * @param webAuthnSignatureOverrides - WebAuthn verifier/module configuration\n\t * @returns a list of dummy SignerSignaturePair entries, one per expected signer\n\t */\n\tpublic static createDummySignerSignaturePairForExpectedSigners(\n\t\texpectedSigners: Signer[],\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): SignerSignaturePair[] {\n\t\tconst signers = [...expectedSigners];\n\t\tconst dummySignerSignatures: SignerSignaturePair[] = [];\n\t\tfor (const signer of signers) {\n\t\t\tlet signerSignaturePair: SignerSignaturePair;\n\t\t\tif (typeof signer === \"string\") {\n\t\t\t\tsignerSignaturePair = EOADummySignerSignaturePair;\n\t\t\t} else {\n\t\t\t\tif (webAuthnSignatureOverrides.isInit == null) {\n\t\t\t\t\tthrow new RangeError(\"Must define isInit parameter when using WebAuthn\");\n\t\t\t\t}\n\t\t\t\tsignerSignaturePair = { ...WebauthnDummySignerSignaturePair };\n\t\t\t\tif (webAuthnSignatureOverrides.isInit) {\n\t\t\t\t\tconst webauthnsharedsigner =\n\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSharedSigner ??\n\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SHARED_SIGNER;\n\t\t\t\t\tsignerSignaturePair.signer = webauthnsharedsigner;\n\t\t\t\t} else {\n\t\t\t\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\t\t\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER;\n\t\t\t\t\tconst webAuthnSignerFactory =\n\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerFactory ??\n\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_FACTORY;\n\t\t\t\t\tconst webAuthnSignerSingleton =\n\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerSingleton ??\n\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;\n\t\t\t\t\tconst webAuthnSignerProxyCreationCode =\n\t\t\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\t\t\tSafeAccount.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;\n\n\t\t\t\t\tsignerSignaturePair.signer = SafeAccount.createWebAuthnSignerVerifierAddress(\n\t\t\t\t\t\tsigner.x,\n\t\t\t\t\t\tsigner.y,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\t\t\t\t\teip7212WebAuthnContractVerifier,\n\t\t\t\t\t\t\twebAuthnSignerFactory,\n\t\t\t\t\t\t\twebAuthnSignerSingleton,\n\t\t\t\t\t\t\twebAuthnSignerProxyCreationCode,\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\tdummySignerSignatures.push(signerSignaturePair);\n\t\t}\n\t\treturn dummySignerSignatures;\n\t}\n\n\t/**\n\t * verify a webauthn signature against a signer and a message hash\n\t * @note: this function works by constructing the bytecode of a webauthn\n\t * verifying contract proxy that represent the input signer, then overriding\n\t * an arbitrary address code and caling \"isValidSignature\" using eth_call\n\t * this way we can check a signature even if the verifying contract is not\n\t * 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\tpublic static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\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\tif (messageHash.length !== 66 || messageHash.slice(0, 2) !== \"0x\") {\n\t\t\tthrow new RangeError(\"Invalid messageHash, must be a 0x-prefixed keccak256 hash.\");\n\t\t}\n\n\t\tconst eip7212WebAuthnPrecompileVerifier =\n\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_PRECOMPILE;\n\t\tconst eip7212WebAuthnContractVerifier =\n\t\t\toverrides.eip7212WebAuthnContractVerifier ?? SafeAccount.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER;\n\t\tconst webAuthnSignerSingleton =\n\t\t\toverrides.webAuthnSignerSingleton ?? SafeAccount.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\"Invalid precompile address. \" +\n\t\t\t\t\t\"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\t\t\tfunctionSelector,\n\t\t\t[\"bytes32\", \"bytes\"],\n\t\t\t[messageHash, signature],\n\t\t);\n\n\t\tconst arbitraryAddress = \"0x1111111111111111111111111111111111111111\";\n\t\tconst ethCallParams = {\n\t\t\tto: arbitraryAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst deployedByteCode = SafeAccount.createSafeWebAuthnSignerProxyDeployedByteCode(\n\t\t\tsigner,\n\t\t\teip7212WebAuthnPrecompileVerifier,\n\t\t\teip7212WebAuthnContractVerifier,\n\t\t\twebAuthnSignerSingleton,\n\t\t);\n\n\t\tconst isModuleEnabledResult = await JsonRpcNode.from(nodeRpcUrl).call(\n\t\t\tethCallParams,\n\t\t\t\"latest\",\n\t\t\t{\n\t\t\t\t[arbitraryAddress]: { code: deployedByteCode },\n\t\t\t},\n\t\t);\n\n\t\tconst decodedCalldata = decodeAbiParameters<[boolean]>([\"bool\"], isModuleEnabledResult);\n\n\t\treturn decodedCalldata[0];\n\t}\n\n\tprivate static createSafeWebAuthnSignerProxyDeployedByteCode(\n\t\tsigner: WebauthnPublicKey,\n\t\teip7212WebAuthnPrecompileVerifier: string,\n\t\teip7212WebAuthnContractVerifier: string,\n\t\twebAuthnSignerSingleton: string,\n\t): string {\n\t\tconst x = encodeAbiParameters([\"uint256\"], [signer.x]);\n\t\tconst y = encodeAbiParameters([\"uint256\"], [signer.y]);\n\t\tconst verifiers = encodeAbiParameters(\n\t\t\t[\"uint176\"],\n\t\t\t[\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\t\tconst byteCode =\n\t\t\t\"0x608060408190527f\" +\n\t\t\tverifiers.slice(2) +\n\t\t\t\"3660b681018290527f\" +\n\t\t\ty.slice(2) +\n\t\t\t\"60a082018190527f\" +\n\t\t\tx.slice(2) +\n\t\t\t\"8285018190527f000000000000000000000000\" +\n\t\t\twebAuthnSignerSingleton.slice(2) +\n\t\t\t\"9490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033\";\n\t\treturn byteCode;\n\t}\n\n\t/**\n\t * create MetaTransaction to enable a module on a Safe account\n\t * @param moduleAddress - Module to enable\n\t * @param accountAddress - Safe account to enable the module for\n\t * @returns a MetaTransaction\n\t */\n\tpublic static createEnableModuleMetaTransaction(\n\t\tmoduleAddress: string,\n\t\taccountAddress: string,\n\t): MetaTransaction {\n\t\tconst callData = createCallData(\n\t\t\t\"0x610b5925\", //\"enableModule(address)\"\n\t\t\t[\"address\"],\n\t\t\t[moduleAddress],\n\t\t);\n\t\treturn {\n\t\t\tto: accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a MetaTransaction that disables a module on this Safe account,\n\t * fetching the previous module in the linked list automatically when not provided.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain (used when prevModuleAddress is not provided)\n\t * @param moduleToDisableAddress - Module to disable\n\t * @param accountAddress - Safe account to disable the module on\n\t * @param overrides - overrides for the default values\n\t * @param overrides.prevModuleAddress - previous module in the linked list (skips the RPC lookup when set)\n\t * @param overrides.modulesStart - pagination start when scanning modules to find the previous one\n\t * @param overrides.modulesPageSize - pagination page size when scanning modules\n\t * @returns a promise of a MetaTransaction\n\t */\n\tpublic async createDisableModuleMetaTransaction(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\tmoduleToDisableAddress: string,\n\t\taccountAddress: string,\n\t\toverrides: {\n\t\t\tprevModuleAddress?: string;\n\t\t\tmodulesStart?: string;\n\t\t\tmodulesPageSize?: bigint;\n\t\t} = {},\n\t): Promise<MetaTransaction> {\n\t\ttry {\n\t\t\tlet prevModuleAddressT = overrides.prevModuleAddress;\n\t\t\tif (prevModuleAddressT == null) {\n\t\t\t\tconst SENTINEL_MODULES = \"0x0000000000000000000000000000000000000001\";\n\t\t\t\tconst target = moduleToDisableAddress.toLowerCase();\n\t\t\t\tlet cursor = overrides.modulesStart ?? SENTINEL_MODULES;\n\t\t\t\t// The predecessor of the first entry on page N is the cursor passed\n\t\t\t\t// to that page (SENTINEL on page 1; the last seen address on later\n\t\t\t\t// pages). We carry it across page boundaries so the lookup works\n\t\t\t\t// even when the module list spans multiple pages.\n\t\t\t\tlet prev = cursor;\n\t\t\t\twhile (prevModuleAddressT == null) {\n\t\t\t\t\tconst [modules, next] = await this.getModules(nodeRpcUrl, {\n\t\t\t\t\t\tstart: cursor,\n\t\t\t\t\t\tpageSize: overrides.modulesPageSize,\n\t\t\t\t\t});\n\t\t\t\t\tfor (const module of modules) {\n\t\t\t\t\t\tif (module.toLowerCase() === target) {\n\t\t\t\t\t\t\tprevModuleAddressT = prev;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprev = module;\n\t\t\t\t\t}\n\t\t\t\t\tif (prevModuleAddressT != null) break;\n\t\t\t\t\tif (\n\t\t\t\t\t\tmodules.length === 0 ||\n\t\t\t\t\t\tnext.toLowerCase() === SENTINEL_MODULES ||\n\t\t\t\t\t\tnext.toLowerCase() === cursor.toLowerCase()\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t\t`moduleToDisable ${moduleToDisableAddress} is not an enabled module.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcursor = next;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn SafeAccount.createStandardDisableModuleMetaTransaction(\n\t\t\t\tmoduleToDisableAddress,\n\t\t\t\tprevModuleAddressT,\n\t\t\t\taccountAddress,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"createDisableModuleMetaTransaction failed\", {\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * create a standard disable-module MetaTransaction (callers provide the previous module).\n\t * @param moduleAddress - Module to disable\n\t * @param prevModuleAddress - previous module in the linked list\n\t * @param accountAddress - Safe account to disable the module on\n\t * @returns a MetaTransaction\n\t */\n\tpublic static createStandardDisableModuleMetaTransaction(\n\t\tmoduleAddress: string,\n\t\tprevModuleAddress: string,\n\t\taccountAddress: string,\n\t): MetaTransaction {\n\t\tconst callData = createCallData(\n\t\t\t\"0xe009cfde\", //\"disableModule(address)\"\n\t\t\t[\"address\", \"address\"],\n\t\t\t[prevModuleAddress, moduleAddress],\n\t\t);\n\t\treturn {\n\t\t\tto: accountAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create the MetaTransactions that migrate a DEPLOYED Safe from one ERC-4337\n\t * module (and EntryPoint) to another. For Safe 4337 accounts the module is\n\t * both the enabled module and the fallback handler, so a migration is exactly:\n\t *   1. disableModule(oldModule)\n\t *   2. enableModule(newModule)\n\t *   3. setFallbackHandler(newModule)\n\t *\n\t * @note Both the v0.6/v0.7 `Safe4337Module` and the v0.9\n\t * `Safe4337MultiChainSignatureModule` are stateless (no per-account storage),\n\t * so there is NO storage to clear when swapping modules — these three\n\t * transactions are the whole migration. The batch is validated and executed\n\t * by the OLD module on the OLD EntryPoint; disabling that module mid-batch is\n\t * safe because validation has already completed.\n\t *\n\t * Unless `skipPreflight` is set, this verifies on-chain that the account is\n\t * actually a Safe running `oldModuleAddress` (the module is enabled AND is the\n\t * current fallback handler) and that its Safe version meets the module minimum\n\t * (>= 1.4.1) — turning a would-be cryptic on-chain `AA23`/`AA24` into a clear\n\t * up-front error.\n\t *\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain (used to find\n\t *   the previous module in the linked list when not provided, and for preflight)\n\t * @param oldModuleAddress - the currently-enabled 4337 module to disable\n\t * @param newModuleAddress - the 4337 module to enable and set as fallback handler\n\t * @param overrides - previous-module lookup overrides and `skipPreflight`\n\t * @returns a promise of [disableOld, enableNew, setFallbackHandler] MetaTransactions\n\t *\n\t * @remarks Shared implementation behind the version-specific migration helpers\n\t * (e.g. {@link SafeAccountV0_3_0.createMigrateToSafeMultiChainSigAccountV1MetaTransactions}).\n\t * It is `protected` on purpose: those wrappers pin the correct module addresses,\n\t * so callers reach migration through them rather than supplying raw module\n\t * addresses directly.\n\t */\n\tprotected async createModuleMigrationMetaTransactions(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\toldModuleAddress: string,\n\t\tnewModuleAddress: string,\n\t\toverrides: {\n\t\t\tprevModuleAddress?: string;\n\t\t\tmodulesStart?: string;\n\t\t\tmodulesPageSize?: bigint;\n\t\t\tskipPreflight?: boolean;\n\t\t} = {},\n\t): Promise<MetaTransaction[]> {\n\t\tif (overrides.skipPreflight !== true) {\n\t\t\tawait this.assertMigratableFromModule(nodeRpcUrl, oldModuleAddress);\n\t\t}\n\n\t\tconst disableOldModule = await this.createDisableModuleMetaTransaction(\n\t\t\tnodeRpcUrl,\n\t\t\toldModuleAddress,\n\t\t\tthis.accountAddress,\n\t\t\toverrides,\n\t\t);\n\n\t\tconst enableNewModule = SafeAccount.createEnableModuleMetaTransaction(\n\t\t\tnewModuleAddress,\n\t\t\tthis.accountAddress,\n\t\t);\n\n\t\tconst setFallbackHandler: MetaTransaction = {\n\t\t\tto: this.accountAddress,\n\t\t\tvalue: 0n,\n\t\t\tdata: createCallData(\n\t\t\t\t\"0xf08a0323\", //setFallbackHandler(address)\n\t\t\t\t[\"address\"],\n\t\t\t\t[newModuleAddress],\n\t\t\t),\n\t\t};\n\n\t\treturn [disableOldModule, enableNewModule, setFallbackHandler];\n\t}\n\n\t/**\n\t * Minimum Safe singleton version required by the ERC-4337 modules.\n\t */\n\tprivate static readonly MIN_SAFE_4337_VERSION = \"1.4.1\";\n\n\t/**\n\t * Assert that this account is a deployed Safe currently running `oldModuleAddress`\n\t * as both its enabled module and its fallback handler, on a Safe version that\n\t * meets the 4337 module minimum. Throws a descriptive `BAD_DATA` error otherwise.\n\t */\n\tprivate async assertMigratableFromModule(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\toldModuleAddress: string,\n\t): Promise<void> {\n\t\tconst node = JsonRpcNode.from(nodeRpcUrl);\n\n\t\t// The migration UserOperation is validated through the Safe's fallback\n\t\t// handler on the old EntryPoint, so the old module must be the fallback\n\t\t// handler for the migration to be processable at all.\n\t\tlet fallbackHandler: string;\n\t\ttry {\n\t\t\tfallbackHandler = await this.getFallbackHandler(node);\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`Could not read the fallback handler of ${this.accountAddress} — is it a deployed Safe? ` +\n\t\t\t\t\t\"Pass { skipPreflight: true } to bypass this check.\",\n\t\t\t\t{ cause: ensureError(err) },\n\t\t\t);\n\t\t}\n\t\tif (fallbackHandler.toLowerCase() !== oldModuleAddress.toLowerCase()) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`Safe ${this.accountAddress} fallback handler is ${fallbackHandler}, expected the ` +\n\t\t\t\t\t`old 4337 module ${oldModuleAddress}. This account is not a Safe running that ` +\n\t\t\t\t\t\"module; pass { skipPreflight: true } to bypass.\",\n\t\t\t);\n\t\t}\n\n\t\t// The old module must also be enabled so execTransactionFromModule (which\n\t\t// executes the migration batch) is authorized.\n\t\tlet moduleEnabled: boolean;\n\t\ttry {\n\t\t\tmoduleEnabled = await this.isModuleEnabled(node, oldModuleAddress);\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`Could not check whether module ${oldModuleAddress} is enabled on Safe ` +\n\t\t\t\t\t`${this.accountAddress} — is it a deployed Safe? Pass { skipPreflight: true } to bypass.`,\n\t\t\t\t{ cause: ensureError(err) },\n\t\t\t);\n\t\t}\n\t\tif (!moduleEnabled) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`The 4337 module ${oldModuleAddress} is not enabled on Safe ${this.accountAddress}. ` +\n\t\t\t\t\t\"Pass { skipPreflight: true } to bypass.\",\n\t\t\t);\n\t\t}\n\n\t\t// Both modules require Safe >= 1.4.1. Treat read/decode failures and\n\t\t// empty/invalid version strings as a failed preflight.\n\t\tlet version: string;\n\t\ttry {\n\t\t\tversion = await this.getSafeVersion(node);\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`Could not read the Safe version (VERSION()) of ${this.accountAddress} — is it a ` +\n\t\t\t\t\t`deployed Safe running module ${oldModuleAddress}? Pass { skipPreflight: true } to bypass.`,\n\t\t\t\t{ cause: ensureError(err) },\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\ttypeof version !== \"string\" ||\n\t\t\tversion.trim() === \"\" ||\n\t\t\t!SafeAccount.isVersionAtLeast(version, SafeAccount.MIN_SAFE_4337_VERSION)\n\t\t) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`Safe ${this.accountAddress} reported version \"${version}\", which does not meet the ` +\n\t\t\t\t\t`minimum ${SafeAccount.MIN_SAFE_4337_VERSION} required by the 4337 modules ` +\n\t\t\t\t\t`(module ${oldModuleAddress}). Pass { skipPreflight: true } to bypass.`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Compare dotted version strings numerically (ignoring any \"+suffix\"), e.g.\n\t * isVersionAtLeast(\"1.4.1\", \"1.4.1\") === true, (\"1.5.0\", \"1.4.1\") === true.\n\t */\n\tprivate static isVersionAtLeast(version: string, minimum: string): boolean {\n\t\tconst parse = (v: string): number[] =>\n\t\t\tv\n\t\t\t\t.split(\"+\")[0]\n\t\t\t\t.split(\".\")\n\t\t\t\t.map((n) => parseInt(n, 10) || 0);\n\t\tconst a = parse(version);\n\t\tconst b = parse(minimum);\n\t\tfor (let i = 0; i < Math.max(a.length, b.length); i++) {\n\t\t\tconst x = a[i] ?? 0;\n\t\t\tconst y = b[i] ?? 0;\n\t\t\tif (x !== y) return x > y;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Simulate the encoded calldata for this account on Tenderly and optionally return a share link.\n\t * When `isInit` isn't provided, nonce is fetched via `nodeRpcUrl` to decide whether to include\n\t * factory address/data in the simulation.\n\t * @param tenderlyAccountSlug - The Tenderly account slug\n\t * @param tenderlyProjectSlug - The Tenderly project slug\n\t * @param tenderlyAccessKey - The Tenderly API access key\n\t * @param nodeRpcUrl - Ethereum JSON-RPC node URL (only used when overrides.isInit is not set)\n\t * @param chainId - Target chain ID\n\t * @param metaTransactions - Transactions to simulate (ignored if overrides.callData is set)\n\t * @param blockNumber - Optional block number for the simulation\n\t * @param overrides - overrides for the default values\n\t * @param overrides.safeModuleExecutorFunctionSelector - executor function to use\n\t * @param overrides.multisendContractAddress - multisend address for batch transactions\n\t * @param overrides.callData - pre-encoded calldata, overriding metaTransactions\n\t * @param overrides.createShareLink - if true (default), also create a shareable dashboard link\n\t * @param overrides.isInit - skip the nonce RPC check and explicitly set whether this is a deployment simulation\n\t * @returns The simulation result, and optionally `callDataSimulationShareLink` / `accountDeploymentSimulationShareLink`\n\t */\n\tasync simulateCallDataWithTenderlyAndCreateShareLink(\n\t\ttenderlyAccountSlug: string,\n\t\ttenderlyProjectSlug: string,\n\t\ttenderlyAccessKey: string,\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode | null = null,\n\t\tchainId: bigint,\n\t\tmetaTransactions: MetaTransaction[],\n\t\tblockNumber: number | null = null,\n\t\toverrides: {\n\t\t\tsafeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector;\n\t\t\tmultisendContractAddress?: string;\n\t\t\tcallData?: string;\n\t\t\tcreateShareLink?: boolean;\n\t\t\tisInit?: boolean;\n\t\t} = {},\n\t): Promise<{\n\t\tsimulation: TenderlySimulationResult;\n\t\tcallDataSimulationShareLink?: string;\n\t\taccountDeploymentSimulationShareLink?: string;\n\t}> {\n\t\tlet isInit: boolean = false;\n\t\tif (nodeRpcUrl == null && overrides.isInit == null) {\n\t\t\tthrow new RangeError(\"nodeRpcUrl and overrides.isInit can't both be null\");\n\t\t} else if (overrides.isInit == null) {\n\t\t\tconst accountNonce = await fetchAccountNonce(\n\t\t\t\tnodeRpcUrl as string,\n\t\t\t\tthis.entrypointAddress,\n\t\t\t\tthis.accountAddress,\n\t\t\t);\n\t\t\tisInit = accountNonce === 0n;\n\t\t} else {\n\t\t\tisInit = overrides.isInit;\n\t\t}\n\n\t\tlet callData = \"0x\" as string;\n\t\tif (overrides.callData == null) {\n\t\t\tif (metaTransactions.length === 1) {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataSingleTransaction(metaTransactions[0], {\n\t\t\t\t\tsafeModuleExecutorFunctionSelector: overrides.safeModuleExecutorFunctionSelector,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tcallData = SafeAccount.createAccountCallDataBatchTransactions(metaTransactions, {\n\t\t\t\t\tsafeModuleExecutorFunctionSelector: overrides.safeModuleExecutorFunctionSelector,\n\t\t\t\t\tmultisendContractAddress: overrides.multisendContractAddress,\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\tconst createShareLink = overrides.createShareLink ?? true;\n\t\tif (createShareLink) {\n\t\t\treturn await simulateSenderCallDataWithTenderlyAndCreateShareLink(\n\t\t\t\ttenderlyAccountSlug,\n\t\t\t\ttenderlyProjectSlug,\n\t\t\t\ttenderlyAccessKey,\n\t\t\t\tchainId,\n\t\t\t\tthis.entrypointAddress,\n\t\t\t\tthis.accountAddress,\n\t\t\t\tcallData,\n\t\t\t\tisInit ? this.factoryAddress : null,\n\t\t\t\tisInit ? this.factoryData : null,\n\t\t\t\tblockNumber,\n\t\t\t);\n\t\t} else {\n\t\t\tconst simulation = await simulateSenderCallDataWithTenderly(\n\t\t\t\ttenderlyAccountSlug,\n\t\t\t\ttenderlyProjectSlug,\n\t\t\t\ttenderlyAccessKey,\n\t\t\t\tchainId,\n\t\t\t\tthis.entrypointAddress,\n\t\t\t\tthis.accountAddress,\n\t\t\t\tcallData,\n\t\t\t\tisInit ? this.factoryAddress : null,\n\t\t\t\tisInit ? this.factoryData : null,\n\t\t\t\tblockNumber,\n\t\t\t);\n\t\t\treturn { simulation };\n\t\t}\n\t}\n\n\t/**\n\t * create EIP-712 signing data for a Safe message, scoped to this account.\n\t * @param chainId - target chain id\n\t * @param message - message string to sign\n\t * @returns an object containing the typed data domain, types, and message value\n\t * needed for hashing and signing a Safe message\n\t */\n\tgetSafeMessageEip712Data(\n\t\tchainId: bigint,\n\t\tmessage: string,\n\t): {\n\t\tdomain: SafeMessageTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeMessageTypedMessageValue;\n\t} {\n\t\treturn getSafeMessageEip712Data(this.accountAddress, chainId, message);\n\t}\n}\n\n/**\n * generate a Safe on-chain identifier per https://docs.safe.global/sdk/onchain-tracking\n * @param project - project name\n * @param platform - \"Web\", \"Mobile\", \"Safe App\", or \"Widget\"; defaults to \"Web\"\n * @param tool - tool name; defaults to \"abstractionkit\"\n * @param toolVersion - tool version; defaults to the current abstractionkit version\n * @returns the on-chain identifier as a hex string (not 0x prefixed)\n */\nfunction generateOnChainIdentifier(\n\tproject: string,\n\tplatform: \"Web\" | \"Mobile\" | \"Safe App\" | \"Widget\" = \"Web\",\n\ttool: string = \"abstractionkit\",\n\ttoolVersion: string = \"0.4.1\",\n): string {\n\tconst identifierPrefix = \"5afe\"; // Safe identifier prefix\n\tconst identifierVersion = \"00\"; // First version\n\tconst projectHash = keccak256(hexlify(toUtf8Bytes(project))).slice(-20);\n\tconst platformHash = keccak256(hexlify(toUtf8Bytes(platform))).slice(-3);\n\tconst toolHash = keccak256(hexlify(toUtf8Bytes(tool))).slice(-3);\n\tconst toolVersionHash = keccak256(hexlify(toUtf8Bytes(toolVersion))).slice(-3);\n\n\t// hex of the UTF-8 bytes, no 0x prefix (Buffer is undefined in browsers / React Native)\n\tconst projectHashEncoded = hexlify(toUtf8Bytes(projectHash)).slice(2);\n\tconst platformHashEncoded = hexlify(toUtf8Bytes(platformHash)).slice(2);\n\tconst toolHashEncoded = hexlify(toUtf8Bytes(toolHash)).slice(2);\n\tconst toolVersionHashEncoded = hexlify(toUtf8Bytes(toolVersionHash)).slice(2);\n\n\tconst res = `${identifierPrefix}${identifierVersion}${projectHashEncoded}${platformHashEncoded}${toolHashEncoded}${toolVersionHashEncoded}`;\n\treturn res;\n}\n","import { AbstractionKitError } from \"src/errors\";\nimport type { MetaTransaction } from \"../../../types\";\nimport { SafeAccount } from \"../SafeAccount\";\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\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\t}\n\n\t/**\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\tpublic createEnableModuleMetaTransaction(accountAddress: string): MetaTransaction {\n\t\treturn SafeAccount.createEnableModuleMetaTransaction(this.moduleAddress, accountAddress);\n\t}\n\n\t/**\n\t * Throws if the RPC call returned empty data (`0x`), which typically\n\t * indicates the module contract is not deployed at the expected address.\n\t * @param result - The raw hex result from an `eth_call`.\n\t * @param requestName - Name of the calling method, used in the error message.\n\t */\n\tpublic checkForEmptyResultAndRevert(result: string, requestName: string): void {\n\t\tif (result === \"0x\") {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\trequestName +\n\t\t\t\t\t\" returned 0x, \" +\n\t\t\t\t\t\"module contract \" +\n\t\t\t\t\tthis.moduleAddress +\n\t\t\t\t\t\" is probably not deployed\",\n\t\t\t);\n\t\t}\n\t}\n}\n","import {decodeAbiParameters} from \"../../../ethereUtils\";\nimport type {Transport} from \"../../../transport\";\nimport {JsonRpcNode} from \"../../../transport\";\nimport type {MetaTransaction} from \"../../../types\";\nimport {createCallData} from \"../../../utils\";\nimport {SafeModule} from \"./SafeModule\";\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 = \"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\tstatic readonly DEFAULT_ALLOWANCE_MODULE_ADDRESS = \"0x691f59471Bfd2B7d639DCF74671a2d648ED1E331\";\n\n\t/**\n\t * @param moduleAddress - Deployed address of the Allowance Module contract.\n\t *   Defaults to {@link DEFAULT_ALLOWANCE_MODULE_ADDRESS}.\n\t */\n\tconstructor(moduleAddress: string = AllowanceModule.DEFAULT_ALLOWANCE_MODULE_ADDRESS) {\n\t\tsuper(moduleAddress);\n\t}\n\n\t/**\n\t * Creates a MetaTransaction that sets a one-time (non-recurring) token allowance\n\t * for a delegate. The allowance is consumed once and never resets, and it is\n\t * active as soon as the Safe executes the transaction.\n\t *\n\t * Note: the deployed AllowanceModule cannot delay activation of a one-time\n\t * allowance — `setAllowance` explicitly requires `resetTimeMin > 0` whenever\n\t * `resetBaseMin` is nonzero and reverts otherwise.\n\t * @param delegate - Address of the delegate to grant the allowance to.\n\t * @param token - ERC-20 token contract address (use zero address for native token).\n\t * @param allowanceAmount - Maximum amount the delegate can spend, in the token's smallest unit.\n\t * @returns A MetaTransaction to be executed by the Safe.\n\t */\n\tpublic createOneTimeAllowanceMetaTransaction(\n\t\tdelegate: string,\n\t\ttoken: string,\n\t\tallowanceAmount: bigint,\n\t): MetaTransaction {\n\t\treturn this.createBaseSetAllowanceMetaTransaction(delegate, token, allowanceAmount, 0n, 0n);\n\t}\n\n\t/**\n\t * Creates a MetaTransaction that sets a recurring token allowance for a delegate.\n\t * The allowance resets to the full amount after each validity period elapses,\n\t * and is spendable immediately once the Safe executes the transaction.\n\t * @param delegate - Address of the delegate to grant the allowance to.\n\t * @param token - ERC-20 token contract address (use zero address for native token).\n\t * @param allowanceAmount - Maximum amount per period, in the token's smallest unit.\n\t * @param recurringAllowanceValidityPeriodInMinutes - Duration of each allowance period in minutes.\n\t * @param inThePastPeriodStartBaseTimeStamp - Optional unix\n\t * timestamp **in seconds** that must be in the past (less than the block timestamp).\n\t * It represents the start of the recurring allowance period accounting — it does\n\t * **not** delay activation: the allowance is active and spendable immediately once\n\t * the Safe executes the transaction; this value only sets when each period resets.\n\t * So if you want to start accounting from a Saturday 10am for example, calculate the\n\t * timestamp of any previous Saturday 10am and use it as the value for this param.\n\t * Defaults to 0n, which starts the period accounting at the moment the Safe\n\t * executes the transaction for a new allowance; when updating an existing\n\t * allowance, 0n keeps its current accounting anchor unchanged.\n\t * @returns A MetaTransaction to be executed by the Safe.\n\t */\n\tpublic createRecurringAllowanceMetaTransaction(\n\t\tdelegate: string,\n\t\ttoken: string,\n\t\tallowanceAmount: bigint,\n\t\trecurringAllowanceValidityPeriodInMinutes: bigint,\n\t\tinThePastPeriodStartBaseTimeStamp: bigint = 0n,\n\t): MetaTransaction {\n\t\t// resetTimeMin is a uint16 on-chain — reject values the ABI encoder\n\t\t// would otherwise refuse with an unhelpful generic error\n\t\tif (\n\t\t\trecurringAllowanceValidityPeriodInMinutes < 0n ||\n\t\t\trecurringAllowanceValidityPeriodInMinutes >= 2n ** 16n\n\t\t) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"recurringAllowanceValidityPeriodInMinutes must fit the contract's \" +\n\t\t\t\t\t\"uint16 resetTimeMin (0 to 65535 minutes).\",\n\t\t\t);\n\t\t}\n\t\tconst baseInMinutes = inThePastPeriodStartBaseTimeStamp / 60n;\n\t\t// resetBaseMin is a uint32 of minutes since the epoch; a millisecond\n\t\t// timestamp (Date.now()) still overflows this bound after conversion\n\t\tif (inThePastPeriodStartBaseTimeStamp < 0n || baseInMinutes >= 2n ** 32n) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"inThePastPeriodStartBaseTimeStamp must be a unix timestamp in \" +\n\t\t\t\t\t\"seconds — its minutes equivalent must fit the contract's \" +\n\t\t\t\t\t\"uint32 resetBaseMin; a millisecond timestamp does not.\",\n\t\t\t);\n\t\t}\n\t\treturn this.createBaseSetAllowanceMetaTransaction(\n\t\t\tdelegate,\n\t\t\ttoken,\n\t\t\tallowanceAmount,\n\t\t\trecurringAllowanceValidityPeriodInMinutes,\n\t\t\tbaseInMinutes,\n\t\t);\n\t}\n\n\t/**\n\t * create MetaTransaction that allows to update the allowance for\n\t * a specified token. This can only be done via a Safe transaction.\n\t * @param delegate - Delegate whose allowance should be updated.\n\t * @param token - Token contract address.\n\t * @param allowanceAmount - allowance in smallest token unit.\n\t * @param resetTimeMin - Time after which the allowance should reset\n\t * @param resetBaseMin - Time based on which the reset time should be increased\n\t * @returns a MetaTransaction\n\t */\n\tpublic createBaseSetAllowanceMetaTransaction(\n\t\tdelegate: string,\n\t\ttoken: string,\n\t\tallowanceAmount: bigint,\n\t\tresetTimeMin: bigint,\n\t\tresetBaseMin: bigint,\n\t): MetaTransaction {\n\t\t//setAllowance(address delegate, address token, uint96 allowanceAmount, uint16 resetTimeMin, uint32 resetBaseMin)\n\t\tconst functionSelector = \"0xbeaeb388\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address\", \"uint96\", \"uint16\", \"uint32\"],\n\t\t\t[delegate, token, allowanceAmount, resetTimeMin, resetBaseMin],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create MetaTransaction that allows to renew(reset) the allowance for a specific\n\t * delegate and token.\n\t * @param delegate - Delegate whose allowance should be updated.\n\t * @param token - Token contract address.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createRenewAllowanceMetaTransaction(delegate: string, token: string): MetaTransaction {\n\t\t//resetAllowance(address delegate, address token)\n\t\tconst functionSelector = \"0xc19bf50e\";\n\t\tconst callData = createCallData(functionSelector, [\"address\", \"address\"], [delegate, token]);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create MetaTransaction that allows to remove the allowance for a specific\n\t * delegate and token. This will set all values except the `nonce` to 0.\n\t * @param delegate - Delegate whose allowance should be updated.\n\t * @param token - Token contract address.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createDeleteAllowanceMetaTransaction(delegate: string, token: string): MetaTransaction {\n\t\t//deleteAllowance(address delegate, address token)\n\t\tconst functionSelector = \"0x885133e3\";\n\t\tconst callData = createCallData(functionSelector, [\"address\", \"address\"], [delegate, token]);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * Creates a MetaTransaction that executes a token transfer using an existing allowance.\n\t * Can be called by the delegate or by anyone with a valid delegate signature.\n\t * @param allowanceSourceSafeAddress - Safe address whose allowance is being spent.\n\t * @param token - ERC-20 token contract address to transfer.\n\t * @param to - Recipient address for the token transfer.\n\t * @param amount - Amount to transfer, in the token's smallest unit.\n\t * @param delegate - Delegate address whose allowance is being used.\n\t * @param overrides.delegateSignature - Optional signature from the delegate. Defaults to a\n\t *   sentinel value indicating the caller is the delegate themselves.\n\t * @param overrides.paymentToken - Optional token address used to pay for execution.\n\t * @param overrides.paymentAmount - Amount to pay for execution (required if paymentToken is set).\n\t * @returns A MetaTransaction to be executed by the Safe.\n\t * @throws Will revert on-chain if the delegate's nonce has reached 65534 for this token.\n\t */\n\tpublic createAllowanceTransferMetaTransaction(\n\t\tallowanceSourceSafeAddress: string,\n\t\ttoken: string,\n\t\tto: string,\n\t\tamount: bigint,\n\t\tdelegate: string,\n\t\toverrides: {\n\t\t\tdelegateSignature?: string;\n\t\t\tpaymentToken?: string;\n\t\t\tpaymentAmount?: bigint;\n\t\t} = {},\n\t): MetaTransaction {\n\t\tlet paymentToken = \"0x0000000000000000000000000000000000000000\";\n\t\tlet paymentAmount = 0n;\n\t\tif (overrides.paymentToken != null) {\n\t\t\tpaymentToken = overrides.paymentToken;\n\t\t\tif (overrides.paymentAmount == null) {\n\t\t\t\tthrow new RangeError(\"must specify paymentAmount if paymentToken is set\");\n\t\t\t}\n\t\t\tpaymentAmount = overrides.paymentAmount;\n\t\t}\n\n\t\tconst delegateSignature =\n\t\t\toverrides.delegateSignature ??\n\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\";\n\n\t\treturn this.createBaseExecuteAllowanceTransferMetaTransaction(\n\t\t\tallowanceSourceSafeAddress,\n\t\t\ttoken,\n\t\t\tto,\n\t\t\tamount,\n\t\t\tpaymentToken,\n\t\t\tpaymentAmount,\n\t\t\tdelegate,\n\t\t\tdelegateSignature,\n\t\t);\n\t}\n\n\t/**\n\t * create MetaTransaction that allows to use the allowance to perform a transfer.\n\t * @param safeAddress - The Safe whose funds should be used.\n\t * @param token - Token contract address.\n\t * @param to - Address that should receive the tokens.\n\t * @param amount - Amount that should be transferred.\n\t * @param paymentToken - Token that should be used to pay for the execution of the transfer.\n\t * @param payment - Amount to should be paid for executing the transfer.\n\t * @param delegate - Delegate whose allowance should be updated.\n\t * @param signature - Signature generated by the delegate to authorize the transfer.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createBaseExecuteAllowanceTransferMetaTransaction(\n\t\tsafeAddress: string,\n\t\ttoken: string,\n\t\tto: string,\n\t\tamount: bigint,\n\t\tpaymentToken: string,\n\t\tpayment: bigint,\n\t\tdelegate: string,\n\t\tdelegateSignature: string,\n\t): MetaTransaction {\n\t\t//executeAllowanceTransfer(address,address,address,uint96,address,uint96,address,bytes)\n\t\tconst functionSelector = \"0x4515641a\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address\", \"address\", \"uint96\", \"address\", \"uint96\", \"address\", \"bytes\"],\n\t\t\t[safeAddress, token, to, amount, paymentToken, payment, delegate, delegateSignature],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a MetaTransaction that allows to add a delegate.\n\t * @param delegate - Delegate that should be added.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createAddDelegateMetaTransaction(delegate: string): MetaTransaction {\n\t\t//\"addDelegate(address)\"\n\t\tconst functionSelector = \"0xe71bdf41\";\n\t\tconst callData = createCallData(functionSelector, [\"address\"], [delegate]);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a MetaTransaction that allows to remove a delegate.\n\t * @param delegate - Delegate that should be removed.\n\t * @param removeAllowances - Indicator if allowances should also be removed.\n\t * This should be set to `true` unless this causes an out of gas,\n\t * in this case the allowances should be \"manually\" deleted via `deleteAllowance`.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createRemoveDelegateMetaTransaction(\n\t\tdelegate: string,\n\t\tremoveAllowances: boolean,\n\t): MetaTransaction {\n\t\t//\"removeDelegate(address,bool)\"\n\t\tconst functionSelector = \"0xdd43a79f\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"bool\"],\n\t\t\t[delegate, removeAllowances],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * Get delegated tokens\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param safeAddress - The target account.\n\t * @param delegate - The target delegate.\n\t * @returns promise of a list of tokens\n\t */\n\tpublic async getTokens(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\tsafeAddress: string,\n\t\tdelegate: string,\n\t): Promise<string[]> {\n\t\t//\"getTokens(address,address)\"\n\t\tconst functionSelector = \"0x8d0e8e1d\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address\"],\n\t\t\t[safeAddress, delegate],\n\t\t);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\n\t\tconst tokens = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\t\tthis.checkForEmptyResultAndRevert(tokens, \"getTokens\");\n\t\tconst decodedCalldata = decodeAbiParameters<[string[]]>([\"address[]\"], tokens);\n\t\treturn decodedCalldata[0];\n\t}\n\n\t/**\n\t * Get the delegate's allowance for a specific token.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param safeAddress - The target account.\n\t * @param delegate - The target delegate.\n\t * @param token - The target token.\n\t * @returns promise of Allowance\n\t */\n\tpublic async getTokensAllowance(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\tsafeAddress: string,\n\t\tdelegate: string,\n\t\ttoken: string,\n\t): Promise<Allowance> {\n\t\t//\"getTokenAllowance(address,address,address)\"\n\t\tconst functionSelector = \"0x94b31fbd\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address\", \"address\"],\n\t\t\t[safeAddress, delegate, token],\n\t\t);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\n\t\tconst tokenAllowance = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\t\tthis.checkForEmptyResultAndRevert(tokenAllowance, \"getTokenAllowance\");\n\t\tconst decodedCalldata = decodeAbiParameters<[bigint[]]>([\"uint256[5]\"], tokenAllowance);\n\t\tconst allowance = decodedCalldata[0];\n\t\treturn {\n\t\t\tamount: BigInt(allowance[0]),\n\t\t\tspent: BigInt(allowance[1]),\n\t\t\tresetTimeMin: BigInt(allowance[2]),\n\t\t\tlastResetMin: BigInt(allowance[3]),\n\t\t\tnonce: BigInt(allowance[4]),\n\t\t};\n\t}\n\n\t/**\n\t * Fetches all delegate addresses for a Safe. Automatically paginates through\n\t * all results unless `maxNumberOfResults` is specified.\n\t * @param nodeRpcUrl - JSON-RPC endpoint URL for the target chain.\n\t * @param safeAddress - The Safe account address to query delegates for.\n\t * @param overrides.start - Starting index for pagination (default 0).\n\t * @param overrides.maxNumberOfResults - Maximum number of delegates to return.\n\t *   If omitted, all delegates are fetched via automatic pagination.\n\t * @returns Array of delegate addresses.\n\t */\n\tpublic async getDelegates(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\tsafeAddress: string,\n\t\toverrides: {\n\t\t\tstart?: bigint;\n\t\t\tmaxNumberOfResults?: bigint;\n\t\t} = {},\n\t): Promise<string[]> {\n\t\tlet start = overrides.start ?? 0n;\n\t\tif (overrides.maxNumberOfResults != null) {\n\t\t\t// the module's page-size parameter is a uint8\n\t\t\tif (overrides.maxNumberOfResults < 0n || overrides.maxNumberOfResults > 255n) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\"maxNumberOfResults must be between 0 and 255 (the module's page \" +\n\t\t\t\t\t\t\"size is a uint8) — omit it to fetch all delegates via pagination.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tawait this.baseGetDelegates(nodeRpcUrl, safeAddress, start, overrides.maxNumberOfResults)\n\t\t\t).results;\n\t\t}\n\t\tconst pageSize = 20n;\n\t\tconst delegates: string[] = [];\n\t\twhile (true) {\n\t\t\tconst getDelegatesResult = await this.baseGetDelegates(\n\t\t\t\tnodeRpcUrl,\n\t\t\t\tsafeAddress,\n\t\t\t\tstart,\n\t\t\t\tpageSize,\n\t\t\t);\n\t\t\tdelegates.push.apply(delegates, getDelegatesResult.results);\n\t\t\tif (getDelegatesResult.next === 0n) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tstart = getDelegatesResult.next;\n\t\t\t}\n\t\t}\n\t\treturn delegates;\n\t}\n\n\t/**\n\t * Fetch a single page of delegate addresses from the module (used internally by `getDelegates`).\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param safeAddress - The target account.\n\t * @param start - Pagination start index\n\t * @param pageSize - Maximum number of delegates to return in this page\n\t * @returns promise of `{ results, next }` — `next` is 0 when there are no more pages\n\t */\n\tpublic async baseGetDelegates(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\tsafeAddress: string,\n\t\tstart: bigint,\n\t\tpageSize: bigint,\n\t): Promise<{ results: string[]; next: bigint }> {\n\t\t//\"getDelegates(address,uint48,uint8)\"\n\t\tconst functionSelector = \"0xeb37abe0\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"uint48\", \"uint8\"],\n\t\t\t[safeAddress, start, pageSize],\n\t\t);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\n\t\tconst delegates = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\t\tthis.checkForEmptyResultAndRevert(delegates, \"getDelegates\");\n\t\tconst decodedCalldata = decodeAbiParameters<[string[], bigint]>(\n\t\t\t[\"address[]\", \"uint48\"],\n\t\t\tdelegates,\n\t\t);\n\n\t\treturn {\n\t\t\tresults: decodedCalldata[0],\n\t\t\tnext: BigInt(decodedCalldata[1]),\n\t\t};\n\t}\n}\n\n/**\n * On-chain allowance state for a delegate/token pair on a Safe account.\n */\nexport type Allowance = {\n\t/** Total allowance amount per period, in the token's smallest unit. */\n\tamount: bigint;\n\t/** Amount already spent in the current period. */\n\tspent: bigint;\n\t/** Reset period duration in minutes. 0 means one-time (non-recurring). */\n\tresetTimeMin: bigint;\n\t/** Timestamp (in minutes since epoch) of the last allowance reset. */\n\tlastResetMin: bigint;\n\t/**\n\t * Monotonically increasing nonce, incremented on each allowance transfer.\n\t * Capped at 65534 (uint16 max - 1); once exhausted, a new delegate is required.\n\t */\n\tnonce: bigint;\n};\n","import {AbstractionKitError} from \"../../../errors\";\nimport {decodeAbiParameters} from \"../../../ethereUtils\";\nimport type {Transport} from \"../../../transport\";\nimport {JsonRpcNode} from \"../../../transport\";\nimport type {MetaTransaction} from \"../../../types\";\nimport {createCallData} from \"../../../utils\";\nimport {SafeModule} from \"./SafeModule\";\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\tstatic readonly DEFAULT_SOCIAL_RECOVERY_ADDRESS =\n\t\tSocialRecoveryModuleGracePeriodSelector.After3Days;\n\n\t/**\n\t * @param moduleAddress - Deployed address of the Social Recovery Module.\n\t *   Defaults to the 3-day grace period deployment.\n\t */\n\tconstructor(moduleAddress: string = SocialRecoveryModule.DEFAULT_SOCIAL_RECOVERY_ADDRESS) {\n\t\tsuper(moduleAddress);\n\t}\n\n\t/**\n\t * create MetaTransaction that lets single guardian confirm the execution of the recovery request.\n\t * Can also trigger the start of the execution by passing true to 'execute' parameter.\n\t * Once triggered the recovery is pending for the recovery period before it can be finalised.\n\t * @param accountAddress - The target account.\n\t * @param newOwners - The new owners' addresses.\n\t * @param newThreshold - The new threshold for the safe.\n\t * @param execute - Whether to auto-start execution of recovery.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createConfirmRecoveryMetaTransaction(\n\t\taccountAddress: string,\n\t\tnewOwners: string[],\n\t\tnewThreshold: number,\n\t\texecute: boolean,\n\t): MetaTransaction {\n\t\t//\"confirmRecovery(address,address[],uint256,bool)\"\n\t\tconst functionSelector = \"0x064e2d0e\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address[]\", \"uint256\", \"bool\"],\n\t\t\t[accountAddress, newOwners, newThreshold, execute],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create MetaTransaction that lets multiple guardians confirm the execution of the recovery request.\n\t * Can also trigger the start of the execution by passing true to 'execute' parameter.\n\t * Once triggered the recovery is pending for the recovery period before it can be finalised.\n\t * @param accountAddress - The target account.\n\t * @param newOwners - The new owners' addresses.\n\t * @param newThreshold - The new threshold for the safe.\n\t * @param signatureData - The guardians signers and signatures pair list.\n\t * @param execute - true to auto-start execution of recovery or false for not.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createMultiConfirmRecoveryMetaTransaction(\n\t\taccountAddress: string,\n\t\tnewOwners: string[],\n\t\tnewThreshold: number,\n\t\tsignaturePairList: RecoverySignaturePair[],\n\t\texecute: boolean,\n\t): MetaTransaction {\n\t\t//\"multiConfirmRecovery(address,address[],uint256,SignatureData[],bool)\"\n\t\tconst functionSelector = \"0x0728e1e7\";\n\t\t// The on-chain module rejects with \"SM: duplicate signers/invalid ordering\"\n\t\t// unless signature pairs are sorted by signer address ascending. Sort here\n\t\t// so callers don't have to know about this internal constraint.\n\t\tconst sortedPairs = [...signaturePairList].sort((a, b) => {\n\t\t\tconst aSigner = BigInt(a.signer);\n\t\t\tconst bSigner = BigInt(b.signer);\n\t\t\tif (aSigner < bSigner) return -1;\n\t\t\tif (aSigner > bSigner) return 1;\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"BAD_DATA\",\n\t\t\t\t`Duplicate signer in recovery signaturePairList: ${a.signer}`,\n\t\t\t);\n\t\t});\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address[]\", \"uint256\", \"(address,bytes)[]\", \"bool\"],\n\t\t\t[\n\t\t\t\taccountAddress,\n\t\t\t\tnewOwners,\n\t\t\t\tnewThreshold,\n\t\t\t\tsortedPairs.map((signaturePair) => [signaturePair.signer, signaturePair.signature]),\n\t\t\t\texecute,\n\t\t\t],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * @notice create MetaTransaction that lets the guardians start the execution of the recovery request.\n\t * Once triggered the recovery is pending for the recovery period before it can be finalised.\n\t * @param accountAddress - The target account.\n\t * @param newOwners - The new owners' addresses.\n\t * @param newThreshold - The new threshold for the safe.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createExecuteRecoveryMetaTransaction(\n\t\taccountAddress: string,\n\t\tnewOwners: string[],\n\t\tnewThreshold: number,\n\t): MetaTransaction {\n\t\t//\"executeRecovery(address,address[],uint256)\"\n\t\tconst functionSelector = \"0xb1f85f69\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address[]\", \"uint256\"],\n\t\t\t[accountAddress, newOwners, newThreshold],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a MetaTransaction that finalizes an ongoing recovery request if the recovery period is over.\n\t * The method is public and callable by anyone to enable orchestration.\n\t * @param accountAddress - The target account.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createFinalizeRecoveryMetaTransaction(accountAddress: string): MetaTransaction {\n\t\t//\"finalizeRecovery(address)\"\n\t\tconst functionSelector = \"0x315a7af3\";\n\t\tconst callData = createCallData(functionSelector, [\"address\"], [accountAddress]);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a MetaTransaction that lets the account cancel an ongoing recovery request.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createCancelRecoveryMetaTransaction(): MetaTransaction {\n\t\t//\"cancelRecovery()\";\n\t\tconst functionSelector = \"0x0ba234d6\";\n\t\tconst callData = functionSelector;\n\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create a MetaTransaction that lets the owner add a guardian for its account.\n\t * @param guardianAddress - The guardian to add.\n\t * @param threshold - The new threshold that will be set after addition.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createAddGuardianWithThresholdMetaTransaction(\n\t\tguardianAddress: string,\n\t\tthreshold: bigint,\n\t): MetaTransaction {\n\t\t//\"addGuardianWithThreshold(address,uint256)\"\n\t\tconst functionSelector = \"0xbe0e54d7\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"uint256\"],\n\t\t\t[guardianAddress, threshold],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create MetaTransaction that lets the owner revoke a guardian from its account.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * (to get the prevGuardian parameter).\n\t * @param accountAddress - The target account.\n\t * @param guardianAddress - The guardian to revoke.\n\t * @param threshold - The new threshold that will be set after execution of revocation.\n\t * @param prevGuardian - (if not provided, will be detected using the nodeRpcUrl)\n\t * The previous guardian linking to the guardian in the linked list.\n\t * @returns promise of a MetaTransaction\n\t */\n\tpublic async createRevokeGuardianWithThresholdMetaTransaction(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t\tguardianAddress: string,\n\t\tthreshold: bigint,\n\t\toverrides: {\n\t\t\tprevGuardianAddress?: string;\n\t\t} = {},\n\t): Promise<MetaTransaction> {\n\t\tlet 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\t\t\t\t\t`${guardianAddress} is not a current guardian for account : ${accountAddress}`,\n\t\t\t\t);\n\t\t\t} else if (guardianToDeleteIndex === 0) {\n\t\t\t\t//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\t\t\tguardianAddress,\n\t\t\tthreshold,\n\t\t);\n\t}\n\n\t/**\n\t * create MetaTransaction that lets the owner revoke a guardian from its account.\n\t * @param prevGuardian - The previous guardian linking to the guardian in the linked list.\n\t * @param guardian - The guardian to revoke.\n\t * @param threshold - The new threshold that will be set after execution of revocation.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createStandardRevokeGuardianWithThresholdMetaTransaction(\n\t\tprevGuardianAddress: string,\n\t\tguardianAddress: string,\n\t\tthreshold: bigint,\n\t): MetaTransaction {\n\t\t//\"revokeGuardianWithThreshold(address,address,uint256)\"\n\t\tconst functionSelector = \"0x936f7d86\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address\", \"uint256\"],\n\t\t\t[prevGuardianAddress, guardianAddress, threshold],\n\t\t);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * create MetaTransaction that lets the owner change the guardian threshold required to initiate a recovery.\n\t * @param threshold - The new threshold that will be set after execution of revocation.\n\t * @returns a MetaTransaction\n\t */\n\tpublic createChangeThresholdMetaTransaction(threshold: bigint): MetaTransaction {\n\t\t//\"changeThreshold(address,uint256)\"\n\t\tconst functionSelector = \"0x694e80c3\";\n\t\tconst callData = createCallData(functionSelector, [\"uint256\"], [threshold]);\n\t\treturn {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t\tvalue: 0n,\n\t\t};\n\t}\n\n\t/**\n\t * Generates the recovery hash that should be signed by the guardian to authorize a recovery\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @param newOwners - The new owners' addresses.\n\t * @param newThreshold - The new threshold for the safe.\n\t * @param nonce - recovery nonce\n\t * @returns promise of a recovery hash\n\t */\n\tpublic async getRecoveryHash(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t\tnewOwners: string[],\n\t\tnewThreshold: number,\n\t\tnonce: bigint,\n\t): Promise<string> {\n\t\t//\"getRecoveryHash(address,address[],uint256,uint256)\"\n\t\tconst functionSelector = \"0x5f19df08\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address[]\", \"uint256\", \"uint256\"],\n\t\t\t[accountAddress, newOwners, newThreshold, nonce],\n\t\t);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\n\t\tconst recoveryHashResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(recoveryHashResult, \"getRecoveryHash\");\n\t\tconst decodedCalldata = decodeAbiParameters<[string]>([\"bytes32\"], recoveryHashResult);\n\t\treturn decodedCalldata[0];\n\t}\n\n\t/**\n\t * Retrieves the account's current ongoing recovery request.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @return promise of the account's current recovery request\n\t */\n\tpublic async getRecoveryRequest(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t): Promise<RecoveryRequest> {\n\t\t//\"getRecoveryRequest(address)\"\n\t\tconst functionSelector = \"0x4f9a28b9\";\n\t\tconst callData = createCallData(functionSelector, [\"address\"], [accountAddress]);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\n\t\tconst recoveryRequestResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(recoveryRequestResult, \"getRecoveryRequest\");\n\t\tconst decodedCalldata = decodeAbiParameters<[[bigint, bigint, bigint, string[]]]>(\n\t\t\t[\"(uint256,uint256,uint64,address[])\"],\n\t\t\trecoveryRequestResult,\n\t\t);\n\n\t\treturn {\n\t\t\tguardiansApprovalCount: BigInt(decodedCalldata[0][0]),\n\t\t\tnewThreshold: BigInt(decodedCalldata[0][1]),\n\t\t\texecuteAfter: BigInt(decodedCalldata[0][2]),\n\t\t\tnewOwners: decodedCalldata[0][3],\n\t\t};\n\t}\n\n\t/**\n\t * Retrieves the guardian approval count for this particular recovery request at current nonce.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @param newOwners - The new owners' addresses.\n\t * @param newThreshold - The new threshold for the safe.\n\t * @return promise of the account's current recovery approvals count\n\t */\n\tpublic async getRecoveryApprovals(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t\tnewOwners: string[],\n\t\tnewThreshold: number,\n\t): Promise<bigint> {\n\t\t//\"getRecoveryApprovals(address,address[],uint256)\"\n\t\tconst functionSelector = \"0x6c6595ca\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address[]\", \"uint256\"],\n\t\t\t[accountAddress, newOwners, newThreshold],\n\t\t);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst recoveryApprovalResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(recoveryApprovalResult, \"getRecoveryApprovals\");\n\t\tconst decodedCalldata = decodeAbiParameters<[bigint]>([\"uint256\"], recoveryApprovalResult);\n\n\t\treturn BigInt(decodedCalldata[0]);\n\t}\n\n\t/**\n\t * Retrieves specific guardian approval status a particular recovery request at current nonce.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @param guardian - The guardian.\n\t * @param newOwners - The new owners' addresses.\n\t * @param newThreshold - The new threshold for the safe.\n\t * @return promise of guardian approval status\n\t */\n\tpublic async hasGuardianApproved(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t\tguardian: string,\n\t\tnewOwners: string[],\n\t\tnewThreshold: number,\n\t): Promise<boolean> {\n\t\t//\"hasGuardianApproved(address,address,address[],uint256)\"\n\t\tconst functionSelector = \"0x37d82c36\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address\", \"address[]\", \"uint256\"],\n\t\t\t[accountAddress, guardian, newOwners, newThreshold],\n\t\t);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst hasGuardianApprovedResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(hasGuardianApprovedResult, \"hasGuardianApproved\");\n\t\tconst decodedCalldata = decodeAbiParameters<[boolean]>([\"bool\"], hasGuardianApprovedResult);\n\n\t\treturn Boolean(decodedCalldata[0]);\n\t}\n\n\t/**\n\t * Checks if an address is a guardian for an account.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @param guardian - The address to check.\n\t * @return promise of `true` if the address is a guardian for\n\t * the account otherwise `false`.\n\t */\n\tpublic async isGuardian(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t\tguardian: string,\n\t): Promise<boolean> {\n\t\t//\"isGuardian(address,address)\"\n\t\tconst functionSelector = \"0xd4ee9734\";\n\t\tconst callData = createCallData(\n\t\t\tfunctionSelector,\n\t\t\t[\"address\", \"address\"],\n\t\t\t[accountAddress, guardian],\n\t\t);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst isGuardianResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(isGuardianResult, \"isGuardian\");\n\t\tconst decodedCalldata = decodeAbiParameters<[boolean]>([\"bool\"], isGuardianResult);\n\n\t\treturn Boolean(decodedCalldata[0]);\n\t}\n\n\t/**\n\t * Counts the number of active guardians for an account.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @return promise of The number of active guardians for an account.\n\t */\n\tpublic async guardiansCount(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t): Promise<bigint> {\n\t\t//\"guardiansCount(address)\"\n\t\tconst functionSelector = \"0xc026e7ee\";\n\t\tconst callData = createCallData(functionSelector, [\"address\"], [accountAddress]);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst guardiansCountResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(guardiansCountResult, \"guardiansCount\");\n\t\tconst decodedCalldata = decodeAbiParameters<[bigint]>([\"uint256\"], guardiansCountResult);\n\n\t\treturn BigInt(decodedCalldata[0]);\n\t}\n\n\t/**\n\t * Retrieves the account threshold.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @return promise of Threshold.\n\t */\n\tpublic async threshold(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t): Promise<bigint> {\n\t\t//\"threshold(address)\"\n\t\tconst functionSelector = \"0xc86ec2bf\";\n\t\tconst callData = createCallData(functionSelector, [\"address\"], [accountAddress]);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst thresholdResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(thresholdResult, \"threshold\");\n\t\tconst decodedCalldata = decodeAbiParameters<[bigint]>([\"uint256\"], thresholdResult);\n\n\t\treturn BigInt(decodedCalldata[0]);\n\t}\n\n\t/**\n\t * Get the active guardians for an account.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @return promise of a list of the active guardians for an account.\n\t */\n\tpublic async getGuardians(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t): Promise<string[]> {\n\t\t//\"getGuardians(address)\"\n\t\tconst functionSelector = \"0xf18858ab\";\n\t\tconst callData = createCallData(functionSelector, [\"address\"], [accountAddress]);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst getGuardiansResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(getGuardiansResult, \"getGuardians\");\n\t\tconst decodedCalldata = decodeAbiParameters<[string[]]>([\"address[]\"], getGuardiansResult);\n\n\t\treturn decodedCalldata[0];\n\t}\n\n\t/**\n\t * Get the module nonce for an account.\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain.\n\t * @param accountAddress - The target account.\n\t * @return promise of the nonce for this account.\n\t */\n\tpublic async nonce(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\taccountAddress: string,\n\t): Promise<bigint> {\n\t\t//\"nonce(address)\"\n\t\tconst functionSelector = \"0x70ae92d2\";\n\t\tconst callData = createCallData(functionSelector, [\"address\"], [accountAddress]);\n\n\t\tconst ethCallParams = {\n\t\t\tto: this.moduleAddress,\n\t\t\tdata: callData,\n\t\t};\n\t\tconst nonceResult = await JsonRpcNode.from(nodeRpcUrl).call(ethCallParams, \"latest\");\n\n\t\tthis.checkForEmptyResultAndRevert(nonceResult, \"nonce\");\n\t\tconst decodedCalldata = decodeAbiParameters<[bigint]>([\"uint256\"], nonceResult);\n\n\t\treturn BigInt(decodedCalldata[0]);\n\t}\n\n\t/**\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\t * object needed for hashing and signing\n\t */\n\tasync getRecoveryRequestEip712Data(\n\t\trpcNode: string | Transport | JsonRpcNode,\n\t\tchainId: bigint,\n\t\taccountAddress: string,\n\t\tnewOwners: string[],\n\t\tnewThreshold: bigint,\n\t\toverrides: {\n\t\t\trecoveryNonce?: bigint;\n\t\t} = {},\n\t): Promise<{\n\t\tdomain: RecoveryRequestTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: RecoveryRequestTypedMessageValue;\n\t}> {\n\t\tlet recoveryNonce: bigint;\n\t\tif (overrides.recoveryNonce == null) {\n\t\t\tconst socialRecoveryModule = new SocialRecoveryModule(this.moduleAddress);\n\t\t\trecoveryNonce = await socialRecoveryModule.nonce(rpcNode, accountAddress);\n\t\t} else {\n\t\t\trecoveryNonce = overrides.recoveryNonce;\n\t\t}\n\n\t\tconst messageValue: RecoveryRequestTypedMessageValue = {\n\t\t\twallet: accountAddress,\n\t\t\tnewOwners,\n\t\t\tnewThreshold,\n\t\t\tnonce: recoveryNonce,\n\t\t};\n\t\tconst domain: RecoveryRequestTypedDataDomain = {\n\t\t\tname: \"Social Recovery Module\",\n\t\t\tversion: \"0.0.1\",\n\t\t\tchainId: Number(chainId),\n\t\t\tverifyingContract: this.moduleAddress,\n\t\t};\n\n\t\treturn {\n\t\t\tdomain,\n\t\t\ttypes: EIP712_RECOVERY_MODULE_TYPE,\n\t\t\tmessageValue,\n\t\t};\n\t}\n}\n\n/**\n * Represents an ongoing recovery request for a Safe account.\n */\nexport type RecoveryRequest = {\n\t/** Number of guardians that have approved this recovery request. */\n\tguardiansApprovalCount: bigint;\n\t/** The new owner threshold that will be set after recovery. */\n\tnewThreshold: bigint;\n\t/** Unix timestamp (seconds) after which the recovery can be finalized. 0 if not yet executed. */\n\texecuteAfter: bigint;\n\t/** The list of new owner addresses that will replace the current owners. */\n\tnewOwners: string[];\n};\n\n/**\n * A guardian address paired with its EIP-712 signature authorizing a recovery.\n */\nexport type RecoverySignaturePair = {\n\t/** Guardian address that produced the signature. */\n\tsigner: string;\n\t/** Hex-encoded signature bytes. */\n\tsignature: 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\t/** Domain name, always \"Social Recovery Module\". */\n\tname: string;\n\t/** Domain version, e.g. \"0.0.1\". */\n\tversion: string;\n\t/** Chain ID of the target network. */\n\tchainId: number;\n\t/** 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\t/** Address of the Safe account being recovered. */\n\twallet: string;\n\t/** New owner addresses to set after recovery. */\n\tnewOwners: string[];\n\t/** New Safe threshold to set after recovery. */\n\tnewThreshold: bigint;\n\t/** 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\tExecuteRecovery: [\n\t\t{ type: \"address\", name: \"wallet\" },\n\t\t{ type: \"address[]\", name: \"newOwners\" },\n\t\t{ type: \"uint256\", name: \"newThreshold\" },\n\t\t{ type: \"uint256\", name: \"nonce\" },\n\t],\n};\n","// Safe Passkey module v0.2.1 addresses.\n// https://github.com/safe-fndn/safe-modules/blob/04e65efbce634e776cc8c1fbe90061f09e09a71b/modules/passkey/CHANGELOG.md?plain=1#L23\n\n/** WebAuthn shared signer contract (Safe Passkey module v0.2.1). */\nexport const DEFAULT_WEB_AUTHN_SHARED_SIGNER_V_0_2_1 = \"0x94a4F6affBd8975951142c3999aEAB7ecee555c2\";\n/** WebAuthn signer singleton proxied by per-owner signers (Safe Passkey module v0.2.1). */\nexport const DEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1 =\n\t\"0x4E27b51350e6c2083EE19011120F50DAfEc5CA50\";\n/** WebAuthn signer factory for deploying per-owner signer proxies (Safe Passkey module v0.2.1). */\nexport const DEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1 =\n\t\"0x1d31F259eE307358a26dFb23EB365939E8641195\";\n/** Runtime bytecode of the WebAuthn signer proxy (Safe Passkey module v0.2.1), used for CREATE2 address prediction. */\nexport const DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1 =\n\t\"0x610100346100ad57601f6101b538819003918201601f19168301916001600160401b038311848410176100b2578084926080946040528339810103126100ad578051906001600160a01b03821682036100ad5760208101516040820151606090920151926001600160b01b03841684036100ad5760805260a05260c05260e05260405160ec90816100c98239608051816082015260a05181604d015260c051816027015260e0518160010152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe7f000000000000000000000000000000000000000000000000000000000000000060b63601527f000000000000000000000000000000000000000000000000000000000000000060a03601527f000000000000000000000000000000000000000000000000000000000000000036608001523660006080376000806056360160807f00000000000000000000000000000000000000000000000000000000000000005af43d600060803e60b1573d6080fd5b3d6080f3fea26469706673582212201660515548d15702d720bbc046b457ca85e941a4559ab9f9518488e4c82e5ee964736f6c634300081a0033\";\n/** RIP-7951 secp256r1 precompile address (used for WebAuthn signature verification). */\nexport const DEFAULT_WEB_AUTHN_PRECOMPILE_RIP_7951 = \"0x0000000000000000000000000000000000000100\";\n/** Daimo P-256 verifier contract (fallback when the RIP-7951 precompile isn't available). */\nexport const DEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1 =\n\t\"0xc2b78104907F722DABAc4C69f826a522B2754De4\";\n","import { keccak256 } from \"../../ethereUtils\";\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\tif (left < right) {\n\t\treturn keccak256(left + right.slice(2));\n\t} else {\n\t\treturn keccak256(right + left.slice(2));\n\t}\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\tif (hashes.length === 0) {\n\t\tthrow new Error(\"Cannot create Merkle tree with empty hash list\");\n\t}\n\n\t// Store the original hashes and their indices\n\tconst originalHashes = [...hashes];\n\n\t// Build the tree level by level\n\tlet currentLevel = [...hashes];\n\tconst tree: string[][] = [currentLevel];\n\n\t// Build tree from bottom to top\n\twhile (currentLevel.length > 1) {\n\t\tconst nextLevel: string[] = [];\n\n\t\tfor (let i = 0; i < currentLevel.length; i += 2) {\n\t\t\tif (i + 1 < currentLevel.length) {\n\t\t\t\t// Hash pair of nodes\n\t\t\t\tnextLevel.push(hashPair(currentLevel[i], currentLevel[i + 1]));\n\t\t\t} else {\n\t\t\t\t// Odd number of nodes - duplicate the last one\n\t\t\t\tnextLevel.push(hashPair(currentLevel[i], currentLevel[i]));\n\t\t\t}\n\t\t}\n\n\t\ttree.push(nextLevel);\n\t\tcurrentLevel = nextLevel;\n\t}\n\tconst root = tree[tree.length - 1][0];\n\n\t// Generate proof for each original hash\n\tconst proofs: string[] = originalHashes.map((_hash, index) => {\n\t\tconst proofArr: string[] = [];\n\t\tlet currentIndex = index;\n\n\t\t// Traverse from leaf to root, collecting sibling hashes\n\t\tfor (let level = 0; level < tree.length - 1; level++) {\n\t\t\tconst currentLevelNodes = tree[level];\n\t\t\tconst isRightNode = currentIndex % 2 === 1;\n\n\t\t\tif (isRightNode) {\n\t\t\t\t// If we're the right node, sibling is on the left\n\t\t\t\tproofArr.push(currentLevelNodes[currentIndex - 1]);\n\t\t\t} else {\n\t\t\t\t// If we're the left node, sibling is on the right\n\t\t\t\tif (currentIndex + 1 < currentLevelNodes.length) {\n\t\t\t\t\tproofArr.push(currentLevelNodes[currentIndex + 1]);\n\t\t\t\t} else {\n\t\t\t\t\t// Odd number of nodes - we're paired with ourselves\n\t\t\t\t\tproofArr.push(currentLevelNodes[currentIndex]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Move to parent index in next level\n\t\t\tcurrentIndex = Math.floor(currentIndex / 2);\n\t\t}\n\t\tlet proof = root;\n\t\tproofArr.reverse().forEach((proofElement) => {\n\t\t\tproof += proofElement.slice(2);\n\t\t});\n\t\treturn proof;\n\t});\n\treturn [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\tlet currentHash = hash;\n\n\tfor (const siblingHash of proof) {\n\t\t// Determine order (smaller hash goes first for consistency)\n\t\tif (currentHash <= siblingHash) {\n\t\t\tcurrentHash = hashPair(currentHash, siblingHash);\n\t\t} else {\n\t\t\tcurrentHash = hashPair(siblingHash, currentHash);\n\t\t}\n\t}\n\n\treturn currentHash === root;\n}\n","import {\n\tgetAddress,\n\thashTypedData,\n\tprivateKeyToAddress,\n\tsignHash,\n} from \"../../ethereUtils\";\nimport type {Bundler} from \"src/Bundler\";\nimport {\n\tEIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE,\n\tEIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\tENTRYPOINT_V9,\n} from \"src/constants\";\nimport {invokeSigner, pickScheme} from \"src/signer/negotiate\";\nimport type {MultiOpSignContext, SignContext, ExternalSigner, TypedData} from \"src/signer/types\";\nimport type {JsonRpcNode, Transport} from \"src/transport\";\nimport type {MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet, UserOperationV9} from \"../../types\";\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_FACTORY_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE_V_0_2_1,\n\tDEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1,\n} from \"./constants\";\nimport {generateMerkleProofs} from \"./MerkleTree\";\nimport {SafeAccount} from \"./SafeAccount\";\nimport type {\n\tCreateUserOperationV9Overrides,\n\tInitCodeOverrides,\n\tMultiChainSignatureMerkleTreeRootTypedDataDomain,\n\tMultiChainSignatureMerkleTreeRootTypedMessageValue,\n\tSafeAccountSingleton,\n\tSafeSignatureOptions,\n\tSafeUserOperationTypedDataDomain,\n\tSafeUserOperationV9TypedMessageValue,\n\tSigner,\n\tSignerSignaturePair,\n\tUserOperationToSign,\n\tUserOperationToSignWithOverrides,\n\tWebauthnPublicKey,\n\tWebAuthnSignatureOverrides,\n} from \"./types\";\n\n/**\n * Safe account on EntryPoint v0.9. Use it as a regular single-chain Safe\n * account, and opt into multi-chain signatures via Merkle trees when you want\n * to sign UserOperations for several chains under one signature.\n *\n * API-compatible with {@link SafeAccountV0_3_0}: same {@link SafeAccount} base,\n * same method signatures, same {@link InitCodeOverrides} shape, so building on\n * EntryPoint v0.9 is not a separate integration. The multi-op methods\n * ({@link signUserOperations}, {@link signUserOperationsWithSigners}) and the\n * Merkle-root EIP-712 helpers are additive; ignore them and the account\n * behaves as a single-chain Safe.\n *\n * Which account this class refers to, however, is not interchangeable with\n * `SafeAccountV0_3_0`:\n *\n * - **New accounts** derive a different counterfactual address for the same\n *   owners, since the module and EntryPoint addresses feed that derivation.\n * - **Deployed accounts** keep the address they have, but must be migrated\n *   before this class can operate on them. Attaching this class to a Safe\n *   deployed through `SafeAccountV0_3_0` is not enough: two pieces of Safe\n *   configuration have to change first — the v0.9 module must be enabled on\n *   the Safe, and the Safe's fallback handler must be updated to point at it.\n *   Until both land, UserOperations sent to the account will fail. Use\n *   {@link SafeAccountV0_3_0.createMigrateToSafeMultiChainSigAccountV1MetaTransactions},\n *   whose batch must be sent as a UserOperation from the v0.7 account itself.\n *\n * @example Single-chain use — the common case\n * ```ts\n * const account = SafeMultiChainSigAccountV1.initializeNewAccount([owner]);\n * const userOp = await account.createUserOperation([tx], nodeRpc, bundlerRpc);\n * userOp.signature = await account.signUserOperationWithSigners(\n *   userOp,\n *   [signer],\n *   chainId,\n * );\n * ```\n *\n * Uses Safe Passkey module v0.2.1 WebAuthn verifiers by default (Daimo P256\n * verifier instead of the base class's FCL P256).\n * @see {@link https://github.com/safe-fndn/safe-modules/blob/04e65efbce634e776cc8c1fbe90061f09e09a71b/modules/passkey/CHANGELOG.md?plain=1#L23}\n *\n * @remarks Signer typing is asymmetric:\n * - {@link signUserOperationWithSigners} (singular) → {@link SignContext}\n * - {@link signUserOperationsWithSigners} (plural) → {@link MultiOpSignContext}\n *\n * Type a signer as `ExternalSigner<unknown>` (what the built-in adapters\n * return) to work on both methods; the narrow contexts exist so signers that\n * read the context get correct non-optional fields per path.\n */\nexport class SafeMultiChainSigAccountV1 extends SafeAccount {\n\tstatic readonly DEFAULT_ENTRYPOINT_ADDRESS = ENTRYPOINT_V9;\n\tstatic readonly DEFAULT_SAFE_4337_MODULE_ADDRESS = \"0x22939E839e3c0F479B713eAF95e0df128554AEAd\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS = \"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 =\n\t\tDEFAULT_WEB_AUTHN_SIGNER_SINGLETON_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_FACTORY: string =\n\t\tDEFAULT_WEB_AUTHN_SIGNER_FACTORY_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE =\n\t\tDEFAULT_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\t// Daimo P256 contract verifier (Safe Passkey module v0.2.1). Same value\n\t// exposed under both names: DAIMO_VERIFIER for self-documentation and\n\t// CONTRACT_VERIFIER as the polymorphic slot fromSafeWebauthn reads.\n\tstatic readonly DEFAULT_WEB_AUTHN_DAIMO_VERIFIER: string =\n\t\tDEFAULT_WEB_AUTHN_DAIMO_VERIFIER_V_0_2_1;\n\tstatic readonly DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER: string =\n\t\tDEFAULT_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 *\n\t * An existing account must already have the v0.9 module enabled, and its\n\t * fallback handler pointing at that module. A Safe deployed through\n\t * {@link SafeAccountV0_3_0} has neither until it is migrated — see the\n\t * class documentation.\n\t *\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\t\t\tonChainIdentifierParams?: OnChainIdentifierParamsType;\n\t\t\tonChainIdentifier?: string;\n\t\t\tsafeAccountSingleton?: 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 ?? SafeMultiChainSigAccountV1.DEFAULT_ENTRYPOINT_ADDRESS;\n\n\t\tsuper(accountAddress, safe4337ModuleAddress, entrypointAddress, {\n\t\t\tonChainIdentifierParams: overrides.onChainIdentifierParams,\n\t\t\tonChainIdentifier: overrides.onChainIdentifier,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton,\n\t\t});\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(owners: Signer[], overrides: InitCodeOverrides = {}): string {\n\t\t// Init code only configures the shared signer and its verifier; the\n\t\t// verifier proxy is deployed and swapped in later by createUserOperation\n\t\t// (nonce == 0), which defaults webAuthnSignerFactory / Singleton /\n\t\t// ProxyCreationCode.\n\t\tconst modOverrides = {\n\t\t\t...overrides,\n\t\t\twebAuthnSharedSigner:\n\t\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t};\n\t\tconst [accountAddress, ,] = SafeAccount.createAccountAddressAndFactoryAddressAndData(\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\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(\"Only one Webauthn signer is allowed during initialization\");\n\t\t\t\t}\n\t\t\t\tif (owners.indexOf(owner) !== 0) {\n\t\t\t\t\tthrow new RangeError(\"Webauthn owner has to be the first owner for an init transaction.\");\n\t\t\t\t}\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\t// Init code only configures the shared signer and its verifier; the\n\t\t// verifier proxy is deployed and swapped in later by createUserOperation\n\t\t// (nonce == 0), which defaults webAuthnSignerFactory / Singleton /\n\t\t// ProxyCreationCode.\n\t\tconst modOverrides = {\n\t\t\t...overrides,\n\t\t\twebAuthnSharedSigner:\n\t\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t};\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\t\t\tonChainIdentifierParams: overrides.onChainIdentifierParams,\n\t\t\tonChainIdentifier: 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 ?? SafeMultiChainSigAccountV1.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\t/**\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\t * 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\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV9TypedMessageValue;\n\t} {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ?? SafeMultiChainSigAccountV1.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 ?? SafeMultiChainSigAccountV1.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_CONTRACT_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\t// Init code only configures the shared signer and its verifier; the\n\t\t// verifier proxy is deployed and swapped in later by createUserOperation\n\t\t// (nonce == 0), which defaults webAuthnSignerFactory / Singleton /\n\t\t// ProxyCreationCode.\n\t\tconst modOverrides = {\n\t\t\t...overrides,\n\t\t\twebAuthnSharedSigner:\n\t\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t};\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 | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\n\t\toverrides: CreateUserOperationV9Overrides = {},\n\t): Promise<UserOperationV9> {\n\t\tconst parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n\t\tif (\n\t\t\tparallelPaymasterInitValues != null &&\n\t\t\t!parallelPaymasterInitValues.paymasterData.toLowerCase().endsWith(\"22e325a297439656\")\n\t\t) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"Invalid paymasterData override, it must end with the PAYMASTER_SIG_MAGIC '22e325a297439656'\",\n\t\t\t);\n\t\t}\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\t{\n\t\t\t\t\t...overrides,\n\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\twebAuthnSharedSigner:\n\t\t\t\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t\t\t\twebAuthnSignerFactory:\n\t\t\t\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\t\t\twebAuthnSignerSingleton:\n\t\t\t\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\t\t\tSafeMultiChainSigAccountV1.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\t\t\t\t...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 * Estimate gas limits for a multichain UserOperation using the bundler.\n\t * Applies the multichain dummy-signature encoding and Safe Passkey module\n\t * v0.2.1 WebAuthn defaults.\n\t *\n\t * @param userOperation - The UserOperation to estimate gas for\n\t * @param bundlerRpc - Bundler RPC URL, transport, or Bundler instance\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: UserOperationV9,\n\t\tbundlerRpc: string | Transport | Bundler,\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(userOperation, bundlerRpc, {\n\t\t\t...overrides,\n\t\t\tisMultiChainSignature: true,\n\t\t\twebAuthnSharedSigner:\n\t\t\t\toverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\twebAuthnSignerFactory:\n\t\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton:\n\t\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t});\n\t}\n\n\t/**\n\t * Get the single-operation EIP-712 typed data for this multichain account.\n\t * Uses the instance EntryPoint and Safe 4337 module, and is the recommended\n\t * manual-signing path for length-1 multichain UserOperations.\n\t *\n\t * @param useroperation - UserOperation to get typed data for\n\t * @param chainId - target chain ID\n\t * @param overrides - optional validity window and explicit address overrides\n\t * @returns Object with domain, types, and messageValue for EIP-712 signing\n\t */\n\tpublic 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\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV9TypedMessageValue;\n\t} {\n\t\treturn SafeMultiChainSigAccountV1.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\t...overrides,\n\t\t\tentrypointAddress: overrides.entrypointAddress ?? this.entrypointAddress,\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress ?? this.safe4337ModuleAddress,\n\t\t});\n\t}\n\n\t/**\n\t * Hash the single-operation EIP-712 typed data for this multichain account.\n\t * Uses the instance EntryPoint and Safe 4337 module.\n\t *\n\t * @param useroperation - UserOperation to hash\n\t * @param chainId - target chain ID\n\t * @param overrides - optional validity window and explicit address overrides\n\t * @returns EIP-712 digest as a hex string\n\t */\n\tpublic 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 data = this.getUserOperationEip712Data(useroperation, chainId, overrides);\n\t\treturn hashTypedData(data.domain, data.types, data.messageValue);\n\t}\n\n\t/**\n\t * Format signer/signature pairs for this multichain account. The multichain\n\t * signature flag, module address, and v0.2.1 WebAuthn defaults are applied\n\t * automatically.\n\t *\n\t * @param signerSignaturePairs - signer/signature pairs to encode\n\t * @param options - optional validity window, Merkle proof, module, and WebAuthn encoding overrides\n\t * @returns formatted UserOperation signature\n\t */\n\tpublic formatUserOperationSignature(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toptions: SafeSignatureOptions & WebAuthnSignatureOverrides = {},\n\t): string {\n\t\treturn SafeMultiChainSigAccountV1.formatSingleUserOperationSignature(\n\t\t\tsignerSignaturePairs,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tsafe4337ModuleAddress: options.safe4337ModuleAddress ?? this.safe4337ModuleAddress,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * Create a signature for a single UserOperation. This is the regular\n\t * signing path — use it for ordinary single-chain transactions. To sign\n\t * several UserOperations under one signature, use\n\t * {@link signUserOperations}.\n\t *\n\t * The multi-chain flag is set automatically, which only affects how the\n\t * signature is encoded: this account's module validates single-chain\n\t * UserOperations through the same scheme, signing the leaf SafeOp hash\n\t * directly rather than a Merkle root.\n\t *\n\t * @param useroperation - useroperation to sign\n\t * @param privateKeys - for the signers\n\t * @param chainId - target chain id\n\t * @param options - {@link SafeSignatureOptions} — timing, multiChainMerkleProof, module address. The multi-chain flag is force-set true and overrides any caller value.\n\t * @returns signature\n\t */\n\tpublic signUserOperation(\n\t\tuserOperation: UserOperationV9,\n\t\tprivateKeys: string[],\n\t\tchainId: bigint,\n\t\toptions: SafeSignatureOptions = {},\n\t): string {\n\t\t// Single-op path signs the leaf SafeOp hash directly (not a Merkle\n\t\t// root), so a caller-supplied proof would be silently encoded into\n\t\t// a signature that fails on-chain. Reject offline.\n\t\tif (options.multiChainMerkleProof != null && options.multiChainMerkleProof.length > 0) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"signUserOperation does not accept multiChainMerkleProof; use signUserOperations for multi-op Merkle signatures\",\n\t\t\t);\n\t\t}\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...options,\n\t\t\t\tisMultiChainSignature: true,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Sign a single UserOperation using one or more {@link ExternalSigner}\n\t * instances. This is the regular signing path — use it for ordinary\n\t * single-chain transactions. See\n\t * {@link SafeAccountV0_3_0.signUserOperationWithSigners} for the full\n\t * design rationale.\n\t *\n\t * The multi-chain flag is set automatically, which only affects how the\n\t * signature is encoded: this account's module validates single-chain\n\t * UserOperations through the same scheme, signing the leaf SafeOp hash\n\t * directly rather than a Merkle root. Signing several UserOperations under\n\t * one signature is a separate method,\n\t * {@link signUserOperationsWithSigners}.\n\t *\n\t * Note the chainId plumbing asymmetry vs the multi-op variant:\n\t *   - **Singular** (this method): `chainId` is a positional argument.\n\t *   - **Plural** ({@link signUserOperationsWithSigners}): `chainId` lives\n\t *     inside each `UserOperationToSign` element, since each op may\n\t *     target a different chain.\n\t * Pick the variant that matches your bundle shape; don't pass the same\n\t * chainId twice.\n\t *\n\t * @param userOperation - UserOperation to sign\n\t * @param signers - one ExternalSigner per owner (any order)\n\t * @param chainId - target chain id\n\t * @param options - {@link SafeSignatureOptions} — timing, multiChainMerkleProof, module address. The multi-chain flag is force-set true and overrides any caller value.\n\t * @returns Promise resolving to the formatted signature string\n\t */\n\tpublic signUserOperationWithSigners(\n\t\tuserOperation: UserOperationV9,\n\t\tsigners: ReadonlyArray<ExternalSigner>,\n\t\tchainId: bigint,\n\t\toptions: SafeSignatureOptions = {},\n\t): Promise<string> {\n\t\t// Single-op path signs the leaf SafeOp hash directly (not a Merkle\n\t\t// root), so a caller-supplied proof would be silently encoded into\n\t\t// a signature that fails on-chain. Reject offline.\n\t\tif (options.multiChainMerkleProof != null && options.multiChainMerkleProof.length > 0) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"signUserOperationWithSigners does not accept multiChainMerkleProof; use signUserOperationsWithSigners for multi-op Merkle signatures\",\n\t\t\t);\n\t\t}\n\t\tconst context: SignContext<UserOperationV9> = {\n\t\t\tuserOperation,\n\t\t\tchainId,\n\t\t\tentryPoint: this.entrypointAddress,\n\t\t};\n\t\treturn SafeAccount.baseSignUserOperationWithSigners(userOperation, signers, chainId, {\n\t\t\tentrypointAddress: this.entrypointAddress,\n\t\t\tsafe4337ModuleAddress: this.safe4337ModuleAddress,\n\t\t\tcontext,\n\t\t\toptions: {\n\t\t\t\t...options,\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\t\tif (userOperationsToSign.length > 1) {\n\t\t\tconst userOperationsHashes: string[] = [];\n\t\t\tuserOperationsToSign.forEach((userOperationsToSign, _index) => {\n\t\t\t\tconst userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n\t\t\t\t\tuserOperationsToSign.userOperation,\n\t\t\t\t\tuserOperationsToSign.chainId,\n\t\t\t\t\t{\n\t\t\t\t\t\tvalidAfter: userOperationsToSign.validAfter,\n\t\t\t\t\t\tvalidUntil: userOperationsToSign.validUntil,\n\t\t\t\t\t\tsafe4337ModuleAddress: this.safe4337ModuleAddress,\n\t\t\t\t\t\tentrypointAddress: this.entrypointAddress,\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\tconst [root, proofs] = generateMerkleProofs(userOperationsHashes);\n\n\t\t\tconst merkleTreeRootHash = hashTypedData(\n\t\t\t\t{ verifyingContract: this.safe4337ModuleAddress },\n\t\t\t\tEIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\t\t\t\t{ merkleTreeRoot: root },\n\t\t\t);\n\n\t\t\tconst signerSignaturePairs: SignerSignaturePair[] = [];\n\t\t\tfor (const privateKey of privateKeys) {\n\t\t\t\tconst signature = signHash(privateKey, merkleTreeRootHash).serialized;\n\t\t\t\tsignerSignaturePairs.push({\n\t\t\t\t\tsigner: privateKeyToAddress(privateKey),\n\t\t\t\t\tsignature,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst userOpSignatures: string[] = [];\n\t\t\tuserOperationsToSign.forEach((userOperationsToSign, index) => {\n\t\t\t\tuserOpSignatures.push(\n\t\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(signerSignaturePairs, {\n\t\t\t\t\t\tvalidAfter: userOperationsToSign.validAfter,\n\t\t\t\t\t\tvalidUntil: userOperationsToSign.validUntil,\n\t\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\t\tmultiChainMerkleProof: proofs[index],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn userOpSignatures;\n\t\t} else {\n\t\t\treturn [\n\t\t\t\tthis.signUserOperation(\n\t\t\t\t\tuserOperationsToSign[0].userOperation,\n\t\t\t\t\tprivateKeys,\n\t\t\t\t\tuserOperationsToSign[0].chainId,\n\t\t\t\t\t{\n\t\t\t\t\t\tvalidUntil: userOperationsToSign[0].validUntil,\n\t\t\t\t\t\tvalidAfter: userOperationsToSign[0].validAfter,\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 * Sign a list of UserOperations with a single multi-chain signature. Each\n\t * signer signs the Merkle root of the UserOperation EIP-712 hashes via\n\t * either `signTypedData` (the root is wrapped in an EIP-712 `MerkleTreeRoot`\n\t * message) or raw-hash signing; both schemes produce signatures that\n\t * validate against the same on-chain digest.\n\t *\n\t * Signers always receive {@link MultiOpSignContext}. The built-in adapters\n\t * `fromPrivateKey`, `fromViem`, `fromEthersWallet`, and `fromViemWalletClient`\n\t * all work here without retyping (`fromViemWalletClient` will sign the\n\t * typed-data Merkle wrapper). User-defined single-op signers\n\t * (`ExternalSigner<SignContext>`) still don't work — they'd receive a\n\t * context shape they didn't declare.\n\t *\n\t * Note the chainId plumbing asymmetry vs the single-op variant:\n\t *   - **Plural** (this method): each `UserOperationToSign` carries its\n\t *     own `chainId`, since a multichain bundle's ops target different\n\t *     chains.\n\t *   - **Singular** ({@link signUserOperationWithSigners}): `chainId` is\n\t *     a positional argument.\n\t * For a length-1 bundle on this method, set `chainId` on the single\n\t * element rather than reaching for the singular variant.\n\t *\n\t * @param userOperationsToSign - UserOperations + chain IDs + validity windows\n\t * @param signers - one ExternalSigner per owner (any order; sorted by address on-chain)\n\t * @returns one signature per input UserOperation, in the same order\n\t */\n\tpublic async signUserOperationsWithSigners(\n\t\tuserOperationsToSign: UserOperationToSign[],\n\t\tsigners: ReadonlyArray<ExternalSigner<MultiOpSignContext<UserOperationV9>>>,\n\t): Promise<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 (signers.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one signer\");\n\t\t}\n\n\t\t// Multi-op context: signers see the full bundle (length 1 or N) so\n\t\t// they can log \"authorizing N ops across these chains\".\n\t\tconst context: MultiOpSignContext<UserOperationV9> = {\n\t\t\tuserOperations: userOperationsToSign.map((u) => ({\n\t\t\t\tuserOperation: u.userOperation,\n\t\t\t\tchainId: u.chainId,\n\t\t\t})),\n\t\t\tentryPoint: this.entrypointAddress,\n\t\t};\n\n\t\tif (userOperationsToSign.length > 1) {\n\t\t\tconst userOperationsHashes: string[] = [];\n\t\t\tuserOperationsToSign.forEach((uopToSign) => {\n\t\t\t\tconst userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n\t\t\t\t\tuopToSign.userOperation,\n\t\t\t\t\tuopToSign.chainId,\n\t\t\t\t\t{\n\t\t\t\t\t\tvalidAfter: uopToSign.validAfter,\n\t\t\t\t\t\tvalidUntil: uopToSign.validUntil,\n\t\t\t\t\t\tsafe4337ModuleAddress: this.safe4337ModuleAddress,\n\t\t\t\t\t\tentrypointAddress: this.entrypointAddress,\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\tconst [root, proofs] = generateMerkleProofs(userOperationsHashes);\n\n\t\t\tconst merkleTreeRootHash = hashTypedData(\n\t\t\t\t{ verifyingContract: this.safe4337ModuleAddress },\n\t\t\t\tEIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\t\t\t\t{ merkleTreeRoot: root },\n\t\t\t) as `0x${string}`;\n\n\t\t\t// Preflight: validate + checksum every signer's address before\n\t\t\t// calling any signer. Catches malformed addresses offline\n\t\t\t// instead of after an external signer has been prompted.\n\t\t\tconst normalizedAddresses = signers.map((signer) => getAddress(signer.address));\n\n\t\t\t// The Merkle root is wrapped in an EIP-712 `MerkleTreeRoot` message\n\t\t\t// whose digest equals `merkleTreeRootHash`, so a typed-data signature\n\t\t\t// over it is byte-identical (for deterministic-ECDSA signers) to a\n\t\t\t// raw-hash signature. Accept both schemes so JSON-RPC wallets that\n\t\t\t// only sign typed data can sign multi-op bundles.\n\t\t\tconst typedDataForBundle: TypedData = {\n\t\t\t\tdomain: {\n\t\t\t\t\tverifyingContract: this.safe4337ModuleAddress as `0x${string}`,\n\t\t\t\t},\n\t\t\t\ttypes: EIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\t\t\t\tprimaryType: EIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE,\n\t\t\t\tmessage: { merkleTreeRoot: root },\n\t\t\t};\n\t\t\tconst schemes = signers.map((signer, i) =>\n\t\t\t\tpickScheme(signer, [\"typedData\", \"hash\"], {\n\t\t\t\t\taccountName: \"SafeMultiChainSigAccountV1 (multi-op Merkle root)\",\n\t\t\t\t\tsignerIndex: i,\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\tconst signatures = await Promise.all(\n\t\t\t\tsigners.map((signer, i) =>\n\t\t\t\t\tinvokeSigner(signer, schemes[i], {\n\t\t\t\t\t\thash: merkleTreeRootHash,\n\t\t\t\t\t\ttypedData: typedDataForBundle,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst signerSignaturePairs: SignerSignaturePair[] = signers.map((_signer, i) => ({\n\t\t\t\tsigner: normalizedAddresses[i],\n\t\t\t\tsignature: signatures[i],\n\t\t\t\tisContractSignature: signers[i].type === \"contract\",\n\t\t\t}));\n\n\t\t\tconst userOpSignatures: string[] = [];\n\t\t\tuserOperationsToSign.forEach((uopToSign, index) => {\n\t\t\t\tuserOpSignatures.push(\n\t\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(signerSignaturePairs, {\n\t\t\t\t\t\tvalidAfter: uopToSign.validAfter,\n\t\t\t\t\t\tvalidUntil: uopToSign.validUntil,\n\t\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\t\tmultiChainMerkleProof: proofs[index],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn userOpSignatures;\n\t\t} else {\n\t\t\t// length === 1: single op with multi-chain flag; signers still get\n\t\t\t// the length-1 multi-op context so the runtime shape matches their\n\t\t\t// declared type.\n\t\t\tconst u = userOperationsToSign[0];\n\t\t\tconst sig = await SafeAccount.baseSignUserOperationWithSigners(\n\t\t\t\tu.userOperation,\n\t\t\t\tsigners,\n\t\t\t\tu.chainId,\n\t\t\t\t{\n\t\t\t\t\tentrypointAddress: this.entrypointAddress,\n\t\t\t\t\tsafe4337ModuleAddress: this.safe4337ModuleAddress,\n\t\t\t\t\tcontext,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tvalidAfter: u.validAfter,\n\t\t\t\t\t\tvalidUntil: u.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\treturn [sig];\n\t\t}\n\t}\n\n\t/**\n\t * Compute the EIP-712 Merkle root wrapper digest that owners sign once\n\t * across all UserOperations in a multi-chain bundle.\n\t *\n\t * Requires length≥2. For a single UserOperation use\n\t * {@link SafeMultiChainSigAccountV1.getUserOperationEip712Hash} (the on-chain\n\t * `merkleTreeDepth == 0` branch verifies against the per-op SafeOp digest,\n\t * not a Merkle wrapper, so signing the wrapper for length=1 produces bytes\n\t * the contract rejects with AA24).\n\t *\n\t * @param userOperationsToSignsToSign - list of UserOperations with their target chain IDs (length ≥ 2)\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\tentrypointAddress?: string;\n\t\t} = {},\n\t): string {\n\t\tconst data = SafeMultiChainSigAccountV1.getMultiChainSingleSignatureUserOperationsEip712Data(\n\t\t\tuserOperationsToSignsToSign,\n\t\t\toverrides,\n\t\t);\n\t\treturn hashTypedData(data.domain, data.types, data.messageValue);\n\t}\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 *\n\t * Requires length≥2. For a single UserOperation use\n\t * {@link SafeMultiChainSigAccountV1.getUserOperationEip712Data} (or\n\t * {@link SafeMultiChainSigAccountV1.getUserOperationEip712Hash}): those\n\t * multichain-class overrides default `safe4337ModuleAddress` to\n\t * `DEFAULT_SAFE_4337_MODULE_ADDRESS`. The on-chain depth=0 path verifies\n\t * against the per-op SafeOp digest, not a Merkle wrapper, so signing the\n\t * wrapper for length=1 produces bytes the contract rejects with AA24. The\n\t * parent `SafeAccount.getUserOperationEip712Data_V9` /\n\t * `getUserOperationEip712Hash_V9` helpers default to a different module and\n\t * would hash against the wrong verifying contract unless\n\t * `overrides.safe4337ModuleAddress` is supplied explicitly.\n\t *\n\t * @param userOperationsToSignsToSign - list of UserOperations with their target chain IDs (length ≥ 2)\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\t): {\n\t\tdomain: MultiChainSignatureMerkleTreeRootTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: MultiChainSignatureMerkleTreeRootTypedMessageValue;\n\t} {\n\t\tif (userOperationsToSign.length < 2) {\n\t\t\tthrow new RangeError(\n\t\t\t\t\"Multi-chain Merkle wrapper helpers require >= 2 userOperations. \" +\n\t\t\t\t\t\"For a single UserOperation, use SafeMultiChainSigAccountV1.getUserOperationEip712Data \" +\n\t\t\t\t\t\"or SafeMultiChainSigAccountV1.getUserOperationEip712Hash (these multichain-class overrides \" +\n\t\t\t\t\t\"default safe4337ModuleAddress to DEFAULT_SAFE_4337_MODULE_ADDRESS, the multi-chain module). \" +\n\t\t\t\t\t\"The on-chain depth=0 path verifies against the per-op SafeOp digest, not a Merkle wrapper. \" +\n\t\t\t\t\t\"If calling the parent SafeAccount.getUserOperationEip712Data_V9 / getUserOperationEip712Hash_V9 \" +\n\t\t\t\t\t\"helpers directly, you must pass overrides.safe4337ModuleAddress = \" +\n\t\t\t\t\t\"SafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS explicitly so signatures hash \" +\n\t\t\t\t\t\"the correct verifying contract.\",\n\t\t\t);\n\t\t}\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\tconst userOperationsHashes: string[] = [];\n\n\t\tuserOperationsToSign.forEach((userOperationsToSign, _index) => {\n\t\t\tconst userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n\t\t\t\tuserOperationsToSign.userOperation,\n\t\t\t\tuserOperationsToSign.chainId,\n\t\t\t\t{\n\t\t\t\t\tvalidAfter: userOperationsToSign.validAfter,\n\t\t\t\t\tvalidUntil: userOperationsToSign.validUntil,\n\t\t\t\t\tsafe4337ModuleAddress,\n\t\t\t\t\tentrypointAddress: overrides.entrypointAddress,\n\t\t\t\t},\n\t\t\t);\n\t\t\tuserOperationsHashes.push(userOperationHash);\n\t\t});\n\t\tconst [root, _proofs] = generateMerkleProofs(userOperationsHashes);\n\t\treturn {\n\t\t\tdomain: { verifyingContract: safe4337ModuleAddress },\n\t\t\ttypes: EIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\t\t\tmessageValue: { merkleTreeRoot: root },\n\t\t};\n\t}\n\n\tprivate static formatSingleUserOperationSignature(\n\t\tsignerSignaturePairs: SignerSignaturePair[],\n\t\toptions: SafeSignatureOptions = {},\n\t\twebAuthnSignatureOverrides: WebAuthnSignatureOverrides = {},\n\t): string {\n\t\treturn SafeAccount.formatSignaturesToUseroperationSignature(signerSignaturePairs, {\n\t\t\tsafe4337ModuleAddress: SafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\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_CONTRACT_VERIFIER,\n\t\t\twebAuthnSignerFactory: SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton: SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\twebAuthnSharedSigner: SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t\t...options,\n\t\t\t...webAuthnSignatureOverrides,\n\t\t\tisMultiChainSignature: true,\n\t\t});\n\t}\n\n\t/**\n\t * format 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 defaultOptions: SafeSignatureOptions = {\n\t\t\tsafe4337ModuleAddress: SafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t};\n\t\tconst defaultWebAuthnOverrides: 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_CONTRACT_VERIFIER,\n\t\t\twebAuthnSignerFactory: SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton: SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\twebAuthnSharedSigner: SafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t};\n\t\tif (userOperationsToSign.length === 1) {\n\t\t\treturn [\n\t\t\t\tSafeMultiChainSigAccountV1.formatSingleUserOperationSignature(\n\t\t\t\t\tsignerSignaturePairs,\n\t\t\t\t\t{\n\t\t\t\t\t\t...userOperationsToSign[0].options,\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},\n\t\t\t\t\tuserOperationsToSign[0].webAuthnSignatureOverrides,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t\tconst userOperationsHashes: string[] = [];\n\t\t// Resolve validity windows once per op so leaf hashing and signature\n\t\t// formatting agree. Options take precedence over the top-level fields\n\t\t// when set; falling through to the top-level avoids encoding 0/0 in\n\t\t// the SafeOp digest while the formatter encoded a non-zero window\n\t\t// (or vice versa).\n\t\tconst resolvedValidity = userOperationsToSign.map((userOperationToSign) => ({\n\t\t\tvalidAfter: userOperationToSign.options?.validAfter ?? userOperationToSign.validAfter,\n\t\t\tvalidUntil: userOperationToSign.options?.validUntil ?? userOperationToSign.validUntil,\n\t\t}));\n\t\tuserOperationsToSign.forEach((userOperationToSign, index) => {\n\t\t\tconst userOperationHash = SafeAccount.getUserOperationEip712Hash_V9(\n\t\t\t\tuserOperationToSign.userOperation,\n\t\t\t\tuserOperationToSign.chainId,\n\t\t\t\t{\n\t\t\t\t\tvalidAfter: resolvedValidity[index].validAfter,\n\t\t\t\t\tvalidUntil: resolvedValidity[index].validUntil,\n\t\t\t\t\tsafe4337ModuleAddress:\n\t\t\t\t\t\tuserOperationToSign.options?.safe4337ModuleAddress ??\n\t\t\t\t\t\tdefaultOptions.safe4337ModuleAddress,\n\t\t\t\t},\n\t\t\t);\n\t\t\tuserOperationsHashes.push(userOperationHash);\n\t\t});\n\t\tconst [_root, proofs] = generateMerkleProofs(userOperationsHashes);\n\t\tconst userOpSignatures: string[] = [];\n\t\tuserOperationsToSign.forEach((userOperationToSign, index) => {\n\t\t\tuserOpSignatures.push(\n\t\t\t\tSafeAccount.formatSignaturesToUseroperationSignature(signerSignaturePairs, {\n\t\t\t\t\t...defaultOptions,\n\t\t\t\t\t...defaultWebAuthnOverrides,\n\t\t\t\t\t...userOperationToSign.options,\n\t\t\t\t\t...userOperationToSign.webAuthnSignatureOverrides,\n\t\t\t\t\tvalidAfter: resolvedValidity[index].validAfter,\n\t\t\t\t\tvalidUntil: resolvedValidity[index].validUntil,\n\t\t\t\t\tisMultiChainSignature: true,\n\t\t\t\t\tmultiChainMerkleProof: proofs[index],\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:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t\twebAuthnSignerFactory:\n\t\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton:\n\t\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\toverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\tSafeMultiChainSigAccountV1.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:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t\twebAuthnSignerFactory:\n\t\t\t\toverrides.webAuthnSignerFactory ??\n\t\t\t\tSafeMultiChainSigAccountV1.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:\n\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t\twebAuthnSignerFactory:\n\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerFactory ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\twebAuthnSignerSingleton:\n\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerSingleton ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\twebAuthnSignatureOverrides.webAuthnSignerProxyCreationCode ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\twebAuthnSharedSigner:\n\t\t\t\twebAuthnSignatureOverrides.webAuthnSharedSigner ??\n\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SHARED_SIGNER,\n\t\t});\n\t}\n\n\tpublic static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\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(\n\t\t\tnodeRpcUrl,\n\t\t\tsigner,\n\t\t\tmessageHash,\n\t\t\tsignature,\n\t\t\t{\n\t\t\t\t...overrides,\n\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t\t\twebAuthnSignerSingleton:\n\t\t\t\t\toverrides.webAuthnSignerSingleton ??\n\t\t\t\t\tSafeMultiChainSigAccountV1.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\t},\n\t\t);\n\t}\n}\n","import type {Bundler} from \"src/Bundler\";\nimport {ENTRYPOINT_V7} from \"src/constants\";\nimport type {SignContext, ExternalSigner} from \"src/signer/types\";\nimport type {JsonRpcNode, Transport} from \"src/transport\";\n\nimport type {MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet, UserOperationV7,} from \"../../types\";\nimport {SafeAccount} from \"./SafeAccount\";\nimport {SafeMultiChainSigAccountV1} from \"./SafeMultiChainSigAccount\";\nimport type {\n\tCreateUserOperationV7Overrides,\n\tInitCodeOverrides,\n\tSafeAccountSingleton,\n\tSafeSignatureOptions,\n\tSafeUserOperationTypedDataDomain,\n\tSafeUserOperationV7TypedMessageValue,\n\tSigner,\n\tSignerSignaturePair,\n} from \"./types\";\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 = \"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS = \"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\t\t\tonChainIdentifierParams?: OnChainIdentifierParamsType;\n\t\t\tonChainIdentifier?: string;\n\t\t\tsafeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ?? SafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\n\t\tsuper(accountAddress, safe4337ModuleAddress, entrypointAddress, {\n\t\t\tonChainIdentifierParams: overrides.onChainIdentifierParams,\n\t\t\tonChainIdentifier: overrides.onChainIdentifier,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton,\n\t\t});\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(owners: Signer[], overrides: InitCodeOverrides = {}): string {\n\t\tconst [accountAddress, ,] = SafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\towners,\n\t\t\toverrides,\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\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 * Instantiates through `new this(...)`, so subclasses calling this\n\t * factory (directly or via `super`) get an instance of the subclass,\n\t * not a plain SafeAccountV0_3_0. A detached call (the method extracted\n\t * into a bare function, where `this` is undefined) falls back to\n\t * constructing a SafeAccountV0_3_0, matching the pre-polymorphic\n\t * behavior.\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 An instance of the calling class 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<T extends typeof SafeAccountV0_3_0>(\n\t\tthis: T,\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): InstanceType<T> {\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(\"Only one Webauthn signer is allowed during initialization\");\n\t\t\t\t}\n\t\t\t\tif (owners.indexOf(owner) !== 0) {\n\t\t\t\t\tthrow new RangeError(\"Webauthn owner has to be the first owner for an init transaction.\");\n\t\t\t\t}\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 ?? SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_3_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\t\t\t);\n\n\t\t// Plain-JS callers may invoke this factory detached\n\t\t// (`const init = SafeAccountV0_3_0.initializeNewAccount; init(...)`),\n\t\t// leaving strict-mode `this` undefined; fall back to this class so\n\t\t// such calls keep working instead of throwing on `new this(...)`.\n\t\t// biome-ignore lint/complexity/noThisInStatic: polymorphic factory; subclasses must get their own type back\n\t\tconst ctor = (this as T | undefined) ?? SafeAccountV0_3_0;\n\t\tconst safe: SafeAccountV0_3_0 = new ctor(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n\t\t\tonChainIdentifierParams: overrides.onChainIdentifierParams,\n\t\t\tonChainIdentifier: 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 as InstanceType<T>;\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 ?? SafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_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\t/**\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\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV7TypedMessageValue;\n\t} {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ?? SafeAccountV0_3_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_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 ?? SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_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 ?? SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_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 | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\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 | Transport | Bundler,\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(userOperation, bundlerRpc, overrides);\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 options - {@link SafeSignatureOptions} — timing, multi-chain encoding, module address\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\toptions: SafeSignatureOptions = {},\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\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * Sign a UserOperation with one or more {@link ExternalSigner} instances\n\t * (viem, ethers, hardware wallets, MPC, HSMs). Each signer declares its\n\t * capabilities (`signHash`, `signTypedData`, or both) and the account picks\n\t * the best match; incompatible signers fail offline with an actionable error.\n\t *\n\t * For a raw private-key string, use the sync {@link signUserOperation}\n\t * instead or wrap with `fromPrivateKey(pk)`. Prebuilt adapters: `fromViem`,\n\t * `fromEthersWallet`, `fromViemWalletClient`, `fromPrivateKey`.\n\t *\n\t * @example\n\t * import { fromViem } from \"abstractionkit\";\n\t * import { privateKeyToAccount } from \"viem/accounts\";\n\t *\n\t * const signer = fromViem(privateKeyToAccount(pk));\n\t * userOp.signature = await account.signUserOperationWithSigners(userOp, [signer], chainId);\n\t *\n\t * @param useroperation - UserOperation to sign\n\t * @param signers - one ExternalSigner per owner (any order)\n\t * @param chainId - target chain ID\n\t * @param options - {@link SafeSignatureOptions} — timing, multi-chain encoding, module address\n\t * @returns Promise resolving to the formatted signature string\n\t */\n\tpublic signUserOperationWithSigners(\n\t\tuseroperation: UserOperationV7,\n\t\tsigners: ReadonlyArray<ExternalSigner>,\n\t\tchainId: bigint,\n\t\toptions: SafeSignatureOptions = {}\n\t): Promise<string> {\n\t\tconst context: SignContext<UserOperationV7> = {\n\t\t\tuserOperation: useroperation,\n\t\t\tchainId,\n\t\t\tentryPoint: this.entrypointAddress,\n\t\t};\n\t\treturn SafeAccount.baseSignUserOperationWithSigners(useroperation, signers, chainId, {\n\t\t\tentrypointAddress: this.entrypointAddress,\n\t\t\tsafe4337ModuleAddress: this.safe4337ModuleAddress,\n\t\t\tcontext,\n\t\t\toptions,\n\t\t});\n\t}\n\n\t/**\n\t * Create the MetaTransactions that migrate this DEPLOYED Safe from EntryPoint\n\t * v0.7 (this account's `Safe4337Module`) to EntryPoint v0.9\n\t * (`SafeMultiChainSigAccountV1`'s `Safe4337MultiChainSignatureModule`).\n\t *\n\t * The returned batch must be sent as a UserOperation FROM THIS v0.7 account\n\t * (it is validated/executed by the v0.7 module on the v0.7 EntryPoint). After\n\t * it lands, attach the same account address to `SafeMultiChainSigAccountV1` to\n\t * operate on EntryPoint v0.9. Both modules are stateless, so no storage\n\t * clearing is required. See {@link createModuleMigrationMetaTransactions}.\n\t *\n\t * @param nodeRpcUrl - The JSON-RPC API url for the target chain\n\t * @param overrides - override the source/target module addresses or module lookup\n\t * @returns a promise of [disableV07, enableV09, setFallbackHandler] MetaTransactions\n\t */\n\tpublic async createMigrateToSafeMultiChainSigAccountV1MetaTransactions(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\toverrides: {\n\t\t\tsafeV07ModuleAddress?: string;\n\t\t\tsafeV09ModuleAddress?: string;\n\t\t\tprevModuleAddress?: string;\n\t\t\tmodulesStart?: string;\n\t\t\tmodulesPageSize?: bigint;\n\t\t\tskipPreflight?: boolean;\n\t\t} = {},\n\t): Promise<MetaTransaction[]> {\n\t\tconst moduleV07Address = overrides.safeV07ModuleAddress ?? this.safe4337ModuleAddress;\n\t\tconst moduleV09Address =\n\t\t\toverrides.safeV09ModuleAddress ??\n\t\t\tSafeMultiChainSigAccountV1.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn this.createModuleMigrationMetaTransactions(\n\t\t\tnodeRpcUrl,\n\t\t\tmoduleV07Address,\n\t\t\tmoduleV09Address,\n\t\t\t{\n\t\t\t\tprevModuleAddress: overrides.prevModuleAddress,\n\t\t\t\tmodulesStart: overrides.modulesStart,\n\t\t\t\tmodulesPageSize: overrides.modulesPageSize,\n\t\t\t\tskipPreflight: overrides.skipPreflight,\n\t\t\t},\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","import type {Bundler} from \"src/Bundler\";\nimport {ENTRYPOINT_V6} from \"src/constants\";\nimport type {SignContext, ExternalSigner} from \"src/signer/types\";\nimport type {JsonRpcNode, Transport} from \"src/transport\";\nimport type {MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet, UserOperationV6,} from \"../../types\";\nimport {SafeAccount} from \"./SafeAccount\";\nimport {SafeAccountV0_3_0} from \"./SafeAccountV0_3_0\";\nimport type {\n\tCreateUserOperationV6Overrides,\n\tInitCodeOverrides,\n\tSafeAccountSingleton,\n\tSafeSignatureOptions,\n\tSafeUserOperationTypedDataDomain,\n\tSafeUserOperationV6TypedMessageValue,\n\tSigner,\n\tSignerSignaturePair,\n} from \"./types\";\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 = \"0xa581c4A4DB7175302464fF3C06380BC3270b4037\";\n\tstatic readonly DEFAULT_SAFE_MODULE_SETUP_ADDRESS = \"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\t\t\tonChainIdentifierParams?: OnChainIdentifierParamsType;\n\t\t\tonChainIdentifier?: string;\n\t\t} = {},\n\t) {\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ?? SafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\n\t\tsuper(accountAddress, safe4337ModuleAddress, entrypointAddress, {\n\t\t\tonChainIdentifierParams: overrides.onChainIdentifierParams,\n\t\t\tonChainIdentifier: overrides.onChainIdentifier,\n\t\t});\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, ,] = SafeAccount.createAccountAddressAndFactoryAddressAndData(\n\t\t\towners,\n\t\t\toverrides,\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\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(\"Only one Webauthn signer is allowed during initialization\");\n\t\t\t\t}\n\t\t\t\tif (owners.indexOf(owner) !== 0) {\n\t\t\t\t\tthrow new RangeError(\"Webauthn owner has to be the first owner for an init transaction.\");\n\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\tSafeAccountV0_2_0.createAccountAddressAndFactoryAddressAndData(\n\t\t\t\towners,\n\t\t\t\toverrides,\n\t\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_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\t\t\tonChainIdentifierParams: overrides.onChainIdentifierParams,\n\t\t\tonChainIdentifier: 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 ?? SafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_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\t/**\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\t\tdomain: SafeUserOperationTypedDataDomain;\n\t\ttypes: Record<string, { name: string; type: string }[]>;\n\t\tmessageValue: SafeUserOperationV6TypedMessageValue;\n\t} {\n\t\tconst validAfter = overrides.validAfter ?? 0n;\n\t\tconst validUntil = overrides.validUntil ?? 0n;\n\t\tconst entrypointAddress =\n\t\t\toverrides.entrypointAddress ?? SafeAccountV0_2_0.DEFAULT_ENTRYPOINT_ADDRESS;\n\t\tconst safe4337ModuleAddress =\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_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 ?? SafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_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\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 ?? SafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\t\tconst safeModuleSetupAddress =\n\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_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(owners: Signer[], overrides: InitCodeOverrides = {}): string {\n\t\tconst [safeAccountFactoryAddress, factoryData] = SafeAccount.createFactoryAddressAndData(\n\t\t\towners,\n\t\t\toverrides,\n\t\t\toverrides.safe4337ModuleAddress ?? SafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS,\n\t\t\toverrides.safeModuleSetupAddress ?? SafeAccountV0_2_0.DEFAULT_SAFE_MODULE_SETUP_ADDRESS,\n\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 | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\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\t/**\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\tpublic async createMigrateToSafeAccountV0_3_0MetaTransactions(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\n\t\toverrides: {\n\t\t\tsafeV06ModuleAddress?: string;\n\t\t\tsafeV07ModuleAddress?: string;\n\t\t\tprevModuleAddress?: string;\n\t\t\tpageSize?: bigint;\n\t\t\tmodulesStart?: string;\n\t\t\tskipPreflight?: boolean;\n\t\t} = {},\n\t): Promise<MetaTransaction[]> {\n\t\tconst moduleV06Address =\n\t\t\toverrides.safeV06ModuleAddress ?? SafeAccountV0_2_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\tconst moduleV07Address =\n\t\t\toverrides.safeV07ModuleAddress ?? SafeAccountV0_3_0.DEFAULT_SAFE_4337_MODULE_ADDRESS;\n\n\t\treturn this.createModuleMigrationMetaTransactions(\n\t\t\tnodeRpcUrl,\n\t\t\tmoduleV06Address,\n\t\t\tmoduleV07Address,\n\t\t\t{\n\t\t\t\t// previous module in the linked list (skips the RPC lookup when set);\n\t\t\t\t// left undefined by default so the predecessor is fetched on-chain.\n\t\t\t\tprevModuleAddress: overrides.prevModuleAddress,\n\t\t\t\tmodulesPageSize: overrides.pageSize,\n\t\t\t\tmodulesStart: overrides.modulesStart,\n\t\t\t\tskipPreflight: overrides.skipPreflight,\n\t\t\t},\n\t\t);\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: UserOperationV6,\n\t\tbundlerRpc: string | Transport | Bundler,\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(userOperation, bundlerRpc, overrides);\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 options - {@link SafeSignatureOptions} — timing, multi-chain encoding, module address\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\toptions: SafeSignatureOptions = {},\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\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * Sign a UserOperation using one or more {@link ExternalSigner} instances.\n\t * See {@link SafeAccountV0_3_0.signUserOperationWithSigners} for full\n\t * design rationale and examples.\n\t *\n\t * @param useroperation - The UserOperation to sign\n\t * @param signers - one ExternalSigner per owner (any order)\n\t * @param chainId - The target chain ID\n\t * @param options - {@link SafeSignatureOptions} — timing, multi-chain encoding, module address\n\t * @returns Promise resolving to the formatted signature string\n\t */\n\tpublic signUserOperationWithSigners(\n\t\tuseroperation: UserOperationV6,\n\t\tsigners: ReadonlyArray<ExternalSigner>,\n\t\tchainId: bigint,\n\t\toptions: SafeSignatureOptions = {},\n\t): Promise<string> {\n\t\tconst context: SignContext<UserOperationV6> = {\n\t\t\tuserOperation: useroperation,\n\t\t\tchainId,\n\t\t\tentryPoint: this.entrypointAddress,\n\t\t};\n\t\treturn SafeAccount.baseSignUserOperationWithSigners(useroperation, signers, chainId, {\n\t\t\tentrypointAddress: this.entrypointAddress,\n\t\t\tsafe4337ModuleAddress: this.safe4337ModuleAddress,\n\t\t\tcontext,\n\t\t\toptions,\n\t\t});\n\t}\n}\n","import type {Bundler} from \"src/Bundler\";\nimport {Safe_L2_V1_5_0} from \"src/constants\";\nimport type {JsonRpcNode, Transport} from \"src/transport\";\nimport type {MetaTransaction, OnChainIdentifierParamsType, StateOverrideSet, UserOperationV7,} from \"src/types\";\nimport {SafeAccount} from \"./SafeAccount\";\nimport {SafeAccountV0_3_0} from \"./SafeAccountV0_3_0\";\nimport type {\n\tCreateUserOperationV7Overrides,\n\tInitCodeOverrides,\n\tSafeAccountSingleton,\n\tSigner,\n\tSignerSignaturePair,\n\tWebauthnPublicKey,\n\tWebAuthnSignatureOverrides,\n} from \"./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\t// Daimo P256 contract verifier paired with module v0.3.0. Same value\n\t// exposed under both names: DAIMO_VERIFIER for self-documentation and\n\t// CONTRACT_VERIFIER as the polymorphic slot fromSafeWebauthn reads.\n\tstatic readonly DEFAULT_WEB_AUTHN_DAIMO_VERIFIER: string =\n\t\t\"0xc2b78104907F722DABAc4C69f826a522B2754De4\";\n\tstatic readonly DEFAULT_WEB_AUTHN_CONTRACT_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\t\t\tonChainIdentifierParams?: OnChainIdentifierParamsType;\n\t\t\tonChainIdentifier?: string;\n\t\t\tsafeAccountSingleton?: SafeAccountSingleton;\n\t\t} = {},\n\t) {\n\t\tsuper(accountAddress, {\n\t\t\tsafe4337ModuleAddress: overrides.safe4337ModuleAddress,\n\t\t\tentrypointAddress: overrides.entrypointAddress,\n\t\t\tonChainIdentifierParams: overrides.onChainIdentifierParams,\n\t\t\tonChainIdentifier: overrides.onChainIdentifier,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton ?? Safe_L2_V1_5_0,\n\t\t});\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\t\tconst modOverrides = {\n\t\t\t...overrides,\n\t\t\tsingletonInitHash: overrides.singletonInitHash ?? Safe_L2_V1_5_0.singletonInitHash,\n\t\t};\n\t\treturn SafeAccountV0_3_0.createProxyAddress(initializerCallData, modOverrides);\n\t}\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<T extends typeof SafeAccountV0_3_0>(\n\t\tthis: T,\n\t\towners: Signer[],\n\t\toverrides: InitCodeOverrides = {},\n\t): InstanceType<T> {\n\t\tconst modOverrides = {\n\t\t\t...overrides,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton ?? Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t};\n\t\t// `super` keeps `this` bound to the calling class, so the base\n\t\t// factory's `new this(...)` constructs an instance of this class\n\t\t// (SafeAccountV1_5_0_M_0_3_0 or a subclass), not SafeAccountV0_3_0.\n\t\t// biome-ignore lint/complexity/noThisInStatic: polymorphic factory dispatch through super\n\t\treturn super.initializeNewAccount(owners, modOverrides) as InstanceType<T>;\n\t}\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(owners: Signer[], overrides: InitCodeOverrides = {}): string {\n\t\tconst modOverrides = {\n\t\t\t...overrides,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton ?? Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t};\n\t\treturn SafeAccountV0_3_0.createAccountAddress(owners, modOverrides);\n\t}\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\t\tconst modOverrides = {\n\t\t\t...overrides,\n\t\t\tsafeAccountSingleton: overrides.safeAccountSingleton ?? Safe_L2_V1_5_0,\n\t\t\teip7212WebAuthnPrecompileVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifierForSharedSigner ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifierForSharedSigner:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifierForSharedSigner ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t};\n\t\treturn SafeAccountV0_3_0.createFactoryAddressAndData(owners, modOverrides);\n\t}\n\n\t/**\n\t * Create a UserOperation with v1.5.0 defaults applied for WebAuthn verification\n\t * (RIP-7951 precompile + Daimo fallback). See {@link SafeAccountV0_3_0.createUserOperation}.\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\tpublic async createUserOperation(\n\t\ttransactions: MetaTransaction[],\n\t\tproviderRpc?: string | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\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:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t});\n\t}\n\n\t/**\n\t * Estimate gas limits for a UserOperation with v1.5.0 WebAuthn defaults applied.\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 | Transport | Bundler,\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:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t});\n\t}\n\n\t/**\n\t * Compute the counterfactual address of the WebAuthn signer proxy for the given public key.\n\t * Applies v1.5.0 defaults for precompile + Daimo verifier.\n\t *\n\t * @param x - X coordinate of the WebAuthn P-256 public key\n\t * @param y - Y coordinate of the WebAuthn P-256 public key\n\t * @param overrides - Override WebAuthn verifier, factory, singleton, and proxy-code addresses\n\t * @returns The counterfactual verifier/proxy 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\treturn SafeAccount.createWebAuthnSignerVerifierAddress(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t});\n\t}\n\n\t/**\n\t * Create a MetaTransaction that deploys the WebAuthn verifier/proxy for the given public key.\n\t * Applies v1.5.0 defaults for precompile + Daimo verifier.\n\t *\n\t * @param x - X coordinate of the WebAuthn P-256 public key\n\t * @param y - Y coordinate of the WebAuthn P-256 public key\n\t * @param overrides - Override WebAuthn verifier and factory addresses\n\t * @returns A MetaTransaction that deploys the verifier\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\treturn SafeAccount.createDeployWebAuthnVerifierMetaTransaction(x, y, {\n\t\t\t...overrides,\n\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t});\n\t}\n\n\t/**\n\t * Build dummy signer/signature pairs for gas estimation, with v1.5.0 WebAuthn defaults.\n\t *\n\t * @param expectedSigners - Signers whose signatures will be produced at sign time\n\t * @param webAuthnSignatureOverrides - Override WebAuthn verifier/module configuration\n\t * @returns An array of dummy SignerSignaturePair entries, one per expected signer\n\t */\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:\n\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\twebAuthnSignatureOverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t});\n\t}\n\n\t/**\n\t * Verify a WebAuthn signature over a message hash on-chain via the P-256 verifier.\n\t * Applies v1.5.0 defaults for precompile + Daimo verifier.\n\t *\n\t * @param nodeRpcUrl - Ethereum JSON-RPC node URL\n\t * @param signer - WebAuthn public key that purportedly produced the signature\n\t * @param messageHash - The hash that was signed\n\t * @param signature - The WebAuthn signature bytes\n\t * @param overrides - Override WebAuthn verifier and singleton addresses\n\t * @returns Promise of `true` if the signature verifies, otherwise `false`\n\t */\n\tpublic static async verifyWebAuthnSignatureForMessageHash(\n\t\tnodeRpcUrl: string | Transport | JsonRpcNode,\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(\n\t\t\tnodeRpcUrl,\n\t\t\tsigner,\n\t\t\tmessageHash,\n\t\t\tsignature,\n\t\t\t{\n\t\t\t\t...overrides,\n\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\toverrides.eip7212WebAuthnPrecompileVerifier ??\n\t\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\toverrides.eip7212WebAuthnContractVerifier ??\n\t\t\t\t\tSafeAccountV1_5_0_M_0_3_0.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t\t},\n\t\t);\n\t}\n}\n","import {decodeAbiParameters, hexlify, privateKeyToAddress, signHash} from \"src/ethereUtils\";\nimport {Bundler} from \"src/Bundler\";\nimport {BaseUserOperationDummyValues, ENTRYPOINT_V8, ENTRYPOINT_V9} from \"src/constants\";\nimport {AbstractionKitError} from \"src/errors\";\nimport {invokeSigner, pickScheme} from \"src/signer/negotiate\";\nimport type {SignContext, ExternalSigner, SigningScheme, TypedData} from \"src/signer/types\";\nimport {JsonRpcNode, type Transport} from \"src/transport\";\nimport type {\n\tGasOption,\n\tJsonRpcResult,\n\tPolygonChain,\n\tStateOverrideSet,\n\tUserOperationV8,\n\tUserOperationV9,\n} from \"src/types\";\nimport {\n\ttype Authorization7702Hex,\n\tbigintToHex,\n\tcreateAndSignEip7702RawTransaction,\n\tcreateRevokeDelegationAuthorization,\n} from \"src/utils7702\";\nimport {\n\tcreateCallData,\n\tcreateUserOperationHash,\n\tfetchAccountNonce,\n\tgetFunctionSelector,\n\tgetUserOperationEip712DataV8V9,\n\tgetUserOperationEip712HashV8V9,\n\thandlefetchGasPrice,\n\tsendJsonRpcRequest,\n} from \"../../utils\";\nimport {SendUseroperationResponse} from \"../SendUseroperationResponse\";\nimport {SmartAccount} from \"../SmartAccount\";\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 querying 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 querying the current gas price from the rpc node */\n\tmaxFeePerGas?: bigint;\n\t/** set the maxPriorityFeePerGas instead of querying 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 querying the current gas price from the rpc node */\n\tmaxFeePerGasPercentageMultiplier?: number;\n\t/** set the maxPriorityFeePerGasPercentageMultiplier instead of querying 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/**\n\t * Skip calling the bundler's gas estimation entirely. When true, the returned\n\t * UserOperation still gets a dummy signature, but its gas limits come from the\n\t * provided overrides (or stay at 0n). Useful when estimation is run separately\n\t * — for example, by a paymaster sponsorship call that returns its own limits.\n\t */\n\tskipGasEstimation?: boolean;\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\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\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\t\t\"address\", //dest\n\t\t\"uint256\", //value\n\t\t\"bytes\", //func\n\t];\n\t/** Function selector for `executeBatch((address,uint256,bytes)[])` */\n\tstatic readonly batchExecutorFunctionSelector = \"0x34fcd5be\"; //executeBatch\n\t/** ABI parameter types for the batch `executeBatch` function */\n\tstatic readonly batchExecutorFunctionInputAbi = [\"(address,uint256,bytes)[]\"];\n\t/** Dummy ECDSA signature used during gas estimation */\n\tstatic readonly dummySignature =\n\t\t\"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(accountAddress: string, entrypointAddress: string, delegateeAddress: string) {\n\t\tsuper(accountAddress);\n\t\tthis.entrypointAddress = entrypointAddress;\n\t\tthis.delegateeAddress = delegateeAddress;\n\t}\n\n\t/**\n\t * Check if this EOA is delegated to the expected delegatee address via EIP-7702.\n\t * Returns `true` only when delegated to `this.delegateeAddress`.\n\t * Use `JsonRpcNode.getDelegatedAddress()` directly to get the raw delegatee address.\n\t *\n\t * @param providerRpc - Ethereum JSON-RPC node URL\n\t * @returns `true` if delegated to the expected address, `false` otherwise\n\t */\n\tpublic async isDelegatedToThisAccount(\n\t\tproviderRpc: string | Transport | JsonRpcNode,\n\t): Promise<boolean> {\n\t\tconst address = await JsonRpcNode.from(providerRpc).getDelegatedAddress(this.accountAddress);\n\t\tif (address === null) return false;\n\t\treturn address.toLowerCase() === this.delegateeAddress.toLowerCase();\n\t}\n\n\t/**\n\t * Create a signed raw EIP-7702 transaction that revokes the delegation,\n\t * restoring the EOA to a normal account. The transaction is type 0x04\n\t * with a zero-address authorization.\n\t *\n\t * Cannot be done via UserOp — the authorization_list is processed before\n\t * execution, removing the account's code mid-transaction.\n\t *\n\t * Authorization nonce defaults to txNonce + 1 because EIP-7702 increments\n\t * the sender's transaction nonce before processing the authorization list.\n\t *\n\t * @param eoaPrivateKey - The EOA's private key (signs both auth and tx)\n\t * @param providerRpc - JSON-RPC endpoint for nonce, gas price, chain ID\n\t * @param overrides - Optional overrides for transaction fields\n\t * @returns Signed raw transaction hex, ready for `eth_sendRawTransaction`\n\t */\n\tpublic async createRevokeDelegationTransaction(\n\t\teoaPrivateKey: string,\n\t\tproviderRpc: string | Transport | JsonRpcNode,\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\tchainId?: bigint;\n\t\t} = {},\n\t): Promise<string> {\n\t\t// Verify the private key matches this account — otherwise the raw\n\t\t// transaction's sender (recovered from the signature) would be a\n\t\t// different EOA and the revoke would target the signer's delegation\n\t\tconst signerAddress = privateKeyToAddress(eoaPrivateKey);\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 (${this.accountAddress})`,\n\t\t\t);\n\t\t}\n\n\t\t// Verify delegation state before revoking\n\t\tconst delegatedTo = await JsonRpcNode.from(providerRpc).getDelegatedAddress(this.accountAddress);\n\t\tif (delegatedTo === null) {\n\t\t\tthrow new AbstractionKitError(\"BAD_DATA\", \"Account is not delegated — nothing to revoke\");\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 +\n\t\t\t\t\t\"), not \" +\n\t\t\t\t\tthis.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\tchainId?: 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(providerRpc, \"eth_getTransactionCount\", [\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t\t\"latest\",\n\t\t\t\t]).then((v) => {\n\t\t\t\t\tresults.nonce = BigInt(v as string);\n\t\t\t\t}),\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).then(([fee, tip]) => {\n\t\t\t\t\tresults.maxFeePerGas = fee;\n\t\t\t\t\tresults.maxPriorityFeePerGas = tip;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (overrides.chainId == null) {\n\t\t\tops.push(\n\t\t\t\tsendJsonRpcRequest(providerRpc, \"eth_chainId\", []).then((v) => {\n\t\t\t\t\tresults.chainId = BigInt(v as string);\n\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 =\n\t\t\toverrides.maxPriorityFeePerGas ?? results.maxPriorityFeePerGas ?? 0n;\n\t\tconst chainId = overrides.chainId ?? results.chainId ?? 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 (returns Authorization7702Hex)\n\t\tconst authHex = createRevokeDelegationAuthorization(chainId, authNonce, eoaPrivateKey);\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 * 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\tpublic static createAccountCallData(to: string, value: bigint, data: string): 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\t}\n\n\t/**\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\tpublic 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\t/**\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\t\ttransactions: SimpleMetaTransaction[],\n\t): string {\n\t\tconst encodedTransactions = [\n\t\t\ttransactions.map((transaction) => [transaction.to, transaction.value, transaction.data]),\n\t\t];\n\t\tconst 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\t/**\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\tprotected async baseCreateUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8 | UserOperationV9> {\n\t\tif (transactions.length < 1) {\n\t\t\tthrow new RangeError(\"There should be at least one transaction\");\n\t\t}\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(providerRpc, this.entrypointAddress, this.accountAddress);\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 (typeof overrides.maxFeePerGas === \"bigint\" && overrides.maxFeePerGas < 0n) {\n\t\t\tthrow new RangeError(\"maxFeePerGas override can't be negative\");\n\t\t}\n\n\t\tif (typeof overrides.maxPriorityFeePerGas === \"bigint\" && overrides.maxPriorityFeePerGas < 0n) {\n\t\t\tthrow new RangeError(\"maxPriorityFeePerGas override can't be negative\");\n\t\t}\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 (overrides.maxFeePerGas == null || overrides.maxPriorityFeePerGas == null) {\n\t\t\tgasPriceOp = handlefetchGasPrice(\n\t\t\t\tproviderRpc,\n\t\t\t\toverrides.polygonGasStation,\n\t\t\t\toverrides.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\t\tlet skipEip7702Auth = false;\n\n\t\tif (overrides.eip7702Auth != null) {\n\t\t\teip7702AuthChainId = overrides.eip7702Auth.chainId;\n\t\t\teip7702AuthAddress = overrides.eip7702Auth.address ?? this.delegateeAddress;\n\t\t\teip7702AuthNonce = overrides.eip7702Auth.nonce ?? null;\n\t\t}\n\n\t\t// When eip7702Auth is provided, check delegation status in parallel.\n\t\t// Best-effort: if the check fails, proceed as if not delegated.\n\t\tlet delegationCheckOp: Promise<string | null> | null = null;\n\t\tif (overrides.eip7702Auth != null && providerRpc != null) {\n\t\t\tdelegationCheckOp = JsonRpcNode.from(providerRpc)\n\t\t\t\t.getDelegatedAddress(this.accountAddress)\n\t\t\t\t.catch(() => null);\n\t\t}\n\n\t\tif (overrides.eip7702Auth != null && eip7702AuthNonce == null) {\n\t\t\t//check for eip7702AuthNonce\n\t\t\tlet eip7702AuthNonceOp: Promise<JsonRpcResult>;\n\t\t\tif (providerRpc != null) {\n\t\t\t\teip7702AuthNonceOp = sendJsonRpcRequest(providerRpc, \"eth_getTransactionCount\", [\n\t\t\t\t\tthis.accountAddress,\n\t\t\t\t\t\"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 \" + \"is not overridden\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Build array of all parallel operations\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)\n\t\t\t\t[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 (\n\t\t\t\t\tdelegatedTo != null &&\n\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()\n\t\t\t\t) {\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\t// eip7702AuthNonce was provided, but still need delegation check + other ops\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)\n\t\t\t\t\t[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 (\n\t\t\t\t\t\tdelegatedTo != null &&\n\t\t\t\t\t\tdelegatedTo.toLowerCase() === (eip7702AuthAddress as string).toLowerCase()\n\t\t\t\t\t) {\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\t//don't check for eip7702AuthNonce\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\t\tmaxFeePerGas =\n\t\t\toverrides.maxFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxFeePerGas) * (((overrides.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\n\t\tmaxPriorityFeePerGas =\n\t\t\toverrides.maxPriorityFeePerGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(maxPriorityFeePerGas) *\n\t\t\t\t\t\t(((overrides.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\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\tif (transactions.length === 1) {\n\t\t\t\tcallData = BaseSimple7702Account.createAccountCallDataSingleTransaction(transactions[0]);\n\t\t\t} else {\n\t\t\t\tcallData = BaseSimple7702Account.createAccountCallDataBatchTransactions(transactions);\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\t\tif (overrides.eip7702Auth != null && !skipEip7702Auth) {\n\t\t\tconst yParity = overrides.eip7702Auth.yParity ?? \"0x0\";\n\t\t\tif (yParity !== \"0x0\" && yParity !== \"0x00\" && yParity !== \"0x1\" && yParity !== \"0x01\") {\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. \" + \"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:\n\t\t\t\t\toverrides.eip7702Auth.r ??\n\t\t\t\t\t\"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2\",\n\t\t\t\ts:\n\t\t\t\t\toverrides.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: null,\n\t\t\t\tpaymasterVerificationGasLimit: null,\n\t\t\t\tpaymasterPostOpGasLimit: null,\n\t\t\t\tpaymasterData: 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: 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\tlet preVerificationGas = BaseUserOperationDummyValues.preVerificationGas;\n\t\tlet verificationGasLimit = BaseUserOperationDummyValues.verificationGasLimit;\n\t\tlet callGasLimit = BaseUserOperationDummyValues.callGasLimit;\n\n\t\t// Set the dummy signature on the user operation regardless of whether\n\t\t// gas estimation runs below, so the returned op always has a valid\n\t\t// placeholder signature (required by paymaster sponsorship calls).\n\t\tuserOperation.signature = overrides.dummySignature ?? BaseSimple7702Account.dummySignature;\n\n\t\tconst skipGasEstimation = overrides.skipGasEstimation ?? false;\n\n\t\t// Apply v0.9 parallel paymaster placeholders unconditionally so the\n\t\t// paymaster stub survives into signing/hashing regardless of whether\n\t\t// gas estimation runs below. The UserOpHash must commit to these\n\t\t// fields, so dropping them when skipGasEstimation is true or when\n\t\t// gas limits are pre-specified would produce an invalid signature.\n\t\tconst parallelPaymasterInitValues = overrides.parallelPaymasterInitValues;\n\t\tif (parallelPaymasterInitValues != null) {\n\t\t\tif (this.entrypointAddress !== ENTRYPOINT_V9) {\n\t\t\t\tthrow new RangeError(\"parallelPaymasterInitValues only works with ep v0.9\");\n\t\t\t}\n\t\t\tuserOperation.paymaster = parallelPaymasterInitValues.paymaster;\n\t\t\tuserOperation.paymasterVerificationGasLimit =\n\t\t\t\tparallelPaymasterInitValues.paymasterVerificationGasLimit;\n\t\t\tuserOperation.paymasterPostOpGasLimit = parallelPaymasterInitValues.paymasterPostOpGasLimit;\n\t\t\tuserOperation.paymasterData = parallelPaymasterInitValues.paymasterData;\n\t\t}\n\n\t\tif (\n\t\t\t!skipGasEstimation &&\n\t\t\t(overrides.preVerificationGas == null ||\n\t\t\t\toverrides.verificationGasLimit == null ||\n\t\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 = { ...userOperation };\n\n\t\t\t\t[preVerificationGas, verificationGasLimit, callGasLimit] =\n\t\t\t\t\tawait this.baseEstimateUserOperationGas(userOperationToEstimate, bundlerRpc, {\n\t\t\t\t\t\tstateOverrideSet: overrides.state_override_set,\n\t\t\t\t\t});\n\t\t\t\t// Compensate for ECDSA verification cost the bundler skips during\n\t\t\t\t// `eth_estimateUserOperationGas`: estimation runs with a dummy\n\t\t\t\t// signature whose signature path is short-circuited (the dummy\n\t\t\t\t// doesn't recover to a real owner, so the bundler bypasses\n\t\t\t\t// signature validation). ~55k gas is the on-chain ECRECOVER +\n\t\t\t\t// signature decode cost that simulation never paid for.\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 can't be null if preVerificationGas,\" +\n\t\t\t\t\t\t\"verificationGasLimit and callGasLimit are not overridden\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\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\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\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\tuserOperation.preVerificationGas =\n\t\t\toverrides.preVerificationGas ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(preVerificationGas) *\n\t\t\t\t\t\t(((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.verificationGasLimit =\n\t\t\toverrides.verificationGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(verificationGasLimit) *\n\t\t\t\t\t\t(((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\n\n\t\tuserOperation.callGasLimit =\n\t\t\toverrides.callGasLimit ??\n\t\t\tBigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(callGasLimit) * (((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) / 100),\n\t\t\t\t),\n\t\t\t);\n\n\t\treturn userOperation;\n\t}\n\n\t/**\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\tprotected async baseEstimateUserOperationGas(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tbundlerRpc: string | Transport | Bundler,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\tconst bundler = Bundler.from(bundlerRpc);\n\n\t\t// Estimate on a shallow copy so the caller's operation is never\n\t\t// mutated, even when estimation throws.\n\t\tconst userOperationToEstimate = {\n\t\t\t...userOperation,\n\t\t\tsignature: overrides.dummySignature ?? BaseSimple7702Account.dummySignature,\n\t\t\tmaxFeePerGas: 0n,\n\t\t\tmaxPriorityFeePerGas: 0n,\n\t\t};\n\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\tuserOperationToEstimate,\n\t\t\tthis.entrypointAddress,\n\t\t\toverrides.stateOverrideSet,\n\t\t);\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\t/**\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\tprotected baseSignUserOperation(\n\t\tuseroperation: UserOperationV8 | UserOperationV9,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\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\n\t\treturn signHash(privateKey, userOperationHash).serialized;\n\t}\n\n\t/**\n\t * Schemes Simple7702 accepts from a Signer. EntryPoint v0.8/v0.9 introduced\n\t * an EIP-712 domain at the EntryPoint contract, and the userOpHash IS the\n\t * EIP-712 digest of the PackedUserOperation under that domain — so signing\n\t * the typed data and signing the raw hash produce signatures that verify\n\t * against the same `userOpHash` (and recover to the same signer address).\n\t * Deterministic-ECDSA signers (ethers, viem, MetaMask) yield byte-identical\n\t * bytes; signers that differ in `s` / `v` normalization still validate the\n\t * same on-chain.\n\t *\n\t * `typedData` is listed first so JSON-RPC wallets that can only sign typed\n\t * data work without a separate code path; `hash` remains a valid fallback\n\t * for local-key signers.\n\t */\n\tpublic static readonly ACCEPTED_SIGNING_SCHEMES: readonly SigningScheme[] = [\"typedData\", \"hash\"];\n\n\t/**\n\t * Build the EIP-712 typed data payload for a UserOperation under the\n\t * EntryPoint v0.8 / v0.9 domain. Lower-level escape hatch for integrators\n\t * driving `signTypedData` themselves with their own signing primitive\n\t * (HSM, MPC, custom wallet abstraction). Most callers should pass an\n\t * {@link ExternalSigner} to {@link signUserOperationWithSigner} instead, which\n\t * builds this internally.\n\t *\n\t * The digest of the returned payload equals the UserOperation hash from\n\t * {@link createUserOperationHash}, so a wallet calling\n\t * `signTypedData(domain, types, message)` produces a signature that\n\t * verifies against the same `userOpHash` as raw ECDSA over that hash.\n\t * Deterministic-ECDSA signers yield byte-identical signatures; signers\n\t * that differ in `s` / `v` normalization still validate the same on-chain.\n\t *\n\t * The base class defaults to EntryPoint v0.8; subclasses\n\t * ({@link Simple7702AccountV09}) override with their own default.\n\t *\n\t * @param userOperation - Unsigned UserOperation to wrap\n\t * @param chainId - Target chain ID (must match the chain that will validate\n\t *   the signature)\n\t * @param overrides - Override the entrypoint address\n\t * @returns EIP-712 {@link TypedData} payload ready for `signTypedData`\n\t * @throws {AbstractionKitError} if the target EntryPoint is not v0.8 / v0.9.\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: { entrypointAddress?: string } = {},\n\t): TypedData {\n\t\tconst entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V8;\n\t\treturn getUserOperationEip712DataV8V9(userOperation, entrypointAddress, chainId);\n\t}\n\n\t/**\n\t * Compute the EIP-712 digest of a UserOperation under the EntryPoint\n\t * v0.8 / v0.9 domain. For these EntryPoints this digest IS the\n\t * `userOpHash` ({@link createUserOperationHash}); signing it with raw\n\t * ECDSA or via `signTypedData` over the data from\n\t * {@link getUserOperationEip712Data} produces a signature that validates\n\t * against the same hash on-chain.\n\t *\n\t * @param userOperation - Unsigned UserOperation to hash\n\t * @param chainId - Target chain ID\n\t * @param overrides - Override the entrypoint address (defaults to EntryPoint v0.8)\n\t * @returns The EIP-712 digest as a hex string\n\t * @throws {AbstractionKitError} if the target EntryPoint is not v0.8 / v0.9.\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuserOperation: UserOperationV8 | UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: { entrypointAddress?: string } = {},\n\t): string {\n\t\tconst entrypointAddress = overrides.entrypointAddress ?? ENTRYPOINT_V8;\n\t\treturn getUserOperationEip712HashV8V9(userOperation, entrypointAddress, chainId);\n\t}\n\n\t/**\n\t * Sign a UserOperation with an {@link ExternalSigner}. The signer can implement\n\t * either `signTypedData` (preferred — JSON-RPC wallets, viem `WalletClient`)\n\t * or `signHash` (local keys, hardware wallets). Both schemes produce\n\t * signatures that validate against the same `userOpHash` because the\n\t * v0.8 / v0.9 userOpHash IS the EIP-712 digest of the PackedUserOperation\n\t * (deterministic-ECDSA signers yield byte-identical bytes).\n\t *\n\t * Signers that implement neither method fail offline with an actionable\n\t * error.\n\t */\n\tprotected async baseSignUserOperationWithSigner<T extends UserOperationV8 | UserOperationV9>(\n\t\tuseroperation: T,\n\t\tsigner: ExternalSigner,\n\t\tchainId: bigint,\n\t): Promise<string> {\n\t\tconst scheme = pickScheme(signer, BaseSimple7702Account.ACCEPTED_SIGNING_SCHEMES, {\n\t\t\taccountName: \"Simple7702 (EIP-712 typed data or raw ECDSA over userOpHash)\",\n\t\t\tsignerIndex: 0,\n\t\t});\n\t\tconst hash = createUserOperationHash(\n\t\t\tuseroperation,\n\t\t\tthis.entrypointAddress,\n\t\t\tchainId,\n\t\t) as `0x${string}`;\n\t\tconst context: SignContext<T> = {\n\t\t\tuserOperation: useroperation,\n\t\t\tchainId,\n\t\t\tentryPoint: this.entrypointAddress,\n\t\t};\n\t\tconst typedData =\n\t\t\tscheme === \"typedData\"\n\t\t\t\t? BaseSimple7702Account.getUserOperationEip712Data(useroperation, chainId, {\n\t\t\t\t\t\tentrypointAddress: this.entrypointAddress,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\treturn invokeSigner(signer, scheme, { hash, typedData, context });\n\t}\n\n\t/**\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 | Transport | Bundler,\n\t): Promise<SendUseroperationResponse> {\n\t\tconst bundler = Bundler.from(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(sendUserOperationRes, bundler, this.entrypointAddress);\n\t}\n\n\t/**\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\t/**\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(approveFunctionSignature);\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\t\tlet decodedMetaTransactions: SimpleMetaTransaction[];\n\t\tif (callData.startsWith(BaseSimple7702Account.batchExecutorFunctionSelector)) {\n\t\t\tconst decodedParamsArray = decodeAbiParameters<\n\t\t\t\t[Array<[string, bigint, string | Uint8Array]>]\n\t\t\t>(BaseSimple7702Account.batchExecutorFunctionInputAbi, `0x${callData.slice(10)}`)[0];\n\t\t\t// decodeAbiParameters can return the \"bytes\" field as a Uint8Array;\n\t\t\t// UTF-8 decoding would corrupt arbitrary calldata, so hex-encode it.\n\t\t\tdecodedMetaTransactions = decodedParamsArray.map((decodedParams) => ({\n\t\t\t\tto: decodedParams[0],\n\t\t\t\tvalue: BigInt(decodedParams[1]),\n\t\t\t\tdata:\n\t\t\t\t\ttypeof decodedParams[2] === \"string\"\n\t\t\t\t\t\t? decodedParams[2]\n\t\t\t\t\t\t: hexlify(decodedParams[2]),\n\t\t\t}));\n\t\t} else if (callData.startsWith(BaseSimple7702Account.executorFunctionSelector)) {\n\t\t\tconst decodedParams = decodeAbiParameters<[string, bigint, string | Uint8Array]>(\n\t\t\t\tBaseSimple7702Account.executorFunctionInputAbi,\n\t\t\t\t`0x${callData.slice(10)}`,\n\t\t\t);\n\t\t\tdecodedMetaTransactions = [\n\t\t\t\t{\n\t\t\t\t\tto: decodedParams[0],\n\t\t\t\t\tvalue: BigInt(decodedParams[1]),\n\t\t\t\t\tdata:\n\t\t\t\t\t\ttypeof decodedParams[2] === \"string\"\n\t\t\t\t\t\t\t? decodedParams[2]\n\t\t\t\t\t\t\t: hexlify(decodedParams[2]),\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\"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\t\t}\n\t\tdecodedMetaTransactions.unshift(approveMetatransaction);\n\t\treturn BaseSimple7702Account.createAccountCallDataBatchTransactions(decodedMetaTransactions);\n\t}\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\t\toverrides: {\n\t\t\tentrypointAddress?: string;\n\t\t\tdelegateeAddress?: string;\n\t\t} = {},\n\t) {\n\t\tsuper(\n\t\t\taccountAddress,\n\t\t\toverrides.entrypointAddress ?? ENTRYPOINT_V8,\n\t\t\toverrides.delegateeAddress ?? Simple7702Account.DEFAULT_DELEGATEE_ADDRESS,\n\t\t);\n\t}\n\n\t/**\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\tpublic async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV8> {\n\t\treturn this.baseCreateUserOperation(transactions, providerRpc, bundlerRpc, overrides);\n\t}\n\n\t/**\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\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV8,\n\t\tbundlerRpc: string | Transport | Bundler,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn this.baseEstimateUserOperationGas(userOperation, bundlerRpc, overrides);\n\t}\n\n\t/**\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\tpublic signUserOperation(\n\t\tuseroperation: UserOperationV8,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n\t): string {\n\t\treturn this.baseSignUserOperation(useroperation, privateKey, chainId);\n\t}\n\n\t/**\n\t * Sign a {@link UserOperationV8} using an {@link ExternalSigner}. This is\n\t * the recommended entry point for any non-private-key signer.\n\t *\n\t * Accepts signers that implement `signTypedData` (JSON-RPC wallets, viem\n\t * `WalletClient`, browser wallets), `signHash` (local keys, hardware\n\t * wallets), or both. The v0.8 userOpHash IS the EIP-712 digest of the\n\t * PackedUserOperation under the EntryPoint domain, so both schemes\n\t * produce signatures that validate against the same `userOpHash`.\n\t *\n\t * Wrapping a custom signing primitive is just an object literal; no\n\t * adapter function required:\n\t *\n\t * ```ts\n\t * const signer: ExternalSigner = {\n\t *   address: ownerAddress,\n\t *   signTypedData: async (td) => myWallet.signTypedData(td),\n\t * }\n\t * userOp.signature = await account.signUserOperationWithSigner(userOp, signer, chainId)\n\t * ```\n\t *\n\t * For signing with a raw private-key string, use the sync\n\t * {@link signUserOperation} method, or wrap explicitly with\n\t * `fromPrivateKey(pk)`.\n\t *\n\t * @see {@link BaseSimple7702Account.getUserOperationEip712Data} for the\n\t *   lower-level escape hatch when you need the typed data outside the\n\t *   dispatcher (e.g., to render a custom confirmation UI or feed an HSM\n\t *   that doesn't fit the {@link ExternalSigner} shape).\n\t */\n\tpublic async signUserOperationWithSigner(\n\t\tuseroperation: UserOperationV8,\n\t\tsigner: ExternalSigner,\n\t\tchainId: bigint,\n\t): Promise<string> {\n\t\treturn this.baseSignUserOperationWithSigner(useroperation, signer, chainId);\n\t}\n\n\t/**\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 | Transport | Bundler,\n\t): Promise<SendUseroperationResponse> {\n\t\treturn this.baseSendUserOperation(userOperation, bundlerRpc);\n\t}\n}\n","import type {Bundler} from \"src/Bundler\";\nimport {ENTRYPOINT_V9} from \"src/constants\";\nimport type {ExternalSigner, TypedData} from \"src/signer/types\";\nimport type {JsonRpcNode, Transport} from \"src/transport\";\nimport type {StateOverrideSet, UserOperationV9} from \"src/types\";\nimport type {SendUseroperationResponse} from \"../SendUseroperationResponse\";\nimport {\n\tBaseSimple7702Account,\n\ttype CreateUserOperationOverrides,\n\ttype SimpleMetaTransaction,\n} from \"./Simple7702Account\";\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 * Build the EIP-712 typed data payload for a {@link UserOperationV9}\n\t * under the EntryPoint v0.9 domain. See\n\t * {@link BaseSimple7702Account.getUserOperationEip712Data} for the\n\t * full semantics; this override just defaults `entrypointAddress` to v0.9.\n\t */\n\tpublic static getUserOperationEip712Data(\n\t\tuserOperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: { entrypointAddress?: string } = {},\n\t): TypedData {\n\t\treturn BaseSimple7702Account.getUserOperationEip712Data(userOperation, chainId, {\n\t\t\tentrypointAddress: overrides.entrypointAddress ?? ENTRYPOINT_V9,\n\t\t});\n\t}\n\n\t/**\n\t * Compute the EIP-712 digest of a {@link UserOperationV9} under the\n\t * EntryPoint v0.9 domain. Defaults `entrypointAddress` to v0.9.\n\t */\n\tpublic static getUserOperationEip712Hash(\n\t\tuserOperation: UserOperationV9,\n\t\tchainId: bigint,\n\t\toverrides: { entrypointAddress?: string } = {},\n\t): string {\n\t\treturn BaseSimple7702Account.getUserOperationEip712Hash(userOperation, chainId, {\n\t\t\tentrypointAddress: overrides.entrypointAddress ?? ENTRYPOINT_V9,\n\t\t});\n\t}\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\t\toverrides: {\n\t\t\tentrypointAddress?: string;\n\t\t\tdelegateeAddress?: string;\n\t\t} = {},\n\t) {\n\t\tsuper(\n\t\t\taccountAddress,\n\t\t\toverrides.entrypointAddress ?? ENTRYPOINT_V9,\n\t\t\toverrides.delegateeAddress ?? Simple7702AccountV09.DEFAULT_DELEGATEE_ADDRESS,\n\t\t);\n\t}\n\n\t/**\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\tpublic async createUserOperation(\n\t\ttransactions: SimpleMetaTransaction[],\n\t\tproviderRpc?: string | Transport | JsonRpcNode,\n\t\tbundlerRpc?: string | Transport | Bundler,\n\t\toverrides: CreateUserOperationOverrides = {},\n\t): Promise<UserOperationV9> {\n\t\treturn this.baseCreateUserOperation(transactions, providerRpc, bundlerRpc, overrides);\n\t}\n\n\t/**\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\tpublic async estimateUserOperationGas(\n\t\tuserOperation: UserOperationV9,\n\t\tbundlerRpc: string | Transport | Bundler,\n\t\toverrides: {\n\t\t\tstateOverrideSet?: StateOverrideSet;\n\t\t\tdummySignature?: string;\n\t\t} = {},\n\t): Promise<[bigint, bigint, bigint]> {\n\t\treturn this.baseEstimateUserOperationGas(userOperation, bundlerRpc, overrides);\n\t}\n\n\t/**\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\tpublic signUserOperation(\n\t\tuseroperation: UserOperationV9,\n\t\tprivateKey: string,\n\t\tchainId: bigint,\n\t): string {\n\t\treturn this.baseSignUserOperation(useroperation, privateKey, chainId);\n\t}\n\n\t/**\n\t * Sign a {@link UserOperationV9} using an {@link ExternalSigner}. This is\n\t * the recommended entry point for any non-private-key signer.\n\t *\n\t * Accepts signers that implement `signTypedData` (JSON-RPC wallets, viem\n\t * `WalletClient`, browser wallets), `signHash` (local keys, hardware\n\t * wallets), or both. The v0.9 userOpHash IS the EIP-712 digest of the\n\t * PackedUserOperation under the EntryPoint domain, so both schemes\n\t * produce signatures that validate against the same `userOpHash`.\n\t *\n\t * Wrapping a custom signing primitive is just an object literal; no\n\t * adapter function required:\n\t *\n\t * ```ts\n\t * const signer: ExternalSigner = {\n\t *   address: ownerAddress,\n\t *   signTypedData: async (td) => myWallet.signTypedData(td),\n\t * }\n\t * userOp.signature = await account.signUserOperationWithSigner(userOp, signer, chainId)\n\t * ```\n\t *\n\t * For signing with a raw private-key string, use the sync\n\t * {@link signUserOperation} method, or wrap explicitly with\n\t * `fromPrivateKey(pk)`.\n\t *\n\t * @see {@link BaseSimple7702Account.getUserOperationEip712Data} for the\n\t *   lower-level escape hatch when you need the typed data outside the\n\t *   dispatcher.\n\t */\n\tpublic async signUserOperationWithSigner(\n\t\tuseroperation: UserOperationV9,\n\t\tsigner: ExternalSigner,\n\t\tchainId: bigint,\n\t): Promise<string> {\n\t\treturn this.baseSignUserOperationWithSigner(useroperation, signer, chainId);\n\t}\n\n\t/**\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 | Transport | Bundler,\n\t): Promise<SendUseroperationResponse> {\n\t\treturn this.baseSendUserOperation(userOperation, bundlerRpc);\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 type { ParallelPaymasterInitValues, UserOperationV9 } from \"../types\";\nimport { Paymaster } from \"./Paymaster\";\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(_chainId: bigint): Promise<ParallelPaymasterInitValues> {\n\t\treturn {\n\t\t\tpaymaster: this.address,\n\t\t\tpaymasterVerificationGasLimit: 45_000n,\n\t\t\tpaymasterPostOpGasLimit: 45_000n,\n\t\t\tpaymasterData:\n\t\t\t\t\"0x010101010101010101010101010101010101010101010101010101010101011c\" +\n\t\t\t\t\"0020\" +\n\t\t\t\t\"22e325a297439656\", // DUMMY SIG + PAYMASTER_SIG_LEN + PAYMASTER_SIG_MAGIC\n\t\t};\n\t}\n\n\t/**\n\t * getApprovedPaymasterData will return a valid paymasterData\n\t * This function is async to simulate a paymaster service\n\t * that requires 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\t\t// the allow all paymaster only checks for this fixed signature\n\t\treturn (\n\t\t\t\"0x7603fbcd3c6cebdb7193b716f62fe7e9d4afd859df4bf7fcdb2e9d486f57a1ca\" +\n\t\t\t\"0020\" + // signature length\n\t\t\t\"22e325a297439656\"\n\t\t); // PAYMASTER_SIG_MAGIC\n\t}\n}\n","import {isAddress} from \"src/ethereUtils\";\nimport {Bundler} from \"src/Bundler\";\nimport {ENTRYPOINT_V6, ENTRYPOINT_V7, ENTRYPOINT_V8} from \"src/constants\";\nimport {AbstractionKitError, ensureError} from \"src/errors\";\nimport {\n\tHttpTransport,\n\tnormalizingTransport,\n\ttype RequestArgs,\n\ttype RequestOptions,\n\ttype Transport,\n} from \"src/transport\";\nimport type {\n\tERC20Token,\n\tERC20TokenWithExchangeRate,\n\tPaymasterMetadata,\n\tPmUserOperationV6Result,\n\tPmUserOperationV7Result,\n\tPmUserOperationV8Result,\n\tSponsorMetadata,\n\tSupportedERC20TokensAndMetadata,\n\tSupportedERC20TokensAndMetadataWithExchangeRate,\n\tTokenQuote,\n} from \"../types\";\nimport {calculateUserOperationMaxGasCost} from \"../utils\";\nimport {Paymaster} from \"./Paymaster\";\nimport type {\n\tAnyUserOperation,\n\tCandidePaymasterContext,\n\tGasPaymasterUserOperationOverrides,\n\tPrependTokenPaymasterApproveAccount,\n\tSameUserOp,\n\tSmartAccountWithEntrypoint,\n} from \"./types\";\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 { userOperation: sponsoredOp } = await paymaster.createSponsorPaymasterUserOperation(userOp, bundlerRpcUrl);\n */\nexport class CandidePaymaster extends Paymaster implements Transport {\n\t/**\n\t * The raw transport the user passed in (or {@link HttpTransport} when a URL\n\t * string was passed). Exposed for introspection — reading `.url`,\n\t * `isHttpTransport(...)` checks, passing it back into another service.\n\t *\n\t * Calls made directly on this field (`paymaster.transport.request(...)`)\n\t * go to the raw transport and skip SDK-level behavior like bigint param\n\t * normalization. For SDK-pipeline behavior, use\n\t * {@link CandidePaymaster.request} or the typed methods.\n\t */\n\treadonly transport: Transport;\n\t/** Normalizing wrapper around {@link transport}, used for every SDK-outbound call. */\n\tprivate readonly outbound: Transport;\n\t/** Cached token/metadata per EntryPoint address (lowercase keys) */\n\tprivate entrypointData = new Map<string, SupportedERC20TokensAndMetadata>();\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/**\n\t * @param rpc - The Candide paymaster JSON-RPC endpoint URL, or any {@link Transport}.\n\t *   When a URL string is passed, the chain id is inferred from the URL path\n\t *   when possible; otherwise it's resolved lazily via `pm_chainId`.\n\t */\n\tconstructor(rpc: string | Transport) {\n\t\tsuper();\n\t\tthis.transport = typeof rpc === \"string\" ? new HttpTransport(rpc) : rpc;\n\t\tthis.outbound = normalizingTransport(this.transport);\n\t\tthis.chainId = typeof rpc === \"string\" ? CandidePaymaster.extractChainIdFromUrl(rpc) : null;\n\t}\n\n\t/**\n\t * Normalize any acceptable input into a `CandidePaymaster`. Returns the\n\t * input by reference when it's already a `CandidePaymaster`.\n\t */\n\tstatic from(input: string | Transport | CandidePaymaster): CandidePaymaster {\n\t\treturn input instanceof CandidePaymaster ? input : new CandidePaymaster(input);\n\t}\n\n\t/**\n\t * Transport delegate. Forwards directly to {@link Transport.request}, so a\n\t * `CandidePaymaster` can be slotted into any other transport position.\n\t */\n\trequest<T = unknown>(args: RequestArgs, options?: RequestOptions): Promise<T> {\n\t\treturn this.outbound.request<T>(args, options);\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(/api\\.candide\\.dev\\/(?:api|public)\\/v\\d+\\/(\\d+)(?:\\/|$)/);\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()\n\t\t\t\t.then((id) => {\n\t\t\t\t\tthis.chainId = id;\n\t\t\t\t\treturn id;\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tthis.chainIdPromise = null;\n\t\t\t\t\tthrow err;\n\t\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 this.outbound.request<string>({ method: \"pm_chainId\" });\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\t\t\tthrow new AbstractionKitError(\"PAYMASTER_ERROR\", \"pm_chainId failed\", { cause: error });\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(entrypoint: string): 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: {\n\t\t\tname: string;\n\t\t\tsymbol: string;\n\t\t\taddress: string;\n\t\t\tdecimals: number | string;\n\t\t\texchangeRate: string | bigint;\n\t\t}[],\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(metadata: PaymasterMetadata): 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(\n\t\t\t\t\t\tmetadata.dummyPaymasterAndData.paymasterVerificationGasLimit,\n\t\t\t\t\t),\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(\"PAYMASTER_ERROR\", \"failed initializing the paymaster\", {\n\t\t\t\tcause: error,\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(\"PAYMASTER_ERROR\", \"fetchAndTransformTokenData failed\", {\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async fetchSupportedTokensRpc(entrypoint: string): Promise<unknown> {\n\t\treturn await this.outbound.request({\n\t\t\tmethod: \"pm_supportedERC20Tokens\",\n\t\t\tparams: [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 this.outbound.request<string[]>({\n\t\t\t\tmethod: \"pm_supportedEntryPoints\",\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\"PAYMASTER_ERROR\", \"pm_supportedEntryPoints failed\", {\n\t\t\t\tcause: error,\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(entrypoint: string): 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(erc20TokenAddress, entrypoint);\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) => token.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<typeof dummyPaymasterAndData, string>;\n\t\t\tuserOp.paymaster = structured.paymaster;\n\t\t\tuserOp.paymasterVerificationGasLimit = structured.paymasterVerificationGasLimit;\n\t\t\tuserOp.paymasterPostOpGasLimit = structured.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 | Transport | Bundler,\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 = Bundler.from(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 =\n\t\t\toverrides.preVerificationGas ??\n\t\t\tapplyMultiplier(preVerificationGas, overrides.preVerificationGasPercentageMultiplier ?? 5);\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(callGasLimit, overrides.callGasLimitPercentageMultiplier ?? 10);\n\n\t\t// Lowercase compare — the entrypoint comes from arbitrary user input\n\t\t// and ENTRYPOINT_V6 is checksummed. Skip the buffer when the caller\n\t\t// pinned verificationGasLimit explicitly: the override is documented\n\t\t// to be used verbatim.\n\t\tif (\n\t\t\toverrides.verificationGasLimit == null &&\n\t\t\tentrypoint.toLowerCase() === ENTRYPOINT_V6.toLowerCase()\n\t\t) {\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\t// ERC-7677 returns sponsor info under `sponsor: { name, icon? }` (singular `icon`).\n\t\t// Normalize into the public `SponsorMetadata` shape.\n\t\tif (result.sponsor?.name != null) {\n\t\t\tconst { name, icon } = result.sponsor;\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\tdescription: \"\",\n\t\t\t\turl: \"\",\n\t\t\t\ticons: icon ? [icon] : [],\n\t\t\t};\n\t\t}\n\t\treturn 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<{ userOperation: SameUserOp<T>; sponsorMetadata?: SponsorMetadata }> {\n\t\ttry {\n\t\t\tconst entrypoint =\n\t\t\t\toverrides.entrypoint ?? this.resolveEntrypoint(smartAccount, userOperation);\n\t\t\tconst chainId = await this.getChainId();\n\t\t\tconst jsonRpcResult = await this.outbound.request<unknown>({\n\t\t\t\tmethod: \"pm_getPaymasterData\",\n\t\t\t\tparams: [userOperation, entrypoint, chainId, context],\n\t\t\t});\n\t\t\tconst sponsorMetadata = this.applyPaymasterResult(userOperation, jsonRpcResult);\n\t\t\treturn {\n\t\t\t\tuserOperation: userOperation as unknown as SameUserOp<T>,\n\t\t\t\tsponsorMetadata,\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\t\t\tthrow new AbstractionKitError(\"PAYMASTER_ERROR\", \"pm_getPaymasterData failed\", {\n\t\t\t\tcause: error,\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 context - Optional additional context to pass to the paymaster RPC\n\t * @param overrides - Override gas limits and multipliers\n\t * @returns An object `{ userOperation, sponsorMetadata? }`\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 | Transport | Bundler,\n\t\tsponsorshipPolicyId?: string,\n\t\tcontext?: CandidePaymasterContext,\n\t\toverrides?: GasPaymasterUserOperationOverrides,\n\t): Promise<{ userOperation: SameUserOp<T>; sponsorMetadata?: SponsorMetadata }> {\n\t\tconst userOp = { ...userOperation } as T;\n\t\tcontext = {\n\t\t\t...(context || {}),\n\t\t\t...(sponsorshipPolicyId !== undefined ? { sponsorshipPolicyId } : {}),\n\t\t};\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(`UserOperation for entrypoint ${entrypoint} is not supported`);\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 || {}), entrypoint: entrypoint };\n\t\treturn await this.createPaymasterUserOperation(smartAccount, userOp, context, _overrides);\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 context - Optional additional context to pass to the paymaster RPC\n\t * @param overrides - Override gas limits and multipliers\n\t * @returns An object `{ userOperation, tokenQuote? }`. `tokenQuote` is absent\n\t *   when called under the `finalize` signing phase (no cost recomputation).\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 | Transport | Bundler,\n\t\tcontext?: CandidePaymasterContext,\n\t\toverrides?: GasPaymasterUserOperationOverrides,\n\t): Promise<{ userOperation: SameUserOp<T>; tokenQuote?: TokenQuote }> {\n\t\ttry {\n\t\t\tconst userOp = { ...userOperation } as T;\n\t\t\tcontext = {\n\t\t\t\t...(context || {}),\n\t\t\t\ttoken: tokenAddress,\n\t\t\t};\n\t\t\tif (!context.token || context.token.trim().length === 0 || !isAddress(context.token)) {\n\t\t\t\tthrow new RangeError(`Invalid token ${context.token ?? \"undefined\"}`);\n\t\t\t}\n\t\t\tconst entrypoint = overrides?.entrypoint ?? this.resolveEntrypoint(smartAccount, userOp);\n\t\t\tawait this.ensureInitialized(entrypoint);\n\t\t\tlet tokenQuote: TokenQuote | undefined;\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(`UserOperation for entrypoint ${entrypoint} is not supported`);\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 gas; a proper\n\t\t\t\t// allowance is calculated later and replaces the infinite one.\n\t\t\t\tconst oldCallData = userOp.callData;\n\t\t\t\tconst requiresAllowanceReset =\n\t\t\t\t\toverrides?.resetApproval ??\n\t\t\t\t\tTOKENS_REQUIRING_ALLOWANCE_RESET.includes(context.token.toLowerCase());\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 exchangeRate = await this.fetchTokenPaymasterExchangeRate(context.token, entrypoint);\n\t\t\t\tconst gasCostWei = calculateUserOperationMaxGasCost(userOp);\n\t\t\t\tlet tokenCost = (exchangeRate * gasCostWei) / 10n ** 18n;\n\t\t\t\tif (tokenCost === 0n) tokenCost = 1n;\n\t\t\t\ttokenQuote = { token: context.token, exchangeRate, tokenCost };\n\t\t\t\tconst approveAmount = tokenCost * 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 || {}), entrypoint: entrypoint };\n\t\t\tconst { userOperation: 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 { userOperation: resultUserOp, tokenQuote };\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\"PAYMASTER_ERROR\", \"createTokenPaymasterUserOperation failed\", {\n\t\t\t\tcause: error,\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 =\n\t\t\t\toverrides.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\tconst tokenCost = (exchangeRate * cost) / 10n ** 18n;\n\t\t\treturn tokenCost === 0n ? 1n : tokenCost;\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(\n\t\t\t\tentrypoint,\n\t\t\t)) as SupportedERC20TokensAndMetadataWithExchangeRate;\n\n\t\t\tconst gasToken = jsonRpcResult.tokens.find(\n\t\t\t\t(token) => token.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\t`${erc20TokenAddress} 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}\n\t\t\tconst exchangeRate = BigInt(gasToken.exchangeRate);\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`pm_supportedERC20Tokens returned a non-positive exchangeRate for token ${erc20TokenAddress} (got ${exchangeRate})`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn exchangeRate;\n\t\t} catch (err) {\n\t\t\tconst error = ensureError(err);\n\n\t\t\tthrow new AbstractionKitError(\"PAYMASTER_ERROR\", \"fetchTokenPaymasterExchangeRate failed\", {\n\t\t\t\tcause: error,\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(\n\t\t\t\tentrypoint,\n\t\t\t)) as SupportedERC20TokensAndMetadataWithExchangeRate;\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 {Bundler} from \"../Bundler\";\nimport {ENTRYPOINT_V6, ENTRYPOINT_V7, ENTRYPOINT_V8, ENTRYPOINT_V9} from \"../constants\";\nimport {AbstractionKitError, ensureError} from \"../errors\";\nimport {\n\tHttpTransport,\n\tnormalizingTransport,\n\ttype RequestArgs,\n\ttype RequestOptions,\n\ttype Transport,\n} from \"../transport\";\nimport type {StateOverrideSet, TokenQuote} from \"../types\";\nimport {calculateUserOperationMaxGasCost} from \"../utils\";\nimport {Paymaster} from \"./Paymaster\";\nimport type {\n\tAnyUserOperation,\n\tErc7677PaymasterConstructorOptions,\n\tErc7677Provider,\n\tGasPaymasterUserOperationOverrides,\n\tPrependTokenPaymasterApproveAccount,\n\tSameUserOp,\n\tSmartAccountWithEntrypoint,\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 * Parse a raw exchange-rate value (bigint or hex/decimal string) into a\n * positive bigint. Returns `null` if the value is missing, unparseable, or\n * `<= 0` — callers throw with their own RPC-method-specific error context.\n */\nfunction parsePositiveExchangeRate(raw: string | bigint | undefined | null): bigint | null {\n\tif (raw == null) return null;\n\tlet value: bigint;\n\ttry {\n\t\tvalue = BigInt(raw);\n\t} catch {\n\t\treturn null;\n\t}\n\treturn value > 0n ? value : null;\n}\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 * ## Fields consumed by this class\n *\n * The whole context object — including the fields below — is forwarded to the\n * RPC verbatim; providers ignore keys they don't recognize. The fields listed\n * here are additionally interpreted by this class:\n *\n * - `exchangeRate` - token-to-ETH exchange rate as a bigint or hex/decimal\n *   string. Represents the count of token smallest-units equivalent to 1 ETH\n *   (10^18 wei) — e.g. for USDC ($1, 6 decimals) at $3000/ETH this is\n *   `3000 * 10^6 = 3e9`. Used to calculate the ERC-20 approval amount when no\n *   provider is auto-detected (floored to a minimum of 1 token smallest-unit\n *   to handle cheap-gas chains). Not needed when `provider` is `\"pimlico\"` or\n *   `\"candide\"`; the class fetches the rate from the provider's RPC.\n * - `paymasterAddress` - overrides the token-flow paymaster address when it\n *   cannot be derived from the stub data or a provider 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 the class runs the token paymaster pipeline.\n * Once the pipeline engages (a provider is detected or an exchange rate is\n * available) the smart account must implement\n * `prependTokenPaymasterApproveToCallData`, otherwise a PAYMASTER_ERROR is\n * thrown:\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 { userOperation: 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 { userOperation: tokenOp, tokenQuote } = 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 { userOperation: tokenOp, tokenQuote } = 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\t\tpaymaster: string;\n\t\t\t\t\tpaymasterVerificationGasLimit: string;\n\t\t\t\t\tpaymasterPostOpGasLimit: string;\n\t\t\t\t\tpaymasterData: string;\n\t\t\t  };\n\t};\n}\n\nexport class Erc7677Paymaster extends Paymaster implements Transport {\n\t/**\n\t * The raw transport the user passed in (or {@link HttpTransport} when a URL\n\t * string was passed). Exposed for introspection — reading `.url`,\n\t * `isHttpTransport(...)` checks, passing it back into another service.\n\t *\n\t * Calls made directly on this field (`paymaster.transport.request(...)`)\n\t * go to the raw transport and skip SDK-level behavior like bigint param\n\t * normalization. For SDK-pipeline behavior, use\n\t * {@link Erc7677Paymaster.request} or the typed methods.\n\t */\n\treadonly transport: Transport;\n\t/** Normalizing wrapper around {@link transport}, used for every SDK-outbound call. */\n\tprivate readonly outbound: Transport;\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 rpc - Paymaster JSON-RPC endpoint URL, or any {@link Transport}.\n\t *   Can be the same URL as the bundler when the provider bundles both\n\t *   (Candide, Pimlico, Alchemy); can also be a separate paymaster-only\n\t *   endpoint, or a fully custom transport.\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 (only when a URL string is passed; non-string inputs\n\t *   default to `null` unless overridden here). Set explicitly to override,\n\t *   or `null` to disable provider-specific features.\n\t */\n\tconstructor(rpc: string | Transport, options: Erc7677PaymasterConstructorOptions = {}) {\n\t\tsuper();\n\t\tthis.transport = typeof rpc === \"string\" ? new HttpTransport(rpc) : rpc;\n\t\tthis.outbound = normalizingTransport(this.transport);\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\t// Provider auto-detection only fires when input is a string (we have a URL to inspect).\n\t\t\tthis.provider = typeof rpc === \"string\" ? Erc7677Paymaster.detectProvider(rpc) : null;\n\t\t} else {\n\t\t\tthis.provider = options.provider;\n\t\t}\n\t}\n\n\t/**\n\t * Normalize any acceptable input into an `Erc7677Paymaster`. Returns the\n\t * input by reference when it's already an `Erc7677Paymaster` (in which\n\t * case the second `options` argument is ignored — the existing instance's\n\t * configuration is preserved).\n\t */\n\tstatic from(\n\t\tinput: string | Transport | Erc7677Paymaster,\n\t\toptions?: Erc7677PaymasterConstructorOptions,\n\t): Erc7677Paymaster {\n\t\treturn input instanceof Erc7677Paymaster ? input : new Erc7677Paymaster(input, options);\n\t}\n\n\t/**\n\t * Transport delegate. Forwards directly to {@link Transport.request}, so\n\t * an `Erc7677Paymaster` can be slotted into any other transport position.\n\t */\n\trequest<T = unknown>(args: RequestArgs, options?: RequestOptions): Promise<T> {\n\t\treturn this.outbound.request<T>(args, options);\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 | Transport | Bundler): Promise<string> {\n\t\tif (this.chainId != null) return this.chainId;\n\t\tconst id = await Bundler.from(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 (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\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 this.outbound.request<unknown>({\n\t\t\t\tmethod: \"pm_getPaymasterStubData\",\n\t\t\t\tparams: [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(\"PAYMASTER_ERROR\", \"pm_getPaymasterStubData failed\", {\n\t\t\t\tcause: 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 this.outbound.request<unknown>({\n\t\t\t\tmethod: \"pm_getPaymasterData\",\n\t\t\t\tparams: [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(\"PAYMASTER_ERROR\", \"pm_getPaymasterData failed\", {\n\t\t\t\tcause: 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(method: string, params: unknown[] = []): Promise<unknown> {\n\t\ttry {\n\t\t\treturn await this.outbound.request<unknown>({ method, params });\n\t\t} catch (err) {\n\t\t\tthrow new AbstractionKitError(\"PAYMASTER_ERROR\", `sendRPCRequest(${method}) failed`, {\n\t\t\t\tcause: 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 An object `{ userOperation, tokenQuote? }`. `tokenQuote` is only\n\t *   populated when the token-payment flow is taken (`context.token` set).\n\t */\n\tasync createPaymasterUserOperation<T extends AnyUserOperation>(\n\t\tsmartAccount: SmartAccountWithEntrypoint,\n\t\tuserOperation: T,\n\t\tbundlerRpc: string | Transport | Bundler,\n\t\tcontext: Erc7677Context = {},\n\t\toverrides: GasPaymasterUserOperationOverrides = {},\n\t): Promise<{ userOperation: SameUserOp<T>; tokenQuote?: TokenQuote }> {\n\t\ttry {\n\t\t\tconst userOp = { ...userOperation } as T;\n\t\t\tconst entrypoint = overrides.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 (context.token != null && typeof context.token === \"string\") {\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(userOp, bundlerRpc, entrypoint, chainIdHex, context, overrides);\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(\"PAYMASTER_ERROR\", \"createPaymasterUserOperation failed\", {\n\t\t\t\tcause: 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(userOp: AnyUserOperation, fields: Erc7677PaymasterFields): 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(fields.paymasterVerificationGasLimit);\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 | Transport | Bundler,\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 = Bundler.from(bundlerRpc);\n\t\t\tuserOp.callGasLimit = 0n;\n\t\t\tuserOp.verificationGasLimit = 0n;\n\t\t\tuserOp.preVerificationGas = 0n;\n\t\t\t// Zero fees during estimation (same pattern as CandidePaymaster):\n\t\t\t// some bundlers reject estimation if the sender can't cover the\n\t\t\t// set fees. Exception: Pimlico's paymaster postOp divides by fee\n\t\t\t// and reverts \"AA50 postOp reverted: divide by zero\" on fee=0, so\n\t\t\t// pass its 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 (\"paymaster\" in userOp && estimation.paymasterVerificationGasLimit != null) {\n\t\t\t\tuserOp.paymasterVerificationGasLimit = estimation.paymasterVerificationGasLimit;\n\t\t\t}\n\t\t\tif (\"paymaster\" in userOp && estimation.paymasterPostOpGasLimit != null) {\n\t\t\t\tuserOp.paymasterPostOpGasLimit = estimation.paymasterPostOpGasLimit;\n\t\t\t}\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 =\n\t\t\toverrides.preVerificationGas ??\n\t\t\tapplyMultiplier(preVerificationGas, overrides.preVerificationGasPercentageMultiplier ?? 5);\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(callGasLimit, overrides.callGasLimitPercentageMultiplier ?? 10);\n\n\t\t// Skip the buffer when the caller pinned verificationGasLimit\n\t\t// explicitly: the override is documented to be used verbatim.\n\t\tif (\n\t\t\toverrides.verificationGasLimit == null &&\n\t\t\tentrypoint.toLowerCase() === ENTRYPOINT_V6.toLowerCase()\n\t\t) {\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: the count of token smallest-units\n\t *   equivalent to 1 ETH (10^18 wei). E.g. for USDC ($1, 6 decimals) at\n\t *   $3000/ETH this is `3000 * 10^6 = 3e9`. Used to compute the token\n\t *   approval amount via `(exchangeRate * gasCostWei) / 10^18`, floored to\n\t *   a minimum of 1 token smallest-unit (see\n\t *   {@link Erc7677Paymaster.tokenFlow}).\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 this.outbound.request<unknown>({\n\t\t\tmethod: \"pimlico_getTokenQuotes\",\n\t\t\tparams: [{ 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((q) => q.token.toLowerCase() === tokenAddress.toLowerCase());\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\tconst exchangeRate = parsePositiveExchangeRate(quote.exchangeRate);\n\t\tif (exchangeRate == null) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t`pimlico_getTokenQuotes returned a non-positive exchangeRate for token ${tokenAddress} (got ${String(quote.exchangeRate)})`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\texchangeRate,\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 =\n\t\t\tcached != null &&\n\t\t\toptions.enforceTTL === true &&\n\t\t\tDate.now() - cached.fetchedAt > CANDIDE_TOKEN_QUOTE_TTL_MS;\n\t\tif (cached != null && !isStale) return cached.data;\n\t\tconst result = (await this.outbound.request<unknown>({\n\t\t\tmethod: \"pm_supportedERC20Tokens\",\n\t\t\tparams: [entrypoint],\n\t\t})) 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: the count of token smallest-units\n\t *   equivalent to 1 ETH (10^18 wei). E.g. for USDC ($1, 6 decimals) at\n\t *   $3000/ETH this is `3000 * 10^6 = 3e9`. Used to compute the token\n\t *   approval amount via `(exchangeRate * gasCostWei) / 10^18`, floored to\n\t *   a minimum of 1 token smallest-unit (see\n\t *   {@link Erc7677Paymaster.tokenFlow}).\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\tconst exchangeRate = parsePositiveExchangeRate(token.exchangeRate);\n\t\tif (exchangeRate == null) {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t`pm_supportedERC20Tokens returned a non-positive exchangeRate for token ${tokenAddress} (got ${String(token.exchangeRate)})`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\texchangeRate,\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 | Transport | Bundler,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t\tcontext: Erc7677Context,\n\t\toverrides: GasPaymasterUserOperationOverrides,\n\t): Promise<{ userOperation: SameUserOp<T>; tokenQuote?: TokenQuote }> {\n\t\t// Case C: no provider, no exchangeRate — fall through to regular flow.\n\t\tif (this.provider == null && context.exchangeRate == null) {\n\t\t\treturn this.sponsoredFlow(userOp, bundlerRpc, entrypoint, chainIdHex, context, overrides);\n\t\t}\n\n\t\t// The flow below always prepends an approval, so verify the account\n\t\t// supports it before spending a provider round-trip on the quote.\n\t\tif (typeof smartAccount.prependTokenPaymasterApproveToCallData !== \"function\") {\n\t\t\tthrow new AbstractionKitError(\n\t\t\t\t\"PAYMASTER_ERROR\",\n\t\t\t\t\"context.token is set but this smart account does not implement \" +\n\t\t\t\t\t\"prependTokenPaymasterApproveToCallData, which the token \" +\n\t\t\t\t\t\"paymaster flow requires to prepend the ERC-20 approval.\",\n\t\t\t);\n\t\t}\n\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(tokenAddress, entrypoint, chainIdHex);\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// Unreachable: the Case C guard above already returned. Kept for\n\t\t\t// definite assignment of exchangeRate.\n\t\t\treturn this.sponsoredFlow(userOp, bundlerRpc, entrypoint, chainIdHex, context, overrides);\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(userOp, entrypoint, chainIdHex, context);\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\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 =\n\t\t\toverrides.resetApproval ??\n\t\t\tTOKENS_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\tlet tokenCost = (exchangeRate * maxGasCostWei) / 10n ** 18n;\n\t\tif (tokenCost === 0n) tokenCost = 1n;\n\t\tconst approveAmount = tokenCost * TOKEN_APPROVE_AMOUNT_MULTIPLIER;\n\t\tconst tokenQuote: TokenQuote = { token: tokenAddress, exchangeRate, tokenCost };\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. The token flow always refetches:\n\t\t// callData was mutated after the stub, so any stub `isFinal` signature\n\t\t// would be over a different UserOp hash.\n\t\tconst final = await this.getPaymasterData(userOp, entrypoint, chainIdHex, context);\n\t\tthis.applyPaymasterFields(userOp, final);\n\n\t\treturn { userOperation: userOp as unknown as SameUserOp<T>, tokenQuote };\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 | Transport | Bundler,\n\t\tentrypoint: string,\n\t\tchainIdHex: string,\n\t\tcontext: Erc7677Context,\n\t\toverrides: GasPaymasterUserOperationOverrides,\n\t): Promise<{ userOperation: 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(userOp, entrypoint, chainIdHex, context);\n\t\tthis.applyPaymasterFields(userOp, stub);\n\n\t\t// Step 2 — gas estimation with the stub paymaster applied.\n\t\tawait this.estimateAndApplyGasLimits(userOp, bundlerRpc, entrypoint, overrides);\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 { userOperation: 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(userOp, entrypoint, chainIdHex, context);\n\t\tthis.applyPaymasterFields(userOp, final);\n\n\t\treturn { userOperation: userOp as unknown as SameUserOp<T> };\n\t}\n}\n","import {encodeAbiParameters, keccak256, solidityPacked} from \"src/ethereUtils\";\nimport {Bundler} from \"src/Bundler\";\nimport {ENTRYPOINT_V7, ENTRYPOINT_V8} from \"src/constants\";\nimport type {Transport} from \"src/transport\";\nimport type {StateOverrideSet, UserOperationV7, UserOperationV8} from \"../types\";\nimport {Paymaster} from \"./Paymaster\";\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. Its\n\t * verificationGasLimit and callGasLimit are trusted as prior estimates\n\t * (e.g. from createUserOperation) and reused during re-estimation;\n\t * only preVerificationGas is always re-estimated.\n\t * @param bundlerRpc - Bundler endpoint rpc url\n\t * @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\t\tbundlerRpc: string | Transport | Bundler,\n\t\tnullifierHash: bigint,\n\t\troot: bigint,\n\t\tproof: string,\n\t\toverrides?: {\n\t\t\t/** set the entrypoint address instead of determining it from the useroperation structure. */\n\t\t\tentrypoint?: string;\n\n\t\t\t/** pass some state overrides for gas estimation */\n\t\t\tstate_override_set?: StateOverrideSet;\n\t\t},\n\t): Promise<UserOperationV8>;\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV7,\n\t\tbundlerRpc: string | Transport | Bundler,\n\t\tnullifierHash: bigint,\n\t\troot: bigint,\n\t\tproof: string,\n\t\toverrides?: {\n\t\t\t/** set the entrypoint address instead of determining it from the useroperation structure. */\n\t\t\tentrypoint?: string;\n\n\t\t\t/** pass some state overrides for gas estimation */\n\t\t\tstate_override_set?: StateOverrideSet;\n\t\t},\n\t): Promise<UserOperationV7>;\n\tasync createPaymasterUserOperation(\n\t\tuserOperation: UserOperationV8 | UserOperationV7,\n\t\tbundlerRpc: string | Transport | Bundler,\n\t\tnullifierHash: bigint,\n\t\troot: bigint,\n\t\tproof: string,\n\t\toverrides?: {\n\t\t\t/** set the entrypoint address instead of determining it from the useroperation structure. */\n\t\t\tentrypoint?: string;\n\t\t\t/** pass some state overrides for gas estimation */\n\t\t\tstate_override_set?: StateOverrideSet;\n\t\t},\n\t): Promise<UserOperationV8 | UserOperationV7> {\n\t\t//256 bytes for proof\n\t\tif (proof.slice(0, 2) !== \"0x\" || proof.length !== 514) {\n\t\t\tthrow new RangeError(\"Invalid proof.\");\n\t\t}\n\n\t\tproof = proof.slice(2);\n\t\tconst proofArr = [\n\t\t\t`0x${proof.slice(0, 64)}`,\n\t\t\t`0x${proof.slice(64, 128)}`,\n\t\t\t`0x${proof.slice(128, 192)}`,\n\t\t\t`0x${proof.slice(192, 256)}`,\n\t\t\t`0x${proof.slice(256, 320)}`,\n\t\t\t`0x${proof.slice(320, 384)}`,\n\t\t\t`0x${proof.slice(384, 448)}`,\n\t\t\t`0x${proof.slice(448, 512)}`,\n\t\t];\n\n\t\tconst paymasterData =\n\t\t\tencodeAbiParameters([\"uint256\"], [root]) +\n\t\t\tencodeAbiParameters([\"uint256\"], [nullifierHash]).slice(2) +\n\t\t\tencodeAbiParameters([\"uint256[8]\"], [proofArr]).slice(2);\n\n\t\t// work on a shallow copy so the caller's userOperation is not mutated\n\t\t// (and not left corrupted if estimation throws below)\n\t\tconst userOp: UserOperationV8 | UserOperationV7 = { ...userOperation };\n\t\tuserOp.paymaster = this.address;\n\t\tuserOp.paymasterData = paymasterData;\n\t\tuserOp.paymasterPostOpGasLimit = 45_000n;\n\t\tuserOp.paymasterVerificationGasLimit = 350_000n;\n\n\t\tif (overrides == null) {\n\t\t\toverrides = {};\n\t\t}\n\t\tlet entrypointAddress = overrides.entrypoint;\n\n\t\tif (entrypointAddress == null) {\n\t\t\tif (\"eip7702Auth\" in userOp) {\n\t\t\t\tentrypointAddress = ENTRYPOINT_V8;\n\t\t\t} else {\n\t\t\t\tentrypointAddress = ENTRYPOINT_V7;\n\t\t\t}\n\t\t}\n\n\t\tlet preVerificationGas = userOp.preVerificationGas;\n\t\tlet verificationGasLimit = userOp.verificationGasLimit;\n\t\tlet callGasLimit = userOp.callGasLimit;\n\n\t\t// Zero only preVerificationGas: the paymaster fields added above grow\n\t\t// the calldata, so pvg must be re-estimated. verificationGasLimit and\n\t\t// callGasLimit are paymaster-independent on v0.7+ (paymaster\n\t\t// validation has its own gas field), so the supplied values are\n\t\t// trusted as prior estimates and passed through — bundlers that skip\n\t\t// estimating supplied fields answer faster. This assumes the caller's\n\t\t// op carries real estimates (e.g. from createUserOperation).\n\t\tuserOp.preVerificationGas = 0n;\n\n\t\tconst bundler = Bundler.from(bundlerRpc);\n\t\tconst estimation = await bundler.estimateUserOperationGas(\n\t\t\tuserOp,\n\t\t\tentrypointAddress as string,\n\t\t\toverrides.state_override_set,\n\t\t);\n\n\t\t// only change gas limits if the estimated limits is higher than\n\t\t// the supplied\n\t\tif (preVerificationGas < estimation.preVerificationGas) {\n\t\t\tpreVerificationGas = estimation.preVerificationGas;\n\t\t}\n\t\tif (verificationGasLimit < estimation.verificationGasLimit) {\n\t\t\tverificationGasLimit = estimation.verificationGasLimit;\n\t\t}\n\t\tif (callGasLimit < estimation.callGasLimit) {\n\t\t\tcallGasLimit = estimation.callGasLimit;\n\t\t}\n\n\t\tuserOp.preVerificationGas = preVerificationGas;\n\t\tuserOp.verificationGasLimit = verificationGasLimit;\n\t\tuserOp.callGasLimit = callGasLimit;\n\n\t\treturn userOp;\n\t}\n}\n\n/**\n * Build the signal parameter expected by `@worldcoin/idkit`'s `IDKitWidget`.\n * Binds the proof to a specific account, nonce, and chain.\n * @param accountAddress - account address\n * @param accountNonce - account nonce\n * @param chainId - chain id\n * @returns keccak256 hash to use as the `signal` for IDKitWidget\n */\nexport function createWorldIdSignal(\n\taccountAddress: string,\n\taccountNonce: bigint,\n\tchainId: bigint,\n): string {\n\treturn keccak256(\n\t\tsolidityPacked([\"address\", \"uint256\", \"uint256\"], [accountAddress, accountNonce, chainId]),\n\t);\n}\n","import { fromUtf8Bytes, getBytes, hexlify, toUtf8Bytes } from \"../../ethereUtils\";\nimport type { ExternalSigner } from \"src/signer/types\";\nimport { SafeAccount } from \"./SafeAccount\";\nimport type { WebauthnPublicKey, WebauthnSignatureData } from \"./types\";\n\n/**\n * Caller-supplied callback that runs the WebAuthn assertion ceremony for a\n * given challenge and returns the structured fields needed to encode a\n * Safe contract signature. The SDK passes the SafeOp digest as the\n * `challenge` so the authenticator signs over the same bytes Safe will\n * verify on-chain.\n *\n * Implementations typically wrap `navigator.credentials.get(...)` in\n * browsers, or an equivalent HSM/native bridge in other environments. The\n * SDK doesn't import `navigator` itself, so the adapter stays\n * environment-agnostic.\n */\nexport type WebauthnAssertionFetcher = (\n\tchallenge: Uint8Array,\n) => Promise<WebauthnSignatureData>;\n\n/** Parameters for {@link fromSafeWebauthn}. */\nexport interface FromSafeWebauthnParams {\n\t/** WebAuthn public key (P-256 x/y coordinates) backing this signer. */\n\tpublicKey: WebauthnPublicKey;\n\t/**\n\t * Whether the UserOperation is the account's first one. When `true`, the\n\t * signer's address is the WebAuthn shared signer (because the per-owner\n\t * verifier proxy isn't deployed yet); when `false`, it's the\n\t * deterministic verifier proxy address derived from `publicKey`.\n\t * Typically computed by the caller as `userOperation.nonce === 0n`.\n\t */\n\tisInit: boolean;\n\t/** Async callback that runs the WebAuthn ceremony for the SafeOp digest. */\n\tgetAssertion: WebauthnAssertionFetcher;\n\t/**\n\t * Account class whose `DEFAULT_WEB_AUTHN_*` statics source the adapter's\n\t * defaults. Required: address derivation depends on Safe Passkey module\n\t * version (v0.2.0 ships FCL P256, v0.2.1 ships Daimo P256 + RIP-7951\n\t * precompile) and the wrong choice produces a signer address that isn't\n\t * an on-chain owner, surfacing as a generic \"Invalid UserOp signature\"\n\t * (`GS026` on-chain) with no offline diagnostic. Pass the same class you\n\t * passed to `initializeNewAccount` — `SafeAccountV0_2_0` /\n\t * `SafeAccountV0_3_0` for v0.2.0, or `SafeMultiChainSigAccountV1` for\n\t * v0.2.1.\n\t *\n\t * Typed against just the static surface the adapter reads (not\n\t * `typeof SafeAccount`) because Safe subclass constructors take fewer\n\t * positional args than the base class — `typeof SafeAccountV0_3_0` is\n\t * not assignable to `typeof SafeAccount`.\n\t */\n\taccountClass: Pick<\n\t\ttypeof SafeAccount,\n\t\t| \"DEFAULT_WEB_AUTHN_SHARED_SIGNER\"\n\t\t| \"DEFAULT_WEB_AUTHN_SIGNER_FACTORY\"\n\t\t| \"DEFAULT_WEB_AUTHN_SIGNER_SINGLETON\"\n\t\t| \"DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE\"\n\t\t| \"DEFAULT_WEB_AUTHN_PRECOMPILE\"\n\t\t| \"DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER\"\n\t>;\n\t/** Override the WebAuthn shared signer address used when `isInit`. Must match the value passed to `initializeNewAccount`. */\n\twebAuthnSharedSigner?: string;\n\t/** Override the WebAuthn signer factory used to derive the verifier proxy. Must match the value passed to `initializeNewAccount`. */\n\twebAuthnSignerFactory?: string;\n\t/** Override the WebAuthn signer singleton used to derive the verifier proxy. Must match the value passed to `initializeNewAccount`. */\n\twebAuthnSignerSingleton?: string;\n\t/** Override the WebAuthn signer proxy creation code used in the address derivation. Must match the value passed to `initializeNewAccount`. */\n\twebAuthnSignerProxyCreationCode?: string;\n\t/** Override the EIP-7212 precompile verifier used in the address derivation. Must match the value passed to `initializeNewAccount`. */\n\teip7212WebAuthnPrecompileVerifier?: string;\n\t/** Override the EIP-7212 contract verifier used in the address derivation. Must match the value passed to `initializeNewAccount`. */\n\teip7212WebAuthnContractVerifier?: string;\n}\n\n/**\n * Adapt a WebAuthn credential to an ExternalSigner for `signUserOperationWithSigners`\n * on Safe accounts. Safe-specific (uses Safe's WebAuthn shared signer /\n * verifier proxy / signature encoding) — for non-Safe accounts, use the\n * account's own WebAuthn adapter.\n *\n * Hides the address routing (shared signer for the init UserOp, per-owner\n * verifier proxy after that), the `type: \"contract\"` tag, and the\n * Safe-specific signature encoding. The caller supplies a\n * {@link FromSafeWebauthnParams.getAssertion} callback that runs the\n * actual WebAuthn ceremony — this is where you call\n * `navigator.credentials.get(...)` (browser) or an equivalent native\n * bridge, since the SDK doesn't import `navigator` itself.\n *\n * Only `signHash` is exposed: WebAuthn signs a flat challenge, so a typed-data\n * preview would never reach the authenticator anyway.\n *\n * **Override consistency.** Pass the same `accountClass` you passed to\n * `initializeNewAccount` so the adapter sources the right Safe Passkey\n * module defaults — v0.2.0 / FCL P256 for `SafeAccount` / `SafeAccountV0_2_0`\n * / `SafeAccountV0_3_0`, v0.2.1 / Daimo P256 + RIP-7951 for\n * `SafeMultiChainSigAccountV1`. Every individual WebAuthn override\n * (`webAuthnSharedSigner`, `webAuthnSignerFactory`, `webAuthnSignerSingleton`,\n * `webAuthnSignerProxyCreationCode`, `eip7212WebAuthnPrecompileVerifier`,\n * `eip7212WebAuthnContractVerifier`) must likewise match what was passed to\n * `InitCodeOverrides` at init time — only set them when you've also\n * overridden them at init. The on-chain owner set is locked to whatever was\n * used at init: `webAuthnSharedSigner` for `isInit=true`, the deterministic\n * verifier proxy derived from the other five for `isInit=false`. A mismatch\n * produces a signature pointing at an address that isn't an owner; on-chain\n * `checkSignatures` reverts with `GS026` and the bundler surfaces it as a\n * generic \"Invalid UserOp signature\" with no offline diagnostic.\n *\n * @example\n * import { fromSafeWebauthn, SafeAccountV0_3_0 } from \"abstractionkit\";\n *\n * // Pass `expectedSigners: [{ x, y }]` so createUserOperation picks the\n * // WebAuthn dummy signature for gas estimation. Without it, the\n * // bundler sizes verification gas against the EOA dummy and the\n * // real signed UserOp gets rejected (or under-budgeted on-chain) at submit.\n * let userOperation = await safe.createUserOperation(\n *   transactions, nodeUrl, bundlerUrl,\n *   { expectedSigners: [{ x, y }] },\n * );\n *\n * const signer = fromSafeWebauthn({\n *   publicKey: { x, y },\n *   isInit: userOperation.nonce === 0n,\n *   accountClass: SafeAccountV0_3_0, // SafeMultiChainSigAccountV1 for multi-chain\n *   getAssertion: async (challenge) => {\n *     const assertion = await navigator.credentials.get({\n *       publicKey: { challenge, rpId, allowCredentials, userVerification },\n *     });\n *     return {\n *       authenticatorData: assertion.response.authenticatorData,\n *       clientDataFields: extractClientDataFields(assertion.response),\n *       rs: extractSignature(assertion.response),\n *     };\n *   },\n * });\n * userOperation.signature = await safe.signUserOperationWithSigners(\n *   userOperation, [signer], chainId,\n * );\n */\nexport function fromSafeWebauthn(params: FromSafeWebauthnParams): ExternalSigner<unknown> {\n\tconst {\n\t\tpublicKey,\n\t\tisInit,\n\t\tgetAssertion,\n\t\taccountClass,\n\t\twebAuthnSharedSigner,\n\t\twebAuthnSignerFactory,\n\t\twebAuthnSignerSingleton,\n\t\twebAuthnSignerProxyCreationCode,\n\t\teip7212WebAuthnPrecompileVerifier,\n\t\teip7212WebAuthnContractVerifier,\n\t} = params;\n\n\t// Guard against non-bigint coords: TS only enforces shape structurally,\n\t// so a pubkey round-tripped through JSON.parse (without a reviver) lands\n\t// here as strings. solidityPacked(\"uint256\", ...) downstream silently\n\t// coerces decimal strings, mishandles unprefixed hex, and throws deep\n\t// inside ethers on malformed input — all manifesting as a wrong verifier\n\t// address with no offline diagnostic. Fail loudly at the boundary instead.\n\tif (typeof publicKey?.x !== \"bigint\" || typeof publicKey?.y !== \"bigint\") {\n\t\tthrow new TypeError(\n\t\t\t\"fromSafeWebauthn: publicKey.x and publicKey.y must be bigint. \" +\n\t\t\t\t\"If they round-tripped through JSON.parse, hydrate them back \" +\n\t\t\t\t\"to bigint first (e.g. BigInt(value) for decimal strings, or \" +\n\t\t\t\t\"use a JSON reviver).\",\n\t\t);\n\t}\n\n\t// Source defaults from `accountClass` so subclasses with different Safe\n\t// Passkey module versions (e.g. SafeMultiChainSigAccountV1's v0.2.1 set)\n\t// are picked up automatically. `createWebAuthnSignerVerifierAddress`\n\t// itself falls back to the parent's v0.2.0 defaults for any field left\n\t// undefined, so we must resolve them here before forwarding.\n\tconst address = isInit\n\t\t? (webAuthnSharedSigner ?? accountClass.DEFAULT_WEB_AUTHN_SHARED_SIGNER)\n\t\t: SafeAccount.createWebAuthnSignerVerifierAddress(publicKey.x, publicKey.y, {\n\t\t\t\twebAuthnSignerFactory:\n\t\t\t\t\twebAuthnSignerFactory ?? accountClass.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,\n\t\t\t\twebAuthnSignerSingleton:\n\t\t\t\t\twebAuthnSignerSingleton ?? accountClass.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,\n\t\t\t\twebAuthnSignerProxyCreationCode:\n\t\t\t\t\twebAuthnSignerProxyCreationCode ??\n\t\t\t\t\taccountClass.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,\n\t\t\t\teip7212WebAuthnPrecompileVerifier:\n\t\t\t\t\teip7212WebAuthnPrecompileVerifier ?? accountClass.DEFAULT_WEB_AUTHN_PRECOMPILE,\n\t\t\t\teip7212WebAuthnContractVerifier:\n\t\t\t\t\teip7212WebAuthnContractVerifier ?? accountClass.DEFAULT_WEB_AUTHN_CONTRACT_VERIFIER,\n\t\t\t});\n\n\treturn {\n\t\taddress: address as `0x${string}`,\n\t\ttype: \"contract\",\n\t\tsignHash: async (hash) => {\n\t\t\tconst assertion = await getAssertion(getBytes(hash));\n\t\t\treturn SafeAccount.createWebAuthnSignature(assertion) as `0x${string}`;\n\t\t},\n\t};\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// WebAuthn pubkey JSON round-trip\n// ────────────────────────────────────────────────────────────────────────────\n\n/**\n * Coerce a `{ x, y }` pair where each coord may be `bigint`, hex string\n * (`\"0x...\"`), decimal string, or a safe-integer number into a canonical\n * {@link WebauthnPublicKey} with bigint coords. Used internally by\n * {@link pubkeyCoordinatesFromJson} — for non-JSON inputs (URL params,\n * RPC responses), pass the pre-parsed object straight to that helper.\n *\n * @throws if either coordinate is missing, the wrong type, or an\n * unparseable string.\n */\nfunction toBigintPubkey(pubkey: {\n\tx: bigint | string | number;\n\ty: bigint | string | number;\n}): WebauthnPublicKey {\n\tif (!pubkey || pubkey.x == null || pubkey.y == null) {\n\t\tthrow new Error(\"toBigintPubkey: pubkey must be `{ x, y }` with both coords set\");\n\t}\n\treturn { x: coerceBigint(pubkey.x, \"x\"), y: coerceBigint(pubkey.y, \"y\") };\n}\n\nfunction coerceBigint(v: bigint | string | number, field: string): bigint {\n\tlet coerced: bigint;\n\tif (typeof v === \"bigint\") {\n\t\tcoerced = v;\n\t} else if (typeof v === \"string\") {\n\t\ttry {\n\t\t\tcoerced = BigInt(v);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t`toBigintPubkey: pubkey.${field} (\"${v}\") is not a valid bigint string. ` +\n\t\t\t\t\t\"Accepted: non-negative bigint, decimal string, or 0x-prefixed hex string.\",\n\t\t\t);\n\t\t}\n\t} else if (typeof v === \"number\") {\n\t\tif (!Number.isSafeInteger(v)) {\n\t\t\tthrow new Error(\n\t\t\t\t`toBigintPubkey: pubkey.${field} is a Number but not a safe integer. ` +\n\t\t\t\t\t\"Pass as bigint or hex string to avoid precision loss.\",\n\t\t\t);\n\t\t}\n\t\tcoerced = BigInt(v);\n\t} else {\n\t\tthrow new Error(\n\t\t\t`toBigintPubkey: pubkey.${field} must be bigint, string, or number (got ${typeof v})`,\n\t\t);\n\t}\n\t// P-256 field elements are non-negative by definition. Reject negatives\n\t// at the coercion boundary so they can't reach `pubkeyCoordinatesToJson`,\n\t// which would emit an invalid `\"0x-...\"` string and break round-trip.\n\tif (coerced < 0n) {\n\t\tthrow new Error(\n\t\t\t`toBigintPubkey: pubkey.${field} must be non-negative (got ${coerced.toString()}). ` +\n\t\t\t\t\"P-256 coordinates are non-negative field elements; negative values aren't valid \" +\n\t\t\t\t\"and would break canonical JSON round-trip serialization.\",\n\t\t);\n\t}\n\treturn coerced;\n}\n\n/**\n * Serialize a WebAuthn pubkey to a JSON string with hex-encoded\n * coordinates. Inverse of {@link pubkeyCoordinatesFromJson}.\n *\n * Any JSON-string persistence — localStorage, backend indexes, query\n * strings, IPC payloads — eventually needs a custom replacer for\n * `bigint` (which `JSON.stringify` can't serialize on its own). This\n * helper ships the canonical version so the round-trip is consistent\n * across call sites.\n *\n * @example\n * ```ts\n * localStorage.setItem(\"passkey\", pubkeyCoordinatesToJson({ x: 0x7a..., y: 0x2e... }));\n * // Stored as: {\"x\":\"0x7a...\",\"y\":\"0x2e...\"}\n * ```\n */\nexport function pubkeyCoordinatesToJson(pubkey: WebauthnPublicKey): string {\n\treturn JSON.stringify({\n\t\tx: `0x${pubkey.x.toString(16)}`,\n\t\ty: `0x${pubkey.y.toString(16)}`,\n\t});\n}\n\n/**\n * Parse a JSON string produced by {@link pubkeyCoordinatesToJson} (or\n * any JSON object with `x` / `y` fields as bigint-compatible values)\n * back into a {@link WebauthnPublicKey} with bigint coords.\n *\n * Lenient about input shape: accepts a JSON string, a pre-parsed object\n * (skip `JSON.parse` if you already ran it), and either hex (`\"0x...\"`)\n * or decimal-string coords. Same one-line cost regardless of where the\n * string came from — localStorage, backend response, query parameter.\n *\n * @example\n * ```ts\n * const raw = localStorage.getItem(\"passkey\");\n * if (raw) {\n *   const pubkey = pubkeyCoordinatesFromJson(raw);\n *   // pubkey: { x: bigint, y: bigint }\n * }\n * ```\n */\nexport function pubkeyCoordinatesFromJson(\n\tinput: string | { x: bigint | string | number; y: bigint | string | number },\n): WebauthnPublicKey {\n\tconst parsed = typeof input === \"string\" ? JSON.parse(input) : input;\n\treturn toBigintPubkey(parsed);\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// WebAuthn assertion normalizer\n// ────────────────────────────────────────────────────────────────────────────\n\n/**\n * Structural shape matching the browser `AuthenticatorAssertionResponse`,\n * `ox/WebAuthnP256` sign output, and `@simplewebauthn/browser`. Consumers\n * can pass any of these without an adapter-specific wrapper.\n *\n * Each field is normalized individually:\n * - `authenticatorData`: `ArrayBuffer` (raw browser API), `Uint8Array`\n *   (most libraries), or `0x`-prefixed hex string (`ox`).\n * - `clientDataJSON`: UTF-8 string (`ox` returns it pre-decoded), or\n *   buffer (raw browser API).\n * - `signature`: pre-decoded `{ r, s }` bigints (`ox` returns this), or a\n *   DER-encoded buffer (raw browser API).\n */\ninterface AuthenticatorAssertionLike {\n\tauthenticatorData: ArrayBuffer | Uint8Array | string;\n\tclientDataJSON: ArrayBuffer | Uint8Array | string;\n\tsignature: ArrayBuffer | Uint8Array | { r: bigint; s: bigint };\n}\n\n/**\n * Turn a structural {@link AuthenticatorAssertionLike} into\n * {@link WebauthnSignatureData}, ready to feed straight into\n * `SafeAccount.createWebAuthnSignature` or the `getAssertion` callback\n * of `fromSafeWebauthn`.\n *\n * Replaces the ~13-line manual pipeline every Safe-passkeys consumer\n * has been writing — `JSON.parse` of `clientDataJSON`, destructure +\n * re-serialize the non-`type` / non-`challenge` fields, hex-encode,\n * normalize `authenticatorData`, parse DER signature → `(r, s)` —\n * with a single call.\n *\n * @example Browser:\n * ```ts\n * const assertion = await navigator.credentials.get({...});\n * return webauthnSignatureFromAssertion(assertion.response);\n * ```\n *\n * @example `ox/WebAuthnP256`:\n * ```ts\n * const { metadata, signature } = await sign({ challenge, credentialId });\n * return webauthnSignatureFromAssertion({\n *   authenticatorData: metadata.authenticatorData, // hex string from ox\n *   clientDataJSON: metadata.clientDataJSON,       // string from ox\n *   signature,                                      // { r, s } from ox\n * });\n * ```\n */\nexport function webauthnSignatureFromAssertion(\n\tresponse: AuthenticatorAssertionLike,\n): WebauthnSignatureData {\n\tconst authenticatorData = toArrayBuffer(response.authenticatorData);\n\tconst clientDataJSON = toUtf8String(response.clientDataJSON);\n\tconst rs = toRSPair(response.signature);\n\treturn {\n\t\tauthenticatorData,\n\t\tclientDataFields: extractClientDataFieldsHex(clientDataJSON),\n\t\trs: [rs.r, rs.s],\n\t};\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Internal: input normalization\n// ────────────────────────────────────────────────────────────────────────────\n\nfunction toArrayBuffer(input: ArrayBuffer | Uint8Array | string): ArrayBuffer {\n\t// ethers' `getBytes` validates hex format and returns a fresh\n\t// Uint8Array; it doesn't accept ArrayBuffer though, so we handle\n\t// that one case manually. Same byte-for-byte output as the previous\n\t// hand-rolled `hexToBytes` plus regex validation.\n\tif (input instanceof ArrayBuffer) return input;\n\tconst bytes = getBytes(input);\n\treturn bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);\n}\n\nfunction toUtf8String(input: ArrayBuffer | Uint8Array | string): string {\n\tif (typeof input === \"string\") return input;\n\tconst bytes = input instanceof Uint8Array ? input : new Uint8Array(input);\n\t// Pure-JS decode so it works in React Native / Hermes too (no TextDecoder there).\n\treturn fromUtf8Bytes(bytes);\n}\n\nfunction toRSPair(\n\tinput: ArrayBuffer | Uint8Array | { r: bigint; s: bigint },\n): { r: bigint; s: bigint } {\n\tif (\n\t\tinput !== null &&\n\t\ttypeof input === \"object\" &&\n\t\t\"r\" in input &&\n\t\t\"s\" in input &&\n\t\ttypeof (input as { r: unknown }).r === \"bigint\" &&\n\t\ttypeof (input as { s: unknown }).s === \"bigint\"\n\t) {\n\t\treturn { r: (input as { r: bigint }).r, s: (input as { s: bigint }).s };\n\t}\n\tconst bytes = input instanceof Uint8Array ? input : new Uint8Array(input as ArrayBuffer);\n\treturn parseDerP256Signature(bytes);\n}\n\n/**\n * Re-serialize every clientDataJSON field except `type` and `challenge`.\n * Robust to authenticators adding or reordering keys (e.g. Safari's\n * `crossOrigin`, future WebAuthn L3 fields) — parses JSON instead of\n * using a regex, validates the shape is a plain object, and emits hex\n * via the pure-JS `toUtf8Bytes` (works in browsers and React Native /\n * Hermes; neither `Buffer` nor `TextEncoder` is defined there by default).\n */\nfunction extractClientDataFieldsHex(clientDataJSON: string): string {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(clientDataJSON);\n\t} catch (err) {\n\t\tthrow new Error(\n\t\t\t`webauthnSignatureFromAssertion: clientDataJSON is not valid JSON (${(err as Error).message})`,\n\t\t);\n\t}\n\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\tthrow new Error(\n\t\t\t\"webauthnSignatureFromAssertion: clientDataJSON must parse to a plain object \" +\n\t\t\t\t`(got ${parsed === null ? \"null\" : Array.isArray(parsed) ? \"array\" : typeof parsed})`,\n\t\t);\n\t}\n\tconst { type: _type, challenge: _challenge, ...rest } = parsed as Record<string, unknown>;\n\tconst fields = Object.entries(rest)\n\t\t.map(([key, value]) => `\"${key}\":${JSON.stringify(value)}`)\n\t\t.join(\",\");\n\t// `hexlify` mirrors what the prior hand-rolled hex loop produced —\n\t// each byte gets exactly 2 lowercase hex chars, no separators, `0x`\n\t// prefix. Confirmed identical for all input sizes via the test suite.\n\treturn hexlify(toUtf8Bytes(fields));\n}\n\n/**\n * Parse a DER-encoded ECDSA P-256 signature into `(r, s)` bigints with\n * low-S normalization. Defends against truncated / malformed DER: every\n * length and tag is bounds-checked against the buffer before slicing,\n * because `Uint8Array.subarray` silently clamps OOB indices and would\n * otherwise produce attacker-controlled-length r/s.\n *\n * DER layout:\n *   0x30 | total-len | 0x02 | r-len | r-bytes | 0x02 | s-len | s-bytes\n */\nfunction parseDerP256Signature(der: Uint8Array): { r: bigint; s: bigint } {\n\tconst malformed = () =>\n\t\tnew Error(\"webauthnSignatureFromAssertion: malformed DER signature\");\n\tif (der.length < 8 || der[0] !== 0x30) throw malformed();\n\n\t// Validate the outer SEQUENCE length up front so trailing garbage and\n\t// length under/overstatement can't survive to the bigint conversion.\n\tconst headerLen = der[1] === 0x81 ? 3 : 2;\n\tconst outerLen = der[1] === 0x81 ? der[2] : der[1];\n\tif (der.length !== headerLen + outerLen) throw malformed();\n\tlet offset = headerLen;\n\n\t// r tag + length + body must fit\n\tif (offset + 2 > der.length) throw malformed();\n\tif (der[offset] !== 0x02) throw malformed();\n\tconst rLen = der[offset + 1];\n\tif (rLen <= 0 || offset + 2 + rLen > der.length) throw malformed();\n\tconst rBytes = der.subarray(offset + 2, offset + 2 + rLen);\n\toffset += 2 + rLen;\n\n\t// s tag + length + body must fit\n\tif (offset + 2 > der.length) throw malformed();\n\tif (der[offset] !== 0x02) throw malformed();\n\tconst sLen = der[offset + 1];\n\tif (sLen <= 0 || offset + 2 + sLen > der.length) throw malformed();\n\tconst sBytes = der.subarray(offset + 2, offset + 2 + sLen);\n\t// No bytes may follow `s` inside the SEQUENCE.\n\tif (offset + 2 + sLen !== der.length) throw malformed();\n\n\t// `hexlify(empty)` returns \"0x\" which BigInt rejects; preserve the\n\t// 0n short-circuit. For DER-parsed r/s the bytes are non-empty by\n\t// the rLen/sLen > 0 checks above, but keep the guard explicit.\n\tconst r = rBytes.length === 0 ? 0n : BigInt(hexlify(rBytes));\n\tlet s = sBytes.length === 0 ? 0n : BigInt(hexlify(sBytes));\n\n\t// Low-S normalize: some authenticators return the high-S form; the\n\t// Safe WebAuthn verifier and most P-256 checkers accept only low-S.\n\tconst P256_N = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n;\n\tconst P256_N_HALF = P256_N >> 1n;\n\tif (s > P256_N_HALF) s = P256_N - s;\n\n\treturn { r, s };\n}\n","import { privateKeyToAddress, signHash, signTypedData } from \"../ethereUtils\";\nimport type { ExternalSigner, TypedData } from \"./types\";\n\n// Structural types for well-known signers. NO imports from viem / ethers\n// at the type level (beyond the already-present ethers runtime dep used by\n// fromPrivateKey); these shapes match their public APIs so users can pass\n// an instance directly.\n\n/**\n * Shape matching viem's `PrivateKeyAccount` / `LocalAccount`.\n *\n * @remarks Requires viem &gt;= 2.0 (the `sign({ hash })` method was added in\n * the 2.0 account refactor; viem 1.x errors structurally).\n * @internal Pass concrete viem instances to {@link fromViem}. For wrapper\n * typing, use `Parameters<typeof fromViem>[0]`.\n */\nexport interface ViemLocalAccountLike {\n\taddress: `0x${string}`;\n\tsign: (args: { hash: `0x${string}` }) => Promise<`0x${string}`>;\n\tsignTypedData: (args: {\n\t\tdomain: TypedData[\"domain\"];\n\t\ttypes: Record<string, Array<{ name: string; type: string }>>;\n\t\tprimaryType: string;\n\t\tmessage: Record<string, unknown>;\n\t}) => Promise<`0x${string}`>;\n}\n\n/**\n * Minimal shape required by {@link fromViemWalletClient}: `account.address`\n * read structurally, `signTypedData` cast locally inside the adapter because\n * viem's const generics can't be reproduced without re-exporting viem's\n * types. Runtime call shape is stable across viem 2.x.\n *\n * @remarks Requires viem &gt;= 2.0.\n * @internal Pass concrete `WalletClient` instances to {@link fromViemWalletClient}.\n */\nexport interface ViemWalletClientLike {\n\taccount?: { address: `0x${string}` } | undefined;\n\tsignTypedData: unknown;\n}\n\n/**\n * Internal shape that viem's `signTypedData` conforms to at runtime.\n * Used only inside {@link fromViemWalletClient}.\n */\ntype ViemSignTypedDataCall = (args: {\n\taccount: { address: `0x${string}` } | `0x${string}`;\n\tdomain: TypedData[\"domain\"];\n\ttypes: TypedData[\"types\"];\n\tprimaryType: string;\n\tmessage: Record<string, unknown>;\n}) => Promise<`0x${string}`>;\n\n/**\n * Shape matching ethers `Wallet` / `HDNodeWallet`. Parameter types\n * deliberately widen ethers' `TypedDataDomain` / `TypedDataField[]` so the\n * interface doesn't import from ethers while still accepting a Wallet\n * instance without casts.\n *\n * @remarks Requires ethers &gt;= 6.0 (ethers 5.x used private `_signTypedData`).\n * @internal Pass concrete `Wallet` / `HDNodeWallet` instances to {@link fromEthersWallet}.\n */\nexport interface EthersWalletLike {\n\taddress: string;\n\tsigningKey: {\n\t\tsign: (hash: string) => { serialized: string };\n\t};\n\tsignTypedData: (\n\t\tdomain: {\n\t\t\tname?: string;\n\t\t\tversion?: string;\n\t\t\tchainId?: number | bigint;\n\t\t\tverifyingContract?: string;\n\t\t\tsalt?: string;\n\t\t},\n\t\ttypes: Record<string, Array<{ name: string; type: string }>>,\n\t\tmessage: Record<string, unknown>,\n\t) => Promise<string>;\n}\n\n/**\n * Build an ExternalSigner from a raw private-key hex string. Supports both raw-hash\n * and typed-data signing, delegated to the internal `ethereUtils` helpers\n * ({@link signHash}, {@link signTypedData}) — no extra packages needed.\n * If you already hold a viem Account or ethers Wallet, use {@link fromViem}\n * or {@link fromEthersWallet} instead.\n *\n * @example\n * import { fromPrivateKey } from \"abstractionkit\";\n * const signer = fromPrivateKey(process.env.PRIVATE_KEY!);\n * userOp.signature = await safe.signUserOperationWithSigners(userOp, [signer], chainId);\n */\nexport function fromPrivateKey(privateKey: string): ExternalSigner<unknown> {\n\treturn {\n\t\taddress: privateKeyToAddress(privateKey),\n\t\tsignHash: (hash) => signHash(privateKey, hash).serialized,\n\t\tsignTypedData: (td) => signTypedData(privateKey, td.domain, td.types, td.message),\n\t};\n}\n\n/**\n * Adapt a viem Local Account (e.g. `privateKeyToAccount(pk)`) to an ExternalSigner.\n * Supports both raw-hash and typed-data signing.\n *\n * @remarks Requires viem &gt;= 2.0.\n */\nexport function fromViem(account: ViemLocalAccountLike): ExternalSigner<unknown> {\n\treturn {\n\t\taddress: account.address,\n\t\tsignHash: (hash) => account.sign({ hash }),\n\t\tsignTypedData: (td) =>\n\t\t\taccount.signTypedData({\n\t\t\t\tdomain: td.domain,\n\t\t\t\ttypes: td.types,\n\t\t\t\tprimaryType: td.primaryType,\n\t\t\t\tmessage: td.message,\n\t\t\t}),\n\t};\n}\n\n/**\n * Adapt a viem `WalletClient` to an ExternalSigner. Only typed-data signing is\n * exposed, because `WalletClient` drives browser/JSON-RPC wallets which\n * can't sign raw hashes. Requires the client to have been constructed with\n * an `account`; for local accounts, prefer `fromViem` so you also get\n * raw-hash fallback.\n *\n * @remarks Requires viem &gt;= 2.0.\n */\nexport function fromViemWalletClient(client: ViemWalletClientLike): ExternalSigner<unknown> {\n\tif (!client.account) {\n\t\tthrow new Error(\n\t\t\t\"fromViemWalletClient: client has no `account` configured. \" +\n\t\t\t\t\"Construct with `createWalletClient({ account, transport, chain })`.\",\n\t\t);\n\t}\n\t// Capture the full account object: passing just the address would force\n\t// viem to route to `eth_signTypedData_v4` (fails on HTTP transports),\n\t// whereas the object may carry local signing methods.\n\tconst account = client.account;\n\tconst signTypedData = client.signTypedData as ViemSignTypedDataCall;\n\treturn {\n\t\taddress: account.address,\n\t\tsignTypedData: (td) =>\n\t\t\tsignTypedData({\n\t\t\t\taccount,\n\t\t\t\tdomain: td.domain,\n\t\t\t\ttypes: td.types,\n\t\t\t\tprimaryType: td.primaryType,\n\t\t\t\tmessage: td.message,\n\t\t\t}),\n\t};\n}\n\n/**\n * Adapt an ethers `Wallet` / `HDNodeWallet` to an ExternalSigner. Supports both\n * raw-hash and typed-data signing.\n *\n * @remarks Requires ethers &gt;= 6.0.\n */\nexport function fromEthersWallet(wallet: EthersWalletLike): ExternalSigner<unknown> {\n\t// ethers types `address` as plain `string`; at runtime it's always\n\t// checksummed 0x-prefixed hex.\n\treturn {\n\t\taddress: wallet.address as `0x${string}`,\n\t\tsignHash: async (hash) => wallet.signingKey.sign(hash).serialized as `0x${string}`,\n\t\tsignTypedData: async (td) =>\n\t\t\t(await wallet.signTypedData(td.domain, td.types, td.message)) as `0x${string}`,\n\t};\n}\n","import {decodeAbiParameters, id} from \"./ethereUtils\";\nimport type {Log, UserOperationReceiptResult} from \"./types\";\n\n/**\n * Why a mined UserOperation reverted, decoded from its receipt.\n */\nexport type UserOperationRevert = {\n\t/** True when the receipt's `success` is false. */\n\treverted: boolean;\n\t/**\n\t * The inner call left no revert data. Usually out-of-gas, though a bare\n\t * `revert()`/`assert` or a call to a non-contract also produce empty data.\n\t */\n\toutOfGas: boolean;\n\t/** Decoded `Error(\"...\")` string, when the call reverted with a reason. */\n\terrorMessage?: string;\n\t/** Decoded `Panic(uint256)` code (0x11 overflow, 0x12 divide-by-zero, ...). */\n\tpanicCode?: number;\n\t/** The raw revert data bytes, for custom errors or further decoding. */\n\trevertData: string;\n};\n\n// EntryPoint event:\n//   UserOperationRevertReason(bytes32 userOpHash, address sender, uint256 nonce, bytes revertReason)\nconst REVERT_REASON_TOPIC = id(\n\t\"UserOperationRevertReason(bytes32,address,uint256,bytes)\",\n).toLowerCase();\nconst ERROR_SELECTOR = \"0x08c379a0\"; // Error(string)\nconst PANIC_SELECTOR = \"0x4e487b71\"; // Panic(uint256)\n\n/**\n * Decode why a mined UserOperation reverted, using only its receipt.\n *\n * A receipt's `success: false` says the inner call reverted but not why. This\n * reads the EntryPoint's `UserOperationRevertReason` log and decodes the revert\n * data into a reason string, a panic code, or empty data (usually out-of-gas),\n * with no extra RPC call.\n *\n * To be certain about out-of-gas (rather than a bare revert with no data), trace\n * the bundle transaction with debug_traceTransaction or a simulation provider.\n *\n * @param receipt - A UserOperation receipt (non-null)\n * @returns The decoded revert: reason string, panic code, or out-of-gas\n */\nexport function decodeUserOperationRevertReason(\n\treceipt: NonNullable<UserOperationReceiptResult>,\n): UserOperationRevert {\n\tif (receipt.success) {\n\t\treturn {reverted: false, outOfGas: false, revertData: \"0x\"};\n\t}\n\n\t// UserOperationRevertReason is indexed by userOpHash (topic[1]). A bundle can\n\t// contain several reverted ops, so match this op's hash as well as the event\n\t// topic; otherwise we could pick up another op's revert reason from the bundle\n\t// logs. The guard keeps it working if a caller passes a receipt without the\n\t// top-level userOpHash. (Inner-call logs of this op do not carry the hash and\n\t// would have to be located by logIndex range, which is out of scope here.)\n\tconst userOpHash = (receipt as {userOpHash?: string}).userOpHash?.toLowerCase();\n\tconst log = collectLogs(receipt).find(\n\t\t(l) =>\n\t\t\tl?.topics?.[0]?.toLowerCase() === REVERT_REASON_TOPIC &&\n\t\t\t(userOpHash == null || l?.topics?.[1]?.toLowerCase() === userOpHash),\n\t);\n\t// The EntryPoint emits UserOperationRevertReason only when the inner call\n\t// left non-empty revert data (`if (result.length > 0) emit ...`). So a\n\t// failed op with no such log left no revert data at all, which is the\n\t// out-of-gas / bare-revert()/assert / call-to-non-contract case.\n\tif (log == null) {\n\t\treturn {reverted: true, outOfGas: true, revertData: \"0x\"};\n\t}\n\n\t// log.data is abi.encode(uint256 nonce, bytes revertReason). A malformed\n\t// or truncated payload would throw from decodeAbiParameters; surface that\n\t// as a best-effort \"reverted, reason unknown\" result rather than letting\n\t// the exception bubble.\n\tlet revertData: string;\n\ttry {\n\t\t[, revertData] = decodeAbiParameters<[bigint, string]>([\"uint256\", \"bytes\"], log.data);\n\t} catch {\n\t\treturn {reverted: true, outOfGas: false, revertData: \"0x\"};\n\t}\n\tconst data = revertData.toLowerCase();\n\n\tif (data === \"0x\" || data === \"\") {\n\t\treturn {reverted: true, outOfGas: true, revertData: \"0x\"};\n\t}\n\tif (data.startsWith(ERROR_SELECTOR)) {\n\t\ttry {\n\t\t\tconst [errorMessage] = decodeAbiParameters<[string]>([\"string\"], \"0x\" + data.slice(10));\n\t\t\treturn {reverted: true, outOfGas: false, errorMessage, revertData};\n\t\t} catch {\n\t\t\treturn {reverted: true, outOfGas: false, revertData};\n\t\t}\n\t}\n\tif (data.startsWith(PANIC_SELECTOR)) {\n\t\ttry {\n\t\t\tconst [code] = decodeAbiParameters<[bigint]>([\"uint256\"], \"0x\" + data.slice(10));\n\t\t\treturn {reverted: true, outOfGas: false, panicCode: Number(code), revertData};\n\t\t} catch {\n\t\t\treturn {reverted: true, outOfGas: false, revertData};\n\t\t}\n\t}\n\treturn {reverted: true, outOfGas: false, revertData};\n}\n\n/**\n * Gather logs from the receipt. Logs are structured `Log[]`, but this also\n * tolerates the legacy JSON-string form so it keeps working if a caller passes\n * a receipt produced by an older SDK version.\n */\nfunction collectLogs(receipt: NonNullable<UserOperationReceiptResult>): Log[] {\n\tconst out: Log[] = [];\n\tconst sources: unknown[] = [receipt.logs, receipt.receipt?.logs];\n\tfor (const src of sources) {\n\t\tif (Array.isArray(src)) out.push(...(src as Log[]));\n\t\telse if (typeof src === \"string\") {\n\t\t\ttry {\n\t\t\t\tout.push(...(JSON.parse(src) as Log[]));\n\t\t\t} catch {\n\t\t\t\t/* ignore malformed legacy logs */\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n","export { Calibur7702Account } from \"./account/Calibur/Calibur7702Account\";\nexport type {\n\tCaliburCreateUserOperationOverrides,\n\tCaliburKey,\n\tCaliburKeySettings,\n\tCaliburKeySettingsResult,\n\tCaliburSignatureOverrides,\n\tWebAuthnSignatureData,\n} from \"./account/Calibur/types\";\nexport { CaliburKeyType } from \"./account/Calibur/types\";\nexport type { Allowance } from \"./account/Safe/modules/AllowanceModule\";\nexport {\n\tALLOWANCE_MODULE_V0_1_0_ADDRESS,\n\tAllowanceModule,\n} from \"./account/Safe/modules/AllowanceModule\";\nexport type {\n\tRecoveryRequest,\n\tRecoveryRequestTypedDataDomain,\n\tRecoveryRequestTypedMessageValue,\n\tRecoverySignaturePair,\n} from \"./account/Safe/modules/SocialRecoveryModule\";\n// ViemLocalAccountLike / ViemWalletClientLike / EthersWalletLike are NOT\n// exported. They're internal structural shapes the adapters match against;\n// callers pass concrete viem / ethers instances directly. If you need the\n// input type for a wrapper, use `Parameters<typeof fromViem>[0]` etc.\nexport {\n\tEIP712_RECOVERY_MODULE_TYPE,\n\tEXECUTE_RECOVERY_PRIMARY_TYPE,\n\tSocialRecoveryModule,\n\tSocialRecoveryModuleGracePeriodSelector,\n} from \"./account/Safe/modules/SocialRecoveryModule\";\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\";\nexport { SafeMultiChainSigAccountV1 } from \"./account/Safe/SafeMultiChainSigAccount\";\nexport type {\n\tSafeMessageTypedDataDomain,\n\tSafeMessageTypedMessageValue,\n} from \"./account/Safe/safeMessage\";\nexport {\n\tgetSafeMessageEip712Data,\n\tSAFE_MESSAGE_MODULE_TYPE,\n\tSAFE_MESSAGE_PRIMARY_TYPE,\n} from \"./account/Safe/safeMessage\";\nexport type {\n\tCreateUserOperationV6Overrides,\n\tCreateUserOperationV7Overrides,\n\tCreateUserOperationV9Overrides,\n\tECDSAPublicAddress,\n\tInitCodeOverrides,\n\tSafeUserOperationTypedDataDomain,\n\tSigner,\n\tSignerSignaturePair,\n\tWebauthnPublicKey,\n\tWebauthnSignatureData,\n} from \"./account/Safe/types\";\nexport {\n\tEOADummySignerSignaturePair,\n\tSafeModuleExecutorFunctionSelector,\n\tWebauthnDummySignerSignaturePair,\n} from \"./account/Safe/types\";\nexport { SendUseroperationResponse } from \"./account/SendUseroperationResponse\";\nexport { SmartAccount } from \"./account/SmartAccount\";\nexport { Simple7702Account } from \"./account/simple/Simple7702Account\";\nexport { Simple7702AccountV09 } from \"./account/simple/Simple7702AccountV09\";\n\nexport { Bundler } from \"./Bundler\";\nexport {\n\tBaseUserOperationDummyValues,\n\tCALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS,\n\tCALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS,\n\tDEFAULT_SECP256R1_PRECOMPILE_ADDRESS,\n\tEIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE,\n\tEIP712_MULTI_CHAIN_OPERATIONS_TYPE,\n\tEIP712_SAFE_OPERATION_PRIMARY_TYPE,\n\tEIP712_SAFE_OPERATION_V6_TYPE,\n\tEIP712_SAFE_OPERATION_V7_TYPE,\n\tENTRYPOINT_V6,\n\tENTRYPOINT_V7,\n\tENTRYPOINT_V8,\n\tENTRYPOINT_V9,\n\tSAFE_FALLBACK_HANDLER_STORAGE_SLOT,\n\tZeroAddress,\n} from \"./constants\";\nexport { AbstractionKitError, parseAaCode } from \"./errors\";\nexport { SafeAccountFactory } from \"./factory/SafeAccountFactory\";\nexport { SmartAccountFactory } from \"./factory/SmartAccountFactory\";\nexport { ExperimentalAllowAllParallelPaymaster } from \"./paymaster/AllowAllPaymaster\";\nexport { CandidePaymaster } from \"./paymaster/CandidePaymaster\";\nexport type {\n\tErc7677Context,\n\tErc7677PaymasterFields,\n\tErc7677StubDataResult,\n} from \"./paymaster/Erc7677Paymaster\";\nexport { Erc7677Paymaster } from \"./paymaster/Erc7677Paymaster\";\nexport type {\n\tAnyUserOperation,\n\tCandidePaymasterContext,\n\tErc7677PaymasterConstructorOptions,\n\tErc7677Provider,\n\tGasPaymasterUserOperationOverrides,\n\tPrependTokenPaymasterApproveAccount,\n\tSameUserOp,\n} from \"./paymaster/types\";\nexport {\n\tcreateWorldIdSignal,\n\tWorldIdPermissionlessPaymaster,\n} from \"./paymaster/WorldIdPermissionlessPaymaster\";\nexport type {\n\tFromSafeWebauthnParams,\n\tWebauthnAssertionFetcher,\n} from \"./account/Safe/adapters\";\nexport {\n\tfromSafeWebauthn,\n\tpubkeyCoordinatesFromJson,\n\tpubkeyCoordinatesToJson,\n\twebauthnSignatureFromAssertion,\n} from \"./account/Safe/adapters\";\nexport {\n\tfromEthersWallet,\n\tfromPrivateKey,\n\tfromViem,\n\tfromViemWalletClient,\n} from \"./signer/adapters\";\n// ─── Signer interface design (capability-oriented) ──────────────────────\n// Named `ExternalSigner` (declaration and export alike) because the old\n// package-level `Signer` is already taken by an owner-identifier union in\n// Safe/types. An eventual rename there would free the unqualified `Signer`.\nexport type {\n\tExternalSigner,\n\tMultiOpSignContext,\n\tSignContext,\n\tSignHashFn,\n\tSigningScheme,\n\tSignTypedDataFn,\n\tTypedData,\n} from \"./signer/types\";\nexport type {\n\tAbiInputValue,\n\tGasEstimationResult,\n\tJsonRpcError,\n\tJsonRpcParam,\n\tJsonRpcResponse,\n\tJsonRpcResult,\n\tLog,\n\tMetaTransaction,\n\tParallelPaymasterInitValues,\n\tSponsorInfo,\n\tSponsorMetadata,\n\tStateOverrideSet,\n\tTokenQuote,\n\tUserOperationByHashResult,\n\tUserOperationReceipt,\n\tUserOperationReceiptResult,\n\tUserOperationV6,\n\tUserOperationV7,\n\tUserOperationV8,\n\tUserOperationV9,\n} from \"./types\";\n\nexport {\n\tBaseRpcTransport,\n\tHttpTransport,\n\tisEventfulTransport,\n\tisHttpTransport,\n\tJsonRpcNode,\n\tTransportRpcError,\n} from \"./transport\";\nexport type {\n\tEthCallTransaction,\n\tEventfulTransport,\n\tHttpTransportOptions,\n\tJsonRpcEnvelope,\n\tProviderRpcError,\n\tRequestArgs,\n\tRequestOptions,\n\tTransport,\n} from \"./transport\";\nexport { GasOption, Operation, PolygonChain } from \"./types\";\nexport type { DepositInfo } from \"./utils\";\nexport {\n\tcalculateUserOperationMaxGasCost,\n\tcreateCallData,\n\tcreateUserOperationHash,\n\tfetchAccountNonce,\n\tgetFunctionSelector,\n\tsendJsonRpcRequest,\n} from \"./utils\";\nexport type { UserOperationRevert } from \"./userOperationRevert\";\nexport { decodeUserOperationRevertReason } from \"./userOperationRevert\";\nexport type { Authorization7702, Authorization7702Hex } from \"./utils7702\";\nexport {\n\tcreateAndSignEip7702DelegationAuthorization,\n\tcreateAndSignEip7702RawTransaction,\n\tcreateAndSignLegacyRawTransaction,\n\tcreateEip7702DelegationAuthorizationHash,\n\tcreateEip7702TransactionHash,\n\tsignHash,\n} from \"./utils7702\";\nexport {\n\tcallTenderlySimulateBundle,\n\tshareTenderlySimulationAndCreateLink,\n\tsimulateSenderCallDataWithTenderly,\n\tsimulateSenderCallDataWithTenderlyAndCreateShareLink,\n\tsimulateUserOperationCallDataWithTenderly,\n\tsimulateUserOperationCallDataWithTenderlyAndCreateShareLink,\n\tsimulateUserOperationWithTenderly,\n\tsimulateUserOperationWithTenderlyAndCreateShareLink,\n} from \"./utilsTenderly\";\n"],"mappings":";;;;;;;;;;;;;;;;AAiEA,SAAS,oBAAoB,MAAc,OAAwB;AAC/D,KAAI,UAAU,QAAQ,UAAU,KAAA,EAAW,QAAO,OAAO,MAAM;AAC/D,KAAI,OAAO,UAAU,UAAU;EAC3B,MAAM,IAAI,KAAK,aAAa;AAC5B,MACI,EAAE,SAAS,MAAM,IACjB,EAAE,SAAS,SAAS,IACpB,EAAE,SAAS,QAAQ,IACnB,EAAE,SAAS,WAAW,IACtB,EAAE,SAAS,WAAW,CAEtB,QAAO;AAEX,MAAI,iBAAiB,KAAK,MAAM,IAAI,MAAM,SAAS,GAC/C,QAAO,GAAG,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,MAAM,GAAG;AAEnD,MAAI,MAAM,SAAS,GAAI,QAAO,2BAA2B,MAAM,OAAO;AACtE,SAAO;;AAEX,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,OAAO,UAAU,SAC5E,QAAO,OAAO,MAAM;AAExB,KAAI,iBAAiB,WAAY,QAAO,+BAA+B,MAAM,OAAO;AACpF,QAAO,aAAa,OAAO,MAAM;;AAGrC,SAAS,eAAe,OAAgB,SAAiB,MAAc,OAA+B;AAClG,KAAI,CAAC,MAAO,OAAM,IAAI,MAAM,qBAAqB,KAAK,GAAG,oBAAoB,MAAM,MAAM,CAAC,YAAY,QAAQ,GAAG;;AAErH,SAAS,YAAY,OAAgB,SAAgC;AACjE,KAAI,CAAC,MAAO,OAAM,IAAI,MAAM,QAAQ;;AAOxC,MAAM,gBAAgB;AAEtB,SAAS,UAAU,OAAkB,MAAe,MAA4B;AAC5E,KA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