@satora/swap 1.10.2 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-K4BQUZC6.js → chunk-2AULREFC.js} +2 -2
- package/dist/chunk-2AULREFC.js.map +1 -0
- package/dist/{chunk-2LGHF7A3.cjs → chunk-4NVWIR74.cjs} +755 -439
- package/dist/chunk-4NVWIR74.cjs.map +1 -0
- package/dist/{chunk-HWK7LVVX.js → chunk-JHZHRY7S.js} +130 -51
- package/dist/chunk-JHZHRY7S.js.map +1 -0
- package/dist/{chunk-7GOXIT24.cjs → chunk-JZTF4JNH.cjs} +110 -31
- package/dist/chunk-JZTF4JNH.cjs.map +1 -0
- package/dist/{chunk-OJNQCRHU.cjs → chunk-Q4TOBBAN.cjs} +7 -7
- package/dist/{chunk-OJNQCRHU.cjs.map → chunk-Q4TOBBAN.cjs.map} +1 -1
- package/dist/{chunk-MYOGO44L.cjs → chunk-TNZW35XA.cjs} +2 -2
- package/dist/chunk-TNZW35XA.cjs.map +1 -0
- package/dist/{chunk-VBNBVJLB.js → chunk-TT3J2OOS.js} +8 -8
- package/dist/{chunk-VBNBVJLB.js.map → chunk-TT3J2OOS.js.map} +1 -1
- package/dist/{chunk-S4T4GK5G.js → chunk-WQMAL2VD.js} +391 -75
- package/dist/chunk-WQMAL2VD.js.map +1 -0
- package/dist/delegate.cjs +3 -3
- package/dist/delegate.js +2 -2
- package/dist/dist-MHRQ5FFV.cjs +394 -0
- package/dist/{dist-MMYSP6LP.cjs.map → dist-MHRQ5FFV.cjs.map} +1 -1
- package/dist/{dist-L5LHQNRK.js → dist-SHY7I6SH.js} +13 -13
- package/dist/{fundSwap-IUPFISXM-ON5IVSSZ.cjs → fundSwap-UBCHMUP4-BEMQNSFQ.cjs} +15 -15
- package/dist/{fundSwap-IUPFISXM-ON5IVSSZ.cjs.map → fundSwap-UBCHMUP4-BEMQNSFQ.cjs.map} +1 -1
- package/dist/{fundSwap-IUPFISXM-6IBPJ5O7.js → fundSwap-UBCHMUP4-WBLYE6MC.js} +11 -11
- package/dist/index.cjs +28 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -13
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +11 -6
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +11 -6
- package/dist/node.js.map +1 -1
- package/dist/types/cjs/pure/cctp/attestation.d.cts +5 -3
- package/dist/types/cjs/pure/cctp/types.d.cts +11 -2
- package/dist/types/cjs/pure/cctp-inbound/submit.d.cts +2 -0
- package/dist/types/cjs/pure/cctp-inbound/types.d.cts +5 -0
- package/dist/types/cjs/pure/cctp-inbound/userOp.d.cts +11 -0
- package/dist/types/cjs/pure/client.d.cts +61 -18
- package/dist/types/cjs/pure/create/arkade-to-lightning.d.cts +8 -0
- package/dist/types/cjs/pure/create/bitcoin-to-lightning.d.cts +8 -0
- package/dist/types/cjs/pure/create/types.d.cts +16 -4
- package/dist/types/cjs/pure/evm/coordinator.d.cts +4 -0
- package/dist/types/cjs/pure/evm/wallet.d.cts +4 -4
- package/dist/types/cjs/pure/generated/api.d.cts +102 -21
- package/dist/types/cjs/pure/redeem/arkade.d.cts +4 -1
- package/dist/types/cjs/pure/storage/types.d.cts +2 -0
- package/dist/types/cjs/pure/swap-verification.d.cts +12 -0
- package/dist/types/cjs/pure/tokens.d.cts +0 -6
- package/dist/types/cjs/pure/types/dex-quote.d.cts +9 -1
- package/dist/types/cjs/pure/version.d.cts +4 -4
- package/dist/types/cjs/swap/client.d.cts +2 -0
- package/dist/types/esm/pure/cctp/attestation.d.ts +5 -3
- package/dist/types/esm/pure/cctp/types.d.ts +11 -2
- package/dist/types/esm/pure/cctp-inbound/submit.d.ts +2 -0
- package/dist/types/esm/pure/cctp-inbound/types.d.ts +5 -0
- package/dist/types/esm/pure/cctp-inbound/userOp.d.ts +11 -0
- package/dist/types/esm/pure/client.d.ts +61 -18
- package/dist/types/esm/pure/create/arkade-to-lightning.d.ts +8 -0
- package/dist/types/esm/pure/create/bitcoin-to-lightning.d.ts +8 -0
- package/dist/types/esm/pure/create/types.d.ts +16 -4
- package/dist/types/esm/pure/evm/coordinator.d.ts +4 -0
- package/dist/types/esm/pure/evm/wallet.d.ts +4 -4
- package/dist/types/esm/pure/generated/api.d.ts +102 -21
- package/dist/types/esm/pure/redeem/arkade.d.ts +4 -1
- package/dist/types/esm/pure/storage/types.d.ts +2 -0
- package/dist/types/esm/pure/swap-verification.d.ts +12 -0
- package/dist/types/esm/pure/tokens.d.ts +0 -6
- package/dist/types/esm/pure/types/dex-quote.d.ts +9 -1
- package/dist/types/esm/pure/version.d.ts +4 -4
- package/dist/types/esm/swap/client.d.ts +2 -0
- package/dist/wallet-33OJRHX5-4VM7QDPO.cjs +31 -0
- package/dist/{wallet-THELKUYT-26NOFCTE.cjs.map → wallet-33OJRHX5-4VM7QDPO.cjs.map} +1 -1
- package/dist/{wallet-THELKUYT-TOHSMRGU.js → wallet-33OJRHX5-PR4S3NI3.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-2LGHF7A3.cjs.map +0 -1
- package/dist/chunk-7GOXIT24.cjs.map +0 -1
- package/dist/chunk-HWK7LVVX.js.map +0 -1
- package/dist/chunk-K4BQUZC6.js.map +0 -1
- package/dist/chunk-MYOGO44L.cjs.map +0 -1
- package/dist/chunk-S4T4GK5G.js.map +0 -1
- package/dist/dist-MMYSP6LP.cjs +0 -394
- package/dist/wallet-THELKUYT-26NOFCTE.cjs +0 -31
- /package/dist/{dist-L5LHQNRK.js.map → dist-SHY7I6SH.js.map} +0 -0
- /package/dist/{fundSwap-IUPFISXM-6IBPJ5O7.js.map → fundSwap-UBCHMUP4-WBLYE6MC.js.map} +0 -0
- /package/dist/{wallet-THELKUYT-TOHSMRGU.js.map → wallet-33OJRHX5-PR4S3NI3.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/constants.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/debug.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/re.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/parse-options.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/identifiers.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/classes/semver.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/parse.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/valid.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/clean.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/inc.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/diff.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/major.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/minor.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/patch.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/prerelease.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/compare.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/rcompare.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/compare-loose.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/compare-build.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/sort.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/rsort.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/gt.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/lt.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/eq.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/neq.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/gte.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/lte.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/cmp.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/coerce.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/truncate.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/lrucache.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/classes/range.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/classes/comparator.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/satisfies.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/to-comparators.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/max-satisfying.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/min-satisfying.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/min-version.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/valid.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/outside.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/gtr.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/ltr.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/intersects.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/simplify.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/subset.js","../../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/index.js","../../../../ts-pure-sdk/src/cctp/attestation.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/createKernelAccount.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/public/getAccountNonce.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/public/getSenderAddress.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/constants.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/public/isPluginInstalled.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/utils.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/utils/toSigner.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/addressToEmptyAccount.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/utils/signerTo7702Validator.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/utils/toKernelPluginManager.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/KernelAccountAbi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/account/ep0_6/encodeCallData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/types/kernel.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/EIP1271Abi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/common/accountMetadata.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/common/getActionSelector.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/abi/SafeCreateCallAbi.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/common/encodeSafeCreateCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_7/encodeExecuteCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_7/encodeExecuteDelegateCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_7/encodeExecuteSingleCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/account/ep0_7/encodeCallData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/ep0_7/hashKernelSignatureWrapper.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/common/eip712WrapHash.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/plugins/ep0_7/getPluginInstallCallData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/accounts/kernel/utils/common/getUpgradeKernelCall.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/errors/index.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/upgradeKernel.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/changeSudoValidator.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/invalidateNonce.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/uninstallPlugin.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/signUserOperation.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/getKernelV3ModuleCurrentNonce.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/getUserOperationGasPrice.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/sendTransaction.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/signMessage.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/signTypedData.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/actions/account-client/writeContract.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/clients/decorators/kernel.ts","../../../node_modules/.pnpm/@zerodev+sdk@5.5.10_viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_zod@3.25.67_/node_modules/@zerodev/sdk/clients/kernelAccountClient.ts","../../../../ts-pure-sdk/src/cctp-inbound/evmSignerAdapter.ts","../../../../ts-pure-sdk/src/cctp-inbound/smartAccount.ts","../../../../ts-pure-sdk/src/cctp-inbound/preflight.ts","../../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/src/sha3.ts","../../../../ts-pure-sdk/src/evm/htlc.ts","../../../../ts-pure-sdk/src/evm/coordinator.ts","../../../../ts-pure-sdk/src/evm/funding-pins.ts","../../../../ts-pure-sdk/src/cctp-inbound/userOp.ts","../../../../ts-pure-sdk/src/cctp-inbound/submit.ts"],"sourcesContent":["'use strict'\n\n// Note: this is the semver.org version of the spec that it implements\n// Not necessarily the package version of this code.\nconst SEMVER_SPEC_VERSION = '2.0.0'\n\nconst MAX_LENGTH = 256\nconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||\n/* istanbul ignore next */ 9007199254740991\n\n// Max safe segment length for coercion.\nconst MAX_SAFE_COMPONENT_LENGTH = 16\n\n// Max safe length for a build identifier. The max length minus 6 characters for\n// the shortest version with a build 0.0.0+BUILD.\nconst MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6\n\nconst RELEASE_TYPES = [\n 'major',\n 'premajor',\n 'minor',\n 'preminor',\n 'patch',\n 'prepatch',\n 'prerelease',\n]\n\nmodule.exports = {\n MAX_LENGTH,\n MAX_SAFE_COMPONENT_LENGTH,\n MAX_SAFE_BUILD_LENGTH,\n MAX_SAFE_INTEGER,\n RELEASE_TYPES,\n SEMVER_SPEC_VERSION,\n FLAG_INCLUDE_PRERELEASE: 0b001,\n FLAG_LOOSE: 0b010,\n}\n","'use strict'\n\nconst debug = (\n typeof process === 'object' &&\n process.env &&\n process.env.NODE_DEBUG &&\n /\\bsemver\\b/i.test(process.env.NODE_DEBUG)\n) ? (...args) => console.error('SEMVER', ...args)\n : () => {}\n\nmodule.exports = debug\n","'use strict'\n\nconst {\n MAX_SAFE_COMPONENT_LENGTH,\n MAX_SAFE_BUILD_LENGTH,\n MAX_LENGTH,\n} = require('./constants')\nconst debug = require('./debug')\nexports = module.exports = {}\n\n// The actual regexps go on exports.re\nconst re = exports.re = []\nconst safeRe = exports.safeRe = []\nconst src = exports.src = []\nconst safeSrc = exports.safeSrc = []\nconst t = exports.t = {}\nlet R = 0\n\nconst LETTERDASHNUMBER = '[a-zA-Z0-9-]'\n\n// Replace some greedy regex tokens to prevent regex dos issues. These regex are\n// used internally via the safeRe object since all inputs in this library get\n// normalized first to trim and collapse all extra whitespace. The original\n// regexes are exported for userland consumption and lower level usage. A\n// future breaking change could export the safer regex only with a note that\n// all input should have extra whitespace removed.\nconst safeRegexReplacements = [\n ['\\\\s', 1],\n ['\\\\d', MAX_LENGTH],\n [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],\n]\n\nconst makeSafeRegex = (value) => {\n for (const [token, max] of safeRegexReplacements) {\n value = value\n .split(`${token}*`).join(`${token}{0,${max}}`)\n .split(`${token}+`).join(`${token}{1,${max}}`)\n }\n return value\n}\n\nconst createToken = (name, value, isGlobal) => {\n const safe = makeSafeRegex(value)\n const index = R++\n debug(name, index, value)\n t[name] = index\n src[index] = value\n safeSrc[index] = safe\n re[index] = new RegExp(value, isGlobal ? 'g' : undefined)\n safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)\n}\n\n// The following Regular Expressions can be used for tokenizing,\n// validating, and parsing SemVer version strings.\n\n// ## Numeric Identifier\n// A single `0`, or a non-zero digit followed by zero or more digits.\n\ncreateToken('NUMERICIDENTIFIER', '0|[1-9]\\\\d*')\ncreateToken('NUMERICIDENTIFIERLOOSE', '\\\\d+')\n\n// ## Non-numeric Identifier\n// Zero or more digits, followed by a letter or hyphen, and then zero or\n// more letters, digits, or hyphens.\n\ncreateToken('NONNUMERICIDENTIFIER', `\\\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)\n\n// ## Main Version\n// Three dot-separated numeric identifiers.\n\ncreateToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})`)\n\ncreateToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})`)\n\n// ## Pre-release Version Identifier\n// A numeric identifier, or a non-numeric identifier.\n// Non-numeric identifiers include numeric identifiers but can be longer.\n// Therefore non-numeric identifiers must go first.\n\ncreateToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]\n}|${src[t.NUMERICIDENTIFIER]})`)\n\ncreateToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]\n}|${src[t.NUMERICIDENTIFIERLOOSE]})`)\n\n// ## Pre-release Version\n// Hyphen, followed by one or more dot-separated pre-release version\n// identifiers.\n\ncreateToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIER]})*))`)\n\ncreateToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)\n\n// ## Build Metadata Identifier\n// Any combination of digits, letters, or hyphens.\n\ncreateToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)\n\n// ## Build Metadata\n// Plus sign, followed by one or more period-separated build metadata\n// identifiers.\n\ncreateToken('BUILD', `(?:\\\\+(${src[t.BUILDIDENTIFIER]\n}(?:\\\\.${src[t.BUILDIDENTIFIER]})*))`)\n\n// ## Full Version String\n// A main version, followed optionally by a pre-release version and\n// build metadata.\n\n// Note that the only major, minor, patch, and pre-release sections of\n// the version string are capturing groups. The build metadata is not a\n// capturing group, because it should not ever be used in version\n// comparison.\n\ncreateToken('FULLPLAIN', `v?${src[t.MAINVERSION]\n}${src[t.PRERELEASE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('FULL', `^${src[t.FULLPLAIN]}$`)\n\n// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.\n// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty\n// common in the npm registry.\ncreateToken('LOOSEPLAIN', `[v=\\\\s]*${src[t.MAINVERSIONLOOSE]\n}${src[t.PRERELEASELOOSE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)\n\ncreateToken('GTLT', '((?:<|>)?=?)')\n\n// Something like \"2.*\" or \"1.2.x\".\n// Note that \"x.x\" is a valid xRange identifier, meaning \"any version\"\n// Only the first item is strictly required.\ncreateToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`)\ncreateToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\\\*`)\n\ncreateToken('XRANGEPLAIN', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:${src[t.PRERELEASE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGEPLAINLOOSE', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:${src[t.PRERELEASELOOSE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAIN]}$`)\ncreateToken('XRANGELOOSE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Coercion.\n// Extract anything that could conceivably be a part of a valid semver\ncreateToken('COERCEPLAIN', `${'(^|[^\\\\d])' +\n '(\\\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)\ncreateToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\\\d])`)\ncreateToken('COERCEFULL', src[t.COERCEPLAIN] +\n `(?:${src[t.PRERELEASE]})?` +\n `(?:${src[t.BUILD]})?` +\n `(?:$|[^\\\\d])`)\ncreateToken('COERCERTL', src[t.COERCE], true)\ncreateToken('COERCERTLFULL', src[t.COERCEFULL], true)\n\n// Tilde ranges.\n// Meaning is \"reasonably at or greater than\"\ncreateToken('LONETILDE', '(?:~>?)')\n\ncreateToken('TILDETRIM', `(\\\\s*)${src[t.LONETILDE]}\\\\s+`, true)\nexports.tildeTrimReplace = '$1~'\n\ncreateToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Caret ranges.\n// Meaning is \"at least and backwards compatible with\"\ncreateToken('LONECARET', '(?:\\\\^)')\n\ncreateToken('CARETTRIM', `(\\\\s*)${src[t.LONECARET]}\\\\s+`, true)\nexports.caretTrimReplace = '$1^'\n\ncreateToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// A simple gt/lt/eq thing, or just \"\" to indicate \"any version\"\ncreateToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\\\s*(${src[t.LOOSEPLAIN]})$|^$`)\ncreateToken('COMPARATOR', `^${src[t.GTLT]}\\\\s*(${src[t.FULLPLAIN]})$|^$`)\n\n// An expression to strip any whitespace between the gtlt and the thing\n// it modifies, so that `> 1.2.3` ==> `>1.2.3`\ncreateToken('COMPARATORTRIM', `(\\\\s*)${src[t.GTLT]\n}\\\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)\nexports.comparatorTrimReplace = '$1$2$3'\n\n// Something like `1.2.3 - 1.2.4`\n// Note that these all use the loose form, because they'll be\n// checked against either the strict or loose comparator form\n// later.\ncreateToken('HYPHENRANGE', `^\\\\s*(${src[t.XRANGEPLAIN]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAIN]})` +\n `\\\\s*$`)\n\ncreateToken('HYPHENRANGELOOSE', `^\\\\s*(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s*$`)\n\n// Star ranges basically just allow anything at all.\ncreateToken('STAR', '(<|>)?=?\\\\s*\\\\*')\n// >=0.0.0 is like a star\ncreateToken('GTE0', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$')\ncreateToken('GTE0PRE', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$')\n","'use strict'\n\n// parse out just the options we care about\nconst looseOption = Object.freeze({ loose: true })\nconst emptyOpts = Object.freeze({ })\nconst parseOptions = options => {\n if (!options) {\n return emptyOpts\n }\n\n if (typeof options !== 'object') {\n return looseOption\n }\n\n return options\n}\nmodule.exports = parseOptions\n","'use strict'\n\nconst numeric = /^[0-9]+$/\nconst compareIdentifiers = (a, b) => {\n if (typeof a === 'number' && typeof b === 'number') {\n return a === b ? 0 : a < b ? -1 : 1\n }\n\n const anum = numeric.test(a)\n const bnum = numeric.test(b)\n\n if (anum && bnum) {\n a = +a\n b = +b\n }\n\n return a === b ? 0\n : (anum && !bnum) ? -1\n : (bnum && !anum) ? 1\n : a < b ? -1\n : 1\n}\n\nconst rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)\n\nmodule.exports = {\n compareIdentifiers,\n rcompareIdentifiers,\n}\n","'use strict'\n\nconst debug = require('../internal/debug')\nconst { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')\nconst { safeRe: re, t } = require('../internal/re')\n\nconst parseOptions = require('../internal/parse-options')\nconst { compareIdentifiers } = require('../internal/identifiers')\nclass SemVer {\n constructor (version, options) {\n options = parseOptions(options)\n\n if (version instanceof SemVer) {\n if (version.loose === !!options.loose &&\n version.includePrerelease === !!options.includePrerelease) {\n return version\n } else {\n version = version.version\n }\n } else if (typeof version !== 'string') {\n throw new TypeError(`Invalid version. Must be a string. Got type \"${typeof version}\".`)\n }\n\n if (version.length > MAX_LENGTH) {\n throw new TypeError(\n `version is longer than ${MAX_LENGTH} characters`\n )\n }\n\n debug('SemVer', version, options)\n this.options = options\n this.loose = !!options.loose\n // this isn't actually relevant for versions, but keep it so that we\n // don't run into trouble passing this.options around.\n this.includePrerelease = !!options.includePrerelease\n\n const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])\n\n if (!m) {\n throw new TypeError(`Invalid Version: ${version}`)\n }\n\n this.raw = version\n\n // these are actually numbers\n this.major = +m[1]\n this.minor = +m[2]\n this.patch = +m[3]\n\n if (this.major > MAX_SAFE_INTEGER || this.major < 0) {\n throw new TypeError('Invalid major version')\n }\n\n if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {\n throw new TypeError('Invalid minor version')\n }\n\n if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {\n throw new TypeError('Invalid patch version')\n }\n\n // numberify any prerelease numeric ids\n if (!m[4]) {\n this.prerelease = []\n } else {\n this.prerelease = m[4].split('.').map((id) => {\n if (/^[0-9]+$/.test(id)) {\n const num = +id\n if (num >= 0 && num < MAX_SAFE_INTEGER) {\n return num\n }\n }\n return id\n })\n }\n\n this.build = m[5] ? m[5].split('.') : []\n this.format()\n }\n\n format () {\n this.version = `${this.major}.${this.minor}.${this.patch}`\n if (this.prerelease.length) {\n this.version += `-${this.prerelease.join('.')}`\n }\n return this.version\n }\n\n toString () {\n return this.version\n }\n\n compare (other) {\n debug('SemVer.compare', this.version, this.options, other)\n if (!(other instanceof SemVer)) {\n if (typeof other === 'string' && other === this.version) {\n return 0\n }\n other = new SemVer(other, this.options)\n }\n\n if (other.version === this.version) {\n return 0\n }\n\n return this.compareMain(other) || this.comparePre(other)\n }\n\n compareMain (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n if (this.major < other.major) {\n return -1\n }\n if (this.major > other.major) {\n return 1\n }\n if (this.minor < other.minor) {\n return -1\n }\n if (this.minor > other.minor) {\n return 1\n }\n if (this.patch < other.patch) {\n return -1\n }\n if (this.patch > other.patch) {\n return 1\n }\n return 0\n }\n\n comparePre (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n // NOT having a prerelease is > having one\n if (this.prerelease.length && !other.prerelease.length) {\n return -1\n } else if (!this.prerelease.length && other.prerelease.length) {\n return 1\n } else if (!this.prerelease.length && !other.prerelease.length) {\n return 0\n }\n\n let i = 0\n do {\n const a = this.prerelease[i]\n const b = other.prerelease[i]\n debug('prerelease compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n compareBuild (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n let i = 0\n do {\n const a = this.build[i]\n const b = other.build[i]\n debug('build compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n // preminor will bump the version up to the next minor release, and immediately\n // down to pre-release. premajor and prepatch work the same way.\n inc (release, identifier, identifierBase) {\n if (release.startsWith('pre')) {\n if (!identifier && identifierBase === false) {\n throw new Error('invalid increment argument: identifier is empty')\n }\n // Avoid an invalid semver results\n if (identifier) {\n const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])\n if (!match || match[1] !== identifier) {\n throw new Error(`invalid identifier: ${identifier}`)\n }\n }\n }\n\n switch (release) {\n case 'premajor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', identifier, identifierBase)\n break\n case 'preminor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor++\n this.inc('pre', identifier, identifierBase)\n break\n case 'prepatch':\n // If this is already a prerelease, it will bump to the next version\n // drop any prereleases that might already exist, since they are not\n // relevant at this point.\n this.prerelease.length = 0\n this.inc('patch', identifier, identifierBase)\n this.inc('pre', identifier, identifierBase)\n break\n // If the input is a non-prerelease version, this acts the same as\n // prepatch.\n case 'prerelease':\n if (this.prerelease.length === 0) {\n this.inc('patch', identifier, identifierBase)\n }\n this.inc('pre', identifier, identifierBase)\n break\n case 'release':\n if (this.prerelease.length === 0) {\n throw new Error(`version ${this.raw} is not a prerelease`)\n }\n this.prerelease.length = 0\n break\n\n case 'major':\n // If this is a pre-major version, bump up to the same major version.\n // Otherwise increment major.\n // 1.0.0-5 bumps to 1.0.0\n // 1.1.0 bumps to 2.0.0\n if (\n this.minor !== 0 ||\n this.patch !== 0 ||\n this.prerelease.length === 0\n ) {\n this.major++\n }\n this.minor = 0\n this.patch = 0\n this.prerelease = []\n break\n case 'minor':\n // If this is a pre-minor version, bump up to the same minor version.\n // Otherwise increment minor.\n // 1.2.0-5 bumps to 1.2.0\n // 1.2.1 bumps to 1.3.0\n if (this.patch !== 0 || this.prerelease.length === 0) {\n this.minor++\n }\n this.patch = 0\n this.prerelease = []\n break\n case 'patch':\n // If this is not a pre-release version, it will increment the patch.\n // If it is a pre-release it will bump up to the same patch version.\n // 1.2.0-5 patches to 1.2.0\n // 1.2.0 patches to 1.2.1\n if (this.prerelease.length === 0) {\n this.patch++\n }\n this.prerelease = []\n break\n // This probably shouldn't be used publicly.\n // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.\n case 'pre': {\n const base = Number(identifierBase) ? 1 : 0\n\n if (this.prerelease.length === 0) {\n this.prerelease = [base]\n } else {\n let i = this.prerelease.length\n while (--i >= 0) {\n if (typeof this.prerelease[i] === 'number') {\n this.prerelease[i]++\n i = -2\n }\n }\n if (i === -1) {\n // didn't increment anything\n if (identifier === this.prerelease.join('.') && identifierBase === false) {\n throw new Error('invalid increment argument: identifier already exists')\n }\n this.prerelease.push(base)\n }\n }\n if (identifier) {\n // 1.2.0-beta.1 bumps to 1.2.0-beta.2,\n // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0\n let prerelease = [identifier, base]\n if (identifierBase === false) {\n prerelease = [identifier]\n }\n if (compareIdentifiers(this.prerelease[0], identifier) === 0) {\n if (isNaN(this.prerelease[1])) {\n this.prerelease = prerelease\n }\n } else {\n this.prerelease = prerelease\n }\n }\n break\n }\n default:\n throw new Error(`invalid increment argument: ${release}`)\n }\n this.raw = this.format()\n if (this.build.length) {\n this.raw += `+${this.build.join('.')}`\n }\n return this\n }\n}\n\nmodule.exports = SemVer\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst parse = (version, options, throwErrors = false) => {\n if (version instanceof SemVer) {\n return version\n }\n try {\n return new SemVer(version, options)\n } catch (er) {\n if (!throwErrors) {\n return null\n }\n throw er\n }\n}\n\nmodule.exports = parse\n","'use strict'\n\nconst parse = require('./parse')\nconst valid = (version, options) => {\n const v = parse(version, options)\n return v ? v.version : null\n}\nmodule.exports = valid\n","'use strict'\n\nconst parse = require('./parse')\nconst clean = (version, options) => {\n const s = parse(version.trim().replace(/^[=v]+/, ''), options)\n return s ? s.version : null\n}\nmodule.exports = clean\n","'use strict'\n\nconst SemVer = require('../classes/semver')\n\nconst inc = (version, release, options, identifier, identifierBase) => {\n if (typeof (options) === 'string') {\n identifierBase = identifier\n identifier = options\n options = undefined\n }\n\n try {\n return new SemVer(\n version instanceof SemVer ? version.version : version,\n options\n ).inc(release, identifier, identifierBase).version\n } catch (er) {\n return null\n }\n}\nmodule.exports = inc\n","'use strict'\n\nconst parse = require('./parse.js')\n\nconst diff = (version1, version2) => {\n const v1 = parse(version1, null, true)\n const v2 = parse(version2, null, true)\n const comparison = v1.compare(v2)\n\n if (comparison === 0) {\n return null\n }\n\n const v1Higher = comparison > 0\n const highVersion = v1Higher ? v1 : v2\n const lowVersion = v1Higher ? v2 : v1\n const highHasPre = !!highVersion.prerelease.length\n const lowHasPre = !!lowVersion.prerelease.length\n\n if (lowHasPre && !highHasPre) {\n // Going from prerelease -> no prerelease requires some special casing\n\n // If the low version has only a major, then it will always be a major\n // Some examples:\n // 1.0.0-1 -> 1.0.0\n // 1.0.0-1 -> 1.1.1\n // 1.0.0-1 -> 2.0.0\n if (!lowVersion.patch && !lowVersion.minor) {\n return 'major'\n }\n\n // If the main part has no difference\n if (lowVersion.compareMain(highVersion) === 0) {\n if (lowVersion.minor && !lowVersion.patch) {\n return 'minor'\n }\n return 'patch'\n }\n }\n\n // add the `pre` prefix if we are going to a prerelease version\n const prefix = highHasPre ? 'pre' : ''\n\n if (v1.major !== v2.major) {\n return prefix + 'major'\n }\n\n if (v1.minor !== v2.minor) {\n return prefix + 'minor'\n }\n\n if (v1.patch !== v2.patch) {\n return prefix + 'patch'\n }\n\n // high and low are prereleases\n return 'prerelease'\n}\n\nmodule.exports = diff\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst major = (a, loose) => new SemVer(a, loose).major\nmodule.exports = major\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst minor = (a, loose) => new SemVer(a, loose).minor\nmodule.exports = minor\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst patch = (a, loose) => new SemVer(a, loose).patch\nmodule.exports = patch\n","'use strict'\n\nconst parse = require('./parse')\nconst prerelease = (version, options) => {\n const parsed = parse(version, options)\n return (parsed && parsed.prerelease.length) ? parsed.prerelease : null\n}\nmodule.exports = prerelease\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst compare = (a, b, loose) =>\n new SemVer(a, loose).compare(new SemVer(b, loose))\n\nmodule.exports = compare\n","'use strict'\n\nconst compare = require('./compare')\nconst rcompare = (a, b, loose) => compare(b, a, loose)\nmodule.exports = rcompare\n","'use strict'\n\nconst compare = require('./compare')\nconst compareLoose = (a, b) => compare(a, b, true)\nmodule.exports = compareLoose\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst compareBuild = (a, b, loose) => {\n const versionA = new SemVer(a, loose)\n const versionB = new SemVer(b, loose)\n return versionA.compare(versionB) || versionA.compareBuild(versionB)\n}\nmodule.exports = compareBuild\n","'use strict'\n\nconst compareBuild = require('./compare-build')\nconst sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))\nmodule.exports = sort\n","'use strict'\n\nconst compareBuild = require('./compare-build')\nconst rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))\nmodule.exports = rsort\n","'use strict'\n\nconst compare = require('./compare')\nconst gt = (a, b, loose) => compare(a, b, loose) > 0\nmodule.exports = gt\n","'use strict'\n\nconst compare = require('./compare')\nconst lt = (a, b, loose) => compare(a, b, loose) < 0\nmodule.exports = lt\n","'use strict'\n\nconst compare = require('./compare')\nconst eq = (a, b, loose) => compare(a, b, loose) === 0\nmodule.exports = eq\n","'use strict'\n\nconst compare = require('./compare')\nconst neq = (a, b, loose) => compare(a, b, loose) !== 0\nmodule.exports = neq\n","'use strict'\n\nconst compare = require('./compare')\nconst gte = (a, b, loose) => compare(a, b, loose) >= 0\nmodule.exports = gte\n","'use strict'\n\nconst compare = require('./compare')\nconst lte = (a, b, loose) => compare(a, b, loose) <= 0\nmodule.exports = lte\n","'use strict'\n\nconst eq = require('./eq')\nconst neq = require('./neq')\nconst gt = require('./gt')\nconst gte = require('./gte')\nconst lt = require('./lt')\nconst lte = require('./lte')\n\nconst cmp = (a, op, b, loose) => {\n switch (op) {\n case '===':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a === b\n\n case '!==':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a !== b\n\n case '':\n case '=':\n case '==':\n return eq(a, b, loose)\n\n case '!=':\n return neq(a, b, loose)\n\n case '>':\n return gt(a, b, loose)\n\n case '>=':\n return gte(a, b, loose)\n\n case '<':\n return lt(a, b, loose)\n\n case '<=':\n return lte(a, b, loose)\n\n default:\n throw new TypeError(`Invalid operator: ${op}`)\n }\n}\nmodule.exports = cmp\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst parse = require('./parse')\nconst { safeRe: re, t } = require('../internal/re')\n\nconst coerce = (version, options) => {\n if (version instanceof SemVer) {\n return version\n }\n\n if (typeof version === 'number') {\n version = String(version)\n }\n\n if (typeof version !== 'string') {\n return null\n }\n\n options = options || {}\n\n let match = null\n if (!options.rtl) {\n match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])\n } else {\n // Find the right-most coercible string that does not share\n // a terminus with a more left-ward coercible string.\n // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'\n // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'\n //\n // Walk through the string checking with a /g regexp\n // Manually set the index so as to pick up overlapping matches.\n // Stop when we get a match that ends at the string end, since no\n // coercible string can be more right-ward without the same terminus.\n const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]\n let next\n while ((next = coerceRtlRegex.exec(version)) &&\n (!match || match.index + match[0].length !== version.length)\n ) {\n if (!match ||\n next.index + next[0].length !== match.index + match[0].length) {\n match = next\n }\n coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length\n }\n // leave it in a clean state\n coerceRtlRegex.lastIndex = -1\n }\n\n if (match === null) {\n return null\n }\n\n const major = match[2]\n const minor = match[3] || '0'\n const patch = match[4] || '0'\n const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''\n const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''\n\n return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)\n}\nmodule.exports = coerce\n","'use strict'\n\nconst parse = require('./parse')\nconst constants = require('../internal/constants')\nconst SemVer = require('../classes/semver')\n\nconst truncate = (version, truncation, options) => {\n if (!constants.RELEASE_TYPES.includes(truncation)) {\n return null\n }\n\n const clonedVersion = cloneInputVersion(version, options)\n return clonedVersion && doTruncation(clonedVersion, truncation)\n}\n\nconst cloneInputVersion = (version, options) => {\n const versionStringToParse = (\n version instanceof SemVer ? version.version : version\n )\n\n return parse(versionStringToParse, options)\n}\n\nconst doTruncation = (version, truncation) => {\n if (isPrerelease(truncation)) {\n return version.version\n }\n\n version.prerelease = []\n\n switch (truncation) {\n case 'major':\n version.minor = 0\n version.patch = 0\n break\n case 'minor':\n version.patch = 0\n break\n }\n\n return version.format()\n}\n\nconst isPrerelease = (type) => {\n return type.startsWith('pre')\n}\n\nmodule.exports = truncate\n","'use strict'\n\nclass LRUCache {\n constructor () {\n this.max = 1000\n this.map = new Map()\n }\n\n get (key) {\n const value = this.map.get(key)\n if (value === undefined) {\n return undefined\n } else {\n // Remove the key from the map and add it to the end\n this.map.delete(key)\n this.map.set(key, value)\n return value\n }\n }\n\n delete (key) {\n return this.map.delete(key)\n }\n\n set (key, value) {\n const deleted = this.delete(key)\n\n if (!deleted && value !== undefined) {\n // If cache is full, delete the least recently used item\n if (this.map.size >= this.max) {\n const firstKey = this.map.keys().next().value\n this.delete(firstKey)\n }\n\n this.map.set(key, value)\n }\n\n return this\n }\n}\n\nmodule.exports = LRUCache\n","'use strict'\n\nconst SPACE_CHARACTERS = /\\s+/g\n\n// hoisted class for cyclic dependency\nclass Range {\n constructor (range, options) {\n options = parseOptions(options)\n\n if (range instanceof Range) {\n if (\n range.loose === !!options.loose &&\n range.includePrerelease === !!options.includePrerelease\n ) {\n return range\n } else {\n return new Range(range.raw, options)\n }\n }\n\n if (range instanceof Comparator) {\n // just put it in the set and return\n this.raw = range.value\n this.set = [[range]]\n this.formatted = undefined\n return this\n }\n\n this.options = options\n this.loose = !!options.loose\n this.includePrerelease = !!options.includePrerelease\n\n // First reduce all whitespace as much as possible so we do not have to rely\n // on potentially slow regexes like \\s*. This is then stored and used for\n // future error messages as well.\n this.raw = range.trim().replace(SPACE_CHARACTERS, ' ')\n\n // First, split on ||\n this.set = this.raw\n .split('||')\n // map the range to a 2d array of comparators\n .map(r => this.parseRange(r.trim()))\n // throw out any comparator lists that are empty\n // this generally means that it was not a valid range, which is allowed\n // in loose mode, but will still throw if the WHOLE range is invalid.\n .filter(c => c.length)\n\n if (!this.set.length) {\n throw new TypeError(`Invalid SemVer Range: ${this.raw}`)\n }\n\n // if we have any that are not the null set, throw out null sets.\n if (this.set.length > 1) {\n // keep the first one, in case they're all null sets\n const first = this.set[0]\n this.set = this.set.filter(c => !isNullSet(c[0]))\n if (this.set.length === 0) {\n this.set = [first]\n } else if (this.set.length > 1) {\n // if we have any that are *, then the range is just *\n for (const c of this.set) {\n if (c.length === 1 && isAny(c[0])) {\n this.set = [c]\n break\n }\n }\n }\n }\n\n this.formatted = undefined\n }\n\n get range () {\n if (this.formatted === undefined) {\n this.formatted = ''\n for (let i = 0; i < this.set.length; i++) {\n if (i > 0) {\n this.formatted += '||'\n }\n const comps = this.set[i]\n for (let k = 0; k < comps.length; k++) {\n if (k > 0) {\n this.formatted += ' '\n }\n this.formatted += comps[k].toString().trim()\n }\n }\n }\n return this.formatted\n }\n\n format () {\n return this.range\n }\n\n toString () {\n return this.range\n }\n\n parseRange (range) {\n // strip build metadata so it can't bleed into the version\n range = range.replace(BUILDSTRIPRE, '')\n\n // memoize range parsing for performance.\n // this is a very hot path, and fully deterministic.\n const memoOpts =\n (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |\n (this.options.loose && FLAG_LOOSE)\n const memoKey = memoOpts + ':' + range\n const cached = cache.get(memoKey)\n if (cached) {\n return cached\n }\n\n const loose = this.options.loose\n // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`\n const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]\n range = range.replace(hr, hyphenReplace(this.options.includePrerelease))\n debug('hyphen replace', range)\n\n // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`\n range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)\n debug('comparator trim', range)\n\n // `~ 1.2.3` => `~1.2.3`\n range = range.replace(re[t.TILDETRIM], tildeTrimReplace)\n debug('tilde trim', range)\n\n // `^ 1.2.3` => `^1.2.3`\n range = range.replace(re[t.CARETTRIM], caretTrimReplace)\n debug('caret trim', range)\n\n // At this point, the range is completely trimmed and\n // ready to be split into comparators.\n\n let rangeList = range\n .split(' ')\n .map(comp => parseComparator(comp, this.options))\n .join(' ')\n .split(/\\s+/)\n // >=0.0.0 is equivalent to *\n .map(comp => replaceGTE0(comp, this.options))\n\n if (loose) {\n // in loose mode, throw out any that are not valid comparators\n rangeList = rangeList.filter(comp => {\n debug('loose invalid filter', comp, this.options)\n return !!comp.match(re[t.COMPARATORLOOSE])\n })\n }\n debug('range list', rangeList)\n\n // if any comparators are the null set, then replace with JUST null set\n // if more than one comparator, remove any * comparators\n // also, don't include the same comparator more than once\n const rangeMap = new Map()\n const comparators = rangeList.map(comp => new Comparator(comp, this.options))\n for (const comp of comparators) {\n if (isNullSet(comp)) {\n return [comp]\n }\n rangeMap.set(comp.value, comp)\n }\n if (rangeMap.size > 1 && rangeMap.has('')) {\n rangeMap.delete('')\n }\n\n const result = [...rangeMap.values()]\n cache.set(memoKey, result)\n return result\n }\n\n intersects (range, options) {\n if (!(range instanceof Range)) {\n throw new TypeError('a Range is required')\n }\n\n return this.set.some((thisComparators) => {\n return (\n isSatisfiable(thisComparators, options) &&\n range.set.some((rangeComparators) => {\n return (\n isSatisfiable(rangeComparators, options) &&\n thisComparators.every((thisComparator) => {\n return rangeComparators.every((rangeComparator) => {\n return thisComparator.intersects(rangeComparator, options)\n })\n })\n )\n })\n )\n })\n }\n\n // if ANY of the sets match ALL of its comparators, then pass\n test (version) {\n if (!version) {\n return false\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n for (let i = 0; i < this.set.length; i++) {\n if (testSet(this.set[i], version, this.options)) {\n return true\n }\n }\n return false\n }\n}\n\nmodule.exports = Range\n\nconst LRU = require('../internal/lrucache')\nconst cache = new LRU()\n\nconst parseOptions = require('../internal/parse-options')\nconst Comparator = require('./comparator')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst {\n safeRe: re,\n src,\n t,\n comparatorTrimReplace,\n tildeTrimReplace,\n caretTrimReplace,\n} = require('../internal/re')\nconst { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')\n\n// unbounded global build-metadata stripper used by parseRange\nconst BUILDSTRIPRE = new RegExp(src[t.BUILD], 'g')\n\nconst isNullSet = c => c.value === '<0.0.0-0'\nconst isAny = c => c.value === ''\n\n// take a set of comparators and determine whether there\n// exists a version which can satisfy it\nconst isSatisfiable = (comparators, options) => {\n let result = true\n const remainingComparators = comparators.slice()\n let testComparator = remainingComparators.pop()\n\n while (result && remainingComparators.length) {\n result = remainingComparators.every((otherComparator) => {\n return testComparator.intersects(otherComparator, options)\n })\n\n testComparator = remainingComparators.pop()\n }\n\n return result\n}\n\n// comprised of xranges, tildes, stars, and gtlt's at this point.\n// already replaced the hyphen ranges\n// turn into a set of JUST comparators.\nconst parseComparator = (comp, options) => {\n comp = comp.replace(re[t.BUILD], '')\n debug('comp', comp, options)\n comp = replaceCarets(comp, options)\n debug('caret', comp)\n comp = replaceTildes(comp, options)\n debug('tildes', comp)\n comp = replaceXRanges(comp, options)\n debug('xrange', comp)\n comp = replaceStars(comp, options)\n debug('stars', comp)\n return comp\n}\n\nconst isX = id => !id || id.toLowerCase() === 'x' || id === '*'\n\n// ~, ~> --> * (any, kinda silly)\n// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0\n// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0\n// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0\n// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0\n// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0\n// ~0.0.1 --> >=0.0.1 <0.1.0-0\nconst replaceTildes = (comp, options) => {\n return comp\n .trim()\n .split(/\\s+/)\n .map((c) => replaceTilde(c, options))\n .join(' ')\n}\n\nconst replaceTilde = (comp, options) => {\n const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('tilde', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0 <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n // ~1.2 == >=1.2.0 <1.3.0-0\n ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`\n } else if (pr) {\n debug('replaceTilde pr', pr)\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n } else {\n // ~1.2.3 == >=1.2.3 <1.3.0-0\n ret = `>=${M}.${m}.${p\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('tilde return', ret)\n return ret\n })\n}\n\n// ^ --> * (any, kinda silly)\n// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0\n// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0\n// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0\n// ^1.2.3 --> >=1.2.3 <2.0.0-0\n// ^1.2.0 --> >=1.2.0 <2.0.0-0\n// ^0.0.1 --> >=0.0.1 <0.0.2-0\n// ^0.1.0 --> >=0.1.0 <0.2.0-0\nconst replaceCarets = (comp, options) => {\n return comp\n .trim()\n .split(/\\s+/)\n .map((c) => replaceCaret(c, options))\n .join(' ')\n}\n\nconst replaceCaret = (comp, options) => {\n debug('caret', comp, options)\n const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]\n const z = options.includePrerelease ? '-0' : ''\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('caret', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n if (M === '0') {\n ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`\n } else {\n ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`\n }\n } else if (pr) {\n debug('replaceCaret pr', pr)\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${+M + 1}.0.0-0`\n }\n } else {\n debug('no pr')\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p\n } <${+M + 1}.0.0-0`\n }\n }\n\n debug('caret return', ret)\n return ret\n })\n}\n\nconst replaceXRanges = (comp, options) => {\n debug('replaceXRanges', comp, options)\n return comp\n .split(/\\s+/)\n .map((c) => replaceXRange(c, options))\n .join(' ')\n}\n\nconst replaceXRange = (comp, options) => {\n comp = comp.trim()\n const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]\n return comp.replace(r, (ret, gtlt, M, m, p, pr) => {\n debug('xRange', comp, ret, gtlt, M, m, p, pr)\n const xM = isX(M)\n const xm = xM || isX(m)\n const xp = xm || isX(p)\n const anyX = xp\n\n if (gtlt === '=' && anyX) {\n gtlt = ''\n }\n\n // if we're including prereleases in the match, then we need\n // to fix this to -0, the lowest possible prerelease value\n pr = options.includePrerelease ? '-0' : ''\n\n if (xM) {\n if (gtlt === '>' || gtlt === '<') {\n // nothing is allowed\n ret = '<0.0.0-0'\n } else {\n // nothing is forbidden\n ret = '*'\n }\n } else if (gtlt && anyX) {\n // we know patch is an x, because we have any x at all.\n // replace X with 0\n if (xm) {\n m = 0\n }\n p = 0\n\n if (gtlt === '>') {\n // >1 => >=2.0.0\n // >1.2 => >=1.3.0\n gtlt = '>='\n if (xm) {\n M = +M + 1\n m = 0\n p = 0\n } else {\n m = +m + 1\n p = 0\n }\n } else if (gtlt === '<=') {\n // <=0.7.x is actually <0.8.0, since any 0.7.x should\n // pass. Similarly, <=7.x is actually <8.0.0, etc.\n gtlt = '<'\n if (xm) {\n M = +M + 1\n } else {\n m = +m + 1\n }\n }\n\n if (gtlt === '<') {\n pr = '-0'\n }\n\n ret = `${gtlt + M}.${m}.${p}${pr}`\n } else if (xm) {\n ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`\n } else if (xp) {\n ret = `>=${M}.${m}.0${pr\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('xRange return', ret)\n\n return ret\n })\n}\n\n// Because * is AND-ed with everything else in the comparator,\n// and '' means \"any version\", just remove the *s entirely.\nconst replaceStars = (comp, options) => {\n debug('replaceStars', comp, options)\n // Looseness is ignored here. star is always as loose as it gets!\n return comp\n .trim()\n .replace(re[t.STAR], '')\n}\n\nconst replaceGTE0 = (comp, options) => {\n debug('replaceGTE0', comp, options)\n return comp\n .trim()\n .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')\n}\n\n// This function is passed to string.replace(re[t.HYPHENRANGE])\n// M, m, patch, prerelease, build\n// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5\n// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do\n// 1.2 - 3.4 => >=1.2.0 <3.5.0-0\n// TODO build?\nconst hyphenReplace = incPr => ($0,\n from, fM, fm, fp, fpr, fb,\n to, tM, tm, tp, tpr) => {\n if (isX(fM)) {\n from = ''\n } else if (isX(fm)) {\n from = `>=${fM}.0.0${incPr ? '-0' : ''}`\n } else if (isX(fp)) {\n from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`\n } else if (fpr) {\n from = `>=${from}`\n } else {\n from = `>=${from}${incPr ? '-0' : ''}`\n }\n\n if (isX(tM)) {\n to = ''\n } else if (isX(tm)) {\n to = `<${+tM + 1}.0.0-0`\n } else if (isX(tp)) {\n to = `<${tM}.${+tm + 1}.0-0`\n } else if (tpr) {\n to = `<=${tM}.${tm}.${tp}-${tpr}`\n } else if (incPr) {\n to = `<${tM}.${tm}.${+tp + 1}-0`\n } else {\n to = `<=${to}`\n }\n\n return `${from} ${to}`.trim()\n}\n\nconst testSet = (set, version, options) => {\n for (let i = 0; i < set.length; i++) {\n if (!set[i].test(version)) {\n return false\n }\n }\n\n if (version.prerelease.length && !options.includePrerelease) {\n // Find the set of versions that are allowed to have prereleases\n // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0\n // That should allow `1.2.3-pr.2` to pass.\n // However, `1.2.4-alpha.notready` should NOT be allowed,\n // even though it's within the range set by the comparators.\n for (let i = 0; i < set.length; i++) {\n debug(set[i].semver)\n if (set[i].semver === Comparator.ANY) {\n continue\n }\n\n if (set[i].semver.prerelease.length > 0) {\n const allowed = set[i].semver\n if (allowed.major === version.major &&\n allowed.minor === version.minor &&\n allowed.patch === version.patch) {\n return true\n }\n }\n }\n\n // Version has a -pre, but it's not one of the ones we like.\n return false\n }\n\n return true\n}\n","'use strict'\n\nconst ANY = Symbol('SemVer ANY')\n// hoisted class for cyclic dependency\nclass Comparator {\n static get ANY () {\n return ANY\n }\n\n constructor (comp, options) {\n options = parseOptions(options)\n\n if (comp instanceof Comparator) {\n if (comp.loose === !!options.loose) {\n return comp\n } else {\n comp = comp.value\n }\n }\n\n comp = comp.trim().split(/\\s+/).join(' ')\n debug('comparator', comp, options)\n this.options = options\n this.loose = !!options.loose\n this.parse(comp)\n\n if (this.semver === ANY) {\n this.value = ''\n } else {\n this.value = this.operator + this.semver.version\n }\n\n debug('comp', this)\n }\n\n parse (comp) {\n const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n const m = comp.match(r)\n\n if (!m) {\n throw new TypeError(`Invalid comparator: ${comp}`)\n }\n\n this.operator = m[1] !== undefined ? m[1] : ''\n if (this.operator === '=') {\n this.operator = ''\n }\n\n // if it literally is just '>' or '' then allow anything.\n if (!m[2]) {\n this.semver = ANY\n } else {\n this.semver = new SemVer(m[2], this.options.loose)\n }\n }\n\n toString () {\n return this.value\n }\n\n test (version) {\n debug('Comparator.test', version, this.options.loose)\n\n if (this.semver === ANY || version === ANY) {\n return true\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n return cmp(version, this.operator, this.semver, this.options)\n }\n\n intersects (comp, options) {\n if (!(comp instanceof Comparator)) {\n throw new TypeError('a Comparator is required')\n }\n\n if (this.operator === '') {\n if (this.value === '') {\n return true\n }\n return new Range(comp.value, options).test(this.value)\n } else if (comp.operator === '') {\n if (comp.value === '') {\n return true\n }\n return new Range(this.value, options).test(comp.semver)\n }\n\n options = parseOptions(options)\n\n // Special cases where nothing can possibly be lower\n if (options.includePrerelease &&\n (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {\n return false\n }\n if (!options.includePrerelease &&\n (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {\n return false\n }\n\n // Same direction increasing (> or >=)\n if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {\n return true\n }\n // Same direction decreasing (< or <=)\n if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {\n return true\n }\n // same SemVer and both sides are inclusive (<= or >=)\n if (\n (this.semver.version === comp.semver.version) &&\n this.operator.includes('=') && comp.operator.includes('=')) {\n return true\n }\n // opposite directions less than\n if (cmp(this.semver, '<', comp.semver, options) &&\n this.operator.startsWith('>') && comp.operator.startsWith('<')) {\n return true\n }\n // opposite directions greater than\n if (cmp(this.semver, '>', comp.semver, options) &&\n this.operator.startsWith('<') && comp.operator.startsWith('>')) {\n return true\n }\n return false\n }\n}\n\nmodule.exports = Comparator\n\nconst parseOptions = require('../internal/parse-options')\nconst { safeRe: re, t } = require('../internal/re')\nconst cmp = require('../functions/cmp')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst Range = require('./range')\n","'use strict'\n\nconst Range = require('../classes/range')\nconst satisfies = (version, range, options) => {\n try {\n range = new Range(range, options)\n } catch (er) {\n return false\n }\n return range.test(version)\n}\nmodule.exports = satisfies\n","'use strict'\n\nconst Range = require('../classes/range')\n\n// Mostly just for testing and legacy API reasons\nconst toComparators = (range, options) =>\n new Range(range, options).set\n .map(comp => comp.map(c => c.value).join(' ').trim().split(' '))\n\nmodule.exports = toComparators\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst Range = require('../classes/range')\n\nconst maxSatisfying = (versions, range, options) => {\n let max = null\n let maxSV = null\n let rangeObj = null\n try {\n rangeObj = new Range(range, options)\n } catch (er) {\n return null\n }\n versions.forEach((v) => {\n if (rangeObj.test(v)) {\n // satisfies(v, range, options)\n if (!max || maxSV.compare(v) === -1) {\n // compare(max, v, true)\n max = v\n maxSV = new SemVer(max, options)\n }\n }\n })\n return max\n}\nmodule.exports = maxSatisfying\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst Range = require('../classes/range')\nconst minSatisfying = (versions, range, options) => {\n let min = null\n let minSV = null\n let rangeObj = null\n try {\n rangeObj = new Range(range, options)\n } catch (er) {\n return null\n }\n versions.forEach((v) => {\n if (rangeObj.test(v)) {\n // satisfies(v, range, options)\n if (!min || minSV.compare(v) === 1) {\n // compare(min, v, true)\n min = v\n minSV = new SemVer(min, options)\n }\n }\n })\n return min\n}\nmodule.exports = minSatisfying\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst Range = require('../classes/range')\nconst gt = require('../functions/gt')\n\nconst minVersion = (range, loose) => {\n range = new Range(range, loose)\n\n let minver = new SemVer('0.0.0')\n if (range.test(minver)) {\n return minver\n }\n\n minver = new SemVer('0.0.0-0')\n if (range.test(minver)) {\n return minver\n }\n\n minver = null\n for (let i = 0; i < range.set.length; ++i) {\n const comparators = range.set[i]\n\n let setMin = null\n comparators.forEach((comparator) => {\n // Clone to avoid manipulating the comparator's semver object.\n const compver = new SemVer(comparator.semver.version)\n switch (comparator.operator) {\n case '>':\n if (compver.prerelease.length === 0) {\n compver.patch++\n } else {\n compver.prerelease.push(0)\n }\n compver.raw = compver.format()\n /* fallthrough */\n case '':\n case '>=':\n if (!setMin || gt(compver, setMin)) {\n setMin = compver\n }\n break\n case '<':\n case '<=':\n /* Ignore maximum versions */\n break\n /* istanbul ignore next */\n default:\n throw new Error(`Unexpected operation: ${comparator.operator}`)\n }\n })\n if (setMin && (!minver || gt(minver, setMin))) {\n minver = setMin\n }\n }\n\n if (minver && range.test(minver)) {\n return minver\n }\n\n return null\n}\nmodule.exports = minVersion\n","'use strict'\n\nconst Range = require('../classes/range')\nconst validRange = (range, options) => {\n try {\n // Return '*' instead of '' so that truthiness works.\n // This will throw if it's invalid anyway\n return new Range(range, options).range || '*'\n } catch (er) {\n return null\n }\n}\nmodule.exports = validRange\n","'use strict'\n\nconst SemVer = require('../classes/semver')\nconst Comparator = require('../classes/comparator')\nconst { ANY } = Comparator\nconst Range = require('../classes/range')\nconst satisfies = require('../functions/satisfies')\nconst gt = require('../functions/gt')\nconst lt = require('../functions/lt')\nconst lte = require('../functions/lte')\nconst gte = require('../functions/gte')\n\nconst outside = (version, range, hilo, options) => {\n version = new SemVer(version, options)\n range = new Range(range, options)\n\n let gtfn, ltefn, ltfn, comp, ecomp\n switch (hilo) {\n case '>':\n gtfn = gt\n ltefn = lte\n ltfn = lt\n comp = '>'\n ecomp = '>='\n break\n case '<':\n gtfn = lt\n ltefn = gte\n ltfn = gt\n comp = '<'\n ecomp = '<='\n break\n default:\n throw new TypeError('Must provide a hilo val of \"<\" or \">\"')\n }\n\n // If it satisfies the range it is not outside\n if (satisfies(version, range, options)) {\n return false\n }\n\n // From now on, variable terms are as if we're in \"gtr\" mode.\n // but note that everything is flipped for the \"ltr\" function.\n\n for (let i = 0; i < range.set.length; ++i) {\n const comparators = range.set[i]\n\n let high = null\n let low = null\n\n comparators.forEach((comparator) => {\n if (comparator.semver === ANY) {\n comparator = new Comparator('>=0.0.0')\n }\n high = high || comparator\n low = low || comparator\n if (gtfn(comparator.semver, high.semver, options)) {\n high = comparator\n } else if (ltfn(comparator.semver, low.semver, options)) {\n low = comparator\n }\n })\n\n // If the edge version comparator has a operator then our version\n // isn't outside it\n if (high.operator === comp || high.operator === ecomp) {\n return false\n }\n\n // If the lowest version comparator has an operator and our version\n // is less than it then it isn't higher than the range\n if ((!low.operator || low.operator === comp) &&\n ltefn(version, low.semver)) {\n return false\n } else if (low.operator === ecomp && ltfn(version, low.semver)) {\n return false\n }\n }\n return true\n}\n\nmodule.exports = outside\n","'use strict'\n\n// Determine if version is greater than all the versions possible in the range.\nconst outside = require('./outside')\nconst gtr = (version, range, options) => outside(version, range, '>', options)\nmodule.exports = gtr\n","'use strict'\n\nconst outside = require('./outside')\n// Determine if version is less than all the versions possible in the range\nconst ltr = (version, range, options) => outside(version, range, '<', options)\nmodule.exports = ltr\n","'use strict'\n\nconst Range = require('../classes/range')\nconst intersects = (r1, r2, options) => {\n r1 = new Range(r1, options)\n r2 = new Range(r2, options)\n return r1.intersects(r2, options)\n}\nmodule.exports = intersects\n","'use strict'\n\n// given a set of versions and a range, create a \"simplified\" range\n// that includes the same versions that the original range does\n// If the original range is shorter than the simplified one, return that.\nconst satisfies = require('../functions/satisfies.js')\nconst compare = require('../functions/compare.js')\nmodule.exports = (versions, range, options) => {\n const set = []\n let first = null\n let prev = null\n const v = versions.sort((a, b) => compare(a, b, options))\n for (const version of v) {\n const included = satisfies(version, range, options)\n if (included) {\n prev = version\n if (!first) {\n first = version\n }\n } else {\n if (prev) {\n set.push([first, prev])\n }\n prev = null\n first = null\n }\n }\n if (first) {\n set.push([first, null])\n }\n\n const ranges = []\n for (const [min, max] of set) {\n if (min === max) {\n ranges.push(min)\n } else if (!max && min === v[0]) {\n ranges.push('*')\n } else if (!max) {\n ranges.push(`>=${min}`)\n } else if (min === v[0]) {\n ranges.push(`<=${max}`)\n } else {\n ranges.push(`${min} - ${max}`)\n }\n }\n const simplified = ranges.join(' || ')\n const original = typeof range.raw === 'string' ? range.raw : String(range)\n return simplified.length < original.length ? simplified : range\n}\n","'use strict'\n\nconst Range = require('../classes/range.js')\nconst Comparator = require('../classes/comparator.js')\nconst { ANY } = Comparator\nconst satisfies = require('../functions/satisfies.js')\nconst compare = require('../functions/compare.js')\n\n// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:\n// - Every simple range `r1, r2, ...` is a null set, OR\n// - Every simple range `r1, r2, ...` which is not a null set is a subset of\n// some `R1, R2, ...`\n//\n// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:\n// - If c is only the ANY comparator\n// - If C is only the ANY comparator, return true\n// - Else if in prerelease mode, return false\n// - else replace c with `[>=0.0.0]`\n// - If C is only the ANY comparator\n// - if in prerelease mode, return true\n// - else replace C with `[>=0.0.0]`\n// - Let EQ be the set of = comparators in c\n// - If EQ is more than one, return true (null set)\n// - Let GT be the highest > or >= comparator in c\n// - Let LT be the lowest < or <= comparator in c\n// - If GT and LT, and GT.semver > LT.semver, return true (null set)\n// - If any C is a = range, and GT or LT are set, return false\n// - If EQ\n// - If GT, and EQ does not satisfy GT, return true (null set)\n// - If LT, and EQ does not satisfy LT, return true (null set)\n// - If EQ satisfies every C, return true\n// - Else return false\n// - If GT\n// - If GT.semver is lower than any > or >= comp in C, return false\n// - If GT is >=, and GT.semver does not satisfy every C, return false\n// - If GT.semver has a prerelease, and not in prerelease mode\n// - If no C has a prerelease and the GT.semver tuple, return false\n// - If LT\n// - If LT.semver is greater than any < or <= comp in C, return false\n// - If LT is <=, and LT.semver does not satisfy every C, return false\n// - If LT.semver has a prerelease, and not in prerelease mode\n// - If no C has a prerelease and the LT.semver tuple, return false\n// - Else return true\n\nconst subset = (sub, dom, options = {}) => {\n if (sub === dom) {\n return true\n }\n\n sub = new Range(sub, options)\n dom = new Range(dom, options)\n let sawNonNull = false\n\n OUTER: for (const simpleSub of sub.set) {\n for (const simpleDom of dom.set) {\n const isSub = simpleSubset(simpleSub, simpleDom, options)\n sawNonNull = sawNonNull || isSub !== null\n if (isSub) {\n continue OUTER\n }\n }\n // the null set is a subset of everything, but null simple ranges in\n // a complex range should be ignored. so if we saw a non-null range,\n // then we know this isn't a subset, but if EVERY simple range was null,\n // then it is a subset.\n if (sawNonNull) {\n return false\n }\n }\n return true\n}\n\nconst minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]\nconst minimumVersion = [new Comparator('>=0.0.0')]\n\nconst simpleSubset = (sub, dom, options) => {\n if (sub === dom) {\n return true\n }\n\n if (sub.length === 1 && sub[0].semver === ANY) {\n if (dom.length === 1 && dom[0].semver === ANY) {\n return true\n } else if (options.includePrerelease) {\n sub = minimumVersionWithPreRelease\n } else {\n sub = minimumVersion\n }\n }\n\n if (dom.length === 1 && dom[0].semver === ANY) {\n if (options.includePrerelease) {\n return true\n } else {\n dom = minimumVersion\n }\n }\n\n const eqSet = new Set()\n let gt, lt\n for (const c of sub) {\n if (c.operator === '>' || c.operator === '>=') {\n gt = higherGT(gt, c, options)\n } else if (c.operator === '<' || c.operator === '<=') {\n lt = lowerLT(lt, c, options)\n } else {\n eqSet.add(c.semver)\n }\n }\n\n if (eqSet.size > 1) {\n return null\n }\n\n let gtltComp\n if (gt && lt) {\n gtltComp = compare(gt.semver, lt.semver, options)\n if (gtltComp > 0) {\n return null\n } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {\n return null\n }\n }\n\n // will iterate one or zero times\n for (const eq of eqSet) {\n if (gt && !satisfies(eq, String(gt), options)) {\n return null\n }\n\n if (lt && !satisfies(eq, String(lt), options)) {\n return null\n }\n\n for (const c of dom) {\n if (!satisfies(eq, String(c), options)) {\n return false\n }\n }\n\n return true\n }\n\n let higher, lower\n let hasDomLT, hasDomGT\n // if the subset has a prerelease, we need a comparator in the superset\n // with the same tuple and a prerelease, or it's not a subset\n let needDomLTPre = lt &&\n !options.includePrerelease &&\n lt.semver.prerelease.length ? lt.semver : false\n let needDomGTPre = gt &&\n !options.includePrerelease &&\n gt.semver.prerelease.length ? gt.semver : false\n // exception: <1.2.3-0 is the same as <1.2.3\n if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&\n lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {\n needDomLTPre = false\n }\n\n for (const c of dom) {\n hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='\n hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='\n if (gt) {\n if (needDomGTPre) {\n if (c.semver.prerelease && c.semver.prerelease.length &&\n c.semver.major === needDomGTPre.major &&\n c.semver.minor === needDomGTPre.minor &&\n c.semver.patch === needDomGTPre.patch) {\n needDomGTPre = false\n }\n }\n if (c.operator === '>' || c.operator === '>=') {\n higher = higherGT(gt, c, options)\n if (higher === c && higher !== gt) {\n return false\n }\n } else if (gt.operator === '>=' && !c.test(gt.semver)) {\n return false\n }\n }\n if (lt) {\n if (needDomLTPre) {\n if (c.semver.prerelease && c.semver.prerelease.length &&\n c.semver.major === needDomLTPre.major &&\n c.semver.minor === needDomLTPre.minor &&\n c.semver.patch === needDomLTPre.patch) {\n needDomLTPre = false\n }\n }\n if (c.operator === '<' || c.operator === '<=') {\n lower = lowerLT(lt, c, options)\n if (lower === c && lower !== lt) {\n return false\n }\n } else if (lt.operator === '<=' && !c.test(lt.semver)) {\n return false\n }\n }\n if (!c.operator && (lt || gt) && gtltComp !== 0) {\n return false\n }\n }\n\n // if there was a < or >, and nothing in the dom, then must be false\n // UNLESS it was limited by another range in the other direction.\n // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0\n if (gt && hasDomLT && !lt && gtltComp !== 0) {\n return false\n }\n\n if (lt && hasDomGT && !gt && gtltComp !== 0) {\n return false\n }\n\n // we needed a prerelease range in a specific tuple, but didn't get one\n // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,\n // because it includes prereleases in the 1.2.3 tuple\n if (needDomGTPre || needDomLTPre) {\n return false\n }\n\n return true\n}\n\n// >=1.2.3 is lower than >1.2.3\nconst higherGT = (a, b, options) => {\n if (!a) {\n return b\n }\n const comp = compare(a.semver, b.semver, options)\n return comp > 0 ? a\n : comp < 0 ? b\n : b.operator === '>' && a.operator === '>=' ? b\n : a\n}\n\n// <=1.2.3 is higher than <1.2.3\nconst lowerLT = (a, b, options) => {\n if (!a) {\n return b\n }\n const comp = compare(a.semver, b.semver, options)\n return comp < 0 ? a\n : comp > 0 ? b\n : b.operator === '<' && a.operator === '<=' ? b\n : a\n}\n\nmodule.exports = subset\n","'use strict'\n\n// just pre-load all the stuff that index.js lazily exports\nconst internalRe = require('./internal/re')\nconst constants = require('./internal/constants')\nconst SemVer = require('./classes/semver')\nconst identifiers = require('./internal/identifiers')\nconst parse = require('./functions/parse')\nconst valid = require('./functions/valid')\nconst clean = require('./functions/clean')\nconst inc = require('./functions/inc')\nconst diff = require('./functions/diff')\nconst major = require('./functions/major')\nconst minor = require('./functions/minor')\nconst patch = require('./functions/patch')\nconst prerelease = require('./functions/prerelease')\nconst compare = require('./functions/compare')\nconst rcompare = require('./functions/rcompare')\nconst compareLoose = require('./functions/compare-loose')\nconst compareBuild = require('./functions/compare-build')\nconst sort = require('./functions/sort')\nconst rsort = require('./functions/rsort')\nconst gt = require('./functions/gt')\nconst lt = require('./functions/lt')\nconst eq = require('./functions/eq')\nconst neq = require('./functions/neq')\nconst gte = require('./functions/gte')\nconst lte = require('./functions/lte')\nconst cmp = require('./functions/cmp')\nconst coerce = require('./functions/coerce')\nconst truncate = require('./functions/truncate')\nconst Comparator = require('./classes/comparator')\nconst Range = require('./classes/range')\nconst satisfies = require('./functions/satisfies')\nconst toComparators = require('./ranges/to-comparators')\nconst maxSatisfying = require('./ranges/max-satisfying')\nconst minSatisfying = require('./ranges/min-satisfying')\nconst minVersion = require('./ranges/min-version')\nconst validRange = require('./ranges/valid')\nconst outside = require('./ranges/outside')\nconst gtr = require('./ranges/gtr')\nconst ltr = require('./ranges/ltr')\nconst intersects = require('./ranges/intersects')\nconst simplifyRange = require('./ranges/simplify')\nconst subset = require('./ranges/subset')\nmodule.exports = {\n parse,\n valid,\n clean,\n inc,\n diff,\n major,\n minor,\n patch,\n prerelease,\n compare,\n rcompare,\n compareLoose,\n compareBuild,\n sort,\n rsort,\n gt,\n lt,\n eq,\n neq,\n gte,\n lte,\n cmp,\n coerce,\n truncate,\n Comparator,\n Range,\n satisfies,\n toComparators,\n maxSatisfying,\n minSatisfying,\n minVersion,\n validRange,\n outside,\n gtr,\n ltr,\n intersects,\n simplifyRange,\n subset,\n SemVer,\n re: internalRe.re,\n src: internalRe.src,\n tokens: internalRe.t,\n SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,\n RELEASE_TYPES: constants.RELEASE_TYPES,\n compareIdentifiers: identifiers.compareIdentifiers,\n rcompareIdentifiers: identifiers.rcompareIdentifiers,\n}\n","/**\n * CCTP attestation client.\n *\n * Polls Circle's IRIS API for attestations after a USDC burn.\n * Used on the destination chain to call MessageTransmitter.receiveMessage().\n */\n\nimport {\n CCTP_DOMAINS,\n type CctpChainName,\n IRIS_API_MAINNET,\n} from \"./constants.js\";\nimport type {\n AttestationResponse,\n CctpMessageResult,\n CctpMessageStatus,\n} from \"./types.js\";\n\nexport interface FetchAttestationOptions {\n /** Source chain name (e.g. \"Polygon\"). */\n sourceChain: CctpChainName;\n /** Transaction hash of the burn on the source chain. */\n txHash: string;\n /** IRIS API base URL. Defaults to mainnet. */\n irisApiUrl?: string;\n /** Polling interval in ms. Defaults to 10000 (10s). */\n pollIntervalMs?: number;\n /** Maximum time to wait in ms. Defaults to 900000 (15min). */\n timeoutMs?: number;\n /** Optional abort signal. */\n signal?: AbortSignal;\n}\n\nexport interface AttestationResult {\n /** Raw CCTP message bytes (hex with 0x prefix). */\n message: string;\n /** Attestation signature bytes (hex with 0x prefix). */\n attestation: string;\n}\n\n/**\n * Poll the IRIS V2 API until the attestation is ready for a given burn tx.\n *\n * @returns The message and attestation bytes needed to call receiveMessage().\n * @throws If the attestation is not ready within the timeout, or the request fails.\n */\nexport async function fetchAttestation(\n options: FetchAttestationOptions,\n): Promise<AttestationResult> {\n const {\n sourceChain,\n txHash,\n irisApiUrl = IRIS_API_MAINNET,\n pollIntervalMs = 10_000,\n timeoutMs = 900_000,\n signal,\n } = options;\n\n const sourceDomain = CCTP_DOMAINS[sourceChain];\n if (sourceDomain === undefined) {\n throw new Error(`Unknown CCTP source chain: ${sourceChain}`);\n }\n\n const url = `${irisApiUrl}/v2/messages/${sourceDomain}?transactionHash=${txHash}`;\n\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeoutMs) {\n signal?.throwIfAborted();\n\n try {\n const response = await fetch(url);\n\n if (response.status === 404) {\n // Message not yet indexed, keep polling\n await sleep(pollIntervalMs, signal);\n continue;\n }\n\n if (!response.ok) {\n throw new Error(\n `IRIS API error: ${response.status} ${response.statusText}`,\n );\n }\n\n const data: AttestationResponse = await response.json();\n\n if (data.messages.length > 0 && data.messages[0].status === \"complete\") {\n return {\n message: data.messages[0].message,\n attestation: data.messages[0].attestation,\n };\n }\n\n // Attestation pending, keep polling\n await sleep(pollIntervalMs, signal);\n } catch (err) {\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw err;\n }\n if (err instanceof CctpForwardingFailedError) {\n // Terminal state from IRIS — retrying cannot change it.\n throw err;\n }\n // Network errors — retry after delay\n await sleep(pollIntervalMs, signal);\n }\n }\n\n throw new Error(\n `Attestation not ready after ${timeoutMs / 1000}s for tx ${txHash} on ${sourceChain}`,\n );\n}\n\n/**\n * Whether IRIS has indexed a CCTP message for a burn tx, attested or not.\n * A single lookup, unlike {@link fetchAttestation}.\n *\n * @throws If IRIS cannot be reached or answers with an error, so an outage\n * is never mistaken for an unknown burn.\n */\nexport async function hasCctpMessage(options: {\n sourceChain: CctpChainName;\n txHash: string;\n irisApiUrl?: string;\n}): Promise<boolean> {\n const { sourceChain, txHash, irisApiUrl = IRIS_API_MAINNET } = options;\n const sourceDomain = CCTP_DOMAINS[sourceChain];\n if (sourceDomain === undefined) {\n throw new Error(`Unknown CCTP source chain: ${sourceChain}`);\n }\n const response = await fetch(\n `${irisApiUrl}/v2/messages/${sourceDomain}?transactionHash=${txHash}`,\n );\n if (response.status === 404) return false;\n if (!response.ok) {\n throw new Error(\n `IRIS API error: ${response.status} ${response.statusText}`,\n );\n }\n const data: AttestationResponse = await response.json();\n return data.messages.length > 0;\n}\n\n// ============================================================================\n// Cross-chain message tracking (with forwarding)\n// ============================================================================\n\n/** A CCTP message reached a terminal non-delivered forwarding state. */\nexport class CctpForwardingFailedError extends Error {}\n\n/** Options for tracking a CCTP cross-chain message via IRIS. */\nexport interface TrackCctpMessageOptions {\n /** Source chain name (e.g. \"Arbitrum\"). */\n sourceChain: CctpChainName;\n /** Transaction hash of the burn/claim on the source chain. */\n txHash: string;\n /** IRIS API base URL. Defaults to mainnet. */\n irisApiUrl?: string;\n /** Polling interval in ms. Defaults to 5000 (5s). */\n pollIntervalMs?: number;\n /** Maximum time to wait in ms. Defaults to 600000 (10min). */\n timeoutMs?: number;\n /** Optional abort signal. */\n signal?: AbortSignal;\n /** Optional callback invoked when the message status changes. */\n onStatusChange?: (status: CctpMessageStatus) => void;\n}\n\n/**\n * Poll the IRIS V2 API until the CCTP message is delivered.\n *\n * Tracks attestation → delivery on the destination chain, whether Circle's\n * Forwarding Service delivers the message or somebody else mints it (the\n * Satora server does for USDC payouts on Polygon and Ethereum).\n *\n * @returns The message result with delivery details (destination tx hash, amount, fee).\n * @throws If the message is not delivered within the timeout.\n */\nexport async function trackCctpMessage(\n options: TrackCctpMessageOptions,\n): Promise<CctpMessageResult> {\n const {\n sourceChain,\n txHash,\n irisApiUrl = IRIS_API_MAINNET,\n pollIntervalMs = 5_000,\n timeoutMs = 600_000,\n signal,\n onStatusChange,\n } = options;\n\n const sourceDomain = CCTP_DOMAINS[sourceChain];\n if (sourceDomain === undefined) {\n throw new Error(`Unknown CCTP source chain: ${sourceChain}`);\n }\n\n const url = `${irisApiUrl}/v2/messages/${sourceDomain}?transactionHash=${txHash}`;\n const startTime = Date.now();\n let lastStatus: CctpMessageStatus | undefined;\n\n const emitStatus = (status: CctpMessageStatus) => {\n if (status !== lastStatus) {\n lastStatus = status;\n onStatusChange?.(status);\n }\n };\n\n while (Date.now() - startTime < timeoutMs) {\n signal?.throwIfAborted();\n\n try {\n const response = await fetch(url);\n\n if (response.status === 404) {\n emitStatus(\"PENDING\");\n await sleep(pollIntervalMs, signal);\n continue;\n }\n\n if (!response.ok) {\n throw new Error(\n `IRIS API error: ${response.status} ${response.statusText}`,\n );\n }\n\n const data: AttestationResponse = await response.json();\n\n if (data.messages.length === 0) {\n emitStatus(\"PENDING\");\n await sleep(pollIntervalMs, signal);\n continue;\n }\n\n const msg = data.messages[0];\n\n if (msg.status !== \"complete\") {\n emitStatus(\"CONFIRMING\");\n await sleep(pollIntervalMs, signal);\n continue;\n }\n\n // Attestation is complete — check delivery. A message Circle's\n // Forwarding Service delivers reports a `forwardState`; one somebody\n // else mints (the Satora server, for USDC on Polygon and Ethereum)\n // has none, and is delivered once IRIS has seen its mint.\n const deliveryTxHash = msg.forwardState\n ? (msg.forwardState === \"COMPLETE\" ||\n msg.forwardState === \"CONFIRMED\") &&\n msg.forwardTxHash\n : msg.destinationMintTxHash;\n if (deliveryTxHash) {\n emitStatus(\"COMPLETE\");\n const cctpSentAmount = msg.decodedMessage?.decodedMessageBody?.amount;\n const cctpPaidFee = msg.decodedMessage?.decodedMessageBody?.feeExecuted;\n return {\n status: \"COMPLETE\",\n forwardTxHash: deliveryTxHash,\n amount:\n cctpSentAmount && cctpPaidFee\n ? (BigInt(cctpSentAmount) - BigInt(cctpPaidFee)).toString()\n : undefined,\n feeExecuted: msg.decodedMessage?.decodedMessageBody?.feeExecuted,\n };\n }\n\n // Forwarding failed — stop polling\n if (\n msg.forwardState &&\n msg.forwardState !== \"PENDING\" &&\n msg.forwardState !== \"COMPLETE\"\n ) {\n emitStatus(\"FAILED\");\n throw new CctpForwardingFailedError(\n `CCTP forwarding failed (state: ${msg.forwardState}) for tx ${txHash} on ${sourceChain}`,\n );\n }\n\n // Attestation complete but delivery still in progress\n emitStatus(\"FORWARDING\");\n await sleep(pollIntervalMs, signal);\n } catch (err) {\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw err;\n }\n if (err instanceof CctpForwardingFailedError) {\n // Terminal state from IRIS — retrying cannot change it.\n throw err;\n }\n // Network errors — retry after delay\n await sleep(pollIntervalMs, signal);\n }\n }\n\n throw new Error(\n `CCTP message not delivered after ${timeoutMs / 1000}s for tx ${txHash} on ${sourceChain}`,\n );\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n const timer = setTimeout(resolve, ms);\n signal?.addEventListener(\n \"abort\",\n () => {\n clearTimeout(timer);\n reject(new DOMException(\"Aborted\", \"AbortError\"));\n },\n { once: true },\n );\n });\n}\n","import { satisfies } from \"semver\"\nimport {\n type Address,\n type Assign,\n type EncodeDeployDataParameters,\n type Hex,\n type LocalAccount,\n type SignableMessage,\n type TypedDataDefinition,\n concatHex,\n createNonceManager,\n encodeFunctionData,\n getTypesForEIP712Domain,\n hashMessage,\n hashTypedData,\n isAddressEqual,\n toHex,\n validateTypedData,\n zeroAddress\n} from \"viem\"\nimport {\n type EntryPointVersion,\n type SmartAccount,\n type SmartAccountImplementation,\n type UserOperation,\n entryPoint06Abi,\n entryPoint07Abi,\n entryPoint07Address,\n toSmartAccount\n} from \"viem/account-abstraction\"\nimport type {\n PrivateKeyAccount,\n SignAuthorizationReturnType\n} from \"viem/accounts\"\nimport {\n getChainId,\n getCode,\n signAuthorization as signAuthorizationAction\n} from \"viem/actions\"\nimport { getAction, verifyAuthorization } from \"viem/utils\"\nimport {\n getAccountNonce,\n getSenderAddress,\n isPluginInstalled\n} from \"../../actions/public/index.js\"\nimport {\n type EXEC_TYPE,\n KernelVersionToAddressesMap,\n MAGIC_VALUE_SIG_REPLAYABLE\n} from \"../../constants.js\"\nimport type {\n CallType,\n EntryPointType,\n GetEntryPointAbi,\n GetKernelVersion,\n KernelPluginManager,\n KernelPluginManagerParams,\n KernelValidator,\n PluginMigrationData\n} from \"../../types/kernel.js\"\nimport type { Signer } from \"../../types/utils.js\"\nimport { KERNEL_FEATURES, hasKernelFeature } from \"../../utils.js\"\nimport { validateKernelVersionWithEntryPoint } from \"../../utils.js\"\nimport { toSigner } from \"../../utils/toSigner.js\"\nimport { addressToEmptyAccount } from \"../addressToEmptyAccount.js\"\nimport { signerTo7702Validator } from \"../utils/signerTo7702Validator.js\"\nimport {\n isKernelPluginManager,\n toKernelPluginManager\n} from \"../utils/toKernelPluginManager.js\"\nimport { KernelInitAbi } from \"./abi/KernelAccountAbi.js\"\nimport { KernelV3InitAbi } from \"./abi/kernel_v_3_0_0/KernelAccountAbi.js\"\nimport { KernelV3FactoryAbi } from \"./abi/kernel_v_3_0_0/KernelFactoryAbi.js\"\nimport { KernelFactoryStakerAbi } from \"./abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js\"\nimport { KernelV3_1AccountAbi } from \"./abi/kernel_v_3_1/KernelAccountAbi.js\"\nimport { encodeCallData as encodeCallDataEpV06 } from \"./utils/account/ep0_6/encodeCallData.js\"\nimport { encodeDeployCallData as encodeDeployCallDataV06 } from \"./utils/account/ep0_6/encodeDeployCallData.js\"\nimport { encodeCallData as encodeCallDataEpV07 } from \"./utils/account/ep0_7/encodeCallData.js\"\nimport { encodeDeployCallData as encodeDeployCallDataV07 } from \"./utils/account/ep0_7/encodeDeployCallData.js\"\nimport {\n type AccountMetadata,\n accountMetadata\n} from \"./utils/common/accountMetadata.js\"\nimport { eip712WrapHash } from \"./utils/common/eip712WrapHash.js\"\nimport { getPluginInstallCallData } from \"./utils/plugins/ep0_7/getPluginInstallCallData.js\"\nimport type { CallArgs } from \"./utils/types.js\"\n\ntype SignMessageParameters = {\n message: SignableMessage\n useReplayableSignature?: boolean\n}\n\nexport type KernelSmartAccountImplementation<\n entryPointVersion extends EntryPointVersion = \"0.7\"\n> = Assign<\n SmartAccountImplementation<\n GetEntryPointAbi<entryPointVersion>,\n entryPointVersion\n >,\n {\n sign: NonNullable<SmartAccountImplementation[\"sign\"]>\n encodeCalls: (\n calls: Parameters<SmartAccountImplementation[\"encodeCalls\"]>[0],\n callType?: CallType | undefined,\n execType?: EXEC_TYPE | undefined\n ) => Promise<Hex>\n kernelVersion: GetKernelVersion<entryPointVersion>\n kernelPluginManager: KernelPluginManager<entryPointVersion>\n factoryAddress: Address\n accountImplementationAddress: Address\n generateInitCode: () => Promise<Hex>\n encodeModuleInstallCallData: () => Promise<Hex>\n encodeDeployCallData: ({\n abi,\n args,\n bytecode\n }: EncodeDeployDataParameters) => Promise<Hex>\n signMessage: (parameters: SignMessageParameters) => Promise<Hex>\n eip7702Authorization?:\n | (() => Promise<SignAuthorizationReturnType | undefined>)\n | undefined\n }\n>\n\nexport type CreateKernelAccountReturnType<\n entryPointVersion extends EntryPointVersion = \"0.7\"\n> = SmartAccount<KernelSmartAccountImplementation<entryPointVersion>>\n\nexport type CreateKernelAccountParameters<\n entryPointVersion extends EntryPointVersion,\n KernelVerion extends GetKernelVersion<entryPointVersion>\n> = {\n entryPoint: EntryPointType<entryPointVersion>\n index?: bigint\n factoryAddress?: Address\n accountImplementationAddress?: Address\n metaFactoryAddress?: Address\n address?: Address\n kernelVersion: GetKernelVersion<entryPointVersion>\n initConfig?: KernelVerion extends \"0.3.1\" ? Hex[] : never\n useMetaFactory?: boolean\n pluginMigrations?: PluginMigrationData[]\n} & (\n | {\n eip7702Auth?: SignAuthorizationReturnType | undefined\n eip7702Account: Signer\n plugins?:\n | Omit<\n KernelPluginManagerParams<entryPointVersion>,\n \"entryPoint\" | \"kernelVersion\"\n >\n | KernelPluginManager<entryPointVersion>\n | undefined\n }\n | {\n eip7702Auth?: SignAuthorizationReturnType | undefined\n eip7702Account?: Signer | undefined\n plugins:\n | Omit<\n KernelPluginManagerParams<entryPointVersion>,\n \"entryPoint\" | \"kernelVersion\"\n >\n | KernelPluginManager<entryPointVersion>\n }\n)\n\n/**\n * The account creation ABI for a kernel smart account (from the KernelFactory)\n */\nconst createAccountAbi = [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"_implementation\",\n type: \"address\"\n },\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\"\n },\n {\n internalType: \"uint256\",\n name: \"_index\",\n type: \"uint256\"\n }\n ],\n name: \"createAccount\",\n outputs: [\n {\n internalType: \"address\",\n name: \"proxy\",\n type: \"address\"\n }\n ],\n stateMutability: \"payable\",\n type: \"function\"\n }\n] as const\n\n/**\n * Default addresses for kernel smart account\n */\nexport const KERNEL_ADDRESSES: {\n ACCOUNT_LOGIC_V0_6: Address\n ACCOUNT_LOGIC_V0_7: Address\n FACTORY_ADDRESS_V0_6: Address\n FACTORY_ADDRESS_V0_7: Address\n FACTORY_STAKER: Address\n} = {\n ACCOUNT_LOGIC_V0_6: \"0xd3082872F8B06073A021b4602e022d5A070d7cfC\",\n ACCOUNT_LOGIC_V0_7: \"0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27\",\n FACTORY_ADDRESS_V0_6: \"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3\",\n FACTORY_ADDRESS_V0_7: \"0x6723b44Abeec4E71eBE3232BD5B455805baDD22f\",\n FACTORY_STAKER: \"0xd703aaE79538628d27099B8c4f621bE4CCd142d5\"\n}\n\nconst getKernelInitData = async <entryPointVersion extends EntryPointVersion>({\n entryPointVersion: _entryPointVersion,\n kernelPluginManager,\n initHook,\n kernelVersion,\n initConfig\n}: {\n entryPointVersion: entryPointVersion\n kernelPluginManager: KernelPluginManager<entryPointVersion>\n initHook: boolean\n kernelVersion: GetKernelVersion<entryPointVersion>\n initConfig?: GetKernelVersion<entryPointVersion> extends \"0.3.1\"\n ? Hex[]\n : never\n}) => {\n const {\n enableData,\n identifier,\n validatorAddress,\n initConfig: initConfig_\n } = await kernelPluginManager.getValidatorInitData()\n\n if (_entryPointVersion === \"0.6\") {\n return encodeFunctionData({\n abi: KernelInitAbi,\n functionName: \"initialize\",\n args: [validatorAddress, enableData]\n })\n }\n\n if (kernelVersion === \"0.3.0\") {\n return encodeFunctionData({\n abi: KernelV3InitAbi,\n functionName: \"initialize\",\n args: [\n identifier,\n initHook && kernelPluginManager.hook\n ? kernelPluginManager.hook?.getIdentifier()\n : zeroAddress,\n enableData,\n initHook && kernelPluginManager.hook\n ? await kernelPluginManager.hook?.getEnableData()\n : \"0x\"\n ]\n })\n }\n return encodeFunctionData({\n abi: KernelV3_1AccountAbi,\n functionName: \"initialize\",\n args: [\n identifier,\n initHook && kernelPluginManager.hook\n ? kernelPluginManager.hook?.getIdentifier()\n : zeroAddress,\n enableData,\n initHook && kernelPluginManager.hook\n ? await kernelPluginManager.hook?.getEnableData()\n : \"0x\",\n initConfig ?? initConfig_ ?? []\n ]\n })\n}\n\n/**\n * Get the account initialization code for a kernel smart account\n * @param index\n * @param factoryAddress\n * @param accountImplementationAddress\n * @param ecdsaValidatorAddress\n */\nconst getAccountInitCode = async <entryPointVersion extends EntryPointVersion>({\n index,\n factoryAddress,\n accountImplementationAddress,\n entryPointVersion: _entryPointVersion,\n kernelPluginManager,\n initHook,\n kernelVersion,\n initConfig,\n useMetaFactory\n}: {\n index: bigint\n factoryAddress: Address\n accountImplementationAddress: Address\n entryPointVersion: entryPointVersion\n kernelPluginManager: KernelPluginManager<entryPointVersion>\n initHook: boolean\n kernelVersion: GetKernelVersion<entryPointVersion>\n initConfig?: GetKernelVersion<entryPointVersion> extends \"0.3.1\"\n ? Hex[]\n : never\n useMetaFactory: boolean\n}): Promise<Hex> => {\n // Build the account initialization data\n const initialisationData = await getKernelInitData<entryPointVersion>({\n entryPointVersion: _entryPointVersion,\n kernelPluginManager,\n initHook,\n kernelVersion,\n initConfig\n })\n\n // Build the account init code\n if (_entryPointVersion === \"0.6\") {\n return encodeFunctionData({\n abi: createAccountAbi,\n functionName: \"createAccount\",\n args: [accountImplementationAddress, initialisationData, index]\n })\n }\n\n if (!useMetaFactory) {\n return encodeFunctionData({\n abi: KernelV3FactoryAbi,\n functionName: \"createAccount\",\n args: [initialisationData, toHex(index, { size: 32 })]\n })\n }\n\n return encodeFunctionData({\n abi: KernelFactoryStakerAbi,\n functionName: \"deployWithFactory\",\n args: [factoryAddress, initialisationData, toHex(index, { size: 32 })]\n })\n}\n\nconst getDefaultAddresses = <entryPointVersion extends EntryPointVersion>(\n entryPointVersion: entryPointVersion,\n kernelVersion: GetKernelVersion<entryPointVersion>,\n {\n accountImplementationAddress,\n factoryAddress,\n metaFactoryAddress\n }: {\n accountImplementationAddress?: Address\n factoryAddress?: Address\n metaFactoryAddress?: Address\n }\n) => {\n validateKernelVersionWithEntryPoint(entryPointVersion, kernelVersion)\n\n const addresses = KernelVersionToAddressesMap[kernelVersion]\n if (!addresses) {\n throw new Error(\n `No addresses found for kernel version ${kernelVersion}`\n )\n }\n\n return {\n accountImplementationAddress:\n accountImplementationAddress ??\n addresses.accountImplementationAddress,\n factoryAddress: factoryAddress ?? addresses.factoryAddress,\n metaFactoryAddress:\n metaFactoryAddress ?? addresses.metaFactoryAddress ?? zeroAddress\n }\n}\n\ntype PluginInstallationCache = {\n pendingPlugins: PluginMigrationData[]\n allInstalled: boolean\n}\n\n/**\n * Build a kernel smart account from a private key, that use the ECDSA signer behind the scene\n * @param client\n * @param privateKey\n * @param entryPoint\n * @param index\n * @param factoryAddress\n * @param accountImplementationAddress\n * @param ecdsaValidatorAddress\n * @param address\n */\nexport async function createKernelAccount<\n entryPointVersion extends EntryPointVersion,\n KernelVersion extends GetKernelVersion<entryPointVersion>\n>(\n client: KernelSmartAccountImplementation[\"client\"],\n {\n plugins,\n entryPoint,\n index = 0n,\n factoryAddress: _factoryAddress,\n accountImplementationAddress: _accountImplementationAddress,\n metaFactoryAddress: _metaFactoryAddress,\n address,\n kernelVersion,\n initConfig,\n useMetaFactory: _useMetaFactory = true,\n eip7702Auth,\n eip7702Account,\n pluginMigrations\n }: CreateKernelAccountParameters<entryPointVersion, KernelVersion>\n): Promise<CreateKernelAccountReturnType<entryPointVersion>> {\n const isEip7702 = !!eip7702Account || !!eip7702Auth\n if (isEip7702 && !satisfies(kernelVersion, \">=0.3.3\")) {\n throw new Error(\"EIP-7702 is recommended for kernel version >=0.3.3\")\n }\n const localAccount = eip7702Account\n ? await toSigner({ signer: eip7702Account, address })\n : undefined\n\n let eip7702Validator: KernelValidator<\"EIP7702Validator\"> | undefined\n if (localAccount) {\n eip7702Validator = await signerTo7702Validator(client, {\n signer: localAccount,\n entryPoint,\n kernelVersion\n })\n }\n let useMetaFactory = _useMetaFactory\n const { accountImplementationAddress, factoryAddress, metaFactoryAddress } =\n getDefaultAddresses(entryPoint.version, kernelVersion, {\n accountImplementationAddress: _accountImplementationAddress,\n factoryAddress: _factoryAddress,\n metaFactoryAddress: _metaFactoryAddress\n })\n\n let chainId: number\n let cachedAccountMetadata: AccountMetadata | undefined\n\n const getMemoizedChainId = async () => {\n if (chainId) return chainId\n chainId = client.chain\n ? client.chain.id\n : await getAction(client, getChainId, \"getChainId\")({})\n return chainId\n }\n\n const getMemoizedAccountMetadata = async () => {\n if (cachedAccountMetadata) return cachedAccountMetadata\n cachedAccountMetadata = await accountMetadata(\n client,\n accountAddress,\n kernelVersion,\n await getMemoizedChainId()\n )\n return cachedAccountMetadata\n }\n\n const kernelPluginManager = isKernelPluginManager<entryPointVersion>(\n plugins\n )\n ? plugins\n : await toKernelPluginManager<entryPointVersion>(client, {\n sudo: localAccount ? eip7702Validator : plugins?.sudo,\n regular: plugins?.regular,\n hook: plugins?.hook,\n action: plugins?.action,\n pluginEnableSignature: plugins?.pluginEnableSignature,\n entryPoint,\n kernelVersion,\n chainId: await getMemoizedChainId()\n })\n\n // initHook flag is activated only if both the hook and sudo validator are given\n // if the hook is given with regular plugins, then consider it as a hook for regular plugins\n const initHook = Boolean(\n isKernelPluginManager<entryPointVersion>(plugins)\n ? plugins.hook &&\n plugins.getIdentifier() ===\n plugins.sudoValidator?.getIdentifier()\n : plugins?.hook && !plugins?.regular\n )\n\n // Helper to generate the init code for the smart account\n const generateInitCode = async () => {\n if (isEip7702) {\n return \"0x\" as `0x${string}`\n }\n if (!accountImplementationAddress || !factoryAddress)\n throw new Error(\"Missing account logic address or factory address\")\n return getAccountInitCode<entryPointVersion>({\n index,\n factoryAddress,\n accountImplementationAddress,\n entryPointVersion: entryPoint.version,\n kernelPluginManager,\n initHook,\n kernelVersion,\n initConfig,\n useMetaFactory\n })\n }\n\n const getFactoryArgs = async () => {\n if (isEip7702) {\n return {\n factory: undefined,\n factoryData: undefined\n }\n }\n return {\n factory:\n entryPoint.version === \"0.6\" || useMetaFactory === false\n ? factoryAddress\n : metaFactoryAddress,\n factoryData: await generateInitCode()\n }\n }\n\n // Fetch account address\n let accountAddress =\n address ??\n (isEip7702\n ? (localAccount?.address ?? zeroAddress)\n : await (async () => {\n const { factory, factoryData } = await getFactoryArgs()\n if (!factory || !factoryData) {\n throw new Error(\"Missing factory address or factory data\")\n }\n\n // Get the sender address based on the init code\n return await getSenderAddress(client, {\n factory,\n factoryData,\n entryPointAddress: entryPoint.address\n })\n })())\n\n // If account is zeroAddress try without meta factory\n if (isAddressEqual(accountAddress, zeroAddress) && useMetaFactory) {\n useMetaFactory = false\n accountAddress = await getSenderAddress(client, {\n factory: factoryAddress,\n factoryData: await generateInitCode(),\n entryPointAddress: entryPoint.address\n })\n if (isAddressEqual(accountAddress, zeroAddress)) {\n useMetaFactory = true\n }\n }\n\n const _entryPoint = {\n address: entryPoint?.address ?? entryPoint07Address,\n abi: ((entryPoint?.version ?? \"0.7\") === \"0.6\"\n ? entryPoint06Abi\n : entryPoint07Abi) as GetEntryPointAbi<entryPointVersion>,\n version: entryPoint?.version ?? \"0.7\"\n } as const\n\n // Cache for plugin installation status\n const pluginCache: PluginInstallationCache = {\n pendingPlugins: pluginMigrations || [],\n allInstalled: false\n }\n\n const checkPluginInstallationStatus = async () => {\n // Skip if no plugins or all are installed\n if (!pluginCache.pendingPlugins.length || pluginCache.allInstalled) {\n pluginCache.allInstalled = true\n return\n }\n\n // Check all pending plugins in parallel\n const installationResults = await Promise.all(\n pluginCache.pendingPlugins.map((plugin) =>\n isPluginInstalled(client, {\n address: accountAddress,\n plugin\n })\n )\n )\n\n // Filter out installed plugins\n pluginCache.pendingPlugins = pluginCache.pendingPlugins.filter(\n (_, index) => !installationResults[index]\n )\n pluginCache.allInstalled = pluginCache.pendingPlugins.length === 0\n }\n\n const signAuthorization = async () => {\n const code = await getCode(client, { address: accountAddress })\n // check if account has not activated 7702 with implementation address\n if (\n !code ||\n code.length === 0 ||\n !code\n .toLowerCase()\n .startsWith(\n `0xef0100${accountImplementationAddress.slice(2).toLowerCase()}`\n )\n ) {\n if (\n eip7702Auth &&\n !isAddressEqual(\n eip7702Auth.address,\n accountImplementationAddress\n )\n ) {\n throw new Error(\n \"EIP-7702 authorization delegate address does not match account implementation address\"\n )\n }\n\n const auth =\n eip7702Auth ??\n (await signAuthorizationAction(client, {\n account: localAccount as LocalAccount,\n address: accountImplementationAddress as `0x${string}`,\n chainId: await getMemoizedChainId()\n }))\n const verified = await verifyAuthorization({\n authorization: auth,\n address: accountAddress\n })\n if (!verified) {\n throw new Error(\"Authorization verification failed\")\n }\n return auth\n }\n return undefined\n }\n\n await checkPluginInstallationStatus()\n\n return toSmartAccount<KernelSmartAccountImplementation<entryPointVersion>>({\n authorization: isEip7702\n ? {\n account:\n (localAccount as PrivateKeyAccount) ??\n addressToEmptyAccount(accountAddress),\n address: accountImplementationAddress\n }\n : undefined,\n kernelVersion,\n kernelPluginManager,\n accountImplementationAddress,\n factoryAddress: (await getFactoryArgs()).factory as Address,\n generateInitCode,\n encodeModuleInstallCallData: async () => {\n return await kernelPluginManager.encodeModuleInstallCallData(\n accountAddress\n )\n },\n nonceKeyManager: createNonceManager({\n source: { get: () => 0, set: () => {} }\n }),\n client,\n entryPoint: _entryPoint,\n getFactoryArgs,\n async getAddress() {\n if (accountAddress) return accountAddress\n\n const { factory, factoryData } = await getFactoryArgs()\n if (!factory || !factoryData) {\n throw new Error(\"Missing factory address or factory data\")\n }\n\n // Get the sender address based on the init code\n accountAddress = await getSenderAddress(client, {\n factory,\n factoryData,\n entryPointAddress: entryPoint.address\n })\n\n return accountAddress\n },\n // Encode the deploy call data\n async encodeDeployCallData(_tx) {\n if (entryPoint.version === \"0.6\") {\n return encodeDeployCallDataV06(_tx)\n }\n return encodeDeployCallDataV07(_tx)\n },\n async encodeCalls(calls, callType, execType) {\n // Check plugin status only if we have pending plugins\n await checkPluginInstallationStatus()\n\n // Add plugin installation calls if needed\n if (\n pluginCache.pendingPlugins.length > 0 &&\n entryPoint.version === \"0.7\" &&\n kernelPluginManager.activeValidatorMode === \"sudo\"\n ) {\n // convert map into for loop\n const pluginInstallCalls: CallArgs[] = []\n for (const plugin of pluginCache.pendingPlugins) {\n pluginInstallCalls.push(\n getPluginInstallCallData(accountAddress, plugin)\n )\n }\n return encodeCallDataEpV07(\n [...calls, ...pluginInstallCalls],\n callType,\n plugins?.hook ? true : undefined,\n execType\n )\n }\n\n if (\n calls.length === 1 &&\n (!callType || callType === \"call\") &&\n calls[0].to.toLowerCase() === accountAddress.toLowerCase()\n ) {\n return calls[0].data ?? \"0x\"\n }\n if (entryPoint.version === \"0.6\") {\n return encodeCallDataEpV06(calls, callType)\n }\n\n if (plugins?.hook) {\n return encodeCallDataEpV07(calls, callType, true, execType)\n }\n return encodeCallDataEpV07(calls, callType, undefined, execType)\n },\n eip7702Authorization: signAuthorization,\n async sign({ hash }) {\n return this.signMessage({ message: hash })\n },\n async signMessage({ message, useReplayableSignature }) {\n const messageHash = hashMessage(message)\n const {\n name,\n chainId: metadataChainId,\n version\n } = await getMemoizedAccountMetadata()\n\n let signature: Hex\n if (isEip7702) {\n signature = await kernelPluginManager.signTypedData({\n message: { hash: messageHash },\n primaryType: \"Kernel\",\n types: {\n Kernel: [{ name: \"hash\", type: \"bytes32\" }]\n },\n domain: {\n name,\n version,\n chainId: useReplayableSignature\n ? 0\n : Number(metadataChainId),\n verifyingContract: accountAddress\n }\n })\n } else if (entryPoint.version === \"0.6\") {\n const wrappedMessageHash = await eip712WrapHash(\n messageHash,\n {\n name,\n chainId: Number(metadataChainId),\n version,\n verifyingContract: accountAddress\n },\n useReplayableSignature\n )\n signature = await kernelPluginManager.signMessage({\n message: { raw: wrappedMessageHash }\n })\n } else {\n signature = await kernelPluginManager.signTypedData({\n message: { hash: messageHash },\n primaryType: \"Kernel\",\n types: {\n Kernel: [{ name: \"hash\", type: \"bytes32\" }]\n },\n domain: {\n name,\n version,\n chainId: useReplayableSignature\n ? 0\n : Number(metadataChainId),\n verifyingContract: accountAddress\n }\n })\n }\n\n if (\n !hasKernelFeature(\n KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,\n version\n )\n ) {\n return signature\n }\n\n if (\n useReplayableSignature &&\n hasKernelFeature(KERNEL_FEATURES.ERC1271_REPLAYABLE, version)\n ) {\n signature = concatHex([MAGIC_VALUE_SIG_REPLAYABLE, signature])\n }\n\n return concatHex([kernelPluginManager.getIdentifier(), signature])\n },\n async signTypedData(typedData) {\n const {\n message,\n primaryType,\n types: _types,\n domain\n } = typedData as TypedDataDefinition\n const types = {\n EIP712Domain: getTypesForEIP712Domain({\n domain: domain\n }),\n ..._types\n }\n\n // Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc\n // as we can't statically check this with TypeScript.\n validateTypedData({\n domain: domain,\n message: message,\n primaryType: primaryType,\n types: types\n })\n\n const typedHash = hashTypedData(typedData)\n\n const {\n name,\n chainId: metadataChainId,\n version\n } = await getMemoizedAccountMetadata()\n\n let signature: Hex\n if (isEip7702) {\n signature = await kernelPluginManager.signTypedData({\n message: { hash: typedHash },\n primaryType: \"Kernel\",\n types: {\n Kernel: [{ name: \"hash\", type: \"bytes32\" }]\n },\n domain: {\n name,\n version,\n chainId: Number(metadataChainId),\n verifyingContract: accountAddress\n }\n })\n } else if (entryPoint.version === \"0.6\") {\n const wrappedMessageHash = await eip712WrapHash(typedHash, {\n name,\n chainId: Number(metadataChainId),\n version,\n verifyingContract: accountAddress\n })\n signature = await kernelPluginManager.signMessage({\n message: { raw: wrappedMessageHash }\n })\n } else {\n signature = await kernelPluginManager.signTypedData({\n message: { hash: typedHash },\n primaryType: \"Kernel\",\n types: {\n Kernel: [{ name: \"hash\", type: \"bytes32\" }]\n },\n domain: {\n name,\n version,\n chainId: Number(metadataChainId),\n verifyingContract: accountAddress\n }\n })\n }\n\n if (\n !hasKernelFeature(\n KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,\n version\n )\n ) {\n return signature\n }\n return concatHex([kernelPluginManager.getIdentifier(), signature])\n },\n // Get the nonce of the smart account\n async getNonce(_args) {\n const key = await kernelPluginManager.getNonceKey(\n accountAddress,\n _args?.key\n )\n return getAccountNonce(client, {\n address: accountAddress,\n entryPointAddress: entryPoint.address,\n key\n })\n },\n async getStubSignature(userOperation) {\n if (!userOperation) {\n throw new Error(\"No user operation provided\")\n }\n return kernelPluginManager.getStubSignature(\n userOperation as UserOperation\n )\n },\n\n // Sign a user operation\n async signUserOperation(parameters) {\n const { chainId = await getMemoizedChainId(), ...userOperation } =\n parameters\n return kernelPluginManager.signUserOperation({\n ...userOperation,\n sender: userOperation.sender ?? (await this.getAddress()),\n chainId\n })\n }\n }) as Promise<CreateKernelAccountReturnType<entryPointVersion>>\n}\n","// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/public/getAccountNonce.ts\n\nimport type { Address, Client } from \"viem\"\nimport { readContract } from \"viem/actions\"\nimport { getAction } from \"viem/utils\"\n\nexport type GetAccountNonceParams = {\n address: Address\n entryPointAddress: Address\n key?: bigint\n}\n\n/**\n * Returns the nonce of the account with the entry point.\n *\n * - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getAccountNonce\n *\n * @param client {@link client} that you created using viem's createPublicClient.\n * @param args {@link GetAccountNonceParams} address, entryPoint & key\n * @returns bigint nonce\n *\n * @example\n * import { createPublicClient } from \"viem\"\n * import { getAccountNonce } from \"permissionless/actions\"\n *\n * const client = createPublicClient({\n * chain: goerli,\n * transport: http(\"https://goerli.infura.io/v3/your-infura-key\")\n * })\n *\n * const nonce = await getAccountNonce(client, {\n * address,\n * entryPoint,\n * key\n * })\n *\n * // Return 0n\n */\nexport const getAccountNonce = async (\n client: Client,\n args: GetAccountNonceParams\n): Promise<bigint> => {\n const { address, entryPointAddress, key = BigInt(0) } = args\n\n return await getAction(\n client,\n readContract,\n \"readContract\"\n )({\n address: entryPointAddress,\n abi: [\n {\n inputs: [\n {\n name: \"sender\",\n type: \"address\"\n },\n {\n name: \"key\",\n type: \"uint192\"\n }\n ],\n name: \"getNonce\",\n outputs: [\n {\n name: \"nonce\",\n type: \"uint256\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n }\n ],\n functionName: \"getNonce\",\n args: [address, key]\n })\n}\n","// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/public/getSenderAddress.ts\n\nimport {\n type Address,\n BaseError,\n type Client,\n type ContractFunctionExecutionErrorType,\n ContractFunctionRevertedError,\n type Hex,\n InvalidInputRpcError,\n type OneOf,\n type Prettify,\n RawContractError,\n RpcRequestError,\n UnknownRpcError,\n concat,\n decodeErrorResult\n} from \"viem\"\n\nimport { simulateContract } from \"viem/actions\"\nimport { getAction } from \"viem/utils\"\n\nexport type GetSenderAddressParams = OneOf<\n | {\n initCode: Hex\n entryPointAddress: Address\n factory?: never\n factoryData?: never\n }\n | {\n entryPointAddress: Address\n factory: Address\n factoryData: Hex\n initCode?: never\n }\n>\n\nexport class InvalidEntryPointError extends BaseError {\n override name = \"InvalidEntryPointError\"\n\n constructor({\n cause,\n entryPointAddress\n }: { cause?: BaseError; entryPointAddress?: Address } = {}) {\n super(\n `The entry point address (\\`entryPoint\\`${\n entryPointAddress ? ` = ${entryPointAddress}` : \"\"\n }) is not a valid entry point. getSenderAddress did not revert with a SenderAddressResult error.`,\n {\n cause\n }\n )\n }\n}\n\n/**\n * Returns the address of the account that will be deployed with the given init code.\n *\n * - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getSenderAddress\n *\n * @param client {@link Client} that you created using viem's createPublicClient.\n * @param args {@link GetSenderAddressParams} initCode & entryPoint\n * @returns Sender's Address\n *\n * @example\n * import { createPublicClient } from \"viem\"\n * import { getSenderAddress } from \"permissionless/actions\"\n *\n * const publicClient = createPublicClient({\n * chain: goerli,\n * transport: http(\"https://goerli.infura.io/v3/your-infura-key\")\n * })\n *\n * const senderAddress = await getSenderAddress(publicClient, {\n * initCode,\n * entryPoint\n * })\n *\n * // Return '0x7a88a206ba40b37a8c07a2b5688cf8b287318b63'\n */\nexport const getSenderAddress = async (\n client: Client,\n args: Prettify<GetSenderAddressParams>\n): Promise<Address> => {\n const { initCode, entryPointAddress, factory, factoryData } = args\n\n if (!initCode && !factory && !factoryData) {\n throw new Error(\n \"Either `initCode` or `factory` and `factoryData` must be provided\"\n )\n }\n\n try {\n await getAction(\n client,\n simulateContract,\n \"simulateContract\"\n )({\n address: entryPointAddress,\n abi: [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"sender\",\n type: \"address\"\n }\n ],\n name: \"SenderAddressResult\",\n type: \"error\"\n },\n {\n inputs: [\n {\n internalType: \"bytes\",\n name: \"initCode\",\n type: \"bytes\"\n }\n ],\n name: \"getSenderAddress\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\"\n }\n ],\n functionName: \"getSenderAddress\",\n args: [initCode || concat([factory as Hex, factoryData as Hex])]\n })\n } catch (e) {\n const revertError = (e as ContractFunctionExecutionErrorType).walk(\n (err) =>\n err instanceof ContractFunctionRevertedError ||\n err instanceof RpcRequestError ||\n err instanceof InvalidInputRpcError ||\n err instanceof UnknownRpcError\n )\n\n if (!revertError) {\n // biome-ignore lint/suspicious/noExplicitAny:\n const cause = (e as ContractFunctionExecutionErrorType).cause as any\n const errorName = cause?.data?.errorName ?? \"\"\n if (\n errorName === \"SenderAddressResult\" &&\n cause?.data?.args &&\n cause?.data?.args[0]\n ) {\n return cause.data?.args[0] as Address\n }\n }\n\n if (revertError instanceof ContractFunctionRevertedError) {\n const errorName = revertError.data?.errorName ?? \"\"\n if (\n errorName === \"SenderAddressResult\" &&\n revertError.data?.args &&\n revertError.data?.args[0]\n ) {\n return revertError.data?.args[0] as Address\n }\n }\n\n if (revertError instanceof RpcRequestError) {\n const hexStringRegex = /0x[a-fA-F0-9]+/\n // biome-ignore lint/suspicious/noExplicitAny:\n const match = (revertError as unknown as any).cause.data.match(\n hexStringRegex\n )\n\n if (!match) {\n throw new Error(\n \"Failed to parse revert bytes from RPC response\"\n )\n }\n\n const data: Hex = match[0]\n\n const error = decodeErrorResult({\n abi: [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"sender\",\n type: \"address\"\n }\n ],\n name: \"SenderAddressResult\",\n type: \"error\"\n }\n ],\n data\n })\n\n return error.args[0] as Address\n }\n\n if (revertError instanceof InvalidInputRpcError) {\n const { data: data_ } = (\n e instanceof RawContractError\n ? e\n : e instanceof BaseError\n ? e.walk((err) => \"data\" in (err as Error)) || e.walk()\n : {}\n ) as RawContractError\n\n const data = typeof data_ === \"string\" ? data_ : data_?.data\n\n if (data === undefined) {\n throw new Error(\n \"Failed to parse revert bytes from RPC response\"\n )\n }\n\n const error = decodeErrorResult({\n abi: [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"sender\",\n type: \"address\"\n }\n ],\n name: \"SenderAddressResult\",\n type: \"error\"\n }\n ],\n data\n })\n\n return error.args[0] as Address\n }\n\n if (revertError instanceof UnknownRpcError) {\n const parsedBody = JSON.parse(\n // biome-ignore lint/suspicious/noExplicitAny:\n (revertError as unknown as any).cause.body\n )\n const revertData = parsedBody.error.data\n\n const hexStringRegex = /0x[a-fA-F0-9]+/\n const match = revertData.match(hexStringRegex)\n\n if (!match) {\n throw new Error(\n \"Failed to parse revert bytes from RPC response\"\n )\n }\n\n const data: Hex = match[0]\n\n const error = decodeErrorResult({\n abi: [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"sender\",\n type: \"address\"\n }\n ],\n name: \"SenderAddressResult\",\n type: \"error\"\n }\n ],\n data\n })\n\n return error.args[0] as Address\n }\n\n throw e\n }\n\n throw new InvalidEntryPointError({ entryPointAddress })\n}\n","import { type Address, type Hex, zeroAddress } from \"viem\"\nimport {\n type EntryPointVersion,\n entryPoint06Address,\n entryPoint07Address\n} from \"viem/account-abstraction\"\nimport type {\n EntryPointType,\n KERNEL_V2_VERSION_TYPE,\n KERNEL_V3_VERSION_TYPE,\n KERNEL_VERSION_TYPE\n} from \"./types/kernel.js\"\n\nexport const DUMMY_ECDSA_SIG =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\"\n\nexport const MAGIC_VALUE_SIG_REPLAYABLE =\n \"0x0555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a\"\n\n// export const KernelImplToVersionMap: { [key: Address]: string } = {\n// \"0x8dD4DBB54d8A8Cf0DE6F9CCC4609470A30EfF18C\": \"0.2.2\",\n// \"0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5\": \"0.2.2\",\n// \"0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab\": \"0.2.3\",\n// \"0x5FC0236D6c88a65beD32EECDC5D60a5CAb377717\": \"0.2.3\",\n// \"0xd3082872F8B06073A021b4602e022d5A070d7cfC\": \"0.2.4\",\n// \"0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27\": \"0.3.0\"\n// }\n\nexport const FACTORY_ADDRESS_V0_6 = \"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3\"\nexport const FACTORY_ADDRESS_V0_6_INIT_CODE_HASH =\n \"0xee9d8350bd899dd261db689aafd87eb8a30f085adbaff48152399438ff4eed73\"\n\nexport const KernelVersionToAddressesMap: {\n [key in KERNEL_VERSION_TYPE]: {\n accountImplementationAddress: Address\n factoryAddress: Address\n metaFactoryAddress?: key extends KERNEL_V3_VERSION_TYPE\n ? Address\n : never\n initCodeHash?: Hex\n }\n} = {\n \"0.0.2\": {\n accountImplementationAddress: zeroAddress,\n factoryAddress: \"0xaee9762ce625e0a8f7b184670fb57c37bfe1d0f1\"\n },\n \"0.2.2\": {\n accountImplementationAddress:\n \"0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5\",\n factoryAddress: FACTORY_ADDRESS_V0_6,\n initCodeHash: FACTORY_ADDRESS_V0_6_INIT_CODE_HASH\n },\n \"0.2.3\": {\n accountImplementationAddress:\n \"0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab\",\n factoryAddress: FACTORY_ADDRESS_V0_6,\n initCodeHash: FACTORY_ADDRESS_V0_6_INIT_CODE_HASH\n },\n \"0.2.4\": {\n accountImplementationAddress:\n \"0xd3082872F8B06073A021b4602e022d5A070d7cfC\",\n factoryAddress: FACTORY_ADDRESS_V0_6,\n initCodeHash: FACTORY_ADDRESS_V0_6_INIT_CODE_HASH\n },\n \"0.3.0\": {\n accountImplementationAddress:\n \"0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27\",\n factoryAddress: \"0x6723b44Abeec4E71eBE3232BD5B455805baDD22f\",\n metaFactoryAddress: \"0xd703aaE79538628d27099B8c4f621bE4CCd142d5\",\n initCodeHash:\n \"0x6fe6e6ea30eddce942b9618033ab8429f9ddac594053bec8a6744fffc71976e2\"\n },\n \"0.3.1\": {\n accountImplementationAddress:\n \"0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D\",\n factoryAddress: \"0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419\",\n metaFactoryAddress: \"0xd703aaE79538628d27099B8c4f621bE4CCd142d5\",\n initCodeHash:\n \"0x85d96aa1c9a65886d094915d76ccae85f14027a02c1647dde659f869460f03e6\"\n },\n \"0.3.2\": {\n accountImplementationAddress:\n \"0xD830D15D3dc0C269F3dBAa0F3e8626d33CFdaBe1\",\n factoryAddress: \"0x7a1dBAB750f12a90EB1B60D2Ae3aD17D4D81EfFe\",\n metaFactoryAddress: \"0xd703aaE79538628d27099B8c4f621bE4CCd142d5\",\n initCodeHash:\n \"0xc7c48c9dd12de68b8a4689b6f8c8c07b61d4d6fa4ddecdd86a6980d045fa67eb\"\n },\n \"0.3.3\": {\n accountImplementationAddress:\n \"0xd6CEDDe84be40893d153Be9d467CD6aD37875b28\",\n factoryAddress: \"0x2577507b78c2008Ff367261CB6285d44ba5eF2E9\",\n metaFactoryAddress: \"0xd703aaE79538628d27099B8c4f621bE4CCd142d5\",\n initCodeHash:\n \"0xc452397f1e7518f8cea0566ac057e243bb1643f6298aba8eec8cdee78ee3b3dd\"\n //\"0x1fefe62c5b9c14c4661af2e04e4a2fa10205066cae5f629d304d483f5fa9e5fc\"\n }\n}\n\nexport const KERNEL_V0_2: KERNEL_V2_VERSION_TYPE = \"0.0.2\"\nexport const KERNEL_V2_2: KERNEL_V2_VERSION_TYPE = \"0.2.2\"\nexport const KERNEL_V2_3: KERNEL_V2_VERSION_TYPE = \"0.2.3\"\nexport const KERNEL_V2_4: KERNEL_V2_VERSION_TYPE = \"0.2.4\"\nexport const KERNEL_V3_0: KERNEL_V3_VERSION_TYPE = \"0.3.0\"\nexport const KERNEL_V3_1: KERNEL_V3_VERSION_TYPE = \"0.3.1\"\nexport const KERNEL_V3_2: KERNEL_V3_VERSION_TYPE = \"0.3.2\"\nexport const KERNEL_V3_3_BETA: KERNEL_V3_VERSION_TYPE = \"0.3.3\"\nexport const KERNEL_V3_3: KERNEL_V3_VERSION_TYPE = \"0.3.3\"\n\nexport const TOKEN_ACTION = \"0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1\"\nexport const ONLY_ENTRYPOINT_HOOK_ADDRESS =\n \"0xb230f0A1C7C95fa11001647383c8C7a8F316b900\"\nexport const KERNEL_NAME = \"Kernel\"\n\nexport const VALIDATOR_TYPE = {\n SUDO: \"0x00\",\n SECONDARY: \"0x01\",\n PERMISSION: \"0x02\",\n EIP7702: \"0x00\"\n} as const\nexport enum VALIDATOR_MODE {\n DEFAULT = \"0x00\",\n ENABLE = \"0x01\"\n}\nexport enum CALL_TYPE {\n SINGLE = \"0x00\",\n BATCH = \"0x01\",\n DELEGATE_CALL = \"0xFF\"\n}\nexport enum EXEC_TYPE {\n DEFAULT = \"0x00\",\n TRY_EXEC = \"0x01\"\n}\n\nexport const PLUGIN_TYPE = {\n VALIDATOR: 1,\n EXECUTOR: 2,\n FALLBACK: 3,\n HOOK: 4,\n POLICY: 5,\n SIGNER: 6\n}\n\n// Safe's library for create and create2: https://github.com/safe-global/safe-contracts/blob/0acdd35a203299585438f53885df630f9d486a86/contracts/libraries/CreateCall.sol\n// Address was found here: https://github.com/safe-global/safe-deployments/blob/926ec6bbe2ebcac3aa2c2c6c0aff74aa590cbc6a/src/assets/v1.4.1/create_call.json\nexport const safeCreateCallAddress =\n \"0x9b35Af71d77eaf8d7e40252370304687390A1A52\"\nexport const KernelFactoryToInitCodeHashMap: { [key: Address]: Hex } = {\n \"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3\":\n \"0xee9d8350bd899dd261db689aafd87eb8a30f085adbaff48152399438ff4eed73\",\n \"0x6723b44Abeec4E71eBE3232BD5B455805baDD22f\":\n \"0x6fe6e6ea30eddce942b9618033ab8429f9ddac594053bec8a6744fffc71976e2\"\n}\n\nexport const KERNEL_IMPLEMENTATION_SLOT =\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\"\n\nexport const getEntryPoint = <TEntryPointVersion extends EntryPointVersion>(\n entryPointVersion: TEntryPointVersion\n): EntryPointType<TEntryPointVersion> => {\n if (entryPointVersion === \"0.6\")\n return {\n address: entryPoint06Address,\n version: entryPointVersion\n }\n return {\n address: entryPoint07Address,\n version: entryPointVersion\n }\n}\n\nexport const KERNEL_7702_DELEGATION_ADDRESS =\n \"0xd6CEDDe84be40893d153Be9d467CD6aD37875b28\"\n\nexport const FAST_POLLING_CHAIN_IDS = [1, 10, 56, 137, 8453, 42161, 84532]\n","export const KernelModuleIsInitializedAbi = [\n {\n type: \"function\",\n name: \"isInitialized\",\n inputs: [\n { name: \"smartAccount\", type: \"address\", internalType: \"address\" }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\"\n }\n] as const\n\nexport const KernelModuleInstallAbi = [\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"moduleType\",\n type: \"uint256\"\n },\n { internalType: \"address\", name: \"module\", type: \"address\" },\n { internalType: \"bytes\", name: \"initData\", type: \"bytes\" }\n ],\n stateMutability: \"payable\",\n type: \"function\",\n name: \"installModule\"\n }\n] as const\n\nexport const KernelModuleIsModuleInstalledAbi = [\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"moduleType\",\n type: \"uint256\"\n },\n { internalType: \"address\", name: \"module\", type: \"address\" },\n {\n internalType: \"bytes\",\n name: \"additionalContext\",\n type: \"bytes\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\",\n name: \"isModuleInstalled\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }]\n }\n] as const\n","import type { Address, Client, Hex } from \"viem\"\nimport { readContract } from \"viem/actions\"\nimport { getAction } from \"viem/utils\"\nimport { KernelModuleIsModuleInstalledAbi } from \"../../accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js\"\nimport type { PLUGIN_TYPE } from \"../../constants.js\"\n\nexport type IsPluginInstalledParams = {\n address: Address\n plugin: {\n type: (typeof PLUGIN_TYPE)[keyof typeof PLUGIN_TYPE]\n address: Address\n data?: Hex\n }\n}\n\n/**\n * Returns whether a plugin is installed on the account.\n *\n * @param client - Client to use\n * @param args - {@link IsPluginInstalledParams} address and plugin details\n * @returns boolean indicating if plugin is installed\n *\n * @example\n * import { createPublicClient } from \"viem\"\n * import { isPluginInstalled } from \"@zerodev/sdk\"\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http()\n * })\n *\n * const isInstalled = await isPluginInstalled(client, {\n * address: accountAddress,\n * plugin: {\n * type: PLUGIN_TYPE.VALIDATOR,\n * address: validatorAddress,\n * data: \"0x\"\n * }\n * })\n */\nexport const isPluginInstalled = async (\n client: Client,\n args: IsPluginInstalledParams\n): Promise<boolean> => {\n const { address, plugin } = args\n const { type, address: pluginAddress, data = \"0x\" } = plugin\n\n try {\n return await getAction(\n client,\n readContract,\n \"readContract\"\n )({\n address,\n abi: KernelModuleIsModuleInstalledAbi,\n functionName: \"isModuleInstalled\",\n args: [BigInt(type), pluginAddress, data]\n })\n } catch (error) {\n return false\n }\n}\n","import { satisfies } from \"semver\"\nimport {\n type Address,\n type Hex,\n concatHex,\n encodeFunctionData,\n erc20Abi,\n hexToSignature,\n isHex,\n pad,\n signatureToHex,\n toHex\n} from \"viem\"\nimport type { EntryPointVersion } from \"viem/account-abstraction\"\nimport type { ZeroDevPaymasterClient } from \"./clients/paymasterClient.js\"\nimport type { CALL_TYPE, EXEC_TYPE } from \"./constants.js\"\nimport type { EntryPointType, GetKernelVersion } from \"./types/kernel.js\"\n\nexport enum KERNEL_FEATURES {\n ERC1271_SIG_WRAPPER = \"ERC1271_SIG_WRAPPER\",\n ERC1271_WITH_VALIDATOR = \"ERC1271_WITH_VALIDATOR\",\n ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH = \"ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH\",\n ERC1271_REPLAYABLE = \"ERC1271_REPLAYABLE\"\n}\n\nexport const KERNEL_FEATURES_BY_VERSION: Record<KERNEL_FEATURES, string> = {\n [KERNEL_FEATURES.ERC1271_SIG_WRAPPER]: \">=0.2.3 || >=0.3.0-beta\",\n [KERNEL_FEATURES.ERC1271_WITH_VALIDATOR]: \">=0.3.0-beta\",\n [KERNEL_FEATURES.ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH]: \">=0.3.0-beta\",\n [KERNEL_FEATURES.ERC1271_REPLAYABLE]: \">=0.3.2\"\n}\n\nexport const hasKernelFeature = (\n feature: KERNEL_FEATURES,\n version: string\n): boolean => {\n if (!(feature in KERNEL_FEATURES_BY_VERSION)) {\n return false\n }\n\n return satisfies(version, KERNEL_FEATURES_BY_VERSION[feature])\n}\n\nexport const getERC20PaymasterApproveCall = async <\n entryPointVersion extends EntryPointVersion\n>(\n client: ZeroDevPaymasterClient<entryPointVersion>,\n {\n gasToken,\n approveAmount,\n entryPoint\n }: {\n gasToken: Address\n approveAmount: bigint\n entryPoint: EntryPointType<entryPointVersion>\n }\n): Promise<{ to: Address; value: bigint; data: Hex }> => {\n const response = await client.request({\n method: \"zd_pm_accounts\",\n params: [\n {\n chainId: client.chain?.id as number,\n entryPointAddress: entryPoint.address\n }\n ]\n })\n return {\n to: gasToken,\n data: encodeFunctionData({\n abi: erc20Abi,\n functionName: \"approve\",\n args: [response[0], approveAmount]\n }),\n value: 0n\n }\n}\n\nexport const fixSignedData = (sig: Hex): Hex => {\n let signature = sig\n if (!isHex(signature)) {\n signature = `0x${signature}`\n if (!isHex(signature)) {\n throw new Error(`Invalid signed data ${sig}`)\n }\n }\n\n let { r, s, v } = hexToSignature(signature)\n if (v === 0n || v === 1n) v += 27n\n // biome-ignore lint/style/noNonNullAssertion: <explanation>\n const joined = signatureToHex({ r, s, v: v! })\n return joined\n}\n\nexport const getExecMode = ({\n callType,\n execType\n}: {\n callType: CALL_TYPE\n execType: EXEC_TYPE\n}): Hex => {\n return concatHex([\n callType, // 1 byte\n execType, // 1 byte\n \"0x00000000\", // 4 bytes\n \"0x00000000\", // 4 bytes\n pad(\"0x00000000\", { size: 22 })\n ])\n}\n\nexport const validateKernelVersionWithEntryPoint = <\n entryPointVersion extends EntryPointVersion\n>(\n entryPointVersion: EntryPointVersion,\n kernelVersion: GetKernelVersion<entryPointVersion>\n) => {\n if (\n (entryPointVersion === \"0.6\" &&\n !satisfies(kernelVersion, \">=0.2.2 || <=0.2.4\")) ||\n (entryPointVersion === \"0.7\" && !satisfies(kernelVersion, \">=0.3.0\"))\n ) {\n throw new Error(\n \"KernelVersion should be >= 0.2.2 and <= 0.2.4 for EntryPointV0.6 and >= 0.3.0 for EntryPointV0.7\"\n )\n }\n}\n\nexport const satisfiesRange = (version: string, range: string): boolean => {\n return satisfies(version, range)\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type\nexport function deepHexlify(obj: any): any {\n if (typeof obj === \"function\") {\n return undefined\n }\n if (obj == null || typeof obj === \"string\" || typeof obj === \"boolean\") {\n return obj\n }\n\n if (typeof obj === \"bigint\" || typeof obj === \"number\") {\n return toHex(obj)\n }\n\n if (obj._isBigNumber != null || typeof obj !== \"object\") {\n return toHex(obj).replace(/^0x0/, \"0x\")\n }\n if (Array.isArray(obj)) {\n return obj.map((member) => deepHexlify(member))\n }\n return Object.keys(obj).reduce(\n // biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type\n (set: any, key: string) => {\n set[key] = deepHexlify(obj[key])\n return set\n },\n {}\n )\n}\n","// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/utils/toOwner.ts\nimport {\n type Account,\n type Address,\n type Chain,\n type EIP1193Provider,\n type EIP1193RequestFn,\n type EIP1474Methods,\n type LocalAccount,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n type WalletClient,\n createWalletClient,\n custom\n} from \"viem\"\nimport { toAccount } from \"viem/accounts\"\n\nimport type { SmartAccount } from \"viem/account-abstraction\"\nimport { signAuthorization, signMessage, signTypedData } from \"viem/actions\"\nimport type { Signer } from \"../types/index.js\"\n\nexport async function toSigner({\n signer,\n address\n}: {\n signer: Signer\n address?: Address\n}): Promise<LocalAccount | SmartAccount> {\n if (\n \"type\" in signer &&\n (signer.type === \"local\" || signer.type === \"smart\")\n ) {\n return signer as LocalAccount | SmartAccount\n }\n\n let walletClient:\n | WalletClient<Transport, Chain | undefined, Account>\n | undefined = undefined\n\n if (\"request\" in signer && !signer?.account) {\n if (!address) {\n address = (\n await Promise.any([\n (signer.request as EIP1193RequestFn<EIP1474Methods>)({\n method: \"eth_requestAccounts\"\n }),\n (signer.request as EIP1193RequestFn<EIP1474Methods>)({\n method: \"eth_accounts\"\n })\n ])\n )[0]\n }\n if (!address) {\n // For TS to be happy\n throw new Error(\"address is required\")\n }\n walletClient = createWalletClient({\n account: address,\n transport: custom(signer as EIP1193Provider)\n })\n }\n\n if (!walletClient) {\n walletClient = signer as WalletClient<\n Transport,\n Chain | undefined,\n Account\n >\n }\n\n return toAccount({\n address: walletClient.account.address,\n async signMessage({ message }) {\n return signMessage(\n walletClient as WalletClient<\n Transport,\n Chain | undefined,\n Account\n >,\n { message }\n )\n },\n async signTypedData(typedData) {\n const { primaryType, domain, message, types } =\n typedData as TypedDataDefinition<TypedData, string>\n return signTypedData(\n walletClient as WalletClient<\n Transport,\n Chain | undefined,\n Account\n >,\n {\n primaryType,\n domain,\n message,\n types\n }\n )\n },\n async signTransaction(_) {\n throw new Error(\n \"Smart account signer doesn't need to sign transactions\"\n )\n },\n async signAuthorization(authorization) {\n return signAuthorization(\n walletClient as WalletClient<\n Transport,\n Chain | undefined,\n Account\n >,\n authorization\n )\n }\n }) as LocalAccount\n}\n","import type { Address, LocalAccount } from \"viem\"\nimport { toAccount } from \"viem/accounts\"\n\nexport type EmptyAccount = LocalAccount<\"empty\">\nexport function addressToEmptyAccount(address: Address): EmptyAccount {\n const account = toAccount({\n address,\n async signMessage() {\n throw new Error(\"Method not supported\")\n },\n async signTransaction(_transaction) {\n throw new Error(\"Method not supported\")\n },\n async signTypedData(_typedData) {\n throw new Error(\"Method not supported\")\n }\n })\n\n return {\n ...account,\n publicKey: \"0x\",\n source: \"empty\"\n }\n}\n","import type { TypedData } from \"abitype\"\nimport type { Address, Client, Hex, TypedDataDefinition } from \"viem\"\nimport {\n type EntryPointVersion,\n type UserOperation,\n getUserOperationHash\n} from \"viem/account-abstraction\"\nimport { toAccount } from \"viem/accounts\"\nimport { getChainId, signMessage } from \"viem/actions\"\nimport type {\n EntryPointType,\n GetKernelVersion,\n KernelValidator,\n Signer\n} from \"../../types/index.js\"\nimport { toSigner } from \"../../utils/toSigner.js\"\n\nexport async function signerTo7702Validator<\n entryPointVersion extends EntryPointVersion\n>(\n client: Client,\n {\n signer,\n entryPoint,\n kernelVersion\n }: {\n signer: Signer\n entryPoint: EntryPointType<entryPointVersion>\n kernelVersion: GetKernelVersion<entryPointVersion>\n }\n): Promise<KernelValidator<\"EIP7702Validator\">> {\n const viemSigner = await toSigner({ signer })\n\n // Fetch chain id\n const chainId = client.chain?.id ?? (await getChainId(client))\n\n // Build the EOA Signer\n const account = toAccount({\n address: viemSigner.address,\n async signMessage({ message }) {\n return signMessage(client, { account: viemSigner, message })\n },\n async signTransaction(_, __) {\n throw new Error(\n \"Smart account signer doesn't need to sign transactions\"\n )\n },\n async signTypedData<\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends\n | keyof TTypedData\n | \"EIP712Domain\" = keyof TTypedData\n >(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {\n return viemSigner.signTypedData(typedData)\n }\n })\n\n return {\n ...account,\n supportedKernelVersions: kernelVersion,\n validatorType: \"EIP7702\",\n address: viemSigner.address,\n source: \"EIP7702Validator\",\n getIdentifier() {\n return \"0x\"\n },\n\n async getEnableData() {\n return viemSigner.address\n },\n async getNonceKey(_accountAddress?: Address, customNonceKey?: bigint) {\n if (customNonceKey) {\n return customNonceKey\n }\n return 0n\n },\n // Sign a user operation\n async signUserOperation(userOperation) {\n const hash = getUserOperationHash({\n userOperation: {\n ...userOperation,\n signature: \"0x\"\n } as UserOperation<entryPointVersion>,\n entryPointAddress: entryPoint.address,\n entryPointVersion: entryPoint.version,\n chainId: chainId\n })\n const signature = await signMessage(client, {\n account: viemSigner,\n message: { raw: hash }\n })\n return signature\n },\n\n // Get simple dummy signature\n async getStubSignature() {\n return \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\"\n },\n\n async isEnabled(\n _kernelAccountAddress: Address,\n _selector: Hex\n ): Promise<boolean> {\n return false\n }\n }\n}\n","import { satisfies } from \"semver\"\nimport {\n type Address,\n type Client,\n type Hex,\n concat,\n concatHex,\n maxUint16,\n maxUint192,\n pad,\n toHex,\n zeroAddress\n} from \"viem\"\nimport type { EntryPointVersion } from \"viem/account-abstraction\"\nimport { getChainId } from \"viem/actions\"\nimport { encodeModuleInstallCallData as encodeModuleInstallCallDataEpV06 } from \"../../accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js\"\nimport {\n ONLY_ENTRYPOINT_HOOK_ADDRESS,\n VALIDATOR_MODE,\n VALIDATOR_TYPE\n} from \"../../constants.js\"\nimport {\n type KernelPluginManager,\n type KernelPluginManagerParams,\n type KernelValidator,\n ValidatorMode\n} from \"../../types/kernel.js\"\nimport { getKernelV3Nonce } from \"../kernel/utils/account/ep0_7/getKernelV3Nonce.js\"\nimport { accountMetadata } from \"../kernel/utils/common/accountMetadata.js\"\nimport { getActionSelector } from \"../kernel/utils/common/getActionSelector.js\"\nimport { getEncodedPluginsData as getEncodedPluginsDataV1 } from \"../kernel/utils/plugins/ep0_6/getEncodedPluginsData.js\"\nimport { getPluginsEnableTypedData as getPluginsEnableTypedDataV1 } from \"../kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js\"\nimport { getEncodedPluginsData as getEncodedPluginsDataV2 } from \"../kernel/utils/plugins/ep0_7/getEncodedPluginsData.js\"\nimport { getPluginsEnableTypedData as getPluginsEnableTypedDataV2 } from \"../kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js\"\nimport { isPluginInitialized } from \"../kernel/utils/plugins/ep0_7/isPluginInitialized.js\"\n\nexport function isKernelPluginManager<\n entryPointVersion extends EntryPointVersion\n>(\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n plugin: any\n): plugin is KernelPluginManager<entryPointVersion> {\n return plugin?.getPluginEnableSignature !== undefined\n}\n\nexport async function toKernelPluginManager<\n entryPointVersion extends EntryPointVersion\n>(\n client: Client,\n {\n sudo,\n regular,\n hook,\n pluginEnableSignature,\n validatorInitData,\n action,\n validAfter = 0,\n validUntil = 0,\n entryPoint,\n kernelVersion,\n chainId,\n isPreInstalled = false\n }: KernelPluginManagerParams<entryPointVersion>\n): Promise<KernelPluginManager<entryPointVersion>> {\n if (\n (sudo && !satisfies(kernelVersion, sudo?.supportedKernelVersions)) ||\n (regular && !satisfies(kernelVersion, regular?.supportedKernelVersions))\n ) {\n throw new Error(\n \"Either sudo or/and regular validator version mismatch. Update to latest plugin package and use the proper plugin version\"\n )\n }\n let pluginEnabled = isPreInstalled\n const activeValidator = regular || sudo\n if (!activeValidator) {\n throw new Error(\"One of `sudo` or `regular` validator must be set\")\n }\n action = {\n selector: action?.selector ?? getActionSelector(entryPoint.version),\n address: action?.address ?? zeroAddress\n }\n if (\n entryPoint.version === \"0.7\" &&\n (action.address.toLowerCase() !== zeroAddress.toLowerCase() ||\n action.selector.toLowerCase() !==\n getActionSelector(entryPoint.version).toLowerCase()) &&\n kernelVersion === \"0.3.0\"\n ) {\n action.hook = {\n address: action.hook?.address ?? ONLY_ENTRYPOINT_HOOK_ADDRESS\n }\n }\n\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n\n const getSignatureData = async (\n accountAddress: Address,\n selector: Hex,\n userOpSignature: Hex = \"0x\"\n ): Promise<Hex> => {\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n if (entryPoint.version === \"0.6\") {\n if (regular) {\n if (pluginEnabled) {\n return ValidatorMode.plugin\n }\n if (await isPluginEnabled(accountAddress, selector)) {\n return ValidatorMode.plugin\n }\n\n const enableSignature =\n await getPluginEnableSignature(accountAddress)\n if (!enableSignature) {\n throw new Error(\"Enable signature not set\")\n }\n return getEncodedPluginsDataV1({\n accountAddress,\n enableSignature,\n action,\n validator: regular,\n validUntil,\n validAfter\n })\n } else if (sudo) {\n return ValidatorMode.sudo\n } else {\n throw new Error(\n \"One of `sudo` or `regular` validator must be set\"\n )\n }\n }\n if (regular) {\n if (pluginEnabled) {\n return userOpSignature\n }\n if (await isPluginEnabled(accountAddress, action.selector)) {\n return userOpSignature\n }\n const enableSignature =\n await getPluginEnableSignature(accountAddress)\n return getEncodedPluginsDataV2({\n enableSignature,\n userOpSignature,\n action,\n enableData: await regular.getEnableData(accountAddress),\n hook\n })\n } else if (sudo) {\n return userOpSignature\n } else {\n throw new Error(\"One of `sudo` or `regular` validator must be set\")\n }\n }\n\n const isPluginEnabled = async (\n accountAddress: Address,\n selector: Hex,\n regularValidator?: KernelValidator\n ) => {\n const isExternalRegularValidator = !!regularValidator\n const regular_ = regularValidator ?? regular\n\n if (isPreInstalled && !isExternalRegularValidator) return true\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n if (!regular_) throw new Error(\"regular validator not set\")\n if (entryPoint.version === \"0.6\") {\n return regular_.isEnabled(accountAddress, selector)\n }\n const isEnabled =\n (await regular_.isEnabled(accountAddress, action.selector)) ||\n (await isPluginInitialized(\n client,\n accountAddress,\n regular_.address\n ))\n if (isEnabled && !isExternalRegularValidator) {\n pluginEnabled = true\n }\n return isEnabled\n }\n\n const getPluginEnableSignature = async (\n accountAddress: Address,\n regularValidator?: KernelValidator\n ) => {\n const isExternalRegularValidator = !!regularValidator\n const regular_ = regularValidator ?? regular\n\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n if (pluginEnableSignature && !isExternalRegularValidator)\n return pluginEnableSignature\n if (!sudo)\n throw new Error(\n \"sudo validator not set -- need it to enable the validator\"\n )\n if (!regular_) throw new Error(\"regular validator not set\")\n\n const { version } = await accountMetadata(\n client,\n accountAddress,\n kernelVersion\n )\n if (!chainId) {\n chainId = client.chain?.id ?? (await getChainId(client))\n }\n let ownerSig: Hex\n if (entryPoint.version === \"0.6\") {\n const typeData = await getPluginsEnableTypedDataV1({\n accountAddress,\n chainId,\n kernelVersion: version ?? kernelVersion,\n action,\n validator: regular_,\n validUntil,\n validAfter\n })\n ownerSig = await sudo.signTypedData(typeData)\n if (!isExternalRegularValidator) {\n pluginEnableSignature = ownerSig\n }\n return ownerSig\n }\n const validatorNonce = await getKernelV3Nonce(client, accountAddress)\n const typedData = await getPluginsEnableTypedDataV2({\n accountAddress,\n chainId,\n kernelVersion: version,\n action,\n hook,\n validator: regular_,\n validatorNonce\n })\n ownerSig = await sudo.signTypedData(typedData)\n if (!isExternalRegularValidator) {\n pluginEnableSignature = ownerSig\n }\n\n return ownerSig\n }\n const getIdentifier = (isSudo = false) => {\n const validator = (isSudo ? sudo : regular) ?? activeValidator\n return concat([\n VALIDATOR_TYPE[validator.validatorType],\n validator.getIdentifier()\n ])\n }\n\n const getPluginsEnableTypedData = async (\n accountAddress: Address,\n regularValidator?: KernelValidator\n ) => {\n const regular_ = regularValidator ?? regular\n\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n if (!sudo)\n throw new Error(\n \"sudo validator not set -- need it to enable the validator\"\n )\n if (!regular_) throw new Error(\"regular validator not set\")\n\n const { version } = await accountMetadata(\n client,\n accountAddress,\n kernelVersion\n )\n\n const validatorNonce = await getKernelV3Nonce(client, accountAddress)\n\n if (!chainId) {\n chainId = client.chain?.id ?? (await getChainId(client))\n }\n const typedData = await getPluginsEnableTypedDataV2({\n accountAddress,\n chainId,\n kernelVersion: version,\n action,\n validator: regular_,\n validatorNonce\n })\n\n return typedData\n }\n\n return {\n sudoValidator: sudo,\n regularValidator: regular,\n activeValidatorMode: sudo && !regular ? \"sudo\" : \"regular\",\n ...activeValidator,\n hook,\n getIdentifier,\n encodeModuleInstallCallData: async (accountAddress: Address) => {\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n if (!regular) throw new Error(\"regular validator not set\")\n if (entryPoint.version === \"0.6\") {\n return await encodeModuleInstallCallDataEpV06({\n accountAddress,\n selector: action.selector,\n executor: action.address,\n validator: regular?.address,\n validUntil,\n validAfter,\n enableData: await regular.getEnableData(accountAddress)\n })\n }\n throw new Error(\"EntryPoint v0.7 not supported yet\")\n },\n signUserOperation: async (userOperation) => {\n const userOpSig =\n await activeValidator.signUserOperation(userOperation)\n if (entryPoint.version === \"0.6\") {\n return concatHex([\n await getSignatureData(\n userOperation.sender,\n userOperation.callData.toString().slice(0, 10) as Hex\n ),\n userOpSig\n ])\n }\n return await getSignatureData(\n userOperation.sender,\n userOperation.callData.toString().slice(0, 10) as Hex,\n userOpSig\n )\n },\n getAction: () => {\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n return action\n },\n getValidityData: () => ({\n validAfter,\n validUntil\n }),\n getStubSignature: async (userOperation) => {\n const userOpSig =\n await activeValidator.getStubSignature(userOperation)\n if (entryPoint.version === \"0.6\") {\n return concatHex([\n await getSignatureData(\n userOperation.sender,\n userOperation.callData.toString().slice(0, 10) as Hex\n ),\n userOpSig\n ])\n }\n return await getSignatureData(\n userOperation.sender,\n userOperation.callData.toString().slice(0, 10) as Hex,\n userOpSig\n )\n },\n getNonceKey: async (\n accountAddress = zeroAddress,\n customNonceKey = 0n\n ) => {\n if (!action) {\n throw new Error(\"Action data must be set\")\n }\n if (entryPoint.version === \"0.6\") {\n if (customNonceKey > maxUint192) {\n throw new Error(\n \"Custom nonce key must be equal or less than maxUint192 for 0.6\"\n )\n }\n\n return await activeValidator.getNonceKey(\n accountAddress,\n customNonceKey\n )\n }\n\n if (customNonceKey > maxUint16)\n throw new Error(\n \"Custom nonce key must be equal or less than 2 bytes(maxUint16) for v0.7\"\n )\n\n const validatorMode =\n !regular ||\n (await isPluginEnabled(accountAddress, action.selector))\n ? VALIDATOR_MODE.DEFAULT\n : VALIDATOR_MODE.ENABLE\n const validatorType = regular\n ? VALIDATOR_TYPE[regular.validatorType]\n : VALIDATOR_TYPE.SUDO\n const encoding = pad(\n concatHex([\n validatorMode, // 1 byte\n validatorType, // 1 byte\n pad(activeValidator.getIdentifier(), {\n size: 20,\n dir: \"right\"\n }), // 20 bytes\n pad(\n toHex(\n await activeValidator.getNonceKey(\n accountAddress,\n customNonceKey\n )\n ),\n {\n size: 2\n }\n ) // 2 byte\n ]),\n { size: 24 }\n )\n const encodedNonceKey = BigInt(encoding)\n return encodedNonceKey\n },\n isPluginEnabled,\n getPluginEnableSignature,\n getPluginsEnableTypedData,\n getValidatorInitData: async () => {\n if (validatorInitData) return validatorInitData\n return {\n validatorAddress: sudo?.address ?? activeValidator.address,\n\n enableData:\n (await sudo?.getEnableData()) ??\n (await activeValidator.getEnableData()),\n\n identifier: pad(getIdentifier(true), { size: 21, dir: \"right\" })\n }\n },\n signUserOperationWithActiveValidator: async (userOperation) => {\n return activeValidator.signUserOperation(userOperation)\n }\n }\n}\n","/**\n * The exeute abi, used to execute a transaction on the kernel smart account\n */\nexport const KernelExecuteAbi = [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\"\n },\n {\n internalType: \"uint256\",\n name: \"value\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"data\",\n type: \"bytes\"\n },\n {\n internalType: \"enum Operation\",\n name: \"\",\n type: \"uint8\"\n }\n ],\n name: \"execute\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n components: [\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\"\n },\n {\n internalType: \"uint256\",\n name: \"value\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"data\",\n type: \"bytes\"\n }\n ],\n internalType: \"struct Call[]\",\n name: \"calls\",\n type: \"tuple[]\"\n }\n ],\n name: \"executeBatch\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\"\n },\n {\n internalType: \"bytes\",\n name: \"data\",\n type: \"bytes\"\n }\n ],\n name: \"executeDelegateCall\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n }\n] as const\n\n/**\n * The init abi, used to initialise kernel account\n */\nexport const KernelInitAbi = [\n {\n inputs: [\n {\n internalType: \"contract IKernelValidator\",\n name: \"_defaultValidator\",\n type: \"address\"\n },\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\"\n }\n ],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n }\n] as const\n\nexport const KernelAccountAbi = [\n {\n inputs: [\n {\n internalType: \"contract IEntryPoint\",\n name: \"_entryPoint\",\n type: \"address\"\n }\n ],\n stateMutability: \"nonpayable\",\n type: \"constructor\"\n },\n {\n inputs: [],\n name: \"AlreadyInitialized\",\n type: \"error\"\n },\n {\n inputs: [],\n name: \"DisabledMode\",\n type: \"error\"\n },\n {\n inputs: [],\n name: \"NotAuthorizedCaller\",\n type: \"error\"\n },\n {\n inputs: [],\n name: \"NotEntryPoint\",\n type: \"error\"\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: \"address\",\n name: \"oldValidator\",\n type: \"address\"\n },\n {\n indexed: true,\n internalType: \"address\",\n name: \"newValidator\",\n type: \"address\"\n }\n ],\n name: \"DefaultValidatorChanged\",\n type: \"event\"\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: \"bytes4\",\n name: \"selector\",\n type: \"bytes4\"\n },\n {\n indexed: true,\n internalType: \"address\",\n name: \"executor\",\n type: \"address\"\n },\n {\n indexed: true,\n internalType: \"address\",\n name: \"validator\",\n type: \"address\"\n }\n ],\n name: \"ExecutionChanged\",\n type: \"event\"\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: false,\n internalType: \"address\",\n name: \"sender\",\n type: \"address\"\n },\n {\n indexed: false,\n internalType: \"uint256\",\n name: \"amount\",\n type: \"uint256\"\n }\n ],\n name: \"Received\",\n type: \"event\"\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: \"address\",\n name: \"newImplementation\",\n type: \"address\"\n }\n ],\n name: \"Upgraded\",\n type: \"event\"\n },\n {\n stateMutability: \"payable\",\n type: \"fallback\"\n },\n {\n inputs: [\n {\n internalType: \"bytes4\",\n name: \"_disableFlag\",\n type: \"bytes4\"\n }\n ],\n name: \"disableMode\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"eip712Domain\",\n outputs: [\n {\n internalType: \"bytes1\",\n name: \"fields\",\n type: \"bytes1\"\n },\n {\n internalType: \"string\",\n name: \"name\",\n type: \"string\"\n },\n {\n internalType: \"string\",\n name: \"version\",\n type: \"string\"\n },\n {\n internalType: \"uint256\",\n name: \"chainId\",\n type: \"uint256\"\n },\n {\n internalType: \"address\",\n name: \"verifyingContract\",\n type: \"address\"\n },\n {\n internalType: \"bytes32\",\n name: \"salt\",\n type: \"bytes32\"\n },\n {\n internalType: \"uint256[]\",\n name: \"extensions\",\n type: \"uint256[]\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"entryPoint\",\n outputs: [\n {\n internalType: \"contract IEntryPoint\",\n name: \"\",\n type: \"address\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\"\n },\n {\n internalType: \"uint256\",\n name: \"value\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"data\",\n type: \"bytes\"\n },\n {\n internalType: \"enum Operation\",\n name: \"\",\n type: \"uint8\"\n }\n ],\n name: \"execute\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n components: [\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\"\n },\n {\n internalType: \"uint256\",\n name: \"value\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"data\",\n type: \"bytes\"\n }\n ],\n internalType: \"struct Call[]\",\n name: \"calls\",\n type: \"tuple[]\"\n }\n ],\n name: \"executeBatch\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"to\",\n type: \"address\"\n },\n {\n internalType: \"bytes\",\n name: \"data\",\n type: \"bytes\"\n }\n ],\n name: \"executeDelegateCall\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"getDefaultValidator\",\n outputs: [\n {\n internalType: \"contract IKernelValidator\",\n name: \"validator\",\n type: \"address\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"getDisabledMode\",\n outputs: [\n {\n internalType: \"bytes4\",\n name: \"disabled\",\n type: \"bytes4\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"bytes4\",\n name: \"_selector\",\n type: \"bytes4\"\n }\n ],\n name: \"getExecution\",\n outputs: [\n {\n components: [\n {\n internalType: \"ValidAfter\",\n name: \"validAfter\",\n type: \"uint48\"\n },\n {\n internalType: \"ValidUntil\",\n name: \"validUntil\",\n type: \"uint48\"\n },\n {\n internalType: \"address\",\n name: \"executor\",\n type: \"address\"\n },\n {\n internalType: \"contract IKernelValidator\",\n name: \"validator\",\n type: \"address\"\n }\n ],\n internalType: \"struct ExecutionDetail\",\n name: \"\",\n type: \"tuple\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"getLastDisabledTime\",\n outputs: [\n {\n internalType: \"uint48\",\n name: \"\",\n type: \"uint48\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"uint192\",\n name: \"key\",\n type: \"uint192\"\n }\n ],\n name: \"getNonce\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"getNonce\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"contract IKernelValidator\",\n name: \"_defaultValidator\",\n type: \"address\"\n },\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\"\n }\n ],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"bytes32\",\n name: \"hash\",\n type: \"bytes32\"\n },\n {\n internalType: \"bytes\",\n name: \"signature\",\n type: \"bytes\"\n }\n ],\n name: \"isValidSignature\",\n outputs: [\n {\n internalType: \"bytes4\",\n name: \"\",\n type: \"bytes4\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"name\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\"\n },\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\"\n },\n {\n internalType: \"uint256[]\",\n name: \"\",\n type: \"uint256[]\"\n },\n {\n internalType: \"uint256[]\",\n name: \"\",\n type: \"uint256[]\"\n },\n {\n internalType: \"bytes\",\n name: \"\",\n type: \"bytes\"\n }\n ],\n name: \"onERC1155BatchReceived\",\n outputs: [\n {\n internalType: \"bytes4\",\n name: \"\",\n type: \"bytes4\"\n }\n ],\n stateMutability: \"pure\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\"\n },\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\"\n },\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\"\n },\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"\",\n type: \"bytes\"\n }\n ],\n name: \"onERC1155Received\",\n outputs: [\n {\n internalType: \"bytes4\",\n name: \"\",\n type: \"bytes4\"\n }\n ],\n stateMutability: \"pure\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\"\n },\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\"\n },\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"\",\n type: \"bytes\"\n }\n ],\n name: \"onERC721Received\",\n outputs: [\n {\n internalType: \"bytes4\",\n name: \"\",\n type: \"bytes4\"\n }\n ],\n stateMutability: \"pure\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"contract IKernelValidator\",\n name: \"_defaultValidator\",\n type: \"address\"\n },\n {\n internalType: \"bytes\",\n name: \"_data\",\n type: \"bytes\"\n }\n ],\n name: \"setDefaultValidator\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"bytes4\",\n name: \"_selector\",\n type: \"bytes4\"\n },\n {\n internalType: \"address\",\n name: \"_executor\",\n type: \"address\"\n },\n {\n internalType: \"contract IKernelValidator\",\n name: \"_validator\",\n type: \"address\"\n },\n {\n internalType: \"ValidUntil\",\n name: \"_validUntil\",\n type: \"uint48\"\n },\n {\n internalType: \"ValidAfter\",\n name: \"_validAfter\",\n type: \"uint48\"\n },\n {\n internalType: \"bytes\",\n name: \"_enableData\",\n type: \"bytes\"\n }\n ],\n name: \"setExecution\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"_newImplementation\",\n type: \"address\"\n }\n ],\n name: \"upgradeTo\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [\n {\n components: [\n {\n internalType: \"address\",\n name: \"sender\",\n type: \"address\"\n },\n {\n internalType: \"uint256\",\n name: \"nonce\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"initCode\",\n type: \"bytes\"\n },\n {\n internalType: \"bytes\",\n name: \"callData\",\n type: \"bytes\"\n },\n {\n internalType: \"uint256\",\n name: \"callGasLimit\",\n type: \"uint256\"\n },\n {\n internalType: \"uint256\",\n name: \"verificationGasLimit\",\n type: \"uint256\"\n },\n {\n internalType: \"uint256\",\n name: \"preVerificationGas\",\n type: \"uint256\"\n },\n {\n internalType: \"uint256\",\n name: \"maxFeePerGas\",\n type: \"uint256\"\n },\n {\n internalType: \"uint256\",\n name: \"maxPriorityFeePerGas\",\n type: \"uint256\"\n },\n {\n internalType: \"bytes\",\n name: \"paymasterAndData\",\n type: \"bytes\"\n },\n {\n internalType: \"bytes\",\n name: \"signature\",\n type: \"bytes\"\n }\n ],\n internalType: \"struct UserOperation\",\n name: \"_userOp\",\n type: \"tuple\"\n },\n {\n internalType: \"bytes32\",\n name: \"userOpHash\",\n type: \"bytes32\"\n },\n {\n internalType: \"uint256\",\n name: \"missingAccountFunds\",\n type: \"uint256\"\n }\n ],\n name: \"validateUserOp\",\n outputs: [\n {\n internalType: \"ValidationData\",\n name: \"validationData\",\n type: \"uint256\"\n }\n ],\n stateMutability: \"payable\",\n type: \"function\"\n },\n {\n inputs: [],\n name: \"version\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\"\n }\n ],\n stateMutability: \"view\",\n type: \"function\"\n },\n {\n stateMutability: \"payable\",\n type: \"receive\"\n }\n] as const\n","import { encodeFunctionData } from \"viem\"\nimport { KernelExecuteAbi } from \"../../abi/KernelAccountAbi.js\"\nimport type { CallArgs } from \"../types.js\"\n\nexport const encodeExecuteBatchCall = (args: readonly CallArgs[]) => {\n return encodeFunctionData({\n abi: KernelExecuteAbi,\n functionName: \"executeBatch\",\n args: [\n args.map((arg) => {\n return {\n to: arg.to,\n value: arg.value || 0n,\n data: arg.data || \"0x\"\n }\n })\n ]\n })\n}\n","import { encodeFunctionData } from \"viem\"\nimport { KernelExecuteAbi } from \"../../abi/KernelAccountAbi.js\"\nimport type { DelegateCallArgs } from \"../types.js\"\n\nexport const encodeExecuteDelegateCall = (args: DelegateCallArgs) => {\n return encodeFunctionData({\n abi: KernelExecuteAbi,\n functionName: \"executeDelegateCall\",\n args: [args.to, args.data || \"0x\"]\n })\n}\n","import { encodeFunctionData } from \"viem\"\nimport { KernelExecuteAbi } from \"../../abi/KernelAccountAbi.js\"\nimport type { CallArgs } from \"../types.js\"\n\nexport const encodeExecuteSingleCall = (args: CallArgs) => {\n return encodeFunctionData({\n abi: KernelExecuteAbi,\n functionName: \"execute\",\n args: [args.to, args.value || 0n, args.data || \"0x\", 0]\n })\n}\n","import type { EntryPointVersion } from \"viem/account-abstraction\"\nimport type { CallType } from \"../../../../../types/kernel.js\"\nimport type { KernelSmartAccountImplementation } from \"../../../createKernelAccount.js\"\nimport { encodeExecuteBatchCall } from \"../../ep0_6/encodeExecuteBatchCall.js\"\nimport { encodeExecuteDelegateCall } from \"../../ep0_6/encodeExecuteDelegateCall.js\"\nimport { encodeExecuteSingleCall } from \"../../ep0_6/encodeExecuteSingleCall.js\"\n\nexport const encodeCallData = async <\n entryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n calls: Parameters<\n KernelSmartAccountImplementation<entryPointVersion>[\"encodeCalls\"]\n >[0],\n callType?: CallType | undefined\n) => {\n if (calls.length > 1) {\n if (callType === \"delegatecall\") {\n throw new Error(\"Cannot batch delegatecall\")\n }\n return encodeExecuteBatchCall(calls)\n }\n\n const call = calls.length === 0 ? undefined : calls[0]\n\n if (!call) {\n throw new Error(\"No calls to encode\")\n }\n\n // Default to `call`\n if (!callType || callType === \"call\") {\n return encodeExecuteSingleCall(call)\n }\n\n if (callType === \"delegatecall\") {\n return encodeExecuteDelegateCall({\n to: call.to,\n data: call.data\n })\n }\n\n throw new Error(\"Invalid call type\")\n}\n","import { type Address, type Hex, encodeFunctionData } from \"viem\"\nimport type { PluginInstallData } from \"../../../../../types/kernel.js\"\nimport { KernelAccountAbi } from \"../../../abi/KernelAccountAbi.js\"\nimport { encodeCallData } from \"./encodeCallData.js\"\n\nexport const encodeModuleInstallCallData = async ({\n accountAddress,\n enableData,\n executor,\n selector,\n validAfter,\n validUntil,\n validator\n}: {\n accountAddress: Address\n} & PluginInstallData<\"0.6\">): Promise<Hex> => {\n return encodeCallData(\n [\n {\n to: accountAddress,\n value: 0n,\n data: encodeFunctionData({\n abi: KernelAccountAbi,\n functionName: \"setExecution\",\n args: [\n selector,\n executor,\n validator,\n validUntil,\n validAfter,\n enableData\n ]\n })\n }\n ],\n \"call\"\n )\n}\n","import type { Address, CustomSource, Hex, LocalAccount, PartialBy } from \"viem\"\nimport type {\n EntryPointVersion,\n UserOperation,\n entryPoint06Abi,\n entryPoint07Abi\n} from \"viem/account-abstraction\"\nimport type { PLUGIN_TYPE, VALIDATOR_TYPE } from \"../constants.js\"\nexport type ZeroDevPaymasterRpcSchema<\n entryPointVersion extends EntryPointVersion\n> = [\n {\n Method: \"zd_sponsorUserOperation\"\n Parameters: [\n {\n chainId: number\n userOp: entryPointVersion extends \"0.6\"\n ? PartialBy<\n UserOperation<\"0.6\">,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n >\n : PartialBy<\n UserOperation<\"0.7\">,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"paymasterVerificationGasLimit\"\n | \"paymasterPostOpGasLimit\"\n >\n entryPointAddress: Address\n gasTokenData?: {\n tokenAddress: Hex\n }\n shouldOverrideFee?: boolean\n manualGasEstimation?: boolean\n shouldConsume?: boolean\n }\n ]\n ReturnType: entryPointVersion extends \"0.6\"\n ? {\n paymasterAndData: Hex\n preVerificationGas: Hex\n verificationGasLimit: Hex\n callGasLimit: Hex\n maxFeePerGas?: Hex\n maxPriorityFeePerGas?: Hex\n paymaster?: never\n paymasterVerificationGasLimit?: never\n paymasterPostOpGasLimit?: never\n paymasterData?: never\n }\n : {\n preVerificationGas: Hex\n verificationGasLimit: Hex\n callGasLimit: Hex\n paymaster: Address\n paymasterVerificationGasLimit: Hex\n paymasterPostOpGasLimit: Hex\n paymasterData: Hex\n maxFeePerGas?: Hex\n maxPriorityFeePerGas?: Hex\n paymasterAndData?: never\n }\n },\n {\n Method: \"zd_pm_accounts\"\n Parameters: [\n {\n chainId: number\n entryPointAddress: Address\n }\n ]\n ReturnType: Address[]\n },\n {\n Method: \"stackup_getERC20TokenQuotes\"\n Parameters: [\n {\n chainId: number\n userOp: UserOperation<\"0.6\">\n entryPointAddress: Address\n tokenAddress: Address\n }\n ]\n ReturnType: {\n maxGasCostToken: string\n tokenDecimals: string\n }\n }\n]\n\nexport type ZeroDevUserOperationGasPriceWithBigIntAsHex = {\n slow: {\n maxFeePerGas: Hex\n maxPriorityFeePerGas: Hex\n }\n standard: {\n maxFeePerGas: Hex\n maxPriorityFeePerGas: Hex\n }\n fast: {\n maxFeePerGas: Hex\n maxPriorityFeePerGas: Hex\n }\n}\n\nexport type ZeroDevAccountClientRpcSchema = [\n {\n Method: \"zd_getUserOperationGasPrice\"\n Parameters: []\n ReturnType: ZeroDevUserOperationGasPriceWithBigIntAsHex\n }\n]\n\nexport type ValidatorType = Extract<\n keyof typeof VALIDATOR_TYPE,\n \"PERMISSION\" | \"SECONDARY\" | \"EIP7702\"\n>\n\nexport type KernelValidator<Name extends string = string> =\n LocalAccount<Name> & {\n validatorType: ValidatorType\n supportedKernelVersions: string\n getNonceKey: (\n accountAddress?: Address,\n customNonceKey?: bigint\n ) => Promise<bigint>\n getStubSignature(\n userOperation: UserOperation,\n pluginEnableSignature?: Hex\n ): Promise<Hex>\n signUserOperation: (\n userOperation: UserOperation & {\n chainId?: number | undefined\n },\n pluginEnableSignature?: Hex\n ) => Promise<Hex>\n getEnableData(accountAddress?: Address): Promise<Hex>\n isEnabled(accountAddress: Address, selector: Hex): Promise<boolean>\n getIdentifier: () => Hex\n }\n\nexport type KernelValidatorHook = {\n getEnableData(accountAddress?: Address): Promise<Hex>\n getIdentifier: () => Hex\n}\n\nexport type ValidatorInitData = {\n validatorAddress: Address\n enableData: Hex\n identifier: Hex\n initConfig?: Hex[]\n}\n\nexport type ActiveValidatorMode = \"sudo\" | \"regular\"\n\nexport type KernelPluginManager<entryPointVersion extends EntryPointVersion> =\n KernelValidator & {\n sudoValidator?: KernelValidator\n regularValidator?: KernelValidator\n activeValidatorMode: ActiveValidatorMode\n hook?: KernelValidatorHook\n getPluginEnableSignature(\n accountAddress: Address,\n regularValidator?: KernelValidator\n ): Promise<Hex>\n getValidatorInitData(): Promise<ValidatorInitData>\n getAction(): Action\n getValidityData(): PluginValidityData\n getIdentifier(isSudo?: boolean): Hex\n encodeModuleInstallCallData: (accountAddress: Address) => Promise<Hex>\n getPluginsEnableTypedData: (\n accountAddress: Address,\n regularValidator?: KernelValidator\n ) => Promise<Parameters<CustomSource[\"signTypedData\"]>[0]>\n isPluginEnabled: (\n accountAddress: Address,\n selector: Hex,\n regularValidator?: KernelValidator\n ) => Promise<boolean>\n signUserOperationWithActiveValidator: (\n userOperation: UserOperation<entryPointVersion>\n ) => Promise<Hex>\n }\n\nexport type PluginInstallData<entryPointVersion extends EntryPointVersion> =\n entryPointVersion extends \"0.6\"\n ? {\n selector: Hex\n executor: Address\n validator: Address\n validUntil: number\n validAfter: number\n enableData: Hex\n }\n : // TODO: Add support for EP v0.7\n never\n\nexport type KernelPluginManagerParams<\n entryPointVersion extends EntryPointVersion\n> = {\n sudo?: KernelValidator\n regular?: KernelValidator\n hook?: KernelValidatorHook\n pluginEnableSignature?: Hex\n validatorInitData?: ValidatorInitData\n action?: Action\n entryPoint: EntryPointType<entryPointVersion>\n kernelVersion: KERNEL_VERSION_TYPE\n chainId?: number\n isPreInstalled?: boolean\n} & Partial<PluginValidityData>\n\nexport type Hook = {\n address: Address\n}\n\nexport type Action = {\n address: Address\n selector: Hex\n hook?: Hook\n}\n\nexport type PluginValidityData = {\n validUntil: number\n validAfter: number\n}\n\nexport enum ValidatorMode {\n sudo = \"0x00000000\",\n plugin = \"0x00000001\",\n enable = \"0x00000002\"\n}\n\nexport type PluginMigrationData = {\n type: (typeof PLUGIN_TYPE)[keyof typeof PLUGIN_TYPE]\n address: Address\n data: Hex\n}\n\nexport type CallType = \"call\" | \"delegatecall\"\n\nexport type KernelEncodeCallDataArgs = {\n to: Address\n value: bigint\n data: Hex\n callType: CallType | undefined\n}[]\n\nexport type GetEntryPointAbi<entryPointVersion extends EntryPointVersion> =\n entryPointVersion extends \"0.6\"\n ? typeof entryPoint06Abi\n : typeof entryPoint07Abi\n\nexport type Execution = {\n target: Address\n value: bigint\n callData: Hex\n}\n\nexport type KERNEL_V2_VERSION_TYPE = \"0.0.2\" | \"0.2.2\" | \"0.2.3\" | \"0.2.4\"\n\nexport type KERNEL_V3_VERSION_TYPE = \"0.3.0\" | \"0.3.1\" | \"0.3.2\" | \"0.3.3\"\n\nexport type KERNEL_VERSION_TYPE =\n | KERNEL_V2_VERSION_TYPE\n | KERNEL_V3_VERSION_TYPE\n\nexport type GetKernelVersion<entryPointVersion extends EntryPointVersion> =\n entryPointVersion extends \"0.6\"\n ? KERNEL_V2_VERSION_TYPE\n : KERNEL_V3_VERSION_TYPE\n\nexport type EntryPointType<entryPointVersion extends EntryPointVersion> = {\n address: Address\n version: entryPointVersion\n}\n","export const KernelV3InitAbi = [\n {\n type: \"function\",\n name: \"initialize\",\n inputs: [\n {\n name: \"_rootValidator\",\n type: \"bytes21\",\n internalType: \"ValidationId\"\n },\n { name: \"hook\", type: \"address\", internalType: \"contract IHook\" },\n { name: \"validatorData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"hookData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"nonpayable\"\n }\n] as const\n\nexport const KernelV3ExecuteAbi = [\n {\n type: \"function\",\n name: \"execute\",\n inputs: [\n { name: \"execMode\", type: \"bytes32\", internalType: \"ExecMode\" },\n { name: \"executionCalldata\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executeFromExecutor\",\n inputs: [\n { name: \"execMode\", type: \"bytes32\", internalType: \"ExecMode\" },\n { name: \"executionCalldata\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [\n { name: \"returnData\", type: \"bytes[]\", internalType: \"bytes[]\" }\n ],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executeUserOp\",\n inputs: [\n {\n name: \"userOp\",\n type: \"tuple\",\n internalType: \"struct PackedUserOperation\",\n components: [\n {\n name: \"sender\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"nonce\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"initCode\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"callData\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"accountGasLimits\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"preVerificationGas\",\n type: \"uint256\",\n internalType: \"uint256\"\n },\n {\n name: \"gasFees\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"paymasterAndData\",\n type: \"bytes\",\n internalType: \"bytes\"\n },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ]\n },\n { name: \"userOpHash\", type: \"bytes32\", internalType: \"bytes32\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n }\n] as const\n\nexport const KernelV3AccountAbi = [\n {\n type: \"constructor\",\n inputs: [\n {\n name: \"_entrypoint\",\n type: \"address\",\n internalType: \"contract IEntryPoint\"\n }\n ],\n stateMutability: \"nonpayable\"\n },\n { type: \"fallback\", stateMutability: \"payable\" },\n { type: \"receive\", stateMutability: \"payable\" },\n {\n type: \"function\",\n name: \"accountId\",\n inputs: [],\n outputs: [\n {\n name: \"accountImplementationId\",\n type: \"string\",\n internalType: \"string\"\n }\n ],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"currentNonce\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\", internalType: \"uint32\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"eip712Domain\",\n inputs: [],\n outputs: [\n { name: \"fields\", type: \"bytes1\", internalType: \"bytes1\" },\n { name: \"name\", type: \"string\", internalType: \"string\" },\n { name: \"version\", type: \"string\", internalType: \"string\" },\n { name: \"chainId\", type: \"uint256\", internalType: \"uint256\" },\n {\n name: \"verifyingContract\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"salt\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"extensions\", type: \"uint256[]\", internalType: \"uint256[]\" }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"entrypoint\",\n inputs: [],\n outputs: [\n { name: \"\", type: \"address\", internalType: \"contract IEntryPoint\" }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"execute\",\n inputs: [\n { name: \"execMode\", type: \"bytes32\", internalType: \"ExecMode\" },\n { name: \"executionCalldata\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executeFromExecutor\",\n inputs: [\n { name: \"execMode\", type: \"bytes32\", internalType: \"ExecMode\" },\n { name: \"executionCalldata\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [\n { name: \"returnData\", type: \"bytes[]\", internalType: \"bytes[]\" }\n ],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executeUserOp\",\n inputs: [\n {\n name: \"userOp\",\n type: \"tuple\",\n internalType: \"struct PackedUserOperation\",\n components: [\n {\n name: \"sender\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"nonce\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"initCode\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"callData\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"accountGasLimits\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"preVerificationGas\",\n type: \"uint256\",\n internalType: \"uint256\"\n },\n {\n name: \"gasFees\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"paymasterAndData\",\n type: \"bytes\",\n internalType: \"bytes\"\n },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ]\n },\n { name: \"userOpHash\", type: \"bytes32\", internalType: \"bytes32\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executorConfig\",\n inputs: [\n {\n name: \"executor\",\n type: \"address\",\n internalType: \"contract IExecutor\"\n }\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct ExecutorManager.ExecutorConfig\",\n components: [\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"initialize\",\n inputs: [\n {\n name: \"_rootValidator\",\n type: \"bytes21\",\n internalType: \"ValidationId\"\n },\n { name: \"hook\", type: \"address\", internalType: \"contract IHook\" },\n { name: \"validatorData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"hookData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"nonpayable\"\n },\n {\n type: \"function\",\n name: \"installModule\",\n inputs: [\n { name: \"moduleType\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"module\", type: \"address\", internalType: \"address\" },\n { name: \"initData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"installValidations\",\n inputs: [\n { name: \"vIds\", type: \"bytes21[]\", internalType: \"ValidationId[]\" },\n {\n name: \"configs\",\n type: \"tuple[]\",\n internalType: \"struct ValidationManager.ValidationConfig[]\",\n components: [\n { name: \"nonce\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n }\n ]\n },\n {\n name: \"validationData\",\n type: \"bytes[]\",\n internalType: \"bytes[]\"\n },\n { name: \"hookData\", type: \"bytes[]\", internalType: \"bytes[]\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"invalidateNonce\",\n inputs: [{ name: \"nonce\", type: \"uint32\", internalType: \"uint32\" }],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"isAllowedSelector\",\n inputs: [\n { name: \"vId\", type: \"bytes21\", internalType: \"ValidationId\" },\n { name: \"selector\", type: \"bytes4\", internalType: \"bytes4\" }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"isModuleInstalled\",\n inputs: [\n { name: \"moduleType\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"module\", type: \"address\", internalType: \"address\" },\n { name: \"additionalContext\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"isValidSignature\",\n inputs: [\n { name: \"hash\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [{ name: \"\", type: \"bytes4\", internalType: \"bytes4\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"permissionConfig\",\n inputs: [{ name: \"pId\", type: \"bytes4\", internalType: \"PermissionId\" }],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct ValidationManager.PermissionConfig\",\n components: [\n {\n name: \"permissionFlag\",\n type: \"bytes2\",\n internalType: \"PassFlag\"\n },\n {\n name: \"signer\",\n type: \"address\",\n internalType: \"contract ISigner\"\n },\n {\n name: \"policyData\",\n type: \"bytes22[]\",\n internalType: \"PolicyData[]\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"rootValidator\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bytes21\", internalType: \"ValidationId\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"selectorConfig\",\n inputs: [{ name: \"selector\", type: \"bytes4\", internalType: \"bytes4\" }],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct SelectorManager.SelectorConfig\",\n components: [\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n },\n {\n name: \"target\",\n type: \"address\",\n internalType: \"address\"\n },\n {\n name: \"callType\",\n type: \"bytes1\",\n internalType: \"CallType\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"supportsExecutionMode\",\n inputs: [{ name: \"mode\", type: \"bytes32\", internalType: \"ExecMode\" }],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"supportsModule\",\n inputs: [\n { name: \"moduleTypeId\", type: \"uint256\", internalType: \"uint256\" }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"uninstallModule\",\n inputs: [\n { name: \"moduleType\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"module\", type: \"address\", internalType: \"address\" },\n { name: \"deInitData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"uninstallValidation\",\n inputs: [\n { name: \"vId\", type: \"bytes21\", internalType: \"ValidationId\" },\n { name: \"deinitData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"hookDeinitData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"upgradeTo\",\n inputs: [\n {\n name: \"_newImplementation\",\n type: \"address\",\n internalType: \"address\"\n }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"validNonceFrom\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\", internalType: \"uint32\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"validateUserOp\",\n inputs: [\n {\n name: \"userOp\",\n type: \"tuple\",\n internalType: \"struct PackedUserOperation\",\n components: [\n {\n name: \"sender\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"nonce\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"initCode\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"callData\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"accountGasLimits\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"preVerificationGas\",\n type: \"uint256\",\n internalType: \"uint256\"\n },\n {\n name: \"gasFees\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"paymasterAndData\",\n type: \"bytes\",\n internalType: \"bytes\"\n },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ]\n },\n { name: \"userOpHash\", type: \"bytes32\", internalType: \"bytes32\" },\n {\n name: \"missingAccountFunds\",\n type: \"uint256\",\n internalType: \"uint256\"\n }\n ],\n outputs: [\n {\n name: \"validationData\",\n type: \"uint256\",\n internalType: \"ValidationData\"\n }\n ],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"validationConfig\",\n inputs: [\n { name: \"vId\", type: \"bytes21\", internalType: \"ValidationId\" }\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct ValidationManager.ValidationConfig\",\n components: [\n { name: \"nonce\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"event\",\n name: \"ModuleInstalled\",\n inputs: [\n {\n name: \"moduleTypeId\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n },\n {\n name: \"module\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ModuleUninstallResult\",\n inputs: [\n {\n name: \"module\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n },\n {\n name: \"result\",\n type: \"bool\",\n indexed: false,\n internalType: \"bool\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ModuleUninstalled\",\n inputs: [\n {\n name: \"moduleTypeId\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n },\n {\n name: \"module\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"NonceInvalidated\",\n inputs: [\n {\n name: \"nonce\",\n type: \"uint32\",\n indexed: false,\n internalType: \"uint32\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"PermissionInstalled\",\n inputs: [\n {\n name: \"permission\",\n type: \"bytes4\",\n indexed: false,\n internalType: \"PermissionId\"\n },\n {\n name: \"nonce\",\n type: \"uint32\",\n indexed: false,\n internalType: \"uint32\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"PermissionUninstalled\",\n inputs: [\n {\n name: \"permission\",\n type: \"bytes4\",\n indexed: false,\n internalType: \"PermissionId\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"Received\",\n inputs: [\n {\n name: \"sender\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n },\n {\n name: \"amount\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"RootValidatorUpdated\",\n inputs: [\n {\n name: \"rootValidator\",\n type: \"bytes21\",\n indexed: false,\n internalType: \"ValidationId\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"SelectorSet\",\n inputs: [\n {\n name: \"selector\",\n type: \"bytes4\",\n indexed: false,\n internalType: \"bytes4\"\n },\n {\n name: \"vId\",\n type: \"bytes21\",\n indexed: false,\n internalType: \"ValidationId\"\n },\n {\n name: \"allowed\",\n type: \"bool\",\n indexed: false,\n internalType: \"bool\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"TryExecuteUnsuccessful\",\n inputs: [\n {\n name: \"batchExecutionindex\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n },\n {\n name: \"result\",\n type: \"bytes\",\n indexed: false,\n internalType: \"bytes\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"Upgraded\",\n inputs: [\n {\n name: \"implementation\",\n type: \"address\",\n indexed: true,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ValidatorInstalled\",\n inputs: [\n {\n name: \"validator\",\n type: \"address\",\n indexed: false,\n internalType: \"contract IValidator\"\n },\n {\n name: \"nonce\",\n type: \"uint32\",\n indexed: false,\n internalType: \"uint32\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ValidatorUninstalled\",\n inputs: [\n {\n name: \"validator\",\n type: \"address\",\n indexed: false,\n internalType: \"contract IValidator\"\n }\n ],\n anonymous: false\n },\n { type: \"error\", name: \"EnableNotApproved\", inputs: [] },\n { type: \"error\", name: \"ExecutionReverted\", inputs: [] },\n { type: \"error\", name: \"InvalidCallType\", inputs: [] },\n { type: \"error\", name: \"InvalidCaller\", inputs: [] },\n { type: \"error\", name: \"InvalidExecutor\", inputs: [] },\n { type: \"error\", name: \"InvalidFallback\", inputs: [] },\n { type: \"error\", name: \"InvalidMode\", inputs: [] },\n { type: \"error\", name: \"InvalidModuleType\", inputs: [] },\n { type: \"error\", name: \"InvalidNonce\", inputs: [] },\n { type: \"error\", name: \"InvalidSelector\", inputs: [] },\n { type: \"error\", name: \"InvalidSignature\", inputs: [] },\n { type: \"error\", name: \"InvalidValidationType\", inputs: [] },\n { type: \"error\", name: \"InvalidValidator\", inputs: [] },\n { type: \"error\", name: \"NonceInvalidationError\", inputs: [] },\n { type: \"error\", name: \"NotSupportedCallType\", inputs: [] },\n { type: \"error\", name: \"OnlyExecuteUserOp\", inputs: [] },\n { type: \"error\", name: \"PermissionDataLengthMismatch\", inputs: [] },\n { type: \"error\", name: \"PermissionNotAlllowedForSignature\", inputs: [] },\n { type: \"error\", name: \"PermissionNotAlllowedForUserOp\", inputs: [] },\n { type: \"error\", name: \"PolicyDataTooLarge\", inputs: [] },\n {\n type: \"error\",\n name: \"PolicyFailed\",\n inputs: [{ name: \"i\", type: \"uint256\", internalType: \"uint256\" }]\n },\n { type: \"error\", name: \"PolicySignatureOrderError\", inputs: [] },\n { type: \"error\", name: \"RootValidatorCannotBeRemoved\", inputs: [] },\n { type: \"error\", name: \"SignerPrefixNotPresent\", inputs: [] }\n] as const\n","import type { Address, Client } from \"viem\"\nimport { readContract } from \"viem/actions\"\nimport { getAction } from \"viem/utils\"\nimport { KernelV3AccountAbi } from \"../../../abi/kernel_v_3_0_0/KernelAccountAbi.js\"\n\nexport const getKernelV3Nonce = async (\n client: Client,\n accountAddress: Address\n): Promise<number> => {\n try {\n const nonce = await getAction(\n client,\n readContract,\n \"readContract\"\n )({\n abi: KernelV3AccountAbi,\n address: accountAddress,\n functionName: \"currentNonce\",\n args: []\n })\n return nonce === 0 ? 1 : nonce\n } catch (error) {\n return 1\n }\n}\n","export const EIP1271Abi = [\n {\n type: \"function\",\n name: \"eip712Domain\",\n inputs: [],\n outputs: [\n { name: \"fields\", type: \"bytes1\", internalType: \"bytes1\" },\n { name: \"name\", type: \"string\", internalType: \"string\" },\n { name: \"version\", type: \"string\", internalType: \"string\" },\n { name: \"chainId\", type: \"uint256\", internalType: \"uint256\" },\n {\n name: \"verifyingContract\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"salt\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"extensions\", type: \"uint256[]\", internalType: \"uint256[]\" }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"isValidSignature\",\n inputs: [\n { name: \"data\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [\n { name: \"magicValue\", type: \"bytes4\", internalType: \"bytes4\" }\n ],\n stateMutability: \"view\"\n }\n] as const\n","import {\n type Address,\n type Client,\n decodeFunctionResult,\n encodeFunctionData,\n publicActions\n} from \"viem\"\nimport { KERNEL_NAME } from \"../../../../constants.js\"\nimport type { KERNEL_VERSION_TYPE } from \"../../../../types/kernel.js\"\nimport { EIP1271Abi } from \"../../abi/EIP1271Abi.js\"\n\nexport type AccountMetadata = {\n name: string\n version: string\n chainId: bigint\n}\nexport const accountMetadata = async (\n client: Client,\n accountAddress: Address,\n kernelVersion: KERNEL_VERSION_TYPE,\n chainId?: number\n): Promise<AccountMetadata> => {\n try {\n const domain = await client.request({\n method: \"eth_call\",\n params: [\n {\n to: accountAddress,\n data: encodeFunctionData({\n abi: EIP1271Abi,\n functionName: \"eip712Domain\"\n })\n },\n \"latest\"\n ]\n })\n if (domain !== \"0x\") {\n const decoded = decodeFunctionResult({\n abi: [...EIP1271Abi],\n functionName: \"eip712Domain\",\n data: domain\n })\n return {\n name: decoded[1],\n version: decoded[2],\n chainId: decoded[3]\n }\n }\n } catch (error) {}\n return {\n name: KERNEL_NAME,\n version: kernelVersion === \"0.3.0\" ? \"0.3.0-beta\" : kernelVersion,\n chainId: BigInt(\n chainId ??\n (client.chain\n ? client.chain.id\n : await client.extend(publicActions).getChainId())\n )\n }\n}\n","import { type Hex, getAbiItem, toFunctionSelector } from \"viem\"\nimport type { EntryPointVersion } from \"viem/account-abstraction\"\nimport { KernelAccountAbi } from \"../../abi/KernelAccountAbi.js\"\nimport { KernelV3AccountAbi } from \"../../abi/kernel_v_3_0_0/KernelAccountAbi.js\"\n\nexport const getActionSelector = (\n entryPointVersion: EntryPointVersion\n): Hex => {\n if (entryPointVersion === \"0.6\") {\n return toFunctionSelector(\n getAbiItem({ abi: KernelAccountAbi, name: \"execute\" })\n )\n } else if (entryPointVersion === \"0.7\") {\n return toFunctionSelector(\n getAbiItem({ abi: KernelV3AccountAbi, name: \"execute\" })\n )\n } else {\n throw new Error(\"Unsupported entry point version\")\n }\n}\n","import { type Address, type Hex, concat, pad, toHex } from \"viem\"\nimport {\n type PluginValidityData,\n ValidatorMode\n} from \"../../../../../types/index.js\"\nimport type { Kernel2_0_plugins } from \"./getPluginsEnableTypedData.js\"\n\nexport const getEncodedPluginsData = async ({\n accountAddress,\n enableSignature,\n action,\n validator,\n validUntil,\n validAfter\n}: {\n accountAddress: Address\n enableSignature: Hex\n} & Kernel2_0_plugins &\n PluginValidityData) => {\n const enableData = await validator.getEnableData(accountAddress)\n const enableDataLength = enableData.length / 2 - 1\n return concat([\n ValidatorMode.enable,\n pad(toHex(validUntil, { size: 6 }), { size: 6 }), // 6 bytes 4 - 10\n pad(toHex(validAfter), { size: 6 }), // 6 bytes 10 - 16\n pad(validator.address, { size: 20 }), // 20 bytes 16 - 36\n pad(action.address, { size: 20 }), // 20 bytes 36 - 56\n pad(toHex(enableDataLength), { size: 32 }), // 32 bytes 56 - 88\n enableData, // 88 - 88 + enableData.length\n pad(toHex(enableSignature.length / 2 - 1), { size: 32 }), // 32 bytes 88 + enableData.length - 120 + enableData.length\n enableSignature // 120 + enableData.length - 120 + enableData.length + enableSignature.length\n ])\n}\n","import {\n type Address,\n type CustomSource,\n concatHex,\n hexToBigInt,\n pad,\n toHex\n} from \"viem\"\nimport type {\n Action,\n KernelValidator,\n PluginValidityData\n} from \"../../../../../types/index.js\"\n\nexport type Kernel2_0_plugins = {\n validator: KernelValidator\n action: Action\n}\nexport const getPluginsEnableTypedData = async ({\n accountAddress,\n chainId,\n kernelVersion,\n action,\n validator,\n validUntil,\n validAfter\n}: {\n accountAddress: Address\n chainId: number\n kernelVersion: string\n} & Kernel2_0_plugins &\n PluginValidityData): Promise<\n Parameters<CustomSource[\"signTypedData\"]>[0]\n> => {\n return {\n domain: {\n name: \"Kernel\",\n version: kernelVersion,\n chainId,\n verifyingContract: accountAddress\n },\n types: {\n ValidatorApproved: [\n { name: \"sig\", type: \"bytes4\" },\n { name: \"validatorData\", type: \"uint256\" },\n { name: \"executor\", type: \"address\" },\n { name: \"enableData\", type: \"bytes\" }\n ]\n },\n message: {\n sig: action.selector,\n validatorData: hexToBigInt(\n concatHex([\n pad(toHex(validUntil ?? 0), {\n size: 6\n }),\n pad(toHex(validAfter ?? 0), {\n size: 6\n }),\n validator.address\n ]),\n { size: 32 }\n ),\n executor: action.address as Address,\n enableData: await validator.getEnableData(accountAddress)\n },\n primaryType: \"ValidatorApproved\"\n }\n}\n","import {\n type Hex,\n concat,\n encodeAbiParameters,\n parseAbiParameters,\n zeroAddress\n} from \"viem\"\nimport { CALL_TYPE } from \"../../../../../constants.js\"\nimport type {\n Action,\n KernelValidatorHook\n} from \"../../../../../types/kernel.js\"\n\nexport const getEncodedPluginsData = async ({\n enableSignature,\n userOpSignature,\n action,\n enableData,\n hook\n}: {\n enableSignature: Hex\n userOpSignature: Hex\n action: Action\n enableData: Hex\n hook?: KernelValidatorHook\n}) => {\n return concat([\n hook?.getIdentifier() ?? zeroAddress, // hook address 20 bytes\n encodeAbiParameters(\n parseAbiParameters(\n \"bytes validatorData, bytes hookData, bytes selectorData, bytes enableSig, bytes userOpSig\"\n ),\n [\n enableData,\n (await hook?.getEnableData()) ?? \"0x\",\n concat([\n action.selector,\n action.address,\n action.hook?.address ?? zeroAddress,\n encodeAbiParameters(\n parseAbiParameters(\n \"bytes selectorInitData, bytes hookInitData\"\n ),\n // [TODO]: Add support for other call_type\n [CALL_TYPE.DELEGATE_CALL, \"0x0000\"]\n )\n ]),\n enableSignature,\n userOpSignature\n ]\n )\n ])\n}\n","import {\n type Address,\n type CustomSource,\n concat,\n encodeAbiParameters,\n pad,\n parseAbiParameters,\n zeroAddress\n} from \"viem\"\nimport { CALL_TYPE, VALIDATOR_TYPE } from \"../../../../../constants.js\"\nimport type { KernelValidatorHook } from \"../../../../../types/kernel.js\"\nimport type { Kernel2_0_plugins } from \"../ep0_6/getPluginsEnableTypedData.js\"\n\nexport const getPluginsEnableTypedData = async ({\n accountAddress,\n chainId,\n kernelVersion,\n action,\n hook,\n validator,\n validatorNonce\n}: {\n accountAddress: Address\n chainId: number\n kernelVersion: string\n validatorNonce: number\n hook?: KernelValidatorHook\n} & Kernel2_0_plugins): Promise<\n Parameters<CustomSource[\"signTypedData\"]>[0]\n> => {\n return {\n domain: {\n name: \"Kernel\",\n version: kernelVersion === \"0.3.0\" ? \"0.3.0-beta\" : kernelVersion,\n chainId,\n verifyingContract: accountAddress\n },\n types: {\n Enable: [\n { name: \"validationId\", type: \"bytes21\" },\n { name: \"nonce\", type: \"uint32\" },\n { name: \"hook\", type: \"address\" },\n { name: \"validatorData\", type: \"bytes\" },\n { name: \"hookData\", type: \"bytes\" },\n { name: \"selectorData\", type: \"bytes\" }\n ]\n },\n message: {\n validationId: concat([\n VALIDATOR_TYPE[validator.validatorType],\n pad(validator.getIdentifier(), { size: 20, dir: \"right\" })\n ]),\n nonce: validatorNonce,\n hook: hook?.getIdentifier() ?? zeroAddress,\n validatorData: await validator.getEnableData(accountAddress),\n hookData: (await hook?.getEnableData(accountAddress)) ?? \"0x\",\n selectorData: concat([\n action.selector,\n action.address,\n action.hook?.address ?? zeroAddress,\n encodeAbiParameters(\n parseAbiParameters(\n \"bytes selectorInitData, bytes hookInitData\"\n ),\n [CALL_TYPE.DELEGATE_CALL, \"0x0000\"]\n )\n ])\n },\n primaryType: \"Enable\"\n }\n}\n","import type { Address, Client } from \"viem\"\nimport { readContract } from \"viem/actions\"\nimport { getAction } from \"viem/utils\"\nimport { KernelModuleIsInitializedAbi } from \"../../../abi/kernel_v_3_0_0/KernelModuleAbi.js\"\n\nexport const isPluginInitialized = async (\n client: Client,\n accountAddress: Address,\n pluginAddress: Address\n) => {\n try {\n return await getAction(\n client,\n readContract,\n \"readContract\"\n )({\n abi: KernelModuleIsInitializedAbi,\n address: pluginAddress,\n functionName: \"isInitialized\",\n args: [accountAddress]\n })\n } catch (error) {}\n return false\n}\n","export const KernelV3FactoryAbi = [\n {\n type: \"constructor\",\n inputs: [{ name: \"_impl\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"nonpayable\"\n },\n {\n type: \"function\",\n name: \"createAccount\",\n inputs: [\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"salt\", type: \"bytes32\", internalType: \"bytes32\" }\n ],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"getAddress\",\n inputs: [\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"salt\", type: \"bytes32\", internalType: \"bytes32\" }\n ],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"implementation\",\n inputs: [],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\"\n },\n { type: \"error\", name: \"InitializeError\", inputs: [] }\n] as const\n","export const KernelFactoryStakerAbi = [\n {\n type: \"constructor\",\n inputs: [{ name: \"_owner\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"nonpayable\"\n },\n {\n type: \"function\",\n name: \"approveFactory\",\n inputs: [\n {\n name: \"factory\",\n type: \"address\",\n internalType: \"contract KernelFactory\"\n },\n { name: \"approval\", type: \"bool\", internalType: \"bool\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"approved\",\n inputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract KernelFactory\"\n }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"cancelOwnershipHandover\",\n inputs: [],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"completeOwnershipHandover\",\n inputs: [\n { name: \"pendingOwner\", type: \"address\", internalType: \"address\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"deployWithFactory\",\n inputs: [\n {\n name: \"factory\",\n type: \"address\",\n internalType: \"contract KernelFactory\"\n },\n { name: \"createData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"salt\", type: \"bytes32\", internalType: \"bytes32\" }\n ],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"owner\",\n inputs: [],\n outputs: [{ name: \"result\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"ownershipHandoverExpiresAt\",\n inputs: [\n { name: \"pendingOwner\", type: \"address\", internalType: \"address\" }\n ],\n outputs: [{ name: \"result\", type: \"uint256\", internalType: \"uint256\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"renounceOwnership\",\n inputs: [],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"requestOwnershipHandover\",\n inputs: [],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"stake\",\n inputs: [\n {\n name: \"entryPoint\",\n type: \"address\",\n internalType: \"contract IEntryPoint\"\n },\n { name: \"unstakeDelay\", type: \"uint32\", internalType: \"uint32\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"transferOwnership\",\n inputs: [\n { name: \"newOwner\", type: \"address\", internalType: \"address\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"unlockStake\",\n inputs: [\n {\n name: \"entryPoint\",\n type: \"address\",\n internalType: \"contract IEntryPoint\"\n }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"withdrawStake\",\n inputs: [\n {\n name: \"entryPoint\",\n type: \"address\",\n internalType: \"contract IEntryPoint\"\n },\n {\n name: \"recipient\",\n type: \"address\",\n internalType: \"address payable\"\n }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"event\",\n name: \"OwnershipHandoverCanceled\",\n inputs: [\n {\n name: \"pendingOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"OwnershipHandoverRequested\",\n inputs: [\n {\n name: \"pendingOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"OwnershipTransferred\",\n inputs: [\n {\n name: \"oldOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\"\n },\n {\n name: \"newOwner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n { type: \"error\", name: \"AlreadyInitialized\", inputs: [] },\n { type: \"error\", name: \"NewOwnerIsZeroAddress\", inputs: [] },\n { type: \"error\", name: \"NoHandoverRequest\", inputs: [] },\n { type: \"error\", name: \"NotApprovedFactory\", inputs: [] },\n { type: \"error\", name: \"Unauthorized\", inputs: [] }\n] as const\n","export const KernelV3_1AccountAbi = [\n {\n type: \"constructor\",\n inputs: [\n {\n name: \"_entrypoint\",\n type: \"address\",\n internalType: \"contract IEntryPoint\"\n }\n ],\n stateMutability: \"nonpayable\"\n },\n { type: \"fallback\", stateMutability: \"payable\" },\n { type: \"receive\", stateMutability: \"payable\" },\n {\n type: \"function\",\n name: \"accountId\",\n inputs: [],\n outputs: [\n {\n name: \"accountImplementationId\",\n type: \"string\",\n internalType: \"string\"\n }\n ],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"changeRootValidator\",\n inputs: [\n {\n name: \"_rootValidator\",\n type: \"bytes21\",\n internalType: \"ValidationId\"\n },\n { name: \"hook\", type: \"address\", internalType: \"contract IHook\" },\n { name: \"validatorData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"hookData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"currentNonce\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\", internalType: \"uint32\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"eip712Domain\",\n inputs: [],\n outputs: [\n { name: \"fields\", type: \"bytes1\", internalType: \"bytes1\" },\n { name: \"name\", type: \"string\", internalType: \"string\" },\n { name: \"version\", type: \"string\", internalType: \"string\" },\n { name: \"chainId\", type: \"uint256\", internalType: \"uint256\" },\n {\n name: \"verifyingContract\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"salt\", type: \"bytes32\", internalType: \"bytes32\" },\n {\n name: \"extensions\",\n type: \"uint256[]\",\n internalType: \"uint256[]\"\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"entrypoint\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IEntryPoint\"\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"execute\",\n inputs: [\n { name: \"execMode\", type: \"bytes32\", internalType: \"ExecMode\" },\n {\n name: \"executionCalldata\",\n type: \"bytes\",\n internalType: \"bytes\"\n }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executeFromExecutor\",\n inputs: [\n { name: \"execMode\", type: \"bytes32\", internalType: \"ExecMode\" },\n {\n name: \"executionCalldata\",\n type: \"bytes\",\n internalType: \"bytes\"\n }\n ],\n outputs: [\n { name: \"returnData\", type: \"bytes[]\", internalType: \"bytes[]\" }\n ],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executeUserOp\",\n inputs: [\n {\n name: \"userOp\",\n type: \"tuple\",\n internalType: \"struct PackedUserOperation\",\n components: [\n {\n name: \"sender\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"nonce\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"initCode\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"callData\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"accountGasLimits\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"preVerificationGas\",\n type: \"uint256\",\n internalType: \"uint256\"\n },\n {\n name: \"gasFees\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"paymasterAndData\",\n type: \"bytes\",\n internalType: \"bytes\"\n },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ]\n },\n { name: \"userOpHash\", type: \"bytes32\", internalType: \"bytes32\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"executorConfig\",\n inputs: [\n {\n name: \"executor\",\n type: \"address\",\n internalType: \"contract IExecutor\"\n }\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct ExecutorManager.ExecutorConfig\",\n components: [\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"initialize\",\n inputs: [\n {\n name: \"_rootValidator\",\n type: \"bytes21\",\n internalType: \"ValidationId\"\n },\n { name: \"hook\", type: \"address\", internalType: \"contract IHook\" },\n { name: \"validatorData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"hookData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"initConfig\", type: \"bytes[]\", internalType: \"bytes[]\" }\n ],\n outputs: [],\n stateMutability: \"nonpayable\"\n },\n {\n type: \"function\",\n name: \"installModule\",\n inputs: [\n { name: \"moduleType\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"module\", type: \"address\", internalType: \"address\" },\n { name: \"initData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"installValidations\",\n inputs: [\n {\n name: \"vIds\",\n type: \"bytes21[]\",\n internalType: \"ValidationId[]\"\n },\n {\n name: \"configs\",\n type: \"tuple[]\",\n internalType: \"struct ValidationManager.ValidationConfig[]\",\n components: [\n { name: \"nonce\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n }\n ]\n },\n {\n name: \"validationData\",\n type: \"bytes[]\",\n internalType: \"bytes[]\"\n },\n { name: \"hookData\", type: \"bytes[]\", internalType: \"bytes[]\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"invalidateNonce\",\n inputs: [{ name: \"nonce\", type: \"uint32\", internalType: \"uint32\" }],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"isAllowedSelector\",\n inputs: [\n { name: \"vId\", type: \"bytes21\", internalType: \"ValidationId\" },\n { name: \"selector\", type: \"bytes4\", internalType: \"bytes4\" }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"isModuleInstalled\",\n inputs: [\n { name: \"moduleType\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"module\", type: \"address\", internalType: \"address\" },\n {\n name: \"additionalContext\",\n type: \"bytes\",\n internalType: \"bytes\"\n }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"isValidSignature\",\n inputs: [\n { name: \"hash\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [{ name: \"\", type: \"bytes4\", internalType: \"bytes4\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"onERC1155BatchReceived\",\n inputs: [\n { name: \"\", type: \"address\", internalType: \"address\" },\n { name: \"\", type: \"address\", internalType: \"address\" },\n { name: \"\", type: \"uint256[]\", internalType: \"uint256[]\" },\n { name: \"\", type: \"uint256[]\", internalType: \"uint256[]\" },\n { name: \"\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [{ name: \"\", type: \"bytes4\", internalType: \"bytes4\" }],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"onERC1155Received\",\n inputs: [\n { name: \"\", type: \"address\", internalType: \"address\" },\n { name: \"\", type: \"address\", internalType: \"address\" },\n { name: \"\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [{ name: \"\", type: \"bytes4\", internalType: \"bytes4\" }],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"onERC721Received\",\n inputs: [\n { name: \"\", type: \"address\", internalType: \"address\" },\n { name: \"\", type: \"address\", internalType: \"address\" },\n { name: \"\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [{ name: \"\", type: \"bytes4\", internalType: \"bytes4\" }],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"permissionConfig\",\n inputs: [{ name: \"pId\", type: \"bytes4\", internalType: \"PermissionId\" }],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct ValidationManager.PermissionConfig\",\n components: [\n {\n name: \"permissionFlag\",\n type: \"bytes2\",\n internalType: \"PassFlag\"\n },\n {\n name: \"signer\",\n type: \"address\",\n internalType: \"contract ISigner\"\n },\n {\n name: \"policyData\",\n type: \"bytes22[]\",\n internalType: \"PolicyData[]\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"rootValidator\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bytes21\", internalType: \"ValidationId\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"selectorConfig\",\n inputs: [{ name: \"selector\", type: \"bytes4\", internalType: \"bytes4\" }],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct SelectorManager.SelectorConfig\",\n components: [\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n },\n {\n name: \"target\",\n type: \"address\",\n internalType: \"address\"\n },\n {\n name: \"callType\",\n type: \"bytes1\",\n internalType: \"CallType\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"supportsExecutionMode\",\n inputs: [{ name: \"mode\", type: \"bytes32\", internalType: \"ExecMode\" }],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"supportsModule\",\n inputs: [\n { name: \"moduleTypeId\", type: \"uint256\", internalType: \"uint256\" }\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"pure\"\n },\n {\n type: \"function\",\n name: \"uninstallModule\",\n inputs: [\n { name: \"moduleType\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"module\", type: \"address\", internalType: \"address\" },\n { name: \"deInitData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"uninstallValidation\",\n inputs: [\n { name: \"vId\", type: \"bytes21\", internalType: \"ValidationId\" },\n { name: \"deinitData\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"hookDeinitData\", type: \"bytes\", internalType: \"bytes\" }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"upgradeTo\",\n inputs: [\n {\n name: \"_newImplementation\",\n type: \"address\",\n internalType: \"address\"\n }\n ],\n outputs: [],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"validNonceFrom\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint32\", internalType: \"uint32\" }],\n stateMutability: \"view\"\n },\n {\n type: \"function\",\n name: \"validateUserOp\",\n inputs: [\n {\n name: \"userOp\",\n type: \"tuple\",\n internalType: \"struct PackedUserOperation\",\n components: [\n {\n name: \"sender\",\n type: \"address\",\n internalType: \"address\"\n },\n { name: \"nonce\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"initCode\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"callData\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"accountGasLimits\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"preVerificationGas\",\n type: \"uint256\",\n internalType: \"uint256\"\n },\n {\n name: \"gasFees\",\n type: \"bytes32\",\n internalType: \"bytes32\"\n },\n {\n name: \"paymasterAndData\",\n type: \"bytes\",\n internalType: \"bytes\"\n },\n { name: \"signature\", type: \"bytes\", internalType: \"bytes\" }\n ]\n },\n { name: \"userOpHash\", type: \"bytes32\", internalType: \"bytes32\" },\n {\n name: \"missingAccountFunds\",\n type: \"uint256\",\n internalType: \"uint256\"\n }\n ],\n outputs: [\n {\n name: \"validationData\",\n type: \"uint256\",\n internalType: \"ValidationData\"\n }\n ],\n stateMutability: \"payable\"\n },\n {\n type: \"function\",\n name: \"validationConfig\",\n inputs: [\n { name: \"vId\", type: \"bytes21\", internalType: \"ValidationId\" }\n ],\n outputs: [\n {\n name: \"\",\n type: \"tuple\",\n internalType: \"struct ValidationManager.ValidationConfig\",\n components: [\n { name: \"nonce\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"hook\",\n type: \"address\",\n internalType: \"contract IHook\"\n }\n ]\n }\n ],\n stateMutability: \"view\"\n },\n {\n type: \"event\",\n name: \"ModuleInstalled\",\n inputs: [\n {\n name: \"moduleTypeId\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n },\n {\n name: \"module\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ModuleUninstallResult\",\n inputs: [\n {\n name: \"module\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n },\n {\n name: \"result\",\n type: \"bool\",\n indexed: false,\n internalType: \"bool\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ModuleUninstalled\",\n inputs: [\n {\n name: \"moduleTypeId\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n },\n {\n name: \"module\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"NonceInvalidated\",\n inputs: [\n {\n name: \"nonce\",\n type: \"uint32\",\n indexed: false,\n internalType: \"uint32\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"PermissionInstalled\",\n inputs: [\n {\n name: \"permission\",\n type: \"bytes4\",\n indexed: false,\n internalType: \"PermissionId\"\n },\n {\n name: \"nonce\",\n type: \"uint32\",\n indexed: false,\n internalType: \"uint32\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"PermissionUninstalled\",\n inputs: [\n {\n name: \"permission\",\n type: \"bytes4\",\n indexed: false,\n internalType: \"PermissionId\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"Received\",\n inputs: [\n {\n name: \"sender\",\n type: \"address\",\n indexed: false,\n internalType: \"address\"\n },\n {\n name: \"amount\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"RootValidatorUpdated\",\n inputs: [\n {\n name: \"rootValidator\",\n type: \"bytes21\",\n indexed: false,\n internalType: \"ValidationId\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"SelectorSet\",\n inputs: [\n {\n name: \"selector\",\n type: \"bytes4\",\n indexed: false,\n internalType: \"bytes4\"\n },\n {\n name: \"vId\",\n type: \"bytes21\",\n indexed: false,\n internalType: \"ValidationId\"\n },\n {\n name: \"allowed\",\n type: \"bool\",\n indexed: false,\n internalType: \"bool\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"TryExecuteUnsuccessful\",\n inputs: [\n {\n name: \"batchExecutionindex\",\n type: \"uint256\",\n indexed: false,\n internalType: \"uint256\"\n },\n {\n name: \"result\",\n type: \"bytes\",\n indexed: false,\n internalType: \"bytes\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"Upgraded\",\n inputs: [\n {\n name: \"implementation\",\n type: \"address\",\n indexed: true,\n internalType: \"address\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ValidatorInstalled\",\n inputs: [\n {\n name: \"validator\",\n type: \"address\",\n indexed: false,\n internalType: \"contract IValidator\"\n },\n {\n name: \"nonce\",\n type: \"uint32\",\n indexed: false,\n internalType: \"uint32\"\n }\n ],\n anonymous: false\n },\n {\n type: \"event\",\n name: \"ValidatorUninstalled\",\n inputs: [\n {\n name: \"validator\",\n type: \"address\",\n indexed: false,\n internalType: \"contract IValidator\"\n }\n ],\n anonymous: false\n },\n { type: \"error\", name: \"EnableNotApproved\", inputs: [] },\n { type: \"error\", name: \"ExecutionReverted\", inputs: [] },\n {\n type: \"error\",\n name: \"InitConfigError\",\n inputs: [{ name: \"idx\", type: \"uint256\", internalType: \"uint256\" }]\n },\n { type: \"error\", name: \"InvalidCallType\", inputs: [] },\n { type: \"error\", name: \"InvalidCaller\", inputs: [] },\n { type: \"error\", name: \"InvalidExecutor\", inputs: [] },\n { type: \"error\", name: \"InvalidFallback\", inputs: [] },\n { type: \"error\", name: \"InvalidMode\", inputs: [] },\n { type: \"error\", name: \"InvalidModuleType\", inputs: [] },\n { type: \"error\", name: \"InvalidNonce\", inputs: [] },\n { type: \"error\", name: \"InvalidSelector\", inputs: [] },\n { type: \"error\", name: \"InvalidSignature\", inputs: [] },\n { type: \"error\", name: \"InvalidValidationType\", inputs: [] },\n { type: \"error\", name: \"InvalidValidator\", inputs: [] },\n { type: \"error\", name: \"NonceInvalidationError\", inputs: [] },\n { type: \"error\", name: \"NotSupportedCallType\", inputs: [] },\n { type: \"error\", name: \"OnlyExecuteUserOp\", inputs: [] },\n { type: \"error\", name: \"PermissionDataLengthMismatch\", inputs: [] },\n {\n type: \"error\",\n name: \"PermissionNotAlllowedForSignature\",\n inputs: []\n },\n { type: \"error\", name: \"PermissionNotAlllowedForUserOp\", inputs: [] },\n { type: \"error\", name: \"PolicyDataTooLarge\", inputs: [] },\n {\n type: \"error\",\n name: \"PolicyFailed\",\n inputs: [{ name: \"i\", type: \"uint256\", internalType: \"uint256\" }]\n },\n { type: \"error\", name: \"PolicySignatureOrderError\", inputs: [] },\n { type: \"error\", name: \"RootValidatorCannotBeRemoved\", inputs: [] },\n { type: \"error\", name: \"SignerPrefixNotPresent\", inputs: [] }\n] as const\n","import { parseAbi } from \"viem\"\n\nexport const SafeCreateCallAbi = parseAbi([\n \"function performCreate(uint256 value, bytes memory deploymentData) public returns (address newContract)\",\n \"function performCreate2(uint256 value, bytes memory deploymentData, bytes32 salt) public returns (address newContract)\"\n])\n","import { encodeFunctionData } from \"viem\"\nimport { SafeCreateCallAbi } from \"../../abi/SafeCreateCallAbi.js\"\n\ntype EncodeExecuteDelegateCallArgs = Parameters<\n typeof encodeFunctionData<typeof SafeCreateCallAbi, \"performCreate\">\n>[0][\"args\"]\n\nexport const encodeSafeCreateCall = (args: EncodeExecuteDelegateCallArgs) => {\n return encodeFunctionData({\n abi: SafeCreateCallAbi,\n functionName: \"performCreate\",\n args\n })\n}\n","import { encodeDeployData } from \"viem\"\nimport type { EntryPointVersion } from \"viem/account-abstraction\"\nimport { safeCreateCallAddress } from \"../../../../../constants.js\"\nimport type { KernelSmartAccountImplementation } from \"../../../createKernelAccount.js\"\nimport { encodeSafeCreateCall } from \"../../common/encodeSafeCreateCall.js\"\nimport { encodeExecuteDelegateCall } from \"../../ep0_6/encodeExecuteDelegateCall.js\"\nimport type { DelegateCallArgs } from \"../../types.js\"\n\nexport const encodeDeployCallData = <\n entryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n tx: Parameters<\n KernelSmartAccountImplementation<entryPointVersion>[\"encodeDeployCallData\"]\n >[0]\n) => {\n const deployCalldataArgs: DelegateCallArgs = {\n to: safeCreateCallAddress,\n data: encodeSafeCreateCall([0n, encodeDeployData(tx)])\n }\n return encodeExecuteDelegateCall(deployCalldataArgs)\n}\n","import {\n type Hex,\n concatHex,\n encodeFunctionData,\n getAbiItem,\n toFunctionSelector,\n toHex\n} from \"viem\"\nimport { CALL_TYPE } from \"../../../../constants.js\"\nimport { getExecMode } from \"../../../../utils.js\"\nimport { KernelV3ExecuteAbi } from \"../../abi/kernel_v_3_0_0/KernelAccountAbi.js\"\nimport type { CallArgs, DelegateCallArgs } from \"../types.js\"\n\nexport type EncodeExecuteOptions = Parameters<typeof getExecMode>[0]\n\ntype EncodeExecuteCallArgs<TOptions> =\n | (TOptions extends {\n callType: CALL_TYPE.DELEGATE_CALL\n }\n ? DelegateCallArgs\n : CallArgs)\n | { calldata: Hex }\n\nexport const encodeExecuteCall = <TOptions extends EncodeExecuteOptions>(\n args: EncodeExecuteCallArgs<TOptions>,\n options: TOptions,\n includeHooks = false\n) => {\n let calldata: Hex\n if (\"calldata\" in args) {\n calldata = args.calldata\n } else {\n calldata = concatHex([\n args.to,\n options.callType !== CALL_TYPE.DELEGATE_CALL\n ? toHex(args.value || 0n, { size: 32 })\n : \"0x\", // No value if delegate call\n args.data || \"0x\"\n ])\n }\n\n const executeUserOpSig = toFunctionSelector(\n getAbiItem({ abi: KernelV3ExecuteAbi, name: \"executeUserOp\" })\n )\n\n // The calldata using hook plugin should be as follows:\n // [0:4] - `executeUserOp` function signature\n // [4:8] - `execute` function signature\n // [8:] - `execute` function arguments\n if (includeHooks) {\n return concatHex([\n executeUserOpSig,\n encodeFunctionData({\n abi: KernelV3ExecuteAbi,\n functionName: \"execute\",\n args: [getExecMode(options), calldata]\n })\n ])\n }\n\n return encodeFunctionData({\n abi: KernelV3ExecuteAbi,\n functionName: \"execute\",\n args: [getExecMode(options), calldata]\n })\n}\n","import { encodeAbiParameters } from \"viem\"\nimport { CALL_TYPE } from \"../../../../constants.js\"\nimport type { CallArgs } from \"../types.js\"\nimport {\n type EncodeExecuteOptions,\n encodeExecuteCall\n} from \"./encodeExecuteCall.js\"\n\nexport const encodeExecuteBatchCall = (\n args: readonly CallArgs[],\n options: Omit<EncodeExecuteOptions, \"callType\">,\n includeHooks?: boolean\n) => {\n const calldata = encodeAbiParameters(\n [\n {\n name: \"executionBatch\",\n type: \"tuple[]\",\n components: [\n {\n name: \"target\",\n type: \"address\"\n },\n {\n name: \"value\",\n type: \"uint256\"\n },\n {\n name: \"callData\",\n type: \"bytes\"\n }\n ]\n }\n ],\n [\n args.map((arg) => {\n return {\n target: arg.to,\n value: arg.value || 0n,\n callData: arg.data || \"0x\"\n }\n })\n ]\n )\n return encodeExecuteCall(\n { calldata },\n {\n callType: CALL_TYPE.BATCH,\n execType: options.execType\n },\n includeHooks\n )\n}\n","import { CALL_TYPE } from \"../../../../constants.js\"\nimport type { DelegateCallArgs } from \"../types.js\"\nimport {\n type EncodeExecuteOptions,\n encodeExecuteCall\n} from \"./encodeExecuteCall.js\"\n\nexport const encodeExecuteDelegateCall = (\n args: DelegateCallArgs,\n options: Omit<EncodeExecuteOptions, \"callType\">,\n includeHooks?: boolean\n) => {\n return encodeExecuteCall(\n args,\n {\n callType: CALL_TYPE.DELEGATE_CALL,\n execType: options.execType\n },\n includeHooks\n )\n}\n","import { CALL_TYPE } from \"../../../../constants.js\"\nimport type { CallArgs } from \"../types.js\"\nimport {\n type EncodeExecuteOptions,\n encodeExecuteCall\n} from \"./encodeExecuteCall.js\"\n\nexport const encodeExecuteSingleCall = (\n args: CallArgs,\n options: Omit<EncodeExecuteOptions, \"callType\">,\n includeHooks?: boolean\n) => {\n return encodeExecuteCall(\n args,\n {\n callType: CALL_TYPE.SINGLE,\n execType: options.execType\n },\n includeHooks\n )\n}\n","import type { EntryPointVersion } from \"viem/account-abstraction\"\nimport { EXEC_TYPE } from \"../../../../../constants.js\"\nimport type { CallType } from \"../../../../../types/kernel.js\"\nimport type { KernelSmartAccountImplementation } from \"../../../createKernelAccount.js\"\nimport { encodeExecuteBatchCall } from \"../../ep0_7/encodeExecuteBatchCall.js\"\nimport { encodeExecuteDelegateCall } from \"../../ep0_7/encodeExecuteDelegateCall.js\"\nimport { encodeExecuteSingleCall } from \"../../ep0_7/encodeExecuteSingleCall.js\"\n\nexport const encodeCallData = async <\n entryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n calls: Parameters<\n KernelSmartAccountImplementation<entryPointVersion>[\"encodeCalls\"]\n >[0],\n callType?: CallType | undefined,\n includeHooks?: boolean,\n execType: EXEC_TYPE = EXEC_TYPE.DEFAULT\n) => {\n if (calls.length > 1) {\n if (callType === \"delegatecall\") {\n throw new Error(\"Cannot batch delegatecall\")\n }\n // Encode a batched call\n return encodeExecuteBatchCall(\n calls,\n {\n execType\n },\n includeHooks\n )\n }\n\n const call = calls.length === 0 ? undefined : calls[0]\n\n if (!call) {\n throw new Error(\"No calls to encode\")\n }\n\n // Default to `call`\n if (!callType || callType === \"call\") {\n return encodeExecuteSingleCall(\n call,\n {\n execType\n },\n includeHooks\n )\n }\n\n if (callType === \"delegatecall\") {\n return encodeExecuteDelegateCall(\n { to: call.to, data: call.data },\n {\n execType\n },\n includeHooks\n )\n }\n\n throw new Error(\"Invalid call type\")\n}\n","import { encodeDeployData } from \"viem\"\nimport type { EntryPointVersion } from \"viem/account-abstraction\"\nimport { EXEC_TYPE, safeCreateCallAddress } from \"../../../../../constants.js\"\nimport type { KernelSmartAccountImplementation } from \"../../../createKernelAccount.js\"\nimport { encodeSafeCreateCall } from \"../../common/encodeSafeCreateCall.js\"\nimport { encodeExecuteDelegateCall } from \"../../ep0_7/encodeExecuteDelegateCall.js\"\nimport type { DelegateCallArgs } from \"../../types.js\"\n\nexport const encodeDeployCallData = <\n entryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n tx: Parameters<\n KernelSmartAccountImplementation<entryPointVersion>[\"encodeDeployCallData\"]\n >[0]\n) => {\n const deployCalldataArgs: DelegateCallArgs = {\n to: safeCreateCallAddress,\n data: encodeSafeCreateCall([0n, encodeDeployData(tx)])\n }\n return encodeExecuteDelegateCall(deployCalldataArgs, {\n execType: EXEC_TYPE.DEFAULT\n })\n}\n","import type { Hex } from \"viem\"\nimport { encodeAbiParameters, keccak256, stringToHex } from \"viem\"\n\nexport const hashKernelMessageHashWrapper = (messageHash: Hex) => {\n return keccak256(\n encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"bytes32\" }],\n [keccak256(stringToHex(\"Kernel(bytes32 hash)\")), messageHash]\n )\n )\n}\n","import {\n type Hex,\n type TypedDataDomain,\n concatHex,\n domainSeparator,\n keccak256\n} from \"viem\"\nimport type { WithRequired } from \"../../../../types/index.js\"\nimport { KERNEL_FEATURES, hasKernelFeature } from \"../../../../utils.js\"\nimport { hashKernelMessageHashWrapper } from \"../ep0_7/hashKernelSignatureWrapper.js\"\n\nexport const eip712WrapHash = async (\n messageHash: Hex,\n domain: WithRequired<\n TypedDataDomain,\n \"name\" | \"chainId\" | \"verifyingContract\" | \"version\"\n >,\n useReplayableSignature?: boolean\n): Promise<Hex> => {\n const { name, version, chainId, verifyingContract } = domain\n\n if (!hasKernelFeature(KERNEL_FEATURES.ERC1271_SIG_WRAPPER, version)) {\n return messageHash\n }\n\n const _chainId =\n hasKernelFeature(KERNEL_FEATURES.ERC1271_REPLAYABLE, version) &&\n useReplayableSignature\n ? 0\n : chainId\n\n const _domainSeparator = domainSeparator({\n domain: {\n name,\n version,\n chainId: _chainId,\n verifyingContract\n }\n })\n\n let finalMessageHash = messageHash\n if (\n hasKernelFeature(\n KERNEL_FEATURES.ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH,\n version\n )\n ) {\n finalMessageHash = hashKernelMessageHashWrapper(finalMessageHash)\n }\n\n const digest = keccak256(\n concatHex([\"0x1901\", _domainSeparator, finalMessageHash])\n )\n return digest\n}\n","import { type Address, encodeFunctionData } from \"viem\"\nimport type { PluginMigrationData } from \"../../../../../types/kernel.js\"\nimport { KernelModuleInstallAbi } from \"../../../abi/kernel_v_3_0_0/KernelModuleAbi.js\"\nimport type { CallArgs } from \"../../types.js\"\n\nexport const getPluginInstallCallData = (\n accountAddress: Address,\n plugin: PluginMigrationData\n): CallArgs => {\n const data = encodeFunctionData({\n abi: KernelModuleInstallAbi,\n functionName: \"installModule\",\n args: [plugin.type, plugin.address, plugin.data]\n })\n return {\n to: accountAddress,\n data\n }\n}\n","import { encodeFunctionData } from \"viem\"\nimport type { SmartAccount } from \"viem/account-abstraction\"\nimport { KernelVersionToAddressesMap } from \"../../../../constants.js\"\nimport type { KERNEL_VERSION_TYPE } from \"../../../../types/kernel.js\"\nimport { validateKernelVersionWithEntryPoint } from \"../../../../utils.js\"\nimport { KernelV3AccountAbi } from \"../../abi/kernel_v_3_0_0/KernelAccountAbi.js\"\nimport type { CallArgs } from \"../types.js\"\n\nexport function getUpgradeKernelCall(\n account: SmartAccount,\n kernelVersion: KERNEL_VERSION_TYPE\n): CallArgs {\n validateKernelVersionWithEntryPoint(\n account.entryPoint.version,\n kernelVersion\n )\n const implementation =\n KernelVersionToAddressesMap[kernelVersion].accountImplementationAddress\n\n return {\n to: account.address,\n data: encodeFunctionData({\n abi: KernelV3AccountAbi,\n functionName: \"upgradeTo\",\n args: [implementation]\n }),\n value: 0n\n }\n}\n","import { BaseError } from \"viem\"\n\nexport class AccountNotFoundError extends BaseError {\n constructor({ docsPath }: { docsPath?: string | undefined } = {}) {\n super(\n [\n \"Could not find an Account to execute with this Action.\",\n \"Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client.\"\n ].join(\"\\n\"),\n {\n docsPath,\n docsSlug: \"account\",\n name: \"AccountNotFoundError\"\n }\n )\n }\n}\n\nexport class SignTransactionNotSupportedBySmartAccountError extends BaseError {\n constructor() {\n super(\"Smart account signer doesn't need to sign transactions\", {\n name: \"SignTransactionNotSupportedError\"\n })\n }\n}\n","import type { Chain, Client, Hash, Prettify, Transport } from \"viem\"\nimport {\n type SendUserOperationParameters,\n type SmartAccount,\n sendUserOperation\n} from \"viem/account-abstraction\"\nimport { getAction, parseAccount } from \"viem/utils\"\nimport { getUpgradeKernelCall } from \"../../accounts/kernel/utils/common/getUpgradeKernelCall.js\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\nimport type { KERNEL_VERSION_TYPE } from \"../../types/kernel.js\"\n\nexport type UpgradeKernelParameters<\n account extends SmartAccount | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n> = Prettify<\n Partial<SendUserOperationParameters<account, accountOverride, calls>> & {\n kernelVersion: KERNEL_VERSION_TYPE\n }\n>\n\nexport async function upgradeKernel<\n account extends SmartAccount | undefined,\n chain extends Chain | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n>(\n client: Client<Transport, chain, account>,\n args: Prettify<UpgradeKernelParameters<account, accountOverride, calls>>\n): Promise<Hash> {\n const { account: account_ = client.account, kernelVersion } = args\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/sendTransaction\"\n })\n\n const account = parseAccount(account_) as SmartAccount\n const call = getUpgradeKernelCall(account, kernelVersion)\n\n return await getAction(\n client,\n sendUserOperation,\n \"sendUserOperation\"\n )({\n ...args,\n calls: [call],\n account\n } as SendUserOperationParameters)\n}\n","import {\n type Chain,\n type Client,\n type Hash,\n type Hex,\n type Prettify,\n type Transport,\n zeroAddress\n} from \"viem\"\nimport {\n type SendUserOperationParameters,\n type SmartAccount,\n sendUserOperation\n} from \"viem/account-abstraction\"\nimport {\n concatHex,\n encodeFunctionData,\n getAction,\n pad,\n parseAccount\n} from \"viem/utils\"\nimport type { KernelSmartAccountImplementation } from \"../../accounts/index.js\"\nimport { KernelV3_1AccountAbi } from \"../../accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js\"\nimport {\n KERNEL_V3_0,\n KERNEL_V3_1,\n KernelVersionToAddressesMap,\n VALIDATOR_TYPE\n} from \"../../constants.js\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\nimport type {\n KernelValidator,\n KernelValidatorHook\n} from \"../../types/kernel.js\"\n\nexport type ChangeSudoValidatorParameters<\n account extends SmartAccount | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n> = Prettify<\n Partial<SendUserOperationParameters<account, accountOverride, calls>> & {\n sudoValidator: KernelValidator<string>\n hook?: KernelValidatorHook\n }\n>\n\nexport async function changeSudoValidator<\n account extends SmartAccount | undefined,\n chain extends Chain | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n>(\n client: Client<Transport, chain, account>,\n args: Prettify<\n ChangeSudoValidatorParameters<account, accountOverride, calls>\n >\n): Promise<Hash> {\n const { sudoValidator, hook, ...restArgs } = args\n\n const account_ = restArgs.account ?? client.account\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/sendTransaction\"\n })\n\n const account = parseAccount(\n account_\n ) as unknown as SmartAccount<KernelSmartAccountImplementation>\n\n let rootValidatorId: Hex\n if (\n [\n VALIDATOR_TYPE.PERMISSION,\n VALIDATOR_TYPE.SECONDARY,\n VALIDATOR_TYPE.EIP7702\n ].includes(VALIDATOR_TYPE[sudoValidator.validatorType])\n ) {\n rootValidatorId = concatHex([\n VALIDATOR_TYPE[sudoValidator.validatorType],\n pad(sudoValidator.getIdentifier(), {\n size: 20,\n dir: \"right\"\n })\n ])\n } else {\n throw new Error(\n `Cannot change sudo validator to type ${sudoValidator.validatorType}`\n )\n }\n\n const validatorData = await sudoValidator.getEnableData(account.address)\n\n const hookId = hook?.getIdentifier() ?? zeroAddress\n\n const hookData = (await hook?.getEnableData(account.address)) ?? \"0x\"\n\n /**\n * @dev Kernel v3.0 does not support changeRootValidator directly, so we need to use delegatecall to call changeRootValidator on Kernel v3.1 implementation contract\n */\n if (account.kernelVersion === KERNEL_V3_0) {\n return await getAction(\n client,\n sendUserOperation,\n \"sendUserOperation\"\n )({\n ...restArgs,\n callData: await account.encodeCalls(\n [\n {\n to: KernelVersionToAddressesMap[KERNEL_V3_1]\n .accountImplementationAddress,\n value: 0n,\n data: encodeFunctionData({\n abi: KernelV3_1AccountAbi,\n functionName: \"changeRootValidator\",\n args: [\n rootValidatorId,\n hookId,\n validatorData,\n hookData\n ]\n })\n }\n ],\n \"delegatecall\"\n )\n } as SendUserOperationParameters)\n }\n\n /**\n * @dev Kernel v3.1 supports changeRootValidator directly\n */\n return await getAction(\n client,\n sendUserOperation,\n \"sendUserOperation\"\n )({\n ...restArgs,\n callData: await account.encodeCalls([\n {\n to: account.address,\n value: 0n,\n data: encodeFunctionData({\n abi: KernelV3_1AccountAbi,\n functionName: \"changeRootValidator\",\n args: [rootValidatorId, hookId, validatorData, hookData]\n })\n }\n ])\n } as SendUserOperationParameters)\n}\n","import type { Chain, Client, Hash, Prettify, Transport } from \"viem\"\nimport {\n type SendUserOperationParameters,\n type SmartAccount,\n sendUserOperation\n} from \"viem/account-abstraction\"\nimport { encodeFunctionData, getAction, parseAccount } from \"viem/utils\"\nimport { KernelV3AccountAbi } from \"../../accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\n\nexport type InvalidateNonceParameters<\n account extends SmartAccount | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n> = Prettify<\n Partial<SendUserOperationParameters<account, accountOverride, calls>> & {\n nonceToSet: number\n }\n>\n\nexport async function invalidateNonce<\n account extends SmartAccount | undefined,\n chain extends Chain | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n>(\n client: Client<Transport, chain, account>,\n args: Prettify<InvalidateNonceParameters<account, accountOverride, calls>>\n): Promise<Hash> {\n const { account: account_ = client.account, nonceToSet } = args\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/sendTransaction\"\n })\n\n const account = parseAccount(account_) as SmartAccount\n\n return await getAction(\n client,\n sendUserOperation,\n \"sendUserOperation\"\n )({\n ...args,\n calls: [\n {\n to: account.address,\n data: encodeFunctionData({\n abi: KernelV3AccountAbi,\n functionName: \"invalidateNonce\",\n args: [nonceToSet]\n }),\n value: 0n\n }\n ],\n account\n } as SendUserOperationParameters)\n}\n","import type { Chain, Client, Hash, Hex, Transport } from \"viem\"\nimport {\n type SendUserOperationParameters,\n type SmartAccount,\n sendUserOperation\n} from \"viem/account-abstraction\"\nimport {\n concatHex,\n encodeFunctionData,\n getAction,\n pad,\n parseAccount\n} from \"viem/utils\"\nimport { KernelV3AccountAbi } from \"../../accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js\"\nimport { encodeCallData } from \"../../accounts/kernel/utils/account/ep0_7/encodeCallData.js\"\nimport { VALIDATOR_TYPE } from \"../../constants.js\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\nimport type {\n KernelValidator,\n KernelValidatorHook\n} from \"../../types/kernel.js\"\n\nexport type UninstallPluginParameters<\n account extends SmartAccount | undefined = SmartAccount | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n> = Partial<SendUserOperationParameters<account, accountOverride, calls>> & {\n plugin: KernelValidator<string>\n hook?: KernelValidatorHook\n}\n\nexport async function uninstallPlugin<\n account extends SmartAccount | undefined,\n chain extends Chain | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n>(\n client: Client<Transport, chain, account>,\n args: UninstallPluginParameters<account, accountOverride, calls>\n): Promise<Hash> {\n const {\n account: account_ = client.account,\n plugin,\n hook,\n ...restArgs\n } = args\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/sendTransaction\"\n })\n\n const account = parseAccount(account_) as SmartAccount\n\n let validatorId: Hex\n if (\n [\n VALIDATOR_TYPE.PERMISSION,\n VALIDATOR_TYPE.SECONDARY,\n VALIDATOR_TYPE.EIP7702\n ].includes(VALIDATOR_TYPE[plugin.validatorType])\n ) {\n validatorId = concatHex([\n VALIDATOR_TYPE[plugin.validatorType],\n pad(plugin.getIdentifier(), {\n size: 20,\n dir: \"right\"\n })\n ])\n } else {\n throw new Error(`Cannot uninstall ${plugin.validatorType} plugin`)\n }\n\n const validatorData = await plugin.getEnableData(account.address)\n\n const hookData = (await hook?.getEnableData(account.address)) ?? \"0x\"\n return await getAction(\n client,\n sendUserOperation,\n \"sendUserOperation\"\n )({\n ...restArgs,\n callData: await encodeCallData([\n {\n to: account.address,\n data: encodeFunctionData({\n abi: KernelV3AccountAbi,\n functionName: \"uninstallValidation\",\n args: [validatorId, validatorData, hookData]\n }),\n value: 0n\n }\n ]),\n account\n } as SendUserOperationParameters)\n}\n","import type { Chain, Client, Transport } from \"viem\"\nimport {\n type PrepareUserOperationParameters,\n type PrepareUserOperationReturnType,\n type SmartAccount,\n type UserOperation,\n prepareUserOperation\n} from \"viem/account-abstraction\"\nimport { getAction, parseAccount } from \"viem/utils\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\n\nexport type SignUserOperationParameters<\n account extends SmartAccount | undefined = SmartAccount | undefined,\n accountOverride extends SmartAccount | undefined = SmartAccount | undefined,\n calls extends readonly unknown[] = readonly unknown[]\n> = PrepareUserOperationParameters<account, accountOverride, calls>\n\nexport type SignUserOperationReturnType = PrepareUserOperationReturnType\n\nexport async function signUserOperation<\n account extends SmartAccount | undefined = SmartAccount | undefined,\n chain extends Chain | undefined = Chain | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n>(\n client: Client<Transport, chain, account>,\n args: SignUserOperationParameters<account, accountOverride, calls>\n): Promise<SignUserOperationReturnType> {\n const { account: account_ = client.account } = args\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/sendTransaction\"\n })\n\n const account = parseAccount(account_) as SmartAccount\n\n const userOperation = await getAction(\n client,\n prepareUserOperation,\n \"prepareUserOperation\"\n )({ ...args, account } as PrepareUserOperationParameters)\n\n userOperation.signature = await account.signUserOperation(\n userOperation as UserOperation\n )\n\n return userOperation\n}\n","import type { Chain, Client, Transport } from \"viem\"\nimport type { SmartAccount } from \"viem/account-abstraction\"\nimport { readContract } from \"viem/actions\"\nimport { getAction, parseAccount } from \"viem/utils\"\nimport { KernelV3AccountAbi } from \"../../accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\n\nexport async function getKernelV3ModuleCurrentNonce<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined\n>(client: Client<TTransport, TChain, TAccount>): Promise<number> {\n const account_ = client.account\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/sendTransaction\"\n })\n\n const account = parseAccount(account_) as SmartAccount\n\n try {\n const nonce = await getAction(\n client,\n readContract,\n \"readContract\"\n )({\n abi: KernelV3AccountAbi,\n address: account.address,\n functionName: \"currentNonce\",\n args: []\n })\n return nonce\n } catch (error) {\n return 1\n }\n}\n","import type { Account, Chain, Client, Transport } from \"viem\"\nimport type { Prettify } from \"viem/chains\"\nimport type { ZeroDevAccountClientRpcSchema } from \"../../types/kernel.js\"\n\nexport type GetUserOperationGasPriceReturnType = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n}\n\nexport const getUserOperationGasPrice = async <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined\n>(\n client: Client<TTransport, TChain, TAccount, ZeroDevAccountClientRpcSchema>\n): Promise<Prettify<GetUserOperationGasPriceReturnType>> => {\n const gasPrice = await client.request({\n method: \"zd_getUserOperationGasPrice\",\n params: []\n })\n\n return {\n maxFeePerGas: BigInt(gasPrice.standard.maxFeePerGas),\n maxPriorityFeePerGas: BigInt(gasPrice.standard.maxPriorityFeePerGas)\n }\n}\n","// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/sendTransaction.ts\n\nimport type {\n Chain,\n Client,\n Hash,\n SendTransactionParameters,\n Transport\n} from \"viem\"\nimport {\n type SendUserOperationParameters,\n type SmartAccount,\n sendUserOperation,\n waitForUserOperationReceipt\n} from \"viem/account-abstraction\"\nimport { getAction, parseAccount } from \"viem/utils\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\n\n/**\n * Creates, signs, and sends a new transaction to the network.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n *\n * - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html\n * - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)\n * - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)\n *\n * @param client - Client to use\n * @param parameters - {@link SendTransactionParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash.\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { sendTransaction } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const hash = await sendTransaction(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { sendTransaction } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const hash = await sendTransaction(client, {\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n */\nexport async function sendTransaction<\n account extends SmartAccount | undefined,\n chain extends Chain | undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n calls extends readonly unknown[] = readonly unknown[]\n>(\n client: Client<Transport, chain, account>,\n args:\n | SendTransactionParameters<chain, account, chainOverride>\n | SendUserOperationParameters<account, accountOverride, calls>\n): Promise<Hash> {\n let userOpHash: Hash\n\n if (\"to\" in args) {\n const {\n account: account_ = client.account,\n data,\n maxFeePerGas,\n maxPriorityFeePerGas,\n to,\n value,\n nonce\n } = args\n\n if (!account_) {\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/sendTransaction\"\n })\n }\n\n const account = parseAccount(account_) as SmartAccount\n\n if (!to) throw new Error(\"Missing to address\")\n\n userOpHash = await getAction(\n client,\n sendUserOperation,\n \"sendUserOperation\"\n )({\n calls: [\n {\n to,\n value: value || BigInt(0),\n data: data || \"0x\"\n }\n ],\n account,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce: nonce ? BigInt(nonce) : undefined\n })\n } else {\n userOpHash = await getAction(\n client,\n sendUserOperation,\n \"sendUserOperation\"\n )({ ...args } as SendUserOperationParameters<account, accountOverride>)\n }\n\n const userOperationReceipt = await getAction(\n client,\n waitForUserOperationReceipt,\n \"waitForUserOperationReceipt\"\n )({\n hash: userOpHash\n })\n\n return userOperationReceipt?.receipt.transactionHash\n}\n","// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/signMessage.ts\n\nimport type {\n Chain,\n Client,\n SignMessageParameters,\n SignMessageReturnType,\n Transport\n} from \"viem\"\nimport type { SmartAccount } from \"viem/account-abstraction\"\nimport { parseAccount } from \"viem/utils\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\n\n/**\n * Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signMessage.html\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data.html#personal-sign)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * With the calculated signature, you can:\n * - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,\n * - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.\n *\n * @param client - Client to use\n * @param parameters - {@link SignMessageParameters}\n * @returns The signed message. {@link SignMessageReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { signMessage } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signMessage(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * message: 'hello world',\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, custom } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { signMessage } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signMessage(client, {\n * message: 'hello world',\n * })\n */\nexport async function signMessage<TAccount extends SmartAccount | undefined>(\n client: Client<Transport, Chain | undefined, TAccount>,\n {\n account: account_ = client.account,\n message\n }: SignMessageParameters<TAccount>\n): Promise<SignMessageReturnType> {\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/signMessage\"\n })\n\n const account = parseAccount(account_) as SmartAccount\n\n return account.signMessage({ message })\n}\n","// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/signTypedData.ts\n\nimport {\n type Chain,\n type Client,\n type SignTypedDataParameters,\n type SignTypedDataReturnType,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n type TypedDataDomain,\n getTypesForEIP712Domain,\n validateTypedData\n} from \"viem\"\nimport type { SmartAccount } from \"viem/account-abstraction\"\nimport { parseAccount } from \"viem/utils\"\nimport { AccountNotFoundError } from \"../../errors/index.js\"\n\n/**\n * Signs typed data and calculates an Ethereum-specific signature in [https://eips.ethereum.org/EIPS/eip-712](https://eips.ethereum.org/EIPS/eip-712): `sign(keccak256(\"\\x19\\x01\" ‖ domainSeparator ‖ hashStruct(message)))`\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data.html#signtypeddata-v4)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * @param client - Client to use\n * @param parameters - {@link SignTypedDataParameters}\n * @returns The signed data. {@link SignTypedDataReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { signTypedData } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signTypedData(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { signTypedData } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const signature = await signTypedData(client, {\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n */\nexport async function signTypedData<\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined\n>(\n client: Client<Transport, Chain | undefined, TAccount>,\n {\n account: account_ = client.account,\n domain,\n message,\n primaryType,\n types: types_\n }: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n): Promise<SignTypedDataReturnType> {\n if (!account_) {\n throw new AccountNotFoundError({\n docsPath: \"/docs/actions/wallet/signMessage\"\n })\n }\n\n const account = parseAccount(account_) as SmartAccount\n\n const types = {\n EIP712Domain: getTypesForEIP712Domain({ domain } as {\n domain: TypedDataDomain\n }),\n ...(types_ as TTypedData)\n }\n\n validateTypedData({\n domain,\n message,\n primaryType,\n types\n } as TypedDataDefinition)\n\n return account.signTypedData({\n domain,\n primaryType,\n types,\n message\n } as TypedDataDefinition)\n}\n","// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/writeContract.ts\n\nimport {\n type Abi,\n type Chain,\n type Client,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type EncodeFunctionDataParameters,\n type Hash,\n type SendTransactionParameters,\n type Transport,\n type WriteContractParameters,\n encodeFunctionData\n} from \"viem\"\nimport type { SmartAccount } from \"viem/account-abstraction\"\nimport { getAction } from \"viem/utils\"\nimport { sendTransaction } from \"./sendTransaction.js\"\n\nexport async function writeContract<\n TChain extends Chain | undefined,\n TAccount extends SmartAccount | undefined,\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<\n TAbi,\n \"nonpayable\" | \"payable\"\n > = ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n TArgs extends ContractFunctionArgs<\n TAbi,\n \"nonpayable\" | \"payable\",\n TFunctionName\n > = ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n TChainOverride extends Chain | undefined = undefined\n>(\n client: Client<Transport, TChain, TAccount>,\n {\n abi,\n address,\n args,\n dataSuffix,\n functionName,\n ...request\n }: WriteContractParameters<\n TAbi,\n TFunctionName,\n TArgs,\n TChain,\n TAccount,\n TChainOverride\n >\n): Promise<Hash> {\n const data = encodeFunctionData<TAbi, TFunctionName>({\n abi,\n args,\n functionName\n } as EncodeFunctionDataParameters<TAbi, TFunctionName>)\n\n const hash = await getAction(\n client,\n sendTransaction<TAccount, undefined, undefined>,\n \"sendTransaction\"\n )({\n data: `${data}${dataSuffix ? dataSuffix.replace(\"0x\", \"\") : \"\"}`,\n to: address,\n ...request\n } as unknown as SendTransactionParameters<\n Chain | undefined,\n TAccount,\n undefined\n >)\n return hash\n}\n","import type {\n Abi,\n Chain,\n Client,\n ContractFunctionArgs,\n ContractFunctionName,\n Hash,\n Prettify,\n Transport,\n TypedData,\n WriteContractParameters\n} from \"viem\"\nimport type { EntryPointVersion, SmartAccount } from \"viem/account-abstraction\"\nimport { getKernelV3ModuleCurrentNonce } from \"../../actions/account-client/getKernelV3ModuleCurrentNonce.js\"\nimport {\n type GetUserOperationGasPriceReturnType,\n getUserOperationGasPrice\n} from \"../../actions/account-client/getUserOperationGasPrice.js\"\nimport {\n type InvalidateNonceParameters,\n invalidateNonce\n} from \"../../actions/account-client/invalidateNonce.js\"\nimport { sendTransaction } from \"../../actions/account-client/sendTransaction.js\"\nimport { signMessage } from \"../../actions/account-client/signMessage.js\"\nimport { signTypedData } from \"../../actions/account-client/signTypedData.js\"\nimport {\n type UpgradeKernelParameters,\n upgradeKernel\n} from \"../../actions/account-client/upgradeKernel.js\"\nimport { writeContract } from \"../../actions/account-client/writeContract.js\"\nimport type {\n ChangeSudoValidatorParameters,\n SignUserOperationReturnType,\n UninstallPluginParameters\n} from \"../../actions/index.js\"\nimport {\n changeSudoValidator,\n signUserOperation,\n uninstallPlugin\n} from \"../../actions/index.js\"\nimport {\n type EstimateGasInERC20Parameters,\n type EstimateGasInERC20ReturnType,\n estimateGasInERC20\n} from \"../../actions/paymaster/estimateGasInERC20.js\"\nimport {\n type SponsorUserOperationParameters,\n type SponsorUserOperationReturnType,\n sponsorUserOperation\n} from \"../../actions/paymaster/sponsorUserOperation.js\"\nimport type { ZeroDevPaymasterClient } from \"../paymasterClient.js\"\n\nexport type ZeroDevPaymasterClientActions = {\n /**\n * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.\n */\n sponsorUserOperation: (\n args: SponsorUserOperationParameters\n ) => Promise<SponsorUserOperationReturnType>\n estimateGasInERC20: (\n args: EstimateGasInERC20Parameters\n ) => Promise<EstimateGasInERC20ReturnType>\n}\n\nexport const zerodevPaymasterActions =\n <entryPointVersion extends EntryPointVersion>() =>\n (client: Client): ZeroDevPaymasterClientActions => ({\n sponsorUserOperation: async (args: SponsorUserOperationParameters) =>\n sponsorUserOperation(\n client as ZeroDevPaymasterClient<entryPointVersion>,\n {\n ...args\n }\n ),\n estimateGasInERC20: async (args: EstimateGasInERC20Parameters) =>\n estimateGasInERC20(\n client as ZeroDevPaymasterClient<entryPointVersion>,\n args\n )\n })\n\nexport type KernelAccountClientActions<\n TChain extends Chain | undefined = Chain | undefined,\n TSmartAccount extends SmartAccount | undefined = SmartAccount | undefined\n> = {\n /**\n * Signs a user operation with the given transport, chain, and smart account.\n *\n * @param args - Parameters for the signUserOperation function\n * @returns A promise that resolves to the result of the signUserOperation function\n */\n signUserOperation: <\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n >(\n args: Parameters<\n typeof signUserOperation<\n TSmartAccount,\n TChain,\n accountOverride,\n calls\n >\n >[1]\n ) => Promise<SignUserOperationReturnType>\n /**\n * Returns the live gas prices that you can use to send a user operation.\n *\n * @returns maxFeePerGas & maxPriorityFeePerGas {@link GetUserOperationGasPriceReturnType}\n */\n getUserOperationGasPrice: () => Promise<\n Prettify<GetUserOperationGasPriceReturnType>\n >\n /**\n * Creates, signs, and sends an uninstall kernel plugin transaction to the network.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n *\n *\n * @param args - {@link UninstallPermissionParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}\n */\n uninstallPlugin: <\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n >(\n args: UninstallPluginParameters<TSmartAccount, accountOverride, calls>\n ) => Promise<Hash>\n /**\n * Creates, signs, and sends a user operation to change sudo validator to the network.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n */\n changeSudoValidator: <\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n >(\n args: ChangeSudoValidatorParameters<\n TSmartAccount,\n accountOverride,\n calls\n >\n ) => Promise<Hash>\n\n /**\n * Creates, signs, and sends a kernel v3 module nonce invalidation transaction to the network.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n *\n *\n * @param args - {@link InvalidateNonceParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}\n */\n invalidateNonce: <\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n >(\n args: InvalidateNonceParameters<TSmartAccount, accountOverride, calls>\n ) => Promise<Hash>\n /**\n * Creates, signs, and sends a transaction to fetch KernelV3 module nonce to the network.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n *\n *\n * @returns nonce\n */\n getKernelV3ModuleCurrentNonce: () => Promise<number>\n /**\n * Creates, signs, and sends a transaction to upgrade the kernel to the network.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n *\n * @param args - {@link UpgradeKernelParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}\n */\n upgradeKernel: <\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n >(\n args: UpgradeKernelParameters<TSmartAccount, accountOverride, calls>\n ) => Promise<Hash>\n\n /**\n * Creates, signs, and sends a new transaction to the network.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n *\n * - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html\n * - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)\n * - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)\n *\n * @param args - {@link SendTransactionParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const hash = await client.sendTransaction({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const hash = await client.sendTransaction({\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n */\n sendTransaction: <\n TChainOverride extends Chain | undefined = undefined,\n accountOverride extends SmartAccount | undefined = undefined,\n calls extends readonly unknown[] = readonly unknown[]\n >(\n args: Parameters<\n typeof sendTransaction<\n TSmartAccount,\n TChain,\n accountOverride,\n TChainOverride,\n calls\n >\n >[1]\n ) => Promise<Hash>\n /**\n * Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signMessage.html\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data.html#personal-sign)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * With the calculated signature, you can:\n * - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,\n * - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.\n *\n * @param args - {@link SignMessageParameters}\n * @returns The signed message. {@link SignMessageReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await client.signMessage({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * message: 'hello world',\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const signature = await client.signMessage({\n * message: 'hello world',\n * })\n */\n signMessage: (\n args: Parameters<typeof signMessage<TSmartAccount>>[1]\n ) => ReturnType<typeof signMessage<TSmartAccount>>\n /**\n * Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data.html#signtypeddata-v4)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * @param client - Client to use\n * @param args - {@link SignTypedDataParameters}\n * @returns The signed data. {@link SignTypedDataReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await client.signTypedData({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const signature = await client.signTypedData({\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n */\n signTypedData: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string\n >(\n args: Parameters<\n typeof signTypedData<TTypedData, TPrimaryType, TSmartAccount>\n >[1]\n ) => ReturnType<\n typeof signTypedData<TTypedData, TPrimaryType, TSmartAccount>\n >\n /**\n * Executes a write function on a contract.\n * This function also allows you to sponsor this transaction if sender is a smartAccount\n *\n * - Docs: https://viem.sh/docs/contract/writeContract.html\n * - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts\n *\n * A \"write\" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms.html) is needed to be broadcast in order to change the state.\n *\n * Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet.html) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).\n *\n * __Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract.html#usage) before you execute it.__\n *\n * @param args - {@link WriteContractParameters}\n * @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms.html#hash). {@link WriteContractReturnType}\n *\n * @example\n * import { createWalletClient, custom, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const hash = await client.writeContract({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),\n * functionName: 'mint',\n * args: [69420],\n * })\n *\n * @example\n * // With Validation\n * import { createWalletClient, custom, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const { request } = await client.simulateContract({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),\n * functionName: 'mint',\n * args: [69420],\n * }\n * const hash = await client.writeContract(request)\n */\n writeContract: <\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<\n TAbi,\n \"nonpayable\" | \"payable\"\n > = ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n TArgs extends ContractFunctionArgs<\n TAbi,\n \"nonpayable\" | \"payable\",\n TFunctionName\n > = ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n TChainOverride extends Chain | undefined = undefined\n >(\n args: WriteContractParameters<\n TAbi,\n TFunctionName,\n TArgs,\n TChain,\n TSmartAccount,\n TChainOverride\n >\n ) => ReturnType<\n typeof writeContract<\n TChain,\n TSmartAccount,\n TAbi,\n TFunctionName,\n TArgs,\n TChainOverride\n >\n >\n}\n\nexport function kernelAccountClientActions() {\n return <\n TChain extends Chain | undefined = Chain | undefined,\n TSmartAccount extends SmartAccount | undefined =\n | SmartAccount\n | undefined\n >(\n client: Client<Transport, TChain, TSmartAccount>\n ): KernelAccountClientActions<TChain, TSmartAccount> => ({\n signUserOperation: (args) => signUserOperation(client, args),\n getUserOperationGasPrice: async () => getUserOperationGasPrice(client),\n uninstallPlugin: async (args) => uninstallPlugin(client, args),\n changeSudoValidator: async (args) => changeSudoValidator(client, args),\n invalidateNonce: async (args) => invalidateNonce(client, args),\n getKernelV3ModuleCurrentNonce: async () =>\n getKernelV3ModuleCurrentNonce(client),\n upgradeKernel: async (args) => upgradeKernel(client, args),\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n sendTransaction: (args) => sendTransaction(client, args as any),\n signMessage: (args) => signMessage(client, args),\n signTypedData: (args) => signTypedData(client, args),\n writeContract: (args) => writeContract(client, args)\n })\n}\n","import {\n type BundlerRpcSchema,\n type Chain,\n type Client,\n type ClientConfig,\n type EstimateFeesPerGasReturnType,\n type Prettify,\n type RpcSchema,\n type Transport,\n createClient\n} from \"viem\"\nimport {\n type BundlerActions,\n type BundlerClientConfig,\n type DeriveEntryPointVersion,\n type DeriveSmartAccount,\n type PaymasterActions,\n type PrepareUserOperationParameters,\n type PrepareUserOperationRequest,\n type PrepareUserOperationReturnType,\n type SmartAccount,\n type UserOperationRequest,\n bundlerActions,\n prepareUserOperation,\n type prepareUserOperation as viemPrepareUserOperation\n} from \"viem/account-abstraction\"\nimport type { KernelSmartAccountImplementation } from \"../accounts/index.js\"\nimport { getUserOperationGasPrice } from \"../actions/index.js\"\nimport { FAST_POLLING_CHAIN_IDS } from \"../constants.js\"\nimport {\n type KernelAccountClientActions,\n kernelAccountClientActions\n} from \"./decorators/kernel.js\"\n\nexport type KernelAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartAccount | undefined = SmartAccount | undefined,\n client extends Client | undefined = Client | undefined,\n rpcSchema extends RpcSchema | undefined = undefined\n> = Prettify<\n Client<\n transport,\n chain extends Chain\n ? chain\n : // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n client extends Client<any, infer chain>\n ? chain\n : undefined,\n account,\n rpcSchema extends RpcSchema\n ? [...BundlerRpcSchema, ...rpcSchema]\n : BundlerRpcSchema,\n BundlerActions<account> & KernelAccountClientActions<chain, account>\n >\n> & {\n client: client\n paymaster: BundlerClientConfig[\"paymaster\"] | undefined\n paymasterContext: BundlerClientConfig[\"paymasterContext\"] | undefined\n userOperation: BundlerClientConfig[\"userOperation\"] | undefined\n}\n\nexport type SmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartAccount | undefined = SmartAccount | undefined,\n client extends Client | undefined = Client | undefined,\n rpcSchema extends RpcSchema | undefined = undefined\n> = Prettify<\n Pick<\n ClientConfig<transport, chain, account, rpcSchema>,\n | \"account\"\n | \"cacheTime\"\n | \"chain\"\n | \"key\"\n | \"name\"\n | \"pollingInterval\"\n | \"rpcSchema\"\n >\n> & {\n bundlerTransport: transport\n /** Client that points to an Execution RPC URL. */\n client?: client | Client | undefined\n /** Paymaster configuration. */\n paymaster?:\n | true\n | {\n /** Retrieves paymaster-related User Operation properties to be used for sending the User Operation. */\n getPaymasterData?:\n | PaymasterActions[\"getPaymasterData\"]\n | undefined\n /** Retrieves paymaster-related User Operation properties to be used for gas estimation. */\n getPaymasterStubData?:\n | PaymasterActions[\"getPaymasterStubData\"]\n | undefined\n }\n | undefined\n /** Paymaster context to pass to `getPaymasterData` and `getPaymasterStubData` calls. */\n paymasterContext?: unknown\n /** User Operation configuration. */\n userOperation?:\n | {\n /** Prepares fee properties for the User Operation request. */\n estimateFeesPerGas?:\n | ((parameters: {\n account: account | SmartAccount\n bundlerClient: Client\n userOperation: UserOperationRequest\n }) => Promise<EstimateFeesPerGasReturnType<\"eip1559\">>)\n | undefined\n /** Prepare User Operation configuration. */\n prepareUserOperation?: typeof viemPrepareUserOperation | undefined\n }\n | undefined\n}\n\nexport function createKernelAccountClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n account extends SmartAccount | undefined = undefined,\n client extends Client | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = undefined\n>(\n parameters: SmartAccountClientConfig<\n transport,\n chain,\n account,\n client,\n rpcSchema\n >\n): KernelAccountClient<transport, chain, account, client, rpcSchema>\n\nexport function createKernelAccountClient(\n parameters: SmartAccountClientConfig\n): KernelAccountClient {\n const {\n client: client_,\n key = \"Account\",\n name = \"Kernel Account Client\",\n paymaster,\n paymasterContext,\n bundlerTransport,\n userOperation\n } = parameters\n\n const chain = parameters.chain ?? client_?.chain\n const defaultPollingInterval = FAST_POLLING_CHAIN_IDS.includes(\n chain?.id as number\n )\n ? 200\n : 1000\n\n const client = Object.assign(\n createClient({\n ...parameters,\n chain,\n transport: bundlerTransport,\n key,\n name,\n type: \"kernelAccountClient\",\n pollingInterval:\n parameters.pollingInterval ?? defaultPollingInterval\n }),\n { client: client_, paymaster, paymasterContext, userOperation }\n )\n\n if (parameters.userOperation?.prepareUserOperation) {\n const customPrepareUserOp =\n parameters.userOperation.prepareUserOperation\n\n return client\n .extend(bundlerActions)\n .extend((_client) => ({\n prepareUserOperation: <\n _account extends SmartAccount | undefined,\n const _calls extends readonly unknown[],\n _request extends PrepareUserOperationRequest<\n _account,\n _accountOverride,\n _calls,\n DeriveSmartAccount<_account, _accountOverride>,\n DeriveEntryPointVersion<\n DeriveSmartAccount<_account, _accountOverride>\n >\n >,\n _accountOverride extends\n | SmartAccount\n | undefined = undefined\n >(\n args: PrepareUserOperationParameters<\n _account,\n _accountOverride,\n _calls,\n _request\n >\n ): Promise<\n PrepareUserOperationReturnType<\n _account,\n _accountOverride,\n _calls,\n _request\n >\n > => {\n return customPrepareUserOp(_client, args) as Promise<\n PrepareUserOperationReturnType<\n _account,\n _accountOverride,\n _calls,\n _request\n >\n >\n }\n }))\n .extend(bundlerActions)\n .extend((_client) => ({\n prepareUserOperation: <\n _account extends SmartAccount | undefined,\n const _calls extends readonly unknown[],\n _request extends PrepareUserOperationRequest<\n _account,\n _accountOverride,\n _calls,\n DeriveSmartAccount<_account, _accountOverride>,\n DeriveEntryPointVersion<\n DeriveSmartAccount<_account, _accountOverride>\n >\n >,\n _accountOverride extends\n | SmartAccount\n | undefined = undefined\n >(\n args: PrepareUserOperationParameters<\n _account,\n _accountOverride,\n _calls,\n _request\n >\n ): Promise<\n PrepareUserOperationReturnType<\n _account,\n _accountOverride,\n _calls,\n _request\n >\n > => {\n return customPrepareUserOp(_client, args) as Promise<\n PrepareUserOperationReturnType<\n _account,\n _accountOverride,\n _calls,\n _request\n >\n >\n }\n }))\n .extend(kernelAccountClientActions()) as KernelAccountClient\n }\n\n if (!client.userOperation?.estimateFeesPerGas) {\n client.userOperation = {\n ...client.userOperation,\n estimateFeesPerGas: async ({ bundlerClient }) => {\n return await getUserOperationGasPrice(bundlerClient)\n }\n }\n }\n\n return client\n .extend(bundlerActions)\n .extend((_client) => ({\n prepareUserOperation: async (\n args: PrepareUserOperationParameters\n ) => {\n let _args = args\n if (_client.account?.authorization) {\n const authorization =\n args.authorization ||\n (await (\n _client.account as SmartAccount<KernelSmartAccountImplementation>\n )?.eip7702Authorization?.())\n _args = {\n ...args,\n authorization\n }\n }\n return await prepareUserOperation(_client, _args)\n }\n }))\n .extend(bundlerActions)\n .extend((_client) => ({\n prepareUserOperation: async (\n args: PrepareUserOperationParameters\n ) => {\n let _args = args\n if (_client.account?.authorization) {\n const authorization =\n args.authorization ||\n (await (\n _client.account as SmartAccount<KernelSmartAccountImplementation>\n )?.eip7702Authorization?.())\n _args = {\n ...args,\n authorization\n }\n }\n return await prepareUserOperation(_client, _args)\n }\n }))\n .extend(kernelAccountClientActions()) as KernelAccountClient\n}\n","/**\n * Bridge `EvmSigner` → a viem `LocalAccount` that ZeroDev's Kernel\n * (under EIP-7702) accepts as the EOA being delegated.\n *\n * Kernel calls:\n * - `signMessage({ message: { raw } })` to sign the UserOp hash.\n * - `signTypedData({ ... })` to sign the Permit2 witness (and any\n * other EIP-712 message routed through the account).\n * - `signAuthorization({...})` to sign the 7702 auth tuple on the\n * first UserOp from this EOA — installs the delegation on-chain.\n *\n * `EvmSigner.signTypedData` is required on all callers. `signMessage`\n * and `signAuthorization` are optional on `EvmSigner` — this adapter\n * throws a clear error if the CCTP path is reached with an\n * `EvmSigner` that lacks them.\n *\n * `signTransaction` is provided as a stub: Kernel never routes txs\n * through the owner account (the bundler submits UserOps), so calling\n * it would be a programmer error.\n */\n\nimport type { Hex, LocalAccount } from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport type { EvmSigner } from \"../evm/wallet.js\";\n\n/**\n * Wrap an `EvmSigner` in a viem `LocalAccount` so ZeroDev Kernel can\n * use it as the EIP-7702 delegated account (`eip7702Account`).\n */\nexport function evmSignerToKernelOwner(signer: EvmSigner): LocalAccount {\n return toAccount({\n address: signer.address as Hex,\n async signMessage({ message }) {\n if (!signer.signMessage) {\n throw new Error(\n \"CCTP-inbound flow requires `EvmSigner.signMessage`. Extend your signer — e.g. `(m) => walletClient.signMessage({ account, message: m })`.\",\n );\n }\n // viem's `message` is `SignableMessage`: either a string or\n // `{ raw: Hex }`. Kernel always passes `{ raw }` — but be\n // defensive about the string shape too.\n const raw =\n typeof message === \"string\"\n ? (new TextEncoder().encode(message) as unknown as string)\n : (message.raw as string);\n return (await signer.signMessage({ raw })) as Hex;\n },\n async signTypedData(typedData) {\n // Narrow viem's broad SignTypedDataParameters to the SDK's\n // internal EIP712TypedData shape — at runtime they're\n // structurally identical, the difference is just generic-heavy\n // typing on viem's side.\n return (await signer.signTypedData(\n typedData as unknown as Parameters<EvmSigner[\"signTypedData\"]>[0],\n )) as Hex;\n },\n async signAuthorization(authorization) {\n if (!signer.signAuthorization) {\n throw new Error(\n \"CCTP-inbound flow under EIP-7702 requires `EvmSigner.signAuthorization`. Extend your signer — e.g. `(a) => walletClient.signAuthorization({ account, ...a })`.\",\n );\n }\n // viem's `AuthorizationRequest` is a `OneOf` — the delegation\n // target arrives as EITHER `address` (the canonical field, which\n // Kernel/viem actually use) OR the `contractAddress` alias.\n // Reading only `contractAddress` yields `undefined` on the\n // `address` branch, which then blows up inside viem's\n // `hashAuthorization` (\"Cannot read properties of undefined\").\n const contractAddress = (authorization.address ??\n authorization.contractAddress) as string;\n const result = await signer.signAuthorization({\n chainId: authorization.chainId as number,\n contractAddress,\n nonce: authorization.nonce as number,\n });\n // viem accepts either `v` or `yParity`; the field they actually\n // read is `yParity`. Pass both for compatibility.\n return {\n r: result.r as Hex,\n s: result.s as Hex,\n v: result.v !== undefined ? BigInt(result.v) : undefined,\n yParity: result.yParity,\n chainId: result.chainId,\n address: result.address as Hex,\n nonce: result.nonce,\n };\n },\n async signTransaction() {\n throw new Error(\n \"signTransaction is not supported on the Kernel owner — UserOps are submitted via the bundler, not from the owner EOA directly.\",\n );\n },\n });\n}\n","/**\n * Build a ZeroDev Kernel smart-account client on Arbitrum from a viem\n * `Account` supplied by the consumer (Privy, wagmi, raw private key —\n * any viem-compatible signer).\n *\n * Under EIP-7702 the consumer's EOA *is* the smart account — its code\n * is delegated to a Kernel implementation on the first UserOp. So the\n * smart-account address and the EOA address are the same, which makes\n * the EOA address usable directly as both:\n * - `mintRecipient` on the source-chain CCTP burn (USDC arrives here)\n * - `destinationCaller` (bytes32-padded) — only this account can\n * call `receiveMessage` on Arbitrum\n *\n * No CREATE2, no factory, no counterfactual address: the first\n * UserOperation carries the 7702 authorization tuple and installs the\n * delegation on-chain; subsequent ones reuse it.\n *\n * Hosted bundler + paymaster setups may live at the same Alchemy app URL;\n * local E2E splits normal chain RPC (Anvil) from bundler RPC (alto).\n */\n\nimport { createKernelAccount, createKernelAccountClient } from \"@zerodev/sdk\";\nimport { getEntryPoint, KERNEL_V3_3 } from \"@zerodev/sdk/constants\";\nimport type { Chain } from \"viem\";\nimport { createPublicClient, http } from \"viem\";\nimport { createPaymasterClient } from \"viem/account-abstraction\";\nimport { arbitrum } from \"viem/chains\";\nimport type { EvmSigner } from \"../evm/wallet.js\";\nimport { evmSignerToKernelOwner } from \"./evmSignerAdapter.js\";\nimport type { AaConfig } from \"./types.js\";\n\nexport interface CreateSwapSmartAccountClientParams {\n /**\n * The EOA being delegated, expressed as the SDK's `EvmSigner`. The\n * same abstraction used by `Client.fundSwap` — one signer covers\n * both the direct-Permit2 and CCTP-inbound paths. The CCTP flow\n * requires `signer.signMessage` (UserOp hash) **and**\n * `signer.signAuthorization` (7702 auth tuple) — both optional on\n * `EvmSigner`; the adapter throws a clear error if either is missing.\n */\n signer: EvmSigner;\n /** AA config (normal chain RPC, bundler URL, optional Gas Manager policy id). */\n aa: AaConfig;\n /**\n * Settlement chain. Defaults to Arbitrum mainnet — the only supported\n * chain today, parameterised here so tests / future chains can plug\n * in without a signature change.\n */\n chain?: Chain;\n}\n\n/**\n * Creates a Kernel smart-account client ready to send UserOperations.\n * Async — resolves once the account is derived.\n *\n * @returns `{ client, account, accountAddress }` where `accountAddress`\n * equals the consumer's EOA address (7702: EOA *is* the account).\n */\nexport async function createSwapSmartAccountClient(\n params: CreateSwapSmartAccountClientParams,\n) {\n const { signer, aa, chain = arbitrum } = params;\n const { bundlerUrl, paymasterPolicyId, rpcUrl = bundlerUrl } = aa;\n\n if (!bundlerUrl) {\n throw new Error(\"aa.bundlerUrl is required\");\n }\n\n const entryPoint = getEntryPoint(\"0.7\");\n\n const publicClient = createPublicClient({\n chain,\n transport: http(rpcUrl),\n });\n\n // Adapt the EvmSigner to a viem LocalAccount. Under 7702 this is the\n // EOA whose code gets delegated to Kernel — the adapter throws a\n // clear error if `signMessage` (UserOp hash) or `signAuthorization`\n // (7702 auth tuple) is missing on the EvmSigner.\n const kernelOwner = evmSignerToKernelOwner(signer);\n\n // EIP-7702 mode: pass the EOA as `eip7702Account`. Kernel signs the\n // authorization tuple on the first UserOp via the account's\n // `signAuthorization`, installing the delegation on-chain. No\n // separate ECDSA validator plugin or CREATE2 factory needed — the\n // delegated EOA's own key gates the account.\n const account = await createKernelAccount(publicClient, {\n eip7702Account: kernelOwner,\n entryPoint,\n kernelVersion: KERNEL_V3_3,\n });\n\n const paymaster = paymasterPolicyId\n ? {\n paymaster: createPaymasterClient({\n transport: http(bundlerUrl),\n }),\n paymasterContext: { policyId: paymasterPolicyId },\n }\n : {};\n\n const client = createKernelAccountClient({\n account,\n chain,\n bundlerTransport: http(bundlerUrl),\n ...paymaster,\n userOperation: {\n // ZeroDev's default fetcher calls `zd_getUserOperationGasPrice`,\n // which Alchemy's bundler rejects. Use Alchemy's\n // `rundler_maxPriorityFeePerGas` instead and combine with viem's\n // base-fee estimate for maxFeePerGas. Falls back to a static\n // floor (0.001 gwei) if the rundler method isn't available.\n estimateFeesPerGas: async () => {\n const STATIC_MIN_PRIORITY = 1_000_000n;\n let maxPriorityFeePerGas = STATIC_MIN_PRIORITY;\n try {\n const resp = await fetch(bundlerUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"rundler_maxPriorityFeePerGas\",\n params: [],\n }),\n });\n const json = await resp.json();\n if (typeof json.result === \"string\") {\n const rundlerFee = BigInt(json.result);\n maxPriorityFeePerGas =\n rundlerFee > STATIC_MIN_PRIORITY\n ? rundlerFee\n : STATIC_MIN_PRIORITY;\n }\n } catch {\n /* fall through to static floor */\n }\n const baseFees = await publicClient.estimateFeesPerGas();\n const maxFeePerGas = baseFees.maxFeePerGas + maxPriorityFeePerGas;\n return { maxFeePerGas, maxPriorityFeePerGas };\n },\n },\n });\n\n return { client, account, accountAddress: account.address };\n}\n","/**\n * Optional per-call pre-flight for the CCTP-inbound UserOp batch.\n *\n * The bundler simulates the whole UserOp and returns a single\n * \"execution reverted\" if any inner call fails — useless for\n * iterating. This helper runs each call individually via `eth_call`\n * with the smart account as `from`, surfacing the per-call revert\n * data before we even talk to the bundler.\n *\n * Limitation: any call that re-enters the smart account (e.g. Permit2\n * invoking `IERC1271.isValidSignature`) reverts here because the\n * account isn't deployed at simulation time but WILL be in the real\n * UserOp via factoryData. Treat these reverts as informational — the\n * bundler's full-simulation is the authoritative check.\n */\n\nimport type { Address, PublicClient } from \"viem\";\nimport { createSdkLogger, type Logger, type LogLevel } from \"../logging.js\";\nimport type { BatchCall } from \"./userOp.js\";\n\n/**\n * Walk a viem error chain and surface any RPC-level revert data\n * (selector + encoded args). viem buries these under `cause` /\n * `data` / nested `data.data`.\n */\nexport function extractRevertData(err: unknown): string | undefined {\n let cur: unknown = err;\n for (let depth = 0; depth < 10 && cur; depth++) {\n const node = cur as { data?: unknown; cause?: unknown };\n if (typeof node.data === \"string\" && node.data.startsWith(\"0x\")) {\n return node.data;\n }\n if (typeof node.data === \"object\" && node.data !== null) {\n const nested = (node.data as { data?: string }).data;\n if (typeof nested === \"string\" && nested.startsWith(\"0x\")) {\n return nested;\n }\n }\n cur = node.cause;\n }\n return undefined;\n}\n\nexport interface SimulateBatchCallsArgs {\n calls: BatchCall[];\n smartAccount: Address;\n publicClient: PublicClient;\n /** Optional logger sink. Silent by default. */\n logger?: Logger;\n /** Minimum log level to emit. Defaults to `silent`. */\n logLevel?: LogLevel;\n}\n\n/**\n * Run `eth_call` once per batch call with the smart account as\n * `from`. Logs per-call status via `console.log` / `console.warn` so\n * failures are visible in devtools. Never throws — pre-flight reverts\n * for calls that re-enter the smart account are expected.\n */\nexport async function simulateBatchCalls(\n args: SimulateBatchCallsArgs,\n): Promise<void> {\n const { calls, smartAccount, publicClient } = args;\n const logger = createSdkLogger(args).child({\n module: \"cctp-inbound/preflight\",\n operation: \"cctp.preflight\",\n data: { smartAccount },\n });\n for (let i = 0; i < calls.length; i++) {\n const call = calls[i];\n const label = `[cctp-inbound/preflight] call ${i + 1}/${calls.length} to ${call.to}`;\n try {\n await publicClient.call({\n account: smartAccount,\n to: call.to,\n data: call.data,\n value: call.value,\n });\n logger.debug({\n event: \"cctp.preflight.call_ok\",\n message: \"CCTP preflight call succeeded\",\n data: { label, index: i, to: call.to },\n });\n } catch (err) {\n const revertData = extractRevertData(err);\n logger.warn({\n event: \"cctp.preflight.call_reverted\",\n message: \"CCTP preflight call reverted; this may be OK at send time\",\n data: {\n label,\n index: i,\n to: call.to,\n revertData: revertData ?? \"(none)\",\n },\n error: err,\n });\n }\n }\n}\n","/**\n * SHA3 (keccak) hash function, based on a new \"Sponge function\" design.\n * Different from older hashes, the internal state is bigger than output size.\n *\n * Check out\n * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf | FIPS-202},\n * {@link https://keccak.team/keccak.html | Website}, and\n * {@link https://crypto.stackexchange.com/q/15727 | the differences between\n * SHA-3 and Keccak}.\n *\n * Check out `sha3-addons` module for cSHAKE, k12, and others.\n * @module\n */\nimport { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.ts';\n// prettier-ignore\nimport {\n abytes, aexists, anumber, aoutput,\n clean, createHasher,\n oidNist,\n swap32IfBE,\n u32,\n type CHash, type CHashXOF,\n type Hash,\n type HashInfo,\n type HashXOF,\n type TArg,\n type TRet\n} from './utils.ts';\n\n// No __PURE__ annotations in sha3 header:\n// EVERYTHING is in fact used on every export.\n// Various per round constants calculations\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\nconst _2n = BigInt(2);\nconst _7n = BigInt(7);\nconst _256n = BigInt(256);\n// FIPS 202 Algorithm 5 rc(): when the outgoing bit is 1, the 8-bit LFSR xors\n// taps 0, 4, 5, and 6, which compresses to the feedback mask `0x71`.\nconst _0x71n = BigInt(0x71);\nconst SHA3_PI: number[] = [];\nconst SHA3_ROTL: number[] = [];\nconst _SHA3_IOTA: bigint[] = []; // no pure annotation: var is always used\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n) t ^= _1n << ((_1n << BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst IOTAS = split(_SHA3_IOTA, true);\n// `split(..., true)` keeps the local little-endian lane-word layout used by\n// `state32`, so these `H` / `L` tables follow the file's first-word /\n// second-word lane slots rather than `_u64.ts`'s usual high/low naming.\nconst SHA3_IOTA_H = IOTAS[0];\nconst SHA3_IOTA_L = IOTAS[1];\n\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h: number, l: number, s: number) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h: number, l: number, s: number) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n\n/**\n * `keccakf1600` internal permutation, additionally allows adjusting the round count.\n * @param s - 5x5 Keccak state encoded as 25 lanes split into 50 uint32 words\n * in this file's local little-endian lane-word order\n * @param rounds - number of rounds to execute\n * @throws If `rounds` is outside the supported `1..24` range. {@link Error}\n * @example\n * Permute a Keccak state with the default 24 rounds.\n * ```ts\n * keccakP(new Uint32Array(50));\n * ```\n */\nexport function keccakP(s: TArg<Uint32Array>, rounds: number = 24): void {\n anumber(rounds, 'rounds');\n // This implementation precomputes only the standard Keccak-f[1600] 24-round Iota table.\n if (rounds < 1 || rounds > 24) throw new Error('\"rounds\" expected integer 1..24');\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n // Same as:\n // for (let x = 0; x < 10; x++) B[x] = s[y + x];\n // for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n for (let y = 0; y < 50; y += 10) {\n const b0 = s[y],\n b1 = s[y + 1],\n b2 = s[y + 2],\n b3 = s[y + 3];\n s[y] ^= ~s[y + 2] & s[y + 4];\n s[y + 1] ^= ~s[y + 3] & s[y + 5];\n s[y + 2] ^= ~s[y + 4] & s[y + 6];\n s[y + 3] ^= ~s[y + 5] & s[y + 7];\n s[y + 4] ^= ~s[y + 6] & s[y + 8];\n s[y + 5] ^= ~s[y + 7] & s[y + 9];\n s[y + 6] ^= ~s[y + 8] & b0;\n s[y + 7] ^= ~s[y + 9] & b1;\n s[y + 8] ^= ~b0 & b2;\n s[y + 9] ^= ~b1 & b3;\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n clean(B);\n}\n\n/**\n * Keccak sponge function.\n * @param blockLen - absorb/squeeze rate in bytes\n * @param suffix - domain separation suffix byte\n * @param outputLen - default digest length in bytes. This base sponge only\n * requires a non-negative integer; wrappers that need positive output\n * lengths must enforce that themselves.\n * @param enableXOF - whether XOF output is allowed\n * @param rounds - number of Keccak-f rounds\n * @example\n * Build a sponge state, absorb bytes, then finalize a digest.\n * ```ts\n * const hash = new Keccak(136, 0x06, 32);\n * hash.update(new Uint8Array([1, 2, 3]));\n * hash.digest();\n * ```\n */\nexport class Keccak implements Hash<Keccak>, HashXOF<Keccak> {\n protected state: Uint8Array;\n protected pos = 0;\n protected posOut = 0;\n protected finished = false;\n protected state32: Uint32Array;\n protected destroyed = false;\n\n public blockLen: number;\n public suffix: number;\n public outputLen: number;\n public canXOF: boolean;\n protected enableXOF = false;\n protected rounds: number;\n\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(\n blockLen: number,\n suffix: number,\n outputLen: number,\n enableXOF = false,\n rounds: number = 24\n ) {\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.canXOF = enableXOF;\n this.rounds = rounds;\n // Can be passed from user as dkLen\n anumber(outputLen, 'outputLen');\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n // 0 < blockLen < 200\n if (!(0 < blockLen && blockLen < 200))\n throw new Error('only keccak-f1600 function is supported');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n clone(): Keccak {\n return this._cloneInto();\n }\n protected keccak(): void {\n swap32IfBE(this.state32);\n keccakP(this.state32, this.rounds);\n swap32IfBE(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data: TArg<Uint8Array>): this {\n aexists(this);\n abytes(data);\n const { blockLen, state } = this;\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen) this.keccak();\n }\n return this;\n }\n protected finish(): void {\n if (this.finished) return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // FIPS 202 appends the SHA3/SHAKE domain-separation suffix before pad10*1.\n // These byte values already include the first padding bit, while the\n // final `0x80` below supplies the closing `1` bit in the last rate byte.\n state[pos] ^= suffix;\n // If that combined suffix lands in the last rate byte and already sets\n // bit 7, absorb it first so the final pad10*1 bit can be xored into a\n // fresh block.\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1) this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n protected writeInto(out: TArg<Uint8Array>): TRet<Uint8Array> {\n aexists(this, false);\n abytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len; ) {\n if (this.posOut >= blockLen) this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out as TRet<Uint8Array>;\n }\n xofInto(out: TArg<Uint8Array>): TRet<Uint8Array> {\n // Plain SHA3/Keccak usage with XOF is probably a mistake, but this base\n // class is also reused by SHAKE/cSHAKE/KMAC/TupleHash/ParallelHash/\n // TurboSHAKE/KangarooTwelve wrappers that intentionally enable XOF.\n if (!this.enableXOF) throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes: number): TRet<Uint8Array> {\n anumber(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out: TArg<Uint8Array>): void {\n aoutput(out, this);\n if (this.finished) throw new Error('digest() was already called');\n // `aoutput(...)` allows oversized buffers; digestInto() must fill only the advertised digest.\n this.writeInto(out.subarray(0, this.outputLen));\n this.destroy();\n }\n digest(): TRet<Uint8Array> {\n const out = new Uint8Array(this.outputLen);\n this.digestInto(out);\n return out as TRet<Uint8Array>;\n }\n destroy(): void {\n this.destroyed = true;\n clean(this.state);\n }\n _cloneInto(to?: Keccak): Keccak {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);\n // Reused destinations can come from a different rate/capacity variant, so clone must rewrite\n // the sponge geometry as well as the state words.\n to.blockLen = blockLen;\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n // Clones must preserve the public capability bit too; `_KMAC` reuses this path and deep clone\n // tests compare instance fields directly, so leaving `canXOF` behind makes the clone lie.\n to.canXOF = this.canXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\n\nconst genKeccak = (\n suffix: number,\n blockLen: number,\n outputLen: number,\n info: TArg<HashInfo> = {}\n) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);\n\n/**\n * SHA3-224 hash function.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-224.\n * ```ts\n * sha3_224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_224: TRet<CHash> = /* @__PURE__ */ genKeccak(\n 0x06,\n 144,\n 28,\n /* @__PURE__ */ oidNist(0x07)\n);\n/**\n * SHA3-256 hash function. Different from keccak-256.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-256.\n * ```ts\n * sha3_256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_256: TRet<CHash> = /* @__PURE__ */ genKeccak(\n 0x06,\n 136,\n 32,\n /* @__PURE__ */ oidNist(0x08)\n);\n/**\n * SHA3-384 hash function.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-384.\n * ```ts\n * sha3_384(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_384: TRet<CHash> = /* @__PURE__ */ genKeccak(\n 0x06,\n 104,\n 48,\n /* @__PURE__ */ oidNist(0x09)\n);\n/**\n * SHA3-512 hash function.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA3-512.\n * ```ts\n * sha3_512(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha3_512: TRet<CHash> = /* @__PURE__ */ genKeccak(\n 0x06,\n 72,\n 64,\n /* @__PURE__ */ oidNist(0x0a)\n);\n\n/**\n * Keccak-224 hash function.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-224.\n * ```ts\n * keccak_224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_224: TRet<CHash> = /* @__PURE__ */ genKeccak(0x01, 144, 28);\n/**\n * Keccak-256 hash function. Different from SHA3-256.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-256.\n * ```ts\n * keccak_256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_256: TRet<CHash> = /* @__PURE__ */ genKeccak(0x01, 136, 32);\n/**\n * Keccak-384 hash function.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-384.\n * ```ts\n * keccak_384(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_384: TRet<CHash> = /* @__PURE__ */ genKeccak(0x01, 104, 48);\n/**\n * Keccak-512 hash function.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with Keccak-512.\n * ```ts\n * keccak_512(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const keccak_512: TRet<CHash> = /* @__PURE__ */ genKeccak(0x01, 72, 64);\n\n/** Options for SHAKE XOF. */\nexport type ShakeOpts = {\n /** Desired number of output bytes. */\n dkLen?: number;\n};\n\nconst genShake = (suffix: number, blockLen: number, outputLen: number, info: TArg<HashInfo> = {}) =>\n createHasher<Keccak, ShakeOpts>(\n (opts: ShakeOpts = {}) =>\n new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true),\n info\n );\n\n/**\n * SHAKE128 XOF with 128-bit security and a 16-byte default output.\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE128.\n * ```ts\n * shake128(new Uint8Array([97, 98, 99]), { dkLen: 32 });\n * ```\n */\nexport const shake128: TRet<CHashXOF<Keccak, ShakeOpts>> =\n /* @__PURE__ */\n genShake(0x1f, 168, 16, /* @__PURE__ */ oidNist(0x0b));\n/**\n * SHAKE256 XOF with 256-bit security and a 32-byte default output.\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE256.\n * ```ts\n * shake256(new Uint8Array([97, 98, 99]), { dkLen: 64 });\n * ```\n */\nexport const shake256: TRet<CHashXOF<Keccak, ShakeOpts>> =\n /* @__PURE__ */\n genShake(0x1f, 136, 32, /* @__PURE__ */ oidNist(0x0c));\n\n/**\n * SHAKE128 XOF with 256-bit output (NIST version).\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE128 using a 32-byte default output.\n * ```ts\n * shake128_32(new Uint8Array([97, 98, 99]), { dkLen: 32 });\n * ```\n */\nexport const shake128_32: TRet<CHashXOF<Keccak, ShakeOpts>> =\n /* @__PURE__ */\n genShake(0x1f, 168, 32, /* @__PURE__ */ oidNist(0x0b));\n/**\n * SHAKE256 XOF with 512-bit output (NIST version).\n * @param msg - message bytes to hash\n * @param opts - Optional output-length override. See {@link ShakeOpts}.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHAKE256 using a 64-byte default output.\n * ```ts\n * shake256_64(new Uint8Array([97, 98, 99]), { dkLen: 64 });\n * ```\n */\nexport const shake256_64: TRet<CHashXOF<Keccak, ShakeOpts>> =\n /* @__PURE__ */\n genShake(0x1f, 136, 64, /* @__PURE__ */ oidNist(0x0c));\n","/**\n * EVM HTLC encoding utilities.\n *\n * Provides helpers for encoding call data to interact with the\n * ReverseAtomicSwapHTLC contract for EVM-to-BTC swaps.\n */\n\nimport { keccak_256 } from \"@noble/hashes/sha3.js\";\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils.js\";\nimport { decodeUint256, type ReceiptLog } from \"./wallet.js\";\n\n/**\n * Parameters for creating an EVM HTLC swap.\n */\nexport interface CreateSwapParams {\n /** Unique swap identifier (UUID or bytes32 hex) */\n swapId: string;\n /** Address to receive tokens on claim (Lendaswap's address) */\n recipient: string;\n /** Input token address (e.g., USDC) */\n tokenIn: string;\n /** Output token address (e.g., WBTC) */\n tokenOut: string;\n /** Amount of input token (in token's smallest unit, e.g., 6 decimals for USDC) */\n amountIn: bigint;\n /** Hash lock (SHA256 of preimage, 32 bytes hex with 0x prefix) */\n hashLock: string;\n /** Unix timestamp after which refund is possible */\n timelock: number;\n /** Uniswap pool fee tier (500, 3000, or 10000) */\n poolFee: number;\n /** Minimum output amount (slippage protection) */\n minAmountOut: bigint;\n}\n\n/**\n * Result of encoding createSwap call data.\n */\nexport interface CreateSwapCallData {\n /** The HTLC contract address to call */\n to: string;\n /** The encoded call data */\n data: string;\n /** Human-readable function signature */\n functionSignature: string;\n}\n\n/**\n * Result of encoding approve call data.\n */\nexport interface ApproveCallData {\n /** The token contract address to call */\n to: string;\n /** The encoded call data */\n data: string;\n /** Human-readable function signature */\n functionSignature: string;\n}\n\n/**\n * Result of encoding refundSwap call data.\n */\nexport interface RefundSwapCallData {\n /** The HTLC contract address to call */\n to: string;\n /** The encoded call data */\n data: string;\n /** Human-readable function signature */\n functionSignature: string;\n}\n\n/**\n * Parameters for creating an HTLCErc20 swap (new contract).\n */\nexport interface HtlcErc20CreateParams {\n /** Hash lock (SHA256 of preimage, 32 bytes hex with 0x prefix) */\n preimageHash: string;\n /** Amount of tokens (in token's smallest unit) */\n amount: bigint;\n /** Token contract address */\n token: string;\n /** Address that can refund (usually the sender/user) */\n sender: string;\n /** Address that can claim with preimage (usually the server) */\n claimer: string;\n /** Unix timestamp after which refund is possible */\n timelock: number;\n}\n\n/**\n * Result of encoding HTLCErc20 create call data.\n */\nexport interface HtlcErc20CreateCallData {\n /** The HTLC contract address to call */\n to: string;\n /** The encoded call data */\n data: string;\n /** Human-readable function signature */\n functionSignature: string;\n}\n\n// Function selectors (first 4 bytes of keccak256 hash of function signature)\n// createSwap(bytes32,address,address,address,uint256,bytes32,uint256,uint24,uint256)\nconst CREATE_SWAP_SELECTOR = \"0x9a4efe51\";\n// approve(address,uint256)\nconst APPROVE_SELECTOR = \"0x095ea7b3\";\n// refundSwap(bytes32)\nconst REFUND_SWAP_SELECTOR = \"0xfe2510ee\";\n// HTLCErc20.create(bytes32,uint256,address,address,address,uint256)\nconst HTLC_ERC20_CREATE_SELECTOR = \"0x06799dee\";\n// HTLCErc20.refund(bytes32,uint256,address,address,uint256)\nconst HTLC_ERC20_REFUND_SELECTOR = \"0x36504721\";\n// HTLCErc20.isActive(bytes32,uint256,address,address,address,uint256)\nconst HTLC_ERC20_IS_ACTIVE_SELECTOR = \"0x160c723c\";\n\n/**\n * Converts a UUID string to a bytes32 hex string (right-padded with zeros).\n *\n * @param uuid - The UUID string (with or without hyphens)\n * @returns The bytes32 hex string (without 0x prefix)\n */\nexport function uuidToBytes32(uuid: string): string {\n // Remove hyphens and 0x prefix if present\n let cleanHex = uuid.replace(/-/g, \"\").replace(/^0x/, \"\");\n\n // Ensure it's valid hex\n if (!/^[0-9a-fA-F]+$/.test(cleanHex)) {\n throw new Error(`Invalid UUID hex: ${uuid}`);\n }\n\n // Right-pad to 64 characters (32 bytes)\n if (cleanHex.length < 64) {\n cleanHex = cleanHex.padEnd(64, \"0\");\n } else if (cleanHex.length > 64) {\n cleanHex = cleanHex.slice(0, 64);\n }\n\n return cleanHex.toLowerCase();\n}\n\n/**\n * Normalizes a bytes32 value (removes 0x prefix, ensures 64 chars).\n */\nexport function normalizeBytes32(value: string): string {\n let clean = value.replace(/^0x/, \"\");\n if (clean.length < 64) {\n clean = clean.padStart(64, \"0\");\n }\n return clean.toLowerCase();\n}\n\n/**\n * Normalizes an address to 32 bytes (left-padded with zeros).\n */\nfunction normalizeAddress(address: string): string {\n const clean = address.replace(/^0x/, \"\").toLowerCase();\n return clean.padStart(64, \"0\");\n}\n\n/**\n * Encodes a uint256 value as 32 bytes hex.\n */\nfunction encodeUint256(value: bigint): string {\n return value.toString(16).padStart(64, \"0\");\n}\n\n/**\n * Encodes a uint24 value as 32 bytes hex (for ABI encoding).\n */\nfunction encodeUint24(value: number): string {\n return value.toString(16).padStart(64, \"0\");\n}\n\n/**\n * Encodes the call data for ERC20 approve function.\n *\n * @param spender - The address to approve (HTLC contract)\n * @param amount - The amount to approve\n * @returns The encoded approve call data\n *\n * @example\n * ```ts\n * const approveData = encodeApproveCallData(htlcAddress, amountIn);\n * // Use with ethers.js:\n * await tokenContract.sendTransaction({ to: tokenAddress, data: approveData.data });\n * ```\n */\nexport function encodeApproveCallData(\n tokenAddress: string,\n spender: string,\n amount: bigint,\n): ApproveCallData {\n const spenderEncoded = normalizeAddress(spender);\n const amountEncoded = encodeUint256(amount);\n\n const data = `${APPROVE_SELECTOR}${spenderEncoded}${amountEncoded}`;\n\n return {\n to: tokenAddress,\n data,\n functionSignature: \"approve(address,uint256)\",\n };\n}\n\n/**\n * Encodes the call data for createSwap function on the HTLC contract.\n *\n * @param htlcAddress - The HTLC contract address\n * @param params - The createSwap parameters\n * @returns The encoded createSwap call data\n *\n * @example\n * ```ts\n * const createData = encodeCreateSwapCallData(htlcAddress, {\n * swapId: \"12345678-1234-1234-1234-123456789abc\",\n * recipient: \"0x...\",\n * tokenIn: \"0x...\", // USDC\n * tokenOut: \"0x...\", // WBTC\n * amountIn: 100000000n, // 100 USDC (6 decimals)\n * hashLock: \"0x...\",\n * timelock: Math.floor(Date.now() / 1000) + 3600,\n * poolFee: 3000,\n * minAmountOut: 0n,\n * });\n * ```\n */\nexport function encodeCreateSwapCallData(\n htlcAddress: string,\n params: CreateSwapParams,\n): CreateSwapCallData {\n // Encode each parameter\n const swapIdEncoded = uuidToBytes32(params.swapId);\n const recipientEncoded = normalizeAddress(params.recipient);\n const tokenInEncoded = normalizeAddress(params.tokenIn);\n const tokenOutEncoded = normalizeAddress(params.tokenOut);\n const amountInEncoded = encodeUint256(params.amountIn);\n const hashLockEncoded = normalizeBytes32(params.hashLock);\n const timelockEncoded = encodeUint256(BigInt(params.timelock));\n const poolFeeEncoded = encodeUint24(params.poolFee);\n const minAmountOutEncoded = encodeUint256(params.minAmountOut);\n\n const data = [\n CREATE_SWAP_SELECTOR,\n swapIdEncoded,\n recipientEncoded,\n tokenInEncoded,\n tokenOutEncoded,\n amountInEncoded,\n hashLockEncoded,\n timelockEncoded,\n poolFeeEncoded,\n minAmountOutEncoded,\n ].join(\"\");\n\n return {\n to: htlcAddress,\n data,\n functionSignature:\n \"createSwap(bytes32,address,address,address,uint256,bytes32,uint256,uint24,uint256)\",\n };\n}\n\n/**\n * Encodes the call data for refundSwap function on the HTLC contract.\n *\n * @param htlcAddress - The HTLC contract address\n * @param swapId - The swap ID (UUID or bytes32 hex)\n * @returns The encoded refundSwap call data\n *\n * @example\n * ```ts\n * const refundData = encodeRefundSwapCallData(htlcAddress, swapId);\n * // Use with viem:\n * await walletClient.sendTransaction({ to: refundData.to, data: refundData.data });\n * ```\n */\nexport function encodeRefundSwapCallData(\n htlcAddress: string,\n swapId: string,\n): RefundSwapCallData {\n const swapIdEncoded = uuidToBytes32(swapId);\n const data = `${REFUND_SWAP_SELECTOR}${swapIdEncoded}`;\n\n return {\n to: htlcAddress,\n data,\n functionSignature: \"refundSwap(bytes32)\",\n };\n}\n\n/**\n * Parameters for HTLCErc20.refund function.\n */\nexport interface HtlcErc20RefundParams {\n preimageHash: string;\n amount: bigint | number;\n token: string;\n claimAddress: string;\n timelock: number;\n}\n\n/**\n * Result of encoding HTLCErc20.refund call data.\n */\nexport interface HtlcErc20RefundCallData {\n to: string;\n data: string;\n functionSignature: string;\n}\n\n/**\n * Encodes the call data for HTLCErc20.refund function.\n *\n * This is for refunding tokens from the HTLCErc20 contract after the timelock has expired.\n *\n * @param htlcAddress - The HTLCErc20 contract address\n * @param params - The refund parameters\n * @returns The encoded refund call data\n *\n * @example\n * ```ts\n * const refundData = encodeHtlcErc20RefundCallData(htlcAddress, {\n * preimageHash: \"0x...\",\n * amount: 100000000n,\n * token: \"0x...\",\n * claimAddress: \"0x...\",\n * timelock: 1234567890,\n * });\n * // Use with viem:\n * await walletClient.sendTransaction({ to: refundData.to, data: refundData.data });\n * ```\n */\nexport function encodeHtlcErc20RefundCallData(\n htlcAddress: string,\n params: HtlcErc20RefundParams,\n): HtlcErc20RefundCallData {\n const preimageHashEncoded = normalizeBytes32(params.preimageHash);\n const amountEncoded = encodeUint256(BigInt(params.amount));\n const tokenEncoded = normalizeAddress(params.token);\n const claimAddressEncoded = normalizeAddress(params.claimAddress);\n const timelockEncoded = encodeUint256(BigInt(params.timelock));\n\n const data = [\n HTLC_ERC20_REFUND_SELECTOR,\n preimageHashEncoded,\n amountEncoded,\n tokenEncoded,\n claimAddressEncoded,\n timelockEncoded,\n ].join(\"\");\n\n return {\n to: htlcAddress,\n data,\n functionSignature: \"refund(bytes32,uint256,address,address,uint256)\",\n };\n}\n\n/** Parameters for `HTLCNative.refund` (no token: the lock is the native coin). */\nexport interface HtlcNativeRefundParams {\n preimageHash: string;\n amount: bigint | number;\n claimAddress: string;\n timelock: number;\n}\n\n// HTLCNative.refund(bytes32,uint256,address,uint256)\nconst HTLC_NATIVE_REFUND_SELECTOR = \"0x35cd4ccb\";\n\n/**\n * Encodes `HTLCNative.refund(preimageHash, amount, claimAddress, timelock)`\n * for a lock created directly on the HTLC (sender == depositor). Locks made\n * through the native coordinator are refunded with `encodeNativeRefundTo`.\n */\nexport function encodeHtlcNativeRefundCallData(\n htlcAddress: string,\n params: HtlcNativeRefundParams,\n): HtlcErc20RefundCallData {\n const data = [\n HTLC_NATIVE_REFUND_SELECTOR,\n normalizeBytes32(params.preimageHash),\n encodeUint256(BigInt(params.amount)),\n normalizeAddress(params.claimAddress),\n encodeUint256(BigInt(params.timelock)),\n ].join(\"\");\n return {\n to: htlcAddress,\n data,\n functionSignature: \"refund(bytes32,uint256,address,uint256)\",\n };\n}\n\n/**\n * Whether client locks on this deployment are keyed under the depositor\n * rather than the coordinator: HTLCErc20 from v7, HTLCNative from v2. The\n * Permit2 funding witness binds `refundAddress` to that sender, so a funding\n * signed for the wrong one is rejected by Permit2 (`InvalidSigner`).\n * Unknown kind or version means an older server, whose deployments lock\n * with the coordinator.\n */\nexport function depositorIsSender(\n kind: string | undefined,\n version: number | undefined,\n): boolean {\n if (version === undefined) return false;\n if (kind === \"native\") return version >= 2;\n if (kind === \"erc20\") return version >= 7;\n return false;\n}\n\n// HTLCErc20.refundFor(bytes32,uint256,address,address,address,uint256)\nconst HTLC_ERC20_REFUND_FOR_SELECTOR = \"0x91fd66ab\";\n// HTLCNative.refundFor(bytes32,uint256,address,address,uint256)\nconst HTLC_NATIVE_REFUND_FOR_SELECTOR = \"0x8dd4ea3e\";\n\n/**\n * Rewrites the server's permissionless `refundFor` of an expired lock\n * (HTLCErc20 v7 / HTLCNative v2) as the depositor's own `refund` on the same\n * HTLC, for a depositor that sends the refund itself, e.g. through a\n * sponsored UserOp, whose paymaster only sponsors a depositor's own calls.\n * Any other call is returned unchanged. Throws when the lock's sender is not\n * `depositor`, since `refund` would then compute a different key and revert.\n */\nexport function refundForAsOwnRefund(\n call: { to: string; data: string },\n depositor: string,\n): { to: string; data: string } {\n const data = call.data.toLowerCase();\n const selector = data.slice(0, 10);\n const native = selector === HTLC_NATIVE_REFUND_FOR_SELECTOR;\n if (!native && selector !== HTLC_ERC20_REFUND_FOR_SELECTOR) return call;\n const words = native ? 5 : 6;\n if (data.length !== 10 + 64 * words) {\n throw new Error(\n `refundFor calldata has ${(data.length - 10) / 64} words, expected ${words}`,\n );\n }\n const word = (i: number) => data.slice(10 + 64 * i, 10 + 64 * (i + 1));\n const senderIndex = native ? 2 : 3;\n const sender = `0x${word(senderIndex).slice(24)}`;\n if (sender !== depositor.toLowerCase()) {\n throw new Error(\n `The lock was created by ${sender}, not ${depositor}; only its sender can refund it directly`,\n );\n }\n const terms = Array.from({ length: words }, (_, i) => word(i)).filter(\n (_, i) => i !== senderIndex,\n );\n const refundSelector = native\n ? HTLC_NATIVE_REFUND_SELECTOR\n : HTLC_ERC20_REFUND_SELECTOR;\n return { to: call.to, data: [refundSelector, ...terms].join(\"\") };\n}\n\n/** A server signature over an HTLC-level EIP-712 struct, as `(v, r, s)`. */\nexport interface HtlcSignature {\n v: number;\n r: string;\n s: string;\n}\n\n/**\n * Parameters for `HTLCErc20.refundBySig`: the lock's terms plus the claim\n * address's `Refund` signature. The depositor is `msg.sender`, so the call\n * carries no sender or claim address; the contract recovers the latter.\n */\nexport interface HtlcErc20RefundBySigParams extends HtlcSignature {\n preimageHash: string;\n amount: bigint | number;\n token: string;\n timelock: number;\n}\n\n// HTLCErc20.refundBySig(bytes32,uint256,address,uint256,uint8,bytes32,bytes32)\nconst HTLC_ERC20_REFUND_BY_SIG_SELECTOR = \"0x072c420d\";\n\n/**\n * Encodes `HTLCErc20.refundBySig(...)` (v7+): the depositor returns its lock\n * before the timelock with the claim address's `Refund` signature, which the\n * server hands out through `/collab-refund-evm/signature`. Must be sent from\n * the depositor address the lock was created under.\n */\nexport function encodeHtlcErc20RefundBySigCallData(\n htlcAddress: string,\n params: HtlcErc20RefundBySigParams,\n): HtlcErc20RefundCallData {\n const data = [\n HTLC_ERC20_REFUND_BY_SIG_SELECTOR,\n normalizeBytes32(params.preimageHash),\n encodeUint256(BigInt(params.amount)),\n normalizeAddress(params.token),\n encodeUint256(BigInt(params.timelock)),\n ...encodeSignature(params),\n ].join(\"\");\n return {\n to: htlcAddress,\n data,\n functionSignature:\n \"refundBySig(bytes32,uint256,address,uint256,uint8,bytes32,bytes32)\",\n };\n}\n\n/** Parameters for `HTLCNative.refundBySig` (no token: the lock is the native coin). */\nexport interface HtlcNativeRefundBySigParams extends HtlcSignature {\n preimageHash: string;\n amount: bigint | number;\n timelock: number;\n}\n\n// HTLCNative.refundBySig(bytes32,uint256,uint256,uint8,bytes32,bytes32)\nconst HTLC_NATIVE_REFUND_BY_SIG_SELECTOR = \"0x3bab851e\";\n\n/** `HTLCNative.refundBySig(...)` (v2+); see {@link encodeHtlcErc20RefundBySigCallData}. */\nexport function encodeHtlcNativeRefundBySigCallData(\n htlcAddress: string,\n params: HtlcNativeRefundBySigParams,\n): HtlcErc20RefundCallData {\n const data = [\n HTLC_NATIVE_REFUND_BY_SIG_SELECTOR,\n normalizeBytes32(params.preimageHash),\n encodeUint256(BigInt(params.amount)),\n encodeUint256(BigInt(params.timelock)),\n ...encodeSignature(params),\n ].join(\"\");\n return {\n to: htlcAddress,\n data,\n functionSignature:\n \"refundBySig(bytes32,uint256,uint256,uint8,bytes32,bytes32)\",\n };\n}\n\n/**\n * Parameters for `HTLCErc20.rehash`: the lock's current terms, the hash and\n * timelock it continues under, and the claim address's `Rehash` signature.\n */\nexport interface HtlcErc20RehashParams extends HtlcSignature {\n preimageHash: string;\n amount: bigint | number;\n token: string;\n timelock: number;\n newPreimageHash: string;\n newTimelock: number;\n}\n\n// HTLCErc20.rehash(bytes32,uint256,address,uint256,bytes32,uint256,uint8,bytes32,bytes32)\nconst HTLC_ERC20_REHASH_SELECTOR = \"0x5a83bf7f\";\n\n/**\n * Encodes `HTLCErc20.rehash(...)` (v7+): the depositor moves its active lock\n * to a new preimage hash and timelock with the claim address's `Rehash`\n * signature, which the server hands out through `/rehash-evm` together with\n * these arguments. Must be sent from the depositor address the lock was\n * created under.\n */\nexport function encodeHtlcErc20RehashCallData(\n htlcAddress: string,\n params: HtlcErc20RehashParams,\n): HtlcErc20RefundCallData {\n const data = [\n HTLC_ERC20_REHASH_SELECTOR,\n normalizeBytes32(params.preimageHash),\n encodeUint256(BigInt(params.amount)),\n normalizeAddress(params.token),\n encodeUint256(BigInt(params.timelock)),\n normalizeBytes32(params.newPreimageHash),\n encodeUint256(BigInt(params.newTimelock)),\n ...encodeSignature(params),\n ].join(\"\");\n return {\n to: htlcAddress,\n data,\n functionSignature:\n \"rehash(bytes32,uint256,address,uint256,bytes32,uint256,uint8,bytes32,bytes32)\",\n };\n}\n\n/** Parameters for `HTLCNative.rehash` (no token: the lock is the native coin). */\nexport interface HtlcNativeRehashParams extends HtlcSignature {\n preimageHash: string;\n amount: bigint | number;\n timelock: number;\n newPreimageHash: string;\n newTimelock: number;\n}\n\n// HTLCNative.rehash(bytes32,uint256,uint256,bytes32,uint256,uint8,bytes32,bytes32)\nconst HTLC_NATIVE_REHASH_SELECTOR = \"0x6eecb3d8\";\n\n/** `HTLCNative.rehash(...)` (v2+); see {@link encodeHtlcErc20RehashCallData}. */\nexport function encodeHtlcNativeRehashCallData(\n htlcAddress: string,\n params: HtlcNativeRehashParams,\n): HtlcErc20RefundCallData {\n const data = [\n HTLC_NATIVE_REHASH_SELECTOR,\n normalizeBytes32(params.preimageHash),\n encodeUint256(BigInt(params.amount)),\n encodeUint256(BigInt(params.timelock)),\n normalizeBytes32(params.newPreimageHash),\n encodeUint256(BigInt(params.newTimelock)),\n ...encodeSignature(params),\n ].join(\"\");\n return {\n to: htlcAddress,\n data,\n functionSignature:\n \"rehash(bytes32,uint256,uint256,bytes32,uint256,uint8,bytes32,bytes32)\",\n };\n}\n\n/**\n * `(uint8 v, bytes32 r, bytes32 s)` as three ABI words. An `r` or `s` that\n * is not exactly 32 bytes is refused: padded or overlong hex would shift\n * every word after it instead of failing.\n */\nfunction encodeSignature(sig: HtlcSignature): string[] {\n if (!Number.isInteger(sig.v) || sig.v < 0 || sig.v > 255) {\n throw new Error(`Signature v must be a uint8, got ${sig.v}`);\n }\n return [encodeUint256(BigInt(sig.v)), word(\"r\", sig.r), word(\"s\", sig.s)];\n}\n\nfunction word(name: string, value: string): string {\n const clean = value.replace(/^0x/, \"\");\n if (!/^[0-9a-fA-F]{64}$/.test(clean)) {\n throw new Error(`Signature ${name} must be 32 bytes of hex, got ${value}`);\n }\n return clean.toLowerCase();\n}\n\nexport interface HtlcErc20IsActiveParams {\n preimageHash: string;\n amount: bigint;\n token: string;\n /** The HTLC's sender: whoever called `create`. */\n refundAddress: string;\n claimAddress: string;\n timelock: number;\n}\n\n/**\n * Encodes `HTLCErc20.isActive(...)`, which answers whether the swap keyed by\n * these parameters is still open (neither redeemed nor refunded). The result\n * is a single ABI word, non-zero for true.\n */\nexport function encodeHtlcErc20IsActiveCallData(\n htlcAddress: string,\n params: HtlcErc20IsActiveParams,\n): { to: string; data: string } {\n const data = [\n HTLC_ERC20_IS_ACTIVE_SELECTOR,\n normalizeBytes32(params.preimageHash),\n encodeUint256(params.amount),\n normalizeAddress(params.token),\n normalizeAddress(params.refundAddress),\n normalizeAddress(params.claimAddress),\n encodeUint256(BigInt(params.timelock)),\n ].join(\"\");\n return { to: htlcAddress, data };\n}\n\n/**\n * The key `HTLCErc20` / `HTLCNative` store a lock under:\n * `keccak256(abi.encode(preimageHash, amount, token, sender, claimAddress, timelock))`,\n * with a zero token word for a native lock.\n */\nexport function htlcSwapKey(params: HtlcErc20IsActiveParams): string {\n const encoded = [\n normalizeBytes32(params.preimageHash),\n encodeUint256(params.amount),\n normalizeAddress(params.token),\n normalizeAddress(params.refundAddress),\n normalizeAddress(params.claimAddress),\n encodeUint256(BigInt(params.timelock)),\n ].join(\"\");\n return `0x${bytesToHex(keccak_256(hexToBytes(encoded)))}`;\n}\n\n// keccak256(\"swaps(bytes32)\")[0:4]\nconst HTLC_SWAPS_SELECTOR = \"0xeb84e7f2\";\n\n/** `SwapState` of HTLCErc20 v7 / HTLCNative v2. */\nexport const HTLC_SWAP_STATE = {\n None: 0n,\n Active: 1n,\n Redeemed: 2n,\n Refunded: 3n,\n Rehashed: 4n,\n} as const;\n\n/** Encodes `swaps(key)`, the lock's `SwapState` as one ABI word. */\nexport function encodeHtlcSwapsCallData(\n htlcAddress: string,\n key: string,\n): { to: string; data: string } {\n return {\n to: htlcAddress,\n data: `${HTLC_SWAPS_SELECTOR}${normalizeBytes32(key)}`,\n };\n}\n\n/**\n * Encodes the call data for HTLCErc20.create function.\n *\n * This is for the new HTLCErc20 contract used in EVM-to-Lightning swaps.\n *\n * @param htlcAddress - The HTLCErc20 contract address\n * @param params - The create parameters\n * @returns The encoded create call data\n *\n * @example\n * ```ts\n * const createData = encodeHtlcErc20CreateCallData(htlcAddress, {\n * preimageHash: \"0x...\",\n * amount: 100000000n,\n * token: \"0x...\",\n * sender: \"0x...\",\n * claimer: \"0x...\",\n * timelock: Math.floor(Date.now() / 1000) + 3600,\n * });\n * // Use with viem:\n * await walletClient.sendTransaction({ to: createData.to, data: createData.data });\n * ```\n */\nexport function encodeHtlcErc20CreateCallData(\n htlcAddress: string,\n params: HtlcErc20CreateParams,\n): HtlcErc20CreateCallData {\n const preimageHashEncoded = normalizeBytes32(params.preimageHash);\n const amountEncoded = encodeUint256(params.amount);\n const tokenEncoded = normalizeAddress(params.token);\n const senderEncoded = normalizeAddress(params.sender);\n const claimerEncoded = normalizeAddress(params.claimer);\n const timelockEncoded = encodeUint256(BigInt(params.timelock));\n\n const data = [\n HTLC_ERC20_CREATE_SELECTOR,\n preimageHashEncoded,\n amountEncoded,\n tokenEncoded,\n senderEncoded,\n claimerEncoded,\n timelockEncoded,\n ].join(\"\");\n\n return {\n to: htlcAddress,\n data,\n functionSignature:\n \"create(bytes32,uint256,address,address,address,uint256)\",\n };\n}\n\n/**\n * Builds both approve and createSwap call data for an EVM-to-BTC swap.\n *\n * @param htlcAddress - The HTLC contract address\n * @param params - The createSwap parameters\n * @returns Both approve and createSwap call data\n *\n * @example\n * ```ts\n * const { approve, createSwap } = buildEvmHtlcCallData(htlcAddress, params);\n *\n * // Step 1: Approve token spend\n * await wallet.sendTransaction({ to: approve.to, data: approve.data });\n *\n * // Step 2: Create the swap\n * await wallet.sendTransaction({ to: createSwap.to, data: createSwap.data });\n * ```\n */\nexport function buildEvmHtlcCallData(\n htlcAddress: string,\n params: CreateSwapParams,\n): {\n approve: ApproveCallData;\n createSwap: CreateSwapCallData;\n} {\n return {\n approve: encodeApproveCallData(\n params.tokenIn,\n htlcAddress,\n params.amountIn,\n ),\n createSwap: encodeCreateSwapCallData(htlcAddress, params),\n };\n}\n\n// ── SwapCreated log ──────────────────────────────────────────────────────────\n\n/** topic0 of `SwapCreated(bytes32,address,address,address,uint256,uint256,bytes32)`. */\nexport const SWAP_CREATED_TOPIC =\n \"0x127ba86dffa89675eb78a2ca7203c29f865789ebec607b9424ed9f8d3d533e9f\";\n\nexport interface SwapCreatedLog {\n preimageHash: string;\n /** The HTLC's sender; the coordinator for a Permit2-funded swap. */\n refundAddress: string;\n claimAddress: string;\n token: string;\n amount: bigint;\n timelock: number;\n key: string;\n}\n\n/**\n * Decodes an HTLCErc20 `SwapCreated` log, or returns undefined for any other\n * log. The amount here is the one the contract keys the swap on, which after\n * a DEX swap inside the funding tx can differ from every amount in the swap\n * record.\n */\nexport function decodeSwapCreatedLog(log: {\n topics: readonly string[];\n data: string;\n}): SwapCreatedLog | undefined {\n if (log.topics.length !== 4) return undefined;\n if (log.topics[0].toLowerCase() !== SWAP_CREATED_TOPIC) return undefined;\n const data = log.data.replace(/^0x/, \"\");\n if (data.length !== 4 * 64) return undefined;\n const word = (i: number) => data.slice(i * 64, (i + 1) * 64);\n const address = (w: string) => `0x${w.slice(24)}`.toLowerCase();\n return {\n preimageHash: `0x${normalizeBytes32(log.topics[1])}`,\n refundAddress: address(normalizeBytes32(log.topics[2])),\n claimAddress: address(normalizeBytes32(log.topics[3])),\n token: address(word(0)),\n amount: decodeUint256(word(1)),\n timelock: Number(decodeUint256(word(2))),\n key: `0x${word(3)}`,\n };\n}\n\n// keccak256(\"SwapRehashed(bytes32,bytes32,bytes32,bytes32)\")\nexport const SWAP_REHASHED_TOPIC =\n \"0x54e7aaf61f7d94f49a761b306cc6ead18e2e3ce3fd40197cbd2cad8ff2aaf04a\";\n\n/** `SwapRehashed(preimageHash, key, newKey, newPreimageHash)`: a lock moved. */\nexport interface SwapRehashedLog {\n preimageHash: string;\n key: string;\n newKey: string;\n newPreimageHash: string;\n}\n\n/** Decodes an HTLC `SwapRehashed` log, or returns undefined for any other log. */\nexport function decodeSwapRehashedLog(log: {\n topics: readonly string[];\n data: string;\n}): SwapRehashedLog | undefined {\n if (log.topics.length !== 4) return undefined;\n if (log.topics[0].toLowerCase() !== SWAP_REHASHED_TOPIC) return undefined;\n const data = log.data.replace(/^0x/, \"\");\n if (data.length !== 64) return undefined;\n return {\n preimageHash: `0x${normalizeBytes32(log.topics[1])}`,\n key: `0x${normalizeBytes32(log.topics[2])}`,\n newKey: `0x${normalizeBytes32(log.topics[3])}`,\n newPreimageHash: `0x${normalizeBytes32(data)}`,\n };\n}\n\n/** The `SwapRehashed` logs `htlcAddress` emitted for the lock keyed `key`. */\nexport function findSwapRehashed(\n logs: readonly ReceiptLog[],\n filter: { htlcAddress: string; key: string },\n): SwapRehashedLog[] {\n const htlc = filter.htlcAddress.toLowerCase();\n const key = `0x${normalizeBytes32(filter.key)}`;\n const matches: SwapRehashedLog[] = [];\n for (const log of logs) {\n if (log.address.toLowerCase() !== htlc) continue;\n const rehashed = decodeSwapRehashedLog(log);\n if (rehashed === undefined || rehashed.key !== key) continue;\n matches.push(rehashed);\n }\n return matches;\n}\n\nexport interface SwapCreatedFilter {\n htlcAddress: string;\n hashLock: string;\n claimAddress: string;\n /** Senders the HTLC may have been created by; any sender when omitted. */\n senders?: readonly string[];\n token?: string;\n}\n\n/**\n * The funding tx runs server-supplied DEX calls before the coordinator\n * creates the HTLC, so a receipt can carry decoys with the right hash lock;\n * the emitting contract and the sender are what tell them apart.\n */\nexport function findSwapCreated(\n logs: readonly ReceiptLog[],\n filter: SwapCreatedFilter,\n): SwapCreatedLog[] {\n const htlc = filter.htlcAddress.toLowerCase();\n const hashLock = `0x${normalizeBytes32(filter.hashLock)}`;\n const claimAddress = filter.claimAddress.toLowerCase();\n const senders = filter.senders?.map((sender) => sender.toLowerCase());\n const token = filter.token?.toLowerCase();\n const matches: SwapCreatedLog[] = [];\n for (const log of logs) {\n if (log.address.toLowerCase() !== htlc) continue;\n const created = decodeSwapCreatedLog(log);\n if (\n created === undefined ||\n created.preimageHash !== hashLock ||\n created.claimAddress !== claimAddress ||\n (senders !== undefined && !senders.includes(created.refundAddress)) ||\n (token !== undefined && created.token !== token)\n ) {\n continue;\n }\n matches.push(created);\n }\n return matches;\n}\n","/**\n * HTLCCoordinator contract utilities.\n *\n * Provides helpers for EIP-712 signing and encoding `redeemAndExecute` call data\n * for the HTLCCoordinator contract used in Arkade-to-EVM swaps, and\n * `executeAndCreate` / refund helpers for EVM-to-BTC coordinator swaps.\n */\n\nimport { keccak_256 } from \"@noble/hashes/sha3.js\";\nimport {\n hexToBytes as nobleFromHex,\n bytesToHex as nobleToHex,\n} from \"@noble/hashes/utils.js\";\nimport { normalizeBytes32 } from \"./htlc.js\";\n\n// ── ABI helpers ──────────────────────────────────────────────────────────────\n\n/** A single call struct for the coordinator's calls array: (address target, uint256 value, bytes data) */\nexport interface CoordinatorCall {\n /** Target contract address */\n target: string;\n /** ETH value to send (usually \"0\") */\n value: bigint;\n /** Encoded call data */\n data: string;\n}\n\n/** Parameters for building the EIP-712 redeem digest */\nexport interface RedeemDigestParams {\n /** HTLCErc20 contract address (verifyingContract) */\n htlcAddress: string;\n /** EVM chain ID */\n chainId: number;\n /** Preimage (32-byte hex with 0x prefix) */\n preimage: string;\n /** WBTC amount locked in the HTLC (in smallest unit) */\n amount: bigint;\n /** WBTC token address */\n token: string;\n /** HTLC sender (server's EVM address) */\n sender: string;\n /** HTLC timelock (unix timestamp) */\n timelock: number;\n /** Caller address (coordinator contract) */\n caller: string;\n /** Destination address where tokens are swept */\n destination: string;\n /** Token to sweep after calls (target token, or WBTC if no swap) */\n sweepToken: string;\n /** Minimum amount of sweepToken to receive (slippage protection) */\n minAmountOut: bigint;\n /** Hash of the calls array (prevents call substitution attacks) */\n callsHash: string;\n /**\n * HTLCErc20 contract VERSION of the deployment this swap lives on — the\n * EIP-712 domain version string. Comes from the swap response's\n * `evm_htlc_version`; defaults to 4 (deployments predating the field).\n */\n htlcVersion?: number | string;\n}\n\n/** Parameters for encoding redeemAndExecute call data */\nexport interface RedeemAndExecuteParams {\n /** Preimage (32-byte hex with 0x prefix) */\n preimage: string;\n /** WBTC amount locked in the HTLC */\n amount: bigint;\n /** WBTC token address */\n token: string;\n /** HTLC sender (server's EVM address) */\n sender: string;\n /** HTLC timelock */\n timelock: number;\n /** Array of calls to execute after redeem (approve + 1inch swap, or empty for WBTC) */\n calls: CoordinatorCall[];\n /** Token to sweep to the user after calls (target token, or WBTC if no swap) */\n sweepToken: string;\n /** Minimum amount of sweepToken to receive (slippage protection, 0 for no check) */\n minAmountOut: bigint;\n /** Destination address where tokens are swept */\n destination: string;\n /** EIP-712 signature v */\n v: number;\n /** EIP-712 signature r (32-byte hex with 0x prefix) */\n r: string;\n /** EIP-712 signature s (32-byte hex with 0x prefix) */\n s: string;\n}\n\n/** Result of building redeemAndExecute call data */\nexport interface RedeemAndExecuteCallData {\n /** The coordinator contract address */\n to: string;\n /** The encoded call data */\n data: string;\n /** Human-readable function signature */\n functionSignature: string;\n}\n\n/** Result of building coordinator call data (used by refund, Permit2, etc.) */\nexport interface ExecuteAndCreateCallData {\n /** The coordinator contract address */\n to: string;\n /** The encoded call data */\n data: string;\n /** Human-readable function signature */\n functionSignature: string;\n}\n\n/** Parameters for encoding refundTo call data */\nexport interface RefundToParams {\n /** SHA256 hash of the preimage (32-byte hex with 0x prefix) */\n preimageHash: string;\n /** WBTC amount locked in the HTLC */\n amount: bigint;\n /** WBTC token address */\n token: string;\n /** Claim address (server's EVM address) */\n claimAddress: string;\n /** HTLC timelock (unix timestamp) */\n timelock: number;\n}\n\n// ── EIP-712 constants ────────────────────────────────────────────────────────\n// hardcoded so that we can potentially support multiple versions\nconst EIP712_DOMAIN_TYPEHASH =\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\";\nconst REDEEM_TYPEHASH =\n \"Redeem(bytes32 preimage,uint256 amount,address token,address sender,uint256 timelock,address caller,address destination,address sweepToken,uint256 minAmountOut,bytes32 callsHash)\";\nconst HTLC_NAME = \"HTLCErc20\";\nconst HTLC_VERSION = \"4\";\n// The native-coin family (`HTLCNative` + `HTLCNativeCoordinator`, e.g. RBTC on\n// Rootstock). Same domain layout under its own name; the `Redeem` struct has no\n// `token` field because the lock asset is the chain's coin.\nconst NATIVE_REDEEM_TYPEHASH =\n \"Redeem(bytes32 preimage,uint256 amount,address sender,uint256 timelock,address caller,address destination,address sweepToken,uint256 minAmountOut,bytes32 callsHash)\";\nconst NATIVE_HTLC_NAME = \"HTLCNative\";\nconst NATIVE_HTLC_VERSION = \"1\";\n/** `address(0)`: the native coin wherever an ERC-20 address is expected. */\nexport const NATIVE_TOKEN_ADDRESS =\n \"0x0000000000000000000000000000000000000000\";\n\n// ── redeemAndExecute selector ────────────────────────────────────────────────\n// keccak256(\"redeemAndExecute(bytes32,uint256,address,address,uint256,(address,uint256,bytes)[],address,uint256,address,uint8,bytes32,bytes32)\")\nconst REDEEM_AND_EXECUTE_SELECTOR = keccak256(\n stringToUtf8Bytes(\n \"redeemAndExecute(bytes32,uint256,address,address,uint256,(address,uint256,bytes)[],address,uint256,address,uint8,bytes32,bytes32)\",\n ),\n).slice(0, 10);\n\n// ── keccak256 ────────────────────────────────────────────────────────────────\n\n/**\n * Computes keccak256 hash using @noble/hashes.\n *\n * @param input - Hex string (with or without 0x) or Uint8Array\n * @returns 32-byte hex string with 0x prefix\n */\nexport function keccak256(input: string | Uint8Array): string {\n const data = typeof input === \"string\" ? hexToBytes(input) : input;\n const hash = keccak_256(data);\n return `0x${bytesToHex(hash)}`;\n}\n\n// ── EIP-712 digest ───────────────────────────────────────────────────────────\n\n/**\n * Builds the EIP-712 digest that the user must sign to authorize\n * the coordinator to call `HTLC.redeem` on their behalf.\n *\n * @param params - The redeem parameters\n * @returns The 32-byte digest as hex string with 0x prefix\n *\n * @example\n * ```ts\n * const digest = buildRedeemDigest({\n * htlcAddress: \"0x...\",\n * chainId: 137,\n * preimage: \"0x...\",\n * amount: 100000n,\n * token: \"0x...\", // WBTC\n * sender: \"0x...\", // server\n * timelock: 1700000000,\n * caller: \"0x...\", // coordinator\n * });\n * // Sign `digest` with user's EVM wallet\n * ```\n */\nexport function buildRedeemDigest(params: RedeemDigestParams): string {\n // Domain separator\n const domainSeparator = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(EIP712_DOMAIN_TYPEHASH)),\n },\n { type: \"bytes32\", value: keccak256(stringToUtf8Bytes(HTLC_NAME)) },\n {\n type: \"bytes32\",\n value: keccak256(\n stringToUtf8Bytes(String(params.htlcVersion ?? HTLC_VERSION)),\n ),\n },\n { type: \"uint256\", value: BigInt(params.chainId) },\n { type: \"address\", value: params.htlcAddress },\n ]),\n );\n\n // Struct hash\n const typeHash = keccak256(stringToUtf8Bytes(REDEEM_TYPEHASH));\n const structHash = keccak256(\n abiEncode([\n { type: \"bytes32\", value: typeHash },\n { type: \"bytes32\", value: params.preimage },\n { type: \"uint256\", value: params.amount },\n { type: \"address\", value: params.token },\n { type: \"address\", value: params.sender },\n { type: \"uint256\", value: BigInt(params.timelock) },\n { type: \"address\", value: params.caller },\n { type: \"address\", value: params.destination },\n { type: \"address\", value: params.sweepToken },\n { type: \"uint256\", value: params.minAmountOut },\n { type: \"bytes32\", value: params.callsHash },\n ]),\n );\n\n // EIP-712 digest: \\x19\\x01 ‖ domainSeparator ‖ structHash\n const prefix = new Uint8Array([0x19, 0x01]);\n const domainBytes = hexToBytes(domainSeparator);\n const structBytes = hexToBytes(structHash);\n const message = new Uint8Array(\n prefix.length + domainBytes.length + structBytes.length,\n );\n message.set(prefix, 0);\n message.set(domainBytes, prefix.length);\n message.set(structBytes, prefix.length + domainBytes.length);\n\n return keccak256(message);\n}\n\n/** Parameters of the `HTLCNative` `Redeem` digest (no `token`). */\nexport type NativeRedeemDigestParams = Omit<RedeemDigestParams, \"token\">;\n\n/**\n * Builds the EIP-712 digest a claimant signs for a native-coin lock\n * (`HTLCNative.redeemBySig`).\n *\n * Mirrors {@link buildRedeemDigest} with the domain name `HTLCNative` and the\n * token-less `Redeem` struct. For direct wallet claims, `caller` and\n * `destination` must both name the payout wallet: the deployed HTLC pays\n * its caller. No coordinator or backend relay is involved.\n */\nexport function buildNativeRedeemDigest(\n params: NativeRedeemDigestParams,\n): string {\n const domainSeparator = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(EIP712_DOMAIN_TYPEHASH)),\n },\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(NATIVE_HTLC_NAME)),\n },\n {\n type: \"bytes32\",\n value: keccak256(\n stringToUtf8Bytes(String(params.htlcVersion ?? NATIVE_HTLC_VERSION)),\n ),\n },\n { type: \"uint256\", value: BigInt(params.chainId) },\n { type: \"address\", value: params.htlcAddress },\n ]),\n );\n\n const structHash = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(NATIVE_REDEEM_TYPEHASH)),\n },\n { type: \"bytes32\", value: params.preimage },\n { type: \"uint256\", value: params.amount },\n { type: \"address\", value: params.sender },\n { type: \"uint256\", value: BigInt(params.timelock) },\n { type: \"address\", value: params.caller },\n { type: \"address\", value: params.destination },\n { type: \"address\", value: params.sweepToken },\n { type: \"uint256\", value: params.minAmountOut },\n { type: \"bytes32\", value: params.callsHash },\n ]),\n );\n\n const prefix = new Uint8Array([0x19, 0x01]);\n const domainBytes = hexToBytes(domainSeparator);\n const structBytes = hexToBytes(structHash);\n const message = new Uint8Array(\n prefix.length + domainBytes.length + structBytes.length,\n );\n message.set(prefix, 0);\n message.set(domainBytes, prefix.length);\n message.set(structBytes, prefix.length + domainBytes.length);\n\n return keccak256(message);\n}\n\n// ── Calls builder ────────────────────────────────────────────────────────────\n\n/**\n * Builds the calls array for `redeemAndExecute` based on 1inch calldata.\n *\n * - If `dexCallData` is provided: returns [approve WBTC to DEX, execute DEX swap]\n * - If `dexCallData` is null/undefined (WBTC target): returns empty array\n *\n * @param wbtcAddress - WBTC token contract address\n * @param amount - WBTC amount to approve\n * @param dexCallData - DEX swap calldata from the creation response (optional)\n * @returns Array of CoordinatorCall structs\n */\nexport function buildRedeemCalls(\n wbtcAddress: string,\n amount: bigint,\n dexCallData?: { to: string; data: string; value: string } | null,\n): CoordinatorCall[] {\n if (!dexCallData) {\n return [];\n }\n\n // Build approve calldata: WBTC.approve(dex_router, amount)\n const approveData = encodeApprove(dexCallData.to, amount);\n\n return [\n {\n target: wbtcAddress,\n value: 0n,\n data: approveData,\n },\n {\n target: dexCallData.to,\n value: BigInt(dexCallData.value || \"0\"),\n data: dexCallData.data,\n },\n ];\n}\n\n/**\n * Compute `keccak256(abi.encode(Call[]))` — the `callsHash` the coordinator's\n * `redeemBySig` signature commits to (`HTLCCoordinator._computeCallsHash`).\n *\n * When the SDK builds the calls itself (publishing `redeemAndExecute` directly\n * rather than via the server) it must produce this hash byte-for-byte, or\n * `redeemBySig` reverts. Solidity `abi.encode(Call[])` is a 32-byte offset word\n * (`0x20`, pointing at the array) followed by the array body; `encodeCalls()`\n * emits only the body (in `redeemAndExecute` the offset lives in the call head),\n * so we prepend the offset here. Matches the server's `calls.abi_encode_params()`.\n */\nexport function computeCoordinatorCallsHash(calls: CoordinatorCall[]): string {\n const ARRAY_OFFSET_WORD =\n \"0000000000000000000000000000000000000000000000000000000000000020\";\n const body = encodeCalls(calls);\n return keccak256(hexToBytes(`0x${ARRAY_OFFSET_WORD}${body}`));\n}\n\n// ── redeemAndExecute calldata ────────────────────────────────────────────────\n\n/**\n * Encodes the call data for `coordinator.redeemAndExecute(...)`.\n *\n * @param coordinatorAddress - The HTLCCoordinator contract address\n * @param params - All parameters for the call\n * @returns The encoded call data\n *\n * @example\n * ```ts\n * const txData = encodeRedeemAndExecute(\"0xCoordinator...\", {\n * preimage: \"0x...\",\n * amount: 100000n,\n * token: \"0xWBTC...\",\n * sender: \"0xServer...\",\n * timelock: 1700000000,\n * calls: buildRedeemCalls(wbtcAddr, amount, dexCallData),\n * sweepToken: targetTokenAddr,\n * minAmountOut: 0n,\n * v: 27,\n * r: \"0x...\",\n * s: \"0x...\",\n * });\n * // Send transaction: { to: txData.to, data: txData.data }\n * ```\n */\nexport function encodeRedeemAndExecute(\n coordinatorAddress: string,\n params: RedeemAndExecuteParams,\n): RedeemAndExecuteCallData {\n // Fixed-length head: 12 slots of 32 bytes each\n // preimage (bytes32), amount (uint256), token (address), sender (address),\n // timelock (uint256), calls_offset (uint256), sweepToken (address),\n // minAmountOut (uint256), destination (address), v (uint8), r (bytes32), s (bytes32)\n const preimage = normalizeBytes32(params.preimage);\n const amount = encodeUint256(params.amount);\n const token = normalizeAddress(params.token);\n const sender = normalizeAddress(params.sender);\n const timelock = encodeUint256(BigInt(params.timelock));\n\n // Calls is a dynamic type — offset points to where the array data starts.\n // Head has 12 slots × 32 bytes = 384 = 0x180\n const callsOffset = encodeUint256(12n * 32n);\n\n const sweepToken = normalizeAddress(params.sweepToken);\n const minAmountOut = encodeUint256(params.minAmountOut);\n const destination = normalizeAddress(params.destination);\n const v = encodeUint256(BigInt(params.v));\n const r = normalizeBytes32(params.r);\n const s = normalizeBytes32(params.s);\n\n // Encode the calls array\n const callsEncoded = encodeCalls(params.calls);\n\n const data = [\n REDEEM_AND_EXECUTE_SELECTOR,\n preimage,\n amount,\n token,\n sender,\n timelock,\n callsOffset,\n sweepToken,\n minAmountOut,\n destination,\n v,\n r,\n s,\n callsEncoded,\n ].join(\"\");\n\n return {\n to: coordinatorAddress,\n data,\n functionSignature:\n \"redeemAndExecute(bytes32,uint256,address,address,uint256,(address,uint256,bytes)[],address,uint256,address,uint8,bytes32,bytes32)\",\n };\n}\n\n// ── refundTo selector ────────────────────────────────────────────────────────\n// keccak256(\"refundTo(bytes32,uint256,address,address,uint256)\")\nconst REFUND_TO_SELECTOR = keccak256(\n stringToUtf8Bytes(\"refundTo(bytes32,uint256,address,address,uint256)\"),\n).slice(0, 10);\n\n// ── HTLCNativeCoordinator ────────────────────────────────────────────────────\n// The native coordinator locks the chain's own coin, so its functions carry\n// no `token` parameter; everything else mirrors HTLCCoordinator.\n\n// keccak256(\"executeAndCreate((address,uint256,bytes)[],bytes32,uint256,address,uint256)\")\nconst NATIVE_EXECUTE_AND_CREATE_SELECTOR = keccak256(\n stringToUtf8Bytes(\n \"executeAndCreate((address,uint256,bytes)[],bytes32,uint256,address,uint256)\",\n ),\n).slice(0, 10);\n\n// keccak256(\"refundTo(bytes32,uint256,address,uint256)\")\nconst NATIVE_REFUND_TO_SELECTOR = keccak256(\n stringToUtf8Bytes(\"refundTo(bytes32,uint256,address,uint256)\"),\n).slice(0, 10);\n\n/** Parameters for `HTLCNativeCoordinator.executeAndCreate`. */\nexport interface NativeExecuteAndCreateParams {\n /** Calls to run before the lock; a plain native lock sends none. */\n calls: CoordinatorCall[];\n /** SHA256 hash of the preimage (32-byte hex with 0x prefix) */\n preimageHash: string;\n /** Exact amount to lock, in wei. The transaction value must cover it. */\n amount: bigint;\n /** Claim address (server's EVM address) */\n claimAddress: string;\n /** HTLC timelock (unix timestamp) */\n timelock: number;\n}\n\n/** Call data for a native lock: the transaction must carry `value`. */\nexport interface NativeExecuteAndCreateCallData\n extends ExecuteAndCreateCallData {\n /** Native coin to attach, in wei (the lock amount for a plain lock). */\n value: bigint;\n}\n\n/**\n * Encodes `HTLCNativeCoordinator.executeAndCreate(calls, preimageHash, amount, claimAddress, timelock)`.\n *\n * The coordinator locks exactly `amount` of the value it received (after the\n * calls ran) and returns any excess, so a plain lock sends `value == amount`\n * and no calls.\n */\nexport function encodeNativeExecuteAndCreate(\n coordinatorAddress: string,\n params: NativeExecuteAndCreateParams,\n): NativeExecuteAndCreateCallData {\n // Head: calls_offset, preimageHash, amount, claimAddress, timelock (5 slots)\n const callsOffset = encodeUint256(5n * 32n);\n const preimageHash = normalizeBytes32(params.preimageHash);\n const amount = encodeUint256(params.amount);\n const claimAddress = normalizeAddress(params.claimAddress);\n const timelock = encodeUint256(BigInt(params.timelock));\n const callsEncoded = encodeCalls(params.calls);\n\n const data = [\n NATIVE_EXECUTE_AND_CREATE_SELECTOR,\n callsOffset,\n preimageHash,\n amount,\n claimAddress,\n timelock,\n callsEncoded,\n ].join(\"\");\n\n return {\n to: coordinatorAddress,\n data,\n value: params.calls.reduce((sum, call) => sum + call.value, params.amount),\n functionSignature:\n \"executeAndCreate((address,uint256,bytes)[],bytes32,uint256,address,uint256)\",\n };\n}\n\n/** Parameters for `HTLCNativeCoordinator.refundTo`. */\nexport interface NativeRefundToParams {\n /** SHA256 hash of the preimage (32-byte hex with 0x prefix) */\n preimageHash: string;\n /** Amount locked in the HTLC, in wei */\n amount: bigint;\n /** Claim address (server's EVM address) */\n claimAddress: string;\n /** HTLC timelock (unix timestamp) */\n timelock: number;\n}\n\n/**\n * Encodes `HTLCNativeCoordinator.refundTo(preimageHash, amount, claimAddress, timelock)`:\n * the permissionless refund of an expired native lock to its depositor.\n */\nexport function encodeNativeRefundTo(\n coordinatorAddress: string,\n params: NativeRefundToParams,\n): ExecuteAndCreateCallData {\n const data = [\n NATIVE_REFUND_TO_SELECTOR,\n normalizeBytes32(params.preimageHash),\n encodeUint256(params.amount),\n normalizeAddress(params.claimAddress),\n encodeUint256(BigInt(params.timelock)),\n ].join(\"\");\n\n return {\n to: coordinatorAddress,\n data,\n functionSignature: \"refundTo(bytes32,uint256,address,uint256)\",\n };\n}\n\n/**\n * Encodes the call data for `coordinator.refundTo(...)`.\n *\n * Signature: refundTo(bytes32 preimageHash, uint256 amount, address token, address claimAddress, uint256 timelock)\n *\n * @param coordinatorAddress - The HTLCCoordinator contract address\n * @param params - All parameters for the call\n * @returns The encoded call data\n */\nexport function encodeRefundTo(\n coordinatorAddress: string,\n params: RefundToParams,\n): ExecuteAndCreateCallData {\n const preimageHash = normalizeBytes32(params.preimageHash);\n const amount = encodeUint256(params.amount);\n const token = normalizeAddress(params.token);\n const claimAddress = normalizeAddress(params.claimAddress);\n const timelock = encodeUint256(BigInt(params.timelock));\n\n const data = [\n REFUND_TO_SELECTOR,\n preimageHash,\n amount,\n token,\n claimAddress,\n timelock,\n ].join(\"\");\n\n return {\n to: coordinatorAddress,\n data,\n functionSignature: \"refundTo(bytes32,uint256,address,address,uint256)\",\n };\n}\n\n// keccak256(\"deposits(bytes32)\")\nconst DEPOSITS_SELECTOR = keccak256(\n stringToUtf8Bytes(\"deposits(bytes32)\"),\n).slice(0, 10);\n\n/**\n * Encodes `coordinator.deposits(key)`: the depositor the coordinator recorded\n * when it created the HTLC with this key, as one ABI word, zero when it never\n * created it or has already refunded it.\n */\nexport function encodeDepositsCallData(\n coordinatorAddress: string,\n key: string,\n): { to: string; data: string } {\n return {\n to: coordinatorAddress,\n data: `${DEPOSITS_SELECTOR}${normalizeBytes32(key)}`,\n };\n}\n\n// ── Collaborative EVM refund EIP-712 ─────────────────────────────────────────\n\nconst COORDINATOR_NAME = \"HTLCCoordinator\";\nconst COORDINATOR_VERSION = \"3\";\n\nconst COLLAB_REFUND_TYPEHASH =\n \"CollabRefund(bytes32 preimageHash,uint256 amount,address token,address claimAddress,uint256 timelock,address caller,address sweepToken,uint256 minAmountOut,bytes32 callsHash)\";\n\n/** Parameters for building the EIP-712 CollabRefund digest */\nexport interface CollabRefundEvmDigestParams {\n /** HTLCCoordinator contract address (verifyingContract) */\n coordinatorAddress: string;\n /**\n * EIP-712 domain version of the coordinator at `coordinatorAddress`.\n * Comes from the server's collab-refund params (`coordinator_version`);.\n */\n coordinatorVersion?: number | string;\n /** EVM chain ID */\n chainId: number;\n /** SHA-256 preimage hash (32-byte hex with 0x prefix) */\n preimageHash: string;\n /** WBTC amount locked in the HTLC (in smallest unit) */\n amount: bigint;\n /** WBTC token address */\n token: string;\n /** Claim address (server's EVM address) */\n claimAddress: string;\n /** HTLC timelock (unix timestamp) */\n timelock: number;\n /** Caller address (server EOA that submits the tx) */\n caller: string;\n /** Token to sweep after refund (WBTC for direct mode, source token for swap mode) */\n sweepToken: string;\n /** Minimum amount out (slippage protection, 0 for no check) */\n minAmountOut: bigint;\n /** keccak256(abi.encode(calls)) binding the coordinator calls array */\n callsHash: string;\n}\n\n/**\n * EIP-712 typed data structure for CollabRefund.\n *\n * Compatible with viem/wagmi's `signTypedData` and `eth_signTypedData_v4`.\n */\nexport interface CollabRefundEvmTypedData {\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: string;\n };\n types: {\n CollabRefund: Array<{ name: string; type: string }>;\n };\n primaryType: \"CollabRefund\";\n message: {\n preimageHash: string;\n amount: bigint;\n token: string;\n claimAddress: string;\n timelock: bigint;\n caller: string;\n sweepToken: string;\n minAmountOut: bigint;\n callsHash: string;\n };\n}\n\n/**\n * Builds the EIP-712 digest for collaborative EVM HTLC refund.\n *\n * The depositor signs this digest to authorize the server to submit\n * `collabRefundTo` or `collabRefundAndExecute` on the coordinator.\n *\n * @param params - CollabRefund parameters\n * @returns The 32-byte digest as hex string with 0x prefix\n */\nexport function buildCollabRefundEvmDigest(\n params: CollabRefundEvmDigestParams,\n): string {\n // Coordinator domain separator\n const domainSeparator = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(EIP712_DOMAIN_TYPEHASH)),\n },\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(COORDINATOR_NAME)),\n },\n {\n type: \"bytes32\",\n value: keccak256(\n stringToUtf8Bytes(\n String(params.coordinatorVersion ?? COORDINATOR_VERSION),\n ),\n ),\n },\n { type: \"uint256\", value: BigInt(params.chainId) },\n { type: \"address\", value: params.coordinatorAddress },\n ]),\n );\n\n // CollabRefund struct hash\n const typeHash = keccak256(stringToUtf8Bytes(COLLAB_REFUND_TYPEHASH));\n const structHash = keccak256(\n abiEncode([\n { type: \"bytes32\", value: typeHash },\n { type: \"bytes32\", value: params.preimageHash },\n { type: \"uint256\", value: params.amount },\n { type: \"address\", value: params.token },\n { type: \"address\", value: params.claimAddress },\n { type: \"uint256\", value: BigInt(params.timelock) },\n { type: \"address\", value: params.caller },\n { type: \"address\", value: params.sweepToken },\n { type: \"uint256\", value: params.minAmountOut },\n { type: \"bytes32\", value: params.callsHash },\n ]),\n );\n\n // EIP-712 digest: \\x19\\x01 ‖ domainSeparator ‖ structHash\n const prefix = new Uint8Array([0x19, 0x01]);\n const domainBytes = hexToBytes(domainSeparator);\n const structBytes = hexToBytes(structHash);\n const message = new Uint8Array(\n prefix.length + domainBytes.length + structBytes.length,\n );\n message.set(prefix, 0);\n message.set(domainBytes, prefix.length);\n message.set(structBytes, prefix.length + domainBytes.length);\n\n return keccak256(message);\n}\n\n/**\n * Builds the EIP-712 typed data structure for CollabRefund.\n *\n * For use with browser wallets via `eth_signTypedData_v4` / wagmi's `signTypedData`.\n *\n * @param params - CollabRefund parameters\n * @returns EIP-712 typed data compatible with viem/wagmi\n */\nexport function buildCollabRefundEvmTypedData(\n params: CollabRefundEvmDigestParams,\n): CollabRefundEvmTypedData {\n return {\n domain: {\n name: COORDINATOR_NAME,\n version: String(params.coordinatorVersion ?? COORDINATOR_VERSION),\n chainId: params.chainId,\n verifyingContract: params.coordinatorAddress,\n },\n types: {\n CollabRefund: [\n { name: \"preimageHash\", type: \"bytes32\" },\n { name: \"amount\", type: \"uint256\" },\n { name: \"token\", type: \"address\" },\n { name: \"claimAddress\", type: \"address\" },\n { name: \"timelock\", type: \"uint256\" },\n { name: \"caller\", type: \"address\" },\n { name: \"sweepToken\", type: \"address\" },\n { name: \"minAmountOut\", type: \"uint256\" },\n { name: \"callsHash\", type: \"bytes32\" },\n ],\n },\n primaryType: \"CollabRefund\",\n message: {\n preimageHash: params.preimageHash,\n amount: params.amount,\n token: params.token,\n claimAddress: params.claimAddress,\n timelock: BigInt(params.timelock),\n caller: params.caller,\n sweepToken: params.sweepToken,\n minAmountOut: params.minAmountOut,\n callsHash: params.callsHash,\n },\n };\n}\n\n// ── Permit2 constants ─────────────────────────────────────────────────────────\n\n/** Canonical Permit2 deployment address (same on all EVM chains) */\nexport const PERMIT2_ADDRESS = \"0x000000000022D473030F116dDEE9F6B43aC78BA3\";\n\n// Permit2 uses a simpler domain: EIP712Domain(string name, uint256 chainId, address verifyingContract)\nconst PERMIT2_DOMAIN_TYPEHASH =\n \"EIP712Domain(string name,uint256 chainId,address verifyingContract)\";\n\nconst PERMIT2_NAME = \"Permit2\";\n\n// Full type string for permitWitnessTransferFrom — includes sub-types alphabetically\nconst PERMIT_WITNESS_TRANSFER_FROM_TYPEHASH =\n \"PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,ExecuteAndCreate witness)\" +\n \"ExecuteAndCreate(bytes32 preimageHash,address token,address claimAddress,address refundAddress,uint256 timelock,bytes32 callsHash)\" +\n \"TokenPermissions(address token,uint256 amount)\";\n\nconst TOKEN_PERMISSIONS_TYPEHASH =\n \"TokenPermissions(address token,uint256 amount)\";\n\nconst EXECUTE_AND_CREATE_WITNESS_TYPEHASH =\n \"ExecuteAndCreate(bytes32 preimageHash,address token,address claimAddress,address refundAddress,uint256 timelock,bytes32 callsHash)\";\n\n// ── Permit2 interfaces ───────────────────────────────────────────────────────\n\n/** Parameters for building the Permit2 EIP-712 digest */\nexport interface Permit2FundingParams {\n /** EVM chain ID */\n chainId: number;\n /** HTLCCoordinator contract address (the spender) */\n coordinatorAddress: string;\n /** Source token address (what user holds, e.g. USDC) */\n sourceToken: string;\n /** Source amount in smallest units */\n sourceAmount: bigint;\n /** SHA-256 preimage hash (0x-prefixed, 32 bytes) */\n preimageHash: string;\n /** Lock token address (WBTC — the token field in the witness) */\n lockToken: string;\n /** Server's claim address */\n claimAddress: string;\n /** Refund address — coordinator address for overload 1 (depositor tracking) */\n refundAddress: string;\n /** HTLC timelock (unix timestamp) */\n timelock: number;\n /** keccak256(abi.encode(calls)) — binds the calls array in the witness */\n callsHash: string;\n /** Random Permit2 nonce (one-use) */\n nonce: bigint;\n /** Signature expiry timestamp */\n deadline: bigint;\n}\n\n/** Result of building Permit2-based coordinator funding call data */\nexport interface Permit2SignedFundingCallData {\n /** One-time approve: source token → Permit2 (max uint256) */\n approve: { to: string; data: string };\n /** The executeAndCreateWithPermit2 tx */\n executeAndCreate: { to: string; data: string };\n}\n\n/**\n * EIP-712 typed data structure for Permit2 permitWitnessTransferFrom.\n *\n * Compatible with viem/wagmi's `signTypedData` and `eth_signTypedData_v4`.\n * Used in the sovereign flow where the user's browser wallet signs\n * the Permit2 message directly.\n */\nexport interface Permit2TypedData {\n domain: {\n name: string;\n chainId: number;\n verifyingContract: string;\n };\n types: {\n PermitWitnessTransferFrom: Array<{ name: string; type: string }>;\n TokenPermissions: Array<{ name: string; type: string }>;\n ExecuteAndCreate: Array<{ name: string; type: string }>;\n };\n primaryType: \"PermitWitnessTransferFrom\";\n message: {\n permitted: { token: string; amount: bigint };\n spender: string;\n nonce: bigint;\n deadline: bigint;\n witness: {\n preimageHash: string;\n token: string;\n claimAddress: string;\n refundAddress: string;\n timelock: bigint;\n callsHash: string;\n };\n };\n}\n\n/** Unsigned Permit2 funding data returned by `getPermit2FundingParamsUnsigned`. */\nexport interface UnsignedPermit2FundingData {\n /** Coordinator contract address */\n coordinatorAddress: string;\n /** The lock's sender: the depositor on HTLCErc20 v7 / HTLCNative v2, the coordinator before. */\n lockSender: string;\n /** The HTLC the coordinator creates the swap on. */\n htlcAddress: string;\n /** Source token address */\n sourceTokenAddress: string;\n /** Source amount in smallest units */\n sourceAmount: bigint;\n /** Lock token address (WBTC) */\n lockTokenAddress: string;\n /** Preimage hash */\n preimageHash: string;\n /** Server's claim address */\n claimAddress: string;\n /** HTLC timelock */\n timelock: number;\n /** Calls array for the coordinator */\n calls: CoordinatorCall[];\n /** Calls hash */\n callsHash: string;\n /** Random Permit2 nonce */\n nonce: bigint;\n /** Signature deadline */\n deadline: bigint;\n /** EIP-712 typed data for wallet signing (pass to signTypedData) */\n typedData: Permit2TypedData;\n}\n\n// ── Permit2 EIP-712 digest ───────────────────────────────────────────────────\n\n/**\n * Builds the EIP-712 digest for Permit2 `permitWitnessTransferFrom` with\n * an `ExecuteAndCreate` witness.\n *\n * The user signs this digest to authorize the coordinator to pull their\n * source tokens via Permit2 and execute the swap + HTLC creation.\n *\n * @param params - The Permit2 funding parameters\n * @returns The 32-byte digest as hex string with 0x prefix\n */\nexport function buildPermit2FundingDigest(\n params: Permit2FundingParams,\n): string {\n // 1. Permit2 domain separator (simpler than standard EIP-712 — no version)\n const domainSeparator = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(PERMIT2_DOMAIN_TYPEHASH)),\n },\n { type: \"bytes32\", value: keccak256(stringToUtf8Bytes(PERMIT2_NAME)) },\n { type: \"uint256\", value: BigInt(params.chainId) },\n { type: \"address\", value: PERMIT2_ADDRESS },\n ]),\n );\n\n // 2. TokenPermissions hash\n const tokenPermissionsHash = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(stringToUtf8Bytes(TOKEN_PERMISSIONS_TYPEHASH)),\n },\n { type: \"address\", value: params.sourceToken },\n { type: \"uint256\", value: params.sourceAmount },\n ]),\n );\n\n // 3. ExecuteAndCreate witness hash\n const witnessHash = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(\n stringToUtf8Bytes(EXECUTE_AND_CREATE_WITNESS_TYPEHASH),\n ),\n },\n { type: \"bytes32\", value: params.preimageHash },\n { type: \"address\", value: params.lockToken },\n { type: \"address\", value: params.claimAddress },\n { type: \"address\", value: params.refundAddress },\n { type: \"uint256\", value: BigInt(params.timelock) },\n { type: \"bytes32\", value: params.callsHash },\n ]),\n );\n\n // 4. Struct hash: PermitWitnessTransferFrom(tokenPermissionsHash, spender, nonce, deadline, witnessHash)\n const structHash = keccak256(\n abiEncode([\n {\n type: \"bytes32\",\n value: keccak256(\n stringToUtf8Bytes(PERMIT_WITNESS_TRANSFER_FROM_TYPEHASH),\n ),\n },\n { type: \"bytes32\", value: tokenPermissionsHash },\n { type: \"address\", value: params.coordinatorAddress },\n { type: \"uint256\", value: params.nonce },\n { type: \"uint256\", value: params.deadline },\n { type: \"bytes32\", value: witnessHash },\n ]),\n );\n\n // 5. EIP-712 digest: \\x19\\x01 ‖ domainSeparator ‖ structHash\n const prefix = new Uint8Array([0x19, 0x01]);\n const domainBytes = hexToBytes(domainSeparator);\n const structBytes = hexToBytes(structHash);\n const message = new Uint8Array(\n prefix.length + domainBytes.length + structBytes.length,\n );\n message.set(prefix, 0);\n message.set(domainBytes, prefix.length);\n message.set(structBytes, prefix.length + domainBytes.length);\n\n return keccak256(message);\n}\n\n// ── Permit2 typed data for wallet signing ──────────────────────────────────\n\n/**\n * Builds the EIP-712 typed data structure for Permit2 `permitWitnessTransferFrom`\n * with an `ExecuteAndCreate` witness.\n *\n * This is intended for the \"sovereign\" flow where the user's browser wallet\n * signs the Permit2 message via `eth_signTypedData_v4` / wagmi's `signTypedData`.\n *\n * @param params - The Permit2 funding parameters\n * @returns EIP-712 typed data compatible with viem/wagmi's `signTypedData`\n *\n * @example\n * ```ts\n * const typedData = buildPermit2TypedData(params);\n * // In the browser with wagmi:\n * const signature = await walletClient.signTypedData(typedData);\n * ```\n */\nexport function buildPermit2TypedData(\n params: Permit2FundingParams,\n): Permit2TypedData {\n return {\n domain: {\n name: PERMIT2_NAME,\n chainId: params.chainId,\n verifyingContract: PERMIT2_ADDRESS,\n },\n types: {\n PermitWitnessTransferFrom: [\n { name: \"permitted\", type: \"TokenPermissions\" },\n { name: \"spender\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"witness\", type: \"ExecuteAndCreate\" },\n ],\n TokenPermissions: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n ExecuteAndCreate: [\n { name: \"preimageHash\", type: \"bytes32\" },\n { name: \"token\", type: \"address\" },\n { name: \"claimAddress\", type: \"address\" },\n { name: \"refundAddress\", type: \"address\" },\n { name: \"timelock\", type: \"uint256\" },\n { name: \"callsHash\", type: \"bytes32\" },\n ],\n },\n primaryType: \"PermitWitnessTransferFrom\",\n message: {\n permitted: {\n token: params.sourceToken,\n amount: params.sourceAmount,\n },\n spender: params.coordinatorAddress,\n nonce: params.nonce,\n deadline: params.deadline,\n witness: {\n preimageHash: params.preimageHash,\n token: params.lockToken,\n claimAddress: params.claimAddress,\n refundAddress: params.refundAddress,\n timelock: BigInt(params.timelock),\n callsHash: params.callsHash,\n },\n },\n };\n}\n\n// ── executeAndCreateWithPermit2 selector (overload 1: depositor tracking) ────\n// keccak256(\"executeAndCreateWithPermit2((address,uint256,bytes)[],bytes32,address,address,uint256,address,((address,uint256),uint256,uint256),bytes)\")\nconst EXECUTE_AND_CREATE_WITH_PERMIT2_SELECTOR = keccak256(\n stringToUtf8Bytes(\n \"executeAndCreateWithPermit2((address,uint256,bytes)[],bytes32,address,address,uint256,address,((address,uint256),uint256,uint256),bytes)\",\n ),\n).slice(0, 10);\n\n// ── executeAndCreateWithPermit2 calldata ─────────────────────────────────────\n\n/** Parameters for encoding executeAndCreateWithPermit2 call data */\nexport interface ExecuteAndCreateWithPermit2Params {\n /** Array of calls to execute (approve DEX + DEX swap) */\n calls: CoordinatorCall[];\n /** SHA-256 preimage hash (32-byte hex with 0x prefix) */\n preimageHash: string;\n /** Lock token address (WBTC) */\n token: string;\n /** Server's claim address */\n claimAddress: string;\n /** HTLC timelock (unix timestamp) */\n timelock: number;\n /** Depositor address (the user whose tokens are pulled via Permit2) */\n depositor: string;\n /** Source token address (permitted token in the Permit2 struct) */\n sourceToken: string;\n /** Source amount (permitted amount) */\n sourceAmount: bigint;\n /** Permit2 nonce */\n nonce: bigint;\n /** Permit2 deadline */\n deadline: bigint;\n /** Signature bytes (compact 65-byte: r || s || v) */\n signature: string;\n /** On-chain depositor code. Only explicit empty code permits EOA normalization. */\n depositorCode?: string;\n}\n\n/** Normalize only signatures belonging to a verified code-free Permit2 owner. */\nexport function normalizePermit2Signature(\n signature: string,\n depositorCode?: string,\n): string {\n // Missing code is unknown, not evidence of an EOA. In particular, 7702\n // delegation markers and ERC-1271 signatures must remain opaque.\n if (depositorCode !== \"0x\") return signature;\n const hex = signature.startsWith(\"0x\") ? signature.slice(2) : signature;\n if (\n !/^[0-9a-fA-F]+$/.test(hex) ||\n (hex.length !== 128 && hex.length !== 130)\n ) {\n throw new Error(\"Invalid Permit2 EOA signature: expected 64 or 65 bytes\");\n }\n if (hex.length === 128) return signature;\n const v = Number.parseInt(hex.slice(-2), 16);\n if (v === 27 || v === 28) return signature;\n if (v !== 0 && v !== 1) {\n throw new Error(\n \"Invalid Permit2 EOA signature: recovery byte must be 0, 1, 27 or 28\",\n );\n }\n return signature.slice(0, -2) + (v + 27).toString(16);\n}\n\n/**\n * Encodes the call data for `coordinator.executeAndCreateWithPermit2(...)` (overload 1).\n *\n * Overload 1 uses depositor tracking: the coordinator becomes the HTLC sender,\n * enabling server-side refundTo for expired swaps.\n *\n * Signature: executeAndCreateWithPermit2(\n * Call[] calls,\n * bytes32 preimageHash,\n * address token,\n * address claimAddress,\n * uint256 timelock,\n * address depositor,\n * ((address,uint256),uint256,uint256) permit,\n * bytes signature\n * )\n *\n * @param coordinatorAddress - The HTLCCoordinator contract address\n * @param params - All parameters for the call\n * @returns The encoded call data\n */\nexport function encodeExecuteAndCreateWithPermit2(\n coordinatorAddress: string,\n params: ExecuteAndCreateWithPermit2Params,\n): ExecuteAndCreateCallData {\n // ABI head layout (11 words):\n // 0: calls offset (dynamic → pointer)\n // 1: preimageHash (bytes32)\n // 2: token (address)\n // 3: claimAddress (address)\n // 4: timelock (uint256)\n // 5: depositor (address)\n // 6: permit.permitted.token (address) ← inline static struct\n // 7: permit.permitted.amount (uint256) ← inline\n // 8: permit.nonce (uint256) ← inline\n // 9: permit.deadline (uint256) ← inline\n // 10: signature offset (dynamic → pointer)\n //\n // Tail:\n // calls data\n // signature data (length + padded bytes)\n const HEAD_WORDS = 11n;\n\n const preimageHash = normalizeBytes32(params.preimageHash);\n const token = normalizeAddress(params.token);\n const claimAddress = normalizeAddress(params.claimAddress);\n const timelock = encodeUint256(BigInt(params.timelock));\n const depositor = normalizeAddress(params.depositor);\n\n // Permit struct fields (encoded inline in the head)\n const permitToken = normalizeAddress(params.sourceToken);\n const permitAmount = encodeUint256(params.sourceAmount);\n const permitNonce = encodeUint256(params.nonce);\n const permitDeadline = encodeUint256(params.deadline);\n\n // Encode the calls array (tail)\n const callsEncoded = encodeCalls(params.calls);\n const callsEncodedBytes = BigInt(callsEncoded.length / 2);\n\n // Encode signature as dynamic bytes (tail)\n const signature = normalizePermit2Signature(\n params.signature,\n params.depositorCode,\n );\n const sigClean = signature.startsWith(\"0x\") ? signature.slice(2) : signature;\n const sigLength = sigClean.length / 2;\n const sigPaddedLength = Math.ceil(sigLength / 32) * 32;\n const signatureEncoded =\n encodeUint256(BigInt(sigLength)) +\n sigClean.padEnd(sigPaddedLength * 2, \"0\");\n\n // Compute offsets (relative to start of params, after selector)\n const callsOffset = HEAD_WORDS * 32n;\n const signatureOffset = callsOffset + callsEncodedBytes;\n\n const data = [\n EXECUTE_AND_CREATE_WITH_PERMIT2_SELECTOR,\n encodeUint256(callsOffset), // 0: calls offset\n preimageHash, // 1: preimageHash\n token, // 2: token\n claimAddress, // 3: claimAddress\n timelock, // 4: timelock\n depositor, // 5: depositor\n permitToken, // 6: permit.permitted.token\n permitAmount, // 7: permit.permitted.amount\n permitNonce, // 8: permit.nonce\n permitDeadline, // 9: permit.deadline\n encodeUint256(signatureOffset), // 10: signature offset\n callsEncoded, // tail: calls data\n signatureEncoded, // tail: signature data\n ].join(\"\");\n\n return {\n to: coordinatorAddress,\n data,\n functionSignature:\n \"executeAndCreateWithPermit2((address,uint256,bytes)[],bytes32,address,address,uint256,address,((address,uint256),uint256,uint256),bytes)\",\n };\n}\n\n// ── EIP-2612 Permit digest ───────────────────────────────────────────────────\n\n/** Parameters for building the EIP-2612 permit digest */\nexport interface Eip2612PermitParams {\n /** Token's EIP-712 domain separator (0x-prefixed, from token.DOMAIN_SEPARATOR()) */\n domainSeparator: string;\n /** Token owner address */\n owner: string;\n /** Spender address (typically Permit2) */\n spender: string;\n /** Approval amount */\n value: bigint;\n /** Token nonce for the owner (from token.nonces(owner)) */\n nonce: number;\n /** Signature deadline (unix timestamp) */\n deadline: bigint;\n}\n\n/**\n * Builds the EIP-712 digest for an EIP-2612 token permit.\n *\n * This is the standard ERC-2612 permit signature that allows gasless\n * token approvals. The user signs this to let `spender` (Permit2) spend\n * their tokens without an on-chain approve transaction.\n *\n * @param params - The EIP-2612 permit parameters\n * @returns The 32-byte digest as hex string with 0x prefix\n */\nexport function buildEip2612PermitDigest(params: Eip2612PermitParams): string {\n const PERMIT_TYPEHASH = keccak256(\n stringToUtf8Bytes(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\",\n ),\n );\n const structHash = keccak256(\n abiEncode([\n { type: \"bytes32\", value: PERMIT_TYPEHASH },\n { type: \"address\", value: params.owner },\n { type: \"address\", value: params.spender },\n { type: \"uint256\", value: params.value },\n { type: \"uint256\", value: BigInt(params.nonce) },\n { type: \"uint256\", value: params.deadline },\n ]),\n );\n\n // EIP-712 digest: 0x1901 || domainSeparator || structHash\n const prefix = new Uint8Array([0x19, 0x01]);\n const domainBytes = hexToBytes(params.domainSeparator);\n const structBytes = hexToBytes(structHash);\n const message = new Uint8Array(\n prefix.length + domainBytes.length + structBytes.length,\n );\n message.set(prefix, 0);\n message.set(domainBytes, prefix.length);\n message.set(structBytes, prefix.length + domainBytes.length);\n\n return keccak256(message);\n}\n\n// ── Internal encoding helpers ────────────────────────────────────────────────\n\n/** Encode ERC20 approve(address,uint256) call data */\nfunction encodeApprove(spender: string, amount: bigint): string {\n const selector = \"0x095ea7b3\";\n return `${selector}${normalizeAddress(spender)}${encodeUint256(amount)}`;\n}\n\n/** Encode the dynamic (address,uint256,bytes)[] array for ABI */\nfunction encodeCalls(calls: CoordinatorCall[]): string {\n // Array length\n const length = encodeUint256(BigInt(calls.length));\n\n if (calls.length === 0) {\n return length;\n }\n\n // Each element is a tuple (address, uint256, bytes) — a dynamic type.\n // We encode offsets first, then each element's data.\n\n // Calculate offsets: each element offset is relative to the start of the array data\n // (after the length word). First we have N offset words, then the actual data.\n const elementDataParts: string[] = [];\n const offsets: bigint[] = [];\n\n // First pass: encode each element and compute sizes\n for (const call of calls) {\n const encoded = encodeSingleCall(call);\n elementDataParts.push(encoded);\n }\n\n // Compute offsets: offset[0] = N * 32, offset[i] = offset[i-1] + size(element[i-1])\n let currentOffset = BigInt(calls.length) * 32n;\n for (let i = 0; i < calls.length; i++) {\n offsets.push(currentOffset);\n // Each encoded element is hex chars / 2 = bytes\n currentOffset += BigInt(elementDataParts[i].length / 2);\n }\n\n const offsetsEncoded = offsets.map((o) => encodeUint256(o)).join(\"\");\n const dataEncoded = elementDataParts.join(\"\");\n\n return length + offsetsEncoded + dataEncoded;\n}\n\n/** Encode a single (address, uint256, bytes) tuple */\nfunction encodeSingleCall(call: CoordinatorCall): string {\n const target = normalizeAddress(call.target);\n const value = encodeUint256(call.value);\n\n // bytes is dynamic: offset (32 bytes) + length (32 bytes) + padded data\n const bytesOffset = encodeUint256(3n * 32n); // offset after target, value, and this offset word\n\n const callData = call.data.startsWith(\"0x\") ? call.data.slice(2) : call.data;\n const dataLength = callData.length / 2;\n const bytesLength = encodeUint256(BigInt(dataLength));\n\n // Pad data to 32-byte boundary\n const paddedLength = Math.ceil(dataLength / 32) * 32;\n const paddedData = callData.padEnd(paddedLength * 2, \"0\");\n\n return target + value + bytesOffset + bytesLength + paddedData;\n}\n\n// ── Low-level ABI encoding ───────────────────────────────────────────────────\n\ninterface AbiValue {\n type: \"bytes32\" | \"uint256\" | \"address\";\n value: string | bigint;\n}\n\nfunction abiEncode(values: AbiValue[]): string {\n return values\n .map((v) => {\n switch (v.type) {\n case \"bytes32\":\n return normalizeBytes32(v.value as string);\n case \"uint256\":\n return encodeUint256(v.value as bigint);\n case \"address\":\n return normalizeAddress(v.value as string);\n default:\n throw new Error(`Unknown ABI type: ${v.type}`);\n }\n })\n .join(\"\");\n}\n\nfunction normalizeAddress(address: string): string {\n const clean = address.replace(/^0x/, \"\").toLowerCase();\n return clean.padStart(64, \"0\");\n}\n\nfunction encodeUint256(value: bigint): string {\n return value.toString(16).padStart(64, \"0\");\n}\n\n// ── Hex / bytes utilities ────────────────────────────────────────────────────\n\nfunction hexToBytes(hex: string): Uint8Array {\n return nobleFromHex(hex.replace(/^0x/, \"\"));\n}\n\nfunction bytesToHex(bytes: Uint8Array): string {\n return nobleToHex(bytes);\n}\n\nfunction stringToUtf8Bytes(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n","/**\n * Binds a server funding payload (`swap-and-lock-calldata-permit2` /\n * `-userop`) to the swap this client created, before anything is signed.\n *\n * The payload names the Permit2 spender (the coordinator), the token it\n * locks and the calls the coordinator runs while it holds the deposit. A\n * server naming its own contract as spender, or a call handing the deposit\n * to itself, would drain the input without creating the swap's lock. So\n * the spender, HTLC, claimer, timelock and lock token come from the swap's\n * creation response, recorded here, the amount is bounded by its input,\n * and the calls are restricted. What gets signed is built from those terms,\n * not from the payload.\n */\n\nimport { computeCoordinatorCallsHash, PERMIT2_ADDRESS } from \"./coordinator.js\";\nimport { normalizeBytes32 } from \"./htlc.js\";\nimport { decodeUint256 } from \"./wallet.js\";\n\n/**\n * What an EVM-sourced swap's funding must use, recorded from its creation\n * response and never updated from a later server answer.\n */\nexport interface EvmFundingTerms {\n chainId: number;\n /** The coordinator: the Permit2 spender. */\n coordinator: string;\n htlcAddress: string;\n htlcKind?: string;\n htlcVersion?: number;\n /** The server's address: the lock's claimer and the relay fee's payee. */\n claimAddress: string;\n timelock: number;\n /** The token the user pays with, on the chain the lock is on. */\n sourceToken: string;\n /** The input the user agreed to at creation, in the token's base units. */\n sourceAmount: string;\n /**\n * The token the coordinator locks. EVM → Arkade responses name none;\n * the payload's is then signed (the coordinator locks only the token the\n * witness names, so nothing else is at risk).\n */\n lockToken?: string;\n}\n\n/**\n * Optional pins on top of the recorded terms, never instead of them.\n */\nexport interface FundingPins {\n /**\n * Contracts the coordinator may call, and the only spenders an approval\n * of the input may name. Without it any target outside the source and\n * lock token is allowed (the SDK knows no router set) and an approval of\n * the input must name the target of a later call in the batch.\n */\n allowedCallTargets?: readonly string[];\n /**\n * Largest input the funding may take. Defaults to the input recorded at\n * creation; a payout-pinned swap re-quoted above it needs this raised.\n */\n maxSourceAmount?: bigint;\n /**\n * Largest relay fee (in source-token base units) the server may take from\n * the input as a transfer to itself. Defaults to 0: no fee.\n */\n maxRelayFee?: bigint;\n}\n\n/**\n * What a funding of one swap must match: the hash lock this client fixed\n * and the terms it recorded at creation, plus optional pins. Get it with\n * `Client.getEvmFundingExpectation`.\n */\nexport interface ExpectedFunding {\n hashLock: string;\n terms: EvmFundingTerms;\n pins?: FundingPins;\n}\n\n/** The parts of a funding payload the checks read. */\nexport interface FundingPayload {\n coordinator_address: string;\n permit2_address?: string;\n source_token_address: string;\n source_amount: string;\n lock_token_address: string;\n preimage_hash: string;\n claim_address: string;\n timelock: number;\n calls: Array<{ target: string; value: string; call_data: string }>;\n calls_hash: string;\n relay_fee?: string;\n}\n\n/** A payload checked against the swap, with what may be signed. */\nexport interface CheckedFunding {\n coordinator: string;\n htlcAddress: string;\n sourceToken: string;\n sourceAmount: bigint;\n lockToken: string;\n preimageHash: string;\n claimAddress: string;\n timelock: number;\n htlcKind?: string;\n htlcVersion?: number;\n calls: Array<{ target: string; value: bigint; data: string }>;\n /** Recomputed from `calls`. */\n callsHash: string;\n}\n\n// transfer(address,uint256), approve(address,uint256)\nconst TRANSFER_SELECTOR = \"0xa9059cbb\";\nconst APPROVE_SELECTOR = \"0x095ea7b3\";\n\nconst lower = (address: string) => address.toLowerCase();\nconst sameHash = (a: string, b: string) =>\n normalizeBytes32(a) === normalizeBytes32(b);\n\nfunction refuse(reason: string): never {\n throw new Error(`Refusing the server's funding: ${reason}`);\n}\n\n/** Decodes `selector(address,uint256)` calldata, or undefined. */\nfunction addressAmount(\n data: string,\n selector: string,\n): { to: string; amount: bigint } | undefined {\n const clean = data.toLowerCase();\n if (!clean.startsWith(selector) || clean.length !== 10 + 128) {\n return undefined;\n }\n const word = clean.slice(10, 74);\n if (!/^0{24}/.test(word)) return undefined;\n return {\n to: `0x${word.slice(24)}`,\n amount: decodeUint256(clean.slice(74)),\n };\n}\n\n/**\n * Checks `payload` against `terms` (and the hash lock this client fixed)\n * and returns what may be signed. Throws before anything is signed for a\n * payload naming another spender, HTLC party, timelock, hash or lock token,\n * an amount above the input, or calls that could move the deposit.\n */\nexport function checkFundingPayload(\n terms: EvmFundingTerms,\n hashLock: string,\n payload: FundingPayload,\n pins: FundingPins = {},\n): CheckedFunding {\n if (lower(payload.coordinator_address) !== lower(terms.coordinator)) {\n refuse(\n `it names spender ${payload.coordinator_address}, not the swap's coordinator ${terms.coordinator}`,\n );\n }\n if (\n payload.permit2_address !== undefined &&\n lower(payload.permit2_address) !== lower(PERMIT2_ADDRESS)\n ) {\n refuse(`it names Permit2 at ${payload.permit2_address}`);\n }\n if (!sameHash(payload.preimage_hash, hashLock)) {\n refuse(\n `it locks under hash ${payload.preimage_hash}, not the swap's ${hashLock}`,\n );\n }\n if (lower(payload.claim_address) !== lower(terms.claimAddress)) {\n refuse(\n `it names claimer ${payload.claim_address}, not the swap's ${terms.claimAddress}`,\n );\n }\n if (payload.timelock !== terms.timelock) {\n refuse(\n `it names timelock ${payload.timelock}, not the swap's ${terms.timelock}`,\n );\n }\n if (lower(payload.source_token_address) !== lower(terms.sourceToken)) {\n refuse(\n `it takes ${payload.source_token_address}, not the swap's source token ${terms.sourceToken}`,\n );\n }\n const lockToken = terms.lockToken ?? payload.lock_token_address;\n if (lower(payload.lock_token_address) !== lower(lockToken)) {\n refuse(\n `it locks ${payload.lock_token_address}, not the swap's lock token ${lockToken}`,\n );\n }\n const sourceAmount = BigInt(payload.source_amount);\n const limit = pins.maxSourceAmount ?? BigInt(terms.sourceAmount);\n if (sourceAmount <= 0n || sourceAmount > limit) {\n refuse(`it takes ${sourceAmount}, more than the input ${limit}`);\n }\n const calls = payload.calls.map((call) => ({\n target: call.target,\n value: BigInt(call.value),\n data: call.call_data,\n }));\n const callsHash = computeCoordinatorCallsHash(calls);\n if (!sameHash(callsHash, payload.calls_hash)) {\n refuse(\"its calls hash does not match its calls\");\n }\n checkCalls(calls, {\n sourceToken: lower(terms.sourceToken),\n lockToken: lower(lockToken),\n feePayee: lower(terms.claimAddress),\n amount: sourceAmount,\n quotedFee:\n payload.relay_fee === undefined ? undefined : BigInt(payload.relay_fee),\n maxRelayFee: pins.maxRelayFee ?? 0n,\n allowed: pins.allowedCallTargets?.map(lower),\n });\n return {\n coordinator: terms.coordinator,\n htlcAddress: terms.htlcAddress,\n sourceToken: terms.sourceToken,\n sourceAmount,\n lockToken,\n preimageHash: `0x${normalizeBytes32(hashLock)}`,\n claimAddress: terms.claimAddress,\n timelock: terms.timelock,\n htlcKind: terms.htlcKind,\n htlcVersion: terms.htlcVersion,\n calls,\n callsHash,\n };\n}\n\n/**\n * The coordinator runs these calls holding the pulled input. No call may\n * carry native value. A call on the source token may only be the relay fee\n * (first, a transfer to the server within the cap and equal to the quoted\n * fee) or an approval of at most the input to a router the batch calls (or\n * a pinned one). No call may touch the lock token unless it is the source\n * token, which follows the same rule. Other targets must be pinned when\n * pins are given.\n */\nfunction checkCalls(\n calls: Array<{ target: string; value: bigint; data: string }>,\n context: {\n sourceToken: string;\n lockToken: string;\n feePayee: string;\n amount: bigint;\n quotedFee?: bigint;\n maxRelayFee: bigint;\n allowed?: string[];\n },\n): void {\n const targets = calls.map((call) => lower(call.target));\n calls.forEach((call, index) => {\n const target = targets[index];\n if (call.value !== 0n) refuse(`call ${index} sends native value`);\n if (target === context.lockToken && target !== context.sourceToken) {\n refuse(`call ${index} calls the lock token`);\n }\n if (target !== context.sourceToken) {\n if (context.allowed && !context.allowed.includes(target)) {\n refuse(`call ${index} targets ${call.target}, which is not pinned`);\n }\n return;\n }\n const fee =\n index === 0 ? addressAmount(call.data, TRANSFER_SELECTOR) : undefined;\n if (fee) {\n if (\n fee.to !== context.feePayee ||\n fee.amount > context.maxRelayFee ||\n (context.quotedFee !== undefined && fee.amount !== context.quotedFee)\n ) {\n refuse(\n `call 0 transfers ${fee.amount} of the input to ${fee.to}; only a relay fee of at most ${context.maxRelayFee} to the server is allowed`,\n );\n }\n return;\n }\n const approval = addressAmount(call.data, APPROVE_SELECTOR);\n if (!approval) {\n refuse(\n `call ${index} calls the source token for something other than a relay fee or an approval`,\n );\n }\n const spenderCalled = context.allowed\n ? context.allowed.includes(approval.to)\n : targets.slice(index + 1).includes(approval.to);\n if (approval.amount > context.amount || !spenderCalled) {\n refuse(\n `call ${index} approves ${approval.amount} of the input to ${approval.to}, ${\n approval.amount > context.amount\n ? \"more than the input\"\n : context.allowed\n ? \"which is not pinned\"\n : \"which the batch never calls\"\n }`,\n );\n }\n });\n}\n","/**\n * Compose the `executeBatch` calldata for a CCTP-inbound UserOperation.\n *\n * The smart account's batch atomically runs:\n * 1. `MessageTransmitter.receiveMessage(message, attestation)` — mints\n * USDC to the smart account.\n * 2. `USDC.approve(Permit2, max)` — idempotent.\n * 3. `HTLCCoordinator.executeAndCreateWithPermit2(...)` — uses an\n * ERC-1271 signature from the smart account as `depositor`.\n *\n * All three calls execute with `msg.sender = smartAccount`, so CCTPv2's\n * `destinationCaller` gate (pinned to the same address on the burn) is\n * satisfied.\n */\n\nimport type { Address, Hex, TypedDataDomain } from \"viem\";\nimport {\n encodeAbiParameters,\n encodeFunctionData,\n isErc6492Signature,\n maxUint256,\n parseAbi,\n parseErc6492Signature,\n} from \"viem\";\nimport { buildPermit2TypedData } from \"../evm/coordinator.js\";\nimport {\n checkFundingPayload,\n type ExpectedFunding,\n} from \"../evm/funding-pins.js\";\nimport { depositorIsSender } from \"../evm/htlc.js\";\n\n/** MessageTransmitter v2 — same on every CCTPv2 EVM chain. */\nconst MESSAGE_TRANSMITTER_V2 =\n \"0x81D40F21F12A8F0E3252Bccb954D722d4c464B64\" as const;\n\n/** Canonical Permit2 deployment — same on all EVM chains. */\nexport const PERMIT2_ADDRESS =\n \"0x000000000022D473030F116dDEE9F6B43aC78BA3\" as const;\n\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) external returns (bool)\",\n]);\n\nconst ERC20_APPROVE_ABI = parseAbi([\n \"function approve(address spender, uint256 amount) external returns (bool)\",\n]);\n\nconst HTLC_COORDINATOR_ABI = parseAbi([\n \"struct TokenPermissions { address token; uint256 amount; }\",\n \"struct PermitTransferFrom { TokenPermissions permitted; uint256 nonce; uint256 deadline; }\",\n \"struct Call { address target; uint256 value; bytes callData; }\",\n \"function executeAndCreateWithPermit2(Call[] calls, bytes32 preimageHash, address token, address claimAddress, uint256 timelock, address depositor, PermitTransferFrom permit, bytes signature) external\",\n]);\n\n/**\n * Shape returned by the backend's\n * `GET /v1/swap/:id/swap-and-lock-calldata-userop` endpoint.\n * Field names match the REST JSON (snake_case).\n */\nexport interface UseropCalldataResponse {\n coordinator_address: string;\n /** HTLC family and VERSION; from HTLCErc20 v7 / HTLCNative v2 the witness names the depositor. */\n htlc_kind?: string;\n htlc_version?: number;\n permit2_address: string;\n source_token_address: string;\n source_amount: string;\n lock_token_address: string;\n preimage_hash: string;\n claim_address: string;\n timelock: number;\n calls: Array<{ target: string; value: string; call_data: string }>;\n calls_hash: string;\n relay_fee?: string;\n aa: {\n entry_point: string;\n /** Kernel implementation the depositor EOA delegates to via EIP-7702. */\n delegation_target: string;\n };\n}\n\n/**\n * Sign arbitrary EIP-712 typed data with the smart account.\n *\n * For Kernel this wraps the hash with its \"message marker\" before\n * ecrecover, so the resulting sig passes ERC-1271 verification on the\n * deployed account. Pass `kernelAccount.signTypedData` directly.\n */\n// biome-ignore lint/suspicious/noExplicitAny: typed-data shape is library-specific\nexport type SignTypedDataFn = (args: any) => Promise<Hex>;\n\nexport interface BuildCctpInboundBatchParams {\n /** Calldata payload from the backend. */\n server: UseropCalldataResponse;\n /**\n * What the funding must match: the hash lock this client fixed and the\n * terms it recorded at the swap's creation (`Client.getEvmFundingExpectation`),\n * plus optional pins. A payload naming another spender, hash, claimer,\n * timelock or token, taking more than the input, or with calls that\n * could move the deposit is refused before anything is signed, and the\n * batch is built from these terms, not from the payload.\n */\n expected: ExpectedFunding;\n /** Deterministic smart-account address that owns the HTLC deposit. */\n smartAccountAddress: Address;\n /** Produces an ERC-1271-compatible Permit2 signature via the smart account. */\n signTypedData: SignTypedDataFn;\n /** Raw IRIS message bytes (hex, 0x-prefixed). */\n cctpMessage: Hex;\n /** Raw IRIS attestation bytes (hex, 0x-prefixed). */\n cctpAttestation: Hex;\n /** Settlement chain id — used as the Permit2 domain chain id. */\n chainId: number;\n /** Whether USDC is already at `smartAccountAddress` (skip receiveMessage). */\n skipReceiveMessage?: boolean;\n /**\n * The account's current `allowance(smartAccount, Permit2)` on the source\n * token. When given, the approve step is composed from it: skipped when the\n * allowance already covers the input, and preceded by an `approve(0)` reset\n * when a smaller non-zero allowance lingers — tokens of the USDT family\n * revert a non-zero → non-zero approve. When omitted, `approve(max)` is\n * always sent (safe for USDC, whose approve overwrites).\n */\n permit2Allowance?: bigint;\n}\n\n/** A single (target, data, value) call the smart account will execute. */\nexport interface BatchCall {\n to: Address;\n data: Hex;\n value: bigint;\n}\n\nexport interface BuiltBatch {\n calls: BatchCall[];\n /** The Permit2 nonce used in the witness; useful to log / surface. */\n permit2Nonce: bigint;\n /** Deadline embedded in the Permit2 signature (unix seconds). */\n permit2Deadline: bigint;\n}\n\n/**\n * Returns the list of calls the smart account's `executeBatch` will run.\n * The Permit2 signature is produced via the Kernel smart account's\n * `signTypedData` — Kernel wraps the hash before signing so the sig\n * passes its own ERC-1271 verification once the account is deployed.\n */\nexport async function buildCctpInboundBatch(\n params: BuildCctpInboundBatchParams,\n): Promise<BuiltBatch> {\n const {\n server,\n smartAccountAddress,\n signTypedData,\n cctpMessage,\n cctpAttestation,\n chainId,\n skipReceiveMessage,\n } = params;\n if (chainId !== params.expected.terms.chainId) {\n throw new Error(\n `The swap locks on chain ${params.expected.terms.chainId}, not the settlement chain ${chainId}`,\n );\n }\n // Bound to the swap before anything is signed; everything below is built\n // from the checked terms, not from the payload.\n const checked = checkFundingPayload(\n params.expected.terms,\n params.expected.hashLock,\n server,\n params.expected.pins,\n );\n\n const calls: BatchCall[] = [];\n\n // 1. receiveMessage — skip if USDC already landed (front-runner / retry).\n if (!skipReceiveMessage) {\n const receiveMessageData = encodeFunctionData({\n abi: MESSAGE_TRANSMITTER_ABI,\n functionName: \"receiveMessage\",\n args: [cctpMessage, cctpAttestation],\n });\n calls.push({\n to: MESSAGE_TRANSMITTER_V2 as Address,\n data: receiveMessageData,\n value: 0n,\n });\n }\n\n // 2. Let Permit2 pull the input from the account. With a known allowance\n // the approve is only sent when needed, and a lingering smaller\n // non-zero allowance is reset to 0 first (USDT-family tokens revert a\n // non-zero → non-zero approve). Without one, approve(max) as before.\n const sourceAmount = checked.sourceAmount;\n const allowance = params.permit2Allowance;\n if (allowance === undefined || allowance < sourceAmount) {\n const approve = (amount: bigint) => ({\n to: checked.sourceToken as Address,\n data: encodeFunctionData({\n abi: ERC20_APPROVE_ABI,\n functionName: \"approve\",\n args: [PERMIT2_ADDRESS as Address, amount],\n }),\n value: 0n,\n });\n if (allowance !== undefined && allowance > 0n) {\n calls.push(approve(0n));\n }\n calls.push(approve(maxUint256));\n }\n\n // 3. Permit2 witness signature, produced via the smart account.\n // Kernel's signTypedData applies its message-marker wrap so the\n // resulting sig passes ERC-1271 when Permit2 calls back into the\n // (by then-deployed) account.\n const nonceBytes = new Uint8Array(32);\n crypto.getRandomValues(nonceBytes);\n const permit2Nonce = BigInt(\n `0x${Array.from(nonceBytes)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\")}`,\n );\n const permit2Deadline = BigInt(Math.floor(Date.now() / 1000) + 30 * 60);\n\n const typedData = buildPermit2TypedData({\n chainId,\n coordinatorAddress: checked.coordinator,\n sourceToken: checked.sourceToken,\n sourceAmount,\n preimageHash: checked.preimageHash,\n lockToken: checked.lockToken,\n claimAddress: checked.claimAddress,\n // The smart account is the depositor; on HTLCErc20 v7 the lock is keyed\n // under it and the witness must say so. The generation is the swap's.\n refundAddress: depositorIsSender(checked.htlcKind, checked.htlcVersion)\n ? smartAccountAddress\n : checked.coordinator,\n timelock: checked.timelock,\n callsHash: checked.callsHash,\n nonce: permit2Nonce,\n deadline: permit2Deadline,\n });\n\n const rawSignature = (await signTypedData({\n domain: typedData.domain as TypedDataDomain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })) as Hex;\n\n // viem's `toSmartAccount` auto-wraps `signTypedData` output in ERC-6492\n // whenever the account's factory/factoryData are non-empty. Permit2 is\n // not ERC-6492-aware, so strip the wrapper and pass the raw Kernel\n // signature. The account will be deployed by factoryData during the\n // UserOp *before* Permit2 verifies, so Permit2 takes the ERC-1271\n // path and Kernel's `isValidSignature` accepts the raw sig.\n const permit2Signature = isErc6492Signature(rawSignature)\n ? parseErc6492Signature(rawSignature).signature\n : rawSignature;\n\n // 4. executeAndCreateWithPermit2\n const dexCalls = checked.calls.map((c) => ({\n target: c.target as Address,\n value: c.value,\n callData: c.data as Hex,\n }));\n\n const executeData = encodeFunctionData({\n abi: HTLC_COORDINATOR_ABI,\n functionName: \"executeAndCreateWithPermit2\",\n args: [\n dexCalls,\n checked.preimageHash as Hex,\n checked.lockToken as Address,\n checked.claimAddress as Address,\n BigInt(checked.timelock),\n smartAccountAddress,\n {\n permitted: {\n token: checked.sourceToken as Address,\n amount: sourceAmount,\n },\n nonce: permit2Nonce,\n deadline: permit2Deadline,\n },\n permit2Signature,\n ],\n });\n calls.push({\n to: checked.coordinator as Address,\n data: executeData,\n value: 0n,\n });\n\n return {\n calls,\n permit2Nonce,\n permit2Deadline,\n };\n}\n\n/**\n * Convert an EVM address (20 bytes) into the bytes32 form CCTPv2's\n * `depositForBurn` expects for `mintRecipient` and `destinationCaller`.\n */\nexport function addressToBytes32Hex(address: Address): Hex {\n return encodeAbiParameters([{ type: \"address\" }], [address]) as Hex;\n}\n","/**\n * `submitUserOp` — end-to-end UserOp submission for the CCTP-inbound\n * settlement step. Composes:\n *\n * 1. Fetch HTLC/DEX calldata from the backend.\n * 2. Build a Kernel smart-account client owned by the caller's signer.\n * 3. Check the smart-account USDC balance; skip `receiveMessage` if\n * funds already landed (retry-safe).\n * 4. Compose the 3-call UserOp batch.\n * 5. Send the UserOp via the bundler; optionally wait for the\n * on-chain tx hash.\n *\n * The authoritative high-level primitive for a settlement — most\n * consumers call this (or the even-higher-level `Client.fundSwap`).\n */\n\nimport type { Address, Chain, Hex } from \"viem\";\nimport { createPublicClient, http } from \"viem\";\nimport { arbitrum } from \"viem/chains\";\nimport type { ApiClient } from \"../api/client.js\";\nimport { MESSAGE_TRANSMITTER_V2 } from \"../cctp/constants.js\";\nimport type { ExpectedFunding } from \"../evm/funding-pins.js\";\nimport type { EvmSigner } from \"../evm/wallet.js\";\nimport type { Logger, LogLevel } from \"../logging.js\";\nimport { simulateBatchCalls } from \"./preflight.js\";\nimport { createSwapSmartAccountClient } from \"./smartAccount.js\";\nimport type { AaConfig } from \"./types.js\";\nimport {\n buildCctpInboundBatch,\n PERMIT2_ADDRESS,\n type UseropCalldataResponse,\n} from \"./userOp.js\";\n\n/** `ERC20.allowance(owner, spender)`. */\nconst ALLOWANCE_ABI = [\n {\n type: \"function\",\n name: \"allowance\",\n stateMutability: \"view\",\n inputs: [\n { name: \"owner\", type: \"address\" },\n { name: \"spender\", type: \"address\" },\n ],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n] as const;\n\n/**\n * CCTPv2 burn/mint message layout (see Circle's `MessageTransmitterV2`):\n *\n * offset size field\n * 0 4 version\n * 4 4 sourceDomain\n * 8 4 destinationDomain\n * 12 32 nonce <-- what we extract\n * 44 32 sender\n * ...\n *\n * Hex-string offsets include the \"0x\" prefix and 2 chars per byte, so the\n * nonce sits at chars [26, 90).\n */\nfunction extractNonce(cctpMessage: Hex): Hex {\n return `0x${cctpMessage.slice(26, 26 + 64)}` as Hex;\n}\n\n/** `MessageTransmitterV2.usedNonces(bytes32)` — returns 0 if unused. */\nconst USED_NONCES_ABI = [\n {\n type: \"function\",\n name: \"usedNonces\",\n stateMutability: \"view\",\n inputs: [{ name: \"nonce\", type: \"bytes32\" }],\n outputs: [{ name: \"\", type: \"uint256\" }],\n },\n] as const;\n\nexport interface SubmitUserOpParams {\n /** Swap ID assigned by the backend at create time. */\n swapId: string;\n /**\n * What the funding must match: the hash lock this client fixed and the\n * terms it recorded at the swap's creation (`Client.getEvmFundingExpectation`),\n * plus optional pins. A payload naming another spender, hash, claimer,\n * timelock or token, taking more than the input, or with calls that\n * could move the deposit is refused before anything is signed, and the\n * batch is built from these terms, not from the payload.\n */\n expected: ExpectedFunding;\n /**\n * Kernel smart-account owner as the SDK's `EvmSigner`. Requires\n * `signer.signMessage` (optional on `EvmSigner`) — Kernel's validator\n * signs the UserOp hash via it. Clear error thrown if missing.\n */\n signer: EvmSigner;\n /** Raw IRIS message bytes (hex, 0x-prefixed). */\n cctpMessage: Hex;\n /** Raw IRIS attestation bytes (hex, 0x-prefixed). */\n cctpAttestation: Hex;\n /**\n * Settlement chain. Defaults to Arbitrum mainnet — the only\n * supported chain today, parameterised for future extension.\n */\n chain?: Chain;\n /** Return immediately after submission without waiting for receipt. */\n noWait?: boolean;\n /**\n * When `true`, run each batched call individually via `eth_call`\n * before submission and log per-call status to the console. Useful\n * for iterating on ABI / calldata issues — bundler reverts are\n * aggregated and often opaque. Never throws; the bundler's real\n * simulation on `sendUserOperation` remains the authoritative check.\n */\n preflightSimulate?: boolean;\n /** Optional logger sink. Silent by default. */\n logger?: Logger;\n /** Minimum log level to emit. Defaults to `silent`. */\n logLevel?: LogLevel;\n}\n\nexport interface SubmitUserOpResult {\n /** Bundler-assigned UserOperation hash. */\n userOpHash: Hex;\n /** Deterministic smart-account address (owned by `signer`). */\n smartAccountAddress: Address;\n /**\n * On-chain transaction hash for the bundle containing this UserOp.\n * Populated when `noWait !== true` — omitted when the caller opts\n * out of waiting.\n */\n transactionHash?: Hex;\n}\n\nexport interface SubmitBalanceUserOpParams {\n /** Swap ID assigned by the backend at create time. */\n swapId: string;\n /**\n * What the funding must match: the hash lock this client fixed and the\n * terms it recorded at the swap's creation (`Client.getEvmFundingExpectation`),\n * plus optional pins. A payload naming another spender, hash, claimer,\n * timelock or token, taking more than the input, or with calls that\n * could move the deposit is refused before anything is signed, and the\n * batch is built from these terms, not from the payload.\n */\n expected: ExpectedFunding;\n /** Kernel smart-account owner as the SDK's `EvmSigner`. */\n signer: EvmSigner;\n /** Settlement chain. Defaults to Arbitrum mainnet. */\n chain?: Chain;\n /** Return immediately after submission without waiting for receipt. */\n noWait?: boolean;\n /** Optional debug simulation of each batched call. */\n preflightSimulate?: boolean;\n /**\n * Maximum amount this balance-based retry may spend, in source-token\n * base units. The UserOp still spends the server-authored swap amount;\n * this guard prevents unrelated smart-account balance from being folded\n * into a retry if calldata ever asks for more than the recovered swap.\n */\n expectedMaxSourceAmount?: bigint;\n /** Persist the signed operation hash before any submission can reach the bundler. */\n onSigned?: (userOpHash: Hex) => Promise<void>;\n /** Optional logger sink. Silent by default. */\n logger?: Logger;\n /** Minimum log level to emit. Defaults to `silent`. */\n logLevel?: LogLevel;\n}\n\n/** Inputs needed from the `CctpInboundClient` to execute a submission. */\nexport interface SubmitUserOpContext {\n apiClient: ApiClient;\n aa: AaConfig;\n}\n\n/**\n * Execute the full CCTP-inbound settlement UserOp for a swap.\n *\n * This is intentionally a free function rather than a\n * `CctpInboundClient` method — the client exposes a thin wrapper that\n * injects its own state; tests and advanced consumers can call the\n * free function directly with a custom `SubmitUserOpContext`.\n */\nasync function sendBalanceUserOp(\n context: SubmitUserOpContext,\n params: SubmitBalanceUserOpParams,\n): Promise<SubmitUserOpResult> {\n const { apiClient, aa } = context;\n const {\n swapId,\n signer,\n chain = arbitrum,\n noWait,\n preflightSimulate,\n } = params;\n\n const { data, error } = await apiClient.GET(\n \"/swap/{id}/swap-and-lock-calldata-userop\",\n { params: { path: { id: swapId } } },\n );\n if (error || !data) {\n throw new Error(\n `Failed to fetch AA balance-funding calldata for swap ${swapId}: ${JSON.stringify(\n error,\n )}`,\n );\n }\n const server = data as unknown as UseropCalldataResponse;\n const sourceAmount = BigInt(server.source_amount);\n if (\n params.expectedMaxSourceAmount != null &&\n sourceAmount > params.expectedMaxSourceAmount\n ) {\n throw new Error(\n `Balance-funding calldata requires ${sourceAmount} source units, but retry is capped at ${params.expectedMaxSourceAmount}.`,\n );\n }\n\n const {\n client: aaClient,\n account: smartAccount,\n accountAddress,\n } = await createSwapSmartAccountClient({ signer, aa, chain });\n\n const publicClient = createPublicClient({\n chain,\n transport: http(aa.rpcUrl ?? aa.bundlerUrl),\n });\n\n // What the account already lets Permit2 pull, read from the swap's\n // recorded source token (not the payload's). The batch builder then only\n // approves when needed and resets a lingering partial allowance first —\n // required for tokens without EIP-2612 that also refuse a non-zero →\n // non-zero approve. An unreadable allowance falls back to the\n // unconditional approve(max).\n let permit2Allowance: bigint | undefined;\n try {\n permit2Allowance = (await publicClient.readContract({\n address: params.expected.terms.sourceToken as Address,\n abi: ALLOWANCE_ABI,\n functionName: \"allowance\",\n args: [accountAddress, PERMIT2_ADDRESS],\n })) as bigint;\n } catch {\n permit2Allowance = undefined;\n }\n\n const { calls } = await buildCctpInboundBatch({\n server,\n expected: params.expected,\n smartAccountAddress: accountAddress,\n signTypedData: (args) => smartAccount.signTypedData(args),\n cctpMessage: \"0x\" as Hex,\n cctpAttestation: \"0x\" as Hex,\n chainId: chain.id,\n skipReceiveMessage: true,\n permit2Allowance,\n });\n\n if (preflightSimulate) {\n await simulateBatchCalls({\n calls,\n smartAccount: accountAddress,\n publicClient,\n logger: params.logger,\n logLevel: params.logLevel,\n });\n }\n\n let userOpHash: Hex;\n if (params.onSigned) {\n const { formatUserOperationRequest, getUserOperationHash } = await import(\n \"viem/account-abstraction\"\n );\n const prepared = await aaClient.prepareUserOperation({ calls });\n const signed = {\n ...prepared,\n signature: await smartAccount.signUserOperation(prepared),\n };\n const entryPoint = smartAccount.entryPoint;\n userOpHash = getUserOperationHash({\n chainId: chain.id,\n entryPointAddress: entryPoint.address,\n entryPointVersion: entryPoint.version,\n userOperation: signed as never,\n });\n // Failure to compute or persist the hash must prevent submission. Once\n // persisted, a lost RPC response must not authorize another funding.\n await params.onSigned(userOpHash);\n await (\n aaClient as unknown as {\n request(\n args: { method: string; params: unknown[] },\n options: { retryCount: number },\n ): Promise<unknown>;\n }\n ).request(\n {\n method: \"eth_sendUserOperation\",\n params: [\n formatUserOperationRequest(signed as never),\n entryPoint.address,\n ],\n },\n { retryCount: 0 },\n );\n } else {\n userOpHash = await aaClient.sendUserOperation({ calls });\n }\n if (noWait) {\n return { userOpHash, smartAccountAddress: accountAddress };\n }\n\n const receipt = await aaClient.waitForUserOperationReceipt({\n hash: userOpHash,\n });\n if (!receipt.success) {\n throw new Error(`Balance-funding UserOperation reverted: ${userOpHash}`);\n }\n\n return {\n userOpHash,\n smartAccountAddress: accountAddress,\n transactionHash: receipt.receipt.transactionHash,\n };\n}\n\nexport async function submitCctpInboundBalanceUserOp(\n context: SubmitUserOpContext,\n params: SubmitBalanceUserOpParams,\n): Promise<SubmitUserOpResult> {\n return sendBalanceUserOp(context, params);\n}\n\nexport async function submitCctpInboundUserOp(\n context: SubmitUserOpContext,\n params: SubmitUserOpParams,\n): Promise<SubmitUserOpResult> {\n const { apiClient, aa } = context;\n const {\n swapId,\n signer,\n cctpMessage,\n cctpAttestation,\n chain = arbitrum,\n noWait,\n preflightSimulate,\n } = params;\n\n // 1. Fetch the HTLC/DEX calldata the backend built for this swap.\n const { data, error } = await apiClient.GET(\n \"/swap/{id}/swap-and-lock-calldata-userop\",\n { params: { path: { id: swapId } } },\n );\n if (error || !data) {\n throw new Error(\n `Failed to fetch CCTP-inbound calldata for swap ${swapId}: ${JSON.stringify(\n error,\n )}`,\n );\n }\n const server = data as unknown as UseropCalldataResponse;\n\n // 2. Derive the Kernel client + the smart-account address.\n const {\n client: aaClient,\n account: smartAccount,\n accountAddress,\n } = await createSwapSmartAccountClient({ signer, aa, chain });\n\n // 3. Decide whether to include `receiveMessage` in the batch, based on\n // whether *this specific burn's nonce* has already been consumed by\n // MessageTransmitter. A prior balance-based heuristic here was\n // unsafe: any USDC that happened to be at the smart-account address\n // (residual from a partial prior attempt, a direct transfer, …) made\n // it skip `receiveMessage` even if the current burn was still\n // unminted, stranding the fresh funds. Nonce consumption is the\n // authoritative signal — `MessageTransmitter.usedNonces(nonce)`\n // returns non-zero iff the mint for *this* message has landed.\n const publicClient = createPublicClient({\n chain,\n transport: http(aa.rpcUrl ?? aa.bundlerUrl),\n });\n const nonce = extractNonce(cctpMessage);\n const usedNonce = (await publicClient.readContract({\n address: MESSAGE_TRANSMITTER_V2 as `0x${string}`,\n abi: USED_NONCES_ABI,\n functionName: \"usedNonces\",\n args: [nonce],\n })) as bigint;\n const skipReceiveMessage = usedNonce !== 0n;\n\n // 4. Compose the 3-call batch (receiveMessage + approve + HTLC create).\n const { calls } = await buildCctpInboundBatch({\n server,\n expected: params.expected,\n smartAccountAddress: accountAddress,\n signTypedData: (args) => smartAccount.signTypedData(args),\n cctpMessage,\n cctpAttestation,\n chainId: chain.id,\n skipReceiveMessage,\n });\n\n // 5. Optional debug pre-flight: per-call `eth_call` with the smart\n // account as `from`, logging per-call status. The bundler's\n // full simulation at `sendUserOperation` is the authoritative\n // check — this is purely for observability while iterating.\n if (preflightSimulate) {\n await simulateBatchCalls({\n calls,\n smartAccount: accountAddress,\n publicClient,\n logger: params.logger,\n logLevel: params.logLevel,\n });\n }\n\n // 6. Send the UserOp via the bundler. If a paymaster was configured it is\n // wired into the Kernel client; otherwise the smart account pays gas.\n const userOpHash = await aaClient.sendUserOperation({ calls });\n\n if (noWait) {\n return { userOpHash, smartAccountAddress: accountAddress };\n }\n\n const receipt = await aaClient.waitForUserOperationReceipt({\n hash: userOpHash,\n });\n // A UserOp can be included on-chain yet revert during execution;\n // waitForUserOperationReceipt resolves with success=false rather than\n // throwing. Surface that as an error so callers retry instead of treating a\n // reverted settlement as done. The batch is atomic, so a reverted attempt\n // applied nothing and re-submission is safe (receiveMessage is nonce-gated).\n if (!receipt.success) {\n throw new Error(\n `CCTP-inbound settlement UserOp ${userOpHash} reverted on-chain${\n receipt.reason ? `: ${receipt.reason}` : \"\"\n }`,\n );\n }\n return {\n userOpHash,\n smartAcc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TYPE","KERNEL_FEATURES","ValidatorMode","getEncodedPluginsData","getPluginsEnableTypedData","encodeExecuteBatchCall","encodeExecuteDelegateCall","encodeExecuteSingleCall","encodeCallData","encodeDeployCallData","index","signAuthorization","chainId","signMessage","signTypedData","word","keccak256","hexToBytes","bytesToHex","domainSeparator","encodeUint256","normalizeAddress","APPROVE_SELECTOR","MESSAGE_TRANSMITTER_V2","PERMIT2_ADDRESS","getUserOperationHash"]}
|