@zerodev/sdk 5.3.26 → 5.4.0-beta.0
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/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/createKernelAccount.js +171 -199
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeCallData.js +13 -9
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeCallData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js +18 -17
- package/_cjs/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_7/encodeCallData.js +12 -8
- package/_cjs/accounts/kernel/utils/account/ep0_7/encodeCallData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js +2 -2
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js.map +1 -1
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js +2 -2
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js.map +1 -1
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js +1 -1
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js.map +1 -1
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js +1 -1
- package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js.map +1 -1
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js +2 -2
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js.map +1 -1
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteCall.js +2 -2
- package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteCall.js.map +1 -1
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -1
- package/_cjs/accounts/kernel/v1/createKernelAccountV1.js +81 -94
- package/_cjs/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
- package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js +104 -110
- package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js.map +1 -1
- package/_cjs/accounts/utils/getCustomNonceKeyFromString.js +2 -4
- package/_cjs/accounts/utils/getCustomNonceKeyFromString.js.map +1 -1
- package/_cjs/accounts/utils/index.js +1 -7
- package/_cjs/accounts/utils/index.js.map +1 -1
- package/_cjs/accounts/utils/multisend.js.map +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js +14 -16
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/actions/account-client/changeSudoValidator.js +27 -21
- package/_cjs/actions/account-client/changeSudoValidator.js.map +1 -1
- package/_cjs/actions/account-client/getKernelV3ModuleCurrentNonce.js +8 -6
- package/_cjs/actions/account-client/getKernelV3ModuleCurrentNonce.js.map +1 -1
- package/_cjs/actions/account-client/invalidateNonce.js +20 -15
- package/_cjs/actions/account-client/invalidateNonce.js.map +1 -1
- package/_cjs/actions/account-client/sendTransaction.js +42 -0
- package/_cjs/actions/account-client/sendTransaction.js.map +1 -0
- package/_cjs/actions/account-client/signMessage.js +15 -0
- package/_cjs/actions/account-client/signMessage.js.map +1 -0
- package/_cjs/actions/account-client/signTypedData.js +32 -0
- package/_cjs/actions/account-client/signTypedData.js.map +1 -0
- package/_cjs/actions/account-client/signUserOperation.js +7 -5
- package/_cjs/actions/account-client/signUserOperation.js.map +1 -1
- package/_cjs/actions/account-client/uninstallPlugin.js +13 -12
- package/_cjs/actions/account-client/uninstallPlugin.js.map +1 -1
- package/_cjs/actions/account-client/writeContract.js +21 -0
- package/_cjs/actions/account-client/writeContract.js.map +1 -0
- package/_cjs/actions/index.js +13 -3
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/paymaster/estimateGasInERC20.js +4 -4
- package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_cjs/actions/paymaster/sponsorUserOperation.js +4 -6
- package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/public/getAccountNonce.js +38 -0
- package/_cjs/actions/public/getAccountNonce.js.map +1 -0
- package/_cjs/actions/public/getSenderAddress.js +166 -0
- package/_cjs/actions/public/getSenderAddress.js.map +1 -0
- package/_cjs/actions/public/index.js +8 -0
- package/_cjs/actions/public/index.js.map +1 -0
- package/_cjs/clients/decorators/kernel.js +17 -27
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/clients/fallbackKernelAccountClient.js.map +1 -1
- package/_cjs/clients/kernelAccountClient.js +27 -45
- package/_cjs/clients/kernelAccountClient.js.map +1 -1
- package/_cjs/clients/paymasterClient.js +7 -18
- package/_cjs/clients/paymasterClient.js.map +1 -1
- package/_cjs/errors/index.js +18 -0
- package/_cjs/errors/index.js.map +1 -0
- package/_cjs/gasTokenAddresses.js +2 -1
- package/_cjs/gasTokenAddresses.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
- package/_cjs/types/kernel.js.map +1 -1
- package/_cjs/utils.js +27 -7
- package/_cjs/utils.js.map +1 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/kernel/createKernelAccount.js +181 -217
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js +13 -9
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js +18 -17
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js +12 -8
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -1
- package/_esm/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
- package/_esm/accounts/kernel/utils/common/getActionSelector.js +2 -2
- package/_esm/accounts/kernel/utils/common/getActionSelector.js.map +1 -1
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js +2 -2
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js.map +1 -1
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js +1 -1
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js.map +1 -1
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js +1 -1
- package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js.map +1 -1
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js +2 -2
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js.map +1 -1
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js +2 -2
- package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js.map +1 -1
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -1
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -1
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -1
- package/_esm/accounts/kernel/v1/createKernelAccountV1.js +91 -98
- package/_esm/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
- package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js +105 -118
- package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js.map +1 -1
- package/_esm/accounts/utils/getCustomNonceKeyFromString.js +2 -4
- package/_esm/accounts/utils/getCustomNonceKeyFromString.js.map +1 -1
- package/_esm/accounts/utils/index.js +0 -5
- package/_esm/accounts/utils/index.js.map +1 -1
- package/_esm/accounts/utils/multisend.js.map +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js +14 -16
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/actions/account-client/changeSudoValidator.js +23 -17
- package/_esm/actions/account-client/changeSudoValidator.js.map +1 -1
- package/_esm/actions/account-client/getKernelV3ModuleCurrentNonce.js +8 -6
- package/_esm/actions/account-client/getKernelV3ModuleCurrentNonce.js.map +1 -1
- package/_esm/actions/account-client/invalidateNonce.js +20 -15
- package/_esm/actions/account-client/invalidateNonce.js.map +1 -1
- package/_esm/actions/account-client/sendTransaction.js +85 -0
- package/_esm/actions/account-client/sendTransaction.js.map +1 -0
- package/_esm/actions/account-client/signMessage.js +58 -0
- package/_esm/actions/account-client/signMessage.js.map +1 -0
- package/_esm/actions/account-client/signTypedData.js +127 -0
- package/_esm/actions/account-client/signTypedData.js.map +1 -0
- package/_esm/actions/account-client/signUserOperation.js +7 -5
- package/_esm/actions/account-client/signUserOperation.js.map +1 -1
- package/_esm/actions/account-client/uninstallPlugin.js +10 -9
- package/_esm/actions/account-client/uninstallPlugin.js.map +1 -1
- package/_esm/actions/account-client/writeContract.js +18 -0
- package/_esm/actions/account-client/writeContract.js.map +1 -0
- package/_esm/actions/index.js +6 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/paymaster/estimateGasInERC20.js +3 -3
- package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_esm/actions/paymaster/sponsorUserOperation.js +3 -5
- package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/public/getAccountNonce.js +61 -0
- package/_esm/actions/public/getAccountNonce.js.map +1 -0
- package/_esm/actions/public/getSenderAddress.js +191 -0
- package/_esm/actions/public/getSenderAddress.js.map +1 -0
- package/_esm/actions/public/index.js +3 -0
- package/_esm/actions/public/index.js.map +1 -0
- package/_esm/clients/decorators/kernel.js +19 -28
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/clients/fallbackKernelAccountClient.js.map +1 -1
- package/_esm/clients/kernelAccountClient.js +28 -46
- package/_esm/clients/kernelAccountClient.js.map +1 -1
- package/_esm/clients/paymasterClient.js +8 -19
- package/_esm/clients/paymasterClient.js.map +1 -1
- package/_esm/errors/index.js +14 -0
- package/_esm/errors/index.js.map +1 -0
- package/_esm/gasTokenAddresses.js +2 -1
- package/_esm/gasTokenAddresses.js.map +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
- package/_esm/types/kernel.js.map +1 -1
- package/_esm/utils.js +29 -7
- package/_esm/utils.js.map +1 -1
- package/_types/accounts/index.d.ts +2 -2
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/kernel/createKernelAccount.d.ts +21 -18
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts +8 -3
- package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts +3 -2
- package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.d.ts +0 -1
- package/_types/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts +8 -3
- package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts +3 -2
- package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/common/accountMetadata.d.ts +2 -2
- package/_types/accounts/kernel/utils/common/accountMetadata.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts +1 -1
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts +1 -1
- package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts +1 -1
- package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts +2 -3
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts +4 -5
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts +2 -3
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/types.d.ts +2 -2
- package/_types/accounts/kernel/utils/types.d.ts.map +1 -1
- package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts +18 -9
- package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts.map +1 -1
- package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts +9 -7
- package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts.map +1 -1
- package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts +2 -2
- package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts.map +1 -1
- package/_types/accounts/utils/index.d.ts +0 -2
- package/_types/accounts/utils/index.d.ts.map +1 -1
- package/_types/accounts/utils/multisend.d.ts +2 -2
- package/_types/accounts/utils/multisend.d.ts.map +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts +4 -4
- package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
- package/_types/actions/account-client/changeSudoValidator.d.ts +5 -11
- package/_types/actions/account-client/changeSudoValidator.d.ts.map +1 -1
- package/_types/actions/account-client/getKernelV3ModuleCurrentNonce.d.ts +2 -5
- package/_types/actions/account-client/getKernelV3ModuleCurrentNonce.d.ts.map +1 -1
- package/_types/actions/account-client/invalidateNonce.d.ts +4 -6
- package/_types/actions/account-client/invalidateNonce.d.ts.map +1 -1
- package/_types/actions/account-client/sendTransaction.d.ts +50 -0
- package/_types/actions/account-client/sendTransaction.d.ts.map +1 -0
- package/_types/actions/account-client/signMessage.d.ts +50 -0
- package/_types/actions/account-client/signMessage.d.ts.map +1 -0
- package/_types/actions/account-client/signTypedData.d.ts +104 -0
- package/_types/actions/account-client/signTypedData.d.ts.map +1 -0
- package/_types/actions/account-client/signUserOperation.d.ts +4 -6
- package/_types/actions/account-client/signUserOperation.d.ts.map +1 -1
- package/_types/actions/account-client/uninstallPlugin.d.ts +5 -7
- package/_types/actions/account-client/uninstallPlugin.d.ts.map +1 -1
- package/_types/actions/account-client/writeContract.d.ts +4 -0
- package/_types/actions/account-client/writeContract.d.ts.map +1 -0
- package/_types/actions/index.d.ts +6 -1
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/paymaster/estimateGasInERC20.d.ts +1305 -4
- package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
- package/_types/actions/paymaster/sponsorUserOperation.d.ts +1314 -10
- package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/public/getAccountNonce.d.ts +34 -0
- package/_types/actions/public/getAccountNonce.d.ts.map +1 -0
- package/_types/actions/public/getSenderAddress.d.ts +46 -0
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -0
- package/_types/actions/public/index.d.ts +3 -0
- package/_types/actions/public/index.d.ts.map +1 -0
- package/_types/clients/decorators/kernel.d.ts +774 -20
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/clients/fallbackKernelAccountClient.d.ts +255 -4
- package/_types/clients/fallbackKernelAccountClient.d.ts.map +1 -1
- package/_types/clients/kernelAccountClient.d.ts +34 -36
- package/_types/clients/kernelAccountClient.d.ts.map +1 -1
- package/_types/clients/paymasterClient.d.ts +10 -24
- package/_types/clients/paymasterClient.d.ts.map +1 -1
- package/_types/errors/index.d.ts +7 -0
- package/_types/errors/index.d.ts.map +1 -0
- package/_types/gasTokenAddresses.d.ts +1 -1
- package/_types/gasTokenAddresses.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/providers/KernelEIP1193Provider.d.ts +3 -4
- package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
- package/_types/types/index.d.ts +1 -0
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +25 -27
- package/_types/types/kernel.d.ts.map +1 -1
- package/_types/utils.d.ts +1310 -4
- package/_types/utils.d.ts.map +1 -1
- package/accounts/index.ts +5 -2
- package/accounts/kernel/createKernelAccount.ts +312 -357
- package/accounts/kernel/utils/account/ep0_6/encodeCallData.ts +22 -12
- package/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.ts +6 -3
- package/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.ts +22 -19
- package/accounts/kernel/utils/account/ep0_7/encodeCallData.ts +21 -11
- package/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.ts +6 -3
- package/accounts/kernel/utils/common/accountMetadata.ts +2 -7
- package/accounts/kernel/utils/common/getActionSelector.ts +3 -3
- package/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.ts +3 -3
- package/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.ts +1 -1
- package/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.ts +1 -1
- package/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.ts +3 -3
- package/accounts/kernel/utils/ep0_7/encodeExecuteCall.ts +2 -2
- package/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts +2 -8
- package/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts +4 -10
- package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +2 -8
- package/accounts/kernel/utils/types.ts +2 -2
- package/accounts/kernel/v1/createKernelAccountV1.ts +147 -174
- package/accounts/kernel/v2/createKernelAccountV0_2.ts +135 -179
- package/accounts/utils/getCustomNonceKeyFromString.ts +3 -6
- package/accounts/utils/index.ts +0 -9
- package/accounts/utils/multisend.ts +5 -2
- package/accounts/utils/toKernelPluginManager.ts +23 -27
- package/actions/account-client/changeSudoValidator.ts +61 -85
- package/actions/account-client/getKernelV3ModuleCurrentNonce.ts +12 -51
- package/actions/account-client/invalidateNonce.ts +38 -67
- package/actions/account-client/sendTransaction.ts +134 -0
- package/actions/account-client/signMessage.ts +75 -0
- package/actions/account-client/signTypedData.ts +159 -0
- package/actions/account-client/signUserOperation.ts +31 -63
- package/actions/account-client/uninstallPlugin.ts +35 -56
- package/actions/account-client/writeContract.ts +72 -0
- package/actions/index.ts +15 -6
- package/actions/paymaster/estimateGasInERC20.ts +12 -8
- package/actions/paymaster/sponsorUserOperation.ts +52 -50
- package/actions/public/getAccountNonce.ts +77 -0
- package/actions/public/getSenderAddress.ts +276 -0
- package/actions/public/index.ts +9 -0
- package/clients/decorators/kernel.ts +363 -159
- package/clients/fallbackKernelAccountClient.ts +9 -11
- package/clients/kernelAccountClient.ts +142 -104
- package/clients/paymasterClient.ts +69 -43
- package/errors/index.ts +17 -0
- package/gasTokenAddresses.ts +3 -2
- package/index.ts +5 -2
- package/package.json +11 -34
- package/providers/KernelEIP1193Provider.ts +4 -7
- package/types/index.ts +2 -0
- package/types/kernel.ts +64 -63
- package/utils.ts +41 -13
- package/_cjs/actions/paymaster/sponsorUserOperationEip7677.js +0 -59
- package/_cjs/actions/paymaster/sponsorUserOperationEip7677.js.map +0 -1
- package/_esm/actions/paymaster/sponsorUserOperationEip7677.js +0 -58
- package/_esm/actions/paymaster/sponsorUserOperationEip7677.js.map +0 -1
- package/_types/actions/paymaster/sponsorUserOperationEip7677.d.ts +0 -16
- package/_types/actions/paymaster/sponsorUserOperationEip7677.d.ts.map +0 -1
- package/actions/paymaster/sponsorUserOperationEip7677.ts +0 -152
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAccountNonce,
|
|
3
|
-
getEntryPointVersion,
|
|
4
|
-
getSenderAddress,
|
|
5
|
-
isSmartAccountDeployed
|
|
6
|
-
} from "permissionless"
|
|
7
|
-
import {
|
|
8
|
-
SignTransactionNotSupportedBySmartAccount,
|
|
9
|
-
type SmartAccount,
|
|
10
|
-
toSmartAccount
|
|
11
|
-
} from "permissionless/accounts"
|
|
12
|
-
import type {
|
|
13
|
-
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
14
|
-
ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
15
|
-
EntryPoint
|
|
16
|
-
} from "permissionless/types"
|
|
17
1
|
import {
|
|
18
2
|
type Address,
|
|
19
|
-
type
|
|
3
|
+
type Assign,
|
|
20
4
|
type Client,
|
|
5
|
+
type EncodeDeployDataParameters,
|
|
21
6
|
type Hex,
|
|
22
|
-
type PublicActions,
|
|
23
|
-
type PublicRpcSchema,
|
|
24
|
-
type Transport,
|
|
25
7
|
type TypedDataDefinition,
|
|
26
8
|
concatHex,
|
|
9
|
+
createNonceManager,
|
|
27
10
|
encodeFunctionData,
|
|
28
11
|
getTypesForEIP712Domain,
|
|
29
12
|
hashMessage,
|
|
@@ -32,16 +15,28 @@ import {
|
|
|
32
15
|
validateTypedData,
|
|
33
16
|
zeroAddress
|
|
34
17
|
} from "viem"
|
|
18
|
+
import {
|
|
19
|
+
type EntryPointVersion,
|
|
20
|
+
type SmartAccount,
|
|
21
|
+
type SmartAccountImplementation,
|
|
22
|
+
type UserOperation,
|
|
23
|
+
entryPoint06Abi,
|
|
24
|
+
entryPoint07Abi,
|
|
25
|
+
entryPoint07Address,
|
|
26
|
+
toSmartAccount
|
|
27
|
+
} from "viem/account-abstraction"
|
|
28
|
+
import { getChainId } from "viem/actions"
|
|
29
|
+
import { getAction } from "viem/utils"
|
|
35
30
|
import { KernelVersionToAddressesMap } from "../../constants.js"
|
|
36
31
|
import type {
|
|
32
|
+
CallType,
|
|
33
|
+
GetEntryPointAbi,
|
|
37
34
|
GetKernelVersion,
|
|
38
|
-
KernelEncodeCallDataArgs,
|
|
39
35
|
KernelPluginManager,
|
|
40
36
|
KernelPluginManagerParams
|
|
41
37
|
} from "../../types/kernel.js"
|
|
42
38
|
import { KERNEL_FEATURES, hasKernelFeature } from "../../utils.js"
|
|
43
39
|
import { validateKernelVersionWithEntryPoint } from "../../utils.js"
|
|
44
|
-
import { parseFactoryAddressAndCallDataFromAccountInitCode } from "../utils/index.js"
|
|
45
40
|
import {
|
|
46
41
|
isKernelPluginManager,
|
|
47
42
|
toKernelPluginManager
|
|
@@ -57,40 +52,62 @@ import { encodeCallData as encodeCallDataEpV07 } from "./utils/account/ep0_7/enc
|
|
|
57
52
|
import { encodeDeployCallData as encodeDeployCallDataV07 } from "./utils/account/ep0_7/encodeDeployCallData.js"
|
|
58
53
|
import { accountMetadata } from "./utils/common/accountMetadata.js"
|
|
59
54
|
import { eip712WrapHash } from "./utils/common/eip712WrapHash.js"
|
|
55
|
+
import {
|
|
56
|
+
getSenderAddress,
|
|
57
|
+
getAccountNonce
|
|
58
|
+
} from "../../actions/public/index.js"
|
|
59
|
+
|
|
60
|
+
export type KernelSmartAccountImplementation<
|
|
61
|
+
entryPointVersion extends EntryPointVersion = "0.7"
|
|
62
|
+
> = Assign<
|
|
63
|
+
SmartAccountImplementation<
|
|
64
|
+
GetEntryPointAbi<entryPointVersion>,
|
|
65
|
+
entryPointVersion
|
|
66
|
+
>,
|
|
67
|
+
{
|
|
68
|
+
sign: NonNullable<SmartAccountImplementation["sign"]>
|
|
69
|
+
encodeCalls: (
|
|
70
|
+
calls: Parameters<SmartAccountImplementation["encodeCalls"]>[0],
|
|
71
|
+
callType?: CallType | undefined
|
|
72
|
+
) => Promise<Hex>
|
|
73
|
+
kernelVersion: GetKernelVersion<entryPointVersion>
|
|
74
|
+
kernelPluginManager: KernelPluginManager<entryPointVersion>
|
|
75
|
+
generateInitCode: () => Promise<Hex>
|
|
76
|
+
encodeModuleInstallCallData: () => Promise<Hex>
|
|
77
|
+
encodeDeployCallData: ({
|
|
78
|
+
abi,
|
|
79
|
+
args,
|
|
80
|
+
bytecode
|
|
81
|
+
}: EncodeDeployDataParameters) => Promise<Hex>
|
|
82
|
+
}
|
|
83
|
+
>
|
|
60
84
|
|
|
61
|
-
export type
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
chain extends Chain | undefined = Chain | undefined
|
|
65
|
-
> = SmartAccount<entryPoint, "kernelSmartAccount", transport, chain> & {
|
|
66
|
-
kernelVersion: GetKernelVersion<entryPoint>
|
|
67
|
-
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
68
|
-
getNonce: (customNonceKey?: bigint) => Promise<bigint>
|
|
69
|
-
generateInitCode: () => Promise<Hex>
|
|
70
|
-
encodeCallData: (args: KernelEncodeCallDataArgs) => Promise<Hex>
|
|
71
|
-
encodeModuleInstallCallData: () => Promise<Hex>
|
|
72
|
-
}
|
|
85
|
+
export type CreateKernelAccountReturnType<
|
|
86
|
+
entryPointVersion extends EntryPointVersion = "0.7"
|
|
87
|
+
> = SmartAccount<KernelSmartAccountImplementation<entryPointVersion>>
|
|
73
88
|
|
|
74
89
|
export type CreateKernelAccountParameters<
|
|
75
|
-
|
|
76
|
-
KernelVerion extends GetKernelVersion<
|
|
90
|
+
entryPointVersion extends EntryPointVersion,
|
|
91
|
+
KernelVerion extends GetKernelVersion<entryPointVersion>
|
|
77
92
|
> = {
|
|
78
93
|
plugins:
|
|
79
94
|
| Omit<
|
|
80
|
-
KernelPluginManagerParams<
|
|
95
|
+
KernelPluginManagerParams<entryPointVersion>,
|
|
81
96
|
"entryPoint" | "kernelVersion"
|
|
82
97
|
>
|
|
83
|
-
| KernelPluginManager<
|
|
84
|
-
entryPoint:
|
|
98
|
+
| KernelPluginManager<entryPointVersion>
|
|
99
|
+
entryPoint: {
|
|
100
|
+
address: Address
|
|
101
|
+
version: entryPointVersion
|
|
102
|
+
}
|
|
85
103
|
index?: bigint
|
|
86
104
|
factoryAddress?: Address
|
|
87
105
|
accountImplementationAddress?: Address
|
|
88
106
|
metaFactoryAddress?: Address
|
|
89
|
-
|
|
90
|
-
kernelVersion: GetKernelVersion<
|
|
107
|
+
address?: Address
|
|
108
|
+
kernelVersion: GetKernelVersion<entryPointVersion>
|
|
91
109
|
initConfig?: KernelVerion extends "0.3.1" ? Hex[] : never
|
|
92
110
|
useMetaFactory?: boolean
|
|
93
|
-
chainId?: number
|
|
94
111
|
}
|
|
95
112
|
|
|
96
113
|
/**
|
|
@@ -145,20 +162,21 @@ export const KERNEL_ADDRESSES: {
|
|
|
145
162
|
FACTORY_STAKER: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5"
|
|
146
163
|
}
|
|
147
164
|
|
|
148
|
-
const getKernelInitData = async <
|
|
149
|
-
|
|
165
|
+
const getKernelInitData = async <entryPointVersion extends EntryPointVersion>({
|
|
166
|
+
entryPointVersion: _entryPointVersion,
|
|
150
167
|
kernelPluginManager,
|
|
151
168
|
initHook,
|
|
152
169
|
kernelVersion,
|
|
153
170
|
initConfig
|
|
154
171
|
}: {
|
|
155
|
-
|
|
156
|
-
kernelPluginManager: KernelPluginManager<
|
|
172
|
+
entryPointVersion: entryPointVersion
|
|
173
|
+
kernelPluginManager: KernelPluginManager<entryPointVersion>
|
|
157
174
|
initHook: boolean
|
|
158
|
-
kernelVersion: GetKernelVersion<
|
|
159
|
-
initConfig?: GetKernelVersion<
|
|
175
|
+
kernelVersion: GetKernelVersion<entryPointVersion>
|
|
176
|
+
initConfig?: GetKernelVersion<entryPointVersion> extends "0.3.1"
|
|
177
|
+
? Hex[]
|
|
178
|
+
: never
|
|
160
179
|
}) => {
|
|
161
|
-
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
162
180
|
const {
|
|
163
181
|
enableData,
|
|
164
182
|
identifier,
|
|
@@ -166,7 +184,7 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
|
166
184
|
initConfig: initConfig_
|
|
167
185
|
} = await kernelPluginManager.getValidatorInitData()
|
|
168
186
|
|
|
169
|
-
if (
|
|
187
|
+
if (_entryPointVersion === "0.6") {
|
|
170
188
|
return encodeFunctionData({
|
|
171
189
|
abi: KernelInitAbi,
|
|
172
190
|
functionName: "initialize",
|
|
@@ -214,12 +232,11 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
|
|
|
214
232
|
* @param accountImplementationAddress
|
|
215
233
|
* @param ecdsaValidatorAddress
|
|
216
234
|
*/
|
|
217
|
-
const getAccountInitCode = async <
|
|
235
|
+
const getAccountInitCode = async <entryPointVersion extends EntryPointVersion>({
|
|
218
236
|
index,
|
|
219
237
|
factoryAddress,
|
|
220
238
|
accountImplementationAddress,
|
|
221
|
-
|
|
222
|
-
entryPoint: entryPointAddress,
|
|
239
|
+
entryPointVersion: _entryPointVersion,
|
|
223
240
|
kernelPluginManager,
|
|
224
241
|
initHook,
|
|
225
242
|
kernelVersion,
|
|
@@ -229,103 +246,51 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
|
|
|
229
246
|
index: bigint
|
|
230
247
|
factoryAddress: Address
|
|
231
248
|
accountImplementationAddress: Address
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
kernelPluginManager: KernelPluginManager<entryPoint>
|
|
249
|
+
entryPointVersion: entryPointVersion
|
|
250
|
+
kernelPluginManager: KernelPluginManager<entryPointVersion>
|
|
235
251
|
initHook: boolean
|
|
236
|
-
kernelVersion: GetKernelVersion<
|
|
237
|
-
initConfig?: GetKernelVersion<
|
|
252
|
+
kernelVersion: GetKernelVersion<entryPointVersion>
|
|
253
|
+
initConfig?: GetKernelVersion<entryPointVersion> extends "0.3.1"
|
|
254
|
+
? Hex[]
|
|
255
|
+
: never
|
|
238
256
|
useMetaFactory: boolean
|
|
239
257
|
}): Promise<Hex> => {
|
|
240
258
|
// Build the account initialization data
|
|
241
|
-
const initialisationData = await getKernelInitData<
|
|
242
|
-
|
|
259
|
+
const initialisationData = await getKernelInitData<entryPointVersion>({
|
|
260
|
+
entryPointVersion: _entryPointVersion,
|
|
243
261
|
kernelPluginManager,
|
|
244
262
|
initHook,
|
|
245
263
|
kernelVersion,
|
|
246
264
|
initConfig
|
|
247
265
|
})
|
|
248
|
-
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
249
266
|
|
|
250
267
|
// Build the account init code
|
|
251
|
-
if (
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
args: [accountImplementationAddress, initialisationData, index]
|
|
258
|
-
}) as Hex
|
|
259
|
-
])
|
|
268
|
+
if (_entryPointVersion === "0.6") {
|
|
269
|
+
return encodeFunctionData({
|
|
270
|
+
abi: createAccountAbi,
|
|
271
|
+
functionName: "createAccount",
|
|
272
|
+
args: [accountImplementationAddress, initialisationData, index]
|
|
273
|
+
})
|
|
260
274
|
}
|
|
261
275
|
|
|
262
276
|
if (!useMetaFactory) {
|
|
263
|
-
return
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
functionName: "createAccount",
|
|
268
|
-
args: [initialisationData, toHex(index, { size: 32 })]
|
|
269
|
-
}) as Hex
|
|
270
|
-
])
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return concatHex([
|
|
274
|
-
metaFactoryAddress ?? zeroAddress,
|
|
275
|
-
encodeFunctionData({
|
|
276
|
-
abi: KernelFactoryStakerAbi,
|
|
277
|
-
functionName: "deployWithFactory",
|
|
278
|
-
args: [
|
|
279
|
-
factoryAddress,
|
|
280
|
-
initialisationData,
|
|
281
|
-
toHex(index, { size: 32 })
|
|
282
|
-
]
|
|
283
|
-
})
|
|
284
|
-
])
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Check the validity of an existing account address, or fetch the pre-deterministic account address for a kernel smart wallet
|
|
289
|
-
* @param client
|
|
290
|
-
* @param entryPoint
|
|
291
|
-
* @param initCodeProvider
|
|
292
|
-
*/
|
|
293
|
-
const getAccountAddress = async <
|
|
294
|
-
entryPoint extends EntryPoint,
|
|
295
|
-
TTransport extends Transport = Transport,
|
|
296
|
-
TChain extends Chain | undefined = Chain | undefined
|
|
297
|
-
>({
|
|
298
|
-
client,
|
|
299
|
-
entryPoint: entryPointAddress,
|
|
300
|
-
initCodeProvider
|
|
301
|
-
}: {
|
|
302
|
-
client: Client<TTransport, TChain, undefined>
|
|
303
|
-
initCodeProvider: () => Promise<Hex>
|
|
304
|
-
entryPoint: entryPoint
|
|
305
|
-
}): Promise<Address> => {
|
|
306
|
-
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
307
|
-
|
|
308
|
-
// Find the init code for this account
|
|
309
|
-
const initCode = await initCodeProvider()
|
|
310
|
-
if (entryPointVersion === "v0.6") {
|
|
311
|
-
return getSenderAddress<ENTRYPOINT_ADDRESS_V06_TYPE>(client, {
|
|
312
|
-
initCode,
|
|
313
|
-
entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V06_TYPE
|
|
277
|
+
return encodeFunctionData({
|
|
278
|
+
abi: KernelV3FactoryAbi,
|
|
279
|
+
functionName: "createAccount",
|
|
280
|
+
args: [initialisationData, toHex(index, { size: 32 })]
|
|
314
281
|
})
|
|
315
282
|
}
|
|
316
283
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
parseFactoryAddressAndCallDataFromAccountInitCode(initCode)[1],
|
|
322
|
-
entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V07_TYPE
|
|
284
|
+
return encodeFunctionData({
|
|
285
|
+
abi: KernelFactoryStakerAbi,
|
|
286
|
+
functionName: "deployWithFactory",
|
|
287
|
+
args: [factoryAddress, initialisationData, toHex(index, { size: 32 })]
|
|
323
288
|
})
|
|
324
289
|
}
|
|
325
290
|
|
|
326
|
-
const getDefaultAddresses = <
|
|
327
|
-
|
|
328
|
-
kernelVersion: GetKernelVersion<
|
|
291
|
+
const getDefaultAddresses = <entryPointVersion extends EntryPointVersion>(
|
|
292
|
+
entryPointVersion: entryPointVersion,
|
|
293
|
+
kernelVersion: GetKernelVersion<entryPointVersion>,
|
|
329
294
|
{
|
|
330
295
|
accountImplementationAddress,
|
|
331
296
|
factoryAddress,
|
|
@@ -336,7 +301,7 @@ const getDefaultAddresses = <entryPoint extends EntryPoint>(
|
|
|
336
301
|
metaFactoryAddress?: Address
|
|
337
302
|
}
|
|
338
303
|
) => {
|
|
339
|
-
validateKernelVersionWithEntryPoint(
|
|
304
|
+
validateKernelVersionWithEntryPoint(entryPointVersion, kernelVersion)
|
|
340
305
|
|
|
341
306
|
const addresses = KernelVersionToAddressesMap[kernelVersion]
|
|
342
307
|
if (!addresses) {
|
|
@@ -350,7 +315,8 @@ const getDefaultAddresses = <entryPoint extends EntryPoint>(
|
|
|
350
315
|
accountImplementationAddress ??
|
|
351
316
|
addresses.accountImplementationAddress,
|
|
352
317
|
factoryAddress: factoryAddress ?? addresses.factoryAddress,
|
|
353
|
-
metaFactoryAddress:
|
|
318
|
+
metaFactoryAddress:
|
|
319
|
+
metaFactoryAddress ?? addresses.metaFactoryAddress ?? zeroAddress
|
|
354
320
|
}
|
|
355
321
|
}
|
|
356
322
|
|
|
@@ -363,60 +329,62 @@ const getDefaultAddresses = <entryPoint extends EntryPoint>(
|
|
|
363
329
|
* @param factoryAddress
|
|
364
330
|
* @param accountImplementationAddress
|
|
365
331
|
* @param ecdsaValidatorAddress
|
|
366
|
-
* @param
|
|
332
|
+
* @param address
|
|
367
333
|
*/
|
|
368
334
|
export async function createKernelAccount<
|
|
369
|
-
|
|
370
|
-
KernelVersion extends GetKernelVersion<
|
|
371
|
-
TTransport extends Transport,
|
|
372
|
-
TChain extends Chain | undefined
|
|
335
|
+
entryPointVersion extends EntryPointVersion,
|
|
336
|
+
KernelVersion extends GetKernelVersion<entryPointVersion>
|
|
373
337
|
>(
|
|
374
|
-
client: Client
|
|
375
|
-
TTransport,
|
|
376
|
-
TChain,
|
|
377
|
-
undefined,
|
|
378
|
-
PublicRpcSchema,
|
|
379
|
-
PublicActions<TTransport, TChain>
|
|
380
|
-
>,
|
|
338
|
+
client: Client,
|
|
381
339
|
{
|
|
382
340
|
plugins,
|
|
383
|
-
entryPoint
|
|
341
|
+
entryPoint,
|
|
384
342
|
index = 0n,
|
|
385
343
|
factoryAddress: _factoryAddress,
|
|
386
344
|
accountImplementationAddress: _accountImplementationAddress,
|
|
387
345
|
metaFactoryAddress: _metaFactoryAddress,
|
|
388
|
-
|
|
346
|
+
address,
|
|
389
347
|
kernelVersion,
|
|
390
348
|
initConfig,
|
|
391
349
|
useMetaFactory = true,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
): Promise<KernelSmartAccount<entryPoint, TTransport, TChain>> {
|
|
395
|
-
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
350
|
+
}: CreateKernelAccountParameters<entryPointVersion, KernelVersion>
|
|
351
|
+
): Promise<CreateKernelAccountReturnType<entryPointVersion>> {
|
|
396
352
|
const { accountImplementationAddress, factoryAddress, metaFactoryAddress } =
|
|
397
|
-
getDefaultAddresses(
|
|
353
|
+
getDefaultAddresses(entryPoint.version, kernelVersion, {
|
|
398
354
|
accountImplementationAddress: _accountImplementationAddress,
|
|
399
355
|
factoryAddress: _factoryAddress,
|
|
400
356
|
metaFactoryAddress: _metaFactoryAddress
|
|
401
357
|
})
|
|
402
358
|
|
|
403
|
-
|
|
359
|
+
let chainId: number
|
|
360
|
+
|
|
361
|
+
const getMemoizedChainId = async () => {
|
|
362
|
+
if (chainId) return chainId
|
|
363
|
+
chainId = client.chain
|
|
364
|
+
? client.chain.id
|
|
365
|
+
: await getAction(client, getChainId, "getChainId")({})
|
|
366
|
+
return chainId
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const kernelPluginManager = isKernelPluginManager<entryPointVersion>(
|
|
370
|
+
plugins
|
|
371
|
+
)
|
|
404
372
|
? plugins
|
|
405
|
-
: await toKernelPluginManager<
|
|
373
|
+
: await toKernelPluginManager<entryPointVersion>(client, {
|
|
406
374
|
sudo: plugins.sudo,
|
|
407
375
|
regular: plugins.regular,
|
|
408
376
|
hook: plugins.hook,
|
|
409
377
|
action: plugins.action,
|
|
410
378
|
pluginEnableSignature: plugins.pluginEnableSignature,
|
|
411
|
-
entryPoint
|
|
379
|
+
entryPoint,
|
|
412
380
|
kernelVersion,
|
|
413
|
-
chainId
|
|
381
|
+
chainId: await getMemoizedChainId()
|
|
414
382
|
})
|
|
415
383
|
|
|
416
384
|
// initHook flag is activated only if both the hook and sudo validator are given
|
|
417
385
|
// if the hook is given with regular plugins, then consider it as a hook for regular plugins
|
|
418
386
|
const initHook = Boolean(
|
|
419
|
-
isKernelPluginManager<
|
|
387
|
+
isKernelPluginManager<entryPointVersion>(plugins)
|
|
420
388
|
? plugins.hook &&
|
|
421
389
|
plugins.getIdentifier() ===
|
|
422
390
|
plugins.sudoValidator?.getIdentifier()
|
|
@@ -427,12 +395,11 @@ export async function createKernelAccount<
|
|
|
427
395
|
const generateInitCode = async () => {
|
|
428
396
|
if (!accountImplementationAddress || !factoryAddress)
|
|
429
397
|
throw new Error("Missing account logic address or factory address")
|
|
430
|
-
return getAccountInitCode<
|
|
398
|
+
return getAccountInitCode<entryPointVersion>({
|
|
431
399
|
index,
|
|
432
400
|
factoryAddress,
|
|
433
401
|
accountImplementationAddress,
|
|
434
|
-
|
|
435
|
-
entryPoint: entryPointAddress,
|
|
402
|
+
entryPointVersion: entryPoint.version,
|
|
436
403
|
kernelPluginManager,
|
|
437
404
|
initHook,
|
|
438
405
|
kernelVersion,
|
|
@@ -441,23 +408,40 @@ export async function createKernelAccount<
|
|
|
441
408
|
})
|
|
442
409
|
}
|
|
443
410
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
411
|
+
const getFactoryArgs = async () => {
|
|
412
|
+
return {
|
|
413
|
+
factory:
|
|
414
|
+
entryPoint.version === "0.6"
|
|
415
|
+
? factoryAddress
|
|
416
|
+
: metaFactoryAddress,
|
|
417
|
+
factoryData: await generateInitCode()
|
|
418
|
+
}
|
|
419
|
+
}
|
|
452
420
|
|
|
453
|
-
if (!accountAddress) throw new Error("Account address not found")
|
|
454
421
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
422
|
+
// Fetch account address
|
|
423
|
+
let accountAddress =
|
|
424
|
+
address ??
|
|
425
|
+
(await (async () => {
|
|
426
|
+
const { factory, factoryData } = await getFactoryArgs()
|
|
427
|
+
|
|
428
|
+
// Get the sender address based on the init code
|
|
429
|
+
return await getSenderAddress(client, {
|
|
430
|
+
factory,
|
|
431
|
+
factoryData,
|
|
432
|
+
entryPointAddress: entryPoint.address
|
|
433
|
+
})
|
|
434
|
+
})())
|
|
435
|
+
|
|
436
|
+
const _entryPoint = {
|
|
437
|
+
address: entryPoint?.address ?? entryPoint07Address,
|
|
438
|
+
abi: ((entryPoint?.version ?? "0.7") === "0.6"
|
|
439
|
+
? entryPoint06Abi
|
|
440
|
+
: entryPoint07Abi) as GetEntryPointAbi<entryPointVersion>,
|
|
441
|
+
version: entryPoint?.version ?? "0.7"
|
|
442
|
+
} as const
|
|
443
|
+
|
|
444
|
+
return toSmartAccount<KernelSmartAccountImplementation<entryPointVersion>>({
|
|
461
445
|
kernelVersion,
|
|
462
446
|
kernelPluginManager,
|
|
463
447
|
generateInitCode,
|
|
@@ -466,197 +450,168 @@ export async function createKernelAccount<
|
|
|
466
450
|
accountAddress
|
|
467
451
|
)
|
|
468
452
|
},
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
// Encode the deploy call data
|
|
476
|
-
async encodeDeployCallData(_tx) {
|
|
477
|
-
if (entryPointVersion === "v0.6") {
|
|
478
|
-
return encodeDeployCallDataV06(_tx)
|
|
479
|
-
}
|
|
480
|
-
return encodeDeployCallDataV07(_tx)
|
|
481
|
-
},
|
|
482
|
-
async encodeCallData(_tx) {
|
|
483
|
-
const tx = _tx as KernelEncodeCallDataArgs
|
|
484
|
-
if (
|
|
485
|
-
!Array.isArray(tx) &&
|
|
486
|
-
(!tx.callType || tx.callType === "call") &&
|
|
487
|
-
tx.to.toLowerCase() === accountAddress.toLowerCase()
|
|
488
|
-
) {
|
|
489
|
-
return tx.data
|
|
490
|
-
}
|
|
491
|
-
if (entryPointVersion === "v0.6") {
|
|
492
|
-
return encodeCallDataEpV06(tx)
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
if (plugins.hook) {
|
|
496
|
-
return encodeCallDataEpV07(tx, true)
|
|
497
|
-
}
|
|
498
|
-
return encodeCallDataEpV07(tx)
|
|
499
|
-
},
|
|
500
|
-
async getFactory() {
|
|
501
|
-
if (smartAccountDeployed) return undefined
|
|
502
|
-
|
|
503
|
-
smartAccountDeployed = await isSmartAccountDeployed(
|
|
504
|
-
client,
|
|
505
|
-
accountAddress
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
if (smartAccountDeployed) return undefined
|
|
509
|
-
|
|
510
|
-
const entryPointVersion =
|
|
511
|
-
getEntryPointVersion(entryPointAddress)
|
|
512
|
-
if (entryPointVersion === "v0.6") {
|
|
513
|
-
return factoryAddress
|
|
514
|
-
}
|
|
515
|
-
if (!useMetaFactory) {
|
|
516
|
-
return factoryAddress
|
|
517
|
-
}
|
|
518
|
-
return metaFactoryAddress
|
|
519
|
-
},
|
|
453
|
+
nonceKeyManager: createNonceManager({source: {get: () => 0, set: () => {}}}),
|
|
454
|
+
client,
|
|
455
|
+
entryPoint: _entryPoint,
|
|
456
|
+
getFactoryArgs,
|
|
457
|
+
async getAddress() {
|
|
458
|
+
if (accountAddress) return accountAddress
|
|
520
459
|
|
|
521
|
-
|
|
522
|
-
if (smartAccountDeployed) return undefined
|
|
460
|
+
const { factory, factoryData } = await getFactoryArgs()
|
|
523
461
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
462
|
+
// Get the sender address based on the init code
|
|
463
|
+
accountAddress = await getSenderAddress(client, {
|
|
464
|
+
factory,
|
|
465
|
+
factoryData,
|
|
466
|
+
entryPointAddress: entryPoint.address
|
|
467
|
+
})
|
|
528
468
|
|
|
529
|
-
|
|
469
|
+
return accountAddress
|
|
470
|
+
},
|
|
471
|
+
// Encode the deploy call data
|
|
472
|
+
async encodeDeployCallData(_tx) {
|
|
473
|
+
if (entryPoint.version === "0.6") {
|
|
474
|
+
return encodeDeployCallDataV06(_tx)
|
|
475
|
+
}
|
|
476
|
+
return encodeDeployCallDataV07(_tx)
|
|
477
|
+
},
|
|
478
|
+
async encodeCalls(calls, callType) {
|
|
479
|
+
if (
|
|
480
|
+
calls.length === 1 &&
|
|
481
|
+
(!callType || callType === "call") &&
|
|
482
|
+
calls[0].to.toLowerCase() === accountAddress.toLowerCase()
|
|
483
|
+
) {
|
|
484
|
+
return calls[0].data ?? "0x"
|
|
485
|
+
}
|
|
486
|
+
if (entryPoint.version === "0.6") {
|
|
487
|
+
return encodeCallDataEpV06(calls, callType)
|
|
488
|
+
}
|
|
530
489
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
return concatHex([
|
|
567
|
-
kernelPluginManager.getIdentifier(),
|
|
568
|
-
signature
|
|
569
|
-
])
|
|
570
|
-
},
|
|
571
|
-
async signTransaction(_, __) {
|
|
572
|
-
throw new SignTransactionNotSupportedBySmartAccount()
|
|
573
|
-
},
|
|
574
|
-
async signTypedData(typedData) {
|
|
575
|
-
const types = {
|
|
576
|
-
EIP712Domain: getTypesForEIP712Domain({
|
|
577
|
-
domain: typedData.domain
|
|
578
|
-
}),
|
|
579
|
-
...typedData.types
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
// Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc
|
|
583
|
-
// as we can't statically check this with TypeScript.
|
|
584
|
-
validateTypedData({
|
|
585
|
-
domain: typedData.domain,
|
|
586
|
-
message: typedData.message,
|
|
587
|
-
primaryType: typedData.primaryType,
|
|
588
|
-
types: types
|
|
589
|
-
} as TypedDataDefinition)
|
|
590
|
-
|
|
591
|
-
const typedHash = hashTypedData(typedData)
|
|
592
|
-
|
|
593
|
-
const {
|
|
594
|
-
name,
|
|
595
|
-
chainId: metadataChainId,
|
|
490
|
+
if (plugins.hook) {
|
|
491
|
+
return encodeCallDataEpV07(calls, callType, true)
|
|
492
|
+
}
|
|
493
|
+
return encodeCallDataEpV07(calls, callType)
|
|
494
|
+
},
|
|
495
|
+
async sign({ hash }) {
|
|
496
|
+
return this.signMessage({ message: hash })
|
|
497
|
+
},
|
|
498
|
+
async signMessage({ message }) {
|
|
499
|
+
const messageHash = hashMessage(message)
|
|
500
|
+
const {
|
|
501
|
+
name,
|
|
502
|
+
chainId: metadataChainId,
|
|
503
|
+
version
|
|
504
|
+
} = await accountMetadata(
|
|
505
|
+
client,
|
|
506
|
+
accountAddress,
|
|
507
|
+
kernelVersion,
|
|
508
|
+
chainId
|
|
509
|
+
)
|
|
510
|
+
const wrappedMessageHash = await eip712WrapHash(messageHash, {
|
|
511
|
+
name,
|
|
512
|
+
chainId: Number(metadataChainId),
|
|
513
|
+
version,
|
|
514
|
+
verifyingContract: accountAddress
|
|
515
|
+
})
|
|
516
|
+
const signature = await kernelPluginManager.signMessage({
|
|
517
|
+
message: { raw: wrappedMessageHash }
|
|
518
|
+
})
|
|
519
|
+
|
|
520
|
+
if (
|
|
521
|
+
!hasKernelFeature(
|
|
522
|
+
KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
|
|
596
523
|
version
|
|
597
|
-
} = await accountMetadata(
|
|
598
|
-
client,
|
|
599
|
-
accountAddress,
|
|
600
|
-
kernelVersion,
|
|
601
|
-
chainId
|
|
602
524
|
)
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
version,
|
|
607
|
-
verifyingContract: accountAddress
|
|
608
|
-
})
|
|
609
|
-
const signature = await kernelPluginManager.signMessage({
|
|
610
|
-
message: { raw: wrappedMessageHash }
|
|
611
|
-
})
|
|
612
|
-
if (
|
|
613
|
-
!hasKernelFeature(
|
|
614
|
-
KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
|
|
615
|
-
version
|
|
616
|
-
)
|
|
617
|
-
) {
|
|
618
|
-
return signature
|
|
619
|
-
}
|
|
620
|
-
return concatHex([
|
|
621
|
-
kernelPluginManager.getIdentifier(),
|
|
622
|
-
signature
|
|
623
|
-
])
|
|
624
|
-
},
|
|
625
|
-
// Get the nonce of the smart account
|
|
626
|
-
async getNonce(customNonceKey?: bigint) {
|
|
627
|
-
const key = await kernelPluginManager.getNonceKey(
|
|
628
|
-
accountAddress,
|
|
629
|
-
customNonceKey
|
|
630
|
-
)
|
|
631
|
-
return getAccountNonce(client, {
|
|
632
|
-
sender: accountAddress,
|
|
633
|
-
entryPoint: entryPointAddress,
|
|
634
|
-
key
|
|
635
|
-
})
|
|
636
|
-
},
|
|
637
|
-
|
|
638
|
-
// Sign a user operation
|
|
639
|
-
async signUserOperation(userOperation) {
|
|
640
|
-
return kernelPluginManager.signUserOperation(userOperation)
|
|
641
|
-
},
|
|
642
|
-
|
|
643
|
-
// Get simple dummy signature
|
|
644
|
-
async getDummySignature(userOperation) {
|
|
645
|
-
return kernelPluginManager.getDummySignature(userOperation)
|
|
646
|
-
},
|
|
525
|
+
) {
|
|
526
|
+
return signature
|
|
527
|
+
}
|
|
647
528
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
529
|
+
return concatHex([kernelPluginManager.getIdentifier(), signature])
|
|
530
|
+
},
|
|
531
|
+
async signTypedData(typedData) {
|
|
532
|
+
const {
|
|
533
|
+
message,
|
|
534
|
+
primaryType,
|
|
535
|
+
types: _types,
|
|
536
|
+
domain
|
|
537
|
+
} = typedData as TypedDataDefinition
|
|
538
|
+
const types = {
|
|
539
|
+
EIP712Domain: getTypesForEIP712Domain({
|
|
540
|
+
domain: domain
|
|
541
|
+
}),
|
|
542
|
+
..._types
|
|
543
|
+
}
|
|
651
544
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
545
|
+
// Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc
|
|
546
|
+
// as we can't statically check this with TypeScript.
|
|
547
|
+
validateTypedData({
|
|
548
|
+
domain: domain,
|
|
549
|
+
message: message,
|
|
550
|
+
primaryType: primaryType,
|
|
551
|
+
types: types
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
const typedHash = hashTypedData(typedData)
|
|
555
|
+
|
|
556
|
+
const {
|
|
557
|
+
name,
|
|
558
|
+
chainId: metadataChainId,
|
|
559
|
+
version
|
|
560
|
+
} = await accountMetadata(
|
|
561
|
+
client,
|
|
562
|
+
accountAddress,
|
|
563
|
+
kernelVersion,
|
|
564
|
+
chainId
|
|
565
|
+
)
|
|
566
|
+
const wrappedMessageHash = await eip712WrapHash(typedHash, {
|
|
567
|
+
name,
|
|
568
|
+
chainId: Number(metadataChainId),
|
|
569
|
+
version,
|
|
570
|
+
verifyingContract: accountAddress
|
|
571
|
+
})
|
|
572
|
+
const signature = await kernelPluginManager.signMessage({
|
|
573
|
+
message: { raw: wrappedMessageHash }
|
|
574
|
+
})
|
|
575
|
+
if (
|
|
576
|
+
!hasKernelFeature(
|
|
577
|
+
KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
|
|
578
|
+
version
|
|
655
579
|
)
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
return generateInitCode()
|
|
580
|
+
) {
|
|
581
|
+
return signature
|
|
659
582
|
}
|
|
660
|
-
|
|
661
|
-
|
|
583
|
+
return concatHex([kernelPluginManager.getIdentifier(), signature])
|
|
584
|
+
},
|
|
585
|
+
// Get the nonce of the smart account
|
|
586
|
+
async getNonce(_args) {
|
|
587
|
+
const key = await kernelPluginManager.getNonceKey(
|
|
588
|
+
accountAddress,
|
|
589
|
+
_args?.key
|
|
590
|
+
)
|
|
591
|
+
return getAccountNonce(client, {
|
|
592
|
+
address: accountAddress,
|
|
593
|
+
entryPointAddress: entryPoint.address,
|
|
594
|
+
key
|
|
595
|
+
})
|
|
596
|
+
},
|
|
597
|
+
async getStubSignature(userOperation) {
|
|
598
|
+
if (!userOperation) {
|
|
599
|
+
throw new Error("No user operation provided")
|
|
600
|
+
}
|
|
601
|
+
return kernelPluginManager.getStubSignature(
|
|
602
|
+
userOperation as UserOperation
|
|
603
|
+
)
|
|
604
|
+
},
|
|
605
|
+
|
|
606
|
+
// Sign a user operation
|
|
607
|
+
async signUserOperation(parameters) {
|
|
608
|
+
const { chainId = await getMemoizedChainId(), ...userOperation } =
|
|
609
|
+
parameters
|
|
610
|
+
return kernelPluginManager.signUserOperation({
|
|
611
|
+
...userOperation,
|
|
612
|
+
sender: userOperation.sender ?? (await this.getAddress()),
|
|
613
|
+
chainId
|
|
614
|
+
})
|
|
615
|
+
}
|
|
616
|
+
}) as Promise<CreateKernelAccountReturnType<entryPointVersion>>
|
|
662
617
|
}
|