@zerodev/sdk 5.3.26 → 5.4.0-beta.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/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/createKernelAccount.js +173 -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 +83 -94
- package/_cjs/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
- package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js +106 -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 +15 -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 +10 -0
- package/_cjs/actions/public/index.js.map +1 -0
- package/_cjs/actions/public/isSmartAccountDeployed.js +14 -0
- package/_cjs/actions/public/isSmartAccountDeployed.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 +26 -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 +1 -0
- package/_cjs/index.js.map +1 -1
- package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
- package/_cjs/types/index.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 +183 -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 +93 -98
- package/_esm/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
- package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js +107 -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 +7 -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 +4 -0
- package/_esm/actions/public/index.js.map +1 -0
- package/_esm/actions/public/isSmartAccountDeployed.js +10 -0
- package/_esm/actions/public/isSmartAccountDeployed.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 +21 -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 +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
- package/_esm/types/index.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 +10 -8
- 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 +7 -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 +4 -0
- package/_types/actions/public/index.d.ts.map +1 -0
- package/_types/actions/public/isSmartAccountDeployed.d.ts +3 -0
- package/_types/actions/public/isSmartAccountDeployed.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 +10 -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 +2 -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 +2 -1
- 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 +315 -359
- 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 +151 -176
- package/accounts/kernel/v2/createKernelAccountV0_2.ts +141 -196
- 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 +16 -5
- 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 +10 -0
- package/actions/public/isSmartAccountDeployed.ts +18 -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 +25 -0
- package/gasTokenAddresses.ts +3 -2
- package/index.ts +6 -2
- package/package.json +11 -34
- package/providers/KernelEIP1193Provider.ts +4 -7
- package/types/index.ts +4 -1
- 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
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/sendTransaction.ts
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
Chain,
|
|
5
|
+
Client,
|
|
6
|
+
Hash,
|
|
7
|
+
SendTransactionParameters,
|
|
8
|
+
Transport
|
|
9
|
+
} from "viem"
|
|
10
|
+
import {
|
|
11
|
+
type SendUserOperationParameters,
|
|
12
|
+
type SmartAccount,
|
|
13
|
+
sendUserOperation,
|
|
14
|
+
waitForUserOperationReceipt
|
|
15
|
+
} from "viem/account-abstraction"
|
|
16
|
+
import { getAction, parseAccount } from "viem/utils"
|
|
17
|
+
import { AccountNotFoundError } from "../../errors"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates, signs, and sends a new transaction to the network.
|
|
21
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
22
|
+
*
|
|
23
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html
|
|
24
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
|
|
25
|
+
* - JSON-RPC Methods:
|
|
26
|
+
* - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
|
|
27
|
+
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
|
|
28
|
+
*
|
|
29
|
+
* @param client - Client to use
|
|
30
|
+
* @param parameters - {@link SendTransactionParameters}
|
|
31
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* import { createWalletClient, custom } from 'viem'
|
|
35
|
+
* import { mainnet } from 'viem/chains'
|
|
36
|
+
* import { sendTransaction } from 'viem/wallet'
|
|
37
|
+
*
|
|
38
|
+
* const client = createWalletClient({
|
|
39
|
+
* chain: mainnet,
|
|
40
|
+
* transport: custom(window.ethereum),
|
|
41
|
+
* })
|
|
42
|
+
* const hash = await sendTransaction(client, {
|
|
43
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
44
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
45
|
+
* value: 1000000000000000000n,
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Account Hoisting
|
|
50
|
+
* import { createWalletClient, http } from 'viem'
|
|
51
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
52
|
+
* import { mainnet } from 'viem/chains'
|
|
53
|
+
* import { sendTransaction } from 'viem/wallet'
|
|
54
|
+
*
|
|
55
|
+
* const client = createWalletClient({
|
|
56
|
+
* account: privateKeyToAccount('0x…'),
|
|
57
|
+
* chain: mainnet,
|
|
58
|
+
* transport: http(),
|
|
59
|
+
* })
|
|
60
|
+
* const hash = await sendTransaction(client, {
|
|
61
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
62
|
+
* value: 1000000000000000000n,
|
|
63
|
+
* })
|
|
64
|
+
*/
|
|
65
|
+
export async function sendTransaction<
|
|
66
|
+
account extends SmartAccount | undefined,
|
|
67
|
+
chain extends Chain | undefined,
|
|
68
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
69
|
+
chainOverride extends Chain | undefined = Chain | undefined,
|
|
70
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
71
|
+
>(
|
|
72
|
+
client: Client<Transport, chain, account>,
|
|
73
|
+
args:
|
|
74
|
+
| SendTransactionParameters<chain, account, chainOverride>
|
|
75
|
+
| SendUserOperationParameters<account, accountOverride, calls>
|
|
76
|
+
): Promise<Hash> {
|
|
77
|
+
let userOpHash: Hash
|
|
78
|
+
|
|
79
|
+
if ("to" in args) {
|
|
80
|
+
const {
|
|
81
|
+
account: account_ = client.account,
|
|
82
|
+
data,
|
|
83
|
+
maxFeePerGas,
|
|
84
|
+
maxPriorityFeePerGas,
|
|
85
|
+
to,
|
|
86
|
+
value,
|
|
87
|
+
nonce
|
|
88
|
+
} = args
|
|
89
|
+
|
|
90
|
+
if (!account_) {
|
|
91
|
+
throw new AccountNotFoundError({
|
|
92
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const account = parseAccount(account_) as SmartAccount
|
|
97
|
+
|
|
98
|
+
if (!to) throw new Error("Missing to address")
|
|
99
|
+
|
|
100
|
+
userOpHash = await getAction(
|
|
101
|
+
client,
|
|
102
|
+
sendUserOperation,
|
|
103
|
+
"sendUserOperation"
|
|
104
|
+
)({
|
|
105
|
+
calls: [
|
|
106
|
+
{
|
|
107
|
+
to,
|
|
108
|
+
value: value || BigInt(0),
|
|
109
|
+
data: data || "0x"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
account,
|
|
113
|
+
maxFeePerGas,
|
|
114
|
+
maxPriorityFeePerGas,
|
|
115
|
+
nonce: nonce ? BigInt(nonce) : undefined
|
|
116
|
+
})
|
|
117
|
+
} else {
|
|
118
|
+
userOpHash = await getAction(
|
|
119
|
+
client,
|
|
120
|
+
sendUserOperation,
|
|
121
|
+
"sendUserOperation"
|
|
122
|
+
)({ ...args } as SendUserOperationParameters<account, accountOverride>)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const userOperationReceipt = await getAction(
|
|
126
|
+
client,
|
|
127
|
+
waitForUserOperationReceipt,
|
|
128
|
+
"waitForUserOperationReceipt"
|
|
129
|
+
)({
|
|
130
|
+
hash: userOpHash
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return userOperationReceipt?.receipt.transactionHash
|
|
134
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/signMessage.ts
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
Chain,
|
|
5
|
+
Client,
|
|
6
|
+
SignMessageParameters,
|
|
7
|
+
SignMessageReturnType,
|
|
8
|
+
Transport
|
|
9
|
+
} from "viem"
|
|
10
|
+
import type { SmartAccount } from "viem/account-abstraction"
|
|
11
|
+
import { parseAccount } from "viem/utils"
|
|
12
|
+
import { AccountNotFoundError } from "../../errors"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
16
|
+
*
|
|
17
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signMessage.html
|
|
18
|
+
* - JSON-RPC Methods:
|
|
19
|
+
* - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data.html#personal-sign)
|
|
20
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
21
|
+
*
|
|
22
|
+
* With the calculated signature, you can:
|
|
23
|
+
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,
|
|
24
|
+
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.
|
|
25
|
+
*
|
|
26
|
+
* @param client - Client to use
|
|
27
|
+
* @param parameters - {@link SignMessageParameters}
|
|
28
|
+
* @returns The signed message. {@link SignMessageReturnType}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* import { createWalletClient, custom } from 'viem'
|
|
32
|
+
* import { mainnet } from 'viem/chains'
|
|
33
|
+
* import { signMessage } from 'viem/wallet'
|
|
34
|
+
*
|
|
35
|
+
* const client = createWalletClient({
|
|
36
|
+
* chain: mainnet,
|
|
37
|
+
* transport: custom(window.ethereum),
|
|
38
|
+
* })
|
|
39
|
+
* const signature = await signMessage(client, {
|
|
40
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
41
|
+
* message: 'hello world',
|
|
42
|
+
* })
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Account Hoisting
|
|
46
|
+
* import { createWalletClient, custom } from 'viem'
|
|
47
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
48
|
+
* import { mainnet } from 'viem/chains'
|
|
49
|
+
* import { signMessage } from 'viem/wallet'
|
|
50
|
+
*
|
|
51
|
+
* const client = createWalletClient({
|
|
52
|
+
* account: privateKeyToAccount('0x…'),
|
|
53
|
+
* chain: mainnet,
|
|
54
|
+
* transport: custom(window.ethereum),
|
|
55
|
+
* })
|
|
56
|
+
* const signature = await signMessage(client, {
|
|
57
|
+
* message: 'hello world',
|
|
58
|
+
* })
|
|
59
|
+
*/
|
|
60
|
+
export async function signMessage<TAccount extends SmartAccount | undefined>(
|
|
61
|
+
client: Client<Transport, Chain | undefined, TAccount>,
|
|
62
|
+
{
|
|
63
|
+
account: account_ = client.account,
|
|
64
|
+
message
|
|
65
|
+
}: SignMessageParameters<TAccount>
|
|
66
|
+
): Promise<SignMessageReturnType> {
|
|
67
|
+
if (!account_)
|
|
68
|
+
throw new AccountNotFoundError({
|
|
69
|
+
docsPath: "/docs/actions/wallet/signMessage"
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const account = parseAccount(account_) as SmartAccount
|
|
73
|
+
|
|
74
|
+
return account.signMessage({ message })
|
|
75
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/signTypedData.ts
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Chain,
|
|
5
|
+
type Client,
|
|
6
|
+
type SignTypedDataParameters,
|
|
7
|
+
type SignTypedDataReturnType,
|
|
8
|
+
type Transport,
|
|
9
|
+
type TypedData,
|
|
10
|
+
type TypedDataDefinition,
|
|
11
|
+
type TypedDataDomain,
|
|
12
|
+
getTypesForEIP712Domain,
|
|
13
|
+
validateTypedData
|
|
14
|
+
} from "viem"
|
|
15
|
+
import type { SmartAccount } from "viem/account-abstraction"
|
|
16
|
+
import { parseAccount } from "viem/utils"
|
|
17
|
+
import { AccountNotFoundError } from "../../errors"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 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)))`
|
|
21
|
+
*
|
|
22
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html
|
|
23
|
+
* - JSON-RPC Methods:
|
|
24
|
+
* - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data.html#signtypeddata-v4)
|
|
25
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
26
|
+
*
|
|
27
|
+
* @param client - Client to use
|
|
28
|
+
* @param parameters - {@link SignTypedDataParameters}
|
|
29
|
+
* @returns The signed data. {@link SignTypedDataReturnType}
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* import { createWalletClient, custom } from 'viem'
|
|
33
|
+
* import { mainnet } from 'viem/chains'
|
|
34
|
+
* import { signTypedData } from 'viem/wallet'
|
|
35
|
+
*
|
|
36
|
+
* const client = createWalletClient({
|
|
37
|
+
* chain: mainnet,
|
|
38
|
+
* transport: custom(window.ethereum),
|
|
39
|
+
* })
|
|
40
|
+
* const signature = await signTypedData(client, {
|
|
41
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
42
|
+
* domain: {
|
|
43
|
+
* name: 'Ether Mail',
|
|
44
|
+
* version: '1',
|
|
45
|
+
* chainId: 1,
|
|
46
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
47
|
+
* },
|
|
48
|
+
* types: {
|
|
49
|
+
* Person: [
|
|
50
|
+
* { name: 'name', type: 'string' },
|
|
51
|
+
* { name: 'wallet', type: 'address' },
|
|
52
|
+
* ],
|
|
53
|
+
* Mail: [
|
|
54
|
+
* { name: 'from', type: 'Person' },
|
|
55
|
+
* { name: 'to', type: 'Person' },
|
|
56
|
+
* { name: 'contents', type: 'string' },
|
|
57
|
+
* ],
|
|
58
|
+
* },
|
|
59
|
+
* primaryType: 'Mail',
|
|
60
|
+
* message: {
|
|
61
|
+
* from: {
|
|
62
|
+
* name: 'Cow',
|
|
63
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
64
|
+
* },
|
|
65
|
+
* to: {
|
|
66
|
+
* name: 'Bob',
|
|
67
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
68
|
+
* },
|
|
69
|
+
* contents: 'Hello, Bob!',
|
|
70
|
+
* },
|
|
71
|
+
* })
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Account Hoisting
|
|
75
|
+
* import { createWalletClient, http } from 'viem'
|
|
76
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
77
|
+
* import { mainnet } from 'viem/chains'
|
|
78
|
+
* import { signTypedData } from 'viem/wallet'
|
|
79
|
+
*
|
|
80
|
+
* const client = createWalletClient({
|
|
81
|
+
* account: privateKeyToAccount('0x…'),
|
|
82
|
+
* chain: mainnet,
|
|
83
|
+
* transport: http(),
|
|
84
|
+
* })
|
|
85
|
+
* const signature = await signTypedData(client, {
|
|
86
|
+
* domain: {
|
|
87
|
+
* name: 'Ether Mail',
|
|
88
|
+
* version: '1',
|
|
89
|
+
* chainId: 1,
|
|
90
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
91
|
+
* },
|
|
92
|
+
* types: {
|
|
93
|
+
* Person: [
|
|
94
|
+
* { name: 'name', type: 'string' },
|
|
95
|
+
* { name: 'wallet', type: 'address' },
|
|
96
|
+
* ],
|
|
97
|
+
* Mail: [
|
|
98
|
+
* { name: 'from', type: 'Person' },
|
|
99
|
+
* { name: 'to', type: 'Person' },
|
|
100
|
+
* { name: 'contents', type: 'string' },
|
|
101
|
+
* ],
|
|
102
|
+
* },
|
|
103
|
+
* primaryType: 'Mail',
|
|
104
|
+
* message: {
|
|
105
|
+
* from: {
|
|
106
|
+
* name: 'Cow',
|
|
107
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
108
|
+
* },
|
|
109
|
+
* to: {
|
|
110
|
+
* name: 'Bob',
|
|
111
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
112
|
+
* },
|
|
113
|
+
* contents: 'Hello, Bob!',
|
|
114
|
+
* },
|
|
115
|
+
* })
|
|
116
|
+
*/
|
|
117
|
+
export async function signTypedData<
|
|
118
|
+
const TTypedData extends TypedData | { [key: string]: unknown },
|
|
119
|
+
TPrimaryType extends string,
|
|
120
|
+
TAccount extends SmartAccount | undefined = SmartAccount | undefined
|
|
121
|
+
>(
|
|
122
|
+
client: Client<Transport, Chain | undefined, TAccount>,
|
|
123
|
+
{
|
|
124
|
+
account: account_ = client.account,
|
|
125
|
+
domain,
|
|
126
|
+
message,
|
|
127
|
+
primaryType,
|
|
128
|
+
types: types_
|
|
129
|
+
}: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>
|
|
130
|
+
): Promise<SignTypedDataReturnType> {
|
|
131
|
+
if (!account_) {
|
|
132
|
+
throw new AccountNotFoundError({
|
|
133
|
+
docsPath: "/docs/actions/wallet/signMessage"
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const account = parseAccount(account_) as SmartAccount
|
|
138
|
+
|
|
139
|
+
const types = {
|
|
140
|
+
EIP712Domain: getTypesForEIP712Domain({ domain } as {
|
|
141
|
+
domain: TypedDataDomain
|
|
142
|
+
}),
|
|
143
|
+
...(types_ as TTypedData)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
validateTypedData({
|
|
147
|
+
domain,
|
|
148
|
+
message,
|
|
149
|
+
primaryType,
|
|
150
|
+
types
|
|
151
|
+
} as TypedDataDefinition)
|
|
152
|
+
|
|
153
|
+
return account.signTypedData({
|
|
154
|
+
domain,
|
|
155
|
+
primaryType,
|
|
156
|
+
types,
|
|
157
|
+
message
|
|
158
|
+
} as TypedDataDefinition)
|
|
159
|
+
}
|
|
@@ -1,80 +1,48 @@
|
|
|
1
|
-
import type { SmartAccount } from "permissionless/accounts"
|
|
2
|
-
import { prepareUserOperationRequest } from "permissionless/actions/smartAccount"
|
|
3
|
-
import type {
|
|
4
|
-
PrepareUserOperationRequestParameters,
|
|
5
|
-
PrepareUserOperationRequestReturnType
|
|
6
|
-
} from "permissionless/actions/smartAccount"
|
|
7
|
-
import type {
|
|
8
|
-
EntryPoint,
|
|
9
|
-
GetEntryPointVersion,
|
|
10
|
-
Prettify,
|
|
11
|
-
UserOperation
|
|
12
|
-
} from "permissionless/types"
|
|
13
|
-
import {
|
|
14
|
-
AccountOrClientNotFoundError,
|
|
15
|
-
parseAccount
|
|
16
|
-
} from "permissionless/utils"
|
|
17
1
|
import type { Chain, Client, Transport } from "viem"
|
|
18
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type PrepareUserOperationParameters,
|
|
4
|
+
type PrepareUserOperationReturnType,
|
|
5
|
+
type SmartAccount,
|
|
6
|
+
type UserOperation,
|
|
7
|
+
prepareUserOperation
|
|
8
|
+
} from "viem/account-abstraction"
|
|
9
|
+
import { getAction, parseAccount } from "viem/utils"
|
|
10
|
+
import { AccountNotFoundError } from "../../errors"
|
|
19
11
|
|
|
20
12
|
export type SignUserOperationParameters<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
| SmartAccount<entryPoint, string, TTransport, TChain>
|
|
26
|
-
| undefined =
|
|
27
|
-
| SmartAccount<entryPoint, string, TTransport, TChain>
|
|
28
|
-
| undefined
|
|
29
|
-
> = PrepareUserOperationRequestParameters<
|
|
30
|
-
entryPoint,
|
|
31
|
-
TTransport,
|
|
32
|
-
TChain,
|
|
33
|
-
TAccount
|
|
34
|
-
>
|
|
13
|
+
account extends SmartAccount | undefined = SmartAccount | undefined,
|
|
14
|
+
accountOverride extends SmartAccount | undefined = SmartAccount | undefined,
|
|
15
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
16
|
+
> = PrepareUserOperationParameters<account, accountOverride, calls>
|
|
35
17
|
|
|
36
|
-
export type SignUserOperationReturnType
|
|
37
|
-
PrepareUserOperationRequestReturnType<entryPoint>
|
|
18
|
+
export type SignUserOperationReturnType = PrepareUserOperationReturnType
|
|
38
19
|
|
|
39
20
|
export async function signUserOperation<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
| SmartAccount<entryPoint, string, TTransport, TChain>
|
|
45
|
-
| undefined =
|
|
46
|
-
| SmartAccount<entryPoint, string, TTransport, TChain>
|
|
47
|
-
| undefined
|
|
21
|
+
account extends SmartAccount | undefined = SmartAccount | undefined,
|
|
22
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
23
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
24
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
48
25
|
>(
|
|
49
|
-
client: Client<
|
|
50
|
-
args:
|
|
51
|
-
|
|
52
|
-
>
|
|
53
|
-
): Promise<SignUserOperationReturnType<entryPoint>> {
|
|
26
|
+
client: Client<Transport, chain, account>,
|
|
27
|
+
args: SignUserOperationParameters<account, accountOverride, calls>
|
|
28
|
+
): Promise<SignUserOperationReturnType> {
|
|
54
29
|
const { account: account_ = client.account } = args
|
|
55
|
-
if (!account_)
|
|
30
|
+
if (!account_)
|
|
31
|
+
throw new AccountNotFoundError({
|
|
32
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
33
|
+
})
|
|
56
34
|
|
|
57
|
-
const account = parseAccount(account_) as SmartAccount
|
|
58
|
-
entryPoint,
|
|
59
|
-
string,
|
|
60
|
-
TTransport,
|
|
61
|
-
TChain
|
|
62
|
-
>
|
|
35
|
+
const account = parseAccount(account_) as SmartAccount
|
|
63
36
|
|
|
64
37
|
const userOperation = await getAction(
|
|
65
38
|
client,
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
)({ ...args, account } as
|
|
69
|
-
entryPoint,
|
|
70
|
-
TTransport,
|
|
71
|
-
TChain,
|
|
72
|
-
TAccount
|
|
73
|
-
>)
|
|
39
|
+
prepareUserOperation,
|
|
40
|
+
"prepareUserOperation"
|
|
41
|
+
)({ ...args, account } as PrepareUserOperationParameters)
|
|
74
42
|
|
|
75
43
|
userOperation.signature = await account.signUserOperation(
|
|
76
|
-
userOperation as UserOperation
|
|
44
|
+
userOperation as UserOperation
|
|
77
45
|
)
|
|
78
46
|
|
|
79
|
-
return userOperation
|
|
47
|
+
return userOperation
|
|
80
48
|
}
|
|
@@ -1,69 +1,49 @@
|
|
|
1
|
+
import type { Chain, Client, Hash, Hex, Transport } from "viem"
|
|
1
2
|
import {
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type SendUserOperationParameters,
|
|
4
|
+
type SmartAccount,
|
|
5
|
+
sendUserOperation
|
|
6
|
+
} from "viem/account-abstraction"
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
+
concatHex,
|
|
9
|
+
encodeFunctionData,
|
|
10
|
+
getAction,
|
|
11
|
+
pad,
|
|
8
12
|
parseAccount
|
|
9
|
-
} from "
|
|
10
|
-
import type { Chain, Client, Hash, Hex, Transport } from "viem"
|
|
11
|
-
import { concatHex, encodeFunctionData, getAction, pad } from "viem/utils"
|
|
12
|
-
import type { KernelSmartAccount } from "../../accounts/index.js"
|
|
13
|
+
} from "viem/utils"
|
|
13
14
|
import { KernelV3AccountAbi } from "../../accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js"
|
|
14
15
|
import { VALIDATOR_TYPE } from "../../constants.js"
|
|
16
|
+
import { AccountNotFoundError } from "../../errors/index.js"
|
|
15
17
|
import type {
|
|
16
18
|
KernelValidator,
|
|
17
19
|
KernelValidatorHook
|
|
18
20
|
} from "../../types/kernel.js"
|
|
19
21
|
|
|
20
22
|
export type UninstallPluginParameters<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
| undefined
|
|
29
|
-
> = Prettify<
|
|
30
|
-
Partial<
|
|
31
|
-
SendTransactionsWithPaymasterParameters<
|
|
32
|
-
entryPoint,
|
|
33
|
-
TTransport,
|
|
34
|
-
TChain,
|
|
35
|
-
TAccount
|
|
36
|
-
>
|
|
37
|
-
> & {
|
|
38
|
-
plugin: KernelValidator<entryPoint, string>
|
|
39
|
-
hook?: KernelValidatorHook
|
|
40
|
-
}
|
|
41
|
-
>
|
|
23
|
+
account extends SmartAccount | undefined = SmartAccount | undefined,
|
|
24
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
25
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
26
|
+
> = Partial<SendUserOperationParameters<account, accountOverride, calls>> & {
|
|
27
|
+
plugin: KernelValidator<string>
|
|
28
|
+
hook?: KernelValidatorHook
|
|
29
|
+
}
|
|
42
30
|
|
|
43
31
|
export async function uninstallPlugin<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
49
|
-
| undefined =
|
|
50
|
-
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
51
|
-
| undefined
|
|
32
|
+
account extends SmartAccount | undefined,
|
|
33
|
+
chain extends Chain | undefined,
|
|
34
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
35
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
52
36
|
>(
|
|
53
|
-
client: Client<
|
|
54
|
-
args:
|
|
55
|
-
UninstallPluginParameters<entryPoint, TTransport, TChain, TAccount>
|
|
56
|
-
>
|
|
37
|
+
client: Client<Transport, chain, account>,
|
|
38
|
+
args: UninstallPluginParameters<account, accountOverride, calls>
|
|
57
39
|
): Promise<Hash> {
|
|
58
|
-
const {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} = args
|
|
64
|
-
if (!account_) throw new AccountOrClientNotFoundError()
|
|
40
|
+
const { account: account_ = client.account, plugin, hook } = args
|
|
41
|
+
if (!account_)
|
|
42
|
+
throw new AccountNotFoundError({
|
|
43
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
44
|
+
})
|
|
65
45
|
|
|
66
|
-
const account = parseAccount(account_) as
|
|
46
|
+
const account = parseAccount(account_) as SmartAccount
|
|
67
47
|
|
|
68
48
|
let validatorId: Hex
|
|
69
49
|
if (
|
|
@@ -87,11 +67,11 @@ export async function uninstallPlugin<
|
|
|
87
67
|
const hookData = (await hook?.getEnableData(account.address)) ?? "0x"
|
|
88
68
|
return await getAction(
|
|
89
69
|
client,
|
|
90
|
-
|
|
91
|
-
"
|
|
70
|
+
sendUserOperation,
|
|
71
|
+
"sendUserOperation"
|
|
92
72
|
)({
|
|
93
73
|
...args,
|
|
94
|
-
|
|
74
|
+
calls: [
|
|
95
75
|
{
|
|
96
76
|
to: account.address,
|
|
97
77
|
data: encodeFunctionData({
|
|
@@ -102,7 +82,6 @@ export async function uninstallPlugin<
|
|
|
102
82
|
value: 0n
|
|
103
83
|
}
|
|
104
84
|
],
|
|
105
|
-
account
|
|
106
|
-
|
|
107
|
-
})
|
|
85
|
+
account
|
|
86
|
+
} as SendUserOperationParameters)
|
|
108
87
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/actions/smartAccount/writeContract.ts
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Abi,
|
|
5
|
+
type Chain,
|
|
6
|
+
type Client,
|
|
7
|
+
type ContractFunctionArgs,
|
|
8
|
+
type ContractFunctionName,
|
|
9
|
+
type EncodeFunctionDataParameters,
|
|
10
|
+
type Hash,
|
|
11
|
+
type SendTransactionParameters,
|
|
12
|
+
type Transport,
|
|
13
|
+
type WriteContractParameters,
|
|
14
|
+
encodeFunctionData
|
|
15
|
+
} from "viem"
|
|
16
|
+
import type { SmartAccount } from "viem/account-abstraction"
|
|
17
|
+
import { getAction } from "viem/utils"
|
|
18
|
+
import { sendTransaction } from "./sendTransaction.js"
|
|
19
|
+
|
|
20
|
+
export async function writeContract<
|
|
21
|
+
TChain extends Chain | undefined,
|
|
22
|
+
TAccount extends SmartAccount | undefined,
|
|
23
|
+
const TAbi extends Abi | readonly unknown[],
|
|
24
|
+
TFunctionName extends ContractFunctionName<
|
|
25
|
+
TAbi,
|
|
26
|
+
"nonpayable" | "payable"
|
|
27
|
+
> = ContractFunctionName<TAbi, "nonpayable" | "payable">,
|
|
28
|
+
TArgs extends ContractFunctionArgs<
|
|
29
|
+
TAbi,
|
|
30
|
+
"nonpayable" | "payable",
|
|
31
|
+
TFunctionName
|
|
32
|
+
> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>,
|
|
33
|
+
TChainOverride extends Chain | undefined = undefined
|
|
34
|
+
>(
|
|
35
|
+
client: Client<Transport, TChain, TAccount>,
|
|
36
|
+
{
|
|
37
|
+
abi,
|
|
38
|
+
address,
|
|
39
|
+
args,
|
|
40
|
+
dataSuffix,
|
|
41
|
+
functionName,
|
|
42
|
+
...request
|
|
43
|
+
}: WriteContractParameters<
|
|
44
|
+
TAbi,
|
|
45
|
+
TFunctionName,
|
|
46
|
+
TArgs,
|
|
47
|
+
TChain,
|
|
48
|
+
TAccount,
|
|
49
|
+
TChainOverride
|
|
50
|
+
>
|
|
51
|
+
): Promise<Hash> {
|
|
52
|
+
const data = encodeFunctionData<TAbi, TFunctionName>({
|
|
53
|
+
abi,
|
|
54
|
+
args,
|
|
55
|
+
functionName
|
|
56
|
+
} as EncodeFunctionDataParameters<TAbi, TFunctionName>)
|
|
57
|
+
|
|
58
|
+
const hash = await getAction(
|
|
59
|
+
client,
|
|
60
|
+
sendTransaction<TAccount, undefined, undefined>,
|
|
61
|
+
"sendTransaction"
|
|
62
|
+
)({
|
|
63
|
+
data: `${data}${dataSuffix ? dataSuffix.replace("0x", "") : ""}`,
|
|
64
|
+
to: address,
|
|
65
|
+
...request
|
|
66
|
+
} as unknown as SendTransactionParameters<
|
|
67
|
+
Chain | undefined,
|
|
68
|
+
TAccount,
|
|
69
|
+
undefined
|
|
70
|
+
>)
|
|
71
|
+
return hash
|
|
72
|
+
}
|